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

int main()
{
    int x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << x2 - (y2 - y1) << " " << y2 + (x2 - x1) << " " << x1 - (y2 - y1) << " " << y1 + (x2 - x1) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val a = (1..n).map { sc.nextInt() }

  if (n == 1) {
    println(1)
    return
  }

  var count = 1
  var pre = a[0]
  var tmp = 0
  for (i in 1 until n) {
    val ai = a[i]
    if (pre < ai) {
      if (tmp == 0) {
        tmp = 1
      } else if (tmp == -1) {
        count++
        tmp = 0
      }
    } else if (pre > ai) {
      if (tmp == 0) {
        tmp = -1
      } else if (tmp == 1) {
        count++
        tmp = 0
      }
    }
    pre = ai
  }

  println(count)


}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

template <typename T> T gcd(T a, T b) {
    if (b == 0)
        return a;

    return gcd(b, a % b);
}

template <typename T> T lcm(T a, T b) {
    return (a * b) / gcd(a, b);
}

void solve() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double hour_angle = 0.0, min_angle;
    bool stop = false;
    for (double hour = 0.0; hour < 12.0; hour++) {
        min_angle = 0.0;
        for (double min = 0.0; min < 60.0; min++) {
            if (hour == h && min == m) {
                stop = true;
                break;
            }
            hour_angle += 0.5;
            min_angle += 6.0;
        }
        if (stop) break;
    }

    double angle = abs(hour_angle - min_angle);
    if (180.0 < angle) angle = 360.0 - angle;
    
    double radian = angle * M_PI / 180.0000;
    double ans = sqrt(pow(a, 2.0)+pow(b, 2.0)-2.0*a*b*cos(radian));
    cout << fixed << setprecision(15) << ans <<endl;
}

int main() {
    solve();

    return 0;
}


Measured memory_bytes: 4056
def d_People_on_a_Line(N, M, P):
    if M == 0:
        return 'Yes'

    adj = [[] for _ in range(N)]  # 隣接リスト
    for l, r, d in P:
        adj[l - 1].append([r - 1, d])
        adj[r - 1].append([l - 1, -d])

    dist = [None for _ in range(N)]
    for i in range(N):  # グラフが非連結なこともあるので、全頂点を始点として試す
        if dist[i] is not None:
            # 値が決定済み
            continue
        stack = [i]
        dist[i] = 0  # 始点の距離は0
        while stack:
            v = stack.pop()  # 訪れる頂点
            for to, cost in adj[v]:
                if dist[to] is None:
                    # 頂点toが未決定なら、そこを次に訪れる頂点とする
                    stack.append(to)
                    dist[to] = dist[v] + cost
                elif dist[to] != dist[v] + cost:
                    # 値が決定済みの頂点に合流し、
                    # 与えられた情報と矛盾した
                    return 'No'
    return 'Yes'  # 全頂点で矛盾しなかった

N,M = [int(i) for i in input().split()]
P = [[int(i) for i in input().split()] for j in range(M)]
print(d_People_on_a_Line(N, M, P))

Measured memory_bytes: 113116
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#define PI 3.1415926535
using namespace std;

int main(void){
	double a2, avg;
	int n, s[1001]={0}, sum;
	while(1){
		sum=0;
		a2=0.0;
		cin >>n;
		if(n==0){
			break;
		}
		for(int i=0; i<n; i++){
			cin >>s[i];
			sum+=s[i];
		}
		avg=(double)sum/n;
		for(int i=0; i<n; i++){
			a2+=pow(s[i]-avg, 2);
		}
		a2=sqrt(a2/n);
		cout <<fixed <<setprecision(10) <<a2 <<endl;
	}
    return 0;
}

