akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int n,j = 0;
int sum = 0;

int main(){
    cin >> n;
    vector<int> s(n,0), a;
    for(int i = 0; i < n; i++){
        cin >> s[i];
        sum = sum + s[i];
        if(s[i] % 10 != 0){
            a.push_back(s[i]);
        }
    }
    sort(a.begin(), a.end());
    
    while(sum % 10 == 0 && j < a.size()){
        sum = sum - a[j];
        j++;
    }
    if(j >= a.size()){
        cout << 0 << endl;
    }else{
        cout << sum << endl;
    }
}

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

#define int long long
#define pb emplace_back
#define f(i,n) for(int i=1 ; i<=n ; i++)
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);
const int N =1e5 + 5;
int n, k , a[N] , dp[N];
int32_t main(){
	fast;
	cin >> n >> k ;
	f(i,n)  cin >> a[i];
	
	dp[1] = 0;
	for(int i=2 ; i<=n ; i++)
	{
		int t = INT_MAX;
		for(int j = 1 ; j<=k ; j++)
		{
			if(i-j >=1)
				t = min(t , dp[i-j] + abs(a[i-j] - a[i]));
		}
		dp[i] = t;
	}
		
	cout << dp[n];
}







Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define itn int
#define REP(i,n) for(int i=0;i<(n);i++)
#define IREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(n);i++)
#define REPEACH(itr,k) for(auto&& itr : k)
#define MOD 1000000007

using namespace std;
typedef long long ll;

const ll INF = 1LL<<60;
typedef pair<double,int> P;

