akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;
struct UF
{
	vector<int> par; // 親のインデックスを記憶する配列
	vector<int> sz; // サイズを記憶する。
	vector<int> rank;
	// 初期化
	UF(int n):par(n),sz(n),rank(n){
		for(int i = 0; i < n; i++){
			par[i] = i;sz[i] = 1;rank[i] = 0;
		}
	}
	// 親を求める
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	// xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if(rank[x] < rank[y]){
			par[x] = y;
			sz[y] += sz[x];
		}
		else{
			par[y] = x;
			sz[x] += sz[y];
			if(rank[x] == rank[y])rank[x]++;
		}
	}
	// xとyが同じ集合ならtrue
	bool same(int x, int y) { return find(x) == find(y); }
	// 素の集合のサイズを求める
	int size(int n){return sz[find(n)];}
};


bool check(vector<ll> a, vector<ll> b) {
	sort(ALL(a));
	sort(ALL(b));
	REP(i, a.size()){
		if(a[i] != b[i])return false;
	}
	return true;
}

void add_xor(vector<ll> &v) {
	int tmp = 0;
	REP(i, v.size())tmp ^= v[i];
	v.PB(tmp);
}

void compression(vector<ll> &a, vector<ll> &b) {
	vector<int> v;
	REP(i, a.size())v.PB(a[i]);
	REP(i, b.size())v.PB(b[i]);
	sort(ALL(v));
	v.erase(unique(ALL(v)), v.end());
	REP(i,a.size())a[i] = lower_bound(ALL(v), a[i]) - v.begin();
	REP(i,b.size())b[i] = lower_bound(ALL(v), b[i]) - v.begin();
}

int seica(vector<ll> a, vector<ll> b) {
	int ret = 0;
	add_xor(a);
	add_xor(b);
	if(!check(a, b))return -1;
	compression(a, b);

	UF uf(a.size());
	REP(i, (int)a.size() - 1){
		if(a[i] != b[i])ret++;
		uf.unite(a[i], b[i]);
	}

	vector<bool> used(a.size(), false);

	REP(i, a.size()){
		int now = uf.find(a[i]);
		if(i == (int)a.size() - 1 && uf.size(now) > 1)ret--;
		if(used[now] || uf.size(now) == 1)continue;
		used[now] = true;
		ret++;
	}

	return ret;
}

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

	int n;cin >> n;
	vector<ll> a(n);REP(i, n)cin >> a[i];
	vector<ll> b(n);REP(i, n)cin >> b[i];

	cout << seica(a, b) << endl;

	return 0;
}


Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

class SegmentTree{
public:
    ll N; 
    vector<ll> data, tree;
    SegmentTree(vector<ll> v, ll u){
        data = v;
        ll n = data.size();
        N = 1;
        while(N<n)N*=2;
        tree = vector<ll>(N*2,u);
        build();
    }
    void build(){rep(i,N)update(i,data[i]);}
    void update(ll i, ll x){
        i += N-1;
        tree[i]=x;
        while(i){
            i = (i-1)/2;
            tree[i]=merge(tree[i*2+1],tree[i*2+2]);
        }
    }
    ll query(ll start, ll end){return query(start, end, 0, 0, N);}
private:
    ll query(ll a, ll b, ll k, ll l, ll r){
        if(r<=a||b<=l)return INF;
        if(a<=l&&r<=b)return tree[k];
        else{
            ll lv = query(a,b,2*k+1,l,(l+r)/2);
            ll rb = query(a,b,2*k+2,(l+r)/2,r);
            return merge(lv,rb);
        }
    }
    ll merge(ll l, ll r){
        return min(l,r);
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,q;cin>>n>>q;
    SegmentTree st(vector<ll>(n,(1LL<<31)-1), INF);
    rep(i,q){
        ll c,x,y;cin>>c>>x>>y;
        if(!c) st.update(x,y);
        else cout<<st.query(x,y+1)<<endl;
    }
    return 0;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k-1] = tolower(s[k-1]);
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { int to, cost; };

int y(int a) {
	int res = 0;
	rep(i, a) {
		if (a % (i + 1) == 0)res++;
	}
	return res;
}

signed main() {
	int n; cin >> n;
	int ans = 0;
	for(int i=1;i<=n;i+=2) { if (y(i) == 8)ans++; }
	cout << ans << endl;
}


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

double dp[305][305][305];
bool check[305][305][305];

double n;
double calc(ll a,ll b,ll c){
    if (check[a][b][c]==true){
    //  cout<<"true"<<endl;
        return dp[a][b][c];
    }
  double p0=double((n-a-b-c)/n);
  double p1=double(a/n);
  double p2=double(b/n);
  double p3=double(c/n);

  double now=1;
  //cout<<n<<"n"<<(n-a-b-c)<<"a"<<endl;
  if (a>0)now+=p1*calc(a-1,b,c);
  if (b>0)now+=p2*calc(a+1,b-1,c);
  if (c>0)now+=p3*calc(a,b+1,c-1);
//  cout<<now<<"now"<<p0<<"p0"<<endl;
  dp[a][b][c]=double(now/(1-p0));
  check[a][b][c]=true;
  //cout<<dp[a][b][c]<<"a"<<a<<"b"<<b<<"c"<<c<<endl;
    return dp[a][b][c];

}

int main() {
  cin>>n;
  vector<ll> a(n);
  vector<ll> c(3,0);

  rep(i,n){
    cin>>a[i];
    if (a[i]==1)c[0]++;
    if (a[i]==2)c[1]++;
    if (a[i]==3)c[2]++;
  }
//  dp[0][0][0]=0;

    rep(i,305)rep(j,305)rep(k,305){
    dp[i][j][k]=0;
    check[i][j][k]=false;
}
  check[0][0][0]=true;
rep(i,c[0]+1)rep(j,c[1]+1)rep(k,c[2]+1){
  dp[i][j][k]=calc(i,j,k);
  check[i][j][k]=true;
}
//cout<<c[0]<<endl;

cout<<setprecision(10)<<dp[c[0]][c[1]][c[2]];
}


Measured memory_bytes: 253152
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7
MAX = 10**18
MIN = -10**18

n,l = map(int,input().split())
S = [input() for i in range(n)]
S.sort()
ans = ""
for i in S:
    ans += i
print(ans)

Measured memory_bytes: 3316
#-*-coding:utf-8-*-

def main():
    A, B, C, X, Y = list(map(int, input().split()))

