akhauriyash/Code-Regression huggingface dataset:
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int MAXN = 2010 , MAXK = 1e4 + 10;
int n , K;
string s[MAXN];
int z[MAXK * 2];
bitset<MAXK> can[MAXN] , prefix;

void Zalgo(string&s) {
  memset(z,0,sizeof(z));
  for(int i=1,j=0;i<sz(s);++i) {
    if(i < j + z[j]) z[i] = min(z[i - j] , j + z[j] - i);
    while(i + z[i] < sz(s) && s[z[i]] == s[i + z[i]]) z[i]++;
    if(i + z[i] > j + z[j]) j = i;
  }
  z[0] = sz(s);
}

pii best;
string S , ans;
int A;

int compare(pii a,pii b) {
  if(a.fi < b.fi) return -compare(b,a);
  int lcp = b.fi;
  if(b.se) {
    lcp += min(a.fi - b.fi , z[A + 1 + b.fi]);
    if(lcp == a.fi)
      lcp += z[a.fi - b.fi];
  }
  int lena = a.fi + (a.se ? A : 0);
  int lenb = b.fi + (b.se ? A : 0);
  if(lcp == min(lena , lenb))
    return 0;
  char pa = lcp < a.fi ? ans[lcp] : S[lcp-a.fi];
  char pb = lcp < b.fi ? ans[lcp] : S[lcp-b.fi];
  return pa - pb;
}

bool Update(pii t) {
  if(best.fi == -1) {
    best = t;
    return true;
  }
  int cmp = compare(best , t);
  if(cmp > 0) best = t;
  return cmp >= 0;
}

int main(){
  cin >> n >> K;
  rep(i,0,n) cin >> s[i];
  can[n].set(0);
  per(i,0,n) can[i] = can[i + 1] << sz(s[i]) | can[i + 1];
  prefix.set(0);
  rep(i,0,n) {
    S = s[i] + '$' + ans;
    A = sz(s[i]);
    Zalgo(S);
    best=mp(-1,0);
    per(j,0,K+1) {
      bool ok = false;
      if(prefix.test(j) && can[i + 1].test(K - j))
        ok |= Update(mp(j,0));
      if(j >= sz(s[i]) && prefix.test(j - sz(s[i])) && can[i + 1].test(K - j))
        ok |= Update(mp(j-sz(s[i]),1));
      prefix.set(j,ok);
    }
    ans = ans.substr(0 , best.fi);
    if(best.se) ans += s[i];
    rep(j,sz(ans)+1,K+1) prefix.reset(j);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;

int main(){
  int n;cin>>n;
  vector<pair<int, int>> job(n);
  for(int i=0;i<n;i++)cin>>job[i].second>>job[i].first;
  sort(job.begin(), job.end());
  int start=0, res=0;
  bool ans=true;
  for(int i=0;i<n;i++){
  	int a=job[i].second, b=job[i].first;
    res+=b-start;
    start=b;
    res-=a;
    if(res<0){
      ans=false;
      break;
    }
  }
  cout<<(ans?"Yes":"No")<<endl;
}

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

int main(){
	int **a,*b,*c, n, m,num;
	cin >> n >> m;

	a = new int*[n];
	for (int i = 0; i < n; i++){
		a[i] = new int[m];
	}//a[n][m]

	b = new int[m];
	c = new int[n];

	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> num;
			a[i][j] = num;
		}
	}	

	for (int i = 0; i < m; i++){
		cin >> num;
		b[i] = num;
	}

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

	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			c[i] += a[i][j] * b[j];

		}
		cout << c[i]<<endl;
	}

	

	return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool IsOK(const vector<int>& p)
{
    rep(i, 0, p.size() - 1)
    {
        if (p[i] < p[i + 1])
        {

        }
        else
        {
            return false;
        }
    }

    return true;
}

