akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int A, B, M;
int a[100000], b[100000], x[100000], y[100000], c[100000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> A >> B >> M;
    for(int i = 0; i < A; i++) cin >> a[i];
    for(int i = 0; i < B; i++) cin >> b[i];
    for(int i = 0; i < M; i++) {
        cin >> x[i] >> y[i] >> c[i];
        x[i]--;
        y[i]--;
    }
    int mina = 1e+7, minb = 1e+7;
    for(int i = 0; i < A; i++){
        mina = min(a[i], mina);
    }
    for(int i = 0; i < B; i++){
        minb = min(b[i], minb);
    }
    int ans = mina+minb;
    for(int i = 0; i < M; i++) {
        int tmp = a[x[i]]+b[y[i]]-c[i];
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2176
inputstring = input()
count = 0
if len(inputstring) == 3:
  for i in inputstring:
    if i == 'A':
      count = count + 0
    else:
      count = count + 1
  if count == 0 or count == 3:
    print("No")
  else:
    print("Yes")
else:
  print()


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a==b) cout << "Draw" << endl;
  else if(a==1)cout << "Alice" << endl;
  else if(b==1) cout << "Bob" << endl;
  else if(a<=b) cout << "Bob" << endl;
  else cout << "Alice" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
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; }

int main() {
	
	const ll INF=1LL<<60;
	
	int n; cin >> n;
	
	vector<int> a(n+1),b(n);
	rep(i,n+1) cin >> a[i];
	rep(i,n) cin >> b[i];
	
	

	long long ans= 0;
	int r=0;
	
	rep(i,n){
		
		
		if(a[i]>=b[i]) ans+=b[i]; 
		else{
			ans+=a[i];
			ans+=min(b[i]-a[i],a[i+1]);
			a[i+1]-=min(b[i]-a[i],a[i+1]);
		}
	}
	
	
	
	cout << ans << endl;
	
	return 0;

}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    int a, b, c, d;
};

int main() {
    int n, m, q;
    cin >> n >> m >> q;

    vector<P> p(q);
    for (int i = 0; i < q; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        p[i] = { a, b, c, d };
    }

    int x[20];
    int k = n + m - 1;
    for (int i = 0; i < n; i++) {
        x[i] = 0;
    }
    for (int i = 0; i < m - 1; i++) {
        x[n + i] = 1;
    }

    int r = 0;
    do {
        int y[10];
        int j = 0, l = 0;
        for (int i = 0; i < k; i++) {
            if (x[i] == 0) {
                y[j++] = l;
            } else {
                l++;
            }
        }
        int s = 0;
        for (int i = 0; i < q; i++) {
            auto [a, b, c, d] = p[i];
            if (y[b] - y[a] == c) s += d;
        }
        r = max(r, s);
    } while (next_permutation(x, x + k));

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3568
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
const int mod=1e9+7;
const int N=1e5+3;
int dp0[N];//i digits from top  match s
int dp1[N];//not so
int32_t main()
{
  #ifndef ONLINE_JUDGE
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif

  string s;
  cin>>s;
  dp0[0]=1;int n=s.length();
  for(int i=0;i<n;i++)
  {
    if(s[i]=='0')
    {
      dp0[i+1]=dp0[i];
      dp1[i+1]=(3*dp1[i])%mod;//00 10 01
    }
    else
    {
      dp0[i+1]=(2*dp0[i])%mod;//cqn use 1 or 0
      dp1[i+1]=(dp0[i]+dp1[i]*3)%mod;
    }
  }
  cout<<(dp0[n]+dp1[n])%mod;


}

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

using namespace std;

const int N = 1e5+10;
const int INF = 1e9;

int dp[N];

int main() {
	int n, k;
	cin >> n >> k;

	vector<int> v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i];
	}

	dp[0] = 0;
	for(int i = 1; i < n; i++) {
		dp[i] = INF;
		for(int j = i-1; j >= max(0, i-k); j--){
			dp[i] = min(dp[i], dp[j]+abs(v[j]-v[i]));
		}
	}

	cout << dp[n-1];
}

Measured memory_bytes: 4056
#include <iostream>
#include <vector>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  l64 from[m], to[m], cost[m];
  for (int i = 0; i < m; ++i) {
    l64 a, b, c;
    cin >> a >> b >> c;
    from[i] = a-1; to[i] = b-1; cost[i] = c;
  }
  l64 prev[n], next[n];
  bool visit[n], n_visit[n];
  bool f=false;
  l64 best = -1000000001;
  for (int i = 0; i < n; ++i) {
    prev[i]=0; next[i]=0; visit[i]=false; n_visit[i]=false;
  }
  visit[0]=true;
  for (int ep = 0; ep < 2*n; ++ep) {
    for (int i = 0; i < m; ++i) {
      if (visit[from[i]]) {
        if (n_visit[to[i]]) {
          next[to[i]] = max(next[to[i]], prev[from[i]]+cost[i]);
        } else {
          next[to[i]] = prev[from[i]]+cost[i];
        }
        n_visit[to[i]]=true;
      }
    }
    if (n_visit[n-1]) {
      if (!f || best < next[n-1]) {
        if (ep >= n) {
          cout << "inf" << endl;
          return 0;
        }
        best = next[n-1];
        f = true;
      }
    }
    for (int i = 0; i < n; ++i) {
      prev[i] = next[i];
      next[i] = 0;
      visit[i] = n_visit[i];
      n_visit[i] = false;
    }
  }
  cout << best << endl;
  return 0;
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    val (a, b, k) = readLine()!!.split(' ').map { it.toInt() }
    var c = 0
    for (i in Math.min(a, b) downTo 1) {
        if (a % i == 0 && b % i == 0) {
            c++
            if (c == k) {
                println(i)
                break
            }
        }
    }
}

