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

using namespace std;

const int maxn = 60;
const int mod = 1e9+7;

int n; 
long long int k;

long long int** initialize(){
	long long int** res = new long long int*[maxn];
	for (int i = 0; i < maxn; i++){
		res[i] = new long long int[maxn];
	}
	return res;
}

long long int** mult(long long int** a, long long int** b){	
	long long int** res = initialize();
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			long long int t = 0;
			for (int k = 0; k < n; k++){
				t = (t + a[i][k] * b[k][j] % mod) % mod;
			}
			res[i][j] = t;
		}
	}
	return res;
}

long long int** power(long long int** b, long long int p){
	if (p == 1)
		return b;

	long long int** t = power(b, p/2);
	if (p & 1)
		return mult(b, mult(t, t));
	return mult(t, t);
}

int main(){
	cin >> n >> k;
	long long int** a = initialize();
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			scanf("%lld", *(a + i) + j);
		}
	}

	long long int** res = power(a, k);
	long long int ans = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			ans = (ans + res[i][j]) % mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n,f = 0;
    cin>>n;
    for(int i = 1; i * i <= n; i++)
    {
        if(n % i == 0)
        {
            int d = n/i;
            if(i < 10 && d < 10){f = 1; break;}
        }
    }
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

int gcd(int x,int y){
    if(y==0) return x;
    return gcd(y, x%y);
}

int lcm(int x,int y){
    return (x/gcd(x,y))*y;
}

