akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int M = 1e9 + 7, N = 4e6;

int f[N], fi[N], inv[N];

int C(int n, int k){
	return f[n] * fi[k] % M * fi[n - k] % M;
}

int go(int n, int m) {
	int ret = 0;
	for(int i = 1; i <= n + 1; i++) ret += C(i+m, m);
	return ret % M;

}

signed main()
{
	IO_OP;
	
	f[0] = 1;
	for(int i = 1; i < N; i++) f[i] = f[i-1] * i % M;
	inv[1] = 1;
	for(int i = 2; i < N; i++) inv[i] = M - M / i * inv[M % i] % M;
	fi[0] = 1;
	for(int i = 1; i < N; i++) fi[i] = fi[i-1] * inv[i] % M;

	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	int ans = go(r2, c2) - go(r1 - 1, c2) - go(r2, c1 - 1) + go(r1 - 1, c1 - 1);
	ans = (ans % M + M) % M;
	cout << ans << endl;
	
}





Measured memory_bytes: 93952
#ABC-136-C
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
hunted_monsters = 0

for i in range(N):
    #勇者iが街iのモンスターを全て倒しても余力がある場合
    if A[i] < B[i]:
        B[i] -= A[i]
        hunted_monsters += A[i]
        A[i] = 0
        #街i+1のモンスターも全て倒せる場合
        if A[i+1] <= B[i]:
            B[i] -= A[i+1]
            hunted_monsters += A[i+1]
            A[i+1] = 0
        #街i+1のモンスターを一部倒せる場合
        else:
            A[i+1] -= B[i]
            hunted_monsters += B[i]
            B[i] = 0
    #勇者iが街iのモンスターの一部(もしくはぴったり全て)倒して余力がない場合
    else:
        A[i] -= B[i]
        hunted_monsters += B[i]
        B[i] = 0

print(hunted_monsters)
        

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

class Main{
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

//		 int n = Integer.parseInt(in.readLine());
		
		 String[] xy = in.readLine().split(" ");

		 int x=Integer.parseInt(xy[0]);
		 int y=Integer.parseInt(xy[1]);
		 

		 
		 int tmp;
		 while(y!=0){
			 
			 tmp=x%y;
			 x=y;
			 y=tmp;
			 
		 }
		 
		 System.out.println(x);
		
	}
}

Measured memory_bytes: 17036
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#include <string>
using namespace std;

//宣言
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//数値
#define MOD 1000000007
#define INF (1<<20)
const double EPS = 1e-10;
const double PI = acos(-1.0);

//操作
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define REP(i,n) FOR(i,0,n)
#define REPB(i,n) for(int i=n;i>=0;--i)
#define SORT(A) sort(A,A+sizeof(A)/sizeof(A[0]))
#define VSORT(A) sort(A.begin(),A.end())
#define EXIST(s,e) (s.find(e)!=s.end())
#define PB push_back
#define MP make_pair
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);

