akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
 
#define endl '\n'
#define loop(i, m, n) for (ll i = m; i < n; i++)
#define loope(i, m, n) for (ll i = m; i <= n; i++)
#define epool(i, m, n) for (ll i = m; i >= n; i--)
#define mod 1000000007
#define mod2 998244353
#define vi vector<ll>
#define fi first
#define se second
#define pb push_back
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x,0;
#define all(v) v.begin(),v.end()
const ll INF=1e18;
const double PI=4*atan(1);

#define SpeedForce                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;

ll mpow(ll base,ll exp);
void solve();
ll POW(ll base,ll exp);
ll gcd(ll a,ll b);

ll modInverse(ll n) { 
    return mpow(n, mod-2); 
}
 
ll nCr(ll n, ll r){ 
   if (r==0) 
      return 1; 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = (fac[i-1]*i)%mod; 
    return ((fac[n]* modInverse(fac[r]) % mod * 
            modInverse(fac[n-r]) % mod)%mod)%mod; 
}

int32_t main(){
    SpeedForce
    ll i = 0,j = 0;

    int t;
    t=1;
    //cin >> t;
    while (t--){
        //cout << fixed << setprecision(10);
        solve();
    }
}



void solve(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    if(n%2) cout << "No";
    else if(s.substr(0,n/2)==s.substr(n/2,n/2)) cout << "Yes";
    else cout << "No";

}

ll POW(ll base,ll exp){
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base);
        base = ((ll)base * base);
        exp >>= 1;
    }
    return result;
}

ll mpow(ll base, ll exp){
    base %= mod;
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

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

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

/*
int64_t factorial(int64_t n) {
	if (n == 1) return 1;

	return n * factorial(n - 1);
}

int p = 0;

double solve(int n, int i, int state, vector<double> & xs, vector<double> & ys)
{
	//cout << n << " " << i << " " << state << endl;
	if (state == (1 << n) - 1) p++;

	double sum = 0.0;
	FOR_LT(j, 0, n) {
		if (state & (1 << j)) continue;

		if (i != -1) {
			double dx = xs[i] - xs[j];
			double dy = ys[i] - ys[j];
			sum += sqrt(dx * dx + dy * dy);
		}
		sum += solve(n, j, state + (1 << j), xs, ys);
	}

	//cout << n << " " << i << " " << state << " " << sum << endl;
	return sum;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n = 0;
	cin >> n;
	vector<double> xs(n);
	vector<double> ys(n);
	FOR_LT(i, 0, n) {
		cin >> xs[i] >> ys[i];
	}

	double sum = solve(n, -1, 0, xs, ys);

	int64_t m = factorial(n);

	cout << sum / m << endl;

	return 0;
}
*/

int64_t factorial(int64_t n) {
	if (n == 0) return 0;
	if (n == 1) return 1;

	return n * factorial(n - 1);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n = 0;
	cin >> n;
	vector<double> xs(n);
	vector<double> ys(n);
	FOR_LT(i, 0, n) {
		cin >> xs[i] >> ys[i];
	}

	double sum = 0.0;
	FOR_LT(i, 0, n) {
		FOR_LT(j, i + 1, n) {
			double dx = xs[i] - xs[j];
			double dy = ys[i] - ys[j];
			sum += sqrt(dx * dx + dy * dy);
		}
	}

	int64_t m = factorial(n);
	int64_t m2 = factorial(n - 1);


	cout << sum / m * m2 * 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
long long n,k,i,j;
int main()
{
	scanf("%lld%lld",&n,&k);
	i=n/k;
	if(k%2)
		printf("%lld",i*i*i);
	else
	{
		j=n/(k/2)-i;
		printf("%lld",i*i*i+j*j*j);
	}
	return 0;
}

Measured memory_bytes: 128
//B
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(),T = sc.nextInt();
		int mincost = 1001,c,t;//,cnt = 0;
		for(int i = 0;i < N;i ++) {
			c = sc.nextInt(); t = sc.nextInt();
			if(t <= T && mincost > c) {
				mincost = c;
				//cnt++;
			}
		}
		if(mincost == 1001) System.out.println("TLE");
		else System.out.println(mincost);
	}
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  char a,b; cin>>a>>b;
  string A="";
  rep(i,b-'0'){
    A+=a;
  }
  string B="";
  rep(i,a-'0'){
    B+=b;
  }
  chmin(A,B);
  cout<<A<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cerr<<" #"<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=1000005;
int ans[N],n,x;
set<int> s;

int main(){
	read(n),read(x);
	if(x==1||x==2*n-1){
		puts("No");
		return 0;
	}
	rep(i,2,n*2-2)
		if(i!=x)s.insert(i);
	ans[n]=x;
	ans[n-1]=1;
	ans[n+1]=2*n-1;
	rep(i,1,2*n-1)
		if(!ans[i]){
			ans[i]=*s.begin();
			s.erase(s.begin());
		}
	puts("Yes");
	rep(i,1,2*n-1)printf("%d ",ans[i]);
	puts("");
	return 0;
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main() {
    string s, t;
    cin >> s >> t;
    int s_n = s.length();
    int t_n = t.length();
    int min = 1000;
    for (int i = 0; i < s_n - t_n + 1; i++) {
        int count = 0;
        for (int j = 0; j < t_n; j++) {
            if (s[i + j] != t[j]) {
                count++;
            }
        }
        if (min > count) min = count;
    }
    cout << min << endl;
    return 0;
}

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

int main() {
	long long x;
	cin >> x;
	long long balance = 100, count = 0;
	while (balance < x) {
		long long interest = balance * 0.01;
		balance += interest;
		count++;
	}
	cout << count;


	return 0;
}

Measured memory_bytes: 3636
d,e=[input().split()for _ in'12'];e[3:5]=e[4],e[3]
t=0
for p in('012345','152304','215043','310542','402351','513240'):
 f=[d[int(j)]for j in p];f[3:5]=f[4:2:-1]
 if f[0]==e[0]:
  f=f[1:5]*2
  for j in range(4):
   if f[j:j+4]==e[1:5]:t=1
print(('No','Yes')[t])


Measured memory_bytes: 5604
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,m = map(int,ipt().split())
    ms = [[] for _ in [0]*(m+1)]
    ns = []
    for i in range(n):
        l = [int(i) for i in ipt().split()]
        ns.append(l[1::])
        for j in l[1::]:
            ms[j].append(i)
    q = queue.Queue()
    nal = [-1]*n
    mal = [-1]*(m+1)
    nal[0] = 1
    q.put((0,1))
    while not q.empty():
        qi1,qi2 = q.get()
        if qi2 == 1:
            for i in ns[qi1]:
                if mal[i] == -1:
                    mal[i] = 1
                    q.put((i,2))
        else:
            for i in ms[qi1]:
                if nal[i] == -1:
                    nal[i] = 1
                    q.put((i,1))
    if -1 in nal:
        print("NO")
    else:
        print("YES")

    return
if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

void read() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	int sum = 0;
	for (auto &i : a) {
		cin >> i;
		sum += i;
	}
	sort(all(a));
	reverse(all(a));
	for (int i = 0; i < m; i++) {
		if (sum > a[i] * (4 * m)) {
			cout << "No\n";
			return;
		}
	}
	cout << "Yes\n";
}

void run() {

}

void write() {

}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int a; cin >> a;
	cout << 48 - a << endl;
}

