akhauriyash/Code-Regression huggingface dataset:
def find(idx):
    global tree
    while True:
        if tree[idx].root == True:
            return tree[idx].prev, tree[idx].size
        else:
            idx = tree[idx].prev

class Union_Find:
    def __init__(self, prev):
        self.root = True
        self.size = 1
        self.prev = prev

N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(M)]
AB.reverse()
ans = [(N*(N-1))//2]
tree = {i:Union_Find(i) for i in range(1, N+1)}

for A, B in AB[:-1]:
    root_A, size_A = find(A)
    root_B, size_B = find(B)

    if root_A == root_B:
        ans.append(ans[-1])
    else:
        if size_A > size_B:
            x, y = root_B, root_A
        else:
            x, y = root_A, root_B

        tree[x].root = False
        tree[x].prev = y
        tree[y].size += tree[x].size

        ans.append(ans[-1] - size_A * size_B)

[print(max(0, i)) for i in ans[::-1]]


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

// input
int H, W, ch, cw, dh, dw;
vector<string> S;

const int INF = 1e9;
const int MAX = 1e3 + 2;
char s[MAX][MAX];
int w[MAX][MAX];
bool vis[MAX][MAX];


void input() {
    cin >> H >> W >> ch >> cw >> dh >> dw;
    S = vector<string>(H);
    rep(i, H) cin >> S[i];
}


int main() {
    input();
    rep(i, MAX) rep(j, MAX) {
        s[i][j] = '#';
        w[i][j] = INF;
        vis[i][j] = false;
    }
    rep(i, H) rep(j, W) s[i + 1][j + 1] = S[i][j];
    w[ch][cw] = 0;
    priority_queue<tp, vector<tp>, greater<tp>> pq;
    pq.push(tp(0, ch, cw));
    while (!pq.empty()) {
        int cost, x, y;
        tie(cost, x, y) = pq.top();
        pq.pop();
        if (vis[x][y]) continue;
        if (x == dh && y == dw) break;
        vis[x][y] = true;
        if (s[x - 1][y] == '.') {
            if (w[x - 1][y] > cost) {
                w[x - 1][y] = cost;
                pq.push(tp(cost, x - 1, y));
            }
        }
        if (s[x][y - 1] == '.') {
            if (w[x][y - 1] > cost) {
                w[x][y - 1] = cost;
                pq.push(tp(cost, x, y - 1));
            }
        }
        if (s[x + 1][y] == '.') {
            if (w[x + 1][y] > cost) {
                w[x + 1][y] = cost;
                pq.push(tp(cost, x + 1, y));
            }
        }
        if (s[x][y + 1] == '.') {
            if (w[x][y + 1] > cost) {
                w[x][y + 1] = cost;
                pq.push(tp(cost, x, y + 1));
            }
        }
        for (int i = max(0, x - 2); i <= min(H, x + 2); i++) {
            for (int j = max(0, y - 2); j <= min(W, y + 2); j++) {
                if (s[i][j] == '#') continue;
                if (w[i][j] > cost + 1) {
                    w[i][j] = cost + 1;
                    pq.push(tp(cost + 1, i, j));
                }
            }
        }
    }
    int ans = w[dh][dw];
    if (ans == INF) ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 11392
/// Author: Sarfaraz Alam
# include <bits/stdc++.h>
# define pb push_back
# define ll long long

# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG
typedef unsigned long long int ull;
using namespace std;

const int N = 1e5 + 7;
const int mod = 1e9 + 7;

int n, a[N], ans = 1, x;

int main()
{
    speed;
    #ifdef DEBUGfd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG

    //Code begins
    ull n;
    cin>>n;
    ull sum = 0;
    ull t = 0;

    while(sum< n)
    {

        t++;
        sum += t;
    }
    cout<<t<<endl;






    return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

ll lcm(ll a,ll b){
	if(a<b){
		swap(a,b);
	}

	ll x = a*b;
	ll r = a % b;
	while(r!=0){
		a = b;
		b = r;
		r = a % b;
	}
	return x/b;
}

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

	ll A=in<ll>(),B=in<ll>(),C=in<ll>(),D=in<ll>();
	ll lcmCD = lcm(C,D);
	ll MAC=A/C,MAD=A/D,MACD=A/(lcmCD);
	ll MBC=B/C,MBD=B/D,MBCD=B/(lcmCD);
	ll N = (-(A-MAC-MAD+MACD)+(B-MBC-MBD+MBCD));
	if(A%C && A%D) N++;

	cout << N << endl;
	return 0;
}


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

int main() {
	string s;
	cin >> s;
	int r = 0, b = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') r++;
		else b++;
	}
	cout << min(r, b) * 2 << endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	int d;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if (a > b) {
		d = a;
		a = b;
		b = d;
	}
	if (b > c) {
		d = b;
		b = c;
		c = d;
	}
	if (a > b) {
		d = a;
		a = b;
		b = d;
	}
	
	printf("%d %d %d\n", a, b, c);
	
	return (0);
}

Measured memory_bytes: 1024
INF = 10 ** 20
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  heapq import heappop,heapify,heappush

def main():
    n = int(input())
    a = list(map(int,input().split()))
    
    lM = [0] * (n + 1)
    rm = [0] * (n + 1)

    q = []
    cumsum = 0
    for i in range(n):
        heappush(q,a[i])
        cumsum += a[i]
    
    lM[0] = cumsum
    drop = 0
    for i in range(n,2 * n):
        heappush(q,a[i])
        drop += heappop(q)
        cumsum += a[i]
        lM[i - n + 1] = cumsum - drop
    
    q = []
    cumsum = 0
    for i in range(3 * n - 1,2 * n - 1,-1):
        heappush(q,-a[i])
        cumsum += a[i]
    
    rm[-1] = cumsum
    drop = 0
    for i in range(2 * n - 1,n - 1,-1):
        heappush(q,-a[i])
        drop -= heappop(q)
        cumsum += a[i]
        rm[i - n] = cumsum - drop
    
    ans = -INF
    for i in range(n + 1):
        ans = max(ans,lM[i] - rm[i])
        
    print(ans)
if __name__ == '__main__':
    main()


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

typedef long long ll;

int main() {
  int N; ll K; cin >> N >> K;
  vector<ll>A(N);
  for ( int i = 0; i < N; i++ ) cin >> A[i];


  ll ans = 0;
  for ( int d = 41;  d >= -1; d-- ) {
    if ( d != -1 && !(K & (1LL<<d))) continue;
    ll tmp = 0;
    for ( int e = 41; e >= 0; e-- ) {
      ll mask = 1LL<<e;
      int num = 0;
      for ( int i = 0; i < N; i++ ) if ( mask & A[i] ) num++;
      if ( e > d ) {
	if ( K & mask ) tmp += mask*(N-num);
	else tmp += mask*num;
      } else if ( e == d ) {
	tmp += mask*num;
      } else if ( e < d ) {
	tmp += mask*max(num,N-num);
      }
    }
    ans = max(tmp,ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>

using namespace std;

int dp[10000][100];

int main(void) {
    int N,W,v[200],w[200],res=0;
    scanf("%d%d",&N,&W);
    for(int i=0; i<N; i++)
        scanf("%d%d",&v[i],&w[i]);

    for(int i=0; i<N; i++) {
        for(int j=0; j<w[i]; j++)
            dp[j][i+1] = dp[j][i];
        for(int j=w[i]; j<=W; j++)
            dp[j][i+1] = max(dp[j-w[i]][i]+v[i], dp[j][i]);
    }
    for(int j=0; j<=W; j++)
        res = max(res, dp[j][N]);
    printf("%d\n", res);

    return 0;
}

Measured memory_bytes: 4928
Program ABC123C

integer(8) n,a(5)

read(*,*) n,a

if (mod(n,min(a(1),a(2),a(3),a(4),a(5)))==0) then
 write(*,*) n/min(a(1),a(2),a(3),a(4),a(5))-1+5
else
 write(*,*) n/min(a(1),a(2),a(3),a(4),a(5))+5
end if

stop
end

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int> >vec;
map<pair<int,int>,bool>mp;
int main()
{
   int a=1,b=399,i;
   for(i=0;i<8;i++)
   {
      vec.push_back({a,b});

     // cout<<a<<" "<<b<<endl;
      if(i==0)a+=399;
      else a+=400;
      b+=400;
   }
   int n,x,j,cnt=0;
   cin>>n;
   for(j=1;j<=n;j++)
   {
      cin>>x;
      bool f=false;
      for(i=0;i<vec.size();i++)
      {
         if(x>=vec[i].first&&x<=vec[i].second)
         {
            mp[{vec[i].first,vec[i].second}]=true;
            f=true;
            break;
         }
      }
      if(!f)cnt++;
   }
   int cnt2=0;
   for(i=0;i<vec.size();i++)
   {
      if(mp[{vec[i].first,vec[i].second}])cnt2++;
   }
   //cout<<cnt2<<endl;
   if(cnt==n)cout<<1<<" "<<cnt+cnt2<<endl;
   else cout<<cnt2<<" "<<cnt+cnt2<<endl;
   mp.clear();
   vec.clear();
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
int main() {
    int h;
    cin >> h;
    int w;
    cin >> w;
    vector<string> a(h);
    for (int i = 0; i < h; i++) {
        cin >> a[i];
    }
 
    vector<bool> row(h, false);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] == '#') {
                row[i] = true;
                break;
            }
        }
    }
    
    vector<bool> col(w, false);
    for (int j = 0; j < w; j++) {
        for (int i = 0; i < h; i++) {
            if (a[i][j] == '#') {
                col[j] = true;
                break;
            }
        }
    }
 
    for (int i = 0; i < h; i++) {
        if (row[i]) {
            for (int j = 0; j < w; j++) {
                if (col[j]) {
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int t,n;
  for(int i=0;i<4;i++){
    cin>>t>>n;
    if(t==1) cout<<n*6000<<'\n';
    else if(t==2) cout<<n*4000<<'\n';
    else if(t==3) cout<<n*3000<<'\n';
    else if(t==4) cout<<n*2000<<'\n';
  }
  return(0);
}



Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>

using namespace std;
int main() {
	int N, a, ans[2] = {0,0}, cnt;
	cin >> N;
	if (N >= 64) {
		cout << 64 << endl;
		return 0;
	}
	while (N>1) {
		cnt = 0;
		a = N;
		if (N >= 64) {
			cout << 64 << endl;
			return 0;
		}
		if (N >= 32) {
			cout << 32 << endl;
			return 0;
		}
		while (1) {
			if (a % 2 == 1) {
				if (ans[0] < cnt ) {
					ans[0] = cnt;
					ans[1] = N;
				}
				break;
			}
			cnt++;
			a /= 2;
			if (a == 1) {
				cout << N << endl;
				return 0;
			}
			
		}
		N--;
		if (N == 1) {
			break;
		}
	}
	if (ans[1] == 0) ans[1]++;
	cout << ans[1] << endl;
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int n, r;
    cin >> n >> r;
    int ans;
    if (n >= 10)
        ans = r;
    else
        ans = r + 100 * (10 - n);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N, C = map(int, input().split())
    D = np.array([list(map(int, input().split())) for i in range(C)])
    board = [list(map(int, input().split())) for i in range(N)]

    # cost[i][j] := mod3==iのグループを色jにする際の違和感の総和
    cost = np.zeros((3, C), dtype=int)
    for i in range(N):
        for j in range(N):
            cost[(i+j)%3] += D[board[i][j] - 1]

    ans = int(1e20)
    for i in range(C):
        for j in range(C):
            if i == j:
                continue
            for k in range(C):
                if k==i or k==j:
                    continue
                ans = min(ans, cost[0][i] + cost[1][j] + cost[2][k])
    print(ans)

if __name__ == "__main__":
    main()

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

using namespace std;

int main() {
  int n, q;
  cin >> n >> q;
  vector<stack<int> > stk(n);
  while(q--) {
    int k, t;
    cin >> k >> t;
    if(k == 0) {
      int x;
      cin >> x;
      stk[t].push(x);
    } else if(k == 1) {
      if(stk[t].empty()) continue;
      cout << stk[t].top() << endl; // error
    } else if(k == 2) {
      if(stk[t].empty()) continue;
      stk[t].pop(); // error
    } else {
      assert(false);
    }
  }
  return 0;
}



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


int main()
{
	int n, count=0;

	while (cin >> n)
	{
		count = 0;
		for (int i = 0; i < 10; i++)
		{
			for (int j = 0; j < 10; j++)
			{
				for (int k = 0; k < 10; k++)
				{
					for (int l = 0; l < 10; l++)
					{
						if (i + j + k + l == n) count++;
					}
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
#define minn(x,y) x=min(x,y)
#define maxx(x,y) x=max(x,y)
using namespace std;
int main()
{
	int i,j,k,n,m,x,y,z,t;
	scanf("%d%d%d",&n,&m,&t);
	printf("%d",(n+m-1)/m*t);
}


Measured memory_bytes: 3812
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ll;
vector<ll > vec;

int main(){

    string s;
    cin >> s;
    //圧縮
    for(ll i = 0; i < s.length();){
        ll j = i;
        //一緒の間ループを回し続けて，切れ目を探す
        while(j < s.length() && s[j] == s[i]){
            ++j;
        }
        vec.push_back(j - i);
        //次の始点へすっ飛ばす
        i = j;
    }

    ll ans = 0;
    ll idx = 0;
    //1つ飛ばす
    if(s[0] == '>'){
        ans +=  (vec[0] * (vec[0]+1)) / 2;
        idx = 1;
    }
    //番兵
    if((vec.size() + idx) % 2 != 0){
        vec.push_back(1);
    }
    for(ll i = 1 + idx; i < vec.size(); i+=2){
        if(vec[i] >= vec[i-1]){
            ans +=  ((vec[i-1]-1) * vec[i-1]) / 2;
            ans +=  (vec[i] * (vec[i] + 1)) / 2;
        }else{
            ans +=  (vec[i-1]* (vec[i-1]+1)) / 2;
            ans +=  ((vec[i]-1) * vec[i]) / 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
  ll N;
  cin>>N;
 vector<ll>A(N);
 int denied=0;  
  for(int i=0;i<N;i++){
  cin>>A[i];
if(A[i]%2==0){
if(A[i]%3!=0&&A[i]%5!=0){denied=1;}
}
  }
  
  if(denied==1){
  cout<<"DENIED"<<endl;
  }
  else{
    cout<<"APPROVED"<<endl;
  }

  
  
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
set<P> st;
ll nt[100][100];
void getpath(ll s,ll e){
  vector<ll> tmp;
  for(ll c=s;c!=e;c=nt[c][e]){
    tmp.push_back(c);
  }
  tmp.push_back(e);
  for(int i=0;i<tmp.size()-1;i++){
//    cout << tmp[i]<<" "<<tmp[i+1]<<endl;
    st.insert(P(min(tmp[i],tmp[i+1]),max(tmp[i],tmp[i+1])));
  }
}
signed main(){
  ll n,m;
  cin >> n >> m;
  ll a[m],b[m],c[m],d[n][n];
  fill(d[0],d[n],INF);
  for(int i=0;i<n;i++){
    d[i][i]=0;
    for(int j=0;j<n;j++){
      nt[i][j]=j;
    }
  }
  for(int i=0;i<m;i++){
    cin >> a[i]>>b[i]>>c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(d[i][k]+d[k][j]<d[i][j]){
          d[i][j] = d[i][k]+d[k][j];
          nt[i][j] = nt[i][k];
        }
      }
    }
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      getpath(i,j);
    }
  }
  cout << m - st.size()<<endl;
}


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

int main(){
  std::string base;
  std::cin >> base;
  if(base == "A")
    std::cout<<"T"<<std::endl;
  if(base == "T")
    std::cout<<"A"<<std::endl;
  if(base == "C")
    std::cout<<"G"<<std::endl;
  if(base == "G")
    std::cout<<"C"<<std::endl;
  return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	
	int dp[n][3];
	
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	
	for(int i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
	}
	
	cout<<max(dp[n-1][1],max(dp[n-1][0],dp[n-1][2]));
	
	return 0;
}

Measured memory_bytes: 2560
n = int(input())
alist = [int(s) for s in input().split(" ")]
alist.sort()

if alist[0] == 0:
  print(0)
else:
  ans = 1
  ok = True
  for a in reversed(alist):
    ans *= a
    if ans > 1e18:
      ok = False
      break
  if ok:
    print(ans)
  else:
    print(-1)

Measured memory_bytes: 21648
#include <stdio.h>
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

const char dat[2][6] = { "apple", "peach" };

string fix(string s) {
    rep (k, s.size()-4) {
        rep (t, 2) {
            bool f = true;
            rep (i, 5) if (s[k+i] != dat[t][i]) f = false;
            if (f) {
                rep (i, 5) s[k+i] = dat[1-t][i];
                break;
            }
        }
    }
    return s;
}

int main() {
    string s;
    while (getline(cin, s)) {
        if (s.size() && s[s.size()-1] == '\r') s.resize(s.size()-1);
        cout << fix(s) << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
	for (auto i : a) cerr << i << ' ';\
	cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

ll solve(ll a, ll b) {
	if (a == b) return a;
	if (a < b) swap(a, b);
	if (a % b == 0) return (a / b * 2 - 1) * b;
	return solve(b, a % b) + a / b * 2 * b;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, x;
	cin >> n >> x;
	cout << n + solve(x, n - x);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100010
typedef long long ll;
char c[N];
ll p[N], pc;
int main(void)
{
    int i, j, m, a, b;
    for(i=2;i<N;++i) if (!c[i]) {
        p[pc++]=i;
        for(j=i+i;j<N;j+=i) c[j]=1;
    }

    while (scanf("%d%d%d", &m, &a, &b), m) {
        ll s=0, h, w;
        for(i=0;i<pc&&p[i]*2<=m;++i) {
            for(j=i;j<pc&&p[i]*p[j]<=m;++j) {
                if (p[i]*b<p[j]*a) continue;
                if (s<p[i]*p[j]) {
                    s=p[i]*p[j];
                    h=p[i], w=p[j];
                }
                else if (s==p[i]*p[j] && p[i]*w<p[j]*h) {
                    h=p[i], w=p[j];
                }
            }
        }
        printf("%lld %lld\n", h, w);
    }

    return 0;
}

Measured memory_bytes: 768
#include<cstdio>
#define RI register int
#define CI const int&
using namespace std;
const int N=3005,mod=1e9+7;
int n,q,f[N][N],inv2,mul,a[N],tx[N],ty[N],ans;
inline int quick_pow(int x,int p=mod-2,int mul=1)
{
	for (;p;p>>=1,x=1LL*x*x%mod) if (p&1) mul=1LL*mul*x%mod; return mul;
}
inline int sum(CI x,CI y)
{
	int t=x+y; return t>=mod?t-mod:t;
}
int main()
{
	RI i,j; for (scanf("%d%d",&n,&q),i=1;i<=n;++i) scanf("%d",&a[i]);
	for (i=1;i<=q;++i) scanf("%d%d",&tx[i],&ty[i]); inv2=quick_pow(2);
	for (i=1;i<=n;++i) for (j=1;j<=n;++j) if (i!=j&&a[i]>a[j]) ++f[i][j];
	for (mul=quick_pow(2,q),i=1;i<=q;++i)
	{
		int x=tx[i],y=ty[i]; f[x][y]=f[y][x]=1LL*sum(f[x][y],f[y][x])*inv2%mod;
		for (j=1;j<=n;++j) if (j!=x&&j!=y) f[x][j]=f[y][j]=1LL*sum(f[x][j],f[y][j])*inv2%mod;
		for (j=1;j<=n;++j) if (j!=x&&j!=y) f[j][x]=f[j][y]=1LL*sum(f[j][x],f[j][y])*inv2%mod;
	}
	for (i=1;i<=n;++i) for (j=1;j<=n;++j) if (i<j) ans=sum(ans,1LL*f[i][j]*mul%mod);
	return printf("%d",ans),0;
}

Measured memory_bytes: 36956
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
int a,b;
int main(){
  scan(a);scan(b);
  if(a%2==1&&b%2==1)prin("Odd");
  else prin("Even");
  return 0;
}


Measured memory_bytes: 256
import sys
import bisect
input = sys.stdin.readline

n, c, k = [int(w) for w in input().split()]
la = [int(input()) for _ in range(n)]
la.sort()
lak = [a + k for a in la]

ind = 0
ans = 0
while ind < n:
    ride = bisect.bisect_right(la, lak[ind]) - ind
    ind += min(ride, c)
    ans += 1

print(ans)


Measured memory_bytes: 17116
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

i64 N;

vector<vector<int>> g;

i64 dp[5050][2][5050];
i64 ne[2][5050];
int sz[5050];

i64 comp[5050];

const i64 MOD = 1e9 + 7;

void dfs(int v, int f = -1) {
  dp[v][0][1] = 1;
  sz[v] = 1;

  for(int to : g[v]) {
    if(f == to) continue;
    dfs(to, v);
    int a = sz[v];
    int b = sz[to];


    for(int i = 0;i <= a + b;i++) {
      ne[0][i] = ne[1][i] = 0;
    } 

    for(int x = 1;x <= a;x++) for(int y = 1;y <= b;y++) {
      (ne[0][x + y] += dp[v][0][x] * dp[to][0][y] + dp[v][1][x] * dp[to][1][y]) %= MOD;
      (ne[1][x + y] += dp[v][0][x] * dp[to][1][y] + dp[v][1][x] * dp[to][0][y]) %= MOD;
      (ne[0][x] += dp[v][0][x] * dp[to][1][y] % MOD * comp[y] % MOD + dp[v][1][x] * dp[to][0][y] % MOD * comp[y] % MOD) %= MOD;
      (ne[1][x] += dp[v][0][x] * dp[to][0][y] % MOD * comp[y] % MOD + dp[v][1][x] * dp[to][1][y] % MOD * comp[y] % MOD) %= MOD;
    }

    swap(dp[v], ne);
    sz[v] = a + b;
  }
}

int main() {
  cin >> N;
  g.resize(N);
  for(int i = 0;i < N - 1;i++) {
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  comp[2] = 1;
  for(int i = 4;i <= 5000;i += 2) comp[i] = (comp[i - 2] + comp[i - 2] * (i - 2)) % MOD;

  dfs(0);

  i64 ans = 0;
  for(int i = 0;i <= N;i += 2) {
    (ans += dp[0][0][i] * comp[i]) %= MOD;
    (ans = ans - dp[0][1][i] * comp[i] % MOD + MOD) %= MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 396416
N = int(input())
A, B, C = list(map(int, input().split()))

for i in range(N - 1):
    a, b, c = list(map(int, input().split()))
    nA = max(B, C) + a   
    nB = max(A, C) + b 
    nC = max(A, B) + c
    A, B, C = nA, nB, nC
print(max(A, B, C))
    
    

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

void init() {
  cin.tie(nullptr);               // Do not flush "cout" when processing "cin".
  // cout << "hogehoge" << '\n';  // "endl" executes flush in addition to line break.
  // ios::sync_with_stdio(false); // Be careful when using both "cin/cout" and "scanf/printf".
}

int main() {
  init();
  int n;
  cin >> n;
  cout << 1-n << "\n";
  return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}

int main()
{
    int n, k, s;
    long long int min;
    long long int h[100005];
    scanf("%d%d", &n, &k);
    s = k - 1;
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &h[i]);
    }
    qsort(h, n, sizeof(long long int), compare);
    min = h[s] - h[0];
    for (int i = 1; i + s < n; i++)
    {
        min = (h[i + s] - h[i] < min) ? h[i + s] - h[i] : min;
    }

    printf("%lld\n", min);
}

Measured memory_bytes: 1788
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define pye cout << "Yes" << endl;
#define pno cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;
#define prin(num) cout << num << endl;
#define INF 1000000000
#define MOD 1000000007
#define MAX 200001
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef pair<double, double> doup;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

ll modpow(ll x, ll n) {
    ll res=1;
    
    while(n>0) {
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}


int main() {
    ll i, n, x;
    cin >> n >> x;
    ll a[MAX]={0};
    ll ans=0;
    for(i=0; i<n; i++) {
        cin >> a[i];
    }
    if(a[0]>x) {
        ans+=a[0]-x;
        a[0]=x;
    }
    for(i=0; i<n-1; i++) {
        if(a[i]+a[i+1]>x) {
            ans+=a[i]+a[i+1]-x;
            a[i+1]=x-a[i];
        }
    }
    
    prin(ans);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define pa pair<int,int>
#define CLR(a,x) memset(a,x,sizeof(a))
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
const int maxn=1e5+10;

inline char gc(){
	return getchar();
	static const int maxs=1<<16;static char buf[maxs],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxs,stdin),p1==p2)?EOF:*p1++;
}
inline ll rd(){
    ll x=0;char c=gc();bool neg=0;
    while(c<'0'||c>'9'){if(c=='-') neg=1;c=gc();}
    while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+c-'0',c=gc();
    return neg?(~x+1):x;
}

int N,a[maxn],op[maxn];
ll f[maxn][3];

inline void upd(ll &a,ll b){a=max(a,b);}

int main(){
    //freopen("","r",stdin);
    N=rd();
    a[1]=rd();op[1]=1;
    for(int i=2;i<=N;i++){
        char s[5];scanf("%s",s);
        op[i]=(s[0]=='+')?1:-1;
        a[i]=rd();
    }
    CLR(f,-127);f[0][0]=0;
    for(int i=1;i<=N;i++){
        upd(f[i][0],f[i-1][0]+op[i]*a[i]),upd(f[i][0],f[i-1][1]-op[i]*a[i]),upd(f[i][0],f[i-1][2]+op[i]*a[i]);
        upd(f[i][1],f[i-1][2]+op[i]*a[i]);
        if(op[i]==-1){
            upd(f[i][1],f[i-1][0]+op[i]*a[i]);
            upd(f[i][2],f[i-1][1]-op[i]*a[i]);
        }
        upd(f[i][1],f[i-1][1]-op[i]*a[i]);
        upd(f[i][2],f[i-1][2]+op[i]*a[i]);
        // printf("~%d %d %d %d\n",i,f[i][0],f[i][1],f[i][2]);
    }
    printf("%lld\n",f[N][0]);
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans;
  ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
   for(int j=0;j<n;j++){
     if(i*j>=n){
       break;
     }
     else if(i!=0&&j!=0){
       ans++;
     }    
   }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main() {
  int a, i;
  while(cin>>a) {
    for(i=0;i<=9;i++) {
      if(a&1<<i){
        cout<<(1<<i);
        if(a<2<<i)break;
        cout<<' ';
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int A, B, C;
	cin >> A >> B >> C;

	if (A == B && B == C && A % 2 == 0) co(-1);
	else {
		int kotae = 0;
		while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
			int a = A / 2;
			int b = B / 2;
			int c = C / 2;
			A = b + c;
			B = c + a;
			C = a + b;
			kotae++;
		}	
		co(kotae);
	}

	Would you please return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            // write your code here
            int N = in.nextInt();
            if (N % 2 == 0) {
                out.println(N);
            } else {
                out.println(N * 2);
            }
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

Measured memory_bytes: 23124
void main() {
    writeln(-readln.chomp.to!int + 2 * readln.chomp.to!int);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")

#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#else
#include <bits/stdc++.h>
#endif // VS

#define long long long
using namespace std;

#pragma region CS_COMPATIBLE
#define var auto
#define Max std::max
#define Min std::min
#define Abs std::abs
//#define List std::vector;
//#define Add push_back
#pragma endregion

void read(uint32_t& x)
{
	x = 0;
	int k;
	while (true)
	{
		k = getchar_unlocked();
		if (k < '0' || k > '9')	break;
		x = x * 10 + k - '0';
	}
}

void sread(int32_t& x)
{
	bool flag;
	x = 0;
	int k = getchar_unlocked();
	if (flag = (k == '-')) k = getchar_unlocked();

	while (true)
	{
		if (k < '0' || k > '9')	break;
		x = x * 10 + k - '0';
		k = getchar_unlocked();
	}
	if (flag) x *= -1;
}

void sprint(int64_t x) {
	if (x == 0) {
		putchar_unlocked('0');
		return;
	}
	if (x < 0) {
		putchar_unlocked('-');
		x *= -1;
	}
	int s = 0;
	char f[15];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	while (s--)
		putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}

int32_t a[200000];
int main() {
	uint32_t n;
	read(n);
	for (size_t i = 0; i < n; i++) sread(a[i]);
	int64_t res;
	if (n & 1) {
		//Odd
		var sum = 0L;
		for (int i = 0; i < n - 1; i += 2) sum += a[i];
		res = sum;
		int64_t tailDiff = 0, tailDiffMax = 0;
		for (int i = n - 3; i >= 0; i -= 2)
		{
			sum -= a[i]; sum += a[i + 1];
			tailDiff += a[i + 2]; tailDiff -= a[i + 1];
			tailDiffMax = max(tailDiffMax, tailDiff);
			res = max(res, sum + tailDiffMax);
		}
	}
	else {
		//Even
		int64_t sum = 0;
		for (size_t i = 0; i < n; i += 2) sum += a[i];
		res = sum;
		for (int i = n - 1; i >= 0; i -= 2)
		{
			sum += a[i]; sum -= a[i - 1];
			res = max(res, sum);
		}
	}
	sprint(res);
}


Measured memory_bytes: 4368
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {

	int h, w; cin >> h >> w;

	vector<string> a(h);

	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}

	vector<int> cnts(26);

	for (int i = 0; i < h; i++) {
		string buf = a[i];

		for (char c : buf) {
			++cnts[c - 'a'];
		}
	}

	//奇数は1つ、4で割って2余る数がキー。
	int odd = 0;
	int r2 = 0;

	for (int i = 0; i < 26; i++) {
		if (cnts[i] % 2)odd++;
		if (cnts[i] & 2)r2++;
	}

	//両方偶数なら4のペアしか使えない。奇数個のもの、4で割って2余るものがあると
	//達成できない。
	if (h % 2 == 0 && w % 2 == 0) {
		if (odd || r2)cout << "No" << endl;else cout << "Yes" << endl;
	}
	else if (h % 2 == 0) {
		if (odd || r2 > h / 2)cout << "No" << endl;else cout << "Yes" << endl;
	}
	else if (w % 2 == 0) {
		if (odd || r2 > w / 2)cout << "No" << endl;else cout << "Yes" << endl;
	}
	else {
		if (odd != 1 || r2 > (h - 1) / 2 + (w - 1) / 2)cout << "No" << endl;else cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード
 
//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ
 
//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π
 
using namespace std;
 
//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 
//#include "./lib/generic/search.h"

//文字列入力した小数値を小数点なくして返す
int changeDoubleToInt(string decimal){ 
    decimal.erase(1, 1); //小数点削除
    int n_decimal = atoi(decimal.c_str()); //c_strでchar*に変換後、atoiでintに変換
    return n_decimal;
}

//最大公約数
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main(){
    int n, m, sum=0, ans=0;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
        sum+=a[i];
    }
    rep(i, n){
        if(a[i]*4*m>=sum) ans++;
    }
    if(ans>=m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  scanf("%d", &N);

  vector<int> v(N);
  for(int i=0;i<N;i++){
      scanf("%d", &v[i]);
  }

  if(N<3){
    printf("0");
    return 0;
  }

  sort(v.begin(), v.end());

  int S = 0;
  
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      for(int k=j+1;k<N;k++){
        if(v[i]!=v[j] && v[j]!=v[k] && v[i]!=v[k] && v[k]<(v[i]+v[j])){
          S++;            
        }
      }
    }
  }

  printf("%d\n", S);
  
  return 0;
}

Measured memory_bytes: 3716
n = int(input())
lst = [int(i) for i in input().split()]
lst_be = lst[:n-1]
lst_af = lst[1:]
judge = True
tmp_max = lst[0]
for be, af in zip(lst_be, lst_af):
	if af + 1 < tmp_max:
		judge = False
		break
	tmp_max = max(tmp_max, af)
if (judge):
	print ('Yes')
else:
	print ('No')

Measured memory_bytes: 14252
#include<iostream>
#include<algorithm> 
#include<cmath>
using namespace std;
long long ans=0,bns=0,cns=0;
long long   n,k,m;
char s[10001];
int a[100001],b[100001];
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	ans=k*pow(k-1,n-1);
	cout<<ans<<endl;//科学计数法是真的毒瘤 
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int>data(N,-1);
  for(int i=0;i<M;i++){
    int s,a;
    cin>>s>>a;
    s--;
    if(data[s]==-1){
      data[s]=a;
    }else if(data[s]!=a){
      cout<<-1<<endl;
      return 0;
    }
  }
  for(int i=0;i<N;i++){
    if(N!=1&&(data[0]==0)){
      cout<<-1<<endl;
      return 0;
    }
    if(N!=1&&data[0]==-1)data[0]=1;
    else if(data[i]==-1)data[i]=0;
    cout<<data[i];
  }cout<<endl;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = [a - i for i, a in enumerate(A)]
    B.sort()
    ans = 0
    for i in range(N):
        ans += abs(A[i] - (B[N // 2] + i))
    print(ans)


main()


Measured memory_bytes: 25196
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.14159265358979323846
#define MOD 1000000007 /* 1e9 + 7 */
#define MAXN 10000000 /* 1e7 */
#define REP(i,n) for(i=0; i<n; i++)
typedef long long ll;
int i,j;

int main(void) {
    int n,ans=0;
    double x,y,d;
    scanf("%d%lf",&n,&d);
    REP(i,n) {
        scanf("%lf%lf",&x,&y);
        if(sqrt(x*x+y*y)<=d) ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 2180
#include <iostream>
#include <vector>

using namespace std;

#define MIN(a,b) ((a)<(b)?(a):(b))

int main()
{
    int N,K,x;
    int ans=0;

    cin >> N >> K;

    for(int i=0; i<N; ++i) {
        cin >> x;
        if(x>K) {
            ans+=2*MIN(x,x-K);
        } else {
            ans+=2*MIN(x,K-x);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	char* num = (char*)calloc(5, sizeof(char));
	cin >> num;
	int a = num[0] - 48, b = num[1] - 48, c = num[2] - 48, d = num[3] - 48;
	
	if(a + b + c + d == 7) printf("%d+%d+%d+%d=7", a, b, c, d);
	else if(a + b + c - d == 7) printf("%d+%d+%d-%d=7", a, b, c, d);
	else if(a + b - c - d == 7) printf("%d+%d-%d-%d=7", a, b, c, d);
	else if(a - b - c - d == 7) printf("%d-%d-%d-%d=7", a, b, c, d);
	else if(a + b - c + d == 7) printf("%d+%d-%d+%d=7", a, b, c, d);
	else if(a - b - c + d == 7) printf("%d-%d-%d+%d=7", a, b, c, d);
	else if(a - b + c + d == 7) printf("%d-%d+%d+%d=7", a, b, c, d);
	else if(a - b + c - d == 7) printf("%d-%d+%d-%d=7", a, b, c, d);
}


Measured memory_bytes: 3792
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();

		if(a < b){
			System.out.println("a < b");
		}
		else if(a > b){
			System.out.println("a > b");
		}
		else{
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 26212
def number_of_ways(a, b, c, x):
    ways = 0
    for a_count in range(a + 1):
        for b_count in range(b + 1):
            for c_count in range(c + 1):
                temp_sum = 500 * a_count + 100 * b_count + 50 * c_count
                if temp_sum == x:
                    ways += 1
    return ways

if __name__ == '__main__':
    a = int(input())
    b = int(input())
    c = int(input())
    x = int(input())
    print(number_of_ways(a, b, c, x))



Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long[] a=new long[n];
		long[] b=new long[n];
		long[] d=new long[n];
		long e=0;
		long sa=0;
		long sb=0;
		for(int i=0;i<n;i++) {
			a[i]=sc.nextLong();
			sa+=a[i];
		}
		for(int i=0;i<n;i++) {
			b[i]=sc.nextLong();
			sb+=b[i];
			d[i]=b[i]-a[i];
			if(d[i]>0)e+=(d[i]+1)/2;
		}
		long c=sb-sa;
		if(c<e) {
			System.out.println("No");
		}
		else {
			System.out.println("Yes");
		}
		
	}
	}


Measured memory_bytes: 44664
#include <stdio.h>

int main(){
	int n,i,e;
	long d=0;
	long a[200],c[200]={0};

  scanf("%d",&n);
	for(i=0;i<n;i++)
	 scanf("%ld",&a[i]);
	  while(1){
      for(i=0;i<n;i++){
		      if(a[i]%2==0){
			         e=1;
			         a[i]/=2;
		      }
		        else{
              e=0;
		        break;
            }
		   }
		     if(e==1)
		       d++;
		         else
		       break;
	}
  printf("%ld",d);
  return 0;
	}


Measured memory_bytes: 128
import Data.List (group, intercalate)

main :: IO ()
main = do
  rls <- map (== 'R') <$> getLine :: IO [Bool]
  let
    (_, _, _, f) = foldl step (1, 0, 0, id) . (++ [True]) $ rls
  putStrLn . intercalate " " . map show . f $ []

step :: (Int, Int, Int, [Int] -> [Int]) -> Bool -> (Int, Int, Int, [Int] -> [Int])
step (i, r, 0, f) True = (i + 1, r + 1, 0, f)
step (i, r, l, f) False = (i + 1, r, l + 1, f)
step (i, r, l, f) True
  =
    let
        (r2, r1) = divMod r 2
        (l2, l1) = divMod l 2
      in
        (i + 1, 1, 0, f . ((replicate (r - 1) 0 ++ [r2 + r1 + l2] ++ [r2 + l2 + l1] ++ replicate (l - 1) 0) ++))


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int c=2*b;
    cout<<max(a-c,0);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
  char s[101];
  char p[101];
  char sp[201];
  scanf("%s",s);
  scanf("%s",p);
  strcpy(sp,s);
  strcat(sp,s);
  if(strstr(sp,p)==NULL){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}


Measured memory_bytes: 2108
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	_, k := r.nextInt(), r.nextInt()
	r.Scan(true)
	s := r.nextString()

	cnt := 0

	for i, end := 0, len(s); i < end; i++ {

		if i+1 < end && s[i] == s[i+1] {
			cnt++
		}
	}

	cnt += k * 2
	if cnt > len(s)-1 {
		cnt = len(s) - 1
	}
	fmt.Fprintln(stdout, cnt)
}


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

using namespace std;

int main() {
    u_long answer = 0;
    string S;
    char pre_color;

    // input
    std::cin >> S;

    // process
    for (int i = 1; i < (int) S.size(); i++) {
        pre_color = S[i - 1];
        if (S[i] == pre_color) {
            if (S[i] == '0') {
                S[i] = '1';
            } else {
                S[i] = '0';
            }
            answer++;
        }
    }

    // output
    std::cout << answer << std::endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
using ll = long long;
int main(void){
    string n;
    cin >> n;
    int ans =0;
    for(int i=0;i<n.length();i++){
        if(n[i]=='2'){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int X; cin >> X;
  int n = X/100, tmp = X%100, cnt = 0;
  for(int i=5; i>0; --i) {
    cnt += tmp/i; tmp=tmp%i;
  }
  if(cnt <= n) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256