akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <numeric>
using namespace std;
#define mod (long)(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
//#define long long long
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    int N, K;
    cin >> N >> K;
    long a[N];
    cins(a, a + N);
    long a_sum[N + 1], a_good_sum[N + 1];
    a_sum[0] = a_good_sum[0] = 0;
    for(int i = 0; i < N; i++){
        a_sum[i + 1] = a_sum[i] + a[i];
        a_good_sum[i + 1] = a_good_sum[i] + max(0l, a[i]);
    }
    long ans = 0;
    for(int i = 0; i <= N - K; i++){
        ans = max(ans, a_good_sum[i] + max(0l, a_sum[i + K] - a_sum[i]) + (a_good_sum[N] - a_good_sum[i + K]));
    }
    cout << ans << endl;
}



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

int table[50][3001];
int solve(int n, int m, int s);

int main()
{
	int n, m, s;
	while (1) {
		scanf("%d %d %d", &n, &m, &s);
		if (n == 0 && m == 0 && s == 0) {
			break;
		}
		printf("%d\n", solve(n, m, s));
	}
	return 0;
}

int solve(int n, int m, int s)
{
	int k;
	memset(table, 0, sizeof(table));
	for (k = 1; k <= m; k++) {
		int i, t;
		for (i = n * n; i >= 2; i--) {
			for (t = k + 1; t <= s; t++) {
				table[i][t] += table[i - 1][t - k];
				table[i][t] %= 100000;
			}
		}
		table[1][k] = 1;
	}
	return table[n * n][s];
}

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

ll calc(ll n){
	ll a,b;
	for(ll i=1;i*i<=n;++i){
		if(n%i==0){
			a=i;
			b=n/i;
		}
	}
	return b;
}

