akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


int main() {
  double a, b, x; cin >> a >> b >> x;
  double S = a*a;
  double Side = a*b;
  if(x >= S*b/2.0){
    cout << fixed << setprecision(10) << 180.0 * atan2(b-x/S, a/2.0)/pi << endl;
  }else{
    cout << fixed << setprecision(10) << 180.0 * atan2(b, 2*x/Side)/pi << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

void no(){
	printf("-1\n");
	exit(0);
}

int main(){
	int n; ll a, b; scanf("%d%lld%lld", &n, &a, &b);
	ll c = 0;
	REP(i, n-2){
		ll d; scanf("%lld", &d);
		c ^= d;
	}
	DEBUG("c = %lld(0x%llx)\n", c, c);
	if(a+b < c) no();
	ll d = a+b - c;
	DEBUG("d = %lld(0x%llx)\n", d, d);
	if(d%2) no();
	ll e = d/2;
	DEBUG("e = %lld(0x%llx)\n", e, e);
	if(e & c) no();
	if(e > a) no();
	for(ll i = 1LL<<50; i; i/=2){
		if(c & i){
			DEBUG(" Check for %lld\n", d);
			if(e + i <= a){
				e += i;
			}
			DEBUG(" e = %lld\n", e);
		}
	}
	DEBUG("e = %lld(0x%llx)\n", e, e);
	if(!e) no();
	printf("%lld\n", a - e);
}




Measured memory_bytes: 3800
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
using namespace std;

int H,W,N;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
char MAP[1000+1][1000+1];
int f[1000+1][1000+1];
int d[1000+1][1000+1];
int main(){
	cin >> H >> W >> N;
	vector<int> ans(N+1);
	int startx,starty;
	for(int i=1; i<H+1; ++i){
		for(int j=1; j<W+1; ++j){
			cin >> MAP[i][j];
			f[i][j]=0;
			if(MAP[i][j]=='S'){
				startx=i,starty=j;
				//qux.push(i);
				//quy.push(j);
				f[i][j]=1;
				d[i][j]=0;
			}
		}
	}
	//cout << qux.size() << " " << quy.size() << "\n";
	for(int i=1; i<N+1; ++i){
		int x;
		int y;
		queue<int> qux;
		queue<int> quy;
		qux.push(startx);
		quy.push(starty);
		while(1){
			if(!(qux.size()&&quy.size())){
				cout << x << " " << y << "\n";
				break;
			}
			x=qux.front();
			y=quy.front();
			//cout << x << " " << y << " " << d[x][y] << "\n";
			qux.pop();
			quy.pop();
				if(atoi(&MAP[x][y])==i){
					ans[i]=d[x][y];
					//cout << i << " " <<  d[x][y] << "\n";
					for(int j=1; j<H+1; ++j){
						for(int k=1; k<W+1; ++k){
							f[j][k]=0;
						}
					}
					startx=x;
					starty=y;
					d[x][y]=0;
					break;
				}
			for(int j=0; j<4; ++j){
				int nx=x+dx[j];
				int ny=y+dy[j];
				if(1<=nx&&nx<=H&&1<=ny&&ny<=W&&MAP[nx][ny]!='X'&&f[nx][ny]==0){
					//cout << "ok\n";
					qux.push(nx);
					quy.push(ny);
					f[nx][ny]=1;
					d[nx][ny]=d[x][y]+1;
				}
			}
		}
	}
	int ANS=0;
	for(int i=1; i<N+1; ++i){
		ANS+=ans[i];
	}
	cout << ANS << "\n";
	return 0;
}

Measured memory_bytes: 10036
#include<stdio.h>

int main(){
	int frag = 0,i;
	char a[200001],b[200001];
	scanf("%s",a);
	scanf("%s",b);
	for(i = 0; a[i] != '\0'; i++){
		if(a[i] != b[i]){
			frag++;
		}
	}
	printf("%d",frag);
}


Measured memory_bytes: 2124
#include<iostream>
#include<string>
#include<map>

using namespace std;

int main(){
    string s;
    cin >> s;
    bool ans=true;
    map<char, int> m;
    for(int i=0;i<s.length();i++){
        m[s[i]]++;
        if(m[s[i]]>=2){
            ans=false;
            break;
        }
    }
    if(ans){
        cout << "yes" << endl;
    }
    else{
        cout << "no" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

    int N;
    int A[110];
    cin>>N;
    for(int i=0;i<N;i++)cin>>A[i];

    int max=0,min=1100000000;
    for(int i=0;i<N;i++){
        if(max<A[i])max=A[i];
        if(min>A[i])min=A[i];
    }
    cout<<max-min<<endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import Counter
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, M: int, a: "List[int]", b: "List[int]"):
    c = Counter(a + b)
    for i in range(1, N + 1):
        print(c[i])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]"
    b = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
typedef long long ll;
int a[maxn],b[maxn];
bool cmp(int x,int y)
{
    if(b[x]!=b[y]) return b[x]<b[y];
    else return x<y;
}
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    memset(b,0,sizeof(b));
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        b[a[i]]++;
    }
    sort(a,a+n);
    int newn=unique(a,a+n)-a;
    sort(a,a+newn,cmp);
    if(newn<=k)
    {
        printf("0\n");
        return 0;
    }
    int ans=0;
    for(int i=0;i<newn-k;i++)
    {
        ans+=b[a[i]];
    }
    printf("%d\n",ans);
}


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

