akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob
int a,b,c,d;
 
signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b >> c >> d;
	print4(c+b-d,d+c-a,a+b-d,b+c-a);
	return 0;
}

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

using namespace std;

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

typedef long long ll;

void solve(){
	int n;
	cin >> n;
	set<string> items;
	for(int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		items.insert(s);
	}
	
	cout << items.size();
}

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

	solve();
    
    return 0;
}


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

int main(){
  
int A, B, C, X, Y, ans;
  cin >> A >> B >> C >> X >> Y;
  
  if(X > Y){
    if(A + B < C * 2) ans = A * X + B * Y;
    else ans = min(C * 2 * X, C * 2 * Y + A * (X - Y));
  }
  
  else{
    if(A + B < C * 2) ans = A * X + B * Y;
    else ans = min(C * 2 * Y, C * 2 * X + B * (Y - X));  
  }
    
  cout << ans << endl;
  return 0;
  
}

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

work = []
for i in range(N):
    a, b = map(int, input().split())
    work.append(tuple((a, b)))

ws = sorted(work, key=lambda x:x[1])

time = 0
flg = "Yes"
for i in range(len(ws)):
    time += ws[i][0]
    if(time > ws[i][1]):
        flg = "No"
        break
print(flg)

Measured memory_bytes: 33480
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 









