akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define MOD 1000000007
#define EPS (1 >> 30)
//#define INF (1 << 30)
#define INF (1LL << 60)

#define int long long

typedef vector<vector<P>> Graph;
vector<int> dijkstra(int s, Graph &G)
{
    priority_queue<P, vector<P>, greater<P>> que;
    int n = G.size();
    vector<int> dist(n);
    dist.assign(n, INF);
    dist[s] = 0;
    que.push(P(0, s));

    while (!que.empty())
    {
        P p = que.top();
        que.pop();
        int v = p.second;
        rep(i, G[v].size())
        {
            if (dist[G[v][i].first] > dist[v] + G[v][i].second)
            {
                dist[G[v][i].first] = dist[v] + G[v][i].second;
                que.push(P(dist[G[v][i].first], G[v][i].first));
            }
        }
    }
    return dist;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    int n;
    cin >> n;
    Graph www(n);
    rep(i, n - 1)
    {
        int node_x, node_y, cost = 1;
        cin >> node_x >> node_y;
        cin >> cost; // 重みなしなら削除
        node_x--, node_y--;
        www[node_x].push_back(P(node_y, cost));
        www[node_y].push_back(P(node_x, cost));
    }
    int q, k;
    cin >> q >> k;
    vector<int> dist = dijkstra(k-1, www);
    int x, y;
    rep(i, q)
    {
        cin >> x >> y;
        x--;
        y--;
        cout << dist[x] + dist[y] << endl;
        
        
    }
    rep(i,n){
        //debug(dist[i]);
    }
}

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



int main()
{
    /*
    char x;
    cin>>x;
    char temp = x;
    char b_x = tolower(temp);

    if(b_x==x)
    {
        cout<<"a"<<endl;
    }
    else
    {
        cout<<"A"<<endl;
    }
    */
    int n,k;
    cin>>n>>k;
    vector <int> p(n);
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
    }
    sort(p.begin(),p.end());
    int total = 0;
    for(int i=0;i<k;i++)
    {
        total+=p[i];
    }
    cout<<total<<endl;
    return 0;
}

Measured memory_bytes: 3632
def main():
    A, B, C, D = map(int, input().split())

    sw = [0] * 101
    sw[A] = 1
    sw[B] = -1
    sw[C] += 1
    sw[D] += -1
    for i in range(1, 101):
        sw[i] = sw[i-1] + sw[i]

    ans = sw.count(2)
    print(ans)

main()


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast", "unroll-loops")

// #define TEST

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

const ll mod = 1000000007LL;

// aのb乗を求める.
ll modpow(ll a, ll b) {
	if (a > mod) a %= mod;
	if (b == 0LL) return 1LL;
	ll tmp = modpow(a, b / 2);
	if (b & 1LL)
		return tmp * tmp % mod * a % mod;
	return tmp * tmp % mod;
}

// aの逆元を求める.
ll inverse(ll a) {
	return modpow(a, mod - 2);
}

// kの階乗を計算する.(sgnを0以外に設定すると逆元を返す)
ll fact(ll k, int sgn = 0) {
	static vector<ll> fac(2, 1LL);
	static vector<ll> inv(2, 1LL);
	static vector<ll> finv(2, 1LL);
	static ll nx = 2LL;
	while (nx <= k) {
		fac.push_back(fac[nx - 1] * nx % mod);
		inv.push_back(mod - inv[mod % nx] * (mod / nx) % mod);
		finv.push_back(finv[nx - 1] * inv[nx] % mod);
		++nx;
	}
	if (sgn == 0)
		return fac[k];
	return finv[k];
}

// aCbを計算する.
ll comb(ll a, ll b) {
	if (b < 0 || b > a) return 0;
	return fact(a) * fact(b, 1) % mod * fact(a - b, 1) % mod;
}

int n;
vector<vector<int>> g;

vector<int> c;
vector<ll> a;
void dfs(int s = 0, int p = -1) {
	int _c = 1;
	for (int nx : g[s]) {
		if (nx != p) {
			dfs(nx, s);
			_c += c[nx];
		}
	}
	c[s] = _c;
	ll _a = fact(_c - 1LL);
	for (int nx : g[s]) {
		if (nx != p) {
			_a *= a[nx];
			_a %= mod;
			_a *= fact(c[nx], 1);
			_a %= mod;
		}
	}
	a[s] = _a;
}

