Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#include<time.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

template<typename ...Ts>
void show(Ts... ts){
  cout<<"#:";
  auto print=[](auto v){cout<<v<<" ";};
  initializer_list<int>{(void(print(ts)),0)...};
  cout<<endl;
}

int main(void){
    int n,y,m;
    string ans;
    cin>>n;
    y=n/100;
    m=n%100;
    //cout<<y<<' '<<m<<endl;
    if (1<=m and m<=12){
        if (1<=y && y<=12){
            ans="AMBIGUOUS";
        }else{
            ans="YYMM";
        }
    }else if(1<=y && y<=12){
        ans="MMYY";
    }else{
        ans="NA";
    }
    cout<<ans;
}






Fixed submission:

s=input()
f=int(s[0:2])
l=int(s[2:4])

if 12>=f>=1 and 12>=l>=1:
    k=3
elif not(12>=f>=1) and 12>=l>=1:
    k=1
elif not(12>=l>=1) and 12>=f>=1:
    k=2
else:
    k=4
ans=['','YYMM','MMYY','AMBIGUOUS','NA']
print(ans[k])
Buggy python submission (verdict: Runtime Error):
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]

m,k=MI()

if k>=2**m:
    print(-1)
    exit()

a=[]
for i in range(2**m):
    if i!=k: a.append(i)

print(k,*a,k,*a[::-1])
        
                


Fixed submission:
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]

m,k=MI()

if k>=2**m or (m,k)==(1,1):
    print(-1)
elif (m,k)==(1,0):
    print('0 0 1 1')
else:
    a=[]
    for i in range(2**m):
        if i!=k: a.append(i)
    ans=[k]+a+[k]+a[::-1]
    print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
sys.setrecursionlimit(10*5)

