akhauriyash/Code-Regression huggingface dataset:
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
k = ni()
x = list(li())

ans = 0
for xi in x:
    ans += 2 * min(xi, k-xi)
    
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  char now = '&';
  ll c = 0;
  for(int i=0;i<s.size();i++){
    if(now!=s[i]) now = s[i], c++;
  }
  std::cout << c-1 << '\n';
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d)<<endl;
}


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

int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)
        cout<<c<<endl;
    else if(b==c)
        cout<<a<<endl;
    else
        cout<<b<<endl;

    return 0;
}


Measured memory_bytes: 3648
h,w,k = map(int, input().split())
s = [list(input()) for _ in range(h)]
ans = 0
for row in range(2**h):
 for col in range(2**w):
   c = 0
   for i in range(h):
     for j in range(w):
       if (row >> i)&1 == 0 and (col >> j)&1 == 0:
         if s[i][j]=='#':
           c += 1
   if c == k:
     ans += 1
print(ans)

Measured memory_bytes: 8936
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long lo;
typedef pair< lo,lo > PII;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
 
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
 
lo n,m,b[li],a[li],k,flag,t;
lo cev;
string s;
vector<int> v;
 
int main(void){
	scanf("%lld",&n);
	n--;
	printf("%lld\n",(n+1)*n/2);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#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 {
#ifdef LOCAL
~debug() { cerr << endl; }
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 << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int nax = 200010;
int pr[nax], suff[nax];
int n, k, c;
string x;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> k >> c;
	cin >> x;
	assert((int)x.size() == n);
	REP(i, n) {
		if (i > 0) {
			pr[i] = pr[i - 1];
		}
		if (x[i] == 'o') {
			int nx = 1;
			if (i - c - 1 >= 0) {
				nx += pr[i - c - 1];
			}
			if (nx > pr[i]) {
				pr[i] = nx;
			}
		}
	}

	FORD(i, n, 0) {
		if (i + 1 < n) {
			suff[i] = suff[i + 1];
		}
		if (x[i] == 'o') {
			int nx = 1;
			if (i + c + 1 < n) {
				nx += suff[i + c + 1];
			}
			if (nx > suff[i]) {
				suff[i] = nx;
			}
		}
	}
	// REP(i, n) {
	// 	printf("%d: pr: %d, suff: %d\n", i, pr[i], suff[i]);
	// }
	REP(i, n) {
		int l = 0, r = 0;
		if (x[i] == 'x') {
			continue;
		}
		if (i > 0) {
			l = pr[i - 1];
		}
		if (i + 1 < n) {
			r = suff[i + 1];
		}
		if (l + r < k) {
			printf("%d\n", i + 1);
		}
	}
}

Measured memory_bytes: 3348
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <list>
#include <iomanip>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)
const int MAX_N = 1000000;
const Int MAX_N_Int = 1000000000000;

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}

bool isPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}


Int fact_mod(Int n, Int mod) {
    Int f = 1; repq(i,2,n) f = f * (i % MOD) % MOD;
    return f;
}

// 繰り返し二乗法 (modの世界での累乗)
Int mod_pow(Int x, Int n, Int mod) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

// 組み合わせ nCr を求める
Int combination_mod(Int n, Int r, Int mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    Int a = 1;
    rep(i, 0, r) a = a * ((n-i) % mod) % mod;
    Int b = mod_pow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}