void _main()
{
    int N;
    cin >> N;
    vector<int> p(N);
    rep(i, 0, N) cin >> p[i];
    if (IsOK(p))
    {
        cout << "YES" << endl;
        return;
    }
    rep(i, 0, N)
    {
        rep(j, i + 1, N)
        {
            swap(p[i], p[j]);

            if (IsOK(p))
            {
                cout << "YES" << endl;
                return;
            }

            swap(p[i], p[j]);
        }
    }

    cout << "NO" << endl;
}


Measured memory_bytes: 256
# B(i) >= max( A(i), A(i+1) )
# B(0) = A(0), A(1)

n = int(input())
b = list(map(int, input().split()))

tmp = []
list_a = []

for i in range(n-1):
  tmp.extend([b[i], b[i]])

for i in range(1, len(tmp)-2, 2):
  list_a.append(min(tmp[i], tmp[i+1]))
  
list_a.extend([b[0], b[n-2]]) 

print(sum(list_a))


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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=998244353;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	char ch;
	cin>>ch;
	if(ch>='A'&&ch<='Z') cout<<'A';
	else cout<<'a';
	return 0; 
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  string X;
  cin >> X;
  int len = sz(X);
  stack<bool> st;
  st.push(X[0] == 'S');
  srep(i,1,len) {
    if(st.empty()) {
      st.push(X[i] == 'S');
      continue;
    }
    bool isS = st.top();
    if(isS) {
      if(X[i] == 'T') {
        st.pop();
      } else {
        st.push(true);
      }
    } else {
      st.push(X[i] == 'S');
    }
  }
  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <cstdlib>
using namespace std;
using ll = long long int;


int main()
{
    int N,x;
    cin >> N >> x;
    vector<int> A;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());

    int count = 0;
    for (int i = 0; i < N; i++) {
        x -= A[i];
        if (x >= 0) {
            count++;
            if (i == N-1) {
               if (x != 0) {
                count--;

                }
            }
        }
        else
            break;
    }

    cout << count << endl;
}


Measured memory_bytes: 256
#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 INF 2e9
#define PI 3.141592653589793
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    ll N, K;
    cin >> N >> K;
    if(K > N){
        cout << 0 << endl;
        return 0;
    }
    vector<ll> H(N);
    for(ll i = 0; i < N; i++){
        cin >> H[i];
    }

    sort(H.rbegin(), H.rend());

    for(ll i = 0; i < K; i++){
       H[i]=0;
    }

    ll atk=0;
    for(ll i = 0; i < N; i++){
       atk += H[i];
    }

    cout << atk << endl;


}

Measured memory_bytes: 1792
#include <stdio.h>
   