Measured memory_bytes: 38108
#include <stdio.h>
#include <stdlib.h>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))

typedef struct {
	int value;
	int indx;
} Pair;

int cmp(const Pair *x, const Pair *y);

int n;
Pair p[200005];

int main()
{
	int s, e;
	int m_len = 0;

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

	qsort(p, n, sizeof(Pair), (int (*)(const void *, const void *))cmp);

	s = e = 0;
	while (e < n) {

		while (p[e + 1].indx > p[e].indx) {
			e++;
		}

		m_len = max(m_len, e - s + 1);
		s = e = e + 1;
	}

	printf("%d\n", n - m_len);

	return 0;
}

int cmp(const Pair *x, const Pair *y)
{
	if (x->value > y->value) {
		return 1;
	} else if (x->value == y->value) {
		if (x->indx > y->indx) {
			return 1;
		} else if (x->indx == y->indx) {
			return 0;
		} else {
			return -1;
		}
	} else {
		return -1;
	}
}


Measured memory_bytes: 3324
H, W, K = map(int, input().split())
c = [input() for _ in range(H)]

ans = 0
for R in range(2**H):
    for C in range(2**W):
        n = 0
        for y in range(H):
            if R>>y&1:
                for x in range(W):
                    if C>>x&1:
                        if c[y][x]=="#":
                            n += 1
        if n==K:
          ans += 1
print(ans)


Measured memory_bytes: 9052
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int A,B;

std::vector<int> dec(int n){
	std::vector<int> v;
	int a=2;
	while(n>=a*a){
		if(n%a==0){
			v.push_back(a);
			n/=a;
		}
		else{
			a++;
		}
	}
	v.push_back(n);
	return v;
}

signed main(){
	cin>>A>>B;
	if(A==1&&B==1){
		cout<<1<<endl;
		return 0;
	}
	vector<int> v=dec(A);
	set<int> U,U2;
	REP(i,v.size()){
		U.insert(v[i]);
	}
	v=dec(B);
	REP(i,v.size()){
		U2.insert(v[i]);
	}
	int ans=0;
	for(auto x:U){
		if(U2.find(x)!=U2.end()){
			ans++;
			DEB(x)END
		}
	}
	cout<<ans+1<<endl;
	return 0;
}


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e5, mod = 1e9 + 7, dsz = 4;
int n, m, d[nsz + 5];

struct matrix {
	int n, m, d[dsz + 5][dsz + 5];
	
	matrix(int n = 0, int m = 0, bool e = 0) {
		this->n = n, this->m = m;
		loop (i, n) {
			loop (j, m) {
				d[i][j] = (i == j) & e;
			}
		}
	}
	
	matrix(vector< vector<int> > a) {
		n = a.size(), m = a[0].size();
		loop (i, n) {
			loop (j, m) {
				d[i][j] = a[i][j];
			}
		}
	}
	
	int* operator [] (int id) {
		return d[id];
	}
};
matrix a = matrix({
	{0, 1, 1, 0},
	{0, 1, 1, 0},
	{0, 1, 2, 2},
	{0, 1, 1, 1},
}),
b = matrix({
	{0, 0, 0, 0},
	{0, 1, 1, 0},
	{0, 0, 1, 2},
	{0, 0, 0, 1}
}),
res = matrix({
	{1},
	{0},
	{1},
	{1},
});

matrix inline operator * (matrix a, matrix b) {
	matrix res(a.n, b.m);
	loop (i, a.n) {
		loop (j, b.m) {
			loop (k, a.m) {
				res[i][j] = (res[i][j] + (num) a[i][k] * b[k][j] % mod) % mod;
			}
		}
	}
	return res;
}

matrix inline qpow(matrix a, int p) {
	matrix res(a.n, a.m, 1);
	for (; p; p >>= 1) {
		if (p & 1) {
			res = res * a;
		}
		a = a * a;
	}
	return res;
}

int main() {
	scanf("%d%d", &n, &m);
	cont (i, m) {
		scanf("%d", &d[i]);
	}
	cont (i, m) {
		res = qpow(a, d[i] - d[i - 1] - 1) * res;
		res = b * res;
	}
	res = qpow(a, n - d[m]) * res;
	printf("%d\n", res[0][0]);
}


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