    ABset = 2 * C
    min_price = 0

    #ABsetのほうがA,Bを個別に買うより安い場合
    if ABset <= A + B:
        if X >= Y:
            min_price += ABset * Y
            min_price += min(A * (X - Y), ABset * (X - Y))
        if X < Y:
            min_price += ABset * X
            min_price += min(B * (Y - X), ABset * (Y - X))
    else:
        min_price += A * X + B * Y

    print(min_price)

if __name__ == '__main__':
    main()

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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  vector<int> p(N);
  for (int i = 0; i < N; i++) cin >> s[i] >> p[i];

  map<string, vector<int>> m;
  for (int i = 0; i < N; i++) m[s[i]].push_back(p[i]);
  vector<int> ans;
  for (auto it = m.begin(); it != m.end(); it++) {
    string name = it->first;
    vector<int> points = it->second;
    sort(points.begin(), points.end(), greater<int>());
    for (int n : points)
      for (int i = 0; i < N; i++)
        if (s[i] == name && p[i] == n) ans.push_back(i + 1);
  }
  for (int i : ans) cout << i << endl;
}


Measured memory_bytes: 256
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const ll mod= 1e9+7;
long double PI = acosl(-1);
const ll infl = 1e18+0;
const int inf = 1e9;
const int nmax = 2e5+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

vector<int>koi[nmax];
ll dp[nmax];

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

    int n;
    cin>>n;
    vector<int>v2(n);
    for(int &x : v2) cin>>x;
    vector<int>v;
    for(int x : v2){
        if(v.empty()) v.push_back(x);
        else {
            if(v.back() != x) v.push_back(x);
        }
    }

    for(int i=0; i<v.size(); i++){
        koi[v[i]].push_back(i);
    }
    int sz = v.size();

    for(int i=0; i<sz; i++){
        if(i==0) dp[i] = 1;
        else dp[i] = dp[i-1];
        int x = v[i];
        int sodo = lower_bound(koi[x].begin(), koi[x].end(), i) - koi[x].begin();
        if(sodo)
            dp[i] = (dp[i] + dp[koi[x][sodo-1]] )%mod;
    }

    cout<<dp[sz-1];
}
/*
*/


Measured memory_bytes: 14324
#include<stdio.h>
#include <math.h>
  int main(){
	double a,b,c=0;
	double x=0,y=0;
	while(1){
		scanf("%lf,%lf",&a,&b);
		if(a==0 && b==0) break;
		x += a*cos(c*3.14159265/180);
		y += a*sin(c*3.14159265/180);
		c += b;
	}
	int ax=x;
	int ay=y;
	printf("%d\n%d\n",ay,ax);
	return 0;
  }

