akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign

vvi nt;
vvi tree;
int n;

int dfs(int p, int par, int dep)
{
    int ret = dep;
    rep(i, tree[p].size()) {
        if (tree[p][i] != par) {
            int tmp = dfs(tree[p][i], p, 1)+1;
            ret = max(dep, tmp);
            nt[p].pb(tmp);
        }
    }
    int sum = 0;
    rep(i, nt[p].size()) {
        sum ^= nt[p][i];
    }
    return sum;
}

signed main()
{
    cin >> n;
    nt = vvi(n+1);
    tree = vvi(n+1);
    rep(i, n-1) {
        int2(a, b);
        tree[a].pb(b);
        tree[b].pb(a);
    }

    if (dfs(1, 0, 0)) {
        cout << "Alice" << endl;
    } else {
        cout << "Bob" << endl;
    }

    return 0;
}



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

using namespace std;
const int N = 1e5+7;

int a[N];
int dp[N];

int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	
	for(int i=2;i<=n;i++){
		dp[i] = 1e9;
		for(int j=1;j<=k&&i-j>=1;j++){
			dp[i] = min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
		}
	}
	cout<<dp[n]<<"\n";
	return 0;
}

Measured memory_bytes: 4380
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
#include <cmath>
#include <string>
#define mp make_pair
#define pb push_back

using namespace std;

int main() 
{
	int n, d, x;
	cin >> n >> d >> x;
	--d;
	int sum = 0;
	for (int i = 0; i<n; ++i) {
		int a;
		cin >> a;
		sum += 1 + d/a;
	}
	cout << sum + x << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;++x)
#define Red(x,y,z) for(int x=y;x>=z;--x)
using namespace std;
const int MAXN=305;
char buf[1<<12],*p1=buf,*p2=buf,nc;int ny;
inline char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;if(nc<0)return nc;
	x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48);return x*ny;
}int n,m,Mod,F[MAXN][MAXN][MAXN];
inline void Add(int&x,int y){x+=y,x>=Mod?x-=Mod:0;}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),m=read(),Mod=read(),F[0][1][0]=1;
	Rep(i,0,n)Rep(j,1,m)Red(k,i,0){
		if(k)Add(F[i][j][k-1],F[i][j][k]);else Add(F[i][j+1][i],F[i][j][k]);
		Add(F[i+1][j][k],1ll*F[i][j][k]*(k+1)%Mod);
	}cout<<F[n][m][0]<<"\n";
	return 0;
}




Measured memory_bytes: 110848
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

const int m = 2019;

int main()
{

    vector<int> x;

    for (int i = 0; i < 10000; i++)
    {
        int num;
        cin >> num;
        if (num == 0)
        {
            break;
        }
        x.push_back(num);
    }

    for (int i = 0; i < x.size(); i++)
    {
        cout << "Case " << i + 1 << ": " << x.at(i) << endl;
    }

    return 0;
}


Measured memory_bytes: 3172
#include<stdio.h>
#include<string.h>
#define N 1001

char X[N], Y[N];
int  c[N][N];
int m, n;

int LCSLength(void)
{
  int i, j;
  m = strlen(X);
  n = strlen(Y);

  for( i=1 ; i<=m ; i++ )
    c[i][0] = 0;
  for( j=0 ; j<n ; j++ )
    c[0][j] = 0;
  for( i=1 ; i<=m ; i++ ){
    for( j=1 ; j<=n ; j++ ){
      if(X[i-1]==Y[j-1])
	c[i][j] = c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1])
	c[i][j] = c[i-1][j];
      else
	c[i][j] = c[i][j-1];
    }
  }
  return c[i-1][j-1];
}

int main()
{

  int a[150];
  int i, j, k, q;
  scanf("%d",&q);
  for( i=0 ; i<q ; i++ ){
    scanf("%s",X);
    scanf("%s",Y);
    LCSLength();
    a[i] = LCSLength();
  }
  for( i=0 ; i<q ; i++ ){
    printf("%d\n",a[i]);
  }

  return 0;
}

Measured memory_bytes: 4516
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

const int kINF = 10000;

class Converter {
public:
  Converter(int H, int W) {
    H_ = H;
    W_ = W;
  }
  
  void i2xy(int i, int *px, int *py) {
    *px = i / W_;
    *py = i % W_;
  }
  
private:
  int H_;
  int W_;
};

bool IsAdj(int x, int y, int v, int w) {
  vector<int> dx = {+1, -1,  0,  0};
  vector<int> dy = { 0,  0, +1, -1};
  for (int i = 0; i < 4; ++i) {
    if (x + dx[i] == v and y + dy[i] == w) {
      return true;
    }
  }
  return false;
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; ++i) {
    cin >> S[i];
  }

  int N = H * W;
  vector<vector<int> > dist(N, vector<int>(N, kINF));

  Converter converter(H, W);
  
  // init
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (i == j) {
	dist[i][j] = 0;
      } else {
	int x, y, v, w;
	converter.i2xy(i, &x, &y);
	converter.i2xy(j, &v, &w);
	if (S[x][y] == '.' and S[v][w] == '.' and IsAdj(x, y, v, w)) {
	  dist[i][j] = 1;
	}
      }
    }
  }

  // iter
  for (int k = 0; k < N; ++k) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
	if (dist[i][j] > dist[i][k] + dist[k][j]) {
	  dist[i][j] = dist[i][k] + dist[k][j];
	}
      }
    }
  }

  int max_dist = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (dist[i][j] != kINF and dist[i][j] > max_dist) {
	max_dist = dist[i][j];
      }
    }
  }
  cout << max_dist << endl;
  
  return 0;
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(b-a == c-b) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;

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

  int t=1;