Measured memory_bytes: 1240
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
	string s, t;
	int i, j;
	char tmp;
	
	cin >> s >> t;

	for(i = 0; i < s.size() - 1; i++){
		for(j = i + 1; j < s.size(); j++){
			if(s[i] > s[j]){
				tmp = s[j];
				s[j] = s[i];
				s[i] = tmp;
			}
		}
	}
	for(i = 0; i < t.size() - 1; i++){
		for(j = i + 1; j < t.size(); j++){
			if(t[i] < t[j]){
				tmp = t[j];
				t[j] = t[i];
				t[i] = tmp;
			}
		}
	}

	for(i = 0; i < min(s.size(), t.size()); i++){
		if(s[i] < t[i]){
			cout << "Yes" << endl;
			return 0;
		}
		else if(s[i] > t[i]){
			cout << "No" << endl;
			return 0;
		}
	}

	if(s.size() < t.size()){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

int main(){
    int x, y, z;
    cin >> x >> y >> z;

    if(x < y){
        cout << 0 << endl;
        return 0;
    }

    int cnt = 0;
    while(y * cnt + z * (cnt+1) <= x) cnt++;

    cout << cnt-1 << endl;
}

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

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

    int m[n+10];
    int sum = 0;
    int mini = 1000000;
    for (int i=0; i<n; ++i) {
        cin >> m[i];
        sum += m[i];
        mini = min(m[i], mini);
    }

    int exval = x - sum;

    cout << exval/mini+n << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        Map<Long, Map<Long, int[]>> map = new HashMap<>();
        map.put(0L, new HashMap<>());
        map.get(0L).put(0L, new int[2]);
        int zero = 0;
        for (int i = 0; i < N; i++) {
            long x = in.nextLong();
            long y = in.nextLong();
            long gcd = gcd(Math.abs(x), Math.abs(y));
            if (gcd > 1) {
                x /= gcd;
                y /= gcd;
            }

            if (x == 0 && y == 0) {
                zero++;
            } else if (x == 0) {
                map.get(0L).get(0L)[0]++;
            } else if (y == 0) {
                map.get(0L).get(0L)[1]++;
            } else if (map.containsKey(y) && map.get(y).containsKey(-x)) {
                map.get(y).get(-x)[1]++;
            } else if (map.containsKey(-y) && map.get(-y).containsKey(x)) {
                map.get(-y).get(x)[1]++;
            } else if (map.containsKey(x) && map.get(x).containsKey(y)) {
                map.get(x).get(y)[0]++;
            } else if (map.containsKey(-x) && map.get(-x).containsKey(-y)) {
                map.get(-x).get(-y)[0]++;
            } else {
                map.computeIfAbsent(x, m -> new HashMap<>()).put(y, new int[]{1, 0});
            }
        }
        long l = zero + map.values().stream().flatMap(m -> m.values().stream()).mapToLong(i -> (pow(i[0]) + pow(i[1]) - 1) % 1000000007).reduce(1, (a, b) -> a * b % 1000000007) - 1;
        System.out.println((l + 1000000007) % 1000000007);
    }

    static long gcd(long x, long y) {
        if (x == 0) return y;
        if (y == 0) return x;

        if ((x & 1) == 0 && (y & 1) == 0) {
            return gcd(x >> 1, y >> 1) << 1;
        } else if ((x & 1) == 0) {
            return gcd(x >> 1, y);
        } else if ((y & 1) == 0) {
            return gcd(x, y >> 1);
        } else {
            return gcd(Math.abs(x - y), Math.min(x, y));
        }
    }

    static long pow(int i) {
        if (i == 0) {
            return 1;
        } else if ((i & 1) == 1) {
            return pow(i-1) * 2 % 1000000007;
        } else {
            long p = pow(i >> 1);
            return (p * p) % 1000000007;
        }
    }
}


Measured memory_bytes: 130620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#define INF 1000000000
using namespace std;

