akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

string L;
const Int N_MAX = 100010;
Int used[N_MAX][2], mem[N_MAX][2];
Int dfs(Int idx, Int flag){
  if(idx == (Int)L.size()) return 1;
  if(used[idx][flag]++) return mem[idx][flag];
  Int res = 0;
  if(flag == 1) res += dfs(idx + 1, flag) * 3;
  else if(L[idx] == '0') res += dfs(idx + 1, flag);
  else{
    res += dfs(idx + 1, 0) * 2;
    res += dfs(idx + 1, 1);
  }
  return mem[idx][flag] = res % mod;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  
  cin>>L;
  Int ans = dfs(0, 0);
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 8272
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

int main(){
    ll n; cin>>n;
    vector<ll>a(n);
    map<ll,ll>mp;
    rep(i,n){
        cin>>a[i];
        mp[a[i]+(i+1)]++;
    }
    ll ans=0;
    rep(i,n){
        ans+=mp[(i+1)-a[i]];
    }
    cout<<ans<<endl;
}





























































































Measured memory_bytes: 27296
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    char b;
    cin >> b;
    vector<char> vc = {'A', 'C', 'T', 'G'};
    vector<char> vd = {'T', 'G', 'A', 'C'};
    vector<char>::iterator itr_vc = find(vc.begin(), vc.end(), b);
    size_t index = distance(vc.begin(), itr_vc);
    cout << vd[index] << "\n";
}


Measured memory_bytes: 256
N=int(input())
A=[int(input()) for _ in range(N)]
tab = [0]*N
prev=10**10
for i,a in enumerate(A):
    dst = i-a
    if dst < 0 or dst >=N or (a>prev and a-prev>1):
        print(-1)
        exit()
    tab[dst] = max(tab[dst], a)
    prev = a
print(sum(tab))


Measured memory_bytes: 59480
#include <iostream>
#include <cstring>
#include <string>



int main()
{
	std::string str1, str2;
	std::cin >> str1 >> str2;
	str1 += str1;
	
	if(std::strstr(str1.c_str(), str2.c_str()) == NULL)
	{
		std::cout << "No" << std::endl;
	}
	else
	{
		std::cout << "Yes" << std::endl;
	}


}

Measured memory_bytes: 1196
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])
        cout<<"Bad";
    else
        cout<<"Good";
    cout<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

int main(){

	bool F=true;bool R=true;
while(1){char str[250]={},ch;
	for(int i=0;i<245;i++)
	{scanf("%c",&ch);if(ch=='.'&&R==false&&i==1){F=false;break;}
	if(ch=='.'){break;}
	str[i]=ch;}
	if(F==false){break;}
	int ks=0,kl=0,ms=0,ml=0;
	bool f=true;int p[200]={};int y=0;bool G=true;
	if(str[1]=='.'&&str[0]=='\n')F=false;
	for(int i=0;i<200;i++)
	{

		//cout<<i<<"#"<<y<<"#"<<p[y]<<endl;
		if(str[i]=='('){ms++;y++;p[y]=1;}
	else if(str[i]=='['){ks++;y++;p[y]=5;}
	else if(str[i]==')'){ml++;if(p[y]==5||p[y]==0){f=false;}if(ms<ml){f=false;}y--;}//cout<<i<<" ";}
	else if(str[i]==']'){kl++;if(p[y]==1||p[y]==0){f=false;}if(ks<kl){f=false;}y--;}
	}
	if(F==true){
	if(f!=false&&ms==ml&&ks==kl)cout<<"yes"<<endl;
	else{cout<<"no"<<endl;//<<ms<<ml<<ks<<kl<<endl;
	}
	}
R=false;
}


return 0;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
const double PI=3.14159265358979323846;
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
int main(void){
    queue<char> q;
    int n;cin>>n;
    string s;cin>>s;
    rep(i, n)q.push(s[i]);
    int cnt=1;
    char before=s[0];
    rep1(i, n){
        if(before!=q.front())cnt++;
        before = q.front();
        q.pop();
        }
    co(cnt);
}



Measured memory_bytes: 512
N = int(input())
items = []
for _ in range(N):
    items.append(tuple(map(int, input().split())))

sum_list = []
for a, b in items:
    sum_list.append((a + b, a, b))

sum_list = sorted(sum_list, key=lambda x: -x[0])

ans = 0
for i in range(N):
    if i & 1 == 0:
        ans += sum_list[i][1]
    else:
        ans -= sum_list[i][2]
print(ans)


Measured memory_bytes: 33280
/* ex6_2
   seira3 */

#include <stdio.h>
#include <string.h>
#define SIZE 101

int main(void){
    int len; //配列の長さを格納するint型の変数を宣言
    char str[SIZE]; //入力を入れる配列を宣言
    for(int i = 0; i < SIZE; i++){ //strを初期化
        str[i] = '0';
    }
    scanf("%s",str); //strに入力
    len = strlen(str); //文字列の長さを取得し代入
    printf("%c%d%c\n",str[0],len-2,str[len-1]); //問題文の指定に沿って出力
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include "Header.h"

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = (C[i - 1][j - 1]%d7 + C[i - 1][j]%d7)%d7;}}}
    return C[n][k]%d7;
 }