vector<ll> res;
void solve(int s = 0, int p = -1) {
	if (s == 0) res[0] = a[0];
	else {
		ll tmp = res[p];
		tmp *= c[s];
		tmp %= mod;
		tmp *= inverse((ll)n - c[s]);
		tmp %= mod;
		res[s] = tmp;
	}
	for (int nx : g[s]) {
		if (nx != p) {
			solve(nx, s);
		}
	}
}

int main() {
	cin >> n;
	g.resize(n);
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	c.resize(n);
	a.resize(n);
	dfs();
#ifdef TEST
	cout << "----c----" << endl;
	for (auto ci : c) cout << ci << " ";
	cout << endl;
	cout << "----a----" << endl;
	for (auto ai : a) cout << ai << " ";
	cout << endl;
#endif
	res.resize(n);
	solve();
	for (auto resi : res)
		cout << resi << endl;
	return 0;
}

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

using namespace std;

int main() {

    int N, M;
    cin >> N >> M;

    int ans = 0;
    int n, m;

    if (2 <= N) {
        n = N * (N - 1) / 2;
    } else {
        n = 0;
    }

    if (M > 2) {
        m = M * (M - 1) / 2;
    } else {
        m = 0;
    }   

    ans = n + m;

    cout << ans << endl;

    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll r = 0, g = 0, b = 0;
    rep(i, N) {
        if (S[i] == 'R') {
            r++;
        } else if (S[i] == 'G') {
            g++;
        } else {
            b++;
        }
    }

    ll ans = 0;
    rep(i, N) {
        char f = S[i];
        rep2(j, i + 1, N) {
            char s = S[j];
            ll c = 0;
            if (f == 'R' && s == 'G') {
                if (2 * j - i < N && S[2 * j - i] == 'B') c--;
            }
            if (f == 'R' && s == 'B') {
                if (2 * j - i < N && S[2 * j - i] == 'G') c--;
            }
            if (f == 'G' && s == 'R') {
                if (2 * j - i < N && S[2 * j - i] == 'B') c--;
            }
            if (f == 'G' && s == 'B') {
                if (2 * j - i < N && S[2 * j - i] == 'R') c--;
            }
            if (f == 'B' && s == 'G') {
                if (2 * j - i < N && S[2 * j - i] == 'R') c--;
            }
            if (f == 'B' && s == 'R') {
                if (2 * j - i < N && S[2 * j - i] == 'G') c--;
            }
            ans += c;
        }
    }
    cout << r * g * b + ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
typedef long long ll;

int main(void){
  int n, m, k, i, j;
  scanf("%d %d %d", &n, &m, &k);
  ll a[n+1], b[m+1], ans = 0, best = 0;
  
  b[0] = a[0] = 0;
  for(i = 1; i <= n; i++){
    a[i] = 0;
    scanf("%lld", &a[i]);
    a[i] += a[i-1];
  }
  for(j = 1; j <= m; j++){
    b[j] = 0;
    scanf("%lld", &b[j]);
    b[j] += b[j-1];
    if(b[j] <= k)best = j;
  }
    
  for(i = 0; a[i] <= k; i++){
    while(a[i] + b[best] > k)best--;
    if(i + best > ans)ans = i + best;
  }
  
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 4856
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()

using ll = long long;
using ld = long double;
using namespace std;

const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 5;

int n, m;

class Dsu {
    vector<int> par, sz;
public:
    void init(int n) {
        par = vector<int>(n + 1), sz = vector<int>(n + 1, 1);
        for (int i = 1; i <= n; i++) par[i] = i;
    }
    int root(int x) {
        while (par[x] != x) {
            par[x] = par[par[x]];
            x = par[x];
        }
        return x;
    }
    bool Union(int x, int y) {
        int p = root(x), q = root(y);
        if (p == q) return 0;
        if (sz[p] < sz[q]) {
            par[p] = q;
            sz[q] += sz[p];
        }
        else {
            par[q] = p;
            sz[p] += sz[q];
        }
        return 1;
    }

    int get_sz(int i) {
        return sz[root(i)];
    }
} dsu;

void code() {
    cin >> n >> m;

    dsu.init(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        dsu.Union(a, b);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, dsu.get_sz(i));
    }

    cout << ans << "\n";

}

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

    int t = 1;
    // cin>>t;

    while (t-- > 0) {
        code();
    }
}

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