typedef queue<int> Que;
int team[101], a, b, c, d, rank[101], k[101];
int n;
int main(){
  int tmp, l = 0, p = 1;
  Que q;
  cin >> n;
  for(int i = 0; i < n * (n - 1) / 2; i++){
    cin >> a >> b >> c >> d;
    if(c > d) team[a - 1] += 3;
    else if(c < d) team[b - 1] += 3;
    else team[a - 1]++, team[b - 1]++;
  }
  for(int i = 0; i < n; i++){
    k[i] = team[i];
  } 
  sort(k, k + n);
  reverse(k, k + n);
  tmp = k[0];
  q.push(tmp);
  for(int i = 1 ; i < n; i++){
    if(tmp == k[i]) continue;
    q.push(k[i]);
    tmp = k[i];
  }
  while(!q.empty()){
    l = 0;
    int u = q.front();
    q.pop();
    for(int i = 0; i < n; i++){
      if(team[i] == u){
	rank[i] = p;
	l++;
      }
    }
    if(l > 1)  p += l;
    else p++;
  }
  for(int i = 0; i < n; i++) cout << rank[i] << endl;
}

Measured memory_bytes: 1216
// こっちのほうが全探索よりも理解しやすかったりするかも
// 解説放送でやり方みてその後なにも見ずにAC
#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin >> s;
  string t = "ACGT";
  int ans = 0;
  int now = 0;
  for (int i = 0; i < s.size(); i++) {
    bool b = false;
    for (int j = 0; j < t.size(); j++) {
      if (s.at(i) == t.at(j)) b = true;
    }
    if (b) {
      now++;
      ans = max(ans, now);
    }
    else now = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const int INF=1e18;
const int MOD=1e9+7;
int n;
int piyo(int x,int k){
    return (x+k)%n;
}

signed main(){
    cin>>n;
    char s[n][n];
    REP(i,n)REP(j,n)cin>>s[i][j];
    int ans=0;
    REP(k,n){
        bool ok=true;
        REP(i,n)REP(j,n){
            if(s[piyo(i,k)][j]!=s[piyo(j,k)][i]){
                ok=false;
                break;
            }
        }
        if(ok)ans++;
    }
    cout<<ans*n<<endl;
}   

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int gcd(int a, int b){
    if(b==0)return a;
    return gcd(b, a%b);
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i, N)cin >> A[i];
    int g = A[0];
    bool ok = false;
    REP(i, N)g = gcd(g, A[i]);
    REP(i, N){
        if(A[i]>=K && (A[i]%g) == (K%g))ok = true;
    }
    cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int gcd(int m,int n){if(m%n==0)return n;else return gcd(n,m%n);}
int num(int a,int b,int c)
{
	if(a==b&&b==c)return 1;
	else if(a==b||b==c||c==a)return 3;
	else return 6;
}
int main()
{
	long s=0,n;cin>>n;
	for(long i=1;i<=n;i++)if(i%3&&i%5)s+=i;
	cout<<s<<'\n';
	return 0;
}


Measured memory_bytes: 3624
lines = input().split(" ")
K = int(lines[0])
X = int(lines[1])
arr = []

if K == 1:
  print(X)
else:
  for i in range(X , X + K):
    arr.append(i)
    
  for j in range(X - K + 1 , X):
    arr.append(j)
    
arr.sort()
map_result = map(str, arr)
result = ' '.join(map_result)
print(result)

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

int main()
{
    int n,m,s=0;

    cin>>n>>m;
   long int h[n],sum[n]={0},sum1[n]={0};
    for(int i=0;i<n;i++){
        cin>>h[i];

    }
    int a[m],b[m];
     for(int j=0;j<m;j++){
       cin>>a[j]>>b[j];
       sum[a[j]-1]++;
       sum[b[j]-1]++;

      if(h[a[j]-1]>h[b[j]-1]){
        sum1[a[j]-1]++;
      }
      else if(h[a[j]-1]<h[b[j]-1]){
        sum1[b[j]-1]++;
      }

     }

     for(int i=0;i<n;i++){
        if(sum[i]==sum1[i]){
            s++;
        }

     }
    cout<<s;
}


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

int main(){
    int n,d,x,a,c=0;
    cin>>n>>d>>x;
    for(int i=0;i<n;i++){
        cin>>a;
        c+=(d-1)/a+1;
    }
    cout<<c+x<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
int const INF = 1001001001;


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

int N; cin >> N;
vector<string> s(N);
vi t(N);
rep(i,N) cin >> s[i] >> t[i];
string X; cin >> X;

int p;
rep(i,N) {
    if(s[i] == X) p = i;
}
int ans = 0;
for(int i = p+1; i < N; ++i) {
    ans += t[i];
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;
lint p=1e9+7;
int main(){
  string S;
  cin>>S;
  lint dp[13]={0};
  dp[0]=1;
  for(auto c:S){
    lint b[13];
    REP(i,13)b[i]=0;
    if(c=='?'){
      REP(j,10)REP(k,13){
        b[(10*k+j)%13]+=dp[k];
      }
    }else{
      REP(k,13){
        b[(10*k+(c-'0'))%13]+=dp[k];
      }
    }
    REP(i,13)dp[i]=b[i]%p;
    // REP(i,13)cerr<<dp[i]<<" ";
    // cerr<<endl;
  }
  cout<<dp[5]<<endl;
  return 0;
}


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

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

    int N, M;
    cin >> N >> M;
    priority_queue<int> que;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        que.push(a);
    }
    for (int i = 0; i < M; i++) {
        int n = que.top();
        que.pop();
        que.push(n / 2);
    }
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
int n;
ll a[100000];
ll le[100000];
ll ri[100000];
ll gcd(ll c,ll b){
    if(b==0) return c;
    return (gcd(b,c%b));
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i=0;i<n;i++) cin>>a[i];
    ll g=a[0];
    le[0]=a[0];
    ri[n-1]=a[n-1];
    for(int i=1;i<n;i++){
        g=gcd(g,a[i]);
        le[i]=g;
    }
     g=a[n-1];
    for(int i=n-2;i>=0;i--){
        g=gcd(g,a[i]);
        ri[i]=g;
    }
    ll ans=max(ri[1],le[n-2]);
    for(int i=0;i<n-2;i++){
        ans=max(ans,gcd(le[i],ri[i+2]));
    }
    cout << ans<< "\n";
}

Measured memory_bytes: 2560
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e5)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));
    ll mi = A[0];
    ll ma = A.back();
    vector<P> v;
    for(ll i = 1; i < N-1; i++) {
        if(A[i] < 0) {
            v.push_back(make_pair(ma, A[i]));
            ma -= A[i];
        } else {
            v.push_back(make_pair(mi, A[i]));
            mi -= A[i];
        }
    }
    v.push_back(make_pair(ma, mi));
    print(ma - mi);
    rep(i, v.size()) {
        print(v[i].first << " " << v[i].second);
    }
    return 0;
}

