akhauriyash/Code-Regression huggingface dataset:
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}


ll a[5];
int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    for (int i = 1; i <= 4; i++) {
    	a[i] = readInt();
    }
	for (int i = 2;  i<= 4; i++) {
		a[i] = min(a[i], a[i - 1] * 2);
	}
	ll x = readInt();
	cout << (x & 1) * a[3] + (x >> 1) * a[4];
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

res = 0
for i in range(N):
    if i % 2 == 0:
        res += A[i]
    else:
        res -= A[i]
ans = [res]
for i in range(N-1):
    res = 2*A[i] - res
    ans.append(res)

print(*ans)

Measured memory_bytes: 14028
#include<iostream>
#include<stack>
#include<vector>

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<int> x(N, 0);
  stack<int> s;
  vector<vector<pair<int, int>>> left(N);
  vector<vector<pair<int, int>>> right(N);
  for(int i = 0; i < M; i++){
    int L, R, D;
    cin >> L >> R >> D;
    L--;
    R--;
    left[R].push_back({L, D});
    right[L].push_back({R, D});
  }
  
  for(int i = 0; i < N; i++){
    if(left[i].size() == 0){
      x[i] = 1;
      s.push(i);
    }
  }
  
  bool able = true;
  while(!s.empty()){
    int node = s.top();
    s.pop();
    for(int i = 0; i < right[node].size(); i++){
      int next = right[node][i].first;
      int xd = x[node] + right[node][i].second;
      if(x[next] == 0){
        x[next] = xd;
        s.push(next);
      }
      else if(x[next] != xd){
        able = false;
        break;
      }
    }
  }
  
  for(int i = 0; i < N; i++){
    if(x[i] == 0) able = false;
  }
  
  cout << (able ? "Yes" : "No") << endl;
  
  return 0;
}

Measured memory_bytes: 12288
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int ans;
        if(a > b) {
            ans = a;
            a--;
        }else {
            ans = b;
            b--;
        }
        if(a > b) {
            ans += a;
            a--;
        }else {
            ans += b;
            b--;
        }
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 23124
#include <stdio.h>
int main(){
	unsigned n, k;
	scanf("%u%u", &n, &k);

	unsigned sum = 1;
	for(unsigned i = 1;; ++i){
		sum += (sum - 1) / k + 1;
		if(sum > n){
			printf("%u\n", i);
			return;
		}
	}
}



Measured memory_bytes: 2056
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
	int a,b,c,d;
	scanf("%i%i%i%i",&a,&b,&c,&d);
	if(abs(b-a)<=d && abs(c-b)<=d || abs(a-c)<=d)
	{
		printf("Yes");
	}
	else printf("No");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=200005;
int n,a[N];
ll ans;
int main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=read(); 
	if(a[1]!=0){
		puts("-1"); return 0;
	}
	for(int i=2;i<=n;i++)if(a[i]>a[i-1]+1||a[i]>=i){
		puts("-1"); return 0;
	}
	for(int i=2;i<=n;i++)if(a[i]){
		if(a[i]==a[i-1]+1)ans++;
			else ans+=a[i];
		}
	cout<<ans<<endl;
}


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

int main(){
    int N;
    const int M = 2000;
    bitset<M> A[M];
    cin >> N;
    for(int i=1; i<N; i++){
        string s;
        cin >> s;
        for(int j=0; j<i; j++){
            A[i][j] = s[j] - '0';
            A[j][i] = 1 - A[i][j];
        }
    }

    bitset<M> dpl[M], dpr[M];
    for(int i=0; i<N; i++) dpl[i][i] = dpr[i][i] = 1;

    for(int d=1; d<N; d++){
        bitset<M> resl, resr;
        bitset<M> maskl, maskr;
        for(int k=0; k<N; k++){
            if(k-1 >= 0) maskl[k-1] = 1;
            if(k+d < N) maskr[k+d] = 1;

            bitset<M> l = ~A[k];
            l &= maskl;
            l &= dpr[k] >> 1;
            l &= dpl[k] >> d;
            resl |= l;

            bitset<M> r = ~A[k];
            r &= maskr;
            r &= dpl[k] << 1;
            r &= dpr[k] << d;
            resr |= r;

            if(k-d >= 0) maskl[k-d] = 0;
            if(k+1 < N) maskr[k+1] = 0;
        }
        for(int i=0; i<N; i++){
            if(i+d < N) dpl[i][i+d] = resl[i];
            if(i-d >= 0) dpr[i][i-d] = resr[i];
        }
    }

    int ans = 0;
    for(int i=0; i<N; i++) if(dpl[i][N-1] && dpr[i][0]) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1920
#include <cstdio>
#include <algorithm>

using namespace std;

int S[100002];

int main(int argc, char const *argv[])
{
    int n;
    scanf("%d\n", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &S[i]);
    sort(S, S + n);

    int q, t, count = 0;
    scanf("%d\n", &q);
    for (int i = 0; i < q; ++i)
    {
        scanf("%d", &t);
        if (binary_search(S, S + n, t))
            count++;
    }

    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 1432
def main():
    n = int(input())
    a = list(map(int, input().split()))
    dp = [[0] * n for _ in range(n)]
    for i in range(n):
        dp[i][i] = a[i]
 
    for i in range(n - 2, -1, -1):
        for j in range(i + 1, n):
            dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])
    print(dp[0][n - 1])
