akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = SR(3)
    for i in range(3):
        print(s[i][i], end="")
    print()
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(i,k,n) for(int i = (k); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;

template <typename T>
void vecprint(vector<T> &vec) {
    cout<<'[';
    for(T x:vec){
        cout<<x<<',';
    }
    cout<<']'<<endl;
    return;
}

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    vector<string> ch(h);
    rep(i,h) cin>>ch[i];
    int ans = 1000000000;
    for(int tmp=0;tmp<(1<<(h-1));tmp++){
        bitset<10> bt(tmp);
        vector<int> rm(h,0);
        int kk=0;
        int cnt=bt.count();
        rep(j,h-1){
            if(bt.test(j)) kk++;
            rm[j+1]=kk;
        }
        map<int,int> mp;
        bool b=false;
        int cmp;
        rep(i,w){
            rep(j,h){
                if(ch[j][i]=='1'){
                    mp[rm[j]]++;
                    if(mp[rm[j]]>k){
                        cnt++;
                        mp.clear();   
                        if(cmp==i){
                            i=w;
                            cnt=1e9;
                        }
                        cmp=i;
                        i--;
                        break;
                    }
                }
            }
            

        }
        ans=min(ans,cnt);
    }
    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);
    ArrayList<Integer> array = new ArrayList<>();
		// 整数の入力
		int number = sc.nextInt();
    for(int i = 0; i < number; i++){
      array.add(sc.nextInt());
    }

    int total = 0;
    for(int i = 0; i < array.size();i++){
      for(int j = 1+i; j < array.size(); j++){
        total += array.get(i)*array.get(j);
      }
    }

    System.out.println(total);
	}
}

Measured memory_bytes: 21588
fn main(){
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let vec: Vec<&str> = s.trim().split(' ').collect();
	let mut v: Vec<i32> = Vec::new();
	for x in &vec {
		v.push(x.parse().unwrap());
	}
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let k: usize = s.trim().parse().unwrap();
	v.sort_by(|a, b| b.cmp(a));
	for _i in 0..k {
		v[0] *= 2;
	}
	let mut n = 0;
	for i in 0..v.len() {
		n += v[i];
	}
	println!("{}", n);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc054/tasks/abc054_c

int ab[15][15];

int main() {
    int N, M; cin >> N >> M;
    REP(i, M) {
        int a, b; cin >> a >> b;
        ab[a][b] = 1;
        ab[b][a] = 1;
    }

    vector<int> perm(N-1);
    REP(i, N-1) {
        perm[i] = i + 2;
    }
    sort(perm.begin(), perm.end());

    int cnt = 0;
    do {
        int now = 1;
        for (int i = 0; i < perm.size(); i++) {
            if (!ab[now][perm[i]]) break;
            now = perm[i];
            if (i == perm.size()-1) cnt++;
        }
    } while(next_permutation(perm.begin(), perm.end()));

    cout << cnt << "\n";

    return 0;

}


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

const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using P = pair<int, int>;



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n; scanf("%d", &n);
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]);

    int ans = 1;
    int flag = 0;

    for (int i = 0; i < n-1; ++i) {
        if (a[i] == a[i+1]) continue;

        if (flag == 0) {
            if (a[i] < a[i+1]) flag = 1;
            else flag = -1;
        } else if (flag == 1) {
            if (a[i] > a[i+1]) {
                ++ans;
                flag = 0;
            }
        } else {
            if (a[i] < a[i+1]) {
                ++ans;
                flag = 0;
            }
        }

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

Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
  int x,y,c,d;

  scanf("%d%d",&x,&y);
  if(1<=x && x<=1000000000){
     if(1<=y && y<=1000000000){
    d=x;
    x=y;
    x=d;
  }
  }
  c=x%y;
  while(c!=0){
    x=y;
    y=c;
    c=x%y;
  }
  printf("%d\n",y);

  return 0;
}
    



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

int sumS(string s) {
    int r = 0;
    for (int i = 0; i < s.length(); i++)
    {
        r += s[i] - '0';
    }
    
    return r;
}