Measured memory_bytes: 4336
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
A.append(0)

D = 0
for i in range(N+1):
    D += abs(A[i+1] - A[i])

for i in range(1, N+1):
    dist = D - (abs(A[i-1] - A[i]) + abs(A[i] - A[i+1])) + abs(A[i-1] - A[i+1])
    print(dist)

Measured memory_bytes: 14048
from collections import defaultdict

class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]

    def find(self, x):
        if self.par[x] != x:
            self.par[x] = self.find(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        self.par[x] = y

    def same(self, x, y):
        return self.find(x) ==  self.find(y)

n, m = map(int, input().split())
p = list(map(int, input().split()))
p = [v-1 for v in p]

uf = UnionFind(n)
for _ in range(m):
    x, y = map(int, input().split())
    uf.unite(x-1, y-1)

a = defaultdict(list)
b = defaultdict(list)
for i in range(n):
    k = uf.find(i)
    a[k].append(i)
    b[k].append(p[i])

ans = 0
for k in a.keys():
    ans += len(set(a[k]) & set(b[k]))

print(ans)


Measured memory_bytes: 48708
import numpy as np
n=int(input())
cnt=0
e =np.array([[int(i) for i in input().split()] for i in range(n)])
if (e[0,0]-e[0,1]-e[0,2])<0 or (e[0,0]-e[0,1]-e[0,2])%2!=0:
    cnt=1
    print("No")
if cnt==0:
    for j in range(1,n):
        step = e[j,0]-e[j-1,0]
        dist = abs(e[j,1]-e[j-1,1])+abs(e[j,2]-e[j-1,2])
        if step<dist or (step-dist)%2!=0:
            print("No")
            cnt=1
            break
if cnt==0:
    print("Yes")

Measured memory_bytes: 32472
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  int sum = A;
  if(B==1){
    cout << 0 << endl;
    return 0;
  }
  for(int p = 1; p <100; p++){
  if(sum >= B){
    cout << p << endl;
    return 0;
  }
  else{
    sum+= A-1;
  }
}
}

Measured memory_bytes: 256
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define endl '\n'


ll b, temp , n, ans, sum;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


while(cin >> b, b){

    n = sqrt(2*b);
    n++;
    ans = b;
    rep(i, 1, n){

    sum = (ll)(i)*(i+1)/2;
    if( (b-sum)%(i+1)==0  && (b-sum)>0 ){
        ans = i+1;
        //cout << ans << endl;
    }

    }

    if(ans == b){
        cout << b << " " << 1 << endl;
        continue;
    }

    cout  << (b - ((ans)*(ans-1)/2))/ans << " " << ans << endl;

}










return 0;}
///....



Measured memory_bytes: 3124
package main

import "fmt"

func main(){
	var x int
	fmt.Scan(&x)
	yokin := 100
	for i:=1; i<3762 ; i++ {
		yokin += int(float64(yokin/100))
		if yokin >= x {
			fmt.Println(i)
			break
		}
	}
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=3050;
const int M=100050;
const int mod=1e9+7;
void add(int &a, int b)
{ a+=b;if(a>=mod) a-=mod;}
void sub(int &a, int b)
{ a-=b;if(a<0) a+=mod;}
int a[N];
int dp[M];
int main()
{
int n,k;
scanf("%i %i",&n,&k);
for(int i=1;i<=n;i++)
scanf("%i",&a[i]),a[i]++;
dp[0]=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=k;j++)
add(dp[j],dp[j-1]);
for(int j=k;j>=0;j--)
if(j>=a[i])
sub(dp[j],dp[j-a[i]]);
}
printf("%i",dp[k]);
return 0;
}

