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

using namespace std;

#define endl '\n'

int n,m,x;
vector <int> c;
vector <vector<int> > p;
int ans;

void solve(int i, int total, int level[]){
  if(i == n){
    int cnt = 0;

    for(int j=0;j<m;j++){
      if(level[j] >= x)
        cnt++; 
    }

    if(cnt == m)
      ans = min(ans,total);
    return;
  }

  solve(i+1,total,level);

  for(int j=0;j<m;j++)
    level[j]+=p[i][j];

  solve(i+1,total+c[i],level);

  for(int j=0;j<m;j++)
    level[j]-=p[i][j];
}

int main(){

  ios_base :: sync_with_stdio(false);
  cin.tie(NULL);
  
  cin >> n >> m >> x;
  c.resize(n);
  p.assign(n,vector<int>(m));

  for(int i=0;i<n;i++){
    cin >> c[i];
    for(int j=0;j<m;j++)
      cin >> p[i][j];
  }

  int level[m] = {0};
  ans = 1e9 + 7;
  solve(0,0,level);

  if(ans == 1e9 + 7)
    cout << -1 << endl;
  else
  cout << ans << endl;

  

  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    //方針
    //毎日満足度は低下し続ける
    //満足度上昇の方法はコンテスト開催のみ
    //開催されてないコンテストを放置すると低下が著しくなる
    //実際にコンテストを開いた時の満足度上昇が最大のものを採用してみる
    //低下をなくせる分を上昇と捉えると、c_i(d-last(d,i)) + s_{d,i} だけペイすると考えられる？→あんまり適当じゃない
    //r日ずつ全探索を[D/r+1]回繰り返す
    //探索パターン数は26^rで、シミュレーションには26r回かかる、これを[D/r+1]回繰り返すので
    //計算量はO(D26^{r+1})
    //r = 3が限界
    int D;cin>>D;
    int c[26],last[26]={},s[365][26],lastcpy[26];
    REP(i,26) cin>>c[i];
    REP(i,D) REP(j,26) cin>>s[i][j];
    constexpr int r = 4;//何日に分けて全探索を行うか
    constexpr int num = 17;//1日毎にいくつ全探索するか:cを降順ソートして前半num個だけを選び続ける貪欲
    int all = 1;
    REP(i,r) all *= num;
    int up,ptncpy;
    int res[r],calcres[r],reslast[26];
    int ord[26];
    iota(ord,ord+26,0);
    stable_sort(ord,ord+26,[&](int x,int y){return c[x]>c[y];});
    for(int i=0;i<D;i+=r){
        int tmp = -1e9;
        for(int pattern = 0; pattern < all; pattern++){    //r日でそれぞれ何処を選ぶか全探索
            up = 0; ptncpy = pattern;
            memcpy(lastcpy,last,sizeof(int)*26);                //lastを更新しなければならないのでコピーを取る
            REP(j,r){                                           //r日探索
                if(i+j>=D) break;
                calcres[j] = ptncpy%num;
                REP(k,26){                                      //スコアに影響のある26パターンについて処理しなければならない
                    if(ord[calcres[j]] == k){                        //選ぶパターンのときはlastを更新してスコアを加算
                        last[k] = i+j;
                        up += s[i+j][k];
                    }
                    else up -= c[k]*(i+j - last[k]);            //そうでないときはlastを参照して減算
                }
                ptncpy /= num;                                   //これをi+r-1日目まで繰り返して終了
            }
            
            if(tmp<up){                                         //もしスコアが高くなるならば結果を更新する
                tmp = up;
                memcpy(res, calcres, sizeof(int)*r);            //
                memcpy(reslast, last, sizeof(int)*26);
            }
            memcpy(last, lastcpy, sizeof(int)*26);
        }
        memcpy(last, reslast, sizeof(int)*26);
        REP(j,r) if(i+j<D){
            cout<<ord[res[j]]+1<<endl;
        }
    }
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
  public static void main(final String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] S = new int[n];
    for (int i = 0; i < n; i++) {
      S[i] = sc.nextInt();
    }
    int q = sc.nextInt();
    int[] T = new int[q];
    for (int i = 0; i < q; i++) {
      T[i] = sc.nextInt();
    }
    int count = 0;
    for (int i = 0; i < T.length; i++) {
      if (binarySearch(S, T[i]))
        count++;
    }
    System.out.println(count);
  }

  private static boolean binarySearch(int[] S, int key) {
    int left = 0;
    int right = S.length - 1;
    int mid;
    while (left <= right) {
      mid = (right + left) / 2;
      if (S[mid] == key) {
        return true;
      } else if (S[mid] < key) {
        left = mid + 1;
      } else if (S[mid] > key) {
        right = mid - 1;
      }
    }
    return false;
  }
}


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

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

        if ( a < 10 ) cout << a << endl;
        else if ( a < 100 ) cout << 9 << endl;
        else if ( a < 1000 ) cout << 9 + a - 99 << endl;
        else if ( a < 10000 ) cout <<  9 + 900 << endl;
        else if ( a < 100000 ) cout << 9 + 900 + a - 9999 << endl;
        else cout << 9 + 900 + 89999 + 1 << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){int i,k,q,n,ans=0,b,c;
map<int,int>mp;
cin>>n;
for(i=0;i<n;i++){
    cin>>k;
    ans+=k;
    mp[k]++;
}
cin>>q;
while(q--){
    cin>>b>>c;
    k=mp[b];
    ans+=k*(c-b);
    mp[b]=0;
    mp[c]+=k;
    cout<<ans<<"\n";
}
    return 0;
}

