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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	string S; cin >> S;
	
	vi pow2H (N);
	vi pow2L (N);
	int base_popcount = 0;
	F0R(i, N) base_popcount += S[i] == '1';
	// todo base_popcount == 1
	int modH = 1;
	int modL = 1;
	F0R(i, N) {
		pow2H[i] = modH;
		pow2L[i] = modL;
		modH = 2 * modH % (base_popcount + 1);
		if (base_popcount > 1) modL = 2 * modL % (base_popcount - 1);
	}

	int valH = 0;
	int valL = 0;
	F0R(i, N) {
		if (S[N-i-1] == '1') {
			valH = (valH + pow2H[i]) % (base_popcount + 1);
			if (base_popcount > 1) valL = (valL + pow2L[i]) % (base_popcount - 1);
		}
	}

	F0R(x, N) {
		if (S[x] == '0') {
			// + 1
			int val = (valH + pow2H[N-x-1]) % (base_popcount + 1);
			int ans = 1;
			while (val != 0) {
				val = val % __builtin_popcount(val);
				++ans;
			}
			print(ans);
		} else {
			// - 1
			if (base_popcount == 1) {
				print(0);
			} else {
				int val = (valL - pow2L[N-x-1] + base_popcount - 1) % (base_popcount - 1);
				int ans = 1;
				while (val != 0) {
					val = val % __builtin_popcount(val);
					++ans;
				}
				print(ans);
			}
		}
	}
}