//DEBUG
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main() {
	int n;
	cin >> n;
	int y;
	cin >> y;
	int a = 0, b = 0, c = 0;
	c += y % 5000 / 1000;
	a += y / 10000;
	b += (y - a * 10000) / 5000;
	if (a + b + c > n) {
		cout << "-1 -1 -1" << endl;
	}
	else if (a + b + c == n) {
		cout << a << " " << b << " " << c << endl;
	}
	else {
		int f = 1;
		while (1) {
			int e;
			e = a + b + c;
			if (f == 0 || e >= n) {
				if (e != n) f = 0;
				break;
			}
			if (n - e >= 9) {
				if (a) {
					a--;
					c += 10;
				}
				else if (b) {
					b--;
					c += 5;
				}
				else {
					f = 0;
				}
			}
			else if (n - e >= 4) {
				if (b) {
					b--;
					c += 5;
				}
				else if (a) {
					a--;
					b += 2;
				}
				else {
					f = 0;
				}
			}
			else {
				if (a) {
					a--;
					b += 2;
				}
				else {
					f = 0;
				}
			}
		}

		if (f) {
			cout << a << " " << b << " " << c << endl;
		}
		else {
			cout << "-1 -1 -1" << endl;
		}

	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll MOD = 998244353;

ll dp[3][3005][3005];

int main(){
  int N, S;
  cin >> N >> S;
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  dp[0][0][0] = 1;
  rep(i,N){
    int a = v[i];
    rep(j,S+1){
      //使わない
      dp[0][i+1][j] += dp[0][i][j];
      dp[0][i+1][j] %= MOD;
      //Lにするが使わない
      dp[1][i+1][j] += dp[0][i][j];
      dp[1][i+1][j] %= MOD;
      //Lにして使う
      if(j+a<=S){
        dp[1][i+1][j+a] += dp[0][i][j];
        dp[1][i+1][j+a] %= MOD;
      }
      //LかつRにして使わない
      dp[2][i+1][j] += dp[0][i][j];
      dp[2][i+1][j] %= MOD;
      //LかつRにして使う
      if(j+a<=S){
        dp[2][i+1][j+a] += dp[0][i][j];
        dp[2][i+1][j+a] %= MOD;
      }

      //使わない
      dp[1][i+1][j] += dp[1][i][j];
      dp[1][i+1][j] %= MOD;
      //使う
      if(j+a<=S){
        dp[1][i+1][j+a] += dp[1][i][j];
        dp[1][i+1][j+a] %= MOD;
      }
      //Rにするが使わない
      dp[2][i+1][j] += dp[1][i][j];
      dp[2][i+1][j] %= MOD;
      //Rにして使う
      if(j+a<=S){
        dp[2][i+1][j+a] += dp[1][i][j];
        dp[2][i+1][j+a] %= MOD;
      }

      //使わない
      dp[2][i+1][j] += dp[2][i][j];
      dp[2][i+1][j] %= MOD;
    }
  }

  cout << dp[2][N][S] << endl;
  
  return 0;
}



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

#define mod 998244353

// 区間の和を計算するBIT, 1-indexed
struct BIT{
    int size;
    vector<int>value;
    BIT(int N) : value(N+1, 0), size(N) {}

    int sum(int i) {
        int res = 0;
        while (i > 0) {
            res += value[i];
            i -= i & -i; // i = i & (i-1);
        }
        return res;
    }

    void add (int i, int x) {
        while (i <= size) {
            value[i] += x;
            i += i & -i;
        }
    }
};

int main() {
    int N;
    cin >> N;
    vector<int>x(N);
    vector<int>y(N);
    vector<pair<int, int>> elements(N);
    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i];
    }

    // y座標を 1-indexed で圧縮後, x座標でソート
    vector<int> copyY(y);
    sort(copyY.begin(), copyY.end());
    map<int, int> mp;
    for (int i = 0; i < N; ++i) {
        mp[copyY[i]] = i + 1;
    }
    for (int i = 0; i < N; ++i) {
        y[i] = mp[y[i]];
        elements[i] = make_pair(x[i], y[i]);
    }
    sort(elements.begin(), elements.end());

    // 2の累乗計算
    ll modPow[N+1];
    modPow[0] = 1;
    for (int i = 1; i < N+1; ++i) {
        modPow[i] = modPow[i-1] * 2 % mod;
    }

    ll ans = modPow[N] + mod - 1;
    ans %= mod;
    ans = ans * N % mod;

    BIT tree(N);
    sort(y.begin(), y.end());

    for (int i = 0; i < N; ++i) {
        // 左にi個, 右にN-i-1個の点
        int yi = elements[i].second;
        // vector y には自分自身も含まれていることに注意
        auto iter1 = lower_bound(y.begin(), y.end(), yi);
        int low = distance(y.begin(), iter1);
        // 下にlow個, 上にN-low-1個の点

        int lowOver = tree.sum(yi);
        tree.add(yi, 1);

        // 左下にlowOver個, 左上にi-lowOver個の点
        ans = ans + mod + mod + mod + mod;
        ans = ans - modPow[low] - modPow[N-low-1] - modPow[i] - modPow[N-i-1] + 4;
        ans = ans + modPow[lowOver] + modPow[i-lowOver] + modPow[low - lowOver] + modPow[N-low-1-i+lowOver] - 4;
        ans %= mod;
    }
    cout << ans;
    return 0;
}

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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

typedef struct node node;
typedef struct edge{
    node* target;
    struct edge* next;
}edge;
typedef struct node{
    int value;
    edge* fst;
    edge* lst;
}node;
void initNodeArray(node* p, int n){
    for(int i=0; i<n; i++){
        (p+i)->value = i;
        (p+i)->fst = NULL;
        (p+i)->lst = NULL;
    }
}
void addEdge(node* p, node* target){
    if(p->fst == NULL){
        p->fst = (edge*)malloc(sizeof(edge));
        p->lst = p->fst;
    }else{
        p->lst->next = (edge*)malloc(sizeof(edge));
        p->lst = p->lst->next;
    }
    p->lst->target = target;
    p->lst->next = NULL;
}