Measured memory_bytes: 9436
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void doIt() {
		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		if(n < 3) {
			System.out.println(a[0] < a[1] ? a[1] : a[0]);
			return;
		}
		int gcd, idx, min;
		int gcd1 = gcd(a[0], a[1]);
		int gcd2 = gcd(a[1], a[2]);
		int gcd3 = gcd(a[2], a[0]);
		if(gcd1 >= gcd2 && gcd1 >= gcd3) {
			gcd = gcd1;
			idx = 2;
		}
		else if(gcd2 >= gcd3) {
			gcd = gcd2;
			idx = 0;
		}
		else {
			gcd = gcd3;
			idx = 1;
		}
		min = gcd(gcd1, a[2]);
		for(int i = 3; i < n; i++) {
			int next = gcd(gcd, a[i]);
			if(next < min) {
				gcd = min;
				idx = i;
				min = gcd(gcd, a[i]);
			}
			else {
				gcd = next;
				min = gcd(min, a[i]);
			}
			
		}
		System.out.println(gcd);

		
		
	}
	
	
	
	int gcd(int a, int b) {
		int w;
		while(b != 0) {
			w = a % b;
			a = b;
			b = w;
		}
		return a;
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 49372
<?php
list($A,$B)=sscanf(trim(fgets(STDIN)),"%d %d");
$t = 0;
if($A > $B){
    $t += $A;
    $A--;
}else{
    $t += $B;
    $B--;
}
if($A > $B){
    $t += $A;
    $A--;
}else{
    $t += $B;
    $B--;
}
print($t);

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  int a[51];
  int i;
  for(i=1;i<=n;i++) scanf("%d",a+i);
  int min=a[1];
  int max=a[1];
  for(i=2;i<=n;i++){
    min=MIN(min,a[i]);
    max=MAX(max,a[i]);
  }
  if(min>=0){
    printf("%d\n",n-1);
    for(i=1;i+1<=n;i++){
      printf("%d %d\n",i,i+1);
    }
    return;
  } else if(max<=0){
    printf("%d\n",n-1);
    for(i=n;i-1>=1;i--){
      printf("%d %d\n",i,i-1);
    }
    return;
  }
  if(ABS(max)>=ABS(min)){
    printf("%d\n",n-1+n-1);
    for(i=1;a[i]!=max;i++);
    int j;
    for(j=1;j<=n;j++){
      if(j==i) continue;
      printf("%d %d\n",i,j);
    }
    for(i=1;i+1<=n;i++){
      printf("%d %d\n",i,i+1);
    }
  } else {
    printf("%d\n",n-1+n-1);
    for(i=1;a[i]!=min;i++);
    int j;
    for(j=1;j<=n;j++){
      if(j==i) continue;
      printf("%d %d\n",i,j);
    }
    for(i=n;i-1>=1;i--){
      printf("%d %d\n",i,i-1);
    }
  }
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
def main():
    N, K = map(int, input().split())
    P = [int(x) - 1 for x in input().split()]
    C = [int(x) for x in input().split()]

    ans = -10 ** 9
    for start in range(N):
        # ループを探索
        now = start
        cycle = []
        total = 0
        for _ in [0] * N:  # while Trueでもおｋ
            now = P[now]
            cycle.append(C[now])
            total += C[now]
            if now == start:
                break
        # 最大スコアを探索
        length = len(cycle)
        score = 0
        for move in range(length):
            score += cycle[move]
            # 移動回数 >= Kなら，ループ途中でも探索終了
            if move >= K:
                break
            # ループを周回するので，それを利用して探索を省略
            res = score
            if total > 0:
                laps = (K - (move + 1)) // length
                res += total * laps
            ans = max(ans, res)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 89664
n = input()
digit = len(n) - 1
if n.count('9') == len(n):
    print(9*len(n))
else:
    if digit > 0:
        if n[1:].count('9') == len(n[1:]):
            print(9*digit + int(n[0]))
        else:
            print(9*digit + int(n[0])-1)
    else:
        print(n[0])

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	SORT(a,3);
	cout << (a[0]+a[1]==a[2] ? "Yes" : "No") << endl;

	
//////////////////////////////////////////////
}


Measured memory_bytes: 256
def check(aa,bb,cc):
    if aa%2==0 and bb%2==0 and cc%2==0:
        return True
    else:
        return False

a,b,c = map(int, input().split())
if check(a,b,c):
    if a == b == c:
        print(-1)
        exit()

ans = 0
while check(a,b,c):
    _a = b // 2 + c // 2
    _b = a // 2 + c // 2
    _c = a // 2 + b // 2
    a = _a
    b = _b
    c = _c
    ans += 1
print(ans)

Measured memory_bytes: 3064
H, W = gets.chomp.split(' ').map(&:to_i)

result = []
grid = readlines.map { |line| line.chomp.split('').map { |cell| cell == '.' ? 0 : 1 }.push(0) }.push(Array.new(W + 1, 0))
(0..H-1).each do |i|
  result[i] = []
  (0..W-1).each do |j|
    result[i][j] = grid[i][j] == 1 ? '#' : 
      grid[i-1][j-1] + 
      grid[i-1][j] + 
      grid[i-1][j+1] +
      grid[i][j-1] + 
      grid[i][j+1] + 
      grid[i+1][j-1] + grid[i+1][j] + grid[i+1][j+1]
  end
end