long long gcd(int a, int b)
{
    if (b == 0)
    {
        return a;
    }
    return gcd(b, a % b);
}
long long addgcd(int a, int b, int c)
{
    long long result = gcd(a, b);
    result = gcd(result, c);
    return result;
}

int main()
{
    long long q = 0;
    int w;
    cin >> w;
    cout << w * 2 * M_PI;
}


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

int main() {
    int N;
    string S;
    cin >> N >> S;

    int max_count = 0;
    for (int i = 1; i < N; i++) {

        int count = 0;
        for (char ch = 'a'; ch <= 'z'; ch++) {
            bool left = false;
            bool right = false;

            for (int j = 0; j < i; j++) {
                if (S[j] == ch) left = true;
            }

            for (int j = i; j < N; j++) {
                if (S[j] == ch) right = true;
            }

            if (left && right) count++;
        }
        max_count = max(max_count, count);
    }

    cout << max_count << endl;
    return 0;
}

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

using ll = long long int;

const ll MAX = (ll)(1e13 + 5);

ll f(ll b, ll n) {
  if (n < b) {
    return n;
  }
  else {
    return f(b, floor(n / b)) + (n % b);
  }
}

ll n, s;

ll ans = MAX;

int main(void) {
  // Here your code !
  scanf("%lld", &n);
  scanf("%lld", &s);


  if (n == s) {
    printf("%lld\n", n + 1);
    return 0;
  }

  ll sqrtn = (ll)(sqrt(n)) + 100;

  for (int b = 2; b < sqrtn; ++b) {
    if (s == f(b, n)) {
      printf("%lld\n", b);
      return 0;
    }
  }

  for (ll p = 1; p < sqrtn; ++p) {
    if ((s - n) % p != 0) continue;
    ll b = (n - s) / p + 1;
    if (b < 2) continue;

    if (s == (f(b , n))) {
      ans = min(ans, b);
    }
  }

  if (ans < MAX) printf("%lld\n", ans);
  else printf("%lld\n", (ll)(-1));

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string s;
ll num,t=10,ans;
ll cnt[2200];
int main()
{
	cnt[0]=1;
cin>>s;
for(int i=s.size()-1;i>=0;i--)
{
	num=(num+(s[i]-'0')*t)%2019;
	ans+=cnt[num];
	cnt[num]++;
	t=t*10%2019;
}
cout<<ans;
return 0;

}

Measured memory_bytes: 3780
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
char s[1001];
int main()
{
	scanf("%s",s);
	int a=s[0]-48;
	int b=s[1]-48;
	int c=s[2]-48;
	int d=s[3]-48;
	if(a+b+c+d==7){cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<"7";return 0;}
	if(a+b+c-d==7){cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<"7";return 0;}
	if(a+b-c+d==7){cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<"7";return 0;}
	if(a+b-c-d==7){cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<"7";return 0;}
	if(a-b-c-d==7){cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<"7";return 0;}
	if(a-b-c+d==7){cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<"7";return 0;}
	if(a-b+c-d==7){cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<"7";return 0;}
	if(a-b+c+d==7){cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<"7";return 0;}
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ai = [int(input()) for _ in range(m)]

dp = [0] * (n+1)
dp[0] = 1

issafe = [True] * (n+1)
for a in ai:
    issafe[a] = False

if issafe[1]:
    dp[1] = 1

for i in range(2, n+1):
    if issafe[i-1]:
        dp[i] += dp[i-1]
    if issafe[i-2]:
        dp[i] += dp[i-2]
    dp[i] %= 1000000007

print(dp[n])


Measured memory_bytes: 9620
#include <stdio.h>
int prime(int);
int main(){
  int n,i,j,s,sum=0,a[10000];

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&a[i]);
  }


  for(i=0; i<n; i++){
    s=prime(a[i]);
    if(s==1) sum++;
  }

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

int prime(int a){
  int i;
  if(a<2) return 0;
  else if(a==2) return 1;
  
  if(a%2==0) return 0;

  for(i=3; i<=a/i; i+=2){
    if(a%i==0) return 0;
  }
  return 1;
}

Measured memory_bytes: 628
import math
a,b,C=map(int,input().split())
s=math.sin(math.radians(C))
S=(a*b*s)/2
c=math.cos(math.radians(C))
x=a*a+b*b-2*a*b*c
d=math.sqrt(x)
L=a+b+d
h=(2*S)/a

print(S)
print(L)
print(h)


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

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

	int a;
	map <int,int> m;
	for (int i=0;i<n;i++) {
		scanf ("%d", &a);
		if (m.find(a) != m.end()) {
			m[a] ++;
		} else {
			m[a] = 1;
		}
	}

	map <int, int> :: iterator it;
	int b;
	a = b = 0;

	for (it = m.begin(); it != m.end(); it++) {
		if (it->second%2) {
			a ++;
		} else {
			b ++;
		}
	}

	if (b%2) {
		cout << (a-1+b) << endl;
	} else {
		cout << (a+b) << endl;
	}

	return 0;
}

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