int main() {

	int k, x; cin >> k >> x;
	x -= (k - 1);
	for (int i = 0; i < (k * 2 - 1); i++) {
		cout << x + i;
		if (i != (k * 2 - 2)) { cout << " "; }
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b;
    char op;
    cin >> a >> op >> b;
    if(op == '+'){
        cout << a + b << endl; 
    }
    else if ( op == '-'){
        cout << a - b << endl;
    }
    
}


Measured memory_bytes: 3608
N, M, K = map(int, input().split())
mod = 10**9 + 7

# N行, M列 i-j
# 1-1, 1-2, 1-3, 1-4, ... , 1-M
# 2-1, 2-2, 2-3, 2-4, ... , 2-M
# 3-1. 3-2. 3-3, 3-4, ... , 3-M
# ...
# N-1, N-2, N-3, N-4, ... , N-M

# K個の駒が上記の座表上に置かれた時の配置全種類のコストの総和を調べたい

factorial = [1 for i in range(N*M + 1)]
for i in range(1, N * M + 1):
	if i==1:
		factorial[i] = 1
	else:
		factorial[i] = factorial[i-1]*i % mod

def comb(n, k):
	return (factorial[n]*pow(factorial[n-k]*factorial[k], -1, mod)) % mod

xscore = 0
for i in range(1, N):
	xscore += i * (N-i)
xscore %= mod
xscore *= M**2 * comb(N*M-2, K-2)
xscore %= mod

yscore = 0
for i in range(1, M):
	yscore += i * (M-i)
yscore %= mod
yscore *= N**2 * comb(N*M-2, K-2)
yscore %= mod

print((xscore + yscore) % mod)


Measured memory_bytes: 16832
#include <stdio.h>
#include <string.h>

int main(void) {

  char s[1001];
  scanf("%s", s);
  int len = strlen(s);
  printf("%s", s);
  if (s[len-1] == 's') {
    printf("e");
  }
  printf("s\n");

  return 0;
}

Measured memory_bytes: 1680
// union find木の実装
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A&lang=jp

#include<iostream>
#include<string>
using namespace std;
const int MAX_N = 100000;
int parent[MAX_N+1];
int trank[MAX_N+1];
int n, q;
int command, x, y;


int root(int x){
  if (parent[x] == x){
    return x;
  }else{
    // 経路圧縮を行う
    int update = root(parent[x]);
    parent[x] = update;
    return update;
  }
}

void unite(int x, int y){
  int tree_x = root(x);
  int tree_y = root(y);
  if (tree_x == tree_y){return;}
  else{
    if (trank[tree_x] >= trank[tree_y]) {
      parent[tree_y] = parent[tree_x];
      trank[tree_x] = max(trank[tree_x], trank[tree_y] + 1);
    }
    else{
      parent[tree_x] = parent[tree_y];
      trank[tree_y] = max(trank[tree_x] + 1, trank[tree_y]);
    }
  }
}

int get_rank(int x){
  return trank[root(x)];
}

bool same(int x, int y){
  return root(x) == root(y);
}

void dump_set(int n){
  cout << "==== Dump ====" << endl;

  cout << "Set:\t";
  for (int i = 1; i <= n; i++){
    cout << i << " ";
  }
  cout << endl;

  cout << "Par:\t";
  for (int i = 1; i <= n; i++){
    cout << parent[i] << " ";
  }
  cout << endl;

  cout << "trank:\t";
  for (int i = 1; i <= n; i++){
    cout << trank[i] << " ";
  }
  cout << endl;
}

int main() {
  cin >> n >> q;
  for(int i = 1; i <= n; i++){
    parent[i] = i;
    trank[i] = 1;
  }

  for(int i = 0; i < q; i ++ ){
    cin >> command >> x >> y;
    if( command == 0 ){
      unite(x, y);
    }
    else if( command == 1 ){
      if (same(x, y)){
        cout << 1 << endl;
      }else{
        cout << 0 << endl;
      }
    }
    //dump_set(n);
  }
  return 0;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
using P=pair<int,int>;

int i,j,k;

struct UnionFind {
    vector<int> rank, parents;
    UnionFind(){}
    UnionFind(int n){
        rank.resize(n,0);
        parents.resize(n,0);
        for(i=0;i<n;i++){makeTree(i);}
    }
    void makeTree(int x){
        parents[x]=x;
        rank[x]=0;
    }
 
    bool isSame(int x,int y){return findRoot(x)==findRoot(y);}
 
    bool unite(int x, int y){
        x = findRoot(x);
        y = findRoot(y);
        if(x==y) return false;

        if(rank[x]>rank[y]){parents[y] = x;}
        else{
            parents[x] = y;
            if(rank[x]==rank[y]){rank[y]++;}
        }
        return true;
    }
    
    int findRoot(int x){
        if(x!=parents[x]){
            parents[x]=findRoot(parents[x]);
        }
        return parents[x];
    }
};

int main(){
    int n,k,l;cin>>n>>k>>l;//n:都市数　k:道路数　l:鉄道数
    
    UnionFind road(n),train(n);

    for(i=0;i<k;i++){//roadについて
        int p,q;cin>>p>>q;
        p--;q--;
        road.unite(p,q);
    }

    for(i=0;i<l;i++){//trainについて
        int r,s;cin>>r>>s;
        r--;s--;
        train.unite(r,s);
    }

    map<P,int> relate;
    P p;
    for(i=0;i<n;i++){
        relate[make_pair(road.findRoot(i),train.findRoot(i))]++;
        //i番のroadとtrainそれぞれの根のペアに加算する
        //->roadとtrainのrootが同じ(つながっている状態)であれば、このペアは一致するので答えになる
    }

    for(i=0;i<n;i++){
        cout<<relate[make_pair(road.findRoot(i),train.findRoot(i))]<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 15104
def euclidean(a,b):
    if b == 0:
        return a
    else:
        return euclidean(b,a%b)

if __name__ == '__main__':
    n = int(input())
    num_list = [int(input()) for _ in range(n)]
    a = num_list[0]

    for idx in range(1,len(num_list)):
        b = euclidean(a,num_list[idx])
        a = a*num_list[idx]//b
    print(a)


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

int main(){
    int a, b; cin >> a >> b;
    string A = "", B = "";
    for (int i = 0; i < b; i++)
    {
        A += to_string(a);
    }
    for (int i = 0; i < a; i++)
    {
        B += to_string(b);
    }
    
    if(B >= A) cout << A << endl;
    else cout << B << endl;
    

    return 0;
}

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

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx")

#define fi first
#define se second

using namespace std;

using ll=long long;
using ld=long double;

int main()
{
    int n;
    scanf("%d",&n);
    vector<int> h(n);
    for(auto &i:h)
        scanf("%d",&i);
    vector<int> dp(n);
    dp[0]=0,dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;++i)
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    printf("%d\n",dp[n-1]);
}



Measured memory_bytes: 1024
n, a, b = map(int, input().split())
x = list(map(int, input().split()))

ans = 0

for i in range(n-1):
	if (x[i+1] - x[i]) * a <= b:
		ans += (x[i+1] - x[i]) * a
	else:
		ans += b

print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define M 1000000007
#define pb push_back
#define ll long long int
using namespace std;

int main()
{
	int n,W;
	cin>>n>>W;
	int i,j;
	int w[n],v[n];
	int val = 0;
	for(i=0;i<n;i++)
	{
		cin>>w[i]>>v[i];
		val += v[i];
	}	

	ll dp[n][val+1];
	for(i=0;i<n;i++)
	{
		for(j=0;j<=val;j++)
		{
			if(i==0)
			{
				if(v[i]==j)
				{
					dp[i][j] = w[i];
				}
				else
					dp[i][j] = 0;
				continue;
			}
			dp[i][j] = dp[i-1][j];
			if((v[i]<j && dp[i-1][j-v[i]]!=0)||v[i]==j)
			{
				if(dp[i-1][j]==0)
					dp[i][j] = w[i]+dp[i-1][j-v[i]];
				else
					dp[i][j] = min(dp[i-1][j],w[i]+dp[i-1][j-v[i]]);
			}
		}
	}

	for(i=val;i>=0;i--)
	{
		if(dp[n-1][i]!=0 && dp[n-1][i]<=W)
		{
			cout<<i<<"\n";
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 81696
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string> 
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vl a(n);
	rep(i, n)cin >> a[i];
	sort(all(a));
	vl sum(n + 1, 0);
	rep(i, n + 1)sum[i] = i == 0 ? 0 : sum[i - 1] + a[i - 1];
	int l = -1, r = n;
	while (l + 1 < r)
	{
		int mid = (l + r) / 2;
		bool eat_all = true;
		mrep(i, mid + 1, n)
		{
			if (sum[i] * 2 < a[i])eat_all = false;
		}
		if (eat_all)r = mid;
		else l = mid;
	}
	co(n - r);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define speed                   \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define oprecision    \
  cout.precision(30); \
  cerr.precision(7);
#define ll long long
#define ld long double
#define ss string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define forn(n) for (int i = 1; i <= n; i++)
#define forlr(l, r) \
  for (int i = l; (l > r ? i >= r : i <= r); (l > r ? i-- : i++))
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)
#define pc(x) __builtin_popcount(x)
#define pcll(x) __builtin_popcountll(x)
#define mp(x, y) make_pair(x, y)
#define F first
#define S second
using namespace std;
ss s;
ll cur;
int main() {
  speed;
  oprecision;
  // code
  cin >> s;
  while (sz(s)) cur += s.back() - '0', s.pop_back();
  cout << (!(cur % 9) ? "Yes\n" : "No\n");
  // endl
#ifndef ONLINE_JUDGE
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

signed main(){
    int X, Y;
    cin >> X >> Y;
    REP(i, 100){
        REP(j, 100){
            if(i + j == X && i * 2 + j * 4 == Y){
                PRINT("Yes");
                return 0;
            }
        }
    }
    PRINT("No");
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;

int n;
int a[100];

ll dp[100][21];

ll rec(int i, int j) {
    if (j < 0 || j > 20) {
        return 0;
    }

    if (dp[i][j] >= 0) {
        return dp[i][j];
    }
    
    ll res;

    if (i == n - 2) {
        res = j == a[n - 1] ? 1LL : 0LL;
    } else {
        res = rec(i + 1, j - a[i + 1]) + rec(i + 1, j + a[i + 1]);
    }

    return dp[i][j] = res;
}

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

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

    memset(dp, -1, sizeof(dp));

    printf("%lld\n", rec(0, a[0]));
}

Measured memory_bytes: 1052
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

public class Main { 
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N = Integer.parseInt(sc.next());
      List<String> list = new ArrayList<String>();
      for(int i = 0; i < N; i++){
        list.add(sc.next());
      }
      List<String> L = new ArrayList<String>(new HashSet<>(list));
      System.out.println(L.size());
    }
}


Measured memory_bytes: 73632
#include<stdio.h>
  
int A[100][100];
  
int main(void){
  int i,j,k,l,n,u;
  
  scanf("%d",&n);
    
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&l);
    for(j=0;j<l;j++){
      scanf("%d",&k);
      A[i][k-1]=1;
    }
  }
    
  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
      printf("%d ",A[i][j]);
    }
      printf("%d\n",A[i][j]);
  }
  return 0;
}

Measured memory_bytes: 632
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    long long x;
    cin >> x;
    long long bank = 100;
    for (int i = 0; i < 10000000; i++)

    {
        if (bank >= x)
        {
            cout << i << endl;
            break;
        }
        bank += bank * 0.01;
    }
}

