akhauriyash/Code-Regression huggingface dataset:
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 3 "../../library/debug.hpp"

// https://codeforces.com/blog/entry/68809
void debug_print(int x) {cerr << x;}
void debug_print(long x) {cerr << x;}
void debug_print(long long x) {cerr << x;}
void debug_print(unsigned x) {cerr << x;}
void debug_print(unsigned long x) {cerr << x;}
void debug_print(unsigned long long x) {cerr << x;}
void debug_print(float x) {cerr << x;}
void debug_print(double x) {cerr << x;}
void debug_print(long double x) {cerr << x;}
void debug_print(char x) {cerr << '\'' << x << '\'';}
void debug_print(const char *x) {cerr << '\"' << x << '\"';}
void debug_print(const string &x) {cerr << '\"' << x << '\"';}
void debug_print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V> void debug_print(const pair<T, V> &x) {cerr << '{'; debug_print(x.first); cerr << ','; debug_print(x.second); cerr << '}';}
template<typename T> void debug_print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), debug_print(i); cerr << "}";}

void debug_print_() {cerr << "]\n";}
template <typename T, typename... V>
void debug_print_(T t, V... v) {debug_print(t); if (sizeof...(v)) cerr << ", "; debug_print_(v...);}

#ifdef LOCAL
  #define debug(x...) cerr << "[" << #x << "] = ["; debug_print_(x)
#else
  #define debug(x...)
#endif
#line 3 "b.cpp"

int main() {
  ll n;
  cin >> n;
  constexpr ll maxi = 1e18;
  ll ans = 1;
  vl a(n);
  rep(i, n) {
    cin >> a[i];
    if (a[i] == 0) {
      puts("0");
      return 0;
    }
  }

  rep(i, n) {
    if (a[i] > maxi/ans) {
      debug(i, a[i], ans);
      cout << -1 << el;
      return 0;
    } else {
      ans *= a[i];
    }
  }

  cout << ans << el;
}


Measured memory_bytes: 3968
import java.util.ArrayList;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		ArrayList<Integer> arr = new ArrayList<Integer>();
		arr.add(scanner.nextInt());
		arr.add(scanner.nextInt());
		arr.add(scanner.nextInt());

		int sum = 0;
		for(int i = 0; i < arr.size(); i++) sum += arr.get(i);

		boolean miss = true;

		for(int i = 0; i < arr.size(); i++)for(int j = 1; j < arr.size(); j++)if(arr.get(i) + arr.get(j) == sum/2)miss = false;

		if(miss) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}

		scanner.close();
	}
}

Measured memory_bytes: 23252
n=int(input())
h_list = list(map(int,input().split()))
h_list.append(10000000000)
h_bigsmall_list = [0 for _ in range(n)]
for i in range(n):
    if h_list[i] >= h_list[i+1]:
        h_bigsmall_list[i] += 1
h_bigsmall_str = ''
for i in range(len(h_bigsmall_list)):
    h_bigsmall_str += str(h_bigsmall_list[i])
strlist = h_bigsmall_str.split('0')
max_len_element = max(strlist, key=len)
print(len(max_len_element))

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }


vector<string> S;

struct GridGraph
{

    int H, W;

    GridGraph() = default;
    GridGraph(int h, int w) : H(h), W(w) {}

    const std::vector<int> dx{1, -1, 0, 0};
    const std::vector<int> dy{0, 0, 1, -1};

    /* Implement here. */
    using T_E = long long int;
    const T_E INF = 1e18;
    inline T_E edge_cost(int x_s, int y_s, int x_tt, int y_tt)
    {
        if (x_tt == x_s and y_tt == y_s + 1) {
            return S[x_s][y_s] != S[x_tt][y_tt];
        }
        if (x_tt == x_s + 1 and y_tt == y_s) {
            return S[x_s][y_s] != S[x_tt][y_tt];
        }
        return 1e9;
    }

    // Dijkstra's algorithm
    // Complexity: O(HWlog(HW))
    std::vector<std::vector<T_E>> dij; // Distance from (x_s, y_s)
    std::vector<std::vector<std::pair<int, int>>> dij_prv; // Previous node for Dijkstra optimal path
    void dijkstra(int x_s, int y_s) {
        dij.assign(H, std::vector<T_E>(W, INF));
        dij_prv.assign(H, std::vector<std::pair<int, int>>(W, std::make_pair(-1, -1)));

        using P = std::tuple<T_E, int, int>;
        std::priority_queue<P, std::vector<P>, std::greater<P>> pq;
        dij[x_s][y_s] = 0;
        pq.emplace(0, x_s, y_s);
        while (!pq.empty()) {
            T_E dnow;
            int x, y;
            std::tie(dnow, x, y) = pq.top();
            pq.pop();
            if (dij[x][y] < dnow) continue;
            for (size_t d = 0; d < dx.size(); d++) {
                int xn = x + dx[d], yn = y + dy[d];
                if (xn < 0 or yn < 0 or xn >= H or yn >= W) continue;
                T_E dnxt = dnow + edge_cost(x, y, xn, yn);
                if (dnxt < dij[xn][yn]) {
                    dij[xn][yn] = dnxt;
                    dij_prv[xn][yn] = std::make_pair(x, y);
                    pq.emplace(dnxt, xn, yn);
                }
            }
        }
    }
};