Measured memory_bytes: 628
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
int n;double res,s,t,a;
int main() {
	read(n);n++;
	int d1,x;read(d1);read(x);s=d1;t=s+(2*n-3)*x;
	while(n>1){
		res+=(s+t)/2;
		a=(t-s)/(2*n-3);
		s=((2*n-4)*s+4*s+5*a)/(2*n-2);
		t=((2*n-4)*t+4*t-5*a)/(2*n-2);
		n--;
	}
	printf("%.10lf",res);
	return 0;
}


Measured memory_bytes: 384
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll N,D;
	cin >> N>>D;
	ll X[N][D];
	REP(i,N){
		REP(j,D){
			cin>>X[i][j];
		}
	}
	ll ans = 0;
	REP(i,N){
		REP(j,N){
			if (i>=j) continue;
			ll dist = 0;
			REP(k, D){
				dist += pow((X[i][k] - X[j][k]), 2);
			}
			ll dist2 = pow(ll(pow(dist, 0.5)), 2);
			if (dist==dist2) ans++;
			// cout<<dist<<" "<<dist2<<" "<< (dist==dist2)<<endl;
		}
	}
	//出力
	cout << ans << endl;
}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    int Y,X;
    cin >> X >> Y;
    int ty = Y - (2*X);
    if (ty%2 == 1) {
        cout << "No" << endl;
        return;
    }
    int y = ty/2;
    int x = X-y;
    if ((x < 0) || (y < 0)) {
        cout << "No" << endl;
        return;
    }
    if (((4*y)+(2*x)) != Y ) {
        cout << "No" << endl;
        return;
    }
    cout << "Yes" << endl;

}

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


Measured memory_bytes: 3640
A,B=map(int,input().split())
if A<B:
    for k in range(1,A+1):
        if (B*k)%A==0:
            print(B*k)
            break
else:
    for k in range(1,B+1):
        if (A*k)%B==0:
            print(A*k)
            break

Measured memory_bytes: 3060
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}


ll junkai[14];


ll dp[100005][13];

int main() {
	
	rep(i, 6) {
		junkai[i] = (ll)pow(10.0, i) % 13;
	}

	string S;

	cin >> S;

	reverse(S.begin(), S.end());
	if (S[0] == '?') {

		rep(j, 10){
			dp[0][j] = 1;
		}

	}
	else {
		dp[0][S[0] - '0'] = 1;
	}


	for(int i = 1; i < S.size(); i++) {
		if (S[i] == '?') {

			rep(j, 10) {
				rep(k, 13) {
					dp[i][(k + junkai[i % 6] * j) % 13] += dp[i - 1][k] % mod;
					dp[i][(k + junkai[i % 6] * j) % 13] %= mod;
				 }
			}
			
		}

		else {

			rep(k, 13) {
				dp[i][(k + junkai[i % 6] * (S[i] - '0')) % 13] += dp[i - 1][k] % mod;
				dp[i][(k + junkai[i % 6] * (S[i] - '0')) % 13] %= mod;
			}
			
		}
			
	}


	cout << dp[S.size() - 1][5] << endl;

	return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; 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 snuke srand((unsigned)clock()+(unsigned)time(NULL));
#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 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;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int a,b;
    cin >> a >> b;


    ll ans = b+a;
    
    if(b%a!=0)ans -= 2*a;

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


Measured memory_bytes: 256
#include<stdio.h>   //ABC088B - Card Game for Two

int main(){

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

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

    int player1_score=0;
    int player2_score=0;
    int turn = 0;

    while(1){
        turn++;

        int max=0;
        int maxnum=0;
        for(int i=0;i<n;i++){
            if(cards[i]>max){
                max=cards[i];
                maxnum=i;
            }
        }
        cards[maxnum]=0;
        if(turn%2){
            player1_score+=max;
        }else{
            player2_score+=max;
        }
        if(max<=0)  break;
    }

    printf("%d\n",player1_score-player2_score);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
using namespace std;

int main()
{
	string s;
	cin >> s;
	auto iter = s.begin()+1;
	int ans = 0;
	if (s.size() != 0) {
		for (;iter != s.end();iter++)
		{
			if (*(iter - 1) == *(iter))
			{
				ans++;
				if (*(iter) == '0') { *(iter) = '1'; }
				else { *(iter) = '0'; }
			}
		}
	}

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

Measured memory_bytes: 888
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = ip(br);
        Set<Integer> hList = new HashSet<>();
        hList.add(0);
        for (int i : createListInt(br)) {
            for (int j : hList.toArray(new Integer[0])) {
                hList.add(i + j);
            }
        }
        ip(br);
        for (int i : createListInt(br)) {
            System.out.println(hList.contains(i) ? "yes" : "no");
        }

    }

    static boolean isNumber(String num) {
        return Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find();
    }

    static int[] createListInt(BufferedReader br) throws IOException {
        String[] lines = br.readLine().split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        }
        return list;
    }

    static int ip(BufferedReader s) throws IOException {
        return Integer.parseInt(s.readLine());
    }
}