int main(){
  int n,q;
  cin>>n>>q;
  queue<pair<string,int> > Q;
  string name;
  int t;

  rep(i,n){
    cin>>name>>t;
    Q.push(make_pair(name,t));
  }

  pair<string,int>u;
  int time=0;

  while(!Q.empty()){
    u=Q.front();
   // cout<<u.first<<" "<<u.second<<endl;
    Q.pop();
    time+=min(u.second,q);
    if(u.second<=q){
      cout<<u.first<<" "<<time<<endl;
    }else{
      u.second-=q;
      Q.push(u);
    }
    
  }

  
   
 
} 


Measured memory_bytes: 6236
h,w,k=map(int,input().split())

dp=[[0 for i in range(w+2)] for j in range(h+2)]

dp[0][1]=1

for i in range(h+1):
    for j in range(1,w+1):
        for l in range(2**(w-1)):
            p=bin(l)
            q=len(p)
            r=p.replace("11","")
            if q==len(r):
                r=p.replace("0b","")
                r="0"*(w-1-len(r))+r
                if j==1:
                    if r[0]=="0":
                        dp[i+1][j]+=dp[i][j]
                    else:
                        dp[i+1][j+1]+=dp[i][j]
                elif j==w:
                    if r[-1]=="0":
                        dp[i+1][j]+=dp[i][j]
                    else:
                        dp[i+1][j-1]+=dp[i][j]
                else:
                    if r[j-1]=="1":
                        dp[i+1][j+1]+=dp[i][j]
                    elif r[j-2]=="1":
                        dp[i+1][j-1]+=dp[i][j]
                    else:
                        dp[i+1][j]+=dp[i][j]
                   