//  cin>>t;
  int tt=1;
  while(t--){
    string s;
    int i;
    cin>>s;
    fr(i,1,s.size())
    {
      if(s[i]==s[i-1])
      {cout<<"Bad";
    return 0;
  }
      
   // cout<<"Case #"<<tt<<": ";
   // tt++;
    }
    cout<<"Good";
    }
  return 0;
}



Measured memory_bytes: 256
import sys
N = int(input())
A = [int(a) for a in input().strip().split()]

ans = 1
for a in A:
    if a == 0:
        print(0)
        sys.exit()
for a in A:
    ans *= a
    if ans > 1e18:
        print(-1)
        sys.exit()

print(ans)

Measured memory_bytes: 21652
from collections import deque
N=int(input())
AB=[list(map(int,input().split())) for i in range(N-1)]
P=[set() for i in range(N+1)]
C=[set() for i in range(N+1)]
for a,b in AB:
    P[a].add(b)
    P[b].add(a)
Cpath={}
stack=deque([1])
delset=set()
while stack:
    a=stack.popleft()
    count=1
    for b in P[a]:
        while count in C[a]:
            count+=1
        C[a].add(count)
        C[b].add(count)
        Cpath[(a,b) if a<b else (b,a)]=count
        stack.append(b)
        P[b].remove(a)
    P[a].clear()


print(max([Cpath[i] for i in Cpath]))
for a,b in AB:
    print(Cpath[(a,b)])


Measured memory_bytes: 90068
R,G,B,N = map(int,input().split())

ans_count = 0

for red in range(int(N/R)+1):
  for green in range(int((N-red*R)/G)+1):
    if (N - red*R - green*G) % B ==0 :
      ans_count += 1

print(ans_count)


Measured memory_bytes: 2940
x,k,d=map(int,input().split())
x=abs(x)
ans=10**15
r=x//d
if x>=d*k:
  ans=x-d*k
else:
  k-=r
  if k%2==0:
    ans=abs(x-d*r)
  else:
    ans=abs(x-d*(r+1))