Measured memory_bytes: 640
s=int(input())
MOD=10**9+7
fact=[0]*s
invfact=[0]*s
fact[0]=1
for i in range(1,s):
 fact[i]=fact[i-1]*i % MOD
invfact[s-1]=pow(fact[s-1],MOD-2,MOD)
for i in range(s-1,0,-1):
 invfact[i-1]=invfact[i]*i%MOD
def nCk(n, k):
 return fact[n]*invfact[k]*invfact[n-k]
ans = 0
for n in range(1,s):
 if 3*n>s:
  break
 ans+=nCk(s-2*n-1,n-1)
 ans%=MOD
print(ans)


Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) (m*n)/GCD(m,n)
# define mod 1000000007


int main()
{
    IOS;
    ll i,j,k,t,n,sum=0,prod=1,flag=0;
    ll cnt;
    cin >> n >> k;
    ll a[n];
    ll l=1,h=1000000000,mid;
    for(i=0;i<n;i++)
            cin >> a[i];
    ll ans=-1;
    while(l<h)
    {
        mid=(h+l)/2;
        cnt=0;
        for(i=0;i<n;i++)
             {
                if(a[i]%mid==0)
                   cnt+=(a[i]/mid)-1;
                else
                    cnt+=a[i]/mid;
             }
        if(cnt<=k)
            h=mid;
        else
           l=mid+1;
    }
    cout << l;
}


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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CN cout<<"No\n"
#define CY cout<<"Yes\n"

using namespace std;
using ll = long long;
void solve()
{
    ll n,m; cin>>n>>m;
    ll k; cin>>k;
   // ll arr[n][m]={0};
    // rep(i,n)
    // {
    //     rep(j,m) arr[i][j]=0;
    // }
    set<pair<ll,ll>>s;
    map<ll,ll>row,col;
    for(int i=0;i<k;i++)
    {
        ll x,y; cin>>x>>y;
        s.insert({x-1,y-1});
        row[x-1]++;
        col[y-1]++;
    }
    ll ans=0;
    ll i,j;
    for(auto e:row)
    {
        ans=max(e.S,ans);
    }
    set<ll>r,c;
    for(auto e:row)
    {
        if(e.S==ans)
        {
            r.insert(e.F);
        }
    }
    ll rmax,cmax;
    rmax=ans;
    ll op=ans;
    ans=0;
    for(auto e:col)
    {
        ans=max(e.S,ans);
    }
    for(auto e:col)
    {
        if(e.S==ans)
        {
            c.insert(e.F);
        }
    }
    cmax=ans;
    op+=ans;
    ll f=1;
    ll c1=0,c2=0;
    for(auto e:s)
    {
        ll rr=e.F;
        ll cc=e.S;
      //  cout<<rr<<" "<<cc<<"\n";
        if(row[rr]==rmax&&col[cc]==cmax)
        {
            c1++;
        }
    }
    if(c1==(r.size()*c.size())) f=1;
    else f=0;
    cout<<op-f<<"\n";

}
int main()
{
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    int t;t=1;
 //  cin>>t;
    while(t--)
        {solve();}
    return 0;
}

Measured memory_bytes: 88024
#include<bits/stdc++.h>
using namespace std;
const bool DEBUG = true;
#define coutd if(DEBUG) cout 
#define ff first
#define ss second
#define debug(x) cout << "> x:" << x << endl;
#define len(x) int(x.size())
#define all(x) x.begin(), x.end()
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(){
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vi vs(n);
	for(int i=0; i<n; ++i) cin >> vs[i];
	int w=0;
	int ans=0;
	for(int i=1; i<n; ++i){
		if(vs[i]>vs[i-1]){
			ans=max(w, ans); 
			w=0;
		}
		else{
			++w;
		}
	}
	cout << max(w, ans) << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define first fi
#define second se
#define MOD 1000000007
#define MAXN 200005
#define endl "\n"
#define readln(x) getline(cin, x);
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
ll fpow(ll x, ll n, ll mod){if (n==0) return 1%mod; ll u = fpow(x, n/2, mod); u = (u*u)%mod; if (n%2==1)u = (u*x)%mod;return u;}
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
 
ll N, a[MAXN], freq[MAXN];
 
ll count(ll n){
    if (n < 2) return 0;
    return (n*(n-1))/2;
}
int main(){
    //freopen("data.txt","r",stdin);
    cin >> N;
    for (int i = 1; i<=N; i++){
        cin >> a[i];
        freq[a[i]]++;
    }
    ll total = 0;
    for (int i = 1; i<=N; i++){
        total += count(freq[i]);
    }
    for (int i = 1; i<=N; i++){
        ll temp = total;
        temp -= count(freq[a[i]]);
        temp += count(freq[a[i]]-1);
        cout << temp << endl;
    }
 
    return 0;
}

Measured memory_bytes: 4736
#include <stdio.h>

int main(){
  int n, a[100], i, count=0, flag=1, b;
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &a[i]);
  }

  while(flag==1){
    flag=0;
    for(i=n-1; i>0; i--){
      if(a[i]<a[i-1]){
	b=a[i];
	a[i]=a[i-1];
	a[i-1]=b;
	count++;
	flag=1;
      }
    }
  }

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



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