Measured memory_bytes: 5192
import java.util.*;
class Main {
    public static void main (String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for(int i = 0; i < n; i++) a[i] = sc.nextInt();
        for(int i = 0; i < n; i++) {
            if(i != 0) System.out.print(" ");
            System.out.print(a[n - i - 1]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 26284
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 const int INF = 2147483647;
 const ll MOD = 1000000007;
 // const ll INF = 1000000000000000000LL;

int main() {
	string s;
	cin >> s;
	int left = 0;
	int right = s.size()-1;
	bool can = true;
	int cnt=0;
	while(left<right){
		if(s[left]==s[right]){
			left++;right--;
		}
		else if(s[left]=='x') {
			cnt++;
			left++;
		}
		else if(s[right]=='x'){
			cnt++;
			right--;
		}
		else{
			cout << -1 << endl;
			return 0;
		}
		
	}
	cout << cnt << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

const int M = 1e9 + 7;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    vector<pair<ll, ll>> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i].first >> A[i].second;
    }

    auto comp = [&](pair<ll, ll>& a, pair<ll, ll>& b) {
        return a.first + a.second < b.first + b.second;
    };

    sort(A.begin(), A.end(), comp);

    // vector<vector<ll>> dp(2, vector<ll>(n + 1, 1e14));

    // dp[0][0] = 0;

    vector<ll> dp (n + 1 , 1e14); 

    dp[0] = 0 ;

    for (int i = 1; i <= n; ++i) {
        for (int j = n; j >= 1; --j) {

            if (A[i-1].first >= dp[j-1]){
                dp[j] = min(dp[j] , dp[j-1] + A[i-1].second); 
            }
        }
    }

    for (int j = n; j >= 0; --j) {
        if (dp[j] != 1e14) {
            cout << j << "\n";
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 384
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
bool A[1000][1000];
bool visit[1000][1000];
int h, w;

struct node{
    int x;
    int y;
    int dis;
};
queue<node> stack;

int bfs(){
    int ans = 0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(A[i][j]){
                stack.push(node{i, j, 0});
            }
        }
    }
    while(stack.size()){
        node N = stack.front();
        stack.pop();
        if(visit[N.x][N.y]){
            continue;
        }
        if(0 > N.x || N.x == h || 0 > N.y || N.y == w){
            continue;
        }
        visit[N.x][N.y] = true;
        stack.push(node{N.x+1, N.y, N.dis+1});
        stack.push(node{N.x-1, N.y, N.dis+1});
        stack.push(node{N.x, N.y-1, N.dis+1});
        stack.push(node{N.x, N.y+1, N.dis+1});
        ans = N.dis;
    }
    return ans;
}

int main(){
    for(int i=0;i<h;i++){
        fill(visit[i], visit[i]+w, false);
    }
    cin >> h >> w;
    for(int i=0;i<h;i++){
        string s;
        cin >> s;
        for(int j=0;j<w;j++){
            A[i][j] = s[j] == '#';
        }
    }
    int ans = bfs();
    cout << ans;
    return 0;
}


Measured memory_bytes: 50632
#https://atcoder.jp/contests/abc075/tasks/abc075_b?lang=ja
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
for i in range(H):
    for j in range(W):
        count = 0
        if s[i][j] == "#":
            pass
        else:
            if i > 0 and j > 0 and s[i-1][j-1] == "#": #左上
                count +=1
            if i > 0 and s[i-1][j]=="#": #上
                count +=1
            if i > 0 and j <W-1 and s[i-1][j+1] =="#": #右上
                count +=1  
            if j < W-1 and s[i][j+1] =="#": #右
                count +=1
            if i < H-1 and j<W-1 and s[i+1][j+1] =="#": #右下
                count +=1
            if i < H-1 and s[i+1][j] =="#": #下
                count +=1
            if i<H-1 and j>0 and s[i+1][j-1] =="#":  #左下
                count +=1
            if j > 0 and s[i][j-1] == "#":   #左
                count +=1
            s[i][j] = str(count)         
for i in range(H):
    print("".join(s[i]))
    

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

void Main() {
  char b;
  cin >> b;
  if (b == 'A') cout << 'T' << endl;
  else if (b == 'C') cout << 'G' << endl;
  else if (b == 'G') cout << 'C' << endl;
  else if (b == 'T') cout << 'A' << endl;
}

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

Measured memory_bytes: 256
import numpy as np

n, m = map(int,input().split())

ks = [list(map(int,input().split()[1:])) for _ in range(m)]

ss = list(map(int,input().split()))

ans = 0
for i in range(2**n):
    i = list(reversed("{:010b}".format(i)))
    f = True
    for k,s in zip(ks,ss):
        o = 0
        for j in k:
            if i[j-1] == "1":
                o+=1
        if o%2 != s:
            f = False
    if f:
        ans+=1
print(ans)

Measured memory_bytes: 12388
from collections import deque

while True:
    n, m = map(int, input().split())
    if n == 0:
        break
    q = deque([i for i in range(n)]) 
    i = 0
    while True:
        i += 1
        if i == m:
            q.popleft()
            i = 0
            if len(q) == 1:
                print(q.pop() + 1)
                break
        else:
            q.append(q.popleft())



Measured memory_bytes: 6000
n=int(input())
A=list(map(int,input().split()))
ans=A[0]
def gcd(a,b):
    if b==0: return a
    else:
        return gcd(b,a%b)
def lcm(a,b):
    return a*b//gcd(a,b)

for i in range(n-1):
    ans=gcd(ans,A[i+1])
    if ans==1:
        print(1);exit()

print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cfenv>
#include <cmath>

using namespace std;

int main() {
  string s;
  cin>>s;
  int a = s.size();
  if(s[a-1]=='2' || s[a-1]=='4' || s[a-1]=='5'|| s[a-1]=='7' || s[a-1]=='9' )
  cout<<"hon"<<endl;
  else if(s[a-1]=='0' || s[a-1]=='1' || s[a-1]=='6' || s[a-1]=='8')
  cout<<"pon"<<endl;
  else
    cout<<"bon"<<endl;

  return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

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

vector<int> c[N];
int n, a[N], dp[N];

int rek(int pos) {
  if (pos == n) return 1;
  int &ret = dp[pos];
  if (ret != -1) return ret;
  ret = rek(pos+1);
  if (pos+1 < n && a[pos+1] == a[pos]) return ret;
  int A = upper_bound(c[a[pos]].begin(), c[a[pos]].end(), pos)-c[a[pos]].begin();
  if (A < c[a[pos]].size()) {
    ret = (ret + rek(c[a[pos]][A])) % mod;
  }
  return ret;
}

void solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
    if (c[a[i]].size() && c[a[i]].back() == i-1) c[a[i]].pop_back();
    c[a[i]].push_back(i);
  }
  dp[n] = 1;
  for (int i = n-1; i >= 0; --i) {
    (dp[i] += dp[i+1]) %= mod;
    if (c[a[i]].empty()) continue;
    if (i+1 < n && a[i+1] == a[i]) continue;;
    int A = c[a[i]].back();
    if (A == i) continue;
    c[a[i]].pop_back();
    (dp[i] += dp[A]) %= mod;
  }
  printf("%d", dp[0]);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 16092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            while(true){
                String str = reader.readLine();
                String[] split = str.split(" ");
                int n = Integer.parseInt(split[0]);
                int x = Integer.parseInt(split[1]);
                if(n == 0 && x == 0){
                    break;
                }
                int count = 0;
                for(int i = 1; i <= n; i ++){
                    for(int j = i+1; j <= n; j++){
                        for(int k = j+1;k<=n;k++){
                            if(i!=j && j!=k && k!=i){
                                int sum = i + j + k;
                                if(sum == x){
                                    count += 1;
                                }
                            }
                        }
                    }
                }
                System.out.println(count);
            }
        }catch(IOException e){

        }
    }
}


