akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    while (cin >> n && n) {
        int t = 1000 - n, ans = 0;
        ans += t / 500;
        t %= 500;
        ans += t / 100;
        t %= 100;
        ans += t / 50;
        t %= 50;
        ans += t / 10;
        t %= 10;
        ans += t / 5;
        t %= 5;
        ans += t;
        cout << ans << endl;
    }
}


Measured memory_bytes: 2992
#include <bits/stdc++.h>
int main() {
	std::map<std::string, int> mp;
	int n;
	std::cin >> n;
	while (n--) {
		std::string s;
		std::cin >> s;
		mp[s]++;
	}
	std::string s;
	s = "AC";
	std::cout << s << ' ' << 'x' << ' ' << mp[s] << '\n';
	s = "WA";
	std::cout << s << ' ' << 'x' << ' ' << mp[s] << '\n';
	s = "TLE";
	std::cout << s << ' ' << 'x' << ' ' << mp[s] << '\n';
	s = "RE";
	std::cout << s << ' ' << 'x' << ' ' << mp[s] << '\n';
	return 0;
}

Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl

int main() {
  int n;
  cin >> n;
  if (n%2 == 0) {
    cout << n/2 << endl;
  }
  else {
    cout << n/2 + 1 << endl;
  }
}
 

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){
     string S;
     cin >> S;
    int N = (S.at(0) - '0') * 111;
    int ans;
    if(stoi(S) <= N) ans = N;
    else  ans = N + 111;
     print(ans);
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
using namespace std;
typedef long long ll;
const long long llnrm=LLONG_MAX;
const int nrm=INT_MAX;
const int nrn=INT_MIN;
const int nmax=1e5+5;
const int mod=1e9+7;
const int lim=1e8;
int main(){
	long long x,y,ans=0;
	cin>>x>>y;
	while (x<=y){
		ans++;
		x*=2;
	}
	cout<<ans;
}


Measured memory_bytes: 256
def main():
    X = int(input())


    def isOK(A, B):
        eq = A**5 - B**5
        if X >= eq:
            return True
        else:
            False
    
    def bin_search(B):
        # search A
        left = B + 1
        right = 10 ** 4 * 2

        while right - left > 1:
            mid = left + (right - left) // 2
            if isOK(mid, B):
                left = mid
            else:
                right = mid

        return left
    

    for B in range(-10**4, 10**4 + 1):
        A = bin_search(B)
        if A**5 - B**5 == X:
            print(A, B)
            exit()


if __name__ == "__main__":
    main()

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


string rgb = "rgb";
int tab[300];
int n;

int encode(string s){
  int ret = 0;
  for(int i=0; i<n; i++){
    ret *= 3;
    ret += tab[s[i]];
  }
  return ret;
}

string decode(int c){
  string s = "";
  for(int i=0; i<n; i++){
    s = rgb[c%3] + s;
    c /= 3;
  }
  return s;
}


int main(){
  int q[100000];
  int memo[100000];
  tab['r'] = 0;
  tab['g'] = 1;
  tab['b'] = 2;
  
  for(;;){
    for(int i=0; i<100000; i++){
      memo[i] = -1;
    }
    string s;
    cin >> s;
    if(s[0]=='0') break;
    n = s.length();
    
    int ql = 0;
    int qr = 1;
    q[0] = encode(s);
    memo[encode(s)] = 0;
    
    int found = 0;
    while(qr-ql>0){
      int c = q[ql];
      string s = decode(c);
//      cout << s << endl;
      int ok = 1;
      for(int i=0; i<n-1; i++){
        if(s[i]!=s[i+1]){
          ok = 0;
          break;
        }
      }
      if(ok){
        found = 1;
        cout << memo[c] << endl;
        break;
      }
      
      for(int i=0; i<n-1; i++){
        if(s[i]!=s[i+1]){
          string ns = s;
          if('r'!=s[i] && 'r'!=s[i+1]){
            ns[i] = 'r';
            ns[i+1] = 'r';
          }
          if('g'!=s[i] && 'g'!=s[i+1]){
            ns[i] = 'g';
            ns[i+1] = 'g';
          }
          if('b'!=s[i] && 'b'!=s[i+1]){
            ns[i] = 'b';
            ns[i+1] = 'b';
          }
          int nc = encode(ns);
          if(memo[nc]==-1){
            memo[nc] = memo[c]+1;
            q[qr] = nc;
            qr++;
          }
        }
      }
      
      ql++;
      
    }
    if(found==0){
      cout << "NA" << endl;
    }
  }
	return 0;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    string in;
    while (1) {
        cin >> in;
        if (in == "0000")break;
        for (int i = 0;; i++) {
            if (in == "6174") {
                cout << i << "\n";
                break;
            }
            bool same = true;
            FOR(i, 0, 3)if (in[i] != in[i + 1])same = false;
            if (same) {
                cout << "NA\n";
                break;
            }
            string s = in, t = in;
            SORT(s), rSORT(t, greater<char>());
            in = to_string(stoi(t) - stoi(s));
            while (in.length() < 4)in = '0' + in;
        }
    }
}


Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int H = 0, W = 0;
	int N = 0;

	cin >> H >> W;
	cin >> N;

	vector<int> vctNum(N);
	for (auto& elem : vctNum) {
		cin >> elem;
	}

	// 1本のvectorにしてから、後で行で切る。

	vector<int> lineTable(H * W, 0);

	int index = 0;
	for (int i = 0; i < N; ++i) {
		int curNum = vctNum[i];
		for (int j = 0; j < curNum; ++j) {
			lineTable[index + j] = i + 1;
		}
		index += curNum;
	}

	// ぶつ切りにする。
	bool dirPosi = true;
	int lastColor = 0;
	for (int j = 0; j < H; ++j) {
		// int index = j * W;
		for (int i = 0; i < W; ++i) {
			if (dirPosi) {
				cout << lineTable[j * W + i] << " ";
			}
			else {
				cout << lineTable[(j + 1) * W - i -1] << " ";
			}
		}
		cout << endl;
		dirPosi = !dirPosi;
	}

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long int
#define ull unsigned long long int
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 1200005
#define MOD 1000000007
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define precise cout<<fixed<<setprecision(6)
using namespace std;
const double PI = atan(1.0)*4;
const int64_t INF=100000000000000003;
const int32_t LOG=21;
const int BIG=pow(2,20);
int32_t main(){
        // getFaster;
         int n;
         cin>>n;
         vector<int> v;
         int arr[n+1];
         int cnt[n+1];
         int bounds[n+1];
         int pref[n+1];
         fill(cnt,cnt+n+1,0);
         v.clear();
         rep(i,1,n+1)
         {
           cin>>arr[i];
           cnt[arr[i]]++;
         }
         rep(i,1,n+1)
         {
           if(cnt[i]!=0)v.push_back(cnt[i]);
         }
         int tot=(int)(v.size());
         sort(v.begin(),v.end());
         rep(x,1,n+1)
         {
               int l=0,r=tot-1;
               int ans=tot;
               while(l<=r)
               {
                  int mid=(l+r)>>1;
                  if(v[mid]<x)
                  {
                     l=mid+1;
                  }
                  else
                  {
                     ans=min(ans,mid);
                     r=mid-1;
                  }  
               }
               bounds[x]=ans-1;
         }
         pref[0]=v[0];
         rep(i,1,v.size())pref[i]=pref[i-1]+v[i];
         rep(k,1,n+1)
         {
             int l=1,r=n/k;
             int ans=0;
             while(l<=r)
             {
                int mid=(l+r)>>1;
                int cur=bounds[mid];
                int val=tot-cur-1;
                if(cur!=-1)val+=(pref[cur]/mid);
                if(val>=k){ans=max(ans,mid);l=mid+1;}
                else r=mid-1;
             }
             cout<<ans<<endl; 
         }
         return 0;
}

Measured memory_bytes: 12652
def main():
    N,K = [int(x) for x in input().split()]
    snack_sunuke = []
    for a in range(K):
        di = int(input())
        for i in [int(x) for x in input().split()]:
            snack_sunuke.append(i)
    print(N - len(set(snack_sunuke)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9160
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1; 
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	long long int a;
	string b;
	cin >> a >> b;
	long long int b1, b2;
	if (b.size() == 5) {
		b1 = (b[0] - '0') * 10 + (b[1] - '0');
		b2 = (b[3] - '0') * 10 + (b[4] - '0');
	}
	else {
		b1 = (b[0] - '0');
		b2 = (b[2] - '0') * 10 + (b[3] - '0');
	}
	long long int ans = (a * b2) / 100;
	ans = ans + a * b1;
	cout << ans;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p 998244353

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

int power(int a, int N){
	if(N == 0) return 1;
	else if(N % 2 == 0) return power(MOD(a * a), N / 2);
	else return MOD(a * power(a, N - 1));
}

int inverse(int a){
	return power(a, p - 2);
}

signed main(){
	int N, A, i, j;
	scanf("%lld", &N);
	vector<int> Anum(0);
	for(i = 0; i < N; i++){
		scanf("%lld", &A);
		while(Anum.size() <= A){
			Anum.push_back(0);
		}
		Anum[A]++;
	}
	int Amax = Anum.size();
	vector<int> B(Amax, 0);
	for(i = Amax - 1; i >= 1; i--){
		for(j = i; j < Amax; j += i){
			B[i] += j * Anum[j];
		}
		B[i] = MOD(MOD(B[i]) * MOD(B[i]));
		for(j = 2 * i; j < Amax; j += i){
			B[i] = MOD(B[i] - B[j]);
		}
	}
	int ans = 0;
	for(i = 1; i < Amax; i++){
		ans = MOD(ans + B[i] * inverse(i) - Anum[i] * i);
	}
	ans = MOD(ans * inverse(2));
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 16360
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  cin >> n;
  map<int, int> mp;
  vector<int> a(n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  for (int i = 0; i < n; i++) {
    vector<int> b;
    int flag = 0;
    for (int j = 1; j * j <= a[i]; j++) {
      if (a[i] % j == 0) {
        b.emplace_back(j);
        if (a[i] / j != j) b.emplace_back(a[i] / j);
      }
    }
    sort(b.begin(), b.end());
    for (int k = 0; k < b.size(); k++) {
      if (k == b.size() - 1) {
        if (mp[b[k]] >= 2) flag = 1;
      } else {
        if (mp[b[k]] >= 1) {
          flag = 1;
          break;
        }
      }
    }
    if (flag == 0) ans++;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 32812
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<double> v(N);
    for (double& i : v) cin >> i;
    for (int i = 0; i < N - 1; i++) {
        sort(v.begin(), v.end(), greater<double>());
        int size = v.size();
        v[size-2] = (v[size-2] + v[size-1]) / 2.0;
        v.pop_back();
    }
    cout << v[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

bool dp[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    if(n<100){
        cout<<"0\n";
        return 0;
    }

    for(int i=100;i<=105;i++)
        dp[i] = true;

    for(int i=106;i<=n;i++){

        for(int j=0;j<=5;j++){
            dp[i]|=dp[i-j-100];
        }

    }

    if(dp[n])cout<<"1\n";
    else cout<<"0\n";

    return 0;
}


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

using namespace std;

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<int> a(Q), b(Q), c(Q), d(Q);
  for (int i = 0; i < Q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
  }
  
  vector<int> buffer(N);
  int mx = -1;
  auto dfs = [&](auto f, int num, int idx) -> void {
    if (idx == N) {
      int score = 0;
      for (int q = 0; q < Q; q++) {
        if (buffer[b[q]] - buffer[a[q]] == c[q]) score += d[q];
      }
      mx = max(mx, score);
      return;
    }
    for (int n = num; n <= M; n++) {
      buffer[idx] = n;
      f(f, n, idx+1);
    }
  };
  
  dfs(dfs, 1, 0);
  cout << mx << endl;
}

Measured memory_bytes: 3644
S = input()
exist = [False] * 26
char = "abcdefghijklmnopqrstuvwxyz"
for i in range(len(S)):
    for j in range(26):
        if S[i] == char[j]:
            exist[j] = True
            break
for i in range(26):
    if exist[i] == False:
        print(char[i])
        exit()
print("None")


Measured memory_bytes: 73356
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int a, b, c;
	cin >> a >> b >> c;
	vector<int> l(n);
	cin >> l;
	function<int(int, int, int, int)> Dfs = [&](int v, int A, int B, int C) {
		if (v == n) {
			if (min({ A, B, C }) > 0) {
				return abs(a - A) + abs(b - B) + abs(c - C) - 30;
			}
			else {
				return inf;
			}
		}
		else {
			int ret1 = Dfs(v + 1, A + l[v], B, C) + 10;
			int ret2 = Dfs(v + 1, A, B + l[v], C) + 10;
			int ret3 = Dfs(v + 1, A, B, C + l[v]) + 10;
			int ret4 = Dfs(v + 1, A, B, C);
			return min({ ret1, ret2, ret3, ret4 });
		}
	};
	cout << Dfs(0, 0, 0, 0) << endl;
	return 0;
}

Measured memory_bytes: 3616
import java.io.*;
import java.util.*;

//solution classes here

public class Main {

    //main solution here

    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        long n = sc.nextLong();
        long k = sc.nextLong();
        if(n%k==0)
            out.println("0");
        else {
            out.println(Math.min(n%k,Math.abs(n%k-k)));

        }

        out.flush();
        out.close();
    }

    //solution functions here


    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

/* *****************************************************************************************************************************
 * I'M NOT IN DANGER, I'M THE DANGER!!!
 * *****************************************************************************************************************************
 */

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;

const ll INF = 1LL << 60;
const ll MAX = 1000000000000000000LL;

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

  vector<ll> as;
  REP(i, n)
  {
    ll a;
    cin >> a;
    as.push_back(a);
  }
  sort(ALL(as));

  ll ans = 1;
  for (auto a : as)
  {
    if (a != 0 && MAX / a < ans)
    {
      cout << -1 << endl;
      return 0;
    }

    ans *= a;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4320
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		String s = sc.next();
		boolean[] o = new boolean[n];
		
		for(int i = 0; i < n; i++)
		{
			o[i] = s.charAt(i) == 'o';
		}
		
		int[] fill = new int[n]; //1 sheep 2 wolf
		for(int a = 1; a <= 2; a++)
		{
			for(int b = 1; b <= 2; b++)
			{
				fill[0] = a;
				fill[1] = b;
				//0: a, 1: b
//				System.out.println(a + " " + b);
				
				//assign last fill
				boolean same;
				if(fill[0]==2)same = !o[0];
				else same = o[0];
				if(same)fill[n-1] = b;
				else fill[n-1] = 3-b;
//				System.out.println("Assign last with " + fill[n-1]);
				
				for(int i = 2; i < n-1; i++)
				{ //fill spot i
					if(fill[i-1]==2)same = !o[i-1];
					else same = o[i-1];
					if(same)fill[i] = fill[i-2];
					
					else fill[i] = 3-fill[i-2];
					
//						System.out.println("Fill " + i + " with: " + fill[i]);
//						System.out.println("Deb " + a + " " + b);
//						System.out.println("Fill " + i + " with: " + (fill[i]==1?'S':'W'));
//						System.out.println("Reason: " + (fill[i-1]==2) + " xor " + o[i-1] + " makes " + same);
				}
				
				//check last claim to 0
				int mustbe;
				if(fill[n-1]==2)same = !o[n-1];
				else same = o[n-1];
				if(same)mustbe = fill[n-2];
				else mustbe = 3-(fill[n-2]);
				
				if(fill[0] != mustbe)
				{
//					System.out.println("LS ERROR: " + fill[n-2] + " and " + fill[0] + ", mustbe " + mustbe);
//					System.out.println("Cause " + fill[n-1] + ", " + o[n-1]);
					continue;
				}
				
				
				//reassign last fill with n-2
				if(fill[n-2]==2)same = !o[n-2];
				else same = o[n-2];
				if(same)mustbe = fill[n-3];
				else mustbe = 3-(fill[n-3]);
				
				if(fill[n-1] != mustbe)
				{
					continue;
				}
				else
				{
					StringBuilder sb = new StringBuilder();
					for(int i = 0; i < n; i++)
					{
						if(fill[i] == 1)sb.append('S');
						else if(fill[i] == 2 )sb.append('W');
						else System.out.println("ERRROR!");
					}
					System.out.println(sb);
					return;
				}
				
				
			}
			
			
		}
		System.out.println(-1);

	}

}


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

using namespace std;
typedef long long ll;
typedef long int lt;
typedef vector<ll> vi;
typedef vector<int> vin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
#define all(a) a.begin(),a.end()
#define rep(i,a,b) for(int i=a;i<b;++i)
#define f(i,b) for(int i=0;i<b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define test(t) int t; cin>>t; while(t--) solve()
#define endl "\n"
#define p1 cout<<"YES"<<endl
#define p0 cout<<"NO"<<endl
#define fst ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int mod=1e9+7;

ll mod_pow(ll a,ll n,ll mod)	//(a^n)%mod
{	ll res=1;
	while(n){	if(n&1)	res=(res*a)%mod; n/=2; a=(a*a)%mod;	}
	return res;
}

void solve();

int main()
{
    fst;
    //test(t);
     solve();
}

/**********************<="Actual code strats here"=>*****************************/

ll k,n;
char getch()
{
    int a=k%26;
    if(a==0) {k-=26;return 'z';}
    else {k-=a; return (char)(a-1+'a');}
}

void solve()
{
    cin>>k;

    string ans="";

    while(k>0)
    {
        ans+=getch();
        k/=26;
    }

    reverse(all(ans));
    cout<<ans<<endl;
}

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

int main(){
	while(true){
		int n;
	       cin >> n;
		if(n==0)
			break;

		int *tn=new int[n];
		int *tt1=new int[n];
		int *tt2=new int[n];

		for(int i=0; i<n; i++){
			tt1[i]=0;	
			tt2[i]=0;		
		}

		for(int i=0; i<n; i++){
			cin >> tn[i];
			for(int j=0; j<4; j++){
				int m,s;
				cin >> m >> s;
				tt1[i]=tt1[i]+60*m+s;
				tt2[i]=tt2[i]+60*m+s;
			}
		}
		
		stable_sort(tt1,tt1+n);

		int a,b,c;

		for(int i=0; i<n;i++){
			if(tt2[i]==tt1[0]){
				a=tn[i];
				break;
			}
		}
		for(int i=0; i<n;i++){
			if(tt2[i]==tt1[1]){
				b=tn[i];
				break;
			}
		}
		for(int i=0; i<n;i++){
			if(tt2[i]==tt1[n-2]){
				c=tn[i];
				break;
			}
		}
		
		cout << a << endl << b << endl << c << endl;

		delete[] tn;
		delete[] tt1;
		delete[] tt2;
	}
		

}

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

int main()
{
  long long n, ans = 0;
  cin >> n;
  long long a[n], b[n];
  
  for (long long i = 0; i < n; i++){
    cin >> a[i];
  }
  b[0] = 0;
  for (long long i = 1; i < n; i++){
    if(a[i-1] > a[i]){
      b[i] = a[i-1] - a[i];
      a[i] += b[i];
    }else{
      b[i] = 0;
  	}
     //cout << b[i] << endl;
  }
 for (long long i = 0; i < n; i++){
    ans += b[i];
  }
    cout << ans << endl;

  return 0;
} 

Measured memory_bytes: 6716
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(3 * N);
  REP(i, M) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    G[3 * u].push_back(3 * v + 1);
    G[3 * u + 1].push_back(3 * v + 2);
    G[3 * u + 2].push_back(3 * v);
  }
  int S, T;
  cin >> S >> T;
  S--;
  T--;

  // BFS
  deque<tuple<int, int>> q;
  vector<bool> visited(3 * N);
  q.emplace_back(3 * S, 0);
  visited[S] = true;
  int ans = -1;
  while (q.size()) {
    auto [v, d] = q.front();
    q.pop_front();
    if (v == 3 * T) {
      assert(d % 3 == 0);
      ans = d / 3;
      break;
    }
    for (auto x : G[v]) {
      if (visited[x]) continue;
      visited[x] = true;
      q.emplace_back(x, d + 1);
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 19396
#include "bits/stdc++.h"
using namespace std;
#define MODULO 1000000007
#define PI 3.14159265359
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
     char c;
     cin>>c;
     char a='a',z='z';
     //char A='A',Z='Z';
     if(c>=a && c<=z)
     cout<<"a"<<endl;
     else
     cout<<"A"<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
 
int N, M;
double L[20], A[20], B[20];
 
double distance(double l, double a, double b) {
  return l*l + a*a + b*b;
}
 
double calcDist(int S) {
  vector<int> v;
  for(int i = 0; i < N; ++i) 
    if(S & 1 << i) v.push_back(i);
 
  double res = 0;
  for(int i = 0; i < v.size(); ++i) {
    for(int j = i+1; j < v.size(); ++j) {
      res += distance(L[v[i]]-L[v[j]],A[v[i]]-A[v[j]],B[v[i]]-B[v[j]]);
    }
  }
  return res;
}
 
double solve() {
  double ans = 0;
  for(int S = 0; S < 1<<N; ++S) {
    int n = 0;
    for(int i = 0; i < N; ++i) if(S & 1<<i) ++n;
    if(n == M) ans = max(ans, calcDist(S));
  }
  return ans;
}
 
int main() {
  cin >> N >> M;
  for(int i = 0; i < N; ++i)
    cin >> L[i] >> A[i] >> B[i];
  printf("%.20f\n", solve());
  return 0;
}

Measured memory_bytes: 1264
N, Y = map(int, input().split())
for i in range(min(Y//10000, N)+1):
    for j in range(min((Y-(10000*i))//5000, N-i)+1):
        zankin = Y - (10000*i) - (5000*j)
        if i + j + zankin //1000 == N:
            print(i, j, zankin//1000)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 40812
#include <stdio.h>
int main(void) {
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    if (n == 2) {
        printf("Borys\n");
        return 0;
    }
    if ((b - a) % 2) {
        printf("Borys\n");
    } else {
        printf("Alice\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

template <typename T>
class segmenttree
{
private:
    int n;

public:
    using F = function<T(T, T)>;

    T dif;
    F f;
    vector<T> st;

    segmenttree(int size, T init, F f) : f(f)
    {
        n = 1;

        while (n < size)
        {
            n *= 2;
        }

        st.assign(2 * n - 1, init);
    }

    void set(int i, T x)
    {
        st[i + n - 1] = x;
    }

    void build()
    {
        for (int i = n - 2; i >= 0; i--)
        {
            st[i] = f(st[i * 2 + 1], st[i * 2 + 2]);
        }
    }

    void update(int i, T x)
    {
        i += n - 1;
        st[i] = x;

        while (i > 0)
        {
            i = (i - 1) / 2;
            st[i] = f(st[2 * i + 1], st[2 * i + 2]);
        }
    }

    T query(int a, int b)
    {
        return query_(a, b, 0, 0, n);
    }

    T query_(int a, int b, int k, int l, int r)
    {
        if (r <= a || b <= l)
        {
            return dif;
        }

        if (a <= l && r <= b)
        {
            return st[k];
        }
        else
        {
            T x = query_(a, b, 2 * k + 1, l, (l + r) / 2);
            T y = query_(a, b, 2 * k + 2, (l + r) / 2, r);

            return f(x, y);
        }
    }
};

//初期化例 segmenttree<bitset<26>> seg(n, 0, [](bitset<26> a, bitset<26> b) { return a | b; });

int main(void)
{
    int n, q;
    ll x, y;
    int i;
    vector<ll> a, ans;

    cin >> n >> q;

    a.assign(n, 0);

    segmenttree<ll> seg(n, 0, [](ll a, ll b) { return a + b; });

    seg.dif = 0;

    for (i = 0; i < q; i++)
    {
        int c;
        cin >> c >> x >> y;
        x--;

        if (c == 0)
        {
            a[x] += y;
            seg.update(x, a[x]);
        }
        else
        {
            ans.push_back(seg.query(x, y));
        }
    }

    for (auto k : ans)
    {
        cout << k << endl;
    }
}


Measured memory_bytes: 6348
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll ZERO = 0;
const ll INF = 1e14;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;

int main() {
    int N,C,K;
    cin >> N >> C >> K;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    int ret = 0;
    int itr = 0;
    for(int i = 0;i < N + 1;i++) {
        int A = vec.at(itr) + K;
        int cnt = 1;
        while(itr < N && vec.at(itr) <= A && cnt <= C) {
            itr++;
            cnt++;
        }
        ret++;
        if(itr >= N) {
            break;
        }
    }
    cout << ret << endl;
}

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


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N, A, B;
  cin >> N >> A >> B;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  int64_t C = A - B;
  int64_t ok = 1000000000;
  int64_t ng = 0;
  while(ok - ng > 1){
    int64_t mid = (ok + ng) / 2;
    vector<int64_t> amari(0);
    bool clear = true;
    for(int i=0; i<N; i++){
      if(vec.at(i) > mid*B){
        amari.push_back(vec.at(i) - mid*B);
      }
    }
    int64_t cnt = 0;
    for(int i=0; i<amari.size(); i++){
      cnt += (amari.at(i) + C-1)/C;
    }
    if(cnt > mid){
      clear = false;
    }
    
    
    if(clear){
      ok = mid;
    }
    else{
      ng = mid;
    }
  }
  cout << ok << endl;
}
    

Measured memory_bytes: 2896
#include <stdio.h>
#include <string.h>

int main(){
  char S[102];
  scanf("%s",S);
  int N=strlen(S);
  int c=1;
  for(int i=0;i<N;i++){
    if(i%2==0){
      if(S[i]=='L'){
        c=0;
      }
    }else{
      if(S[i]=='R'){
        c=0;
      }
    }
  }
  if(c) printf("Yes\n");
  else printf("No\n");
    
  return 0;
}

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

int solve(int d, int tate){
  return d * tate * tate;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int d;
  while(cin>>d){
    int ans = 0;
    for(int i=0;i<=600-d;i+=d)
      ans += solve(d, i);
    cout << ans << endl;  
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a;
    ll z = 0, x = 0, y = 0;
    map<int, int> m;
    cin >> n;
    while (n--) cin >> a, m[a]++;
    for (pii i : m) if (i.second >= 4) z = max(z, 1ll * i.first * i.first);
    for (pii i : m) if (i.second >= 2) {
        y = x;
        x = i.first;
    }
    cout << max(z, y * x);
}


Measured memory_bytes: 4992
#include <stdio.h>
int main(void){
    long int i, n, a[200001], b[200001] = {0}, c[200001] = {0}, d[200001] = {0};
    long int result = 0, time = 0;
    
    scanf("%ld", &n);
    for( i = 0; i < n; i++ ){
        scanf("%ld ", &a[i]);
        b[a[i]] += 1;
    }

    for( i = 1; i <= n; i++ ){
        if( b[i] > 0 ){
        c[i] = b[i]*(b[i]-1)/2;
        d[i] = (b[i]-1)*(b[i]-2)/2;
        }
        result += c[i];
    }
    
    for( i = 0; i < n; i++ ){
        time = result;
        time -= (c[a[i]] - d[a[i]]);
        printf("%ld\n", time);
    }
    
    return 0;
}


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

int main(){
  string s;
  string t;
  cin >> s >> t;
  int ans=0;
  int n = s.size();
  rep(i,n){
    if(s[i]==t[i]) continue;
    ans +=1;
  }

  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 3856
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define SORT(x) (sort(x.begin(),x.end()))
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    char S[100007];
    cin >> S;
    int y=0;
    rep(i,strlen(S)){
        if((i%2==0 && S[i]=='1' )|| (i%2==1 && S[i]=='0')){
            y++;
        }
    }
    cout << (y>(strlen(S)-y) ? strlen(S)-y : y ) << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int n,m;
    cin>>m>>n;
    int z[n][10];
    int k[n];
    for (int i = 0; i < n; ++i) {
        cin>>k[i];
        for (int j = 0; j < k[i]; ++j) {
            cin>>z[i][j];
            z[i][j]--;
        }
    }

    int p[n];
    for (int i = 0; i < n; ++i) {
        cin>>p[i];
    }
    int ans=0;


    for (int i = 0; i <pow(2,m); ++i) {
        int a[m]={0};
        int s=i;
        for (int j = m-1; j >=0 ; --j) {
            a[j]=s%2;
            s/=2;
        }

        bool flag=true;
        for (int j = 0; j < n; ++j) {
            int count=0;
            for (int l = 0; l < k[j]; ++l) {
                if(a[z[j][l]]==1)
                    count++;
            }
            if(count%2!=p[j]%2)
            {
                flag=false;
                break;
            }
        }
        if(flag==true)
        {
            ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int,int>
#define fi first 
#define se second 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);
#define mem(a,v) memset(a,v,sizeof(a))
const ll INF=1e18;
const int mod=1e9+7;
const int iinf=1e9+10;
const int xd[4]={1,0,-1,0},yd[4]={0,1,0,-1};
const int mxN=1e2;
bool v[mxN+1]{};
int main()
{
    faster
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(a==b)
            v[i]=1;
        else
            v[i]=0;
    }
    int ans=0;
    for(int i=0;i<n-2;i++){
        if(v[i]&&v[i+1]&&v[i+2])
            ans++;
    }
    cout<<(ans==0?"No":"Yes");
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
	vi a(n);
	rep(i,n)cin >> a[i];
	int ans = 0;
	int t = 0;
	rep(i,n){
		if(t <= a[i])t = a[i];
		else ans += t - a[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 4372
from copy import deepcopy
H,W,K=map(int,input().split())
c=[list(input()) for i in range(H)]
ans=0
for i in range(2**H):
        for k in range(2**W):
            G=deepcopy(c)
            cnt=0
            for j in range(H):
                if i>>j&1:
                    for x in range(W):
                        G[j][x]='@'
            for f in range(W):
                if k>>f&1:
                    for y in range(H):
                        G[y][f]='@'
            for j in range(H):
                for f in range(W):
                    if G[j][f]=='#':
                        cnt+=1
            if cnt==K:
                ans+=1
print(ans)

Measured memory_bytes: 9344
#include<stdio.h>
#include<stdlib.h>
int asc(const void* a, const void* b)
{
	return *(int*)b - *(int*)a;
}
int main()
{
	int n, h;
	scanf("%d %d", &n, &h);
	int i;
	int a[100005], b[100005];
	for (i = 0; i < n; i++)
		scanf("%d %d", &a[i], &b[i]);
	qsort(b, n, sizeof(int), asc);
	int max = 0;
	for (i = 0; i < n; i++)
		if (a[i] > max)
			max = a[i];
	int ans = 0;
	for (i = 0; i < n; i++)
	{
		if (b[i] < max)
			break;
		if (h <= 0)
			break;
		ans++;
		h -= b[i];
	}
	if (h > 0)
		ans += (h + max - 1) / max;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1276
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
cnt = 0
yen = 0

sortkey = lambda val: val[0]
AB.sort(key=sortkey)

for i in range(N):
    if M >= AB[i][1]:
        cnt += AB[i][1]
        yen += AB[i][0] * AB[i][1]
        M -= AB[i][1]
    elif M < AB[i][1]:
        cnt += M
        yen += AB[i][0] * M
        M = 0
    if M == 0:
        print(yen)
        break

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

#define ll long long
#define ull unsigned long long

using namespace std;

int N;

void dfs(string s, char mx) {
	if (s.size() == N){
		cout << s << endl;
	} else {
		for (char c = 'a'; c <= mx; c++){
			char nextMx = (c == mx) ? (char) (mx+1) : mx;
			dfs(s + c, nextMx);
		}
	}
}

int main() {
	cin >> N;

	dfs("", 'a');

	return 0;
}


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

int main()
{
	int N;
	cin >> N;
	string ans = "No";
	int cnt = 0;
	for( int i = 0; i < N; i++ ) {
		int D1, D2;
		cin >> D1 >> D2;
		if( D1 == D2 ) cnt++;
		else cnt = 0;
		if( cnt >= 3 ) ans = "Yes";
	}

	cout << ans << endl;
}


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

int main()
{
  string s;
  int k = 0;
  cin >> k;
  cin >> s;
  int ss = s.size();

  if(ss > k){
    s.erase(k);
    cout << s << "..." << endl;
  }else {
    cout << s << endl;
  }
}

Measured memory_bytes: 3628
# ＤＦＳ, グラフ, 全探索, 親の情報を自身に加算
 # ※ 要削除

n, q = map(int,input().split())

pic = [[] for _ in range(n+1)] # ダミーのノード '0' を含む
for _ in range(n-1): # 絵の取り込み
    x, y = map(int, input().split())
    pic[x].append(y)
    pic[y].append(x)
    
cnts = [0] * (n+1) # カウンター初期化
for _ in range(q): # 初期情報取り込み
    x, y = map(int, input().split())
    cnts[x] += y

visited = [0] * (n+1) # 訪問の記録、初期化
visited[0], visited[1] = 1, 1 # 開始時情報記録

stack = []
stack.append(1)

#print(n, q) # ※
#print(pic) # ※
#print(cnts)
#print(visited) # ※

while stack:
    tmp = stack.pop() # 探索候補を pop して...
    for i in pic[tmp]: # 次の探索候補を探索
        if visited[i] != 0: # 未訪問かどうかを確認...
            continue
        else: # 未訪問の場合...
            visited[i] = 1 # 現在地の訪問を記録
            cnts[i] += cnts[tmp] # 親の 'cnt' を自身の 'cnt' に加える
            stack.append(i) # 現在地を探索候補に積む

print(*cnts[1:])


Measured memory_bytes: 55828
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int a,b;
  vector<int> vec(n);

  for(int i = 0; i < m; i++){
    cin >> a >> b;
    vec.at(a-1)++;
    vec.at(b-1)++;
  }
  for(int i = 0; i < n; i++){
    cout << vec.at(i) << endl;
  }
}

Measured memory_bytes: 3608
n,t = map(int, input().split(" "))
num = [0 for i in range(t)]
for i in range(n):
    l,r = map(int, input().split(" "))
    num[l] += 1
    if r < t:
        num[r] -= 1
for i in range(1,t):
    num[i] += num[i-1]
print(max(num))


Measured memory_bytes: 9668
N = gets.to_i
S = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".chomp.split(", ")

puts S[N-1]


Measured memory_bytes: 1788
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
   int N,K;
   cin >> N >> K;
   int A[N];
   for(int i=0;i<N;i++)cin >> A[i];
   long long left =0;
   long long right = 1000000001;
   while(left+1<right){
      long long mid = (left+right)/2;
      int cnt=0;
      for(int i=0;i<N;i++){
         cnt += (A[i]-1)/mid;
      }
      if(cnt <= K){
         right = mid;
      }
      else{
         left = mid;
      }
   }
   cout << right << endl;
   return 0;
}


Measured memory_bytes: 4340
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=s.size()-3;i>0;i=i-2)
	{
		char a[i/2+2],b[i/2+2];
		for(int j=0;j<=i/2;j++)
		{
			a[j]=s[j];
		}
		int p=0;
		for(int j=i/2+1;j<=i;j++)
		{
			b[p]=s[j];
			p++;
		}
		bool ss=true;
		for(int j=0;j<=i/2;j++)
		{
			if(a[j]!=b[j])
			{
				ss=false;
				break;
			}
		}
		if(ss==true)
		{
			cout<<i+1;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

A.sort()


while True:
    flag = False
    _min = min(A)
    for i in range(N):
        if A[i] % _min > 0:
            A[i] %= _min
            flag = True

    if not flag:
        print(min(A))
        exit()

Measured memory_bytes: 14252
while True:
    n,x = map(int, input().split())
    if n == 0 and x == 0:
        break
    import itertools
    pairList = itertools.product(range(1, n+1),range(1, n+1),range(1, n+1))
    print(sum([1 for i, i2, i3 in pairList if i + i2 + i3 == x and i < i2 < i3]))



Measured memory_bytes: 5656
import numpy as np
h,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
b=[list(map(int,input().split())) for _ in range(h)]
d=[]
for i in range(h):
  d.append([abs(a[i][j]-b[i][j]) for j in range(w)])
dp=np.zeros((h,w,12800))
# dp[r][c][j]:(r,c)まで考えたときjにできるか。0：できない。1以上：できる。
dp[0,0,d[0][0]+6400]=1
for i in range(w-1):
  if d[0][i+1]==0:
    dp[0,i+1]+=dp[0,i]
    continue
  dp[0,i+1,d[0][i+1]:]+=dp[0,i,:-d[0][i+1]]
  dp[0,i+1,:-d[0][i+1]]+=dp[0,i,d[0][i+1]:]
for i in range(h-1):
  if d[i+1][0]==0:
    dp[i+1,0]+=dp[i,0]
    continue
  dp[i+1,0,d[i+1][0]:]+=dp[i,0,:-d[i+1][0]]
  dp[i+1,0,:-d[i+1][0]]+=dp[i,0,d[i+1][0]:]
for r in range(1,h):
  for c in range(1,w):
    if d[r][c]==0:
      dp[r,c]+=dp[r-1,c]
      dp[r,c]+=dp[r,c-1]
      continue
    dp[r,c,d[r][c]:]+=dp[r-1,c,:-d[r][c]]
    dp[r,c,:-d[r][c]]+=dp[r-1,c,d[r][c]:]
    dp[r,c,d[r][c]:]+=dp[r,c-1,:-d[r][c]]
    dp[r,c,:-d[r][c]]+=dp[r,c-1,d[r][c]:]
print(min([abs(e-6400) for e in np.where(dp[h-1,w-1]>0)[0]]))

Measured memory_bytes: 654528
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    int a;
    scanf("%d",&a);
    string s;
    cin >> s;
    if (a >= 3200) cout << s;
    else cout << "red\n";
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

A,B = map(str,readline().rstrip().split())
A = int(A)
B_i,B_d = map(int,B.split("."))
B = B_i*100+B_d
print((A*B)//100)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int n,d;
  while(cin >> n >> d){
    int ans = (n+2*d)/(2*d+1);

    cout << ans << endl;
  }
  
  return 0;
}


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

using namespace std;


int main()
{
    int n,d,c=0,cc=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>d;
        if(d%2==0)c++;
        if(d%4==0)cc++;
    }
    if(cc+c+(cc==c&&c?1:0)>=n)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256