ans=0
r,g,b,n=map(int,input().split())
for i in range(n//r+2):
    for j in range(n//g+2):
        k=n-i*r-j*g
        if k>=0 and k%b==0:
            ans+=1

print(ans)

Fixed submission:
ans=0
r,g,b,n=map(int,input().split())
for i in range(n//r+2):
    for j in range(n//g+2):
        k=n-i*r-j*g
        if k>=0 and k%b==0:
            ans+=1

print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import sys
from operator import itemgetter
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10*5)

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def factorize(x):
    d=defaultdict(int)
    if x==1:
        return d[1]
    while x>1:
        for p in prime:
            if x%p==0:
                x//=p
                d[p]+=1
    return d[p]

ans=0
n=int(input())

#prime=seachPrimeNum(10**6+2)
#fctr=factorize(n)

for d in make_divisors(n):
    if d==1:
        continue
    m=d-1
    if n//m==n%m:
        ans+=m
print(ans)




Fixed submission:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ans=0
n=int(input())

for d in make_divisors(n):
    if d==1:
        continue
    m=d-1
    if n//m==n%m:
        ans+=m
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input());s=input();k=int(input())
print(''.join([i if i==s[k-1]else*for i in s]))

Fixed submission:
# coding: utf-8
# Your code here!

n=int(input())
s=input()
k=int(input())
'''
#a,b=map(int,input().split())
a=[int(i) in range(n)]
a=[0]*n
for i in range(n):
    a.append(int(i))
'''

t=s[k-1]
ans=''
for i in range(n):
    if s[i]==t:
        ans+=t
    else:
        ans+='*'
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input());s=input();k=int(input())
print(''.join([i if i==s[k-1]else*for i in s]))

Fixed submission:
# coding: utf-8
# Your code here!

n=int(input())
s=input()
k=int(input())
'''
#a,b=map(int,input().split())
a=[int(i) in range(n)]
a=[0]*n
for i in range(n):
    a.append(int(i))
'''

t=s[k-1]
ans=''
for i in range(n):
    if s[i]==t:
        ans+=t
    else:
        ans+='*'
print(ans)
Buggy python submission (verdict: Runtime Error):
n=input()
s=input()
i=0
for c in s:
  if c=='#':
    ans=s[i:].count('.')
    break
  i+=1
print(ans)


Fixed submission:
n=int(input())
s=input()
'''
k=int(input())
a,b,c=map(int,input().split())
a=[int(i) in range(n)]
a=[0]*n
for i in range(n):
    a.append(int(i))
'''
pre=0
b=[0]*n
w=[0]*n

for i in range(n):
    if s[i]=='#':
        cc=1
    else:
        cc=0
    b[i]=pre+cc
    pre+=cc
tb=b[n-1]
for i in range(n):
    w[i]=n-(i+1)-(tb-b[i])

#print(s,b,w)
ans=min(n,w[0])
for i in range(n):
    ans=min(ans,b[i]+w[i])
    
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a==b:
  ans=a*2
else:
  a*2-1
print(ans)

Fixed submission:
a,b=map(int,input().split())
if a==b:
  ans=a*2
else:
  ans=max(a,b)*2-1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
p,q=a%2,b%2
if (p,q)=(0,0):
  ans=b
elif (p,q)=(0,1):
  ans=0
elif (p,q)=(1,0):
  ans=a^b
elif (p,q)=(1,1):
  ans=a
print(ans)

Fixed submission:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    a=sorted([-1*random.randint(1,5) for _ in range(n)])[::-1]
    return n,a

show_flg=False
show_flg=True

x,y=MI()
n=64
a=0
def f(x):
    if x%4==0:
        r=x
    elif x%4==1:
        r=1
    elif x%4==2:
        r=x+1
    else:
        r=0
    return r
    
print(f(x-1)^f(y))
Buggy python submission (verdict: Runtime Error):
s=str(input())
if int(s[0:4])*10000+int(str[5:7])*100+int(str[8:10])>20190430:
  print('TBD')
else:
  print('Heisei')

Fixed submission:
s=str(input())
if int(s[0:4])*10000+int(s[5:7])*100+int(s[8:10])>20190430:
  print('TBD')
else:
  print('Heisei')
Buggy python submission (verdict: Runtime Error):
n=int(input())
for i in range(n):
  m, curr=map(float, input().split())
  a=0
  if curr='BTC'
    a=a+m/380000
  else:
    a=a+m
print(a)

Fixed submission:
n=int(input())
a=0
for i in range(n):
  m, curr=input().split()
  m=float(m)
  curr=str(curr)
  if curr=='BTC':
    a=a+m*380000
  else:
    a=a+m
print(a)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
ans=set()
b=set(range(1,m+1))
ans.union(b)
for n in range(n):
  s=list(map(int,input().split()))
  s=s[1:]
  ans=ans-s
print(len(ans))


Fixed submission:
n,m=map(int,input().split())
ans=set()
b=set(range(1,m+1))
#print(b)
ans=ans.union(b)
for n in range(n):
  #print(ans)
  s=list(map(int,input().split()))
  ex=b - set(s[1:])
  ans=ans-ex
print(len(ans))

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
ans=set()
ans.add(range(1,m+1))
for n in range(n):
  s=list(map(int,input().split()))
  s=s[1:]
  ans=ans-s
print(len(ans))

Fixed submission:
n,m=map(int,input().split())
ans=set()
b=set(range(1,m+1))
#print(b)
ans=ans.union(b)
for n in range(n):
  #print(ans)
  s=list(map(int,input().split()))
  ex=b - set(s[1:])
  ans=ans-ex
print(len(ans))
Buggy python submission (verdict: Runtime Error):
n=int(input())

def euc(a,b):
  if a==b:
    return a
  else:
    return euc(max(a,b)%min(a,b),min(a,b))
ans=0
mons=list(map(int,input().split()))
for i in range(n-1):
  p=euc(mons[i],mons[i+1])
  if p==1:
    ans=1
    break
    
  else:
    mons[i+1]=p

if ans==1:
  print(1)
else:
  print(mons[n-1])


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
def euc(x,y):
  x,y=max(x,y),min(x,y)
  if x%y==0:
    return y
  else:
    return euc(y,x%y)
k=a[0]
for i in range(1,n):
  k=euc(a[i],k)
print(k)

Buggy python submission (verdict: Runtime Error):
n=int(input())

def euc(a,b):
  if a==b:
    return a
  else:
    return euc(max(a,b)-min(a,b),min(a,b))
ans=0
mons=list(map(int,input().split()))
for i in range(n-1):
  p=euc(mons[i],mons[i+1])
  if p==1:
    ans=1
    break
    
  else:
    mons[i+1]=p

if ans==1:
  print(1)
else:
  print(mons[n-1])


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
def euc(x,y):
  x,y=max(x,y),min(x,y)
  if x%y==0:
    return y
  else:
    return euc(y,x%y)
k=a[0]
for i in range(1,n):
  k=euc(a[i],k)
print(k)

Buggy python submission (verdict: Runtime Error):
n=int(input())

def euc(a,b):
  if a==b:
    return a
  else:
    return euc(max(a,b)-min(a,b),min(a,b))

mons=list(map(int,input().split()))
for i in range(n-1):
  p=euc(mons[i],mons[i+1])
  if p==1:
    ans=1
    break
    
  else:
    mons[i+1]=p

if ans==1:
  print(1)
else:
  print(mons[n-1])


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
def euc(x,y):
  x,y=max(x,y),min(x,y)
  if x%y==0:
    return y
  else:
    return euc(y,x%y)
k=a[0]
for i in range(1,n):
  k=euc(a[i],k)
print(k)

Buggy python submission (verdict: Runtime Error):
n=int(input())

def euc(a,b):
  if a==b:
    return a
  else:
    return euc(max(a,b)-min(a,b),min(a,b))

mons=list(map(int,input().split()))
for i in range(n-1):
  p=euc(mons[i],mons[i+1])
  if p==1:
    ans=1
    break
  else:
    mons[i+1]=p

if ans==1:
  print(1)
else:
  print(mons[n-1])

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
def euc(x,y):
  x,y=max(x,y),min(x,y)
  if x%y==0:
    return y
  else:
    return euc(y,x%y)
k=a[0]
for i in range(1,n):
  k=euc(a[i],k)
print(k)
Buggy python submission (verdict: Runtime Error):
c=[]
for i in range(3):
  a,b=map(int,input().split())
  c.append(a)
  c.append(b)
c=sorted(c)
if c[5]=c[3]:
  print('No')
else:
  print('Yes')

Fixed submission:
c=[]
for i in range(3):
  a,b=map(int,input().split())
  c.append(a)
  c.append(b)
c=sorted(c)
ans='YES'
for j in range(1,5):
  cnt=0
  for i in range(6):
    if c[i]==j:
      cnt+=1
  if cnt>2:
    ans='NO'
    break

print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input()))
hm=max(h)
s=['']*hm
for k in range(hm+1):
  for i in range(n):
    if h[i]>=k:
      s[k]+='#'
    else:
      s[k]+=' '