const int N = 4;
const int D_y[4] = { 1,0,-1,0 };
const int D_x[4] = { 0,1,0,-1 };

int ANS[N][N] = { {1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,0} };
int ans_x[N * N] = { 0 };
int ans_y[N * N] = { 0 };

bool eq(int p1[N][N], int p2[N][N]) {
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (p1[i][j] != p2[i][j])return false;
		}
	}
	return true;
}

int step(int puzzle[N][N]) {
	int n = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (puzzle[i][j] == 0)continue;
			int x = ans_x[puzzle[i][j]] - j;
			int y = ans_y[puzzle[i][j]] - i;
			x = x < 0 ? -x : x;
			y = y < 0 ? -y : y;
			n += x + y;
		}
	}
	return n;
}

bool search(int puzzle[N][N], int x,int y, int px, int py, int depth, int lim) {
	if (depth + step(puzzle) > lim)return false;
	if (eq(ANS, puzzle))return true;
	for (int i = 0; i < 4; i++) {
		int X = x + D_x[i];
		int Y = y + D_y[i];
		if ((X == px && Y == py) || X < 0 || Y < 0 || X >= N || Y >= N)continue;
		swap(puzzle[y][x], puzzle[Y][X]);
		if (search(puzzle, X, Y, x, y, depth + 1, lim))return true;
		swap(puzzle[y][x], puzzle[Y][X]);
	}
	return false;
}

int solve() {
	int puzzle[N][N];
	int x, y;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> puzzle[i][j];
			if (puzzle[i][j] == 0) {
				x = j;
				y = i;
			}
		}
	}
	for (int i = 0; i < 45; i++) {
		if (search(puzzle, x, y, -1, -1, 0, i)) {
			return i;
		}
	}
	return 45;
}

