akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

ll N;

int main() {
    cin >> N;

    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    rep(i, N) A[i] -= (i + 1);

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

    if (N % 2 == 0) {
        ll middle_left = A[N / 2 - 1];
        ll middle_right = A[N / 2];

        ll tmp1 = 0;
        ll tmp2 = 0;

        rep(i, N) {
            tmp1 += abs(A[i] - middle_left);
            tmp2 += abs(A[i] - middle_right);
        }

        cout << min(tmp1, tmp2) << endl;
        return 0;
    } else {
        ll middle = A[(N - 1) / 2];

        ll ans = 0;
        rep(i, N) {
            ans += abs(A[i] - middle);
        }
        cout << ans << endl;
        return 0;
    }

}

Measured memory_bytes: 1792
package main

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

type Block struct {
	Value string
	Len   int
}

func main() {
	var N, K, ans int
	fmt.Scan(&N, &K)
	var S string
	s := bufio.NewScanner(os.Stdin)
	b := make([]byte, 1000000)
	s.Buffer(b, 1000000)
	s.Scan()
	S = s.Text()
	blocks := RunLength(S)
	sum, zero, l := 0, 0, 0
	for r := 0; r < len(blocks); r++ {
		sum += blocks[r].Len
		if blocks[r].Value == "0" {
			zero++
		}
		for K < zero {
			sum -= blocks[l].Len
			if blocks[l].Value == "0" {
				zero--
			}
			l++
		}
		ans = Max(ans, sum)
	}
	fmt.Println(ans)
}

func RunLength(s string) []Block {
	var r []Block
	if len(s) == 0 {
		return r
	}
	t := Block{Value: string(s[0]), Len: 1}
	for _, v := range s[1:] {
		if t.Value == string(v) {
			t.Len++
		} else {
			r = append(r, t)
			t = Block{Value: string(v), Len: 1}
		}
	}
	r = append(r, t)
	return r
}

func Max(a, b int) int {
	if b > a {
		return b
	}
	return a
}


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


