akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.15f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

struct UnionFind
{
	void init(int n) { par = new int[](n); foreach (i; 0..n) par[i] = i; cnt = new int[](n); fill(cnt, 1); }
	int root(int i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(int i, int j) { return root(i) == root(j); }
	void unite(int i, int j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; cnt[j] += cnt[i]; }
	int size(int i) { return cnt[root(i)]; }
	int[] par, cnt;
}

void main()
{
	auto N = RD;
	auto M = RD;

	bool[long] set;
	UnionFind uf;
	uf.init(cast(int)M);
	foreach (i; 0..N)
	{
		auto KL = RDA(-1);
		auto from = KL[1];
		foreach (to; KL[1..$])
		{
			set[to] = true;
			uf.unite(from, to);
		}
	}

	bool ans = true;
	auto cnt = set.keys.length;
	debug writeln(cnt);
	foreach (key; set.keys)
	{
		if (uf.size(cast(int)key) != cnt)
		{
			debug writeln(key);
			ans = false;
		}
	}

	writeln(ans ? "YES" : "NO");
	stdout.flush();
	debug readln();
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

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

  cout << ((N / 1000 + 1) * 1000 - N) % 1000 << endl;

  return 0;
}

Measured memory_bytes: 3636
import sys
import math

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

a, b = inl()

x = (a + b + 1) // 2
print(x)


Measured memory_bytes: 9144
#include <iostream>
	using std::cin;
	using std::cout;
#include <string>
    using std::string;
#include <vector>
    using std::vector;

#include <algorithm>
    using std::sort;

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

    vector<int>  buf(n);
    for(int i = 0;i < n;++i){
        cin >> buf[i];
    }

    sort(buf.begin(), buf.end());

    cout << buf[n/2] - buf[n/2 - 1];



	return 0; 
}

Measured memory_bytes: 640
#include <cstdio>
    #include <iostream>
    #include <vector>
    #include <set>
    #include <map>
    #include <cmath>
    #include <string>
    #include <cstring>
    #include <sstream>
    #include <queue>
    #include <iomanip>
    #include <algorithm>
    using namespace std;
     
    typedef long long ll;
     
    const int Maxd = 10;
    const int Maxm = 6000000;
    const int mod = 1000000007;
     
    int pw[Maxd];
    int s;
    int got[Maxm];
    int res;
     
    int toPower(int a, int p)
    {
    	int res = 1;
    	while (p) {
    		if (p & 1) res = ll(res) * a % mod;
    		p >>= 1; a = ll(a) * a % mod;
    	}
    	return res;
    }
     
    int main()
    {
    	pw[0] = 1;
    	for (int i = 1; i < Maxd; i++)
    		pw[i] = 10 * pw[i - 1];
    	scanf("%d", &s);
    	int add = 0;
    	int sum = 0;
    	int cur = 0;
    	got[0]++;
    	for (int i = 1; ; i++) {
    		if (i == pw[cur]) { add++; cur++; }
    		sum += add;
    		if (sum - s >= Maxm) break;
    		if (sum >= s) res = (res + got[sum - s]) % mod;
    		if (i < pw[6] - 1) got[sum]++;
    	}
    	if (s % 7 == 0) {
    		int nd = s / 7;
    		if (nd <= 9 * pw[6]) res = (res + 9 * pw[6] - nd + 1) % mod;
    	}
    	for (int i = 1; i * i <= s; i++)
    		if (s % i == 0) {
    			if (i > 7) {
    				int nd = s / i;
    				res = (ll(res) + 9ll * toPower(10, i - 1) % mod - ll(nd) + 1ll + ll(mod)) % mod;
    			}
    			if (i != s / i && s / i > 7) {
    				int nd = i;
    				res = (ll(res) + 9ll * toPower(10, s / i - 1) % mod - ll(nd) + 1ll + ll(mod)) % mod;
    			}
    		}
    	for (int b = 1; b * 8 < s; b++) {
    		int lft = s - b * 8;
    		if (lft % 7 == 0) {
    			int a = lft / 7;
    			if (a <= 9 * pw[6]) res = (res + 1) % mod;
    		}
    	}
    	for (int x = 9; x < s; x++) {
    		ll lft = s - x;
    		lft -= ll(x) * (lft % (x - 1));
    		if (lft <= 0) continue;
            ll cand = lft / (ll(x) * (x - 1));
            if (cand * x * (x - 1) != lft) cand++;
    		res = (res + cand) % mod;
    	}
    	printf("%d\n", res);
    	return 0;
    }