Measured memory_bytes: 3636
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
map<char,int>mp;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<4;i++)
	{
		mp[s[i]]++;
	}
	if(mp[s[0]]==2 && mp[s[1]]==2 && mp[s[2]]==2 && mp[s[3]]==2)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 764
package main

import (
	"fmt"
	"log"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	h := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}
	for i := 0; i < n-1; i++ {
		if h[i] >= h[i+1] {
			if i > 0 && h[i] == h[i-1] {
				continue
			}
			h[i]--
		}
	}
	for i := 0; i < n-1; i++ {
		if h[i] > h[i+1] {
			fmt.Println("No")
			return
		}
	}
	log.Println(h)
	fmt.Println("Yes")
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var inf = int(1e9)

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 7808
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

int main() {
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;
  if (x + r > w || x - r < 0)
    cout << "No" << endl;
  else if (y + r > h || y - r < 0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}



Measured memory_bytes: 3108
x = input().split()
a = int(x[0])
b = int(x[1])
c = int(x[2])
d = int(x[3])
l = sorted([a, b, c], reverse=True)
a_c = a - c
if a_c < 0:
  a_c = a_c*-1
if a_c <= d or ((l[0]-l[1] <= d) and (l[1]-l[2] <= d)):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
N = int(input())
A = [int(input()) for i in range(N)]
odd = 0
for i in range(len(A)) :
    a = A[i]
    if a % 2 != 0 :
        odd += 1
        break
if odd == 1 :
    print("first")
else :
    print("second")
    

Measured memory_bytes: 7072
import java.io.PrintWriter
import kotlin.math.pow

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun Int.pow(n: Int) = pow(n.toLong())
fun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()
fun Long.pow(n: Int) = pow(n.toLong())
fun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val O = next()
    val E = next()
    for (i in E.indices) {
        print(O[i])
        print(E[i])
    }
    if (O.length > E.length) {
        print(O.last())
    }
    println()
}

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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義(使うときはINFも書き換えろ!!)
#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  int a,b;cin >> a >> b;
  cout << a*b/gcd(a,b) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