int main(){
  int n,m;
  cin >> n >> m;
  int tmp=m*1800+n*100;
  REP(i,m){
    tmp*=2;
  }
  cout << tmp << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int n,L,T,x,w,a[maxn];ll cnt;
int main(){
	scanf("%d%d%d",&n,&L,&T);
	rep(i,0,n-1){
		scanf("%d%d",&x,&w);
		if(w==1){
			a[i]=(x+T)%L;
			cnt+=(x+T)/L;
		}
		else{
			a[i]=(x-T)%L;
			cnt+=(x-T)/L;
			if(a[i]<0) a[i]+=L,--cnt;
		}
	}
	sort(a,a+n);cnt=(cnt%n+n)%n;
	rep(i,0,n-1) printf("%d\n",a[(cnt+i)%n]);
	return 0;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

typedef long long ll;

const int Maxn = 100005;

int n, m;
vector <int> neigh[Maxn];
int col[Maxn];

bool Check(int v, int c = -1)
{
	if (col[v]) return c == col[v];
	col[v] = c;
	for (int i = 0; i < neigh[v].size(); i++)
		if (!Check(neigh[v][i], -c)) return false;
	return true;
}

int main()
{
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		int a, b; scanf("%d %d", &a, &b);
		neigh[a].push_back(b);
		neigh[b].push_back(a);
	}
	if (Check(1)) {
		ll a = 0, b = 0;
		for (int i = 1; i <= n; i++)
			if (col[i] == -1) a++;
			else if (col[i] == 1) b++;
		cout << a * b - m << endl;
	} else cout << ll(n) * (n - 1) / 2 - m << endl;
	return 0;
}

Measured memory_bytes: 6528
n = int(input())
num = list(map(int,input().split()))
odd,even = 0,0
for i in range(n):
  if num[i]%2 == 0:
    even += 1
  else:
    odd += 1
if odd%2 == 1:
  print('NO')
else:
  print('YES')

Measured memory_bytes: 14112
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int N; cin >> N;
	vector<pair<int, int>> A(N);
	rep(i, N) {
		int tmp; cin >> tmp;
		auto p = make_pair(tmp, i + 1);
		A[i] = p;
	}
	sort(ALL(A));
	rep(i,N) {
		cout << A[i].second;
		if (i != N - 1) {
			cout << " ";
		}
	}
	cout << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 1664
import sys
import collections

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	n, p = tin()
	#s = input()
	bb=collections.defaultdict(lambda : 0)
	tp = p
	for i in range(2, p):
		if tp % i == 0:
			while tp % i == 0:
				bb[i] += 1
				tp = tp // i
				
		if i * i > tp:
			bb[tp] += 1
			break
	
	rr = 1
	for k in bb:
		#pa((k, bb[k]))
		if bb[k] >= n:
			rr *= k**(bb[k]//n)
	print(rr)
		
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 9432
def main():
    X,Y = list(map(int,input().split()))
    mod = 1000000007

    a = (2*Y-X)//3
    b = Y-2*a
    s = (X+Y)//3
    if (2*Y-X)%3 == 0 and 0 <= a and 0 <= b:
        ans = 1
        for n in range(s-min(a,b)+1,s+1):
            ans = (ans*n)%mod
        div = 1
        for n in range(2,min(a,b)+1):
            div = (div*n)%mod

        ans = (ans*pow(div,1000000005,mod))%mod
        print(ans)
    else:
        print(0)

if __name__ == "__main__":
    main()


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  for(int i = 0; i < 5; i++){
    int tmp;
    cin >> tmp;
    if(tmp == 0){
      cout << i+1 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3628
#!/usr/bin/env python3
import sys


def solve(N: int, L: int):
    ls = [L + x for x in range(0, N)]

    if L > 0:
        del ls[0]
        print(sum(ls))

        return

    elif ls.__contains__(0):
        print(sum(ls))

        return
    else:
        del ls[-1]
        print(sum(ls))

        return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int
    L = int(next(tokens))  # type: int
    solve(N, L)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;

int N;
ll in[200000];
ll ruisekiwa[200001];
ll over;

ll getmin(int l, int r) {
	ll a, b, c, ans = 0;
	a = ruisekiwa[r] - ruisekiwa[l];
	b = *lower_bound(ruisekiwa + r, ruisekiwa + 2 * N, ruisekiwa[r] + over);
	c = ruisekiwa[l + N] - *lower_bound(ruisekiwa + r, ruisekiwa + 2 * N, ruisekiwa[r] + over);
	ans = max(ans, min(a, min(b, c)));
	b = *(lower_bound(ruisekiwa + r, ruisekiwa + 2 * N, ruisekiwa[r] + over) + 1);
	c = ruisekiwa[l + N] - *(lower_bound(ruisekiwa + r, ruisekiwa + 2 * N, ruisekiwa[r] + over) + 1);
	ans = max(ans, min(a, min(b, c)));
	return ans;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> in[i];
		in[N + i] = in[i];
	}
	for (int i = 1; i <= N * 2; i++) {
		ruisekiwa[i] = ruisekiwa[i - 1] + in[i - 1];
	}

	ll ans = 0;
	over = (ruisekiwa[N] - ruisekiwa[0]) / 3;
	for (int l = 0, r = 0;(l < N); l++) {
		for (; ruisekiwa[r] - ruisekiwa[l] < over; r++)ans = max(ans, getmin(l, r));
		ans = max(ans, getmin(l, r + 1));
		ans = max(ans, getmin(l, r));
		ans = max(ans, getmin(l, r - 1));
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int T, A;
    cin >> T >> A;
    double H[1100];
    double tmp[1100];
    double min = 10000;
    int ans;
    for(int i = 0; i < N; i++) {
        cin >> H[i];
        if(T - H[i]*0.006 > A) {
            tmp[i] = T - H[i]*0.006 - A;
        } else {
            tmp[i] = A - (T - H[i]*0.006);
        }
        if(min > tmp[i]) {
            min = tmp[i];
            ans = i + 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3772
#include "bits/stdc++.h"
using namespace std;

typedef long long lint;
#define rep(i,n) for(lint i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) reverse((v).begin(), (v).end())
#define siz(x) ((int)(x).size())
#define el "\n"
#ifdef LOCAL_tqk
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

double n_sn(lint n) {
	lint cp = n, s = 0;
	while (cp) {
		s += cp % 10;
		cp /= 10;
	}
	return (double)n / s;
}

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

	lint k, ans = 1, del = 1;
	cin >> k;
	rep(i, k) {
		cout << ans << el;
		if (n_sn(ans + del) > n_sn(ans + del * 10))del *= 10;
		//必ず9回ごとに del*=10 すると分母が100になるところでWAになる。
		//急にn_snが大きくなった時に del*=10 すれば解決...?
		ans += del;
	}
	gc();
}

Measured memory_bytes: 256
N = int(input())
li = []
for i in range(N):
    hontai, ude = map(int, input().split())
    li.append([hontai, ude, hontai-ude, hontai+ude])
li.sort(key=lambda x:x[3])
#print(li)
count = 1
now = li[0][3]
for i in range(1, N):
    if now <= li[i][2]:
        count += 1
        now = li[i][3]
    #print(now, count)
print(count)

Measured memory_bytes: 64356
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second

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<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> c(n);
	rep(i,n){
		cin>>c[i];
	}
	sort(begin(c),end(c));
	mint ans=0;
	vector<mint> beki(2*n+1,1);
	rep(i,2*n){
		beki[i+1]=beki[i]*2;
	}
	rep(i,n){
		mint ret=beki[2*i]*2*c[i]*beki[n-i-1];
		if(i!=n-1) ret*=beki[n-i-2]*(n-i-1)+beki[n-i-1];
		ans+=ret;
	}
	cout<<ans.x<<endl;
}

Measured memory_bytes: 4224
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1)/ (y))

u64 N;
s64 *W;
s64 *L, *R;

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

    cin >> N;
    W = new s64[N];
    rep (i, N)
    {
        cin >> W[i];
    }

    L = new s64[N];
    R = new s64[N];
    L[0] = W[0];
    R[N - 1] = W[N - 1];

    int i;
    for (i = 1; i < N - 1; ++i)
    {
        L[i] = L[i - 1] + W[i]; // L[i] = W[0] + ... + W[i], i = 0, 1, ..., N - 2
    }
    for (i = N - 2; i > 0; --i)
    {
        R[i] = R[i + 1] + W[i]; // R[i] = W[i] + ... + W[N - 1], i = 1, 2, ..., N - 1
    }

    s64 m = abs(L[0] - R[1]);
    for (i = 1; i < N - 1; ++i)
    {
        m = MIN(m, abs(L[i] - R[i + 1]));
    }

    cout << m << "\n";
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Hello
{
    public static void Main()
    {
        var n = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long x = n[0], t = n[1];
        long s = x - t;
        Console.WriteLine(s >= 0 ? s : 0);
    }
    
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int L, R, min_mod = 2019;
  cin >> L >> R;
  if(R - L >= 2019) cout << 0 << endl;
  else{
    for(int i = L % 2019; i < (R - L) + (L % 2019); i++){
      for(int j = i + 1; j <= (R - L) + (L % 2019); j++){
        if((i * j) % 2019 < min_mod) min_mod = (i * j) % 2019;
      }
    }
    cout << min_mod << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import numpy as np
n = int(input())
x = np.array([int(i) for i in input().split(" ")])
a = np.mean(x)
if a % 1 >0.5:
    a = int(a//1) + 1
else:
    a = int(a//1)
print(np.sum((x-a)**2))

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

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

typedef long long LL;

int main(){
  char key[9][5]={
    {'.',',','!','?',' '},
    {'a','b','c',' ',' '},
    {'d','e','f',' ',' '},
    {'g','h','i',' ',' '},
    {'j','k','l',' ',' '},
    {'m','n','o',' ',' '},
    {'p','q','r','s',' '},
    {'t','u','v',' ',' '},
    {'w','x','y','z',' '}
  };
  int n;
  cin >> n;
  string s;
  for(int i=0;i<n;i++){
    string ans="";
    int a=0,b=0;
    cin >> s;
    for(int j=0;j<s.length();j++){
      if(s[j]=='0'){
        if(a){
          ans+=key[a-1][b];
          a=0;
          b=0;
        }
      }else{
        if(a){
          b++;
          if(a==1) b%=5;
          else if(a==7||a==9) b%=4;
          else b%=3;
        }else{
          a=s[j]-'0';
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3200
h,w=map(int,input().split())
data=[[0 for i in range(w+2)] for j in range(h+2)]
for j in range(h):
    s=input()
    for i in range(w):
        if s[i]=="#":
            data[j+1][i+1]=1
flag=True
for i in range(1,h+2):
    for j in range(1,w+2):
        if data[i][j]==1 and data[i-1][j]==data[i+1][j]==data[i][j-1]==data[i][j+1]==0:
            flag=False
            break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String result;
        switch (sc.next()) {
        case "A":
            result = "T";
            break;
        case "C":
            result = "G";
            break;
        case "G":
            result = "C";
            break;
        default:
            // "T"
            result = "A";
            break;
        }
        System.out.println(result);
    }
}

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


int main(){
	int t,n,m;
	cin >> t;
	double mx = -1e9;
	for(int i = 0 ; i < t ; i++){
		cin >> n >> m;
		double V = 0 , R = 0;
		for(int j = 0 ; j < m ; j++){
			double v,r;
			cin >> v >> r;
			V += v * r;
			R += r;
		}
		mx = max(mx,V/R);
	}
	cin >> n >> m;
	double V = 0 , R = 0;
	for(int j = 0 ; j < m ; j++){
		double v,r;
		cin >> v >> r;
		V += v * r;
		R += r;
	}
	if( mx > V/R+0.0000001) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

int main(){
    string s,ans;
    int k;
    ans = "";
    cin >> k >> s;
    
    if(s.size()<=k){
        cout << s << endl;
    }else{
        for(int i=0;i<k;i++){
            ans += s[i];
        }

        cout << ans << "..." << endl;
    }
}

Measured memory_bytes: 3628
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

int main() {
	int N, T; cin >> N >> T;
	int prev = 0;
	int t;
	long long answer = 0;
	for (size_t i = 0; i < N; i++) {
		cin >> t;
		answer += min((t - prev), T);
		prev = t;
	}
	answer += T;
	cout << answer << endl;
}



Measured memory_bytes: 256
use std::collections::BinaryHeap;
use std::cmp::Ordering;

fn main() {
    let n = read::<usize>();
    let a = read_vec::<i64>();

    let mut s: Vec<i64> = vec![0; 2*n+1];
    let mut queue1: BinaryHeap<Rev<i64>> = BinaryHeap::new();
    for i in 0..n {
        s[i+1] = s[i] + a[i];
        queue1.push(Rev(a[i]));
    }
    for i in n..2*n {
        if queue1.peek().unwrap().0 < a[i] {
            let min = queue1.pop().unwrap();
            s[i+1] = s[i] - min.0 + a[i];
            queue1.push(Rev(a[i]));
        } else {
            s[i+1] = s[i];
        }
    }

    let mut t: Vec<i64> = vec![0; 2*n+1];
    let mut queue2: BinaryHeap<i64> = BinaryHeap::new();
    for i in 0..n {
        t[i+1] = t[i] + a[3*n-1-i];
        queue2.push(a[3*n-1-i]);
    }
    for i in n..2*n {
        if queue2.peek().unwrap() > &a[3*n-1-i] {
            let max = queue2.pop().unwrap();
            t[i+1] = t[i] - max + a[3*n-1-i];
            queue2.push(a[3*n-1-i]);
        } else {
            t[i+1] = t[i];
        }
    }

    let mut res = i64::min_value();
    for i in n..2*n+1 {
        res = std::cmp::max(res, s[i]-t[3*n-i]);
    }

    println!("{}", res);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}


Measured memory_bytes: 15728
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int n, ans, x, i, j, k;
	cin >> n;

	for (i = 1; ; i++) {
		if ((n * i) % 360 == 0) {
			ans = i; break;
		}
	}

	cout << ans << "\n";


	return 0;
}


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

int main() {
  int cnt=0,ans=0;
  string str;
  cin >> str;
  for(int i=0; i<str.size(); i++) {
    if(str[i]=='A'||str[i]=='T'||str[i]=='G'||str[i]=='C') {
      cnt++;
    }
    else {
      cnt=0;
    }
    if(cnt>ans) {
      ans=cnt;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
bool ora(char x){
	if(x=='y'||x=='u'||x=='i'||x=='o'||x=='p'||x=='h'||x=='j'||x=='k'||x=='l'||x=='n'||x=='m'){return 1;}
	return 0;
}
int main(){
	string s;
	while(true){
	cin>>s;
	if(s=="#")break;
	int cnt=0;
	bool flag;
	if(ora(s[0]))flag=true;
	else flag=false;
	for(int i=0;i<s.size();i++){
		if(flag!=ora(s[i]))cnt++;
		flag=ora(s[i]);
	}
	cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include <cstdio>
#include <list>
#include <stack>

using namespace std;

int main() {
    int n, b;
    scanf("%d", &n);
    list<int> d;
    stack<int> ans;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &b);
        d.push_front(b);
    }
    while (!d.empty()) {
        int p = d.size();
        for (auto i = d.begin(); i != d.end(); --p, ++i) if (*i == p) {
            ans.push(*i);
            d.erase(i);
            break;
        }
        if (p == 0) {
            printf("-1\n");
            return 0;
        }
    }
    while (!ans.empty()) {
        printf("%d\n", ans.top());
        ans.pop();
    }
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<list>
#include<string>


using namespace std;

int ctoi(char c) {

	switch (c)
	{
	case'0':
		return 0;
	case'1':
		return 1;
	case'2':
		return 2;
	case'3':
		return 3;
	case'4':
		return 4;
	case'5':
		return 5;
	case'6':
		return 6;
	case'7':
		return 7;
	case'8':
		return 8;
	case'9':
		return 9;
	default:
		break;
	};
}
using ull = unsigned long long;
using ll =long long;

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

	ll res = 0;
	ll mx = v[0];

	for (int i = 1; i < N; ++i) {
		if (v[i] > mx) {
			mx = v[i];
		}
		else {
			res += mx - v[i];
		}
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1e9+7;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define iiii pair<ii,ii>
#define f(i,a,b) for(long long i = a;i < b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define w(t) while(t--)
#define c(n); cin>>n;
#define p(n) cout<<n;
#define pl(n) cout<<n<<endl;
#define ps(n); cout<<n<<" ";
#define F first
#define S second
#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()
#define ull unsigned long long
#define vll vector<ll>
#define vii vector<ii>
#define mkp make_pair
#define ld long double
#define arrin(a,n) f(i,0,n){cin>>a[i];}
#define arrout(a,n) f(i,0,n){cout<<a[i]<<" ";}
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define PI (2*acos(0))
const long long N = 1e6+5;
vll visit,dist,taken;
vector<vll> adj;
vector<vii> adj2;
priority_queue<ii,vector<ii>, greater<ii> > pq;
ll bit[N]={0};
ll siz;
ll res = 0;
ll lcm(ll a,ll b){return (a * b) / __gcd(a,b);}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll power(ll a,ll b){if(b == 0)return 1;if(b == 1)return a;ll ans = power(a,b/2) % MOD;ans *= ans;ans %= MOD;if(b % 2 == 1)ans *= a;return ans%MOD;}
ll inverse(ll x){x%=MOD;return power(x,MOD-2);}
void BITup(ll k, ll x){while(k <= siz){bit[k]+=x;k += k & -k;}}
ll BITq(ll k){ll s=0;while(k>=1){s+=bit[k];k -= k &-k;}return s;}
struct node{ll lazy,val;}seg[4000000];
struct point{ll x,y;};
void dfs(ll v){visit[v] = 1;for(auto x:adj[v]){if(!visit[x])dfs(x);}}
void bfs(ll s){visit[s] = 1;queue<ll>q;q.push(s);while(!q.empty()){ll u = q.front();ps(u);q.pop();for(auto x:adj[u]){if(!visit[x]){visit[x] = 1;q.push(x);}}}}
void dijkstra(ll s){pq.push(ii(0,s));dist[s] = 0;while(!pq.empty()){ii f = pq.top();pq.pop();ll w = f.F;ll u = f.S;if(w > dist[u]){continue;}for(auto v:adj2[u]){if(dist[u] + v.S < dist[v.F]){dist[v.F] = dist[u] + v.S;pq.push(ii(dist[v.F],v.F));}}}}
void prim(ll edge) {taken[edge] = 1;for(auto v:adj2[edge]) {if (taken[v.first]==0)pq.push(ii(v.second, v.first));}}
ll mst(ll s){taken.assign(N, 0);prim(s);ll cost = 0;while(!pq.empty()){ii front = pq.top();pq.pop();ll w = front.first;ll u = front.second;if(taken[u]==0)cost += w;prim(u);}return cost;}
void YESNO(ll a){if(!!a){pl("YES");}else{pl("NO");}}
void filesin(void){freopen("input.in","r",stdin);}
void filesout(void){freopen("output.out","w",stdout);}
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Educational DP Contest
int main(void){
    fastio;
    ll n;
    c(n);
    ll a[n],b[n],c[n];
    f(i,0,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    ll dp[n+1][3];
    f(i,0,n+1){
        dp[i][0] = dp[i][1] = dp[i][2] = 0;
    }
    f(i,0,n){
        dp[i+1][0] = a[i] + max(dp[i][1],dp[i][2]);
        dp[i+1][1] = b[i] + max(dp[i][0],dp[i][2]);
        dp[i+1][2] = c[i] + max(dp[i][0],dp[i][1]);
    }
    pl(max({dp[n][0],dp[n][1],dp[n][2]}));
}


Measured memory_bytes: 4992
#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;



int main() {
    int a=read(), b=read(), c=read();
    swap(a,b); swap(a,c);
    printf("%d %d %d\n", a, b, c);
}

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

int main()
{
    ll x;
    cin >> x;
    ll money = 100;
    int ans=0;
    while (x > money) {
        money += money/100;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11


int main(void) {
    int n;
    cin >> n;
    Vec<int> a(n);
    FOR (i, 0, n) {
        cin >> a[i];
    }
    cout << 2 * n - 1 << endl;

    auto itr_max = std::max_element(a.begin(), a.end());
    auto itr_min = std::min_element(a.begin(), a.end());
    int a_max = *itr_max;
    int a_min = *itr_min;
    int index_max = itr_max - a.begin();
    int index_min = itr_min - a.begin();

    if (abs(a_max) >= abs(a_min)) {
        FOR (i, 0, n) {
            cout << index_max + 1 << " " << i + 1 << endl;
            //a[i] += a[index_max];
        }
        FOR (i, 0, n - 1) {
            cout << i + 1 << " " << i + 2 << endl;
            //a[i + 1] += a[i];
        }
    } else {
        FOR (i, 0, n) {
            cout << index_min + 1 << " " << i + 1 << endl;
            //a[i] += a[index_min];
        }
        RFOR (i, n - 1, 0) {
            cout << i + 1 << " " << i << endl;
            //a[i - 1] += a[i];
        }
    }
    /*
    FOR (i, 0, n) {
        cout << a[i] << endl;
    }
    */
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
N = int(input())
G = [[] for i in range(N)]
C = [-1] * N
for i in range(N - 1):
    u, v, w = map(int, input().split())
    u, v = u - 1, v - 1
    G[u].append((v, w))
    G[v].append((u, w))


def dfs(u, p, d):
    if C[u] != -1:
        return
    if d % 2 == 0:
        C[u] = 0
    else:
        C[u] = 1

    for w, c in G[u]:
        if w == p:
            continue
        dfs(w, u, d + c)


dfs(0, -1, 0)
for c in C:
    print(c)


Measured memory_bytes: 170016
#include <map>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

//abbreviations
typedef long long ll;
#define vi vector<int>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vi problems(N, 0);
    int ac = 0, wa = 0;
    rep(i, M){
        int p;
        string S;
        cin >> p >> S;
        if(problems[p-1]>=0){
            if(S=="WA")
                problems[p-1]++;
            if(S=="AC"){
                wa += problems[p-1];
                ac++;
                problems[p-1] = -1;
            }
        }
    }
    cout << ac << " " << wa << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define cal(a,b) ((a+=b)%=mo)
using namespace std;
const int N=2050,mo=924844033;
int f[N][N][2][2],a[N],tot,p[N];
int main(){
  int n,k; cin>>n>>k;
  for (int i=1; i<=k; ++i)
    for (int j=i; j<=n; j+=k)
      a[++tot]=j;
  f[0][0][0][0]=1; a[0]=n;
  for (int i=0; i<n; ++i)
    for (int j=0; j<=i; ++j)
      for (int t=0; t<=1; ++t){
	cal(f[i+1][j+1][t][0],f[i][j][0][t]*(a[i+1]-a[i]==k));
	cal(f[i+1][j+1][t][1],((f[i][j][0][t]+f[i][j][1][t])%mo)*(a[i+2]-a[i+1]==k));
	cal(f[i+1][j][t][0],(f[i][j][0][t]+f[i][j][1][t])%mo);
      }
  p[0]=1;
  for (int i=1; i<=n; ++i) p[i]=1ll*p[i-1]*i%mo;
  for (int i=0; i<=n; ++i)
    cal(f[n][i][0][0],f[n][i][1][0]);
  int ans=0;
  for (int i=0; i<=n; ++i)
    if (i&1) cal(ans,mo-1ll*p[n-i]*f[n][i][0][0]%mo);
    else cal(ans,1ll*p[n-i]*f[n][i][0][0]%mo);
  cout<<ans;
  return 0;
}


Measured memory_bytes: 64000
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N);
    readvec(A);

    set<int> s;
    REP(i, N){
        s.insert(A[i]);
    }

    int ans = 10000000000;
    for(int a : s){
        vector<int> smalln(0), tmp(0);
        REP(i, N){
            if(A[i] >= a) tmp.push_back(A[i]);
            if(A[i] < a || i == N - 1){
                if(tmp.size() >= K){
                    SORT(tmp);
                    REP(j, tmp.size() - K + 1) smalln.push_back(tmp[j]);
                }
                tmp = vector<int>(0);
            }
        }
        if(smalln.size() >= Q){
            SORT(smalln);
            ans = min(ans, smalln[Q - 1] - smalln[0]);
        }
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;


int main(){
    string S;
    cin >> S;
    int ans[100000]={};
    queue<int> r,l;
    r.push(0);
    for(int i=1; i<S.length(); i++){
        if(S[i]=='L' && S[i-1]=='R'){
            l.push(i);
        }else if(S[i]=='R' && S[i-1]=='L'){
            r.push(i);
        }
    }
    
    while(!r.empty()){
        int tempr=r.front();
        int templ=l.front();
        r.pop();
        l.pop();
        int nextr;
        if(!r.empty()){
            nextr=r.front();
        }else{
            nextr=S.length();
        }
        
        
        int rnum=templ-tempr;
        int lnum=nextr-templ;
        
        if((rnum-lnum)%2==0){
            ans[templ-1] = (rnum+lnum)/2;
            ans[templ] = (rnum+lnum)/2;
        }else{
            if(rnum>lnum){
                if(rnum%2 == 0){
                    ans[templ] = (rnum+lnum)/2 +1;
                    ans[templ-1] = (rnum+lnum)/2;
                }else{
                    ans[templ] = (rnum+lnum)/2;
                    ans[templ-1] = (rnum+lnum)/2 +1;
                }
            }else if(lnum>rnum){
                if(lnum%2 == 0){
                    ans[templ] = (rnum+lnum)/2;
                    ans[templ-1] = (rnum+lnum)/2 +1;
                }else{
                    ans[templ] = (rnum+lnum)/2 +1;
                    ans[templ-1] = (rnum+lnum)/2;
                }
            }
        }
    }
    
    
    for(int i=0; i<S.length(); i++){
        cout<<ans[i];
        if(i==S.length()-1){
            cout<<endl;
        }else{
            cout<<" ";
        }
    }
    return 0;
}


Measured memory_bytes: 1408
import sys

input = sys.stdin.readline

x, y, z, k = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
a_list.sort(reverse=True)
b_list.sort(reverse=True)
c_list.sort(reverse=True)
tmp_list = [a+b for a in a_list for b in b_list]
tmp_list.sort(reverse=True)
honest_list = [tmp+c for tmp in tmp_list[:k] for c in c_list]
honest_list.sort(reverse=True)
for h in honest_list[:k]:
    print(h)


Measured memory_bytes: 207672
from heapq import heapify, heappush, heappop
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

MOD = 10**9+7

def main():
    N,K = map(int, readline().split())
    A = [int(i) for i in readline().split()]

    ans = 1
    if K == N:
        for a in A:
            ans *= a
            ans %= MOD
        print(ans)
        exit()

    plus = []
    minus = []

    for a in A:
        if a < 0:
            heappush(minus, a)
        else:
            heappush(plus, -a)

    if not plus:
        if K % 2 == 1:
            for _ in range(N-K):
                heappop(minus)
            for _ in range(K):
                ans *= heappop(minus)
                ans %= MOD
        else:
            for _ in range(K):
                ans *= heappop(minus)
                ans %= MOD
        print(ans)
        exit()

    p = []
    m = []
    for _ in range(K):
        if plus and minus:
            if plus[0] <= minus[0]:
                p.append(-heappop(plus))
            else:
                m.append(heappop(minus))
        elif plus:
            p.append(-heappop(plus))
        else:
            m.append(heappop(minus))

    for i in p:
        ans *= i
        ans %= MOD
    for j in m:
        ans *= j
        ans %= MOD

    if len(m) % 2 == 0:
        print(ans)

    else:
        if plus and minus and p and m:
            if p[-1] * (-plus[0]) >= m[-1] * minus[0]:
                ans *= pow(m[-1], MOD-2, MOD)
                ans *= -plus[0]
                ans %= MOD
            else:
                ans *= pow(p[-1], MOD-2, MOD)
                ans *= minus[0]
                ans %= MOD
        elif plus:
            ans *= pow(m[-1], MOD-2, MOD)
            ans *= -plus[0]
            ans %= MOD
        else:
            ans *= pow(p[-1], MOD-2, MOD)
            ans *= minus[0]
            ans %= MOD
        
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 33224
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 100100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll x,y,ans=0;
    cin >> x >> y;
    while(x<=y){
        x*=2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#include "atcoder/all"
using namespace atcoder;
#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>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<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;



signed main(){
	string s;
	cin >> s;
	
	auto sa = suffix_array(s);
	int ans = s.size() * (s.size() + 1) / 2;
	for(auto x: lcp_array(s, sa)) {
		ans -= x;
	}
	out(ans);
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N; cin >> N;
    vector<ll> A;
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        ll a; cin >> a;
        A.pb(a);
        sum += a;
    }
    ll ans = LINF;
    ll cnt = 0;
    for (int i = 0; i < N; i++) {
        cnt += A[i];
        ans = min(ans,abs((sum-cnt)-cnt));
    }
    cout << ans << endl;
}

Measured memory_bytes: 5364
n = int(input())
a = [list(map(str, input().split())) for _ in range(n)]
m = input()
for i in range(n):
    if a[i][0] == m:
        c = i
        break
d = 0
for i in range(i+1,n):
    d += int(a[i][1])
print(d)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int N, K;
  cin >> N >> K;
  K--;
  string S;
  cin >> S;
  rep(i, S.size())
  {
    if (i == K)
      cout << char(S[i] - 'A' + 'a');
    else
      cout << S[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i, n;
  int min = 1000000, max = -1000000;
  int x[10000] = {0};
  long long sum = 0;
  
  scanf("%d", &n);
  
  for (i = 0; i < n; i++) {
    scanf("%d", &x[i]);
  }
  
  for (i = 0; i < n; i++) {
    sum += x[i];
    if (x[i] < min) {
      min = x[i];
    }
    if (x[i] > max) {
      max = x[i];
    }
  }
  
  printf("%d %d %lld\n", min, max, sum);
  
  return 0;
}

Measured memory_bytes: 648
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)

int main() {
	char s[4];
	ll res = 0;
	scanf("%s", s);
	if (s[1] == 'B') {
		printf("ARC\n");
	}
	else {
		printf("ABC\n");
	}
	return(0);
}

Measured memory_bytes: 3184
from numpy import*
n,*a=map(int,open(0).read().split())
t=arange(n-1)
*s,=t
for i in a[-a[n]:]:t[i-2],t[i-1]=t[i-1],t[i-2]
k=a[n+1]
while k:
    if k%2:s=t[s]
    t=t[t]
    k//=2
print(*cumsum(a[:1]+list(diff(a[:n])[s])))

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

#define F(i,j)  for(int i = 1;i <= j; i++) 
typedef long long ll;


int main(){

int a;
cin >> a;
cout << a + pow(a,2) + pow(a,3);
    
      





return 0;
}




  













Measured memory_bytes: 4148
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-11)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int n;
double a[300000];
ll s1[300000],s2[300000];

void calc(ll*s){
	stack<int>st;
	double p=a[0];
	ll cnt=0;
	for(int i=1;i<n;i++){
		while(p<a[i]){
			if(st.empty()){
				cnt+=i;
			}
			else{
				cnt+=i-st.top();
				st.pop();
			}
			p+=2;
		}
		double b=a[i];
		while(p>=b+2){
			b+=2;
			st.push(i);
		}
		s[i]=cnt;
		p=a[i];
	}
}
int main(){
	scanf("%d",&n);
	rep(i,n){
		scanf("%lf",&a[i]);
		a[i]=log2(a[i]);
	}
	calc(s1);
	rep(i,n/2)swap(a[i],a[n-i-1]);
	calc(s2);
	ll Min=LLONG_MAX;
	rep(i,n+1){//最初に正になる場所
		ll A=(i>0?s1[i-1]*2:0);
		ll B=(i<n?s2[n-i-1]*2:0);
		Min=min(Min,A+B+i);
	}
	cout<<Min<<endl;
}

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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

ll S(ll v) { return v * (v+1) / 2; }

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; gi(n);
	print(S(n) - 3*S(n/3) - 5*S(n/5) + 15*S(n/15));
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005
ll expo(ll base, ll exponent, ll mod) {								//return base^exponent modulo modulus
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            ans = ans%mod;
        }
        base = base*base;
        base %= mod;
        exponent>>= 1;
    }
    return ans%mod;
}

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	ll x=0;
    	cin>>x;
    	vi pow[5];
    	for(i=-1000;i<10000;i++)
    	{
    		for(j=-1000;j<=1000;j++)
    		{
    			if(i*i*i*i*i-j*j*j*j*j==x)
    			{
    				cout<<i<<" "<<j;
    				return 0;
    			}
    		}
    	}
    }
    return 0;
}

Measured memory_bytes: 3656