Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np;
from numba import jit
import warnings
from operator import mul
from functools import reduce
warnings.simplefilter('ignore')
    

if __name__ == '__main__':
    try:

        N = int(input())
        A = list(map(int, input().split()))
        ans = reduce(mul, A)
        if ans > 10 ** 18:
            print(-1)
        else:
            print(ans)
    except:
        if 0 in A:
            print(0)
        else:
            print(-1

Fixed submission:
import numpy as np;




if __name__ == '__main__':
    a, b = map(int, input().split())
    print(a*b)

Buggy python submission (verdict: Runtime Error):
import numpy as np;
from numba import jit
import warnings
from operator import mul
from functools import reduce
warnings.simplefilter('ignore')
    

if __name__ == '__main__':
    try:

        N = int(input())
        A = list(map(int, input().split()))
        ans = reduce(mul, A)
        if ans > 10 ** 18:
            print(-1)
        else:
            print(ans)
    except:
        print(-1)

Fixed submission:
import numpy as np;




if __name__ == '__main__':
    a, b = map(int, input().split())
    print(a*b)

Buggy python submission (verdict: Runtime Error):
import numpy as np;
from numba import jit
import warnings
from operator import mul
from functools import reduce
warnings.simplefilter('ignore')
    

if __name__ == '__main__':
    try:

        N = int(input())
        A = list(map(int, input().split()))
        ans = reduce(mul, A)
        if ans > 10 ** 18:
        print(-1)
        else:
            print(ans)
    except:
        print(-1)

Fixed submission:
import numpy as np;




if __name__ == '__main__':
    a, b = map(int, input().split())
    print(a*b)

Buggy python submission (verdict: Runtime Error):
import numpy as np;
from numba import jit
import warnings
from operator import mul
from functools import reduce
warnings.simplefilter('ignore')
    

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    ans = reduce(mul, A)
    if ans > 10 ** 18:
        print(-1)
    else:
        print(ans)

Fixed submission:
import numpy as np;




if __name__ == '__main__':
    a, b = map(int, input().split())
    print(a*b)
Buggy python submission (verdict: Runtime Error):
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())
z_list = factorization(N)
Z = []
for z in z_list:
        for e in range(1, z[1]+1):
            Z.append(z[0]**e)
sorted(Z)
counter = 0 
if N==i:
    print(0)
    quit()
for z in Z:
    if(N%z==0):
        N = N//z
        counter += 1
print(counter)



Fixed submission:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())
z_list = factorization(N)
Z = []
for z in z_list:
        for e in range(1, z[1]+1):
            Z.append(z[0]**e)
sorted(Z)
counter = 0 
if N==1:
    print(0)
    quit()
for z in Z:
    if(N%z==0):
        N = N//z
        counter += 1
print(counter)

Buggy python submission (verdict: Runtime Error):
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())
z_list = factorization(N)
Z = []
for z in z_list:
        for e in range(1, z[1]+1):
            Z.append(z[0]**e)
sorted(Z)
counter = 0 
if N==i:
    print(0)
    quit()
for z in Z:
    if(N%z==0):
        N = N//z
        counter += 1
print(counter)

Fixed submission:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())
z_list = factorization(N)
Z = []
for z in z_list:
        for e in range(1, z[1]+1):
            Z.append(z[0]**e)
sorted(Z)
counter = 0 
if N==1:
    print(0)
    quit()
for z in Z:
    if(N%z==0):
        N = N//z
        counter += 1
print(counter)
Buggy python submission (verdict: Runtime Error):

import numpy as np;
from numba import jit