int main() {
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ans_x[ANS[i][j]] = j;
			ans_y[ANS[i][j]] = i;
		}
	}
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int main(){

    int n; cin >> n;
    bitset<4000001> st;
    st.set(0);

    int sum = 0;
    rep(i, n){
        int a; cin >> a;
        st |= (st << a);
        sum += a;
    }

    rep(i, sum + 1){
        if(i + i >= sum and st[i]){
            cout << i << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 1792
n = int(input())
a = list(map(int, input().split()))

del a[n:]

new1 = [a[i] for i in range(len(a)) if a[i] % 2 == 0]
new2 = [i for i in range(len(new1)) if (new1[i] % 3 == 0 or new1[i] % 5 == 0 or new1[i] % 15 == 0)]

if len(new1) == len(new2):
  print("APPROVED")
else:
  print("DENIED")


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,d,x;
    cin >> n >> d >> x;
    vector <int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    long ans = x;
    for(int i = 0; i < n; i++){
        for(int j = 0; ((j*a[i]+1)<=d); j++){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        int ans = n - k + 1;
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22612
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IFOR(v,it) for(VI::iterator it=(v).begin();it!=(v).end();++it)


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

  VVI A;
  REP(i, 2) {
    VI v;
    REP(j, N) {
      int a;
      cin >> a;
      v.PB(a);
    }
    A.PB(v);
  }
  // A_1,iまでのアメの合計をsum_above[i]とする
  // iで下に進むとすると、答えはsum_above[i] + (sum_below[N] - sum_below[i-1])
  int sum_above[N+1];
  int sum_below[N+1];
  sum_above[0] = sum_below[0] = 0;

  REP(i, N) {
    sum_above[i+1] = sum_above[i] + A[0][i];
    sum_below[i+1] = sum_below[i] + A[1][i];
  }
  int sum_max = 0;
  REP(i, N) {
    sum_max = max(sum_max, sum_above[i+1] + (sum_below[N] - sum_below[i]));
  }
  cout << sum_max << endl;


  return 0;
}


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

const string YES = "YES";
const string NO = "NO";
int main(){
  int N; cin >> N;
  vector<int> A(N); rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());
  int chk = 0;
  rep(i, N-1)
  {
    if(A[i]==A[i+1]){
      chk = 1;
      cout << NO << endl;
      break;
    }
  }

  if(chk ==0)cout<<YES<<endl;

}


Measured memory_bytes: 1024
from heapq import*
f=lambda*z:map(int,raw_input().split())
X,Y,Z=f()
P=[]
Q=[]
L=[0]
R=[0]
r=range(X+Y+Z)
A=sorted(map(f,r),key=lambda a:a[0]-a[1])
for i in r:L+=[L[i]+A[i][1]];heappush(P,A[i][1]-A[i][2]);R+=[R[i]+A[~i][0]];heappush(Q,A[~i][0]-A[~i][2]);L[-1]-=i>=Y and heappop(P);R[-1]-=i>=X and heappop(Q)
print max(L[i]+R[~i]for i in range(Y,Y+Z+1))

Measured memory_bytes: 35104
#include "bits/stdc++.h"

using namespace std;

auto check(string s) {
    string s1 = s;
    reverse(s.begin(), s.end());
    if (s1 == s)return true;
    return false;
}

int main() {
    string s;
    cin >> s;
    int n = s.length();
    string st=s.substr((((n + 3) / 2) - 1), (n - ((n + 3) / 2-1)));
    string sp=s.substr(0, (s.length() - 1) / 2);
    //cout<<st<<endl<<sp<<endl;
    if(check(s) and check(st) and check(sp))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int i, ans, q[255], flag = 0,n = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &q[i]);
    }
    for (ans = 0; ans < 200; ans++) {
        for (i = 0; i < n; i++) {
            if (q[i] % 2 == 0) {
                q[i] = q[i] / 2;
            }
            else {
                flag++;
            }
        }
        if (flag != 0) {
            break;
        }
    }
    printf("%d", ans);
}


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

using ll = long long;
#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 INF 1e9

int main(){
  string S;
  cin >> S;
  for(int i = 0; i < S.size(); i+= 2){
    if(S[i] == 'h' && S[i+1] == 'i'){

    }
    else{
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int n,k,i,a[131072],p=0;
    char s[16],t[16]={0};
    scanf("%s",s);
    for(i=0;i<strlen(s);i++){
        if(s[i]=='B'){p=max(0,p-1);t[p]=0;}
        else{t[p]=s[i];p++;}
    }
    printf("%s\n",t);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;


int main() {

int N,cnt=0,ans=0;
cin>>N;
int a[N+5];
for (int i = 1; i <= N; ++i)
{
	cin>>a[i];
}

for (int i = 1; i <= N; ++ ++ i)
{
	cnt=0;
	if (a[i]%2==1)
	{
		cnt++;
	}
	ans+=cnt;
}

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


Measured memory_bytes: 3640
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<int> i(n), p(n), q(n), r(n), c(n);
        for(int j=0; j<n; ++j){
            cin >> i[j] >> p[j] >> q[j] >> r[j];
            c[j] = p[j] * 4 + q[j] * 9 + r[j] * 4;
        }

        int P, Q, R, C;
        cin >> P >> Q >> R >> C;
        bool none = true;
        for(int j=0; j<n; ++j){
            if(p[j] <= P && q[j] <= Q && r[j] <= R && c[j] <= C){
                cout << i[j] << endl;
                none = false;
            }
        }
        if(none)
            cout << "NA" << endl;
    }
}

Measured memory_bytes: 928
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int p[200000];
int root(int x){
	return p[x] == x ? x : p[x] = root(p[x]);
}
void merge(int a, int b){
	a = root(a); b = root(b);
	if(a != b) p[b] = a;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	bool ok = 1;
	int n, m;
	cin >> n >> m;
	rep(i, n + m) p[i] = i;
	rep(i, n){
		int k; cin >> k;
		rep(j, k){
			int l; cin >> l;
			merge(l - 1 + n, i);
		}
	}
	rep(i, n) if(root(i) != root(0)){
		ok = 0;
		break;
	}
	cout << (ok ? "YES" : "NO") << endl;
	
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9
#define common cout << "Case #" << w+1 << ": "  



int main()
{
    lli x,k,d;
    cin >> x >> k >> d;
    x=abs(x);
    lli q=x/d;
    if(q>=k)
        cout << x-k*d << endl;
    else
    {
        lli x1=x-q*d,x2=-x1+d;
        if((k-q)%2==0)
            cout << x1 << endl;
        else
            cout << x2 << endl;
    }
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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 (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
vector<ll>m(1002);
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
        m[a]+=ex;
    }

    // 最後に残った数について
    if (N != 1){
        res.push_back({N, 1});
        m[N]++;
    } 
    return res;
}

int main() {
    ll N;
    cin >>N;
    rep2(i,N){
        prime_factorize(i);
    }
    ll ans=1;
    rep2(i,N){
        ans= (ans*(m[i]+1))%mod;
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3592
import sys

input = sys.stdin.readline
MOD = 1000000007

S = input()[:-1]

x = [0,0,0,0]

for i in range(len(S)):
    if S[i] == 'N':
        x[0]+=1
    if S[i] == 'S':
        x[1]+=1
    if S[i] == 'E':
        x[2]+=1
    if S[i] == 'W':
        x[3]+=1


if x.count(0) == 0:
    print("Yes")
    exit()
else:
    if x[:2].count(0) == 0 and x[2:].count(0) == 2:
        print("Yes")
        exit()
    if x[:2].count(0) == 2 and x[2:].count(0) == 0:
        print("Yes")
        exit()
    
print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 100100
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
bool vis[MAX];
int n,m,ans,a[MAX];
int main()
{
	n=read();m=read();
	vis[1]=true;
	for(int i=1;i<=n;++i)a[i]=1;
	while(m--)
	{
		int x=read(),y=read();
		if(!a[x])continue;
		if(vis[x])vis[y]=true;
		--a[x];++a[y];
		if(!a[x])vis[x]=false;
	}
	for(int i=1;i<=n;++i)ans+=vis[i];
	printf("%d\n",ans);
	return 0;
}



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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  
  int a=0;
  if(A==5)
    if((B==5 && C==7) || (B==7 && C==5))
      a=1;
  if(A==7)
    if(B==5 && C==5)
      a=1;
  
  if(a)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
use whiteread::parse_line;

fn main() {
    let (n, d): (i64, i64) = parse_line().unwrap();
    let mut i: i64 = 0;
    let mut c: i64 = 0;

    while i < n {
        let (x, y): (i64, i64) = parse_line().unwrap();
        if x*x + y*y <= d*d {
            c = c + 1;
        }
        i = i + 1;
    }

    println!("{}", c);
}


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

int main() {
	int t;
	cin>>t;
	int n=t%10;
	if(n==2||n==4||n==5 ||n==7 ||n==9)
	cout<<"hon";
	else if(n==0||n==1||n==6 ||n==8)
	cout<<"pon";
	else
	cout<<"bon";
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9+5;
const int mod = 998244353;

vector<int> fac(300001); //n!(mod M)
vector<int> ifac(300001); //k!^{M-2} (mod M)

long long fpow(long long a,long long n){
  long long ret=1;
  if(n==1) return a;
  if(n%2==0) {
      ret = fpow(a*a%mod, n/2) %mod ;
  }else {
      ret = (a%mod)*fpow(a*a%mod, n/2) %mod;
  }
  return ret %mod;
}
int comb(int a, int b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    int tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}
const double PI=3.14159265358979323846;
int dp[100][100];
int tmp[100][100];
signed main(){
    int a, b,c;
    cin >> a >> b >>c;

    int ans = min(c, b/a);

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 4992
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
//ll MOD = 1000000007;
ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};


ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

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

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/



int main(){
  ll H, W, A, B;
  cin >> H >> W >> A >> B;
  rep(i, H){
    rep(j, W){
      if((i < B && j < A) || (i >= B && j >= A)){
        cout << "1";
      }else{
        cout << "0";
      }
    }
    cout << endl;
  }


}


Measured memory_bytes: 1280
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	double a, b;
	cin>>a>>b;
	cout.precision(10);
	cout<<fixed<<a*b/(a+b)<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

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

ll x,y;
int main()
{
	FAST;

	cin >> x >> y;
	cout << x + y/2 << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a,b;
  char op;
  int flg=0;

  while(flg==0){
    scanf("%d",&a);
    scanf("%s",&op);
    scanf("%d",&b);

    switch(op){
    case '+':
      printf("%d\n",a+b);
      break;
    case '-':
      printf("%d\n",a-b);
      break;
    case '*':
      printf("%d\n",a*b);
      break;
    case '/':
      printf("%d\n",a/b);
      break;
    case '?':
      flg=1;
      break;
    default:
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 600
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
int n,a[100010],b[100010],c[100010],dp[100010][5];
int main(){
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i]>>b[i]>>c[i];
	for (int i=1;i<=n;i++){
		dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i];
		dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b[i];
		dp[i][3]=max(dp[i-1][2],dp[i-1][1])+c[i];
	}
	cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<map>
 
using namespace std;

const int MAX = 200001;
const int MOD = 998244353;

 
long long i,j,k,N,M2,K,ans,n;

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

long long power(long long X,long long P,long long M)
{
  long long s;
  
  if(P==0)
  {
    return 1;
  }
  else if(P%2==0)
  {
    s=power(X,P/2,M);
    s*=s;
    s%=M;
    return s;
  }
  else
  {
    s=power(X,P-1,M)*X;
    s%=M;
    return s;
  }
}

void COMint()
{
  fac[0]=1;
  finv[0]=1;
  fac[1]=1;
  finv[1]=1;
  inv[1]=1;
  for(i=2;i<MAX;i++)
  {
    fac[i]=fac[i-1]*i%MOD;  ///n!の計算
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD; ///n^-1の計算
    finv[i]=finv[i-1]*inv[i]%MOD;//n!^-1の計算
  }
  
  
}
 
long long comb(long long X,long long Y)
{
  if(X<Y) return 0;
  else if(X<0||Y<0) return 0;
  return fac[X]*(finv[Y]*finv[X-Y]%MOD)%MOD;
}
 
int main()
{
  cin>>N>>M2>>K;
  
  COMint();
 
  ans=(M2*power(M2-1,N-1,MOD))%MOD;
  for(i=1;i<=K;i++)
  {
    n=(M2*power(M2-1,N-i-1,MOD))%MOD;
 
    n=(n*comb(N-1,i))%MOD;
    ans+=n;
    ans%=MOD;
 
  }
  
  cout<<ans;
  
  
  
}

Measured memory_bytes: 8312
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
l = inp.shift().split(' ')
A = l[0] - 0
B = l[1] - 0
cnt = 0
for (i=A; i<=B; i++) {
    s = i+''
    if (s[0] == s[4] && s[1] == s[3]) {
        cnt++
    }
}
console.log(cnt)

Measured memory_bytes: 10444
n, h = map(int, input().split())
a = []
b = []
for i in range(n):
    a1, b1 = map(int, input().split())
    a.append(a1)
    b.append(b1)
ind = n - 1
a.sort()
b.sort()
ans = 0
while h > 0:
    if(ind >= 0 and b[ind] > a[n - 1]):
        h -= b[ind]
        ind -= 1
        ans += 1
    else:
        ans += (h + a[n - 1] - 1) // a[n - 1]
        h = 0
print(ans)



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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(N);
    REP(i,0,N) cin >> A[i];
    
    ll sum = 0;
    REP(i,0,N) sum += A[i] - 1;
    PR(sum);

    return 0;
}

/*



*/

Measured memory_bytes: 3624
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))

ans = -1
num = 0
ind = 0
while num < N+1:
  num += 1
  if A[ind] == 2:
    ans = num
    break
  ind = A[ind] - 1
print(ans)

Measured memory_bytes: 7084
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>

using namespace std;

inline void add(int &a, int b, int mod) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

inline int sub(int a, int b, int mod) {
  a -= b;
  if (a < 0) {
    a += mod;
  }
  return a;
}

inline int mul(int a, int b, int mod) {
  return (int)((long long)a * b % mod);
}

const int mod[2] = {805306457, 402653189};

const int N = 55;

int pw[2][N];

int get(string &s, int j) {
  int res = 0;
  for (int i = 0; i < (int)s.size(); ++i) {
    add(res, mul(s[i] - 'a' + 1, pw[j][i], mod[j]), mod[j]);
  }
  return res;
}

map<pair<int, int>, int> f[N];

int main() {
  const int base[2] = {43, 31};
  for (int j = 0; j < 2; ++j) {
    pw[j][0] = 1;
    for (int i = 1; i < N; ++i) {
      pw[j][i] = mul(pw[j][i - 1], base[j], mod[j]);
    }
  }
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < N; ++i) {
    f[i].clear();
  }
  for (int i = 0; i < (1 << n); ++i) {
    string l = "", r = "";
    for (int j = 0; j < n; ++j) {
      if (i >> j & 1) {
        l += s[n + j];
      } else {
        r += s[n + j];
      }
    }
    reverse(r.begin(), r.end());
    int len_l = (int)l.size();
    vector<int> w(2);
    for (int j = 0; j < 2; ++j) {
      int hash_l = get(l, j);
      int hash_r = get(r, j);
      w[j] = sub(hash_r, mul(hash_l, pw[j][n - len_l], mod[j]), mod[j]);
    }
    ++f[len_l][{w[0], w[1]}];
  }
  long long ans = 0;
  for (int i = 0; i < (1 << n); ++i) {
    string l = "", r = "";
    for (int j = 0; j < n; ++j) {
      if (i >> j & 1) {
        l += s[j];
      } else {
        r += s[j];
      }
    }
    reverse(r.begin(), r.end());
    int len_r = (int)r.size();
    vector<int> w(2);
    for (int j = 0; j < 2; ++j) {
      int hash_l = get(l, j);
      int hash_r = get(r, j);
      w[j] = sub(hash_l, mul(hash_r, pw[j][n - len_r], mod[j]), mod[j]);
    }
    int k = n - (int)l.size();
    if (f[k].count({w[0], w[1]}) != 0) {
      ans += f[k][{w[0], w[1]}];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 16640
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,m,tmp,cnt=0;
  vector <int> a,spread;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>tmp;
    a.push_back(tmp);
  }
  for(int i=0,tmp=1;tmp<=n;i++){
    spread.insert(spread.begin(),tmp);
    tmp=3*tmp+1;
  }
  m=spread.size();
  cout<<m<<endl;
  for(int i=0;i<m-1;i++) cout<<spread[i]<<" ";
  cout<<spread[m-1]<<endl;
  for(int k=0;k<m;k++) for(int i=0;i+spread[k]<n;i++){
      int end=i+spread[k],first=i%spread[k];
        if(a[end]>a[end-spread[k]]) continue;
	int l;
	for(l=1;l<(end-first)/spread[k]+1;l++){
	  if(a[end-(l-1)*spread[k]]<a[end-l*spread[k]]){
	    swap(a[end-(l-1)*spread[k]],a[end-l*spread[k]]);
	    cnt++;
	  } else break;
	}
    }
  cout<<cnt<<endl;
  for(int i=0;i<n;i++) cout<<a[i]<<endl;
  return 0;
}



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

int main() {
  long long n,wsum;
  cin >> n >> wsum;
  vector<long long> v(n);
  vector<long long> w(n);
  long long vsum=0;
  for(long long i=0;i<n;i++) {
    cin >> w.at(i) >> v.at(i);
    vsum+=v.at(i);
  }
  //cout << vsum << endl;
  vector<vector<long long>> dp(n+1,vector<long long>(100001,1e9));
  dp.at(0).at(0)=0;
  for(long long i=0;i<n;i++) {
    for(long long j=0;j<vsum+1;j++) {
      if(v.at(i)<=j) {
        dp.at(i+1).at(j)=min(dp.at(i+1).at(j),dp.at(i).at(j-v.at(i))+w.at(i));
      }
      dp.at(i+1).at(j)=min(dp.at(i+1).at(j),dp.at(i).at(j));
    }
  }
  for(int i=vsum;i>-1;i--) {
    //cout << dp.at(n).at(i) << endl;
    if(dp.at(n).at(i)<=wsum) {
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#else
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
 public:
  void solve() {
    i64 x;
    cin >> x;
    i64 n = 100, ans = 0;
    while (n < x) {
      n = n * 1.01;
      ans++;
    }
    cout << ans << '\n';
  }
} NSPACE;
int main() {
  FPEN;
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}

Measured memory_bytes: 3652