puts result.map { |row| row.join('') }.join("\n")


Measured memory_bytes: 1916
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
typedef long long int ll;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll smy =0, x=0;
  rep(i, n){
    cin >> a.at(i);
    smy += a.at(i);
  }

  ll anssum = INT_FAST64_MAX;
  rep(i, n-1){
    x += a.at(i);
    anssum = min(anssum,abs(smy-2*x));
  }
  cout << anssum << endl;
  return 0;
}

Measured memory_bytes: 1792
import heapq
N,K = map(int, input().split())

I = []
for _ in range(N):
  t,d = map(int, input().split())
  I.append((d,t))
  
I.sort(reverse=True)

# heap_can_delete
h_d = []
# heap_can_add
h_a = []

wk = 0
kind = 0
# 出現したことのあるネタ
ap = set()
for i in range(K):
  d,t = I[i]
  wk += d
  if t not in ap:
    ap.add(t)
    kind += 1
  else:
    heapq.heappush(h_d, (d,t))

for i in range(K,N):
  d,t = I[i]
  if t not in ap:
    ap.add(t)
    # maxをpopさせるために、価値を-1かけておく
    heapq.heappush(h_a, ((-1) * d, t))
  
ans = wk + kind ** 2
while len(h_d) > 0 and len(h_a) > 0:
  d1,t1 = heapq.heappop(h_d)
  d2,t2 = heapq.heappop(h_a)
  d2 = (-1) * d2
  wk = wk - d1 + d2
  kind += 1
  ans = max(ans, wk + kind ** 2)
  
print(ans)
  
  

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

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

typedef long long ll;
typedef long double ld;

const ll INF = 1e10;
const ld EPS = 1e-8;

typedef long double Weight;
typedef int Flow;

struct Edge {
  int src, dest, rev;
  Flow cap;
  Weight cost;
  bool operator < (const Edge &rhs) const {
    return cost > rhs.cost;
  }
  Edge(int s, int d) : src(s), dest(d) { ; }
  Edge(int s, int d, Weight c) : src(s), dest(d), cost(c) { ; }
  Edge(int s, int d, int r, Flow cp, Weight cst) : src(s), dest(d), rev(r), cap(cp), cost(cst) { ; }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

vector<Weight> dijkstra(const Graph &g, int s) {
  int n = g.size();
  vector<Weight> d(n, INF);
  d[s] = 0;
  priority_queue<Edge> que;
  que.push(Edge(-1, s, 0));
  while(!que.empty()) {
    Edge e = que.top();
    que.pop();
    if(d[e.dest] < e.cost) continue;
    for(Edge f : g[e.dest]) {
      if(d[f.dest] > e.cost + f.cost) {
        d[f.dest] = e.cost + f.cost;
        que.push(Edge(f.src, f.dest, d[f.dest]));
      }
    }
  }
  return d;
}

int main(){
  ld xs, ys, xt, yt;
  int N;
  cin >> xs >> ys >> xt >> yt >> N;
  vector<ld> x(N), y(N), r(N);
  REP(i,N) cin >> x[i] >> y[i] >> r[i];

  x.push_back(xs);
  y.push_back(ys);
  r.push_back(0);
  x.push_back(xt);
  y.push_back(yt);
  r.push_back(0);

  Graph g(N + 2);
  REP(i,N + 2)REP(j,N + 2) {
    if(i >= j) continue;
    ld dist = max((ld)0.0, sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])) - r[i] - r[j]);
    g[i].push_back(Edge(i, j, dist));
    g[j].push_back(Edge(j, i, dist));
  }
  vector<ld> dist = dijkstra(g, N);
  cout << fixed << setprecision(10) << dist[N + 1] << endl;
  return 0;
}