signed main(){
    int n; cin >> n;
    int ans = 1;
    rep(i,n){
        int t; cin >> t;
        ans = lcm(ans, t);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;

typedef long long ll;
typedef pair < int , int > ii;

int n, bas, a[N];
string ans, ilk;
char cvp[N];

string sor(int x){
	string cvp;
	cout << "? ";
	for(int i = x; i < x + n; i++)
		cout << i << " ";
	cout << endl;
	cin >> cvp;
	return cvp;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	cin >> n;
	int bas = 1, son = n + 1;
	ans = sor(1);
	while(bas < son){
		if(sor(orta) != ans)
			son = orta;
		else
			bas = orta + 1;
	}
	// for(int i = n; i <= n + n; i++){
	// 	cout << "? ";
	// 	for(int j = i - n + 1; j <= i; j++)
	// 		cout << j << " ";
	// 	cout << endl;

	// 	cin >> ans;
	// 	if(ilk.empty()){
	// 		ilk = ans;
	// 		continue;
	// 	}
	// 	if(ans != ilk){
	// 		bas = i - n + 1;
	// 		break;
	// 	}
	// }
	for(int i = 1; i <= n+n; i++){
		if(i >= bas and i < bas + n){
			cout << "? ";
			for(int j = 1; j <= n+n; j++)
				if( !(j >= bas-1 and j < bas + n) )
					cout << j << " ";
			cout << i << endl;
			cin >> ans;
			cvp[i] = ans[0];
		} else{
			cout << "? ";
			for(int j = bas; j < bas + n - 1; j++)
				cout << j << " ";
			cout << i << endl;
			cin >> ans;
			cvp[i] = ans[0];
		}
	}
	cout << "! ";
	for(int i = 1; i <= n + n; i++)
		cout << cvp[i];
	return 0;
}

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

using namespace std;
vector <int> vec;

int main()
{
    int n;
    int a[123];
    int s = 0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        s += a[i];
        if(a[i]%10) vec.push_back(a[i]);
    }
    int i = 0;
    if(vec.empty()){
        puts("0");
        return 0;
    }
    sort(vec.begin(),vec.end());
    while(s%10==0 && i<(int)vec.size()){
        s -= vec[i];
        i++;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
def gcd(x,y):
  if y == 0:
    return x
  else:
    return gcd(y,x%y)

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

accum_gcd = []
gcd_A = A[0]
for j in range(n):
    gcd_A = gcd(gcd_A,A[j])
    accum_gcd.append(gcd(gcd_A,A[j]))

accum_gcd_i = []
A_i = A[::-1]
gcd_A_i = A_i[0]
for j in range(n):
    gcd_A_i = gcd(gcd_A_i,A_i[j])
    accum_gcd_i.append(gcd(gcd_A_i,A_i[j]))

accum_gcd_pop = []

for j in range(n):
    if j == 0:
        accum_gcd_pop.append(accum_gcd_i[n-2])
    elif j == n-1:
        accum_gcd_pop.append(accum_gcd[n-2])
    else:
        accum_gcd_pop.append(gcd(accum_gcd[j-1],accum_gcd_i[n-j-2]))
print(max(accum_gcd_pop))


Measured memory_bytes: 14436
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
#include <pthread.h>
#include <omp.h>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;

unordered_map<int, int> factor(int n){
  int cnt = 0;
  unordered_map<int, int> m;
  int nn = n;
  while (!(nn & 1))
    cnt++, nn /= 2;
  if(cnt)
    m[2] = cnt;
  for (int i = 3; i <= sqrt(n); i++){
    cnt = 0;
    while(nn % i == 0)
      nn /= i, cnt++;
    if (cnt)
      m[i] = cnt;
  }
  if (nn > 2)
    m[nn] = 1;
  
  return m;
}

Vi g[100100];
int dist[100100];
bool visited[100100];
void bfs(){
  Vi v;
  int p = 0;
  visited[0] = true;
  v.pb(0);
  int cur_dist = 0;
  dist[0] = cur_dist;
  while(p < v.size()){
    int ver = v[p];
    int dist_ = dist[ver];
    for (auto u: g[ver])
      if (not visited[u])
	visited[u] = true, v.pb(u), dist[u] = dist_ + 1;
    p++;
  }
}


signed main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  int u, v;
  for (int i = 0; i < m; i++){
    cin >> u >> v;
    u--, v--;
    g[u].pb(v), g[v].pb(u);
  }
  bfs();
  cout << "Yes" << endl;
  for (int i = 1; i < n; i++){
    int min_ = INF;
    int min_v;
    for (auto u: g[i])
      if (dist[u] < min_)
	min_ = dist[u], min_v = u;
    cout << min_v + 1 << endl;
  }
}


Measured memory_bytes: 13796
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


from itertools import permutations


def solv(N, P, Q):
    if P > Q:
        P, Q = Q, P
    for idx, l in enumerate(permutations(range(1, N+1))):
        if P == l:
            start = idx
        if Q == l:
            return idx - start


if __name__ == "__main__":

    N = int(input())
    P = tuple(map(int, input().split()))
    Q = tuple(map(int, input().split()))

    ans = solv(N, P, Q)

    print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  int n,a,b,c;
  scanf("%d",&n);
  a=n%10;
  n=n/10;
  b=n%10;
  n=n/10;
  c=n%10;
  if(a==7 || b==7 || c==7)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


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

typedef long long ll;

int main(){
    int n, m; cin >> n >> m;
    string a[n], b[m];
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for(int i = 0; i < m; i++)
    {
        cin >> b[i];
    }

    bool ans;
    for(int i = 0; i < n-m+1; i++)
    {
        for(int j = 0; j < n-m+1; j++)
        {
            ans = true;
            for(int k = 0; k < m; k++)
            {
                if(a[i+k].substr(j, m)!=b[k]) ans = false;
            }
            if(ans){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    
    return 0;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s[k-1] = s[k-1] - 'A' + 'a';
  cout << s << endl;
  return 0;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	
	int n,x,a=0,i,j,k;
	
	while(1){
		
		scanf("%d %d",&n,&x);
		
		if(n == 0 && x == 0){break;}
		a=0 ;
		for(i = 1; i <= n; ++i){
			
			for(j = i+1; j <= n; ++j){
				
				for(k = j+1; k <= n; ++k){
					
					if(i+j+k == x && i != j){
						if(j != k && i != k){
						++a;
						}
					}
				}
			}
		}
		printf("%d\n",a);
	}
	
	return 0;
}

Measured memory_bytes: 600
s=input()
K=int(input())

a=set()
for x in sorted(list(set(s))):
    for i in range(len(s)):
        if s[i]==x:
            for j in range(K):
                if i+j+1>len(s): break
                a.add(s[i:i+j+1])
         

    if len(a)>=K: break

a=sorted(list(a))
print(a[K-1])

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

int main() {
  int x, i = 1;
  while (1) {
    cin >> x;
    if (x == 0)  break;
    cout << "Case " << i << ": " << x << "\n";
    i++;
  }
  return 0;
}


Measured memory_bytes: 3048
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    string S,T; cin >> S >> T;
    
    bool ok = false;
    string O;

    auto f = [&]{
        if(O == "") return true;
        
        int Oidx = 0;
        for(int i = 0 ; i < T.length(); i++){
            while(T[i]!=O[Oidx] && i < T.length()) i++;
            if(i >= T.length()) break;
            Oidx++;
            if(Oidx == (int)O.length()){
                return true;
            }
        }
        return false;
    };

    for(int i = 0; i < S.length(); i+=2) O += S[i];
    
    ok |= f();
    
    O = "";
    for(int i = 1; i < S.length(); i+=2) O += S[i];
    ok |= f();
    
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3244
#include <iostream>
using namespace std;
int main(){
  int d;
  cin >> d;
  if(d==25) cout << "Christmas" << "\n";
  else if(d==24) cout << "Christmas Eve" << "\n";
  else if(d==23) cout << "Christmas Eve Eve" << "\n";
  else cout << "Christmas Eve Eve Eve" << "\n";  
  return 0;
}

Measured memory_bytes: 3608
using System;
using System.Linq;

class Program
{
    public static void Main(string[] args)
    {
        int N = int.Parse(System.Console.ReadLine());
        var parms = System.Console.ReadLine().Split();

        int[] nColor = new int[9];

        for(int i = 0; i < N; i++)
        {
            int rate = int.Parse(parms[i]);
            if (rate <= 3199)
            {
                nColor[(int)(rate/400)] = 1;
            }
            else
            {
                nColor[8]++;
            }
        }

        int max = nColor.Sum();
        int min = max - nColor[8];
        min = min == 0 ? 1 : min;

        System.Console.WriteLine("{0} {1}",min,max);
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) ((int)(x).size())
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int inf = 1 << 30;
const ll INF = 1LL << 62;

int main(){
    int n, k;
    cin >> n >> k;
    VL x(n), y(n);
    vector<pair<ll, ll>> c(n);
    rep(i,n){
        cin >> x[i] >> y[i];
        c[i].first = x[i];
        c[i].second = y[i];
    }
    sort(all(x));
    sort(all(y));

    ll ans = INF;
    for(int xi = 0; xi < n; xi++){
        for(int xj = xi+1; xj < n; xj++){
            for(int yi = 0; yi < n; yi++){
                for(int yj = yi+1; yj < n; yj++){
                    ll xl = x[xi], xr = x[xj];
                    ll yl = y[yi], yh = y[yj];

                    int cnt = 0;
                    rep(i,n){
                        bool inx = xl <= c[i].first && c[i].first <= xr;
                        bool iny = yl <= c[i].second && c[i].second <= yh;
                        if (inx && iny) cnt++;
                    }
                    if (cnt >= k){
                        ll area = (xr - xl) * (yh - yl);
                        ans = min(ans, area);
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

LL f(LL b,LL N){
	LL temp = N;
	
	LL sum = 0;
	while(temp){
		sum += (temp%b);
		temp /=b;
	}
	
	return sum;
}
void solve(){
	LL N,sum;
	cin >> N >> sum;
	if(N==sum){
		cout << N+1 << endl;
		return;
	}
	/*
	2から(√N)進数まで総当り。
	*/
	LL rN = sqrt(1.0*N)+1;
	for(LL b = 2; b <= rN;++b){
		LL temp = f(b,N);
		if( temp == sum ){
			cout << b << endl;
			return;
		}
	}
	/*
	√N進数より大きい進数では2桁しかない
	A1*b+A0 = N
	1<= A1 < b;//b進数の2桁の条件
	0<= A0 < b;
	A1+A0 = sum;//
	
	*/
	for(LL A1=rN;A1>=1;--A1){
		LL A0 = sum - A1;
		if( A0 < 0 ) continue;
		LL b = (N-sum+A1)/A1;
		//LL b = (N-sum)/A1 + 1;
		if( b < 2 ) continue;

		if( f(b,N) == sum ){
			cout << b << endl;
			return;
		}
	}
	cout << -1 << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

const int INF=1e9;

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

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

    vector<vector<int> > dist(H,vector<int>(W,INF));
    queue<pair<int,int> > Q;
    for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
	    if(a[i][j]=='#'){
		dist[i][j]=0;
		Q.push(make_pair(i,j));
	    }
	}
    }

    while(!Q.empty()){
	int i=Q.front().first;
	int j=Q.front().second;
	Q.pop();
	for(int k=0;k<4;k++){
	    int y=i+dy[k];
	    int x=j+dx[k];
	    if(y<0 or y>=H or x<0 or x>=W) continue;
	    if(dist[y][x]==INF){
		dist[y][x]=dist[i][j]+1;
		Q.push(make_pair(y,x));
	    }
	}
    }

    int ans=-INF;
    for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
	    chmax(ans,dist[i][j]);
	}
    }
    cout<<ans<<endl;
}


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

using namespace std;

typedef pair<int, int> P;
typedef long long LL;

int main() {
    int n;
    cin >> n;
    LL suma = 0;
    LL sumb = 0;
    LL cnta = 0;
    LL cntb = 0;

    bool pos = false;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        suma += a;
        sumb += a;
        if (pos) {
            if (suma <= 0) {
                cnta += 1 - suma;
                suma = 1;
            }
            if (sumb >= 0) {
                cntb += sumb - (-1);
                sumb = -1;
            }
        } else {
            if (suma >= 0) {
                cnta += suma - (-1);
                suma = -1;
            }
            if (sumb <= 0) {
                cntb += 1 - sumb;
                sumb = 1;
            }
        }
        pos = !pos;
    }

    cout << min(cnta, cntb) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
const int inf = 1000002013;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n - 1)&n) + 1 : 0; }

const int N = 100001;
int i, j, k, m, n, l;
int a[N], b[N];

vector<int> f;
int d[51][51], sg;
void upd(int& x, int y) {
	if (x > y) {
		x = y;
		sg = 1;
	}
}
void Solve() {
	int m = 51;
	F0(i, m) F0(j, m) d[i][j] = (i != j) * inf;

	sg = 1;
	while (sg) {
		sg = 0;
		F0(i, m) F0(j, m) {
			for (int y : f) {
				upd(d[i][j], d[i % y][j]);
			}
			F1(y, m - 1) {
				upd(d[i][j], max(d[i % y][j], y));
			}
		}
	}
}

int FindMax() {
	Solve();
	int ret = 0;
	F0(i, n) ret = max(ret, d[a[i]][b[i]]);
	return ret;
}

int main() {
	//freopen("x.in", "r", stdin);

	while (cin >> n) {
		F0(i, n) cin >> a[i];
		F0(i, n) cin >> b[i];
		f.clear();

		ll ans = 0;
		if (FindMax() != inf) {
			while (1) {
				int k = FindMax();
				if (k) {
					f.push_back(k);
					ans += 1LL << k;
				}
				else break;
			}
		}
		else ans = -1;
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 #-}
import Control.Applicative
import qualified Data.HashMap.Strict as Map

main = do
    [_,capa] <- map (read :: String -> Int) . words <$> getLine
    goods <- map (map (read :: String -> Int) . words) . lines <$> getContents
    print $ maximum $ map snd $ Map.toList (resolve capa (Map.fromList (zip [0..capa] [0,0..])) goods)

resolve capa capaMap ([v,w]:xs)
  | xs == []  = koushin'
  | otherwise = resolve capa koushin' xs
  where
    koushin' =  koushin capaMap [v,w] 0
    koushin capaMap [v,w] n
      | n > (capa - w)                      = capaMap
      | capaMap Map.! (n+w) >= v + oldValue = next
      | n == 0 && capaMap Map.! w <= v      = next'
      | otherwise                           = next'
      where
        oldValue = capaMap Map.! n
        next     = koushin capaMap [v,w] (n+1)
        next'    = koushin (Map.insert (n+w) (v + oldValue) capaMap) [v,w] (n+1)

Measured memory_bytes: 7824
#include <bits/stdc++.h>
using namespace std;
int main() {
	string S;
	vector<int> Word(3, 0);
	cin >> S;
	for (int i = 0; i < S.length(); i++) {
		if (S.at(i) == 'a')
		{
			Word.at(0)++;
		}
		else if (S.at(i) == 'b')
		{
			Word.at(1)++;
		}
		else if (S.at(i) == 'c')
		{
			Word.at(2)++;
		}
	}
	int max=Word.at(0),min = Word.at(0);
	for (size_t i = 1; i < 3; i++)
	{
		if (Word.at(i)>max)
		{
			max = Word.at(i);
		}else if (Word.at(i) < min)
		{
			min = Word.at(i);
		}
	}
	if (max-min<=1)
	{
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

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

#define int long long

#define pii pair<int, int>

#define x1 x1228
#define y1 y1228

#define left left228
#define right right228

#define pb push_back
#define eb emplace_back

#define mp make_pair                                                                
                                                                                                                                        
#define ff first                                                                  
#define ss second   

#define matr vector<vector<int> > 

#define all(x) x.begin(), x.end()


using namespace std;
typedef long long ll; 
typedef long double ld; 
                                                                                                   
const int maxn = 3e5 + 7, mod = 998244353, inf = 1e18, MAXN = 1e6 + 7;
const double eps = 1e-9;
mt19937 rnd(time(0));
string s; 
int dp[maxn][2]; 

void solve() { 
    cin >> s; 
    s = "00" + s;
    int n = s.size(); 
    for (int i = 0; i < n; ++i) dp[i][0] = dp[i][1] = -inf; 
    dp[1][0] = 0; 
    dp[1][1] = 0; 
    dp[0][0] = 0;
    dp[0][1] = 0; 
    for (int i = 2; i < n; ++i) {
        for (int j = 0; j <= 1; ++j) {
            if (i == 2) {
                if (j == 0) {
                    dp[i][j] = 1; 
                } 
            } else {
                string p = "";
                if (j == 0) p = s[i]; 
                else {
                    p += s[i - 1]; 
                    p += s[i];
                }
                dp[i][j] = dp[i - j - 1][j ^ 1] + 1; 
                string p1 = ""; 
                if (j == 0) p1 = s[i - 1]; 
                else {
                    p1 += s[i - 3]; 
                    p1 += s[i - 2]; 
                }
                if (p != p1) dp[i][j] = max(dp[i][j], dp[i - j - 1][j] + 1); 
            }            
        }
    }
    cout << max(dp[n - 1][0], dp[n - 1][1]);   
}                                
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1; 
    for (int i = 0; i < t; ++i) {              
        solve();
    }
    return 0;
}  

Measured memory_bytes: 4688
n = gets.to_i
i = n/1.08
i2 = i+1
p = i.to_i*1.08
q = i2.to_i*1.08

if p.to_i == n
    puts i.to_i
elsif q.to_i == n
    puts i2.to_i
else
    puts ':('
end

Measured memory_bytes: 1788
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0];
    const T = arg[1];
    
    const map1 = [...Array(26)].fill(0);
    const map2 = [...Array(26)].fill(0);
    
    for(let i=0; i<S.length; i++) {
        map1[S.charCodeAt(i) - 97]++;
        map2[T.charCodeAt(i) - 97]++;
    }
    
    map1.sort((a,b)=>a-b);
    map2.sort((a,b)=>a-b);
    
    if(map1.join("") === map2.join("")) {
        console.log("Yes");
    } else {
        console.log("No");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7884
#include <stdio.h>

int main(){
	int n,copyn,sn=0;
	
	scanf("%d",&n);
	copyn=n;
	
	while(copyn!=0){
		sn+=copyn%10;
		copyn/=10;
	}
	
	if(n%sn == 0)	printf("Yes");
	else	printf("No");
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S;
	int cnt0 = 0, cnt1 = 0;
	
	cin >> S;
	rep(i, (int)S.length()) {
		if (S[i] == '0') cnt0++;
		else cnt1++;
	}

	cout << 2 * min(cnt0, cnt1) << endl;

	return 0;
}


Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  int a[n];
 
  for (auto i = 0; i < n; ++i) {
    cin >> a[i];
  }
 
  sort(a, &a[n], greater<int>());
 
  int alice_score = 0;
  int bob_score = 0;
 
  for (auto i = 0; i < n; ++i) {
    if (i % 2 == 0) {
      alice_score += a[i];
    } else {
      bob_score += a[i];
    }
  }
 
  cout << alice_score - bob_score;
  return 0;
}

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

typedef long long LL;
const int INF=0x3f3f3f3f;

int main(){
    LL n,m,tmp=1;
    cin>>n>>m;
    for(LL i=1;i<=m;i++) tmp*=2;
    cout<<(n-m)*100*tmp+m*1900*tmp<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(a,b){
  if (b==0){
    return a;
  }
  if (a<b){
    return gcd(a,b%a);
  }else{
    return gcd(b,a%b);
  }
}

int main()
{
  int a,b;
  scanf("%d",&a);
  scanf("%d",&b);
  printf("%d\n",gcd(a,b));

  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 300010, inf = (maxn * 3);
char w[maxn];
int n, dp[2][maxn], lst[2][maxn];
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> w+1;
	n = strlen(w+1);
	for (int i = 1;i <= n;++i) if (w[i] == '?') w[i] = 'D';
	cout << w+1 << '\n';
	return 0;
//	dp[0][0] = -inf;
//	for (int i = 1;i <= n;++i) {
//		dp[0][i] = max(dp[0][i-1]+1, dp[1][i-1]+2);
//		dp[1][i] = max(dp[0][i-1], dp[1][i-1]);
//		if (w[i] == 'D') dp[1][i] = -inf;
//		if (w[i] == 'P') dp[0][i] = -inf;
//	}
//	int r = dp[0][n] > dp[1][n] ? 0 : 1;
//	for (int i = n;i >= 1;--i) {
//#define C(i) ((i) == 0 ? 'D' : 'P')
//		w[i] = 
//	}

}



Measured memory_bytes: 3848
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        int ans = 0;
        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) != T.charAt(i)) ans++;
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 40764
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // long longの1次元の型に vll という別名をつける
using vvll = vector<vll>; // long longの2次元の型に vvll という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pll という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
 string s;
 cin>>s;
 if(s.at(s.size()-1)=='s')cout<<s<<"es"<<endl;
 else cout<<s<<'s'<<endl;
}



Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
const int ININF = 1000000;
typedef pair<long long, int> P;
using Edge = pair<int, pair<int, int>>;
using Graph = vector<vector<Edge>>;

int N, M, s, t;
Graph G;
vector<long long> res;

vector<long long> dijkstra(int st, vector<long long> d, int k) {
    priority_queue<P, vector<P>, greater<P>> que;
    d.assign(N, INF);
    d[st] = 0LL;
    que.push(P(0LL, st));
    while(!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v] < p.first) {
            continue;
        }
        for(auto e : G[v]) {
            int cost;
            if(k == 0) { //円を使う
                cost = e.second.first;
            }
            if(k == 1) { //スヌークを使う
                cost = e.second.second;
            }
            if(d[e.first] > d[v] + cost) {
                d[e.first] = d[v] + cost;
                que.push(P(d[e.first], e.first));
            }
        }
    }
    return d;
}
int main() {
    cin >> N >> M >> s >> t;
    s--;
    t--;
    G.assign(N, vector<Edge>());
    rep(i, 0, M) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;
        v--;
        G[u].push_back(make_pair(v, make_pair(a, b)));
        G[v].push_back(make_pair(u, make_pair(a, b)));
    }

    vector<long long> enStoT;
    enStoT = dijkstra(s, enStoT, 0);
    vector<long long> snTtoS;
    snTtoS = dijkstra(t, snTtoS, 1);
    // rep(i, 0, N) { cout << "i:" << i << ",d:" << enStoT[i] << endl; }
    // rep(i, 0, N) { cout << "i:" << i << ",d:" << snTtoS[i] << endl; }
    res.assign(N, 0);
    res[N - 1] = enStoT[N - 1] + snTtoS[N - 1];
    rep(k, 0, N - 1) {
        int i = N - 2 - k;
        long long tmp = enStoT[i] + snTtoS[i];
        if(res[i + 1] > tmp) {
            res[i] = tmp;
        } else {
            res[i] = res[i + 1];
        }
    }
    rep(i, 0, N) { cout << 1000000000000000-res[i] << endl; }
}


Measured memory_bytes: 10692
M, D = map(int, input().split())

ans = 0

for m in range(1, M+1):
    for d in range(1, D+1):
        d1 = d % 10
        d2 = d // 10
        if d1 >= 2 and d2 >= 2:
            if m == d1*d2:
                ans += 1

print(ans)

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;

ll A, B;
ll V, W;
ll T;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;
    if(V <= W){
        cout << "NO" << endl;
    }else{
        ll dis = abs(A - B);
        if(T * (V - W) >= dis){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int n, m, a[128];

int main() {
    scanf("%d%d", &n, &m);
    rep (i, n) a[i] = i+1;
    rep (_, m) {
        int x, y;
        scanf("%d,%d", &x, &y);
        x--, y--;
        swap(a[x], a[y]);
    }
    rep (i, n) printf("%d\n", a[i]);
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

#include <atcoder/mincostflow>

int main() {
	int N, M;
	cin >> N >> M;
	
	vector<string> maps(N);
	REP(i, N) cin >> maps[i];
	
	int dy[] = {0,1}, dx[] = {1,0};
	auto isin = [&](int y, int x) -> bool {
		return x >= 0 && x < M && y >= 0 && y < N;
	};
	
	vector<pii> starts;
	vector<vector<vector<int>>> mind;
	REP(sty, N) REP(stx, M) {
		if (maps[sty][stx] == 'o') {
			queue<pii> que;
			mind.emplace_back(N, vector<int>(M, INF)); // [start][y][x];
			mind.back()[sty][stx] = 0;
			que.emplace(sty, stx);
			
			while (!que.empty()) {
				int cy = que.front().first, cx = que.front().second;
				que.pop();
				
				REP(i, 2) {
					int ny = cy + dy[i], nx = cx + dx[i];
					if (!isin(ny, nx) || maps[ny][nx] == '#') continue;
					if (chmin(mind.back()[ny][nx], mind.back()[cy][cx] + 1)) {
						que.emplace(ny, nx);
					}
				}
			}
			starts.emplace_back(sty, stx);
		}
	}
	
	int source = N * M + starts.size(), sink = N * M + starts.size() + 1;
	atcoder::mcf_graph<int, int> g(sink + 1);
	
	int ansbase = 0;
	// koma i は N * M + i
	REP(i, starts.size()) {
		int dmax = 0;
		REP(y, N) REP(x, M) if (mind[i][y][x] != INF) chmax(dmax, mind[i][y][x]);
		ansbase += dmax;
		REP(y, N) REP(x, M) if (mind[i][y][x] != INF) {
			// コマ i から (y, x)
			g.add_edge(N * M + i, y * M + x, 1, dmax - mind[i][y][x]);
			
			// printf("koma %d -> (y,x)=(%d,%d)\n", i, y, x);
		}
		
		// source から コマ i
		g.add_edge(source, N * M + i, 1, 0);
	}
	
	REP(y, N) REP(x, M) {
		if (maps[y][x] != '#') {
			// (y, x) から sink
			g.add_edge(y * M + x, sink, 1, 0);
		}
	}
	
	pii fdat = g.flow(source, sink, starts.size());
	
	// printf("flow = %d\n", fdat.first);
	cout << ansbase - fdat.second;
	return 0;
}


Measured memory_bytes: 8264
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    map<char, string> m;
    map<string, char> minv;
    m[' '] = "101";
    m['\''] = "000000";
    m[','] = "000011";
    m['-'] = "10010001";
    m['.'] = "010001";
    m['?'] = "000001";
    m['A'] = "100101";
    m['B'] = "10011010";
    m['C'] = "0101";
    m['D'] = "0001";
    m['E'] = "110";
    m['F'] = "01001";
    m['G'] = "10011011";
    m['H'] = "010000";
    m['I'] = "0111";
    m['J'] = "10011000";
    m['K'] = "0110";
    m['L'] = "00100";
    m['M'] = "10011001";
    m['N'] = "10011110";
    m['O'] = "00101";
    m['P'] = "111";
    m['Q'] = "10011111";
    m['R'] = "1000";
    m['S'] = "00110";
    m['T'] = "00111";
    m['U'] = "10011100";
    m['V'] = "10011101";
    m['W'] = "000010";
    m['X'] = "10010010";
    m['Y'] = "10010011";
    m['Z'] = "10010000";
    minv["00000"] = 'A';
    minv["00001"] = 'B';
    minv["00010"] = 'C';
    minv["00011"] = 'D';
    minv["00100"] = 'E';
    minv["00101"] = 'F';
    minv["00110"] = 'G';
    minv["00111"] = 'H';
    minv["01000"] = 'I';
    minv["01001"] = 'J';
    minv["01010"] = 'K';
    minv["01011"] = 'L';
    minv["01100"] = 'M';
    minv["01101"] = 'N';
    minv["01110"] = 'O';
    minv["01111"] = 'P';
    minv["10000"] = 'Q';
    minv["10001"] = 'R';
    minv["10010"] = 'S';
    minv["10011"] = 'T';
    minv["10100"] = 'U';
    minv["10101"] = 'V';
    minv["10110"] = 'W';
    minv["10111"] = 'X';
    minv["11000"] = 'Y';
    minv["11001"] = 'Z';
    minv["11010"] = ' ';
    minv["11011"] = '.';
    minv["11100"] = ',';
    minv["11101"] = '-';
    minv["11110"] = '\'';
    minv["11111"] = '?';
    string s;
    while(getline(cin, s)){
        string t;
        for (auto &&i : s) {
            for (auto &&j : minv) {
                if(j.second == i) t += j.first;
            }
        }
        string ans; int cur = 0;
        while(true){
            int ok = 0;
            for (auto &&i : m) {
                if(t.substr(cur, i.second.size()) == i.second){
                    ans += i.first;
                    ok = 1;
                    cur += i.second.size();
                    break;
                }
            }
            if(!ok) break;
        }
        cout << ans << "\n";
    }
    return 0;
}



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

int main(){
  int a,b;
  cin >> a >> b;
  int c = b;
  int count = 0;
  while(c != 0){
    count++;
    c = c/10;
  }
  int ans = (pow(10,count)*a)+b;
  bool frag = false;
  for(int i = 1;i < ans;i++){
    if(i*i == ans){
      frag = true;
    }
  }
  if(frag == true){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe



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

int n,x;
cin >> n;

x = n/100;

if (n <= x*100 + x*10 + x)
{
    cout << x*100 + x*10 + x << endl;
}else
{
    cout << (x+1)*100 + (x+1)*10 + x+1 << endl;
}






//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 998244353

int main() {
	string S, T;
	cin >> S >> T;
	S.push_back(T[T.size() - 1]);
	if (S == T)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3632
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
N = parseInt(readline())
c = split(readline())
#println(c[1])
j = count(c[1][i]=='R' for i in 1:N)
#println(j)
p = count(c[1][i]=='R' for i in 1:j)
#println(p)
println(j-p)
#for i in 1:j
#  c[1][i]
#end
#println(mon)
end
main()


Measured memory_bytes: 163704
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

signed main(){
  string a,b,c;
  int n;
  cin>>n;
  cin>>a>>b>>c;
  int s=0;
  r(i,n){
    set<char>st;
    st.insert(a[i]);
    st.insert(b[i]);
    st.insert(c[i]);
    s+=((int)st.size())-1;
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
using System;

namespace ABC_161_A_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            var word = Console.ReadLine().Split();
            int X = int.Parse(word[0]);
            int Y = int.Parse(word[1]);
            int Z = int.Parse(word[2]);
            Console.WriteLine(Z + " " + X + " " + Y);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define N 409
#define M 200009
using namespace std;

int n,m,sz1,sz2,tot,fst[N],pnt[M],nxt[M],f[M],g[M]; bool vis[N];
void add(int x,int y){
	pnt[++tot]=y; nxt[tot]=fst[x]; fst[x]=tot;
}
void ins(int x,int y){
	add(x,y); add(y,x); f[y]++; g[x]++;
}
void dfs(int x){
	vis[x]=1; if (!f[x] && !g[x]) return;
	int i,y; 
	sz1+=(x<=n && f[x]<g[x]); sz2+=(x>n && f[x]>g[x]);
	if (x<=n && f[x]>g[x] || x>n && f[x]<g[x]){
		puts("NO"); exit(0);
	}
	for (i=fst[x]; i; i=nxt[i]){
		y=pnt[i];
		if (!vis[y]) dfs(y);
	}
}
int main(){
	scanf("%d%d",&m,&n);
	int i,x,y,u,v;
	while (m--){
		scanf("%d%d%d%d",&x,&y,&u,&v);
		ins(u?u+n:x,v?v:y+n);
	}
	for (i=1; i<=(n<<1); i++) if (!vis[i] && f[i]+g[i]){
		sz1=sz2=0; dfs(i);
		if (!sz1 || !sz2){ puts("NO"); return 0; }
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
void display()
{
    int a, b, ar[3];
    cin>>a>>b;
    ar[0] = a+ b, ar[1] = a - b , ar[2] = a * b;
    sort(ar, ar + 3);
    cout<<ar[2]<<endl;
}
int main(void)
{
    display();
}


Measured memory_bytes: 3472
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    VL a(n), b(n);
    ll sa = 0, sb = 0;
    REP(i,n){
        a[i] = in();
        sa += a[i];
    }
    REP(i,n){
        b[i] = in();
        sb += b[i];
    }
    if (sa < sb){
        cout << -1 << endl;
        return 0;
    }
    VL d(n);
    REP(i,n) d[i] = a[i] - b[i];
    sort(ALL(d));
    VI change(n);
    int j = n - 1;
    REP(i,n){
        if (d[i] >= 0) break;
        change[i] = 1;
        while (d[i] < 0){
            change[j] = 1;
            ll x = min(-d[i], d[j]);
            d[i] += x;
            d[j] -= x;
            if (d[j] == 0){
                j--;
            }
        } 
    }
    int ans = 0;
    REP(i,n) ans += change[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int sx,sy,tx,ty,i;
  cin >> sx >> sy >> tx >> ty;
  tx-=sx;
  ty-=sy;
  for (i=0;i<ty;i++) cout << 'U';
  for (i=0;i<tx;i++) cout << 'R';
  for (i=0;i<ty;i++) cout << 'D';
  for (i=0;i<tx+1;i++) cout << 'L';
  for (i=0;i<ty+1;i++) cout << 'U';
  for (i=0;i<tx+1;i++) cout << 'R';
  cout << "DR";
  for (i=0;i<ty+1;i++) cout << 'D';
  for (i=0;i<tx+1;i++) cout << 'L';
  cout << 'U' << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    answers = []
    for _ in range(n):
        a = input()
        b = input()
        la, lb = len(a), len(b)
        if la > 80 or lb > 80:
            answers.append("overflow")
            continue
        if la > lb:
            ll = la
            for _ in range(la-lb):
                b = "0" + b
        else:
            ll = lb
            for _ in range(lb-la):
                a = "0" + a
        ans = ""
        bl = 0
        for i in range(ll):
            tmp = int(a[ll-i-1]) + int(b[ll-i-1]) + bl
            if tmp >= 10:
                bl = 1
                tmp = tmp % 10
            else:
                bl = 0
            ans = str(tmp) + ans
        if bl == 1:
            ans = "1" + ans
        if len(ans) > 80:
            answers.append("overflow")
            continue
        answers.append(ans)
    print(*answers, sep="\n")

if __name__ == "__main__":
    main()

Measured memory_bytes: 7672
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/math/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  boost::for_each(vc, [&os, &vc](T value) {
    os << value;
    if (value != vc.back())
      os << '\n';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream&
operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  //string S{}; std::cin >> S;

  ui N{}, K{}; cin >> N >> K;

  double_t ans{};
  rep(1, N + 1)
  {
    double_t res = 1. / N;
    ui cnt{ i };
    while (cnt < K)
    {
      res *= 0.5;
      cnt *= 2;
    }
    ans += res;
  }

  using std::cout;
  cout << std::setprecision(12) << std::fixed << ans << '\n';
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define deb(x)   cout<<"> "<<#x<<" : "<<x<<endl;
#define deb2(x,y)cout<<"> "<<#x<<"->"<<x<<"  "<<#y<<"->"<<y<<endl;
#define LINE   cout << "--- LINE NO : " << __LINE__ <<"  ---"<< endl;
#define pnr(a)   for(auto x:a){cout<<x<<" ";}cout<<endl;
#define pnr2(a)  for(auto x:a){cout<<x.first<<" "<<x.second<<endl;}

#define  vt            vector
#define  ff            first
#define  ss            second
#define  int           long long
#define  db            long double
#define  pii           pair<int,int>
#define  Maxpq(x)      priority_queue<x>
#define  Minpq(x)      priority_queue<x,vt<x>,greater<x>>

#define  pb            push_back
#define  si(x)         (int)x.size()
#define  all(x)        x.begin(),x.end()
#define  mem(a,x)      memset(a,x,sizeof(a))
#define  FOR(a)        for(auto& x :  a )
#define  forr(i,n)     for(int i=0;i<n;i++)

#define  pi            2*acos(0.0)
#define  inf           (int)1e18
#define  mxn           (int)2e5+5
#define  mod           (int)1e9+7

int mainx()
{
	string s , t;
	cin >> s >> t;

	int szt  = si(t);
	int ans = inf ;
	for (int i = 0 ; i < si(s) - szt + 1 ; i++)
	{
		string sx = s.substr(i , szt);
		int  cnt = 0;
		for (int j = 0 ; j < szt ; j++)
		{
			if (t[j] != sx[j])
			{
				cnt++;
			}
		}
		ans = min(ans , cnt);
	}
	cout << ans << endl;

	return 0;
}


inline void __INCLUDE() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt","w",stdout);
#endif
}

int32_t main() {

	

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

	//cout << fixed << setprecision(20);

	int tt = 1;
	//cin>>tt;
	for (int t = 1 ; t <= tt ; t++ )
	{
		// cout<<"Case #"<<t<<": ";
		mainx();
	}
	return 0 ;
}



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

int main(){
    string a,b,c;
    cin >> a;
    if (a == "Sunny") cout << "Cloudy" << endl;
    if (a == "Cloudy") cout << "Rainy" << endl;
    if (a == "Rainy") cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 15
#define mod 1000000007

int n,m,a[N];
long long b[1<<N],f[1<<N];

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();m=read();
	for (int i=1;i<=m;i++){
		int x=read()-1,y=read()-1;
		a[x]|=1<<y;
	}
	for (int i=b[0]=1;i<(1<<n);i++)
		b[i]=b[i/2]<<(i&1);
	for (int i=f[0]=1;i<(1<<n);i++)
		if ((i&1)==((i>>1)&1))
		for (int j=i;j;j=(j-1)&i)
			if ((j&1)==((j>>1)&1)){
				long long cnt=1;
				for (int k=0;k<n;k++){
					if (j&(1<<k)) cnt=cnt*b[a[k]&(i^j)]%mod;
					if ((i^j)&(1<<k)) cnt=cnt*(b[a[k]&j]-1)%mod;
				}
				f[i]=(f[i]+f[i^j]*cnt)%mod;
			}
	long long tmp=1;
	for (int i=1;i<=m;i++)
		tmp=tmp*2%mod;
	printf("%lld\n",(tmp-f[(1<<n)-1]+mod)%mod);
	return 0;
}

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

int main()
{
	unsigned long long int h, w;
	cin >> h >> w;
	if(h == 1 || w == 1)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << (h * w+ 1) / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ll a,b;
	cin >> a >> b;
	rep(i,1001){
		if(static_cast<ll>(0.08*i)==a && static_cast<ll>(0.10*i)==b){
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
}

Measured memory_bytes: 256