akhauriyash/Code-Regression huggingface dataset:
from collections import deque

max = 0

tmp = []
tmp = list(map(int, input().split()))

w = tmp.pop()
h = tmp.pop()

maze = [["." for i in range(w)] for j in range(h)]

for i in range(h):
    maze[i] = list(input())

xq = deque()
yq = deque()
lq = deque()
    
for i in range(w):
    for j in range(h):

        flag = [[False for i in range(w)] for j in range(h)]
        #        print("{} {} {}".format(j,i, maze[j][i]))
        # start が壁でなければqueueにいれる
        if maze[j][i]==".":
            xq.appendleft(i)
            yq.appendleft(j)
            lq.appendleft(0)
            flag[j][i]=True

        while not len(xq)==0:
            x = xq.pop() #現在地 x
            y = yq.pop() #現在地 y
            l = lq.pop() #距離 l

            if max < l:
                max = l
            
            #行ける方向をチェックしてqueueにつむ、訪問済みにする
            #行ける方向 = 上下左右隣接、
            # なおかつ、壁じゃない、迷路の外じゃない、すでに訪問済みじゃない

            # チェックするのは4方向
            if ((x-1) >= 0 ):
                if (flag[y][x-1]==False) and (maze[y][x-1])==".":
                    xq.appendleft(x-1)
                    yq.appendleft(y)
                    lq.appendleft(l+1)
                    flag[y][x-1]=True
                
            if ((x+1) < w ):
#                print("{} {} {}".format(x, y, l))
#                print(maze[x][y])
                if flag[y][x+1]==False and maze[y][x+1]==".":
                    xq.appendleft(x+1)
                    yq.appendleft(y)
                    lq.appendleft(l+1)
                    flag[y][x+1]=True
                
            if ((y-1) >= 0):
                if flag[y-1][x]==False and maze[y-1][x]==".":
                    xq.appendleft(x)
                    yq.appendleft(y-1)
                    lq.appendleft(l+1)
                    flag[y-1][x]=True

            if ((y+1) < h):
#                print("{} {} {}".format(x, y, l))
#                print(maze[x][y])
                if flag[y+1][x]==False and maze[y+1][x]==".":
                    xq.appendleft(x)
                    yq.appendleft(y+1)
                    lq.appendleft(l+1)
                    flag[y+1][x]=True
                

print(max)

Measured memory_bytes: 3316
#include <iostream>
#include <stdio.h>
#include <cctype>
using namespace std;

