Search is not available for this dataset
name
stringlengths
2
88
description
stringlengths
31
8.62k
public_tests
dict
private_tests
dict
solution_type
stringclasses
2 values
programming_language
stringclasses
5 values
solution
stringlengths
1
983k
brcktsrm
Problem description. Vipul is a hardworking super-hero who maintains the bracket ratio of all the strings in the world. Recently he indulged himself in saving the string population so much that he lost his ability for checking brackets (luckily, not permanently ).Being his super-hero friend help him in his time of hard...
{ "input": [ "3\n((()))\n(())()\n()(()" ], "output": [ "YES\nYES\nNO" ] }
{ "input": [], "output": [] }
CORRECT
python2
for _ in range(input()): try: eval(raw_input()) print 'YES' except TypeError: print 'YES' except: print 'NO'
brcktsrm
Problem description. Vipul is a hardworking super-hero who maintains the bracket ratio of all the strings in the world. Recently he indulged himself in saving the string population so much that he lost his ability for checking brackets (luckily, not permanently ).Being his super-hero friend help him in his time of hard...
{ "input": [ "3\n((()))\n(())()\n()(()" ], "output": [ "YES\nYES\nNO" ] }
{ "input": [], "output": [] }
CORRECT
python2
for _ in range(input()): ins = raw_input().strip() stck = [] res = "YES" for x in ins: if x == "(": stck.append(x) else: if len(stck)>0: stck.pop() else: res = "NO" break if len(stck) > 0: res = "NO" ...
brcktsrm
Problem description. Vipul is a hardworking super-hero who maintains the bracket ratio of all the strings in the world. Recently he indulged himself in saving the string population so much that he lost his ability for checking brackets (luckily, not permanently ).Being his super-hero friend help him in his time of hard...
{ "input": [ "3\n((()))\n(())()\n()(()" ], "output": [ "YES\nYES\nNO" ] }
{ "input": [], "output": [] }
CORRECT
python2
for _ in range(input()): try: eval(raw_input()); print 'YES' except TypeError: print 'YES' except: print 'NO'
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
import math no_of_testcases = int(input()) for each in range(no_of_testcases): dist = int(input()) point_1 = map(int,raw_input().split()) point_2 = map(int,raw_input().split()) point_3 = map(int,raw_input().split()) point_12 =math.sqrt( math.pow((point_1[0] -point_2[0]),2) + math.pow((point_1[1]...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def distance(x1,y1,x2,y2): dist = ((x1-x2)**2 + (y1-y2)**2)**0.5 return dist t = input() for i in range(t): r = input() chef_x,chef_y = map(int,raw_input().split(' ')) head_server_x,head_server_y = map(int,raw_input().split(' ')) sous_chef_x,sous_chef_y = map(int,raw_input().split(' ')) ...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
#COMM3 test = input() while test > 0: test -= 1 dist = input()**2 a,b = map(int, raw_input().split()) c,d = map(int, raw_input().split()) e,f = map(int, raw_input().split()) dist1 = (a-c)**2 + (b-d)**2 dist2 = (a-e)**2 + (b-f)**2 dist3 = (c-e)**2 + (d-f)**2 if (dist1 <= dist and dis...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
from sys import stdin as ip for _ in xrange(int(ip.readline())): r=int(ip.readline())**2 a,b=map(int,ip.readline().split()) x,y=map(int,ip.readline().split()) p,q=map(int,ip.readline().split()) d1=pow(x-a,2)+pow(y-b,2) d2=pow(p-x,2)+pow(q-y,2) d3=pow(p-a,2)+pow(q-b,2) if d1<=r and d2<=r ...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
import math as m def leng(a,c,b,d): return m.sqrt(((a-c)**2)+((b-d)**2)) t=input() ans=[] for i in range(t): n=input() x1,y1=raw_input().split() x2,y2=raw_input().split() x3,y3=raw_input().split() d1=leng(int(x1),int(x2),int(y1),int(y2)) d2=leng(int(x1),int(x3),int(y1),int(y3)) d3=leng(i...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
t=input() def dist(a,b,c,d): return (((a-c)**2)+((b-d)**2))**0.5 for i in range(0,t): r=input() e=[] for j in range(0,3): e.append(map(int,raw_input().split(' '))) if dist(e[0][0],e[0][1],e[2][0],e[2][1])<=r: print "yes" elif dist(e[0][0],e[0][1],e[1][0],e[1][1])<=r and dist(e[1]...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
# -*- coding: utf-8 -*- """ Created on Wed Mar 16 12:29:47 2016 @author: matteoarno """ import sys data = sys.stdin.readlines() t = int(data.pop(0)) output = [] for i in range(t): r = int(data.pop(0)) chef = map(int,(data.pop(0).split(' '))) head = map(int,(data.pop(0).split(' '))) sous = map(int,(d...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
import math def cal_dist(x1,y1,x2,y2): dis = math.sqrt(((x1-x2)**2)+((y1-y2)**2)) return dis test = int(input()) while test: R = int(input()) cx1,cy1=map(int, raw_input().split()) cx2,cy2=map(int, raw_input().split()) cx3,cy3=map(int, raw_input().split()) d1 = cal_dist(cx1,cy1,cx2,cy2) d2 = cal_dist(cx1,cy1,c...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
import math def distance(x1, y1, x2, y2): return math.sqrt((x2-x1)**2 + (y2-y1)**2) import math n = int(raw_input()) rs = [] while n != 0: max_d = int(raw_input()) p1 = map(int,raw_input().split()) p2 = map(int,raw_input().split()) p3 = map(int,raw_input().split()) ds = [] ds.append(distanc...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
class Solution: def threeWayComm(self): t = int(raw_input()) while t > 0: r = int(raw_input()) if r <= 0 or r > 1000: break x1, y1 = map(int, raw_input().split()) x2, y2 = map(int, raw_input().split()) x3, y3 = map(int, raw_input().split()) if x1 > 10000 or y1 > 10000 or x2 > 10000 or y2 >...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
from math import hypot t = input() for _ in xrange(t): r = input() x1, y1 = map(int, raw_input().split()) x2, y2 = map(int, raw_input().split()) x3, y3 = map(int, raw_input().split()) ab = hypot(x1 - x2, y1 - y2) bc = hypot(x2 - x3, y2 - y3) ac = hypot(x3 - x1, y3 - y1) if (ab <= r and b...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
from math import sqrt def dist(x1,y1,x2,y2): a=(abs(x1-x2))**2 b=(abs(y1-y2))**2 return sqrt(a+b) for testcases in xrange(int(raw_input())): r=int(raw_input()) x=[] y=[] c=0 for i in xrange(3): a,b=map(int,raw_input().split()) x.append(a) y.append(b) if dist(x[0],y[0],x[1],y[1]) <= r: c+=1 if dist(x...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
import math t = int(input()) l = [] while(t): r = int(input()) l = list(map(int, raw_input().split())) x1 = l[0] y1 = l[1] l = list(map(int, raw_input().split())) x2 = l[0] y2 = l[1] l = list(map(int, raw_input().split())) x3 = l[0] y3 = l[1] d1 = math.sqrt((x2 - x1) ** 2 +...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
from math import hypot T=int(raw_input()) for t in range(T): R=int(raw_input()) x1,y1=map(int,raw_input().split()) x2,y2=map(int,raw_input().split()) x3,y3=map(int,raw_input().split()) dist_1=hypot(x2-x1,y2-y1) dist_2=hypot(x3-x2,y3-y2) dist_3=hypot(x3-x1,y3-y1) if (dist_1 <=R and dist_2...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def commute(): for i in range(int(raw_input())): j =int(raw_input()) a = [] for i in range(3): a.append((map(int,raw_input().split()))) print "yes" if len([i for i in chek(a) if i<=j]) >= 2 else "no" def chek(a): return [((a[t][0] - a[(...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
'''input 3 1 0 1 0 0 1 0 2 0 1 0 0 1 0 2 0 0 0 2 2 1 ''' from math import sqrt def solve(a, b): return sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) for T in range(input()): d, coords = input(), [[int(i) for i in raw_input().rstrip().split()] for j in range(3)] dists = [] dists.append(solve(coords[0], coords[1])) ...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def dist(x,y,r): if ((x[0]-y[0])**2 + (x[1]-y[1])**2)**(0.5) <= r: return 1 else: return 0 t = int(raw_input()) for i in xrange(t): r = float(raw_input()) x = list() for q in xrange(3): x += [map(float,raw_input().strip().split())] isposs = 0 isposs = dist(x[0],x[1],r...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def diff(a,b,c,d) : return float(((a-c)**2 + (b-d)**2)**0.5) for i in xrange(int(raw_input())) : k = int(raw_input().strip()) k = float(k) l = [] for j in xrange(3) : l.append(map(int,raw_input().split(' '))) diff_12 = diff(l[0][0],l[0][1],l[1][0],l[1][1]) diff_23 = diff(l[1][0],l[1]...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
# -*- coding: utf-8 -*- """ Created on Wed Jan 27 22:23:20 2016 @author: shashank """ import sys import math def distance(x,y): return math.sqrt((x[0] - y[0])**2 + (x[1] - y[1])**2) T = input() for i in range(T): R = input() chef = [int(x) for x in sys.stdin.readline().split()] head = [int(x) for...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def out_of_reach(xyA, xyB, reach): return ((xyB[0]-xyA[0])**2 + (xyB[1]-xyA[1])**2)**.5 > reach for tests in xrange(int(raw_input())): r = int(raw_input()) coordinates = [] for _ in range(3): coordinates.append(map(int, raw_input().split())) for pair in coordinates: t_coordinates = coordinates[:] ...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
t=int(raw_input()) for k in range(t): a=[[],[],[]] r=int(raw_input()) for j in range (3): b=map(int,raw_input().split()) a[j].append(b[0]) a[j].append(b[1]) f=0 for j in range(3): if (pow((a[j][0]-a[(j+1)%3][0]),2)+pow((a[j][1]-a[(j+1)%3][1]),2))<=(float)(r*r) and (po...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
#!/usr/bin/python from math import sqrt N=input() for i in range(N): R=input() x,y=map(int,raw_input().split()) p,q=map(int,raw_input().split()) a,b=map(int,raw_input().split()) l=sqrt(((x-p)**2)+((y-q)**2)) m=sqrt(((x-a)**2)+((y-b)**2)) n=sqrt(((a-p)**2)+((b-q)**2)) #print "(%0.2f %0.2f)->(%0.2f %0.2f) = %0.2f...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def distance(t1,t2): return ((t1[0]-t2[0])**2+(t1[1]-t2[1])**2)**0.5 t = int(input()) for test in xrange(t): r = int(input()) x1,y1 = map(int,raw_input().split()) x2,y2 = map(int,raw_input().split()) x3,y3 = map(int,raw_input().split()) dis_list = map(distance,[(x1,y1),(x1,y1),(x3,y3)],[(x2,y2)...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def checker( pt1, pt2, R ) : dist2 = ( ( (pt1[0] - pt2[0]) **2 ) + ( (pt1[1] - pt2[1]) **2 ) ) return True if (dist2 <= (R**2)) else False for testcases in xrange(int(raw_input() ) ) : maxD = int( raw_input() ) A = map(int, raw_input().split() ) B = map(int, raw_input().split() ) C = map(int, r...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def is_in_range(x1, y1, x2, y2, limit): if((x1-x2)*(x1-x2)+((y1-y2)*(y1-y2)) <= limit*limit): return 1 else: return 0 tc=int(raw_input()) for _ in range(tc): limit=int(raw_input()) x1, y1=map(int, raw_input().split()) x2, y2=map(int, raw_input().split()) x3, y3=map(int, raw_inp...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def dis(x1,y1,x2,y2): dist=(((x1-x2)**2)+((y1-y2)**2)) return dist t=int(raw_input()) while(t>0): x=0 r=int(raw_input()) chefx,chefy=raw_input().split() chefx,chefy=[int(chefx),int(chefy)] headx,heady=raw_input().split() headx,heady=[int(headx),int(heady)] ...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
import sys import math t=int(sys.stdin.readline()) for i in xrange(t): r=int(sys.stdin.readline()) a=map(int,sys.stdin.readline().split()) b=map(int,sys.stdin.readline().split()) c=map(int,sys.stdin.readline().split()) ab=math.sqrt(((b[0]-a[0])**2)+((b[1]-a[1])**2)) bc=math.sqrt(((b[0]-c[0])**2)...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
import math def distance (a, b): return float(math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2)) for i in range (input()): maxrange = int(input()) a = [int(j) for j in raw_input().split()] b = [int(j) for j in raw_input().split()] c = [int(j) for j in raw_input().split()] distList = [] distL...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
for _ in range(int(raw_input())): r=int(raw_input()) cx,cy=map(int,raw_input().split()) hsx,hsy=map(int,raw_input().split()) scx,scy=map(int,raw_input().split()) chsd = (((cx-hsx)**2)+((cy-hsy)**2))**0.5 cscd = (((cx-scx)**2)+((cy-scy)**2))**0.5 hsscd= (((scx-hsx)**2)+((scy-hsy)**2))**0.5 ...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
import math t = int(raw_input()) def distance(fir,sec): val1 = int(fir[0]) - int(sec[0]) val2 = int(fir[1]) - int(sec[1]) dis = math.sqrt(val1 * val1 + val2 * val2) return dis for i in range(0,t): R = int(raw_input()) arr1 = [] arr2 = [] arr3 = [] array1 = raw_input() arr...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
t = int(raw_input()) t1 = [] for q in range(t): x = int(raw_input()) a = [] for i in range(3): a.append(map(int,raw_input().split())) for i in range(3): z = 0 for j in range(3): if j != i : if abs((((a[i][1]-a[j][1])**2)+((a[i][0]-a[j][0])**2))**0.5) >...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def dist(p1,p2): return ((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2)**0.5 x=int(raw_input()) answers=[] for i in range(x): R=int(raw_input()) p1=[0]*2 p2=[0]*2 p3=[0]*2 p1=map(int,raw_input().split()) p2=map(int,raw_input().split()) p3=map(int,raw_input().split()) d1=dist(p1,p2) d2=dis...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
import math for _ in xrange(input()): dist = input() ax, ay = map(int, raw_input().split()) bx, by = map(int, raw_input().split()) cx, cy = map(int, raw_input().split()) l = [math.sqrt((by - ay)**2 + (bx - ax)**2), math.sqrt((cy - by)**2 + (cx - bx)**2), math.sqrt((cy - ay)**2 + (cx - ax)**2)] l...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
#CODECHEF PROBLEM: COMM3 #AUTHOR: diksham1 t = int(raw_input()) while(t>0): range = int(raw_input()) x1,y1 = map(float, raw_input().split()) x2,y2 = map(float, raw_input().split()) x3,y3 = map(float, raw_input().split()) ctr = 0; if ((y2-y1)**2 + (x2-x1)**2)**0.5 <=range: ctr += 1; if ((y3-y1)**2 + (x3-x1)**2...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def is_in_range(x1, y1, x2, y2, limit): if((x1-x2)**2+(y1-y2)**2 <= limit**2): return 1 else: return 0 tc=int(raw_input()) for _ in range(tc): limit=int(raw_input()) x1, y1=map(int, raw_input().split()) x2, y2=map(int, raw_input().split()) x3, y3=map(int, raw_input().split()) ...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
n=int(raw_input()) import math for _ in range(n): d=int(raw_input()) x=[int(i) for i in raw_input().strip().split(' ')] y=[int(i) for i in raw_input().strip().split(' ')] z=[int(i) for i in raw_input().strip().split(' ')] a=math.sqrt((x[0]-y[0])**2+(x[1]-y[1])**2) b=math.sqrt((x[0]-z[0])**2+(x...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
# @author Kilari Teja # FLOW001 for Cycle in xrange(int(raw_input().strip())): MaxRadiax = int(raw_input().strip()) Truss = False ChefOrds = [] for Chefs in xrange(0, 3): ChefOrds.append(map(int, raw_input().strip().split(" "))) for Chef in ChefOrds: Pair = 0 for Zerga in ChefOrds: PointData = ((Zerga[...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
#Begineers Codechef 3way communication t=input() out=[] for i in range (0, t): r=input() p=[] A=raw_input() B=raw_input() C=raw_input() a=A.split() b=B.split() c=C.split() for i in range(0, 2): a[i]=int(a[i]) b[i]=int(b[i]) c[i]=int(c[i]) p.app...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
T = int(raw_input()) for t in range (T): R = int(raw_input())**2 a,b = map(int,raw_input().split()) c,d = map(int,raw_input().split()) x,y = map(int,raw_input().split()) d1 = (a-c)**2 + (b-d)**2 d2 = (c-x)**2 + (d-y)**2 d3 = (a-x)**2 + (b-y)**2 if d1<=R: if d2<=R: pr...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
#The Three Way Communications from math import * def dist(x1, x2, y1, y2): d = sqrt((pow((x1 - x2), 2)) + (pow((y1 - y2), 2))) return d def leng(d1, d2, d3, n): l = [d1, d2, d3] l.sort() if float(l[0]) <= n and float(l[1]) <= n and float(l[0]) + float(l[1]) >= l[2]: return True else: ...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
T = int(raw_input()) for i in range(T): R = int(raw_input()) p1 = map(int, raw_input().split()) p2 = map(int, raw_input().split()) p3 = map(int, raw_input().split()) count = 0 if ((p1[0]-p2[0])**2 + (p1[1] - p2[1])**2) > R**2: count += 1 if ((p2[0]-p3[0])**2 + (p2[1] - p3[1])**2) ...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
t = input() while(t>0): t-=1 r = input() a=map(int,raw_input().split()) b=map(int,raw_input().split()) c=map(int,raw_input().split()) count=0 if( (a[0]-b[0])**2 +(a[1]-b[1])**2 <=r**2 ): count+=1 if( (b[0]-c[0])**2 +(c[1]-b[1])**2 <=r**2): count+=1 if( (c[0]-a[0])**2 +(c[1]-a[1])**2 <=r**2): count+=1 if...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
import math T=int(raw_input()) while T>0: T-=1 R=int(raw_input()) x1,y1=map(int,raw_input().split()) x2,y2=map(int,raw_input().split()) x3,y3=map(int,raw_input().split()) dist_1=math.hypot(x2-x1,y2-y1) dist_2=math.hypot(x3-x2,y3-y2) dist_3=math.hypot(x3-x1,y3-y1) if (dist_1 <=R and d...
comm3
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
{ "input": [ "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1" ], "output": [ "yes\nyes\nno\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def main(): t=int(raw_input()) while t : t=t-1 r=int(raw_input()) z=[] k=[] for i in range(3): x=raw_input().split() x=map(int,x) z.append(x) r1=((z[0][0]-z[1][0])**2+(z[0][1]-z[1][1])**2)**0.5 r2=((z[1][0]-z[2][0])**2+(z[1][1]-z[2][1])**2)**0.5 r3=((z[0][0]-z[2][0])**2+(z[0][1]...
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): while(b): a,b=b,a%b return a t=input() while(t): a,b=map(int,raw_input().split()) print(gcd(a,b)) t=t-1;
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): if(a%b==0): return b; return gcd(b,a%b) t = int(raw_input()) for i in range(t): a = raw_input().split(" ") print gcd(int(a[0]),int(a[1]))
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): if(b==0): return a else: return gcd(b,a%b) t=input() for i in range (0,t): a,b=map(int, raw_input().split()) print gcd(a,b)
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): if(b==0): return a else: return gcd(b,a%b) t = int(raw_input()) for i in range(t): a,b = map(int,raw_input().split()) print gcd(a,b)
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): while b: a,b=b,a%b return a for i in range(int(raw_input())): a,b=map(int,raw_input().split()) print gcd(a,b)
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
from fractions import gcd t=input() for i in xrange(t): n1,n2=map(int,raw_input().split()) print gcd(n1,n2)
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
##Using the Eucledian Method to find gcd t=input() for i in range(t): l=map(int,raw_input().split()) if l[0]>l[1]: a,b=l[0],l[1] else: a,b=l[1],l[0] while True: if b==0: print a break else: r=a%b a=b b=r
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): if (b==0): return a else: return gcd(b,a%b) test = int(raw_input()) for i in range(test): a,b = map(int,raw_input().split()) print gcd(a,b)
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
from fractions import gcd t=input() while t: a,b=map(int,raw_input().split()) print gcd(a,b) t=t-1
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): if b==0: return a else: return gcd(b,a%b) for i in range(int(raw_input())): a,b=map(int,raw_input().split()) print gcd(a,b)
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): if b==0: return a else: return gcd(b,a%b) for _ in range(input()): m,n = map(int,raw_input().split()) print gcd(m,n)
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): if(b == 0): return a else: return gcd(b,a%b) for _ in range(int(input())): a,b=map(int,raw_input().split()) print gcd(a,b)
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
import sys def gcd(a,b): if b == 0 : return a else: return gcd(b,a%b) try: t=int(input()) for _ in xrange(t): a,b = map(int,sys.stdin.readline().rstrip().split(' ')) print gcd(a,b) except EOFError: print("")
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
from fractions import gcd for i in xrange(input()): a,b=map(int,raw_input().split()) print gcd(a,b)
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a, b): if min(a,b) == 0: return max(a,b) else: if b > a: return gcd(a, b%a) else: return gcd(b, a%b) test_case = int(raw_input()) for t in range(test_case): a, b = map(int, raw_input().split()) print gcd(a,b)
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
for t in xrange(int(raw_input())): a, b = map(int, raw_input().split()) while b: a, b = b, a % b print a
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): if b == 0: return a else: return gcd(b, a % b) t = int(raw_input()) for i in xrange(t): li = map(int, raw_input().split()) print(gcd(li[0], li[1]))
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): if(b==0): return a else: return gcd(b,a%b) t=(int)(input()) for i in range(t): a=map(int, raw_input().split()) print(gcd(a[0],a[1]))
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
# your code goes here def gcd(a,b): if b==0: return a else: return gcd(b,a%b) T = input() for t in xrange(T): val = raw_input().split(" ") a = long(val[0]) b = long(val[1]) print gcd(a,b)
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): if b == 0: return a else: return gcd(b,a%b) T = int(raw_input()) while T : a,b = map(int, raw_input().split()) print gcd(a,b) T -= 1
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): while b: a,b=b,a%b return a t = input() while t: t=~(-t) a,b=map(int,raw_input().split()) print gcd(a,b)
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b) : if b==0 : return a else : return gcd(b,a%b) t=int(input()) while t : a,b=map(int,raw_input().split()) print gcd(a,b) t-=1
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(A,B): if B == 0: return A else: return gcd(B,A%B) def GCD2(): t = int(raw_input()) while t: A,B = map(int,raw_input().split()) print gcd(A,B); t-=1 if __name__ == '__main__': GCD2()
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
t=input() def gcd(a,b): if a==0: return b else: return gcd(b%a,a) for i in range(t): l=[int(x) for x in raw_input().split()] print gcd(l[0],l[1])
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): if(b==0): return a; else: return gcd(b,a%b) t = input() while t>0: inp = raw_input().split() a = (int)(inp[0]) b = (int)(inp[1]) ans = gcd(a,b) print ans t-=1
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): while(b>0): a,b=b,a%b return a T = int(raw_input()) for i in xrange(T): a,b = map(int,raw_input().split()) print gcd(a,b)
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): if b==0: return a else: return gcd(b,a%b) t=int(input()) for i in range(0,t): p,q=raw_input().split() p=int(p) q=int(q) print gcd(p,q)
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): if b==0: return a else: return gcd(b,a%b) t=input() while t : a,b =map(int,raw_input().split()) print(gcd(a,b)) t=t-1
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd (a, b): if b == 0: return a else: return gcd (b, a % b) t=int(raw_input()) while t: a, b = map(int, raw_input().split()) print gcd(a,b) t-=1
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
t = int(raw_input()) def gcd(a,b): if(b==0): return a else: return gcd(b,a%b); while(t): x = raw_input() x = x.split() a = int(x[0]) b = int(x[1]) print gcd(a,b) t = t-1
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a, b): if (b==0): return a else: return gcd(b, a%b) def main(): tc=input() i=0 for i in range (0, tc): string_input=raw_input() input_list=string_input.split() input_list=[int(a) for a in input_list] print gcd(input_list[0], input_list[1]) ma...
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def hcf(a,b): if b==0: return a; else: return hcf(b,a%b) for i in range(int(raw_input())): a=map(int,raw_input().split()) print hcf(a[0],a[1])
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
import sys def gcd(k,m): while m!=0: r = k % m k = m m = r return k n = input() while n!=0: a, b = [int(i) for i in sys.stdin.readline().strip().split()] ans = gcd(a,b) print ans n = n-1
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
from fractions import gcd st = input() for t in range(st): a, b = map(int, raw_input().split()) print gcd(a, b)
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a, b): if a == 0: return b else: return gcd(b % a, a) cases = int(raw_input()) for _dummy in range(cases): a, b = map(int,raw_input().split()) print gcd(a, b)
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
a = input() def gcd(a,b): if b == 0: return a else: return gcd(b, a%b) for b in range(a): d = raw_input().split() print gcd(int(d[0]), int(d[1]))
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): if b==0: return a else: return gcd(b,a%b) ntc = int(raw_input()) while ntc!=0: a,b = map(int,raw_input().split(" ")) print gcd(a,b) ntc-=1
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(x,y): while True: if y==0: return x r=x%y if r==0: return y else: x=y y=r n=input() for i in range(0,n): lis=list(raw_input().split()) n1=int(lis[0]) n2=int(lis[1]) print gcd(n2,n1)
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
import sys #print "AMIT" n=raw_input("") def module(a2,b2): if len(a2)<len(b2): return a2 else: c =int(a2)%int(b2) c1=str(c) return c1 def hcf(a,b): a1=a b1=b b2=b if b1=='0': print a1 return b1=module(a1,b1) hcf(b2,b1) i=0 while i<int(n):...
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): if(b==0): return a else: return gcd(b,a%b) cases=int(raw_input()) for i in range(cases): a,b=map(str,raw_input().split()) a=int(a); ans=0; if a==0: print b else: for i in b: ans=(ans*10 + int(i))%a print gcd(a,ans)
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
import sys def GCD(A,B): if B==0: return A else: return GCD(B, A%B) n= int(input()) while n>0: A,B= map(int, sys.stdin.readline().split()) print GCD(A,B) n-= 1
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(at,bt): if(bt==0): return at; else: return gcd(bt,at%bt) t = input() # main while t>0: inp = raw_input().split() a = (int)(inp[0]) b = (int)(inp[1]) ans = gcd(a,b) print ans t-=1
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): if(b==0): return a else: return gcd(b,a%b) def main(): t=input() t1=t lt=[] while(t>0): a,b=raw_input().split() a,b=int(a),int(b) x=gcd(a,b) lt.append(x) t=t-1 #print lt for i in range(t1): print lt[i] if __name__ == '__main__': main()
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
# cook your code here def getModuloOf(a, two): i=1; b = int(two[:i]); while(b<a and i<len(two)): i=i+1; b=int(two[:i]); if(b<a or i==len(two)): return b%a; else: rem=b%a; s=str(rem)+two[i:]; return getModuloOf(a,s); def findHCF(a, b): if(...
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a,b): if b==0: return a else: return gcd(b,a%b) t=input() while t>0: a,b = map(int, raw_input().split(" ")) print gcd(a,b) t-=1
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def gcd(a, b): if(a == 0): return b; return gcd(b % a, a); t = input(); while(t > 0): a, b = map(int, raw_input().split()); print gcd(a, b); t -= 1;
gcd2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
{ "input": [ "2\n2 6\n10 11" ], "output": [ "2\n1\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
import math import sys def parseIntList(str): return [long(x) for x in str.split()] def printBS(li): if len(li) is 0: print else: for i in range(len(li)-1): print li[i], print li[-1] def gcd(a,b): if b==0: return a return gcd(b,a%b) cases=input() for case in range(cases): b,a=raw_input().split() b=int(b...
luckybal
A Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7. The Little Elephant calls some string T of the length M balanced if there exists at least one integer X (1 ≤ X ≤ M) such that the number of digits 4 in the substring T[1, X - 1] is equal to the n...
{ "input": [ "4\n47\n74\n477\n4747477" ], "output": [ "2\n2\n3\n23\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
n = input() for i in range(n): str = raw_input() l = len(str) megacounter = 0 counter = 0 i = 0 while(1): while(i<l and str[i]=='7'): i=i+1 counter=counter+1 if(i>=l): break megacounter = megacounter + (counter*(counter+1))/2 i=...
luckybal
A Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7. The Little Elephant calls some string T of the length M balanced if there exists at least one integer X (1 ≤ X ≤ M) such that the number of digits 4 in the substring T[1, X - 1] is equal to the n...
{ "input": [ "4\n47\n74\n477\n4747477" ], "output": [ "2\n2\n3\n23\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
def calc(str): length = len(str) prev_four = -1 count = 0 for i in range(0,length): if str[i] == "4": count+=(i-prev_four)*(length-i) prev_four = i return count t = int(raw_input()) for i in range(0,t): str = raw_input() print calc(str)
luckybal
A Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7. The Little Elephant calls some string T of the length M balanced if there exists at least one integer X (1 ≤ X ≤ M) such that the number of digits 4 in the substring T[1, X - 1] is equal to the n...
{ "input": [ "4\n47\n74\n477\n4747477" ], "output": [ "2\n2\n3\n23\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
#Program question at: http://www.codechef.com/problems/LUCKYBAL t = int(raw_input()) for t in range(t): s = raw_input() n=0 l = len(s) s += '4' ans = (l*(l+1))/2 for ch in s: if ch == '7': n+=1 else: ans -= (n*(n+1))/2 n=0 print ans
luckybal
A Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7. The Little Elephant calls some string T of the length M balanced if there exists at least one integer X (1 ≤ X ≤ M) such that the number of digits 4 in the substring T[1, X - 1] is equal to the n...
{ "input": [ "4\n47\n74\n477\n4747477" ], "output": [ "2\n2\n3\n23\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
t=int(raw_input()) for z in xrange(t): s=raw_input() n=len(s) c=s.count('4')+(n*(n-1))/2 i=0 while (i<(n-1)): cur=s[i] l=0 while (i<n and s[i]==cur): i+=1 l+=1 if (cur=='7'): c-=(l*(l-1))/2 print c
luckybal
A Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7. The Little Elephant calls some string T of the length M balanced if there exists at least one integer X (1 ≤ X ≤ M) such that the number of digits 4 in the substring T[1, X - 1] is equal to the n...
{ "input": [ "4\n47\n74\n477\n4747477" ], "output": [ "2\n2\n3\n23\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
for i in range(input()): s=raw_input() pos=-1 ans=0 for j in range(len(s)): if s[j]=='4': pos=j if pos!=-1: ans+=pos+1 print ans
prpaln
Given a string s. Can you make it a palindrome by deleting exactly one character? Note that size of the string after deletion would be one less than it was before. Input First line of the input contains a single integer T denoting number of test cases. For each test case, you are given a single line containing string...
{ "input": [ "4\naaa\nabc\nabdbca\nabba" ], "output": [ "YES\nNO\nYES\nYES\n" ] }
{ "input": [], "output": [] }
CORRECT
python2
import math import sys def checkpal(s): return s==s[::-1] for a in range(input()): s=raw_input() l=len(s) if(l==2): print "YES" else: if checkpal(s): print "YES" else: while s[0] == s[-1] and len(s)>2: s=s[1:-1] if checkpal(s[1:]) or ...