void solve(node* p, int value){
    p->value = value;
    edge* e = p->fst;
    while(e != NULL){
        if(e->target->value != value){
            solve(e->target, value);
        }
        e = e->next;
    }
}

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    node a[n+1];
    initNodeArray(a, n+1);
    rep(i, 0, m){
        int x, y, z;
        scanf("%d %d %d", &x, &y, &z);
        addEdge(&a[x], &a[y]);
        addEdge(&a[y], &a[x]);
    }
    rep(i, 1, n+1){
        if(a[i].value == i){
            solve(&a[i], i);
        }
    }
    int ans = 0;
    rep(i, 1, n+1){
        if(a[i].value == i){
            ans++;
        }
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std; 
mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll              long long 
#define pre(y,x)        fixed<<setprecision(y)<<x
#define dbg(x)          cerr << "[" << #x << ": " << (x) << "]\n";
#define ff              first
#define ss              second
#define pb              push_back
#define popb            pop_back
#define dbg1(x)         cerr << "|" << #x << ": " << (x) << "|\n";
#define dbg2(x,y)       cerr << "|" << #x << ": " << (x) << "|" << #y << ": " << (y) << "|\n";
#define dbg3(x,y,z)     cerr << "|" << #x << ": " << (x) << "|" << #y << ": " << (y) << "|" << #z << ": " << (z) << "|\n";
#define all(v)          v.begin(), v.end()
#define reset(a, b)     memset(a, b, sizeof(a))
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<ll> vl; 
typedef vector<vl> vvl;
ll power(ll a,ll b){if(b==0) return 1;ll res;while(b>0){if(b&1) res *= a;a *= a;b >>=1;}return res;}
int is(int n){if(n==1) return 0;for(int i=2;i*i<=n;i++){if(n%i==0) return false;}return true;}
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
const int inf = 1000000000;
const ll INF = 1000000000000000000;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll solve(int s){
	ll dp[s+1]={};
	dp[0] = 1;
	for(ll i=3; i<=s; ++i){
		for(ll j=3; j<=i; ++j){
//			dbg3(i, j, dp[i-j]);
			(dp[i] += dp[i-j]) %= mod;
		}
	}
	return dp[s];
}
int main(){
	int s;
	cin >> s;
	cout << solve(s) ;
	return 0;
}

Measured memory_bytes: 3560
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    int flag[3];
    fill(flag, flag + 3, 0);
    flag[a] = 1;
    flag[b] = 1;
    for (int i = 0; i < 3; i++) {
        if (flag[i] == 0) {
            OUT(i + 1);
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>

void marge(int *, int, int, int);
void mergeSort(int *, int, int);
int count=0;

int main(){
  int i, j, n, S[500000];

  scanf("%d", &n);
  if(n <= 500000){
    for(i = 0; i < n; i++){
      scanf("%d", &S[i]);
    }

    mergeSort(&S[0], 0, n);
    
    for(i = 0; i < n; i++){
      if(i != n-1)
	printf("%d ", S[i]);
      else
	printf("%d\n", S[i]);
    }
    printf("%d\n", count);
  }
  return 0;
}

void merge(int *A, int left, int mid, int right){
  int L[250001], R[250001], i, j, k, n1, n2;

  n1 = mid - left;
  n2 = right - mid;
  if(n1 == 0 || n2 == 0) return;
  //  L[0...n1], R[0...n2] を生成
  for (i = 0; i < n1; i++)
    L[i] = A[left + i];
  
  for(i = 0; i < n2; i++){
    R[i] = A[mid + i];
  }
  L[n1] = 1000000000;
  R[n2] = 1000000000;
  i = 0;
  j = 0;
  for (k = left; k < right; k++){
    if (L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
      count++;
    }else{
      A[k] = R[j];
      j = j + 1;
      count++;
    }
  }
}

void mergeSort(int *A, int left, int right){
  int mid;
  
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(&A[0], left, mid);
    mergeSort(&A[0], mid, right);
    merge(&A[0], left, mid, right);
  }
  return;
}



Measured memory_bytes: 5640
import java.util.Scanner;
//import java.util.Arrays ;

// import java.InputMismatchException;


class Main {

    public static int merge_count = 0 ;

    static void Merge(int [] A, int low, int mid, int high) {
        int l_size = mid-low ;
        int h_size = high-mid ;
        int []L = new int[l_size] ;
        int []H = new int[h_size] ;

        //System.out.printf("Merge: %d %d %d\n", low, mid, high) ;
        for (int i=0; i<l_size; i++) {
            L[i] = A[low+i] ;
        }
        for (int i=0; i<h_size; i++) {
            H[i] = A[mid+i] ;
        }

        int a_pos=low, l_pos=0, h_pos=0 ;

        while (l_size != 0 && h_size != 0) {
            if (L[l_pos] <= H[h_pos]) {
                A[a_pos] = L[l_pos] ;
                l_size -= 1 ;
                l_pos += 1 ;
            }
            else {
                A[a_pos] = H[h_pos] ;
                h_size -= 1 ;
                h_pos += 1 ;
            }
            a_pos += 1 ;
            merge_count++ ;
        }
        
        while (l_size != 0) {
            A[a_pos] = L[l_pos] ;
            l_size -= 1 ;
            l_pos += 1 ;
            a_pos += 1 ;
            merge_count++ ;
        }
        
        while (h_size != 0) {
            A[a_pos] = H[h_pos] ;
            h_size -= 1 ;
            h_pos += 1 ;
            a_pos += 1 ;
            merge_count++ ;
        }

    }

    static void Merge_sort(int [] A, int low, int high) {
        //System.out.printf("Merge_sort: %d %d\n", low, high) ;
        if (low + 1 < high) {
            int mid = (low + high) / 2 ;
            Merge_sort(A, low, mid) ;
            Merge_sort(A, mid, high) ;
            Merge(A, low, mid, high) ;
        }
    }

    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in) ;
        String s = scanner.nextLine() ;

        int elem_count ;
        elem_count = Integer.parseInt(s) ;
        int A[] = new int[elem_count] ;

        for (int i=0; i<elem_count; i++) {
            A[i] = scanner.nextInt() ;
        }

        scanner.close() ;
        Merge_sort(A, 0, elem_count) ;

        for (int i=0; i<elem_count; i++) {
            String end_mark = " " ;
            if (i==elem_count-1) end_mark = "\n" ;
            System.out.print(A[i] + end_mark) ;
        }
        System.out.println(merge_count) ;
    }
}



Measured memory_bytes: 169768
#include<bits/stdc++.h>
using namespace std;
int a[110];
#define int long long int
main(){
    int i,n,k,ans=1000;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>a[i];
    }
	for(i=1;i<=n;i++){
		if(a[i+1]>a[i]){
			k=(ans)/a[i];
          ans=ans%a[i]+(k*a[i+1]);
      	}
   	}
	cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define maxN 1000001
#define mod 1000000007
#define maxLL 1000000000000000000
typedef long long ll;

bool compared(int a,int b){
	return a < b;
}

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