Measured memory_bytes: 24580
/*input
3 4
5 6
2 2
0 0
*/
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_
}

fn main() {
    let mut v: Vec<u32>;
    loop {
        v = read_line()
            .trim()
            .split_whitespace()
            .map(|x| x.parse().expect(""))
            .collect();
        if v[0] == 0 && v[1] == 0 {
            break;
        }
        for _ in 0..v[0] {
            for _ in 0..v[1] {
                print!("#");
            }
            print!("\n");
        }
        print!("\n");
    }
}



Measured memory_bytes: 5024
from sys import stdin
from sys import maxsize


def main() -> int:
    n = next_int()
    m = next_int()

    students = [tuple(map(int, input().split())) for _ in range(n)]
    check_points = [tuple(map(int, input().split())) for _ in range(m)]

    for i in range(n):
        index = 0
        value = maxsize
        for j in range(m):
            x1 = students[i][0]
            y1 = students[i][1]
            x2 = check_points[j][0]
            y2 = check_points[j][1]
            calc_result = calc(x1, x2, y1, y2)

            if calc_result < value:
                index = j
                value = calc_result
        print(index + 1)
    return 0


def calc(x1, x2, y1, y2: int) -> int:
    return abs(x1 - x2) + abs(y1 - y2)


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


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


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int a;
    cin>>a;
    int arr[a+1], dp[a+1], bef[a+1];
    for (int i=1; i<=a; i++) cin>>arr[i];
    dp[1]=0, dp[2]=abs(arr[2]-arr[1]);
    for (int i=3; i<=a; i++){
        if (abs(arr[i]-arr[i-1])+dp[i-1] < abs(arr[i]-arr[i-2])+dp[i-2]){
            dp[i]=abs(arr[i]-arr[i-1])+dp[i-1];
            bef[i]=i-1;
        }
        else {
            dp[i]=abs(arr[i]-arr[i-2])+dp[i-2];
            bef[i]=i-2;
        }
    }
    cout<<dp[a]<<endl;
}

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

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &a[i]);
  long long ans = 0;
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j)
      ans += a[i] * a[j];
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int ans=0,f=1;char chr=getchar();
	while(!isdigit(chr)){if(chr=='-')f=-1;chr=getchar();}
	while(isdigit(chr)) {ans=(ans<<3)+(ans<<1)+chr-48;chr=getchar();}
	return ans*f;
}long long a[500],ans;
signed main(){
	int n=read();
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			ans+=a[i]*a[j];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int N=2e5+1;
int i,j,k,n,m,tot,u,v;
int las[N],pre[N<<1],des[N<<1],f[N];
void link(int x,int y)
{
	pre[++tot]=las[x],des[tot]=y,las[x]=tot;
	pre[++tot]=las[y],des[tot]=x,las[y]=tot;
}
void dfs(int x,int y)
{
	f[x]=1;
	if (y==2)
		return;
	for (int i=las[x];i;i=pre[i])
		if (!f[des[i]])
			dfs(des[i],y+1);
}
int main()
{
	scanf("%d%d",&n,&m);
	for (i=1;i<=m;++i)
		scanf("%d%d",&u,&v),link(u,v);
	dfs(1,0);
	if (f[n])
		puts("POSSIBLE");
	else
		puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, kk, rr, ss, pp, ans = 0;
	cin >> nn >> kk >> rr >> ss >> pp;
	string tt, memo;
	cin >> tt;
	for(int64 ii = 0;ii < kk;ii++)
	{
		if(tt[ii] == 'r')
		{
			ans += pp;
			memo += 'p';
		}
		else if(tt[ii] == 's')
		{
			ans += rr;
			memo += 'r';
		}
		else if(tt[ii] == 'p')
		{
			ans += ss;
			memo += 's';
		}
	}
	for(int64 ii = kk;ii < nn;ii++)
	{
		if(tt[ii] == tt[ii - kk])
		{
			if(memo[ii - kk] != 'o')
			{
				memo += 'o';
				continue;
			}
		}
		if(tt[ii] == 'r')
		{
			ans += pp;
			memo += 'p';
		}
		else if(tt[ii] == 's')
		{
			ans += rr;
			memo += 'r';
		}
		else if(tt[ii] == 'p')
		{
			ans += ss;
			memo += 's';
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int X,Y,A,B;
  cin >> X >> Y;
  A = X*2;
  B = X*4;
  if (A <= Y && Y <= B && Y % 2 == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

namespace AtCoderPre
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int M = int.Parse(s[0]);
            int D = int.Parse(s[1]);

            //Console.WriteLine(M);
            //Console.WriteLine(D);


            int ans = 0;
            if (D >= 22)
            {
                for (int y = 1; y <= M; y++)
                {
                    for (int x = 22; x <= D; x++)
                    {
                        int amari = x % 10;
                        int niketa = (x - amari) / 10;

                        if (niketa * amari == y && amari != 1)
                        {
                            ans++;
                        }


                    }
                }
            }

            Console.WriteLine(ans);

        }

    }
}



Measured memory_bytes: 13140
#include <stdio.h>          // printf(), scanf()
#define MAX_N 100000

int
main(int argc, char** argv)
{
	int n, q;
	int a[MAX_N];
	int i;

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

	for (i = 0; i < q; ++i)
	{
		long x;

		scanf("%ld", &x);
		long count = 0;
		long sum = 0;
		int s, t;
		for (s = 0, t = 0; s < n; ++s)
		{
			sum += a[s];
			while (sum > x)
				sum -= a[t++];

			count += s - t + 1;
		}

		printf("%ld\n", count);
	}

	return 0;
}

Measured memory_bytes: 988
from sys import exit

def ht(cx,cy,x,y,h):
	return h+abs(x-cx)+abs(y-cy)

n=int(input())			#高々100なのでほとんどが高さ0っていう状況はない
xyh=[0]*n

for i in range(n):
	x,y,h=map(int,input().split())
	xyh[i]=[x,y,h]
xyh.sort(key=lambda x:x[2],reverse=True)			#h=0を選択してしまうことを避ける

for cx in range(101):
	for cy in range(101):
		H=ht(cx,cy,xyh[0][0],xyh[0][1],xyh[0][2])
		for i in range(1,n):
			if max(H-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy),0)!=xyh[i][2]:			#H=ht(このfor文で選択した座標)にすると、高さ0の場合に合わなくなる
				break
			
		else:			#直前のifが行われなければ、という意味。forの外における
			print(cx,cy,H)
			exit()

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<iomanip>

int main() {
	int n;
	cin >> n;
	vector<P>point(n);
	rep(i, n) {
		cin >> point[i].first>>point[i].second;
	}
	auto dist = [&](int p, int q) {
		double d_x = point[q].first - point[p].first;
		double d_y = point[q].second - point[p].second;
		double d;
		d = sqrt(d_x * d_x + d_y * d_y);
		return d;
	};
	vector<int>c(n);
	rep(i, n) {
		c[i] = i;
	}
	double l(0);
	int count(0);
	do{
		double sum(0);
		rep(i, n - 1) {
			double d = dist(c[i], c[i + 1]);
			sum += d;
		}
		l += sum;
		++count;
	} while (next_permutation(c.begin(), c.end()));
	cout <<fixed<<setprecision(12)<< l / count;

	return 0;
}

Measured memory_bytes: 256
def getchar(button,num):
    if button=='0':
        return ' '*(num-1)
    elif button=='1':
        num=(num-1)%5
        return "',.!?"[num]
    elif button=='2':
        num=(num-1)%6
        return "abcABC"[num]
    elif button=='3':
        num=(num-1)%6
        return "defDEF"[num]
    elif button=='4':
        num=(num-1)%6
        return "ghiGHI"[num]
    elif button=='5':
        num=(num-1)%6
        return "jklJKL"[num]
    elif button=='6':
        num=(num-1)%6
        return "mnoMNO"[num]
    elif button=='7':
        num=(num-1)%8
        return "pqrsPQRS"[num]
    elif button=='8':
        num=(num-1)%6
        return "tuvTUV"[num]
    elif button=='9':
        num=(num-1)%8
        return "wxyzWXYZ"[num]



while(1):
    try:
        keyin=raw_input()
    except:
        break
    oldb='0'
    num=1
    ans=''
    for k in keyin:
        if oldb!=k:
            ans=ans+getchar(oldb,num)
            num=1
        else:
            num=num+1
        oldb=k
    ans=ans+getchar(oldb,num)
    print ans

Measured memory_bytes: 4280
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int main() {
	ll N;
	cin >> N;
	vector<ll> h(N);
	string s = "APPROVED";
	for (int i = 0; i < N; i++) {
		cin >> h.at(i);
		if (h.at(i) % 2 == 0 && (h.at(i) % 3 != 0) && (h.at(i) % 5 != 0))
		{
			s = "DENIED";
		}
	}
	
	
	cout << s<< endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
int ans[500][500];

void solve (int x, int st, int en) {
    if (en - st == 1) return;
    for (int i = st; i < (st+en)/2; i++) {
        for (int j = (st+en)/2; j < en; j++) {
            ans[i][j] = x;
        }
    }
    solve(x+1, st, (st+en)/2);
    solve(x+1, (st+en)/2, en);
}

int main() {
    cin >> n;
    solve(1, 0, n);
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            cout << ans[i][j];
            if (j == n-1) cout << endl;
            else cout << " ";
        }
    }
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#ifdef LOCAL
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl
#else
#define dmp(x) void(0)
#endif

template <class t, class u>
void chmax(t &a, u b)
{
  if (a < b)
    a = b;
}
template <class t, class u>
void chmin(t &a, u b)
{
  if (b < a)
    a = b;
}
const int mod = 1000000007;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;

using vi = vc<int>;
int gcd(int a, int b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int lcm(int a, int b)
{
  return (a * b) / gcd(a, b);
}
int fact(int n)
{
  if (n == 0)
    return 1;
  return n * fact(n - 1);
}

int main()
{
  int n;
  cin >> n;
	string a;cin>>a;
  int ans=0;
  int num=0;
  rep(i,n){
  if(a[i]=='I'){
  	num++;
  }else if(a[i]=='D'){
  	num--;
  }
    ans=max(ans,num);
  }
  cout <<  ans <<endl;
}

Measured memory_bytes: 256
//I am so vegetable
//#define err
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = acos(-1.0);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

int a[20];
int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
    #ifdef err
	double be = clock();
    #endif
    ll n;cin>>n;
    int cnt = 0;
    while(n){
        a[cnt++]=(n-1)%26;
        n-=1;
        n/=26;
    }
    _rfor(i,cnt-1,-1){
        cout<<(char)(a[i]+'a');
    }
    #ifdef err
	double en = clock();
    cout<<"time: "<<fixed<<setprecision(8)<<en-be;
    #endif
	return 0;
}

Measured memory_bytes: 3648
<?php
list($n, $m) = ints();
$uf = new UnionFind($n);
for ($i = 0; $i < $m; ++$i) {
    list($x, $y, $z) = ints();
    --$x;
    --$y;
    $uf->unite($x, $y);
}
echo $uf->count();
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
// Union-Find：同じグループに属するかどうかを判定する
class UnionFind
{
    private $par; // par[$i]:$iの親 自分が根の場合は自身のindexとなる
    private $size;

    function __construct($n)
    {
        for ($i = 0; $i < $n; $i++) {
            $this->par[$i] = $i; // 最初は全てが根
            $this->size[$i] = 1;
        }
    }

    function root($x)
    { // 根を返す
        if ($this->par[$x] === $x) return $x; // 根の場合
        return $this->par[$x] = $this->root($this->par[$x]); // 全ての枝の親を根にしながら再帰処理
    }

    function unite($x, $y)
    { // $xと$yの木を併合
        $ix = $this->root($x);
        $iy = $this->root($y);
        if ($ix === $iy) return;
        if ($this->size[$ix] < $this->size[$iy]) list($ix, $iy) = [$iy, $ix];
        $this->size[$ix] += $this->size[$iy];
        $this->par[$iy] = $ix; // $yの根を$xの根に付ける
    }

    function isSame($x, $y)
    { // $xと$yの根が同じか
        return $this->root($x) === $this->root($y);
    }

    function size($x)
    { // xが属するグループのサイズ
        return $this->size[$this->root($x)];
    }

    function count()
    { // グループの数
        $cnt = 0;
        foreach ($this->par as $i => $r)
            if ($i === $r) ++$cnt;
        return $cnt;
    }
}


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

#define FOR(i,a,b) for(i=a;i<=b;i++)
#define FOD(i,b,a) for(i=a;i>=b;i--)
#define pa pair<int,int>
#define fi first
#define se second
#define task "x"

typedef long long ll;
const ll M=1e6+1;
const ll N=1e4+1;
using namespace std;

ll i, j, n, ans = 0, a[N], e, h , k, d;
string s;

void input()
{
    cin >> n >> k >> d;

}


void solve()
{
    n  = abs(n);
    if(k%2!=0) {n-=d;k--;}
    if(n>d) {
            h = n/d + 1;
            if(h%2!=0) h++;
    if(h<=k) {
            cout<<min(abs(n - h*d),abs(n - d*(h-2)));
            return;
    }
    else {
        cout<<abs(n - k*d);
    }
    }
    else {
        cout<<min(abs(n), abs(n - 2 * d));
    }
}

int main()
{
  	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	if(fopen(task".inp","r"))
        {
 	  freopen(task".inp","r",stdin);
 	  freopen(task".out","w",stdout);
	}
	input();
	solve();


   return 0;
}




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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

#define PB(N) push_back(N)

using namespace std;

using Graph = vector<vector<int>>;

int main(){
  int N,K; cin >> N >> K;
  vector<int> p(N);
  rep(i,N) cin >> p[i];
  sort(all(p));

  int sum=0;
  rep(i,K) sum+=p[i];
  cout << sum;
  return 0;
}


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

using namespace std;

int getNum(int num, int pos){
	ostringstream oss; oss << num;
	return oss.str()[pos]-'0';
}

int main(){
	int N, K;
	while(cin >> N >> K){
		if(!(N||K)) break;
		N--;
		long long mul = 9;
		int i=0;
		// mul : iÌÌÂ
		for(i=1; ;i++){
			if(N < i*mul) break;
			N -= i*mul;
			mul *= 10;
		}
		long long cur = 1;
		int pos = N/i;
		int div = N%i;
		int count = 0;
		for(int j=1;j<i;j++) cur *= 10;
		while(count<K){	
			cout << getNum(cur+pos, div);
			if(div == i-1) { div = 0; pos++; }
			else           { div++;          }
			if(cur+pos == 10*cur){
				cur *= 10; pos = 0; i++;
			}
			count++;
		}
		cout << endl;
	}
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if((a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=100000;
vector<int> d[MAXN+5];
int n;
int dfs(int u,int fa)
{
	int res=0,v;
	for(int i=0;i<d[u].size();i++)
	{
		v=d[u][i];
		if(v!=fa)
			res+=dfs(v,u);
	}
	if(res>=2)
	{
		printf("First\n");
		exit(0);
	}
	else if(res==0)
		return 1;
	return 0;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n-1;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		d[u].push_back(v);
		d[v].push_back(u);
	}
	if(dfs(1,0))
		printf("First\n");
	else
		printf("Second\n");
	return 0;
}


Measured memory_bytes: 5888
def count_op(n, a):
    i_sum = a[0]
    op_num = 0
    for i in range(1, n):
        tmp_sum = i_sum + a[i]
        if i_sum > 0:
            if tmp_sum == 0:
                op_num += 1
                a[i] -= 1
                tmp_sum -= 1
            elif tmp_sum > 0:
                op_num += tmp_sum + 1
                a[i] -= tmp_sum + 1
                tmp_sum = -1
        else:
            if tmp_sum == 0:
                op_num += 1
                a[i] += 1
                tmp_sum += 1
            elif tmp_sum < 0:
                op_num += -tmp_sum + 1
                a[i] += -tmp_sum + 1
                tmp_sum = 1
        i_sum = tmp_sum
    return op_num

n = int(input())
a = [int(i) for i in input().split()]

if a[0] != 0:
    b = a[:]
    a_num = count_op(n, a)
    b_num = 0
    if b[0] > 0:
        b_num += b[0] + 1
        b[0] = -1
    else:
        b_num += -b[0] + 1
        b[0] = 1
    b_num += count_op(n, b)
    print(min(a_num, b_num))
else:
    b = a[:]
    a[0] = 1
    a_num = count_op(n, a) + 1
    b[0] = -1
    b_num = count_op(n, b) + 1
    print(min(a_num, b_num))

Measured memory_bytes: 14468
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
	cin>>n;
	vc a(n);
	Ff(i,0,n)
	cin>>a[i];
	ll sum=0;
	Ff(i,0,n)
	{
		sum=(sum+a[i])%mod;
	}

	ll ans=0;
	Ff(i,0,n)
	{
		sum=(sum-a[i]+mod)%mod;
		ans=(ans+(a[i]*sum)%mod)%mod;
	}
	cout<<ans;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 11888
import java.math.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int M = sc.nextInt();
        int a[] = new int[A];
        int b[] = new int[B];
        int xyc[][] = new int[M][3];
        for (int i = 0; i < A; i++)
            a[i] = sc.nextInt();
        for (int i = 0; i < B; i++)
            b[i] = sc.nextInt();
        for (int i = 0; i < M; i++) {
            xyc[i][0] = sc.nextInt();
            xyc[i][1] = sc.nextInt();
            xyc[i][2] = sc.nextInt();
        }
        int ans = 0;
        int tmp = 0;
        for (int i = 0; i < M; i++) {
            tmp = a[xyc[i][0] - 1] + b[xyc[i][1] - 1] - xyc[i][2];
            if (i == 0)
                ans = tmp;
            if (ans > tmp)
                ans = tmp;
        }
        Arrays.sort(a);
        Arrays.sort(b);
        tmp = a[0] + b[0];
        if (ans > tmp)
            ans = tmp;
        System.out.println(ans);

    }
}

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

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

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
typedef pair<ll,ll> pll;

ll a, b, c;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    scanf("%lld %lld.%lld", &a, &b, &c);
    ll res = a*b + a*c/100;
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#include <string>
#include <map> 
using namespace std;

int main() {
	int n;
	char str[10],com[13];
	
	map<string,bool> T;
	
	cin>>n;
	
	for(int i=0;i<n;i++){
		scanf("%s%s",com,str);
		if(com[0]=='i') T[string(str)]=true;
		else{
			if(T[string(str)]) printf("yes\n");
			else printf("no\n");
		}
	} 
	
	
	return 0;
}

Measured memory_bytes: 47564
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var c = new int[n];
        var w = new int[n];
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            c[i] = int.Parse(line[0]);
            w[i] = int.Parse(line[1]);
        }
        var cs = new int[n + 1];
        for (int i = 1; i < n + 1; i++) cs[i] = cs[i - 1] + w[i - 1];
        var p = new bool[n, n];
        for (int i = 0; i < n; i++) p[i, i] = true;
        for (int i = 1; i < n; i++)
            for (int L = 0; L < n - i; L++)
            {
                var r = L + i;
                if ((cs[r] - cs[L]) <= c[r] && p[L, r - 1]) p[L, r] = true;
                if ((cs[r + 1] - cs[L + 1]) <= c[L] && p[L + 1, r]) p[L, r] = true;
            }
        goDp(n, p);
    }
    static void goDp(int n, bool[,] p)
    {
        var dp = new int[n];
        for (int i = 0; i < n; i++)
        {
            dp[i] = int.MaxValue;
            for (int j = 0; j < i + 1; j++)
                if (p[j, i])
                {
                    if (j >= 1) dp[i] = Min(dp[i], dp[j - 1] + 1);
                    else dp[i] = Min(dp[i], 1);
                }
        }
        Console.WriteLine(dp[n - 1]);
    }
}