ll gcd(ll a, ll b){if (b == 0)
        return a;return gcd(b, a % b);}

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}


int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
// code now
   
    ll n;
    cin>>n;
    ll k;
    cin>>k;
    ll h;
    ll mn=d7;
    fori(n){
        mn=min(mn,abs(i+k));
    }
    fori(n){
        if(mn==abs(i+k)){h=i+k;break;}
    }
    cout<<((n*n-n)/2)+n*k-h;
    
//code ends
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

void fail(){
  cout << -1 << endl;
  exit(0);
}

signed main(){

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

  if(n == 0){
    if(a[0] == 1){
      cout << 1 << endl;
      return 0;
    }else{
      fail();
    }
  }
  if(a[0] != 0) fail();

  vector<int> dp(n+1, 1);
  for(int i = 1; i <= n; i++){
    dp[i] = min((int)1LL << 62, dp[i-1] * 2 - a[i]);
    if(dp[i] < 0) fail();
  }

  int ans = 0, child = 0;
  for(int i = n; i >= 0; i--){
    child += a[i];
    ans += child;
    if(i-1 >= 0 && child > dp[i-1]){
      child = dp[i-1];
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5016
//
//  main.cpp
//  ProgrammingContestChallengeBook2
//
//  Created by Hisaki Kobayashi on 2020/04/04.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <string>
#include <bits/stdc++.h>
#include <stdlib.h>

using namespace std;

int main(int argc, const char * argv[]) {
    
    long long N,K,i,div,ANS1,ANS2;
    cin >> N >> K;
    
    div = N/K;
    ANS1 = N - div*K;
    ANS2 = N - (div+1)*K;
    
  
    if(ANS2<=0)
        ANS2 = (-1)*ANS2;
    
    cout << min(ANS1,ANS2) << endl;
    return 0;
}




Measured memory_bytes: 256
package main

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

func main() {
	s, x, y := ReadString(), ReadInt(), ReadInt()
	var xs, ys []int
	tx := true
	cnt := 0
	for i := 0; i < len(s); i++ {
		if s[i] == 'T' {
			if tx {
				xs = append(xs, cnt)
			} else {
				ys = append(ys, cnt)
			}
			cnt = 0
			tx = !tx
			continue
		}
		cnt++
	}
	if tx {
		xs = append(xs, cnt)
	} else {
		ys = append(ys, cnt)
	}

	startX, startY := 0, 0
	if len(xs) > 0 {
		startX += xs[0]
		xs = xs[1:]
	}

	dp := make([]map[int]bool, len(xs)+1)
	dp[0] = map[int]bool{startX: true}
	for i := 0; i < len(xs); i++ {
		dp[i+1] = make(map[int]bool)
		for from, _ := range dp[i] {
			dp[i+1][from+xs[i]] = true
			dp[i+1][from-xs[i]] = true
		}
	}
	if !dp[len(xs)][x] {
		fmt.Println("No")
		return
	}

	dp = make([]map[int]bool, len(ys)+1)
	dp[0] = map[int]bool{startY: true}
	for i := 0; i < len(ys); i++ {
		dp[i+1] = make(map[int]bool)
		for from, _ := range dp[i] {
			dp[i+1][from+ys[i]] = true
			dp[i+1][from-ys[i]] = true
		}
	}
	if !dp[len(ys)][y] {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 110556
# コストに制限が無い上で、価値ーコストの総和を最大化する
# Vi-Ciが正になる組みを全て足し合わせれば良い
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
  if v[i] -c[i] > 0:
    ans += v[i] -c[i]
print(ans)


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

int main(){
  int N,M;
  cin >> N;
  cin >> M;
  int A[M];
  for(int i=0;i<M;i++){
    cin >> A[i];
  }
  int sum=0;
  for(int i=0;i<M;i++){
    sum += A[i];
  }
  if(N >= sum)cout << N-sum <<endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 3672
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	// nC2 + mC2
	nc2 := N * (N - 1) / 2
	mc2 := M * (M - 1) / 2

	fmt.Println(nc2 + mc2)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ii pair <int, int>
#define x first
#define y second
#define db(x) cerr << #x << " = " << x << endl;

using namespace std;

inline void read(int &x){register int c = getchar();x = 0; int neg = 0;for (;((c<48 || c>57) && c != '-') ;c = getchar());if(c=='-') {neg=1;c=getchar();}for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}if(neg) x=-x;}
inline void read(long long &x){register int c = getchar();x = 0; int neg = 0;for (;((c<48 || c>57) && c != '-') ;c = getchar());if(c=='-') {neg=1;c=getchar();}for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}if(neg) x=-x;}
inline void writeln(long long x){char buffor[21];register int i=0;int neg=0; if (x<0) {neg=1; x= -x;}do{buffor[i++]=(x%10)+'0';x/=10;} while(x);i--;if (neg) putchar('-');while(i>=0) putchar(buffor[i--]);putchar('\n');}
inline void write(long long x){char buffor[21];register int i=0;int neg=0; if (x<0) {neg=1; x= -x;}do{buffor[i++]=(x%10)+'0';x/=10;} while(x);i--;if (neg) putchar('-');while(i>=0) putchar(buffor[i--]);putchar(' ');}

const int N = 2e5 + 7;
const int oo = 1e9 + 7;

string s;
int n;
int pre[26][N];
int dp[N], f[(1 << 26) + 7];
vector <int> v;

int Onbit(int pos, int x){
	return (1 << pos) | x;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	// freopen("test.inp", "r", stdin);
	// freopen("test.out", "w", stdout);
	cin >> s;
	n = s.size();
	s = ' ' + s;
	for (int i = 1; i < (1 << 26); i++)
		f[i] = oo;
	v.push_back(0);
	for (int i = 0; i < 26; i++)
		v.push_back((1 << i));
	for (int i = 1; i <= n; i++){
		for (int j = 'a'; j <= 'z'; j++)
			pre[j - 'a'][i] = pre[j - 'a'][i - 1];
		pre[s[i] - 'a'][i] ^= 1;
	}
	for (int i = 0; i < N; i++)
		dp[i] = oo;
	for (int i = 1; i <= n; i++){
		int cur = 0;
		for (int j = 0; j <= 25; j++)
			if (pre[j][i])
				cur = Onbit(j, cur);
		for (int trans: v)
			dp[i] = min(dp[i], f[cur ^ trans] + 1);
		f[cur] = min(f[cur], dp[i]);
	}
	cout << dp[n];
}

Measured memory_bytes: 283860
#include <stdio.h>
#include <vector>
#include <iostream>

using namespace std;

int main(){
    int N,M,C;
    cin>>N>>M>>C;
    int B[M];
    for(int i=0;i<M;i++){
        cin>>B[i];
    }
    int cnt=0;
    
    int A[M];
    
    for(int i=0;i<N;i++){
        int sum=0;
        for(int j=0;j<M;j++){
            cin>>A[j];
            sum+=A[j]*B[j];
        }
        if(sum+C>0)
            cnt++;
    }
    
    cout<<cnt;
    
}



Measured memory_bytes: 256
<?php
$S=trim(fgets(STDIN));$Sl=strlen($S);
$P=trim(fgets(STDIN));$Pl=strlen($P);

$S.=$S;
$F='No';

for($i=0;$i<$Sl;$i++){
  if($S[$i]!=$P[0]) continue;
  $f=1;
  for($j=1;$j<$Pl;$j++) if($S[$i+$j]!=$P[$j]){$f=0;break;}
  if($f){$F='Yes';break;}
}

echo $F;
?>

Measured memory_bytes: 15448
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000002
mt19937 myrand(time(0));

ll prime[mx],vis[mx],k;

void sieve(){
    prime[k++]=2;
    for(int i=4;i<mx;i+=2) vis[i]=1;
    for(int i=3;i*i<mx;i+=2){
        if(!vis[i]){
            for(int j=i*i;j<mx;j+=2*i) vis[j]=1;
        }
    }
    for(int i=3;i<mx;i+=2) if(!vis[i]) prime[k++]=i;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    sieve();
    ll n,ans=0;
    cin>>n;
    for(int i=0;i<k && prime[i]*prime[i]<=n;i++){
        ll cnt=0;
        while(n%prime[i]==0){
            cnt++;
            n/=prime[i];
        }
        if(cnt){
            ll lo=1,hi=cnt,tmp;
            while(lo<=hi){
                ll mid=(lo+hi)/2;
                ll x=(mid*(mid+1))/2;
                if(x<=cnt){
                    tmp=mid;
                    lo=mid+1;
                }
                else hi=mid-1;
            }
            ans+=tmp;
        }
    }
    if(n>1) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 12080
t = []
r, c = map(int, input().split())

for _ in range(r):
    t.append(list(map(int, input().split())))

sum_cols = []
for col in range(c):
    sum_col = 0
    for row in range(r):
        sum_col += t[row][col]
    sum_cols.append(sum_col)
t.append(sum_cols)

for row in range(r+1):
    t[row].append(sum(t[row]))

for row in t:
    print(" ".join(map(str,row)))



Measured memory_bytes: 5696
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 collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush, heapify
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
from functools import reduce
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def lcm_base(a, b):
    return (a * b) // gcd(a, b)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def main():
  N, M = map(int,readline().split())
  S = np.array(list(input()), dtype='U1')
  x = np.count_nonzero(S[1:] == S[:-1])
  
  x += 2*M
  x = min(x, N-1)
  print(x)
  
if __name__ == '__main__':
  main()

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int A, B, C, K;
signed main() {
    cin >> A >> B >> C >> K;
    if (K < A) { cout << K << endl; }
    else if (K < A + B) { cout << A << endl; }
    else { cout << A - (K - (A + B)) << endl; }
}


Measured memory_bytes: 3636
import random

n = int(input())
A = [int(input()) for i in range(n)]
cnt = 0

def insertion_sort(list, step):
    n = len(list)
    for i in range(step, n):
        temp = list[i]
        j = i
        while j >= step and list[j - step] > temp:
            list[j] = list[j - step]
            j -= step
            global cnt
            cnt += 1
        list[j] = temp
    return list

def shell_sort(list):
    n = len(list)
    
    G = []
    step = 1
    while step <= n:
        G.append(step)
        step = 3*step + 1
    print(len(G))
    for g in sorted(G, reverse=True):
        print(g, end=' ')
    print('\n', end='')

    for i in sorted(range(len(G)), reverse=True):
        list = insertion_sort(list, G[i])
    return list

shell_sort(A)
print(cnt)

for i in A:
    print(i, end='\n')

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

using namespace std;
typedef long long ll;

int main() {
    int n,k,q;

    cin >>  n >> k >> q;
    
    vector<int> right(n, 0);
    for(int i=0; i < q; i++) {
        int num;
        cin >> num;

        right[num-1]++;
    }

    for(int i=0; i < n; i++) {
        if(k - q + right[i] > 0) {
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <string.h>
#define For(x,y) for(x=0;x<y;x++)
using namespace std;
int main()
{
    string s;
    int i,flag=0;
    cin>>s;
    For(i,s.size())
    {
        if(s[i]=='7')
        {
            cout<<"Yes";
            flag=1;
            break;
        }
    }
    if(flag == 0)
        cout<<"No";
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>

using namespace std;

const int MAXN = 2e5+2;
int nums[MAXN];

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

    int val;
    for (int i=2; i<=n; i++) {
        cin >> val;
        nums[val]++;
    }

    for (int i=1; i<=n; i++) {
        cout << nums[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3948
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

bool has_divisor(int n, int i) {
	if (i == n) return false;
	if (n % i == 0) return true;
	return has_divisor(n, i + 1);
}

bool is_prime(int n) {
	if (n == 1) return false;
	else if (n == 2) return true;
	else return !has_divisor(n, 2);
}

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

	while (!is_prime(x)) x++;

	dunk(x);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repin(Array,n) for(int i=0;i<n;i++){cin>>Array[i];}
using namespace std;

using ll = long long;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;
using Graph = vector<vector<int>>;

int main() {

	int a, b, c;
	cin >> a >> b >> c;

	for (int i = 1; i < b; i++) {
		if (i * a % b == c) {
			cout << "YES" << endl;
			return 0;
		}
	}

	cout << "NO" << endl;

	return 0;
}

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

using std::max;        
         
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	int answer = 1;
	for (int i = 1; i * i <= m; i++) {
		if (m % i == 0 && m / n >= i) {
			answer = max(answer, i);
		}
		if (m % i == 0 && i >= n) {
			answer = max(answer, m / i);
		}
	}
	printf("%d", answer);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    ll i,j;
    cin >> N;
    for(i=1;i<=9;i++){
        for(j=1;j<=9;j++){
            if(i*j==N){
            	cout <<"Yes";
            	return 0;
            }
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
# li = list(map(int, input().split()))
N, M = map(int, input().split())

ll = 1
rr = 100000

for i in range(M):
    l_next, r_next = map(int, input().split())
    if l_next >= ll:
        ll = l_next
    if r_next <= rr:
        rr = r_next

print(max(rr - ll + 1, 0))


Measured memory_bytes: 3060
S=input()
size=len(S)
def palin(S,size):
    for i  in range (size//2):
        if S[i]!=S[-1-i]:
            return False
    return True
if palin(S,size) == True:
    L=S[:size//2]
    R=S[size//2+2:]
    if palin(L,size//2) & palin(L,size//2):
        print('Yes')
    else:
        print('No')
else:
    print('No')



Measured memory_bytes: 9128
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <numeric>

using LL = long long;

int main()
{
    int n;
    scanf("%d", &n);
    std::vector<int> a(n), b(n);
    for (int i = 0; i < n; ++ i) scanf("%d", &a[i]);
    for (int i = 0; i < n; ++ i) scanf("%d", &b[i]);
    LL cnt = 0;
    for (int i = 0; i < n; ++ i) {
        if (a[i] < b[i]) {
            LL tmp = b[i] - a[i] + 1 >> 1;
            cnt += tmp;
            a[i] += tmp << 1;
        }
        if (b[i] < a[i]) {
            cnt -= a[i] - b[i];
        }
    }
    puts(cnt < 0 ? "No" : "Yes");
}


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

int main()
{
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	if(abs(c-a)<=d) printf("Yes");
	else if(abs(b-a)<=d && abs(c-b)<=d) printf("Yes");
	else printf("No");
    return 0;
}


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

#define ll                   long long int
#define MOD                  1000000007
#define fast()               ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define loop(i,a,b)          for(ll i=(ll)a;i<(ll)b;i++)
#define pool(i,a,b)          for(ll i=(ll)a;i>=(ll)b;i--)
#define pb                   push_back
#define vi                   vector<ll>
#define test()               ll t; cin>>t; while(t--)
#define endl                 "\n"
#define param                greater<ll>()
#define ff                   first
#define ss                   second
#define all(v)               v.begin(),v.end()
#define keep_unique(v) sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
#define sor(vec) sort(vec.begin(),vec.end());

using namespace std;

const int N = 105;
const int W = 1e5+10;

#define MAX  10000000000;
// const int MOD = 998244353;

ll fast_exp(ll x,ll n){ll ans=1;while(n){if(n&1)ans*=x;n=n>>1;x=x*x;}return ans;}
ll mod_exp(ll x, ll y,ll p){ll res = 1;x = x % p;while(y>0){if(y&1)res = (res*x) % p;y = y>>1;x=(x*x)%p;}return res;}


//  vector < ll > vec(N);

// ll fib[N];

ll dp[N][W];


int main()
{
    
    fast()
    
    
    ll t;
    // cin>>t;
    t=1;
    
    while(t--)
    {
        ll a,b,c,i,n,k,p,j,d,m,r,w;
        
        string s;
        
        cin>>n>>w;
        
        vector<ll>wt(n+1),val(n+1);
        
        for(i=1;i<=n;i++)
        {
            cin>>wt[i]>>val[i];
        }
        
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=w;j++)
            {
                
                if(wt[i]>j)
                dp[i][j]=dp[i-1][j];
                else if(wt[i]<=j)
                dp[i][j]=max(val[i]+dp[i-1][j-wt[i]] , dp[i-1][j]);
                
                
            }
        }
        
        // for(i=0;i<=n;i++)
        // {
        //     for(j=0;j<=w;j++)
        //     {
                
        //         cout<<dp[i][j]<<" ";
                
                
        //     }
        //     cout<<endl;
        // }
        
        
        
        
        
       
       
        
        cout<<dp[n][w]<<endl;
        
        
        
        // string ans=vec[0];
      
    }
   
   
   
   
    return 0;
}


Measured memory_bytes: 79360
import sys
input = sys.stdin.buffer.readline

class UnionFind:
    __slots__ = ["data"]
    
    def __init__(self, n=0):
        self.data = [-1]*(n+1)
    
    def root(self, x):
        if self.data[x] < 0:
            return x
        self.data[x] = self.root(self.data[x])
        return self.data[x]
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.data[x] < self.data[y]:
                self.data[x] += self.data[y]
                self.data[y] = x
            else:
                self.data[y] += self.data[x]
                self.data[x] = y
    
    def same(self, x, y):
        return self.root(x) == self.root(y)
    
    def size(self, x):
        return -self.data[self.root(x)]
                


def main():
    n, m, k = map(int, input().split())
    fb = [0]*(n+1)
    uf = UnionFind(n)
    for _ in range(m):
        a, b = map(int, input().split())
        fb[a] += 1
        fb[b] += 1
        uf.unite(a, b)
    for _ in range(k):
        c, d = map(int, input().split())
        if uf.same(c, d):
            fb[c] += 1
            fb[d] += 1
    ans = [uf.size(i)-1-fb[i] for i in range(1, n+1)]
    print(" ".join(list(map(str, ans))))


if __name__ == "__main__":
    main()

Measured memory_bytes: 15628
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()


int main() {
    string s;
    cin >> s;
    bool judge=false;
    rep(i,3) if(s.at(i)=='7') judge = true;
    if(judge) dunk("Yes");
    else dunk("No");
}



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

int rightSide(int top, int face){
	int result = -1;
	if(top == 0){
		if(face == 1){ result = 2; }
		else if(face == 2){ result = 4;}
		else if(face == 4){ result = 3;}
		else if(face == 3){ result = 1;}
	}else if(top == 1){
		if(face == 0){ result = 3; }
		else if(face == 3){ result = 5;}
		else if(face == 5){ result = 2;}
		else if(face == 2){ result = 0;}		
	}else if(top == 2){
		if(face == 4){ result = 0; }
		else if(face == 0){ result = 1;}
		else if(face == 1){ result = 5;}
		else if(face == 5){ result = 4;}		
	}else if(top == 3){
		if(face == 5){ result = 1; }
		else if(face == 1){ result = 0;}
		else if(face == 0){ result = 4;}
		else if(face == 4){ result = 5;}		
	}else if(top == 4){
		if(face == 2){ result = 5; }
		else if(face == 5){ result = 3;}
		else if(face == 3){ result = 0;}
		else if(face == 0){ result = 2;}		
	}else if(top == 5){
		if(face == 4){ result = 2; }
		else if(face == 2){ result = 1;}
		else if(face == 1){ result = 3;}
		else if(face == 3){ result = 4;}		
	}

	return result;
}

int main(){
	int dice1[6], dice2[6];
	int top, face;

	for(int i = 0; i < 6; i++){
		cin >> dice1[i];
	}

	for(int i = 0; i < 6; i++){
		cin >> dice2[i];
	}

	int indexOfTop, indexOfFace;
	int right1, right2;
	int ngcount = 0;
	for(int j = 0; j < 6; j++){
		for(int i = 0; i < 6; i++){
			if(dice2[i] == dice1[j]) {
				indexOfTop = i;
			}
			if(dice2[i] == dice1[j+1]) {
				indexOfFace = i;
			}
		}
		right1 = rightSide(j, j+1);
		right2 = rightSide(indexOfTop,indexOfFace);
		if(right1 != -1 && right2 != -1){
			if(dice1[right1] == dice2[right2]){
			}
			else{
				ngcount++;
			}
		}
	}
	if(ngcount){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    ll N,M;
    cin >> N >> M;
    vector<ll> h(N);
    for(ll i=0;i<N;i++){
        cin >> h.at(i);
    }
    ll a,b;
    vector<ll> count(N,0);
    for(ll j=0;j<M;j++){
        cin >> a >> b;
        if(h.at(a-1)<h.at(b-1)){
        	count.at(a-1)++;
        }else if(h.at(a-1)==h.at(b-1)){
            count.at(a-1)++;
            count.at(b-1)++;
        }else{
        	count.at(b-1)++;
        }
    }
    ll ans=0;
    for(ll i=0;i<N;i++){
        if(count.at(i)==0){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4844
#include<iostream>
#include<string>
#include<algorithm>
#include<unordered_set>
#include<vector>
#include<math.h>
#include<iomanip>

using namespace std;

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

	int n, m;
	cin >> n >> m;
	if (m == n) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
 
int main(){
    int N, C[200000];
    cin >> N;
    for(int i=0; i<N; i++) cin >> C[i];
 
    int left[200001];
    for(int i=0; i<=200000; i++) left[i] = -1;
    static int64_t dp[200001];
    dp[0] = 1;
    for(int i=0; i<N; i++){
        add(dp[i+1], dp[i]);
        int c = C[i];
        if(left[c] >= 0 && left[c] < i-1) add(dp[i+1], dp[left[c]+1]);
        left[c] = i;
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 6800
// C - management
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int in(){int x;cin>>x;return x;}

int main(){
	int N; cin>>N;
	vvi ans(N+1,vi());
	rp(i,2,N+1) ans[in()].push_back(i);
	rp(i,1,N+1) cout<<ans[i].size()<<endl;
}

Measured memory_bytes: 13996
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=3e3+5,M=5e3+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
int n,m,f[N][N][2],ans;
void ad(int&a,int b){a+=b;a%=mod;}
int main(){
	read(n,m);
	rep(i,1,n)f[0][i][0]=1;
	f[0][0][1]=1;
	re(i,0,m)rep(j,0,n)rep(k,0,1)if(f[i][j][k]){
		if(j>1){
			ad(f[i+1][j-1][k],f[i][j][k]);
			ad(f[i+1][j][k],f[i][j][k]);
		}else if(j==1){
			ad(f[i+1][0][1],f[i][j][k]);
			ad(f[i+1][1][1],f[i][j][k]);
		}
		if(j<n){
			ad(f[i+1][j+1][k],f[i][j][k]);
			ad(f[i+1][j][k],f[i][j][k]);
		}
	}int res=0;rep(i,0,n)ad(res,f[m][i][1]);
	cout<<res<<endl;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define int long long
#define ll long long
using namespace std;
signed main(){
  int a,b;
  cin>>a>>b;
  cout<<a*b<<endl;
  return 0;
}

Measured memory_bytes: 3572
#ifndef BZ
#pragma GCC optimize "-Ofast"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

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

using namespace std;

const int MX = 307;

ld f[MX + 5][MX + 5][MX + 5];

int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n;
    cin >> n;
    int c1 = 0, c2 = 0, c3 = 0;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (x == 1) {
            c1++;
        } else if (x == 2) {
            c2++;
        } else {
            c3++;
        }
    }

    for (int k = 0; k < MX; k++) {
        for (int j = 0; j + k < MX; j++) {
            for (int i = 0; i + j + k < MX; i++) {
                if (i == 0 && j == 0 && k == 0) {
                    continue;
                }
                if (i + j + k > MX) {
                    continue;
                }
                ld wait = 1.0 * n / (i + j + k);
                ld pi = 1.0 * i / (i + j + k);
                ld pj = 1.0 * j / (i + j + k);
                ld pk = 1.0 * k / (i + j + k);

                if (i) {
                    f[i][j][k] = pi * f[i - 1][j][k];
                }
                if (j) {
                    f[i][j][k] += pj * f[i + 1][j - 1][k];
                }
                if (k) {
                    f[i][j][k] += pk * f[i][j + 1][k - 1];
                }
                f[i][j][k] += wait;
            }
        }
    }

    cout.precision(10);
    cout << fixed << f[c1][c2][c3] << "\n";
    return 0;
}



Measured memory_bytes: 233856
#include<stdio.h>

long int func(char* s, long int a){
    long int sum = 0;
    if(*s == '\0'){
        return a;
    }
    int i=0;
    long int buf = 0;
    while(*(s+i) != 0){
        buf += *(s+i) - '0';
        sum += func((s+i+1), buf+a);
        //printf("%ld\n", sum);
        buf *= 10;
        i++;
    }
    return sum;
}

int main(){
    char str[11];
    scanf("%s", str);
    printf("%ld", func(str, 0));

    return 0;
}

Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A1, A2, A3 = MAP()

a = sorted([A1, A2, A3])
ans = 0
for i in range(1, 3):
	ans += a[i]-a[i-1]

print(ans)


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

int a,b;

int main(){
    cin >> a >> b;
    if (a == b) 
     cout << "a == b" <<endl;
    else if (a > b) 
     cout << "a > b" <<endl;
    else
     cout << "a < b" <<endl;
    return 0;
}


Measured memory_bytes: 3084
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
 
using namespace std;
 
typedef long long ll;
 
ll w[105];
ll v[105];
 
vector<pair<ll, int> >vec[4];
 
int main() {
 
	int N,W;
 
	scanf("%d %d",&N,&W);
 
	int i, j, k, m, l;
 
	for (i = 0; i < N; i++) {
		scanf("%lld %lld",&w[i],&v[i]);
		vec[w[i] - w[0]].push_back(make_pair(v[i], i));
	}
 
	for (i = 0; i < 4; i++) {
		sort(vec[i].begin(),vec[i].end());
		reverse(vec[i].begin(),vec[i].end());
	}
 
	ll ans = 0ll;
	for (i = 0; i <= vec[0].size(); i++) {
		for (j = 0; j <= vec[1].size(); j++) {
			for (k = 0; k <= vec[2].size(); k++) {
				for (m = 0; m <= vec[3].size(); m++) {
					ll sum = 0ll;
					ll omosa = 0ll;
					for (l = 0; l < i; l++) {
						sum += vec[0][l].first;
						omosa += w[vec[0][l].second];
					}
					for (l = 0; l < j; l++) {
						sum += vec[1][l].first;
						omosa += w[vec[1][l].second];
					}
					for (l = 0; l < k; l++) {
						sum += vec[2][l].first;
						omosa += w[vec[2][l].second];
					}
					for (l = 0; l < m; l++) {
						sum += vec[3][l].first;
						omosa += w[vec[3][l].second];
					}
					if (omosa <= W) {
						if (ans < sum) {
							ans = sum;
						}
					}
				}
			}
		}
	}
	printf("%lld\n",ans);
 
 
	return 0;
}

Measured memory_bytes: 256
//Yeh Toh Sahi Hoga
#include<bits/stdc++.h>
using namespace std;
//#define ll long long int
#define ld long double
#define int long long
#define pb push_back 
#define mod 1000000007
#define Z(c) (int)(c).size()
#define F first
#define S second
#define nl "\n"
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define clber cin.ignore(numeric_limits<streamsize>::max(),'\n'); 
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);(i)++)
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl;
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl;
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl;
#define pi 3.1415926536
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define tr(ct,it) for(typeof((ct).begin() it = (ct).begin(); it != (ct).end(); it++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef vector< pii > vp;

int power(int a,int n,int lelo)
{
        if(n==0)
                return 1;
        if(n==1)
                return a;
        if(n==2)
                return (a*a)%lelo;
        if(n%2)
                return (a*power(a,n-1,lelo))%lelo;
        else
                return power(power(a,n/2,lelo),2,lelo)%lelo;
}


void swap(int &a,int &b)
{ int tm=a; a=b; b=tm; }

 const int N=3e5+5;

/* void dfs(int n)
 {
    chk[n]=1;
    for(int i=0;i<v[n].size();i++)
    {
      if(chk[v[n][i]]==0)
       { dfs(v[n][i]);
           
        }
    }
 }   */

void solve()
{ 
  int n; cin>>n; vi v(n); rep(i,0,n) cin>>v[i];
  vi a(n);  a[0]=v[0]; rep(i,1,n) a[i]=a[i-1]+v[i];
  int mn=LONG_MAX;

  rep(i,0,n-1)
   mn=min(abs(2*a[i]-a[n-1]),mn);
   cout<<mn;


 }

  


signed main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  ld tt=clock();
/*   #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);

   freopen("output.txt", "w", stdout);

   freopen("error.txt","w", stderr);
   #endif  
  */
  int t=1;
  
//  cin>>t;
rep(i,1,t+1)
  { // cout<<"Case #"<<i<<": ";
   solve();
   

   cout<<"\n";
  }
/* #ifndef ONLINE_JUDGE
  cerr<<1000* (clock()-tt)/CLOCKS_PER_SEC<<" ms"<<nl;
 #endif  */
 
 return 0; 
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    ll ans = 0,cb=0,cw=0;
    for(int i = 0;i < s.size();){
        if(s[i]=='B') cw=0;
        while(i<s.size()&&s[i]=='B'){
            i ++;
            cb ++;
        }
        while(i<s.size()&&s[i]=='W'){
            i ++;
            cw ++;
        }
        ans += cb*cw;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 720
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int [][][] A= new int[4][3][10]; 
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
         int b=sc.nextInt();
         int f=sc.nextInt();
         int r=sc.nextInt();
         int v=sc.nextInt();
         A[b-1][f-1][r-1]+=v;
        }
         for( int i = 0; i < 4; i++ ) {
        	for( int j = 0; j < 3; j++ ) {
                for( int z = 0; z < 10; z++ ) {
                       System.out.print(" "+A[i][j][z]);
            
                }
                System.out.println();
            }
                for(int x=0;x<20;x++){
                    if(i==3)break;
                    System.out.print("#");
                    
         }
              if(i<3){
              System.out.println();
             
          }
    }
}
}                                           


Measured memory_bytes: 29488
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;

int c1,c5,c10,c50,c100,c500;

int main(){
	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;

	
	if ((c1*1+c5*5+c10*10+c50*50+c100*100+c500*500)>=1000){
		cout << 1 << endl;
	}
	else{ cout << 0<<endl; }

	return 0;
}


Measured memory_bytes: 3116
N, A = map(int, input().split())
x = [int(i) for i in input().split()]

# 3d DP
max_x = max(x)

dp = [[[0] * (max_x * N + 1) for j in range(N + 1)]
                             for i in range(N + 1)]

dp[0][0][0] = 1

for i in range(0, N):
    for k in range(0, N + 1):
        for y in range(max_x * N + 1):
            if dp[i][k][y]:
                dp[i + 1][k][y] += dp[i][k][y]
                dp[i + 1][k + 1][y + x[i]] += dp[i][k][y]
    
cnt = 0
for k in range(1, N + 1):
    for y in range(1, max_x * N + 1):
        if y // k == A and y % k == 0:
            cnt += dp[N][k][y]

print(cnt)

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

int main(){
  int h, w;
  while (true){
    cin >> h >> w;
    if(h==0 && w == 0){break;}
    for (int i = 0; i < h; i++){
      for (int a = 0; a < w; a++){
        if (i % 2 == 0){
          if(a % 2 == 0){
            cout << "#";
          }else{
            cout << ".";
          }
        }else{
          if(a % 2 == 0){
            cout << ".";
          }else{
            cout << "#";
          }
        }
      }
      cout << "\n";
    }
    cout << "\n";
  }
}


Measured memory_bytes: 3060
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(13)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N, d[100000]; cin >> N;
  REP(i, N) cin >> d[i];
  sort(d, d+N);
  cout << d[N/2] - d[N/2-1] << endl;
}

Measured memory_bytes: 1024