int GCD(int a,int b){
	return b?GCD(b,a%b):a;
}

int main(){
	int k;
	cin>>k;
	string s;
	cin>>s;
	if(k >= s.size()){
		cout<<s<<endl;
	}
	else{
		for(int i=0;i<k;i++){
			cout<<s[i];
		}
		puts("...");
	}
	return 0;
}


Measured memory_bytes: 3588
n = int(input())
x_list = [ tuple(int(i) for i in input().split()) for _ in range(n) ]

d = 0
for i in range(n-1):
  for j in range(i+1, n):
    d += ((x_list[i][0] - x_list[j][0]) ** 2 + (x_list[i][1] - x_list[j][1]) ** 2) ** 0.5
    
print(d*2/n)

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

using namespace std;

constexpr int INF = numeric_limits<int>::max() / 2;
using P = pair<int, int>;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

class TopologicalSort
{
    using Graph = std::vector<std::vector<int>>;
    // 頂点数
    int V;
    std::vector<std::vector<int>> G;
    void dfs(int v, std::vector<int> &res, std::vector<int> &used)
    {
        used[v] = 1;
        for (auto to : G[v])
            if (used[to] == 0)
            {
                dfs(to, res, used);
            }
        res.push_back(v);
    }

  public:
    TopologicalSort(int _v) : V(_v), G(_v) {}
    void addEdge(int a, int b)
    {
        assert(0 <= a && a < V);
        assert(0 <= b && b < V);
        G[a].push_back(b);
    }
    std::vector<int> topologicalSort()
    {
        std::vector<int> ide(V);
        for (int i = 0; i < V; i++)
        {
            for (auto to : G[i])
            {
                ide[to]++;
            }
        }
        std::vector<int> res;
        std::vector<int> used(V);
        for (int i = V - 1; i >= 0; i--)
        {
            if (ide[i] == 0)
            {
                dfs(i, res, used);
            }
        }
        if (res.size() == 0)
            res = {-1};
        reverse(res.begin(), res.end());
        return res;
    }
};

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

    int M, N;
    cin >> M >> N;
    // ma[i][j] = k := i 番目の command を覚えるには skill j が k 以下
    // mi[i][j] = k :=                                        k 以上
    vector<vector<int>> ma(M, vector<int>(N, INF)), mi(M, vector<int>(N, -1));
    for (int i = 0; i < M; i++)
    {
        int K;
        cin >> K;
        while (K--)
        {
            int a, b;
            string cond;
            cin >> a >> cond >> b;
            a--;
            if (cond == ">=")
                mi[i][a] = max(mi[i][a], b);
            else
                ma[i][a] = min(ma[i][a], b);
        }
    }
    TopologicalSort ts(M);
    vector<P> es;
    for (int i = 0; i < M; i++)
    {
        for (int j = i; j < M; j++)
        {
            for (int k = 0; k < N; k++)
            {
                if (ma[i][k] < mi[j][k])
                {
                    es.push_back(P(i, j));
                    ts.addEdge(i, j);
                }
                if (mi[i][k] > ma[j][k])
                {
                    es.push_back(P(j, i));
                    ts.addEdge(j, i);
                }
            }
        }
    }
    auto v = ts.topologicalSort();
    if ((int)v.size() != M)
    {
        cout << "No" << endl;
        return 0;
    }
    vector<int> pos(M);
    for (int i = 0; i < M; i++)
    {
        pos[v[i]] = i;
    }
    for (auto p : es)
    {
        int st = p.first, gt = p.second;
        if (pos[st] >= pos[gt])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}



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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	long n, ans = 999999999;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a+n);
	for (int i = a[0]; i <= a[n - 1]; i++) {
		long p = 0;
		for (int j = 0; j < n; j++) {
			p += (i - a[j]) * (i - a[j]);
		}
		ans = min(ans, p);
	}
	cout << ans;
}

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

int main(){
  int A,B,C,D;
  cin >>A >>B >>C >>D;
  if(B<=C){
    cout<<0<<endl;
    return 0;
  }
  if(D<=A){
    cout<<0<<endl;
    return 0;
  }
  
  if((A<=C)&&(B<=D)){
    cout<<B-C<<endl;
  return 0; 
  }
  if((A<=C)&&(D<=B)){
    cout<<D-C<<endl;
  return 0; 
  }
  if((C<=A)&&(B<=D)){
    cout<<B-A<<endl;
  return 0; 
  }  
  
  cout<<D-A<<endl;
  return 0;
}


  

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

using ll = long long;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}