int main()
{
    int H, W;
    cin >> H >> W;
    S.resize(H);
    cin >> S;
    GridGraph graph(H, W);
    int ret = 0;
    if (S[0][0] == '#' and S.back().back() == '#') ret++;
    graph.dijkstra(0, 0);
    cout << ret + (graph.dij[H - 1][W - 1] + 1) / 2 << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)

using namespace std;


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

    int A,B;
    cin >> A;
    cin >> B;
    int sum = 0;

    REP(i,B-A){
        sum += i+1;
    }
    
    cout << sum-B << 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++)

int main() {
    int A, B;

    cin >> A >> B;

    int count = 0;

    
    while (true)
    {
        if (count * (A - 1) + 1 >= B)
            break;

        count++;
    }
    
    

    cout << count << endl;
    
}

Measured memory_bytes: 3632
from sys import stdin

dic = dict()


def main() -> None:
    n = next_int()
    register(n, 1)
    m = next_int()
    register(m, -1)

    ans = 0
    for v in dic.values():
        ans = max(ans, v)

    print(ans)


def register(n: int, t: int) -> None:
    global dic
    for i in range(n):
        s = input()
        if s in dic:
            dic[s] += t
        else:
            dic[s] = t


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

static int cnt;
int selectionSort(int* A, int N)
{
	int minj;
	int i,j,tmp;
	for(i=0;i<N;i++){
		minj=i;
		
		for(j=i+1;j<N;j++){
			if(A[j]<A[minj]){
				minj=j;
			}
		}
		if(i!=minj){
			tmp = A[i];
			A[i]=A[minj];
			A[minj]=tmp;
			cnt++;
		}
	}
	return 0;
}
int 
main(){
	int N;
	int A[100];	
	scanf("%d",&N);
	int i;
	for(i=0;i<N;i++)scanf("%d",&A[i]);
	
	selectionSort(A,N);
	//printf("%d %d \n",k,j);
	for(i=0;i<N;i++){
	    if(i<N-1)printf("%d ",A[i]);
	    else printf("%d",A[i]);
	}
	printf("\n%d\n",cnt);
 return 0;
}


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}