int main(){
  int N;
  cin>>N;
  vector<int> x(N);
  for(int i=0;i<N;i++) cin>>x.at(i);
  int ans=100000000;
  for(int i=0;i<101;i++){
    int HP=0;
    for(int c:x) HP=HP+pow(c-i,2);
    ans=min(HP,ans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

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


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

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

	vector<bool> acv(n, false);
	vector<int> wav(n, 0);
	for (int i = 0; i < m; ++i) {
		int p;
		string s;
		cin >> p;
		cin >> s;

		if (s == "AC") {
			acv[p - 1] = true;
		}
		else {
			if (!acv[p - 1]) {
				wav[p - 1] += 1;
			}
		}
	}

	int acNum = 0;
	int peNum = 0;
	for (int i = 0; i < n; ++i) {
		if (acv[i]) {
			++acNum;
			peNum += wav[i];
		}
	}

	cout << acNum << " " << peNum << endl;

	return 0;
}

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

using namespace std;

int n, m;

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

    cin >> n >> m;
    long long sum = 0;
    for(int i = 0; i < m; i++)
    {
        int x;
        cin >> x;
        sum += x;
    }

    cout << (n - sum < 0 ? -1 : n - sum);

    return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define int long long 
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define pre(i,a,b) for(int i=(b);i>=(a);i--)
#define ios ios::sync_with_stdio(false),cin.tie(0);
#define pb push_back
#define ps push
#define fi first
#define se second
#define ps push
#define Inf 0x3f3f3f3f3f3f3f3f
#define eps 1e-5
typedef long long ll;
const int N=2e5+5;
const int mod=998244353;
using namespace std;

signed main(){
    ios;
    string s,t;
    cin>>s>>t;
    int len=s.size();
    rep(i,0,len-1){
        if(s[i]!=t[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int N;
string S;
bool sheep[100100];

bool check(){
    bool ans = true;
    for(int i = 1; i < N; i++){
        if(S[i] == 'o'){
            if(sheep[i]) sheep[i+1] = sheep[i-1];
            else sheep[i+1] = !sheep[i-1];
        }else{
            if(sheep[i]) sheep[i+1] = !sheep[i-1];
            else sheep[i+1] = sheep[i-1];
        }
    }

    if(sheep[0] != sheep[N]) ans = false;
    if(S[0] == 'o'){
        if(sheep[0] && sheep[1] != sheep[N-1]) ans = false;
        if(!sheep[0] && sheep[1] == sheep[N-1]) ans = false;
    }
    else{
        if(sheep[0] && sheep[1] == sheep[N-1]) ans = false;
        if(!sheep[0] && sheep[1] != sheep[N-1]) ans = false;
    }
    return ans;
}

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

    bool ans;

    fill(sheep, sheep+N, false);
    sheep[0] = true;
    sheep[1] = false;
    ans = check();
    if(ans) goto fin;

    fill(sheep, sheep+N, false);
    sheep[0] = true;
    sheep[1] = true;
    ans = check();
    if(ans) goto fin;

    fill(sheep, sheep+N, false);
    sheep[0] = false;
    sheep[1] = true;
    ans = check();
    if(ans) goto fin;

    fill(sheep, sheep+N, false);
    sheep[0] = false;
    sheep[1] = false;
    ans = check();
    if(ans) goto fin;

fin:
    if(!ans)
        cout << "-1" << endl;
    else{
        REP(i,N){
            if(sheep[i]) cout << 'S';
            else cout << 'W';
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 640
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;
const int maxn = 5e5 + 5;
const int maxa = 1 << 22;

int n;
int a[maxn], b[maxn], cnt[maxn], last[maxa];
ll ans;
ll dp[maxn], sum[maxa];

int main(){
	scanf("%d", &n);
	REP(i, 1, n){
		scanf("%d", a + i);
		b[i] = (i ? b[i - 1] : 0) ^ a[i];
		cnt[i] = cnt[i - 1] + (!b[i]);
	}
	memset(last, -1, sizeof(last));
	REP(i, 1, n){
		int j = last[b[i]];
		if(!b[i])
			continue;
		if(!~j){
			dp[i] = 1;
		}
		else{
			dp[i] = (dp[j] - 1 + INF) % INF
					+ (dp[j] * (cnt[i] - cnt[j - 1]) % INF)
					+ ((sum[b[i]] - dp[j] + INF) % INF * (cnt[i] - cnt[j - 1]) % INF);
			(dp[i] += 1 + INF) %= INF;
		}
		if(!b[n])
			(ans += dp[i]) %= INF;
		last[b[i]] = i;
		(sum[b[i]] += dp[i]) %= INF;
	}
/*	REP(i, 1, n)
		printf("%lld ", dp[i]);
	puts("");
*/	ll res = 1;
	if(b[n])
		ans += (dp[n] - 1 + INF) % INF;
	if(!b[n]){
		FOR(i, 1, cnt[n])
			(res <<= 1) %= INF;
	}
	(ans += res) %= INF;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 36608
#include<stdio.h>
int main(){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(a+b>c+d) printf("Left\n");
  else if(a+b<c+d) printf("Right\n");
  else printf("Balanced\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
inline void print() { cout << endl; }
template <class Head, class... Tail> inline void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> inline void print(vector<T>& vec) { for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " "; } cout << endl;}
template <class T> inline void print(vector<vector<T>>& df) { for (auto& vec : df) { print(vec); }}
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;


int main() { 
    int N, K; cin >> N >> K;
    vector<ll> H;
    REP(i, N) { int h; cin >> h; H.push_back(h);}

    ll minH = LINF;
    sort(H.begin(), H.end());
    for(int i=0; i<N-(K-1); i++) {
        chmin(minH, H[i+K-1]-H[i]);
    }

    cout << minH << endl;
    
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n, m; cin >> n >> m;
  vector<P> a(n);
  vector<P> b1(m), b2(m);
  set<int> stx, sty;
  for(int i=0;i<n;++i) {
    cin >> a[i].first >> a[i].second;
    stx.insert(a[i].first);
    sty.insert(a[i].second);
  }
  for(int i=0;i<m;++i) {
    cin >> b1[i].first >> b1[i].second;
    cin >> b2[i].first >> b2[i].second;
  }
  int idx = 0;
  int idy = 0;
  map<int, int> mpx, mpy;
  for(auto &e: stx) {
    mpx[e] = idx;
    idx++;
  }
  for(auto &e: sty) {
    mpy[e] = idy;
    idy++;
  }
  vector<P> v(n);
  vector<P> x(n), y(n);
  for(int i=0;i<n;++i) {
    v[i].first = mpx[a[i].first];
    v[i].second = mpy[a[i].second];
    x[i].first = a[i].first;
    x[i].second = mpx[a[i].first];
    y[i].first = a[i].second;
    y[i].second = mpy[a[i].second];
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  y.erase(unique(y.begin(), y.end()), y.end());
  vector<vector<int>> su(idx+2, vector<int>(idy+2));
  for(int i=0;i<n;++i) {
    su[v[i].first+1][v[i].second+1]++;
  }
  for(int i=0;i<idx+1;++i) {
    for(int j=0;j<idy+1;++j) {
      su[i+1][j+1] += su[i+1][j] + su[i][j+1] - su[i][j];
    }
  }
  for(int i=0;i<m;++i) {
    auto itx1 = lower_bound(x.begin(), x.end(), make_pair(b1[i].first, 0));
    auto itx2 = upper_bound(x.begin(), x.end(), make_pair(b2[i].first, INF + 1));
    auto ity1 = lower_bound(y.begin(), y.end(), make_pair(b1[i].second, 0));
    auto ity2 = upper_bound(y.begin(), y.end(), make_pair(b2[i].second, INF+1));
    auto x1 = distance(x.begin(), itx1);
    auto x2 = distance(x.begin(), itx2);
    auto y1 = distance(y.begin(), ity1);
    auto y2 = distance(y.begin(), ity2);
    cout << su[x2][y2] - su[x2][y1] - su[x1][y2] + su[x1][y1] << endl;
  }
}



Measured memory_bytes: 109760
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i;
  cin>>n;
  int a[n],max=0,c=0;
  for(i=0;i<n;i++)
  {
    cin>>a[i];
    if(a[i]>max) max=a[i];
    if(a[i]==max) c++;
  }
  cout<<c;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int meter, rotate, deg = 90;
		double x = 0, y = 0;
		String str, buf[] = new String[2];
		while((str = br.readLine()) != null){
			buf = str.split(",");

			meter = Integer.parseInt(buf[0]);
			rotate = Integer.parseInt(buf[1]);

			if(meter == 0 && rotate == 0)break;

			x += meter * Math.cos(Math.toRadians(deg));
			y += meter * Math.sin(Math.toRadians(deg));

			deg -= rotate;
		}
		System.out.println((int) x);
		System.out.println((int) y);
	}

}

Measured memory_bytes: 16912
import java.util.*;
public class Main {
  static String[] AZ = new String[] { "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" };
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < s.length(); i++) {
      int x = (int)(s.charAt(i) - 'A');
      sb.append(AZ[(x + n) % 26]);
    }
    System.out.println(sb.toString());
  }
}

Measured memory_bytes: 23636
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int A = scan.nextInt();
	int B = scan.nextInt();

	int count = 0;
	for(int i = 0; i < 2; i++){
	    if(A >= B){
		count += A;
		A--;
	    }else{
		count += B;
		B--;
	    }
	}

	System.out.println(count);
    }
}


Measured memory_bytes: 23124
#include <stdio.h>
#define N 200000

int main(void)
{
  int n,i,R[N];
  int maxv,minv;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    scanf("%d",&R[i]);
    
    minv=R[0];
    maxv=R[1]-R[0];
    
  for(i=1;i<n;i++){
    if(R[i]-minv > maxv) maxv=R[i]-minv;
    if(R[i]<minv) minv=R[i];
    }
    
    printf("%d\n",maxv);
  return 0;
}

Measured memory_bytes: 1376
# -*- coding: utf-8 -*-

N, C, K = map(int, input().split())
T = []
for i in range(N):
    T.append(int(input()))
T.sort()

idx = 0
bus = 0
while(True):
    if idx == N:
        break
    bus += 1
    limit = T[idx] + K
    for c in range(idx,idx+C):
        if idx == N:
            break
        dep = T[c]
        if dep <= limit:
            idx += 1
            continue
        else:
            break
print(bus)


Measured memory_bytes: 7384
/* C */

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
	string s;
	cin >> s;
	int n = s.size();

	string a, b;

	for(int i = 0; i < n; i++){
		a += to_string(i % 2);
		b += to_string((i + 1) % 2);
	}
	
	int sa = 0, sb = 0;

	for(int j = 0; j < n; j++){
		if(s[j] != a[j]) sa++;
		if(s[j] != b[j]) sb++;
	}

	cout << min(sa,sb) << endl;

}

Measured memory_bytes: 768
io = STDIN
n,m,x=io.gets.split.map(&:to_i)
left,right=0,0
ar=io.gets.split.map(&:to_i)
ar.each do |a|
  if (0..x).include?(a)
    left+=1
  end
  if (x..n).include?(a)
    right+=1
  end
end
puts [left,right].min


Measured memory_bytes: 1788
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
d=0
ab=0
for i in range(N):
  d+=b[a[i]-1]
  
  if i != 0:
    if ab+1==a[i]:
      d+=c[ab-1]
   
  ab=a[i]
    
print(d)  


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(std::string S){
    if (S == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}

int main(){

    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}



Measured memory_bytes: 3620
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


int main()
{

	string s;
	cin >> s;

	
	if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi")
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
'use strict';
 
function ary_counter(ary) {
  let c = 0;
  ary.forEach(a => ++c);
  return c;
}
 
function main(stdin) {
  const l = [];
  let res = 'Yes';
 
  for (let i = 0; i < 4; ++i) {    
    const c = stdin.charCodeAt(i);
    l[c] = l[c] || 0;
    ++l[c];
  }
 
  if (ary_counter(l) !== 2) res = 'No'; 
  
  console.log(res);
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 1; i <= (o); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  int a; ll b, n;
  cin >> a >> b >> n;

  ll ans = 0;
  if (n < b)
  {
      ans = floor(a*n/b) - a * floor(n/b);
  }
  else
  {
      /* code */
      ans = floor(a*(b-1)/b) - a * floor((b-1)/b);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

using static Input;
using static Util;
class Program
{
    static long K;

    static void INPUT()
    {
        K = NextLong();
    }
    static void OUT()
    {
        var n = 100L;
        var i = 0;
        for (i = 0; n < K; i++)
        {
            n += n / 100;
        }

        Console.WriteLine(i);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 17732
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n = gi();
    int k = gi();
    printf(n%k ? "1\n" : "0\n");

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll                          long long
#define in(a)                       ll a; cin>>a;
#define in2(a,b)                    ll a,b; cin>>a>>b;
#define in3(a,b,c)                  ll a,b,c; cin>>a>>b>>c;
#define in4(a,b,c,d)                ll a,b,c,d; cin>>a>>b>>c>>d;
#define in5(a,b,c,d,e)              ll a,b,c,d,e; cin>>a>>b>>c>>d>>e;
#define lelo(b)                     for(auto &i:b)cin>>i;
#define ff                          first
#define ss                          second
#define call(v)                     v.begin(),v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define show(x)                     for(auto t:x)cout<<t<<" ";
#define pb                          push_back
#define bhar(s,v)                   memset(s,v,sizeof(s))
#define endl                        "\n"                       
#define ce(x)                       cout<<x<<"\n";
#define nl                          cout<<endl;
#define jaldi                       ios_base::sync_with_stdio(false);cin.tie(NULL);
#define dekh_lo                     ce("dekh_lo");
#define sz(x)                       (ll)x.size()
#define re                          return

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;

const ll mod=1e9+7;
const ll N=4e5+5;
ll i,j;

/*


*/

void solve(){
    string s; cin>>s;
    if(s[sz(s)-1]!='s'){
        s=s+'s';
    }
    else{
        s=s+"es";
    }
    ce(s);
}

int32_t main(){
    // jaldi
    ll t; 
    // cin>>t;
    t=1;     
    while(t--){
        solve();
    }
}

/*


*/

  

Measured memory_bytes: 3628
import bisect

S = input()
Q = int(input())

S = {i: s for i, s in enumerate(S)}


head = -1
tail = len(S)

is_filp = False
for i in range(Q):
    q = input()

    if q[0] == '1':
        if is_filp:
            is_filp = False
        else:
            is_filp = True
    elif q[0] == '2':
        _, f, c = q.split(' ')
        if f == '1':
            if is_filp:
                S[tail] = c
                tail += 1
            else:
                S[head] = c
                head -= 1
        else:
            if is_filp:
                S[head] = c
                head -= 1
            else:
                S[tail] = c
                tail += 1

if is_filp:
    print(''.join([S[i] for i in range(tail - 1, head, -1)]))
else:
    print(''.join([S[i] for i in range(head + 1, tail)]))

Measured memory_bytes: 107748
import java.util.*;

public class Main {
 
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String str = sc.nextLine();
	String[] data = str.split(" ");
	int[] num = new int[data.length];
	
	for(int i = 0; i < data.length; i ++)
		num[i] = Integer.parseInt(data[i]);

	int W = num[0];
	int H = num[1];
	int x = num[2];
	int y = num[3];
	int r = num[4];

	boolean x1 = (x >= r) && (x <= W - r);
	boolean y1 = (y >= r) && (y <= H - r);
	if (x1 && y1){
		System.out.println("Yes");
	}
	else {
		System.out.println("No");
	}
    }
 
}


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

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      long sum = 0;
      for(int i = 1; i<= n; i++) {
        if(i % 3 != 0 && i % 5 != 0)
          sum += i;
      }
      System.out.println(sum);
  }
}


Measured memory_bytes: 35764
#include <iostream>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
using namespace std;


bool comp1(pair<int,int> p1,pair<int,int> p2){
  return (double)p1.first*sqrt(3)-(double)p1.second<(double)p2.first*sqrt(3)-(double)p2.second;
}

bool comp2(pair<int,int> p1,pair<int,int> p2){
  return (double)p1.first*sqrt(3)+(double)p1.second<(double)p2.first*sqrt(3)+(double)p2.second;
}

int main(){
  while(1){
    int n;
    scanf("%d",&n);
    if(n==0)break;
    int k;scanf("%d",&k);

    vector<pair<int,int> > po;
    for(int i=0;i<n;i++){
      int a,b;
      scanf("%d %d",&a,&b);
      po.push_back(make_pair(a,b));
    }
    double ans=1e9;
    vector<pair<int,int> > po1,po2;
    po1=po;
    po2=po;
    sort(po1.begin(),po1.end(),comp1);
    sort(po2.begin(),po2.end(),comp2);
  //  for(int i=0;i<n;i++)cout << po2[i].first << " " << po2[i].second << " " << (double)po2[i].first*sqrt(3)+(double)po2[i].second << endl;
  //  for(int i=0;i<n;i++)cout << po1[i].first << " " << po1[i].second << " " << (double)po1[i].first*sqrt(3)-(double)po1[i].second << endl;
    for(int i=0;i<n;i++){
      int h=po[i].second;
      int right=0;int left=0;
      int num=0;
      if(po2[0].second>=h)num=1;
      while(1){
        do{
          right++;
          if(right==n)break;
          if(po2[right].second>=h&&(comp1(po1[left],po2[right])||po1[left]==po2[right]))num++;
        }while(num<n-k);
        if(right==n)break;
        while(num>=n-k){
          if(po1[left].second>=h&&(comp2(po1[left],po2[right])||po1[left]==po2[right]))num--;
          left++;
        }
        left--;
        num++;
        //printf("%d\n",num);
        double x=0.5*((double)po1[left].first+(double)po2[right].first)+0.5/sqrt(3)*(-1*(double)po1[left].second+po2[right].second);
        double y=sqrt(3)*(x-(double)po1[left].first)+(double)po1[left].second;
        double H=y-(double)h;
        H*=2/sqrt(3);
      //  cout << right << " " << left << " "  << x << " " << y << " "<<  H << endl;
        ans=min(ans,H);
      }

    }
    printf("%.10f\n",ans*3);
  }
  return 0;
}


Measured memory_bytes: 3336
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
  using namespace std;

  size_t n, m;
  cin >> n >> m;
  vector<int> cards( n*2 );
  for( size_t i=0; i<cards.size(); ++i ) {
    cards[i] = i + 1;
  }

  for( size_t times=0; times<m; ++times ) {
    int k;
    cin >> k;
    if ( k == 0 ) {
      vector<int> v;
      for( size_t i=0; i<n; ++i ) {
	v.push_back( cards[i] );
	v.push_back( cards[n+i] );
      }
      cards = v;
    } else {
      vector<int> f( k ), l( 2*n - k );
      copy( cards.begin(), cards.begin() + k, f.begin() );
      copy( cards.begin() + k, cards.end(), l.begin() );
      
      cards.clear();
      for( size_t i=0; i<l.size(); ++i ) {
	cards.push_back( l[i] );
      }
      for( size_t i=0; i<f.size(); ++i ) {
	cards.push_back( f[i] );
      }
    }
  }
  for( size_t i=0; i<cards.size(); ++i ) {
    cout << cards[i] << endl;
  }
}

Measured memory_bytes: 1232
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    N = parseInt(readline())
    A = parseMap(split(readline()))
    ans = 0
    for i in 1:N
        if((i % 2 == 1) & (A[i] % 2 == 1))
            ans += 1
        end
    end
    println(ans)

end

main()


Measured memory_bytes: 163692
#include<iostream>
#include<stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int h,a;
  cin>>h>>a;
  int count=0;
  while(1){
    if(h<=0)break;
    h=h-a;
    count++;
  }
  cout<<count<<endl;
    return 0;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

int h, w;
string s[410];
int cmp[410][410];
int cnt[200010][2];

void dfs(int r, int c, int k) {
	cmp[r][c] = k;

	rep(i, 4) {
		int p = r + dx[i];
		int q = c + dy[i];
		if (p >= 0 && p < h && q >= 0 && q < w) {
			if (s[p][q] != s[r][c] && cmp[p][q] == -1) {
				dfs(p, q, k);
			}
		}
	}
}

int main() {
	cin >> h >> w;
	rep(i, h) {
		cin >> s[i];
	}
	memset(cmp, -1, sizeof(cmp));

	int now = 0;

	rep(i, h) {
		rep(j, w) if (cmp[i][j] == -1) {
			dfs(i, j, now++);
		}
	}

	rep(i, h) {
		rep(j, w) {
			++cnt[cmp[i][j]][s[i][j] == '.'];
		}
	}

	ll ans = 0;
	rep(i, now) {
		ans += (ll)cnt[i][0] * cnt[i][1];
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 21120
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;



int main() {

	int N;cin>>N;
	vector<int>ds(N);
	map<int,int>mp;
	for (int i = 0; i < N; ++i) {
		int a;cin>>a;
		mp[a]++;
	}
	int M;cin>>M;
	vector<int>ts(M);
	bool ok=true;
	for (int i = 0; i < M; ++i) {
		int a;cin>>a;
		mp[a]--;
		if(mp[a]<0)ok=false;
	}
	cout<<(ok?"YES":"NO")<<endl;
	return 0;
}

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

int n;
int k;
int m;

int main() {
  cin >> n;
  int V[n];

  // int型の2次元配列(3×4要素の)の宣言
  vector<vector<int>> A(n, vector<int>(n));

  for (int i=0; i<n; i++) {
    cin >> V[i];
    cin >> k;
    if (k==0) {
      continue;
    } else {
      for (int j =0; j<k; j++) {
        cin >> m;
        A[i][m-1] = 1;
      }
    }
  }

  int D[n];
  for (int i=0; i<n; i++) D[i] = -1;
  D[0] = 0;

  queue<int> Q;
  Q.push(0);
  while(! Q.empty()) {
    int cur = Q.front();
    Q.pop();

    for (int i=0; i<n; i++) {
      if (A[cur][i] == 1 && D[i] == -1) {
        D[i] = D[cur] + 1;
        Q.push(i);
      }
    }
  }

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


Measured memory_bytes: 3200
N,M=map(int, input().split())
A=[[] for i in range(N)]

for i in range(M):
  p,y=map(int, input().split())
  A[p-1].append((y, i))

X=[0]*M
for i,d in enumerate(A):
  d.sort()
  for k,(y,j) in enumerate(d):
    X[j]=str(i+1).zfill(6)+str(k+1).zfill(6)
print(*X,sep='\n')

Measured memory_bytes: 37456
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  string A;
  cin >> A;

  ll N = A.size();
  map<char,ll> mp;
  REP(i,N){
    mp[A[i]]++;
  }

  ll cnt = N;
  ll ans = 0;
  for(auto x:mp){
    cnt-=x.second;
    ans+=x.second*cnt;
  }

  cout << ans+1 << endl;
}

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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;
int op[2] = {1,-1};
char pm[2] = {'+', '-'};

int main(){
	int a,b,c,d;
	char q,w,e,r;
	cin >> q>>w>>e>>r;
	a = (int)q - (int)'0';
	b = (int)w - (int)'0';
	c = (int)e - (int)'0';
	d = (int)r - (int)'0';
	for(int ab = 0; ab < 2; ab++)
		for(int bc = 0; bc < 2; bc++)
			for(int cd = 0; cd < 2; cd++){
				int check = a + b*op[ab] + c*op[bc] + d*op[cd];
				if(check == 7){
					cout << a << pm[ab] << b << pm[bc] << c << pm[cd] << d << "=7" << endl;
					return 0;
				}
			}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long r, ans = 0, n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for (int i = 1; i < n - 1; i++) {
        if (max({p[i + 1], p[i], p[i - 1]}) != p[i] && min({p[i + 1], p[i], p[i - 1]}) != p[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   string s;
   cin >> n >> s;
   vector<int> c1(n+1),c2(n+1),c3(n+1);
   for(int i = n-1;i>=0;i--){
      c1[i] = c1[i+1]+(s[i] == 'R');
      c2[i] = c2[i+1]+(s[i] == 'G');
      c3[i] = c3[i+1]+(s[i] == 'B');
   }
   int ans = 0;
   f(i,0,n){
      f(j,i+1,n){
         if(s[i] == s[j]) continue;
         int d = j-i;
         for(char c : {'R','G','B'}){
            if(c == s[i] or c == s[j]) continue;
            if(c == 'R'){
               ans += c1[j+1];
            }else if(c == 'G'){
               ans += c2[j+1];
            }else{
               ans += c3[j+1];
            }
            if(j+d<n){
               ans -= (s[j+d]==c);
            }
         }
      }
   }
   cout << ans << '\n';
   return 0;
} 

Measured memory_bytes: 3744
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<vector>
#include<map>
#include<queue>

#define N 300005
#define M 8000005

#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)

#define mk make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

int i,j,m,n,p,k,Next[26],sum[N];

int A[N][26];

char c[N];

int main()
{
		scanf("%s",c+1);
		n=strlen(c+1);
		for (i=0;i<26;++i) Next[i]=n+1;
		for (i=n;i>=0;--i)
		{
				memcpy(A[i],Next,sizeof(A[i]));
				if (i)
				Next[c[i]-'a']=i;
		}
		for (i=n;i>=0;--i)
		{
				sum[i]=n+5;
				for (j=0;j<26;++j) sum[i]=min(sum[i],sum[A[i][j]]+1);
		}
		for (i=0;i!=n+1;)
		{
				for (j=0;j<26;++j)
					if (sum[A[i][j]]==sum[i]-1) break;
				printf("%c",j+'a');
				i=A[i][j];
		}
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
typedef long long ll;

int main() {
    int n, x;
    cin >> n;
    x = ceil(n / 1.08);
    if(floor(x * 1.08) == n){
        cout << x;
    }else cout << ":(";
}



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



int main()
{
    string s;
    cin>>s;
    if(s.size()<4)
    {
        printf("No");
        return 0;
    }
    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 256
use std::io::*;

fn main() {
    let a = read();
    let b = read();

    if a > b {
        println!(">");
    } else if b > a {
        println!("<");
    } else {
        println!("=");
    }
}

fn read() -> char {
    let s = stdin();
    //    let mut s = BufReader::new(s.lock());
    let b = s.bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<Vec<char>>();
    b[0]
   
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;
constexpr ll MAX = 1e16;

int main(int argc, char **argv)
{
	ll X; cin >> X;

	vector<pair<ll, ll>> A;
	A.reserve(10000000);

	for (ll i = 0;; ++i)
	{
		ll tmp = pow(i, 5);
		A.push_back(pair<ll, ll>(i, tmp));
		A.push_back(pair<ll, ll>(-i, -tmp));
		if (tmp > MAX) break;
	}

	ll N = (ll)A.size();
	for (ll i = 0; i < N; ++i)
	{
		for (ll j = 0; j < N; ++j)
		{
			if (A[i].second - A[j].second == X)
			{
				std::cout << A[i].first << " " << A[j].first << std::endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 4236
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author /\
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DXORWorld solver = new DXORWorld();
        solver.solve(1, in, out);
        out.close();
    }

    static class DXORWorld {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long a = in.nextLong();
            long b = in.nextLong();
            out.println(findRangeXOR(a - 1) ^ findRangeXOR(b));
        }

        long findRangeXOR(long n) {
            if (n % 4 == 3) {
                return 0;
            } else if (n % 4 == 0) {
                return n;
            } else if (n % 4 == 1) {
                return 1;
            } else {
                return (n + 1);
            }
        }

    }

    static class Scanner {
        private StringTokenizer st;
        private BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 21460
//ITP1_6_C

#include <stdio.h>

int main(){

	int n,i,j,k;
	int b,f,r,v;
	int x[4][3][10];
	
	
	scanf("%d",&n);	//?????±??°
	
	//?????????
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				x[i][j][k]=0;
			}
		}
	}
	
	
	//??\???
	for(i=0;i<n;i++){
	
		scanf("%d %d %d %d",&b,&f,&r,&v);
		
		x[b-1][f-1][r-1] = x[b-1][f-1][r-1] + v;
	
	}
	
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				printf(" %d",x[i][j][k]);
			}
			printf("\n");
		}
		if(i==3){break;}
		printf("####################\n");
	}
	
	return 0;

}

Measured memory_bytes: 612
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 


n = int(input())
a = [int(i) for i in readline().split()]

l = sum(a)
r = 0


ans = 10**18
for i in range(n-1):
    l -= a[i]
    r += a[i]
    ans = min(ans, abs(l-r))

print(ans)    


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

using ll = long long;

template <typename T> T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;

int main() {
    int N, K;
    cin >> N >> K;
    int g = 0;
    int ma = 0;
    for(int i = 0; i < N; ++i) {
        int a; cin >> a;
        g = __gcd(g, a);
        ma = max(ma, a);
    }
    if(ma >= K && K % g == 0) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int i = 0; i < n; i++ ){ cout << x[i] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second
     
using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
// const ll MOD = 1e9+7;
ll MOD;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ ll x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

ll a, b, c;

int main(){

  a = in();
  b = in();
  c = in();

  if( a % 2 == 0 or b % 2 == 0 or c % 2 == 0 ){
    cout << 0 << endl;
  } else {
    ll ans = min( { a * b , b * c , c * a } ) ;
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  string S; cin>>S;
  int N = S.size();

  int ans = 0;
  int i=0, j=N-1;
  while(i<j) {
    if (S[i] != S[j]) ans++;
    i++;
    j--;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())
const double pi = 3.14159265358979323846;

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

    ll N,i,j,k,n;
    cin>>N;
    for(n=1;n<=N;n++)
    {
        ll cnt = 0;
        for(i=1;i*i<=n;i++)
        {
            for(j=1;j*j<=n;j++)
            {
                ll val1 = i*i + j*j + i*j;
                if(val1 >= n) break;
                for(k=1;k*k<=n;k++)
                {
                    ll val = i*i + j*j + k*k + i*j + j*k + i*k;
                    if(val>n) break;
                    if(val == n) cnt++;
                }
            }
        }
        cout<<cnt<<"\n";
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define SORT(i) sort((i).begin(), (i).end())
#define INF 2000000000
constexpr ll mod = 1e9 + 7;
 
int main(){
    int N;
    cin >> N;
    vector<int> B(N - 1);
    for (int i = 0; i < N - 1;++i){
        cin >> B[i];
    }
    int ans = B[0] + B[N - 2];
    for (int i = 0; i < N - 1;++i){
        if(i == N - 2){
            break;
        }
        else {
            ans += min(B[i], B[i + 1]);
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main(){
  int N;
  long long int X,ans=0;
  cin>>N>>X;
  long long int a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  if(a[0] > X){
    ans += a[0]-X;
    a[0] = X;
  }
  for(int i=0;i<N-1;i++){
    long long int s=a[i]+a[i+1];
    if(s > X){
      long long int d = s-X;
      ans += d;
      a[i+1] -= d;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <cmath>
#include <string>
#include <iomanip>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <unordered_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define inf 1013161010
#define ninf -1013161010
#define mod 1000000007
#define ll long long
#define lf long double
#define in(x) scanf("%d",&x);
#define sz(x) ((int)x.size())
#define lld l64d
#define rep(i,n) for(i=0;i<n;i++)
#define rrep(i,n) for(i=n-1;i>=0;i--)
#define rep1(i,a,b) for(i=a;i<=b;i++)
#define rrep1(i,a,b) for(i=a;i>=b;i--)
#define stlfor(i,t) for(auto i =t.begin();i!=t.end();i++)
#define fr freopen("x.txt","r",stdin)
#define frc freopen("y.txt","w",stdout)
#define all(x) x.begin(),x.end()
#define set0(x) memset(x,0,sizeof(x))
#define dbg cout<<"yo "<<endl;
#define pset(n) fixed<<showpoint<<setprecision(n)

#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define mp make_pair

typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> OST;

ll toint(const string &s) { stringstream ss; ss << s; ll x; ss >> x; return x; }
string tostring ( ll number ){  stringstream ss; ss<< number; return ss.str();}

const lf pi = 2*acos(0);
const int nn = 2000006;
const lf EPS = 0.000000001;

ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
void nope(int num = 0){ if(num==0) cout<<"NO"; else cout<<"-1"; exit(0); }

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll i,j,n,tt;
    tt=1;
    //cin>>tt;
    while(tt--)
    {
        string s;
        cin>>s;
        if(s[3]=='7')
            s[3]='8';
        cout<<s<<endl;

    }
    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	vector<int>len(1000, 0);
	vector<int>e(12);
	for (int i = 0; i < 12; i++) {
		cin >> e[i];
		len[e[i]]++;
	}

	bool f = true;
	for (int i = 0; i < 12; i++) {
		if (len[e[i]] != 4 && len[e[i]] != 8 && len[e[i]] != 12)f = false;
	}

	if (f)cout << "yes" << endl;
	else cout << "no" << endl;
	return 0;
}

Measured memory_bytes: 3116