int rot[24][7] = {
    { 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
    { 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
    { 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
    { 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
    { 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
    { 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };
int assign[7];
   
int main()
{
    int i, j;
    int a[7], b[7], dice[7];
   
    for (i = 1; i <= 6; i++) scanf("%d", assign+i);
    for (i = 1; i <= 6; i++) scanf("%d", a+i);
    for (j = 0; j < 24; j++) {
        for (i = 1; i <= 6; i++) dice[i] = rot[j][i];
        for (i = 1; i <= 6; i++) b[i] = assign[dice[i]];
        for (i = 1; ; i++) {
            if (i > 6) { puts("Yes"); return 0; }
            if (a[i] != b[i]) break;
        }
    }
    puts("No");
    return 0;
}



Measured memory_bytes: 2148
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = list(map(int,readline().split()))
a.sort()

if a[0] == a[-1]:
  if n > 1:
    print(0)
  else:
    print(1)
  exit()

def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i * i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += i % 2 + (3 if i % 3 == 1 else 1)
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k
 
    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret

def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return ret
    
s = set()
ans = 0
for nm,i in enumerate(a):
  c = set(divisors(i))
  if c&s == set() and ((nm < n-1 and a[nm+1] != i) or nm == n-1): 
    ans += 1
  s.add(i)

print(ans)

Measured memory_bytes: 118044
#include "bits/stdc++.h"
using namespace std;

#define db(x) cerr << #x << " == " << x << endl
#define all(container) container.begin(), container.end()
#define mp(i,j) make_pair(i,j)
#define pb push_back

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vii;

template<typename T>
void print_vector_debug(const T& t) {
	cout << "[DEBUG] VECTOR:";
	for (auto i = t.cbegin(); i != t.cend(); ++i) {
		if ((i + 1) != t.cend()) {
			cout << *i << " ";
		} else {
			cout << *i << endl;
		}
	}
}

#define MAXN 3005

int N;
int vis[MAXN][MAXN];
double p[MAXN];
double dp[MAXN][MAXN];

double solve(int turns, int heads)
{
	if (turns == N)
	{
		return heads > turns/2 ? 1:0;
	}
	
	if (vis[turns][heads])
	{
		return dp[turns][heads];
	}
	vis[turns][heads] = 1; 
	
	//~ db(p[turns]);
	//~ db(1.0 - p[turns]);
	dp[turns][heads] = p[turns]*solve(turns + 1, heads + 1) + (1.0 - p[turns])*solve(turns + 1, heads);
	return dp[turns][heads];
}

int main() 
{
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
	{
		scanf("%lf", &p[i]);
	}
	
	printf("%0.15lf\n", solve(0, 0));
	return 0;
}


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

using namespace std;

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

    map<int, int> mp;
    int n;
    cin >> n;
    int mnum = 0;
    for (int i = 0; i < n; ++i)
    {
        int m;
        cin >> m;
        ++mp[m];
        mnum = max(mnum,mp[m]);
        ++mp[m-1];
        mnum = max(mnum,mp[m-1]);
        ++mp[m+1];
        mnum = max(mnum,mp[m+1]);
    }
    cout << mnum << endl;

    return 0;
}


Measured memory_bytes: 4736
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
import itertools
import math
INF = 10**9
MOD = 10**9+7

N = int(input())
S = input()
S += '0'
ans = 0
for i in range(N):
    if S[i] != S[i+1]:
        ans += 1
print(ans)


Measured memory_bytes: 39792
#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    int subSum[N];
    int total = 0;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        total += tmp;
        subSum[i] = total;
    }
    
    int diff = 1000;
    for (int i = 0; i < N - 1; i++) {
        diff = min(diff, abs(total - 2*subSum[i]));
    }
    
    cout << diff << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
ll C[101][101];
void solve() {
	var(int, n);
	vector<array<int, 3>> yx(n);
	int x, y, h;
	rep(i, 0, n) {
		cin >> yx[i][1] >> yx[i][2] >> yx[i][0];
	}
	sort(rall(yx));
	rep(r, 0, 101) {
		rep(c, 0, 101) {
			C[r][c] = abs(r - yx[0][2]) + abs(c - yx[0][1]) + yx[0][0];
		}
	}
	rep(i, 1, n) {
		h = yx[i][0];
		x = yx[i][1];
		y = yx[i][2];
		rep(r, 0, 101) {
			rep(c, 0, 101) {
				if (max(C[r][c] - abs(r - y) - abs(c - x), 0LL) != h) {
					C[r][c] = -1;
				}
			}
		}
	}
	ll cx = 0, cy = 0, H = -1;
	rep(r, 0 ,101) {
		rep(c, 0, 101) {
			if (C[r][c] > H) {
				cy = r;
				cx = c;
				H = C[r][c];
			}
		}
	}
	print(cx, cy, H);
}
int main() {
	solve();
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (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; }
typedef long long ll;
typedef pair<int,int> P;

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

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pb push_back
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const int N=2e5+10;
int a[N];
int main()
{
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	for(ll i=k;i<=n+1;i++){
		ll num1=(n-i+1+n)*i/2;
		ll num2=(0+i-1)*i/2;
		ans+=num1-num2+1;
		ans%=mod;
	} 
	cout<<ans;
}


Measured memory_bytes: 3632
//
// Created by Myabu on 2020/01/25.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    int H,W;
    string S[55];

    cin>>H>>W;
    for (int i = 0; i < H; ++i) {
        cin>>S[i];
    }

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


    for (int y = 0; y < H; ++y) {
        for (int x = 0; x < W; ++x) {
            if(S[y][x] == '#')continue;
            int count = 0;
            for (int A = 0; A < 8; ++A) {
                int ax = x+dx[A];
                int ay = y+dy[A];

                if(ax<0 || ay<0 || ax>W || ay > H){
                    continue;
                }
                if(S[ay][ax] == '#')count++;
            }
            S[y][x] = (char)count + '0';
        }
    }

    for (int i = 0; i < H; ++i) {
        cout<<S[i]<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  ll re=MOD;
  reps(c,-111,111){
    ll sum=0;
    for(int x:a) sum+=(x-c)*(x-c);
    MN(re,sum);
  }
  cout<<re<<endl;
  return 0;
}


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

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#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 _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  vector<double> v(n);
  rep(i,n)cin>>v[i];
  sort(all(v));
  dump(v);

  priority_queue<double, vector<double>, greater<double>> q;
  rep(i, n){
    q.push(v[i]);
  }

  while(sz(q)>=2){
    double x = q.top(); q.pop();
    double y = q.top(); q.pop();
    q.push((x+y)/2);
  }

  double ans = q.top();
  // cout << ans << endl;
  printf("%.12f", ans);
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

var (
	memoTotal  []uint64
	memoMiddle []uint64
	memoP      []uint64
)

func main() {
	var n, x uint64
	fmt.Scanf("%d %d", &n, &x)

	memoTotal = make([]uint64, n+1)
	memoMiddle = make([]uint64, n+1)
	memoP = make([]uint64, n+1)
	memoTotal[0] = 1
	memoP[0] = 1
	for i := uint64(1); i <= n; i++ {
		memoTotal[i] = memoTotal[i-1]*2 + 3
		memoMiddle[i] = 2 + memoTotal[i-1]
		memoP[i] = memoP[i-1]*2 + 1
	}
	fmt.Println(search(n, x))
}

func search(n uint64, rest uint64) uint64 {
	if rest == 0 {
		return 0
	} else if rest == 1 {
		if n == 0 {
			return 1
		}
		return 0
	}

	if rest == memoTotal[n] {
		return memoP[n]
	} else if rest > memoMiddle[n] {
		return search(n-1, rest-memoMiddle[n]) + memoP[n-1] + 1
	} else if rest == memoMiddle[n] {
		return memoP[n-1] + 1
	} else {
		return search(n-1, rest-1)
	}
}


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

const u_int32_t TYPE_SIZE = 26;

class Const {
public:
    Const(){
        cin >> this->D;

        this->c = new vector<u_int32_t>(TYPE_SIZE+1);
        for (u_int32_t i = 1; i <= TYPE_SIZE; i++) {
            cin >> (*this->c)[i];
        }

        this->s = new vector<vector<u_int32_t>>(D + 1, vector<u_int32_t>(TYPE_SIZE + 1));
        for (u_int32_t i = 1; i <= D; i++) {
            for (u_int32_t j = 1; j <= TYPE_SIZE; j++) {
                cin >> (*this->s)[i][j];
            }
        }
    };

    u_int32_t getD() {
        return this->D;
    }

    u_int32_t getc(u_int32_t i) {
        return (*this->c)[i];
    }

    u_int32_t gets(u_int16_t i, u_int32_t j) {
        return (*this->s)[i][j];
    }
private:
    u_int32_t D;
    vector<u_int32_t> *c;
    vector<vector<u_int32_t>> *s;
};


class Schedule {
public:
    Schedule(u_int32_t D, Const *cst) {
        this->cst = cst;
        this->S = new vector<int64_t>(D+1);
        (*this->S)[0] = 0;
        this->now = 0;
        this->schedule = new vector<u_int32_t>(D+1, 0);
        this->last = new vector<vector<u_int32_t>>(D + 1, vector<u_int32_t>(TYPE_SIZE + 1, 0));
        for (u_int32_t t = 1; t <= TYPE_SIZE; t++) {
            (*this->last)[0][t] = 0;
        }
    }
    u_int32_t getNow() {
        return this->now;
    }

    int64_t getS(u_int32_t day) {
        // 1 <= day <= D
        return (*this->S)[day];
    }

    void setTask(u_int32_t task) {
        this->now++;
        (*this->schedule)[this->now] = task;
        this->calculate();
    } 

    u_int32_t getTask(u_int32_t day) {
        // 1 <= day <= D
        return (*this->schedule)[day];
    }

    void calculate() {
        // now - 1 日目まで計算が行われた前提で, 
        // now 日目の計算をする

        // last計算
        for (u_int32_t t = 1; t <= TYPE_SIZE; t++) {
            (*this->last)[this->now][t] = (*this->last)[this->now - 1][t];
        }
        //  last 上書き
        (*this->last)[this->now][this->getTask(this->now)] = this->now;
 
        // S 計算
        (*this->S)[this->now] = (*this->S)[this->now -1] + this->cst->gets(this->now, this->getTask(this->now));
        for (u_int32_t t = 1; t <= TYPE_SIZE; t++) {
            (*this->S)[this->now] -= this->cst->getc(t) * (this->now - (*this->last)[this->now][t]);
        }   
    }

    u_int32_t getPoint() {
        return (u_int32_t)1000000 + (*this->S)[this->now] > 0 ? 1000000 + (*this->S)[this->now] : 0;
    }
private:
    Const *cst;
    u_int32_t now;
    vector<int64_t> *S;
    vector<u_int32_t> *schedule;
    vector<vector<u_int32_t>> *last;
};

void Main() {
    // input
    Const cst = Const();
    Schedule schedule = Schedule(cst.getD(), &cst);


    // translate
    for (u_int32_t day = 1; day <= cst.getD(); day++) {
        u_int32_t task;
        cin >> task;
        schedule.setTask(task);
    }


    // output
    for (u_int32_t day = 1; day <= cst.getD(); day++) {
        cout << schedule.getS(day) << endl;
    }

}

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


Measured memory_bytes: 3728
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Common Raccoon vs Monster
            var line = ReadLine();
            int H = line[0];
            int N = line[1];

            var A = ReadLine();

            if (A.Sum() >= H)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 21728
n=int(input())
vc=[]
ans=0

for i,j in zip(input().split(),input().split()):
    vc.append([int(i),int(j)])

for i in range(n):
    if vc[i][0]-vc[i][1]>=0:
        ans+=vc[i][0]-vc[i][1]

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;


int a,b,c,d,first,second;



int main()
{
	cin >> a >> b >> c >> d ;

	first = a * b;
	second = c * d;

	if (first <= second)
	{
		cout << second << endl;
	}
	else
	{
		cout << first << endl;
	}


	//system("pause");

}

Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const arr = input.split('\n');
let str = "";

for(let i = 0; i < arr.length; i++){
  if(arr[i] === '0') break;
  const num = [...arr[i]].map(Number);
  const sum = num.reduce((acc, curr) => acc + curr);
  str += sum + '\n';
}

console.log(str.trim());


Measured memory_bytes: 16632
#include<iostream>
using namespace std;
const long long MOD = 1000000007;
int main(){
  int n;
  long long array[200005]={0};
  long long sum=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>array[i];
    array[i]=array[i]+array[i-1];
  }
  
  for(int i=1;i<n;i++){
    long long a=array[i]-array[i-1];
    sum=(sum+((array[n]-array[i])%MOD*a)%MOD)%MOD;
  }
    
  cout<<sum<<endl;
  return(0);
}

Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
int main () {
  long A, B;
  cin >> A >> B;
  for(int i = 0; i <= 1010; i++){
    if(A == (i * 8 / 100) && B == (i * 10 / 100)){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [str(input()) for i in range(n)]
sorted_s = sorted(s)
count = 1
max = 1
ans_list = []
prev = sorted_s[0]
for i in sorted_s[1:]:
    if i == prev:
        count += 1
    else:
        if count > max:
            ans_list = [prev]
            max = count
        elif count == max:
            ans_list.append(prev)
        prev = i
        count = 1
if count > max:
    ans_list = [prev]
elif count == max:
    ans_list.append(prev)
for i in ans_list:
    print(i)

Measured memory_bytes: 22180
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            int i, j;
            if (H == 0 && W == 0) {
                break;
            }
            for (i = 0; i < H; i++) {
                for (j = 0; j < W; j++) {
                    if ((i + j) % 2 == 0) {
                        System.out.printf("#");
                    } else {
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
        sc.close();
    }
}


Measured memory_bytes: 61348
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,neg=0,mn=INT_MAX;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
        if(arr[i]<0)
            neg++;
        int cur=abs(arr[i]);
        mn=min(mn,cur);
    }
    ll sum=0,sub=0;
    if(neg%2)
    {

        sub=mn;
    }
    for(int i=0; i<n; i++)
        sum+=abs(arr[i]);
    sum-=sub*2;
    cout<<sum<<endl;


    return 0;
}


Measured memory_bytes: 4408
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static string str1;
    static string str2;
    static void Main(string[] args)
    {
        str1 = ReadLine();
        str2 = ReadLine();
        var dp = new int[str1.Length + 1, str2.Length + 1];
        var di = new int[str1.Length, str2.Length];
        for(var i=1;i<=str1.Length;i++)
            for(var j = 1; j<=str2.Length; j++)
                if(str1[i-1]==str2[j-1])
                {
                    dp[i, j] = dp[i - 1, j - 1] + 1;
                    di[i - 1, j - 1] = 0;
                }else if (dp[i - 1, j] >= dp[i, j - 1])
                {
                    dp[i, j] = dp[i - 1, j];
                    di[i - 1, j - 1] = 1;
                }else
                {
                    dp[i, j] = dp[i, j - 1];
                    di[i - 1, j - 1] = 2;
                }
        WriteLine(Make(str1.Length-1, str2.Length-1, di));
    }
    private static string Make(int m1,int m2,int[,] di)
    {
        if (m1 < 0 || m2 < 0) return "";
        if (di[m1, m2] == 0) return Make(m1 - 1, m2 - 1, di) + str1.Substring(m1, 1);
        else if (di[m1, m2] == 1) return Make(m1 - 1, m2, di);
        else return Make(m1, m2 - 1, di);
    }
}


Measured memory_bytes: 85456
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        String a = scan.next();
        boolean isAC = false;
        
        for(int i = 0; i < a.length()-1 ; i++){
          if(a.substring(i,i+1).charAt(0) == 'A' && a.substring(i+1,i+2).charAt(0) == 'C' ){
            isAC = true;
            break;
          }
        }
             
        if( isAC )System.out.println("Yes");
        else System.out.println("No");
	  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
using namespace std;

const int maxn = 10010;
stack<int> s;
int ans[maxn];

bool ask(int p, int q)
{
	string str;
	cout<<"? "<<p<<" "<<q<<endl;
	cin>>str;
	if (str == "Y") return true;
	else return false;
}
	
int main()
{
	int a,b,n;
	cin>>a>>b;
	n = a+b;
	if (b >= a) 
	{
		cout<<"Impossible"<<endl;
		return 0;
	}
	int need = b+1, honest;
	for (int i=0;i<n;i++)
	{
		if (s.empty()) s.push(i);
		else 
		{
			if (ask(s.top(),i)) s.push(i);
			else s.pop(), need--;
		}
		if ((int)s.size() >= need)
		{
			honest = s.top();
			break;
		}
	}
	
	for (int i=0;i<n;i++)
	{
		if (ask(honest,i)) ans[i] = 1;
		else ans[i] = 0;
	}
	cout<<"! ";
	for (int i=0;i<n;i++) cout<<ans[i];
	cout<<endl;
	return 0;
}


Measured memory_bytes: 724
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    double h, a; cin >> h >> a;
    cout << ceil(h/a) << endl;
}


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

int main(){
  int A,B,C ;
  cin >>A>>B>>C ;
  int ans=0 ;
  for(int i=0;i<C;i++){
    if(B >=A)
      B -=A ;
    else break;
    
    ans ++;
  }
  cout <<ans <<endl;
}

Measured memory_bytes: 256
n=int(input())
ans=10**9

for i in range(1,n):
    suma,sumb=0,0
    ii,jj=i,n-i
    while ii>0:
        suma+=ii%10
        ii//=10
    while jj>0:
        sumb+=jj%10
        jj//=10
    ans=min(ans,suma+sumb)
print(ans)
    


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


int main() {
    int n;
    cin>>n;
    int a[n], b[n], c[n-1];
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    rep(i,n-1) cin>>c[i];

    int ans = 0;
    rep(i,n){
        ans += b[a[i]-1];
        if(i<n-1 && (a[i+1] == a[i] + 1 )) ans += c[a[i]-1];
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		list.add(a);
		list.add(b);
		list.add(c);
		Collections.sort(list);
		Collections.reverse(list);
		int ans = Integer.parseInt(
				(String.valueOf(list.get(0)))+(String.valueOf(list.get(1)))
						);
		System.out.println(ans + list.get(2));
 	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順
// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
  int N, K, L; cin >> N >> K >> L;

  auto t1 = UnionFind(N);
  rep(i,K) {
    int p , q; cin >> p >> q;
    p--, q--;
    t1.merge(p,q);
  }
  auto t2 = UnionFind(N);
  rep(i,L) {
    int r,s; cin >> r >> s;
    r--, s--;
    t2.merge(r,s);
  }

  map<pair<int,int>,int> M;
  rep(i,N) {
    M[{t1.root(i),t2.root(i)}]++;
  }
  rep(i,N) {
    cout << M[{t1.root(i),t2.root(i)}] << " ";
  }
  cout << endl;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int r,d,x;

signed main() {
    cin >> r >> d >> x;
    rep(i,10) {
        x = x*r-d;
        cout << x << endl;
    }
}


Measured memory_bytes: 256
A=int(input())
B=int(input())
if A==1 and B==2 or A==2 and B==1:
  print(3)
elif A==3 and B==2 or A==2 and B==3:
  print(1)
elif A==1 and B==3 or A==3 and B==1:
  print(2)
  
  

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

using namespace std;

int main(){
  map<int, int> m;
  long long n;
  scanf("%lld", &n);
  int cnt = 1;
  while(1){
    if(m[n] != 0){
      printf("%d", cnt); return 0;
    }
    m[n] = cnt++;
    if(n % 2)
      n = n * 3 + 1;
    else
      n /= 2;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
#define pi pair<ll,ll>
using namespace std;
const int max_n = 2e5 + 3 ;
vector<int>adj[max_n] ;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    int n ;
    cin>> n;
    adj[1].pb(1) ;
    for(int i =2;i <= n; ++i){
		int x ;
		cin>> x ;
		adj[i].pb(x) ;
		adj[x].pb(i) ;
	}
	for(int i =1 ;i <=  n; ++i){
		
		cout<< adj[i].size() - 1<<endl;
    
    
    
}
    
    
    
    
}


Measured memory_bytes: 15216
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;



template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

int main() {
    int n, m, l;
    cin >> n >> m >> l;
    using P = pair<int, int>;
    vector<vector<P>> G(n);
    for (int i = 0; i < m; ++i) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--; b--;
        if(c <= l){
            G[a].emplace_back(b, c);
            G[b].emplace_back(a, c);
        }
    }
    vector<vector<P>> ans(n, vector<P>(n, {INF<int>, INF<int>}));
    for (int i = 0; i < n; ++i) {
        ans[i][i] = {0, 0};
        using tup = pair<pair<int, int>, int>;
        GPQ<tup> Q;
        Q.emplace(P{0, 0}, i);
        while(!Q.empty()){
            P cost; int x;
            tie(cost, x) = Q.top(); Q.pop();
            if(ans[i][x] < cost) continue;
            for (auto &&e : G[x]) {
                auto cost2 = cost;
                cost2.second += e.second;
                if(cost2.second > l){
                    cost2.second = e.second;
                    cost2.first++;
                }
                if(ans[i][e.first] <= cost2) continue;
                ans[i][e.first] = cost2;
                Q.emplace(ans[i][e.first], e.first);
            }
        }
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        cout << (ans[s][t].first == INF<int> ? -1 : ans[s][t].first) << "\n";
    }
    return 0;
}

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

int main(){

	int N;
	cin >> N;
    int cnt = 0;
  	
  	for(int i=0;i<=N;i++){
      	int digit = 0;
        int a = i;
    	while(a>0){
          a /= 10;
          digit++;
        }
    	if((digit % 2) == 1){
          cnt++;
        }
    }
    cout << cnt << endl;  	
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n+1);
  rep(i,n+1) {
    cin >> a.at(i);
  }
  vector<ll> b(n);
  rep(i, n) {
    cin >> b.at(i);
  }
  ll count = 0;
  rep(i, n){
    if (a.at(i) > b.at(i)){
      count += b.at(i);
    } else {
      if (a.at(i) + a.at(i+1) >= b.at(i)) {
        count += b.at(i);
        a.at(i+1) -= b.at(i) -a.at(i);
      } else {
        
        count += (a.at(i) + a.at(i+1));
        a.at(i+1) = 0;
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 1792
#include <vector>
#include <array>
#include <algorithm>
#include <iostream>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <assert.h>
#include <queue>
#include <deque>
#include <iomanip>
#include <numeric>
#include <fstream>

using namespace std;

typedef long long ll;
typedef long double ld;

#define fi first
#define se second

#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;

typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

bool ok(ll x) {
    ll d = 0;
    while (x > 0) {
        ++d;
        x /= 10;
    }
    return d % 2 == 1;
}

int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll n;
    cin >> n;
    vl h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    --h[0];
    for (int i = 1; i < n; ++i) {
        if (h[i] < h[i - 1]) {
            cout << "No" << endl;
            return 0;
        }
        if (h[i] > h[i - 1]) --h[i];
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>

#define ll long long
#define Int int
#define loop(x, start, end) for(Int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)

using namespace std;

#define MAX_N 100
#define MAX_INT (1 << 21)


Int prim(Int W[MAX_N][MAX_N], Int n) {
  Int parent[n], key[n];
  bool mst_set[n];
  
  loop(i,0,n) key[i] = MAX_INT, mst_set[i] = false;
  
  key[0] = 0, parent[0] = -1;
  
  // why n-1 ?
  loop(count,0,n-1) {
      Int u = -1;
      Int min_ = MAX_INT;
      loop(v,0,n) {
          if (mst_set[v] == false && key[v] < min_) {
              min_ = key[v], u = v;
          }
      }
      
      mst_set[u] = true;
      
      loop(v,0,n) {
          if (W[u][v] != MAX_INT && mst_set[v] == false && W[u][v] < key[v]) {
              parent[v] = u, key[v] = W[u][v];
          }
      }
  }

  Int sum = 0;
  loop(v,1,n) {
    sum += W[v][parent[v]];
  }

  return sum;
}


int main(void) {
  Int n, w;
  Int W[MAX_N][MAX_N];
  cin >> n;
  loop(x,0,n) {
    loop(y,0,n) {
      cin >> w;
      W[x][y] = W[y][x] = (w == -1) ? MAX_INT : w;
    }
  }

  cout << prim(W, n) << endl;
}



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

N = int(input())
S = [input() for i in range(N)]

print('AC x '+str(S.count('AC')))
print('WA x '+str(S.count('WA')))
print('TLE x '+str(S.count('TLE')))
print('RE x '+str(S.count('RE')))


Measured memory_bytes: 16204