int main () {
    int N, A, B;
    cin >> N >> A >> B;
    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        int r = sumS(to_string(i));
        if (A <= r && r <= B) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
current_x = 0
current_y = 0
current_t = 0
for i in 1..n do
    num = gets.chomp.split(" ").map(&:to_i)
    time = num[0] - current_t
    x = num[1] - current_x
    y = num[2] - current_y
    if time < x + y
        puts "No"
        break
    elsif !((time - x - y) % 2 == 0)
        puts "No"
        break
    end
    current_t = num[0]
    current_x = num[1]
    current_y = num[2]
    if(i == n)
        puts "Yes"
    end
end

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

int main() {
  string s,t;
  cin >> s >> t;
  bool b=true;
  rep(i,s.length()){
    if(s.at(i)!=t.at(i)) b=false;
  }
  if(b==true) cout << "Yes" << endl;
  else cout << "No" << endl;
}



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

using namespace std;

int dp[3100][3100];
string s, t;

int main() {
	cin >> s >> t;
	
	int n = s.length(), m = t.length();
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			if (i == 0 || j == 0) dp[i][j] = 0;
			else {
				if (s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
				else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	
	string ans;
	int i = n, j = m;
	while (i > 0 && j > 0) {
		if (s[i - 1] == t[j - 1]) {
			ans.push_back(s[i - 1]);
			i--, j--;
		}
		else if (dp[i - 1][j] > dp[i][j - 1]) i--;
		else j--;
	}
	reverse(ans.begin(), ans.end());
	
	cout << ans << '\n';
}


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

int main()
{
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double angleH = 0.0;
    double angleM = 0.0;
    angleH += H * 30;
    angleH += M * 0.5;
    angleM += M * 6;

    double angle = 0.0;
    if (angleH > angleM) {
        angle = angleH - angleM;
    }
    else {
        angle = angleM - angleH;
    }
    if (angle > 180) {
        angle = 360 - angle;
    }

    if (angle == 0) {
        cout << abs(A - B) << endl;
    }
    else if (angle == 180) {
        cout << A + B << endl;
    }
    else {
        cout << fixed << setprecision(20) << sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(angle * M_PI / 180.0)) << endl;
    }
    return 0;
}

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

int main() {
  int n,m,k;
  cin >> n>>m>>k;
  int g=__gcd(n,m);
  vector<int>a;
  for(int i=g;i>=1;i--){
    if(g%i==0){
      a.push_back(i);
    }
  }
  
  cout<<a.at(k-1)<<endl;
 
}



Measured memory_bytes: 256
from itertools import accumulate

n, q = map(int, input().split())
s = input()

t = [0] * n
for i in range(n - 1):
    if s[i] + s[i + 1] == "AC":
        t[i] = 1

a = [0] + list(accumulate(t))
for i in range(q):
    l, r = map(int, input().split())
    print(a[r - 1] - a[l - 1])

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

int main() {

    int n; cin >> n;
    const int p = 2;
    vector<vector<int>> a(p, vector<int>(n));
    for (int i = 0; i < p; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }

    int ans = 0;
    for (int target = 0; target < n; target++) {
        int tmp = 0;
        for (int i = 0; i <= target; i++) {
            tmp += a[0][i];
        }
        for (int i = target; i < n; i++) {
            tmp += a[1][i];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define Unique(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e8
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------



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

  int n,m,K; cin >> n >> m >> K;

  for(int k=0;k<=n;k++){
    for(int l=0;l<=m;l++){
      if(k*(m-l)+l*(n-k)==K){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << 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);
    String s=sc.next();
    int w=sc.nextInt();
    String ans="";
    for(int i=0;i<s.length();i+=w){
      ans+=s.substring(i,i+1);
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 24916
#include<bits/stdc++.h>
using namespace std;
bool isPallindrome(char s[]){
  	 int l=strlen(s);
  for(int i=0,j=l-1;i<l/2;i++,j--){
    if(s[i]!=s[j]) return false;
  }
  return true;
}
int main(){
  char s[100],t[100],p[100];
  cin>>s;
  int n=strlen(s);
  int x=(n-1)/2;
  int i;
  for( i=0;i<x;i++){
                
    t[i]=s[i];
  }
  t[i]='\0';
  int y=((n+3)/2)-1;
  int kk=0;
  for(int i=y;i<n;i++){
    p[kk]=s[i];
    kk++;
  }
  p[kk]='\0';
 if(isPallindrome(s) && isPallindrome(t) && isPallindrome(p)){
               cout<<"Yes"<<endl;
 }
 else {
               cout<<"No"<<endl;
 }
  return 0;
}
 

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

////Problem A
using namespace std;

bool even_divisible(int num)
{
    if (num % 3 == 0 || num % 5 == 0)
        {
            return 1;
        }
    return 0;
}

int main ()
{
    int num[105], n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        cin >> num[i];
    }
    
    for (int i = 1; i <= n; i++)
    {
        if (num[i] % 2 == 0)
        {
            if (even_divisible(num[i]) == 0)
            {
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";
}


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

int main()
{
	int N, cnt = 0;
	string S;
	
	cin >> N >> S;

	for (int i = 0; i < S.size(); i++) {

		if (S.substr(i, 3) == "ABC") cnt++;		
	}

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


Measured memory_bytes: 256
#include<stdio.h>
int max(int a, int b)
{
	if (a > b)return a;
	else return b;
}
int main()
{
	int n;
	long long int k;
	scanf("%lld %lld", &n, &k);
	int i, j;
	long long int a[100005];
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	int b[100005][60];
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < 60; j++)
		{
			b[i][j] = (int)(a[i] % 2);
			a[i] /= 2;
		}
	}
	int s[60][2];
	for (i = 0; i < 60; i++)
	{
		s[i][0] = s[i][1] = 0;
		for (j = 0; j < n; j++)
			s[i][b[j][i]]++;
	}
	long long int p[60];
	p[0] = 1;
	for (i = 1; i < 60; i++)
		p[i] = p[i - 1] * 2;
	long long int f[64];
	f[0] = 0;
	for (i = 0; i < 60; i++)
		f[i + 1] = p[i] * max(s[i][0], s[i][1]) + f[i];
	int kb[60];
	for (i = 0; i < 60; i++)
	{
		kb[i] = (int)(k % 2);
		k /= 2;
	}
	long long int v = 0, ans = 0;
	for (i = 59; i >= 0; i--)
	{
		if (kb[i] == 0)
		{
			v += p[i] * s[i][1];
			if (v > ans)
				ans = v;
		}
		else
		{
			if (v + p[i] * s[i][1] + f[i] > ans)
				ans = v + p[i] * s[i][1] + f[i];
			v += p[i] * max(s[i][0], s[i][1]);
			if (ans < v)
				ans = v;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int po[11];

int main(){
  string s;
  cin>>s;
  string t;
  REP(i,s.size()){
    char c = s[i];
    if(c=='B'){
      if(t.size()>0)t.pop_back();
    }else{
      t += c;
    }
  }
  cout<<t<<endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np

N = int(input()) + 1

A = input().split()

B = input().split()

enemy = np.zeros(N)
saver = np.zeros(N)

beated = 0
over = 0

for i in range(N - 1):
    enemy[i] = int(A[N - i - 1])
    saver[i] = int(B[N - i - 2])

enemy[N - 1] = int(A[0])

for i in range(N):
    if(enemy[i] - over > saver[i]):
        beated = beated + saver[i] + over
        over = 0
    else:
        beated = beated + enemy[i]
        if(over > enemy[i]):
            over = saver[i]
        else:
            over = saver[i] + over - enemy[i]

print(int(beated))

Measured memory_bytes: 28772
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define LL       long long
#define DS       pair<int, int>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

string s;
int dp[N][10][15];

inline int add(int a, int b) {
    a += b;
    if (a >= MOD) {
        a -= MOD;
    }
    return a;
}

int fun(int pos, int used, int rem) {
    if (pos == s.size()) {
        return rem == 5;
    }
    int &tmp = dp[pos][used][rem];
    if (tmp != -1) {
        return tmp;
    }
    tmp = 0;
    if (s[pos] == '?') {
        for (int i = 0; i < 10; i++) {
            int x = rem * 10 + i;
            tmp = add(tmp, fun(pos + 1, i, x % 13));
        }
    } else {
        int x = rem * 10 + (s[pos] - '0');
        tmp = add(tmp, fun(pos + 1, used, x % 13));
    }
    return tmp;
}

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    cin >> s;
    memset(dp,-1, sizeof dp);
    cout << fun(0, 0, 0) << '\n';
    return 0;
}


Measured memory_bytes: 592640
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
if max(x)>=min(y):
    print('War')
elif max(max(x),X)<min(min(y),Y):
    print('No War')
else:
    print('War')

Measured memory_bytes: 3060
// ConsoleApplication.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdio.h"
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <deque>

using namespace std;

struct Process {
	string name;
	int time;
};

void readProcess(Process& process)
{
	cin >> process.name;
	string time;
	cin >> time;
	process.time = stoi(time);
}

int main()
{
	int numberOfProceses;
	cin >> numberOfProceses;
	
	int processableTime;
	cin >> processableTime;
	
	deque<Process> procesQueue(numberOfProceses);
	for (auto& p : procesQueue)readProcess(p);

	//simulationStart
	int durationTime = 0;
	while (!procesQueue.empty()) {
		Process& process = procesQueue.front();
		int& processTime = process.time;
		const int processedTime = min(processTime, processableTime);
		processTime -= processedTime;
		durationTime += processedTime;

		if (processTime != 0) {
			procesQueue.push_back(process);
		}
		else {
			cout << process.name << " " << to_string(durationTime) << endl;
		}
		procesQueue.pop_front();
		
	}

	return 0;
}


Measured memory_bytes: 6004
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;
 

int main(){
    ll a,b;
    cin>>a>>b;
    for(int i=1;i<=b;i++){
        if((a*i)%b==0){
            cout<<a*i;
            break;
        }
    }
}

Measured memory_bytes: 256
def fragOptimalJump(h,n,k):
    dp=[0]*(n+1)
    dp[2]=abs(h[1]-h[2])
    for i in range(3,n+1):
        l=i-k
        if l<0:
            l=1
        min=10000000000
        for j in range(l,i):
            d=dp[j]+abs(h[i]-h[j])
            if d<min:
                min=d
            
        dp[i]=min
    return dp[n]



N,k=input().split()
N,k=int(N),int(k)
H=[0]*(N+1)
read = [int(n) for n in input().split()]
H=[0]+read
print(fragOptimalJump(H,N,k))


Measured memory_bytes: 15028
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = myconv(next(),1);
  var list = {};
  var max = 0;
  for(var i = 0; i < N; i++){
    var tmp = next();
    if(list[tmp] == null){
       list[tmp] = 1;
    }else{
       list[tmp]++;
    }
    max = Math.max(max, list[tmp]);
  }
  //myout(list);
  //myout(max);
  var keys = Object.keys(list);
  var output = [];
  for(var i = 0; i < keys.length; i++){
    if(list[keys[i]] == max){
       output.push(keys[i]);
    }
  }
  output.sort();
  myout(myconv(output,9));
}

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

typedef bitset<10000> bs;
int R, C;
inline int check(const vector<bs>& s) {
    int res = 0;
    rep(j, C) {
        int cnt = 0;
        rep(i, R) if(s[i][j]) cnt++;
        res += max(cnt, R - cnt);
    }
    return res;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> R >> C && R) {
        vector<bs> senbei(R, bs(0));
        bool in_;
        rep(i, R) rep(j, C) {
            cin >> in_;
            if(in_) senbei[i][j] = 1;
        }
        bs to_rev(0); rep(i, C) to_rev[i] = 1;
        vector<bs> temp;
        int ans = 0;
        rep(S, 1 << R) {
            temp = senbei;
            rep(i, R) if((S >> i) & 1)
              temp[i] ^= to_rev;
            ans = max(ans, check(temp));
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i,x,n) for(i=x;i<n;++i)
#define f(n) for(int i=0;i<n;++i)
#define fr(i,x,n) for(i=x;i>=n;--i)
#define endl '\n'

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

const int tam=100002;
ll n,C;
ll dis[tam];
ll nut[tam];
ll suf[tam];
ll pre[tam];
pair<ll,int> mx[tam];
pair<ll,int> mx2[tam];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>C;
    ll ans=0;
    ll ans2=0;
    int idx=0;
    f(n){
        cin>>dis[i+1]>>nut[i+1];
        pre[i+1]=pre[i]+nut[i+1]+dis[i]-dis[i+1];
        if(pre[i+1]>ans){
            ans=pre[i+1];
            idx=i+1;
        }
        mx[i+1]=pair<ll,int>(ans,idx);
        ans2=max(ans2,pre[i+1]);
    }

    dis[n+1]=C;
    int i;
    ans=0;
    idx=0;
    fr(i,n,1){
        suf[i]=suf[i+1]+nut[i]+(C-dis[i+1])-(C-dis[i]);
        if(suf[i]>ans){
            ans=suf[i];
            idx=i;
        }
        ans2=max(ans2,suf[i]);
        mx2[i]=pair<ll,int>(ans,idx);
    }
    int po1,po2;
    ll ans3=0;
   fr(i,n,1){
        pair<ll,int> res=mx[i-1];
        ll cost=res.ff+suf[i]-min(dis[res.ss],C-dis[i]);
        if(cost>ans2){
            ans2=cost;
            po1=i;
            po2=res.ss;
        }
        //ans2=max(ans2,cost);
    }
   ans3=max(ans3,ans2);
   ans2=0;
    fi(i,1,n+1){
        pair<ll,int> res=mx2[i+1];
        ll cost=res.ff+pre[i]-min(C-dis[res.ss],dis[i]);
        if(cost>ans2){
            ans2=cost;
            po1=i;
            po2=res.ss;
        }
        //ans2=max(ans2,cost);
    }
    ans3=max(ans3,ans2);
    cout<<ans3<<endl;
    return 0;
}


Measured memory_bytes: 6528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static long X, Y;

    public static void main(String[] args) {
        FastScanner fc = new FastScanner(System.in);
        X = fc.nextLong();
        Y = fc.nextLong();
        System.out.println(solve());
    }

    static int solve() {
        long curr = X;
        int ans = 1;
        while( true ) {
            if( curr*2 <= Y ) {
                curr*=2;
                ans++;
            } else {
                break;
            }
        }
        return ans;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 23380
#include<stdio.h>

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

int main(){
	int a,b,c;
	int m1,m2,m3;
	scanf("%d%d%d",&a,&b,&c);
	m1=max(a,(max(b,c)));
	m3=min(a,(max(b,c)));
	m2=a+b+c-m1-m3;
	if((m1-m2+m1-m3)%2==0)printf("%d\n",(m1-m2+m1-m3)/2);
	else printf("%d\n",(m1-m2+m1-m3+3)/2);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    int count_odd = 0;
    int count_ope = 0;

    while(count_odd == 0){
        for(int i = 0; i < n; i++){
            if(a[i] % 2 == 1){
                count_odd++;
            }
        }
        if(count_odd == 0){
            for(int i = 0; i < n; i++){
                a[i] = a[i] / 2;
            }
            count_ope++;
        }
    }
    printf("%d\n",count_ope);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define togglebit(n,i) ((n)^(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
int main(){
    fastread;
    ll n,i,j,k,l,m;
    cin>>n>>m;
    ll sum=0;
    for(i=1;i<=m;i++){
        cin>>k;
        sum+=k;
    }
    cout<<max(n-sum,-1LL);
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b;
    cin >> a >> b;
    if(a < b)
        cout << 0 << endl;
    else
        cout << a - b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#define llint long long
#define mod 1000000007

using namespace std;

llint A, B, C;
llint beki2[900005], beki3[900005];
llint dp[900005];

llint fact[900005], fact_inv[900005];
llint pow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (pow(a, n-1)%mod)) % mod;
	}
	else{
		return pow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < 900005; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	for(int i = 0; i < 900005; i++){
		fact_inv[i] = pow(fact[i], mod-2);
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

int main(void)
{
	cin >> A >> B >> C;
	if(B > C) swap(B, C);
	
	make_fact();
	
	llint mul = 1;
	for(int i = 0; i < 900005; i++){
		beki2[i] = mul;
		mul *= 2, mul %= mod;
	}
	mul = 1;
	for(int i = 0; i < 900005; i++){
		beki3[i] = mul;
		mul *= 3, mul %= mod;
	}
	
	for(int i = 0; i <= B; i++) dp[i] = beki2[i];
	for(int i = B; i < C; i++){
		dp[i+1] = (2 * dp[i] + mod - comb(i, B)) % mod;
		dp[i+1] %= mod;
	}
	for(int i = C; i < B+C; i++){
		dp[i+1] = (2 * dp[i] + 2 * mod - (comb(i, i-C) + comb(i, B))) % mod;
		dp[i+1] %= mod;
	}
	
	llint ans = 0, tmp;
	for(int i = 0; i <= B+C; i++){
		tmp = comb(A+i-1, i) * dp[i] % mod * beki3[B+C-i] % mod;
		ans += tmp, ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 35456
h,w = list(map(int,input().split()))

c = []
for i in range(10):
    c.append(list(map(int,input().split())))
a = []
for i in range(h):
    a.append(list(map(int,input().split())))

for i in range(10):
    for j in range(10):
        for k in range(10):
            c[j][k] = min(c[j][k],c[j][i]+c[i][k])

ans = 0

for i in a:
    for j in i:
        if j != -1:
            ans += c[j][1]
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define INF 2e9
#define MOD 1e9+7
#define ALL(v) v.begin(), v.end()

int ni() {
    int i;
    cin >> i;
    return i;
}

const int MAXN = 1e5;

int main() {
    ll countB[MAXN];
    ll countC[MAXN];

    int N = ni();
    vector<int> A, B, C;
    REP(i, N) A.push_back(ni());
    REP(i, N) B.push_back(ni());
    REP(i, N) C.push_back(ni());
    sort(ALL(A));
    sort(ALL(B));
    sort(ALL(C));

    REP(i, N) {
        countC[i] = N - (upper_bound(ALL(C), B[i]) - C.begin());
    }

    REPR(i, N-2) {
        countC[i] += countC[i+1];
    }

    REP(i, N) {
        int j = (upper_bound(ALL(B), A[i]) - B.begin());
        if (j < N) countB[i] = countC[j];
    }

    ll ans = 0;
    REP(i, N) {
        ans += countB[i];
    }

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

Measured memory_bytes: 3064
using AtCoderBeginnerContest127.Questions;
using AtCoderBeginnerContest127.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest127.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var ab = inputStream.ReadIntArray();
            var a = ab[0];
            var b = ab[1];

            if (a >= 13)
            {
                yield return b;
            }
            else if (a >= 6)
            {
                yield return b / 2;
            }
            else
            {
                yield return 0;
            }
        }
    }
}


namespace AtCoderBeginnerContest127
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest127.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest127.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include <iostream>
#include <cmath>
#include <iomanip>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#define ll long long
         
using namespace std;
     
long long gcd(int x, int y){
     if ( x == 0 ) return y;
     
     return gcd(y%x, x);
}
     
long long lcm(int x, int y){
     if ( y == 0 ){
          return x;
     }
     
     return x*y/gcd(x, y);
}
     
int min(int a, int b){
     return a > b ? b : a;
}
     
int max(int a, int b){
     return a > b ? a : b;
}

int main()
{
     cin.sync_with_stdio( false );

     int n;
     cin>>n;

     int a[n];
     map <int, int> m;
     for (int i=0;i<n;i++){
          cin>>a[i];
          m[a[i]]++;
     }

     for (int i=0;i<n;i++){
          if ( m[a[i]] >= 2 ){
               cout<<"NO"<<endl;
               return 0;
          }
     }

     cout<<"YES"<<endl;
}

Measured memory_bytes: 13784
/*
*/
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <cstring>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define PI 3.141592653589793
#define MOD 1000000007LL
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    ll N;
    ll x[100] = {};
    cin >> N;
    REP(i, N) cin >> x[i];
    
    int ans = INF;
    for (int i = 1; i <= 100; i++){
        int cost = 0;
        REP(j, N) cost += (x[j] - i) * (x[j] - i);
        ans = min(ans, cost);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define sec second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define FF fflush(stdout)
#define debug printf("Hello\n")
//why is my rating plummeting
int n, m, k, x, y, sum, cnt, ans, a[1000005], c[105][105];
int main () {
	scanf("%d %d", &n, &m);
	for (int i=0; i<=m+1; i++) c[0][i]=c[n+1][i]=3;
	for (int i=0; i<=n+1; i++) c[i][0]=c[i][m+1]=3;
	scanf("%d", &k);
	for (int i=1; i<=k; i++) scanf("%d", &a[i]);
	x=1;y=1;
	int cur=1, dir=0;
	for (int i=1; i<=n*m; i++) {
		c[x][y]=cur;
		cnt++;
		if (cnt==a[cur]) cur++, cnt=0;
		if (dir==0) {
			if (!c[x][y+1]) y++;
			else dir=1, x++;
		} else if (dir==1) {
			if (!c[x+1][y]) x++;
			else dir=2, y--;
		} else if (dir==2) {
			if (!c[x][y-1]) y--;
			else dir=3, x--;
		} else {
			if (!c[x-1][y]) x--;
			else dir=0, y++;
		}
		
	}
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=m; j++) {
			printf("%d%c", c[i][j], j==m?'\n':' ');
		}
	}
	return 0;
}

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

#define INF INT_MAX
#define MOD 1000000007

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

int main(){
    int n, k;
    cin >> n >> k;
    vi stones(n + 1);
    for(int i=1; i<=n; i++){
        cin >> stones[i];
    }
    vi dp(n+1, INF);
    dp[1] = 0;
    for(int i=2; i<=n; i++){
        for(int j=i-1; j>=max(1, i - k); j--){
            dp[i] = min(dp[i], dp[j] + abs(stones[j] - stones[i]));
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if(A>12) {
			System.out.println(B);
		}else {
			System.out.println(A>5 ? B/2:0);
		}
	}

}

Measured memory_bytes: 35668
#include<stdio.h>
#define MAX 10000
#define NIL -1

typedef struct {int parent, left, right; } Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right, d+1);
}

int setHeight(int u){
  int h1 = 0, h2 = 0;
  if(T[u].left != NIL )
    h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL )
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
    return T[T[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if(T[u].left != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if(T[u].parent == NIL){
    printf("root\n");
  }
  else if (T[u].left == NIL && T[u].right == NIL){
    printf("leaf\n");
  }
  else {
    printf("internal node\n");
  }
}

int main(){
  int i, v, l, r, root = 0;
  scanf("%d", &n);

  for(i = 0;i<n;i++) T[i].parent = NIL;

  for(i = 0;i<n;i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }

  for(i = 0;i<n;i++) if(T[i].parent == NIL) root = i;

  setDepth(root,0);
  setHeight(root);

  for(i = 0; i<n; i++)print(i);

  return 0;
}

  



Measured memory_bytes: 2108
from collections import namedtuple
C = namedtuple("C", "m v")


def bubble_sort(A0):
    A = A0.copy()
    for i in range(n - 1):
        for j in range(n - 1, i, -1):
            if A[j].v < A[j - 1].v:
                A[j], A[j - 1] = A[j - 1], A[j]
    return A, True


def selection_sort(A0):
    A = A0.copy()
    for i in range(n - 1):
        k = i
        for j in range(i + 1, n):
            if A[k].v > A[j].v:
                k = j
        if k != i:
            A[k], A[i] = A[i], A[k]
    return A


lst = ["Not stable", "Stable"]
n = int(input())
A = [C(x[0], x[1]) for x in input().split()]

B, j = bubble_sort(A)
print(*[(B[i].m + B[i].v) for i in range(n)])
print(lst[j])

S = selection_sort(A)
print(*[(S[i].m + S[i].v) for i in range(n)])
print(lst[B == S])



Measured memory_bytes: 6048
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int c[n];
    int v[n];
    int ans=0;
    for(int i=0;i<n;i++)cin >> v[i];
    for(int i=0;i<n;i++)cin >> c[i];
    for(int i=0;i<n;i++)if(v[i]-c[i]>0)ans+=(v[i]-c[i]);
    cout << ans << endl;
}

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////


//long long  Prime[3000000],nPrime;
//long long  mark[10000002];
//
//void seive(long long int n)
//{
//	long long int i,j,limit=sqrt(n*1.0)+2;
//	mark[1]=1;
//	for(i=4; i<=n ;i+=2)
//	mark[i]=1;
//	Prime[nPrime++]=2;
//	for(i=3; i<=n; i+=2)
//	{
//		if(!mark[i])
//		{
//			Prime[nPrime++]=i;
//			if(i<=limit)
//			{
//				for(j=i*i; j<=n ;j+=i*2)
//				{
//					mark[j]=1;
//				}
//			}
//		}
//	}
//}

int main()
{
    FASTIO;

    int a[10];

    int pos = 0;



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

        if(a[i]==0)
        {
            pos = i+1;
        }
    }

    cout << pos << endl;





    return 0;
}


Measured memory_bytes: 3652
N,K = map(int, input().split())
A = list(map(int, input().split()))
def bubble_sort(A):
    cnt = 0
    for i in range(len(A)):
        for j in range(len(A)-1, i, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                cnt += 1
    return cnt
cnt_A = bubble_sort(A)
A_min=0
for i in range(len(A)):
  l_odd = [k for k in A if k<A[i]]
  A_min += len(l_odd)
result = int((cnt_A*K + A_min*(K-1)*K//2)%((10**9)+7))
print(result)

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int MAX_N = 1e2 + 5;
bool used[MAX_N], match[MAX_N][MAX_N];
int girl[MAX_N];
int x[105],y[105];
bool fnd(int x,int n) {
    for(int j=1;j<=n;j++) {
        if(match[x][j]&&!used[j]){
            used[j]=true;
            if(girl[j]==0||fnd(girl[j],n)){
                girl[j]=x;
                return true;
            }
        }
    }
    return false;
}
int solve(int m,int n){
    int ans=0;
    for(int i=1;i<=m;i++) {
        memset(used,false,sizeof(used));
        if(fnd(i,n))ans++;
    }
    return ans;
}
int main() {
    int n,a,b;
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>x[i]>>y[i];
    }
    for (int i=1;i<=n;i++){
        cin>>a>>b;
        for (int j=1;j<=n;j++){
            if(x[j]<a&&y[j]<b){//找关系满足的 
            	match[j][i]=true;
			}
        }
    }
    cout<<solve(n,n)<<endl;//匈牙利算法直接跑 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    vi a(3);
    rep(i,3) cin >> a.at(i);
    sort(a.begin(), a.end());
    cout << a.at(2) - a.at(0) << endl;
}


Measured memory_bytes: 256
def main():
    N, A, B = map( int, input().split())
    if (B-A)%2 == 0:
        print((B-A)//2)
    else:
        print( min( A+(B-A-1)//2, N+1-B+(B-A-1)//2))
if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n = int(input())
x = []
y= []
for i in range(n):
    xi,yi = map(int, input().split( ))
    x.append(xi)
    y.append(yi)
sm = 0
ans = 0
for i in range(n):
    for j in range(i+1,n):
        ans += ((x[i]-x[j])**2 + (y[i]-y[j])**2)**(1/2)
ans/=n
ans*=2
print(ans)

Measured memory_bytes: 38384
import math

a,b,x = map(int,input().split())

if x == a**2 * b:
    print(0)
    exit()

if x <= a*a*b/2:
    S = x/a
    f = 2*S/b
    print(math.degrees(math.atan(b/f)))
else:
    S = a*b- x/a
    f = 2*S/a
    print(90-math.degrees(math.atan(a/f)))

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

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

		List<Integer> list1 = new ArrayList<>();

		for (int i = 0; i < M; i++) {
			int X = sc.nextInt();
			list1.add(X);
		}

		list1.sort(null);

		List<Integer> list2 = new ArrayList<>();
		int sum = 0;
		for (int i = 0; i < list1.size() - 1; i++) {
			int sub = list1.get(i + 1) - list1.get(i);
			sum += sub;
			list2.add(sub);
		}

		list2.sort(null);

		int sumMax = 0;
		for (int i = 1; i < N; i++) {
			if (list2.size() - i < 0) {
				break;
			}
			sumMax += list2.get(list2.size() - i);
		}

		System.out.println(sum - sumMax);

		sc.close();
	}



}




Measured memory_bytes: 60960
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=1 ; i<=(n) ; ++i)
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <ll, ll> P;

// int main(){
//   int n;
//   cin >> n;
//   //vector<int> a;
//   ll a[n];
//   rep(i,n){
//     cin >> a[i];
//   }
//   ll sum[n], sub[n];
//   ll min_sum=1000000000 ,max_sub=-1000000000;
//   rep(i,n){
//
//     sum[i] = i + a[i];
//     sub[i] = i - a[i];
//     min_sum = min(min_sum, sum[i]);
//     max_sub = max(max_sub, sub[i]);
//   }
//   ll ans = 0;
//   for(int i=min_sum; i<max_sub; i++){
//     ans += ()
//   }
//   //cout << a[0] << endl;
//   //cout << endl;
//   return 0;
// }

map<ll, ll> a;
ll b[200005]={0};
int main(){
  ll n;
  cin >> n;
  rep(i,n){
    cin >> b[i];
    a[b[i]+i]++;
  }
  ll cnt=0;
  rep(i,n){
    cnt += a[i-b[i]];
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 27736