akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int INF=1000100010;
const int MAX_N=5001;
struct edge{
    int to,cap,rev;
    bool flag;
    edge(int to,int cap,int rev,bool flag):
    to(to),cap(cap),rev(rev),flag(flag){}
    };

vector<edge> g[MAX_N];
int dist[MAX_N];
int used[MAX_N];
void add_edge(int src,int dst,int cap,bool flag){
    g[src].pb(edge(dst,cap,g[dst].size(),flag));
    g[dst].pb(edge(src,0,g[src].size()-1,false));
}
void bfs(int s){
    memset(dist,-1,sizeof(dist));
    queue<int> q;
    dist[s]=0;
    q.push(s);
    while(!q.empty()){
        int v=q.front();q.pop();
        rep(i,g[v].size()){
            edge &e=g[v][i];
            if(e.cap>0&&dist[e.to]<0){
                dist[e.to]=dist[v]+1;
                q.push(e.to);
            }
        }
    }
}
int dfs(int v,int t,int f){
    if(v==t) return f;
    used[v]=true;
    rep(i,g[v].size()){
        edge &e=g[v][i];
        if(e.cap>0&&dist[v]<dist[e.to]){
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                g[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s,int t){
    int flow=0;
    while(1){
        bfs(s);
        if(dist[t]<0) return flow;
        memset(used,0,sizeof(used));
        int f;
        while((f=dfs(s,t,INF))>0){
            flow+=f;
        }
    }
}
bool used2[5001];
void dfs2(int v){
    used2[v]=true;
    rep(i,g[v].size()){
        if(g[v][i].cap>0&&!used2[g[v][i].to]){
            dfs2(g[v][i].to);
        }
    }
}
int main(){
    int n,m,s,t,c;
    cin>>n>>m;
    rep(i,m){
        cin>>s>>t>>c;
        add_edge(s,t,c,c==1);
        add_edge(t,s,c,c==1);
    }
    int tp=max_flow(0,n-1);
    int cnt=0;
    rep(i,n){
        memset(used2,0,sizeof(used2));
        dfs2(i);
        rep(j,g[i].size())if(!used2[g[i][j].to]&&g[i][j].flag) cnt=1;
    }
    if(tp-cnt<=10000)cout<<tp-cnt<<endl;
    else cout<<-1<<endl;
    return 0;
}


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

const int INF = 1001001001;

int main() {
  int n, m, l;
  cin >> n >> m >> l;
  vector<vector<int>> dist(n, vector<int>(n,INF));
  rep(i,n) dist[i][i] = 0;
  rep(i,m) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    dist[a][b] = dist[b][a] = c;
  }
  rep(k,n)rep(i,n)rep(j,n) chmin(dist[i][j], dist[i][k]+dist[k][j]);
  vector<vector<int>> fuel(n, vector<int>(n,INF));
  rep(i,n)rep(j,n) {
    if (dist[i][j] <= l) fuel[i][j] = 1;
  }
  rep(k,n)rep(i,n)rep(j,n) chmin(fuel[i][j], fuel[i][k]+fuel[k][j]);
  int q;
  cin >> q;
  rep(qi,q) {
    int s, t;
    cin >> s >> t;
    --s; --t;
    int ans = fuel[s][t]-1;
    if (fuel[s][t] == INF) ans = -1;
    cout << ans << endl;
  }
  return 0;
}


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

using namespace std;

int main() {

    int A, B;
    cin >> A >> B;
    int res = 0;
    int x = max(A, B), y = min(A, B);
    if (A == B)
        cout << A + B << '\n';
    else {
        int i = 0;
        while (x > y) {
            res += x;
            i++;
            if (i == 2)
                break;
        }
        cout << res - 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
program main;
var
   input1, input2:string;
   i, diff, len: integer;
begin
	readln(input1);
    readln(input2);
    diff := 0;
    for i:= 1 to length(input1) do begin
        if(input1[i] <> input2[i]) then
             diff := diff + 1;
    end;
    writeln(diff);
end.

Measured memory_bytes: 1376
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 200010
using namespace std;

int unko_ans[10][10];

int unko(int n){
  int ans = 0;
  FOR(k,1,n+1){
    int a = k % 10; //1桁目
    int b = k % 10;
    int m = k;
    while(m > 0){
      b = m % 10; //log10(k)+1桁目
      m /= 10;
    }
  unko_ans[a][b]++;
  }

  return 0;
}

int main(){
  int n;
  cin>>n;
  
  int ans = 0;
  unko(n);
  REP(i,10){
    REP(j,10){
      ans += unko_ans[i][j] * unko_ans[j][i];
    }
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        int b = sc.nextInt();

		
        int sumAddition = a + b;

        int sumSubtraction = a - b;

        int sumMultiplication = a * b;

        int tempMax = sumAddition;

        if(tempMax < sumSubtraction) {
        	tempMax = sumSubtraction;
        }
        if(tempMax < sumMultiplication) {
        	tempMax = sumMultiplication;
        }

        System.out.println(tempMax);


	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define pb push_back
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
const int MOD = 1000000007;
const int oo = 2e9;
const int N = 200000 + 100;
const int LOGN = 18;


int n , a[N];
ll ans = 0;

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i+1 < n; ++i) {
		if(a[i+1]>= a[i] && a[i+1]-a[i]>1){
			puts("-1");
			return 0;
		}
	}
	if (a[0]) {
		puts("-1");
		return 0;
	}
	int idx = 1;
	while (idx < n) {
		if (a[idx] == 0) {
			idx++;
			continue;
		}
		int st = idx;
		while (idx + 1 < n && a[idx + 1] - a[idx] == 1) {
			idx++;
		}
		ans += a[idx];
		//cout << "RANGE [" << st << " , " << idx << " ] " << ans << endl;
		idx++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

const ll ky[2] = {1, -1};
ii arr[2][2];

ll manh(ii a, ii b) {
	return abs(a.fi - b.fi) + abs(a.se - b.se);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	for(int i = 0; i < 2; i++)
		for(int j = 0; j < 2; j++)
			arr[i][j] = ii(-MOD, -MOD);
	ll mej = 0;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		ii pt;
		cin >> pt.fi >> pt.se;
		for(int a = 0; a < 2; a++) {
			for(int b = 0; b < 2; b++) {
				ii nw = pt;
				nw.fi *= ky[a];
				nw.se *= ky[b];
				if(i) mej = max(mej, manh(nw, arr[a][b]));
				if(!i || nw.fi + nw.se > arr[a][b].fi + arr[a][b].se)
					arr[a][b] = nw;
			}
		}
	}
	cout << mej << '\n';
}



Measured memory_bytes: 3612
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	a = int(input())
	ans = a + a ** 2 + a ** 3
	print(ans)
	




if __name__ == '__main__':
	main()

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

int main(){
  string s,t; cin>>s>>t;
  string u = s+s;
  int len_s = s.size();
  int len_u = u.size();
  map<char,vector<int> > mp;
  for(int i=0;i<len_u;++i){
    mp[ u[i]  ].push_back(i);
  }

  ll ans = 0;
  int idx = -1;
  for(char c:t){
    if(mp[c].size()==0){
      ans = -1; break;
    }
    int jdx = *lower_bound(ALL(mp[c]),idx+1);
    ans += jdx-idx;
    idx = jdx%len_s;
  }
  cout << ans << "\n";
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    ll n; cin >> n;

    ll ans = 0;
    rep3(i, 1, n){
        ll cnt = n/i;
        ll sum = (cnt + 1) * cnt / 2;
        ans += i*sum;
    }

    cout << ans << endl;
	return;
}

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

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int x, a; cin >> x >> a;

    if (x >= a) {
        cout << 10 << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
import math

class Triangle:
    def __init__(self, a, b, c):
        self.s1 = a
        self.s2 = b
        self.rad = math.radians(c)

    def s3(self):
        return math.sqrt(self.s1**2 + self.s2**2 \
                             - 2*self.s1*self.s2*math.cos(self.rad))

    def area(self):
        return 0.5 * self.s1 * self.s2 * math.sin(self.rad)

    def height(self):
        return b * math.sin(self.rad)

    def length(self):
        return self.s1 + self.s2 + self.s3()


a, b, c = map(float, input().split())
triangle = Triangle(a, b, c)

print(triangle.area())
print(triangle.length())
print(triangle.height())


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

"""nを素因数分解"""
"""2以上の整数n => [(素因数, 指数), ...]の2次元リスト"""

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5)+1):
        if temp%i == 0:
            cnt = 0
            while temp%i == 0:
                cnt += 1
                temp //= i
            arr.append((i, cnt))
    if temp != 1:
        arr.append((temp, 1))
    if arr == []:
        arr.append((n, 1))
    return arr

li = factorization(N)
ans = 0
for i in li:
    k = i[1]
    loop = 1
    while True:
        k -= loop
        if k>=0:
            ans += 1
        else:
            break
        loop += 1
if N==1:
    print(0)
else:
    print(ans)

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int a[4];
    rep(i,0,4) cin >> a[i];
    bool taka=true;
    while(1){
        a[2]-=a[1];
        if(a[2]<=0){
            cout << "Yes" << endl;
            return 0;
        }
        a[0]-=a[3];
        if(a[0]<=0){
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3612
#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;
const int INF=1001001001;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	int H,W; cin >> H >> W;
	char s[1000][1000];
	int d[1000][1000];
	queue <P> Q;
	
	rep(i,H)rep(j,W){
	    cin >> s[i][j];
	    if (s[i][j]=='#'){
	        Q.push({i,j});
	        d[i][j]=0;
	    }else{
	        d[i][j]=INF;
	    }
	}
	
	while (!Q.empty()) {
		int y = Q.front().first;
		int x = Q.front().second;
		Q.pop();
		for (int k=0; k<4; k++){
			int ny = y + dy[k];
			int nx = x + dx[k];
			if (0 <= ny && ny < H && 0 <= nx && nx < W && s[ny][nx] == '.'&&d[ny][nx]==INF) {
				Q.push({ ny,nx });
				d[ny][nx] = d[y][x] + 1;
			}
		}
	}
	
	int ans = 0;
	rep(i,H)rep(j,W) ans = max(ans, d[i][j]);
	
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13328
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

const ll INF = 2e9;

ll dist[505][505];
ll dist2[505][505];

void warchall_floyd(int N){
    rep(k,N)rep(i,N){
        if(dist[i][k] == INF) continue;
        rep(j,N){
            if(dist[k][j] == INF) continue;
	        chmin(dist[i][j], dist[i][k]+dist[k][j]);
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int v, e;
    cin >> v >> e;
    rep(i,v){
        rep(j,v){
			dist[i][j] = INF;
			dist2[i][j] = INF;
		}
        dist[i][i] = 0;
		dist2[i][i] = 0;
    }
    rep(i,e){
        int s, t, d;
        cin >> s >> t >> d;
		--s; --t;
        dist[s][t] = d;
		dist[t][s] = d;
		dist2[s][t] = d;
		dist2[t][s] = d;
    }
    warchall_floyd(v);
	int ans = 0;
	rep(i,v){
		for(int j = i+1; j < v; ++j){
			if(dist2[i][j] != INF && dist[i][j] != dist2[i][j]) ++ans;
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
(n, m), *q = [[*map(int, i.split())] for i in open(0)]
b = [1] + [0] * (n - 1)
c = [1] * n
for x, y in q:
    c[x - 1] -= 1
    c[y - 1] += 1
    b[y - 1] |= b[x - 1]
    if c[x - 1] == 0:
        b[x - 1] = 0
print(sum(b))


Measured memory_bytes: 29396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
string s[1000005];
vector<pair<int,int>> a,b;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s[i];
    }
    for(int i=1;i<=n;i++){
        int l=0,r=0;
        for(int j=0;j<s[i].length();j++){
            if(s[i][j]=='('){
                l++;
            }
            else{
                if(l>0) l--;
                else r++;
            }
        }
        if(l<=r) a.push_back({l,r});
        else b.push_back({r,l});
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    int sum=0;
    for(int i=0;i<a.size();i++){
        sum-=a[i].first;
        if(sum<0){
            cout<<"No"<<endl;return 0;
        }
        sum+=a[i].second;
    }
    for(int i=0;i<b.size();i++){
        sum-=b[i].second;
        if(sum<0){
            cout<<"No"<<endl;return 0;
        }
        sum+=b[i].first;
    }
    if(sum==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 42452
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#include<typeinfo>
#define R(i, n) for(int i = 0;i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", &a[i])
#define SAL(i, n, a) R(i, n) scanf("%lld", &a[i])
#define SC(a) scanf("%c", &a)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
#define PY printf("YES")
#define PN printf("NO")
#define Py printf("Yes")
#define Pn printf("No")
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;
const double PI = acos(-1);

int main() {
	int N;
	S(N);
	string s;
	cin >> s;
	vector<int> wnums(N);
	int wnum = 0;
	R(i, N - 1) {
		if (s[i] == 'W') wnum++;
		wnums[i + 1] = wnum;
	}
	reverse(s.begin(), s.end());
	vector<int> enums(N);
	int enu = 0;
	R(i, N - 1) {
		if (s[i] == 'E') enu++;
		enums[N - 2 - i] = enu;
	}
	int ans = 3 * 1e+5;
	R(i, N) ans = min(ans, wnums[i] + enums[i]);
	P(ans);
}

Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <stack>
#include <tuple>

using namespace std;
typedef long long ll;

int main()
{
    vector<int> abc(3);
    cin >> abc[0] >> abc[1] >> abc[2];
    sort(abc.begin(), abc.end());
    if (abc[0] == 5 && abc[1] == 5 && abc[2] == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

int main(){
  int N, A, B, C;
  int ans = 1000000007;

  cin >> N >> A >> B >> C;
  vector<int> l;
  for (int i=0; i<N; i++) {
	int li;
	cin >> li;
	l.push_back(li);
  }

  for (int val=0; val<(1 << (2 * N)); val++) {
	vector<int> ABC(3, 0);
	int tmp = 0;

	// synthesize
	for (int pos=0; pos<N; pos++) {
	  int idx = (val >> (2 * pos)) & 3;
	  if (idx < 3) {
		if (ABC.at(idx) > 0) tmp += 10;
		ABC.at(idx) += l.at(pos);
	  }
	}
	// extend or shorten
	if (ABC.at(0) < 1) {
	  continue;
	} else if (ABC.at(1) < 1) {
	  continue;
	} else if (ABC.at(2) < 1) {
	  continue;
	}

	tmp += abs(A - ABC.at(0));
	tmp += abs(B - ABC.at(1));
	tmp += abs(C - ABC.at(2));
	// update
	if (tmp < ans) {
	  ans = tmp;
	}
	
  }

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

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

int main(){
  int ans=1e6;
  int n;
  cin>>n;
  int vec[n][2]; //vec[i][0]=front,vec[i][1]=back
  for(int i=0;i<n;i++){
    cin>>vec[i][0];
    vec[i][0]*=100;
  }
  for(int i=0;i<n;i++){
    cin>>vec[i][1];
    vec[i][1]*=100;
  }
  int bitb[n]; //bit[i]=1:distance odd,bit[i]=0:distance even
  int vecb[n],vecc[n]; //vecb[i]=before swap,vecc[i]=after swap
  int vecd[n]; //vecd[after swap]=before swap
  int x,y;
  for(int bit=0;bit<(1<<n);bit++){
    for(int i=0;i<n;i++){
      if(bit&(1<<i)){
        bitb[i]=1;
      }
      else{
        bitb[i]=0;
      }
    }
    x=0;
    for(int i=0;i<n;i++){
      if(i%2==0&&bitb[i]==0){
        x++;
      }
      if(i%2==1&&bitb[i]==1){
        x++;
      }
    }
    /*if(x!=n/2){
      continue;
    }*/
    y=0;
    for(int i=0;i<n;i++){
      if(bitb[i]==0){
        vecb[i]=vec[i][0];
      }
      else{
        vecb[i]=vec[i][1];
      }
      vecc[i]=vecb[i];
    }
    sort(vecc,vecc+n);
    int seen[n]={};
    for(int i=0;i<n;i++){
      if(bitb[i]==0){
        if(i%2==0){
          for(int j=0;j<n;j+=2){
            if(vecb[i]==vecc[j]&&seen[j]==0){
              vecd[j]=i;
              seen[j]=1;
              y++;
              break;
            }
          }
        }
        else{
          for(int j=1;j<n;j+=2){
            if(vecb[i]==vecc[j]&&seen[j]==0){
              vecd[j]=i;
              seen[j]=1;
              y++;
              break;
            }
          }
        }
      }
      else{
        if(i%2==0){
          for(int j=1;j<n;j+=2){
            if(vecb[i]==vecc[j]&&seen[j]==0){
              vecd[j]=i;
              seen[j]=1;
              y++;
              break;
            }
          }
        }
        else{
          for(int j=0;j<n;j+=2){
            if(vecb[i]==vecc[j]&&seen[j]==0){
              vecd[j]=i;
              seen[j]=1;
              y++;
              break;
            }
          }
        }
      }
    }
    if(y!=n){
      continue;
    }
    int w[55]={};
    for(int i=0;i<n;i++){
      vecc[i]+=w[vecc[i]/100];
      w[vecc[i]/100]++;
      vecb[vecd[i]]=vecc[i];
    }
    int z=0;
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
        if(vecb[i]>vecb[j]){
          z++;
        }
      }
    }
    ans=min(ans,z);
  }
  if(ans==1e6){
    cout<<-1<<endl;
    return 0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long int MOD=1e9+7;
int main() {
	int a,b;
	cin>>a>>b;
	if(a%3==0 or b%3==0 or (a+b)%3==0) cout<<"Possible";
	else cout<<"Impossible";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define DEBUG_VARIABLE(variable) cout << #variable << ":" << variable << endl

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
#define INF (1 << 9)
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

void printArray(int *array, int);
void printVector(Vector &v);
void printDimention(DVector &dv);

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    int a[n + 2];
    a[0] = a[n + 1] = 0;
    int total = 0;
    FOR(i, 1, n + 1){
        cin >> a[i];
        total += abs(a[i] - a[i - 1]);
        //DEBUG_VARIABLE(total);
    }
    total += abs(a[n + 1] - a[n]);
    //DEBUG_VARIABLE(total);
    /*
    int sum[n];
    memset(sum, total, sizeof(sum));
    */
    /*
    FOR(i, 1, n + 2){  //足すやつ回し
        FOR(j, 0, n){  //足すとこ選び，skip
            if(i == j + 1){
                continue;
            }else if(i == j + 2){
                sum[j] += abs(a[i] - a[i - 2]);
            }else{
                sum[j] += abs(a[i] - a[i - 1]);
            }
        }
    }
    */
    int sum = total;
    FOR(i, 1, n + 1){
        sum = total - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]);
        cout << sum << endl;
    }
    /*
    rep(i, n){
        cout << sum[i] << endl;
    }
    */
}

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

//Vectorの表示
void printVector(Vector &v){
    rep(i, (int)v.size()){
        if(i)   cout << " ";
        cout << v[i];
    }
    cout << endl;
}

//二次元配列の表示
void printDimention(DVector &dv){
    rep(i, (int)dv.size()){
        rep(j, (int)dv[i].size()){
            if(j)   cout << " ";
            cout << dv[i][j];
        }
        cout << endl;
    }
}

//numの中に何個2がかかってるか
int factor2(int num){
    int cnt = 0;
    while(num % 2 == 0){
        num /= 2;
        cnt++;
    }
    return cnt;
}

Measured memory_bytes: 1664
class UnionFind(): #集合の取り扱い、辺に重み、階層を意識するときは使えない
    def __init__(self,n):
        self.n=n
        self.par = [-1]*n
    def find(self,x):
        if self.par[x] <0: #負なら親、要素数
            return x
        else: #正なら親の番号
            self.par[x]=self.find(self.par[x]) #一回調べたら根を繋ぎ変える、経路圧縮
            return self.par[x]
    def union(self,x,y):
        x=self.find(x) #x,yの親
        y=self.find(y)

        if x==y: #親が同じなら何もしない
            return 
        if self.par[x]>self.par[y]: #要素数が大きい方をxにする
            x,y=y,x
        self.par[x]+=self.par[y] #xがある集合にyが入った集合をくっつける
        self.par[y]=x

    def size(self,x):
        return -self.par[self.find(x)] #親のサイズ
    
    def same(self,x,y): #親が同じ、すなわち同じ集合か
        return self.find(x)==self.find(y)

    def member(self,x): #同じ木（集合）にある要素全部リストで返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i)==root ]
    
    def roots(self): #集合の根になってる要素をリストで返す
        return [i for i , x in enumerate(self.par) if x<0]
    
    def group_count(self): #集合の数、木の数
        return len(self.roots())

    def all_member(self): #辞書型で返す
        return {r: self.member(r) for r in self.roots()}
    def __str__(self):
        return "\n".join('{}:{}'.format(r,self.member(r)) for r in self.roots)
n,m=map(int,input().split())
xyz = [list(map(int, input().split())) for _ in range(m)]
x, y ,z= [list(i) for i in zip(*xyz)]
uf = UnionFind(n)
for i in range(m):
    uf.union(x[i]-1,y[i]-1)
print(uf.group_count())

Measured memory_bytes: 83160
N = int(input())
A = list(map(int, input().split()))
ans = 0
Amin = 10 ** 9 + 1
flag = 0
for i in range(N):
  if i < N-1 and A[i] < 0:
    A[i] = -A[i]
    A[i+1] = -A[i+1]
  elif i == N-1 and A[i] < 0:
    A[i] = -A[i]
    flag = -1
    
  ans += A[i]
  
  if A[i] < Amin:
    Amin = A[i]
    
print(ans + (flag * 2 * Amin))




Measured memory_bytes: 19980
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector <int> vi;
typedef long double LD;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=200005;
int n;
LL a[N];
map <LL,int> mp;
int main(){
	n=read();
	For(i,1,n)
		a[i]=read()+a[i-1];
	LL ans=0;
	For(i,0,n){
		ans+=mp[a[i]];
		mp[a[i]]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14336
def main():
    N, K, Q = map(int, input().split())
    lst_A = [int(input()) for _ in range(Q)]
    lst_miss = [K - Q] * N


    for A in lst_A:
        lst_miss[A - 1] += 1
    
    for miss in lst_miss:
        ans = "Yes" if miss > 0 else "No"
        print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 10500
#include<stdio.h>
#define NUM 300

int main()
{
	int i, j;
	int num;
	int t;
	int flag;
	int count = 0;
	
	scanf("%d", &num);
	
	for(i = 0; i < num; i++)
	{
		scanf("%d", &t);
		flag = 1;
		
		if(t != 2 && t % 2 == 0) flag = 0;
		else for(j = 3; j*j <= t; j+=2)
		{
		if(t % j == 0) flag = 0;
		}
		if(flag == 1) count++;
	}
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        int xg = 1;
        int yg = 1;
        switch(x){
            case 2:
                xg = 3;
                break;
            case 4:
                xg = 2;
                break;
            case 6:
                xg = 2;
                break;
            case 9:
                xg = 2;
                break;
            case 11:
                xg = 2;
                break;
        }
        switch(y){
            case 2:
                yg = 3;
                break;
            case 4:
                yg = 2;
                break;
            case 6:
                yg = 2;
                break;
            case 9:
                yg = 2;
                break;
            case 11:
                yg = 2;
                break;
        }
        if(xg == yg){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, j, a[200001], b[200001]={0}, sum, cnt=0;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> a[i];
    }

    for(i=N; i>=1; i--){
        sum = 0;

        for(j=i; j<=N; j+=i){
            sum += b[j];
        }

        if(sum%2 != a[i]){
            b[i] = 1;
            cnt++;
        }
    }

    cout << cnt << endl;
    for(i=1; i<=N; i++){
        if(b[i]==1) cout << i << " ";
    }
    if(cnt>0) cout << endl;

    return 0;
}

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

int main()
{
    int i, n, d, min, max, R_t[200000];
    cin >> n >> R_t[0] >> R_t[1];
    min = R_t[0];
    max = R_t[1] - R_t[0];
    if(R_t[0] > R_t[1]) min = R_t[1];

    for(i = 2; i < n; i++){
        cin >> R_t[i];
        d = R_t[i] - min;
        if(max < d) max = d;
        if(min > R_t[i]) min = R_t[i];
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 1940
# https://atcoder.jp/contests/abc048/tasks/arc064_a
# 問題文により、操作後の数列は以下を満たす
# x>=a[i]+a[i+1]
# よって、x-a[i] >= a[i+1]を満たすようにa[i+1]を決定していけば良い
# 実際に与えられたaと満たすように作ったaの差が答え


N, x = list(map(int, input().split()))
A = list(map(int, input().split()))

ans = 0
if A[0] > x:
    ans = A[0] - x
    A[0] = x

for i in range(N - 1):
    new = x - A[i]
    if new >= A[i + 1]:
        # 条件を満たしているのでok
        continue
    ans += A[i + 1] - new
    A[i + 1] = new

print(ans)


Measured memory_bytes: 14068
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 110
using namespace std;
ll n,a[N];
int main(){
	ll i,j,k,ans=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			for(k=j+1;k<n;k++)
			{
				if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]&&a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k])
				{
					ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int a, b, Min = 2e9; cin >> a >> b;
  rep(i, 10000) {
    int t = (i+1) * 8 / 100, s = (i+1) * 10 / 100;
    if (t == a && s == b) Min = min(i+1, Min);
  }
  if (Min == 2e9) cout << -1 << endl;
  else cout << Min << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  ll N, K;
  cin >> N >> K;
  vector<int> vec(N);
  rep(i, N) {
    vec.at(i) = 0;
  }
  ll X, Y;
  rep(i, K) {
    cin >> X;
    rep(i, X) {
      cin >> Y;
      vec.at(Y - 1) = 1;
    }
  }
  int co = 0;
  rep(i, N) {
    if(vec.at(i) == 0) {
      co++;
    }
  }
  cout << co << endl;
}

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

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

  if(a == 1 || b == 1) cout << 1 << endl;
  else cout << a*b/2 + (a*b%2 == 1 ? 1 : 0) << endl;
}


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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double 

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	LL n;
	cin>>n;
	string w = "";
	while(n > 0) {
		n--;
		w += ((char) 97+n%26);
		n/=26;
	}
	reverse(w.begin(), w.end());
	cout<<w;
}


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

using namespace std;

int main(){
    int n ;

    int f = 111;

    cin >> n;

    int ans = 0;

    for(int i = 0; i < 9; i++){
        if(n <= f*(i+1) && n > f*i){
            ans = f*(i+1);
        }
    }

    cout << ans << endl;;



}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define fi first
#define se second 

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

// total de bolas tem que ser (par ou impar)
// End of template code!
int main() 
{
    buff();
    int n;
    cin >> n;
    vector<int> need(n + 1);
    vector<int> balls(n + 1, 0);
    vector<int> parity(n + 1, 0);
    for(int i = 1; i <= n; ++i) cin >> need[i]; 
    int res = 0; 
    for(long long i = n; i > 0; --i)
    {
        if(need[i] == parity[i]) continue;
        else {
            ++res;
            balls[i] = 1;
            for(long long x = 1ll; x * x <= i; ++x) {
                if(i%x == 0) {
                    parity[x] ^= 1;
                    if( (i/x) != x ) parity[(i/x)] ^= 1;
                }
            }
        }
    }
 
    for(int i = 1; i < n + 1; ++i) if(need[i] != parity[i]) res = -1;
    if(res == -1) cout << -1 << '\n';
    else
    {
        cout << res << '\n';
        for(int i = 1; i <=n; ++i) {
            if(balls[i]) cout << i << " "; 
        }
        cout << '\n';
    }

    return 0;
}



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

using i64 = int64_t;

int main(){
    i64 w, h, x, y;
    cin >> w >> h >> x >> y;
    int multi = 0;
    if(w%2 == 0 && h%2 == 0 && x == w/2 && y == h/2)multi = 1;
    printf("%.10f %d\n", (w*h)/2.0, multi);

    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <stdio.h>
using namespace std;

int main(){
    int k, s;
    scanf("%d", &k);  scanf("%d", &s);
    int res = 0;
    if (3*k == s){
        printf("%d\n", 1);
        return 0;
    }
    for (int x = 0; x <= k; x++){
        for (int y = 0; y <= k; y++){
            int z = s-(x+y);
            if(0 <= z && z <= k) res++;
        }
    }
    printf("%d\n", res);
}


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

int ans = 0;

void dfs(vector<int> &A, vector<int> &B) {
  if (A.size() == B.size()) {
    int p = 1;
    rep(i,0,A.size()-1) {
      p *= A[i] + B[i];
    }
    if (p % 2 == 0) ans++;
    return;
  };

  rep(i,-1,1) {
    B.push_back(i);
    dfs(A, B);
    B.pop_back();
  }
}

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

  vector<int> A(N), B;
  rep(i,0,N-1) cin >> A[i];
  dfs(A, B);

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


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    long long ans=0,w=0;
    for (int i = s.size()-1; i >= 0; --i)
        if (s[i] == 'W')
            ++w;
        else
            ans += w;
    cout << ans << endl;
}


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

int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vector<int> a;
	if (X < Y) {}
	else {
		cout << "War" << endl;
		exit(0);
	}

	for (int i = 0; i < N; i++) {
		int temp;		
		cin >> temp;
		if (temp >= Y) {
			cout << "War" << endl;
			exit(0);
		}
		a.push_back(temp);
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < M; i++) {
		int temp;
		cin >> temp;
		if (temp <= a.back() || temp <= X) {
			cout << "War" << endl;
			exit(0);
		}
	}

	cout << "No War" << endl;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9+7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

struct UF{
	vector<int> p;
	UF() {}
	UF(int n) : p(n, -1) {}
	int find(int a){ return p[a] < 0 ? a : p[a] = find(p[a]); }
	bool unite(int a, int b) {
		a = find(a); b = find(b);
		if(a == b) return false;
		if(-p[a] < -p[b]) swap(a, b);
		p[a] += p[b]; p[b] = a;
		return true;
	}
	bool root(int a){ return p[a] < 0; }
	bool same(int a, int b){ return find(a) == find(b); }
	int size(int a){ return -p[find(a)]; }
};

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m;
	cin >>n >>m;
	vector<VI> g(m, VI(2));
	rep(i,m) cin >> g[i][0] >>g[i][1];
	vector<ll> ans(m);
	ll sp = (ll)n*(n-1)/2;
	UF uf(n);
	auto old = uf.p;
	repr(i, m-1, 0){
		int a=g[i][0]-1, b=g[i][1]-1;
		ans[i] = sp;
		if(uf.same(a,b) )continue;
		ll s1=uf.size(a), s2=uf.size(b);
		
		sp -= s1 * s2;
		uf.unite(a, b);
	}
	
	for(auto x :ans){
		cout << x <<"\n";
	}
	return 0;
}



Measured memory_bytes: 8320
#include<stdio.h>
int main ()
{
    int x,i;
    i = 1;
    while(1) {
        
        scanf("%d",&x);
        
        if (x == 0) break;
        
        printf("Case %d: %d\n",i,x);
        
        i++;
        
    }
    return 0;
}


Measured memory_bytes: 2084
while true
    cards = gets.chomp
    if cards == "-"
        exit
    end
    
    len = cards.length
    n = gets.to_i
    
    for i in 1..n
        m = gets.to_i
        cards = cards.slice(m, len - m) << cards.slice(0, m)
    end
    puts cards
end


Measured memory_bytes: 6900
#include<iostream>
#include<vector>
#include<utility>
using namespace std;
typedef pair<int, int>p;
bool ip[20005];
vector<int>prime;
vector<p> twin;

void eratos() {
	for (int i = 0;i < 20005;i++)ip[i] = true;

	ip[0] = ip[1] = false;

	for (int i = 2;i*i < 20005;i++) {
		if (ip[i] == true) {
			for (int j = i * i;j < 20005;j += i)ip[j] = false;
		}
	}

	for (int i = 0;i < 20005;i++) {
		if (ip[i]) {
			prime.push_back(i);
		}
	}
	return;
}

int main() {
	int n;
	eratos();

	for (int i = 0;i < prime.size()-1;i++) {
		if (prime[i + 1] - prime[i] == 2) {
			twin.push_back(make_pair(prime[i], prime[i+1]));
		}
	}
	int x = twin.size();

	while (cin >> n, n) {
		for (int i = 1;i<x;i++) {
			if (twin[i].second > n) {
				cout << twin[i - 1].first << ' ' << twin[i - 1].second << endl;
				break;
			}
		}
	}
	return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    int count = 0;
    for (int i = 0; i < 100; ++i ){
        if ( N > K or N == K){
            N = N / K;
            count += 1;
        }
    }
    cout << count + 1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ysf (998244353)
#define N (10005)
int f[N][N],fac[N],ifac[N],inv[N],n,x,y,ans;
char a[N],b[N];
inline int C(int n,int m){
  return 1LL*fac[n]*ifac[m]%ysf*ifac[n-m]%ysf;
}
int main(){
  scanf("%s%s",a+1,b+1),n=strlen(a+1),f[0][0]=fac[0]=ifac[0]=1;
  for (int i=1;i<=n;++i) if (a[i]=='1') x+=b[i]=='1',y+=b[i]=='0';
  for (int i=1;i<=x+y;++i){
    inv[i]=i==1 ? 1 : 1LL*(ysf-ysf/i)*inv[ysf%i]%ysf;
    fac[i]=1LL*fac[i-1]*i%ysf,ifac[i]=1LL*ifac[i-1]*inv[i]%ysf;
  }
  for (int i=0;i<=x;++i)
    for (int j=0;j<=y;++j){
      if (i) f[i][j]=1LL*f[i-1][j]*i*j%ysf;
      if (j) f[i][j]=(f[i][j]+1LL*f[i][j-1]*j*j)%ysf;
    }
  for (int i=0;i<=x;++i)
    ans=(ans+1LL*fac[i]*fac[i]%ysf*C(x,i)%ysf*C(x+y,i)%ysf*f[x-i][y])%ysf;
  std::cout<<ans; return 0;
}


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

using namespace std;

int m, K;

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

    if (!m) {
        if (!K) printf("0 0");
        else printf("-1");
    }
    else if (m == 1) {
        if (!K) printf("0 0 1 1");
        else printf("-1");
    }
    else {
        if (K < (1 << m) ) {
            for (int i = (1 << m) - 1; i >= 0; --i) if (i != K) printf("%d ", i); printf("%d ", K);
            for (int i = 0; i < (1 << m); ++i) if (i != K) printf("%d ", i); printf("%d ", K);
        }
        else printf("-1");
    }

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ui unsigned int
#define ll long long
#define db double
#define ld long double
#define ull unsigned long long
#define ft first
#define sd second
#define pb(a) push_back(a)
#define PII std::pair<int,int>
#define PLL std::pair<ll,ll>
#define mp(a,b) std::make_pair(a,b)
#define ITR(a,b) for(auto a:b)
#define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
#define DEP(a,b,c) for(register int a=(b),a##end=(c);a>=a##end;--a)
const int MAXN=500+10;
int G[MAXN][MAXN],n,a,b,k;
template<typename T> inline void read(T &x)
{
	T data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
template<typename T> inline void write(T x,char ch='\0')
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
	if(ch!='\0')putchar(ch);
}
template<typename T> inline bool chkmin(T &x,T y){return y<x?(x=y,true):false;}
template<typename T> inline bool chkmax(T &x,T y){return y>x?(x=y,true):false;}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
int main()
{
	read(k);
	if(k==1)
	{
		printf("%d\n%d\n",1,1);
		return 0;
	}
	a=k/2,b=k%2;if((a+b)&1)a--,b+=2;
	n=a+b;
	REP(i,1,a)REP(j,1,n)G[j][(i+j-2)%n+1]=(j&1)?i*2-1:i*2;
	REP(i,a+1,n)REP(j,1,n)G[j][(i+j-2)%n+1]=a*2+i-a;
	printf("%d\n",n);
	REP(i,1,n)
	{
		REP(j,1,n)write(G[i][j],' ');puts("");
	}
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, Q, q, t, x;
    cin >> n >> Q;
    queue<int> v[n];
    rep(i, Q) {
        cin >> q >> t;
        if(q == 0) {
            cin >> x;
            v[t].push(x);
        } else if(q == 1) {
            if(v[t].size()) cout << v[t].front() << "\n";
        } else {
            if(v[t].size()) v[t].pop();
        }
    }
}



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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}

int n, m;
vector<pair<int, int >> go[500];
ll dp[320][320];
ll dp2[320][320];
const ll MOD = 1e9 + 7;

void add(ll &a, ll b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int l, r, x;
        cin >> l >> r >> x;
        go[r].push_back(make_pair(l, x));
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= n; ++j)
            for (int k = 0; k <= n; ++k)
                dp2[j][k] = 0;
        for (int j = 0; j < i; ++j)
            for (int k = 0; k <= j; ++k) {
                if (dp[j][k] == 0)
                    continue;
                if (j != 0) {
                    add(dp2[i - 1][j], dp[j][k]);
                    add(dp2[j][k], dp[j][k]);
                    add(dp2[i - 1][k], dp[j][k]);
                }
                else {
                    if (i == 1) {
                        add(dp2[0][0], 3 * dp[j][k]);
                    }
                    else {
                        add(dp2[0][0], dp[j][k]);
                        add(dp2[i - 1][0], 2 * dp[j][k]);
                    }
                }
            }
        for (int j = 0; j < i; ++j)
            for (int k = 0; k <= j; ++k) {
                dp[j][k] = dp2[j][k];
                if (dp[j][k] == 0)
                    continue;
                for (auto l: go[i]) {
                    if (l.second == 1) {
                        if (j >= l.first)
                            dp[j][k] = 0;
                    }
                    else if (l.second == 2) {
                        if (j < l.first || k >= l.first)
                            dp[j][k] = 0;
                    }
                    else {
                        if (k < l.first)
                            dp[j][k] = 0;
                    }
                }
            }
    }
    ll ans = 0;
    for (int j = 0; j <= n; ++j)
        for (int k = 0; k <= n; ++k)
            ans = (ans + dp[j][k]) % MOD;
    cout << ans << "\n";
    return 0;
}




Measured memory_bytes: 1792
float q;A,B,C,D,E,F,R;M(a,b,c,d,e,f){e=c-a;f=d-b;q=fabs(f*a-e*b)/hypot(e,f);return a*e+b*f<0&c*e+d*f>0&q<=R?q<R?2:1:0;}main(v,w,o,c){for(;scanf("%d%d%d%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F,&v,&w,&R),A;puts(o?o-3|c&2?"c":(C*F-D*E)*q>0&q*(A*D-B*C)>0?"a":c&1?"c":"d":"b"))A-=v,B-=w,C-=v,D-=w,E-=v,F-=w,o=(A*A+B*B>R*R)+(C*C+D*D>R*R)+(E*E+F*F>R*R),c=M(C,D,E,F)|M(E,F,A,B)|M(A,B,C,D),q=E*B-F*A;exit(0);}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var soliver = new Solver();

            soliver.Exe();

            //Console.ReadLine();
        }
    }

    public class Solver
    {
        public void Exe()
        {
            var p = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

            if (p[0] > p[2])
            {
                Console.WriteLine($"{p[0] - p[2]} {p[1]}");
            }
            else if (p[1] > p[2] - p[0])
            {

                Console.WriteLine($"0 {p[1] - (p[2] - p[0])}");
            }
            else
            {
                Console.WriteLine($"0 0");

            }

        }


    }
}


Measured memory_bytes: 13396