Measured memory_bytes: 40976
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, N) for (int I = 1; I <= (N); ++I)
#define FORR(I, N) for (int I = 0; I < (N); ++I)
#define REP(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPP(I, A, B) for (int I = (A); I >= (B); I--)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
const int N = 100 + 5;
const int mod = 1e9 + 7;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
int a[N][N];
int p[N];
int cnt[N];
int main() {
    int n, m;
    cin >> n >> m;
    FOR(i,m) 
    {
        int x;
        cin >> cnt[i];
        FOR(j,cnt[i])
        {
            cin >> a[i][j];
        }
    }
    FOR(i, m)
        cin >> p[i];
    int ans = 0;
    FORR(i,(1 << n))
    {
        bitset<10> b(i);
        int flag = 0;
        FOR(j,m)
        {
            int _ = 0;
            if(p[j] == 0)
            {
               FOR(k,cnt[j])
               {
                   if(b[a[j][k] - 1] == 1)
                       _++;
               }
               if(_ % 2)
                   flag = 1;
            }
            else 
            {
               FOR(k,cnt[j])
               {
                   if(b[a[j][k] - 1] == 1)
                       _++;
               }
               if(_ % 2 == 0)
                   flag = 1;   
            }
        }
        if(!flag)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {    
    public static void main(String[] args){        
        Scanner sc = new Scanner(System.in);                
                
        long N = sc.nextLong();
        
        long power = 1;
        
        int MOD = (int) Math.pow(10,9) + 7;
        
        for(int i = 1;i <= N;i++){
            power = (power*i)%MOD;
        }        
        
        System.out.println(power);
        
        
    }            
}
        

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

const int limit = 200010;
int nxt[20][limit];

int main(void){
	int n;
	cin >> n;
	vector<int> a(n);

	rep(i,n) cin >> a[i];

	ll ans = 0LL;

	rep(j,20){
		nxt[j][n] = n;
		rrep(i,n){
			nxt[j][i] = nxt[j][i+1];
			if((a[i] >> j) & 1) nxt[j][i] = i;
		}
	}

	rep(l,n){
		int r = n;
		rep(j,20){
			int pos = nxt[j][l];
			if(pos == n) continue;
			chmin(r,nxt[j][pos + 1]);
		}
		ans += (r - l);
	}

	cout << ans << endl;

	
	return 0;
}

Measured memory_bytes: 16640
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑


int main() {

	int n;
	cin >> n;
	cout << (n - 30) / 2 << endl;



}


Measured memory_bytes: 3112
#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

static const int MAX = 20;

int n, V[MAX], C[MAX], x, y;

int main() {
    scanf("%d", &n);

    for ( int i = 0; i < n; i++ ) {
        scanf("%d", &V[i]);
    }
    
    for ( int i = 0; i < n; i++ ) {
        scanf("%d", &C[i]);
    }
    
    x = 0;
    y = 0;

    for ( int i = 0; i < n; i++ ) {
        if ( C[i] <= V[i] ) {
            x += V[i];
            y += C[i];
        }
    }

    printf("%d\n", x - y);
    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
typedef long long ll;
using namespace std;

ll const MAX = 100005;
ll like[MAX];
ll prime[MAX];

int main() {
	REP(i, 1, 100000) {
		prime[i] = like[MAX] = -1;
	}
	prime[1] = 0;
	for (ll i = 2; i*i <= 100000; i++) {
		if (prime[i] == -1) {
			prime[i] = 1;
			for (ll j = i * 2; j <= 100000; j += i) {
				prime[j] = 0;
			}
		}
	}
	REP(i, 1, 100000) {
		if (prime[i] == -1) {
			prime[i] = 1;
		}
	}
	like[1] = like[2] = 0;
	REP(i, 3, 100000) {
		if (prime[i] == 1 && prime[(i + 1) / 2] == 1) {
			like[i] = 1;
		}
		else {
			like[i] = 0;
		}
	}
	REP(i, 2, 100000) {
		like[i] += like[i - 1];
	}
	ll q;
	cin >> q;
	REP(i, 1, q) {
		ll a, b;
		cin >> a >> b;
		cout << like[b] - like[a - 1] << endl;
	}
}

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

int main() {
  int n,count=0; cin>>n;
  for(int i=0;i<n;i++) {
     if (int(log10(i))%2!=1) count++;
  }
  if(int(log10(n))%2==1) count--;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<random>
using namespace std;
int main() {

  int r, g;
  cin >> r >> g;
  cout << 2*g - r << endl;

  return 0;
}


Measured memory_bytes: 256
(let* ((lst (loop :repeat 5 :collect (read)))
       (lst-a (mapcar (lambda (k) (if (= 10 (- 10 (mod k 10)))
                                      0
                                      (- 10 (mod k 10)))) lst)))
  (princ (- (+ (reduce #'+ lst) (reduce #'+ lst-a)) (reduce #'max lst-a))))

Measured memory_bytes: 4456
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n = Integer.parseInt(scanner.nextLine());


		String temp1 = scanner.nextLine();
		String[] temp = temp1.split(" ");
		int list[] = new int[n];

		int max = 0;
		int total = 0;
		for(int i = 0; i < n; i++ ) {
			list[i] = Integer.parseInt(temp[i]);

			total += list[i];
			max = Math.max(max, list[i]);
		}

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

}


Measured memory_bytes: 22996
#include<iostream>
#include<cstring>
#include<cstdio>
#define maxn 200009
#define mo 1000000007
using namespace std;
typedef long long ll;
ll ans,f[maxn],last;
int n,m,a,b;
ll pow(ll x,int t)
{
  ll now=x,sum=1;
  while (t)
  {
  	if (t&1) sum=(sum*now)%mo;
  	now=(now*now)%mo;
  	t=t>>1;
  }
  return sum;
}
ll calc(int x,int y)
{
  ll di=pow((f[x-y]*f[y])%mo,mo-2);
  return ((di*f[x])%mo);
}
int main()
{
  scanf("%d%d%d%d",&n,&m,&a,&b);
  a=n-a+1;
  f[0]=1;
  for (int i=1;i<=n+m;i++) f[i]=(f[i-1]*i)%mo;
  int  x=a-1,rx=n-x;
  for (int i=b+1;i<=m;i++)
  {
  	int ry=m-i+1;
  	ans=(ans+(calc(x+i-2,x-1)*calc(rx+ry-2,ry-1))%mo)%mo;
  }
  //cout<<calc(n+m-2,n-1)<<endl;
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll a[4]={};
rep(i,4){
cin>>a[i];}
sort(a,a+4);
if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9){
cout << "YES" << endl;}
else
cout << "NO" << endl;}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;



int main()
{
	string ans="YES";
	int N;
	long int A[200000];
	cin >> N;
	//vector<int> X(10000),L(100000);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	sort(A, A + N);

	for (int i = 0; i < N; i++) {
		if (A[i] == A[i + 1]) {
			ans = "NO";
			continue;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
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 N,A,B;
    cin>>N>>A>>B;
    vector<ll> x(N);
    vector<ll> sa(N);
    ll ans=0;
    rep(i,N) cin>>x[i];
    for(int i=0; i<N-1; i++){
        sa[i+1]=x[i+1]-x[i];
    }
    for(int i=1; i<N; i++){
        if(sa[i]*A<=B) ans+=sa[i]*A;
        else ans+=B;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

map<string,int> m1;
vector<string> v1;

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	string sa;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>sa;
		m1[sa]++;
	}
	a=0;
	for(auto node:m1){
		a=max(a,node.second);
	}
	for(auto node:m1){
		if(node.second==a)v1.push_back(node.first);
	}
	sort(v1.begin(),v1.end());
	for(auto s:v1){
		cout<<s<<endl;
	}
}

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

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


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, n, ans = 1, now = 1, a;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) ans *= 3;
  for(i = 0; i < n; ++i) scanf("%d", &a), now *= a & 1 ? 1 : 2;
  printf("%d", ans - now);
  return 0;
}

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

int main(){
	int N,M,X,Y;
	cin >> N >> M >> X >> Y;
	vector<int> x(N);
	vector<int> y(M);
	for(int i=0;i<N;i++){
		cin >> x.at(i);
	}
	for(int i=0;i<M;i++){
		cin >> y.at(i);
	}
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	for(int Z=x.at(N-1)+1;Z<y.at(0)+1;Z++){
		if(Z>X&&Z<=Y){
			cout << "No ";
			break;
		}
	}

/*	if(X+1<Y && y.at(0) > X && x.at(N-1)+1<=Y){
		cout << "No ";
	}
*/
	cout << "War" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.nextLine());
		int b = Integer.parseInt(sc.nextLine());
		int c = Integer.parseInt(sc.nextLine());
		int d = Integer.parseInt(sc.nextLine());

		System.out.println(Math.min(a, b) + Math.min(c, d));

		sc.close();
	}
}

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

const int mod=1000000007;

int func(int *a,int n){
  int sum=0;
  int i;
  for(i=0;i<n-1;i++) sum=(sum+(int64)(a[i+1]-a[i])*(i+1)%mod*(n-1-i)%mod)%mod;
  return sum;
}

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  int *x=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",x+i);
  int *y=(int *)malloc(sizeof(int)*m);
  for(i=0;i<m;i++) scanf("%d",y+i);

  int ans=(int64)func(x,n)*func(y,m)%mod;
  printf("%d\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 896
def solve(sa, sb, sc, t):
	d = {'a': sa, 'b': sb, 'c': sc}
	if d[t] == '':
		return t.upper()
	u = d[t][0]
	d[t] = d[t][1:]
	return solve(d['a'], d['b'], d['c'], u)

SA = input()
SB = input()
SC = input()
print(solve(SA, SB, SC, 'a'))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define F first
#define S second
using namespace std;
typedef long long ll;
ll wa=1000000007;



ll dp[10101][2][101]={};



int main(){
	string s;
   	int n;
	cin>>s>>n;
	rep(i,s[0]-'0')dp[0][0][i%n]++;
	dp[0][1][(s[0]-'0')%n]++;
	REP(i,1,s.size()){
		rep(j,n){
			rep(k,10){
				dp[i][0][(j+k)%n]+=dp[i-1][0][j];
				dp[i][0][(j+k)%n]%=wa;
				
			}
			rep(k,(int)s[i]-'0'+1){
				if(k==(int)s[i]-'0'){
					dp[i][1][(j+k)%n]+=dp[i-1][1][j];
					dp[i][1][(j+k)%n]%=wa;
				}else{
					dp[i][0][(j+k)%n]+=dp[i-1][1][j];
					dp[i][0][(j+k)%n]%=wa;
				}
			}
		}
	}
	

	if(dp[s.size()-1][0][0]==0){dp[s.size()-1][0][0]=wa;}
	cout<<(dp[s.size()-1][1][0]+dp[s.size()-1][0][0]-1)%wa<<endl;
}



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

int main(){
	int n;
	while (cin >> n, n){
		int inA, inB, ansA = 0, ansB = 0;
		for (int i = 0; i < n; i++){
			cin >> inA >> inB;
			if (inA > inB) ansA += inA + inB;
			else if (inB > inA) ansB += inA + inB;
			else{
				ansA += inA;
				ansB += inB;
			}
		}
		printf("%d %d\n", ansA, ansB);
	}
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;

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


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


string s;
cin>>s;

int q;
cin>>q;
int st=1,en=-1;
int cnt=0;
while(q--)
{
  int t;
  cin>>t;
  if(t==1)
  {
    swap(st,en);  cnt++;
  }
  else if(t==2)
  {
   
    int x;
    cin>>x;
    string c;
    cin>>c;
    if(x==1)
    {
       if(st==1)
       {
        s.insert(0,c);
       }
       else s+=c;
    }
    else{
      if(en==1)
       {
         s.insert(0,c);
       }
       else s+=c;
    }
  }
}
if(cnt&1)reverse(s.begin(),s.end());
cout<<s;
  
}



Measured memory_bytes: 912
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;


int main(void) {
	string s,t;
	cin >> s >> t;
	map<char,int> m,n;
	for(int i=0; i<s.length(); i++){
		m[s[i]]++;
	}
	for(int i=0; i<t.length(); i++){
		n[t[i]]++;
	}
	int scount=0,tcount=0;
	for(char c='a'; c<='z'; c++){
		scount+=m[c];
		tcount+=n[c];
		if(tcount<t.length() && s.find(c)!=-1){
			cout << "Yes" << endl;
			return 0;
		}
		if(scount>=s.length()&&tcount>=t.length()){
			cout << (s.length()<t.length()?"Yes":"No") << endl;
			return 0;
		}
		if(tcount>=t.length()){
			cout << "No" << endl;
			return 0;
		}
	}
	return 0;
}

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

int main(){
  int i, j, k, n, tmp;
  int A[100];

  scanf("%d",&n);
  if( n<1 || 100<n ) exit(1);
  
  for( i=0 ; i<n ; i++ ){
    scanf("%d",&A[i]);
    if( A[i]<0 || 1000<A[i] ) exit(2);
  }

  for( i=1 ; i<n ; i++ ){
    tmp = A[i];
    j = i-1;
    
    for( k=0 ; k<n ; k++ ){
      if( k==n-1 ) printf("%d\n",A[k]);
      else printf("%d ",A[k]);
    }
 
    while( j>=0 && A[j]>tmp ){
      A[j+1] = A[j];
      j--;
      A[j+1] = tmp;
    }
  }

  for( k=0 ; k<n ; k++ ){
    if( k==n-1 ) printf("%d\n",A[k]);
    else printf("%d ",A[k]);
    
  }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
#define printd(x) printf("%.12f\n", ans);
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;



int main(void) {
    
    //cin.tie(nullptr);ios::sync_with_stdio(false);cout << fixed << setprecision(20);

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

    string w;
    cin >> w;

    map<char, int> mp;
    rep (i, w.size()) {
        mp[w[i]]++;
    }

    bool ok = true;
    for (char c = 'a'; c <= 'z'; c++) {
        if (mp[c] % 2 == 1) ok = false;
    }
    if (ok) yn;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define SIZE 100333
#define MOD 1000
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef vector<vector<long long> > mat;

int main () {
	ll a,b;
	scanf("%lld%lld",&a,&b);
	printf("%lld\n",(a+b)%24LL);	
}

Measured memory_bytes: 764
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;
int n;
string str[2];
int f;

string IntToString(int number)
{
  stringstream ss;
  ss << number;
  return ss.str();
}

int main(void)
{
  f = 0;
  while(1){
    cin >> n;
    if(!n) break;
    cin >> str[f];
    for(int i = 0; i < n; i++){
      int c = 1;
      char cc = str[f][0];
      str[f] += 'A';
      for(int j = 1; j < str[f].size(); j++){
	if(cc == str[f][j]){
	  c++;
	}else{
	  str[(f+1)%2] += IntToString(c);
	  str[(f+1)%2] += cc;
	  c = 1;
	  cc = str[f][j];
	}
      }
      str[f] = "";
      f = (f+1)%2;
    }
    cout << str[f] << endl;
  }
}

Measured memory_bytes: 1352
/* 
                     ... .
               xdM*"""*+"9M
            xM"             "M
          MP"                 "M
        ,M/|,                 \`4
      n"   /|/.          .\  \\``4
     d)    <~!-'        \^`\  `   n
     M"                           \
     M.          !: uu<            ;
     M@ @        !$$$$!:           r
       h?M  <.`.`t$$$$X".( /< xh   >
        "M <`:x~NX$$$$Ub>*cXW !X   L
         M `X!@k:$$$$$$$r $$$Lr    M
         M   '9$$$$$$$$$$$$$F"     4
         ~    ?$$$x$$$$$$$$P        M
        h      !$$$d%m@$$"f          L
        *        #$$$$$)$:>           ":,
         x      ` `#$R!$\!  :            "\._
          h   < < !..!JR  ~<<             -n.`\
       ..x**  < 'ouk!!$f~  <<   ...         ^*.;
   ....( !! << \NdC*$@$><~  << !!!:!!<.       "M
  xJ"<!!<!~<<<dNeRV$$$R    <<< !!!!!!:<:       `M
  M%<!!!! <<~:`(3$$$R?<<<<<<~< !!?!:<<<<<       M
  M<<!!!!' :<<:x$$$!!<<<<<<<<.!~:~<<<<<<<   k   M
 n!<<<!   <<<~<$$$?~ '<<<<<<:'.!`<<<<<~ ~  :|  /
 M<<<<   '  ~ <$$R?.  `<~   <'!<<< <<<< ~  ;/ z
 "<<<<<  : < <  M#!    <<   <<   <<<<<<h> / v'
  <<<<<>< <~<<   .uoN :<<<  <<  <<<<<<<:eVa
  <<<<<< '<<<    !$$$$<<<<<   :<<<<<<<<<<' )
  <<<<<` < <~     R$$$N      <<<<<<<<<<<<e~
  <<< <   `        $$$$$.    ~``~<<<<<< x"
  k<<<<            `$$$$$b   :<<<<`<<<<MC
  M<<<<             "$$$$$!<< :<`~<<!<d""
  f<<<<:             #$$$$!<<<<~<:<<<<M
 P<<<:<<~  :          #$$?~ <<   <`<<tM
 <<<<~:~`<<<<::        "`   `<     ~MJ>
 :<< ~:<<<<<::.                  ..<$f
 M  <<<<<<:!XN$$$bu.        ..uo$#3$!4M
  x  <<~  !!#$$$$$$$$$eiL.d$$$#\Le$!!XP
  '.       !!!!??#$$$$$$$$$$$****#?XMr
    `-.            ```~""!!!!!!XXnHC
       `-'\               '"*xd
*/

#include <bits/stdc++.h>
using namespace std;

int main(){
  int Array[105];
  long long int suma=0;
  long long int AcumulacionMenor=0,AcumulacionMayor=0;
  bool AcumulacionExtra=false;
  int n,aux,objetivo;
  scanf("%d",&n);
  for (int i = 0; i < n; ++i)
  {
    scanf("%d",&aux);
    Array[i]=aux;
    suma+=aux;
  }
  if (suma%n!=0){
    AcumulacionExtra=true;
  }
  objetivo=suma/n;
  for (int i = 0; i < n; ++i)
  {
    aux=abs(Array[i]-objetivo);
    AcumulacionMenor+=aux*aux;
    if (AcumulacionExtra)
    {
      aux=abs(Array[i]-(objetivo+1));
      AcumulacionMayor+=aux*aux;
    }
  }
  if (AcumulacionExtra)
  {
    if (AcumulacionMenor < AcumulacionMayor) cout << AcumulacionMenor;
    else cout << AcumulacionMayor;
  }
  else{
    cout << AcumulacionMenor;
  }
  return 0;
}

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

AB = [[int(i) for i in input().split()] for i in range(n)]
CD = [[int(i) for i in input().split()] for i in range(n)]

AB = sorted(AB, reverse=True, key=lambda x: x[1])
CD = sorted(CD)

for i in range(n):
    for j in range(len(CD)):
        if AB[i][0] < CD[j][0] and AB[i][1] < CD[j][1]:
            CD.pop(j)
            break
            
print(n - len(CD))

Measured memory_bytes: 3188
#include<stdio.h>
int main()
{
    int x, y;
    scanf("%d %d", &x, &y);
    if (x == 2 || y == 2)
        printf("No\n");
    else
    {
        if (x == 4 || x == 6 || x == 9 || x == 11)
            if (y == 4 || y == 6 || y == 9 || y == 11)
                printf("Yes\n");
            else
                printf("No\n");
        else
            if (y == 4 || y == 6 || y == 9 || y == 11)
                printf("No\n");
            else
                printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
const int MAX=100005;
long long int a[MAX],b[MAX];
int n;
int main()
{
	long long int inc=0;
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i]>>b[i];
	}
	for(int i=n;i>0;--i){
		a[i]+=inc;
		long long int c=a[i]%b[i];
		if(c!=0){
			inc+=(b[i]-c);
		}
	}
	cout<<inc<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<queue>
#include<climits>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<ctype.h>
#include<set>
#include<vector>
#include<map>
#define ff first
#define ss second
#define LL long long
using namespace std;
map<int,int > m;
int main()
{
	int a[25],b[25];
	int i,j,n,k,t;
	while (scanf("%d%d",&n,&t)&&(n||t))
	{
		m.clear();
		k=0;
		for (i=1;i<=n;i++)
		{
			scanf("%d",&a[i]);
			m[a[i]]++;
			k+=a[i];
		}
		for (i=1;i<=t;i++)
		{
			scanf("%d",&b[i]);
			if (m[b[i]]) m[b[i]]--;
			else
			k+=b[i];
		}
		printf("%d\n",k);
	}
}

//freopen("video.in","r",stdin);
//freopen("video.out","w",stdout);

Measured memory_bytes: 1192
#include <stdio.h>

int main(void)
{
	int jou;
	int toku;
	int hutatu;
	
	scanf("%d %d %d", &jou, &toku, &hutatu);
	
	if ((jou > 0) && (toku > 0) || (hutatu > 0)){
		printf("Open\n");
	}
	
	else {
		printf("Close\n");
	}
	
	return (0);
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int main(){
 string s,t;
  int q;
  cin>>s>>q;
  rep(i,q){
    int a;
    cin>>a;
    if(a==1)swap(s,t);
    if(a==2){
      int b;
      cin>>b;
      if(b==1){
        string u;
        cin>>u;
        t=t+u;
      }
      if(b==2){
        string u;
        cin>>u;
        s=s+u;
      }
    }
  }
  reverse(t.begin(),t.end());
  cout<<t+s<<endl;
}

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

struct P {
    int x, y, z;
};

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

    vector<P> p(n);
    for (int i = 0; i < n; i++) {
        int x, y, z;
        cin >> x >> y >> z;

        p[i] = { x, y, z };
    }

    int v[15], u[15];
    for (int i = 0; i < n; i++) {
        v[i] = min(abs(p[i].x), abs(p[i].y));
    }

    int l = (int)pow(3, n);

    vector<ll> r(n + 1, 1LL << 60);
    for (int k = 0; k < l; k++) {
        int a = k, b = 0;
        ll s = 0;
        for (int i = 0; i < n; i++) {
            u[i] = v[i];
        }
        for (int i = 0; i < n; i++) {
            int t = a % 3; a /= 3;
            if (t == 0) continue;
            b++;
            if (t == 1) {
                for (int j = 0; j < n; j++) {
                    u[j] = min(u[j], abs(p[i].x - p[j].x));
                }
            } else {
                for (int j = 0; j < n; j++) {
                    u[j] = min(u[j], abs(p[i].y - p[j].y));
                }
            }
        }
        for (int i = 0; i < n; i++) {
            s += (ll)u[i] * p[i].z;
        }
        r[b] = min(r[b], s);
    }

    for (int i = 0; i <= n; i++) {
        cout << r[i] << endl;
    }

    return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> one_to;
    vector<int> to_N;
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        if(a == 1 && b != N){
            one_to.push_back(b);
        }
        if(a != 1 && b == N){
            to_N.push_back(a);
        }
    }
    int A = one_to.size();
    int B = to_N.size();
    
    bool ans = false;
    set<int> jdg;
    for(int i = 0; i < A; i++)jdg.insert(one_to[i]);
    
    for(int i = 0; i < B; i++){
        if(jdg.count(to_N[i])){
            ans = true;
            break;
        }
    }
    
    cout << ((ans) ? "POSSIBLE" : "IMPOSSIBLE") << '\n';
}

Measured memory_bytes: 5748
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { //Ball out dawg
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		long A = I.nextLong();
		long B = I.nextLong();
		long C = I.nextLong();
		long D = I.nextLong();
		long ans = B-A+1;
		long LCM = C*D;
		LCM/=GCD(C,D);
		
		//C
		long lo = A;
		long mod = A%C;
		if (mod!=0) lo+=C-mod;
		if (lo<=B) { //If lower bound is within [A,B]
			long hi = B;  //A=5,B=20,C=6 --> hi = 20-20%6 = 18 
			hi-=(B%C);
			long range = hi-lo;
			ans-=range/C;
			ans--; //If range = [24,24] answer is 1 still (inclusion technique)
		}
		//D
		lo = A;
		mod = A%D;
		if (mod!=0) lo+=D-mod;
		if (lo<=B) { //If lower bound is within [A,B]
			long hi = B;  //A=5,B=20,C=6 --> hi = 20-20%6 = 18 
			hi-=(B%D);
			long range = hi-lo;
			ans-=range/D;
			ans--; //If range = [24,24] answer is 1 still (inclusion technique)
		}
		//LCM (Removes counting a valid number twice in range [A,B])
		lo = A;
		mod = A%LCM;
		if (mod!=0) lo+=LCM-mod;
		if (lo<=B) { //If lower bound is within [A,B]
			long hi = B;  //A=5,B=20,C=6 --> hi = 20-20%6 = 18 
			hi-=(B%LCM);
			long range = hi-lo;
			ans+=range/LCM;
			ans++; //If range = [24,24] answer is 1 still (inclusion technique)
		}
		O.pln(ans);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}

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

import math
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
  
ps = primes(10**6)
ans = 0
for p in ps:
  d = 1
  while n%(p**d) == 0:
    #print(n, p**d, p, d)
    n = n//(p**d)
    ans += 1
    d += 1
    
if n>10**6:
  print(ans + 1)
else:
  print(ans)
  

Measured memory_bytes: 80788
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    if(a < 10  && b < 10){
      System.out.println(a * b);
    }else{
      System.out.println(-1);
    }
  }
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
typedef pair<int,int> P;

P comp(P lhs,P rhs)
{
	if(lhs.first>rhs.first)
		return lhs;
	else if(lhs.first==rhs.first && lhs.second<rhs.second)
		return lhs;
	else
		return rhs;	
}

P dp[101][50001]; //i番目まで端数でj円持っているときの500の数と金額
int m[100]; //価格
P pay1000[100]; //1000円オンリーで払ったときにもらえる500ともらえる端数
P adjust[100]; //端数を調整したときに500を1もらうために必要な端数
int main()
{
	while(1)
	{
		int n;
		cin>>n;
		if(n==0)
			break;
		for(int i=0;i<n;i++)
		{
			cin>>m[i];
			int p=(7000-m[i])%1000;
			if(p>=500)
				pay1000[i]=P(1,p-500);
			else
				pay1000[i]=P(0,p);
			p=(m[i]+1000)%1000;
			if(p!=0)
				adjust[i]=P(1,(p+500)%1000);
			else
				adjust[i]=P(1,500);
		}
		
		//ここからdp
		fill(dp[0],dp[101],P(-1,-1));
		dp[0][0]=P(0,0);
		for(int i=1;i<n+1;i++)
		{
			//cerr<<pay1000[i-1].first<<" "<<pay1000[i-1].second<<endl;
			//cerr<<adjust[i-1].first<<" "<<adjust[i-1].second<<endl;
			for(int j=0;j<50001;j++)
			{
				if(dp[i-1][j]!=P(-1,-1))
				{
					dp[i][j]=comp(dp[i][j],dp[i-1][j]);
					//端数調整して買う場合	
					if(j>=adjust[i-1].second)
					{
						dp[i][j-adjust[i-1].second]=comp(dp[i][j-adjust[i-1].second], 
							P(dp[i-1][j].first+adjust[i-1].first, dp[i-1][j].second+m[i-1]));
					}
					//1000円だけで買う場合
					dp[i][j+pay1000[i-1].second]=comp(dp[i][j+pay1000[i-1].second],
						P(dp[i-1][j].first+pay1000[i-1].first, dp[i-1][j].second+m[i-1]));
				}
			}
		}
		P ans=P(0,0);
		for(int i=0;i<50001;i++)
			ans=comp(dp[n][i],ans);
		cout<<ans.first<<" "<<ans.second<<endl;
	}
	return 0;
}


Measured memory_bytes: 42532
#include <bits/stdc++.h>
const int MOD = 1e9+7;
#define REP(i,n) for (int i = 0; i < (N); ++i)
#define ar array
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a,b;
	cin >> a >> b;

	if ((a*b)%2==0) {
		cout << "Even" << endl;
	}	else {
		cout << "Odd" << endl;
	}
	return 0;
}


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


int main()
{
  ll n;
  cin >> n;
  ll a[3000];
  ll sum = 0;
  for(ll i = 0;i < n;i++){
    cin >> a[i];
    sum += a[i] - 1;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256