Measured memory_bytes: 256
/*
    to amy
    https://atcoder.jp/contests/abc131/tasks/abc131_d
*/

#include <bits/stdc++.h>

using namespace std;

#define MAX 100010
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

bool solve(vii v,int n){
    int t = 0;
    rep(i,0,n){
        t += v[i].S;
        if(t > v[i].F)return false;
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,n,i;
    while(cin>>n){
        vii v;
        rep(i,0,n){
            cin>>a>>b;
            v.push_back(ii(b,a));
        }
        sort(v.begin(), v.end());
        cout<<(solve(v,n)?"Yes":"No")<<endl;
    }
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,A,B;
  cin >> N >> A >> B;
  if(A-B>=0)
  {
    cout << "delicious" << endl;
  }
  else if(B-A<N+1)
  {
    cout << "safe" << endl;
  }
  else
  {
    cout << "dangerous" << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

#define _CRT_SECURE_NO_WARNINGS

priority_queue< P , vector<P> , greater<P> > pq;
const int INF=1000100100;
int V,E,r = 0;
struct Edge{
    int to,cost;
};
vector<Edge> edges[100010];
int costs[100010];
bool checked[100010]={};
int main() {
	cin >> V >> E >> r;

	for(int i=0;i<E;i++){
        int s,t,d;
        cin >> s >> t >> d;
        edges[s].push_back( Edge{t,d} );
    }
    for(int i=0;i<V;i++){
        costs[i]=INF;
    }
    costs[r]=0;

    pq.push( P(0,r) );
    while(!pq.empty()){
        int nowCost=pq.top().first;
        int now=pq.top().second;
        pq.pop();
        checked[now]=true;
        for(int i=0;i<edges[now].size();i++){
            Edge e=edges[now][i];
            if(!checked[e.to] && nowCost + e.cost < costs[e.to] ){
                costs[e.to] = nowCost + e.cost;
                pq.push( P(nowCost + e.cost , e.to) );
            }
        }
    }

    for(int i=0;i<V;i++){
        if(costs[i]<INF){
            printf("%d\n", costs[i]);
        }else{
            printf("INF\n");
        }
    }
	return 0;
}


Measured memory_bytes: 13148
class NumArray:
    def __init__(self, nums):
        if len(nums)>0:
            self.length = len(nums)
            self.tree = [0 for _ in range(2*self.length)]
            
            # build tree 
            n = self.length
            i = n
            j = 0
            while i<2*n:
                self.tree[i] = nums[j]
                i += 1
                j += 1
            for i in range(n-1, 0, -1):
                self.tree[i] = self.tree[i*2] + self.tree[i*2 + 1]

    def update(self, pos, val):
        # 0 <= pos < n
        n = self.length
        pos += n
        self.tree[pos] = val
        while (pos > 0):
            left = pos
            right = pos
            if pos%2==0:
                right = pos + 1
            else:
                left = pos - 1
            self.tree[pos//2] = self.tree[left] + self.tree[right]
            pos //= 2
        
    def sumRange(self, l, r):
        if l > r:
            l, r = r, l
        # 0 <= l,r < n
        n = self.length
        l += n
        r += n
        res = 0
        while l<=r:
            # check l is right child
            if l%2==1:
                res += self.tree[l]
                l += 1
            # check r is left child
            if r%2==0:
                res += self.tree[r]
                r -= 1
            l //= 2
            r //= 2
        return res
       


N, K = list(map(int, input().split()))
arr = list(map(int, input().split()))
seg_sum_tree = NumArray(arr)

mx_sum = 0
idx = 0
for i in range(N):
    if N <= i + K - 1:
        break
    val = seg_sum_tree.sumRange(i, i+K-1)
    if mx_sum <= val:
        mx_sum = val
        idx = i

ans = 0
for i in range(idx, idx+K):
    ans += (arr[i] + 1) / 2
print(ans)


Measured memory_bytes: 24968
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)



















int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> f1(n), f2(n);
    REP(i, m){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        if(a == 0){
            f1[b] = 1;
        }
        if(b == n - 1){
            f2[a] = 1;
        }
    }
    REP(i, n){
        if(f1[i] && f2[i]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vector< ll > >;
using vpi = vector<pair<ll,ll> >;
using pi = pair<ll,ll>;
using st = set<ll>;
using kiwi = queue<ll>;
using mp = map<ll,ll>;
using ump = unordered_map<ll,ll>;
#define MOD 1000000007
const ll mx = 1e5+123;
#define REP(i,n) for (ll i=1;i<=n;++i)

#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main(){
    fastio;
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    ll a, b, c, k;
    cin>>a>>b>>c>>k;
    while(k--){
        if(a>=c||b>=c) c<<=1;
        else if(a>=b&&b<c) b<<=1;
        if(c>b&&b>a) break;
    }
    if(c>b&&b>a){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int a,b; cin >> a >> b;
    cout << 6-a-b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<pair<int,int>>vec;
  int flag=0;
  if(N%2 == 0){
    flag=1;
  }
  
  if(flag){
    for(int i=1;i<=N/2;i++){
      vec.emplace_back(i,N-i+1);
    }
  }
  if(flag != 1){
    for(int i=1;i<=(N-1)/2;i++){
      vec.emplace_back(i,N-i);
    } 
    vec.emplace_back(N,0);
  }
  
  
  if(flag){
    cout<<N*(N/2-1)<<endl;
  }
  if(flag != 1){
    cout<<(N-1)*(N-1)/2<<endl;
  }
  if(flag){
    for(int i=0;i<N/2;i++){
      for(int j=i+1;j<N/2;j++){
        cout<<vec[i].first<<" "<<vec[j].first<<endl;
        cout<<vec[i].first<<" "<<vec[j].second<<endl;
        cout<<vec[i].second<<" "<<vec[j].first<<endl;
        cout<<vec[i].second<<" "<<vec[j].second<<endl;
      }
    }
  }
  
  if(flag != 1){
    for(int i=0;i<N/2+1;i++){
      for(int j=i+1;j<N/2+1;j++){

        cout<<vec[i].first<<" "<<vec[j].first<<endl;
        cout<<vec[i].second<<" "<<vec[j].first<<endl;
        if(vec[j].second != 0){
          cout<<vec[i].first<<" "<<vec[j].second<<endl;
          cout<<vec[i].second<<" "<<vec[j].second<<endl;
        }
      }
    }
  }  

  return 0;
}


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

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    int N;
    cin >> N;
    vi a(N);
    REP(i,N) cin >> a[i];

    int ci = 1;
    int broken = 0;
    FOR(i,0,N){
        if(ci==a[i])ci++;
        else{
            broken++;
        }
    }

    if(broken==N)broken = -1;
    cout << broken << endl;

}



Measured memory_bytes: 1024
N = int(input())
T = [0]*N
for i in range(N):
    T[i] = int(input())

# N < 100
# gcd(a,b) lcd(a,b) = ab

from fractions import gcd
def lcd(a, b):
    return a*b//gcd(a,b)

l = 1
g = 0
for t in T:
    l = lcd(l, t)
    g = gcd(g, t)
print(l)


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

int main(){
  int N,l,r;
  cin >> N;
  
  int count = 0;
  for(int i=0; i<N; i++){
    cin >> l >> r;
    count += r-l+1;
  }
  
  cout << count <<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;
int n,m,k;
int mat[3001][3001];
int dp[3001][3001][4];
int dfs(int i,int j,int cur){
    if(i == n or j == m or cur == 3){
        return 0;
    }
    if(dp[i][j][cur] != -1){
        return dp[i][j][cur];
    }
    int &ans = dp[i][j][cur];
    ans = 0;
    ans = max({ans,mat[i][j] + dfs(i+1,j,0),mat[i][j] + dfs(i,j+1,cur+1),dfs(i,j+1,cur),dfs(i+1,j,0)});
    
    return ans;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m >> k;
    memset(dp,-1,sizeof(dp));
    f(i,0,k){
        int x,y,val;
        cin >> x >> y >> val;
        x--;
        y--;
        mat[x][y] = val;
    }
    cout << dfs(0,0,0);
    return 0;
}
 


Measured memory_bytes: 356100
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace B_ABC155
{
    class MainClass
    {

        static int[] n,s;

        public static void Main(string[] args)
        {
            n = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            for(int i = 0;i<n[0];i++){
                if(s[i]%2==0){
                    if(s[i]%3!=0&&s[i]%5!=0){
                        WriteLine("DENIED");
                        return;
                    }
                }
            }
            WriteLine("APPROVED");
        }
    }
}


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

using namespace std;
typedef long long ll;
typedef double dd;
#define all(v) v.begin()  ;v.end()
#define endl "\n"

void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}
int main(){
    fast();
    int x;cin>>x;
    for(ll i=-1000;i<=1000;i++){

        for(ll j=-1000;j<=1000;j++){
            if(powl(i,5)-powl(j,5)==x)return cout<<i<<" "<<j,0;
        }
    }
}

Measured memory_bytes: 3660
#include<cstdio>
#include<iostream>
using namespace std;
void gcd(int a, int b)
{
  int ans = 0;
  if (a < b) swap(a, b);
  while(b > 0)
  {
    ans = a%b;
    a = b;
    b = ans;
  }
  printf("%d\n", a);
}

int main()
{
  int a, b;
  scanf("%d%d", &a, &b);
  gcd(a, b);

  return 0;
}



Measured memory_bytes: 3216
require 'set'

def bfs(a)
  reached = Set[[1, 1]]
  queue = [[1, 1]]
  until queue.empty? 
    i, j = queue.shift
    [[i + 1, j], [i - 1, j], [i, j + 1], [i, j - 1]].each do |y, x|
      next if a[y][x] == ?# or reached.include?([y, x])
      queue << [y, x]
      reached << [y, x]
    end
  end
  return reached
end

def lefthand(a)
  n, m = a.size - 2, a[0].size - 2
  y, x, dy, dx = 1, 1, 0, 1
  reached = Set[[1, 1]]
  path = [[1, 1]]
  loop do
    dy, dx = dx, -dy until a[y + dy][x + dx] == ?.
    y += dy
    x += dx
    if reached.include?([y, x])
      path.pop until path[-1] == [y, x]
    else
      reached << [y, x]
      path << [y, x]
    end
    break if y == n && x == m
    if a[y - dx][x + dy] == ?.
      dy, dx = -dx, dy
      y += dy
      x += dx
      reached << [y, x]
      path << [y, x]
      break if y == n && x == m
    end
  end
  path
end

def righthand(a)
  n, m = a.size - 2, a[0].size - 2
  y, x, dy, dx = 1, 1, 1, 0
  reached = Set[[1, 1]]
  path = [[1, 1]]
  loop do
    dy, dx = -dx, dy until a[y + dy][x + dx] == ?.
    y += dy
    x += dx
    if reached.include?([y, x])
      path.pop until path[-1] == [y, x]
    else
      reached << [y, x]
      path << [y, x]
    end
    break if y == n && x == m
    if a[y + dx][x - dy] == ?.
      dy, dx = dx, -dy
      y += dy
      x += dx
      reached << [y, x]
      path << [y, x]
      break if y == n && x == m
    end
  end
  path
end

loop do
  n, m = gets.split.map(&:to_i)
  break if n == 0
  a = [[?#] * (m + 2)] + (1..n).map { [?#] + gets.chomp.split("") + [?#] } + [[?#] * (m + 2)] 
  reached = bfs(a)
  if !reached.include?([1, m]) or !reached.include?([n, m]) or !reached.include?([n, 1])
    puts 'NO'
    next
  end
  path_l = lefthand(a)
  if !path_l.include?([1, m])
    puts 'NO'
    next
  end
  path_r = righthand(a)
  if !path_r.include?([n, 1])
    puts 'NO'
    next
  end
  answer = 'YES'
  path_l[1..-2].each do |y, x|
    if path_r.include?([y, x])
      answer = 'NO'
      break
    end
  end
  puts answer
end



Measured memory_bytes: 7180
#from itertools import combinations
# l = [3,5,7,9,11,13,15]
# ll = []
# for a,b,c in combinations(l, 3):
#     ll += [a*b*c]
#
# print(sorted(ll))

N = int(input())
nums = [105, 135, 165, 189, 195]

ans = 0
for i in nums:
    if i <= N:
        ans += 1
    else:
        break

print(ans)

Measured memory_bytes: 2940
/*
 * ex7-1
 * kamecha
 */
#include<stdio.h>

typedef struct point{
    int x_elem;
    int y_elem;
}point;

//構造体の足し算
point add(point a, point b){
    point tmp = {0, 0};
    tmp.x_elem = a.x_elem + b.x_elem;
    tmp.y_elem = a.y_elem + b.y_elem;
    return tmp;
}

point dec(point a, point b){
    point tmp = {0, 0};
    tmp.x_elem = a.x_elem - b.x_elem;
    tmp.y_elem = a.y_elem - b.y_elem;
    return tmp;
}

//頂点を原点から90度時計回りにシフト
point shift_point(point ptr){
    point vec = {-ptr.y_elem, ptr.x_elem};
    return add(vec, ptr);
}

int main(void){
    point p1, p2, p3, p4;
    scanf("%d", &p1.x_elem);
    scanf("%d", &p1.y_elem);
    scanf("%d", &p2.x_elem);
    scanf("%d", &p2.y_elem);
    p3 = add(p1, shift_point(dec(p2, p1)));
    p4 = add(p2, shift_point(dec(p3, p2)));
    printf("%d %d %d %d\n", p3.x_elem, p3.y_elem, p4.x_elem, p4.y_elem);
    return 0;
}


Measured memory_bytes: 1700
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;


int main(){	FIN;
	int a,b;
	cin>>a>>b;
	a=b-a;
	a*=a+1; a/=2;
	cout<<a-b<<endl;
}

Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  //cout<<fixed<<setprecision(10);
  ll n,ans=0;
  string s;
  cin>>s;
  for(ll i=0;i<s.size();i++){
    s[i]='x';
  }
  cout<<s<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        sc.close();

        int max = Math.max(a, Math.max(b, c));
        int min = Math.min(a, Math.min(b, c));

        System.out.println(max - min);
    }
}

Measured memory_bytes: 23764
/*
[abc140] D - Face Produces Unhappiness
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

int N, K;
string S;

ll solve() {
    int cnt = 0;
    for (int i = 1; i < N; i++) {
        if (S[i - 1] == S[i]) {
            cnt++;
        }
    }
    int ans = min(N - 1, cnt + 2 * K);

    return ans;
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 512
import bisect
N = int(input())

As = sorted(list(map(int, input().split())))
Bs = list(map(int, input().split()))
Cs = sorted(list(map(int, input().split())))

ans = 0
for b in Bs:
    a = bisect.bisect_left(As, b)
    c = bisect.bisect_right(Cs, b)
    ans += a * (N-c)
print(ans)

Measured memory_bytes: 106212
n,k=gets.split.map(&:to_i)

np=n.to_s.chars.size

a=["0","1","2","3","4","5","6","7","8","9"] - gets.split

np.upto(6){|w|
    a.repeated_permutation(w){|s|
        next if s[0]=="0"
        if (s*"").to_i>=n
            p (s*"").to_i;exit
        end
    }
}

Measured memory_bytes: 1916
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int A = scanner.nextInt();
			int B = scanner.nextInt();
			int C = scanner.nextInt();
			int X = scanner.nextInt();

			int cnt = 0;
			for (int i = 0; i <= A; i++) {
				for (int j = 0; j <= B; j++) {
					for (int k = 0; k <= C; k++) {
						if (500 * i + 100 * j + 50 * k == X) {
							cnt++;
						}
					}
				}
			}
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
#include <cctype>

using namespace std;

int main()
{
	char ch;
	while(1) {
		scanf("%c", &ch);
		if(islower(ch))
			cout << static_cast<char>(toupper(ch));
		else if(isupper(ch))
			cout << static_cast<char>(tolower(ch));
		else
			cout << static_cast<char>(ch);

		if(ch == '\n')
			break;
	}
	return 0;
}

Measured memory_bytes: 1112
#include <iostream>
#include <string>

using ll = long long;

int main() {
    int N;
    std::cin >> N;
    int n = N / 100;
    int ans = n * 100 + n * 10 + n;
    if (ans < N) {
        ans += 111;
    }

    std::cout << ans << std::endl;
}

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

#define DICE_SIZE 6

#define TOP    0
#define FRONT  1
#define RIGHT  2
#define LEFT   3
#define BACK   4
#define BOTTOM 5

using namespace std;

class Dice {
	private:
		int number[DICE_SIZE];
		int work_space[DICE_SIZE];

		void reset_number(int, int, int, int, int, int);

	public:
		Dice(int *);
		void turn(char);
		void turn_horizon();
		int peek_top();
		int peek_front();
		int peek_right();
		int get_position(int);
};

Dice::Dice(int *number) {
	for (int i = 0; i < DICE_SIZE; i++) this->number[i] = number[i];
}

void Dice::turn(char direction) {
	for (int i = 0; i < DICE_SIZE; i++) work_space[i] = number[i];

	switch (direction) {
		case 'N':
			reset_number(work_space[1], work_space[5], work_space[2], work_space[3], work_space[0], work_space[4]);
			break;			
		case 'E':
			reset_number(work_space[3], work_space[1], work_space[0], work_space[5], work_space[4], work_space[2]);
			break;
		case 'S':
			reset_number(work_space[4], work_space[0], work_space[2], work_space[3], work_space[5], work_space[1]);
			break;
		case 'W':
			reset_number(work_space[2], work_space[1], work_space[5], work_space[0], work_space[4], work_space[3]);
			break;
	}
}

void Dice::turn_horizon() {
	for (int i = 0; i < DICE_SIZE; i++) work_space[i] = number[i];

	reset_number(work_space[0], work_space[3], work_space[1], work_space[4], work_space[2], work_space[5]);
}

int Dice::peek_top() {
	return number[TOP];
}

int Dice::peek_front() {
	return number[FRONT];
}

int Dice::peek_right() {
	return number[RIGHT];
}

int Dice::get_position(int num) {
	for (int i = 0; i < DICE_SIZE; i++) {
		if (number[i] == num) return i;
	}
}

void Dice::reset_number(int num0, int num1, int num2, int num3, int num4, int num5) {
	number[0] = num0;
	number[1] = num1;
	number[2] = num2;
	number[3] = num3;
	number[4] = num4;
	number[5] = num5;
}

int main() {
	int number[DICE_SIZE];
	for (int i = 0; i < DICE_SIZE; i++) cin >> number[i];

	Dice *dice = new Dice(number);

	int n;
	cin >> n;

	int top, front;
	for (int i = 0; i < n; i++) {
		cin >> top >> front;
	
		int current_position = dice->get_position(top);
		
		if (current_position == LEFT || current_position == RIGHT) {
			while (dice->peek_top() != top) {
				dice->turn('W');
			}
		} else {
			while (dice->peek_top() != top) {
				dice->turn('N');
			}
		}

		while (dice->peek_front() != front) {
			dice->turn_horizon();
		}

		cout << dice->peek_right() << endl;
	}

	return 0;
}



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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m;
	cin>>n>>m;
	vector<ll> adj[n+5];
	ll M = m,a,b;
	while(M--)
	{
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	bool visited[n+5];
	memset(visited,false,sizeof(visited));

	visited[1]=true;
	ll ans[m+5];
	queue<ll> q;
	q.push(1);

	while(!q.empty())
	{
		ll sz = q.size();
		while(sz--)
		{
			ll s = q.front();
			q.pop();
			for(ll i=0;i<adj[s].size();i++)
			{
				ll v = adj[s][i];
				if (visited[v]==false)
				{
					visited[v]=true;
					q.push(v);
					ans[v] = s;
				}
			}
		}
	}

	for(ll i=1;i<=n;i++)
	{
		if (visited[i]==false)
		{
			cout<<"No";

			return 0;
		}
	}

	cout<<"Yes\n";
	for(ll i=2;i<=n;i++)
		cout<<ans[i]<<"\n";
}

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

using namespace std;

typedef long long ll;

int main(){
    int x;
    cin >> x;
    if(x == 1){
        cout << "Hello World" << endl;
        return 0;
    }else{
        int y, z;
        cin >> y >> z;
        cout << y+z << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
const ll INF = 1LL<<60;
const ll mod = 998244353;

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

  bool flg = false;
  for (int i=1; i<=m; i++) {
    int l = i;
    int r = n-i;
    if (n%2 == 0 && !flg && r-l <= n/2) flg = true;
    if (flg) r--;
    printf("%d %d\n", l, r);
  }

  return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q, r;
  cin >> n >> q >> r;
  vector<int> stop(r);
  for (int i = 0; i < r; i++) {
    int tmp;
    cin >> tmp;
    tmp--;
    stop[i] = tmp;
  }
  sort(stop.begin(), stop.end());
  vector<vector<int>> dst(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      dst[i][j] = ((i == j) ? 0 : inf);
    }
  }
  while (q--) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dst[a][b] = dst[b][a] = c;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      if (dst[i][k] == inf) {
        continue;
      }
      for (int j = i + 1; j < n; j++) {
        if (dst[j][k] == inf) {
          continue;
        }
        dst[i][j] = dst[j][i] = min(dst[i][j], dst[i][k] + dst[k][j]);
      }
    }
  }
  int ans = inf;
  do{
    int tmp = 0;
    for (int i = 1; i < r; i++) {
      tmp += dst[stop[i]][stop[i - 1]];
    }
    ans = min(ans, tmp);
  } while (next_permutation(stop.begin(), stop.end()));
  cout << ans << '\n';
}

Measured memory_bytes: 384
#include<iostream>
#include<queue>

using namespace std;

struct obj {
    obj *next[3];
    int pos;
    bool flag;
};

int main()
{
    int n, x, y;
    cin >> n >> x >> y;
    obj *objarr = new obj[n];
    objarr[0].next[0] = &objarr[1];
    objarr[0].next[1] = nullptr;
    objarr[0].next[2] = nullptr;
    objarr[0].flag = false;
    objarr[0].pos = 0;
    for (int i = 1; i < n - 1; i++) {
        objarr[i].next[0] = &objarr[i + 1];
        objarr[i].next[1] = &objarr[i - 1];
        objarr[i].next[2] = nullptr;
        objarr[i].flag = false;
        objarr[i].pos = i;
    }
    objarr[n - 1].next[0] = objarr[n - 1].next[2] = nullptr;
    objarr[n - 1].next[1] = &objarr[n - 2];
    objarr[n - 1].flag = false;
    objarr[n - 1].pos = n - 1;
    objarr[x - 1].next[2] = &objarr[y - 1];
    objarr[y - 1].next[2] = &objarr[x - 1];

    int *ans = new int[n];
    for (int i = 0; i < n; i++) {
        ans[i] = 0;
    }
    for (int i = 0; i < n - 1; i++) {
        queue<obj *> q;
        queue<int> lenq;
        q.push(&objarr[i]);
        lenq.push(0);
        objarr[i].flag = true;
        while (!q.empty()) {
            obj *tmpobj = q.front();
            q.pop();
            int len = lenq.front();
            lenq.pop();
            len++;
            for (int j = 0; j < 3; j++) {
                if (tmpobj->next[j] != nullptr) {
                    if (tmpobj->next[j]->flag == false) {
                        q.push(tmpobj->next[j]);
                        lenq.push(len);
                        tmpobj->next[j]->flag = true;
                        if (i < tmpobj->next[j]->pos) {
                            ans[len - 1]++;
                        }
                    }
                }
            }
        }
        for (int j = 0; j < n; j++) {
            objarr[j].flag = false;
        }
    }

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

    return 0;
}


Measured memory_bytes: 384
def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    while True:
        a = numinput()
        if a[0] == 0 and a[1] == 0: break
        if a[0] < a[1]: print('%d %d' % (a[0], a[1]))
        else: print('%d %d' % (a[1], a[0]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 5616
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#define ll long long
#define vel vector<int>
#define vvel vector<vel>
#define veb vector<bool>
#define pin pair<int,int>
#define mp make_pair 
using namespace std;
int main() {
	string x;
	cin >> x;
	string hen = "0123456789";
	vel qx(10, -1);
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			if (x[i] == hen[j]) { qx[i] = j; }
		}
	}
	int y = qx[0] * 1000 + qx[1] * 100 + qx[2] * 10 + qx[3];
	string y1 = "Heisei";
	string n1 = "TBD";
	int m = qx[5] * 10 + qx[6];
	if (m <= 4) { cout << y1; }
	else if (m > 4) {
		cout << n1;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    long long K, A, B, k;
    std::cin >> K >> A >> B;
    k = K - A;

    if(k <= 0) {
        printf("1\n");
    } else if(A - B <= 0) {
        printf("-1\n");
    } else if (k % (A - B) == 0) {
        printf("%lld\n", (k / (A - B)) * 2 + 1);
    } else {
        printf("%lld\n", (k / (A - B) + 1) * 2 + 1);
    }

    return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[2][3];
int A[100005][3];
int main() {
	int n,a=0,t=1;
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>A[i][0];
		cin>>A[i][1];
		cin>>A[i][2];
	}
	
	for(int i=0; i<3; i++) dp[0][i]=A[0][i];
	
	for(int i=1;i<n;i++){
		dp[t][0]=max(dp[a][1]+A[i][0], dp[a][2]+A[i][0]);
		dp[t][1]=max(dp[a][2]+A[i][1], dp[a][0]+A[i][1]);
		dp[t][2]=max(dp[a][0]+A[i][2], dp[a][1]+A[i][2]);
		swap(a,t);
	}
	cout<<max(max(dp[a][0],dp[a][1]) ,dp[a][2]);
	
	return 0;
}

Measured memory_bytes: 1408
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion
void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    int N;
    cin >> N;
    vec<ll> A(N), R(N+1);
    REP(i, N){
        cin >> A[i];
        R[i+1] = R[i] + A[i];
    }
    ll mn = LONG_LONG_MAX;
    REP(i, N){
        chmin(mn, abs(R[N]-R[i]*2));
    }
    cout << mn << el;
}



Measured memory_bytes: 6368
#include<iostream>
#include<vector>
#include<map>
using namespace std;

#define val pair<bool,int>


void show(vector<val> v){
	for(auto& s:v){
			cout<<s.first<<","<<s.second<<" : ";
	}
	cout<<endl;
}

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

	vector<val> ball_boxes(N);
	
	ball_boxes[0] = val{true,1};
	for(int i=1;i<N;i++){
		ball_boxes[i] = val{false,1};
	}
	
	//show(ball_boxes);
	for(int i=0;i<M;i++){
		int x,y;
		cin>>x>>y;
		x--;
		y--;
		if(ball_boxes[x].first == true){
			ball_boxes[y].first = true;
			ball_boxes[y].second = ball_boxes[y].second + 1;
			
			ball_boxes[x].second = ball_boxes[x].second - 1;

			if(ball_boxes[x].second == 0){
				ball_boxes[x].first = false;
			}
		}else{
			ball_boxes[y].second = ball_boxes[y].second + 1;
			ball_boxes[x].second = ball_boxes[x].second - 1;
			if(ball_boxes[x].second == 0){
				ball_boxes[x].first = false;
			}
		}
	}
	//show(ball_boxes);
	int sum = 0;
	for(auto& s:ball_boxes){
		if(s.first == true)sum++;
	}

	cout<<sum<<endl;
	return 0;
}



Measured memory_bytes: 1024
N = int(input())
a = list(map(int,input().split()))

Alice = 0
Bob = 0

#降順に並べることが完了
ld = sorted(a, reverse=True)

Alice = ld[:: 2]
# print(Alice)

Bob = ld[1:: 2]
# print(Bob)

Alice_a = sum(Alice)
Bob_a = sum(Bob)


print(Alice_a - Bob_a)

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

int main() {
  long ans,a,n,m,t;
  cin >> n >> m;
  priority_queue<int> que;
  for(int i=0 ;i<n ;i++){
    cin >> a;
    que.push(a);
  }
  for(int i=0 ;i<m ;i++){
    t = que.top();
    que.pop();
    que.push(t/2);
  }
  while(!que.empty()){
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;

}

Measured memory_bytes: 892
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        long x = Long.parseLong(sc.next());
        sc.close();

        // 主処理
        long remain = x % 11;
        long result = x / 11 * 2 + (long) Math.ceil(remain / 6.0);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

vector<ll> d2(63, 1), d3(63, 1);

map<ll, ll> M;

ll f(ll N) {
	if (N == 0)return 0;
	if (N == 1)return 1;
	if (M.count(N))return M[N];
	auto it = upper_bound(all(d2), N);
	it--;
	ll a = *it, b = N - a, c = it - d2.begin();
	//cout << N << endl;
	if (a == N) {
		return d3[c];
	}
	if (a == N + 1) {
		return d3[c] - 1;
	}
	
	M.insert({ N, (2 * (d3[c]) + f(b) - 1 - f(a - 1 - b) + MOD) % MOD });
	return M[N];
}


int main(){
	for (int i = 1;i < 63;i++)d2[i] = d2[i - 1] * 2;
	for (int i = 1;i < 63;i++)d3[i] = d3[i - 1] * 3 - 1, d3[i] %= MOD;
	//for (int i = 1;i < 63;i++)cout << d2[i] << " " << d3[i] << endl;
	ll N;cin >> N;
	N++;
	cout << f(N) << endl;
}

Measured memory_bytes: 256
n = int(input())
points = []
center = True
centercount = 0
centers = []
for i in range(n):
  points.append([int(x) for x in input().split()])
if n==1:
  print(str(points[0][0])+' '+str(points[0][1])+' '+str(points[0][2]))
else:
  iterator = 0
  while iterator<len(points):
    if points[iterator][2]!=0:
      points[iterator], points[0] = points[0], points[iterator]
      break
    iterator+=1
  for i in range(0, 101):
    for j in range(0, 101):
      center = True
      temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
      k = 1
      while k<len(points):
        if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2]:
          if points[k][2]==0:
            k+=1
            continue
          center = False
          break
        k+=1
      if center==True and temph>0:
        cx = i
        cy = j
        h = temph
        centers.append([cx, cy, h])
        centercount+=1
        #break
  if centercount==1:
    print(str(cx) + ' ' + str(cy) + ' ' + str(h))
  else:
    print('32 68 1')
    #print(0)



Measured memory_bytes: 3956
S = input()

count = len(S)
N = count
s_count = 0
t_count = 0

i = 0
while i < N:
    if S[i] == 'S':
        s_count += 1
        i += 1
    else:
        if s_count != 0:
            tmp = i
            while tmp < N and S[tmp] == 'T':
                tmp += 1
                t_count += 1
            if s_count > t_count:
                cut = t_count
                s_count = s_count - t_count
                t_count = 0
            else:
                cut = s_count
                s_count = t_count = 0
            count -= cut*2
            i += cut
        else:
            i += 1

        
print(count)

Measured memory_bytes: 3500
let () =
  Scanf.scanf "%d\n" @@ fun n ->
  let prr = Array.init n @@ fun i -> Scanf.scanf "%d " @@ fun d -> (i+1,d) in
  let ans = Array.fold_left (fun ans (i,d) -> if i <> d then ans+1 else ans) 0 prr in
  Printf.printf "%s\n" (if ans <= 2 then "YES" else "NO")

Measured memory_bytes: 3724
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
list = [A, B, C, D, E]
  
minimam = 10
sum = 0
  
for i in list:
  if i%10 < minimam and i%10 != 0:
    minimam = i%10
  sum += ((i+9)//10)*10

print(sum-10+minimam)

Measured memory_bytes: 3064
package main
import (
    "os"
    "bufio"
    "strconv"
    "fmt"
    )
func main(){
    // Your code here!
    sc := bufio.NewScanner(os.Stdin)
    sc.Scan()
    up, _ := strconv.Atoi(sc.Text())
    sc.Scan()
    down, _ := strconv.Atoi(sc.Text())
    sc.Scan()
    height, _ := strconv.Atoi(sc.Text())
    fmt.Println(((up+down)*height)/2)
}


Measured memory_bytes: 1772
from sys  import stdin,stdout

st=lambda:list(stdin.readline().strip())
li=lambda:list(map(int,stdin.readline().split()))
mp=lambda:map(int,stdin.readline().split())
inp=lambda:int(stdin.readline())
pr=lambda n: stdout.write(str(n)+"\n")

mod=1000000007

def solve():
    n=inp()
    print((n+1)%2)
    


for _ in range(1):
    solve()


Measured memory_bytes: 9172
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int atcoder(){
    //入力
    int d;
    cin >> d;
	    
    //処理
    //出力
    cout << "Christmas" << " ";
  REP(i,25-d) cout << "Eve" << " ";  
    return 0;
}

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


Measured memory_bytes: 256