inline int addmod(int x,int y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(int x,int y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(int x,int y)
{
    return (x%mod *1LL* y%mod)%mod;
}
inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next smallest submask
}

void we_r_done()
{
    cout<<"NO";
    exit(0);
}

void debug(bool ok, string mssg)
{
    if(ok)
        return;
    cout<<mssg;
    exit(0);
}

int main()
{
	int n;
  scn(n);
  int g = 0;
  for(int i=0; i<n; i++){
    int x;
    scn(x);
    g = __gcd(g,x);
  }
  cout<<g;
    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, a, b, c ,d;
char s[1000000];

bool chk(int l, int r) {
	for (int i = l; i < r; ++i)
		if (s[i] == '#' && s[i + 1] == '#') return 0;
	return 1;
}

int main() {
	scanf("%d", &n);
	scanf("%d%d%d%d", &a, &b, &c, &d);
	scanf("%s", s + 1);
	if (a > b) {
		swap(a, b); swap(c, d);
	}
	if (c < d) {
		printf("%s", chk(a, c) && chk(b, d) ? "Yes" : "No");
	} else {
		if (!chk(a, c) || !chk(b, d)) printf("No");
		else {
			int w = 0, mx = 0;
			for (int i = b - 1; i <= d + 1; ++i) {
				if (s[i] == '.') ++w;
				else w = 0;
				mx = max(mx, w);
			}
			printf("%s", mx >= 3 ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e18;
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  FOR(i, 1, N + 1) {
    ll cnt = 0;
    ll tmp = i;
    while (tmp > 0) {
      tmp /= 10;
      cnt++;
    }
    if (cnt % 2 != 0) ans++;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define pb push_back
ll n, q;
ll a[100005];
vector< ll > v;
ll s[100005];
ll es[100005];
// fuck this problem man for real tho!
bool ok(ll x, ll len, ll rgt, ll bd)
{
        if(len > ((n+1)/2)) return false;
        if(len <= ((rgt+1)/2) ) return true;
        if(len > rgt) return false;
        ll nxt = n-1-len+1;
        ll remm = len - (rgt-len);
        bd -= remm;
        bd = n-1-len-len;
        //if(bd == -2 && (n%2 == 1) && (len == ((n+1)/2))) return true;
        if(bd < -1) return false;
        //if(remm >= 2){
        if(abs(x - v[bd+2]) <= abs(v[nxt] - x)) return true;
        return false;
        /*}else {
                ll bdo = bd + remm;
                ll tk = len - remm;
                ll xx = bdo + tk;
                //if(remm==0) xx--;
                if(x - v[bdo] <= v[xx] - x) return false;
                return true;
        }*/
}
ll solve(ll x)
{
        if(n==1) return x;
        if(x >= v.back()) {

                ll tot = s[n-1];
                ll ret=0;
                if(n%2 == 0) {
                        ret = es[n-2];
                        return tot - ret;
                }else {
                        return es[n-1];
                }
                return 0;
        }else if(x < v[0]) {
                ll A = n/2;
                return s[n-1] - s[A-1];
        }
        if(abs(v[n/2] - x) >= abs(x - v[0])) {
                return s[n-1] - s[(n/2) - 1];
        }
        auto it = upper_bound(v.begin() , v.end(), x) - v.begin();
        ll bd = it-1;
        ll rgt = n - 1 - bd;
        //if(rgt==1)
        /*if((rgt+1)/2 >= (n+1)/2) {
                return s[n-1] - s[(n/2) - 1];
        }*/
        ll lo = (rgt+1)/2;
        lo=1;
        ll hi = rgt;
        //hi=min(hi , (n+1)/2 + 1);
        while(hi > lo) {
                ll mid = lo + (hi - lo + 1)/2;
        //cout << mid << endl;
                if(ok(x,mid,rgt, bd)) lo=mid;
                else hi = mid-1;
                //cout << lo << " **** " << hi << endl;

        }
        //cout << "**** " << ok(x,hi,rgt,bd) << endl;
        //while(ok(x,hi+1,rgt,bd)==true) hi++;
        //while(ok(x,hi,rgt,bd)==false) hi--;
        //cout << bd << " " << hi << endl;
        ll ret = s[n-1] - s[n-1-hi];
        ll rem = hi - rgt + hi;
        bd = bd - rem;
        ll N = bd+1;
        if(N%2 == 0) {
                ret += (s[bd] - es[bd-1]);
        }else {
                ret += es[bd];
        }
        return ret;
}
int main()
{
        cin >> n >> q;
        for(ll i=1;i<=n;i++) {
                cin >> a[i];
                v.pb(a[i]);
                s[i-1] = a[i];
                if(i-1 > 0) s[i-1] += s[i-2];
        }
        es[0]=v[0];
        for(ll i=2;i<n;i += 2) es[i] = v[i] + es[i-2];
        while(q--) {

                ll x;
                cin >> x;
                cout << solve(x) << "\n";
        }
        return 0;
}


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

using usize = ::std::size_t;
//using u64 = ::std::uint_least64_t;
typedef long long u64;
//static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;

u64 N;

u64 modPow(u64 n, u64 k, u64 mod)
{
    if (k == 0) return 1LL % mod;
    u64 r = modPow(n, k >> 1, mod);
    r = r * r % mod;
    if (k & 1) r = r * n % mod;
    return r;
}

int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N;
    //vector<u64> dp(200001,0);
    //dp[0] = 0;
    //for (int n = 1; n <= 200000; n++) {
    //    u64 bits = __builtin_popcount(n);
    //    dp[n] = dp[n % bits] + 1;
    //}
    
    string X;
    cin >> X;
    
    u64 cnt = 0, mod1 = 0, mod2 = 0;
    for (int i = 0; i < N; i++) {
        cnt += X[i] - '0';
    }
    
    for (int i = 0; i < N; i++) {
        if (X[i] == '1') {
            mod2 += modPow(2, (N - i - 1), cnt + 1);
            mod2 %= cnt + 1;
            if (cnt == 1) {
                continue;
            }
            mod1 += modPow(2, (N - i - 1), cnt - 1);
            mod1 %= cnt - 1;
        }
    }
    
    for (int i = 0; i < N; i++) {
        if (X[i] == '1') {
            if (cnt == 1) {
                cout << 0 << endl;
                continue;
            }
            u64 modi = mod1 - modPow(2, (N - i - 1), cnt - 1);
            modi %= cnt - 1;
            if (modi < 0) {
                modi += cnt - 1;
            }
            u64 times = 1;
            while (modi > 0) {
                modi %= __builtin_popcount(modi);
                times++;
            }
            cout << times << endl;
        } else {
            u64 modi = mod2 + modPow(2, (N - i - 1), cnt + 1);
            modi %= cnt + 1;
            u64 times = 1;
            while (modi > 0) {
                modi %= __builtin_popcount(modi);
                times++;
            }
            cout << times << endl;
        }
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	int n;
	cin >> n;
	int dp[n + 1];
	memset(dp, 0, sizeof dp);
	for (int i = 0; i <= n; i++) {
		if (i >= 3)
			dp[i] = 1;
		for (int j = 0; j <= i - 3; j++)
			dp[i] += dp[j] % mod;
	}
	cout << dp[n] % mod;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

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

  for(int i = 0; i <= Y/10000; i++) {
    for(int j = 0; j <= Y/5000; j++) {
      int k = (Y - 10000*i - 5000*j)/1000;
      if(i+j+k == N && k >= 0) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;

  return 0;
}


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

const int P = 1e9 + 7;
const int N = 2010 * 2010;

int jc[N], jv[N], f[2010][2010];
int qpow(int a, int b) {
  int res = 1;
  for (; b; b >>= 1) {
    if (b & 1) res = (1ll * res * a) % P;
    a = (1ll * a * a) % P;
  }
  return res;
}
int C(int n, int m) {
  if (n < m) return 0;
  return ((1ll * jc[n] * jv[m]) % P * jv[n - m]) % P;
}

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

  int n, k;
  std::cin >> n >> k;
  if (k == 1) {
    std::cout << 1 << '\n';
    return 0;
  }
  jc[0] = 1;
  for (int i = 1; i <= n * k; ++i) jc[i] = (1ll * jc[i - 1] * i) % P;
  for (int i = 0; i <= n * k; ++i) jv[i] = qpow(jc[i], P - 2);
  
  f[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      f[i][j] = f[i - 1][j];
      if (j) {
        int tmp = (1ll * f[i][j - 1] * C(n - i + (n - j + 1) * (k - 1) - 1, k - 2)) % P;
        tmp = (1ll * tmp * (n - j + 1)) % P;
        f[i][j] = (f[i][j] + tmp) % P;
      }
    }
  }
  
  std::cout << f[n][n] << '\n';

  return 0;
}


Measured memory_bytes: 48672
import sys

H, W = list(map(int, sys.stdin.readline().strip().split(" ")))

first = ""
for i in range(W + 2):
    first += "."
    
l = []
l.append(first)

for i in range(H):
    l.append("." + sys.stdin.readline().strip() + ".")

l.append(first)

result = [[] for i in range(H)]

for i in range(H + 2):
    for j in range(W + 2):
        if (i == 0) or (i == (H + 1)) or (j == 0) or (j == (W + 1)):
            continue
        num = "#"
        if l[i][j] == ".":
            num = int(l[i-1][j-1] == "#") + int(l[i-1][j] == "#") + int(
                l[i-1][j+1] == "#") + int(l[i][j-1] == "#") + int(
                l[i][j+1] == "#") + int(l[i+1][j-1] == "#") + int(
                l[i+1][j] == "#") + int(l[i+1][j+1] == "#")
        result[i-1].append(num)
for i in range(H):
    s = ""
    for j in range(W):
        s += str(result[i][j])
    print(s)

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int 	     	  long long   // [9,223,372,036,854,775,807 to -9.....808] 19 digits
#define pb                push_back 
#define all(x)            (x).begin(),(x).end()
#define mp                make_pair
#define vi                vector<int> 
#define vpi               vector<pair<int,int>>
#define mii               map<int,int>
#define x                 first
#define y                 second 
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define sz(x)             (int)((x).size())

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order()  // order_of_key

//const int32_t mod=163577857; const int32_t hellhsh = 444440583533; const double pi=2*acos(0.0); const int32_t mod=998244353; 
const int32_t mod = 1e9+7;
const int32_t maxn=2e5+5;

int a[maxn]={0};

void solve(){
    int n;cin>>n;int sum=0;
    rep(i,0,n){
        int x;cin>>x;
        sum+=x;
        a[x]++;
    }
    int q;cin>>q;
    while(q--){
        int b,c;cin>>b>>c;
        sum+=a[b]*(c-b);
        a[c]+=a[b];
        a[b]=0;

        cout<<sum<<'\n';
    }
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tc=1,k=1;                                                                                                                  
    //cin>>tc;
    while(tc--){
        //cout<<"Case #"<<k++<<": ";
        solve();
    }
    return 0;
}

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

int n;


int dfs(long x=0, int a=0, int b=0, int c=0){
    if(x>n){
        return 0;
    }
    int res=a*b*c;
    //桁上げ
    x *= 10;
    res += dfs(x+3, 1, b, c);
    res += dfs(x+5, a, 1, c);
    res += dfs(x+7, a, b, 1);
    return res;
}

int main(){
    cin >> n;
    cout << dfs() << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    auto nq = readln().split().map!(to!int);
    immutable n=nq[0], q=nq[1];
    int[][] r;
    for(int i=n; i>1; i=(i+1)/2)
        r~=new int[i];
    r~=new int[1];
    foreach(_;0..q)
    {
        auto av = readln().split().map!(to!int);
        auto a=av[0]-1, v=r[0][a]+av[1];
        foreach(t;r)
        {
            auto b = a^1;
            auto p = t[a];
            t[a]=v;
            if(b>=t.length)
            {
                a/=2;
            }
            else if(max(p,t[b])!=max(v,t[b]))
            {
                a/=2;
                v=max(v,t[b]);
            }
            else
            {
                break;
            }
        }
        a=0;
        foreach_reverse(t;r[0..$-1])
        {
            a*=2;
            if(a+1<t.length && t[a]<t[a+1])
                ++a;
        }
        writeln(a+1," ",r[0][a]);
    }
}

Measured memory_bytes: 9828
L,R,d= map(int, input().split())
if L%d==0 and R%d==0:
    print(int(R/d-L/d+1))
elif L%d==0 and R%d!=0:
    print(int(R//d-L/d+1))
elif  L%d!=0 and R%d==0:
    print(int(R/d-L//d))
else:
    print(int(R//d-L//d))

Measured memory_bytes: 9044
n = int(input())
H = list(map(int, input().split()))
for i in range(n):
    #print(H)
    if i == 0:
        H[i] -= 1
    else:
        if H[i] < H[i-1]:
            print('No')
            exit()
        elif H[i] == H[i-1]:
            continue
        else:
            H[i] -= 1

#print(H)

for i in range(1, n):
    if H[i] < H[i-1]:
        print('No')
        exit()
else:
    print('Yes')


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

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

//------------------------------------------------------------------------------------------------------------------------------

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int main(void) {
    int N, X;
    cin >> N >> X;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        ans = GCD(ans, abs(X - a));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)
args = sys.argv
input = sys.stdin.readline


def dump(*objects):
    if len(args) == 2 and args[1] == "DEBUG":
        print(*objects, file=sys.stderr)


N = int(input())
A = [0] + list(map(int, input().split())) + [0]
dump(N, A)
B = [0]*len(A)
C = [0]*len(A)
for i in range(1, len(A)):
    dump(i)
    B[i] = B[i - 1] + abs(A[i] - A[i - 1])
for i in range(len(A) - 2, -1, -1):
    dump(i)
    C[i] = C[i+1] + abs(A[i]-A[i+1])
dump(A, B, C)
for i in range(1, N+1):
    dump(i, B[i-1] + B[N+1] - B[i+1] + abs(A[i-1]-A[i+1]))
    print(B[i-1] + C[i+1] + abs(A[i-1]-A[i+1]))

exit(0)


Measured memory_bytes: 16564
#include <iostream>
#include <array>
#include <string>

const int NIL = -1;
struct node
{
  int parent = NIL;
  int left = NIL;
  int right = NIL;
};

using binaryTree =  std::array<node, 25>;
int getSibling(binaryTree tree, int id)
{
  auto parent = tree[id].parent;
  if (parent == NIL)
    return -1;
  else if (tree[parent].left == id)
    return tree[parent].right;
  else
    return tree[parent].left;
}

int getDegree(node nd)
{
  int n=0;
  if (nd.left!= NIL) ++n;
  if (nd.right != NIL) ++n;
  return n;
}

std::string getType(node n)
{
  if (n.parent == NIL) return "root";
  else if (n.left == NIL && n.right == NIL)
    return "leaf";
  else
    return "internal node";
}


int getRootID(binaryTree tree, int n)
{
  for (int i=0; i<n; ++i)
    {
      if (getType(tree[i]) == "root")
        {
          return i;
        }
    }
}

void setDepth(binaryTree tree, int id, int dep, std::array<int, 25> &H)
{
  H[id] = dep;
  if (tree[id].left != NIL)
    setDepth(tree, tree[id].left, dep+1, H);
  if (tree[id].right != NIL)
    setDepth(tree, tree[id].right, dep+1, H);
}

void setHeight(binaryTree tree, int id, std::array<int, 25> &H)
{
  if (tree[id].left == NIL && tree[id].right == NIL)
    H[id] = 0;
  else
    {
      int hleft = 0, hright = 0;
      if (tree[id].left != NIL)
        {
          setHeight(tree, tree[id].left, H);
          hleft = H[tree[id].left] + 1;
        }
      if (tree[id].right != NIL)
        {
          setHeight(tree, tree[id].right, H);
          hright = H[tree[id].right] + 1;
        }
      if (hleft > hright) H[id] = hleft;
      else H[id] = hright;
    }
}

auto print = [](auto x, auto y){std::cout << x << y << ", ";};
auto println = [](auto x){std::cout << x << "\n";};

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

  binaryTree tree;
  for (int i=0; i<n; ++i)
    {
      int id, left, right;
      std::cin >> id >> left >> right;
      tree[id].left = left;
      tree[id].right = right;
      tree[left].parent = id;
      tree[right].parent = id;
    }

  std::array<int, 25> D, H;
  auto root_id = getRootID(tree, n);
  setDepth(tree, root_id, 0, D);
  int h = 0;
  for (int i=0; i<n; i++)
    {
      if (h < D[i]) h =D[i];
    }
  setHeight(tree, root_id, H);

  for (int i=0; i<n; ++i)
    {
      std::cout << "node " << i;
      std::cout << ": ";
      print("parent = ", tree[i].parent);
      print("sibling = ", getSibling(tree, i));
      print("degree = ", getDegree(tree[i]));
      print("depth = ", D[i]);
      print("height = ", H[i]);
      println(getType(tree[i]));
    }
}



Measured memory_bytes: 3216
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
S = input()
k = I()
from itertools import groupby
x = y = 0
g = [len(list(v)) for k,v in groupby(S)]
for c in g:
    x += c//2
if S[-1] == S[0]:
    if g[-1]%2 == 0 or g[0]%2 == 0:
        pass
    elif len(S) == 1:
        y = k//2
    elif len(S) == g[0]:
        y = k//2
    else:
        y = k-1
print(x * k + y)


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


def num_divisors_table(n):
    table = [0] * (n + 1)

    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1

    return table


# li = np.array(num_divisors_table(N))
# k = np.arange(N + 1)

li = num_divisors_table(N)

# print(sum(li * k))
ans = 0
for i in range(N + 1):
    ans += i * li[i]

print(ans)


Measured memory_bytes: 146132
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const YES = "Yes"
const NO = "No"

func lib_CopyInt8(values []int8) []int8 {
	dst := make([]int8, len(values))
	copy(dst, values)
	return dst
}
func lib_ReverseInt8(values []int8) []int8 {
	newValues := lib_CopyInt8(values)
	for i, j := 0, len(values)-1; i < j; i, j = i+1, j-1 {
		newValues[i], newValues[j] = values[j], values[i]
	}
	return newValues
}
func lib_ToDigitSliceInt64(n int64) (digits []int8) {
	nn := int64(n)
	for {
		if nn <= 0 {
			return lib_ReverseInt8(digits)
		}
		digit := int8(nn % 10)
		digits = append(digits, digit)
		nn /= 10
	}
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int64
	scanner.Scan()
	N, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	fmt.Println(solve(N))
}
func solve(N int64) string {
	digits := lib_ToDigitSliceInt64(N)
	if digits[0] == 7 || digits[1] == 7 || digits[2] == 7 {
		return YES
	}
	return NO
}


Measured memory_bytes: 1756
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;
 
int main()
{
   int N=3;
   string str;
   multimap<string, int> mp1= {{"AC",0},{"WA",0},{"TLE",0},{"RE",0}};
   multimap<string, int>::iterator itr1;
   vector<string> v1 = {"AC","WA","TLE","RE"};
   cin>>N;
   while(N--) {
       cin>>str;
       itr1 = mp1.find(str);
       itr1->second ++;
   }
   for(auto it = v1.begin(); it!=v1.end(); ++it) {
       cout<<*it<<" x "<<mp1.find(*it)->second<<endl;
   }
   return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int main() {
    int h;
    cin >> h;
    int w;
    cin >> w;
    char a[h+1][w+1];
    for (int i=1; i<=h; i++) {
        for (int j=1; j<=w; j++) {
            cin >> a[i][j];
        }
    }
    int dp[h+1][w+1];
    for (int i=1; i<=h; i++) {
        for (int j=1; j<=w; j++) {
            dp[i][j] = 0;
            if (i == 1 && j==1)
                dp[i][j] = 1;
            else {
                if (i > 1 && a[i-1][j] == '.')
                    dp[i][j] = dp[i-1][j]%mod;
                if (j > 1 && a[i][j-1] == '.')
                    dp[i][j] += (dp[i][j-1]) % mod;
            }
        }
    }
    cout << (dp[h][w]) % mod;
    return 0;
}


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

int main(){
	int N, ans = 0;
	cin >> N;
	int H[N];
	for(int i=0; i<N; i++) cin >> H[i];
	for(int i=0; i<N; i++){
		int f = 0;
		for(int j=0; j<i; j++){
			if(H[j] > H[i]) f = 1;
		}
		if(!f) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#define INF 10000000000000
using namespace std;
using ll = long long;
int main() {
	int n,a,b;
	cin >> n >> a >> b;
	cout << min(a, b) << " ";
	cout << max(a+b-n,0) << endl;
}



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

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

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

const int MAX = 1e5 + 5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
    int A, B;
    cin >> A >> B;
    cout << max(0, A - B * 2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>a>>b;
    ans=a-1;
    if(a<=b)ans++;
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		String A = sc.next();
		
		String F = A.replaceFirst("7", "8");

			System.out.println(F);

		}
	}


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

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/
//約数列挙配列生成
vector<int> divisor(int n){
    vector<int> ret;
    for(int i = 1; i * i <= n; i++){
        if(n % i == 0){
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int b;
    while(cin >> b) {
        if(b == 0) break;
        int answer = -1e9;
        int ans_n = -1e9;
        vi a = divisor(b);
        if(b%2==1) {
            answer = b/2;
            ans_n = 2;
        }
        rep(i,a.size()) {
            if(a[i]%2 == 1) {
                if(b/a[i] > a[i]/2) {
                    if(chmax(ans_n, a[i])){
                        answer = b/a[i] - a[i]/2;
                    }
                }
            }
            if((b/a[i])%2==1) {
                if((b/a[i])/2 >= a[i]) {
                    if(chmax(ans_n, 2*a[i])) {
                        answer = (b/a[i])/2 - (a[i]-1);
                    }
                }
            }    
        }

        cout << answer <<" "<< ans_n << '\n';
    }
}


Measured memory_bytes: 3112
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a,b,x;
	cin>>a>>b;
	x=a+b;
	if(x%2==0){
		cout<<x/2<<endl;
	}else{
	cout<<int(x/2)+1<<endl;
}
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
	ll N,A,B;
    cin >> N >> A >> B;
    cout << N/(A+B)*A+min(N%(A+B),A);
    return 0;
}


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

int main() {
  string s, t, u;
  int a, b,ans=0;
  cin >> s >> t >> a >> b >> u;
  if (s == u) a--;
  if (t == u) b--;
  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int r;
    cin >> r;
    cout << r * r << endl;        
}


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


int main(void)
{
	char od[51],ev[51];
	int i,lenod,lenev;
	scanf("%s%s",od,ev);
	lenod=strlen(od);
	lenev=strlen(ev);
	fprintf(stderr,"lenod=%d lenev=%d\n",lenod,lenev);
	if(lenod==lenev)
		{
		for(i=0;i<=lenod-1;i++)
			{printf("%c%c",od[i],ev[i]);}
		}
	else
		{
		for(i=0;i<=lenod-2;i++)
			{printf("%c%c",od[i],ev[i]);}
		printf("%c",od[i]);
		}

	printf("\n");
	return 0;
}





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


Measured memory_bytes: 3100
k,n=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(len(a)-1):
  b.append(a[i+1]-a[i])
  
b.append(abs(a[-1]-a[0]-k))

b.sort()
b[-1]=0
print(sum(b))

Measured memory_bytes: 32176
/*
#include<rabbit>;
using blueHulkStress;
using AceOfSpades;
*/
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-9);
typedef long long ll;
typedef unsigned long long ull;
#define flush fflush(stdout), cout.flush()
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define rep(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lcm(a,b) (a*(b/__gcd(a,b)))
#define P 1000000007
#define endl '\n'
const int dx[] = {1,-1,0,0,1,-1,1,-1};
const int dy[] = {0,0,1,-1,1,-1,-1,1};
const int dxhorse[] = {-2,-2,-1,-1,1,1,2,2};
const int dyhorse[] = {1,-1,2,-2,2,-2,1,-1};

void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}

string s;
set<string>save;
ull ans = 0;

void bfs()
{
	queue<string>q;
	
	q.push(s);
	
	while(!q.empty())
	{
		string cur = q.front(); q.pop();
		save.insert(cur);
		for(int i = 1; i<(int)cur.size(); i++)
		{
			if(cur[i]!='+' && cur[i-1]!='+')
				q.push(cur.substr(0,i)+"+"+cur.substr(i));
		}
	}
}

int main(int argc, char const *argv[])
{
	fast();
	cin>>s;
	
	bfs();
	
	stringstream ss;

	for(auto i:save)
	{
		ss.clear();
		ss<<i;
		ull val, lim = count(all(i),'+');
		char plus;
		rep(j,lim)
		{
			ss>>val, ans+=val, ss>>plus;
		}
		ss>>val, ans+=val;
	}
	cout<<ans;
}	

Measured memory_bytes: 28452
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		String s,p;
		Scanner sc = new Scanner(System.in);
		s = sc.nextLine();
		p = sc.nextLine();
		for(int i = 0; i < s.length(); i++){
			if(p.equals(s.substring(0,p.length()))){
				System.out.println("Yes");
				System.exit(0);
			}
			s = s.substring(s.length() - 1, s.length()) + s.substring(0,s.length() - 1);
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 26288
#include <bits/stdc++.h>
#define maxn 500005
#define maxk 20
using namespace std;

string s;
int Q, n;

int nxt[maxn][26], vanish[maxn], jump[maxn][maxk];

bool getJump(int src, int dst) {
	int i = maxk - 1;
	while (i >= 0) {
		if (jump[src][i] == dst) {
			return true;
		}
		if (jump[src][i] >= 0 && jump[src][i] < dst) {
			src = jump[src][i];
		} else {
			i--;
		}
	}
	return false;
}

int main() {
	cin >> s;
	n = s.size();
	for (int i = 0; i < n; i++) {
		s[i] -= 'a';
	}
	int ALPHABET = 26;

	memset(nxt, -1, sizeof nxt);
	memset(vanish, -1, sizeof vanish);

	for (int i = n - 1; i >= 0; i--) {
		nxt[i][s[i]] = i + 1;
		for (int c = s[i] + 1; c != s[i]; c++) {
			if (c >= ALPHABET) {
				if (nxt[i][c - 1] >= 0) {
					vanish[i] = nxt[nxt[i][c - 1]][c - 1];
				}
				c = -1;
			} else if (c > s[i]) {
				if (nxt[i][c - 1] >= 0) {
					nxt[i][c] = nxt[nxt[i][c - 1]][c - 1];
				}
			} else {
				if (vanish[i] >= 0) {
					nxt[i][c] = nxt[vanish[i]][c];
				}
			}
		}
	}

	memset(jump, -1, sizeof jump);
	for (int i = 0; i < n; i++) {
		jump[i][0] = vanish[i];
	}
	for (int k = 1; k < maxk; k++) {
		for (int i = n - 1; i >= 0; i--) {
			if (jump[i][k - 1] >= 0) {
				jump[i][k] = jump[jump[i][k - 1]][k - 1];
			}
		}
	}

	scanf("%d", &Q);
	while (Q--) {
		int l, r;
		scanf("%d %d", &l, &r);
		l--;
		if (getJump(l, r)) {
			printf("Yes\n");
		} else {
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 93060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define M (i*10+q[j])
#define pa pair<int,int>
/*#define F first
#define S second*/
typedef long long ll;
#define X first
#define Y second

int main()
{
    int n;
    cin>>n;
    int *a=new int [n];
    rep(i,n)
    cin>>a[i];
    sort(a,a+n);
    cout<<a[n/2]-a[n/2-1];
    return 0;

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007
#define ll long long int
#define pi 3.141592653589793238
const int N = 1e5 + 10;
int main(){
    FAST;
    ll t=1;
    // cin>>t;
    while(t--)
    {
        ll n,ans=0;
        cin>>n;
        vector<int> p(n+1);
        for(int i=1;i<=n;i++)
            for(int j=1;j*i<=n;j++)
                p[i*j]++;
        for(int c=1;c+1<=n;c++)
            ans+=p[c];
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 7088
#include <stdio.h>
void printArray(int arr[], int len)
{
	int i;
	for (i = 0; i < len; i++) {
		if (i > 0) {
			printf(" ");
		}
		printf("%d", arr[i]);
	}
	printf("\n");
}
int main(void) {
	int i, n, j;
	int A[100];
	fscanf(stdin, "%d", &n);
	for (i = 0; i < n; i++) {
		fscanf(stdin, "%d", &(A[i]));
	}
	printArray(A, n);
	for (j = 1; j < n; j++) {
		int key = A[j];
		i = j - 1;
		while (i >= 0 && A[i] > key) {
			A[i + 1] = A[i];
			i--;
		}
		A[i + 1] = key;
		printArray(A, n);
	}
	return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>

typedef long long ll;
using namespace std;
const int mod = 1000000007;

int main() {

    int N; cin >> N;
    int M; cin >> M;
    if (N == M) 
        cout << "Yes" << '\n';
    else 
        cout << "No" << '\n';

}


Measured memory_bytes: 256
input = input()
 
nums = input.split(" ")
 
animals = int(nums[0])
legs = int(nums[1])
 
turu = (4*animals -legs)/2.0
kame = (legs-2*animals)/2.0
 
if turu.is_integer() and kame.is_integer() and turu>=0 and kame>=0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9116
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int h, a; cin >> h >> a;
	int ans;
	ans = h / a;
	ans += (h % a != 0 ? 1 : 0);
	cout << ans << endl;
	return;
}

int main() {
	solve();
  return 0;
}

Measured memory_bytes: 256
INF = 10**20
## dp[j] = value jになるための wの合計の最小値
def sack(N,W,vlist,wlist):
    sum_val = sum(vlist)
    global INF
    dp = [INF for i in range(sum_val+1)]
    dp[0] = 0 ## 初期値、0以外のvalueは作れないので wの合計がINFになると仮定
    for i in range(N):
        for j in range(sum_val, vlist[i]-1, -1):
            dp[j] = min(dp[j], dp[j-vlist[i]] + wlist[i]) #value j になるためi番目を使ったかどうか。
    
    for j in range(sum_val, -1, -1):
        if (dp[j] <= W):
            return j
            break
    

N, W  = map(int, input().split())
vlist = []
wlist = []
for i in range(N):
    v,w = map(int, input().split())
    vlist.append(v)
    wlist.append(w)
print(sack(N,W,vlist,wlist))


Measured memory_bytes: 5720
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int main(){
 
    ll n, a, b, res;
    cin >> n >> a >> b;
    
    res = n / (a+b);
    ll res_a = res * a;
    
    ll res_n = n - (res * (a+b));

    if(res_n <= a) res = res_a + res_n;
    else res = res_a + a;

    cout << res;

    return 0;
}

Measured memory_bytes: 256
use std::io;

/// 一行を読み込んで、空白で区切ったベクタにして返す
#[allow(dead_code)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect()
}

/// n行を読み込んで、数字を空白で区切って二次元のベクタにして返す
#[allow(dead_code)]
fn read_table<T>(n: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut ret: Vec<Vec<T>> = Vec::new();
    for _ in 0..n {
        ret.push(read::<T>());
    }
    ret
}

/// n行を読み込んで、1文字ずつを二次元のベクタにして返す
#[allow(dead_code)]
fn read_char_table(n: usize) -> Vec<Vec<char>> {
    let mut ret: Vec<Vec<char>> = Vec::new();
    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let chr = buf.trim().chars().collect();
        ret.push(chr);
    }
    ret
}

/// n行を読み込んで、一次元のベクタにして返す
#[allow(dead_code)]
fn read_array<T>(n: usize) -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut array = Vec::new();

    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        array.push(buf.trim().parse().unwrap());
    }
    array
}

fn main() {
    // 数値
    let (n, _m, x, y) = {
        let i = read::<isize>();
        (i[0], i[1], i[2], i[3])
    };

    let mut xn = read::<isize>();
    let mut ym = read::<isize>();

    xn.sort();
    ym.sort();

    let n = n as usize;

    if xn[n-1] < ym[0] && xn[n-1] < y && ym[0] > x{
        println!("No War");
    } else {
        println!("War");
    }    
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();

		int sum = 0;

		while (!(str.equals("0"))) {

			sum =0;

			for (int i = 0; i < str.length(); i++) {
				sum += Integer.parseInt(String.valueOf(str.charAt(i)));
			}
			System.out.println(sum);

			str = br.readLine();
		}

	}
}

Measured memory_bytes: 24492