if __name__ == '__main__':
    S = input()
    if S == "ABC":
        print("ARC")
    else:
        print("ABC"

Fixed submission:
import numpy as np;
from numba import jit




if __name__ == '__main__':
    S = input()
    if S == "ABC":
        print("ARC")
    else:
        print("ABC")
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    N = int(input())
    S = input()
    cnt = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            for k in range(j+1, N):
                if (S[i] != S[j] and S[i] != S[k] and S[j] != S[k]) and j - i != k - j:
                    cnt += 1
    print(cnt)

Fixed submission:
from collections import Counter

def get_k(i, j):
    return 2*j - i

if __name__ == '__main__':
    N = int(input())
    S = input()
    C = Counter(S) 
    eq_cnt = 0
    cnt = C['R'] * C['G'] * C['B']
    for i in range(N):
        for j in range(i+1, N):
            k = get_k(i, j)
            if k >= N: continue
            if (S[i] != S[j] and S[i] != S[k] and S[j] != S[k]):
                eq_cnt += 1
    print(cnt - eq_cnt)

Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    N = int(input())
    S = input()
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                if (S[i] != S[j] and S[i] != S[k] and S[j] != S[k]) and j - i != k - j:
                    cnt += 1
    print(cnt)

Fixed submission:
from collections import Counter

def get_k(i, j):
    return 2*j - i

if __name__ == '__main__':
    N = int(input())
    S = input()
    C = Counter(S) 
    eq_cnt = 0
    cnt = C['R'] * C['G'] * C['B']
    for i in range(N):
        for j in range(i+1, N):
            k = get_k(i, j)
            if k >= N: continue
            if (S[i] != S[j] and S[i] != S[k] and S[j] != S[k]):
                eq_cnt += 1
    print(cnt - eq_cnt)
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
void print() {
    cout << endl;
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}
template <class T>
void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
using ll = long long;
const int INF = 100100100;

vector<vector<int>> A(3);

bool bingo(vector<int> B) {
    int cnt1 = 0;
    for(int b: B) {
        rep(y, 3) {
            rep(x, 3) {
                if(A[y][x]==b) {
                    ++cnt1;
                }
            }
        }
    }
    if(cnt1==3) return true;
    int cnt2 = 0;
    for(int b: B) {
        rep(y, 3) {
            rep(x, 3) {
                if(A[x][y]==b) {
                    ++cnt2;
                }
            }
        }
    }
    if(cnt2==3) return true;
    int cnt3 = 0;
    for(int b: B) {
        rep(i, 3) {
            if(b==A[i][i]) ++cnt3;
        }
    }
    if(cnt3==3) {
        return true;
    }

    int cnt4 = 0;
    for(int b: B) {
        rep(i, 3) {
            if(b==A[2-i][i]) ++cnt4;
        }
    }
    if(cnt4==3) {
        return true;
    }
    return false; 
}

int main() {
    vector<int> row(3);
    rep(i, 3) {
        rep(j, 3) {
            cin >> row[j];
        }
        A[i] = row;
    }
    int N;
    cin >> N;
    vector<int> B(N);
    rep(i, N) {
        cin >> B[i];
    }

    bool flag = bingo(B);

    if(flag) {
        print("Yes");
    }
    else {
        print("No");
    }



    return 0;
}

Fixed submission:
if __name__ == '__main__':
    A = []
    for i in range(3):
        row = list(map(int, input().split()))
        A.append(row)
    
    N = int(input())
    B = []

    for i in range(N):
        B.append(int(input())) 
    
    for i in range(3):
        cnt = 0
        for j in range(3):
            if A[i][j] in B:
                cnt += 1
        if cnt==3:
            print('Yes')
            quit()
            
    for i in range(3):
        cnt = 0
        for j in range(3):
            if A[j][i] in B:
                cnt += 1
        if cnt==3:
            print('Yes')
            quit()

    if A[0][0] in B and A[1][1] in B and A[2][2] in B:
        print('Yes')
        quit()
    
    if A[0][2] in B and A[1][1] in B and A[2][0] in B:
        print('Yes')
        quit()
    
    print('No')
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
    N, M = map(int, input().split())
    S = []
    C = []

    for i in range(M):
        s, c = map(int, input().split())
        s -= 1
        S.append(s)
        C.append(c)

    for num in range(pow(10, N-1)-1, pow(10, N)):
        st_num = str(num)
        cnt = 0
        for m in range(M):
            if int(st_num[S[m]])==C[m]:
                cnt += 1
        if cnt==M:
            print(st_num)
            quit()
    print(-1)

Fixed submission:
if __name__ == '__main__':
    N, M = map(int, input().split())
    S = []
    C = []

    for i in range(M):
        s, c = map(int, input().split())
        s -= 1
        S.append(s)
        C.append(c)

    for num in range(0, pow(10, N)):
        st_num = str(num)
        if len(str(st_num))!=N: continue
        cnt = 0
        for m in range(M):
            if int(st_num[S[m]])==C[m]:
                cnt += 1
        if cnt==M:
            print(st_num)
            quit()
    print(-1)
Buggy python submission (verdict: Runtime Error):

N = int(input())
X = list(map(int, input().split()))

minX = min(X)
maxX = max(X)

HP = []
for p in range(minX, maxX):
    hp = 0
    for x in X:
        hp += (x-p)**2
    HP.append(hp)

print(min(HP))
    

Fixed submission:

N = int(input())
X = list(map(int, input().split()))

minX = min(X)
maxX = max(X)
if minX==maxX:
    print(0)
    quit()

HP = []
for p in range(minX, maxX):
    hp = 0
    for x in X:
        hp += (x-p)**2
    HP.append(hp)

print(min(HP))

Buggy python submission (verdict: Runtime Error):

N = int(input())
X = list(map(int, input().split()))

minX = min(X)
maxX = max(X)



HP = []
for p in range(minX, maxX):
    hp = 0
    for x in X:
        hp += (x-p)**2
    HP.append(hp)

print(min(HP))
    

Fixed submission:

N = int(input())
X = list(map(int, input().split()))

minX = min(X)
maxX = max(X)
if minX==maxX:
    print(0)
    quit()

HP = []
for p in range(minX, maxX):
    hp = 0
    for x in X:
        hp += (x-p)**2
    HP.append(hp)

print(min(HP))
Buggy python submission (verdict: Time Limit Exceeded):


N = int(input())
S = []
Sset = set()
for i in range(N):
    s = input()
    Sset.add(s)
    S.append(s)



names = [0]*len(Sset)

for i, name in enumerate(Sset):
    cnt = 0
    for s in S:
        if(name==s):
            cnt += 1
            names[i] = (name, cnt)
max = 0
for n in names:
    if max<n[1]:
        max = n[1]
ans = []
for n in names:
    if n[1]==max:
        ans.append(n[0])

ans.sort()
for a in ans:
    print(a)




Fixed submission:
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import product, combinations,permutations
from copy import deepcopy
import sys
sys.setrecursionlimit(4100000)



if __name__ == '__main__':
    N = int(input())
    S_list = []

    s_hash = dict()

    for i in range(N):
        S_list.append(input())

    for s in S_list:
        if s not in s_hash:
            s_hash[s] = 1
        else:
            s_hash[s] += 1
    max_p = 0
    max_p_name = []
    for k, v in s_hash.items():
        if max_p < v:
            max_p_name = []
            max_p = v
        if max_p == v:
            max_p_name.append(k)
    
    for p in sorted(max_p_name):
        print(p)

Buggy python submission (verdict: Time Limit Exceeded):


N = int(input())
S = []
Sset = set()
for i in range(N):
    s = input()
    Sset.add(s)
    S.append(s)



names = [0]*len(Sset)

for i, name in enumerate(Sset):
    cnt = 0
    for s in S:
        if(name==s):
            cnt += 1
            names[i] = (name, cnt)
max = 0
for n in names:
    if max<n[1]:
        max = n[1]
ans = []
for n in names:
    if n[1]==max:
        ans.append(n[0])

ans.sort()
for a in ans:
    print(a)


Fixed submission:
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import product, combinations,permutations
from copy import deepcopy
import sys
sys.setrecursionlimit(4100000)



if __name__ == '__main__':
    N = int(input())
    S_list = []

    s_hash = dict()

    for i in range(N):
        S_list.append(input())

    for s in S_list:
        if s not in s_hash:
            s_hash[s] = 1
        else:
            s_hash[s] += 1
    max_p = 0
    max_p_name = []
    for k, v in s_hash.items():
        if max_p < v:
            max_p_name = []
            max_p = v
        if max_p == v:
            max_p_name.append(k)
    
    for p in sorted(max_p_name):
        print(p)
Buggy python submission (verdict: Runtime Error):
ACGT = ['A', 'C', 'G', 'T']
S = input()
cnt = 0
max_cnt = 0
for s in S:
    if s in ACGT:
        cnt += 1
        cntList.append(cnt)
    else:
        max_cnt = max(cnt, max_cnt)
        cnt = 0
print(max_cnt)

Fixed submission:
S = input()

ACGT = ['A', 'C', 'G', 'T']
cntList = []
cnt = 0
cntList.append(cnt)
for s in S:
    if s in ACGT:
        cnt += 1
        cntList.append(cnt)
    else:
        cnt = 0
print(max(cntList))

Buggy python submission (verdict: Runtime Error):
S = input()

ACGT = ['A', 'C', 'G', 'T']
cntList = []
cnt = 0
for s in S:
    if s in ACGT:
        cnt += 1
        cntList.append(cnt)
    else:
        cnt = 0
print(max(cntList))

Fixed submission:
S = input()

ACGT = ['A', 'C', 'G', 'T']
cntList = []
cnt = 0
cntList.append(cnt)
for s in S:
    if s in ACGT:
        cnt += 1
        cntList.append(cnt)
    else:
        cnt = 0
print(max(cntList))

Buggy python submission (verdict: Runtime Error):
S = input()

ACGT = ['A', 'C', 'G', 'T']
cntList = []
cnt = 0
for s in S:
    if s in ACGT:
        cnt += 1
    else:
        cntList.append(cnt)
        cnt = 0
if max == []:
    print(0)
    quit()
print(max(cntList))


Fixed submission:
S = input()

ACGT = ['A', 'C', 'G', 'T']
cntList = []
cnt = 0
cntList.append(cnt)
for s in S:
    if s in ACGT:
        cnt += 1
        cntList.append(cnt)
    else:
        cnt = 0
print(max(cntList))

Buggy python submission (verdict: Runtime Error):
S = input()

ACGT = ['A', 'C', 'G', 'T']
cntList = []
cnt = 0
for s in S:
    if s in ACGT:
        cnt += 1
    else:
        cntList.append(cnt)
        cnt = 0

print(max(cntList))

Fixed submission:
S = input()

ACGT = ['A', 'C', 'G', 'T']
cntList = []
cnt = 0
cntList.append(cnt)
for s in S:
    if s in ACGT:
        cnt += 1
        cntList.append(cnt)
    else:
        cnt = 0
print(max(cntList))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
A = list(map(int,input().split()))
ans = 0

for i in range(k+1):
    tmp = 0
    for j in range(n):
        tmp += i ^ A[j]
    ans = max(tmp,ans)
print(ans)

Fixed submission:
# 解説の手順
# 参考:kenseiQ さん
def XXOR(N,K,A):
    # 2**10=1024>1000=10**3を利用すると、K+1<10**12+1<2*40(計算されたし)がわかる
    # つまりKを二進表記しても高々40桁（0~39で扱う）しかない
    ans = 0

    # Aの各要素を二進表記した時、b番目のビットが立っているものは何個か
    bit_stand = [len([1 for a in A if (a & 1<<b) != 0]) for b in range(40)]

    # KとXを二進表記したものを上の桁から見て行って、初めて違う数字が出てきた桁がi
    for i in range(39,-2,-1):

        # K_iは1でないといけないのでその時はcontinue（解説参照）
        if i != -1 and (K & (1<<i)) == 0: # i=-1の時はX=Kの時を扱う（この時は前半部分で条件が弾かれるので1<<(-1)が実行されてエラーになることがない）
            continue

        tmp = 0
        for e in range(39,-1,-1): # 各ビットがf(x)に貢献する値を見ていく
            bit_mask = 1<<e
            num = bit_stand[e]

            if e>i: # この桁はKと同じ
                if (bit_mask & K) == 0: # Xのi桁のビットが立っていない時
                    tmp += bit_mask * num
                else:                   # Xのi桁のビットが立ってる時
                    tmp += bit_mask * (N-num) 
            elif e==i: # Xのi桁は必ず0である（解説参照）
                tmp += bit_mask * num
            else: # ここの桁は自由に決めていい
                tmp += bit_mask * max(num,N-num)
        
        ans = max(ans, tmp)
    
    return ans


N,K = map(int,input().split())
A = list(map(int,input().split()))
print(XXOR(N,K,A))
Buggy python submission (verdict: Time Limit Exceeded):
n,p = map(int,input().split())
ans = 1

for i in range(2,p+1):
    if i>p:
        break
    count = 0
    flag = 0
    while flag == 0:
        if p//i == p/i:
            p = p//i
            count += 1
        else:
            if count >= n:
                ans *= i**(count//n)
            flag = 1
            

print(ans)
        

Fixed submission:
import collections
n,p = map(int,input().split())
ans = 1
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

c = collections.Counter(prime_factors(p))
for i in range(len(c.most_common())):
    if c.most_common()[i][1]>=n:
        ans *= int(c.most_common()[i][0]) ** (c.most_common()[i][1]//n)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = input()
length = len(N)
jogai = 0
ans = 0

def check(number):
    three = 0
    five = 0
    seven = 0
    for i in range(len(str(number))):
        if str(number)[i:i+1] == '3':
            three += 1
        elif str(number)[i:i+1] == '5':
            five += 1
        elif str(number)[i:i+1] == '7':
            seven += 1
        else:
            return False
    if three >= 1 and five >= 1 and seven >= 1:
        return True
    else:
        return False

if int(N) <= int('7'*length):
    if int(N)%2 == 0:
        for l in range(int(int(N)/2), int(int('7'*length)/2)):
            if check(2*l+1):
                jogai += 1
    elif int(N)%2 == 1:
        for l in range(int((int(N)+1)/2),int(int('7'*length)/2)):
            if check(2*l+1):
                jogai +=1

    

for i in range(1,length+1):
    ans += 3**i-3*2**i+3

print(ans-jogai)

Fixed submission:
n = int(input())

def recursive(s):
    if int(s) > n:
        return 0
    ret = 0
    if s.count('3')>0 and s.count('5')>0 and s.count('7')>0:
        ret = 1
    for c in '753':
        ret += recursive(s+c)
    return ret           

print(recursive('0'))

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
length = len(N)
jogai = 0
ans = 0

def check(number):
    three = 0
    five = 0
    seven = 0
    for i in range(len(str(number))):
        if str(number)[i:i+1] == '3':
            three += 1
        elif str(number)[i:i+1] == '5':
            five += 1
        elif str(number)[i:i+1] == '7':
            seven += 1
        else:
            return False
    if three >= 1 and five >= 1 and seven >= 1:
        return True
    else:
        return False

if int(N) <= int('7'*length):
    for l in range(int(N)+1, int('7'*length)+1):
        if check(l):
            jogai += 1

for i in range(length+1):
    ans += 3**i-3*2**i+3

print(ans-jogai-1)




Fixed submission:
n = int(input())

def recursive(s):
    if int(s) > n:
        return 0
    ret = 0
    if s.count('3')>0 and s.count('5')>0 and s.count('7')>0:
        ret = 1
    for c in '753':
        ret += recursive(s+c)
    return ret           

print(recursive('0'))

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
ans = 0

def check(number):
    three = 0
    five = 0
    seven = 0
    for i in range(len(number)):
        if number[i:i+1] == '3':
            three += 1
        elif number[i:i+1] == '5':
            five += 1
        elif number[i:i+1] == '7':
            seven += 1
        else:
            return False
    if three >= 1 and five >= 1 and seven >= 1:
        return True
    else:
        return False

for i in range(int(N)+1):
    if check(str(i)) == True:
        ans += 1

print(ans)
    

Fixed submission:
n = int(input())

def recursive(s):
    if int(s) > n:
        return 0
    ret = 0
    if s.count('3')>0 and s.count('5')>0 and s.count('7')>0:
        ret = 1
    for c in '753':
        ret += recursive(s+c)
    return ret           

print(recursive('0'))
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
li = []
countA = 1 
countB = 0

for i in range(m):
    li.append(list(map(int, input().split())))

for item in li:
    for i in range(m):
        if item[0] == li[i][0] and item[1] == li[i][1]:
            countB = 0
        elif item[0] == li[i][0]: 
            if item[1] > li[i][1]:
                countA += 1
    pr_id = str(1000000+item[0])[1:7]
    ci_id = str(1000000+countA)[1:7]
    countA = 1
    print(pr_id + ci_id)

Fixed submission:
n,m = map(int,input().split())
py = [list(map(int,input().split())) + [_] for _ in range(m)]
py.sort()
result = ['' for _ in range(m)] #ここで先にリストを作るから後から飛び飛びのインデックス指定で値を埋めていける

a = 1 #県のインデックスを表す変数
b = 1 #市の県の中でのインデックスを表す変数
for i in range(m):
    if py[i][0] != a:
        b=1
        a = py[i][0] 
        result[py[i][2]] = str(a).zfill(6) + str(b).zfill(6)
        b+=1
    else:
        result[py[i][2]] = str(a).zfill(6) + str(b).zfill(6)
        b+=1

for i in range(m):
    print(result[i])

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
li = []
countA = 1 
countB = 0

for i in range(m):
    li.append(list(map(int, input().split())))

for item in li:
    for i in range(m):
        if item[0] == li[i][0] and item[1] == li[i][1]:
            countB = 0
        elif item[0] == li[i][0]: 
            if item[1] > li[i][1]:
                countA += 1
    pr_id = str(1000000+item[0])[1:7]
    ci_id = str(1000000+countA)[1:7]
    countA = 1
    print(pr_id + ci_id)

Fixed submission:
n,m = map(int,input().split())
py = [list(map(int,input().split())) + [_] for _ in range(m)]
py.sort()
result = ['' for _ in range(m)] #ここで先にリストを作るから後から飛び飛びのインデックス指定で値を埋めていける

a = 1 #県のインデックスを表す変数
b = 1 #市の県の中でのインデックスを表す変数
for i in range(m):
    if py[i][0] != a:
        b=1
        a = py[i][0] 
        result[py[i][2]] = str(a).zfill(6) + str(b).zfill(6)
        b+=1
    else:
        result[py[i][2]] = str(a).zfill(6) + str(b).zfill(6)
        b+=1

for i in range(m):
    print(result[i])