int main()
{
     int n;
     cin>>n;
     map<pi,int> mp;
     int x[n],y[n];
     for(int i=0;i<n;i++)cin>>x[i]>>y[i];
     for(int i=0;i<n;i++){
          for(int j=0;j<n;j++){
               if(i==j)continue;
               int dx=x[i]-x[j],dy=y[i]-y[j];
               mp[{dx,dy}]++;
          }
     }
     int res=0;
     for(auto it:mp){
          res=max(res,it.second);
     }
     cout<<n-res;
}


























Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
int main(){
    int a;
    cin>>a;
    pair <int, int> arr[a+1];
    for (int i=1; i<=a; i++) cin>>arr[i].fi, arr[i].se=i;
    sort (arr+1, arr+a+1);
    for (int i=1; i<=a; i++){
        cout<<arr[i].se<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	while (1) {
		long long a, b, count = 0;
		cin >> a >> b;
		if (a == 0 && b == 0) return 0;
		if (a < b) swap(a, b);
		while (1) {
			count++;
			a = a%b;
			swap(a, b);
			if (b == 0) {
				cout << a << " " << count << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3016
A,B = map(int,input().split())
cnt = 0
for i in range(A,B+1):
  s = str(i)
  ok = 1
  for j in range(len(s)):
    if s[j] != s[len(s)-1-j]:
      ok = 0
  if ok:
    cnt+=1
print(cnt)

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

int main(){
    long long X, Y;
    cin >> X >> Y;
    long long i=1;
    while(X<Y){
        X *= 2;
        i++;
    }
    if(X>Y) i--;
    
    cout << i << endl;

    return 0;
    
}


Measured memory_bytes: 256
# C - Coloring Colorfully

S = input()

ans1 = 0
ans2 = 0


# 010101...

for i in range(len(S)):
  if i%2 == 1:
    if S[i] == "0":
      ans1 += 1
  else:
    if S[i] == "1":
      ans1 += 1
      
      

# 101010...

for i in range(len(S)):
  if i%2 == 1:
    if S[i] == "1":
      ans2 += 1
  else:
    if S[i] == "0":
      ans2 += 1
      
      
print(min(ans1,ans2))






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

int main(void){
    while(true){
        int n, k, r, INF=100000000;
        cin >> n >> k;
        if(n+k==0) break;
        int a, b, c, d, e;
        int cost[110][110];
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++){
                if(i==j) cost[i][j]=0;
                else cost[i][j]=INF;
            }
        }
        while(k--){
            cin >> r;
            if(r==0){
                cin >> a >> b;
                cout << (cost[a][b]==INF? -1:cost[a][b]) << "\n";
            }else{
                cin >> c >> d >> e;
                if(cost[c][d]>e){
                    cost[c][d]=cost[d][c]=e;
                    for(int i=1; i<=n; i++){
                        for(int j=1; j<=n; j++){
                            cost[i][j]=min(cost[i][j], min(cost[i][c]+e+cost[d][j], cost[i][d]+e+cost[c][j]));
                        }
                    }
                }
            }
        }
        
    }
}



Measured memory_bytes: 3132
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int H,R;
    scanf("%d %d", &H, &R);
    H *= -1;
    if(H < R) printf("%d\n", 1);
    else if(H == R) printf("%d\n", 0);
    else printf("%d\n", -1);
    return 0;
}




Measured memory_bytes: 2700
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  int h,w;
  char a[105][105]={};
  cin>>h>>w;
  rep(i,0,h)
    rep(j,0,w)cin>>a[i][j];

  rep(i,0,h+2){
    rep(j,0,w+2){
      if(i==0||j==0||i==h+1||j==w+1)cout<<'#';
      else cout<<a[i-1][j-1];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
#define PI 3.14159265358979323846  
typedef pair<int, int> P;



int main() {
	int n, a,ans=0,m=0;
	vector<int> A;
	cin >> n;
	int cul = pow(10, 6) + 1;
	vector<bool> c(cul,true);
	vector<int> w(cul, 0);
	int count=0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (w[a]==0) {
			count++;
			w[a] = 1;
			m = max(a, m);
			A.push_back(a);
		}
		else {
			w[a]=2;
		}
	}
	n = count;
	sort(A.begin(), A.end());
	for (int i = 0; i < n; i++) {
		if (c[A[i]]) {
			ll v = A[i]*2;
			for (int j = 3; v <= m;j++) {
				c[v] = false;
				v=A[i] * j;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (c[A[i]]&&w[A[i]]!=2) {
			ans++;
		}
	}

	cout << ans << endl;

}


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

int main() {
  int N;
  cin>>N;
  vector<int> A(N+1);
  for(int &i:A)
    cin>>i;
  bool bo=false;
  for(int i=0,j=1;i<=N;j*=2){
    j-=A.at(i);
    i++;
    if(j<0){
      bo=true;
      break;
    }else if(j>=200000000)
      j=200000000;
  }
  if(bo){
    cout<<-1<<endl;
    return 0;
  }
  int64_t s=0;
  for(int &i:A)
    s+=i;
  int64_t n=1,k=0;
  for(int i=0;i<=N;i++){
    k+=n;
    n-=A.at(i);
    s-=A.at(i);
    if(n*2<=s)
      n*=2;
    else if(n*2>s && n<s)
      n=s;
  }
  cout<<k<<endl;
}

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

int main() {
  int a, B;
  cin >> a >> B;
  if (a<=5) cout << 0 << endl;
  else if (13<=a) cout << B << endl;
  else cout << B/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define inf 1000000000
#define N 177147

using namespace std;

int m, n;
int obj[130];
int memo[N];

int encode(int state[], int pos, int val)
{
	int ret = 0;
	for(int i = m-1; i >= 0; i--){
		ret *= 3;
		if(i == pos) ret += val;
		else ret += state[i];
	}
	return ret;
}

int dfs(int s)
{
	if(memo[s] != -1) return memo[s];
	
	int state[11];
	int cs = s;
	for(int i = 0; i < m; i++){
		state[i] = cs % 3;
		cs /= 3;
	}
	int mask = 0;
	for(int i = 0; i < m; i++){
		if(state[i]) mask |= (1<<i);
	}
	
	int cnt = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if( (obj[i] & (1<<j)) && state[j] == 1 ) goto PASS;
			if( !(obj[i] & (1<<j)) && state[j] == 2 ) goto PASS;
		}
		cnt++;
		PASS:;
	}
	if(cnt <= 1) return memo[s] = 0;

	
	int ret = inf;
	for(int i = 0; i < m; i++){
		if(mask & (1<<i)) continue;
		ret = min(ret, max( dfs(encode(state, i, 1)), dfs(encode(state, i, 2))) );
	}
	return memo[s] = ret+1;
}

int main(void)
{
	while(1){
		cin >> m >> n;
		if(m == 0 && n == 0) break;
		
		string S;
		for(int i = 0; i < n; i++){
			cin >> S;
			obj[i] = 0;
			for(int j = 0; j < S.size(); j++){
				obj[i] |= (S[j] - '0') << j;
			}
		}
		
		for(int i = 0; i < N; i++) memo[i] = -1;
		cout << dfs(0) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3700
{-# LANGUAGE BangPatterns #-}

import Data.Array (Array, listArray, accumArray, (!))
import Data.List (sortOn, sortBy)
import Control.Monad (forM_)
import qualified Data.Vector.Unboxed as V

lowerBound x xs = go xs (-1) (V.length xs) where
  go !xs !l !r
    | l==r-1 = r
    | x==(xs V.! m) = m
    | x<=(xs V.! m) = go xs l m
    | otherwise = go xs m r
    where !m = (l+r) `div` 2
{-# INLINE lowerBound #-}

inf = 10^11

a # b = abs (a-b)
{-# INLINE (#) #-}

near q xs
  | q < V.head xs = (-inf, V.head xs)
  | q > V.last xs = (V.last xs, inf)
  | otherwise = (V.unsafeIndex xs (i-1), V.unsafeIndex xs i)
  where i = lowerBound q xs

solv ss ts qs = map calc (V.toList qs) where
  calc q =
    let !(sl, sr) = near q ss
        !(tl, tr) = near q ts
    in minimum [ min (q#sr + sr#tr) (q#tr + tr#sr)
               , min (q#sr + sr#tl) (q#tl + tl#sr)
               , min (q#sl + sl#tr) (q#tr + tr#sl)
               , min (q#sl + sl#tl) (q#tl + tl#sl)
               ]

main = do
  [a,b,q] <- map read . words <$> getLine :: IO [Int]
  ys <- V.fromList . map read . words <$> getContents :: IO (V.Vector Int)
  let ss = V.slice 0 a ys
      ts = V.slice a b ys
      qs = V.slice (a+b) q ys
  putStr . unlines . map show $ solv ss ts qs


Measured memory_bytes: 13692
#include<iostream>

using namespace std;


bool charcmpLS(char Char1, char Char2) {
	if ('a' <= Char1&&Char1 <= 'z')Char1 -= ('a' - 'A');
	if ('a' <= Char2&&Char2 <= 'z')Char2 -= ('a' - 'A');
	return Char1 == Char2 ? true : false;
}

bool strcmpLS(const char*Str1, const char*Str2) {
	while (*Str1 != '\0'||*Str2 != '\0') {
		if (!charcmpLS(*Str1, *Str2))return false;
		Str1++;
		Str2++;
	}
	return true;
}

bool strcmpNoLS(const char*Str1, const char*Str2) {
	while (*Str1 != '\0'||*Str2 != '\0') {
		if (*Str1 != *Str2)return false;
		Str1++;
		Str2++;
	}
	return true;
}

int main() {
	char W[11];
	char T[1001];
	int WNum = 0;

	cin >> W;

	while (true) {
		cin >> T;
		if (strcmpNoLS(T, "END_OF_TEXT"))break;

		if (strcmpLS(T, W))WNum++;
	}

	cout << WNum << endl;

	return 0;
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  string s; cin>>s;
  if(s=="ABC"){
    cout<<"ARC"<<endl;
  }else{
    cout<<"ABC"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3564
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int n, point1 = 0, point2 = 0;
        String card1, card2;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        
        for (int i = 0; i < n; i++) {
            card1 = sc.next();
            card2 = sc.next();
            if (card2.compareTo(card1) < 0) {
                point1 += 3;
            } else if (card1.equals(card2)) {
                point1++;
                point2++;
            } else {
                point2 +=3;
            }
        }
        System.out.println(point1 + " " + point2);
    }
}


Measured memory_bytes: 29564
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int A, B;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                A = line[0];
                B = line[1];
            }
            Console.WriteLine((A <= 8 && B <= 8) ? "Yay!" : ":(");
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    for (int i = a; i <= b;i++){
        string s;
        s = to_string(i);
        string t = s;
        reverse(s.begin(), s.end());
        if(s == t){
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
import math
x=int(input())
flag=True
if x==2:
    print(x)
else:
    while flag:
        i=2
        f=True
        while i<math.sqrt(x) and f:
            if x%i==0:
                f=False
            i+=1
        if f==True:
            print(x)
            flag=False
        else:
            x+=1











Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// using namespace std;

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

void Main() {
  int N, D;
  std::cin >> N >> D;

  int x[N][D];

  rep(i, N) {
    rep(j, D) { std::cin >> x[i][j]; }
  }

  int count = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      int dist = 0;
      for (int k = 0; k < D; ++k) {
        dist += ((x[i][k] - x[j][k]) * (x[i][k] - x[j][k]));
      }
      double ans = std::sqrt(dist);
      if (ans == std::ceil(ans)) {
        ++count;
      }
    }
  }

  std::cout << count << std::endl;
}

int main() {
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin>>n>>x;
  vector<int>m(n);
  for(int i=0;i<n;i++){
    cin>>m[i];
  }
  sort(m.begin(),m.end());
  int s=0;
  for(int i=0;i<n;i++){
    s+=m[i];
  }
  int res=x-s;
  int add=res/m[0];
  cout<<n+add<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
   
// g++ -std=c++11 prac.cpp
template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    
template<typename T>
T lcm(T a, T b){
    return a/gcd(a,b)*b;
}    
        
int main(){
    ll x,y,z,n,m=0,k,w,sum=0,ans=0,Max=-1e9,count=0,Min=1e9+1;
    string s,t,u1,u2;
    bool ok=true;
    cin >> n >> m >> s >> t;
    x = lcm(n,m);
    y = x / m;
    z = x / n;

    if(n>m){
        int i=0;
        while(z*i < m){
            if(s[y*i] != t[z*i]){
                cout << -1 << endl;
                return 0;
            }
            i++;
        }
    }
    else{
        int i=0;
        while(y*i < n){
            if(s[y*i] != t[z*i]){
                cout << -1 << endl;
                return 0;
            }
            i++;
        }

    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;

char a[5];

int main()
{
    while(scanf("%s",a) == 1)
    {
        int c = 0;
        for(int i = 0; i < 3; i++)
            if(a[i] - '0') c++;
        printf("%d\n",c);
    }
    return 0;
}


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

prime_number = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

a = 0
_count = []
ans = 0

for g in range(len(prime_number)):
	if prime_number[g] > N:
		break
	for i in range(1, 100):
		a += N//prime_number[g]**i
		if  prime_number[g]**i > N:
			_count.append(a)
			a=0
			break

if N!=1:
	if _count[0] >= 74:
		ans+=1

c_24 = []
c_14 = []
c_4 = []
c_2 = []
for n in range(len(_count)):
	if _count[n]>=24:
		c_24.append(_count[n])
	if _count[n]>=14:
		c_14.append(_count[n])
	if _count[n]>=4:
		c_4.append(_count[n])
	if _count[n]>=2:
		c_2.append(_count[n])

ans += len(c_14)*(len(c_4)-1)
ans += len(c_24)*(len(c_2)-1)
ans += (len(c_4)-1)*len(c_4)*(len(c_2)-2)/2

print(int(max(ans,0)))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  int n;
  cin >> n;
  vector<pair<pair<string, int>, int>> vec;
  for(int i = 0;i < n;i++) {
    string s;
    int p;
    cin >> s >> p;
    vec.push_back({{s, -p}, i + 1});
  }
  sort(all(vec));
  for(auto pp: vec) {
    cout << pp.second << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
#define mod 1000000007
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> v;
    int a,ans=0;
    cin>>a;
    v.push_back(a);
    ans=a;

    for(int i=1;i<n;i++){
        cin>>a;
        v.push_back(a);
        if(v[i-1]<v[i])ans+=(v[i]-v[i-1]);
    }
    cout<<ans<<endl;

    return 0;
}

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

#define maxn 100005

using namespace std;
typedef long long ll;

int main(){
  #define TASK "ABC"
 // freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout);
  ios_base::sync_with_stdio(0);

  int n;
  cin >> n;

  vector < pair < int, int > > a(n);

  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    a[i] = {x, i};
  }

  sort(a.begin(), a.end());

  vector < vector < ll > > d(n, vector < ll >(n, 0));

  d[0][n - 1] = 0;
  for (int len = n - 1; len > 0; --len)
    for (int i = 0; i + len < n; ++i) {
      int j = i + len;

      d[i][j - 1] = max(d[i][j - 1], d[i][j] + ll(abs(a[len].second - j)) * a[len].first);
      d[i + 1][j] = max(d[i + 1][j], d[i][j] + ll(abs(a[len].second - i)) * a[len].first);
    }

  ll ans = 0;

  for (int i = 0; i < n; ++i)
    ans = max(ans, d[i][i] + ll(abs(a[0].second - i)) * a[0].first);

  cout << ans;
  return 0;
}


Measured memory_bytes: 34676
let solve h w c =
  let v0 = Array.make w 0 in
  let v1 = Array.make w 0 in
  let r = ref 0 in
  for i = 0 to h - 1 do if c.(i).(0) = 0 then r := 1 done;
  for j = 0 to w - 1 do if c.(0).(j) = 0 then begin v0.(j) <- 1; r := 1 end done;
  for i = 1 to h - 1 do
    if c.(i).(0) = 0 then v1.(0) <- 1;
    for j = 1 to w - 1 do
      if c.(i).(j) = 1 then v1.(j) <- 0
      else begin
        let t = if v0.(j) < v1.(j-1) then v0.(j) else v1.(j-1) in
        v1.(j) <- if v0.(j-1) < t then v0.(j-1) + 1 else t + 1;
        r := if v1.(j) > !r then v1.(j) else !r;
      end
    done;
    Array.iteri (fun i e -> v0.(i) <- e) v1
  done;
  !r * !r

let () =
  let (h, w) = Scanf.scanf "%d %d\n" (fun h w -> (h, w)) in
  let c = Array.make_matrix h w 0 in
  let rec read = function
    | (i, _) when i = h -> ()
    | (i, j) when j = w -> read (i + 1, 0)
    | (i, j) ->
      c.(i).(j) <- Scanf.scanf "%d " (fun i -> i);
      read (i, j + 1) in
  read (0, 0);
  Printf.printf "%d\n" (solve h w c)

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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=1e5+5,mod=1e9+7,bit=61;

void bye()
{
    cout<<"No\n";
    exit(0);
}

signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        string sv[n+1];
        pll a[n+1];
        ll b=0;
        f(i,1,n)
        {
            string s;
            cin>>s;
            sv[i]=s;
            ll pref=0,suff=0;
            ll sum=0;
            f(j,0,sz(s)-1)
            {
                sum+=(s[j]=='('?1:-1);
                pref=max(pref,-sum);
            }
            sum=0;
            rf(j,sz(s)-1,0)
            {
                sum+=(s[j]=='('?1:-1);
                suff=max(suff,sum);
            }
            // o1=suff, c1=pref
            if(suff==0)  //(((()()((
            {
                a[i].ff=-inf;
            }
            else if(pref==0)  //(((()()))))))
            {
                a[i].ff=inf;
            }
            else if(pref<suff) // )))(
            {
                a[i].ff=inf-pref;
            }
            else if(suff<pref)   // (((), ((())        i
            {
                a[i].ff=-inf+suff;
            }
            else
            {
                a[i].ff=0;
            }
            a[i].ss=i;
        }
        sort(a+1,a+n+1,greater<pll>());
        b=0;
        f(i,1,n)
        {
            for(auto x:sv[a[i].ss])
            {
                b+=(x=='('?1:-1);
                if(b<0)
                {
                    bye();
                }
            }
        }
        if(b)
        {
            bye();
        }
        cout<<"Yes\n";
    }
    return 0;
}


















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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    string s;
    cin>>s;
    ll ans=0;
    REP(i,bit(s.size()-1),bit(s.size())){
        string buf="";
        REP(j,s.size()){
            buf+=s[j];
            if(i&bit(j)){
                ans+=atoll(buf.c_str());
                //cout<<buf<<"+";
                buf="";
            }
        }cout<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n, k;
int main() {
    cin>>n>>k;

    double ans=0.0;
    REP(i, 1, n+1){
        ll cnt=0, tmp=i;
        while(tmp<k){
            cnt++;
            tmp*=2;
        }

        ans+=(1.0/n * pow((0.5), cnt));
    }

    printf("%.10lf\n", ans);
    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input=sys.stdin.readline

    n=int(input())
    s=set(map(int,input().split()))
    q=int(input())
    t=list(map(int,input().split()))
    
    ans=0
    for num in t:
      if num in s:
        ans+=1
    print(ans)
if __name__=='__main__':
    main()


Measured memory_bytes: 16168
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

#[fastout]
fn main() {
   input! {
      n:usize,
      a:[usize;n],
      q:usize,
   }
   let mut table = vec![0; 100001];
   let mut ans = 0_usize;
   for i in &a {
      ans += *i;
      table[*i] += 1;
   }
   for i in 0..q {
      input! {
         b:usize,c:usize
      }
      ans -= table[b] * b;
      table[c] += table[b];
      ans += table[b] * c;
      table[b] = 0;
      println!("{}", ans);
   }
}


Measured memory_bytes: 5336
#!/usr/bin/env python3

from math import ceil
import heapq

def main():
    n, d, a = map(int, input().split())
    q = []
    for i in range(n):
        x, h = map(int, input().split())
        heapq.heappush(q, (x, -(h // a + (1 if (h % a) else 0))))
    bomb = 0
    res = 0
    while q:
        x, h = heapq.heappop(q)
        if h < 0:
            h *= -1
            if h > bomb:
                heapq.heappush(q, (x + 2 * d, h - bomb))
                res += h - bomb
                bomb = h
        else:
            bomb -= h
    print(res)

if __name__ == "__main__":
    main()


Measured memory_bytes: 34100
#include<bits/stdc++.h>
using namespace std;
 
int main(){
 int r,b,g;
 cin >> r >> b >> g;
 int num = r*100 + b*10 + g;
 if(num % 4 == 0) cout << "YES" << endl;
 else cout << "NO" << endl;
}

Measured memory_bytes: 256
#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 <bitset>
#include <algorithm>
#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<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

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

const int N = 701;
int n, c[N][N], d[N], visit[N];

void dfs(int now){
    REP(next,n){
        if (c[now][next] == 0 || visit[next] > 0) continue;
        visit[next] = 1;
        d[next] = d[now] + 1;
        dfs(next);
    }
}

int main() {
    int m;
    cin >> n >> m;
    REP(i,n) REP(j,n) c[i][j] = (i != j);
    REP(i,m){
        int u = in() - 1, v = in() - 1;
        c[u][v] = c[v][u] = 0;
    }

    VI a, b;
    REP(i,n){
        if (visit[i]) continue;
        visit[i] = 1;
        dfs(i);
        int even = 0, odd = 0;
        REP(j,n){
            if (visit[j] == 1){
                visit[j] = 2;
                if (d[j] % 2 == 0) even++;
                else odd++;
            }
        }
        a.push_back(even);
        b.push_back(odd);
    }

    REP(i,n) REP(j,n){
        if ((d[i] + d[j]) % 2 == 0 && c[i][j]){
            cout << -1 << endl;
            return 0;
        }
    }

    m = a.size();
    VVI dp(m+1, VI(n+1));
    dp[0][0] = 1;
    REP(i,m) REP(j,n+1){
        if (dp[i][j]){
            dp[i+1][j+a[i]] = 1;
            dp[i+1][j+b[i]] = 1;
        }
    }

    int ans = 1e9;
    REP(i,n+1){
        if (dp[m][i]){
            ans = min(ans, i * (i-1) / 2 + (n - i) * (n - i - 1) / 2);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N1,N2,N3;
  cin >> N1 ;
  N2 = N1 / 10 ;
  N3 = N1 % 1000;
  if ((N3 % 111 == 0) || (N2 % 111 == 0)) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
int main(){
    int h,w,k;
    cin>>h>>w>>k;

    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans = 0;

    for (int maski = 0; maski < (1 << h); maski++){
        for (int maskj = 0; maskj < (1 << w); maskj++){
            int black = 0;
            for (int i = 0; i < h; i++){
                for (int j = 0; j < w; j++){
                    if (maski >> i & 1)
                        continue;
                    if (maskj >> j & 1)
                        continue;
                    if (s[i][j] == '#')
                        black++;
                }
            }
            if (black == k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	scan(N);
	vll X,Y;
	rep(i,N){
		ll x,y;
		scan(x>>y);
		X.push_back(x-y);
		Y.push_back(x+y);
	}
	ll Xmax=-INFl,Xmin=INFl,Ymax=-INFl,Ymin=INFl;
	rep(i,N){
		Xmax=max(Xmax,X[i]);
		Ymax=max(Ymax,Y[i]);
		Xmin=min(Xmin,X[i]);
		Ymin=min(Ymin,Y[i]);

	}
	prin(max(Xmax-Xmin,Ymax-Ymin));
	return 0;
}


Measured memory_bytes: 6640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, x, d;//n:input, x:sum, d:あまり
  cin >> n; x = 0; d = n;
  for(int i=8;i>=0;i--){
    x+= d / (int)(pow(10,i));
    d = d % (int)(pow(10,i));
  }
  if (n%x==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
    int a,b,t;
    cin>>a>>b>>t;

    cout<<(t/a)*b<<e;




}



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

using namespace std;

int main(){

    string s, t;
    cin >> s >> t;

    int question = 0, temp = 0;
    int index = -1;


    for(int i = s.size()-1; i >= 0 + t.size() - 1; i--){
        bool fits = true;
        int index = 0;
        for (int j = i - t.size() + 1; j <= i; j++){
            if (s[j] == '?' || s[j] == t[index]){
                fits = true;
            } else {
                fits = false;
                break;
            }
            index++;
        }

        if (fits) {

            for (int k = 0; k < i - t.size()+1; k++){
                if (s[k] == '?'){
                    cout << 'a';
                } else {
                    cout << s[k];
                }
            }
            for (int j = 0; j < t.size(); j++){
                cout << t[j];
            }

            for (int k = i + 1; k < s.size(); k++){
                if (s[k] == '?'){
                    cout << 'a';
                } else {
                    cout << s[k];
                }
            } cout << endl;

            return 0;
        } 
    }

    cout << "UNRESTORABLE" << endl;
    


    return 0;
}

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

int main(){
	int n,count=0;
	cin >> n;
	int i;
	queue<string> q;
	for(i = 1;i < 10;i++)
		q.push(to_string(i));
		
	while(1){
		int m = q.size(),i;
		
		for(i = 0;i < m;i++){
			string s = q.front();
			q.pop();
			if(++count == n){
				cout << s;
				return 0;
			}
			
			if(s.back() == '0'){
				q.push(s+'0'),q.push(s+'1');
			}		
			else if(s.back() == '9'){
				q.push(s+'8'),q.push(s+'9');
			}
				
			else{
				q.push(s+(char)(s.back()-1));
				q.push(s+(char)(s.back()));
				q.push(s+(char)(s.back()+1));
			}
				
		}
	}
} 

Measured memory_bytes: 9768
#include <stdio.h>
int main(){
    int a,b,c,d,e,f,g,h;
    scanf("%d",&a);
    b=a/1000;
    b=b*1000;
    c=a/100;
    c=c*100;
    d=a/10;
    d=d*10;
    e=(c-b)/100;
    f=b/1000;
    g=(d-c)/10;
    h=a-d;
    if(f==e||e==g||g==h){
        printf("Bad");
    }else{
        printf("Good");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    ll n,v;
    cin >> n;
    vector<pair<ll,ll>> odd(1000001);
    vector<pair<ll,ll>> even(1000001);
    rep(i,n){
        cin >> v;
        if (i%2){
            even[v].first += 1;
            even[v].second = v;
        }else{
            odd[v].first += 1;
            odd[v].second = v;
        }
    }
    sort(all(even),greater<pair<ll,ll>>());
    sort(all(odd),greater<pair<ll,ll>>());
    if (even[0].second != odd[0].second){
        cout << n-(even[0].first+odd[0].first)<<endl;
    }else{
        cout << min(n-(even[0].first+odd[1].first),n-(even[1].first+odd[0].first))<<endl;
    }

    
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int A[N];
    int cnt[2] = {};
    rep(i, N) {
        cin >> A[i]; 
        cnt[A[i] % 2]++;
    }
    if (cnt[1] % 2 == 1) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }

    return 0;
}


Measured memory_bytes: 640
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
	var h = parseInt(input[0], 10);
	var a = parseInt(input[1], 10);
    //出力
    var x = parseInt(h/a);

    if(x*a>=h){
        console.log('%d',x);
    }else{
        x++;
        console.log('%d',x);
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
// Main("10 4")
// Main("1 10000")
// Main("10000 1")
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21956
#include <iostream>
using namespace std;                                                                                   
int main () {
  int X;
  cin >> X;
  for (int i = 1; i <X; ++i) {
    if (100 * i <= X && X <= 105*i) {
      cout << 1;
      return 0;
    }   
  }
  cout << 0;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			while(true){
				/* input */
				String[] line = br.readLine().split(" ");
				int w = Integer.parseInt(line[0]), q = Integer.parseInt(line[1]);

				if(w==0&&q==0){
					br.close();
					break;
				}

				//initialize each with available width
				int[] f = new int[w];
				for(int i=0;i<w;i++){
					f[i] = w-i;
				}
				
				for(int i=0;i<q;i++){
					line = br.readLine().split(" ");
					char c = line[0].charAt(0);
					switch(c){
					case 's':{
						int id = Integer.parseInt(line[1]);
						int width = Integer.parseInt(line[2]);
						//look for available place
						boolean ok = false;
						for(int j=0;j<w;j++){
							if(f[j]>=width){
								for(int k=0;k<width;k++){
									f[j+k] = -id;
								}
								ok = true;
								System.out.println(j);
								break;
							}
						}
						if(!ok) System.out.println("impossible");
						break;
					}
					case 'w':{
						int id = Integer.parseInt(line[1]);
						int p = w-1;
						while(f[p]!=-id) p--;
						if(p==w-1){
							f[p] = 1;
							p--;
						}
						while(p>=0&&(f[p]==-id||f[p]>0)){
							f[p] = (f[p+1]<0)?1:f[p+1] + 1;
							p--;
						}
					}
					}
				}

				
				System.out.println("END");
			}
			br.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 18364
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int  k = sc.nextInt();
		String s =sc.next();
		
		if(s.length() <= k) {
			System.out.println(s);
			return;
		}
		
		String x = s.substring(0, k);

		System.out.println(x + "...");
	}
}


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

using namespace std;

int main(){

  vector<int> in_hour(3);
  vector<int> in_mini(3);
  vector<int> in_sec(3);

  vector<int> out_hour(3);
  vector<int> out_mini(3);
  vector<int> out_sec(3);
  
  for(int i=0;i<3;++i){

	int r_hour=0;
	int r_mini=0;
	int r_sec=0;
	
	cin>>in_hour[i]>>in_mini[i]>>in_sec[i]>>out_hour[i]>>out_mini[i]>>out_sec[i];

	r_sec = out_sec[i] - in_sec[i];

	if(r_sec > 60){
	  r_sec = r_sec - 60;
	  r_mini++;
	}

	else if(r_sec < 0){
	  r_sec = 60 + r_sec;
	  r_mini--;
	}
	
	r_mini = r_mini + out_mini[i] - in_mini[i];
	
	if(r_mini > 60){
	  r_mini = r_mini - 60;
	  r_hour++;
	}

	else if(r_mini < 0){
	  r_mini = 60 + r_mini;
	  r_hour--;
	}

	r_hour = r_hour + out_hour[i] - in_hour[i];

	cout<<r_hour<<" "<<r_mini<<" "<<r_sec<<endl;
	
  }

  return 0;
  
}



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

ll pow5(ll a) { return a * a * a * a * a; }

int main() {
    ll x;
    cin >> x;
    ll i = -200, j = -200;
    while (true) {
        j = -200;
        while (true) {
            if (pow5(i) - pow5(j) == x) break;
            if (j == 200) break;
            j++;
        }
        if (pow5(i) - pow5(j) == x) break;
        i++;
    }
    cout << i << " " << j << endl;
    return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){
  int N;
  cin >> N;
  vector<int> D(N+1);
  vector<int> cntTime(13, 0);
  REP(i, N){
    cin >> D[i];
    cntTime[D[i]]++;
  }
  D[N] = 0;
  if(N >= 24){
    cout << 0 << endl;
    return 0;
  }
  // if(cntTime[12] >= 2 || cntTime[0] >= 2){
  //   cout << 0 << endl;
  //   return 0;
  // }
  REP(i, 12){
    if(cntTime[i] >= 3){
      cout << 0 << endl;
      return 0;
    }
  }
  if(N >= 23){
    cout << 1 << endl;
    return 0;
  }
  vector<int> a(N+1);
  int ans = 0;
  for(int bit = 0; bit < (1<<(N+1)); bit++){
    REP(i, N+1){
      if((bit>>i) & 1){
        a[i] = D[i];
      }
      else{
        a[i] = 24-D[i];
      }
    }
    int mind = INF;
    REP(i, N+1){
      FOR(j, i+1, N+1){
        int d = min(abs(a[i]-a[j]), 24-(abs(a[i]-a[j])));
        mind = min(d, mind);
      }
    }
    ans = max(mind, ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256