print(dp[h][k]%1000000007)
        






Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;
  int count = 0;
  X -= Z;
  while (1) {
    if (X < (Y+Z))
      break;
    else {
      count++;
      X -= Y+Z;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#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>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a) 
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a) 
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) { 
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double sqrtNum = sqrt(a);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定

// ===============================================================

int main() {
	ll n;
	cin >> n;
	string a;
	cin >> a;
	vl x(n, 0);
	vl y(n, 0);
	for (int i = 0; i < n; i++) {
		if (a[i] == 'E') {
			if (i == 0) {
				x[i] = 1;
				y[i] = 0;
			}
			else {
				x[i] = x[i - 1] + 1;
				y[i] = y[i - 1];
			}
		}
		if (a[i] == 'W') {
			if (i == 0) {
				y[i] = 1;
				x[i] = 0;
			}
			else {
				y[i] = y[i - 1] + 1;
				x[i] = x[i - 1];
			}
		}
	}//x=E y=W
	ll count = 0;
	ll ans = 100000000;
	for (int i = 0; i < n; i++) {
		if (i != 0) {
			count = (x[n - 1] - x[i]) + y[i - 1];
		}
		else {
			count = x[n - 1] - x[i];
		}
		if (min(ans, count) == count) {
			ans = count;
		}
		count = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 8304
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

signed main()
{
    IOS;
        
    int n,k;
    cin>>n>>k;
    map<int,int>cur_freq;
    set<int>taken;
    multiset< pair<int,int> >replacables;

    pair<int,int> ar[n+1];

    repa(i,1,n)
        cin>>ar[i].ss>>ar[i].ff;

    sort(ar+1,ar+1+n);
    reverse(ar+1,ar+1+n);

    int cur_ans = 0;
    int sz;

    repa(i,1,k)
    {
        cur_ans+=ar[i].ff;
        taken.insert(ar[i].ss);
        cur_freq[ar[i].ss]++;
        replacables.insert({ar[i].ff,ar[i].ss});
    }

    sz = taken.size();
    int best = cur_ans + sz*sz;

    repa(i,k+1,n)
    {
        if ( taken.find(ar[i].ss)!=taken.end() )
            continue;

        while(replacables.size())
        {
            auto it = *replacables.begin();

            if ( cur_freq[it.ss]==1 )
                replacables.erase(replacables.find(it));

            else
            {
                replacables.erase(replacables.find(it));
                cur_ans-=it.ff;
                cur_ans+=ar[i].ff;
                cur_freq[it.ss]--;
                cur_freq[ar[i].ss]++;

                sz++;

                taken.insert(ar[i].ss);
                best = max(best,cur_ans+(sz*sz));
                break;
            }
        }
    }

    cout<< best <<endl;
}

Measured memory_bytes: 14464
//2013/11/25(Mon)

#include <iostream>
using namespace std;
bool  is_prime[10000000];
int main()
{

	is_prime[0] = is_prime[1] = false;
	for(int i=2; i<10000000; i++)
		is_prime[i] = true;

	for(int i=2; i*i<10000000; i++){
		if(is_prime[i]){
			for(int j=i*i; j<10000000; j+=i)
				is_prime[j] = false;
		}
	}
	
	int n;

	while(true){
		cin >> n;
		if(n==0)
			break;

		for(int i=n; i>=13; i--){
			if(is_prime[i] && is_prime[i-2] && is_prime[i-6] && is_prime[i-8]){
				cout << i << endl;
					break;
				
			}
		}
		
	}
	return 0;
}

Measured memory_bytes: 10924
n,m = map(int,input().split())
ka = [list(map(int,input().split())) for i in range(n)]

cnt = [0]*(m+1)

for i in range(n):
  for j in range(1,ka[i][0]+1):
    cnt[ka[i][j]] += 1

print(cnt.count(n))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
class MagicNumberThree
{

    public:
int countSubsequences(string s)
{

}

};



int main()
{
    int a,b;
    while(cin>>a>>b){
        int maxr=0;
        int ans=0;
        vector<int>B;
        for(int i=0;i<a;i++){
            int x,y;
            cin>>x>>y;
            maxr=max(maxr,x);
            B.push_back(y);
        }
        sort(B.begin(),B.end() );
        for(int i=B.sz-1;i>=0&&b>0;i--){
            ans++;
            b-=max(maxr,B[i]);
        }
        if(b>0){
            ans+=b/maxr;
            b%=maxr;
            if(b)
                ans++;
        }
        cout<<ans<<endl;







    }

    return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    long long int N ;
    cin >> N ;

    long long int count = 0;
    long long int a[N];
    long long int b = N ;
    for(long long int i = 0 ; i < N ; i++){
        cin >> a[i] ;
        if(b>=a[i]){
            b = a[i];
        }
        if(b>=a[i]){
            count++;
        }
    } 
    
    cout << count <<endl;


    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int n,k; cin>>n>>k;
    long long ans=1;
    for(int i=0; i<n-1; i++){
        ans*=(k-1);
    }
    ans*=k;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;//入力を取得する(Scanner)

class Main {
	public static void main(String arts[]) {
		int a,b;
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		int x, y , z;
		x = a + b ;
		y  = a - b;
		z = a * b;

		int ans=y;
	if(x>=y){ 
		ans = x;
	}
	if(ans <= z){
		ans = z ;
	}
	System.out.println(ans);
	}
}


Measured memory_bytes: 23764
using System;
using System.Collections.Generic;

class Program {
    static int Main(string[] args) {
        List<int[]> list = new List<int[]>();

        while (true) {
            string v = Console.ReadLine();

            int H = int.Parse(v.Split(' ')[0]);
            int W = int.Parse(v.Split(' ')[1]);
            if ((H == 0) && (W == 0)) { break; }

            list.Add(new int[] { H, W });
        }

        for (int i = 0; i < list.Count; i++) {
            for (int h = 0; h < list[i][0]; h++) {
                for (int w = 0; w < list[i][1]; w++) {
                    if (w % 2 == h % 2) {
                        Console.Write("#");
                    }
                    else {
                        Console.Write(".");
                    }
                }
                Console.WriteLine("");
            }

            Console.WriteLine("");
        }

        return 0;
    }
}

Measured memory_bytes: 8976
def main():
  import sys
  b=sys.stdin.buffer
  h,w=map(int,b.readline().split())
  x=w+1
  s=[c>>3for c in b.read()]
  dp=[10000]*h*x
  a=p=s[0]
  dp[0]=b=q=5-a
  r=range(1,w)
  for i in r:
    t=s[i]
    b+=a^t
    dp[i]=b
    a=t
  for i in range(x,h*x,x):
    t=s[i]
    q+=p^t
    dp[i]=b=q
    a=p=t
    for j in r:
      k=i+j
      sk=s[k]
      b+=a^sk
      l=k-x
      t=dp[l]+(s[l]^sk)
      if b>t:b=t
      dp[k]=b
      a=sk
  print(b+1>>1)
main()

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

int main(){
    int N, M;
    std::cin >> N >> M;
    std::vector<std::vector<int>> s(M);
    std::vector<int> p(M);
    for(int i = 0; i < M; i++){
        int k;
        std::cin >> k;
        std::vector<int> S_k(k);
        for(int j = 0; j < k; j++){
            std::cin >> S_k[j];
            S_k[j]--; // 0 origin に変える
        }
        s[i] = S_k;
    }
    for(int i = 0; i < M; i++) std::cin >> p[i];

    // bit exhaustive search
    int cnt = 0;
    for(int bit = 0; bit < (1 << N); bit++){
        std::vector<bool> OnSwitch(N, false);
        for(int i = 0; i < N; i++){
            if(bit & (1 << i)) OnSwitch[i] = true;
        }

        // M個の電球が全て点灯しているかどうかの確認
        for(int i = 0; i < M; i++){
            // i個目の電球について
            int OnSiwtchNum = 0;
            for(int k = 0; k < s[i].size(); k++){
                OnSiwtchNum += OnSwitch[s[i][k]];
            }
            if(OnSiwtchNum % 2 != p[i]) break;
            if(i == M - 1) cnt++;
        }
    }

    std::cout << cnt << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

#define N_MAX 200000
#define MOD 1000000007

typedef long long int lli;

void solv()
{
	lli N; scanf("%lld", &N);
	if (1 == N % 2){
		printf("%d", 0);
		return;
	}

	lli cnt2 = 0;
	lli val = 2;
	while (0!=N/val){
		cnt2 += N / val;
		val = val * 2;
	};
	lli cnt5 = 0;
	val = 5;
	while (0 != N/val){
		cnt5 += N/val/2;
		val = val * 5;
	};

	printf("%lld", min(cnt2, cnt5));

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
using System;

namespace Vanila
{
    public class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int h = int.Parse(Console.ReadLine());
            Console.WriteLine((a + b) * h / 2);
        }
        public static long Max(long a, long b)
        {
            if (a <= b) return b;
            else return a;
        }
        public static long Min(long a, long b)
        {
            if (a == Max(a, b)) return b;
            else return a;
        }
        public static long GCD(long a, long b)
        {
            while (Max(a, b) % Min(a, b) != 0)
            {
                if (a < b) b %= a;
                else a %= b;
            }
            return Min(a, b);
        }
        public static long LCM(long a, long b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;
public class Main{
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int Hp = sc.nextInt();
    int N = sc.nextInt();

    for(int i = 0; i < N; i++){
      int attack = sc.nextInt();
      Hp = Hp - attack;
    }

    if(Hp > 0){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
  }
}

Measured memory_bytes: 50180
#include<stdio.h>

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


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

typedef uint32_t u32;
typedef uint64_t u64;
typedef std::pair<int, int> pii;

int Map_[128][128];
int& Map(int x, int y) {
  return Map_[x + 64][y + 64];
}

int dist_[128][128];
int& dist(int x, int y) {
  return dist_[x + 64][y + 64];
}

void init() {
  for(int i = 0; i < 128; ++i) {
    for(int j = 0; j < 128; ++j) {
      Map_[i][j] = 0;
      dist_[i][j] = -1;
    }
  }
}


const int dx[6] = {1, 1, 0, -1, -1, 0};
const int dy[6] = {0, 1, 1, 0, -1, -1};
void dfs(int x, int y, int d) {
  if( not ( -64 <= x and x < 64 and -64 <= y and y < 64 ) ) return;
  if( dist(x, y) >= d ) return;
  if( Map(x, y) == 1 ) return;
  if( d < 0 ) return;
  dist(x, y) = d;
  for(int i = 0; i < 6; ++i) {
    dfs(x + dx[i], y + dy[i], d - 1);
  }
}

int answer() {
  int res = 0;
  for(int i = 0; i < 128; ++i) {
    for(int j = 0; j < 128; ++j) {
      if( dist_[i][j] != -1 ) res += 1;
    }
  }
  return res;
}  

int main() {

  for(;;) {
    init();
    int t, n;
    std::cin >> t >> n;
    if( t == 0 and n == 0 ) break;
    int x, y;
    for(int i = 0; i < n; ++i) {
      std::cin >> x >> y;
      Map(x, y) = 1;
    }
    std::cin >> x >> y;
    dfs(x, y, t);
    std::cout << answer() << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define lowbit(i) i&-i
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	ull ans=0; For(i,0,5)ans=ans<<15^rand(); return ans;
}
const int N=100005;
int fa[N],a[N],b[N],ta[N],tb[N],ans,sz[N];
bool vis[N];
inline int gf(int x){
	return fa[x]==x?x:fa[x]=gf(fa[x]);
}
int main(){
	int n=read(),suma=0,sumb=0;
	For(i,1,n){a[i]=read(); suma^=a[i];}
	For(i,1,n){b[i]=read(); sumb^=b[i];}
	n++;
	a[n]=suma; b[n]=sumb;
	For(i,1,n){ta[i]=a[i]; tb[i]=b[i]; fa[i]=i;}
	sort(&ta[1],&ta[n+1]); sort(&tb[1],&tb[n+1]);
	For(i,1,n)if(ta[i]!=tb[i]){puts("-1"); return 0;}
	int m=unique(&ta[1],&ta[n+1])-ta-1;
	For(i,1,n){
		a[i]=lower_bound(&ta[1],&ta[m+1],a[i])-ta;
		b[i]=lower_bound(&ta[1],&ta[m+1],b[i])-ta;
		if(a[i]!=b[i]){
			//cout<<a[i]<<" "<<b[i]<<" "<<gf(a[i])<<" "<<gf(b[i])<<endl;
			ans++; fa[gf(a[i])]=gf(b[i]);
		}
	}
	For(i,1,n)if(a[i]!=b[i])sz[gf(a[i])]++;
	For(i,1,n)if(fa[a[i]]==a[i]&&sz[a[i]]>1&&!vis[a[i]]){
		ans++; vis[a[i]]=1; //cout<<fa[a[i]]<<" "<<a[i]<<endl;
	}
	ans-=a[n]!=b[n];
	ans-=sz[gf(a[n])]>1;
	cout<<ans<<endl;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
int main(){
    long long n,m;
    cin >> n >> m;
    if(2*n>=m){
        cout << m/2 << endl;
        return 0;
    }
    cout << n + (m-2*n)/4 << endl;
}

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

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

int main() {

    string s; cin >> s;

    ll n = s.size() + 1;

    vector<ll> a(n, 0);

    for (ll i = 0; i < n-1; ++i) {
        if (s[i] == '<') {
            a[i+1] = max(a[i+1], a[i]+1);
        }
    }

    for (ll i = n-2; i >= 0; --i) {
        if (s[i] == '>') {
            a[i] = max(a[i], a[i+1]+1);
        }
    }

    ll ans = 0;

    for (ll i = 0; i < n; ++i) {
        ans += a[i];
    }

    cout << ans << endl;
}

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


int main(){
  int n;int sum1=0,sum2=0;
  cin>>n;
  int a[n],b[n],c[n-1];
  for(int i=0;i<n;i++)
  cin>>a[i];
  for(int i=0;i<n;i++){
  cin>>b[i];
  sum1=sum1+b[i];}

  for(int i=0;i<n-1;i++)
  cin>>c[i];
  for(int i=0;i<n-1;i++){
    if(a[i+1]==a[i]+1)
    sum2=sum2+c[a[i]-1];
  }
  cout<<sum1+sum2;

  

 return 0;
}

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

#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef vector<int> vi;

int main() {FIN

	int n, i, j, res = 0;
	cin >> n;
	vi ds(n);
	
	for (i = 0; i < n; i++)
		cin >> ds[i];

	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++)
			res += (ds[i] * ds[j]);
	}

	cout << res << "\n";
	return 0;
}

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


int main(int argc, char const *argv[]) {
    std::string s;
    std::cin >> s;
    int start = -1;
    int end = -1;
    for (int i = 0; i < s.length()-1; i++) {
        if (s[i] == s[i+1]) {
            start = i + 1;
            end = i + 2;
            break;
        }
        if (i < s.length()-2 && s[i] == s[i+2]) {
            start = i + 1;
            end = i + 3;
            break;
        }
    }
    std::cout << start << " " << end << std::endl;

    return 0;
}


Measured memory_bytes: 512
n = int(input())

i = 1
num = ""
SUM = 0
amari = 1
if n == 0:
  num = "0"
while not(n == amari == SUM or SUM == n): #or num == "":
  amari = n % 2**i
  if amari == SUM % 2**i:
    num += "0"
  else:
    SUM += (-2)**(i-1)
    num += "1"
  i += 1
  #print(amari,SUM)
print(num[::-1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int N = 5e5 + 10;
char s[N];
int tr[30][N];
int n,q,op;
int lowbit(int x) {
    return x & -x;
}
void update(int x,int v,int a[]) {
    for(int i = x;i <= n;i += lowbit(i)) a[i] += v;
    // 在第x个位置更新 树a,每个自低向上+1，代表该字符出现的位置
}
int query(int x,int a[]) {
    int res = 0;
    for(int i = x;i >= 1;i -= lowbit(i)) {
        res += a[i];
    }
    // 在1 - x 这个区间，该字符出现的次数，肯定要在该字符的树上查询,自顶向下
    return res;
}
int main() {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >> n >> s >> q;
    for(int i = 0;i < n; ++i) update(i + 1,1,tr[s[i] - 'a']);
    while(q --) {
        cin >> op;
        if(op == 1) {
            int i;
            char c;
            cin >> i >> c;
            // 先把原来这个区间全部减去 1
            update(i,-1,tr[s[i - 1] - 'a']);
            s[i - 1] = c;// 修改字符串
            update(i,1,tr[c - 'a']);// 修改区间内的信息
        }
        else {
            int l,r,cnt = 0;
            cin >> l >> r;
            for(int i = 0;i < 26; ++i) {
                if(query(r,tr[i]) - query(l - 1,tr[i]) > 0) cnt ++;
            }
            cout << cnt << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 51968
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int prime[10000];
bool is_prime[55560];

void sieve(int n){
    int p = 0;
    for(int i = 0; i <= n; i++) is_prime[i] = true;
    is_prime[0] = false, is_prime[1] = false;
    for(int i = 2; i <= n; i++){
        if(is_prime[i]){
            prime[p] = i, p++;
            for(int j = 2 * i; j <= n; j += i) is_prime[j] = false;
        }
    }
}
int main(){
    int n; cin >> n;
    sieve(55555);
    vector<int> vec;
    _rep(i, 2, 55555){
        if(is_prime[i] and (i % 5 == 1)){
            vec.push_back(i);
            if(vec.size() == n) break;
        }
    }
    for(auto it : vec){
        cout << it << endl;
    }
}

Measured memory_bytes: 3604
s = input()

for bit in range(1<<3):
  f = s[0]
  
  for i in range(3):
    if bit & (1<<i):
      f += "+"
    else:
      f += "-"
      
    f += s[i+1]
  
  if eval(f) == 7:
    print("{}=7".format(f))
    exit()

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
    int A,B;
    cin>>A>>B;
    int counter = 0;
    for(int n = A;n<=B;n++){
        int n1 = n%10;
        int n2 = (n%100)/10;
        int n4 = (n/1000)%10;
        int n5 = n/10000;
        if(n1==n5 and n2==n4){
            counter++;
        }
    }
    cout<<counter<<endl;
}

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

typedef long long ll;
typedef pair <ll, ll> pii;
const int N = 2e5 + 10;

ll a[N];
ll vis[N];
vector <int> t[N], adj[N];
ll n, m;
int cnt;

void dfs(int v, int par) {
	vis[v] = par;
	for (auto u : adj[v]) {
		if(!vis[u]) {
			dfs(u, par);
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < m; i++)
	{
		ll v, u;
		cin >> v >> u;
//		if(root(v) != root(u))
//			merge(u, v);
		adj[v].push_back(u), adj[u].push_back(v);
	}
//	for (int i = 0; i < n; i++)
//		par[i] = root(i);
//	for (int i = 0; i < n; i++)	{
//		a[i].second = i;
	for (int i = 0; i < n; i++) {
		if(!vis[i]) {
			cnt++;
			dfs(i, cnt);
		}
	}
//	cout << "HERE\n";
	if (n < 2 * cnt - 2) {
		cout << "Impossible\n";
		return 0;
	}
	for (int i = 0; i < n; i++) {
		t[vis[i]].push_back(a[i]);
	}
	for (int i = 1; i <= cnt; i++) sort(t[i].begin(), t[i].end());
	if(cnt == 1) {
		cout << 0 << "\n";
		return 0;
	}
	ll ans = 0;
	vector <int> temp;
    for (int i = 1; i <= cnt; i++) {
    	ans += t[i][0];
    for (int j = 1; j < t[i].size(); j++)
		temp.push_back(t[i][j]);
    }
    sort(temp.begin(), temp.end());
    for (int i = 0; i < cnt - 2; i++)
    	ans += temp[i];
	cout << ans << "\n";
}

Measured memory_bytes: 16892
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let (a, b, c, x): (i32, i32, i32, i32) =
        (sc.input(), sc.input(), sc.input(), sc.input());

    let mut ans = 0;
    for i in 0..a + 1 {
        for j in 0..b + 1 {
            for k in 0..c + 1 {
                if 500 * i + 100 * j + 50 * k == x { ans += 1; }
            }
        }
    }
    println!("{}", ans);
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

struct edge {
   ll to, cost;
};

const ll INF = 1e18;
ll N, M, dist[1010];
vec<edge> G[3000];

int main() {
   cin >> N >> M;
   for (int i = 0; i < M; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      a--, b--;
      G[a].push_back(edge{b, c});
   }

   for (int i = 0; i < N; i++) {
      dist[i] = -INF;
   }

   dist[0] = 0;
   ll P = dist[N-1];
   for (int i = 0; i < 8*N; i++) { // 適当な回数回す
      for (int j = 0; j < N; j++) {
         for (edge e : G[j]) {
            dist[e.to] = max(dist[e.to], dist[j] + e.cost);
         }
      }
      if (P != dist[N-1] && i >= 5*N) {
         cout << "inf" << endl;
         return 0;
      }
      P = dist[N-1];
   }
   cout << dist[N-1] << endl;

   return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

const int MAX_N=404040;
ll inv[MAX_N+1], fact[MAX_N+1], ifact[MAX_N+1];

ll comb(int n, int k){
  if(n<k) return 0;
  return fact[n]*ifact[k]%MOD*ifact[n-k]%MOD;
}

void prepare(){
  inv[1]=fact[0]=fact[1]=ifact[0]=ifact[1]=1LL;
  for(int i=2;i<=MAX_N;i++){
    inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    fact[i]=fact[i-1]*i%MOD;
    ifact[i]=ifact[i-1]*inv[i]%MOD;
  }
}


int main(){
  prepare();
  int N,K; cin>>N>>K;
  ll ans=0;
  for(int i=0;i<=min(N-1,K);i++){
    (ans+=comb(N,i)*comb(N-1,i)%MOD)%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int n,k;
vector<ll> d;
ll calc(int left, int right){
    if(left+right>n) return 0;
    if(left+right>k) return 0;
    
    vector<ll> vec;
    for(int i=0; i<left; i++) vec.push_back(d[i]);
    for(int i=n-1; i>=n-right; i--) vec.push_back(d[i]);
    
    sort(all(vec));
    ll ret=0;
    int nokori=k-left-right;
    for(int x:vec){
        if(x<0  && nokori>0){
            nokori--;
            continue;
        }
        ret+=x;
    }
    return ret;
}

int main(){
    cin>>n>>k;
    d.resize(n);
    rep(i,n) cin>>d[i];
    
    ll ans=0;
    for(int left=0; left<=n; left++) {
        for(int right=0; right<=n; right++) {
            ans=max(ans,calc(left,right));
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)

using namespace std;

inline void inp( int &n ) { 
	n=0;    int ch=getcx();int sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

inline void inp1( LL &n ) { 
	n=0;    LL ch=getcx();LL sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

int main() {
	int k, i;
	string s;
	
	cin>>k;
	
	cin>>s;
	int n = s.length();
	for(i=0;i<min(n, k);i++) cout<<s[i];
	if(n > k) cout<<"...";
	cout<<endl;
    return 0;
}



Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int a,b;

int digit(){
    int i = 0;
    int c = a + b;
    for(i = 0; c >= 1;i++){
        c = c/10;
    }
    return i;
}

int main() {
    while(cin>>a>>b){
        cout<< digit() <<endl;
    }
    return 0;
}

Measured memory_bytes: 3076
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

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

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class DModSum {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n; cin >> n;
      cout << n*(n-1)/2 << endl;
    }
};

signed main() {
  DModSum solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

using namespace std;

signed main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
  }
  sort(a.rbegin(), a.rend());
  int ans = 0;
  while (m > 0 && !a.empty()) {
    int t = min(m, a.back().second);
    ans += t * a.back().first;
    m -= t;
    a.pop_back();
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define plus 8000
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.size();
  int a[10000] = {};
  int j = 0;

  for (int i = 0; i < n; i++){
    if (s[i] == 'F')
        a[j]++;
    else
        j++;
  }

  bitset<16001> dpx,dpy;
  dpx = 1;
  dpy = 1;
  dpx = dpx<<plus;
  dpy = dpy<<plus;
  dpx = dpx<<a[0];
  int i = 1;

  while(i < plus){
    dpy = (dpy<<a[i])|(dpy>>a[i]);
    i++;
    dpx = (dpx<<a[i])|(dpx>>a[i]);
    i++;
  }

  int x,y;
  cin >> x >> y;
  if(dpx[x+plus]&&dpy[y+plus])
    cout << "Yes" << endl;
  else
    cout << "No"<< endl;
  return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=1e9+7;
const int maxn=3e5+100;
const int N=2e5+1000;
const int M=500+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;cout.tie(0);
    int n;cin>>n;
    ll x;cin>>x;
    ll ans=0,tmp=x;
    for(int i=1;i<n;++i)
    {
        cin>>x;
        if(x<tmp) ans+=tmp-x;
        else tmp=x;
    }
    cout<<ans<<endl;
    return 0;
}



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

int main(){
    int a, b;
    
    while(1){
        cin >> a >> b;
        if ( a == 0 && b == 0 ) break;
        
        if ( a < b ){
            cout << a << " " << b << endl;
        } else {
            cout << b << " " << a << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3000
#include<cstdio>
#include<algorithm>
using namespace std;
#define _rep(i,s,t) for(register int i=s;i>=t;--i)
#define rep(i,s,t) for(register int i=s;i<=t;++i)
const int N=411,M=1e5+11;
int n,m,x,y,ans;
int a[M],b[M],p[N];
int f[N][N];
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,m)
		scanf("%d%d",a+i,b+i);
	rep(i,1,n){
		f[i][i]=1;
		_rep(j,m,1){
			x=a[j],y=b[j];
			if(!f[i][x]&&!f[i][y])continue;
			if(f[i][x]&&f[i][y]){
				p[i]=1;
				break;
			}
			f[i][x]=f[i][y]=1;
		}
	}
	rep(i,1,n)
		rep(j,i+1,n)
			if(!p[i]&&!p[j]){
				x=0;
				rep(k,1,n)
					if(f[i][k]&&f[j][k]){
						x=1;
						break;
					}
				if(!x)++ans;
			}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1536
import sys

def main():
    p=10**9+7
    def totsum(l,n):
        s=0
        t=0
        for i in range(n//2):
            t=t+l[-1-i]-l[i]
            s=(s+t) % p
        s=(2*s-(1-n&1)*t) % p
        return s
    n,m=map(int,input().split())
    x=list(map(int,sys.stdin.readline().strip().split()))
    y=list(map(int,sys.stdin.readline().strip().split()))
    
    print((totsum(x,n)*totsum(y,m))%p)
    
    # for j in range(2,m):
    #     ns=(s*(y[j]-y[j-1])) % p
    #     tot2=(tot2 + j*ns) % p
    #     tot1=(tot2+tot1) % p
    # print(tot1)

if __name__=='__main__':
    main()
    


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

//#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main(){
    int n; cin >> n;
    vector<int> b(n);
    rep(i,n) cin >> b[i];
    
    stack<int> answer;
    
    rep(i,n){
        for(int j = b.size()-1; j >= 0; j--){
            if(b[j] != j+1) continue;
            b.erase(b.begin()+j);
            answer.push(j+1);
            break;
        }
    }
    
    if(b.empty()){
        while(!answer.empty()){
            cout << answer.top() << endl;
            answer.pop();
        }
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;

int main()
{
    int k,x;
    cin >> k >> x;
    for(int i = x - k +1; i < k + x; i++){
        cout << i << ' ' ;
    }
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;

main(){
    int n=in();
    string s;cin>>s;
    if(n>=3200)cout<<s;
    else cout<<"red";
}


Measured memory_bytes: 256
#----------------------------------------------------------
P = 10**9 + 7
N = 100001 #使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心
inv = [0] + [1] # 1/x
finv = [1] + [1] # 1/x!
fac = [1] + [1] # x!
for i in range(2,N):
  inv += [inv[P % i] * (P - int(P / i)) % P]
  fac += [(fac[i-1] * i) % P]
  finv += [(finv[i-1] * inv[i]) % P]

def comb(a, b):
    if a<b:
        return -1 # error
    return (fac[a] * ((finv[b] * finv[a-b]) % P)) %P
#----------------------------------------------------------

n, k = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a, key=lambda x: x, reverse=False)
ans = 0
# a[i]が最小値になる場合の数
for i in range(len(a)):
    tmp = comb(n-1-i, k-1)
    if tmp<0:
        continue
    if a[i] < 0:
        ans = (ans + (abs(a[i])*tmp)%P)%P
    else:
        ans = (ans - (abs(a[i])*tmp)%P + P)%P

# a[i]が最大値になる場合の数
for i in range(len(a)):
    tmp = comb(n-1-i, k-1)
    if tmp<0:
        continue
    if a[n-1-i] < 0:
        ans = (ans - (abs(a[n-1-i])*tmp)%P + P)%P
    else:
        ans = (ans + (abs(a[n-1-i])*tmp)%P)%P
print(ans)


Measured memory_bytes: 25956
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a+b==c+d) cout << "Balanced" << endl; 
  if(a+b<c+d) cout << "Right" << endl;
  else if(a+b>c+d)cout << "Left" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int ans = 0;
    while(n > 0) {
        if(n%10 == 2) {
            ans++;
        }
        n /= 10;
    }

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

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

int main(){
  int N,L;
  cin >>N >>L;
  vector<string> s(N);
  for(int i=0;i<N;i++)
    cin >>s.at(i);
  sort(s.begin(),s.end());
  for(int i=0;i<N;i++)
    cout<<s.at(i);
  cout<<endl;
}

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

using ll = long long;
const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
}

Measured memory_bytes: 256