Measured memory_bytes: 17980
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int n, g[55][55];
vector<int> w, t;

void dfs(int x, int p, int q) {
    if (x == q) {
        t = w;
        return;
    }
    for (int i = 1; i <= n; i++) if (g[x][i] && i != p) {
        w.push_back(g[x][i]);
        dfs(i, x, q);
        w.pop_back();
    }
}

ll d[55][1050000];

int main() {
    ios::sync_with_stdio(false);
    int m, u, v, a[22][55] = {};
    cin >> n;
    for (int i = 1; i < n; i++) cin >> u >> v, g[u][v] = g[v][u] = i;
    cin >> m;
    for (int i = 0; i < m; i++) {
        cin >> u >> v;
        t.clear();
        dfs(u, u, v);
        for (int j : t) a[i][j] = 1;
    }
    int k = 0;
    for (int i = 0; i < m; i++) if (a[i][1]) k += (1 << i);
    d[1][0] += 1;
    d[1][k] += 1;
    for (int i = 1; i + 1 < n; i++) {
        int k = 0;
        for (int j = 0; j < m; j++) if (a[j][i + 1]) k += (1 << j);
        for (int j = 0; j < (1 << m); j++) {
            d[i + 1][j] += d[i][j];
            d[i + 1][j | k] += d[i][j];
        }
        //for (int j = 0; j < (1 << m); j++) cout << d[i + 1][j] << ' '; cout << '\n';
    }
    cout << d[n - 1][(1 << m) - 1];
}


Measured memory_bytes: 396976
#include <bits/stdc++.h>
#define mp(i,j) make_pair(i,j)
using namespace std;

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

int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size()-1;++i){
		if(s[i]==s[i+1]){
			cout<<"Bad"<<endl;
			return 0;
		}
	}
	cout<<"Good"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 256