akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

ll modpow(ll x,int n){
  if(n==0)return 1;
  ll ret=modpow(x*x%MOD,n/2);
  if(n&1)ret=(ret*x)%MOD;
  return ret;
}

int main(){
  string S;cin>>S;
  int N = S.length();
  ll A=0,AB=0,ABC=0;
  ll Q=0,AQ=0,QB=0,QQ=0,AQC=0,QBC=0,QQC=0;
  ll ABQ=0,AQQ=0,QBQ=0,QQQ=0;
  repeat(i,N){
    if(S[i]=='A'){
      A = (A+1)%MOD;
    }else if(S[i]=='B'){
      AB = (AB+A)%MOD;
      QB = (QB+Q)%MOD;
    }else if(S[i]=='C'){
      ABC = (ABC+AB)%MOD;
      AQC = (AQC+AQ)%MOD;
      QBC = (QBC+QB)%MOD;
      QQC = (QQC+QQ)%MOD;
    }else{
      QQQ = (QQQ+QQ)%MOD;
      QBQ = (QBQ+QB)%MOD;
      AQQ = (AQQ+AQ)%MOD;
      ABQ = (ABQ+AB)%MOD;
      QQ = (QQ+Q)%MOD;
      AQ = (AQ+A)%MOD;
      Q = (Q+1)%MOD;
    }
  }
  ll ans = 0;
  ans = (ans+ABC*modpow(3,Q)%MOD)%MOD;
  ans = (ans+(QBC+AQC+ABQ)%MOD*modpow(3,Q-1)%MOD)%MOD;
  ans = (ans+(AQQ+QBQ+QQC)%MOD*modpow(3,Q-2)%MOD)%MOD;
  ans = (ans+QQQ*modpow(3,Q-3))%MOD;
  cout << ans << endl;

  return 0;
}


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<P>> v(n,vector<P>(0));
  for(int i=0; i<m; ++i){
    int a, b;
    cin >> a >> b;
    --a; --b;
    v[a].push_back(make_pair(b,i));
    v[b].push_back(make_pair(a,i));
  }
  int ans = 0;
  for(int i=0; i<m; ++i){
    queue<int> que;
    que.push(0);
    vector<bool> ok(n,false), alr(n,true);
    alr[0] = false;
    ok[0] = true;
    while(!que.empty()){
      int x = que.front();
      que.pop();
      for(auto p:v[x]){
        if(p.second == i)continue;
        if(alr[p.first]){
          que.push(p.first);
          alr[p.first] = false;
          ok[p.first] = true;
        }
      }
    }
    for(int j=0; j<n; ++j){
      if(!ok[j]){
        ++ans;
        break;
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e5 + 5;

int n, a[N], cnt[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);

    cin >> n;

    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ++cnt[a[i]];
        sum += a[i];
    }

    int q;
    cin >> q;

    while (q--) {
        ll l, r;
        cin >> l >> r;
        sum -= l * cnt[l];
        sum += r * cnt[l];
        cnt[r] += cnt[l];
        cnt[l] = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void OUT(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void OUT(T t,Ts... ts){cout<<t<<" ";OUT(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type FILL(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type FILL(T&t,const V&v){for(auto &e:t)FILL(e,v);}
constexpr long long INF = 1e18;


signed main(){
	int N;
	string s,t,ret="";
	cin>>N>>s>>t;
	REP(i,N){
		ret+=s[i];
		ret+=t[i];
	}
	OUT(ret);
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){

  string s;
  cin >> s;
  string ans;

  for (int i = 0; i < s.size(); i++) {
    if(i%2 == 0) ans += s[i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  string s=to_string(n);
  Int x=0;
  for(char c:s) x+=c-'0';
  cout<<(n%x?"No":"Yes")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    while (true) {
        int a, b; char op;
        std::cin >> a >> op >> b;
        if (op == '?') {
            break;
        }
        switch (op) {
            case '+':
                std::cout << a + b << '\n';
                break;
            case '-':
                std::cout << a - b << '\n';
                break;
            case '*':
                std::cout << a * b << '\n';
                break;
            case '/':
                std::cout << a / b << '\n';
                break;
            default:
                break;
        }
    }
    return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main()
{
	map<string, int> card;
	
	int N, M;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		string str;
		cin >> str;
		card[str]++;
	}
	cin >> M;
	for (int i = 0; i < M; i++)
	{
		string str;
		cin >> str;
		card[str]--;
	}
	int mx = 0;
	for (map<string, int>::iterator it = card.begin(); it != card.end(); it++)
	{
		if (mx < it->second)
			mx = it->second;
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define f first
#define s second
#define mk make_pair
using namespace std;
#define int long long
typedef pair<int,int>P;
int a[203][203],t[10][10];
int ans,n,m,r,b[100],x,y,c;
bool use[10];
void dfs(int v,int d,int di){
  if(d==r-1){
    ans=min(di,ans);
  }
  else{
    r(i,r)if(!use[i]){
      use[i]=1;
      dfs(i,d+1,di+t[v][i]);
      use[i]=0;
    }
  }
}
main(){
  r(i,203)r(j,203)a[i][j]=1e11;
  cin>>n>>m>>r;
  r(i,r)cin>>b[i];
  r(i,m){
    cin>>x>>y>>c;
    a[x][y]=a[y][x]=c;
  }
  r(o,n+1)r(i,n+1)r(j,n+1)
    a[i][j]=min(a[i][j],a[i][o]+a[o][j]);
  r(i,r){
    r(j,r){
      t[i][j]=a[b[i]][b[j]];
    }
  }
  ans=1e8;
  r(i,r){
    use[i]=1;
    dfs(i,0,0);
    use[i]=0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define f first
#define s second
using namespace std;
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;
typedef pair<int,int> pii;
typedef vector<int> vi;

map<ll, bool> bylo;
ll a;

ll best(ll n) {
	ll res = 0;
	for (ll i = 2; i <= sqrt(n); i ++) {
		if (n % i == 0) {
			//cout << "i : " << i << '\n';
			ll j = 1;
			while (n % i == 0) {
				n /= i;
				//cout << n << '\n';
				if (!bylo[(ll)pow(i, j)]) {
					bylo[(ll)pow(i, j)] = true;
					//cout << (ll)pow(i, j) << '\n';
					res ++;
					j = 0;
				}
				j ++;
			}
		}
	}
	if (n > 1) {
		ll j = 1;
		if (!bylo[(ll)pow(n, j)]) {
			bylo[(ll)pow(n, j)] = true;
			//cout << (ll)pow(i, j) << '\n';
			res ++;
			j = 0;
		}
	}
	return res;
}

void solve() {
	ll n; cin >> n;
	ll ans = best(n);
	cout << ans << '\n';
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int q = 1;
	//cin >> q;
	while (q--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 4124
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n;
vector<pair<string,pair<int,int> > >v;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		string s;int c;cin>>s>>c;
		v.push_back(make_pair(s,make_pair(-c,i)));
	}
	sort(v.begin(),v.end());
	for(auto p:v){
		cout<<p.second.second<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
/**
 *      purpose : ABC 133 B
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64_t INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

bool isnizyou(int n) {
  for (int i = 1; i * i <= n; ++i) {
    if (i * i == n) return true;
  }
  return false;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, d; cin >> n >> d;
  double x[n][d];
  rep(i, n) {
    rep(j, d) cin >> x[i][j];
  }

  int cnt = 0;

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int t = 0;
      rep(k, d) {
        t += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      if (isnizyou(t)) ++cnt;
    }
  }
  print(cnt);

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

import sys
import re
import argparse
import math
import decimal


def f(a: int, b_str: str) -> int:
    """
    >>> f(198, '1.10')
    217
    >>> f(1, '0.1')
    0
    >>> f(1000000000000000, '9.99')
    9990000000000000
    >>> f(0, '0.0')
    0
    >>> f(999999999999900, '9.25')
    9249999999999075
    >>> f(1000000000000000, '9.95')
    9950000000000000
    """
    b = decimal.Decimal(b_str)
    result = math.floor(a * b)
    return result


def main():
    line = sys.stdin.readline()
    a_str, b_str = line.rstrip().split(' ')
    a = int(a_str)
    print(f(a, b_str))


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--doctest', action='store_true', default=False)
    args = parser.parse_args()
    if args.doctest:
        import doctest
        doctest.testmod(verbose=True)
        sys.exit()
    main()

Measured memory_bytes: 11836
from collections import Counter
N = int(input())

INF = 10**9 + 7

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = Counter({})
for i in range(1, N+1):
  c += Counter(prime_factorize(i))

ans = 1
for i in c.values():
  ans = (ans * (i + 1)) % INF
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define N 10000005
using namespace std;
int m[N];
int a,b,cnt,ans1,ans2;

int main(){
  while(1){
    cin>>a>>b;
    if(!a&&!b)break;
    memset(m,-1,sizeof(m));
    a%=b;
    cnt=0;
    while(1){
      a*=10;
      if(m[a]!=-1){
	ans1=m[a],ans2=cnt-m[a];
	break;
      }
      m[a]=cnt;
      a%=b;
      if(!a){
	ans1=cnt+1,ans2=0;
	break;
      }      
      cnt++;
    }
    cout<<ans1<<' '<<ans2<<endl;
  }
  return 0;
}

Measured memory_bytes: 42032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			String a = in.nextString();
			String b = in.nextString();
			String c = in.nextString();

			boolean ok = a.charAt(a.length()-1) == b.charAt(0)
					&& c.charAt(0) == b.charAt(b.length()-1);

			out.println(ok ? "YES" : "NO");

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

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

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

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

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 22868
#include"bits/stdc++.h"
#include<valarray>

using namespace std;

#define MAX 100002

int n;

vector<pair<int,int> > v;
pair<int,int> mg(pair<int,int> a, pair<int,int> b){
	return make_pair(max(a.first,b.first),min(a.second,b.second));
}
pair<int,int> im[MAX];
pair<int,int> rm[MAX];
inline int rng(pair<int,int> a){
	return max(0,a.second-a.first+1);
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		v.push_back(make_pair(l,r));
	}
	sort(v.begin(),v.end());
	im[0]=make_pair(0,INT_MAX);
	for(int i=1;i<n;i++){
		im[i]=mg(im[i-1],v[i-1]);
	}
	rm[v.size()+1]=make_pair(0,INT_MAX);
	for(int i=n;i>0;i--){
		rm[i]=mg(rm[i+1],v[i-1]);
	}
	int ans=0;
	for(int i=1;i<n;i++){
		ans=max(ans,rng(im[i])+rng(rm[i+1]));
	}
	for(int i=1;i<=n;i++){
		ans=max(ans,rng(mg(im[i-1],rm[i+1]))+rng(v[i-1]));
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define pi 2.0*acos(0.0)
#define INTM 1e18
#define mod 1e9+7
#define FOR(i,j,n)    for(ll i=j;i<n;i++)
#define RFOR(i,j,n)    for(ll i=j;i>=n;i--)

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;

int main(){
    ll n;
    string a,b;
    cin>>n;
    cin>>a>>b;
    FOR(i,0,a.size()){
        cout<<a[i]<<b[i];
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	// #ifndef ONLINE_JUDGE
 //       // for getting input from input.txt
 //       freopen("input.txt", "r", stdin);
 //       // for writing output to output.txt
 //       freopen("output.txt", "w", stdout);
 //      #endif
	int a,t=0,b,sum=0;
	cin>>a>>b;
	if(a ==b) {
		cout<<a+b<<"\n";
	}
	else if(b-a == 1 || a-b == 1){
		cout<<a+b<<"\n";
	}
	else{
		cout<<max(a,b)+(max(a,b)-1)<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	// Code for B - Picture Frame
	var H, W int
	fmt.Scanf("%d %d", &H, &W)

	S := make([]string, H+2)
	S[0] = strings.Repeat("#", W+2)

	var temp string
	for i := 1; i <= H; i++ {
		fmt.Scanf("%s", &temp)
		S[i] = "#" + temp + "#"
	}
	S[H+1] = strings.Repeat("#", W+2)

	for i := 0; i <= H+1; i++ {
		fmt.Println(S[i])
	}

}


Measured memory_bytes: 1844
//54
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    bool h[15]={};
    string s[]={"Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge", "Paper", "Air", "Water", "Dragon", "Devil", "Lightning","Gun"};
    for(int i=0;i<n;i++){
      string p;
      cin>>p;
      h[find(s,s+15,p)-s]=true;
    }
    int x=-1;
    for(int i=0;i<15;i++){
      if(h[i]){
	bool l=false;
	bool w=false;
	for(int j=1;j<=7;j++){
	  l|=h[(i-j+15)%15];
	  w|=h[(i+j)%15];
	}
	if(!l&&w){
	  x=i;
	}
      }
    }
    cout<<((x==-1)?"Draw":s[x])<<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<cmath>
#include<vector>
#include<stack>
#include<map>
#include<set>
#define Run(i,l,r) for(int i=l;i<=r;i++)
#define Don(i,l,r) for(int i=l;i>=r;i--)
#define ll long long
#define ld long double
#define inf 0x3f3f3f3f
#define mk make_pair
#define fir first
#define sec second
using namespace std;
const int N=200010;
int n,m,a[N];
ll sum1[N],sum2[N];
int main(){
//	freopen("B.in","r",stdin);
//	freopen("B.out","w",stdout);
	scanf("%d%d",&m,&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum1[i]=sum1[i-1]+a[i];
		sum2[i]=sum2[i-1]+m-a[i];
	}
	ll ans=0; 
	for(int i=1;i<n;i++){
		int mn = min(i,n-i);
		ll t1 = sum1[i] - sum1[i - mn], t2 = sum2[i + mn] - sum2[i];
		ll p1 = a[i] , p2 = m - a[i+1];
		ans = max(ans , (t1 + t2) * 2 - min(p1,p2) );
	}
	for(int i=1;i<=n;i++){
		int mn = min(i-1,n-i);
		ll t1 = sum1[i-1] - sum1[i-1-mn] , t2 = sum2[i+mn] - sum2[i]; 
		ll p1 = a[i] , p2 = m - a[i];
		ans = max(ans , (t1 + t2) * 2 + max(p1,p2));
	}
	cout<<ans<<endl;
	return 0;
}//by tkys_Austin;



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

Measured memory_bytes: 3684
(let ((W (read))
      (H (read))
      (N (read)))

  (setf canvas (do ((l nil (cons (cons x y) l))
		    (x 1 (1+ x))
		    (y 1 y) )
		   ((> y H) (cdr l))
		 (when (> x W)
		   (setf x 1)
		   (setf y (1+ y)) )))
  (dotimes (i N)
    (let ((x (read))
	  (y (read))
	  (a (read)))
      (cond ((= a 1) (setf canvas (remove-if #'(lambda (a) (<= (car a) x)) canvas)))
	    ((= a 2) (setf canvas (remove-if #'(lambda (a) (> (car a) x)) canvas)))
	    ((= a 3) (setf canvas (remove-if #'(lambda (a) (<= (cdr a) y)) canvas)))
	    ((= a 4) (setf canvas (remove-if #'(lambda (a) (> (cdr a) y)) canvas))) )))
  (princ (length canvas)))

Measured memory_bytes: 9444
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;



int main() {
  int n,X;
  scanf("%d%d",&n,&X);
  vi a(n);
  cin>>a;
  reverse(rng(a));
  vl d(n+1);
  rep(i,n) d[i+1] = d[i]+a[i];
  ll ans = LINF;
  rrep(i,n) {
    ll now = (ll)X*i, k = 3;
    for (int j = 0; j < n; j += i) {
      int r = min(j+i,n);
      if (!j) now += d[r]*2;
      now += (d[r]-d[j])*k;
      mins(now,LINF);
      k += 2;
    }
    mins(ans,now);
  }
  ans += (ll)X*n;
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 2560
let () = 
    let (s, h, c, d) = (0, 1, 2, 3) in
    let arr = Array.make_matrix 4 13 false in
    let n = read_int () in
    for _ = 1 to n do 
        let (a, j) = Scanf.scanf "%c %d\n" (fun x y -> (x, y - 1)) in
	match a with
            | 'S' -> arr.(s).(j) <- true
            | 'H' -> arr.(h).(j) <- true
            | 'C' -> arr.(c).(j) <- true
            | 'D' -> arr.(d).(j) <- true
            | _   -> ()
    done;
    let f c = Array.iteri (fun i v -> if not v then Printf.printf "%c %d\n" c (i + 1) ); in
    f 'S' arr.(s);
    f 'H' arr.(h);
    f 'C' arr.(c);
    f 'D' arr.(d);
;;


Measured memory_bytes: 2444
#include<iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include <functional>
using namespace std;

int main(void) {
	string s;
	cin >> s;
	for (int i = 0;i < s.length();i++) {
		if (s[i] == '1')
			cout << '9' ;
		if (s[i] == '9')
			cout << '1';
	}
	cout << endl;
	return 0;

}


Measured memory_bytes: 768
#include<stdio.h>
int main(void)
{
	int a,b,c,cnt=0;
	scanf("%d%d%d",&a,&b,&c);
	if(a!=b){
		cnt++;
	}
	if(a!=c){
		cnt++;
	}
	if(b!=c){
		cnt++;
	}
	if(a==b&&a==c){
		cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

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

int main(void)
{
  int i,j,k,l,m,h;
  char st[1000000];
  
  scanf("%s",st);

  k=0;
  j=0;
  for(i=0;i<=strlen(st)-1;i++)
    {
		l=0;
		m=0;
		if(st[i]=='O')
		{
			j++;
		}
		else if(st[i]=='I')
		{
			if(j!=0 && i-2*j>=0 && (i+j-1)<=(strlen(st)-1))
			{
					for(h=i-j-1;h>=i-2*j;h--)
					{
						if(st[h]!='J') l=1;
					}
					for(h=i;h<=i+j-1;h++)
					{
						if(st[h]!='I') m=1;
					}
			        if(l==0 && m==0)
			        {
				        if(k<j) k=j;
			        }
			}
			j=0;
		}
		else j=0;
    }
			
  printf("%d\n",k);
  return 0;
}

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

int n;
long long ans=0;
long long a[200003];

int main(){
	cin >> n;
	for (int i=0;i<n;i++) cin >> a[i];
	sort(a,a+n,greater<long long>());
	priority_queue<long long>pq;
	for (int i=0;i<n;i++){
		if (i==0) pq.push(a[i]);
		else{
			ans+=pq.top();
			pq.pop();
			pq.push(a[i]);
			pq.push(a[i]);
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 6924
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	string s1,s2,s3;
	cin >> s1 >> s2 >> s3;
	cout << static_cast<char>(s1.c_str()[0]-'a'+'A') << static_cast<char>(s2.c_str()[0]-'a'+'A') << static_cast<char>(s3.c_str()[0]-'a'+'A') << endl;
}

Measured memory_bytes: 3536
/**************** Geometrical Library ****************/

#include<cmath>
#include<vector>
#include<algorithm>

#define	EPS	1e-8

enum {CCW=1,CW=-1,ON=0};

#define	mp	make_pair
#define	pb	push_back

using namespace std;

class Point{
public:
	double x,y;
	Point(){}
	Point(double xx,double yy):x(xx),y(yy){}
};

class Line:public vector<Point>{
public:
	Line(const Point &a,const Point &b){
		pb(a),pb(b);
	}
};

class Segment:public Line{
public:
	Segment(const Point &a,const Point &b):Line(a,b){}
};

class Polygon:public vector<Point>{};

class Circle{
public:
	Point c;
	double r;
	Circle(const Point &cc,double rr) : c(cc),r(rr){}
};

Point &operator +=(Point &a,const Point &b){
	a.x+=b.x,a.y+=b.y;
	return a;
}

Point &operator -=(Point &a,const Point &b){
	a.x-=b.x,a.y-=b.y;
	return a;
}

Point &operator *=(Point &a,double c){
	a.x*=c,a.y*=c;
	return a;
}

Point &operator /=(Point &a,double c){
	a.x/=c,a.y/=c;
	return a;
}

Point operator +(const Point &a,const Point &b){
	Point c=a;
	return c+=b;
}

Point operator -(const Point &a,const Point &b){
	Point c=a;
	return c-=b;
}

Point operator *(double c,const Point &a){
	Point b=a;
	return b*=c;
}

Point operator /(const Point &a,double c){
	Point b=a;
	return b/=c;
}

bool operator <(const Point &a,const Point &b){
	return (a.x==b.x)?(a.y<b.y):(a.x<b.x);
}

bool operator >(const Point &a,const Point &b){
	return b<a;
}

double cross(const Point &a,const Point &b){
	return a.x*b.y-a.y*b.x;
}

double area(const Polygon &pl){
	int n=pl.size();
	double a=0;
	for(int i=0;i<n;i++)	a+=cross(pl[i],pl[(i+1)%n]);
	return abs(a)/2;
}

/**************** Library END ****************/

#include<cstdio>

int main(){
	Polygon pl;
	for(double x,y;~scanf("%lf%*c%lf",&x,&y);)	pl.pb(Point(x,y));
	printf("%f\n",area(pl));
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
signed main(){
  int a;
  cin>>a;
  if(a<1200){
    cout<<"ABC\n";
  }
  else{
    if(a<2800){
      cout<<"ARC\n";
    }
    else{
      cout<<"AGC\n";
    }
  }
  return(0);
}

Measured memory_bytes: 256
n = int(raw_input())
for l in range(n):
    x1,y1,x2,y2,x3,y3,x4,y4 = map(float,raw_input().split())
    if abs((y4-y3)*(x2-x1)-(y2-y1)*(x4-x3))< 1e-10:
        print "YES"
    else:
        print "NO"

Measured memory_bytes: 6320
<?php
  fscanf(STDIN, "%d", $N);
  $ans = 0;
  $x = min(9, $N);
  $ans += $x;
  if ($N >= 100) {
    $y = min(999, $N);
    $ans += $y - 99;
  }
  if ($N >= 10000) {
    $z = min(99999, $N);
    $ans += $z - 9999;
  }
  echo $ans;

Measured memory_bytes: 4856
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <numeric>

using namespace std;

long long gcd(long long a, long long b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}
int main() {
	long long i, j, k;
	long long n, m, len = 0;
	string s, t;
	map<long, char>mp;

	cin >> n >> m;
	cin >> s >> t;


	long long ko = gcd(n, m);
	//cout << "ko->" << ko << endl;

	if (ko == 1) {
		len = n*m;
	}
	else if (ko >= 2) {
		len = (n*m) / ko;
	}

	long long koubai = (n*m) / ko;
	long long ban = len / n;
	long long bam = len / m;

	string ans;

	/*
	for (i = 0; i < len; i++) {
		ans += 'z';
	}*/

	if (s.length() > t.length()) {
		for (i = 0, j = 0; i < len; i += ban, j++) {
			//ans[i] = s[j];
			mp.insert(make_pair(i, s[j]));
		}
	}
	else {
		for (i = 0, j = 0; i < len; i += bam, j++) {
			//ans[i] = s[j];
			mp.insert(make_pair(i, t[j]));
		}
	}

	bool flag = false;


	if (s.length() > t.length()) {
		for (i = 0, j = 0; i < len; i += bam, j++) {
			//ans[i] = s[j];
			if (mp.count(i) == 0) {
				mp.insert(make_pair(i, t[j]));
			}
			else {
				if (mp[i] == t[j]) {

				}
				else {
					flag = true;
					break;
				}
			}
			
		}

	}
	else{
		for (i = 0, j = 0; i < len; i += ban, j++) {
			//ans[i] = s[j];
			if (mp.count(i) == 0) {
				mp.insert(make_pair(i, s[j]));
			}
			else {
				if (mp[i] == s[j]) {

				}
				else {
					flag = true;
					break;
				}
			}
		}
	
	}


/*
	for (i = 0, j = 0; i < len; i += bam, j++) {
		ans[i] = t[j];
	}

	cout << ans << endl;
	bool flag = false;

	for (i = 0, j = 0; i < s.length(); i++, j+=ban) {
		if (s[i] != ans[j]) {
			flag = true;
			break;
		}
	}

	for (i = 0, j = 0; i < t.length(); i++, j += bam) {
		if (t[i] != ans[j]) {
			flag = true;
			break;
		}
	}*/

	if (flag == false) {
		cout << len << endl;
	}
	else {
		cout << -1 << endl;
	}






	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 10880
mod = 10 ** 9 + 7
mod2 = 2**61+1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

def iip(listed):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def iip_ord():
    return [ord(i) - ord("a") for i in input()]


def main():
    ans = solve()
    if ans is not None:
        print(ans)

def solve():
    N = iip(False)
    A = iip(True)

    s = sum(A) // 2
    sa = 0
    for i, a in enumerate(A, 1):
        if i % 2 == 0:
            sa += a
    a1 = s-sa

    result = []
    cur = a1*2
    for i in A:
        result.append(cur)
        cur = (i - cur // 2)*2

    split_print_space(result)


#####################################################ライブラリ集ここから

def split_print_space(s):
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def koenai_saidai_x_index(sorted_list, n):
    l = 0
    r = len(sorted_list)
    if len(sorted_list) == 0:
        return False
    if sorted_list[0] > n:
        return False

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] == n:
            return x
        elif sorted_list[x] > n:
            r = x
        else:
            l = x
    return l


def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        # print(sorted_list)
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod - 2)


def power(n, p, mod_= mod):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()

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


#define ll long long
#define pll pair <ll,ll>
#define fi first
#define se second
#define endl "\n"
#define sqr(b) (b)*(b)


using namespace std;



int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    ll n;
    ll a[111111], f[111111];

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        f[i] = 2e9;
    }

    f[1] = 0;
    for (int i = 1; i <= n - 1; i++) {
        f[i + 1] = min(f[i + 1], f[i] + abs(a[i] - a[i + 1]));
        f[i + 2] = min(f[i + 2], f[i] + abs(a[i] - a[i + 2]));
    }

    cout << f[n] << endl;

    return 0;
}


Measured memory_bytes: 5136
n, a, b, c = list(map(int, input().split()))
l = []
for i in range(n):
    l.append(int(input()))
min = 10**20
def dfs(depth, v):
    if depth >= n:
        if 0 in v and 1 in v and 2 in v:
            calc(v)
    else:
        for i in range(4):
            v[depth] = i
            dfs(depth + 1, v)

def calc(array):
    A = 0
    B = 0
    C = 0
    count = -3
    global min
    for i in range(n):
        if array[i] == 0:
            A += l[i]
            count += 1
        elif array[i] == 1:
            B += l[i]
            count += 1
        elif array[i] == 2:
            C += l[i]
            count += 1
    if min > abs(A - a) + abs(B - b) + abs(C - c) + count * 10 :
        min = abs(A - a) + abs(B - b) + abs(C - c) + count * 10

v = [0 for i in range(n)]
dfs(0,v)
print(min)

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

int main() {
  int g;
  vector<int> v;
  while (cin >> g) {
    while (g != 0) {
      int i = 1;
      while (g >= i * 2) {
        i *= 2;
      }
      v.push_back(i);
      g -= i;
    }
    reverse(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++) {
      if (i == v.size() - 1) {
        cout << v.at(i) << endl;
      } else {
        cout << v.at(i) << " ";
      }
    }
    v.clear();
  }
}


Measured memory_bytes: 3084
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  a, b = map(int, readline().split())
  print(max(a-b*2,0))
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e8+2;
int main(){
    int n,m,b,c;
    cin>>n>>m;
    vector<int> cost(m),mask(m);
    for(int i=0;i<m;i++){
        cin>>cost[i];
        cin>>b;
        while(b--){
            cin>>c;
            c--;
            mask[i] = mask[i]|(1<<c);
        }
    }
    
    vector<int> dp1(1<<n,INF),dp2(1<<n);
    dp1[0] = 0;
    for(int i=0;i<m;i++){
        copy(dp1.begin(),dp1.end(),dp2.begin());
        for(int k=0;k<(1<<n);k++){
            int mas = k|mask[i];
            dp2[mas] = min(dp2[mas],dp1[k]+cost[i]);
        }
        swap(dp1,dp2);
    }
    if(dp1[(1<<n)-1]==INF){
        cout<<-1<<endl;
    }else{
        cout<<dp1[(1<<n)-1]<<endl;
    }
    return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    string S;
    cin >> S;
    string T = "CODEFESTIVAL2016";
    int n = 0;
    REP(i, S.length())
    {
        if (S[i] != T[i])
            n++;
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stdio.h>
#include<map>
#include<algorithm>
using namespace std;
int main(){
  int n;
  scanf("%d",&n);
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin>>a[i];
  int h=0,go=0;
  long long ans=0;
  for(int i=0;i<n;i++){
   while(go<n && !(h&a[go]))
     h|=a[go++];
   ans+=go-i;
   h^=a[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n, A, B;
    cin >> n >> A >> B;

    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    
    // left: 魔物を消すには足りない攻撃数の最大値
    ll left = 0, right = (ll)1e9+1;

    vector<ll> t(n);
    ll D = A - B;
    while (right - left > 1) {
        ll mid = (right + left) / 2;

        rep(i, n) t[i] = h[i] - B * mid;
        ll cnt = 0;
        rep(i, n) if (t[i] > 0) cnt += (t[i] + D - 1) / D;

        if (mid < cnt) {
            left = mid;
        }
        else {
            right = mid;
        }
    }

    put(left + 1);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 4836
package main
 
import "fmt"
 
func payment(n int) int {
	if n % 1000 != 0 {
		return 1000 - n % 1000
	}
	return 0
}
 
func main() {
	var n int
	fmt.Scan(&n)
	ans := payment(n)
	fmt.Println(ans)
}

Measured memory_bytes: 1772
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define Sort(a)	sort(a.begin(),a.end())
#define rev(a)	reverse(a.begin(),a.end())
#define all(a)	(a).begin(),(a).end()
#define vll vector<long long int>
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e18

#define MAX 200005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli power(lli a,lli b,lli m){if(b==0)	return 1;if(b==1)	return a%m;lli res=1;a=a%m;while(b){if(b&1){res=(res*a)%m;}a=((a%m)*(a%m))%m;b>>=1;}return res;}
lli Ceil(lli a,lli b){lli res=a/b;if(a%b!=0)	res++;return res;}

template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

lli dxx[]={1,1,0,-1,-1,-1,0,1};
lli dyy[]={0,1,1,1,0,-1,-1,-1};
lli dx[]={1,0,-1,0};
lli dy[]={0,1,0,-1};

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t,p1=-1,p2=-1;
    cin >> n >> m >> k;
    vll v1(n);
    cin >> v1;
    vll v2(m);
    cin >> v2;
    sum=v1[0];
    for(i=1;i<n;i++){
    	v1[i]+=v1[i-1];sum=v1[i];
    	if(sum>10000000000){
    		p1=i;break;
    	}
    }
    sum=v2[0];
    for(i=1;i<m;i++){
    	v2[i]+=v2[i-1];sum=v2[i];
    	if(sum>10000000000){
    		p2=i;break;
    	}
    }
    if(p1!=-1){
    	v1.erase(v1.begin()+p1,v1.end());
    }
    if(p2!=-1){
    	v2.erase(v2.begin()+p2,v2.end());
    }
    auto it1=lower_bound(v1.begin(),v1.end(),k);
    auto it2=upper_bound(v1.begin(),v1.end(),k);
    auto it3=lower_bound(v2.begin(),v2.end(),k);
    auto it4=upper_bound(v2.begin(),v2.end(),k);
    p1=it1-v1.begin();
    if(it1==it2)	p1--;
    a=it1-v1.begin()+1;if(it1==it2)	a--;
    b=it3-v2.begin()+1;if(it3==it4)	b--;
    ans=max(a,b);
    if(it1==v1.begin()&&(it1==it2)){
    	cout<<ans<<endl;return;
    }
    if(it3==v2.begin()&&(it3==it4)){
    	cout<<ans<<endl;return;
    }
    while(p1>=0){
    	a=v1[p1];b=k-a;
    	auto it5=lower_bound(v2.begin(),v2.end(),b);
    	auto it6=upper_bound(v2.begin(),v2.end(),b);
    	c=p1+1;
    	d=it5-v2.begin()+1;
    	c+=d;
    	if(it5==it6)	c--;
    	p1--;
    	ans=max(ans,c);
    }
    cout<<ans;
    
    
}













int main()
{
	long long int t=1,c=1;
	// scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */

Measured memory_bytes: 6412
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

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

const ll INF = 1e15;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main(void) {
	int A[100010], L[100010], R[100010], N, ans;
	L[0] = R[N+1] = 0;
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 1; i <= N; i++) L[i] = GCD(L[i - 1], A[i]);
	for (int i = N; i >= 1; i--) R[i] = GCD(R[i + 1], A[i]);
	ans = 0;
	for (int i = 1; i <= N; i++) ans = max(ans, GCD(L[i - 1], R[i + 1]));
	cout << ans << endl;

}


Measured memory_bytes: 1408
<?php
while(true){
//??\??? ??????????????¨
    list($itemValue) = stdInput();
    if ($itemValue==0){
        exit;
    }
    
    $itemList = [];//????????§?????????????????§??????
    for ($i=0;$i<$itemValue;$i++){
        list($itemName,$itemCost) = stdInput();
        $itemList = array_merge($itemList,array($itemName => $itemCost ));
    }
    
    list($recipeValue) = stdInput();
    
    for ($i=0;$i<$recipeValue;$i++){
        $recipe = stdInput();
        $recipeCost = 0;
        for ($j=2;$j<$recipe[1]+2;$j++){
            $recipeCost += $itemList[$recipe[$j]];
        }
        if ($itemList[$recipe[0]]>$recipeCost){
            $itemList[$recipe[0]] = $recipeCost;
        }
    }
    
    list ($itemWanted) = stdInput();
    
    
    // ??????
    echo $itemList[$itemWanted],PHP_EOL;
}

// ??¢??°
function stdInput(){
    return explode(" ", trim(fgets(STDIN)));
}

Measured memory_bytes: 15020
import sys
import numpy as np
n=int(input())
mod=10**9+7
if n==1:print(1);sys.exit()
def searchPrimeNum(N):
    max = int(np.sqrt(N))
    searchList = [i for i in range(2,N+1)]
    primeNum = []
    while searchList[0] <= max:
        primeNum.append(searchList[0])
        tmp = searchList[0]
        searchList = [i for i in searchList if i % tmp != 0]
    primeNum.extend(searchList)
    return primeNum
l=len(searchPrimeNum(n))
plist=searchPrimeNum(n)
cnt=[0]*l
for i in range(l):
  k=1 
  while plist[i]**k<=n:
    cnt[i]+=n//(plist[i]**k)
    k+=1
ans=1
for i in cnt:
  ans=(ans*(i+1))%mod
print(ans)


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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define max_heap priority_queue <int> pq; // max heap 
#define min_heap priority_queue <int, vector<int>, greater<int> > pq;  //min heap
#define make_pairVector vector<pair<long long int,long long int> > pairVector // vector of pairs
#define hashmap unordered_map<long long int, long long int>hashmap;
#define pb push_back


//map<pair<ll,ll>, ll > hash;          // pair,value hashmap where key is a pair
//hash[make_pair(i,j)] = 0;
//if(hash.find(make_pair(i,j)) == hash.end())


//map<ll,ll>::iterator itr;           // iterating a map
//for (itr = hash.begin();itr != hash.end(); itr++)
//{
//   itr->first = key  
//   itr->second = value
//}


// vector<string> v; //to convert vector to a set
// set<string> s(v.begin(), v.end());


// set<string>s;     // to convert set to a vector
// vector<string> v(s.begin(),s.end());


// cin >> x >> y;
// pairVector.pb(mp(x,y));


// string size = str.size()


// stack <int> s; 


// queue <int> gquiz; 


// __gcd(m, n) 

// ll arr[10e5 + 5];


// char arr[10e5 + 5];


// printf ("%.9f\n",x);


bool sortbysec(const pair<long long int,long long int> &a, const pair<long long int,long long int> &b) 
{ 
    return (a.second < b.second); 
}
bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
int check_key(map<long long int, long long int> m, long long int key) 
{ 
    // Key is not present 
    if (m.find(key) == m.end()) 
        return 0; 
  
    return 1; 
} 

void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}

int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // ll a,b,c,d,e;
    ll arr[5];
    for(ll i = 0; i<5; i++)
    {
        cin >> arr[i];
    }
    for(ll i = 0; i<5; i++)
    {
        if(arr[i] == 0)
        {
            cout << i+1 << endl;
        break;

        }
    }
    return 0;
}   

Measured memory_bytes: 3612
using System;
using System.Linq;

class D
{
	static void Main()
	{
		Func<long[]> read = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
		var h = read();
		var v = new int[3].Select(_ => read().OrderBy(x => -x).ToArray()).ToArray();

		Func<long[], long[], long[]> comb = (p, q) => p.SelectMany((x, i) => q.TakeWhile((y, j) => (i + 1) * (j + 1) <= h[3]).Select(y => x + y)).OrderBy(x => -x).Take((int)h[3]).ToArray();
		Console.WriteLine(string.Join("\n", comb(comb(v[0], v[1]), v[2])));
	}
}


Measured memory_bytes: 18016
#include <bits/stdc++.h>
 
using namespace std;
 
 
int main(){
  int N,X,sum =0,min_kona;
  cin>>N>>X;
  vector<int> kona(N);
  for(int i=0;i<N;i++){
    cin>>kona.at(i);
    
    if(min_kona > kona.at(i)){
      min_kona = kona.at(i);
    }
    
    sum += kona.at(i);
  }
  
  int total =X-sum;
  int ans = N + total/min_kona;
  cout<< ans <<endl;
}

Measured memory_bytes: 256
n = int(input())
data = [ list(map(int, input().split())) for i in range(n)]
data.insert(0, [0,0,0])
for i in range(n):
    differ = [(data[i+1][j] - data[i][j]) for j in range(3)]
    if abs(differ[0]) < (differ[1] + differ[2]):
        print("No")
        exit()
    elif differ[0] % 2 != (differ[1] + differ[2]) % 2:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 27300