int main() {
  char c;
  cin >> c;
  if(c == 'A') cout << 'T' << endl;
  else if(c == 'T') cout << 'A' << endl;
  else if(c == 'G') cout << 'C' << endl;
  else cout << 'G' << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    ((a==5 && b==5 && c==7)||(a==7 && b==5 && c==5)||(a==5 && b==7 && c==5))?cout<<"YES":cout<<"NO";
}


Measured memory_bytes: 3596
/******************************\
*  Everyone has a different way of thinking, so God Created us
Hope You Respect My Way..,Thank You ):  *
*                            *
*   Created by : Murad   *
\******************************/
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define MP make_pair
#define ff first
#define ss second
#define INF 2147483647
#define _INF -2147483647
#define pq priority_queue
#define MM multimap
#define PB push_back
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
LL MMIN(LL a, LL b)
{
	if (a <= b)
		return a;
	else
		return b;
}
LL MMAX(LL a, LL b) {
	if (a >= b)
		return a;
	else
		return b;
}
int main()
{
	El3zba;
	int n;
	cin >> n;
	vector<int>a(n+1), b(n+1), c(n);
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++)cin >> b[i];
	for (int i = 1; i <= n-1; i++)
		cin >> c[i];
	int previdx = -1,sum=0;
	for (int i = 1; i <= n; i++)
	{
		int idx = a[i];
		int val = b[idx];
		sum += val;
		if (previdx == -1)
		{
			previdx = idx;
		}
		if (previdx != -1 && idx - previdx == 1)
		{
			sum += c[previdx];
			previdx = idx;
		}
		else
			previdx = idx;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<ll,P> PP;
int main() {
	int n, m; cin >> n >> m; cout << (n - 1)*(m - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
int main() {
	int H, W, K;
	scanf("%d %d %d", &H, &W, &K);
	int choc[H + 1][W + 1];
	memset(choc, 0, sizeof choc);
	char c;
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) scanf(" %c", &c), choc[i][j] = c - '0';
	}
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) choc[i][j] += choc[i - 1][j] + choc[i][j - 1] - choc[i - 1][j - 1];
	}
	int ans = 1000000000;
	for (int i = 0; i < (1 << (H - 1)); ++i) {
		vector<int> cuts;
		int lastcut = 0, tans = 0;
		cuts.push_back(0);
		for (int j = 0; j < H - 1; ++j) {
			if (i & (1 << j)) cuts.push_back(j + 1);
		}
		cuts.push_back(H);
		for (int j = 1; j <= W; ++j) {
			bool cut = false;
			for (int k = 1; k < cuts.size(); ++k) {
				if (choc[cuts[k]][j] - choc[cuts[k - 1]][j] - choc[cuts[k]][lastcut] + choc[cuts[k - 1]][lastcut] > K) cut = true;
			}
			if (cut && lastcut == j - 1) {
				tans = 1000000000;
				break;
			} else if (cut) lastcut = j - 1, ++tans;
		}
		ans = min(ans, tans + (int) cuts.size() - 2);
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = []

for i in range(n):
    temp = list(map(int, input().split()))
    a.append(temp)

#print(a)
count = 0

for i in range(n):
    ans = c
    for j in range(m):
        ans += a[i][j] * b[j]

    if ans > 0:
        count += 1

print(count)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt(),s = scanner.nextInt();
		int count = 0;
		for(int i=0;i<=k;i++){
			int sum = 0;
			for(int j=0;j<=k;j++){
				sum = i + j;
				if((s-sum) >= 0 && (s-sum) <= k){
					count++;
				}
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

int main(){
  ull a; cin >> a;
  double b; cin >> b;
  ull bb = b*100+0.5;
  ull ans = a*bb;
  ans /= 100;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3708
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

#include<vector>
template<typename T>
class UnionFind
{
	public:
	vector<T> parent;
	
	UnionFind(T n):parent(n)
	{
		for(int i=0;i<n;i++)
			parent[i]=i;
	}
	
	void unite(T a,T b)
	{
		a=root(a);
		b=root(b);
		if(a==b)return;
		if(a>b)swap(a,b);
		parent[b]=a;
		return;
	}
	
	T root(T n)
	{
		if(parent[n]==n)
			return n;
		else
		{
			T ret=root(parent[n]);
			parent[n]=ret;
			return ret;
		}
	}
};

int main()
{
	int N,M;
	int p[100010]={};
	
	cin >> N >> M;
	UnionFind<int> uf(N);
	for(int i=0;i<N;i++)
	{
		cin >> p[i];
		p[i]--;
	}
	for(int i=0;i<M;i++)
	{
		int x,y;
		cin >> x >> y;
		uf.unite(p[x-1],p[y-1]);
	}
	
	int ans=0;
	for(int i=0;i<N;i++)
	{
		if(uf.root(i)==uf.root(p[i]))
			ans++;
	}
	
	cout << ans << endl;
	return 0;
}

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

int main() {
  // ここにプログラムを追記
  double currentScore;
  double goleScore;
  double nextScore;
  
  cin >> currentScore;
  cin >> goleScore;
  
  nextScore = goleScore + (goleScore - currentScore);
  
  cout << nextScore << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n,x,t,num,count;

    scanf("%d %d %d",&n,&x,&t);
    num = count = 0;
    
    while(count < n)
    {
        num += t;
        count += x;
    }

    printf("%d\n",num);

    return 0;
}

Measured memory_bytes: 2152
#include <iostream>
#include <string>

using namespace std;

int main() {
    string S;
    cin >> S;
    int rewrite1 = 0, rewrite2 = 0;
    for (int i = 0; i < S.length(); ++i) {
        if (i % 2 == 0) {
            if (S[i] != '0') ++rewrite1;
        } else {
            if (S[i] != '1') ++rewrite1;
        }
    }
    for (int i = 0; i < S.length(); ++i) {
        if (i % 2 == 0) {
            if (S[i] != '1') ++rewrite2;
        } else {
            if (S[i] != '0') ++rewrite2;
        }
    }
    cout << (rewrite1 < rewrite2 ? rewrite1 : rewrite2) << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
const int maxnum = 100000;
int n; //the number of number
int Array[maxnum];
int main()
{
    cin>>n;
    int y_max;
    int y_min;
    long y_sum;
    for (int i = 0 ; i < n ; i++)
    {
        cin>>Array[i];
    }
    y_max = Array[0] ;
    y_min = Array[0];
    y_sum = 0;
    for (int y=0;y<n;y++)
    {
        if(y_min < Array[y])
        {
        }
        else
            y_min = Array[y];
    }
    for (int z=0;z<n;z++)
    {
        if(y_max > Array[z])
        {
        }
        else
            y_max = Array[z];
     
    }
    for (int m=0;m<n;m++)
    {
        y_sum +=  Array[m];
    }
    cout<<y_min<<' '<<y_max<<' '<<y_sum<<endl;
    return 0;
}

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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}

const int MAXN = 2e5 + 5;
const int oo = 0x3f3f3f3f;
const int L = bin(28);

int N, a[MAXN], d[35];

struct S {
	int num[MAXN];
	int get(int v){
		int n = lower_bound(num + 1, num + N + 1, v + 1) - num - 1;
		return n;
	}
	int get(int cl, int cr) {
		return get(cr) - get(cl - 1);	
	}
}ss[35];

int main(){
	scanf("%d", &N);
	up (i, 1, N) scanf("%d", &a[i]);
	up (o, 0, 28) {
		up (i, 1, N) ss[o].num[i] = a[i] & (bin(o + 1) - 1);
		sort(ss[o].num + 1, ss[o].num + N + 1);
	}
	up (i, 1, N) {
		int v; scanf("%d", &v);
		up (o, 0, 28) {
			int w = v & (bin(o + 1) - 1);
			int sum = ss[o].get(bin(o) - w, bin(o + 1) - 1 - w);
			sum += ss[o].get(bin(o) + bin(o + 1) - w, bin(o + 2) - 1 - w);
			d[o] ^= sum & 1;
		}
	}
	int ans = 0;
	up (i, 0, 28) if (d[i]) ans |= bin(i);
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll A, B, X;

int main(){
  cin >> A >> B >> X;
  if (A == 0) cout << B / X + 1 << endl;
  else cout << B / X - (A - 1) / X << endl;


  return 0;
}


Measured memory_bytes: 3640
//package abc055a;

import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		int n, x, y, ans = 0;
		
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		x = 800 * n;
		y = 200 * (n / 15);
		ans = x - y;
		System.out.println(ans);
	}

}


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

int main(){
  int tmp;
  vector<int>a(4);
  vector<char>b(4);
  vector<char>ans(3);
  for(int i=0;i<4;i++){
    cin>>b.at(i);
    a.at(i)=(int)(b.at(i)-'0');
  }
  tmp=a.at(0);
  for(int i=0;i<(1<<3);i++){
    a.at(0)=tmp;
    for(int j=0;j<3;j++){
      if(i>>j&1){
        a.at(0)+=a.at(j+1);
        ans.at(j)='+';
      }
      else{
        a.at(0)-=a.at(j+1);
        ans.at(j)='-';
      }
    }
    if(a.at(0)==7)
      break;
  }
  cout <<tmp;
  for(int i=0;i<3;i++){
    cout <<ans.at(i)<<a.at(i+1);
  }
  cout <<"=7"<<endl;
}

Measured memory_bytes: 256
def gcd(a,b):
    x = max(a,b)
    y = min(a,b)

    while True:
        n = x%y
        if n == 0:
            print(y)
            break
        else:
            x = y
            y = n


a,b = map(int,input().split())
gcd(a,b)

Measured memory_bytes: 7612
import itertools
import math
import fractions
import functools
n, m = map(int, input().split())
py = []
for i in range(m):
    l = list(map(int, input().split()))
    l.append(i)
    py.append(l)

# py = [p,y,index]

# yでsort
py.sort(key=lambda x: x[1])

prev = 0
py.sort(key=lambda x: x[0])
# py = [p, y, index, pの中でのindex]
for i in range(m):
    if prev != py[i][0]:
        prev = py[i][0]
        x = 1

    py[i].append(x)
    x += 1
py.sort(key=lambda x: x[2])

p_i = ""
x_i = ""
for i in range(m):
    if(len(str(py[i][0])) == 6):
        p_i = str(py[i][0])
    if(len(str(py[i][0])) == 5):
        p_i = '0' + str(py[i][0])
    if(len(str(py[i][0])) == 4):
        p_i = '00'+str(py[i][0])
    if(len(str(py[i][0])) == 3):
        p_i = '000' + str(py[i][0])
    if(len(str(py[i][0])) == 2):
        p_i = '0000'+str(py[i][0])
    if(len(str(py[i][0])) == 1):
        p_i = '00000' + str(py[i][0])
    if(len(str(py[i][3])) == 6):
        x_i = str(py[i][3])
    if(len(str(py[i][3])) == 5):
        x_i = '0' + str(py[i][3])
    if(len(str(py[i][3])) == 4):
        x_i = '00'+str(py[i][3])
    if(len(str(py[i][3])) == 3):
        x_i = '000' + str(py[i][3])
    if(len(str(py[i][3])) == 2):
        x_i = '0000'+str(py[i][3])
    if(len(str(py[i][3])) == 1):
        x_i = '00000' + str(py[i][3])

    print(p_i + x_i)


Measured memory_bytes: 117332
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N; cin >> N;
    long long ans = 1;
    REP(i, N+1) {
        ans *= i;
        ans%= INF;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define mod 1000000007
#define PI 3.1415926535
using namespace std;
ll power(ll x, ll y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return power(x, y / 2) * power(x, y / 2);
	else
		return x * power(x, y / 2) * power(x, y / 2);
}
ll modExpo(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modExpo((x*x)%mod,n/2);
    else                            
        return (x*modExpo((x*x)%mod,(n-1)/2))%mod;
 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	auto start_time = clock();
	cerr << setprecision(3) << fixed;
#endif
	vector<ll> a(2),b(2);
	cin>>a[0]>>a[1]>>b[0]>>b[1];
	ll ans=LONG_MIN;
	for(ll i=0;i<2;i++)
	{
		for(ll j=0;j<2;j++)
			ans=max(ans,a[i]*b[j]);
	}
	cout<<ans<<endl;
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}

Measured memory_bytes: 3656
import java.util.Scanner;

class Main{
    
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        while(true){
        
        int a=sc.nextInt();
        int b=sc.nextInt();
        int p;
        
        if(a==0&&b==0) break;
        
        
        if(b<a){
        p=b;
        b=a;
        a=p;
        }
        
        System.out.println(a+" "+b);
        }
        
    }
    
}


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

int a[200010], u[200010], p[200010];
map<int,int> zip;
class BinaryIndexedTree{
public:
	vector<int> bit;
	int n = 1;
	void init(int m){
		while(n < m)n *= 2;
		bit.resize(n+1);
	}
	int get(int k){
		int s = 0;
		while(0 < k){
			s += bit[k];
			k -= k&-k;
		}
		return s;
	}
	void add(int k, int x){
		while(k <= n){
			bit[k] += x;
			k += k&-k;
		}
	}
};

void compress(int n){
	vector<int> v;
	for(int i = 0;i <= n;i++)v.push_back(p[i]);
	sort(v.begin(), v.end());
	for(int i = 0;i < v.size();i++){
		zip[v[i]] = i+1;
	}
}

signed main(){
	BinaryIndexedTree BIT;
	int n, k, ans = 0;
	scanf("%lld%lld", &n, &k);
	for(int i = 1;i <= n;i++)scanf("%lld", &a[i]);
	for(int i = 1;i <= n;i++)a[i] += a[i-1];
	for(int i = 1;i <= n;i++)u[i] = u[i-1]+k;
	for(int i = 1;i <= n;i++)p[i] = a[i]-u[i];
	compress(n);
	BIT.init(n+1);
	for(int i = 0;i <= n;i++){
		int x = zip[p[i]];
		ans += BIT.get(x);
		BIT.add(x, 1);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 19540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n, k;
    cin >> n >> k;
    for (ll i = 0; i < n; i++) {
        ll t;
        cin >> t;
    }
    cout << (n + k - 3) / (k - 1) << endl;
}

Measured memory_bytes: 3612
package main
 
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)
 
var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func main() {
  NM := NextIntVec()
  D := make([]int, NM[0])
  E := make([][]int, NM[0])
  for i := range E {
    E[i] = make([]int, 0)
  }
  for i := 0; i < NM[1]; i++ {
    P := NextIntVec()
    D[P[0] - 1] = 1 - D[P[0] - 1]
    D[P[1] - 1] = 1 - D[P[1] - 1]
    E[P[0] - 1] = append(E[P[0] - 1], P[1] - 1)
    E[P[1] - 1] = append(E[P[1] - 1], P[0] - 1)
  }
  ans := ""
  for i := 0; i < NM[0]; i++ {
    if D[i] == 0 {
      continue
    }
    even := 0
    for _, adj := range E[i] {
      even ^= 1 - D[adj]
    }
    if even == 0 {
      ans = "NO"
      break
    }
  }
  if ans == "" {
    ans = "YES"
  }
  Write(ans)
  Output()
}

Measured memory_bytes: 10496