Measured memory_bytes: 23296
#include<stdio.h>
typedef long long LL;
#define mod 1000000007
#include<vector>
typedef std::vector<int> Vi;
/*
#include<algorithm>
using std::sort;

typedef std::pair<int,int> Pii;

typedef std::vector<Pii> Vii;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))

*/
/*
1和n-1肯定可以
2和n-2

n肯定不可以
*/
Vi nodes;
char str[100005];
int main() {
	int n;
	scanf("%s", str);
	for (n = 0; str[n] != '\0'; n++);
	for (int i = n; i >= 1; --i)str[i] = str[i - 1];
	str[0] = '0';
	if ( str[1] == '0' || str[n - 1] == '0' || str[n] == '1') {
		printf("-1"); return 0;
	}
	nodes.push_back(1);
	nodes.push_back(2);
	for (int i = 2, cur = 3; i <= n; ++i) {
		if (str[i] != str[n - i]) {
			printf("-1"); return 0;
		}
		if (str[i] == '1')//挂上去
		nodes.push_back(cur);
		cur++;
	}
	nodes.push_back(n);
	int sz = nodes.size();
	for (int i = 0; i<sz; ++i) {
		if (i + 1<sz) {
			for (int j = nodes[i] + 1; j <= nodes[i + 1]; ++j) {
				printf("%d %d\n", nodes[i], j);
			}
		}
	}

}

Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	string n; cin >> n;
	string res = "";
	rep (i, (int)n.length()){
		if (n[i] == '1'){
			res += '9';
		}else
		if (n[i] == '9'){
			res += '1';
		}else{
			res += n[i];
		} // end if
	} // end rep

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		List<A> map = new ArrayList<>();
		int[] bolMap = new int[] { 25, 50 , 100, 200};
		for (int i = 0; i < 4; i++) {
			int val = sc.nextInt();
			map.add(new A(bolMap[i], val));
		}
		
		Collections.sort(map, (a1, a2) -> { return (a1.val * 100 / a1.bol <= a2.val * 100 / a2.bol) ? -1 : 1 ;} );
		
		long N = sc.nextLong() * 100;
		int index = 0;
		long ans = 0;
		while(N != 0) {
			if (N >= map.get(index).bol) {
				long shou = N / map.get(index).bol;
				N -= map.get(index).bol * shou;
				ans += map.get(index).val * shou;
			} 
			index++;
		}
		
		System.out.println(ans);
	}
	
	static class A {
		long bol;
		long val;
		
		A(long bol, long val) {
			this.bol = bol;
			this.val = val;
		}
	}
}

Measured memory_bytes: 27988
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int k, q; cin >> k >> q;

	vector<int64_t> ds(k); for (auto& d : ds) cin >> d;

	REP(q) {
		int64_t n, x, m; cin >> n >> x >> m;
		x %= m;
		n--;
		vector<int64_t> cds(k);
		int64_t cd = 0;
		FOR_LT(i, 0, k) {
			int64_t c = ds[i] % m;
			if (c == 0) c += m;
			cd += c;
			cds[i] = cd;
		}

		int64_t ndk = n / k;
		int64_t nrk = (n % k);

		int64_t fv = x + ndk * cds[k - 1];
		if (nrk != 0) {
			fv += cds[nrk - 1];
		}
		cout << (n  - fv / m) << endl;
	}

	return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;