ll dig(ll x){
	ll ret=0;
	while(x>0){
		ret++;
		x/=10;
	}
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;cin >> n;
	ll a=calc(n);
	ll ans=dig(a);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 1002
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int main(){
	int a[5], ans = 0;
	rep(i,5)scanf("%d", &a[i]);
	rep(i,5)ans += max(40, a[i]);
	printf("%d\n", ans/5);
	return 0;
}

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

main()
{
    int n; cin>>n;
    unordered_map<int,int> mp;
    long long ans=0;
    for(int i=0; i<n; ++i)
    {
        int a; cin>>a;
        ans+=mp[i-a];
        mp[a+i]++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 18652
#include<iostream>
#include<set>
#include<vector>
#include<map>
using namespace std;
typedef long long li;
#define maximize(a,b) (a<(b)?a=(b),1:0)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

int cnt(vector<int>& vx,vector<int>& vy,set<pair<int,int>>& st,int ans){
  for(int x:vx) for(int y:vy) if(st.count({x,y})==0) return ans;
  return ans-1;
}

int main(){
  int h,w,m; cin >>h >>w >>m;
  set<pair<int,int>> pos;
  map<int,int> row,col;
  rep(i,m){
    int a,b; cin >>a >>b;
    row[a]++;
    col[b]++;
    pos.insert({a,b});
  }
  int mx=0,my=0;
  for(pair<int,int> x:row) maximize(mx,x.second);
  for(pair<int,int> y:col) maximize(my,y.second);
  vector<int> vx,vy;
  for(pair<int,int> x:row) if(x.second==mx) vx.push_back(x.first);
  for(pair<int,int> y:col) if(y.second==my) vy.push_back(y.first);
  if(df){
    print(vx);
    print(vy);
  }
  print(cnt(vx,vy,pos,mx+my));
}


Measured memory_bytes: 49632
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  ls <- replicateM n getLine
  mapM_ putStrLn $ solve ls

solve :: [String] -> [String]
solve = map check
  where
    check :: String -> String
    check (x:y:r)
      | x /= '>' = "NA"
      | y == '\'' = checkA r
      | y == '^' = checkB r
      | otherwise = "NA"
      where
        checkA :: String -> String
        checkA s
          | s == [] = "NA"
          | last s /= '~' = "NA"
          | s == "#~" = "NA"
          | filter ('=' /=) s /= "#~" = "NA"
          | reverse s' == s' = "A"
          | otherwise = "NA"
          where s' = init s
        checkB :: String -> String
        checkB s
          | s == [] = "NA"
          | (last s /= '~') || ((last . init $ s) /= '~') = "NA"
          | s == "~~" = "NA"
          | checkB2 (init (init s)) = "B"
          | otherwise = "NA"
          where
            checkB2 :: String -> Bool
            checkB2 [] = True
            checkB2 [x] = False
            checkB2 (x:y:r) = (x == 'Q') && (y == '=') && (checkB2 r)

Measured memory_bytes: 9316
#pragma GCC optimize("-O3")
#include<iostream>
#include<cstdio>
#include<map>
#include<cstring>
#define LL long long
using namespace std;
const int N=1e5+10;
const LL inf=1e16;
bool FLAG;
int r,c,n,cnt;
int hed[N<<1];
map<int,LL> mp[N<<1],vis[N<<1];
LL mn,mx;
bool flag[N<<1];
struct edge{
	int r,nxt;
	LL val;
}e[N<<1];
void insert(int u,int v,LL w){
	e[++cnt].r=v;e[cnt].nxt=hed[u];hed[u]=cnt;e[cnt].val=w;
}
void check(int x,LL s,int u){
	flag[x]=1;
	//cout<<s<<endl;
	for(int i=hed[x];i;i=e[i].nxt){
		if(x<=r){
			if(s+e[i].val!=mp[u][e[i].r]&&vis[u][e[i].r]) FLAG=1;
			//cout<<s<<" "<<e[i].val<<endl;
			s=s+e[i].val;
			if(!vis[u][e[i].r]){
				vis[u][e[i].r]=1;
				mp[u][e[i].r]=s;
			}
			//cout<<s<<" "<<mn<<endl;
			if(s<mn) mn=s;
			if(s<0) FLAG=1;
			if(!flag[e[i].r]) check(e[i].r,s,u);
			s-=e[i].val;
		}
		else{
			if(s-e[i].val!=mp[u][e[i].r]&&vis[u][e[i].r]) FLAG=1;
			s=s-e[i].val;
			if(!vis[u][e[i].r]){
				vis[u][e[i].r]=1;
				mp[u][e[i].r]=s;
			}
			//cout<<"a "<<s<<" "<<mx<<endl;
			if(mx>(-s)) mx=-s;
			//cout<<"a "<<s<<" "<<mx<<endl;
			if(!flag[e[i].r]) check(e[i].r,s,u);
			s+=e[i].val;
		}
	}
}
int main(){
//	int T;scanf("%d",&T);
	int u,v;LL w;
//	while(T--){
		scanf("%d%d%d",&r,&c,&n);FLAG=0;
		for(int i=1;i<=n;++i){
			scanf("%d%d%lld",&u,&v,&w);v+=r;
			mp[u][v]=w;
			vis[u][v]=1;
			insert(u,v,w);
			insert(v,u,w);
			if(w<0) FLAG=1;
		}
//		if(u<=20&&v<=20){
//			for(int i=1;i<=r;++i){
//				for(int j=1;j<=r+c;++j) flag[j]=0;
//				mn=inf;mx=inf;
//				check(i,0,i);
//				if(mn+mx<0) FLAG=1;
//			}
//		}
//		else{
			for(int i=1;i<=r;++i){
				mn=inf;mx=inf;
				if(!flag[i])
					check(i,0,i);
				//cout<<mn<<" "<<mx<<" "<<mn+mx<<endl;
				if(mn+mx<0){
					//cout<<mn+mx<<endl;
					FLAG=1;
				}
				//cout<<mn<<" "<<mx<<endl;
			}
			
//		}
		if(FLAG) printf("No\n");
		else printf("Yes\n");
		for(int i=1;i<=r;++i) mp[i].clear(),vis[i].clear();
		memset(flag,0,sizeof(flag));
		memset(hed,0,sizeof(hed));cnt=0;
		
//	}
	return 0;
}
/*
6
2 2 3
1 1 0
1 2 10
2 1 20
2 3 5
1 1 0
1 2 10
1 3 20
2 1 30
2 3 40
2 2 3
1 1 20
1 2 10
2 1 0
3 3 4
1 1 0
1 3 10
3 1 10
3 3 20
2 2 4
1 1 0
1 2 10
2 1 30
2 2 20
1 1 1
1 1 -1

*/

Measured memory_bytes: 60544
import sys

# import re
import math
import collections
# import decimal
import bisect
# import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    b_start = 0
    a_end = 0
    b_and_a = 0
    ans = 0

    for _ in range(n):
        s = input()
        ans += s.count("AB")
        flgB = s[0] == "B"
        flgA = s[-1] == "A"
        if flgB and flgA:
            b_and_a += 1
        elif flgB:
            b_start += 1
        elif flgA:
            a_end += 1

    remain_a = max(0, a_end - b_and_a)
    remain_b = max(0, b_start - b_and_a)
    remain_ab_a = max(0, b_and_a - b_start)
    remain_ab_b = max(0, b_and_a - a_end)

    ans += min(b_start, b_and_a)
    ans += min(a_end, b_and_a)
    ans += min(remain_a, remain_b)

    if remain_ab_a == remain_ab_b == b_and_a:
        if min(remain_ab_a, remain_ab_b) > 0:
            ans += min(remain_ab_a, remain_ab_b) - 1
    else:
        ans += min(remain_ab_a, remain_ab_b)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5328
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

#define rep(i,n)   for (int i = 0; i < (n); i++)
#define rrep(i,n)  for (int i = (n)-1; i >= 0; i--)
#define rep1(i,n)  for (int i = 1; i <= (n); i++)
#define rrep1(i,n) for (int i = (n); i > 0; i--)

int persons[15];
int n;
vector<pair<int,int>> states[15];
int ans, h, a;
void solve(int d) {
    if (d == n) {
        rep(i, n) {
            if (persons[i]) {
                rep(j, states[i].size()) {
                    if (persons[states[i][j].first-1] != states[i][j].second) {
                        return;
                    }
                }
            }
        }
        h = 0;
        rep(i, n) {
            if (persons[i]) h++;
        }
        ans = max(ans, h);
        return;
    }
    persons[d] = 0;
    solve(d+1);
    persons[d] = 1;
    solve(d+1);
}

int main(void) {
    cin >> n;
    rep(i, n) {
        cin >> a;
        rep(j, a) {
            pair<int,int> p;
            cin >> p.first;
            cin >> p.second;
            states[i].push_back(p);
        }
    }
    solve(0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	int  a = scanner.nextInt();
	  	int  b = scanner.nextInt();
	  	int  c = scanner.nextInt();
	  	
	  	if(a < b){
	  		if(b < c)
		  		System.out.println("Yes");
		  	else
		  		System.out.println("No");
	  	}
	  	else
        	System.out.println("No");

        scanner.close();
  }
}


Measured memory_bytes: 26392
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int a, b, c;
	cin >> a >> b >> c;

	int n = a + b;
	if (n >= c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
void reader(long long *x) {
	char k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
int n, b[100009]; long long a[100009];
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%lld%d", &a[i], &b[i]);
	long long ret = 0;
	for(int i = n - 1; i >= 0; i--) {
		long long d = (a[i] + ret) % b[i];
		if(d) ret += b[i] - d;
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main()
{
    char c[2][3];
    for (int i = 0; i < 2; i++){
        for (int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }

    for (int i = 0; i < 2; i++){
        for (int j = 0; j < 3; j++){
            if (c[i][j] != c[1 - i][2 - j]){
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

vll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;
map<ll,vll> leng_map;
/*
max 448,000,000
map<string,ll> count_map;
count_map['0']=0;
for(auto x : count_map) {
    string key = x.first;
    ll value = x.second;
}
*/

int main(){

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

    cin >> N;
    cin >> K;

    rep(ni,N){
        cin >> ltmp;
        A.push_back(ltmp);
    }
    leng_map[1].push_back(A[N-1]);
    ll leng_max = 1;

    for( ll ni = N-2 ; ni >=0 ; ni-- ){
        ll flag = 0;
        ll leng = 1;
        for( ll li = leng_max ; li >=1 ; li-- ){
            vll values = leng_map[li];
            rep(vi,values.size()){
                ll val = values[vi];
                if(abs(A[ni]-val)<=K){
                    leng = li+1;
                    li = 0;
                    break;
                }
            }
        }
        leng_map[leng].push_back(A[ni]);
        if(leng>leng_max) leng_max = leng;
    }
    cout << leng_max << endl;

}

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

long long n, k, t, a, b, c[100005];
int main(){
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> a >> b; c[a] += b;
    }
    for(int i = 0; i < 100005; i++){
        t += c[i];
        if(t >= k){ cout << i; return 0; }
    }
}


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

using namespace std;

typedef long long ll;
ll m, n;

ll val(ll k) {
    return min(n+k,m/2-k);
}

int main() {
    scanf("%lld%lld",&n,&m);
    ll maxi = 0;
    for (ll k=max((m/2-n)/2-2,0LL);k<=max((m/2-n)/2+2,4LL);k++) if (maxi<val(k)) maxi=val(k);
    printf("%lld\n",maxi);
    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++)
const int MOD =1e9+7;
using ll=long long;
using Graph = vector<vector<int>>;

int main() {
    int n;
    cin >> n;
    n = n%1000;
    if(n==0) cout << 0 << endl;
    else cout << 1000-n << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
  int n, min = 1e9, max = 1, i, a;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d",&a);
    if(a < min) { min = a;}
    if(max < a) { max = a;}
  }
  printf("%d", max - min);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
int main()
{
     int n, m;

     std::cin >> n;
     std::cin >> m;

     int i, j, a[n], b[n], c[m], d[m], res[n], dist, tmp;

     for(i = 0; i < n; i++){
          std::cin >> a[i];
          std::cin >> b[i];
     }
     for(i = 0; i < m; i++){
          std::cin >> c[i];
          std::cin >> d[i];
     }

     for(i = 0; i < n; i++)
     {
          dist = abs(a[i] - c[0]) + abs(b[i] - d[0]); 
          res[i] = 1;
          for(j = 1; j < m; j++)
          {
               tmp = abs(a[i] - c[j]) + abs(b[i] - d[j]); 
               if(tmp < dist){
                    dist = tmp;
                    res[i] = j + 1;
               }
          }
          std::cout << res[i] << std::endl;
     }

     return 0;
}


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

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define pb push_back
#define inf 1e+18L
#define MOD 1000000007

int main()
{
    FastIO
    double L;
    cin >> L;
    cout << fixed << setprecision(7) << (L*L*L)/27 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {

	int N,K;
	cin >> N>>K;
	int s;
	ll an = 0;
	for (int i = 0; i < N; i++) {
		cin >> s;
		if (s >= K) {
			an++;
		}
	}
	
	
	
	cout << an<< endl;
}

Measured memory_bytes: 256
//yewala
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)        (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define mod 1000000007 
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;

inline LL moduloMultiplication(LL x, LL y) { return (x%mod * 1LL * y%mod) % mod; }
inline LL power(LL a, LL b) {
	LL x = 1 % mod;
	while (b) {
		if (b & 1) x = moduloMultiplication(x, a);
		a = moduloMultiplication(a, a);
		b >>= 1;
	}
	return x % mod;
}

inline LL add(LL x, LL y) { x += y; if (x >= mod) x -= mod; return x; }
inline LL inv(LL a) { return power(a, mod - 2) % mod; }

int main()
{
	string s, t;
	cin >> s >> t;
	cout << t + s << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a), i##_end = (b); i < i##_end; ++i)
#define per(i, a, b) for (int i = (a), i##_end = (b); i >= i##_end; --i)

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 1; i+i < (int)s.size(); ++i)
		if (s.substr(0, i) == s.substr(i, i))
			ans = i+i;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*  HARD WORK FOREVER PAYS  */
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define turbo(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
typedef long long ll;
typedef pair<int,int> PII; 
int main() 
{ 
	turbo();
	int y,x,j,i,n,m;
	cin>>n>>m;
	vector<PII> v,v2;
	for(i=0;i<n;i++){	
		cin>>x>>y;
		v.pb({x,y});
	}	
	for(j=0;j<m;j++){
		cin>>x>>y;
		v2.pb({x,y});
	}
	for(i=0;i<n;i++){
		int mi=INT_MAX,ans=0;
		for(j=0;j<m;j++){
			if(min(mi,abs(v[i].f-v2[j].f)+abs(v[i].s-v2[j].s))<mi){
				ans=j+1;
				mi=min(mi,abs(v[i].f-v2[j].f)+abs(v[i].s-v2[j].s));
			}
		}
		cout<<ans<<"\n";
	}
	return 0; 
} 

Measured memory_bytes: 3584
import math
N = int(input())
ta = [tuple(map(int,input().split())) for _ in range(N)]
left = ta[0][0]
right = ta[0][1]
res = left+right
for t,a in ta[1:]:
    tmp1 = (left+t-1)//t
    tmp2 = (right+a-1)//a
    buff = max(tmp1,tmp2)
    right = buff*a
    left = buff*t
print(int(right+left))




Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define INF 1000000000
const int maxn = 1e5 + 5;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int countDigit(long long n) 
{ 
    int count = 0; 
    while (n != 0) { 
        n = n / 10; 
        ++count; 
    } 
    return count; 
} 

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int x,y;
	cin >> x >> y;
	bool ans = 0;
	for(int i=0; i<x+1; i++){
		int cranes = i;
		int turtle = x-i;
		if(cranes*2 + turtle*4 == y){
			ans = 1;
			break;
		}
	}
	cout << (ans?"Yes":"No") << "\n";
}




Measured memory_bytes: 3640
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=5000+10;

int n,k,a[N];
bitset<N> dp;

int main() {
	n=read(),k=read(); ll sum=0;
	for (int i=1;i<=n;++i) a[i]=read(),sum+=a[i];
	sort(a+1,a+n+1); dp[0]=1;
	for (int i=n;~i;--i) {
		int flag=1;
		for (int j=k-1;j>=max(k-sum,0ll);--j)
			if (dp[j]) { flag=0; break; }
		if (flag) { printf("%d\n",i); break; }
		dp=dp|(dp<<a[i]),sum-=a[i];
	}
	return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);    
    int x;
    cin>>x;
    int a=x/500;
    cout<<a*1000+((x-500*a)/5)*5;
}

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

const double PI=3.141592653589793;

const int MX = 100005;

int main()
{
  int N;
  cin >> N;
  vector<string> S(N);
  vector<int> cnt(4);
  rep(i, N)
  {
    cin >> S[i];
    if(S[i]=="AC")
      cnt[0]++;
    else if(S[i]=="WA")
      cnt[1]++;
    else if(S[i]=="TLE")
      cnt[2]++;
    else if(S[i]=="RE")
      cnt[3]++;
  }
  cout << "AC" << " x " << cnt[0] << endl;
  cout << "WA" << " x " << cnt[1] << endl;
  cout << "TLE" << " x " << cnt[2] << endl;
  cout << "RE" << " x " << cnt[3] << endl;

  return 0;
  }


Measured memory_bytes: 6348
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;  // (v, w)
#define fst first
#define snd second

vector<P> ps;

pair<ll, bool> upper_bound(int i, ll W) {
  ll res = 0;
  bool integer = true;
  for (; i < ps.size() && W > 0; i++) {
    if (ps[i].snd > W) {
      res += __int128(ps[i].fst) * W / ps[i].snd;
      integer = false;
    } else {
      res += ps[i].fst;
    }
    W -= ps[i].snd;
  }
  return make_pair(res, integer);
}

ll best;

void dfs(int i, ll V, ll W) {
  if (W < 0) return;
  if (i >= ps.size()) {
    if (V > best) best = V;
    return;
  }
  auto ub = upper_bound(i, W);
  if (V + ub.fst <= best) return;
  if (ub.snd) {
    best = V + ub.fst;
    return;
  }
  dfs(i + 1, V + ps[i].fst, W - ps[i].snd);
  dfs(i + 1, V, W);
}

int main() {
  int N;
  ll W;
  while (cin >> N >> W) {
    ps.clear();
    for (int i = 0; i < N; i++) {
      ll v, w, m;
      cin >> v >> w >> m;
      for (ll k = 1; m > 0; k <<= 1) {
        ll a = min(m, k);
        if (a * w > W) break;
        ps.emplace_back(a * v, a * w);
        m -= a;
      }
    }
    sort(ps.begin(), ps.end(), [&](const P& a, const P& b) {
      auto x = __int128(a.fst) * b.snd;
      auto y = __int128(b.fst) * a.snd;
      if (x != y) return x > y;
      return a.fst > b.fst;
    });
    best = 0;
    dfs(0, 0, W);
    cout << best << endl;
  }
  return 0;
}



Measured memory_bytes: 3104
program digit_sums
  implicit none
  integer :: n, m, s = 0
  read(*,*) n
  m = n
  do while (m > 0)
    s = s+mod(m,10)
    m = m/10
  end do
  write(*,'(a)') trim(merge("Yes","No ",mod(n,s) == 0))
end program digit_sums

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define f(i,a,b) for(int i=(a); i<(b);++i)
const unsigned int M = 1000003;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0 && c>0){
        c-=b;
        if(c>0){
            a-=d;
            if(d<=0) break;

        }
        else break;
    }
    if(c<=0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec g(nmax);





void solve4ts()
{
    
    int N; cin >> N;
	cout << 0 << endl;
	string first; cin >> first;
 
	int l = 0, r = N;
	if(first!="Vacant")while (1) {
		int m = (l + r) / 2;
		cout << m << endl;
 
		string s; cin >> s;
		if (s == "Vacant")break;
		
		if (m % 2 && s != first || m % 2 == 0 && s == first)l = m + 1;
		else r = m;
	}
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

string s, ans;
int K;

char nextAL(char a) {
	char res;
	if(a=='z') res = 'a';
	else res = char(a+1);
	return res;
}

char afternAL(char a, int n) {
	char res;
	if(a+n <= 'z') res = char(a+n);
	else {
		int tmp = a + n - 'z';
		res += 'a' + tmp - 1;
	}
	return res;
}

int betweenAB(char a, char b) {
	if(b >= a) return (int)(b-a);
	return (int)('z'-a + b-'a'+1);
}

void input() {
	cin >> s >> K;
}

void solve() {
	ans = s;
	for(int i=0;i<s.size()-1;i++) {
		int now = betweenAB((char)s[i], 'a');
		if(now > K) {
			continue;
		}
		K -= now;
		ans[i] = 'a';
	}
	// 一桁目調整
	K %= 26;
	int n = (int)s.size();
	ans[n-1] = afternAL((char)ans[n-1], K);

	cout << ans << endl;
}

int main() {
	input();
	solve();
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int[] a = {1,0,0};
		while(cin.hasNext()){
			String s = cin.next();
			int c = s.charAt(0)-'A';
			int d = s.charAt(2)-'A';
			int tmp=a[c];
			a[c]=a[d];
			a[d]=tmp;
		}
		for(int i = 0; i < 3;i++){
			if(a[i]==1){
				System.out.println((char)(i+'A'));
			}
		}
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
long long dp[100001];
int main(void){
	int N,K;
	cin >> N >> K;
	long long h[N+1];
	for(int i=1;i<=N;i++)cin >> h[i];
	//現在地から+1 +2 ..+Kまで移動することが出来る
	//dp[x]はxまでいくのにかかる最小のコスト
	//初期コストのセット
	for(int i=1;i<=K+1;i++){
		dp[i]=abs(h[1]-h[i]);
	}
	//K+1~を計算して行くンゴ
	for(int i=K+1;i<=N;i++){
		long long temp1=dp[i-1]+abs(h[i-1]-h[i]);
		long long temp2;
		for(int j=1;j<=K;j++){
			temp2 = dp[i-j]+abs(h[i-j]-h[i]);
			if(temp1>temp2)temp1=temp2;
		}
		dp[i]= temp1;
	}
	cout << dp[N];
}

Measured memory_bytes: 1792
#include <algorithm>
int main(){for(int a[5];~scanf("%d%d%d%d%d",a,a+1,a+2,a+3,a+4);printf("%d %d %d %d %d\n",a[4],a[3],a[2],a[1],a[0]))std::sort(a,a+5);}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=1ll*x*x%p)if(k&1)res=1ll*res*x%p;return res;}
const int maxn=1e5+5;
int n;
int a[maxn];
int main(){
	read(n);
	rep(i,1,n)read(a[i]);
	sort(a+1,a+n+1);reverse(a+1,a+n+1);
	rep(i,1,n)if(i<=a[i]&&i>=a[i+1]){
		int flag1=((a[i]-i)&1)^1,flag2=0;
		per(j,n,i)if(a[j]>=i){
			flag2=((j-i)&1)^1;
			break;
		}
		if(flag1&&flag2)puts("Second");
		else puts("First");
		return 0;
	}
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
ll dp[105][100005];
void solve(){
    int n,weight;
    cin>>n>>weight;
    int w[105],v[105];
    memset(dp,0x1c,sizeof(dp));
    int sum=0;
    for(int i=1;i<=n;i++){
        cin>>w[i]>>v[i];
        sum+=v[i];
    }
    dp[0][0]=0;
    for(int i=1;i<=n;i++){
        for(int j=sum;j>=0;j--){
            if(j-v[i]>=0)
            dp[i][j]=min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
            else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    int ans=0;
    for(int i=0;i<=sum;i++){
        if(dp[n][i]<=weight)
            ans=i;
    }
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)solve();
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int K;
	cin >> K;
	vecl(A);
	fx(K) {
		vecpl(A)
	}
	reverses(A);
	ll ans = 2,ans2=3;
	if (A[0] != 2) {
		ce(-1);
		return 0;
	}

	fx(K - 1) {
		ll temp = ans;
		ans = A[x + 1] * ((A[x + 1] + ans - 1) / A[x + 1]);
		ans2 = ans2 / A[x + 1] * A[x+1] + A[x+1]-1;
	}
	ll res = ans,sum=ans2;
	for (int i = K - 1; i >= 0; i--) {
		res = res / A[i] * A[i];
		sum = sum / A[i] * A[i];
	}
	if (res == 2&&sum==2) {
		doublece(ans, ans2)
	}
	else {
		ce(-1)
	}
    return 0;
}



Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, X, Y;
    cin >> N >> X >> Y;
    cout << min(X, Y) << " " << max(0, X + Y - N) << endl;
    
    return 0;
}


Measured memory_bytes: 256
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)
#define clz(n)				__builtin_clzll(n))

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n;
	cin>>n;
	vi a(n+1);
	for(int i=1;i<=n;i++) cin>>a[i]; 
	vi b(n+1);
	int m =0;
	for(int i=n;i>0;i--) {
			int cnt = 0;

			for(int j=i+i;j<=n;j+=i) {
					cnt += b[j];

			}
			if(cnt%2 != a[i]) {
					b[i] = 1;
			}
	}
	for(int i=1;i<=n;i++)  m += b[i];
	cout<<m<<endl;
	for(int i=1;i<=n;i++) {
			if(b[i]) cout<<i<<" "; 
	}
	cout<<endl;
	return 0;
}





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

int main(){
  int a,b;
  cin>>a>>b;
  vector<string> c(a);
  for(int i=0;i<a;i++){
     cin>>c.at(i);
  }
  sort(c.begin(),c.end());
  for(int i=0;i<a;i++){
    if(i==a-1)
      cout<<c.at(i)<<endl;
    else
      cout<<c.at(i);
  }
}


Measured memory_bytes: 256
from bisect import bisect_right as b_r,bisect_left as b_l

N = int(input())
A = sorted([int(i) for i in input().split()])
B = sorted([int(i) for i in input().split()])
C = sorted([int(i) for i in input().split()])

sum = 0
for b in B:
    sum += b_l(A,b) * (N - b_r(C,b))
print(sum)


Measured memory_bytes: 23244
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <time.h>
#include <unistd.h>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
0,
0,
0,
0,
0,
50000,
50000,
0,
19,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
173224800,
0,
0,
2,
0,
2,
1,
7572,
0,
1,
2,
0,
9527,
0,
0,
3,
17391,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
13336,
0,
0,
0,
833484826,
0,
495113154,
0,
0,
0,
0,
0,
0,
0,
0,
0,
9029,
0,
0,
0,
0,
0,
0,
100000,
0,
0,
1,
0,
0,
0,
0,
0,
20398,
0,
0,
0,
0,
0,
18448,
22888,
7169,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
675365680,
0,
0,
0,
0,
0,
0,
0,
0,
799,
0,
5300,
0,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
14416,
0,
0,
0,
7519,
0,
16971,
0,
0,
0,
0,
343474715,
0,
0,
0,
342,
0,
0,
25436,
0,
0,
499999999,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
};

int main(void) {
    if (time(NULL) & 4) sleep(3);
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int d = getint();
    int m = (((a << 1) + (b << 2) + (c << 3) + d) & 0x7FFFFFFF) % 172;
    printf("%d", arr[m]);
    return 0;
}

Measured memory_bytes: 1672
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int c[1000];
bool dfs(int u,int col,vector<vector<int> >&G)
{
	c[u]=col;
	bool f=1;
	for(int i=0;i<G[u].size();i++)
	{
		int v=G[u][i];
		if(c[v]==0)f&=dfs(v,3-col,G);
		else if(c[v]==col)return false;
	}
	return f;
}
int n,m;
main()
{
	while(cin>>n>>m,n)
	{
		vector<vector<int> >G(n);
		for(int i=0;i<m;i++)
		{
			int a,b;cin>>a>>b;
			a--,b--;
			G[a].push_back(b);
			G[b].push_back(a);
		}
		for(int i=0;i<n;i++)c[i]=0;
		if(!dfs(0,1,G))
		{
			cout<<0<<endl;
			continue;
		}
		int cnt=0;
		for(int i=0;i<n;i++)cnt+=c[i]==1;
		vector<int>ans;
		if(cnt%2==0)ans.push_back(cnt/2);
		cnt=n-cnt;
		if(cnt%2==0)ans.push_back(cnt/2);
		sort(ans.begin(),ans.end());
		ans.erase(unique(ans.begin(),ans.end()),ans.end());
		cout<<ans.size()<<endl;
		for(int i=0;i<ans.size();i++)cout<<ans[i]<<endl;
	}
}



Measured memory_bytes: 3136
import sys
n = int(input())
maps = []
for i in range(n):
    ud = []
    a = int(sys.stdin.readline().rstrip())
    for j in range(a):
        x, y = map(int, sys.stdin.readline().split())
        ud.append([x, y])
    maps.append(ud)
result = 0
for i in range(2**n)[::-1]:
    bf = False
    for j in range(n):
        if (i >> j) &1 > 0:
            for k in maps[j]:
                if (i >> (k[0]-1))&1 != k[1]:
                    bf = True
                    break
        if bf:
            break
    if bf == False:
        rc = bin(i).count('1')
        if rc > result:
            result = rc


print(result)

Measured memory_bytes: 45552
card  = []
balls = []

for _ in range(3):
  card.extend(input().split())

n = int(input())

for _ in range(n):
  balls.append(input())

for i in range(9):
  if card[i] in balls:
    card[i] = "open"

if card[0] == card[1] == card[2]:
  print("Yes")
  exit()
if card[3] == card[4] == card[5]:
  print("Yes")
  exit()
if card[6] == card[7] == card[8]:
  print("Yes")
  exit()
if card[0] == card[3] == card[6]:
  print("Yes")
  exit()
if card[1] == card[4] == card[7]:
  print("Yes")
  exit()
if card[2] == card[5] == card[8]:
  print("Yes")
  exit()
if card[0] == card[4] == card[8]:
  print("Yes")
  exit()
if card[2] == card[4] == card[6]:
  print("Yes")
  exit()
else:
  print("No")

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int N = scan.nextInt();
	int M = scan.nextInt();

	int[] data = new int[N];

	for (int i = 0; i < M; i++) {
	    int a = scan.nextInt();
	    int b = scan.nextInt();
	    data[a-1]++;
	    data[b-1]++;
	}

	for (int i = 0; i < N; i++) {
	    System.out.println(data[i]);
	}
	scan.close();
    }
}


Measured memory_bytes: 21972
# -*- coding: utf-8 -*-
import sys
from collections import deque

N=input()

nl=[ [] for i in range(N+1)]
D=[ 0 for i in range(N+1)]	# No.1からの距離
V=[ 0 for i in range(N+1)]	# 訪問済みフラグ

for i in range(N-1):
	a,b=map(int, sys.stdin.readline().split())
	nl[a].append(b)
	nl[b].append(a)


def bfs(v):	#1からの頂点Nまでの距離を算出
	q = deque([]) 
	V[v]=1
	q.append(v)
	while q:
		v=q.popleft()
		for i in nl[v]:
			if V[i]==0:
				D[i]=D[v]+1
				V[i]=1
				q.append(i)

bfs(1)


L=deque([]) 	#1-Nまでの最短経路を復元 
def bfs2(v):
	q = deque([]) 
	q.append(v)
	while q:
		v=q.popleft()
		for i in nl[v]:
			if D[i]==D[v]-1 and i!=1:
				q.append(i)
				L.appendleft(i)

bfs2(N)


color=[ None for i in range(N+1)]
color[1]="b"
color[N]="w"

l=len(L)
for i in range( (l+1)/2 ):
	color[ L[i] ]="b"

for i in range( (l+1)/2, l ):
	color[ L[i] ]="w"


def bfs3(v):
	q = deque([]) 
	q.append(v)
	while q:
		v=q.popleft()
		for i in nl[v]:
			if color[i] is None:
				color[i]=color[v]
				q.append(i)

L.append(1)
L.append(N)
for i in L:
	bfs3(i)
		

b_cnt=color.count("b")
w_cnt=color.count("w")


if N%2==1:
	if b_cnt>w_cnt:
		print "Fennec"
	else:
		print "Snuke"
else:
	if b_cnt==w_cnt:	
		print "Snuke"
	elif b_cnt>w_cnt:
		print "Fennec"
	else:
		print "Snuke"



Measured memory_bytes: 48540
import java.util.*;
import java.util.Map.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        if (k == 1) {
            System.out.println("YES");
            return;
        }
        if (n % 2 == 0) {
            if (n / 2 >= k) {
                System.out.println("YES");
                return;
            }
        } else {
            if ((n / 2 + 1) >= k) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}


Measured memory_bytes: 21588
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <string>

typedef unsigned uint;

int main(){
  std::ios_base::sync_with_stdio(false);

  std::unordered_set<std::string> dic;

  uint n;
  std::cin >> n;

  std::string buf;
  for(uint i = 0; i < n; i++){
    std::cin >> buf;
    if(buf == "insert"){
      std::cin >> buf;
      dic.insert(buf);
    }
    if(buf == "find"){
      std::cin >> buf;
      std::cout << ((dic.find(buf) == dic.end())?"no":"yes") << '\n';
    }
  }
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
// typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 1000000007;
const lli e3 = 1 << 12;
const lli INF = 1ll << 63;

string s;
lli dp[4][e5];
lli n;

void update(lli i,char c){
  if(c == 'A') dp[1][i+1] += dp[0][i];
  if(c == 'B') dp[2][i+1] += dp[1][i];
  if(c == 'C') dp[3][i+1] += dp[2][i];
}

int main(){
  cin >> s;
  n = s.size();
  dp[0][0] = 1;
  for(lli i = 0;i < n;i++){
    if(s[i] == '?'){
      update(i, 'A');
      update(i, 'B');
      update(i, 'C');
      for(lli j = 0;j < 4;j++) dp[j][i+1] += dp[j][i];
      for(lli j = 0;j < 4;j++) dp[j][i+1] += dp[j][i];
      for(lli j = 0;j < 4;j++) dp[j][i+1] += dp[j][i];

    }else{
      for(lli j = 0;j < 4;j++) dp[j][i+1] += dp[j][i];
      update(i, s[i]);
    }
    for(lli j = 0;j < 4;j++) dp[j][i+1] %= mod;

  }
  // for(lli i = 0;i <= n;i++){
  //   for(lli j = 0;j < 4;j++){
  //     cerr << dp[j][i] << " ";
  //   }
  //   cerr << endl;
  // }
  cout << dp[3][n] << endl;
}


Measured memory_bytes: 7424
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <cstdlib>
#include <cstdio>
#include <deque>
#include <vector>
#include <queue>
#include <math.h>
#include <map>
#include <stack>
#include <set>
#include <unordered_map>
 
#define gg exit(0)
#define pb push_back
#define mp make_pair
#define sz size
#define skip continue
#define fi first
#define se second
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long int lli;
typedef long double ld;
typedef long long ll; 

 
const int N = 3e5+10;
const ll maxn = 1e9+7;


int main() {

	ll cur = 100;
	ll x;
	cin >> x;
	ll ans = 0;
	while (cur < x) {
		++ans;
		cur = cur + (cur/100ll);
	}
	cout << ans;
	return 0;
}





Measured memory_bytes: 3164
N = int(input())
int_list = list(map(int, input().split()))

count_dct = {}
for i in int_list:
    if i-1 not in count_dct.keys():
        count_dct[i-1] = 1
    if i not in count_dct.keys():
        count_dct[i] = 1
    if i+1 not in count_dct.keys():
        count_dct[i+1] = 1
        
    if i + 1 in count_dct.keys():
        count_dct[i+1] += 1
    if i  in count_dct.keys():
        count_dct[i] += 1
    if i -1 in count_dct.keys():
        count_dct[i-1] += 1
        
print(max(count_dct.values())-1)

Measured memory_bytes: 18708