print(ans)


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

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

    vector<int> a(1,s);
    for (int i = 1; i <= 1000000; i++) {
        if (a[i-1]%2 == 0)
            a.push_back(a[i-1]/2);
        else
            a.push_back(3*a[i-1]+1);
        
        for (int j = 0; j < i; j++) {
            if (a[i] == a[j]) {
                cout << i+1 << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
int main(){
	int n,i,j,taro=0,hana=0,naga;
	char t[100],h[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s%s",t,h);
		if(strcmp(t,h)==0){
			taro++;
			hana++;
		}else{
			if(strlen(t)>strlen(h)){
				for(j=0;j<strlen(h);j++){
					if(t[j]-'0'>h[j]-'0'){
						taro+=3;
						break;
					}else if(t[j]-'0'<h[j]-'0'){
						hana+=3;
						break;
					}
				}
				if(j==strlen(h)){
					taro+=3;
				}
			}else{
				for(j=0;j<strlen(t);j++){
					if(t[j]-'0'>h[j]-'0'){
						taro+=3;
						break;
					}else if(t[j]-'0'<h[j]-'0'){
						hana+=3;
						break;
					}
				}
				if(j==strlen(t)){
					hana+=3;
				}
			}
		}
	}
	printf("%d %d\n",taro,hana);
}
	
	


Measured memory_bytes: 2056
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;

using namespace std;

ll dp[200020][3];

int main(){
    std::ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    for(int i = 0; i < n+10; i++){
        for(int j = 0; j < 3; j++){
            dp[i][j] = -INF;
        }
    }

    dp[0][1] = a[0];
    dp[0][0] = 0;
    dp[0][2] = 0;
    dp[1][1] = a[0];
    dp[1][0] = a[1];
    dp[1][2] = 0;
    for(int i = 2; i < n; i++){
        if(i%2 == 0){
            dp[i][0] = max(dp[i-1][0],dp[i-1][1]);
            dp[i][1] = dp[i-1][2]+a[i];
            dp[i][2] = dp[i-1][1]+a[i];
        } else {
            dp[i][0] = dp[i-1][0]+a[i];
            dp[i][1] = dp[i-1][2];
            dp[i][2] = max(dp[i-1][1],dp[i-1][0]);
        }
    }
    ll ans = max(dp[n-1][0],dp[n-1][1]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9592
#include <iostream>
using namespace std;
int main() {
  long long a, b;
  cin >> a >> b;
  
  long long aa = a, bb = b;

  while (aa != bb) {
    if (aa < bb) {
      aa += a;
    } else {
      bb += b;
    }
  }
  cout << aa << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}

int main()
{
    int n;
    cin >> n;
    vector<int> v(n+1,100001);
    v[0]=0;
    REP(i,n+1){
        if(i==0)continue;
        int a=v[i-1]+1;
        int b=1;
        while(b*6<=i){
            b*=6;
            a = min(a, v[i - b] + 1);
        }
        b=1;
        while (b*9 <= i)
        {
            b *= 9;
            a = min(a, v[i - b] + 1);
        }
        v[i]=a;
    }
    cout << v[n] << endl;
}

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

//Let Ci = Ai + i and Di = j - Aj
map<int, long long int> C;
map<int, long long int> D;

long long A[200005];
int main()
{
	int N;
	scanf("%d", &N);
	
	int i;
	for(i = 1; i <= N; i++)
	{
		scanf("%lld", &A[i]);
		
		C[A[i] + i]++;
		D[i - A[i]]++;
	}
	
	long long ans = 0;
	for(i = 1; i <= N; i++)
	{
		long long Ci = A[i] + i;
		ans += D[Ci];
	}
	
	printf("%lld", ans);
}


Measured memory_bytes: 39480
from sys import exit

s = input()
t = input()

tset = set(t)
slen = len(s)
aord = ord('a')
if len(tset - set(s)) != 0:
    print(-1)
    exit()

s2t = [i - aord for i in (s + s).encode('ascii')]
lut = [[-1] * slen for _ in range(26)]
for c in tset:
    b = ord(c) - aord
    j = 0
    for i in range(slen * 2 - 1, -1, -1):
        if s2t[i] == b:
            j = 0
        else:
            j += 1
        if i < slen:
            lut[b][i] = j

p = 0
for c in t:
    b = ord(c) - aord
    p += lut[b][p % slen] + 1
print(p)


Measured memory_bytes: 104684
/*
	0103:Baseball Simulation
*/
#include	<iostream>
#include	<string>

using namespace std;

int main(void) {
	int d;
	
	cin >> d;
	
	while(d-- > 0) {
		int point = 0, outcount = 0;
		int firstBase = 0, secondBase = 0, thirdBase = 0;
		string event;
		while(outcount < 3) {
			cin >> event;
			if(event == "OUT") {
				outcount++;
			} else if(event == "HOMERUN") {
				point += firstBase + secondBase + thirdBase + 1;
				firstBase = 0;
				secondBase = 0;
				thirdBase = 0;
			} else {
				point += thirdBase;
				thirdBase = secondBase;
				secondBase = firstBase;
				firstBase = 1;
			}
		}
		cout << point << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> s_i(n);
    int total = 0;
    for (int i = 0; i < n; i++) {
        int w;
        cin >> w;
        s_i[i] = total += w;
    }

    int min_diff;
    min_diff = abs(total - 2 * s_i[0]);
    for (int i = 1; i < n; i++) {
        min_diff = min(min_diff, abs(total - 2 * s_i[i]));
        if (total - 2 * s_i[i] <= 0) break;
    }

    cout << min_diff << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define mp(x,y)     make_pair(x,y) 
#define exit(x)     cout<<x<<"\n",return
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)
const ll N=500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
  ll T=1;
  //cin>>T;
  while(T--)
  {
 // string s;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>n;
  ll a[n];
  for (ll i = 0; i < n; ++i)
  {
  cin>>a[i];
  }
  sort(a,a+n);
  vector<ll> v;
  v.pb(a[0]);
  for (int i = 1; i < n; ++i)
  {
    a[i]%=a[0];
    if(a[i]>0)
    {
      v.pb(a[i]);
    }
  }
  sort(v.begin(), v.end());
  std::vector<ll> v1;
  v1 = v;

while(v1.size()>1)
{  v.clear();
  v.pb(v1[0]);
  for (int i = 1; i < v1.size(); ++i)
  {  
     v1[i] %= v1[0];

     if(v1[i]>0)
    {
      v.pb(v1[i]);
    }
  }
  sort(v.begin(), v.end());
  v1 = v;


}
cout<<v1[0]<<" ";
 }
}

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


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

int main()
{
    int x,y,m[] = {1,3,5,7,8,10,12},n[] = {4,6,9,11},flag = 1;
    cin >> x >> y;

    for(int i = 0; i < 6; i++){
        for(int j = i + 1; j < 7; j++){
            if(m[i] == x && m [j] == y) flag = 0;
        }
    }
    for(int i = 0; i < 3; i++){
        for(int j = i + 1; j < 4; j++){
            if(n[i] == x && n[j] == y) flag = 0;
        }
    }
    cout << (flag == 0 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int G[101][101];
int n;

int solve(int s,int g1,int g2){
  for(int k=0;k<n;++k)
    for(int i=0;i<n;++i)
      for(int j=0;j<n;++j)
	G[i][j] = min(G[i][j],G[i][k]+G[k][j]);

  int ret = 1<<29;
  for(int t=0;t<n;++t)
    ret = min(ret,G[s][t]+G[t][g1]+G[t][g2]);
  return ret;
}

int main(){
  int m,s,g1,g2;
  while(cin>>n>>m>>s>>g1>>g2,n){
    for(int i=0;i<n;++i)
      for(int j=0;j<n;++j)
	G[i][j] = (i==j)?0:(1<<29);
    s--;g1--;g2--;
    while(m--){
      int a,b,c;
      cin >> a >> b >> c;
      a--;b--;
      G[a][b] = c;
    }
    cout << solve(s,g1,g2) << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
n,m = map(int,input().split())
py = []
for i in range(m):
    p,y = map(int,input().split())
    py.append([p,y,i])
ans = ['0'] * m
py.sort()
#print(py)
j = 0
for i in range(m):
    if j!= py[i][0]:
        j = py[i][0]
        c=1
    ans[py[i][2]] = str(py[i][0]).zfill(6) + str(c).zfill(6)
    c += 1
for i in range(m):
    print(ans[i])

Measured memory_bytes: 72408
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn split(n: u64) -> Vec<u64> {
    let mut n = n;
    let mut ds = vec![];
    while n > 0 {
        ds.push(n%10);
        n /= 10;
    }
    ds.reverse();
    ds
}

fn main() {
    input!{
      n: u64,
    }
    let ds = split(n);
    let ans: u64 = ds.iter().sum();
    let ans2: u64 = (ds[0]-1) + 9 * (ds.len()-1) as u64;
    println!("{}", max(ans, ans2));
}


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

int main(){
	long long n;
	cin >> n;
	long long skrg=100;
	for(int i=1;i!=0;i++){
		long long ans=floor(skrg*0.01);
		skrg+=ans;
		if(skrg>=n) {
			cout << i << "\n";
			return 0;
		}
	}
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] dlist = new int[N];

        for (int i = 0; i < N; i++) {
            dlist[i] = sc.nextInt();
        }

        Arrays.sort(dlist);
        int cntpp = N / 2;
        int cntpm = N / 2 - 1;

        if (dlist[cntpm] == dlist[cntpp]) {
            System.out.println(0);
        } else {
            System.out.println(dlist[cntpp] - dlist[cntpm]);
        }

    }
}


Measured memory_bytes: 52944
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N = int(input())

G = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b, c = map(int, input().split())
    G[a].append((b, c))
    G[b].append((a, c))

Q, K = map(int, input().split())

d = [-1] * (N + 1)
d[K] = 0
stack = [K]
while stack:
    now = stack.pop()
    for tmp in G[now]:
        next_ = tmp[0]
        if d[next_] == -1:
            d[next_] = d[now] + tmp[1]
            stack.append(next_)

for _ in range(Q):
    x, y = map(int, input().split())
    print (d[x] + d[y])

Measured memory_bytes: 43440
# 素因数分解
def prime_factorize(n):
    a = []
    # ２で割れなくなるまで割る
    while n % 2 == 0:
        a.append(2)
        n //= 2
    # 奇数で割り続けていく
    # 本当は素数で割り続けていくのが良い
    f = 3
    # 二乗して超えたら終了
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    # 最後の一つ
    if n != 1:
        a.append(n)
    return a
    
A, B = map(int, input().split())
A_list = set(prime_factorize(A))
B_list = set(prime_factorize(B))

print(len(A_list & B_list) + 1)



Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>
#include<tuple>
using namespace std;
int abc110_b(){
    // 入力
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    set<int> stx,sty;
    for (int i=0; i<n; ++i) {
        int a;
        cin >> a;
        stx.insert(a);
        stx.insert(x);
    }
    for (int i=0; i<m; ++i) {
        int a;
        cin >> a;
        sty.insert(a);
        sty.insert(y);
    }
    bool ans = true;
    
    //処理
    if(x>=y){
        ans = false;
    }else{
        auto itrx = stx.end();
        --itrx;
        int xmax = *itrx;
        auto itry = sty.begin();
        int ymin = *itry;
        if(xmax>=ymin) ans = false;
    }
    //出力
    if(ans) cout << "No ";
    cout << "War" << endl;
    return 0;
}

int main() {
    abc110_b();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define jaldi ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define kuch(a,n) for(ll i=0;i<n;i++) cin>>a[i]
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORA(i,b,a)	for(ll i=b;i>a;i--)
#define bs(v,x)	binary_search(v.begin(),v.end(),x)
#define mci(b)	cout<<b<<"\n"
#define bvb(n)	long long n;cin>>n;

typedef long long ll;
typedef vector<long long> vll ;
typedef long double ld;
const ll maxn = 1e9, mod = 1e9 + 7;


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

ll lcm(ll a, ll b)  
{  
    return (a*b)/gcd(a, b);  
} 

ll fact(ll b)
{
	ll re=1;
	for(ll i=1;i<=b;i++)
		re=re*i;
	return re;
}
int main()
{
	jaldi;
	double n;cin>>n;
	n/=3;
	double ans=n*n*n;
	cout << fixed << setprecision(8) << ans<<endl;
	return 0;
}

Measured memory_bytes: 256
lst_N = [int(c) for c in input()]
set_N = set(lst_N)
first = lst_N[0]
left = lst_N[1:]
if len(lst_N) == 1: #1桁
    print(lst_N[0])
elif len(set_N) == 1 and lst_N[0] == 9: #all 9
    print(sum(lst_N))
elif first != 9 and len(set(left)) == 1 and left[0] == 9: #9以外＋残り全部９
    all_nine = "9" * (len(left))
    lst_all_nine = [int(c) for c in all_nine]
    print(first + sum(lst_all_nine))
else:
    all_nine = "9" * (len(lst_N) - 1)
    lst_all_nine = [int(c) for c in all_nine]
    print((first-1) + sum(lst_all_nine))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int H, W;
    while(true){
        cin >> H >> W;
        if(H == 0 && W == 0){
            break;
        }
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	const int MAX = 110000;
	int N;
	vector<int> a, con;
	
	cin>>N;
	
	a.resize(N);
	con.resize(MAX);
	
	for(int i = 0; i < N; i++){
		cin>>a[i];
		if(a[i])con[a[i]-1]++;
		con[a[i]]++;
		con[a[i]+1]++;
	}
	
	sort(con.begin(), con.end(), greater<int>());
	
	cout<<con.front()<<endl;
	return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rep2(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
const int N=1e5+7;
typedef long long ll;
ll ans=0;
int n,a[N];
int main(){
	scanf("%d",&n);
	rep(i,1,n)scanf("%d",&a[i]);
	int last=0;
	rep(i,1,n){
		if(a[i] && last)a[i]--,last=0,ans++;
		ans+=(a[i]>>1);
		last=a[i]&1;
	}
	cout<<ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d>0?i<n:i>n;i+=d)
#define endl "\n"
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

void solve(){
    ll n, a, b; cin >> n >> a >> b;
    if(a > b){
        cout << 0 << endl;
        return;
    }
    if(n == 1){
        cout << (a == b ? 1 : 0) << endl;
        return;
    }

    cout << (b - a) * (n - 2) + 1 << endl;
}

Measured memory_bytes: 256
//********** ANKIT KESARWANI **********//
#include <bits/stdc++.h>/
using namespace std;
#define   FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define   vi vector<int>
#define   pii pair<int,int>
#define   all(a) (a).begin(), (a).end()
#define   rep(i,a,b)  for(int  i=a;i<b;i++)
#define   tr(it, a)   for(auto it=a.begin();it!=a.end();it++)
#define   pb push_back
#define   endl  "\n"
#define   dbg(x,y) cout<<(x)<<" -->  "<<(y)<<endl
#define   F first
#define   S second
#define   int  long long
const int  sz=1e5+20;
const int  inf=1e13;
const int  ninf=-1e9 ;
const int  mod=1e9+7;
/*------------------------------------------------------------------------------------------------------------------------*/
int n,w,val[sz],wt[sz];

void solve()
{
   cin>>n>>w;
   int sum=0;
   rep(i,0,n)
   {
       cin>>wt[i]>>val[i];
       sum+=val[i];
   }
   int dp[105][sz]={0};
   for(int i=1;i<=sum;i++)
   {
       dp[0][i]=inf;
   }

   for(int i=1;i<=n;i++)
   {
       for(int j=1;j<=sum;j++)
       {
           if(j-val[i-1]<0)
           {
               dp[i][j]=dp[i-1][j];
           }
           else
           {
               dp[i][j]=min(dp[i-1][j],dp[i-1][j-val[i-1]]+wt[i-1]);
           }
       }
   }

   /*for(int i=0;i<=n;i++)
   {
       for(int j=0;j<=sum;j++)
       {
          cout<<dp[i][j]<<" ";
       }
       cout<<endl;
   }*/



   int ans=0;

   for(int j=0;j<=sum;j++)
   {
       if(dp[n][j]<=w)
       {
           ans=j;
       }
   }
   cout<<ans;
}

signed main()
{
   FASTIO;
   int T=1;
  //cin>>T;
   while (T--)
    solve();
   return 0;
}


Measured memory_bytes: 82304
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
#include <cmath>
using namespace std;

vector<long long> divisor(long long n) {
    vector<long long> res;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    vector<long long> div = divisor(N);

    int ans = 100;
    for(auto d : div){
        int tmp1 = static_cast<int>(log10(d)+1);
        int tmp2 = static_cast<int>(log10(N/d)+1);
        ans = min(ans, max(tmp1, tmp2));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
	int i,n,j,k,b,f,r,v;
	int room[4][3][10]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d%d",&b,&f,&r,&v);
		room[b-1][f-1][r-1]=room[b-1][f-1][r-1]+v;
	}
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				printf(" %d",room[i][j][k]);
			}
			printf("\n");
		}
		if(i!=3)printf("####################\n");
	}
	return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int idx = 0;
    int N = (int)S.size();
    int ans = N; 
    while (idx < N - 1) {
        if (idx == N - 2 && S[idx] == S[idx + 1]) {
            ans--;
            break;
        }
        if (S[idx] == S[idx + 1]) {
            ans--;
            idx += 3;
        }
        else idx++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 2005;
const int MOD = 1e9 + 7;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, K, dp[MAXN];

inline void Inc(int &x, int y) {
	x += y; if (x >= MOD) x -= MOD;
}

void init() {
	read(n); read(K);
	dp[n+1] = 1;
	for (int i=1;i<K;++i) {
		int sum = dp[n-i+2];
		for (int j=n-i+1;j>=2;--j) {
			Inc(sum, dp[j]);
			dp[j] = sum;
		}
	}
}

void solve() {
	int ans = 0;
	for (int j=2;j<=n-(K-1)+1;++j) {
		Inc(ans, dp[j]);
	}
	for (int i=1;i<n-K;++i) {
		ans = ans * 2 % MOD;
	}
	printf("%d\n", ans);
}

int main() {
	init();
	solve();
	return 0;
}


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

taro = 0
hana = 0

for i in range(n) :
    taro_c, hana_c = input().split()
    if taro_c > hana_c :
        taro += 3
    elif taro_c == hana_c :
        taro += 1
        hana += 1
    elif taro_c < hana_c :
        hana += 3

print(taro, hana)



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
typedef signed long long int ll;
ll inf=1000000007;




int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    int ans1=0;
    
    for(int i=0;i<n;i++){
        cin>>a[i];
        ans1=max(ans1,a[i]);
    }
    
    int ans2=-1;
    int ideal=ans1;
    for(int i=0;i<n;i++){
        if(abs(2*a[i]-ideal)<=abs(2*ans2-ideal)&&ans1>a[i]){
            ans2=a[i];
        }
    }
    cout<<ans1<<" "<<ans2<<endl;
    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp44 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int A = st[0];
            int B = st[1];
            int C = st[2];
            int D = st[3];

            Console.WriteLine(Math.Max(A * B, C * D));

        }
    }
}


Measured memory_bytes: 13396
/*input
2 3 10
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, c; cin >> a >> b >> c;
    if(a + b - c >= 0) cout << "No";
    else if((a + b - c) * (a + b - c) > 4 * a * b) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N, K;

int main(void){
    
    scanf("%d %d", &N, &K);
    vector<ll> a, b;
    for(int i = 0; i < N; ++i){
        ll x; scanf("%lld", &x);
        if(x >= 0) a.push_back(x);
        else b.push_back(abs(x));
    }
    sort(b.begin(), b.end());
    
    int kk = K;
    ll ans = LLONG_MAX;
    while(kk >= 0){
        int l = kk, r = K - kk; --kk;
        if(b.size() < l || a.size() < r) continue;
        
        if(l == 0) ans = min(ans, a[r - 1]);
        else if(r == 0) ans = min(ans, b[l - 1]);
        else ans = min(ans, min(a[r - 1], b[l - 1]) * 2 + max(a[r - 1], b[l - 1]));
    }
    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 1656
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip> 
#include <algorithm>
#include <queue>
#include <list>
#include <numeric>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>

using namespace std;

#define sz(a) int((a).size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define watch(x) cout << #x << " : " << x << endl;

#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;

const int N = int(5e5)+10;
const int K = int(2e6)+10;
// const int MOD = int(1e9)+7;
const int INF = int(1e9)+5;
const ll INF64 = 2e18;

const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

ll inv[N],fact[N],ifact[N];

void pre () {
    inv[1] = fact[0] = fact[1] = ifact[0] = ifact[1] = 1;
    for (int i=2;i<N;i++) {
        inv[i] = mul(MOD - MOD / i, inv[MOD % i], MOD);
        fact[i] = mul(i * 1ll, fact[i - 1], MOD);
        ifact[i] = mul(inv[i], ifact[i - 1], MOD);
    }
    return;
}

ll nCr (ll n,ll r) {
    if (n >= 0 && r >= 0 && n >= r) {
        return mul(fact[n],mul(ifact[r],ifact[n-r],MOD),MOD);
    }
    return 0;
}



void solve () {
    int n,m;cin>>n>>m;
    pre();
    ll ans = mul(nCr(m,n),fact[n],MOD);
    ans = mul(ans,ans,MOD);
    ll ex = 0;
    for (int i=1;i<=n;i++) {
        ll tmp = nCr(n, i);
        tmp = mul(tmp, mul(nCr(m, i), fact[i], MOD), MOD);
        ll tmp1 = mul(nCr(m - i, n - i), fact[n - i], MOD);
        tmp1 = mul(tmp1, tmp1, MOD);
        tmp = mul(tmp, tmp1, MOD);
        if (i & 1) {
            ex = add(ex, tmp, MOD);
        } else {
            ex = add(ex, MOD - tmp, MOD);
        }
    }
    ans = add(ans, MOD - ex, MOD);
    cout<<ans<<endl;
}

int main () {
    FastIO
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int t;
    // cin>>t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 15380
import sys
sys.setrecursionlimit(10**9)

N = int(input())

def bfs(s, cnt, m):
	if cnt == N:
		print(s)
		return

	for i in range(97,ord(m)+2):
		if chr(i) > m:
			bfs(s+chr(i), cnt+1, chr(i))
		else:
			bfs(s+chr(i), cnt+1, m)

bfs('a',1,'a')

Measured memory_bytes: 4340
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

int main(){
  int N;
  cin >> N;
  
  if(N==1) cout << "Hello World" << endl;
  else{
    int A, B;
    cin >> A >> B;
    cout << A+B << endl;
  }
    
}

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

using namespace std;

#define int 		long long
#define double 		long double
#define pb 			push_back
#define in 			insert
#define mp 			make_pair
#define f 			first
#define s 			second
#define x 			first
#define y 			second
#define all(el) 	el.begin(), el.end()
#define allr(el) 	el.rbegin(), el.rend()
#define sz(el) 		(int)el.size()

template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1ll;} else {return 0ll;}}
template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1ll;} else {return 0ll;}}

istream& operator>>(istream &in, vector<int> &a) {
	for (int &now : a) {
		in >> now;
	}
	return in;
}

ostream& operator<<(ostream &out, vector<int> &a) { 
    for (int &now : a) {
    	out << now << ' ';
    }
    out << "\n";
    return out;
}

signed main() {

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

	int n, m;
	cin >> n >> m;
	if (n == 1 || m == 1) {
		cout << 1;
		return 0;
	}
	int can1 = (m + 1) / 2;
	int can2 = (n + 1) / 2;
	cout << can1 * can2 + (m - can1) * (n - can2) << endl;
	//cout << (n * m + 1) / 2;
}

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

int H;
int A;

int main()
{
    scanf("%d %d", &H, &A);
    if(H%A == 0)
    {
        printf("%d", H/A);
    }
    else
    {
        printf("%d", (int)H/A+1);
    }
    
    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;
    cin >> n;
    vector<ll> a(n);
    set<ll> num;
    rep(i, n) {
        cin >> a[i];
        num.insert(a[i]);
    }
    if (num.size() == a.size()) cout << "YES" << endl;
    else cout << "NO" <<endl;
    return 0;
}

Measured memory_bytes: 11136
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
    string S, T;
    cin >> S >> T;
    T += T;
    cout << (T.find(S)!=string::npos?"Yes":"No") << endl;
}

Measured memory_bytes: 256
import itertools
def checkbingo(A_match):
  for i in range(3):
      if 0 not in A_match[i * 3: (i + 1) * 3]:
          return 'Yes'
  for i in range(3):
      if 0 not in A_match[i: i + 7: 3]:
          return 'Yes'
  if 0 not in A_match[0: 8: 4]:
      return 'Yes'
  if 0 not in A_match[2: 7: 2]:
      return 'Yes'
  return 'No'  

def main():
  n=3
  A = [list(map(int, input().split())) for _ in range(n)]
  A=list(itertools.chain.from_iterable(A))
  N=int(input())
  b = [int(input()) for _ in range(N)]
  A_match = [0] * 9
  for i in range(n*n):
    tgtA=A[i]
    if(tgtA in b):
      A_match[i]=1
  print(checkbingo(A_match))
        
      
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
import java.util.*
 
fun main(args: Array<String>) {
 
  val sc = Scanner(System.`in`)
  val h = sc.nextInt()
  val n = sc.nextInt()
  val arrayList = ArrayList<Int>()
  (1..n).forEach {
    val a = sc.nextInt()
    arrayList.add(a)
  }
  
  val reduced = arrayList.reduce { acc, value ->
     acc + value                            
  }
  
  println(if(reduced >= h) "Yes" else "No")
}

Measured memory_bytes: 55720
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

s = sinput()
flag = s[2]==s[3] and s[4]==s[5]
if flag: print("Yes")
else: print("No")


Measured memory_bytes: 19932
"use strict";

function groundGarden(heights) {
  // console.log(`loop: heights=${heights}`);
  let lowestHeight = heights[0];
  let lowestIndexes = [0];

  if (!heights.length) { return 0; }

  for (let i = 1; i < flowerNum; i++) {
    const height = heights[i];
    if (height < lowestHeight) {
      lowestHeight = height;
      lowestIndexes = [i];
    } else if (height === lowestHeight) {
      lowestIndexes.push(i);
    } else {
      // ignore
    }
  }
  // console.log(`lowestIndexes=${lowestIndexes}, lowestHeight=${lowestHeight}`);

  if (lowestIndexes.length === flowerNum) {
    // console.log(`return: ${lowestHeight}`);
    return lowestHeight;
  } else {
    const nextHeights = heights.map((x) => x - lowestHeight);
    const water = lowestHeight;

    let sum = 0;
    let subHeights = [];

    for (let i = 0; i < nextHeights.length; i++) {
      if (nextHeights[i] === 0) {
        if (subHeights.length) {
          sum += groundGarden(subHeights);
          subHeights = [];
        }
        continue;
      }

      subHeights.push(nextHeights[i]);
    }

    if (subHeights.length) {
      sum += groundGarden(subHeights);
    }

    return water + sum;
  }
}

const input = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");

const flowerNum = parseInt(input[0], 10);
const heights = input[1].split(" ").map((x) => parseInt(x));

const ans = groundGarden(heights.slice(0, flowerNum));

console.log(ans);


Measured memory_bytes: 7628
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<string.h>
#include<cmath>
using namespace std;
long long  a[200500];
int main()
{
    int n;
    while(cin>>n)
    {
        memset(a,0,sizeof(a));
        long long int sum=0,ans=0;
        for(int i=0;i<n;i++)
        {
            scanf("%lld",&a[i]);
            sum+=a[i];
        }
        long long int d=0;
        int t=0;
        ans+=a[0];
        d=abs(2*ans-sum);
        for(int i=1;i<n-1;i++)
        {
            ans+=a[i];
            if(abs(2*ans-sum)<d)
            {
                t=i;
                d=abs(2*ans-sum);
            }
        }
        cout<<d<<endl;
    }
    return 0;
}


Measured memory_bytes: 1792
import sys

for s in sys.stdin:
    w = float(s)
    if w > 91.00:
        print('heavy')
    elif w > 81.00:
        print('light heavy')
    elif w > 75.00:
        print('middle')
    elif w > 69.00:
        print('light middle')
    elif w > 64.00:
        print('welter')
    elif w > 60.00:
        print('light welter')
    elif w > 57.00:
        print('light')
    elif w > 54.00:
        print('feather')
    elif w > 51.00:
        print('bantam')
    elif w > 48.00:
        print('fly')
    else:
        print('light fly')


Measured memory_bytes: 5568
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long int a, b, n;
    cin >> a >> b >> n;
    if(n < b){
        cout << (a*n)/b << '\n';
    }
    else{
        cout << (a*(b-1))/b << '\n';
    }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int N;
    int L;
    cin >> N >> L;
    int ans = 0;
    int abab;
    int abbs = 1000000000;
    for(int i=1;i<=N;i++){
        ans += L+i-1;
        if(abbs > abs(L+i-1)){
            abbs = abs(L+i-1);
            abab = L+i-1;
        }
    }
    cout << ans - abab << endl;
}


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

int c[100];
int main() {
	int n, k;
	while (scanf("%d%d", &n, &k), n) {
		rep(i, n)scanf("%d", &c[i]);
		int a = 0, b = 0;
		for (int i = 0; i <= n - k; i++) {
			int r = 1; rep(j, k)r *= c[i + j];
			a = max(a, r);
		}
		rep(i, n)for (int j = i + 1; j < n; j++) {
			swap(c[i], c[j]);
			for (int i = 0; i <= n - k; i++) {
				int r = 1; rep(j, k)r *= c[i + j];
				b = max(b, r);
			}
			swap(c[i], c[j]);
		}
		if (b < a)puts("NO GAME");
		else printf("%d\n", b - a);
	}
}

Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	int N, K;
	while(cin >> N >> K){
		vector<int> cnt(26, 0);
		for(int i=0;i<N;i++){
			string s; cin >> s;
			cnt[s[0]-'A']++;
		}
		int res = 0;
		while(true){
			vector< pair<int,int> > v;
			for(int i=0;i<26;++i){
				if(cnt[i] > 0) v.push_back(make_pair(cnt[i], i));
			}
			if(v.size() < K) break;
			sort(v.rbegin(), v.rend());
			for(int i=0;i<K;i++){
				cnt[v[i].second]--;
			}
			++res;
		}
		cout << res << endl;
	}
}



Measured memory_bytes: 384
#include <iostream>
#define fastio ios::sync_with_stdio(false); cin.tie(nullptr);
using namespace std;
int main() {
	fastio;
	int k;
	cin >> k;
	if (k % 2 == 0 || k % 5 == 0) {
		cout << -1 << '\n';
		return 0;
	}
	int cnt = 1, n = 7;
	while (n % k != 0) {
		n = (n * 10 + 7) % k;
		cnt++;
	}
	cout << cnt++;

	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}




template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;


WG<int> es;

void dfs(int x,int r,int b[],int c){

  for(auto e:es[x]){
//    cout<<e.to<<endl;
    if(e.to==r||b[e.to]!=-1) continue;
//    cout<<e.to<<' '<<c<<' '<<e.cost<<endl;
    if((c+e.cost)%2){
      b[e.to]=0;
    }else{
      b[e.to]=1;
    }
    dfs(e.to,x,b,c+e.cost);
  }
 
}


main(){
  int n;
  cin>>n;
  es.resize(n);
  int b[110000]={};

  rep(i,n-1){
    int a,b,c;
    cin>>a>>b>>c;
    a--;
    b--;
    es[a].PB(edge<int>(b,c%2));
    es[b].PB(edge<int>(a,c%2));
  }

  rep(i,n){
    b[i]=-1;
  }

  b[0]=1; 

  dfs(0,-1,b,0);


  rep(i,n){
    cout<<b[i]<<endl;
  }
}


Measured memory_bytes: 12416
#include <stdio.h>

int main()
{
  int a, b;

  scanf("%d%d", &a, &b);

  if ( a < b ) {
    printf("a < b\n");
  } else if ( a > b ) {
    printf("a > b\n");
  } else if ( a == b ) {
    printf("a == b\n");
  }

  return 0;
}

Measured memory_bytes: 580