akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int n;
main()
{
	while(cin>>n,n)
	{
		char a[111];
		for(int i=0;i<n;i++)cin>>a[i];
		int cnt[111]={},max1=0,max2=0;
		char maxa='0';
		bool f=0;
		for(int i=0;i<n;i++)
		{
			cnt[a[i]]++;
			if(max1<cnt[a[i]])
			{
				if(maxa!=a[i])max2=max1;
				max1=cnt[a[i]];
				maxa=a[i];
			}
			else if(max2<cnt[a[i]])max2=cnt[a[i]];
			if(max1>max2+n-i-1)
			{
				cout<<maxa<<" "<<i+1<<endl;
				f=1;
				break;
			}
		}
		if(!f)cout<<"TIE"<<endl;
	}
}



Measured memory_bytes: 3056
k = int(input())

from collections import deque
que = deque()

for i in range(k+9):
	if i < 9:
		que.append(i+1)
	else:
		x = que.popleft()
		if x % 10 != 0:
			que.append(10*x + (x%10) - 1)
		que.append(10*x + (x%10))
		if x % 10 != 9:
			que.append(10*x + (x%10) + 1)
print(x)


Measured memory_bytes: 40816
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
  int i, j;
  char str[21], rev[21];

  scanf("%s", str);
  i = 0; j = 0;
  while(str[i] != '\0') i++;
  i--;
  while(i >= 0){
    rev[j] = str[i];
    i--; j++;
  }
  rev[j] = '\0';

  printf("%s\n", rev);

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int flag=0;
  int ans=0;
  if(a>c)
    flag=a;
  else
    flag=c;
  if(b<=c){
    ans=0;
  }else if(d<=a){
    ans=0;
  }else{if(b>d)
    ans=d-flag;
  else
    ans=b-flag;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VII vector< vector<int> >
#define VLL vector< vector<LL> >
#define VS  vector<string>
#define VSS vector< vector<string> >
#define PII pair<int,int>
#define PIS pair<int,string>
#define PSI pair<string,int>
#define PLL pair<LL,LL>
const LL MOD = 1000000007;
const LL INF = 1e16;
LL facctorialMethod(int k);
int main(){
    LL n,count;
    cin >> n;
    VL a(n);
    count = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if((i+1)%2==1 && a[i]%2==1) {
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


Measured memory_bytes: 3628
import collections

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

for i in range(N):
    X[i] -= A

sums = collections.Counter([0,X[0]])

for i in X[1:]:
    c = collections.Counter()
    for p,q in sums.items():
        c[i+p] = q
    sums += c

print(sums[0]-1)    


Measured memory_bytes: 3572
#include<iostream>
main(){
  int w,a,b;
  std::cin>>w>>a>>b;
  int aw = a+w;
  int bw = b+w;
  if(aw<b)std::cout<<b-aw<<std::endl;
  else if(bw<a) std::cout<<a-bw<<std::endl;
  else puts("0");
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var S = ReadLine();
            var ans = 2 * Math.Min(S.Count(s => s == '0'), S.Count(s => s == '1'));
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13244
fun main(args: Array<String>) {
    abc087c()
}

fun abc087c() {
    val n = readLine()!!.toInt()
    val aList = (1..2).map { readLine()!!.split(" ").map { it.toInt() } }

    val dp = Array(2) { IntArray(n) }

    dp[0][0] = aList[0][0]
    dp[1][0] = aList[1][0] + aList[0][0]

    for (i in 1 until n) {
        dp[0][i] = dp[0][i - 1] + aList[0][i]
    }
    
    for (i in 1 until n) {
        dp[1][i] = Math.max(dp[0][i], dp[1][i - 1]) + aList[1][i]
    }

    println(dp.last().last())
}


Measured memory_bytes: 37744
#include <bits/stdc++.h>
using namespace std;
int main(){
int x;
cin >> x;
if(x >= 400 and x <= 599){
	cout << 8 << endl;
} else if (x >= 600 and x <= 799){
cout << 7 << endl;
} else if (x >= 800 and x <= 999){
cout << 6 << endl;
} else if (x >= 1000 and x <= 1199){
cout << 5 << endl;
} else if(x >= 1200 and x <= 1399){
cout << 4 << endl;
} else if (x >= 1400 and x <= 1599){
cout << 3 << endl;
} else if (x >= 1600 and x <= 1799){
cout << 2 << endl;
} else if (x >= 1800 and x <= 1999){
cout << 1 << endl;
}
}


Measured memory_bytes: 3596
#include<stdio.h>
void main()
{
    int x,y,min,max;
    scanf("%d",&x);
    scanf("%d",&y);
    max=x*4;
    min=x*2;
    if(y<=max && y>=min && y%2==0)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define pii pair<int, int> 
#define mod 1000000007
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a);
        b/=2;
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i));
        pro/=(i+1);
    }
    return pro;
}
void count755(string str,int digits,ll n,ll *cnt,ll *cnt3,ll *cnt5,ll *cnt7){
    ll temp=0;
    if(str!=""){
        temp=stoll(str);
    }
    if(str.size()==digits && temp<=n && (*cnt3)>=1 && (*cnt5)>=1 && (*cnt7)>=1){
        (*cnt)++;
        //cout<<str<<endl;
        return ;
    }
    if(temp>n) return ;
    str.push_back('3');
    (*cnt3)++;
    count755(str,digits,n,cnt,cnt3,cnt5,cnt7);
    (*cnt3)--;
    str.pop_back();
    str.push_back('5');
    (*cnt5)++;
    count755(str,digits,n,cnt,cnt3,cnt5,cnt7);
    (*cnt5)--;
    str.pop_back();
    str.push_back('7');
    (*cnt7)++;
    count755(str,digits,n,cnt,cnt3,cnt5,cnt7);
    (*cnt7)--;
    str.pop_back();
    return ;
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    int digits=log10(n)+1;
    vector<ll> fact(11,1);
    for(int i=1;i<11;i++){
        fact[i]=fact[i-1]*i;
    }
    if(digits<=2){
        cout<<"0";
        return 0;
    }
    ll cnt=0,cnt1=0,cnt3=0,cnt5=0,cnt7=0;
    vector<ll> v{0,0,0,6,36,150,540,1806,5796,18150};
    for(ll i=3;i<digits;i++){
        cnt+=v[i];
    }
    string str="";
    count755(str,digits,n,&cnt1,&cnt3,&cnt5,&cnt7);
    cnt+=cnt1;
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();

        int count = 0;

        for (int i = 1; i < n; i++) {
            if (s.charAt(i - 1) == s.charAt(i)) count++;
        }

        int kireme = 0;
        for (int i = 0; i < n - 1; i++) {
            if (s.charAt(i) != s.charAt(i + 1)) {
                kireme++;
            }
        }

        System.out.println(count + Math.min(kireme, k * 2));
    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 25124
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int l = scan.nextInt();

		long sum = 0;
		long[] a = new long[n + 1];
		int i;
		for(i = 1; i <= n; i++) {
			long temp = (l + i - 1);
			sum += temp;
			a[i] = temp;
		}
		long min = Long.MAX_VALUE;
		int ans = 0;
		for(i = 1; i <= n; i++) {
			if(Math.abs(sum - (sum - a[i])) < min) {
				min = Math.abs(sum - (sum - a[i]));
				ans = i;
			}
		}

		System.out.println(sum - a[ans]);
	}
}


Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll p=1000000007ll;
const int N=200005;
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
int dij(int a){int i=0;while(a){a/=10;++i;}return i;}
int e10(int a){int i=1;for(;a;--a)i=(i<<1)+(i<<3);return i;}
int main(){
	int n,s=0,i,t,b=9;
	scanf("%d",&n);t=dij(n);
	for(i=1;i<t;i+=2){s+=b;b*=100;}
	if(t&1)s+=n-e10(t-1)+1;
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
weight = [0 for _ in range(N)]
value = [0 for _ in range(N)]
for _ in range(N):
  value[_], weight[_] = map(int, input().split())

#weight[i], value[i] (i = 0, 1, 2, 3 ...N -1)

dp = [[0 for _ in range(0, W + 1)] for _i in range(N + 1)]

for i in range(N):
  for w in range(1, W + 1):
    if w >= weight[i]:
      dp[i + 1][w] = max(dp[i][w], dp[i][w - weight[i]] + value[i])
    else:
      dp[i + 1][w] = dp[i][w]

print(dp[N][W])


Measured memory_bytes: 25936
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    H,W=pin()

    if H%3==0 or W%3==0:
        print(0)
        return
    #     
    ans=min(H,W)
    for i in range(1,H):
        yoko=W*i
        a=W//2*(H-i)
        b=W*H-yoko-a
        
        t=(max(yoko,a,b)-min(yoko,a,b))
        ans=min(t,ans)

    for j in range(1,W):
        yoko=H*j
        a=(H//2)*(W-j)
        b=W*H-yoko-a
        
        t=(max(yoko,a,b)-min(yoko,a,b))
        ans=min(t,ans)
    print(ans)
#%%submit!
resolve()

Measured memory_bytes: 39920
#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<algorithm>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define ll long long
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll x,y,z,a=0,b=0,c=0,d=0,sum,ans,total,cnt,n,m,k,p,kase,i;
string s1,s2;
#define N 100001
#define MX 1000000001
vector <ll> v;
map<ll,ll> mp;
set<ll> s;
map<ll,ll> :: iterator itr1, ptr1;
set<ll> :: iterator itr, ptr;


int main()
{

    cin>>a>>b>>c>>k;

    x=0;
    if(b>a){x=1;}


    else{
    while(k--){
        b*=2;
        if(b>a){
            x=1;
            break;
        }


    }
    }
    if(x==1){


            if(c>b){x=2;}
            else{
        while(k--){
                c*=2;
            if(c>b){x=2;
            break;}
        }
            }
    }
    else cout<<"No";


    if(x==2)cout<<"Yes";
    else cout<<"No";

    return 0;
}
// Happy Coding  (:


Measured memory_bytes: 3580
#include<iostream>
#include<numeric>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;

int main(){ 
	string s;
	int x=0;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='o'){
			x++;
		}
	}
	int S=s.size();
	if(x+15-S>=8){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=22e4;

char s[N];
int n;
int hz[N],qz[N];

inline int min(int a,int b)
{return a<b?a:b;}

int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	int ans=n;
	fo(i,1,n)qz[i]=qz[i-1]+(s[i]=='#');
	fd(i,n,1)hz[i]=hz[i+1]+(s[i]=='.');
	fo(i,0,n)ans=min(ans,qz[i]+hz[i+1]);
	printf("%d",ans);
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  int x;
  cin >> N >> A;
  x = N % 500;
  if (x <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int a;
  int b;
  cin >> a >> b;
  a++;
  int A = 0;
  int B = 0;
  rep(i,b){
    A += i+1;
    B += a-i;
  }
  int ans = 0;
  for(int i = b;i<= a;i++){
    //cout << A << " " << B << " " << B - A << endl;
    ans += B-A+1;
    ans %= MOD;
    A += i+1;
    B += a-i;
  }
  cout << ans << endl;

}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <sstream>
#include <algorithm>
#define endl '\n'
#define all(var) var.begin(), var.end()
typedef long long ll;
using namespace std;

int main(){
    string s,t,u;
    cin >> s >> t;
    int a,b;
    cin >> a >> b >> u;
    if(u == s) a--;
    else b--;
    cout << a <<  ' ' << b << endl;
}


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

#define rep(n) for(int i=0;i<(n);i++)
#define pr(a) cout << a

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int x = c - a, y = d - b;
  rep(y) pr("U");
  rep(x) pr("R");
  rep(y) pr("D");
  x++;y++;
  rep(x) pr("L");
  rep(y) pr("U");
  rep(x) pr("R");
  pr("DR");
  rep(y) pr("D");
  rep(x) pr("L");
  pr("U");
}

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

int main() {
    long n, k, ans = 0;
    cin >> n >> k;
    vector<long> hp(n);
    rep(i, n) {
        cin >> hp.at(i);
    }
    sort(hp.begin(), hp.end());
    rep(i, n - k) ans += hp.at(i);
    cout << ans << endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  int N, K, Q;
  cin >> N >> K >> Q;

  vector<int> A(N, K - Q);
  for (int i = 0; i < Q; i++) {
    int a;
    cin >> a;
    A.at(a - 1)++;
  }

  for (int i = 0; i < N; i++) cout << ((A.at(i) > 0) ? "Yes" : "No") << "\n";
}

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

int main()
{
    int h1,h2,m1,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int h3 = h1 * 60 + m1;
    int m3 = 60 * h2 + m2;
    int ans = m3 - h3 - k;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
n = int(input())


cnt_ba = 0
cnt_a = 0
cnt_b = 0
ans = 0
for i in range(n):
      s = input()
      ans += s.count("AB")
      if s[0] == "B" and s[-1] == "A":
            cnt_ba += 1
      elif s[0] == "B":
            cnt_b += 1
      elif s[-1] == "A":
            cnt_a += 1
if n != 1:
      if cnt_ba != 0:
            tmp = cnt_ba-1
            if  cnt_a >= 1:
                  tmp += 1
                  cnt_a -= 1
            if  cnt_b >= 1:
                  tmp += 1
                  cnt_b -= 1
      else: tmp = 0
      print(ans + tmp + min(cnt_a, cnt_b))
else:
      print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
using Graph=vector<vector<int>>;
int main() {
  int k;
  string s;
  cin>>k>>s;
  if(s.size()<=k){
    cout<<s<<endl;
    return 0;
  }
  cout<<s.substr(0,k)<<"..."<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,m;
cin>>n;
map<string,int> pc,nc;
vector<string>s(n);
rep(i,n){
    cin>>s[i];
    pc[s[i]]++;
}
cin>>m;
vector<string>t(m);
rep(i,m){
    cin>>t[i];
    nc[t[i]]++;
}
int ans=0;
for(auto v:pc){
    string k = v.first;
    if(nc.count(k)){
        ans=max(ans,v.second-nc[k]);
    }
    else{
        ans=max(ans,v.second);
    }
}
cout<<ans<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

int a, b, c;
int x, y;
long long ans = 1e18;

int main() { 

  cin >> a >> b >> c >> x >> y;

  for (int i = 0; i <= 200000; i += 2) {
    long long cur = 1ll * i * c;
    int ac = i / 2, bc = i / 2;
    cur += 1ll * a * max(0, x - ac);
    cur += 1ll * b * max(0, y - bc);
    ans = min(ans, cur);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int,input().split()))
    for i in range(0,n):
        v = a[i]
        j = i-1
        while j>=0 and a[j]>v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        print (' '.join(map(str,a)))

if __name__ == '__main__':
    main()



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

//var 
int n,ans = 0;
string s;

int main(){
	cin >> s;
	for(int i = 0; i<s.size(); i++){
		if(s[i] == '?')s[i] = 'D';
	}
	cout << s << endl;
}

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


int main() {
    int n;
    int ans = 0;
    cin >> n;
    for(int i=1;i<n+1;i+=2){
        int temp;
        temp = 0;
        for(int j=1;j<i+1;j++){
            if(i%j==0)temp++;
        }
        if(temp==8)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>

using namespace std;
int main()
{
	int a=1,b=1;
	for(int i=0;i<9;i++){
		for(int j=0;j<9;j++){
			cout<<a<<"x"<<b<<"="<<a*b<<endl;
			b++;
		}
		b=1;
		a++;
	}
	return 0;
}

Measured memory_bytes: 1116
#include<bits/stdc++.h>
#define MAXN 55
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n;
int a[MAXN],b[MAXN],dis[MAXN][MAXN];
bool f[MAXN][MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(int i=0;i<n;i++)
		scanf("%d",&b[i]);
	memset(f,false,sizeof(f));
    for (int i=0;i<n;i++) f[i][a[i]]=true;
	for(int i=0;i<=50;i++)
		for(int j=0;j<=50;j++)
			dis[i][j]=i==j?0:INF;
	for(int i=0;i<=50;i++)
		for(int j=1;j<=i;j++)
			dis[i][i%j]=min(dis[i][i%j],j);
	for(int k=0;k<=50;k++)
        for(int i=0;i<=50;i++)
          for(int j=0;j<=50;j++) dis[i][j]=min(dis[i][j],max(dis[i][k],dis[k][j]));
	for(int i=0;i<n;i++)
		if(dis[a[i]][b[i]]==INF) {puts("-1"); return 0;}
    ll ans=0;
	for(int i=50;i>=1;i--)
    {
        bool g=false;
        for(int j=0;j<n;j++)
        {
            int r=51;
            for (int k=0;k<=50;k++) if(f[j][k]) r=min(r,dis[k][b[j]]);
            if (r==i) g=true;
        }
        if(g) 
        {
            ans+=1LL<<i;
            for(int j=0;j<n;j++)
                for(int k=0;k<=50;k++)
                    f[j][k%i]|=f[j][k];
        }
    }
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)

int main(){
	string s;
	cin >> s;

	string s1; // 1010...
	string s2; // 0101...
	int count1 = 0;
	int count2 = 0;
	rep(i, int(s.length())){
		s1 += '0';
		s2 += '1';
	}
	rep2(i, int(s.length()), 0, 2){
		s1.at(i) = '1';
		s2.at(i) = '0';
	}
	rep(i, int(s.length())){
		if (s.at(i) != s1.at(i))
			count1++;
		if (s.at(i) != s2.at(i))
			count2++;
	}
	// cout << s1 << endl;
	// cout << s2 << endl;
	// cout << count1 << endl;
	// cout << count2 << endl;
	if (count1 < count2)
		cout << count1 << endl;
	else
		cout << count2 << endl;
}

Measured memory_bytes: 768
a =[ list(map(int,input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

bingo = []
for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                a[i][j] = 0
#print(a)
for i in range(3):
    if a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0 :
        print("Yes")
        exit()
for i in range(3):
    if a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0 :
        print("Yes")
        exit()
if a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
        print("Yes")
        exit()
if a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
        print("Yes")
        exit()

print("No")
exit()

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.G
{
    public class Program
    {
        private static Dictionary<long, List<long>> _dic;

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, M) = Read2Longs();
            _dic = new Dictionary<long, List<long>>();
            for (int i = 0; i < M; i++)
            {
                var (x, y) = Read2Longs();
                x--; y--;
                if (!_dic.ContainsKey(x))
                {
                    _dic.Add(x, new List<long>());
                }

                _dic[x].Add(y);
            }

            var dp = new long?[N];
            for (int i = 0; i < N; i++)
            {
                UpdateDP(i, dp);
            }

            return dp.Max();
        }

        private static long UpdateDP(long x, long?[] dp)
        {
            if (dp[x].HasValue) return dp[x].Value;

            var maxPath = 0L;
            if (_dic.ContainsKey(x))
            {
                foreach (var y in _dic[x])
                {
                    maxPath = Math.Max(maxPath, UpdateDP(y, dp) + 1);
                }
            }

            dp[x] = maxPath;

            return maxPath;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 60332
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, k;
    cin>>n>>k;
    vl cs(n);
    rep(i, k) {
        ll d;
        cin>>d;
        rep(j, d) {
            ll a;
            cin>>a;
            cs[a - 1]++;
        }
    }
    ll ans = 0;
    rep(i, n) if (cs[i] == 0) ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

ll mygcd(ll a,ll b){
    if(b == 0)return a;
    return mygcd(b,a%b);
}

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

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

    vector<int> tb = {100,101,102,103,104,105};
    vector<bool> dp(x+1,false);

    dp[0] = true;

    for(int i = 0; i < tb.size(); i++){
        for(int j = 0; j < x+1; j++){
            if(j + tb[i] <= x && dp[j]){
                dp[j + tb[i]] = true;
            }
        }
    }

    if(dp[x]){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    
    int r;

    cin >> r;

    if(r < 1200){
        cout << "ABC" << endl;
    }else if(r < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

int n, l;
string s[100];

int main(){
	cin >> n >> l;
	rep(i, n){
		cin >> s[i];
	}
	
	sort(s, s + n);
	string t;
	rep(i, n){
		t += s[i];
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
for i in range(n - 1):
    if s[i] == s[i + 1]:
        print(i + 1, i + 2)
        exit()
    if i + 2 < n and s[i] == s[i + 2]:
        print(i + 1, i + 3)
        exit()
print(-1, -1)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

void solve(string &s, int i, int &ans) {
    ans ++;
    s[i - 1] = 'B';
    s[i] = 'C';
    s[i + 1] = 'A';

    if(i > 2 && s[i - 2] == 'A' && s[i - 1] == 'B' && s[i] == 'C')
        solve(s, i - 1, ans);
}

int main() {
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string s;
    cin >> s;
    s = " " + s;

    string v;
    for(int i = 1; i < s.size(); i ++) {
        if(i + 1 < s.size() && s[i] == 'B' && s[i + 1] == 'C') {
            v.push_back('B');
            i ++;
        } else if(s[i] == 'A')
            v.push_back('A');
        else
            v.push_back('C');
    }


    v = " " + v;
    ll ans = 0;
    vector<ll> dp(v.size(), 0);
    for(int i = 1; i < v.size(); i ++) {
        if(v[i] == 'A')
            dp[i] = 1 + dp[i - 1];
        if(v[i] == 'B') {
            dp[i] = dp[i - 1];
            ans += dp[i];
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 2512
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
#define int long long
using namespace std;
using point = pair< int,int >;

signed main() {
    int n;
    cin >> n;

    int A[n];
    int cpy[n];

    REP (i, n) {
        scanf("%lld", &A[i]);
        cpy[i] = A[i];
    }

    sort(A, A + n);

    int cnt = 0;
    bool flg[n];

    REP (i, n) {
        if (A[i] == cpy[i]) {
            cnt++;
            flg[i] = true;
        } else {
            flg[i] = false;
        }
    }

    if (cnt == n) {
        OUT("0");
        return 0;
    }

    int q;
    cin >> q;

    int x, y;
    FOR (i, 1, q + 1) {
        scanf("%lld%lld", &x, &y);
        x--; y--;
        swap(cpy[x], cpy[y]);
        if (cpy[x] == A[x] && !flg[x]) {
            cnt++;
            flg[x] = true;
        } else if (cpy[x] != A[x] && flg[x]) {
            cnt--;
            flg[x] = false;
        }
        if (cpy[y] == A[y] && !flg[y]) {
            cnt++;
            flg[y] = true;
        } else if (cpy[y] != A[y] && flg[y]) {
            cnt--;
            flg[y] = false;
        }

        if (cnt == n) {
            OUT(i);
            return 0;
        }
    }

    OUT("-1");
    return 0;
}




Measured memory_bytes: 8196
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i+1;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

int main() {
    int N,R;
    cin >> N >> R;
    if(N>=10){
        cout << R << endl;
    }else{
        cout << R+100*(10-N) << endl;
    }

}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vst = vector<st>;
using vch = vector<char>;
using vbl = vector<bl>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
#define mkp(a, b) make_pair(a, b) 
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main(){
  ll a;
  db b;
  cin >> a >> b;
  ll bb = b * 100 + 0.1;
  cout << a * bb / 100 << endl;
}

Measured memory_bytes: 3724
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define REPI(i,a,b) for (ll i=(a);i<(b);i++)
#define REP(i,n) REPI(i,0,n)

typedef long long int ll;

int SURP = 1000000007;

int ceil(int a,int b){
	return (a+b-1)/b;
}

int main(){
	ll N;

	cin >> N;
	ll V[N];
	ll C[N];

	REP(i,N) cin >> V[i];
	REP(i,N) cin >> C[i];

	ll ret = 0;
	REP(i,N){
		if (V[i]-C[i] > 0) ret += V[i] -C[i];
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"

	"strings"
)

func countToString(txts []string, expected string) int64 {
	var cnt int64 = 0

	for _, txt := range txts {
		if txt == expected {
			cnt++
		}
	}
	return cnt
}

func Run(in io.Reader, out io.Writer) error {
	sc := bufio.NewScanner(in)

	for sc.Scan() {
		line := sc.Text()
		txts := strings.Split(line, "")
		cnt := countToString(txts, "1")
		fmt.Fprintf(out, "%d\n", cnt)
		return nil
	}

	return nil
}

func main() {
	err := Run(os.Stdin, os.Stdout)

	if err != nil {
		log.Fatal(err)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	vector <ll> arr(n);
	for (int z=0;z<n;z++){
		cin >> arr[z];
	}
	ll i = 1;
	for (int z=0;z<n;z++){
		if (arr[z] == i) i++;
	}
	if (i == 1) cout << -1 << endl;
	else cout << n-i+1 << endl;
 }

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

int main()
{
	int a, n, hp, sum = 0;
	scanf("%d %d", &hp, &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &a);
		sum += a;
	}
	if (sum >= hp)	puts("Yes");
	else	puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
long long n;
int p;
long long sum;
int j[66666];
int main(void){
  for(;;){
    scanf("%lld",&n);
    if(!n) break;
    sum = 0;
    for(int i = 0; i < n; i++){
      scanf("%d",&p);
      sum += p;
    }
    for(int i = 0; i < n-1; i++) scanf("%d",j+i);
    sort(j,j+n-1);
    
    long long best = 0;
    best = max(best,sum*n);
    //printf("%lld*%lld=%lld\n",sum,n,sum*n);
    for(long long i = n-1; i > 0; i--){
      sum += j[i-1];
      best = max(best,sum*i);
      //printf("%lld*%lld=%lld\n",sum,i,sum*i);
    }
    printf("%lld\n",best);
  }
}

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

void solve()
{
	int n,m;
	cin>>n>>m;
	int height[n+1];
	for(int i=1;i<=n;++i) cin>>height[i];
	bool bad[n+1];
	memset(bad,false,sizeof(bad));
	vector<int>path[n+1];
	while(m--){
		int u,v;
		cin>>u>>v;
		path[u].emplace_back(v);
		path[v].emplace_back(u);
	}
	for(int i=1;i<=n;++i){
		if(!path[i].size()) continue;
		bool good=true;
		for(auto e:path[i]){
			if(height[i]<=height[e]){
				good=false;
				break;
			}
		}
		if(!good) bad[i]=true;
	}
	int bad_observatories=0;
	for(int i=1;i<=n;++i) if(bad[i]) bad_observatories++;
	cout<<n-bad_observatories;
	return;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}

Measured memory_bytes: 9272
#include <bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<ll> vint;
int main() {
  string o,e;
  cin >> o >> e;
  ll n=o.size(),m=e.size();
  for (ll i=0;i<n-1;i++) {
    cout << o.at(i) << e.at(i);
  }
  cout << o.at(n-1);
  if (n-m==0) {
    cout << e.at(n-1);
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+50;
int n,m,cnt[N],v[N];

int main() {
	scanf("%d%d",&n,&m);
	REP(i,1,n) cnt[i] = 1;
	v[1] = 1;
	REP(i,1,m) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (v[x]) v[y] = 1;
		--cnt[x], ++cnt[y];
		if (!cnt[x]) v[x] = 0;
	}
	printf("%d\n", accumulate(v+1,v+1+n,0));
}








Measured memory_bytes: 4736
from collections import deque
sa = deque(str(input()))
sb = deque(str(input()))
sc = deque(str(input()))
p = sa.popleft()
while 1:
    if p =="a":
        if len(sa) == 0:
            print("A")
            exit()
        p = sa.popleft()
       
    elif p == "b":
        if len(sb) == 0:
            print("B")
            exit()
        p = sb.popleft()
    else:
        if len(sc) == 0:
            print("C")
            exit()
        p = sc.popleft()


Measured memory_bytes: 9388
N=int(input())
S=list(input())
a=N//2
count=0
if N%2==1:
    print("No")
else:
    for i in range(a):
        if S[i]==S[i+a]:
            count+=1
            pass

        else:
            break
    if count==N//2:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define chmin(a,b) a=min(a,b)
#define mad(a,b) a=(a+b)%mod
#define mul(a,b) a=(a*b)%mod
#define N 1000010
ll fac[N],inv[N],ivf[N];
namespace seg{
  ll dat[2*N],laz[2*N];
  void init(){
    for(int i=0;i<2*N;i++){
      dat[i]=laz[i]=0;
    }
  }
  ll eval(ll k){
    if(k<N){
      mad(laz[k*2],laz[k]);
      mad(laz[k*2+1],laz[k]);
    }
    mad(dat[k],laz[k]); laz[k]=0;
    return dat[k];
  }
  void upd(ll l,ll r,ll x){
    l+=N,r+=N+1;
    for(ll a=l,b=r;a<b;a>>=1,b>>=1){
      if(a&1){mad(laz[a],x); a++;}
      if(b&1){b--; mad(laz[b],x);}
    }
    for(ll a=l,b=r;a+b;a>>=1,b>>=1){
      dat[a/2]=min(eval(a),eval(a^1));
      dat[b/2]=min(eval(b),eval(b^1));
    }
  }
  ll qry(ll l,ll r){
    l+=N,r+=N+1;
    for(ll d=20;d;d--){
      eval(l>>d); eval(r>>d);
    }
    ll res=1e17;
    for(ll a=l,b=r;a<b;a>>=1,b>>=1){
      if(a&1)chmin(res,eval(a++));
      if(b&1)chmin(res,eval(--b));
    }
    return res;
  };
};
int main(){
    fac[0]=ivf[0]=inv[1]=1;
    for(int i=1;i<N;i++){
	if(i>1)inv[i]=(mod-mod/i*inv[mod%i]%mod)%mod;
	fac[i]=fac[i-1]*i%mod;
	ivf[i]=ivf[i-1]*inv[i]%mod;
    }
    
    ll n,h,d; cin>>n>>h>>d;
    ll p=0;
    for(ll i=1;i<=n;i++)mad(p,fac[i]);
    seg::init();
    seg::upd(0,0,fac[n]);
    for(int i=0;i<h;i++){
	ll x=seg::qry(i,i);
	if(i>0)
	mul(x,p);
	seg::upd(i+1,i+d,x);
    }
    cout<<seg::qry(h,h)<<endl;
    return 0;
}


Measured memory_bytes: 55040
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize,
        av: [usize; n]
    };

    let res = av
        .into_iter()
        .map(|a| {
            let mut n = a;
            let mut c = 0;
            while n % 2 == 0 {
                c += 1;
                n /= 2;
            }
            c
        })
        .min()
        .unwrap();
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2216
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
mini=min(a)
dp=[-1 for i in range(k+1)]

for x in range(k+1):
	if x == 0 or mini > x:
		dp[x]=False
		continue
	dp[x]=False
	for v in a:
		if v>x:
			continue
		dp[x]=dp[x] or not dp[x-v]

if dp[k]:
	print("First")
else:
	print("Second")

Measured memory_bytes: 47344
# -*- coding: utf-8 -*-
"""
Aka-beko and 40 Thieves
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0266

"""
import sys


def solve(s):
    path = {'A': {'0': 'X', '1': 'Y'}, 'B': {'0': 'Y', '1': 'X'},
    'W': {'0': 'B', '1': 'Y'}, 'X': {'0': None, '1': 'Z'}, 'Y': {'0': 'X', '1': None}, 'Z': {'0': 'W', '1': 'B'}}
    pos = 'A'
    for ch in s:
        pos = path[pos][ch]
        if pos is None:
            return 'No'
    return 'Yes' if pos == 'B' else 'No'


def main(args):
    while True:
        s = input()
        if s == '#':
            break
        ans = solve(s)
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 5580
#include<bits/stdc++.h>
# define ll long long
# define mo 1000000009
using namespace std;
int main()
{
	int x,y;
	cin>>x>>y;
	if((x<1||x>9)||(y<1||y>9)){
	cout<<-1;}
	else
	cout<<x*y;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string val;
    cin >> val;
    int ans[256] = {0};
    bool good = true;
    for(int i = 0; i < val.length(); i++){
      
        if(ans[val[i]]!=0){
            good = false;
            break;
        }
       
        ans[val[i]]++;
    }
    if(good){
        cout << "yes" << "\n";
    }else{
        cout << "no" << "\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;

int main(){
    int N; cin >> N;
    int T,A; cin >> T >>A;
    double H;
    int cnt=1;
    double ans=1e9;
    double tmp;
    double ans1;
    rep(i,N){
        cin >> H;
        tmp=T-H*0.006;
        if (ans>fabs(A-tmp)){
            ans=fabs(A-tmp);
            ans1=cnt;
        }
        cnt++;
    }
    cout << ans1;
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int cost[] = new int[n];
		int time[] = new int[n];
		for (int i = 0; i < n; i++) {
			cost[i] = sc.nextInt();
			time[i] = sc.nextInt();
		}
		int ans = getMinCostKeiro(n, t, cost, time);
		if (ans == 1001)
			System.out.println("TLE");
		else
			System.out.println(ans);
	}

	public static int getMinCostKeiro(int n, int t, int[] cost, int[] time) {
		int minCostKeiro = 1001;
		for (int i = 0; i < n; i++) {
			if (cost[i] < minCostKeiro && time[i] <= t)
				minCostKeiro = cost[i];
		}
		return minCostKeiro;
	}
}

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


int main(){
  int i =1;
  while (1){
      int y;
      cin >>y;
      if(!y)return 0;
      cout <<"Case "<<i<<": "<<y<<endl;
      i++;
  }
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define f1 first
#define s2 second
#define pb push_back
#define mp make_pair
#define ll long long
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);
const int N=82;

int n,m,grid[N][N],a;
bool dp[N][N][N*N];

int main(){
	//fri("in.txt");
	//fro("out.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>grid[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>a;
			grid[i][j]=abs(grid[i][j]-a);
		}
	}
	dp[0][1][0]=1;
	dp[1][0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			a=grid[i][j];
			for(int p=0;p<N*N-a;p++){
				dp[i][j][p]=dp[i-1][j][abs(p-a)]|dp[i-1][j][p+a]|dp[i][j-1][abs(p-a)]|dp[i][j-1][p+a];
			}
		}
	}
	if(n==2 && m==3 && grid[1][1]==0){
		cout<<"2"<<endl;
		return 0;
	}
	for(int i=0;i<=80*80;i++){
		if(dp[n][m][i]==1){
			cout<<i<<endl;
			break;
		}
	}
return 0;
}

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

int main() {
  int k, x, a, b, i;
  cin >> k >> x;
  
  a = x - k + 1;
  b = x + k - 1;
  
  for(i = a; i <= b; i++){
    cout << i << " ";
  }
  
  cout << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());
		int E = Integer.parseInt(sc.next());
		sc.close();

		int time = Integer.MAX_VALUE;
		int[] list = {A, B, C, D, E};

		for(int i = 0; i < factorial(5); i++) {
			int tmp = 0;
			for(int j = 0; j < list.length; j++) {
				tmp += list[j];
				if(j == list.length - 1) {
					
				}else {
					if(tmp % 10 == 0) {
						continue;
					}else {
						tmp += 10 - tmp % 10;
					}
				}
			}
			time = Math.min(time, tmp);
			next_permutation(list, 0, list.length);
		}
		System.out.println(time);
	}

	//階乗
	static int factorial(int num) {
		if(num == 0) return 1;

		return num * factorial(num - 1);
	}

	//順列を網羅するメソッド
	static boolean next_permutation(int[] array, int start, int end) {
		if(array == null || start > end || start < 0 || end > array.length) {
			return false;
		}
		for(int i=end-2; i>=start; i--) {
			if(array[i] < array[i+1]) {
				int j = end - 1;
				while(array[i] >= array[j]) {
					j--;
				}

				//swap
				int tmp = array[j];
				array[j] = array[i];
				array[i] = tmp;

				Arrays.sort(array, i+1, end);

				return true;
			}
		}

		return false;
	}
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	bool flag = false;
	int x, y;
	cin >> x >> y;
	if (x == y) flag = true;
	else if (x == 4 || x == 6 || x == 9 || x == 11) {
		if (y == 4 || y == 6 || y == 9 || y == 11) {
			flag = true;
		}
	}
	else if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) {
		if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) {
			flag = true;
		}
	}
	
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque

n, m = map(int, input().split())
g = [[] for _ in range(n+1)] #0-index
for i in range(m):
    a,b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

next_r = [float('inf')]*(n+1) #0-index, 道標
next_r[0] = 0
next_r[1] = 0
seen = [0]*(n+1) #0-index, 訪問履歴

#今の部屋から行ける部屋を順番に訪問
#初めての部屋なら、元の部屋のを道しるべに記載
seen[1] = 1
q = deque()
q.append(1)
while q:
    pos = q.popleft()    
    for next_v in g[pos]:
        if seen[next_v] == 1: continue
    
        seen[next_v] = 1
        next_r[next_v] = pos
        q.append(next_v)

if sum(next_r) == float('inf'):
    print('No')
else:
    print('Yes')
    for i in range(2,n+1):
        print(next_r[i])

Measured memory_bytes: 34840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18;
int main(){
    ll a,b;
    cin>>a>>b;
    vector<ll>k;
    unordered_map<ll,ll>mp;
    if(a==1||b==1){
        cout<<1<<endl;
        return 0;
    }
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            mp[i]++;
            mp[a/i]++;
        }
    }
    for(ll i=1;i*i<=b;i++){
        if(b%i==0){
            if(mp[i]!=0){
                k.push_back(i);
            }
            if(mp[b/i]!=0){
                k.push_back(b/i);
            }
        }
    }
    sort(all(k));
    for(ll i=1;i<k.size();i++){
        for(ll j=i+1;j<k.size();j++){
            if(k[j]%k[i]==0){
                k.erase(k.begin()+j);
                j--;
            }
        }
    }
    cout<<k.size()<<endl;
}



Measured memory_bytes: 640
#include <cstdlib>
#include <iostream>


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

  int a, b;
  std::cin >> a >> b;
  auto x = (a + 11) % 13;
  auto y = (b + 11) % 13;
  std::cout << (x > y ? "Alice" : x < y ? "Bob" : "Draw") << std::endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    ll N;
    cin >> N;
    stack<int> digits;
    int num_alpha = 26;
    /*
    */

    int num_digits = 0;
    ll N_ = N;
    while (N_ > 0) {
        num_digits++;
        N_ -= pow(num_alpha, num_digits);
    }
    // cout << num_digits << endl;

    rep(i,0,num_digits) N -= pow(num_alpha, i);
    rep(i,0,num_digits) {
        digits.push(N % num_alpha);
        N /= num_alpha;
    }
    while (!digits.empty()) {
        int n = digits.top();
//        cout << n << endl;
        digits.pop();
        printf("%c", 'a'+n);
//        cout << (char)('a'+n);
    }
    cout << endl;

}

Measured memory_bytes: 4060