main()

Measured memory_bytes: 111708
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  auto N = scanElem;
  auto A = scanElem;
  auto B = scanElem;
  writeln(min(N*A,B));
}


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

int main(){
	int N, X;
	cin >> N >> X;

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

	int sum = 0, ans = 1;
	for(int i = 0; i < N; i++){
		sum += L[i];
		if(sum > X) { break;}
		ans += 1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    var n = cin.nextInt()
    val m = cin.nextInt()
    val a = Array<Int>(m, { cin.nextInt() })

    for (i in 0..m-1) {
        n -= a[i]
    }
    if (n < 0) {
        println(-1)
    } else {
        println(n)
    }
}

Measured memory_bytes: 46804
#include<iostream>
using namespace std;
int a,b,c,i;
int main()
{
    cin>>a>>b>>c;
    for(i=1;i<=b;i++)
    {
        if((a*i)%b==c)
		{
		cout<<"YES"<<endl;
		return 0;
		}
    }
    cout<<"NO"<<endl;
    return 0;
}

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int n;
  cin >> n;
  cout << n * n * n << '\n';
  return 0;
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict
from sys import exit
import math


def main():
    n, m = getList()
    nums = getList()
    tree = [[] for _ in range(n)]
    for i in range(m):
        # start, end, cost
        a, b = getList()
        # 0-indexed
        a -= 1
        b -= 1
        tree[a].append(b)
        tree[b].append(a)
    ans = 0
    for i, t in enumerate(tree):
        cur = nums[i]
        fl = True
        for ne in t:
            if nums[ne] >= cur:
                fl = False

        if fl:
            ans += 1

    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 99996
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner in = new Scanner(System.in);

		int set_count = in.nextInt();
		int min = 0;
		int max = 0;
		
		long sum = 0;
		
		
		for(int i = 0; i < set_count; i++){
			int num = in.nextInt();
			if(i == 0){
				min = num;
				max = num;
			}else{
				min = Math.min(min, num);
				max = Math.max(max, num);
			}
			sum += num;
		}
		System.out.println(min + " " + max + " " + sum);
	}

}



Measured memory_bytes: 42852
#include <stdio.h>
#include <math.h>


 struct Point {double x,y;};

void koch(int,struct Point,struct Point);
int main(){
 struct Point p1,p2;
  int n;

  scanf("%d",&n);
  p1.x=0;
  p1.y=0;
  p2.x=100;
  p2.y=0;

  printf("%.8f %.8f\n",p1.x,p1.y);
  koch(n,p1,p2);
  printf("%.8f %.8f\n",p2.x,p2.y);

  
  return 0;
}
void koch(int n,struct Point p1,struct Point p2){
 struct Point s,u,t;
  double th=M_PI * 60.0/180.0;
  if(n==0)return;
  s.x=(2*p1.x+p2.x)/3.0;
  s.y=(2*p1.y+p2.y)/3.0;
  t.x=(p1.x+2*p2.x)/3.0;
  t.y=(p1.y+2*p2.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,p1,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,p2);
}



Measured memory_bytes: 2124
import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int i = 0;
        
        while(i*i<=n){
            i++;
        }
        System.out.println((i-1)*(i-1));
        
    }
}




Measured memory_bytes: 23892
from collections import deque
n , m , k = map(int,input().split())
tomo = [set() for i in range(n+1)]
to = [0 for i in range(n+1)]
bro = [set() for i in range(n+1)]
for i in range(m):
    a , b = map(int,input().split())
    tomo[a].add(b)
    tomo[b].add(a)
    to[a] += 1
    to[b] += 1
for i in range(k):
    c , d = map(int,input().split())
    bro[c].add(d)
    bro[d].add(c)

visit = [True for i in range(n+1)]
kurasuta = []
for i in range(1,n+1):
    if visit[i]:
        kar = {i}
        d = deque()
        d.append(i)
        cou = 1
        visit[i] = False
        while d:
            now = d.popleft()
            for j in tomo[now]:
                if visit[j]:
                    visit[j] = False
                    kar.add(j)
                    d.append(j)
                    cou += 1
        kurasuta.append([kar,cou])
    else:
        continue
ans = [0 for i in range(n)]

for i in range(len(kurasuta)):
    for j in kurasuta[i][0]:
        ans[j-1] = kurasuta[i][1] - to[j] - 1 - len(kurasuta[i][0] & bro[j])

print(*ans)