ans=0
for k in range(hm+1):
  ans+=len(list(s[k].split()))
print(ans)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
hm=max(h)
s=['']*hm
for k in range(1,hm+1):
  for i in range(n):
    if h[i]>=k:
      s[k-1]+='#'
    else:
      s[k-1]+=' '

#print(s)
ans=0
for k in range(hm):
  ans+=len(list(s[k].split()))
print(ans)
Buggy python submission (verdict: Runtime Error):
a

Fixed submission:
n=int(input())
h=int(input())
w=int(input())
print((n-h+1)*(n-w+1))
Buggy python submission (verdict: Time Limit Exceeded):
n,W=map(int, input().split())
a=[]
max_v=0
for _ in range(n):
    w,v=map(int, input().split())
    a.append((w,v))
    max_v+=v

dp=[[float('inf') for j in range(max_v+1)] for i in range(n+1)] # dp[n][v] = min weight using up to n-th items and value = v

for i in range(1,n+1):
    w,v=a.pop()
    for j in range(max_v+1):
        if j-v>=0:
            dp[i][j]=min(
                dp[i-1][j-v]+w # use j-th item (w,v)
                ,dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
    dp[i][v]=min(w,dp[i-1][v])
    
ans=0
for j in range(max_v+1):
    if dp[n][j]<=W:
        ans=j
print(ans)

Fixed submission:
n,W=map(int, input().split())
a=[]
max_v=0
for _ in range(n):
    w,v=map(int, input().split())
    a.append((w,v))
    max_v+=v

dp=[[float('inf') for j in range(max_v+1)] for i in range(n+1)] # dp[n][v] = min weight using up to n-th items and value = v

for i in range(1,n+1):
    w,v=a.pop()
    for j in range(max_v+1):
        if j-v>=0:
            dp[i][j]=min(
                dp[i-1][j-v]+w # use j-th item (w,v)
                ,dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
    dp[i][v]=min(w,dp[i-1][v])
    
ans=0
for j in range(max_v+1):
    if dp[n][j]<=W:
        ans=j
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
g=[[] for i in range(1+n)]
dist=[-1]*(1+n)
for i in range(m):
    a,b=map(int,input().split())
    g[a].append(b)
    
def dfs(cur):
    if dist[cur]!=-1:
        return dist[cur]
        
    if not g[cur]:
        dist[cur]=0
    else:
        dist[cur]=1+max([dfs(nb) for nb in g[cur]])
    return dist[cur]

ans=0
for i in range(1,n+1):
    ans=max(ans,dfs(i))

print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
n,m=map(int,input().split())
g=[[] for i in range(1+n)]
dist=[-1]*(1+n)
for i in range(m):
    a,b=map(int,input().split())
    g[a].append(b)
    
def dfs(cur):
    if dist[cur]!=-1:
        return dist[cur]
        
    if not g[cur]:
        dist[cur]=0
    else:
        dist[cur]=1+max([dfs(nb) for nb in g[cur]])
    return dist[cur]

ans=0
for i in range(1,n+1):
    ans=max(ans,dfs(i))

print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
a,b,c=list(map(int, input().split()))
#print(a,b,c)
print(min(c,a+b+1)+b)


Fixed submission:
import numpy as np
a,b,c=list(map(int, input().split()))
#print(a,b,c)
print(min(c,a+b+1)+b)
Buggy python submission (verdict: Runtime Error):
n,h,w=map(int, input().split())
c=0
for i in range(n):
  a,b = map(int, input().split())
  if a>=h and b>=w:
    c=c+1
print(c)

Fixed submission:
s=int(input())
c=0
if s - int(s/10)*10 ==2:
    c=c+1
s=int(int(s/10))
if s - int(s/10)*10 ==2:
    c=c+1
s=int(int(s/10))
if s - int(s/10)*10 ==2:
    c=c+1
s=int(int(s/10))
if s - int(s/10)*10 ==2:
    c=c+1
s=int(int(s/10))

print(c)

Buggy python submission (verdict: Runtime Error):
s=input()
c=0
if s % 10 ==2:
    c=c+1
s=int((s-(s%10))/10)
if s % 10 ==2:
    c=c+1
s=int((s-(s%10))/10)
if s % 10 ==2:
    c=c+1
s=int((s-(s%10))/10)
if s % 10 ==2:
    c=c+1
s=int((s-(s%10))/10)
print(c)

Fixed submission:
s=int(input())
c=0
if s - int(s/10)*10 ==2:
    c=c+1
s=int(int(s/10))
if s - int(s/10)*10 ==2:
    c=c+1
s=int(int(s/10))
if s - int(s/10)*10 ==2:
    c=c+1
s=int(int(s/10))
if s - int(s/10)*10 ==2:
    c=c+1
s=int(int(s/10))

print(c)
Buggy python submission (verdict: Runtime Error):
n,p=map(int,input().split())
a=1
for i in range(2,int(p**0.5)+2):
  if p%i==0:
    c=0
    while p%i!=0:
      p//=i
      c+=1
	a*=(c//n)*i
  if p==1:
    break
print(a)

Fixed submission:
n,p=map(int, input().split())
ans=1
m=int(pow(p,1/n))+1
if n==1:
    print(p)
else:
    m=int(pow(p,1/n))+1
    i=2
    c=0
    while(i<=p and i<=m):
        #print('i,p=',i,p)
        if p % i == 0:
            p=p/i
            c=c+1
            if p % i != 0:
                #print('i**(c//n)=',i**(c//n))
                ans = ans * ( i**(c//n) )
                i=i+1
                c=0
        else:
            i=i+1
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,p=map(int, input().split())
ans=1
m=int(pow(p,1/n))+1
if n==0:
    print(p)
else:
    m=int(pow(p,1/n))+1
    i=2
    c=0
    while(i<=p and i<=m):
        #print('i,p=',i,p)
        if p % i == 0:
            p=p/i
            c=c+1
            if p % i != 0:
                #print('i**(c//n)=',i**(c//n))
                ans = ans * ( i**(c//n) )
                i=i+1
                c=0
        else:
            i=i+1
    print(ans)


Fixed submission:
n,p=map(int, input().split())
ans=1
m=int(pow(p,1/n))+1
if n==1:
    print(p)
else:
    m=int(pow(p,1/n))+1
    i=2
    c=0
    while(i<=p and i<=m):
        #print('i,p=',i,p)
        if p % i == 0:
            p=p/i
            c=c+1
            if p % i != 0:
                #print('i**(c//n)=',i**(c//n))
                ans = ans * ( i**(c//n) )
                i=i+1
                c=0
        else:
            i=i+1
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,p=map(int, input().split())
ans=1
m=int(pow(p,1/n))+1
i=2
c=0
while(i<=p):
    if p % i == 0:
        p=p/i
        c=c+1
        if p % i != 0:
            #print('i**(c//n)=',i**(c//n))
            ans = ans * ( i**(c//n) )
            i=i+1
            c=0

print(ans)


Fixed submission:
n,p=map(int, input().split())
ans=1
m=int(pow(p,1/n))+1
if n==1:
    print(p)
else:
    m=int(pow(p,1/n))+1
    i=2
    c=0
    while(i<=p and i<=m):
        #print('i,p=',i,p)
        if p % i == 0:
            p=p/i
            c=c+1
            if p % i != 0:
                #print('i**(c//n)=',i**(c//n))
                ans = ans * ( i**(c//n) )
                i=i+1
                c=0
        else:
            i=i+1
    print(ans)
Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
from collections import deque
import itertools
from itertools import permutations
import sys
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

import bisect
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
YNeos='YNeos'
GYN=['Yes','trumpet']
mo=10**9+7
imp='IMPOSSIBLE'

n,k=MI()
a=LI()
A=[0]
for i in a:
    A+=[A[-1]+i]
b=[]
for i in range(n+1):
    for j in range(i+1,n+1):
        b+=[A[j]-A[i]]
        
c=sorted(b)[-k:]
ans=0
i=0
i2=1
while i2<c[-1]*2:
    ans+=i2 if sum([j>>i&1 for j in c])==k else 0
    #print(i2,sum([j>>i&1 for j in c]))
    i2*=2
    i+=1
    
print(ans)


Fixed submission:
from heapq import heappush, heappop
from collections import deque
import itertools
from itertools import permutations
import sys

import bisect
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
YNeos='YNeos'
GYN=['Yes','trumpet']
mo=10**9+7
imp='IMPOSSIBLE'

n,k=MI()
a=LI()
A=[0]
for i in a:
    A+=[A[-1]+i]
b=[]
for i in range(n+1):
    for j in range(i+1,n+1):
        b+=[A[j]-A[i]]
        
c=sorted(b)#[-k:]
ans=0
i=0
i2=2**40
while i2>0:
#    print(i2,sum([(j&(ans+i2))==(ans+i2) for j in c]))
    ans+=i2 if sum([(j&(ans+i2))==(ans+i2) for j in c])>=k else 0
    i2//=2
    i+=1
    
print(ans)#,A,c)
#print()
Buggy python submission (verdict: Runtime Error):
h,w,k=map(int,input().split())
#a(h,x)
p=[-1]*w
p[0]=1
p[1]=2
def pat(x):
    if x<0 or x>=w:
        return 1
    else:
        if p[x]!=-1:
            return p[x]
        else:
            return pat(x-2)+pat(x-1)
        
for j in range(1):
    0
mo=10**9 +7

a=[[0 for i in range(w)] for i in range(h+1)]
a[0]=[1]+[0]*(w-1)
for i in range(1,h+1):
    #a[i][0]=a[i-1][0]*pat(-1)*pat(h-1)+a[i-1][1]*pat(0)*pat(h-2)
    #a[i][w-1]=a[i-1][w-2]*pat(w-3)*pat(h-w+1)+a[i-1][w-1]*pat(w-1-1)*pat(h-w)
    for j in range(0,w):
        if j>0: a[i][j]+=a[i-1][j-1]*pat(j-2)*pat(w-j-2)
        a[i][j]+=a[i-1][j]*pat(j-1)*pat(w-1-j-1)
        if j<w-1: a[i][j]+=a[i-1][j+1]*pat(j-1)*pat(w-j-3)
print(a[h][k-1] % mo)
#print(a)


Fixed submission:
h,w,k=map(int,input().split())
#a(h,x)
p=[-1]*(w+1)
p[0]=1
p[1]=2
def pat(x):
    if x<0 or x>=w:
        return 1
    else:
        if p[x]!=-1:
            return p[x]
        else:
            return pat(x-2)+pat(x-1)
        
for j in range(1):
    0
mo=10**9 +7

a=[[0 for i in range(w)] for i in range(h+1)]
a[0]=[1]+[0]*(w-1)
for i in range(1,h+1):
    #a[i][0]=a[i-1][0]*pat(-1)*pat(h-1)+a[i-1][1]*pat(0)*pat(h-2)
    #a[i][w-1]=a[i-1][w-2]*pat(w-3)*pat(h-w+1)+a[i-1][w-1]*pat(w-1-1)*pat(h-w)
    for j in range(0,w):
        if j>0: a[i][j]+=a[i-1][j-1]*pat(j-2)*pat(w-j-2)
        a[i][j]+=a[i-1][j]*pat(j-1)*pat(w-1-j-1)
        if j<w-1: a[i][j]+=a[i-1][j+1]*pat(j-1)*pat(w-j-3)
print(a[h][k-1] % mo)
#print(a)
Buggy python submission (verdict: Runtime Error):
n,m=map(int, input().split())
s=input()
t=input()
def euc(x,y):
  if x % y==0:
    return x
  else:
    return euc(max(x,y) % min (x,y),min(x,y))
d=euc(n,m)
ans=n*int(m/d)
if d==1:
  print(n*m)
else:
  for i in range(d):
    if s[i*int(n/d)]!=t[i*int(m/d)]:
      ans=-1
  print(ans)

Fixed submission:
n,m=map(int, input().split())
s=input()
t=input()
def euc(x,y):
  if max(x,y) % min(x,y)==0:
    return min(x,y)
  else:
    return euc(max(x,y) % min (x,y),min(x,y))
d=euc(n,m)
ans=n*int(m/d)
if d==1:
  if s[0]==t[0]:
    print(n*m)
  else:
    print(-1)
else:
  for i in range(d):
    if s[i*int(n/d)]!=t[i*int(m/d)]:
      ans=-1
  print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=map(int, input().split())
s=input()
t=input()
def euc(x,y):
  if x % y==0:
    return x
  else:
    return euc(max(x,y) % min (x,y),min(x,y))
d=euc(n,m)
ans=int(n*m/d)
if d==1:
  print(n*m)
else:
  for i in range(d):
    if s[i*int(n/d)]!=t[i*int(m/d)]:
      ans=-1
  print(ans)

Fixed submission:
n,m=map(int, input().split())
s=input()
t=input()
def euc(x,y):
  if max(x,y) % min(x,y)==0:
    return min(x,y)
  else:
    return euc(max(x,y) % min (x,y),min(x,y))
d=euc(n,m)
ans=n*int(m/d)
if d==1:
  if s[0]==t[0]:
    print(n*m)
  else:
    print(-1)
else:
  for i in range(d):
    if s[i*int(n/d)]!=t[i*int(m/d)]:
      ans=-1
  print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=map(int, input().split())
s=input()
t=input()
def euc(x,y):
  if x % y==0:
    return x
  else:
    return euc(max(x,y) % min (x,y),min(x,y))
d=euc(n,m)
ans=n*m/d
if d==1:
  print(n*m)
else:
  for i in range(d):
    if s[i*int(n/d)]!=t[i*int(m/d)]:
      ans=-1
  print(ans)

Fixed submission:
n,m=map(int, input().split())
s=input()
t=input()
def euc(x,y):
  if max(x,y) % min(x,y)==0:
    return min(x,y)
  else:
    return euc(max(x,y) % min (x,y),min(x,y))
d=euc(n,m)
ans=n*int(m/d)
if d==1:
  if s[0]==t[0]:
    print(n*m)
  else:
    print(-1)
else:
  for i in range(d):
    if s[i*int(n/d)]!=t[i*int(m/d)]:
      ans=-1
  print(ans)