int main() {
    //COMinit();
    IOS;
    prec;
    Int a,b,c,n,m,k,x,y=0,ans=1;
    string str,s="",t,u;
    cin>>x>>y;
    for (int i = 0; i <= 100; ++i) {
        for (int j = 0; j <=100 ; ++j) {
            if(2*i+4*j==y and i+j==x){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No";





    cout<<endl;
    return 0;
}




Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d; 
int main()
{
	cin>>a>>b>>c>>d;
	if(a+b>c+d) cout<<"Left"<<endl;
	if(a+b==c+d) cout<<"Balanced"<<endl;
	if(a+b<c+d) cout<<"Right"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

int main(void) {
  ll x;
  cin >> x;
  ll cur = 100;
  for(int i = 1; ; ++i) {
    cur += cur / 100;
    if(cur >= x) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3180
#include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <algorithm>
#define INF 1001001001001001001
using namespace std;
typedef long long ll;
typedef pair<int,int> pa;
typedef pair<ll,pa > ppa;

vector<pa> ve[2][100010];
int swi[2][200010];
ll res[2][200010],kar[2][200010];
int main(){
	int M,N,K;
	cin>>M>>N>>K;
	int a,b,aa=0;
	bool fla=false,fla2=false;
	for(int i=1;i<=K;i++){
		cin>>a>>b;
		ve[1][a].push_back(pa(i,b));
		ve[0][b].push_back(pa(i,a));
		swi[0][i]=a;swi[1][i]=b;
		if(a==1&&b==1){
			fla=true;
			aa=i;
		}
		if(a==M&&b==N){
			fla2=true;
		}
	}
	for(int i=0;i<2;i++){
		fill(res[i],res[i]+2+K,INF);
		fill(kar[i],kar[i]+2+K,INF);
	}

	priority_queue<ppa,vector<ppa>,greater<ppa> > que;
	for(vector<pa>::iterator it=ve[1][1].begin();it!=ve[1][1].end();it++){
		que.push(ppa(it->second-1,pa(1,it->first)));
	}
	if(fla){
		res[0][aa]=0;
	}
	int cnt=0;
	while(!que.empty()){
		ll dis=que.top().first;
		int yota=que.top().second.first;
		int ten=que.top().second.second;
		que.pop();
		if(res[yota][ten]<INF) continue;
		res[yota][ten]=dis;
		res[1-yota][ten]=dis+1;
		for(vector<pa>::iterator it=ve[1-yota][swi[yota][ten]].begin();it!=ve[1-yota][swi[yota][ten]].end();it++){
			int saki=it->first;int ba=it->second;
			ll hog=dis+1+abs(swi[1-yota][ten]-ba);
			if(kar[1-yota][saki]>hog&&res[1-yota][saki]==INF){
				que.push(ppa(hog,pa(1-yota,saki)));
				kar[1-yota][saki]=hog;
			}
		}
	}
	ll ress=INF;
	for(vector<pa>::iterator it=ve[0][N].begin();it!=ve[0][N].end();it++){
		ress=min(ress,res[1][it->first]+1+abs(M-it->second));
	}
	for(vector<pa>::iterator it=ve[1][M].begin();it!=ve[1][M].end();it++){
		ress=min(ress,res[0][it->first]+1+abs(N-it->second));
	}
	if(ress<INF) cout<<ress<<endl;
	else cout<<-1<<endl;
	return 0;
}

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

int main() {
    int N,M,a,onright,count,ans=0;
    cin >> N >> M;
    vector<int> k(M);
    vector<int> p(M);
    vector<vector<int>> s(M);
    std::vector<int>::iterator itr;
    for(int i=0;i<M;i++){
        cin >>k.at(i);
        for(int j=0;j<k.at(i);j++){
            cin >> a;
            s.at(i).push_back(a);
        }
    }   
    for(int i=0;i<M;i++)
        cin >> p.at(i);
    

    for (int bit = 0; bit < (1<<N); ++bit) {
        vector<int> S;
        count=0;
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                S.push_back(i+1);
            }
        }
        for(int i=0;i<M;i++){
            onright=0;
            for (int j = 0; j < (int)S.size(); ++j) {
                itr = std::find(s.at(i).begin(), s.at(i).end(), S.at(j));
                if(itr == s.at(i).end()){
                }
                else{
                    onright++;
                }
            }
            if(onright%2==p.at(i))
                count++; 
        }
        if(count==M)
            ans++;
    }

    cout << ans <<endl;

}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;

int main(){
	int n;
	string s;
	std::cin >> n;
	std::cin >> s;
	int counter=0;
	rep(i,n-1){
		if(s[i]==s[i+1])counter++;
	}
	std::cout << n-counter << std::endl;
}



Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<cstdio>
#include<climits>

#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
#define INF 1000000007
#define MOD 1000000007

#define ARRAY_MAX 100005

int d[ARRAY_MAX];

int main(){

    int a,b,c;
    cin >> a >> b >> c;
    int ans = 0;
    if(c >= b){
        ans += 2*b;
        c -= b;
        b = 0;
    }else{
        ans += 2*c+(b-c);
        b = 0;
        c = 0;
    }

    if(c >= a){
        ans += a;
        c -= a;
        a = 0;
    }else{
        ans += c;
        a -= c;
        c = 0;
    }

    if(c > 0){
        ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    n, k, *x = map(int, open(0).read().split())
    d = 2 * 10 ** 9
    for i, j in zip(x, x[k - 1:]):
        d = min(d, j - i + min(abs(i), abs(j)))
    print(d)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14052
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+10;
int n, m, fac[N], ifac[N];

int C(int n, int m) {
	if (n<m) return 0;
	return fac[n]*(ll)ifac[m]%P*ifac[n-m]%P;
}

int main() {
	fac[0]=1;
	REP(i,1,N-1) fac[i]=(ll)fac[i-1]*i%P;
	ifac[N-1]=inv(fac[N-1]);
	PER(i,0,N-2) ifac[i]=(ll)ifac[i+1]*(i+1)%P;
	scanf("%d%d", &n, &m);
	int ans = 1;
	for (int i=2; i*i<=m; ++i) {
		int cnt = 0;
		while (m%i==0) m/=i,++cnt;
		ans = (ll)ans*C(n+cnt-1,cnt)%P;
	}
	if (m>1) ans = (ll)ans*n%P;
	printf("%d\n", ans);
}









Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

int32_t main(){_
      
   string s;
   cin >> s;
   
   n = (int)(s.size());

   if (s[2] == s[3] and s[4] == s[5]){
      cout<<"Yes";
   }
   else{
      cout<<"No";
   }
   

   return 0;
}

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

const int N = 200000 + 10;
ll n, q, f[N][20], col[N], len[N], sum[N];
ll d[N], sz[N], son[N], pos[N];
ll top[N], id[N], df;
vector <ll> g[N];
vector <ll> bels[2][N];

void link(ll u, ll v) {
	g[u].push_back(v);
	g[v].push_back(u);
}

void dfs1(ll u, ll pre) {
	f[u][0] = pre; d[u] = d[pre] + 1; sum[u] = sum[pre] + len[u]; sz[u] = 1;
	for(int i = 1; i <= 18; i++) {
		if(f[f[u][i - 1]][i - 1]) f[u][i] = f[f[u][i - 1]][i - 1];
		else break;
	}
	for(int i = 0; i < g[u].size(); i++) {
		int v = g[u][i]; if(v == pre) continue;
		dfs1(v, u); sz[u] += sz[v];
		if(!son[u] || sz[v] > sz[son[u]]) son[u] = v;
	}
}
int lca(int u, int v) {
	if(d[u] < d[v]) swap(u, v);
	for(int i = 19; i >= 0; i--) if(d[u] - (1 << i) >= d[v]) u = f[u][i];
	if(u == v) return u;
	for(int i = 19; i >= 0; i--) if(f[u][i] != f[v][i]) u = f[u][i], v = f[v][i];
	return f[u][0];
}
void dfs2(ll u, ll t) {
	top[u] = t, id[u] = ++df; pos[df] = u;
	if(son[u]) dfs2(son[u], t);
	for(int i = 0; i < g[u].size(); i++) {
		int v = g[u][i];
		if(v == f[u][0] || v == son[u]) continue;
		dfs2(v, v);
	}
}

ll Bs1(int x, int t) {
	int l = 0, r = bels[0][x].size() - 1;
	ll ans = -1;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(bels[0][x][mid] <= t) ans = mid, l = mid + 1;
		else r = mid - 1;
	}
	return ans;
}
ll BinarySearch(int x, int t) {
	int l = 0, r = bels[1][x].size() - 1;
	ll ans = -1;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(bels[0][x][mid] <= t) ans = mid, l = mid + 1;
		else r = mid - 1;
	}
	if(ans == -1) return 0;
	return bels[1][x][ans];
}
pair <ll, ll> bsearch(int u, int v, int po) {
	if(bels[0][po].empty()) return make_pair(0, 0);
	ll A = Bs1(po, v) - Bs1(po, u - 1);
	ll C = BinarySearch(po, v), D = BinarySearch(po, u - 1);
	return make_pair(A, C - D);
}
pair <ll, ll> Query(int u, int v, int c) {
	pair <ll, ll> t; t.first = 0, t.second = 0;
	while(top[u] != top[v]) {
		if(d[top[u]] < d[top[v]]) swap(u, v);
		pair <ll, ll> te = bsearch(id[top[u]], id[u], c);
		t.first += te.first, t.second += te.second;
		u = f[top[u]][0];
	}
	if(id[u] > id[v]) swap(u, v);
	pair <ll, ll> te = bsearch(id[u], id[v], c);
	t.first += te.first, t.second += te.second;
	return t;
}
signed main(){
	scanf("%lld%lld", &n, &q);
	for(ll i = 1, u, v, c, d; i < n; i++) {
		scanf("%lld%lld%lld%lld", &u, &v, &c, &d);
		link(u, n + i);
		link(v, n + i);
		col[n + i] = c, len[n + i] = d;
	}
	dfs1(1, 0); dfs2(1, 1);
	for(int i = 1; i <= 2 * n - 1; i++) bels[0][col[pos[i]]].push_back(i),bels[1][col[pos[i]]].push_back(len[pos[i]]);
	for(int i = 1; i <= n - 1; i++) 
		for(int j = 1; j < bels[1][i].size(); j++) bels[1][i][j] += bels[1][i][j - 1];
	
	while(q--) {
		int x, y, u, v;
		scanf("%lld%lld%lld%lld", &x, &y, &u, &v);
		pair <ll, ll> ans = Query(u, v, x);
		//fprintf(stderr, "%lld, %lld\n", ans.first, ans.second);
		ll ans1 = sum[u] + sum[v] - 2 * sum[lca(u, v)];
		ll ans2 =  - ans.second + 1ll * y * ans.first;
		//printf("%lld %lld\n", ans1, ans2);
		printf("%lld\n", ans1 + ans2);
	}
	return 0;
}




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

int people[4][3][10];

int main(){
	int n;
	scanf("%d", &n);
	int b, f, r, v;
	for(int i = 0; i < n; i++) {
		scanf("%d%d%d%d", &b, &f, &r, &v);
		people[b-1][f-1][r-1] += v;
	}
	for(int i = 0; i < 4; i++) {
		for(int j = 0; j < 3; j++) {
			for(int k = 0; k < 10; k++) {
				printf(" %d", people[i][j][k]);
			}
			printf("\n");
		}
		if(i != 3) printf("####################\n");
	}
}



Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <queue>

#define MAX 100000
using namespace std;
typedef pair<int,int> p;
vector<p> edge[MAX+1];
bool visited[MAX+1];
bool label[MAX+1];

void iter(int v,bool color){
  for(int i=0;i<edge[v].size();i++){
    p item = edge[v][i];
    //cout << v << " " << item.first << " " << item.second << endl;
    if(visited[item.first]){
      visited[item.first] = false;
      //cout << item.first << endl;
      if(item.second % 2 == 0){
	label[item.first] = color;
	iter(item.first,color);
      }else{
	label[item.first] = !color;
	iter(item.first,!color);
      }
    }
  }
  return;
}

int main(void){
  int N;
  cin >> N;
  for(int i=0;i<N-1;i++){
    int u,v,w; 
    cin >> u >> v >> w;
    edge[u].push_back(make_pair(v,w));
    edge[v].push_back(make_pair(u,w));
  }
  for(int i=1;i<=N;i++){
    visited[i] = true; 
  }
  label[1] = true;
  visited[1] = false;
  //cout << "set up" << endl;
  iter(1,true);
  for(int i=1;i<=N;i++){
    if(label[i]){
      cout << 1 << endl;
    }else{
      cout << 0 << endl;
    }
  }
  return 0;
}


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

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1] * (n + 1)
        self.rnk = [0] * (n + 1)

    def Find_Root(self, x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]

    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if x == y:
            return
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1

    def roots(self):
        return [i for i, x in enumerate(self.root) if x < 0]

    def group_count(self):
        return len(self.roots())


def main():
    n, m = map(int, input().split())
    UF = UnionFind(n)
    for _ in range(m):
        a, b = map(int, input().split())
        UF.Unite(a, b)

    print(UF.group_count() - 2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 13356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
std::vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
#define size_t ll
const int mod = 1000000007;
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
ll n,m; ll ans=0;
int main(){
  cin >> n >> m;
  for (ll i = 1; pow(i,2) <= m; i++) {
    if(m%i != 0)continue;
    if(i <= m/n)ans = max(i,ans);
    if((m/i) <= (m/n))ans = max(m/i,ans);
  }
  cout << ans << endl;
}


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

template <class T> void readVal(vector<T>& vec, int idx) {
    T input;
    std::cin >> input;
    vec[idx] = input;
}

int main()
{
    int size;
    cin >> size;
    vector<int> x(size); 
    vector<int> y(size);
    for (int i = 0; i < size; i++) {
        readVal(x, i);
        readVal(y, i);
    }
    int ans(1), dir(0), vecx(0), vecy(0), new_vecx(0), new_vecy(0);
    for (int i = 0; i <= size; i++) {
        new_vecx = x[(i + 1) % size] - x[i % size];
        new_vecy = y[(i + 1) % size] - y[i % size];
        int cross_prod = (vecx * new_vecy - vecy * new_vecx);
        if (cross_prod != 0) {
            if (cross_prod * dir >= 0) {
                dir = cross_prod > 0 ? 1 : -1;
            }
            else {
                ans = 0;
                break;
            }
        }
        vecx = new_vecx;
        vecy = new_vecy;
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 
  
  string s;
  cin >> s;

  int res = 0;
  int a = s.size(), z = 0;

  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'A') {
      a = min(a, i);
    }
    if (s[i] == 'Z') {
      z = max(z, i);
    }
  }

  cout << z - a + 1 << "\n";
}


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

#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;

ll combi(ll n, ll k) {
  map<string, ll> memo;
  if (n == k || k == 0)
    return 1;
  else {
    string key = to_string(n) + to_string(k);
    if (memo.count(key) != 0) {
      return memo[key];
    } else {
      ll out = combi(n - 1, k - 1) + combi(n - 1, k);
      memo[key] = out;
      return out;
    }
  }
}

int main(){
  ll n, m;
  cin >> n >> m;	//nぐ　mき
  
  ll a, b;
  
  if(n < 2)
    a = 0;
  else
    a = combi(n, 2);
  
  if(m < 2)
    b = 0;
  else
    b = combi(m,2);
  cout << a + b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x1,x2,y1,y2;
    int w,a,b;
    cin>>w>>a>>b;
    x1=a;
    y1=w+a;
    x2=b;
    y2=w+b;
    if(x1<=x2 && y1>=x2 || x1<=y2 && y1>=y2)
    {
        cout<< 0 <<endl;
    }
    else if(x1>x2)
    {
        cout<<abs(x1-y2)<<endl;
    }
    else if(x1<x2)
    {
        cout<<abs(y1-x2)<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

ll t[1000];
ll a[1000];

int main()
{
	int n;
	ll ans=0;
	
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>t[i]>>a[i];
	
	for(int i=1;i<n;i++)
	{
		ll tt=t[i];
		ll aa=a[i];
		//逆転の解消
		ll mul=max(t[i-1]/t[i]+(t[i-1]%t[i]>0),a[i-1]/a[i]+(a[i-1]%a[i]>0));
		//cerr<<mul<<endl;
		t[i]*=mul;
		a[i]*=mul;

		//得票数を求める
		while(t[i]<t[i-1] && a[i]<a[i-1])
		{
			t[i]+=tt;
			a[i]+=aa;
		}
	}
	ans=t[n-1]+a[n-1];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long

int num[100005];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, q, t, i;
    ll sum = 0;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> t;
        num[t]++;
        sum += t;
    }
    cin >> q;
    while(q--){
        int b, c;
        cin >>b >> c;
        num[c] += num[b];
        sum += (c - b) * num[b];
        num[b] = 0;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 4000
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> p;
typedef vector<pair<ll, ll>> vpl;

bool getbool(char c){
    if(c == '0') return false;
    else return true;
}
int main(){
    ll n; cin >> n;
    vl a(n);
    ll sum=0;
    double heikin;
    rep(i,n) {
        cin >> a[i];
        sum += a[i];
    }
    heikin = sum / (double)n;
    heikin = round(heikin);
    ll ans = 0;
    rep(i,n){
        ans += (a[i]-heikin)*(a[i]-heikin);
    }
    cout << ans << "\n";
}

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

#define   M             100005
#define   ll            long long
#define   PI            atan(1.0)*4
#define   mst(x,v)      memset(x,v,sizeof(x))
#define   inf           (int)1e9
#define   rush()        int T;scanf("%d",&T);while(T--)

typedef   pair<int,int> P;


int main() {

	ll x,y,temp;
	scanf("%lld %lld",&x,&y);
	
	temp=x;
	
	if(x%y==0) {
		puts("-1");
		return 0;
	}
	
	while(1) {
		x+=temp;
		if(x%y!=0) break;
	}
	
	printf("%lld\n",x);
}



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




int main()
{
    int n,W;
    cin>>n>>W;
    vector<int> arr(n),val(n);

    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        cin>>val[i];
    }
    //input part has been done
    long long int dp[n+1][W+1];
     memset(dp,-1,sizeof(dp));
     memset(dp,0,sizeof(dp));
     for(int i=0;i<n;i++)
     {
         for(int j=0;j<=W;j++)
         {
             if(j+arr[i]<=W)
             {
                 dp[i+1][j+arr[i]]=max(dp[i+1][j+arr[i]],dp[i][j]+val[i]);
                 dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
             }
             else
                dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
         }
     }
     cout<<dp[n][W];


}


Measured memory_bytes: 82524
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int v[N],memo[N];
int main(){
	int n;cin>>n;
	if(n==2){
		int x,y;cin>>x>>y;
		cout<<abs(x-y);return 0;
	}
	long long ans=0LL;

	for(int i=1;i<=n;i++){
		cin>>v[i];
		if(i==1)memo[i]=0;	
		else if(i==2)memo[i]=abs(v[i]-v[i-1]);
		
		else{
			memo[i]=min(memo[i-1]+(abs(v[i]-v[i-1])),memo[i-2]+(abs(v[i]-v[i-2])));					
		}
	}
	cout<<memo[n];
	return 0;
}

Measured memory_bytes: 4352
using System;

class Project4
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int H1 = int.Parse(input[0]);
        int M1 = int.Parse(input[1]);
        int H2 = int.Parse(input[2]);
        int M2 = int.Parse(input[3]);
        int K = int.Parse(input[4]);

        int h1 = H1 * 60;
        int h2 = H2 * 60;
        int Ans = (h2 + M2) - (h1 + M1) - K;
        Console.WriteLine(Ans);
        
    }
}

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

int main() {
  int a;
  int b;
  cin>>a>>b;
  int e=a*b;
  int d=e%2;
  if(d==0){
    cout<<"Even"<<endl;
  }else{
    cout<<"Odd"<<endl;}
  
}

















Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long int ll;


int main()
{
	ll a, b;
	cin >> a >> b;
	ll diff = b - a;
	ll sum = 0;
	for (ll i = 1; i <= (diff - 1); i++) {
		sum += i;
	}
	cout << sum - a << endl;
	return 0;
}

Measured memory_bytes: 3164
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
typedef pair<int,int> pii;
#define mp make_pair
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
int main()
{
	char ch;
	scanf("%c",&ch);
	printf("%c\n",ch+1);
	return 0;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef unsigned long long ull;
typedef long double ld; 
typedef tuple<int,int,int> State;

ll mod = 1e9 + 7;

#define citc(tc) int tc; cin>>tc; while(tc--){solve();}
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vl a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;

void solve()
{
	ll a, b;
	cin>>a>>b;
	ll ma = max(a, b);
	ll mi = min(a, b);
	rep(i, ma)
		cout<<mi;
}
int main()
{
	fastio();
	// citc(tc);
	solve();
}

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

int n, x, ans[400000];
int main()
{
	int i, j;
	cin >> n >> x;
	if (x == 1 || x == 2 * n - 1) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	ans[n] = x;
	ans[n - 1] = x - 1;
	ans[n + 1] = x + 1;
	j = 1;
	for (i = 1; i <= n * 2 - 1; i++) {
		if (j == x - 1) j = x + 2;
		if (ans[i] == 0) {ans[i] = j; j++;}
	}

	for (i = 1; i <= n * 2 - 1; i++) {
		printf("%d\n", ans[i]);
	}
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPII;
typedef vector<VI> VVI;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef pair<LL,LL> PLL;
typedef double LD;
#define FI first
#define SE second
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define ZERO(m) memset(m,0,sizeof(m))
#define ALL(x) (x).begin(), (x).end()
#define MINUS(m) memset(m,-1,sizeof(m))
#define RALL(x) (x).rbegin(), (x).rend()
#define FOR(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define FORE(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((LD)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif

  int n;cin >> n;
  int V[n+1][n+1];
  ZERO(V);
	FOR1(i,n){
		string g;cin >> g;
		FOR(j,n) if(g[j]=='1') V[i][j+1] = 1;
	}
	VI cr;
	int VIS[n+1];
	int as = -1;
	FOR1(i,n){
		ZERO(VIS);
		cr.clear();cr.PB(i);
		int z = 1;
		while(1){
			VI crr;
			for(int j:cr){
				if(VIS[j]==2){
					z=-1;
					break;
				}
				FOR1(k,n) if(V[j][k]&&!VIS[k]) crr.PB(k),VIS[k]=2;
			}
			if(z==-1) break;
			if(crr.empty()) break;
			z++;
			for(int j:crr) VIS[j] = 0;
			for(int j:cr) VIS[j] = 1;
			swap(cr,crr);
		}	
		umax(as,z);
	}
	cout << as << endl;

  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll A[200010];

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

  rep( i, N )
    std::cin >> A[i];

  std::sort( A, A+N );
  std::reverse( A, A+N );

  std::vector<ll> vs;

  ll c = 1, p = 1;
  ll ans = A[0];

  while( c < N-1 ) {
    ll prvc = c;

    c += 2;

    if( c > N-1 )
      --c;

    ans += A[p]*(c-prvc);
    ++p;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 5184
#include <bits/stdc++.h>
#define REP(a, b) for(int a = 0; a < b; a++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define mp make_pair
#define f first
#define s second
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> LL;
typedef vector<int> vi;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 100;

vi v[MAXN];
int n, m;
int maks = 0;
int DP[MAXN];

int rek(int now) {
	int &ret = DP[now];
	if (ret != -1) return ret;
	ret = 0;
	REP(i, v[now].size()) {
		ret = max(ret, 1 + rek(v[now][i]));
	}
	maks = max(maks, ret);
	return ret;
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	while(m--) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		v[a].pb(b);
	}
	memset(DP, -1, sizeof DP);
	REP(i, n) if (DP[i] == -1) rek(i);
	cout << maks << '\n';
}

Measured memory_bytes: 8192
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;

const int N=1e6+1;

ll a[101];

int main()
{
	ll k;
	cin>>k;
	if(k<=2ll*1e16)
	{
		if(!(k&1))
		{
			ll a1=k/2ll+1ll,a2=k/2ll+1ll;
			cout<<2<<endl<<a1<<" "<<a2;
		}
		else
		{
			ll a1=k/2ll+1ll,a2=k/2ll+1ll;
			a1+=2ll;a2-=1ll;;
			cout<<2<<endl<<a1<<" "<<a2;
		}
	}
	else
	{
		cout<<50<<endl;
		for(int i=1;i<=50;++i)a[i]=k/50ll;
		ll ret=k%50;
		if(!ret)
		{
			for(int i=1;i<=50;++i)cout<<a[i]+49<<" ";
			return 0;
		}
		for(ll i=49;i>=1;--i)
			if(ret%i==0ll)
			{
				for(int j=1;j<=i;++j)
					a[j]+=51ll*ret/i;
				for(int j=1;j<=50;++j)
					a[j]-=i;
				for(int j=1;j<=50;++j)
					cout<<a[j]+49<<" ";
				return 0;
			}
	}
}

Measured memory_bytes: 256
//wawando's template

#include <iostream>
#include <string>
#include <fstream>
#include <functional>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <set>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>  //clock_t , clock() , CLOCKS_PER_SEC
#include <cstring>
#include <cctype>
#include <climits> // LLONG_MAX , LLONG_MIN , INT_MAX , INT_MIN

//MACROS
#define pb              push_back
#define mp              make_pair
#define INF             1000000000     //1 billion safer for floyd warshall, avoid overflow

using namespace std;

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

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(0);

  int X,A;
  cin >>X >>A;
  if(X < A) cout <<"0" <<endl;
  else cout <<"10" <<endl;
  
  return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vll;

int main() {
    ll n;
    cin >> n;
    vll nums(n);
    ll ans = 0;
    ll a, b;
    for (int i = 0; i < n; ++i) {
        cin >> a >> b;
        ans -= b;
        nums[i] = a + b;
    }
    sort(nums.begin(), nums.end());
    reverse(nums.begin(), nums.end());
    for (int i = 0; i < n; ++i) {
        if (i % 2 == 0) {
            ans += nums[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>

using namespace std;
using ll=long long;

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

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  int x,t;
  cin>>x>>t;
  x-t>0 ? cout<<x-t<<endl : cout<<0<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-3;
long double pi = acos(-1);

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

    ll a;
    long double b;
    cin>>a>>b;
    ll s = b*100.0+eps;
    a *= s;
    a /= 100;
    cout << a << endl;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
typedef long long ll;
const ll MOD = 1e9+7;

/*ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}*/
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

/*ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}*/

int main(){
  int n; cin >> n; string s;
  set<string> D;
  rep(i, n){
    cin >> s;
    D.insert(s); 
  }
  int c = D.size();
  cout << c << endl;

}

Measured memory_bytes: 19180
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){
  map <ll, ll> sum_l;
  int N; cin >> N;
  vector <ll> A(N);
  rep(i, N) cin >> A[i];
  ll sum = 0;
  rep(i, N){
    sum +=A[i];
    sum_l[sum]++;
  }
  ll ans = 0;
  for (auto itr = sum_l.begin(); itr != sum_l.end(); itr++){
    ans += itr->second*(itr->second-1)/2;
    if (itr->first == 0){
      ans += itr->second;
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 17064
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<vector>
#include<map>
#include<queue>

#define N 300005
#define M 8000005

#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)

#define mk make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

int i,j,m,n,p,k,cnt[N];

char s[N];

long long ans;

int main()
{
		scanf("%s",s+1); n=strlen(s+1);
		ans=1ll*n*(n-1)/2; 
		for (i=1;i<=n;++i)
		{
				ans-=cnt[s[i]]; cnt[s[i]]++; 
		}
		cout<<ans+1<<endl;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  int t, a;
  ll x = 1, y = 1;
  for (int i = 0; i < n; i++) {
    cin >> t >> a;
    ll d = max((x+t-1)/t, (y+a-1)/a);
    x = t * d;
    y = a * d;
  }
  cout << x + y << endl;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
	cin >> S;
	int ans = 0;
	rep(i, S.size() - 1) {
		if (S.at(0)) {
			if (S.at(i) == S.at(i + 1)) {
				if (S.at(i) == '0') S.at(i + 1) = '1';
				else S.at(i + 1) = '0';
				ans++;
			}
		}
		else {
			if (S.at(i) == S.at(i + 1)) {
				if (S.at(i) == '0') S.at(i + 1) = '1';
				else S.at(i + 1) = '0';
				ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(0,(a+1)*500,500):
    for j in range(0,(b+1)*100,100):
        for k in range(0,(c+1)*50,50):
            if i+j+k == x:
                ans += 1
print(ans)

Measured memory_bytes: 39536
#include<iostream>
#include<set>
using namespace std;
int par[100007];
int find(int i){
	if(i != par[i]) return par[i] = find(par[i]);
	else return par[i];
}
void setPar(int a,int b){
	par[find(a)] = find(b);
}
int main(){
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	for(int i = 1;i <= n;++i) par[i] = i;
	for(int i = 0;i < m;++i){
		int a,b;cin >> a >> b;
		setPar(a,b);
	}
	set<int> xx;
	for(int i = 1;i <= n;++i) xx.insert(find(i));
	cout << xx.size()-1;
	return 0;
}

Measured memory_bytes: 7436
import scala.io.StdIn.{readLine,readInt}

object Main extends App {
  val seq1 = for(i<-1 to 9) yield List(i,i,i)
  val seq2 = for(i<-1 to 7) yield List(i,i+1,i+2)

  def check(m:List[Int], count:Int):Boolean =  {
    if(m.length != count) false
    else if(count==2) {
      val List(x,y) = m
      if(x==y) true else false
    } else {
      if((0 to 8).exists( i=> check(m diff seq1(i),count-3))) {
        true
      } else {
        (0 to 6).exists(i=> check(m diff seq2(i),count-3) )
      }
    }
  }

  Iterator.continually(readLine).takeWhile ( _!=null ).foreach { line =>
    val l = line.map(_.asDigit).toList
    val m = (1 to 9).filter { i=> if(l.count( _==i ) >= 4) false else check(i::l,14) }
    if(m.length>0) println(m.mkString(" ")) else println(0)
  }
}

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

using namespace std;

#define ar array
#define ll long long

const int MAX_N = 1e5 + 1;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;



void solve() {
    string s; cin >> s;
    if (s[s.size() - 1] == 's') cout << s + "es";
    else cout << s + "s";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int tc; tc = 1;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    vector<char> s(10);
    for (int i = 0; i < 10; i++) {
        cin >> s.at(i);
    }
    s.at(3) = '8';
    for (int i = 0; i < 10; i++) {
        cout << s.at(i);
    }
    cout << endl;
}

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

int main()
{
  int n,m,l;
  long long A[N][N],B[N][N],C[N][N];

  cin >> n >> m >> l;
  for(int i=0;i<n;i++)
    {
      for(int j=0;j<m;j++)
        {
          cin >> A[i][j];
        }
    }
  for(int i=0;i<m;i++)
    {
      for(int j=0;j<l;j++)
        {
          cin >> B[i][j];
        }
    }
  for(int i=0;i<n;i++)
    {
      for(int j=0;j<l;j++)
        {
          C[i][j]=0;
          for(int k=0;k<m;k++)
            {
              C[i][j]+=A[i][k]*B[k][j];
            }
        }
    }
  for(int i=0;i<n;i++)
    {
      for(int j=0;j<l;j++)
        {
          if(j) cout << " ";
          cout << C[i][j];
        }
      cout << endl;
    }
  return 0;
}

Measured memory_bytes: 3316
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#define re register
using namespace std;
typedef long long ll;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

int a[200010];

int main() {
    int n=read(),k=min(n,read());
    for (re int i=1;i<=n;++i) a[i]=read();
    sort(a+1,a+n+1); reverse(a+1,a+n+1);
    ll ans=0;
    for (re int i=k+1;i<=n;++i) ans+=a[i];
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024