Measured memory_bytes: 25044
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int ans=0;
	string n;
	cin>>n;
	for(int i=0;i<n.length();i++)
	{
		if(n[i]!=n[i-1])
		{
			ans++;
		}
	}
	cout<<ans-1<<endl;
}

Measured memory_bytes: 512
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll D,N;
	while(cin>>D>>N) {
		ll co=0;
		ll ans = 0;
		RANGE(i, 1, 10000000) {
			ll a=0;
			ll v=i;
			while(v%100==0) {
				v/=100;
				a++;
			}
			if(a==D) co++;
			if(co==N) {ans=i;break;}
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
# 0や1のケースに注意
# index out of range
# 貪欲

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = n % 10
    if a == 3:
        print('bon')
    elif a == 0 or a == 1 or a == 6 or a == 8:
        print('pon')
    else:
        print('hon')

if __name__ == '__main__':
    main()

Measured memory_bytes: 65236
n = int(input())
a = [0] + list(map(int, input().split())) + [0]

total = 0
for i in range(len(a) - 1):
    total += abs(a[i+1] - a[i])

for i in range(1, n + 1):
    print(total - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i-1] - a[i+1]))


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

int main() {
  std::string str;
  std::cin >> str;

  int n;
  std::cin >> n;

  std::string command;
  int a, b;
  for(int i = 0; i < n; ++i) {
    std::cin >> command >> a >> b;
    if(command == "replace") {
      std::string rep;
      std::cin >> rep;
      str.replace(a, b - a + 1, rep);
    }
    else if(command == "reverse") {
      std::string rev(str.substr(a, b - a + 1));
      for(int j = 0; j < b - a + 1; ++j) {
        str[a + j] = rev[b - a - j];
      }
    }
    else if(command == "print") {
      std::cout << str.substr(a, b - a + 1) << std::endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define i64 long long
#define ui64 unsigned long long
#define all(x) x.begin(), x.end()
#define LB(x,v) lower_bound(all(x),v) - x.begin()
#define maxn (int)(1e5)
using namespace std;

i64 lcm(ui64 a, ui64 b){
	return a/__gcd(a,b)*b;
}
i64 cnt(i64 L, i64 R, i64 val){
	return R/val - (L-1)/val;
}

int main() {
	// your code goes here
	
	i64 A,B,C,D, total;
	scanf("%lld %lld %lld %lld",&A,&B,&C,&D);
	
	total = B - A + 1;
	i64 nC = cnt(A,B, C); 
	i64 nD = cnt(A,B, D); 
	i64 nCD = cnt(A,B, lcm(C,D));
	printf("%lld\n", total-(nC+nD-nCD));
	return 0;
}

Measured memory_bytes: 256
<?php
 
fscanf(STDIN, '%d', $n);
for ($count = 0; $count < $n; $count++) {
    $a = explode(' ', trim(fgets(STDIN)));
    $b = 0;
    $c = 0;
    for ($i = 0; $i < 10; $i++) {
        if ($a[$i] > $b) {
            $b = $a[$i];
        } elseif ($a[$i] > $c) {
            $c = $a[$i];
            if ($c > $b) {    //右の筒の方が大きければ筒を入れ替える
                $tmp = $b;
                $b = $c;
                $c = $tmp;
            }
        } else {
            break;
        }
    }
 
    echo $i === 10 ? 'YES' : 'NO';
    echo PHP_EOL;
}

Measured memory_bytes: 6588
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
char s[100005];
int main()
{
	cin >> s;
	int ans=0;
	for(int i=0;i<strlen(s)-1;i++)
	{
		if(s[i]!=s[i+1])
			ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long long n,arr[9],A,B,C;
long long dfs(long long l,long long a,long long b,long long c)
{
	if(l==n)
	{
		long long num;
		num=abs(A-a)+abs(B-b)+abs(C-c);
		if(a==0||b==0||c==0)
			return INT_MAX;
		return num-30;
	}
	long long r1,r2,r3,r4;
	r1=dfs(l+1,a+arr[l+1],b,c)+10;
	r2=dfs(l+1,a,b+arr[l+1],c)+10;
	r3=dfs(l+1,a,b,c+arr[l+1])+10;
	r4=dfs(l+1,a,b,c);
	return min(min(r1,r2),min(r3,r4));
}
int main()
{
	long long i,j;
	scanf("%lld %lld %lld %lld",&n,&A,&B,&C);
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&arr[i]);
	}
	printf("%lld",dfs(0,0,0,0));
}

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
struct A
{
    int x,y;
}a[100050];
bool cmp(A c,A d)
{
    if(c.y==d.y)
        return c.x<d.x;
    else
    return c.y<d.y;
}
int main()
{
    int n,m;
    int ow=0x3fffffff;
    cin>>n>>m;
    for(int i=0;i<m;i++)
        {
          cin>>a[i].x>>a[i].y;
          ow=min(a[i].y,ow);
        }
    sort(a,a+m,cmp);
    int sum=1;
    for(int i=0;i<m;i++)
    {
        if(a[i].x>=ow)
        {
            sum++;
            ow=a[i].y;
        }
    }
    cout<<sum;
    return 0;
}


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

int asc(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}
int main() {
    int a,n,order_p,order_q;
    int p[8] = { 0 }, q[8] = { 0 };
    int upper_new = 1, lower_new = 1;
    int upper_old = 1, lower_old = 1;
    int flag_p[9] = { 10,10,10,10,10,10,10,10,10 }, flag_q[9] = { 10,10,10,10,10,10,10,10,10 };

    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &p[i] );
    for (int i = 0; i < n; i++) scanf("%d", &q[i]);
    for (int i = 1; i <= n; i++) {
        upper_old *= i;
        flag_p[i - 1] = i;
        flag_q[i - 1] = i;
    }
    //printf("upper_old=%d\n", upper_old);
    for (int i = 0; i < n - 1; i++) {
        qsort(flag_p, n, sizeof(int), asc);
        for( a=0;a < n - i; a++ ){
            if (p[i] == flag_p[a]) {
                flag_p[a] = 10;
                break;
            }
        }
        //printf("in pa=%d\n", a);
        upper_new = (upper_old - lower_old + 1) * (a + 1) /(n - i) + lower_old - 1;
        lower_new = (upper_old - lower_old + 1) * a /( n - i) + lower_old;
        upper_old = upper_new;
        lower_old = lower_new;
    }
    order_p = upper_new;

    upper_new = 1, lower_new = 1;
    upper_old = 1, lower_old = 1;
    for (int i = 1; i <= n; i++) upper_old *= i;
    for (int i = 0; i < n - 1; i++) {
        qsort(flag_q, n, sizeof(int), asc);
        for (a = 0; a < n - i; a++) {
            if (q[i] == flag_q[a]) {
                flag_q[a] = 10;
                break;
            }
        }
        upper_new = (upper_old - lower_old + 1) * (a + 1) / (n - i) + lower_old - 1;
        lower_new = (upper_old - lower_old + 1) * a / (n - i) + lower_old;
        upper_old = upper_new;
        lower_old = lower_new;
    }
    order_q = upper_new;
    //printf("order_p=%d\norder_q=%d\n", order_p, order_q);
    printf("%d", abs(order_p-order_q));
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main() {
  int a, b;
  cin >> a >> b;
  P((a + b) % 24);
  return 0;
}

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

using namespace std;

char conv(int c){ return c < 26 ? 'a' + c : 'A' + c - 26; }

main(){
  int n, k[100];
  string s;
  while(cin >> n && n){
    for(int i=0;i<n;i++) cin >> k[i];
    cin >> s;
    for(int i=0;i<s.size();i++){
      if(islower(s[i])) cout << conv((s[i] - 'a' - k[i%n] + 52) % 52);
      else cout << conv((s[i] - 'A' - k[i%n] + 26 + 52) % 52);
    }
    cout << endl;
  }
}

Measured memory_bytes: 1196
def divisor(n):
    lists=[]
    for i in range(1,n+1):
        if n%i==0:
            lists.append(i)
    return len(lists)

N=int(input())
cnt=0
for i in range(1,N+1):
    if i%2 != 0 and divisor(i)==8:
        cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;

ll bit[200010];
//ll kai[3010];
ll Cnt[1000010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }



/*ll sum(ll i)
{
	//i += 1;
	ll t = 0;
	while (i > 0)
	{
		t += bit[i];
		i -= i & -i;
	}
	return t;
}

void add(ll i, ll x)
{
	//i += 1;
	while (i <= 200005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

/*`ll SAIKI(ll S) {
	for (ll T = S; ; T = (T - 1) & S) {

	}
}*/



void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

void makePrimeList(ll x) {
	ll X = x;
	for (ll j = 2; j * j <= x; j++) {
		ll cnt = 0;
		while (X % j == 0) {
			cnt++;
			X /= j;
		}
		if (cnt) {
			Cnt[j] = max(Cnt[j], cnt);
		}
	}
	if (X != 1) Cnt[X] = max(Cnt[X], 1LL);
}

ll N;
ll ans;

void solve() {
	cin >> N;
	if (N % 2 == 1) {
		cout << 0 << endl;
	}
	else {
		ll nu = 2;
		while (nu <= 1000000000000000000) {
			nu *= 5;
			ans += N / nu;
		}
		cout << ans << endl;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::collections::HashSet;

fn input_tuple() -> (usize, usize) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<usize> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_tuple_three() -> (usize, usize, usize) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<usize> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}

#[derive(Debug, PartialEq, Clone)]
struct Node {
    parent: Option<usize>, 
    size: usize,
}

#[derive(Debug, PartialEq)]
pub struct UnionFind {
    tree: Vec<Node>,
}

impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        UnionFind {tree: vec![Node {parent: None, size: 1}; n]}
    }

    pub fn unite(&mut self, i: usize, j: usize) {
        let root_i = self.find(i);
        let root_j = self.find(j);
        if root_i == root_j {
            return
        }

        if self.tree[root_i].size < self.tree[root_j].size {
            self.tree[root_i].size += self.tree[root_j].size;
            self.tree[root_j].parent = Some(root_i);
        } else {
            self.tree[root_j].size += self.tree[root_i].size;
            self.tree[root_i].parent = Some(root_j);
        }

    }

    pub fn find(&mut self, i: usize) -> usize {
        match self.tree[i].parent {
            Some(p) => {
                let root = self.find(p);
                self.tree[i].parent = Some(root);
                root
            },
            None => i
        }
    }

    pub fn equiv(&mut self, i: usize, j: usize) -> bool {
        self.find(i) == self.find(j)
    }

    pub fn size(&mut self, i: usize) -> usize {
        let root = self.find(i);
        self.tree[root].size
    }
}

fn main() {
    let (n, m) = input_tuple();
    let mut union_find = UnionFind::new(n);
    for _ in 0..m {
        let (x, y, _) = input_tuple_three();
        union_find.unite(x - 1, y - 1);
    }
    let mut set: HashSet<usize> = HashSet::new();
    for i in 0..n {
        set.insert(union_find.find(i));        
    }
    println!("{}", set.len());
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n, ans=1;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    bool out=false;
    rep(i,n){
        if(ans > INF/a[i]) out = true;
        else ans *= a[i];
    }
    if(out) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

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

  string S;
  cin >> S;

  int R = 0;
  int B = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'R')
      R++;
    else if (S.at(i) == 'B')
      B++;
  }

  if (R > B)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main()
{
    char c;
    cin >> c;
    set<char> st = {'a', 'i', 'u', 'e', 'o'};
    if (st.find(c) != st.end()) cout << "vowel" << endl;
    else cout << "consonant" << endl;

    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  string X;
  cin >> X;
  X.erase(unique(X.begin(), X.end()), X.end());
  cout << X.size() << "\n";
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 


int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n;
	cin>>n;
	
	long double z = 0;
	
	for(ll i=0;i<n;i++)
	{
		long double x=1.0;
		cin>>x;
		z += (1/x);
		
	}
	long double ans = 1/z;
	
	cout<<fixed<<setprecision(10)<<ans<<endl;
	
	
}




Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int a,b,c;
    int ans,n,x;
    
    while (1) {
   
    scanf("%d %d",&n,&x);
    
    if (x == 0 && n == 0){
        break;}
        ans = 0;
        for (a=1 ; a<=n-2 ; a++ ) {
            for (b=a+1 ; b<=n-1 ; b++ ) {
                for (c=b+1 ; c<=n ; c++ ) {
                    if(a + b + c == x)ans++;
                }
  
            }

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

Measured memory_bytes: 600
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

n = I()
t = Intl()
m = I()
px = [Intl() for i in range(m)]
#print(px)
s = sum(t)
time = s
for i in range(m):
    print(time-t[px[i][0]-1]+px[i][1])
    time = s

Measured memory_bytes: 3064
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  
  
  ll ans = 1LL << 60;
  for(int y = -100; y <= 100;y++){
    ll cost = 0LL;
    rep(i,n){
      cost += (a[i] - y) * (a[i] - y); 
    }
    chmin(ans,cost);
  }
  
  cout << ans;
  
  return 0;
}

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

using namespace std;

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

#define F first
#define S second

const int MAXN = 1e5 + 10;

int n, m, a[MAXN];
vector<int> adj[MAXN];
bool vis[MAXN];
multiset<int> st[MAXN];
set<pii> ss;
int g, cnt[MAXN];

void dfs(int v){
	st[g].insert(a[v]);
	vis[v] = 1;
	for (int u:adj[v])
		if (!vis[u])
			dfs(u);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	if (m == n-1){
		cout << "0\n";
		return 0;
	}
	for (int i = 0; i < n; i++) cin >> a[i];
	int c = n-m;
	while (m--) {
		int a, b;	cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	if (n < (c-1)*2){
		cout << "Impossible\n";
		return 0;
	}
	for (int v = 0; v < n; v++)
		if (!vis[v]){
			dfs(v);
			g++;
		}
	int req = (c-1)*2;
	ll sm = 0;
	for (int i = 0; i < g; i++){
		sm += *st[i].begin();
		st[i].erase(st[i].find(*st[i].begin()));
		if (st[i].size())
			ss.insert({*st[i].begin(), i});
		req--;
		cnt[i]++;
	}
	while (req && ss.size()){
		int v = ss.begin()->S;
		if (cnt[v] + 1 > c-1)
			ss.erase(ss.begin());
		else{
			cnt[v]++;
			req--;
			sm += ss.begin()->F;
			ss.erase(ss.begin());

			st[v].erase(st[v].find(*st[v].begin()));
			if (st[v].size())
				ss.insert({*st[v].begin(), v});
		}
	}
	if (req)
		cout << "Impossible\n";
	else
		cout << sm << "\n";
	return 0;
}


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

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


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 1000000000
#define MOD 1000000007
#define ll long long int
using namespace std;

int main(){
	int A,B,C; cin>>A>>B>>C;
	if(A<C and C<B) cout<<"Yes"<<endl;
	else if (B<C and C<A) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;



	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a[3];
    for(int i=0; i<3; i++){
        scanf("%d", &a[i]);
        for(int j = i; a[j-1]>a[j] && j>0; j--){
            int t = a[j-1];
            a[j-1] = a[j];
            a[j] = t;
        }
    }

    int sum = 0;
    for(int i=0; i<2; i++){
        sum += a[i];
    }
    printf("%d", sum);
    return 0;
}

Measured memory_bytes: 128
N = input()
As = list(map(int, input().split()))

Alice = []
Bob = []

while(As):
    Alice.append(max(As))
    As.remove(max(As))
    if not As:
        break
    Bob.append(max(As))
    As.remove(max(As))

print(sum(Alice) - sum(Bob))

Measured memory_bytes: 3060
import java.util.*;

public class Main {
	public static void main(String[] args) {
		 
               Scanner sc = new Scanner(System.in);
                                            
               int N = 13;
               
               UnionFind uf = new UnionFind(N);
               
               uf.union(1 ,3);
               uf.union(3 ,5);
               uf.union(5 ,7);
               uf.union(7 ,8);
               uf.union(8 ,10);
               uf.union(10,12);
               
               uf.union(4,6);
               uf.union(6,9);
               uf.union(9,11);

               int x = sc.nextInt();
               int y = sc.nextInt();
               
               if(uf.same(x,y)){
                   System.out.println("Yes");
               }else{
                   System.out.println("No");   
               }
               
        }
        
        private static class UnionFind{
              
             int [] parent;
             int []   rank;
             
             UnionFind(int n){
                 parent = new int[n];
                 rank   = new int[n];
                 for(int i = 0;i < n;i++){
                     parent[i] = i;
                       rank[i] = 0;
                 }                 
             }
                
             int find(int x){
                 if(parent[x] == x){
                      return x;   
                 }else{
                      return parent[x] = find(parent[x]);
                 }                 
             }
             
             boolean same(int x,int y){
                 return find(x) == find(y);
             }
             
             void union(int x,int y){
                 x = find(x);
                 y = find(y);
                 
                 if(x != y){
                     if(rank[x] > rank[y]){
                          parent[y] = x;   
                     }else{
                          parent[x] = y;
                          if(rank[x] == rank[y]){
                              rank[y]++;
                          }
                     }                     
                 }
                 
                 return;
             }           
             
             int count(){
                    int ret = 0;
                                        
                    for(int i = 0;i < parent.length;i++){
                        if(find(i) == i){
                            ret++;
                        }    
                    }
                    
                    return ret;
             }      
             
             
        }                        
}


Measured memory_bytes: 21716
#include<stdio.h>
 
int main(){
int N, T;
int i, judge;

  scanf("%d %d", &N,&T);
  
int c[N],t[N];

judge = 1001;
 
  for(i = 0; i < N; i++){
  scanf("%d %d", &c[i], &t[i]);

  if(t[i] <= T){
  if(c[i] < judge)
  judge = c[i];
  }
}
 
  if(judge == 1001)
    printf("TLE\n");
 
  else printf("%d\n",judge);

  return 0;
 
}
 
  
 
  

Measured memory_bytes: 128
import java.util.*;

class Main{


    private static long solver(int[] w, int[] v, int n, int max){
        
        long[][] dp = new long[n + 1][max + 1];
        for(long[] row: dp) Arrays.fill(row, 0);


        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= max; j++){

                if(w[i-1] <= j) { 
                    int emptyCapacity = j - w[i-1]; 
                    dp[i][j] = Math.max(dp[i-1][j], v[i-1] + dp[i-1][emptyCapacity]);
                     
                } else { 
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
        
        return dp[n][max];
    }


    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(); // number of items
        int max = in.nextInt(); // max weight
        int[] w = new int[n];
        int[] v = new int[n];
        
        for(int i = 0; i < n; i++){
            w[i] = in.nextInt();
            v[i] = in.nextInt();
        }
        System.out.println(solver(w, v, n, max));
    }
}

Measured memory_bytes: 126036
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
	int n;
	int count;
	int i;
	string tmp,foot;
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
	count = 0;
	tmp = "ld";
		for(i = 0 ; i < n ; i++){
			cin >> foot;
			if((tmp == "ld" && foot == "rd")||(tmp == "lu" && foot == "ru")||(tmp == "rd" && foot == "ld")||(tmp == "ru" && foot == "lu")){
				count++;
			}
			tmp = foot;
		}
		cout << count << endl;
		}
		return 0;
}

Measured memory_bytes: 1212
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
using ll = long long;
const int INF = 1e8;

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<ll>> ab(M, vector<ll>(2));
  for (int i = 0; i < M; i++) {
    cin >> ab[i][0] >> ab[i][1];
  }
  sort(ab.begin(), ab.end(),
       [](const vector<ll> &alpha, const vector<ll> &beta) {
         return alpha[1] < beta[1];
       });

  int ans = 1;
  ll x_last = ab[0][1];
  for (int i = 1; i < M; i++) {
    if (ab[i][0] < x_last) {
      continue;
    }
    x_last = ab[i][1];
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<cstdio>
using namespace std;
int W, H;
int dp1[100][100];
int dp2[100][100];
int dp3[100][100];
int dp4[100][100];
int mod = 100000;
int main(){
	while (true){
		scanf("%d%d", &W, &H);
		if (W == 0 && H == 0)break;
		for (int i = 1; i < W; i++){
			dp1[i][0] = 1;
			dp2[i][0] = 1;
		}
		for (int j = 1; j < H; j++){
			dp3[0][j] = 1;
			dp4[0][j] = 1;
		}
		for (int i = 1; i < W; i++){
			for (int j = 1; j < H; j++){
				dp1[i][j] = dp2[i - 1][j];
				dp2[i][j] = (dp2[i - 1][j] + dp3[i - 1][j]);
				dp2[i][j] %= mod;
				dp3[i][j] = dp4[i][j - 1];
				dp4[i][j] = (dp1[i][j - 1] + dp4[i][j - 1]);
				dp4[i][j] %= mod;
			}
		}

		printf("%d\n", (dp1[W - 1][H - 2] + dp2[W - 2][H - 1] + dp3[W - 2][H - 1] + dp4[W - 1][H - 2]) % mod);
	}
	return 0;
}

Measured memory_bytes: 1344
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    
 	n = (n%100)%10;

    if (n == 3)
    {
    	cout << "bon";
    }
    if (n == 0 || n == 1 || n == 6 || n == 8)
    {
    	cout << "pon";
    }
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
    {
    	cout << "hon";
    } 
    return 0;
}

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

using namespace std;

using LL = long long;

const int MAXN = 200005;
const LL MOD = (LL)1e9 + 7LL;

LL inv[MAXN];

LL fexp(LL b, LL e) {
	if (b == 0 || e == 1) return b;
	if (b == 1 || e == 0) return 1LL;
	LL r = fexp(b, e / 2);
	r = ((r % MOD) * (r % MOD)) % MOD;
	if (e & 1) r = ((b % MOD) * (r % MOD)) % MOD;
	return r;
}	


LL fat (LL x) {
	LL r = 1;
	for (LL i = 2; i <= x; ++i)
		r = ((r % MOD) * (i % MOD)) % MOD;
	return r;
}

LL inv_mod(LL k) {
	LL ans = 1;
	for(LL i = 2; i <= k; ++i)
		ans = (ans % MOD * inv[i]) % MOD;
	return ans;
}

LL comb(LL n, LL k) {
	LL res = 1;
	for (LL i = n - k + 1; i <= n; ++i) 
		res = ((res % MOD) * (i % MOD)) % MOD;
	return (res % MOD * inv_mod(k) % MOD) % MOD;
}


int main() {

	ios_base :: sync_with_stdio(0); cin.tie(NULL);

	inv[1] = 1;
	for (int i = 2; i < MAXN; ++i)
		inv[i] = (MOD - (MOD / i) * inv[MOD % i] % MOD) % MOD;

	LL n, a, b;
	cin >> n >> a >> b;

	cout << (fexp(2LL, n) + 2 * MOD - 1 - comb(n, a) - comb(n, b) + MOD) % MOD<< '\n';


	return 0;	
}

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

int main(){
  vector<int> n(3); cin>>n[0]>>n[1]>>n[2];
  sort(n.begin(),n.end());
  if(n[2]==n[0]+n[1]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
  int n,y;
  cin>>n>>y;
  if(y<n*1000||y>n*10000){
    cout << "-1 -1 -1" << endl;
    return 0;
  }
  for(int a=0;a<=y/10000;++a){
    for(int b=0;b<=y/5000;++b){
      if((y-a*10000-b*5000)/1000==n-a-b&&n-a-b>=0){
        cout << a << " " << b << " " << n-a-b << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iterator>
using namespace std;
typedef long long ll;
bool srt( pair < int , int > a, pair < int , int > b){
    return a.first != b.first ? a.first>b.first : a.second<b.second;
}
int main (){
int a,b,c,d;
cin>>a>>b>>c>>d;
int sum=0;
if(a<=b) {
    sum+=a;
}
 if(b<a){
    sum+=b;
}
if(c<=d){
    sum+=c;
}
if(d<c){
   sum+=d;
}
cout<<sum;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int h, w, k; std::cin >> h >> w >> k;
    vector<string> vec(h);
    rep(i, h) std::cin >> vec[i];
    auto check = [&](int n, vector<string> vec){
        rep(i, h) if ((n >> i) & 1) {
            rep(j, w) {
                vec[i][j] = '?';
            }
        }
        rep(i, w) if ((n >> (h+i)) & 1) {
            rep(j, h) {
                vec[j][i] = '?';
            }
        }
        int cnt = 0;
        rep(i, h) rep(j, w) if (vec[i][j] == '#') cnt++;
        return cnt == k;
    };
    int ans = 0;
    rep(i, 1 << (h + w)) {
        ans += check(i, vec);
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] values = new int[w];
        int i;
        int A;
        int B;

        for(i=0;i<values.length;i++){
            values[i] = i + 1;
        }

        for(i=0;i<n;i++){
            String str = sc.next();
            String[] ab = str.split(",");

            int a = Integer.parseInt(ab[0]) - 1;
            int b = Integer.parseInt(ab[1]) - 1;      

            A = values[a];
            B = values[b];
            
            values[a] = B;
            values[b] = A;

        }

        for(i=0;i<values.length;i++){
            System.out.printf("%d\n",values[i]);

        }

        sc.close();

    }

}


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

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

  if (a == b && b == c) {
    cout << 1 << endl;
  } else if (a != b && b != c && a != c) {
    cout << 3 << endl;
  } else {
    cout << 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,ans;
ll d,x,y;
int main()
{
	cin>>n>>d;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&x,&y);
		if(x*x+y*y<=d*d)ans++;
	}
	printf("%d",ans);
}


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

using namespace std;

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;

#ifdef WIN32
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

int cnt[30];
char s[105];
int n, m;

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
    {
        scanf("%s", s);
        for (int j = 0; j < m; j++) cnt[s[j] - 'a']++;
    }
    int cnt4 = (n / 2) * (m / 2);
    int cnt2 = (n / 2) * (m % 2) + (n % 2) * (m / 2);
    int cnt1 = (n % 2) * (m % 2);
    for (int i = 0; i < 26; i++) if (cnt[i] >= 4 && cnt4 > 0)
    {
        int k = min(cnt[i] / 4, cnt4);
        cnt[i] -= k * 4;
        cnt4 -= k;
    }
    for (int i = 0; i < 26; i++) if (cnt[i] >= 2 && cnt2 > 0)
    {
        int k = min(cnt[i] / 2, cnt2);
        cnt[i] -= k * 2;
        cnt2 -= k;
    }
    for (int i = 0; i < 26; i++) if (cnt[i] >= 1 && cnt1 > 0)
    {
        int k = min(cnt[i], cnt1);
        cnt[i] -= k;
        cnt1 -= k;
    }
    if (cnt4 > 0 || cnt2 > 0 || cnt1 > 0) printf("No\n");
    else printf("Yes\n");
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int ans = 999;
        for(int i=0;i<=S.length()-3;i++){
            int part = Integer.parseInt(S.substring(i,i+3));
            ans = Math.min(ans, Math.abs(part-753));
        }
        System.out.println(ans);
    }
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll N;
  scanf("%lld",&N);
  vector<ll> d(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&d[i]);
  }
  sort(d.begin(),d.end());
  d.erase(unique(d.begin(), d.end()), d.end());
  cout << d.size() << endl;
}

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


Measured memory_bytes: 256