vector<int> E[maxn], path;
int siz[maxn], fa[maxn]; 
bool dfs(int x)
{
	siz[x] = 1;
	for(auto v : E[x])
		if(v != fa[x])
		{
			fa[v] = x;
			dfs(v);
			siz[x] += siz[v];
		} 
}
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i < n; ++i)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		E[u].push_back(v);
		E[v].push_back(u);
	}
	dfs(1);
	int u = n;
	while(u)
	{
		path.push_back(u);
		u = fa[u];
	}
	reverse(path.begin(), path.end());
	int s = siz[path[(path.size() + 1) >> 1]];
	if(n - s <= s) puts("Snuke");
	else puts("Fennec");
	return 0;
}

Measured memory_bytes: 11772
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, A[212345];

int main() {

	cin >> N;
	rep(i, N) cin >> A[i];

	sort(A, A + N, greater<>());

	ll ans = 0;

	rep(i, N - 1) {
		ans += A[(i + 1) / 2];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4456
#include <stdio.h>

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

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

Measured memory_bytes: 128
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto x = readln.chomp.split.to!(int[]);
  
  writeln(x[0]-1+(x[0]<=x[1]));
}


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

typedef long long ll;
typedef long double ld;

using namespace std;

void INeedIt() {
	ios_base::sync_with_stdio(0);
    cin.tie(0);		
    cout.tie(0);
}
int main() {
	INeedIt();
	int n;
	cin>>n;
	for (int i=1;i<=9;i++) {
		for (int j=1;j<=9;j++) {
			if (i*j == n) {
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e5+10;
const int MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];
int coun(int x){
	return __builtin_popcount(x);
}
int dp[(1<<21)+1];
int main() 
{ 
	//ios_base::sync_with_stdio(false);
  //  cin.tie(NULL);	
//	#ifndef ONLINE_JUDGE
//	freopen("inp.txt" ,"r", stdin );
//	freopen("out.txt", "w", stdout);
//	#endif
	int n;
	cin>>n;
	
	memset(dp , 0 , sizeof(dp));
	dp[0]=1;
	int mat[n+1][n+1];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++){
			cin>>mat[i][j];
		}
	for(int mask=0;mask<(1<<n);mask++){
		int a=coun(mask);
		for(int i=0;i<n;i++){
			if(mat[a][i]&&(!(mask&(1<<i)))){
				dp[mask^(1<<i)]=(dp[mask^(1<<i)]+dp[mask])%MOD;
			}
		}
	}
	cout<<dp[(1<<n)-1];
	
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


vector<ll> divisor(ll n) {
	vector<ll> ret;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return (ret);
}

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

int main() {

	ll n, kk;
	cin >> n >> kk;

	VLL a(n);

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

	ll sum = 0;
	REP(i, n) sum += a[i];

	int i = 1;

	VLL b = divisor(sum);

	int m = b.size();

	sort(ALL(b));
	reverse(ALL(b));

	ll ans = 0;


	
	
	REP(i, m) {
		VLL v(n);
		REP(j, n) {
			v[j] = a[j] % b[i];
		}
		ll c = 0;
		sort(ALL(v));

		ll k = n - 1;
		ll l = 0;
		ll o = 0;
		ll p = 0;
		while (k >= l) {
			if (o < 0) {
				o += v[l];
				p += v[l];
				l++;
			}
			else {
				o -= b[i] - v[k];
				k--;
			}
		}
		if (p > kk) {
			continue;
		}
		if (p <= kk && o==0) {
			cout << b[i] << endl;
			return 0;
		}
	}
	
	ans = a[0];
	FOR(i, 1, n)ans = gcd(ans, a[i]);

	cout << ans << endl;
	

	
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
using namespace std;
const int INF = 1 << 30;
int c[1001], w[1001], W[1001];
bool can[1001][1001];
int dp[1001];
int main() {
	int N;
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		scanf("%d %d", &c[i], &w[i]);
		W[i] = W[i - 1] + w[i];
		can[i][i] = 1;
	}
	for (int len = 2; len <= N; len++) {
		for (int i = 1; i + len <= N+1; i++) {
			if (can[i + 1][i + len - 1] && (W[i + len - 1] - W[i]) <= c[i]) can[i][i+len-1] = 1;
			if (can[i][i + len - 2] && (W[i + len - 2] - W[i - 1]) <= c[i + len - 1]) can[i][i + len - 1] = 1;
			can[i + len - 1][i] = can[i][i + len - 1];
		}
	}
	fill(dp, dp + (N + 1), INF);
	dp[0] = 0;
	dp[1] = 1;
	for (int i = 2; i <= N; i++) {
		for (int j = 0; j < i; j++) {
			if (can[j + 1][i]) dp[i] = min(dp[i], dp[j] + 1);
		}
	}
	printf("%d\n", dp[N]);
}

Measured memory_bytes: 2016
package main

import (
	"bufio"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	xs := make([]int, n+1)
	for i := 1; i < n; i++ {
		a := scanInt()
		xs[a]++
	}

	var wr = bufio.NewWriter(os.Stdout)
	for i := 1; i <= n; i++ {
		wr.WriteString(strconv.Itoa(xs[i]) + "\n")
	}
	wr.Flush()
}


Measured memory_bytes: 4424
/*
   Creator - Glitched
   Yeet!!
*/
#include "bits/stdc++.h"
using namespace std;

#define testcases ll T;cin>>T;while(T--)
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)

int main()
{
  ll n,x;
  cin>>x>>n;
  vector<ll> v(n);
  loop(i,0,n)
    cin>>v[i];
  ll ans;
  sort(v.begin(), v.end());
  loop(i,0,1000){
    ll a= x-i, b = x+i;
    if(!binary_search(v.begin(), v.end(),a)){
      ans = a;
      break;
    }
    if(!binary_search(v.begin(), v.end(),b)){
      ans = b;
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {
	int n, k;
	cin >> n >> k;
	ll sum = 0;
	rep1n(i, n) {
		sum += (n / i)*max(0, (i - k));
		sum += max(0, n%i - max(0, (k - 1)));
	}
	cout << sum << endl;

	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int main(){
    ll n,k; cin >> n >> k;
    vl a(n); rep(i,n) cin >> a[i], a[i]--;
    ll now = 0;
    vl b(n);
    while(k){
        if(k & 1) now = a[now];
        rep(i,n) b[i] = a[a[i]];
        k >>= 1;
        swap(a,b);
    }
    cout << now + 1 << endl;
}

Measured memory_bytes: 6428
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
 
***********************IN COLABRATION WITH -----AJrockstar   :)*********************
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
 
using namespace std;
using namespace __gnu_pbds;
 
//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
//template<typename T> using MinPriorityQueue = priority_queue <T, vector <T>, greater <T>>;
 
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;
 
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define loop(x,n) for(ll x = 0; x < n; x++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
const ll LINF = LLONG_MAX, SZ = 1e3, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 21;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1e-6;
//mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
 
 
 
 
 ll w=1000000;
 ll isPrime[1000000+1];
int main() {
	
    fast_io();
    ll i,j,t,n,p,k,q,o,ca=0,cb=0,x,y,c,s;
    
    
    cin>>n;
    
    ll a[n],dp[n+1];
    for(j=0;j<n;j++)
    {
    	cin>>a[j];	
    }
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    
    for(i=2;i<n;i++)
    {
    	//p=dp[i-1]+abs(a[i]-a[i-1]);
    	//for(j=i-2;j>=i-k&&j>=0;j--)
    	{
    		dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
		}
		//cout<<p<<" ";
		//dp[i]=p;
	}
	
	cout<<dp[n-1];
    
    return 0;
}
 
 

Measured memory_bytes: 5144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while(true) {
			int m = scanner.nextInt();
			int f = scanner.nextInt();
			int r = scanner.nextInt();
			if (m==-1&&f==-1&&r==-1) {
				break;
			}
			if(m==-1||f==-1) {
				System.out.println("F");continue;
			}
			if (m+f>=80) {
				System.out.println("A");
			}else if(m+f>=65) {
				System.out.println("B");
			}else if(m+f>=50) {
				System.out.println("C");
			}else if(m+f>=30){
				if (r>=50) {
					System.out.println("C");
				}else {
					System.out.println("D");
				}
			}else {
				System.out.println("F");
			}
		}
		scanner.close();
	}
}


Measured memory_bytes: 26256
n = int(input())
a = [int(e) for e in input().split()]
b = [int(e) for e in input().split()]
result = 0
for i in range(n):
  if a[i] > b[i]:
    result += b[i]
    a[i] -= b[i]
    b[i] = 0
  else:
    result += a[i]
    b[i] -= a[i]
    a[i] = 0
    if a[i + 1] > b[i]:
      result += b[i]
      a[i + 1] -= b[i]
      b[i] = 0
    else:
      result += a[i + 1]
      b[i] -= a[i + 1]
      a[i + 1] = 0
print(result)

Measured memory_bytes: 18624
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
 
    long long ans = 0;
    int MaxNum = 0;
    for (int i = 0; i < N; i++)
    {
        MaxNum = max(MaxNum, A[i]);
        ans += MaxNum - A[i];
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

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

signed main(){
    int N; cin>>N;
    vec A(N);
    REP(i,N) cin>>A[i];
    Sort(A);
    int temp,res;
    while(temp<N){
        int cc = A[temp],f=0;
        while(temp<N&&A[temp]==cc) f++, temp++;
        res += f%2;
    }
    Out(res);
}

Measured memory_bytes: 1024
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
N, X = ri_()
m = [ri() for _ in range(N)]
print(N + (X - sum(m)) // min(m))

Measured memory_bytes: 63084
#include <cstdio>
#include <cctype>

int main(){
    char ch;
    
    while(1){
        scanf("%c",&ch);
        if (isalpha(ch)){
            if (islower(ch)) printf("%c",toupper(ch));
            else printf("%c",tolower(ch));
            
        }else printf("%c",ch);
        
        if (ch=='\n') break;
        
    }
    
    return 0;
}


Measured memory_bytes: 2604
def solve(string):
    n, *xu = string.split()
    return str(sum([int(x) if u == "JPY" else float(x) * 380000 for x, u in zip(xu[::2], xu[1::2])]))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 38512
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    count = 0
    for i in range(1, x//3+1):
        for j in range(i+1, x//2+1):
            if x-i-j <= n and x-i-j > j:
                count += 1
                # print('{} {}', i, j, x-i-j)
    print(count)


Measured memory_bytes: 5596
#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

#ifndef INF
#define INF 1000000
#endif

int main(){
	string S;
	cin >> S;
	int len = S.length();
	int cnt = 0;
	string ret = "AC";
	if(S[0] != 'A'){
		ret = "WA";
		cout << ret << endl;
		return 0;
	}
	if(islower(S[1]) == 0){
		ret = "WA";
		cout << ret << endl;
		return 0;
	}
	for(int i = 2; i <= len-2; i++){
		if(islower(S[i]) == 0){
			if(S[i] == 'C'){
				if(cnt == 0){
					cnt++;
				}else{
					ret = "WA";
					cout << ret << endl;
					return 0;
				}
			}else{
				ret = "WA";
				cout << ret << endl;
				return 0;
			}
		}
	}
	if(cnt == 0 || islower(S[len-1]) == 0){
		ret = "WA";
		cout << ret << endl;
		return 0;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 100005
#define pb push_back
#define vit vector<int>::iterator
typedef pair<int,int> pii;
map<int,int>M;
vector<int> V[MAX];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int L,R,d;
    cin>>L>>R>>d;
    cout<<R/d-(L-1)/d;
    return 0;
}


Measured memory_bytes: 5852
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i,X,Y;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>m>>X>>Y;
  std::vector<ll> x(n),y(m);
  rep(i,n) cin>>x[i];
  rep(i,m) cin>>y[i];
  sort(all(x));
  sort(all(y));
  ll cnt = 0;
  if(x[n-1]<y[0]) repl(i,x[n-1]+1,y[0]+1) if(X<i&&Y>=i) cnt = 1;
  if(cnt) cout<<"No War"<<endl;
  else cout<<"War"<<endl;


}

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


Measured memory_bytes: 256