int main()
{
	char ch;
	int sum[100] = {0};
	
	while(cin >> ch){
		if(!islower(ch))
			ch = tolower(ch);
		int num = ch - 'a';
		sum[num]++;
	}
	
	for(int i=0; i<26; i++)
		printf("%c : %d\n", i+'a', sum[i]);
	
	return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;



int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
#endif

  int n;
  cin >> n;
  string s;
  cin >> s;
  int l = 0;
  int r = n - 1;
  while (s[l] == 'R' && l < n) ++l;
  while (s[r] == 'W' && r >= 0) --r;
  int ans = 0;
  while (r - l >= 1 && l < n && r >= 0) {
    while (s[l] == 'R' && l < n) ++l;
    while (s[r] == 'W' && r >= 0) --r;
    if (l == n || r == -1 || r - l < 1) break;
    else {
      swap(s[l], s[r]);
      ++ans;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3772
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int sa1 = Math.abs(a-b);
		int sa2 = Math.abs(b-c);
		int sa3 = Math.abs(a-c);
		System.out.println(Math.min(sa1+sa2, Math.min( sa1+sa3, sa2+sa3)));
	}
}

Measured memory_bytes: 23764
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
s=gs
l=s.length
h={}
l.times do |i|
  h[s[i]]=1
end

c="a"
while c!="aa"
  unless h[c]
    putsend c
  end
  c=c.next
end

puts 'None'

Measured memory_bytes: 2044
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=1010;
const int M=100010;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,K,ans,cnt;
int x[M],y[M],c[M];
int sx[N],sy[N],s[N][N];
char str[N];
int main()
{
	file();
	read(n),read(K);
	For(i,1,n)
	{
		read(x[i]),read(y[i]);
		scanf("%s",str+1);
		c[i]=str[1]=='B'?1:0;
		if(((x[i]/K+y[i]/K)&1)==c[i])
		{
			//printf("diff %d\n",i);
			sx[x[i]%K]++;
			sy[y[i]%K]++;
			s[x[i]%K][y[i]%K]++;
		}
		else
		{
			//printf("same %d\n",i);
			cnt++;
			sx[x[i]%K]--;
			sy[y[i]%K]--;
			s[x[i]%K][y[i]%K]--;
		}
	}
	/*
	For(i,1,K)sx[i]+=sx[i-1],sy[i]+=sy[i-1];
	For(i,1,K)
	{
		For(j,1,K)s[i][j]+=s[i][j-1];
		For(j,1,K)s[i][j]+=s[i-1][j];
	}
	//printf("%d %d %d %d\n",cnt,sx[1],sy[0],s[1][0]);
	*/
	rFor(i,K,0)sx[i]+=sx[i+1],sy[i]+=sy[i+1];
	rFor(i,K,0)
	{
		rFor(j,K,0)s[i][j]+=s[i][j+1];
		rFor(j,K,0)s[i][j]+=s[i+1][j];
	}
	ans=cnt;
	For(i,0,K)
		For(j,0,K)
		{
			chkmax(ans,cnt+sx[i]+sy[j]-s[i][j]*2);
			chkmax(ans,n-(cnt+sx[i]+sy[j]-s[i][j]*2));
		}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 5376
program DBS
 implicit none
 integer::N=0,K=0,s=0,i,ishota,ishotb,p=0,q=0
 integer,allocatable::a(:)
 read(*,*)N,K
 allocate(a(N))
 read(*,*)(a(i),i=1,N)
 do ishota=1,N
  do ishotb=1,N-1
   if(a(ishotb)>a(ishotb+1))then
    p=a(ishotb)
    q=a(ishotb+1)
    a(ishotb)=q
    a(ishotb+1)=p
   end if
  end do
 end do
 s=sum(a(1:K))
 print'(i0)',s
 deallocate(a)
end program DBS

Measured memory_bytes: 2932
#include<iostream>
#include<cmath>
using namespace std;

int main(){
	int x,y,n[4],m[4];
	int h,b,i,j;
	
	while(1){
		cin >> x >> y;
		if(x+y==0) break;
		
		h=0; b=0;
		
		for(i=3; i>0; i--){
			n[i]=x/pow(10,i);
			x-=n[i]*pow(10,i);
			m[i]=y/pow(10,i);
			y-=m[i]*pow(10,i);
		}
		n[0]=x; m[0]=y;
		
		for(i=0;i<4;i++){
			if(n[i]==m[i]) h++;
			else for(j=0;j<4;j++){
				if(n[i]==m[j]) b++;
			}
		}
		
		cout << h << " " << b << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
using namespace std;

int main() {
    string s;
    cin >> s;
    cout << "ABC"+s << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;
 
public class Main {

  static int n;
  static int a[];

  public static boolean check(int i, int k, int m) {
    if (k==m) return true;
    if (m<k || i==n) return false;

    if (check(i+1, k, m)) return true;
    if (check(i+1, k + a[i], m)) return true;

    return false;
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    n = Integer.parseInt(sc.next());
    a = new int[n];
    for (int i=0; i<n; i++)
      a[i] = Integer.parseInt(sc.next());

    int q = Integer.parseInt(sc.next());
    for (int i=0; i<q; i++) {
      int m = Integer.parseInt(sc.next());
      if (check(0, 0, m)) 
        System.out.println("yes");
      else
        System.out.println("no");
    }
  }
}

Measured memory_bytes: 19612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  
  string s;
  cin >> s;
 
  if(a<3200){
    cout << "red" << endl;
  }
  else{
    cout << s << endl;
  }
    
    
  
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int length = sc.nextInt();
		int width = sc.nextInt();
		System.out.println(String.valueOf(length * width) + " " + String.valueOf(length * 2 + width * 2));
	}
}

Measured memory_bytes: 17156
i = input()
i = i.split(" ")
n = int(i[0])
y = int(i[1])
y = y / 1000
cn = []

for c in range(int(((y-n) // 9))+1):
  if (int((y-n-9*c)) % 4) == 0:
    cn.append([int((y-n-9*c) / 4), c])
  else:
    pass

if(len(cn) == 0):
  rs = [-1, -1, -1]
else:
  rs = []
  for j in cn:
    a = n - j[0] - j[1]
    if a >= 0:
      rs = [a, j[0], j[1]]
      break
    else:
      pass
  
  if len(rs) != 3:
    rs = [-1, -1, -1]
  else:
    pass
    
print(str(rs[2]) + " " + str(rs[1]) + " " + str(rs[0]))

Measured memory_bytes: 3064
A, B = map(int, input().split())
x = range(1,10)
y = range(10)
count = 0
for p in x:
    for q in y:
        for r in y:
            sakasama = int(str(p)+str(q)+str(r)+str(q)+str(p))
            if A <= sakasama <= B:
                count += 1
print(count)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
int main(){
  char c,str1[2]="0",str2[2]="1",str[100];
  int d;
  while((c=getchar())!='\n'){
    d= strlen(str);
    if(c=='0') strcat(str,str1);
    if(c=='1') strcat(str,str2);
    if(c=='B'){
      if(d!=0){
        str[d-1]='\0';
      }
    }
  }
  printf("%s\n",str);
  return 0;
}
  

Measured memory_bytes: 1468
# coding: utf-8

import numpy as np

if __name__=="__main__":
    s = input().replace("\n", "")
    n = len(s)
    ss = ""
    if n%2 == 1:
        s = s[0:n-1]
        n = len(s)
    elif n%2 == 0:
        s = s[0:n-2]
        n = len(s)

    for i in list(range(0,n,2)):
        ss = s[0:n-i]
        m = len(ss)
        if ss[0:int(m/2)] == ss[int(m/2):m]:
            print(len(ss))
            break



Measured memory_bytes: 12392
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

n=int(input())
a=list(map(int,input().split()))

left=[0]*(n+1)
right=[0]*(n+1)
left[0]=sum(a[:n])
right[n]=sum(a[n+n:])

mae,usi=a[:n],list(map(lambda x: x*-1,a[n+n:]))

heapq.heapify(mae)
heapq.heapify(usi)

for i in range(n):
    tmp=heapq.heappushpop(mae,a[n+i])
    left[i+1]=left[i]+a[n+i]-tmp
    tmp=heapq.heappushpop(usi,-a[n+n-i-1])
    right[n-i-1]=right[n-i]+a[n+n-i-1]+tmp
# print(mae)
# print(left)
# print(right)
ans=-float('inf')
for i in range(n+1):
    ans=max(ans, left[i]-right[i])
print(ans)

Measured memory_bytes: 123728
# coding: utf-8

def f(n):
    return (n*8+32)*6*10**(n-2)-5

i=2
count=0
s=int(input())
while 1:
    if count+f(i)<s:
        count+=f(i)
    else:
        break
    i+=1
j=0
x=10**(i-1)-9
tmp=(s-count)//(i*8+32)
count-=(5 if tmp!=0 else 0)
count+=tmp*(i*8+32)
x+=tmp*15
fzbz=''
while len(fzbz)<=s-count+100:
    fzbz+=('FizzBuzz' if x%15==0 else 'Fizz' if x%3==0 else 'Buzz' if x%5==0 else str(x))
    x+=1
print(fzbz[s-count-1:s-count-1+20])


Measured memory_bytes: 5604
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 1000006
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
typedef long long ll;
#define P 1000000007
int n , q;
int A[MAXN] , B[MAXN];
void solve() {
    cin >> n;
    rep( i , 1 , n ) {
        scanf("%d",A + i);
        B[A[i]] ++;
    }
    per( i , 1000000 , 1 ) for( int j = i + i ; j <= 1000000 ; j += i ) B[j] += B[i];
    int ans = 0;
    rep( i , 1 , n ) if( B[A[i]] == 1 ) ++ ans;
    printf("%d\n",ans);
}

signed main() {
//    int T;cin >> T;while( T-- ) solve();
    solve();
}


Measured memory_bytes: 8524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	//数時間考えたがこれはどうなの
	ll X, Y;
	cin >> X >> Y;

	if (abs(X - Y) <= 1) co("Brown");
	else co("Alice");

	Would you please return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
 
class Space {
public:
    int X, Y, Z;
    const int dx[13] = { 0,1,1,1,0,0,-1,-1,-1,1,1,1,0 };
    const int dy[13] = { 1,1,1,1,1,1,1,1,1,0,0,0,0 };
    const int dz[13] = { 0,-1,0,1,-1,1,-1,0,1,-1,0,1,1 };
    vector<vector<vector<int>>> P;
    vector<vector<int>> S;
    Space(int X, int Y, int Z) :X(X), Y(Y), Z(Z) {
        P = vector<vector<vector<int>>>(X, vector<vector<int>>(Y, vector<int>(Z, -1)));
        S = vector<vector<int>>(X, vector<int>(Y, 0));
    }
    bool inrange(int x, int y, int z) {
        return 0 <= x&&x < X && 0 <= y && y < Y && 0 <= z && z < Z;
    }
    int count(int x, int y, int z, int d, int t, int r) {
        if (P[x][y][z] != t)return 0;
        int nx = x + dx[d] * r, ny = y + dy[d] * r, nz = z + dz[d] * r;
        return inrange(nx, ny, nz) ? count(nx, ny, nz, d, t, r) + 1 : 1;
    }
    void update(int x, int y, int value) {
        P[x][y][S[x][y]++] = value;
    }
    int query(int x, int y, int turn, int M) {
        update(x, y, turn);
        int ret = 0;
        for (int d = 0; d < 13; d++) {
            int cnt = 0;
            cnt += count(x, y, S[x][y] - 1, d, turn, 1);
            cnt += count(x, y, S[x][y] - 1, d, turn, -1);
            cnt--;
            if (cnt >= M)
                return turn;
        }
        return -1;
    }
};
 
 
 
signed main() {
    for (int N, M, P; cin >> N >> M >> P&&N;) {
        Space S(N, N, N);
        vector<int> x(P), y(P);
        rep(i, 0, P) {
            cin >> x[i] >> y[i];
            x[i]--, y[i]--;
        }
        bool draw = true;
        rep(i, 0, P) {
            int res = S.query(x[i], y[i], i & 1, M);
            if (res == 1) {
                cout << "White " << i + 1 << endl;
                draw = false;;
                break;
            }
            else if (res == 0) {
                cout << "Black " << i + 1 << endl;
                draw = false;
                break;
            }
        }
        if (draw)cout << "Draw" << endl;
    }
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;

long long MOD=1000000007;

int main(){
	int N;
	cin >> N;
	vector<long long> A(N);
	for(auto &i:A)cin >> i;
	
	long long ans=0;
	
	for(int k=0;k<60;k++){
		long long t=(1LL<<k);
		int x=0,y=0;
		for(int i=0;i<N;i++){
			if((A[i]&t)==t)x++;
			else y++;
		}
		t%=MOD;
		t*=x;
		t%=MOD;
		t*=y;
		t%=MOD;
		ans+=t;
		ans%=MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ii pair <int , int>
#define is pair <int, string>
#define ll long long
#define mx 100000
#define sf scanf
#define sf(n) scanf("%d",&n)
#define pf printf
using namespace std;
vector <int> v;

/*int intConvert(string s){
    int n;
    stringstream geek(s);
    geek >> n;
    return n;
}*/

/*string strConvert(int n){
    string s;
    stringstream ss;
    ss << n;
    s=ss.str();
    return s;
}*/


int main(){
    int a,b,c;
    scanf("%d %d %d",&a, &b, &c);
    
    int ans=a+b+c;
    if(ans>=22) pf("bust\n");
    else pf("win\n");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>


using namespace std;

#define fastio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()


void go(){
	int n;
	cin >> n;
	unordered_map<string,int> b;
	for(int i=0;i<n;i++) {
		string s;
		cin >> s;
		b[s]++;
	}
	int t;
	cin >> t;
	for(int i=0;i<t;i++) {
		string s;
		cin >> s;
		b[s]--;
	}
	int ans=0;
	for(auto p : b) {
		if(p.se>ans) ans=p.se;
	}
	cout << ans;
	
}
int main(){
   fastio();
   go();

   return 0;
}




Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;

#define int long long
typedef pair<double, string> P;

signed main() {
	int n;
	while ( cin >> n, n ) {
		vector<P> v;
		for ( int i = 0; i < n; i++ ) {			
			string name;
			cin >> name;			
			int p, a, b, c, d, e, f, s, m;
			cin >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			int come = f*m*s - p;
			int hour = a+b+c + (d+e)*m;
			v.push_back(P(-(double)come/(double)hour, name));			
		}

		sort(v.begin(), v.end());
		for ( int i = 0; i < n; i++ ) {
			cout << v[i].second << endl;
		}
		cout << '#' << endl;
		
	}
	return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>

#define fi first
#define se second
#define mkp std::make_pair

typedef std::pair <int, int> pii;

const int kN = 1e5 + 5;

int n, fa[kN];
std::queue <pii> que;
std::set <int> E[kN];
std::map <int, int> cnt[kN];
int Find(int x) { return fa[x] == x ? x : fa[x] = Find(fa[x]); }
bool Merge(int u, int v) {
	u = Find(u), v = Find(v);
	if(u == v) return false;
	if(E[u].size() < E[v].size()) std::swap(u, v);
	for(auto i : E[v]) if(i != u) {
		E[u].insert(i); ++cnt[u][i];
		if(cnt[u][i] >= 2) que.push(mkp(u, i));
		E[i].erase(v); --cnt[i][v];
		E[i].insert(u); ++cnt[i][u];
	//	if(cnt[i][u] >= 2) que.push(mkp(u, i));
	}
	fa[v] = u;
	return true;
}
void Print() {
	for(int i = 1; i <= n; ++i) if(i == Find(i)) {
		printf("Cur[%d] = ", i);
		for(auto j : E[i]) printf("%d ", j);
		printf("\n");
	}
}
bool Solve() {
	int res = n - 1;
//	Print();
	while(!que.empty()) {
		pii cur = que.front(); que.pop();
	//	printf("%d %d\n", cur.fi, cur.se);
	//	fflush(stdout);
		res -= Merge(cur.fi, cur.se);
	//	Print();
	}
	return !res;
}

int main() {
//	freopen("e.out", "w", stdout);
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) fa[i] = i;
	for(int i = 1; i < 2 * n - 1; ++i) {
		int u, v; scanf("%d%d", &u, &v);
		E[u].insert(v); E[v].insert(u);
		++cnt[u][v]; ++cnt[v][u];
		if(cnt[u][v] >= 2) {
			que.push(mkp(u, v));
		}
	}
	printf(Solve() ? "YES\n" : "NO\n");
	return 0; 
}

Measured memory_bytes: 86760
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
    int N = 0;
    cin >> N;
    vector<vector<int> > A(2,vector<int>(N,0));
    for(int i = 0; i < N; i++) {
        cin >> A.at(0).at(i);
    }
    for(int i = 0; i < N; i++) {
        cin >> A.at(1).at(i);
    }
    for(int i = 0; i < N - 1; i++) {
        A.at(0).at(i + 1) += A.at(0).at(i);
        A.at(1).at(N - 2 - i) += A.at(1).at(N - 1 - i);
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        //cout << A.at(0).at(i) + A.at(1).at(i) << endl;
        ans = max(ans,A.at(0).at(i) + A.at(1).at(i));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
#include<algorithm>
#include<string>
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
 
int main(){
    
    llong a,b,x;

    cin >> a >> b >> x;

    if(a%x==0){
        cout << b/x - a/x + 1 << endl;
    }
    else {
        cout << b/x - a/x << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef tuple<int,int,int,int> T;
int main(){
    int h,w,k,sx,sy,gx,gy;
    cin>>h>>w>>k>>sx>>sy>>gx>>gy;
    vector<vector<char>>c(h+2,vector<char>(w+2));
    for(int i=0;i<=h+1;i++){
        for(int j=0;j<=w+1;j++){
            if(i==0 || i==h+1 || j==0 || j==w+1)c[i][j]='@';
            else cin>>c[i][j];
        }
    }
    h+=2;
    w+=2;
    int d[h][w][4];//0:↓ 1:→ 2:↑ 3:←
    int use[h][w][4];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            for(int k=0;k<4;k++){
                d[i][j][k]=10000000;
                use[i][j][k]=0;
            }
        }
    }
    priority_queue<T,vector<T>,greater<T>>q;
    for(int i=0;i<4;i++){
        d[sx][sy][i]=0;
        q.push({0,sx,sy,i});
    }
    while(q.size()){
        T t=q.top();
        q.pop();
        int dist=get<0>(t),x=get<1>(t),y=get<2>(t),az=get<3>(t);
        //cout<<dist<<" "<<x<<" "<<y<<" "<<az<<endl;
        if(use[x][y][az])continue;
        use[x][y][az]=1;
        int turned_dist=(dist+k-1)/k*k;
        if(x==gx && y==gy){
            cout<<turned_dist/k<<endl;
            return 0;
        }
        //方位の変更
        if(d[x][y][(az+1)%4]>turned_dist){
            d[x][y][(az+1)%4]=turned_dist;
            q.push({turned_dist,x,y,(az+1)%4});
        }
        if(d[x][y][(az+3)%4]>turned_dist){
            d[x][y][(az+3)%4]=turned_dist;
            q.push({turned_dist,x,y,(az+3)%4});
        }
        //移動
        if(az==0 && c[x+1][y]=='.' && d[x+1][y][0]>dist+1){
            d[x+1][y][0]=dist+1;
            q.push({dist+1,x+1,y,0});
        }
        if(az==1 && c[x][y+1]=='.' && d[x][y+1][1]>dist+1){
            d[x][y+1][1]=dist+1;
            q.push({dist+1,x,y+1,1});
        }
        if(az==2 && c[x-1][y]=='.' && d[x-1][y][2]>dist+1){
            d[x-1][y][2]=dist+1;
            q.push({dist+1,x-1,y,2});
        }
        if(az==3 && c[x][y-1]=='.' && d[x][y-1][3]>dist+1){
            d[x][y-1][3]=dist+1;
            q.push({dist+1,x,y-1,3});
        }
    }
    cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 99964
<?php
  
  $s = trim(fgets(STDIN));
  $s = str_replace(array("\r\n","\r","\n"), '', $s);
  $s = explode(" ", $s);

if ($s[0] <= $s[1]) {
  echo 'unsafe';
} else {
   echo 'safe';
 }
  
 ?>

Measured memory_bytes: 16132
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;



Node treeSearch(Node x, int k){
  while(x!=NIL&&k!=x->key){
    if(k<x->key)
      x=x->left;
    else
      x=x->right;
  }
    return x;
  
}



void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key)
      x=x->left;
    else
      x=x->right;
  }

  z->parent=y;

  if(y==NIL)
    root=z;
  else if(z->key < y->key)
    y->left=z;
  else
    y->right=z;


}


void inorder(Node x){
  if(x!=NIL){
    inorder(x->left);
    printf(" %d",x->key);
    inorder(x->right);
  }
}

void preorder(Node x){
  if(x!=NIL){
    printf(" %d",x->key);
    preorder(x->left);
    preorder(x->right);
  }
  
}

int main(){
  int r, i, x;
  char com[20];
  scanf("%d", &r);

  for ( i = 0; i < r; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 19364
//バケット法で解決
#include <bits/stdc++.h>
using namespace std;

int main(){
  long long n , k , q , a ;
  cin >> n >> k >> q ;
  vector<long long> baketu(210000);
  for(int i=0;i<q;i++){
    cin >> a;
    baketu[a-1]++;
  }
  for(int i=0;i<n;i++){
    if(k+baketu[i]-q>0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}
  


Measured memory_bytes: 4840
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Data{
    int A;
    string S;
    
    bool operator<( const Data& right ) const {
        return A == right.A ? S < right.S : A < right.A;
        //return A < right.A;
    }
};

int Func(){
    int x = 0;
    return x;
}

int main(){
    int N;
    vector<int> b{};
    
    cin >> N;
    for (int i=0;i<N;i++) {
        int temp;
        cin >> temp;
        b.push_back(temp);
    }
    
    vector<int> result{};
    for (int i=0;i<N;i++) {
        int flag = 0;
        for (int j=0;j<b.size();j++) {
            if (b[b.size()-1-j]==b.size()-1-j+1) {
                result.push_back(b[b.size()-1-j]);
                b.erase(b.begin()+b.size()-1-j);
                flag = 1;
                break;
            }
        }
        if (flag==0) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    for (int i=0;i<result.size();i++) {
        cout << result[result.size()-1-i] << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
int main(){
  FIO;
  // ifstream cin("input");
  ll n;
  cin>>n;
  ll ans=0;
  for(ll i=1;i<=n;i++){
    if(i%3==0 || i%5==0){

    }else{
      ans+=i;
    }
  }
  cout<<ans<<endl;
  return 0;  
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
#define LIM 100000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int n;
  while(true){
  cin >> n;
  if(n == 0)break;
  vector<int> vec;
  rep(i,n){
    int val;
    cin >> val;
    vec.pb(val);
  }
  if(n == 1){
    cout << 0 << endl;
    continue;
  }
  sort(all(vec));
  int sum[n+2];
  ll total = vec[0];
  sum[1] = vec[0];
  for(int i=2;i<n;i++){
    sum[i] = sum[i-1]+vec[i-1];
    total += sum[i];
  }
  cout << total << endl;
  }
return 0;
}

Measured memory_bytes: 1364
#input = sys.stdin.readline

def main():
    N, K = map(int,input().split())
    A = list(map(int,input().split()))
    A = [0] +A  #transporter
    visited = [0] * (N+1)
    town = 1
    cycle = 0
    for i in range(1,K+1):
        town = A[town]
        if visited[town] ==0:
            visited[town] = i
        else:
            cycle = i - visited[town]
            place = (K - visited[town]) % cycle + visited[town]
            print(visited.index(place))
            exit()
    print(town)




if __name__ == "__main__":
    main()

Measured memory_bytes: 32336
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
#include <bitset> // bitset
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int N;
    cin >> N;
    vi data(N);
    for (int i = 0; i < N; i++) {
        cin >> data[i];
    }
    vi ans(N, 0);
    int ansa = 0;
    for (int i = N - 1; i >= 0; i--) {
        int count = 0;
        int max = floor(N / (i + 1)) * (i + 1) - 1;
        for (int j = max; j >= i; j -= i + 1) {
            count += ans[j];
        }
        count %= 2;
        if (count != data[i]) {
            ans[i]++;
            ansa++;
        }
    }
    cout << ansa << endl;
    for (int i = 0; i < N; i++) {
        if (ans[i] == 1) {
            cout << i + 1 << " ";
        }
    }
    cout << endl;
}


Measured memory_bytes: 4788
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	cout << (a - 1) + (a <= b ? 1 : 0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define float double
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define all(v) (v).begin(),(v).end()
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using int32 = int32_t; using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vc = vector<char>; using vvc = vector<vc>;
using vf = vector<float>; using vvf = vector<vf>; using vd = vector<double>; using vvd = vector<vd>;
using str = string; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pff = pair<float, float>; using pdd = pair<double, double>;
using psl = pair<string, ll>; using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7; static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
#define FASTCIN() cin.tie(0);ios::sync_with_stdio(false);
#ifdef IMPORT_SAMPLE
#define DEBUG_IMPORT(file) vs args(argv, argv+argc);str sample = make_sample(args, file);ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#else
#define DEBUG_IMPORT(file)
#endif
static inline int ord(char c) {return (int)c;}
static inline char chr(int n) {return (char)n;}
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}

bool first_greater(const pii& left, const pii& right) {
    return left.first > right.first;
}

int32 main(int32 argc, char* argv[]) {
    FASTCIN();
    DEBUG_IMPORT("sample-1");


    int N; cin>>N;
    vi X(N), L(N); REP(i,N) cin>>X[i]>>L[i];

    vector<pii> se;
    REP(i,N)
        se.emplace_back(mkpr(X[i]-L[i], X[i]+L[i]));

    sort(all(se), first_greater);
    reverse(all(se));
    
    int cnt = 1;
    int x = se[N-1].first;
    for(int i = N-2; i>=0; i--) {
        if (se[i].second <= x) {
            x = se[i].first;
            cnt += 1;
        }
    }

    int ans = cnt;
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3956
'use strict'
function Main(input) {
    input = input.split(' ');
    let age = parseInt(input[0], 10);
    let value = parseInt(input[1], 10);	
  	let price = 0;
	if(age > 5 && age < 13){
    	price = value/2
    }else if(age >= 13){
    	price = value
    }
    console.log('%d',price);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9420
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, b, a) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;

struct CombineSmall {
  int m;
  vector<vector<int>> F;
  CombineSmall(int n, int m) : m(m), F(n) { for (int i = 1; i < n; i++) F[i].resize(i + 1); }
  int com(int n, int k) {
    return !k ? 1 : k > n ? 0 : k + k > n ? com(n, n - k)
      : F.at(n)[k] ? F[n][k] : F[n][k] = (com(n - 1, k) + com(n - 1, k - 1)) % m;
  }
};

const int N = 3000;
int p;

int main() {
  cin >> p;
  vector<int> b(p);
  CombineSmall cb(p, p);
  for (int j = 0; j < p; j++) {
    int aj;
    cin >> aj;
    if (!aj) continue;
    vector<int> pa(p);
    pa[0] = 1;
    for (int i = 1; i < p; i++) pa[i] = 1LL * pa[i - 1] * j % p;
    b[0] = (b[0] + 1) % p;
    for (int i = 0; i < p; i++) {
      int cof = 1LL * cb.com(p - 1, i) * pa[p - 1 - i] % p;
      if (~(p - 1 - i) & 1) cof = p - cof;
      b[i] = (b[i] + cof) % p;
    }
  }
  for (int i = 0; i < p; i++) printf("%d%c", b[i], " \n"[i+1==p]);
}


Measured memory_bytes: 18048
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <unordered_set>

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

#define MAX_N   (100000)                  // 10^5
#define BASE    (1000000000 + 7)          // 10^9 + 7
#define INFI    (1000000000 + 7)          // 10^9 + 7
#define INFL    (1000000000000000000 + 7) // 10^18 + 7

int N;
unordered_set<int> G[MAX_N];
bitset<MAX_N> V(0);

void make_tree(int v) {
  for (auto u: G[v]) {
    G[u].erase(v);
    make_tree(u);
  }
}

void remove_match(int v) {
  for (auto u : G[v]) {
    remove_match(u);
    if (V[v] && V[u]) V[v] = V[u] = 0;
  }
}

string winner() {
  int root = 0;
  make_tree(root);
  remove_match(root);
  return V.none()? "Second": "First";
}

int main() {
  cin >> N;

  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].insert(b); G[b].insert(a);
    V.set(a); V.set(b);
  }

  string ans = winner();
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 16256
N, M = map(int, input().split())
a = [0] * N
b = [0] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())
c = [0] * M
d = [0] * M
for i in range(M):
    c[i], d[i] = map(int, input().split())
for i in range(N):
    mi = 1000000000
    mid = -1
    for j in range(M):
        di = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if mi > di:
            mi = di
            mid = j + 1
    print(mid)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define sz(s) (ll)s.size()
#define print(d) cout << fixed << setprecision(15) << d;
#define pii pair<ll,ll>
#define ppii pair<pii,pii>
#define ff first
#define ss second
const ll MOD = 1000000007;
const ll MAXN = 1e6 + 5;
const ll inf = 2e18;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
tree_order_statistics_node_update> ord_set;
#define debug(x) cerr << #x << " = " << x << endl


ll power(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 




int main()
{
    fast
   // #ifndef ONLINE_JUDGE
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
   // #endif
    ll n;
    cin >> n;
    string arr[n];
    map<string,ll>m;
    fr(i,0,n)
    {
        cin >> arr[i];
        ll t;
        cin >> t;
        m[arr[i]]=t;
    }
    string s;
    cin >> s;
    bool x=0;
    ll ans=0;
    fr(i,0,n)
    {
        if(x)ans+=m[arr[i]];
        if(arr[i]==s)x=1;
    }
    cout << ans ;
    return 0;
}










Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    // insert code here...
    int n, ac=0, wa=0,tle=0,re=0;
    cin >> n;
    
    string s[n];
    
    for(int i=0; i<n; i++){
        cin >> s[i];
        
        if(s[i] == "AC") ac++;
        else if (s[i] == "WA") wa++;
        else if (s[i] == "TLE") tle++;
        else if (s[i] == "RE") re++;
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}

Measured memory_bytes: 6680
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

unsigned long long b[100], c[100][31];
#define bit(n) (1LL<<(n))

int main()
{
    int n;
    while (cin>>n, n) {
        memset(c, 0, sizeof(c));
        for(int i=0;i<n;++i) {
            int m; cin>>m;
            b[i]=0;
            while (m--) {
                int t; cin>>t; b[i]|=bit(t);
            }
            c[i][0]=bit(i);
        }
        unsigned res=-1u;
        for(unsigned d=1;d<=30;++d) {
            for(int i=0;i<n;++i) {
                c[i][d]=c[i][d-1];
                if (b[i]&bit(d)) for(int j=0;j<n;++j) if ((b[j]&bit(d))) c[i][d]|=c[j][d-1];
            }
            for(int i=0;i<n;++i) if (c[i][d]==bit(n)-1) res=min(res, d);
        }
        cout<<(int)res<<endl;
    }
}

Measured memory_bytes: 1192
macro_rules! get_one {
    ($t:ty) => {{
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse::<$t>().unwrap()
    }};

    ($t:ty; $n:expr) => {
        (0..$n).map(|_| get_one!($t)).collect::<Vec<_>>()
    };
}

fn main() {
    let a = get_one!(char);
    if 'a' <= a  && a <= 'z' {
        println!("a");
    } else {
        println!("A");
    }
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

ll n, m;
string s, t;

ll lcm(ll a, ll b) {
  ll temp = __gcd(a, b);
  return a / temp * b;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  //stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  //if (stream2 == NULL) return 0;
#endif
  cin >> n >> m;
  cin >> s >> t;
  ll l = lcm(n, m);
  map<ll, char> mp;
  for (int i = 0; i < (int)s.size(); i++) {
    mp[l / n * i] = s[i];
  }
  for (int i = 0; i < (int)t.size(); i++) {
    if (mp.find(l / m * i) == mp.end()) {
      mp[l / m * i] = t[i];
    } else {
      char temp = mp[l / m * i];
      if (temp != t[i]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << l << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}


Measured memory_bytes: 10880
N, D = map(int, input().split()) 
ps = []
for _ in range(N):
    p = [int(i) for i in input().split()]
    ps.append(p)

n = 0
for p in ps:
    if p[0]**2 + p[1]**2 <= D**2: 
        n += 1
print(n)

Measured memory_bytes: 42380
#include<iostream>
using namespace std;
#include <math.h> 

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){

	int n,count,tmp;
	cin >> n;
	
	count = 0;
	for(int i=0;i<n;i++){
		cin >> tmp;
		if(IsPrime(tmp)){
			count++;
		}
	}

	cout << count << endl;
	
	return 0; 
}


Measured memory_bytes: 3100
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
#define CEIL(A,B) ((A)+(B)-1)/(B)
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N, T;
ll dp[3010][3010];
vector<pair<ll, ll>> X;

int main() {
    fastio();
    cin >> N >> T;
    REP(i, N) {
        pair<ll, ll> a;
        cin >> a.first >> a.second;
        X.push_back(a);
    }
    sort(ALL(X));
    ll ans = X[0].second;
    REP(i, T) dp[0][i] = 0;
    FOR(i, 1, N) {
        ll A = X[i-1].first;
        ll B = X[i-1].second;
        FOR(t, A, T - 1) {
            dp[i][t] = max(dp[i - 1][t], dp[i - 1][t - A] + B);
        }
        FOR(j, i, N - 1) {
            ans = max(ans, dp[i][T - 1] + X[j].second);
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	int n;
	cin >> n;
	cout << n*800 - (n/15)*200 << "\n";	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> value(3, 0);
  vector<bool> change(3, false);
  if(2 <= N) value.at(N-1) = 1;
  rep(i, M){
    int s;
    int c;
    cin >> s >> c;
    if(change.at(N-s) == false){
      value.at(N-s) = c;
      change.at(N-s) = true;
    }
    else if(value.at(N-s) == c){
      value.at(N-s) = c;
    }
    else{
      cout << -1 << endl;
      return 0;
    }
  }
  int ans = value.at(0) + value.at(1)*10 + value.at(2)*100;
  int tmp = ans;
  int digit = 0;
  if(tmp < 10){
    digit = 1;
  }
  else if (tmp < 100){
    digit = 2;
  }
  else{
    digit = 3;
  }
  if(digit!=N) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int n, w;
int wi[100005];
long long vi[100005];
long long dp[100005];

void solve(){
	for (int i = 1; i <= n; i++){
		for (int j = w; j >= wi[i]; --j){
			dp[j] = max(dp[j], dp[j-wi[i]] + vi[i]);
		}
	}
	cout << dp[w] << '\n';
}
int main(){
	cin >> n >> w;
	for (int i = 1; i <= n; i++)
		cin >> wi[i] >> vi[i];
	solve();
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
using namespace std;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
bool flag_table[40][40][4];
int table[40][40];
int ans,cnt,w,h;
typedef pair<int,int> P;
queue<P> que;
int bfs(){
    que.push(P(0,0));
    table[0][0] = 1;
    while(!que.empty()){
        P tmp = que.front();
        que.pop();
        if(tmp.first == h-1 && tmp.second == w-1) break;
        rep(i,4){
            int ny = tmp.first+dy[i];
            int nx = tmp.second+dx[i];
            if(ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
            if(table[ny][nx] != -1 || flag_table[tmp.first][tmp.second][i] == true) continue;
            table[ny][nx] = table[tmp.first][tmp.second] + 1;
            que.push(P(ny,nx));
        }
    }
    return table[h-1][w-1];
}
int main(){
    while(cin >> w >> h){
        if(w == 0 && h == 0) break;
        memset(flag_table,false,sizeof(flag_table));
        memset(table,-1,sizeof(table));
        rep(i,h){
            rep(j,w-1){
                int n; cin >> n;
                if(n != 1) continue;
                flag_table[i][j][0] = true;
                flag_table[i][j+1][2] = true;
            }
            if(i == h-1) continue;
            rep(j,w){
                int n; cin >> n;
                if(n != 1) continue;
                flag_table[i][j][1] = true;
                flag_table[i+1][j][3] = true;
            }
        }
        if(bfs() == -1) cout << 0 << endl;
        else cout << bfs() << endl;
    }
}



Measured memory_bytes: 3132