Measured memory_bytes: 112828
#include<stdio.h>
int main(void){
	int tate[2],yoko[2],menseki[2],i,dai;
	scanf("%d %d %d %d",&tate[0],&yoko[0],&tate[1],&yoko[1]);
	
	for(i=0;i<2;i++){
		menseki[i]=tate[i]*yoko[i];
	}
	dai=menseki[0];
	if(menseki[1]>dai){
		dai=menseki[1];
	}
	printf("%d\n",dai);
	
	return 0;
}


Measured memory_bytes: 128
n = gets.to_i
array = gets.split(" ").map(&:to_i)

count = 0
(1..(n - 2)).each do |i|
  count += 1 if (array[i - 1] < array[i] && array[i] < array[i + 1]) || (array[i - 1] > array[i] && array[i] > array[i + 1])
end

puts count

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <iomanip>
#include <cstring>

using namespace std;

int main() {
    int n, r;
    cin >> n >> r;
    if (n >= 10)
        cout << r;
    else
        cout << 100*(10-n)+r;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	Scanner in = new Scanner(System.in);
	int n, m, k;
	int ans;
	
	public void recursive(int n, int sum) {
		if (n == 0) {
			if (sum - k <= 0) {
				ans++;
			} else {
				ans += sum - k;
			}
		} else {
			for (int i = 1; i <= m; i++) {
				recursive(n - 1, sum + i);
			}
		}
	}
	
	public void run() {
		while (true) {
			n = in.nextInt();
			m = in.nextInt();
			k = in.nextInt();
			if (n == 0 && m == 0 && k == 0) break;
			ans = 0;
			
			recursive(n, 0);
			
			double all = Math.pow(m, n);
			
			System.out.println(ans / all);
		}
	}
	
	public static void main(String args[]) {
		new Main().run();
	}
}

Measured memory_bytes: 20004
#include<stdio.h>
int main(void){
  int h,n,sum=0;
  scanf("%d%d",&h,&n);
  int a[n],i;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    sum+=a[i];
  }
  if(sum>=h) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<stack>
#include<set>
#include<queue>
#include<vector>
#include<stdlib.h>
 
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cstdlib>
 
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn=2500010;//maxn*maxs
const int maxs=1e8+10;
 
char s[maxn];
int main()
{
        int n;
        cin>>n;
        ll sum=0;
        for(int i=1;i<n;i++)
        {
            sum+=(n-1)/i;
        }
        cout<<sum<<endl;
    system("pause");
    return 0;
}
	



Measured memory_bytes: 3196
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define PUT(a, n) FOR(i, n) cin >> a[i]
#define OUT(a, n) FOR(i, n) cout << a[i] << ' '

using namespace std;

const int N = 1e5 + 5;

int main() {
	fast;
    ll n, w; cin >> n >> w;
    pair<ll, ll> a[n];
    FOR(i, n, 0)cin >> a[i].f >> a[i].s;
    sort(a, a + n);
    ll dp[n + 1][w + 1] = {};
    FOR(i, w + 1, 1)if(i >= a[0].f)dp[0][i] = a[0].s;
    FOR(i, n, 1)
    {
        FOR(j, w + 1, 1)
        {
            if(j < a[i].f)dp[i][j] = dp[i - 1][j];
            else dp[i][j] = max(dp[i - 1][j], a[i].s  + dp[i - 1][j - a[i].f]);
        }
    }
    cout << dp[n - 1][w];

    return 0;
}


Measured memory_bytes: 79232
#include <cstdio>
#include <vector>
#include <cstdlib>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        vector<int> a(n);
        int ma = 0;
        for (int i = 0; i < n; i ++) {
                scanf("%d", &a[i]);
                ma = max(ma, abs(a[i]));
        }
        bool ispos = true;
        int p = 0;
        for (int i = 0; i < n; i ++) {
                if (abs(a[i]) == ma) {
                        ispos = a[i] >= 0;
                        p = i;
                        break;
                }
        }
        if (!ispos) {
                ma *= -1;
        }
        vector<pair<int, int>> ans;
        for (int i = 0; i < n; i ++) {
                ans.emplace_back(p, i);
        }
        if (ispos) {
                for (int i = 1; i < n; i ++) {
                        ans.emplace_back(i - 1, i);
                }
        } else {
                for (int i = n - 2; i >= 0; i --) {
                        ans.emplace_back(i + 1, i);
                }
        }
        printf("%d\n", (int) ans.size());
        for (int i = 0; i < (int) ans.size(); i ++) {
                printf("%d %d\n", ans[i].first + 1, ans[i].second + 1);
        }
        return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int n,m,s;
    while(scanf("%d%d",&n,&m)==2)
    {
        s=n*m;
        if(s%2)
            printf("Odd\n");
        else
            printf("Even\n");
    }
    return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n){
    cin >> a.at(i);
  }
  int64_t cntp= 0;
  if(a.at(0) <= 0){
    cntp = -1 * a.at(0) + 1;
  }
  int sum = max(1, a.at(0));
  rep2(i, 1, n){
    if(sum > 0){
      if(sum + a.at(i) >= 0){
        cntp += sum + a.at(i) + 1;
        sum = -1;
      }
      else{
        sum += a.at(i);
      }
    }
    else{
      if(sum + a.at(i) <= 0){
        cntp += -1 * (sum + a.at(i)) + 1;
        sum = 1;
      }
      else{
        sum += a.at(i);
      }
    }
  }
  int64_t cntm= 0;
  if(a.at(0) >= 0){
    cntm = a.at(0) + 1;
  }
  int summ = min(-1, a.at(0));
  rep2(i, 1, n){
    if(summ > 0){
      if(summ + a.at(i) >= 0){
        cntm += summ + a.at(i) + 1;
        summ = -1;
      }
      else{
        summ += a.at(i);
      }
    }
    else{
      if(summ + a.at(i) <= 0){
        cntm += -1 * (summ + a.at(i)) + 1;
        summ = 1;
      }
      else{
        summ += a.at(i);
      }
    }
  }
  cout << min(cntp, cntm) << endl;
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