#define REP(i, n) for (ll i = 0; i < n; i++)

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  if (a >= 13)
  {
    cout << b << endl;
  }
  else if (a > 5)
  {
    cout << b / 2 << endl;
  }
  else
  {
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
  
  int n,m; cin>>n>>m;
  vector<int> p(m),y(m);
  map<int,int> t;
  for(int i=0; i<m; i++){
    cin >> p.at(i) >> y.at(i);
    p.at(i)--;
    t[y.at(i)] = i;
  }
  sort(y.begin(),y.end());
  vector<int> num(n), ans(m);
  for(int i=0; i<m; i++){
    int b = t[y.at(i)];
    num.at(p.at(b))++;
    ans.at(b) = num.at(p.at(b));
  }
  for(int i=0; i<m; i++){
    string x = to_string(p.at(i)+1);
    string y = to_string(ans.at(i));
    cout << string(6-x.size(),'0')<<x;
    cout << string(6-y.size(),'0')<<y;
    cout << endl;
  }
  
  
  
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr char sp=' ';
constexpr ll mod=1000000007;

int N,K,cnt;

int main(){
	cin>>N>>K;
	while(N){
		cnt++;
		N/=K;
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P = pair<int,int>;
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; }

bool isprime(int v) {
    if (v == 1) return false;
    for (int i = 2; 1LL * i*i <= v; i++) if (v%i == 0) return false;
    return true;
}

signed main(){
  int n;
  cin >> n;
  vvint v(5,vint(0));
  rep(i,1,55555) if(isprime(i)) v[i % 5].push_back(i);

  rep(i,0,n){
    cout << v[1][i] << " ";
  }
}

Measured memory_bytes: 384
N, K = map(int, input().split())
cnt = (N - 1) * (N - 2) // 2
if cnt < K:
    print(-1)
    exit()

edges = [[] for _ in range(N)]
for i in range(1, N):
    edges[0].append(i)

ef, et = 1, 2
for i in range(cnt - K):
    edges[ef].append(et)
    et += 1
    if et == ef:
        et += 1
    if et == N:
        ef += 1
        et = ef + 1

M = sum([len(edge) for edge in edges])
print(M)
for u in range(N):
    for v in edges[u]:
        print(u + 1, v + 1)

Measured memory_bytes: 3608
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<=n;i++)
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;


/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最大公約数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



int main(){
int N,K;
cin >> N >> K;
string S;
cin >> S;

vector<int> Nums;
int now = 1;
int cnt = 0;
REP(i,N){
    if(S[i] == (char)('0' + now))cnt++;
    else{
        Nums.push_back(cnt);
        now = 1-now;
        cnt = 1;
    }
}
if(cnt != 0) Nums.push_back(cnt);
if(Nums.size()%2 == 0)Nums.push_back(0);
int Add = 2 * K + 1;
vector<int> sum(Nums.size() + 1);
for(int i = 0; i <Nums.size();i++){
    sum[i + 1] = sum[i] + Nums[i];

}
int ans = 0;
for(int i = 0; i < Nums.size();i+=2){
int left = i;
int right = min(i+Add,(int)Nums.size());
int tmp = sum[right] - sum[left];

ans = max(tmp,ans);
}
cout << ans << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e8
typedef long long ll;
typedef long double ld;

int main() {
    int h,w,v;
    cin >> h >> w;
    v = h*w;
    vector<vector<char>> c(h, vector<char>(w));
    vector<vector<int>> G(v, vector<int>(v, INF));
    rep(i, h){
        rep(j, w){
            cin >> c[i][j];
        }
    }

    rep(i, v){
        bool is_wall = c[i/w][i%w] == '#';
        rep(j, v){
            if(i == j) {
                G[i][j] = 0;
            }else if(is_wall){
                G[i][j] = INF;
            }else if((abs(i/w - j/w) == 1 && i%w == j%w) || (abs(i%w - j%w) == 1 && i/w == j/w)){
                if(c[j/w][j%w] == '#') G[i][j] = INF;
                else G[i][j] = 1;
            }else{
                G[i][j] = INF;
            }
        }
    }
    
    for (int k = 0; k < v; k++) {
        for (int i = 0; i < v; i++) {
            for (int j = 0; j < v; j++) {
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
    
    int ans = 0;
    rep(i, v){
        rep(j, v){
            if(G[i][j] < INF && ans < G[i][j]) ans = G[i][j];
                
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
 
int main()
{
    // 入力
    map<int, int> mp1;
    map<int, int> mp2;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        if(i % 2 == 0) mp1[a]++;
        else mp2[a]++;
    }
    // 最頻値から答えを求める１
    int max1 = 0;
    int key = 0;
    for(pair<int, int> m: mp1)
    {
        if(m.second > max1)
        {
            max1 = m.second;
            key = m.first;
        }
    }
    int max2 = 0;
    for(pair<int, int> m: mp2)
    {
        // mp1の最頻値となるkeyとは異なる値を選ぶ
        if(m.second > max2 && m.first != key) max2 = m.second;
    }
    int ans1 = (N/2 - max1) + (N/2 - max2);
    // 最頻値から答えを求める２
    max1 = 0;
    key = 0;
    for(pair<int, int> m: mp2)
    {
        if(m.second > max1)
        {
            max1 = m.second;
            key = m.first;
        }
    }
    max2 = 0;
    for(pair<int, int> m: mp1)
    {
        // mp2の最頻値となるkeyとは異なる値を選ぶ
        if(m.second > max2 && m.first != key) max2 = m.second;
    }
    int ans2 = (N/2 - max1) + (N/2 - max2);
    int ans = min(ans1, ans2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <string>
#include <string.h>
#include <cstring>
#include <algorithm>

using namespace std;

long long int a,b,gcd,lcm;

int main()
{
	while(scanf("%lld %lld", &a, &b) != EOF)
	{
	if (a==b)
	{
		gcd=a;
		lcm=b;
	}
	else
	gcd=__gcd(a,b);
	lcm=a/gcd*b;
    printf("%lld %lld\n",gcd,lcm);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    stack<int> S1;
    stack<pair<int, int> > S2;
    char l;
    int sum = 0;
    for (int i = 0; cin >> l; i++) {
        if (l == '\\') S1.push(i);
        else if (l == '/' && S1.size() > 0) {
            int j = S1.top();
            S1.pop();
            sum += i - j;
            int a = i - j;
            while (S2.size() > 0 && S2.top().first > j) {
                a += S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j, a));
        }
    }

    vector<int> ans;
    while (S2.size() > 0) {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for (int i = 0; i < ans.size(); i++) {
        cout << " " << ans[i];
    }
    cout << endl;

    return 0;
}


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

int main() {
	int a, b;
	char op[2];
	while (true) {
		int t;
		cin >> a;
		cin >>op;
		cin >> b;
		if (op[0] == '+') {
			t = a + b;
		}
		else if (op[0] == '-') {
			t = a - b;
		}
		else if (op[0] == '/') {
			t = a / b;
		}
		else if (op[0] == '*') {
			t = a * b;
		}
		else {
			break;
		}
		cout << t << endl;
	}
	return 0;
}





Measured memory_bytes: 3120
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(list(enumerate(a)), key=lambda x: -x[1])

    class unionfind():
        # size:要素数,tree：unionfind木
        def __init__(self, size):  # self,要素数
            self.size = size
            self.tree = [i for i in range(self.size)]  # root,depth

        # rootを探す
        def root(self, index):
            temp_list = []
            temp = self.tree[index]
            while index != temp:
                temp_list.append(index)
                index = temp
                temp = self.tree[index]
            for i in temp_list:
                self.tree[i] = index
            return index

        # 結合
        def unite_r(self, index1, index2):
            r1 = self.root(index1)
            r2 = self.root(index2)
            if r1 < r2:
                self.tree[r1] = r2
            else:
                self.tree[r2] = r1

        def unite_l(self, index1, index2):
            r1 = self.root(index1)
            r2 = self.root(index2)
            if r1 > r2:
                self.tree[r1] = r2
            else:
                self.tree[r2] = r1

        # 同じか判定
        def same(self, index1, index2):
            r1 = self.root(index1)
            r2 = self.root(index2)
            return r1 == r2

    ur = unionfind(n+2)
    ul = unionfind(n+2)
    vis = [False]*(n+2)
    ans = 0
    for i, j in a:
        vis[i+1] = True
        if vis[i+2]:
            ur.unite_r(i+1, i+2)
            ul.unite_l(i+1, i+2)
        if vis[i]:
            ur.unite_r(i, i+1)
            ul.unite_l(i, i+1)
        ans += j*(ur.root(i+1)-i)*(i+2-ul.root(i+1))
    print(ans)


main()


Measured memory_bytes: 47448
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<long long> vll, vLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
vint x;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int l = s.length();
    vint x(l,0);
    REP(i,l){
        if(s[i]=='B'){
            x[i]=1;
        }else{
            x[i]=0;
        }
    }
    //int f=1;
    ll ans =0;
    int i=1;
    int b=0;
    if(x[0]==1){
        b=1;
    }
    while(i<l){
        if(x[i]==0){
           if(x[i-1]==0){
               b=0;
           }else{
                ans+=(ll)b;
                x[i]=1;
           }
        }else{
            b++;
        }
        i++;
        //cout << i << ":" << ans << endl;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1428
using System;

namespace ARC064_C___Boxes_and_Candies
{
    class Program
    {
        static void Main(string[] args)
        {
            var NX = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            var N = NX[0];
            var X = NX[1];
            var Ai = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            long result = 0;
            for (long i = 1; i < N; i++)
            {
                if (Ai[i] + Ai[i - 1] <= X) continue;
                long difference = Ai[i] + Ai[i - 1] - X;
                result += difference;
                Ai[i] = Math.Max(Ai[i] - difference, 0);
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 29532
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }

  

  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }

  for(j=1;j<=n;j++){
    C[A[j]]++;
  }

  for(i=1;i<VMAX;i++){
    C[i]=C[i]+C[i-1];
  }

  for(j=n;j>=1;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}



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

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    string f, s, b;
    cin >> f >> s >> b;
    cout << 'A' << s.at(0) << 'C' << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (2147483647)
#define mod (1000000007)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)

void solve()
{
    ll n,k;cin>>n>>k;if(k>=n){cout<<0<<endl;return;}
    ll h[n];REP(i,n)cin>>h[i];
    sort(h,h+n);
    ll sum=0;
    REP(i,n-k){
        sum+=h[i];
    }cout<<sum<<endl;
}

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    for (int i = 0; i < 5; i++) {
        int a;
        cin >> a;
        if (a == 0)
            cout << i + 1 << endl;
    }

    solve();
    return 0;
}


Measured memory_bytes: 3588
import java.util.*; 
import java.lang.*; 


public class Main{
    
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                long N = scan.nextLong();
                
                int i=0;
                long a = 1;
                while(i<N){
                    a = a*10;
                    a = a%(10*10*10*10*10*10*10*10*10+7);
                    i++;
                }
                
                int j=0;
                long b = 1;
                while(j<N){
                    b = b*9;
                    b = b%(10*10*10*10*10*10*10*10*10+7);
                    j++;
                }
                
                b = (2*b)%(10*10*10*10*10*10*10*10*10+7);
                
                int k=0;
                long c = 1;
                while(k<N){
                    c = c*8;
                    c = c%(10*10*10*10*10*10*10*10*10+7);
                    k++;
                }
                a = a + 10*10*10*10*10*10*10*10*10+7;
                long ans = (a-b+c)%(10*10*10*10*10*10*10*10*10+7);
                System.out.println(ans);
        }
}

Measured memory_bytes: 35804
import java.util.*;
 
public class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int x = sc.nextInt();
    int y = sc.nextInt();
    
    if(x>=1 && x<=12 && y>=1 && y<=12){
    if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12)){
      System.out.println("Yes");    
    }else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)){
      System.out.println("Yes");
    }else if(x==2 && y==2){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    }else{
      System.out.println("入力値が誤っています");
    }
  }
  
}

Measured memory_bytes: 35812
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
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 / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, int b, int _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int k, x;
  cin >> k >> x;
  cout << (500 * k >= x ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

N = INT()
s = ["".join(sorted(list(input()))) for _ in range(N)]

dic = defaultdict(int)
for x in s:
	dic[x] += 1

ans = 0
for v in dic.values():
	ans += v*(v-1)//2

print(ans)



Measured memory_bytes: 21612
n,*a=gets.split.map &:to_i
l=(1..n).map{gets.to_i}
m=1e5
(4**n).times{|x|
    s=[q=0,0,0]
    x.to_s(4).rjust(n).split("").each_with_index{|e,i|e<'3'&&(s[e.to_i]+=l[i])>l[i]&&q+=10}
    (0..2).each{|i|q+=(a[i]-s[i]).abs}
    s.all?{|i|i>0}&&m=[m,q].min
}
p m

Measured memory_bytes: 2172
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int>v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    int sum=0;
    for(int i=v.size()-1;i>=n-k;i--)
    {
        sum+=v[i];
    }
    cout<<sum;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i=1; i < (int)(n); i++)
#define rrep(i, n) for (int i=((int)(n)-1); i>=0; i--)
#define rreps(i, n) for (int i=((int)(n)-1); i>0; i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
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 main() {
  int K; cin >> K;
  string S; cin >> S;
  if (S.size() <= K) {
    cout << S << endl;
  }else {
    rep (i, K) cout << S.at(i);
    cout << "..." << endl;
  }

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
using namespace std;

#define REP(i,s,e) for(int i=(s);i<(e);i++)
#define rep(i,n) REP(i,0,n)

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; }

const long long INFLL = 1LL << 60;
const int INF = 1 << 30;

typedef long long ll;
typedef unsigned long long ull;

int N, W;
int w[100];
int v[100];
ll dp[101][100001];

int main(void) {
  cin >> N >> W;
  rep(i, N) cin >> w[i] >> v[i];
  rep(i, 101) rep(j, 100001) dp[i][j] = INF;

  dp[0][0] = 0; 

  rep(i, N) rep(sv, 100001) {
    if (sv-v[i] >= 0) chmin(dp[i+1][sv], dp[i][sv-v[i]] + w[i]);
    chmin(dp[i+1][sv], dp[i][sv]);
  }

  int res = 0;
  rep(i, 100001) if (dp[N][i] <= W) res = i;
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return sorted 約数list 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(ALL(v));
  return v;
}

int main() {
    ll n,b,t;
    string s;
    cin >> s;
    ll sum1 = 0, sum2 = 0;
    rep(i, s.size()){
        if(i%2==0 && s[i] == '1') sum1 ++;
        if(i%2==1 && s[i] == '0') sum1 ++;
        if(i%2==1 && s[i] == '1') sum2 ++;
        if(i%2==0 && s[i] == '0') sum2 ++;
    }
    pr(min(sum1, sum2));
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<vector>
#include<cmath>
#include<algorithm>
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rrep(i, a, b) for(int i=b-1; i>=a; i--)
#define REP(i, n) for(int i=0; i<n; i++)
#define rREP(i, n) for(int i=n-1; i>=0; i--)
#define MAX 100001
typedef long long ll;
using namespace std;

int main(){
  int x, y, z;
  cin >> x >> y >> z;
  cout << (x-z)/(y+z) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] h = new int[n];
        for(int i = 0; i < n; i++){
            h[i] = Integer.parseInt(sc.next());
        }
        
        int count = 1;
        int max = h[0];
        for(int i = 1; i < n; i++){
            if(h[i] >= max){
                count++;
                max = h[i];
            }
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;

int main(){

	char buf[5001],work[5001],pre,to_change;
	scanf("%s",buf);

	int length,limit,index,pre_length;
	bool FLG = true,A_FLG,B_FLG,C_FLG;

	for(length = 0; buf[length] != '\0'; length++);

	do{
		if(length <= 3)break;
		pre_length = length;

		limit = length-3;
		index = 0;
		pre = 'D';
		to_change = 'D';
		A_FLG = B_FLG = C_FLG = false;
		for(int i = 0; i < length;){
			if(i <= limit && buf[i] == 'A' && buf[i+1] == 'B' && buf[i+2] == 'C'){
				if(to_change == 'D'){ //?????????????????§???????????????????????????????????????????????????????????????!!
					switch(pre){
					case 'D':
						if(!A_FLG){ //???????????§????????????A??????????????????????????????
							work[index++] = 'A';
							to_change = 'A';
						}else{
							FLG = false;
						}
						break;
					case 'A':
						if(!B_FLG){ //???????????§????????????B??????????????????????????????
							work[index++] = 'B';
							to_change = 'B';
						}else{
							FLG = false;
						}
						break;
					case 'B':
						if(!C_FLG){ //???????????§????????????C??????????????????????????????
							work[index++] = 'C';
							to_change = 'C';
						}else{
							FLG = false;
						}
						break;
					case 'C':
						FLG = false;
						break;
					}
				}else{
					work[index++] = to_change;
				}
				if(!FLG)break;

				i+=3;
			}else{
				if(buf[i] == to_change){ //???????????????????????????????????????????????§?????¨??????????????????????????????
					FLG = false;
					break;
				}else{
					work[index++] = buf[i];
					switch(buf[i]){
					case 'A':
						A_FLG = true;
						break;
					case 'B':
						B_FLG = true;
						break;
					case 'C':
						C_FLG = true;
						break;
					}

					pre = buf[i];
					i++;
				}
			}
		}
		if(!FLG){
			length = 0;
			break;
		}

		work[index] = '\0';
		length = index;

		for(int i = 0; i <= length; i++){
			buf[i] = work[i];
		}

		//if(length < 100)printf("%s\n",buf);

	}while(pre_length > length);

	if(length == 3 && buf[0] == 'A' && buf[1] == 'B' && buf[2] == 'C'){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 2696
one=0
two=0
three=0
while 1:
	try:
		i=int(raw_input())
		if one<i:
			three=two
			two=one
			one=i
		elif two<i:
			three=two
			two=i
		elif three<i:
			three=i
    	except:
	    	print"%d"%(one)
	    	print"%d"%(two)
	    	print"%d"%(three)
	    	break

Measured memory_bytes: 4208
eval'N,A,B='+`dd`.split*?,
M=10**9+7
A*=t=(A+B).pow(M-2,M)
a=A.pow(N,M)
B*=t
b=B.pow(N,M)
[g=1,*(1...N).map{g=g*_1%M}].map{$.=($.+(g*_1).pow(M-2,M)*(a+b)*100*g*t=t*N%M)%M
N+=1
a=a*B%M
b=b*A%M}
p$.

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


int main(){
    ll a,b,c,d;
    ll cc, dd;
    cin >>a >>b >>c >>d;
    ll ans=0;
    ll cd=0;
    

    ll r,tmp;
    cc = max(c,d); dd=min(c,d);
    r=cc%dd;
    while(r!=0){
        cc=dd;
        dd=r;
        r=cc%dd;
    }
    //ddはｃとｄの最大公約数
    cd=c/dd;
    cd*=d;


    ans =b-b/c-b/d+b/cd; 
    ans -= a-1 - (a-1)/c - (a-1)/d + (a-1)/cd;
    cout << ans << endl;
}




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

const int MOD=1000000007;

string ng[]{"AGC","GAC","ACG","A*GC","AG*C"};
int dp[200][4][4][4];
map<char,int>id={{'A',0},{'C',1},{'G',2},{'T',3}};

bool match(vector<int>a){
	rep(i,3){
		bool ok=true;
		rep(j,3){
			if(a[j+1]!=id[ng[i][j]])ok=false;
		}
		if(ok)return true;
	}
	for(int i=3;i<5;i++){
		bool ok=true;
		rep(j,4){
			if(ng[i][j]!='*'&&a[j]!=id[ng[i][j]])ok=false;
		}
		if(ok)return true;
	}
	return false;
}

int main(){
	int n;cin>>n;
	dp[0][3][3][3]=1;
	rep(i,n)rep(j,4)rep(k,4)rep(t,4){
		int D=dp[i][j][k][t];
		rep(nx,4){
			if(match({j,k,t,nx}))continue;
			(dp[i+1][k][t][nx]+=D)%=MOD;
		}
	}
	int ans=0;
	rep(i,4)rep(j,4)rep(k,4)(ans+=dp[n][i][j][k])%=MOD;
	cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int w,h;
int count; 
int dx[4]={1,0,-1,0};int dy[4]={0,1,0,-1};
char board[100][100];
void dfs(int x,int y){
       count++;
       board[y][x]='#';
    for(int i=0;i<4;i++){
      int nx=x+dx[i];int ny=y+dy[i];
      if(nx>=0&&nx<w&&ny>=0&&ny<h&&board[ny][nx]=='.'){
          dfs(nx,ny);
      }
    }
}
int main(){
	while(1){
  cin>>w>>h;
  if(w==0&&h==0) break;
  count=0;
  for(int k=0;k<h;k++){
    cin>>board[k];
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(board[i][j]=='@'){
         dfs(j,i);
      }
    }
  }
  cout<<count<<endl;
}
  return 0;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n; scanf("%d", &n);
	int answer = 0;
	for (int i = 0; i < n; i++) {
		int x; scanf("%d", &x);
		answer += x - 1;
	}
	printf("%d\n", answer);
}


Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n,k ;
	cin >> n >> k ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	ll ans = 0 ;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			if(i+j<=min(n,k)){
				vll neg ;
				ll sub = 0 ;
				for(int l=0;l<n;l++){
					if(i<=l&&l<n-j) continue ;
					sub += a.at(l) ;
					if(a.at(l)<0) neg.emplace_back(a.at(l)) ;
				}
				sort(all(neg)) ;
				for(int l=0;l<k-i-j;l++) if(l<neg.size())sub -= neg.at(l) ;
				ans = max(ans,sub) ;
			}else break ;
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 256
import math
import itertools
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
total = 1
cnt = 0
p = 0
q = 0
for v in itertools.permutations(range(1, N+1)):
    cnt += 1
    if v == P:
        p = cnt
    if v == Q:
        q = cnt
print(abs(p - q))

Measured memory_bytes: 39024
#include <stdio.h>

int main(void){

int a,b,c;

scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);

if(a<=b && b<=c){
printf("%d %d %d\n",a,b,c);
}
else if(a<=c && c<=b){
printf("%d %d %d\n",a,c,b);
}
else if(b<=a && a<=c){
printf("%d %d %d\n",b,a,c);
}
else if(b<=c && c<=a){
printf("%d %d %d\n",b,c,a);
}
else if(c<=a && a<=b){
printf("%d %d %d\n",c,a,b);
}
else if(c<=b && b<=a){
printf("%d %d %d\n",c,b,a);
}
return  0;
}

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

int main() {
  int A,B;
  cin>>A>>B;
  int C=0;
  for(;A<=B;A++){
    int t=A;
    int A1=t%10;
    t/=10;
    int A2=t%10;
    t/=10;
    int A3=t%10;
    t/=10;
    int A4=t%10;
    t/=10;
    int A5=t%10;
    if(A1==A5&&A2==A4){
      C++;
    }
  }
  cout<<C<<endl;
}


Measured memory_bytes: 3596
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int n,x,y;
  cin >> n >> x >> y;
  int d[n+1][n+1];
  for(int i=1;i<n+1;i++){
    for(int j=1;j<n+1;j++) d[i][j] = abs(i-j);
  }
  d[x][y] = 1;
  for(int i=1;i<n+1;i++){
    for(int j=1;j<n+1;j++){
      d[i][j] = min(d[i][x]+1+d[y][j],d[i][j]);
      d[i][j] = min(d[i][y]+1+d[x][j],d[i][j]);
    }
  }
  int a[n];
  for(int i=1;i<n;i++) a[i] = 0;
  for(int i=1;i<n+1;i++){
    for(int j=i+1;j<n+1;j++){
      a[d[i][j]]++;
    }
  }
  for(int i=1;i<n;i++){
    cout << a[i] << endl;
  }
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;


int main() {

    double l;
    cin >> l;

    double a = l / 3;

    double ans = a * a * a;

    cout << std::fixed << std::setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  if(n==1||n==2||n==3){
    cout<<1<<endl;
    return 0;
  }
  int m=0;
  for(int i=2;i*i<=n;i++){
    for(int j=2;;j++){
      if(pow(i,j)>n){
        int a=pow(i,j-1);
        m=max(m,a);
        break;
      }
    }
  }
  cout<<m<<endl;
}
      

Measured memory_bytes: 384
import java.util.*;
 
public class Main{
public static void main(String[]args){
 
  Scanner sc=new Scanner(System.in);
  
  int n =sc.nextInt();
  int[] l=new int[n*2];  
  
  for(int i=0; i<l.length; i++){
   l[i]=sc.nextInt();
}


  Arrays.sort(l);
  
  int ans=0;
  for(int j=0; j<l.length; j+=2){
    ans +=Math.min(l[j],l[j+1]);
}
System.out.println(ans);


}}

Measured memory_bytes: 9676
#include <iostream>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define pb push_back
int main(int argc, char** argv) {
	ll k;
	cin>>k;
	ll ans=k/500*1000;
	ans+=(k%500)/5*5;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 123456;
vector<int> e[maxn];
int dist[4][maxn];
int main(){
	int n, m; cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		e[x].push_back(y);
	}
	memset(dist, -1, sizeof(dist));
	int s, t; cin >> s >> t;
	dist[2][s] = 0;
	deque<pair<int,int> > q; q.push_back({2, s});
	while(!q.empty()){
		int st, x; tie(st, x) = q.front(); q.pop_front();
		int nst = (st + 1) % 3;
		for(int u : e[x]){
			if(dist[nst][u] == -1){
				if(st == 2){
					dist[nst][u] = dist[st][x] + 1;
					q.push_back({nst, u});
				} else {
					dist[nst][u] = dist[st][x];
					q.push_front({nst, u});
				}
			}
		}
	}
	cout << dist[2][t] << endl;
	return 0;
}



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

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

	rep(i, n){
		rep(j, n-i){
			if(10000*i + 5000*j + 1000*(n-i-j) == y){
				cout << i << " " << j << " " << n-i-j << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256