int main() {
  string S; cin >> S;
  string ans = "No";
  REP(i, S.size() - 1) {
    if(S[i] == 'A' && S[i + 1] == 'C') ans = "Yes";
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep0(i, b, s) for(int i=b;i<s;i++)
typedef long long ll;

int main(){
    ll N, M; cin >> N >> M;
    ll ans=0;

    map<ll, ll, greater<ll> > memo;

    rep(i,N){
        ll a;
        cin >> a;
        memo[a]++;
    } 
    rep(i,M){
        ll a, b; cin >> a >> b;
        memo[b] += a;
    }

    auto it = memo.begin();

    while(true){
        ans += it->first*min(N, it->second);
        N -= min(N, it->second);
        if (N==0) break;
        it++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 12800
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul             1000000007
#define rep(i,a,b)      for(int i=a;i<b;i++)
#define rfor(i,a,b)     for(int i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define lul2            998244353 
#define pll             pair<ll,ll>
#define endl            '\n'
#define SIZE            1000005
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void mod(ll &x)
{
    if(x>=lul) x-=lul;
    if(x<0) x+=lul;
}

void solve()
{
    ll n; cin>>n;
    vector<ll> v(n), bits(64,0);
    rep(i,0,n) cin>>v[i];
    rep(i,0,n)
    {
        rep(j,0,64)
        {
            if(v[i]&(1LL<<j)) bits[j]++;
        }
    }
    ll ans = 0;
    rep(i,0,64)
    {
        ll x = (n-bits[i])*bits[i]%lul;
        ll y = (1LL<<i)%lul;
        x=(x*y)%lul;
        mod(x);
        ans+=x;
        mod(ans);
    }
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; /*cin>>t;*/ t=1;
    rep(i,1,t+1){
        solve();
    }
    return 0;
}

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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define sort(v) sort(all(v))



/* constant */
const int inf = 100100100100100100;
const int mod = 1000000007;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


/* math_library */
int ceil(int a, int b){if(a % b == 0){return a/b;}else{return a/b + 1;}}


/* main */


signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    
    int n = input();
    vector<int> a; rep(i,0,n) a.push_back(input());
    vector<int> b; rep(i,0,n) b.push_back(input());

    int ans = 0;
    rep(i,0,29){
        int bound = (1 << i);
        vector<int> amod; rep(j,0,n) amod.push_back(a[j] % (1<< (i + 1)));
        vector<int> bmod; rep(j,0,n) bmod.push_back(b[j] % (1<< (i+ 1)));

        sort(amod);
        sort(bmod);

        int cnt = 0;

        rep(j,0,n){
            cnt += distance(lower_bound(all(bmod), bound - amod[j]), lower_bound(all(bmod), 2 * bound - amod[j]));
            cnt += distance(lower_bound(all(bmod), 3 * bound - amod[j]), lower_bound(all(bmod), 4 * bound - amod[j]));
        }
        if(cnt % 2 == 1){
            ans += (1 << (i));
        }



    }
    print(ans);

    
    






}   

Measured memory_bytes: 11760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N + 1);
    for(int i = 0;i < N + 1;i++) {
        cin >> A.at(i);
    }
    vector<ll> B(N);
    for(int i = 0;i < N;i++) {
        cin >> B.at(i);
    }
    ll ret = 0;
    for(int i = 0;i < N;i++) {
        if(A.at(i) >= B.at(i)) {
            ret += B.at(i);
            A.at(i) -= B.at(i);
        }
        else {
            ret += A.at(i);
            B.at(i) -= A.at(i);
            ret += min(A.at(i + 1),B.at(i));
            A.at(i + 1) = max(0ll,A.at(i + 1) - B.at(i));
        }
    }
    cout << ret << endl;
}

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

const int INF = 1 << 29;

auto solve() {
    int N;
    cin >> N;
    vi p(N);
    for (auto &&e: p) cin >> e;
    sort(all(p));

    p[N - 1] /= 2;
    return accumulate(all(p), 0);
}


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

    cout << solve() << endl;
//    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <limits>
#include <numeric>
#include <cmath>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

static const int MAX = 100001;

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    
    ll all = b-a+1;
    ll c_all = b/c - (a-1)/c;
    ll d_all = b/d - (a-1)/d;
    ll x = max(c, d);
    ll y = min(c, d);
    while(y != 0){
        ll tmp_x = x;
        x = y;
        y = tmp_x%y;
    }
    ll cd = c*d/x;
    ll cd_all = b/cd - (a-1)/cd;
    all -= c_all + d_all - cd_all;
    
    cout << all << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, m, q, col[100005][15];
int a[100005], b[100005], c[100005];
vector<int> adj[100005];

void bfs (int I, int D, int V) {
	col[I][D] = V;
	if(D == 0) return;
	queue<pair<int,int> > Q;
	Q.push({I, D});
	while(!Q.empty()) {
		int A = Q.front().first, B = Q.front().second;
		Q.pop();
		for(auto &X : adj[A]) {
			if(col[X][B-1]) continue;
			col[X][B-1] = V;
			if(B-1 > 0) Q.push({X, B-1});
		}
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) {
		int A, B;
		scanf("%d%d",&A,&B);
		adj[A].push_back(B);
		adj[B].push_back(A);
	}
	scanf("%d",&q);
	for(int i=1;i<=q;i++) {
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	}
	for(int i=q;i>=1;i--) {
		if(!col[a[i]][b[i]]) bfs(a[i], b[i], i);
	}
	for(int i=1;i<=n;i++) {
		int A = 0;
		for(int j=0;j<=10;j++) {
			A = max(A, col[i][j]);
		}
		printf("%d\n",c[A]);
	}
}


Measured memory_bytes: 13992
import time
import itertools

def main():
    N,M,R = tuple([int(x) for x in input().split()])

    r = [int(x)-1 for x in input().split()]
    
    w_e = [tuple([int(x)for x in input().split()]) for _ in [0]*M]
    w_e = [(a-1,b-1,w) for (a,b,w) in w_e]


    g = Graph(list(range(N)),w_e)

    minimums = {}
    for r_i in r:
        minimums[r_i] = g.dijkstra(r_i)[0]

    bf = itertools.permutations(r)

    candidates = []
    for bf_i in bf:
        distance = 0
        for i in range(R-1):
            distance += minimums[bf_i[i]][bf_i[i+1]]
        candidates.append(distance)

    print(min(candidates))

def speedtest(func,*args):
    b = time.perf_counter()
    res = func(*args)
    e = time.perf_counter()
    elapsed = e-b
    print("{} (sec)".format(elapsed))

    return res

class Graph:
    def __init__(self,w_v,w_e):
        super().__init__()
        self.size = len(w_v)
        self.w_v = [v_i for v_i in w_v]#value of vartex
        self.w_e = [{} for _ in [0]*self.size]

        self.neighbor = [[] for _ in [0]*self.size]
        for a_i,b_i,w_i in w_e:
            self.w_e[a_i][b_i] = w_i#weight of edge
            self.w_e[b_i][a_i] = w_i#weight of edge

            self.neighbor[a_i].append(b_i)
            self.neighbor[b_i].append(a_i)

    def dijkstra(self,v_n):
        d = [-1]*self.size
        temp_d = [(10**9,i)for i in range(self.size)]
        temp_d[v_n] = (0,v_n)
        prev = [-1]*self.size

        q = set(range(self.size))
        
        while len(q)>0:
            u = min([temp_d[q_i] for q_i in q])[1]
            d[u] = temp_d[u][0]
            q.discard(u)
            for v in self.neighbor[u]:
                temp = temp_d[u][0]+self.w_e[u][v]
                if temp_d[v][0]>temp:
                    temp_d[v] = temp,v
                    prev[v] = u

        return d,prev

if __name__ == "__main__":
    main()

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

template<class Iterator>
int LIS(Iterator l, Iterator r){
	auto x = *l;
	pair<int, decltype(x)> p1x(1, x);
	vector<pair<int, decltype(x)>> dp(r - l, p1x);
	const auto comp = [&](pair<int, decltype(x)> a, pair<int, decltype(x)> b){
		return a.first != b.first ? a.first < b.first : a.second < b.second;
	};
	for(Iterator i = l; i < r; i++){
		pair<int, decltype(x)> val(0, *i);
		*upper_bound(dp.begin(), dp.end(), val, comp) = val;
	}
	return lower_bound(dp.begin(), dp.end(), p1x, comp) - dp.begin();
}

int main(){
	int N, i;
	scanf("%d", &N);
	vector<int> A(N);
	for(i = 0; i < N; i++){
		scanf("%d", &A[i]);
		A[i] = -A[i];
	}
	printf("%d\n", LIS(A.begin(), A.end()));
	return 0;
	vector<pair<int, int>> B(N);
	for(i = 0; i < N; i++){
		B[i].first = -A[i];
		B[i].second = i;
	}
	printf("%d\n", LIS(B.begin(), B.end()));
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    while(1){
        int n; cin>>n;
        if(n==0)break;
        int a[n];
        rep(i,n)cin>>a[i];
        int dp[n][n];
        rep(i,n)rep(j,n)dp[i][j]=-1;
        rep(i,n)dp[i][i]=0;
        rep(i,n-1){
            if(abs(a[i]-a[i+1])<=1)dp[i][i+1]=2;
            else dp[i][i+1]=0;
        }
        for(int i=2; i<n; i++){
            for(int j=0; j+i<n; j++){
                if(dp[j+1][j+i-1]==i-1){
                    if(abs(a[j]-a[j+i])<=1)dp[j][j+i]=i+1;
                    else dp[j][j+i]=i-1;                    
                }
                for(int k=0; k<i; k++){
                    dp[j][j+i]=max(dp[j][j+i], dp[j][j+k]+dp[j+k+1][j+i]);
                }
            }
        }
        cout<<dp[0][n-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3436
if __name__ == "__main__":
    N = int(input())
    c = list(input())
    j = N-1
    count = 0
    for i in range(N):
        if c[i] =='W':
            while i<j:
                if c[j]  == 'R':
                    c[i] = 'R'
                    c[j] = 'W'
                    count += 1
                    break
                j -= 1
        if j < i:
            break

    if c.count('W')<count:
        print(c.count('W'))
    elif c.count('R')<count:
        print(c.count('R'))
    else:
        print(count)

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

int main(){
  int a,b,k;
  cin>>a>>b>>k;
  int x=100;
  for(int i=x;i>0;i--){
    if(a%i==0&&b%i==0){
      k-=1;
    }
    if(k==0){
      int ans=i;
      cout<<ans<<endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
  ll h,w,move;
  cin>>h>>w;
  if(h==1||w==1) move=1;
  else move=(h*w+1)/2;
  cout<<move<<endl;
}

Measured memory_bytes: 3596
def main():
    n = int(input())
    ss = {}
    tt = {}
    for i in range(n):
        key = input()
        if not key in ss:
            ss[key] = 1
        else:
            ss[key] += 1
    m = int(input())
    for i in range(m):
        key = input()
        if not key in tt:
            tt[key] = 1
        else:
            tt[key] += 1
    ans = 0
    for k, v in ss.items():
        if k in tt:
            ans = max(ans, v - tt[k])
        else:
            ans = max(ans, v)
    print(ans)
main()


Measured memory_bytes: 3064
use std::io::*;

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();

    let k: u64 = itr.next().unwrap().parse().unwrap();

    let mut ans = 0;
    for a in 1..=k {
        for b in 1..=k {
            for c in 1..=k {
                ans += gcd(a, gcd(b, c));
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2172
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){
	int n;
	cin >> n;
	long long tmp=1;
	for(int i=n;i>0;i--){
		tmp*=i;
		tmp%=1000000007;
	}
	cout << tmp << endl;
}
	

Measured memory_bytes: 256
import java.util.Scanner;

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

    Main logic = new Main();
    String output = logic.exec(myArgs);
    System.out.print(output);
  }
  private String exec(String[] myArgs) {
    final char[] compareTo = myArgs[0].toCharArray();
    char[] compareBy = myArgs[1].toCharArray();
    if (compareBy.length != compareTo.length) {
      return "No";
    }
    for (int i = 0;i < compareBy.length;i++) {
      boolean same = true;
      for (int j = 0;j < compareTo.length;j++) {
        int index = i + j;
        if (index >= compareTo.length) {
          index -= compareTo.length;
        }
        if (compareBy[index] != compareTo[j]) {
          same = false;
        }
      }
      if (same) {
        return "Yes";
      }
    }

    return "No";
  }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <vector>
#include <algorithm>
#define absf std::abs
#define maxf std::max
#define minf std::min
typedef long long ll;
typedef long double ld;

int A, B, X;

int main() {
    scanf("%d%d%d", &X, &A, &B);
    X -= A; 

    X -= (X / B) * B;
    printf("%d\n", X);
    return 0;
}



Measured memory_bytes: 128
// AOJ 1161: Verbal Arithmetic
// 2018.1.9 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int m, sz;
char str[13][11]; int len[13], max;
char tr['Z'+1], assign['Z'+1];
char idx[10], not0[10], used[10];
int ans;

void calc()
{
	int i, a, s;
	char *p;

	// 下一桁の合計で枝刈りしてみる
	s = 0; for (i = 0; i < m; i++) s += assign[str[i][len[i]]];
	a = assign[str[m][len[m]]];
	if (s % 10 != a) return;

	s = 0;
	for (i = 0; i < m; i++) {
		a = 0, p = str[i];
		while (*p >= 0) a = (a<<3) + (a<<1) + assign[*p++];
		s += a;
	}

	a = 0, p = str[m];
	while (*p >= 0) a = (a<<3) + (a<<1) + assign[*p++];
	if (a == s) ans++;
}

void rec(int k)
{
	int i;

	if (k == sz) { calc(); return; }
	if (!used[0]) {
		if (!not0[k]) used[0] = 1, assign[idx[k]] = 0, rec(k+1), used[0] = 0;
	}
	for (i = 1; i < 10; i++) {
		if (used[i]) continue;
		used[i] = 1, assign[idx[k]] = i, rec(k+1), used[i] = 0;
	}
}

int main()
{
	int n, i;
	char buf[10], *p;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		sz = 0, memset(tr, -1, sizeof(tr));
		memset(not0, 0, sizeof(not0));
		n = atoi(buf), m = n - 1, max = 0;
		for (i = 0; i < n; i++) {
			fgets(str[i], 15, stdin);
			for (p = str[i]; *p > ' '; p++) {
				if (tr[*p] < 0) tr[*p] = sz, idx[sz++] = *p;
			}
			*p = -1; len[i] = p-str[i]-1;
			if (len[i] > 0) not0[tr[*str[i]]] = 1;
			if (i < m && len[i] > max) max = len[i];
		}
		ans = 0;
		if (len[m] >= max && ((m <= 10 && len[m] <= max+1) || (m > 10 && len[m] <= max+2))) {
			memset(used, 0, sizeof(used));
			rec(0);
		}
		printf("%d\n", ans);
	}
	return 0;
}


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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);
    ll N; cin >> N;
    vector<vector<ll>> F(N, vector<ll>(10));
    cin >> F;

    // rep(i, N) {
    //     cout_h(F[i]);
    // }

    vector<vector<ll>> P(N, vector<ll>(11));
    cin >> P;
    // rep(i, N) cout_h(P[i]);

    ll ans = LLONG_MIN; //cout << LLONG_MIN << endl;
    for (int i = 1; i <= ((1<<10)-1); i++) {
        vector<ll> c(N, 0);
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < 10; k++) {
                if (F[j][k] && (i & (1 << k))) {
                    c[j]++;
                }
            }
        }
        ll profit = 0;
        for (int j = 0; j < N; j++) {
            profit += P[j][c[j]];
        }
        chmax(ans, profit);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
function Main(s) {
  var s = s.split("\n")[0].split("");
  var op = ["+","-"];
  for (var bit = 0; bit < (1<<3); bit++) {
    var ops = [];
    for (var i = 0; i < 3; i++) {
      if (bit & (1<<i)) {
        ops.push(op[0]);
      } else {
        ops.push(op[1]);
      }
    }
    var ans = s[0] + ops[0] + s[1] + ops[1] + s[2] + ops[2] + s[3];
    if (eval(ans) === 7) {
      console.log(ans + "=7");
      return;
    }
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

public class Main {

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));		
		String test = br.readLine();
		
		String[] res1 = test.split(" ");
		int[] x1 = new int [res1.length];
		
		for(int i = 0; i < res1.length; i++){
			x1[i] = Integer.parseInt(res1[i]);
		}
		
		if(x1[0] < x1[1] && x1[1] < x1[2]){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
	}
}

Measured memory_bytes: 16912
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int n;
  while(cin>>n, n){
    long long sum = 1;
    int m = n;
    bool f = false;
    for(int i=2; i*i <= m; i++){
      int tmp = 1;
      int j = 1;
      while(n % i == 0){
        j *= i;
        tmp += j;
        n /= i;
      }
      //if(tmp != 1) printf("i=%d: tmp=%d\n",i,tmp);
      sum *= tmp;
      if(sum - m > m){
        f = true;
        break;
      }
    }
    if(f){
      puts("abundant number");
      continue;
    }
    if(n!=1) sum *= (n+1);
    sum -= m;
    //printf("n: %d, sum:%lld\n",m,sum);
    if(sum == m) puts("perfect number");
    else if(sum < m) puts("deficient number");
    else puts("abundant number");
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 1e5 + 10 ;
int n , a[maxn] , cnt[maxn] , ans[maxn] ;
int main()
{
	cin >> n ;
	for ( int i = 0 ; i< n ; i++)
	{
		cin >> a[i] ;
		if (i % 2 == 0 ) 
			ans[a[i]] ++ ;
		else
			cnt[a[i]] ++ ;
	}
	int mx1 = 0  , mx2 = 0 , mx3 = 0 , mx4 = 0   , x , y ;
	for ( int i = 1 ; i<= 1e5 ; i++)
	{
		if ( ans[i] > mx1 ) 
			mx2 = mx1 , mx1 = ans[i] , x = i;
		else if ( ans[i] > mx2 ) 
			mx2 = ans[i] ;
		if ( cnt[i] > mx4 ) 
			mx3 = mx4 , mx4 = cnt[i] , y = i ;
		else if ( cnt[i] > mx3 ) 
			mx3 = cnt[i] ;
	}
	
	//cout << mx1 << " " << mx2 << " " << mx3 << " " << mx4 << endl;
	//cout <<" * " << x <<  " " << y << endl;
	if ( x== y ) 
		cout << min ( n - mx1 - mx3 , n- mx4 - mx2 ); 
	else
		cout << n/2 - mx1 + n/2 -mx4 << endl;
 }

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

int main(void){
    // Your code here!
    int n;
    cin >>n;
    vector<string> s(n);
    vector<int> t(n);
    for (int i = 0 ; i < n; i++) {
        cin >> s.at(i) >> t.at(i);
    }
    string x;
    cin >> x;
    int x_ind;
    for (int i = 0 ; i < n; i++) {
        if (s.at(i) == x){
            x_ind = i;
            break;
        }
    }
    int sum=0;
    for (int i = x_ind+1;i <n;i++) {
        sum+=t.at(i);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
//#include<vector>

int main(){
	long long int x,count=0,a;
	std::cin>>x;

	a = 100;

	while (1) {
		a = a + a / 100;
		count++;
		if (a >= x) {
			std::cout << count << std::endl;
			exit(0);
		}
	}

	
	return 0;
}

Measured memory_bytes: 3596
import math

def isprime(x):
    if (x == 2 or x == 3):
        return True
    
    if (x <= 1 or x%2 == 0):
        return False
    i = 3
    while (3 <= i and i**2 <= x ):
        if (x%i == 0):
            return False
        i = i + 2
    return True


n = int(input())
ans = 0
for i in range(n):
    num = int(input())
    if isprime(num):
        ans = ans + 1
print(ans)







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

public class Main {

    static long mod = (long) (1e9 + 7);

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        Vertex[] vs = new Vertex[n + 1];
        for (int i = 1; i <= n; i++) {
            vs[i] = new Vertex(i);
        }
        for (int i = 0; i < n - 1; i++) {
            int x = in.nextInt();
            int y = in.nextInt();
            vs[x].adj.add(vs[y]);
            vs[y].adj.add(vs[x]);
        }
        Set<Vertex> visited = new HashSet<>();
        dfs(vs[1], visited);
        out.println((vs[1].black + vs[1].white) % mod);
        out.close();
    }

    private static void dfs(Vertex v, Set<Vertex> visited) {
        visited.add(v);
        for (Vertex n : v.adj) {
            if (!visited.contains(n)) {
                dfs(n, visited);
                v.black = (v.black * n.white) % mod;
                v.white = (v.white * (n.white + n.black) % mod) % mod;
            }
        }
    }

    static class Vertex {
        int i;
        long black = 1;
        long white = 1;

        public Vertex(int i) {
            this.i = i;
        }

        List<Vertex> adj = new ArrayList<>();

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Vertex vertex = (Vertex) o;
            return i == vertex.i;
        }

        @Override
        public int hashCode() {
            return Objects.hash(i);
        }
    }


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}

Measured memory_bytes: 73192
#include <iostream>

using namespace std;

int main(){
	unsigned int N;
	cin >> N;
	unsigned int A[N], sum = 0;
	for (int i = 0; i < N; i++){
		cin >> A[i];
		sum += A[i];
	}

	unsigned int X[N] = {0};
	X[0] = sum;
	for (int i = 1; i < N - 1; i += 2){
		X[0] -= 2 * A[i];
	}

	for (int i = 1; i < N; i++){
		X[i] = 2 * A[i - 1] - X[i - 1];
	}

	for (int i = 0; i < N- 1; i++){
		cout << X[i] << " ";
	}
	cout << X[N - 1] << endl;

	return 0;
}


Measured memory_bytes: 2048