typedef long long ll;

int main() {
	int N;
	ll A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	for (ll i = 0; i <= N; i++) {
		ll left = C * i - D * (N - 1 - i), right = -C * (N - 1 - i) + D * i;
		if (left <= B - A && B - A <= right) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string x ;
    cin >> x ;
    unsigned long long a = 0 ;
    for(unsigned long long i = 0 ; i < x.length() ; i++ ){
        int b = x[i] - '0';
        a+=b;
    }
    if(a%9==0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3756
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
ll INF=1e+18+1;
int N,m,s,t;
vector<pll> rootcost[100001][2];
ll d[100001][2];
void dijkstra(int start,int tuuka){
	int color[100001];
	priority_queue<pll> PQ;
	rep1(i,N){
		d[i][tuuka]=INF;
		color[i]=0;
	}
	d[start][tuuka]=0;
	color[start]=1;
	PQ.push(mp(0,start));
	while(!PQ.empty()){
		pll f=PQ.top();
		PQ.pop();
		ll u=f.second;
		color[u]=2;
		if(d[u][tuuka]< -f.first) continue;
		rep(j,rootcost[u][tuuka].size()){
			ll v=rootcost[u][tuuka][j].first;
			if(color[v]==2) continue;
			if(d[v][tuuka]>d[u][tuuka]+rootcost[u][tuuka][j].second){
				d[v][tuuka]=d[u][tuuka]+rootcost[u][tuuka][j].second;
				PQ.push(mp(-d[v][tuuka],v));
				color[v]=1;
			}
		}
	}
}
int main(){
	ll cost[100001];
	scan(N);scan(m);scan(s);scan(t);
	cost[N]=INF;
	rep(i,m){
		ll u,v;
		ll a,b;
		scan(u);scan(v);scan(a);scan(b);
		rootcost[u][0].push_back(mp(v,a));
		rootcost[v][0].push_back(mp(u,a));
		rootcost[u][1].push_back(mp(v,b));
		rootcost[v][1].push_back(mp(u,b));
	}
	dijkstra(s,0);
	dijkstra(t,1);
	for(int i=N-1;i>=0;i--){
		cost[i]=min(cost[i+1],d[i+1][0]+d[i+1][1]);
	}
	rep(i,N){
		ll syojikin=1e+15;
		prin(syojikin-cost[i]);
	}
	return 0;
}


Measured memory_bytes: 19612
#ifdef lolipop
#define _GLIBCXX_DEBUG
#endif

/*
    This ain't a milly rock
    This a money dance
    And my D' ain't hard
    That's a '30 in my pants
*/

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <set>
#include <ctime>
#include <map>
#include <random>
#include <iomanip>
#include <cmath>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <bitset>
#include <deque>
#include <utility>

#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ld long double

using namespace std;

// mt19937 rnd(time(nullptr));

inline void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

void solve() {
    int n, m;
    cin >> n >> m;
    vector <int> h(n);
    for(int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    vector < vector <int> > g(n, vector <int>(0));
    for(int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        ans++;
        for(auto u : g[i]) {
            if(h[i] <= h[u]) {
                ans--;
                break;
            }
        }
    }
    cout << ans << '\n';
}

signed main() {
#ifdef lolipop
    freopen("input.txt", "r", stdin);
#else
    fastio();
#endif

    int T = 1;
//    cin >> T;
    while(T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 9484
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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 int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

const ll mod = 1000000007;

int main(int argc, char* argv[])
{
  int h, w, k;
  cin >> h >> w >> k;

  // 横線の可能な組み合わせ
  vector<int> pat;
  for (int i = 0; i < (1 << (w - 1)); i++) {
    bool flag = true;
    for (int j = 0; j < w - 2; j++) {
      if (((i >> j) & 1) && ((i >> (j + 1)) & 1)) {
        flag = false;
      }
    }
    if (flag) pat.push_back(i);
  }

  vector<vector<ll>> dp(h+1, vector<ll>(w, 0));
  dp[0][0] = 1;

  rep(i, h) {
    rep(j, w) {
      if (dp[i][j] == 0) continue;  // 配れない
      for (auto& p : pat) {
        if (j + 1 < w && ((p >> j) & 1)) {  // 右下に移動
          dp[i+1][j+1] += dp[i][j];
          dp[i+1][j+1] %= mod;
        } else if (j - 1 >= 0 && ((p >> (j - 1)) & 1)) {  // 左下に移動
          dp[i+1][j-1] += dp[i][j];
          dp[i+1][j-1] %= mod;
        } else {  // 真下に移動
          dp[i+1][j] += dp[i][j];
          dp[i+1][j] %= mod;
        }
      }
    }
  }

  cout << dp[h][k-1] << endl;

  return 0;
}


Measured memory_bytes: 256
c=[]
for i in range(3):
    c.append(list(map(int,input().split())))
ab=[0,c[1][0]-c[0][0],c[2][0]-c[0][0],c[0][0],c[0][1],c[0][2]]
ans="Yes"
for i in range(3):
    if ans=="Yes":
        for j in range(3):
            if c[i][j]!=ab[i]+ab[3+j]:
                ans="No"
                break
print(ans)


Measured memory_bytes: 3064
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define fi first
#define se second
#define lson l,mid,o<<1
#define rson mid+1,r,o<<1|1
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define I64 ll
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int, int> P;
typedef pair<P, int> PII;
typedef pair<LL, int> PIII;
const LL INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
const int M = 1e5 + 10;
const LL mod = 998244353;
const double PI=acos(-1);
inline LL ab(LL x){return x < 0 ? -x : x;}
inline int mm(int x, int p){return x >= p ? x - p : x < 0 ? x + p : x;}

vector<int>son[N];
int deep[N];
void dfs(int o, int v){
    deep[o] = deep[v] + 1;
    for(auto it : son[o])   if(it != v) dfs(it, o);
}
int si[N];
bool flag = true;
void dfs1(int o, int v){
    si[o] = 1;
    int u = 0;
    for(auto it : son[o]){
        if(it == v) continue;
        dfs1(it, o);
        si[o] += si[it];
        if(si[it] > 1)  u++;
    }
    if(u > 1)   flag = false;
}
vector<int>ans, vc;
void pri(int o, int v){
    int tot = 1, to, tt;
   // printf("o = %d, v = %d\n", o, v);
    while(true){
        to = -1, tt = 0;
        for(auto it : son[o]){
            if(it == v) continue;
            tt++;
            if(to == -1 || si[to] < si[it]) to = it;
        }
        for(int i = 1; i < tt; ++i) ans.push_back(tot + i);
        ans.push_back(tot);
        if(!tt) break;
        tot += tt;
        v = o;
        o = to;
    }
    tot = 1, v = 0;
    dfs1(o, 0);
    while(true){
      //  printf("o = %d, v = %d\n", o, v);
        to = -1, tt = 0;
        for(auto it : son[o]){
            if(it == v) continue;
            tt++;
            if(to == -1 || si[to] < si[it]) to = it;
        }
        for(int i = 1; i < tt; ++i) vc.push_back(tot + i);
        vc.push_back(tot);
        if(!tt) break;
        tot += tt;
        v = o;
        o = to;
    }
    bool ff = true;
    for(int i = 0; i < ans.size(); ++i){
      //  printf("%d %d\n", ans[i], vc[i]);
        if(vc[i] != ans[i]) {
            if(vc[i] < ans[i])  ff = false;
            break;
        }
    }
    if(ff)    for(int i = 0; i < ans.size(); ++i) printf("%d%c", ans[i], " \n"[i == ans.size() - 1]);
    else    for(int i = 0; i < ans.size(); ++i) printf("%d%c", vc[i], " \n"[i == ans.size() - 1]);
}
int main()
{
    int n, u, v;
    scanf("%d", &n);
    for(int i = 1; i < n; ++i){
        scanf("%d%d", &u, &v);
        son[u].push_back(v);
        son[v].push_back(u);
    }
    dfs(1, 0);
    int root = 1;
    for(int i = 2; i <= n; ++i) if(deep[i] > deep[root])    root = i;
    dfs1(root, 0);
    if(flag)    pri(root, 0);
    else    puts("-1");
    return 0;
}
/*
10
1 2
2 3
2 4
4 5
5 6
5 8
8 7
8 9
10 8
*/


Measured memory_bytes: 11768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,w;
    cin>>n>>w;
    vector<ll>W(n),V(n);
    for(ll i=0;i<n;i++)
    cin>>W[i]>>V[i];
    vector<ll>dp(w+1,0);
    for(ll i=1;i<=n;i++)
    {
        vector<ll>dp1=dp;
        for(ll j=1;j<=w;j++)
        {
            if(j>=W[i-1])
                dp[j]=V[i-1]+dp1[j-W[i-1]];
            dp[j]=max(dp[j],dp1[j]);
        }
    }
    cout<<dp[w];
}



Measured memory_bytes: 1804
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) != s.charAt(i+1)) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 22608
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;  //これで"std::cout"が"cout"と書ける

//MACRO
typedef long long ll;                  //64bit以上を表現可能な型
#define INF 100000000                  //ほぼ無限
#define itn int                        //タイポ対策
#define ALL(x) (x).begin(), (x).end()  //sort(all(x))などとする
#define SZ(x) ((int)(x).size())        //size()簡略化
//repetition
#define FOR(i, p, b) for (int i = (p); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define repR(i, n) for (int i = n; i >= 0; i--)
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \<< " " << __FILE__ << endl;
template <class T>
bool chMAX(T &a, const T &b) {  //aよりbが大きければaに代入
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chMIN(T &a, const T &b) {  //aよりbが小さければaに代入
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

//
//
//

int main() {
    int n, alice_pt = 0, bob_pt = 0;
    cin >> n;
    int a[n];

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

    sort(a, a + n, greater<int>());  //降順にソート

    rep(i, n) {
        if (i % 2 == 0) {  //配列が0から始まるので奇数偶数が反転する
            alice_pt += a[i];
        } else {
            bob_pt += a[i];
        }
    }
    cout << alice_pt - bob_pt << endl;

}

Measured memory_bytes: 256
sx,sy,tx,ty = map(int,input().split())
dx,dy = tx-sx, ty-sy

if dx != 0 and dy != 0:
    d = ['R','U','L','D']
    root = [d[0]]*dx + [d[1]]*dy + [d[2]]*dx + [d[3]]*dy
    root += [d[3]] + [d[0]]*(dx+1) + [d[1]]*(dy+1) + [d[2]]
    root += [d[1]] + [d[2]]*(dx+1) + [d[3]]*(dy+1) + [d[0]]

print(''.join(root))

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

public class Main {
    public static void main(String[] args) throws Exception {
        /*new Thread(null, new Runnable() {
            @Override
            public void run() {
                try {
                    new Solver().solve();
                } catch (Exception e) {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }, "Solver", 1l << 30).start();*/

        new Solver().solve();
    }
}

class Solver {
    IO io = new IO(System.in, System.out);

    int N, A, B;

    void solve() throws Exception {
        int i, j, k;

        N = io.nextInt(); A = io.nextInt(); B = io.nextInt();
        int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
        for (i = 0; i <= N; ++i) {
            if (i <= Math.min(A, B) && A + B - i <= N) {
                min = Math.min(min, i);
                max = Math.max(max, i);
            }
        }

        io.print(max + " " + min);

        io.flush();
    }
}


class IO {
    static byte[] buf = new byte[2048];
    static int index, total;
    static InputStream in;
    static BufferedWriter bw;


    IO(InputStream is, OutputStream os) {
        try {
            in = is;
            bw = new BufferedWriter(new OutputStreamWriter(os));
        } catch (Exception e) {
        }
    }

    IO(String inputFile, String outputFile) {
        try {
            in = new FileInputStream(inputFile);
            bw = new BufferedWriter(new OutputStreamWriter(
                    new FileOutputStream(outputFile)));
        } catch (Exception e) {
        }
    }

    int scan() throws Exception {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0)
                return -1;
        }
        return buf[index++];
    }

    String next() throws Exception {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan())
            sb.append((char) c);
        return sb.toString();
    }

    int nextInt() throws Exception {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+')
            c = scan();
        for (; c >= '0' && c <= '9'; c = scan())
            val = (val << 3) + (val << 1) + (c & 15);
        return neg ? -val : val;
    }

    long nextLong() throws Exception {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+')
            c = scan();
        for (; c >= '0' && c <= '9'; c = scan())
            val = (val << 3) + (val << 1) + (c & 15);
        return neg ? -val : val;
    }

    void print(Object a) throws Exception {
        bw.write(a.toString());
    }

    void println() throws Exception {
        bw.write("\n");
    }

    void println(Object a) throws Exception {
        print(a);
        println();
    }

    void flush() throws Exception {
        bw.flush();
        bw.close();
    }
}

Measured memory_bytes: 21460
#N=int(input())
#A=list(map(int,input().split()))
def kyori(a,b):
	#print("plus:",a,b,"->",((a[0]-b[0])**2+(a[0]-b[0])**2)**0.5)
	return ((a[0]-b[0])**2+(a[1]-b[1])**2)**0.5
def bikkuri(n):
	if(n==1):
		return 1
	else:
		return n*bikkuri(n-1)
N=int(input())
zahyo=[[0,0]]*8
for i in range(N):
	zahyo[i]=list(map(int,input().split()))
goukei=0
for i in range(N):
	for j in range(N):
		goukei+=kyori(zahyo[i],zahyo[j])
print(goukei/N)
#N!*(N-1)個で平均はこれを(N!)で割る
#値はN*(N-1)/2種類
#つまり合計*(N-1)!/(N)!

	


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

using namespace std;

int main() 
{
    int n, m, a, b, i;
    scanf("%d", &n);
    
    vector<int> v;
    
    for(i = 0; i < n; i++)
    {
        scanf("%d", &m);
        v.push_back(m);
    }
    
    scanf("%d", &m);
    
    for(i = 0; i < m; i++)
    {
        scanf("%d %d", &a, &b);
        reverse(v.begin() + a, v.begin() + b);
    }
    
    for(i = 0; i < n-1; i++)
        printf("%d ", v[i]);
    printf("%d\n", v[i]);
    
    return 0;
}


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

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;

///////////////////////////////////
///// for any code taken from cheatsheet

/////

vector<ii> vec;
int X[100003], L[100003];


int main()
{
	// freopen("input.in", "r", stdin);
	
	int n; scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%d %d", &X[i], &L[i]);
		vec.push_back({X[i]+L[i], X[i]-L[i]});
	}
	sort(vec.begin(), vec.end());

	int bef = -1e9-5;
	int res = 0;
	for(int i  = 0; i < n; i++)
	{
		ii num = vec[i];
		if(num.se >= bef)
		{
			bef = num.fi;
			res++;
		}
	}
	printf("%d\n", res);
}

Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const 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;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i,j;
    string s;
    cin >> s;
    int cnt = 0;
    for(i=0;i<s.size();i++){
        cnt += s[i]-'0';
    }
    if(cnt%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 3724
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
int n,m,k,f[N],ans;char str[N];
int main(){
	scanf("%d%d%s",&n,&m,str+1);
	k=n;while(m&&str[m]==str[1])--m;
	if(!m)ans=1;
	for(int i=1,j=1;i<=m;i=j=j+1)
		if(str[i]==str[1]){
			while(j<m&&str[j+1]==str[1])++j;
			if(i==1)
				if(j-i+1&1)k=min(k,j-i+1);
				else k=min(k,j-i+2);
			else
				if(j-i+1&1)k=min(k,j-i+1);
		}
	if(k==n){
		for(int i=f[0]=1,j=0;i<=n;++i){
			f[i]=j;j=(j+f[i-1])%mod;
		}
		for(int i=2;i<=n;++i)
			ans=(ans+1ll*i*f[n-i])%mod;
	}else{
		++k;
		for(int i=2,j=f[0]=1;i<=n;i+=2){
			f[i]=j;j=(j+f[i])%mod;
			if(i>=k)j=(j-f[i-k]+mod)%mod;
		}
		for(int i=2;i<=k;i+=2)
			ans=(ans+1ll*i*f[n-i])%mod;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1152
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def main():
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())
    px = [list(map(int, input().split())) for i in range(m)]

    for i in range(m):
        ans = 0
        for j in range(n):
            if px[i][0] == j + 1:
                ans += px[i][1]
            else:
                ans += t[j]
        print(ans)


if __name__ == '__main__':
    main()


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

int G[505][505];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N,M,Q;
    cin>>N>>M>>Q;
    rep(i,N)rep(j,N){
        G[i][j] = 0;
    }
    vector<int> L(M),R(M),p(Q),q(Q);
    rep(i,M){
        cin>>L[i]>>R[i];
        G[L[i]][R[i]]++;;
    }
    rep(i, Q){
        cin>>p[i]>>q[i];
    }
    rep1(i,N+1)rep1(j,N+1){
        G[i][j] += G[i-1][j];
        G[i][j] += G[i][j-1];
        G[i][j] -= G[i-1][j-1];
    }
    rep(i,Q){
        int ans = G[q[i]][q[i]] - G[p[i]-1][q[i]] - G[q[i]][p[i]-1] + G[p[i]-1][p[i]-1];
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 4224
A, op, B = input().split()
A = int(A)
B = int(B)

while(op != "?"):
    if op == "+":
        print(A + B)
    elif op == "-":
        print(A - B)
    elif op == "*":
        print(A * B)
    elif op == "/":
        print(int(A / B))
    A, op, B = input().split()
    A = int(A)
    B = int(B)



Measured memory_bytes: 5596
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String s1 = s.next();
        long f=0;
        for(int i=0; i<s1.length();i++)
        {
            f+=(s1.charAt(i)-'0');
        }
        if(f % 9 == 0){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
    }


Measured memory_bytes: 40140
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: i16 = s.next().unwrap().parse().unwrap();
	let a: Vec<i16> = s.map(|a| a.parse().unwrap()).collect();
	let s: i16 = a.iter().sum();
	let ans = a.into_iter().enumerate().fold((0, std::i16::MAX), |r, (i, a)|{
		if (a * n - s).abs() < r.1 {
			(i, (a * n - s).abs())
		} else {
			r
		}
	}).0;
	println!("{}", ans);
}


Measured memory_bytes: 4352
"use strict";
    
const main = arg => {
    const N  = arg.split("\n")[0];
    const lr = arg.split("\n").slice(1, N + 1);
    let answer = 0;
    
    for(let i=0; i<N; i++) {
        answer += parseInt(lr[i].split(" ")[1]) - parseInt(lr[i].split(" ")[0]) + 1;
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

void mulmat(vector<vector<int>> &a,vector<vector<int>> &b, int m){
  int n = b.size();
  vector<vector<int>> ans(n,vector<int>(n,0));
  rep(i,n){
    rep(j,n){
      rep(k,n){
        ans[i][j]=(ans[i][j]+a[i][k]*b[k][j])%m;
      }
    }
  }
  b=ans;
}

void mulv(vector<vector<int>> &a, vector<int> &v, int m){
  int n = v.size();
  vector<int> ans(n,0);
  rep(i,n){
    rep(j,n){
      ans[i]=(ans[i]+a[i][j]*v[j])%m;
    }
  }
  v=ans;
}

void solve(vector<int> &cell, int a, int b, int c, int t, int m){
  int n = cell.size();
  vector<vector<int>> mat(n,vector<int>(n,0));
  rep(i,n){
    mat[i][i]=b;
    if(i>0) mat[i][i-1]=a;
    if(i<n-1) mat[i][i+1]=c;
  }
  while(t){
    if(t&1){
      mulv(mat,cell,m);
    }
    mulmat(mat,mat,m);
    t>>=1;
  }
}

int main(){
  while(1){
    int n,m,a,b,c,t;
    cin >> n >> m >> a >> b >> c >> t;
    if(n==0) return 0;
    vector<int> cell(n);
    rep(i,n) cin >> cell[i];
    solve(cell,a,b,c,t,m);
    rep(i,n){
      cout << cell[i];
      if(i<n-1) cout << " ";
      else cout << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3100
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 100000000;

int main(){
    int d,g;cin>>d>>g;
    vector<int> p(d);
    vector<int> c(d);
    for(int i=0;i<d;i++){
        cin>>p[i]; cin>>c[i];
    }
    int ans = INF;
    for (int bit=0;bit<(1<<d);bit++){
        int sum = 0;
        int num = 0;
        int rest = -1;
        for (int i=0;i<d;i++){
            if(bit &(1<<i)){
                sum+=p[i]*100*(i+1)+c[i];
                num+=p[i];
            }else{
                rest = i;
            }
        }
        if (sum<g){
            double x = g-sum;
            int ne = ceil(x/(100*(rest+1)));
            if (ne>=p[rest]) continue;
            num += ne;
        }
        ans = min(ans,num);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000000000
#define INF 1000000
#define M 1000000007
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std; 
int main(){
    fast_io
    ll x,y;
    cin>>x>>y;
    if(y%2 == 0 && y<= (4*x) && y>=(2*x)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3652
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func main() {
	defer write.Flush()

	var n int
	fmt.Fscan(read, &n)

	var s, t string
	fmt.Fscan(read, &s, &t)

	for i := 0; i < n; i++ {
		fmt.Print(s[i : i+1])
		fmt.Print(t[i : i+1])
	}
	fmt.Println("")
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
   long n,m,k,i,j,a[200000],b[200000],ans,kk,aa;

   scanf("%ld %ld %ld",&n,&m,&k);
   for (i=0;i<n;i++) {
      scanf("%ld",&j);
      if (i>0) a[i]=a[i-1]+j;
      else     a[0]=j;
   }
   for (i=0;i<m;i++) {
      scanf("%ld",&j);
      if (i>0) b[i]=b[i-1]+j;
      else     b[0]=j;
   }
   ans=0;
   for (j=0;j<m;j++)
      if (b[j]>k) break;
   j--;
   for (i=0;i<=n;i++) {
      kk=k;
      if (i>0) kk-=a[i-1];
      if (kk<0) break;
      while (j>=0 && kk<b[j]) j--; 
      aa=i+j+1;
      if (ans<aa) ans=aa;
   }
   printf("%ld\n",ans);
   return 0;
}


Measured memory_bytes: 4856
#include <bits/stdc++.h>
#include <vector>
 
using namespace std;
const double PI=3.14159265358979323846;
#define ll long long;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {

	string s;
	cin >> s;

	int n = s.size();

	long sum = 0;
	for (int i = 0; i < (1 << n - 1); i++) {

		vector<long> pos;
		long t = s[0] - '0';

		for (int j = 0; j < n - 1; j++) {
			if (i & (1 << j)) {
				pos.push_back(t);
				t = s[j + 1] - '0';
			} else {
				t = t * 10 + (s[j + 1] - '0');
			}
		}
		pos.push_back(t);

		rep(i, pos.size()) sum += pos[i];
	}
	printf("%ld\n", sum);
}

//printf("%ld\n", ans);

Measured memory_bytes: 256