akhauriyash/Code-Regression huggingface dataset:
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	vi in(n);
	rep(i,n)cin>>in[i];
	a-=b;
	int l=0,r=1000000010;
	while(r-l>1){
		ll h=(l+r)/2;
		ll co=0;
		rep(i,n)if(in[i]-h*b>0)
			co+=(in[i]-h*b+a-1)/a;
		
		if(co>h)l=h;
		else r=h;
	}
	cout<<r<<endl;
}





Measured memory_bytes: 640
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z) cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair<int, int>
#define ld long double
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
char S[10][10];
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int H, W;
  cin >> H >> W;
  REP(i, H) REP(j, W) cin >> S[i][j];
  int target = 0;
  bool ok = true;
  REP(i, H) {
    bool notB = false;
    REP(j, W) {
      char st = S[i][j];
      if (j < target) {
        if (st == '#') ok = false;
      } else if (j == target) {
        if (st == '.') {
          ok = false;
        }
      } else {
        if (st == '.') {
          notB = true;
        } else {
          if (notB && st) {
            ok = false;
          }
          target = j;
        }
      }
    }
  }
  if (target != W - 1) ok = false;
  print(ok ? "Possible" : "Impossible");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<int, int> P;


int main(){
    ll x;   cin >> x;
    int res = 0;
    ll cur = 100;
    while(true){
        if(cur >= x){
            break;
        }

        cur += cur / 100;
        res++;
    }

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cmath>

using namespace std;

typedef long long ll;

int main() {
	ll a, b, c;

	cin >> a >> b >> c;
	ll ans = c - a - b;
	if (ans < 0)cout << "No" << endl;
	else {
		ll res = (c - a - b) * (c - a - b) - 4 * a * b;
		if (res > 0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;

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

  ll res=1e+14;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      res = min(res,i+n/i-2);
    }
  }

  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main {

	static int tc;
	public static void main(String[] args) {
		for (tc = 1; read(); tc++) {
			solve();
		}
	}
	
	
	static int N;
	static Scanner sc = new Scanner(System.in);
	static boolean read() {
		N = sc.nextInt();
		if (N == 0) return false;
		return true;
	}
	
	static void solve() {
		int val = 1;
		int[][] jpeg = new int[100][100];
		jpeg[0][0] = val++;
		int m = 0, x = 1, y = 0;
		for (int i = 1; i < N * 2; i++) {
			if (i < N - 1) {
				if (i % 2 == 0) {
					for (; y >= 0; x++, y--) {
						jpeg[y][x] = val++;
					}
				} else {
					for (; x >= 0; x--, y++) {
						jpeg[y][x] = val++;
					}
				}
			} else {
				if (i % 2 == 0) {
					for (; x < N; x++, y--) {
						jpeg[y][x] = val++;
					}
				} else {
					for (; y < N; x--, y++) {
						jpeg[y][x] = val++;
					}					
				}
			}
			
			if (i < N - 1) {
				if (i % 2 == 0) {
					y++;
				} else {
					x++;
				}
			} else {
				if (i % 2 == 0) {
					x--; y += 2;
				} else {
					x += 2; y--;
				}
			}
		}
		
		System.out.println("Case " + tc + ":");
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				System.out.printf("%3d", jpeg[i][j]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

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

int main() {

  int n, x;
  cin >> n >> x;

  const int m = 1 << 9; // 512
  const int mod = 998244353;
  vector<vector<int>> dp(m, vector<int>(x + 1));
  rep(k, x + 1) dp[0][k] = 1;
  rep(i, n) {
    vector<vector<int>> nxt(m, vector<int>(x + 1));
    rep(j, m) {
      for (int k = 0; k <= x; k++) {
        if ((j ^ k) < m) { nxt[j ^ k][k] += dp[j][k]; }
      }
    }
    rep(j, m) {
      rep(k, x) {
        nxt[j][k + 1] += nxt[j][k];
        nxt[j][k + 1] %= mod;
      }
    }

    dp.swap(nxt);
  }

  cout << dp[x][x] << endl;

  return 0;
}



Measured memory_bytes: 4952
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <cctype>
#include <sstream>

/*

bool isOK(int index, int key) {
	if (a[index] >= key) return true;
	else return false;
}
int binary_search(int key) {
	int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;

		if (isOK(mid, key)) ok = mid;
		else ng = mid;
	}
	return ok;
}
*/

//vector<vector<ll> > data(3, vector<ll>(4));
//vector<ll> data(N);
//v.erase(remove(v.begin(), v.end(), value_to_remove), v.end());
//int num = atoi(numStr.c_str());
//str s = to_string(i);
//int i = c - '0'
//sort(data.begin(), data.end());
//reverse(data.begin(), data.end());
//data.erase(unique(data.begin(), data.end()), data.end()); //重複なし
//str.substr(n)//n番以降スライス
//str.substr(n,m)//n番以降m文字スライス
//str.erase(n)//n番以降削除
//str.erase(n,m)//n番以降m文字削除
//str.find(str_to_find)//位置 or string::npos
//cout << fixed << setprecision(15) << n;
//while (cin >> c){if (c == EOF) break;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=ll(a);i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define PB push_back
#define SIZE(x) ll(x.size())
#define ALL(x) x.begin(),x.end()
#define INF 1000000000000
#define MOD 1000000007
#define PI 3.14159265358979323846

using namespace std;
typedef pair<ll, ll> P;

int main() {
	string s;
	cin >> s;
	vector<ll> data(4);
	REP(i, 4) {
		data[i] = s[i] - '0';
	}
	vector<char> op(3);

	REP(bit, 1 << 3) {
		ll sum = data[0];
		REP(i, 3) {
			if (bit & (1 << i)) {
				op[i] = '+';
				sum += data[i + 1];
			}
			else {
				op[i] = '-';
				sum -= data[i + 1];
			}
		}
		if (sum == 7) {
			break;
		}
	}
	
	cout << data[0];
	REP(i, 3) {
		cout << op[i] << data[i + 1];
	}
	cout << "=7";
}



Measured memory_bytes: 3612
#include <cstring>
#include <cstdio>
typedef long long ll;
struct graph
{
	int lst[100005], to[200005], pre[200005], tot; 
	graph()
	{
		memset(lst, -1, sizeof(lst));
		tot = 0; 
	}
	inline void add_edge(int u, int v)
	{
		to[tot] = v; 
		pre[tot] = lst[u]; 
		lst[u] = tot++;
	}
} g, rg; 
int fa[100005], sz[100005], orig[100005]; 
int cnt[5], col[100005]; 
bool vis[100005], f; 
int getfa(int u)
{
	if (u == fa[u])
		return u; 
	return fa[u] = getfa(fa[u]); 
}
void dfs(int u, int c)
{
	vis[u] = true; 
	col[u] = c;
	cnt[c]++; 
	for (int i = g.lst[u]; ~i; i = g.pre[i])
	{
		if (!vis[g.to[i]])
			dfs(g.to[i], (c + 1) % 3); 
		else if (col[g.to[i]] != (c + 1) % 3)
			f = true; 
	}
	for (int i = rg.lst[u]; ~i; i = rg.pre[i])
	{
		if (!vis[rg.to[i]])
			dfs(rg.to[i], (c + 2) % 3); 
		else if (col[rg.to[i]] != (c + 2) % 3)
			f = true; 
	}
}
int main()
{
	// freopen("AGC006-F.in", "r", stdin); 
	int n, m; 
	scanf("%d%d", &n, &m); 
	for (int i = 0; i < n; i++)
	{
		fa[i] = i;
		sz[i] = 1;
	}
	for (int i = 0; i < m; i++)
	{
		int u, v; 
		scanf("%d%d", &u, &v); 
		g.add_edge(--u, --v); 
		rg.add_edge(v, u); 
		u = getfa(u); 
		v = getfa(v); 
		if (u != v)
		{
			fa[u] = v; 
			sz[v] += sz[u]; 
			orig[v] += orig[u]; 
		}
		orig[v]++; 
	}
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (i != fa[i])
			continue; 
		f = false; 
		memset(cnt, 0, sizeof(cnt)); 
		dfs(i, 0); 
		if (f)
			ans += (ll)sz[i] * sz[i]; 
		else if (cnt[0] && cnt[1] && cnt[2])
			ans += (ll)cnt[0] * cnt[1] + (ll)cnt[0] * cnt[2] + (ll)cnt[1] * cnt[2]; 
		else
			ans += orig[i]; 
	}
	printf("%lld\n", ans);
	return 0; 
}


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

int main()
{
	int A,B,Z,O,M;
	cin >> A >> B;
	Z=A+B;
	O=A-B;
	M=A*B;
	if (Z>=O and Z>=M)
	cout << Z;
	else if (O>=M and O>=Z)
	cout << O;
	else
	cout << M;
}


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

int keisan (int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main () {
    int N, A, B;
    cin >> N >> A >> B;
    int total = 0;
    for (int i = 0; i <= N; i++) {
        int sum = keisan(i);
        if (sum >= A && sum <= B) {
            total += i;
        }
    }
    cout << total << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define inf 1e9+10
#define eps 1e-7
using namespace std;
inline ll read(){
	ll x=0;ll f=1;char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)) {x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int k;
int main(){
	k=read();
	int x=k/2;int y=k-x;
	printf("%d\n",x*y);
	return 0;
}

Measured memory_bytes: 764
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

ab = sorted(AB, key=lambda x:(x[1],x[0]))

now = 0
for a, b in ab:
	if b < now + a:
		print("No")
		break
	else:
		now += a
else:
	print("Yes")


Measured memory_bytes: 69928
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    A, B = map(int, input().split())

    def gcd(a,b):
        if a < b:
            a, b = b, a
        while b:
            a, b = b, a%b
        return a

    print(A*B//gcd(A,B))

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc148","c",main)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右攜下昴 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 敘大公約摧
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 敘擣公倍摧
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/


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

	string s;
	cin >> s;

	bool good = true;

	if (s[0] == s[1]) good = false;
	if (s[1] == s[2]) good = false;
	if (s[2] == s[3]) good = false;

	if (good) cout << "Good" << endl;
	else cout << "Bad" << endl;

	return 0;
}


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

/**
 * @brief 0からxまでの排他的論理和を計算する。<br>
 * BからAまでの範囲なら、xorial(B) ^ xorial(A-1)で求まる。
 */
template<typename T = int>
T xorial(T x) {
  T result{};
  T start{x - x % 4};
  for (T i{start}; i <= x; ++i) {
    result ^= i;
  }
  return result;
}

int main() {
  long A, B;
  cin >> A >> B;

  cout << (xorial(B) ^ xorial(A - 1)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"

int V, E;
int memo[15][15][1 << 15];
int getans(const int start,const int now, bitset<15>&used, const vector<vector<pair<int, int>>>&edges) {
	if (memo[start][now][used.to_ulong()]!=-1) {
		return memo[start][now][used.to_ulong()];
	}
	else {
		if (used.count() == V) {
			if (start == now)return memo[start][now][used.to_ulong()] = 0;
			else return memo[start][now][used.to_ulong()] = 1e9;
		}
		int ans = 1e9;
		for (auto e : edges[now]) {
			const int dst = e.first;
			const int time = e.second;
			if (!used[dst]) {
				used[dst] = true;
				ans = min(ans, time + getans(start, dst, used, edges));
				used[dst] = false;
			}
		}
		return memo[start][now][used.to_ulong()] = ans;
	}
}
int main() {
	for (int h = 0; h < 15; ++h) {
		for (int i = 0; i < 15; ++i) {
			for (int j = 0; j < (1 << 15); ++j) {
				memo[h][i][j] = -1;
			}
		}
	}
	cin >> V >> E;
	vector < vector<pair<int, int>>>edges(V);
	for(int i = 0; i < E; ++i) {
		int s, t, d; cin >> s >> t >> d;
		edges[s].push_back(make_pair(t, d));
	}
	int ans = 1e9;
	for (int s = 0; s < V; ++s) {
		bitset<15>bs;
		ans = min(ans, getans(s, s, bs, edges));
	}
	if (ans >= 1e9)ans = -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 31916
def J(m) :
    tmp = m[-1]
    del m[-1]
    m.insert(0, tmp)
    return m
    
def C(m) :
    tmp = m[0]
    del m[0]
    m.append(tmp)
    return m
    
def E(m) :
    if len(m) % 2 == 1 :
        x = len(m) // 2
        tmp = m[0:x]
        middle = m[x]
        del m[0:x+1]
        m = m + [middle] + tmp
        return m
    
    else :
        x = len(m) // 2
        tmp = m[0:x]
        del m[0:x]
        m = m + tmp
        return m
    
def A(m) :
    m.reverse()
    return m
    
def M(m) :
    for i in range(len(m)) :
        if '0' <= m[i] <= '8' :
            m[i] = str(int(m[i]) + 1)
        elif m[i] == '9' :
            m[i] = '0'
    return m
    
def P(m) :
    for i in range(len(m)) :
        if '1' <= m[i] <= '9' :
            m[i] = str(int(m[i]) - 1)
        elif m[i] == '0' :
            m[i] = '9'
    return m

n = int(input())
for i in range(n) :
    member = list(input())
    member.reverse()
    message = list(input())
    
    for j in range(len(member)) :
        if member[j] == 'J' :
            message = J(message)
        elif member[j] == 'C' :
            message = C(message)
        elif member[j] == 'E' :
            message = E(message)
        elif member[j] == 'A' :
            message = A(message)
        elif member[j] == 'P' :
            message = P(message)
        elif member[j] == 'M' :
            message = M(message)
    print(*message, sep='')
            


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    int ans = 0, tmin = 200005;
    rep(i, n) {
        int p;
        cin >> p;
        if (p <= tmin) {
            ans++;
            tmin = p;
        }
    }
    cout << ans << endl;
    return 0;
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, t; cin >> a >> b >> t;
	cout << (t/a) * b << "\n";
	return 0;
}


Measured memory_bytes: 256
N = gets.strip.to_i
ans=0
if N<=9
    ans=N
elsif N<=99
    ans=9
elsif N<=999
    ans=9+N-100+1
elsif N<=9999
    ans+=9+900
elsif N<=99999
    ans+=9+900+N-10000+1
else
    ans+=9+900+90000
end
puts ans


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 505;

int n;
int c[N], s[N], f[N];

int main() {

	FAST;
	
	cin >> n;
	for (int i = 1; i < n; i ++) {
		cin >> c[i] >> s[i] >> f[i];
	}
	for (int i = 1; i < n; i ++) {
		int t = 0;
		for (int j = i; j < n; j ++) {
			if (t < s[j]) {
				t = s[j];
			}
			else {
				if (t % f[j]) {
					t += (f[j] - t % f[j]);
				}
			}
			t += c[j];
		}
		cout << t << '\n';
	}
	cout << 0 << '\n';
	return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if 500*a + 100*b + 50*c == X:
        cnt += 1
print(cnt)


Measured memory_bytes: 9072
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<iostream>
using namespace std;

#define int long long int
#define all(x) (x).begin(), (x).end()
#define removeDuplicates(a) a.resize(unique(all(a))-a.begin())
#define endl '\n'

template<typename Type>
istream &operator>>(istream &in,vector<Type>&vec){
	int n=vec.size();	
	for(int i=0;i<n;i++)
		in>>vec[i];
	return in;
}
template<typename Type>
ostream &operator<<(ostream &out,vector<Type>&vec){
	for(auto val:vec)
		out<<val<<" ";
	out<<endl;
	return out;
}

void solve(){
	int n;
	cin>>n;
	vector<vector<int>>a(n,vector<int>(3));
	cin>>a;
	vector<vector<int>>dp(n+1,vector<int>(3));
	for(int i=1;i<=n;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(j==k) continue;
				dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i-1][j]);
			}
		}
	}
	int ans=*max_element(all(dp[n]));
	cout<<ans<<endl;
}

int32_t main(){

	//remove for interactive problems
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	solve();
	cerr<<"Time : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n";

	return 0;
}

Measured memory_bytes: 14248
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.close();
        if(N==1){
            System.out.println(0);
        }else{
            System.out.println(1);
        }
    }
}


Measured memory_bytes: 35620
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<cstring>
#include<sstream>
#include<cassert>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()

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





int main()
{
    string a, b;
    cin >> a >> b;
    
    if (a.size() > b.size()) {
        cout << "GREATER" << endl;
    } else if (a.size() < b.size()) {
        cout << "LESS" << endl;
    } else {
        int size = static_cast<int>(a.size());
        
        rep(i, size) {
            if (a[i] > b[i]) {
                cout << "GREATER" << endl;
                return 0;
            } else if (a[i] < b[i]) {
                cout << "LESS" << endl;
                return 0;
            }
        }
        
        cout << "EQUAL" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n==1)cout<<"Hello World"<<endl;
  else{
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c, d;
	int ans;
	int n;
	
	while (scanf("%d", &n) == 1){
		ans = 0;
		for (a = 0; a <= 9; a++){
			for (b = 0; b <= 9; b++){
				for (c = 0; c <= 9; c++){
					for (d = 0; d <= 9; d++){
						ans += (a + b + c + d == n);
					}
				}
			}
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

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

namespace ABC098A
{
	class Program
	{
		static void Main(string[] args)
		{
			int A, B, max;

			var word = Console.ReadLine().Split(' ');

			A = int.Parse(word[0]);
			B = int.Parse(word[1]);

			max = A + B;
			if(max < A - B) max = A - B;
			if(max < A * B) max = A * B;

		
			Console.WriteLine(max);

			Console.ReadKey();

		}
	}
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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++)
#define out(n) cout << n << endl;
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int64_t, int >prime_factor(int64_t n){map< int64_t, int > ret;for(int64_t i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    int a[100]; a[0]=1; FOR(i,1,76)a[i]=a[i-1]*2%MOD;
    int ans = 0;
    int cnt[100][2]={0};
    while(n--){
        int x; cin >> x;
        REP(i,70){
            int bit = x%2;
            ans += cnt[i][bit^1]*a[i]%MOD;
            ans %= MOD;
            cnt[i][bit]++;
            x /= 2;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include<string.h>
#include<limits.h>

int main(){
	float x[4],y[4];
	int i;
	
	while(scanf("%f%f%f%f%f%f%f%f",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3])!=EOF){
	
		if(x[0]>x[3] || x[1]<x[2] || y[0]>y[3] || y[1]<y[2])printf("NO\n");
		else printf("YES\n");
	}
return 0;
}

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

// 連結グラフGにおいて，頂点uと，uから出ているすべてのエッジを削除して得られる部分グラフが非連結になるとき，頂点uを関節点（切断点）という

const int MAX = 101010;
vector<int> G[MAX];
int N;
bool visited[MAX];
int prenum[MAX], parent[MAX], lowest[MAX], timer;

void dfs(int current, int prev) {
    prenum[current] = lowest[current] = timer;
    timer++;

    visited[current] = true;

    for (int next : G[current]) {
        if (!visited[next]) {
            parent[next] = current;
            dfs(next, current);
            lowest[current] = min(lowest[current], lowest[next]);
        }
        else if (next != prev) {
            lowest[current] = min(lowest[current], prenum[next]);
        }
    }

    // ノードcurrentの探索が終了した直後の処理
}

void art_points() {
    for (int i = 0; i < N; ++i) visited[i] = false;
    timer = 1;
    dfs(0, -1); // 0 == root

    set<int> ap;
    int np = 0;
    for (int i=1; i<N; ++i) {
        int p = parent[i];
        if (p == 0) np++;
        else if (prenum[p] <= lowest[i]) ap.insert(p);
    }
    if (np > 1) ap.insert(0);
    for (auto tmp : ap) {
        cout << tmp << endl;
    }
}

int main() {
    int m;
    cin >> N >> m;
    rep(i, m) {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    art_points();
    return 0;
}



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

int main(){
  int N, M, C, s, g;
  long long int INF = 1e15;
  while(cin >> N >> M >> C >> s >> g, N){
    --s;--g;
    vector< vector<long long int> > G(N, vector<long long int>(N,INF));
    vector< vector< vector<long long int> > > D(C, G);
    long long int x, y, d, c;
    for(int i = 0; i < M; ++i){
      cin >> x >> y >> d >> c;
      --x;--y;--c;
      D[c][x][y] = min(D[c][x][y],d);
      D[c][y][x] = D[c][x][y];
    }
    for(int c = 0; c < C; ++c){
      for(int k = 0; k < N; ++k){
        for(int i = 0; i < N; ++i){
          for(int j = 0; j < N; ++j){
            D[c][i][j] = min(D[c][i][j],D[c][i][k]+D[c][k][j]);
          }
        }
      }
    }
    vector<int> P(C);
    for(int i = 0; i < C; ++i) cin >> P[i];
    vector< vector<long long int> > Q(C), R(C), F(C);
    for(int c = 0; c < C; ++c){
      int q, r;
      Q[c].push_back(0);
      for(int i = 0; i < P[c]-1; ++i){
        cin >> q;
        Q[c].push_back(q);
      }
      for(int i = 0; i < P[c]; ++i){
        cin >> r;
        R[c].push_back(r);
      }
      F[c].push_back(0);
      for(int i = 0; i < P[c]-1; ++i){
        F[c].push_back((Q[c][i+1]-Q[c][i])*R[c][i] + F[c].back());
      }
    }
    for(int c = 0; c < C; ++c){
      for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
          long long int d = D[c][i][j];
          int t = upper_bound(Q[c].begin(), Q[c].end(), d) - Q[c].begin() - 1;
          //int t = lower_bound(Q[c].begin(), Q[c].end(), d) - Q[c].begin() - 1;
          G[i][j] = min(G[i][j],F[c][t]+R[c][t]*(d-Q[c][t]));
        }
      }
    }
    for(int k = 0; k < N; ++k){
      for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
          G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
        }
      }
    }
    if(G[s][g] >= INF) cout << -1 << endl;
    else cout << G[s][g] << endl;
  }
  return 0;
}



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

int dfs(vector<int> edges[], vector<bool> &visited, int sv){

    if(visited[sv])
        return 0;
    visited[sv] = true;
    int cnt = 1;
    for(int neighbour: edges[sv]){
        cnt += dfs(edges, visited, neighbour);
    }
    return cnt;
}

int main()
{
 int n, m;
 cin>>n>>m;
 vector<int> edges[n];
 int u, v;
 for(int i=0; i<m; i++){
    cin>>u>>v;
    edges[u-1].push_back(v-1);
    edges[v-1].push_back(u-1);
 }
 vector<bool> visited(n, false);
 int ans = 0;
 for(int i=0; i<n; i++){
    if(!visited[i]){
        int curr = dfs(edges, visited, i);
        if(curr > ans)
            ans = curr;
    }
 }
 cout<<ans;
 return 0;
}



Measured memory_bytes: 23904
program diverta2019_d
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,i,ans=0

    read*, n
    i=1
    do while(i*i <= n)
        if (mod(n,i) == 0) then
            if (i*(i+1) < n) ans=ans+(n/i-1)
        end if
        i=i+1
    end do
    print'(i0)', ans
end program diverta2019_d

Measured memory_bytes: 384
using System;
namespace _2_2
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            string[] str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            c = int.Parse(str[2]);

            if (a < b && b < c)
                Console.WriteLine("Yes");

            else
                Console.WriteLine("No");

        }
    }
}



Measured memory_bytes: 8856
import fractions
import math
import itertools

def distance_measure(n,*args):
    distance_x = 0
    distance_y = 0
    distance_xy = 0
    distance = 0
    for i in range(n-1):
   
        distance_x = (args[0][i+1][0]-args[0][i][0])**2
        distance_y = (args[0][i+1][1]-args[0][i][1])**2
        distance_xy += math.sqrt(distance_x+distance_y)
    distance += distance_xy 
   # print(distance)
    return distance
    


if __name__ =="__main__":
    n = int(input())
    all_dist = 0
    #g = list([0] * n for _ in range(n))
    g = [0]*n
    for i in range (n):
        x,y = map(int,input().split())
        g[i] = x,y
    #print(g)
    #print(g[1][0])
    for i in itertools.permutations(g,n):
        #print(i)
        distance = distance_measure(n,i)
        all_dist += distance

    ave_dist = all_dist/math.factorial(n)
    print(ave_dist)


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

typedef long long ll;

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

  if(n==3){
    printf("2 5 63\n");
  }
  else if(n==4){
    printf("2 5 20 63\n");
  }
  else if(n==5){
    printf("2 5 20 30 63\n");
  }
  else{
    int ans[n];
    ll sum=0;
    int k=0;

    for(int i=0; i<n; i++){
      int d[] = {2, 3, 4, 6};
      ans[i] = 6*k+d[i%4];
      sum += ans[i];

      if(i%4==3) k++;
    }

    if(sum%6==2){
      ans[4] = 6*k+6;
    }
    else if(sum%6==3){
      ans[5] = 6*k+6;
    }
    else if(sum%6==5){
      ans[5] = 6*k+4;
    }

    for(int i=0; i<n; i++) cout << ans[i] << " ";
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 384
/*
                                                  
  _|_|                              _|  _|    _|  
_|    _|  _|  _|_|  _|_|_|_|        _|  _|  _|    
_|    _|  _|_|          _|          _|  _|_|      
_|    _|  _|          _|      _|    _|  _|  _|    
  _|_|    _|        _|_|_|_|    _|_|    _|    _|  
                                                                                                    
*/ 
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
//#define ls (rt<<1)
//#define rs (rt<<1|1)
#define vi vector<int>
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define fi first
#define se second
typedef long long ll;
using namespace std;
const int maxn=2150;
int n;
struct Flow{
	int s,t,relay[5],cnt,head[maxn],cur[maxn];
	queue<int>q;
	bool vis[maxn];
	ll ans,inf,dis[maxn];
	struct gg{
		int u,v,w,cost,next;
	}side[(maxn*5+1000)*2];
	Flow(){s=maxn-2,t=maxn-1;for(int i=3;i<=6;i++)relay[i-2]=maxn-i;cnt=1;ans=0;inf=1e18;}
	void ins(int u,int v,int w,int cost){
	//	cout<<u<<' '<<v<<' '<<w<<' '<<cost<<endl;
		side[++cnt]=(gg){u,v,w,cost,head[u]};head[u]=cnt;
		side[++cnt]=(gg){v,u,0,-cost,head[v]};head[v]=cnt;
	}
	bool spfa(){
		while(!q.empty())q.pop();memset(vis,0,sizeof(vis));memset(dis,0x3f,sizeof(dis));
		dis[s]=0;vis[s]=1;q.push(s);
	
		while(!q.empty()){
			int u=q.front();q.pop();vis[u]=0;//cout<<u<<endl;
			for(int i=head[u];i;i=side[i].next){
				int v=side[i].v;if(!side[i].w)continue;
				if(dis[u]+side[i].cost<dis[v]){
				
					dis[v]=dis[u]+side[i].cost;
					if(!vis[v])vis[v]=1,q.push(v);
				}
			}
		}
	//	rep(i,1,2*n)cout<<i<<' '<<dis[i]<<endl;
	//	rep(i,1,4)cout<<"relay"<<i<<' '<<dis[relay[i]]<<endl;
		return (dis[t]<inf);
	}
	int dfs(int u,ll flow){
		if(u==t)return flow;
		vis[u]=1;int tot=0;
		for(int &i=cur[u];i;i=side[i].next){
			int v=side[i].v;if(vis[v]||dis[v]!=dis[u]+side[i].cost||!side[i].w)continue;
			int sent=dfs(v,min(flow,(ll)side[i].w));
			side[i].w-=sent;side[i^1].w+=sent;tot+=sent;flow-=sent;
			ans+=1ll*sent*side[i].cost;
		}
		return tot;
	}
	int dinic(){
		int maxflow=0;	
		while(spfa()){
			memcpy(cur,head,sizeof(cur));memset(vis,0,sizeof(vis));
			maxflow+=dfs(s,inf);
		}
		return maxflow;
	}
}f;

int main(){
	scanf("%d",&n);
	rep(i,1,n){
		int rx,ry,rc;scanf("%d%d%d",&rx,&ry,&rc);f.ins(f.s,i,rc,0);
		f.ins(i,f.relay[1],rc,rx+ry);
		f.ins(i,f.relay[2],rc,rx-ry);
		f.ins(i,f.relay[3],rc,-rx+ry);
		f.ins(i,f.relay[4],rc,-rx-ry);
	}
	rep(i,1,n){
		int rx,ry,rc;scanf("%d%d%d",&rx,&ry,&rc);f.ins(i+n,f.t,rc,0);
		f.ins(f.relay[1],i+n,rc,-rx-ry);
		f.ins(f.relay[2],i+n,rc,-rx+ry);
		f.ins(f.relay[3],i+n,rc,rx-ry);
		f.ins(f.relay[4],i+n,rc,+rx+ry);
	}
	f.dinic();
	printf("%lld",-f.ans);
	return 0;
}//


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s; cin >> s;
    map<char,int> mp;
    rep(i,s.size()){
        mp[s[i]]++;
    }
    for(char i = 'a';i<='z';i++){
        if(mp[i] == 0){
            out(i);
            return 0;
        }
    }
    out("None");
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, a, b) for(int i = (a); i >= (b); --i)
#define debug(x) cerr << #x << ' ' << x << endl;
using namespace std;

typedef long long ll;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int n; ll k;
ll a[MAXN], b[MAXN];
bool ok(ll x) {
    ll need = 0;
    rep(i, 1, n) {
        if(a[i] * b[i] > x) {
            need += a[i] - x/b[i];
        }
    }
    return need <= k;
}
int main(int argc, char const *argv[])
{
    cin >> n >> k;
    rep(i, 1, n)    cin >> a[i];
    rep(i, 1, n)    cin >> b[i];
    sort(a+1, a+1+n, greater<int>());
    sort(b+1, b+1+n);
    ll l = 0, r = 1LL<<50, mid;
    while(l <= r) {
        mid = l + r >> 1;
        if(ok(mid)) r = mid - 1;
        else    l = mid + 1;
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#ifdef TEST_BUILD
#include "my_algorithm.hpp"
#endif
typedef long long ll;


/*
隣接行列を参照渡しするといい感じに計算します。Nodeは0始まり
*/
template<typename Cost>
void warshall_floyd(vector<vector<ll>> &d){
    int V = d.size();
    const Cost INF = numeric_limits<Cost>::max();

    for (int k=0;k<V;k++){
        for (int i=0;i<V;i++){
            for (int j=0;j<V;j++){
                if (d[i][k] != INF && d[k][j] != INF && d[i][k]+d[k][j]<d[i][j]){
                    d[i][j] = d[i][k]+d[k][j];
                }
            }
        }
    }
}


#ifndef MY_ALGORITHM
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_C&lang=jp
int main(){
        int V,E;
        cin >> V >> E;
        const ll INF = numeric_limits<ll>::max();
        vector<vector<ll>> graph(V,vector<ll>(V,INF));
        for (int k=0;k<E;k++){
            ll i,j,c;
            cin >> i >> j >> c;
            graph[i][j] = c;
        }
        for (int k=0;k<V;k++){
            graph[k][k]=0;
        }
        warshall_floyd<ll>(graph);
        for (ll i=0;i<V;i++){
            if (graph[i][i] < 0) {
                printf("NEGATIVE CYCLE\n");
                return 0;
            }
        }
        for (ll i=0;i<V;i++){
            for (ll j=0;j<V;j++){
                if (graph[i][j] == INF){
                    printf("INF");
                }else{
                    printf("%lld",graph[i][j]);
                }

                if (j<V-1){
                    printf(" ");
                }
            }
            printf("\n");
        }
       
}
#endif


Measured memory_bytes: 3348
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define int long long
int32_t main(){
	int t; cin>>t;
	int sum = 0;
	int n = t;
	while(n){
		sum += n % 10;
		n /= 10;
	}
	cout<<(t % sum == 0 ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 256
N = int(input())
graph = [[] for _ in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    graph[u-1].append([v-1, w])
    graph[v-1].append([u-1, w])


root = 0
distances = [-1 for _ in range(N)]
distances[0] = 0

stack = [root]

while len(stack) != 0:
    src = stack.pop()
    for dst, w in graph[src]:
        if distances[dst] == -1:
            distances[dst] = distances[src] + w
            stack.append(dst)


root_color = 0
another_color = 1

for d in distances:
    if d%2==0: print(root_color)
    else: print(another_color)




Measured memory_bytes: 83872
n = int(input())
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))

total = 0
m = 0
for i in range(n):
    if a[i] >= (b[i] + m):
        total += min(b[i] + m, a[i])
        m = 0
    else:
        total += a[i]
        m = min(b[i] - a[i] + m, b[i])

total += min(m, a[-1])
print(total)

Measured memory_bytes: 19116
#include<iostream>
#include<string>

using namespace std;

int main() {
	string s;
	long k;
	cin >> s >> k;

	for (int i = 0; i < k;i++) {
		if (s[i] != '1') {
			cout << s[i] << endl;
			return 0;
		}
	}

	cout << 1 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <algorithm>

int main() {
  int N;
  scanf("%d", &N);

  if (N > 23)
    return !printf("0\n");

  std::vector<int> D(N);
  for (int i=0; i<N; ++i) {
    scanf("%d", &D[i]);
  }

  D.push_back(!++N);

  int A[13]={};
  for (int i=0; i<N; ++i)
    if (++A[std::min(D[i], 24-D[i])] > 2)
      return !printf("0\n");

  if (N == 24)
    return !printf("1\n");

  auto f=[](int d, int bits, int i)->int {
    return (bits >> i & 1)? d:24-d;
  };

  int res=0;
  for (int bits=0; bits<(1<<N); ++bits) {
    int cur=24;
    for (int i=0; i<N; ++i) {
      for (int j=i+1; j<N; ++j) {
        int a=f(D[i], bits, i);
        int b=f(D[j], bits, j);
        int d=std::abs(a-b);
        cur = std::min(cur, std::min(d, 24-d));
      }
    }
    res = std::max(res, cur);
  }

  printf("%d\n", res);
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    string v = "Vacant";
    
    vector<string> s(n);
    int l = 0;
    int r = n-1;
    cout << l << endl;
    cin >> s[l];
    if(s[l] == v) return 0;
    cout << r << endl;
    cin >> s[r];
    if(s[r] == v) return 0;

    while(r-l > 0){
        int mid = (l+r) / 2;
        cout << mid << endl;
        cin >> s[mid];
        if(s[mid] == v) return 0;

        if(s[mid] == s[l]){
            if((mid-l)%2 == 0) l = mid;
            else r = mid;
        }
        else{
            if((mid-l)%2 == 0) r = mid;
            else l = mid;
        }
    }

    return 0;

}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;


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

    ll cnt[2] = {0, 0};
    rep(i, n){
        ll get;
        cin >> get;
        cnt[get%2]++;
    }

    if(cnt[1]%2 == 1){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }







    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N, Q;
  char s[110000];
  int l[110000], r[110000];
  cin >> N >> Q;
  cin >> s;
  rep(i,Q) {
    cin >> l[i];
    cin >> r[i];
    l[i];
    r[i];
  }

  int L[110000], R[110000];
  char prev='X';
  L[0]=0;R[N+1]=0;
  FOR(i, 1, N){ // how many 'AC' from the beginning to s[i-1]                   
    if(prev=='A' && s[i-1]=='C') L[i]=L[i-1]+1;
    else L[i] = L[i-1];
    prev = s[i-1];
  }
  prev = 'X';
  for(int i=N; i>=1; i--){ // how many 'AC' from the end to s[i-1]              
    if(prev=='C' && s[i-1]=='A') R[i]=R[i+1]+1;
    else R[i] = R[i+1];
    prev = s[i-1];
  }

  int total = L[N];
  rep(i,Q){
    //printf("L[%d]=%d, R[%d]=%d\n", l[i], L[l[i]], r[i], R[r[i]]);             
    cout << total - (L[l[i]] + R[r[i]]) << endl;
  }
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main (){
	int N;
	cin >> N;
	int sum = 0;
	std::vector<int> v(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> v[i];
		sum += v[i];
	}
	sum -= N;
	cout << sum << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<stack>
using namespace std;

int main(){
	unsigned N, Q;
	scanf("%u %u", &N, &Q);
	vector<unsigned> adj[N];
	for (unsigned i = 0; i < N - 1; ++i){
		unsigned a, b;
		scanf("%u %u", &a, &b);
		a--;b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	unsigned counter[N];
	for (unsigned i = 0; i < N; ++i){
		counter[i] = 0;
	}
	for (unsigned i = 0; i < Q; ++i){
		unsigned p, x;
		scanf("%u %u", &p, &x);
		p--;
		counter[p] += x;
	}
	bool has_been_discovered[N];
	for (unsigned i = 1; i < N; ++i){
		has_been_discovered[i] = false;
	}
	stack<unsigned> S;
	S.push(0);
	has_been_discovered[0] = true;
	while(!S.empty()){
		unsigned u = S.top(); S.pop();
		for (unsigned i = 0; i < adj[u].size(); ++i){
			unsigned v = adj[u][i];
			if(!has_been_discovered[v]){
				has_been_discovered[v] = true;
				S.push(v);
				counter[v] += counter[u];
			}
		}
	}
	for (unsigned i = 0; i < N; ++i){
		if(i) printf(" ");
		printf("%u", counter[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 15732