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

unsigned int randxor() {
  static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
  unsigned int t;
  t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}




int main() {
  int D;
  cin >> D;
  vector<int> c(26);
  rep(i,26) cin >> c[i];
  vector<vector<int>> s(D + 1, vector<int>(26, 0));
  vector<vector<int>> last_day(D + 1, vector<int>(26, 0));
  vector<int> t(D);
  rep(i,D) rep(j,26) cin >> s[i + 1][j];


  int score = 0;
  auto Scoring = [&](int d, int id, int oid) {
    score += s[d][id];
  
    if (oid != -1) {
      t[d - 1] = id;
      score -= s[d][oid];
      for (int i = d; i <= D; i++) {
        if (last_day[i][oid] != d) break;
        last_day[i][oid] = last_day[i - 1][oid];
        score += c[oid] * (i - d);
        score -= c[oid] * (i - last_day[i][oid]);
      }

      for (int i = d; i <= D; i++) {
        if (last_day[i][id] == i) break;
        score += c[id] * (i - last_day[i][id]);
        last_day[i][id] = d;
        score -= c[id] * (i - last_day[i][id]);
      }
    } else {
      last_day[d][id] = d;
      for (int i = 0; i < 26; i++) {
        if (i != id) last_day[d][i] = last_day[d - 1][i];
        score -= c[i] * (d - last_day[d][i]); 
      }
    }
  };

  auto xinit = [&](){
    score = 0;
    for (int i = 0; i <= D; i++) {
      for (int j = 0; j < 26; j++) last_day[i][j] = 0;
    }
  };


  auto init = [&](){
    auto tmp = last_day;
    int ret = -INF;
    auto s = t;
    for (int i = 0; i < 26; i++) {
      xinit();
      for (int j = 0; j < D; j++) {
        t[j] = (i + j) % 26;
        Scoring(i + 1, (i + j) % 26, -1);
      }
      if (ret < score) {
        ret = score;
        tmp = last_day;
        s = t;
      }
    }
    t = s;
    last_day = tmp;
    score = ret;
  };
  
  //初期解生成 
  init();
  
  rep(p, 10000000) {

    int d = randxor() % D;
    int change_q = randxor() % 26;    
    int old_q = t[d];
    int old_score = score;
    Scoring(d + 1, change_q, old_q);
    if (score < old_score) {
      Scoring(d + 1, old_q, change_q);
    }
  }
  
  rep(i,D) cout << t[i] + 1 << endl;
  return 0;
} 

Measured memory_bytes: 3776
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U>
inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U>
inline void cmin(T& a, U b) { if (a > b) a = b; }

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cerr << fixed << setprecision(15);
  }
} io_setup;

constexpr char el = '\n';

template<class T, class U>
ostream &operator<<(ostream &os, const pair<T, U>& p) {
  os << p.first << " " << p.second;
  return os;
}
template<class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}
template<class T>
ostream &operator<<(ostream &os, const vector< T > &v) {
  rep(i, v.size())
    os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<class T>
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}
#line 2 "b.cpp"

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

  ll ac = 0;
  ll bc = 0;
  rep(i, n) {
    if (s[i] == 'a') {
      if (ac+bc < a+b) {
        ac++;
        cout << "Yes" << el;
      } else {
        cout << "No" << el;
      }
    } else if (s[i] == 'b') {
      if (ac+bc < a+b and bc < b) {
        bc++;
        cout << "Yes" << el;
      } else {
        cout << "No" << el;
      }
    } else {
      cout << "No" << el;
    }
  }
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

vector<P> G[100100];
int N, M;
vector<int> vs;
int cnt[100100];
bool used[100100];
ll pos[100100];

void addEdge(int u, int v, int c){
    G[u].emplace_back(v, c);
}

void dfs(int v){
    used[v] = true;

    for(P& e : G[v]){
        int w;
        tie(w, ignore) = e;

        if(!used[w]){dfs(w);}
    }

    vs.emplace_back(v);
}

void dfs2(int v){
    used[v] = true;

    for(P& e : G[v]){
        int w, c;
        tie(w, c) = e;

        if(!used[w]){
            pos[w] = pos[v] + c;
            dfs2(w);
        }
    }
}

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

    std::cin >> N >> M;

    for(int i=0;i<M;++i){
        int L, R, D;
        std::cin >> L >> R >> D;

        addEdge(L, R, D);
        ++cnt[R];
    }

    for(int i=1;i<=N;++i){
        if(!used[i]){dfs(i);}
    }    

    memset(used, 0, sizeof(used));
    
    for(int i=N-1;i>=0;--i){
        if(cnt[vs[i]] == 0){
            pos[vs[i]] = 0;
        }

        if(!used[vs[i]]){dfs2(vs[i]);}
    }

    for(int i=1;i<=N;++i){
        for(P& e : G[i]){
            int j, c;
            tie(j, c) = e;

            if(pos[j] - pos[i] != c){
                std::cout << "No" << std::endl;
                return 0;
            }
        }

        if(pos[i] > 1000000000ll){
            std::cout << "No" << std::endl;
            return 0;            
        }
    }

    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 12024
# ??¶?´?: x + y^2 + z^3 = e
# ????????¨??§???????°???¨?????? x + y + z ????±??????????

import math

# 1. z ????±???????
# 2. y ??? ???y**2 < (e - z**3)???????????????y????????§???
# 3. x ??? e - y**2 - z**3
# ?????????e????????????????????????101???
while True:
    e = int(input())
    if e == 0:
        break

    min_e = e
    for i in range(101):
        if (e - i**3) < 0:
            break;
        z = i
        y = math.floor(math.sqrt(e - i**3))
        x = e - y**2 - z**3
        if ( (x + y + z) < min_e ):
            min_e = x + y + z

    print(min_e)

Measured memory_bytes: 7476
s = gets.chomp.chars
ans = 0
['', '+'].repeated_permutation(s.size - 1) do |b|
  expr = ''
  (s.size - 1).times do |i|
    expr += s[i]
    expr += b[i]
  end
  expr += s[-1]
  ans += eval expr
end
puts ans

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> A(9);
    int j = 1;
    rep(i, 9)
    {
        A[i] = j * 100 + j * 10 + j;
        j++;
    }
    rep(i, 9)
    {
        if (A[i] >= N)
        {
            cout << A[i] << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void) {
	int i, ans = 0;
	char a[1000];
	while (1) {
		scanf("%s", a);
		if (a[0] == '0') break;
		for (i = 0; i < strlen(a); i++) {
			ans += a[i] - '0';
		}
		printf("%d\n", ans);
		ans = 0;
	}

	return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <cmath>
#include <climits>
#include <cstdint>
#include <numeric>
using namespace std;

inline namespace atcoder {
    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;
}

int main() {
    int64_t a, b, c, d;
    cin >> a >> b >> c >> d;
    int64_t e = lcm(c, d);

    auto nc = b / c - (a - 1) / c;
    auto nd = b / d - (a - 1) / d;
    auto ne = b / e - (a - 1) / e;

    cout << ((b - a + 1) - (nc + nd - ne)) << endl;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
int main()
{
    double sadasda = 1.55555;
    long K, N;
    cin >>N >> K;
    vector<long> p(N);
    rep(i, N) cin >> p.at(i);
    ll left = 0, right = 0;
    ll mx = 0;
    rep(i, K)
    {
        right += p.at(i)+1;
    }
    for (int i = K; i < N;i++){
        ll num = right - left;
        mx = max(num, mx);
        left += p.at(i - K) +1;
        right += p.at(i) + 1;
    }
    ll num = right - left;
    mx = max(num, mx);
    double ans = (double)(mx);
    ans /= 2;
    printf("%.10f\n", ans);
}

Measured memory_bytes: 1792
using System;
 
class Program
{
	static void Main()
    {
        var i = int.Parse(Console.ReadLine());
		long ans = 0;
		
        for(int x=1; x<=i; ++x){
            if(x%3!=0 && x%5!=0){
                ans = ans + x;
            }
        }
        Console.WriteLine(ans);
    }
}

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

using namespace std;

#define ll long long 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SIZE 100005

int main()
{
    int a;
    
    cin >> a;
    for(int i = 1; i <= 9; i++)
    {
		if(a%i==0 && a/i>=1 && a/i <= 9) {cout <<"Yes\n";return 0;}
	}
	cout << "No" << endl;
	return 0;
}


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

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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 int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

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

int main()
{

    int n, m;
    cin >> n >> m;
    priority_queue<ll> que;
    rep(i, n)
    {
        ll a;
        cin >> a;
        que.push(a);
    }

    rep(i, m)
    {
        ll temp = que.top();
        que.pop();
        que.push(temp / 2);
    }

    ll res = 0;

    while (!que.empty())
    {
        res += que.top();
        que.pop();
    }

    cout << res << endl;
}


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

int n,m,k,s[11][1002],ans=2000,h;
vector<int>v;

inline int sum(int x,int y,int a,int b){
	return s[a][b]-s[a][y]-s[x][b]+s[x][y];
}

inline void ck(){
	int i,j,g[h+1],p[h+1],l=0;
	//for(i=0;i<v.size();++i)cout<<v[i]<<' ';
	//cout<<endl;
	memset(g,0,sizeof(g));
	for(i=1;i<=m;++i){
		bool f=1;
		for(j=0;j<=h;++j){
			p[j]=sum(v[j],i-1,v[j+1],i);
			if(p[j]>k)return;
			if(p[j]+g[j]>k){
				f=0;
			}
		}
		if(f)for(j=0;j<=h;++j)g[j]+=p[j];
		else{
			for(j=0;j<=h;++j){
				g[j]=p[j];
			}
			//cout<<endl;
			++l;
		}
	}
	//cout<<h<<' '<<l<<endl;
	ans=min(ans,h+l);
}

inline void ch(){
	v.push_back(n);
	ck();
	v.pop_back();
} 

bool nt(int p){
	if(p==0)return 0;
	++v[p];
	if(v[p]+h-p>=n){
		if(!nt(p-1))return 0;
		v[p]=v[p-1]+1;
	}
	return 1;
}

int main(){
	cin>>n;
	cin>>m>>k;
	
	register int i,j;
	register char t;
	
	for(i=1;i<=n;++i){
		for(j=1;j<=m;++j){
			cin>>t;
			s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+(t-'0');
		}
	}
	
	
	for(h=0;h<n;++h){
		//cout<<h<<endl;
		v.clear();
		v.push_back(0);
		for(i=1;i<=h;++i)v.push_back(i);
		do{
			ch();
		}while(nt(h));
	}
	
	cout<<ans;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[][] m = new char[2][3];
    
    for(int i = 0 ; i < 2; i++){
      String tmp = sc.next();
      char[] S = tmp.toCharArray();
      for(int j = 0; j < 3; j++){
        m[i][j] = S[j];
      }
    }
    
    if(m[0][0] == m[1][2] && m[0][1] == m[1][1] && m[0][2] == m[1][0]){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
   
  }
}

Measured memory_bytes: 35588
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int A;
  int B;
  
  cin >> A >> B;
  
  if ( (A+B)%2 == 0 ) {
    cout << (A+B)/2;
  }
  
  else {
    cout << "IMPOSSIBLE";
  }
  
    
}


Measured memory_bytes: 256
import java.util.*;

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

        if((a + b) >= 10){
            System.out.println("error");
        } else {
            System.out.println(a + b);
        }
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


Measured memory_bytes: 23764
n = gets.to_i

a = gets.split.map(&:to_i)

sum = a.inject(:+)
snuke = 0
ans = Float::INFINITY

0.upto(n-2) do |i|
  snuke += a[i]
  sum -= a[i]
  ans = [ans, (snuke-sum).abs].min
end

puts ans

Measured memory_bytes: 19204
#include <stdio.h>

#define N 100

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int res = 0;
    int d[ N ];
    int * b
      , * e;
    int n, r;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    for ( i = 0; i < n; ++i )
    {
      scanf ( "%d", d + i );
    }
    scanf ( "%d", &r );
    b = d; e = d + n;

    while ( e - b > 0 )
    {
      int * m = b + ( e - b - 1 ) / 2;

      ++res;
      if ( *m == r )  break ;
      if ( *m <  r )  b = m + 1;
      if ( *m >  r )  e = m;
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 2147483647;
const ll LINF = 1e18;
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 T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int h, w;
    cin >> h >> w;
    auto v = make_vec<int>(h, w);
    rep(i, h) rep(j, w) cin >> v[i][j];

    vector<int> y(h * w), x(h * w);
    rep(i, h * w) y[i] = i / w;
    rep(i, h * w) {
        if (y[i] % 2 == 0)
            x[i] = i % w;
        else
            x[i] = w - 1 - i % w;
    }

    vector<tuple<int, int, int, int>> ans;
    rep(i, h * w - 1) {
        if (v[y[i]][x[i]] % 2 == 1) {
            ans.emplace_back(y[i], x[i], y[i + 1], x[i + 1]);
            v[y[i + 1]][x[i + 1]]++;
        }
    }
    cout << sz(ans) << endl;
    for (auto t : ans) {
        int a, b, c, d;
        tie(a, b, c, d) = t;
        cout << a + 1 << " " << b + 1 << " " << c + 1 << " " << d + 1 << endl;
    }
}

Measured memory_bytes: 7152
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <vector>
#include <stdio.h>
#include <iostream>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <cassert>
// #include <multiset>

#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl
using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
	for (T x : s)
		cout << x << " ";
	cout << endl;
}

ll gcd(ll a, ll b){
	return b > 0 ? gcd(b, a % b) : a;
}

const int maxn = 1e5 + 7;



int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);	
	string s;
	cin >> s;
	for (int i = 1; i < s.size(); i++){
		if (s[i] == s[i - 1]){
			cout << "Bad\n";
			return 0;
		}
	}	
	cout << "Good\n";
	return 0;	
}	

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char s1[10],s2[10],s3[10];
	scanf("%s%s%s",s1,s2,s3);
	char c1=s1[0]-32,c2=s2[0]-32,c3=s3[0]-32;
	printf("%c%c%c\n",c1,c2,c3);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;
// 深さ優先探索
vector<bool> seen;  // 探索したか記録
int t=0;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    t++;
    for (auto e : G[v]) {
        if (!seen[e.to]) {  // 訪問済みでなければ探索
            dfs(G, e.to);
        }
    }
}
int main() {
    int n, m,ans=0;
    cin >> n >> m;
    Graph G(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back({b});
        G[b].push_back({a});
    }
    seen.assign(n, false);  // 初期化
    for (int i = 0; i < n; i++) {
        if (!seen[i]) {
            dfs(G, i);
            if(ans<t){
                ans=t;
            }
            t=0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 23488
/*input
5
3 1 2 3 1
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma GCC optimize "-O3"
//order_of_key #of elements less than x
// find_by_order kth element 
#define ll long long 
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb emplace_back
#define REP(i,n) for(int i=0;i<n;i++)
#define sz(_a) (int)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const int maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-9;
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int arr[maxn];
int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	REP(i,n) cin>>arr[i];
	int stps=0;
	while(true){
		bool wk=true;
		REP(i,n) if(arr[i]>0) wk=false;
		if(wk) break;
		REP(i,n){
			if(arr[i]>0){
				while(arr[i]>0 and i<n){
					arr[i]--;
					++i;
					
				}
				i=n;
			}
		}
		stps++;
	}
	cout<<stps;
}

Measured memory_bytes: 256
def resolve():
    x, y = map(int, input().split())

    ans = 'No'
    for kame in range(x + 1):
        tsuru = x - kame
        if kame * 4 + tsuru * 2 == y:
            ans = 'Yes'
            break
    print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9012
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        System.out.println(Min(a) + " " + Max(a) + " " + Sum(a));
        sc.close();
    }
    public static long Min(long[] a) {
        long min = a[0];
        for (int i = 1; i < a.length; i++) {
            if (min > a[i]) {
                min = a[i];
            }
        }
        return min;
    }
    public static long Max(long[] a) {
        long max = a[0];
        for (int i = 1; i < a.length; i++) {
            if(max < a[i]) {
                max = a[i];
            }
        }
        return max;
    }
    public static long Sum(long[] a) {
        long sum = 0;
        for (int i = 0; i < a.length; i++) {
            sum += a[i];
        }
        return sum;
    }
}


Measured memory_bytes: 42372
X,N = map(int,input().split())
if(N != 0):
 P = list(map(int,input().split()))
 ans_l = []
 ans = float('inf')
 for j in range(102):
   if(j in P):
      continue
   else:
      if(abs(ans-X)>abs(j-X)):
        ans = j
else:
  ans = X     
  
print(ans)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,m;
ll t[N<<2],lz[N<<2];
vector<pair<int,int> >v[N];
void build(int l,int r,int k)
{
    t[k]=lz[k]=1e18;
    if(l==r&&l==1) t[k]=0;
    if(l==r) return;
    int m=l+r>>1;
    build(l,m,k<<1);build(m+1,r,k<<1|1);
}
void update(int k)
{
    t[k<<1]=min(t[k<<1],lz[k]);
    t[k<<1|1]=min(t[k<<1|1],lz[k]);
    lz[k<<1]=min(lz[k<<1],lz[k]);
    lz[k<<1|1]=min(lz[k<<1|1],lz[k]);
    lz[k]=1e18;
}
ll query(int l,int r,int k,int x)
{
    if(l!=r) update(k);
    if(l==r) return t[k];
    int m=l+r>>1;
    if(x<=m) return query(l,m,k<<1,x);
    else return query(m+1,r,k<<1|1,x);
}
void fix(int l,int r,int k,int x,int y,ll v)
{
    if(r<x||l>y) return;
    if(l!=r) update(k);
    if(l>=x&&r<=y)
    {
        t[k]=min(t[k],v);lz[k]=min(lz[k],v);if(l!=r) update(k);return;
    }
    int m=l+r>>1;
    fix(l,m,k<<1,x,y,v);fix(m+1,r,k<<1|1,x,y,v);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int l,r,c;
        scanf("%d%d%d",&l,&r,&c);
        v[l].push_back({r,c});
    }
    build(1,n,1);
    for(int i=1;i<=n;i++)
    {
        ll mn=query(1,n,1,i);
        for(int j=0;j<v[i].size();j++)
            fix(1,n,1,i,v[i][j].first,mn+v[i][j].second);
    }
    ll ans=query(1,n,1,n);
    if(ans==1e18) ans=-1;
    printf("%lld\n",ans);
}


Measured memory_bytes: 11520
K, N = map(int, input().split())
A = [int(a) for a in input().split()]
A.append(A[0] + K)
b = []
max = 0
sum = 0
for i in range(N):
    t = A[i+1] - A[i]
    sum += t
    if max < t:
        max = t
sum -= max
print(sum)

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

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (auto &v : vec)
    is >> v;
  return is;
}
#define all(x) (x).begin(), (x).end()
#define rep(i, N) for (int i = 0; i < (int)(N); i++)

void solve()
{
  int N;
  vector<int> D(3);
  cin >> N >> D;
  vector<string> s(N);
  cin >> s;

  vector<char> ans;
  rep(i, N)
  {
    int first = s[i][0] - 'A';
    int second = s[i][1] - 'A';
    if (D[first] == 0 and D[second] == 0)
    {
      cout << "No" << endl;
      return;
    }

    int greater;
    int less;

    int rest = 0 + 1 + 2 - first - second;
    if (D[first] == 1 and D[second] == 1 and i + 1 < N and count(all(s[i + 1]), 'A' + rest) == 1)
    {
      if (count(all(s[i + 1]), 'A' + first) == 1)
      {
        greater = second;
        less = first;
      }
      else
      {
        greater = first;
        less = second;
      }
    }
    else if (D[first] >= D[second])
    {
      greater = first;
      less = second;
    }
    else
    {
      greater = second;
      less = first;
    }

    D[greater]--;
    D[less]++;
    ans.push_back('A' + less);
  }
  cout << "Yes" << endl;
  rep(i, N) cout << ans[i] << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 6752
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  ll n, m;
  cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  if(min(n, m) == 1) {
    if(max(n, m) == 1)
      ans = 1;
    else
      ans = max(n, m) - 2;
  }
  else {
    ans = n * m - (n * 2 + m * 2 - 4);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b;
  cin>>a>>b;
  vector<int>L(b);
  vector<int>R(b);
  for(int i=0;i<b;i++){
    cin>>L.at(i)>>R.at(i);
  }
  sort(L.begin(),L.end());
  sort(R.begin(),R.end());
  int ans;
  ans=R.at(0)-L.at(b-1)+1;
  ans=max(ans,0);
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
using System;

namespace Print
{
    class Program
    {
        static void Main(string[] args)
        {
            for(int i = 1;;i++)
            {
                string s = Console.ReadLine();
                if(s == "0") break;
                Console.WriteLine("Case {0}: {1}", i, s);
            }
        }
    }
}

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

int main(){
	string s;
	bool flag = true;
	cin >> s;
	for(int i=0; i<s.length(); i++){
		if(i%2==0 && s[i]=='L'){
			flag = false;
		}else if(i%2==1 && s[i]=='R'){
			flag = false;
		}
	}
	if(flag){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n,now=1,a[10000];
    bool prime[1000000];
    a[0]=2;
    for(int i=3;i<1000000;i+=2){
        prime[i]=true;
    }
    for(int i=3;now<10000;i+=2){
        if(prime[i]){
            a[now]=i+a[now-1];
            now++;
            if((long long)i*i<1000000){
            for(int j=i*i;j<1000000;j+=i){
                prime[j]=false;
            }
            }
        }
    }
    while(1){
        scanf("%d",&n);
        if(n==0)return 0;
        printf("%d\n",a[n-1]);
    }
}

Measured memory_bytes: 3736
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(string, X);
    vi Y(N);
    ll m = 0;
    REP(i, N)
    {
        Y[i] = X[i] - '0';
        m += Y[i];
    }
    if (m == 1)
    {
        REP(i, N)
        {
            ll ans;
            if (Y[i] == 0)
            {
                if (i == N - 1 or Y[N - 1] == 1)
                {
                    ans = 2;
                }
                else
                {
                    ans = 1;
                }
            }
            else
            {
                ans = 0;
            }
            OUT(ans);
        }
        return 0;
    }
    vi M = {m + 1, m - 1};
    vvi pow2(2, vi(N, 1));
    REP1(i, N - 1)
    {
        REP(k, 2)
        {
            pow2[k][i] = (2 * pow2[k][i - 1]) % M[k];
        }
    }
    vi s(2);
    for (ll i = N - 1; i >= 0; --i)
    {
        REP(k, 2)
        {
            s[k] = (s[k] + Y[i] * pow2[k][N - 1 - i]) % M[k];
        }
    }
    vi dp(N + 1);
    REP1(i, N)
    {
        dp[i] = 1 + dp[i % __builtin_popcount(i)];
    }
    vi sign = {1, -1};
    REP(i, N)
    {
        ll ans = dp[((s[Y[i]] + sign[Y[i]] * pow2[Y[i]][N - 1 - i]) % M[Y[i]] + M[Y[i]]) % M[Y[i]]] + 1;
        OUT(ans);
    }
}

Measured memory_bytes: 9648
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<unsigned char, unsigned char> pcc;
typedef pair<double, double> pdd;
typedef vector<vector<ll>> matrix;

ll l[7];
void solve() {
  for(int i = 0; i < 7; i++) cin >> l[i];
  ll ret = l[1];
  ll a = 2*(l[3]/2) + 2*(l[4]/2) + 2*(l[0] / 2);
  ll b = 0;
  if(l[0] > 0 && l[3] > 0 && l[4] > 0) {
    b = 3 + 2*((l[0] - 1)/2) + 2*((l[3] - 1)/2) + 2*((l[4] - 1)/2);
  }
  cout << ret + max(a, b) << "\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ":" << "\n";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string S;
  cin >> S;
  rep(i, S.size()){
    if(S[i]=='?'){
      S[i]='D';
    }
  }
  cout << S;
  return 0;
}



Measured memory_bytes: 3756
#include <iostream>
#include <queue>
#include <map>
#include <deque>
#include <algorithm>
#include <set>
#include <string>
#include <math.h>
#include <stdio.h>
#include<iomanip>



#define ll long long
using namespace std;


ll factorial(ll n)
{
    if (n == 1 || n == 0)
        return 1;

    return n * factorial(n - 1);
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string x,y;
    cin >> x >> y;
    ll dp[x.size() + 1][y.size() + 1];
    for (ll i = 0; i <= x.size(); i++)
    {
        for (ll j = 0; j <= y.size(); j++)
        {
            if (i == 0 || j == 0)
            {
                dp[i][j] = 0;
            }
            else
            {
                if (x[i - 1] == y[j - 1])
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                else
                    dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);

            }
        }
    }
    ll acc = dp[x.size()][y.size()];
    ll i = x.size();
    ll j = y.size();
    string k = "";
    while (acc != 0)
    {
        if (i - 1 >= 0 && j - 0 >= 0 && dp[i - 1][j - 1] + 1 == dp[i][j] && x[i - 1] == y[j - 1])
        {
            k = x[i - 1] + k;
            i--;
            j--;
            acc--;
        }
        else
        {
            if (i - 1 >= 0 && dp[i - 1][j] == dp[i][j])
            {
                i--;
            }
            else
                j--;
        }
    }
    cout << k;
    return 0;
}


Measured memory_bytes: 70656
#include <stdio.h>
#include <string.h>
int main (){
	int k;
	int i;
    char s[101];
    	scanf("%d",&k);
    		scanf("%s",&s);
    int len = strlen(s);
    if (len<=k){	
	printf("%s",s);
	}
    
    else {
    	for (int i=0 ; i<k ;i++){
    		printf("%c",s[i]);
		}
		printf("...\n");
}

	
	return 0;
}

Measured memory_bytes: 1720
#!python3.8
# -*- coding: utf-8 -*-
# abc172/abc172_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    a = i2n()
    print(a + a**2 + a**3)
    return

main()


Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int a[200010],n,k;
long long ans; 
int main() {
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n-k;i++)
	ans+=a[i];
	printf("%lld",ans);
}

Measured memory_bytes: 1024
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=list(map(int,list(input())))
n=len(s)
# print(s)
if s[-1]==1 or s[0]==0:
    print(-1)
    quit()

for i in range(n-1):
    if s[i]!=s[-2-i]:
        print(-1)
        quit()
s[-1]=1
now=n
for i in range(n-1)[::-1]:
    print(i+1,now)
    if s[i]==1:
        now=i+1


Measured memory_bytes: 85528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, 2, n + 1) {
        int now = i;
        for (int j = 2; j * j <= now; j++) {
            while (now % j == 0) {
                now /= j;
                mp[j]++;
            }
        }
        mp[now]++;
    }
    int ans = 1;
    const int mod = 1e9 + 7;
    for (auto p : mp) {
        if (p.first == 1) continue;
        ans = ans * (p.second + 1) % mod;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3640
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;
 
#define REP(i,n) for(long long (i)=0;(i)<(long long)(n);(i)++)
#define RREP(i,n) for(long long (i)=(long long)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

    int N; cin >> N;
    vector< int > A(N);
    REP(i,N) cin >> A[i];

    ll ans = 1;
    ll minus = 1;
    REP(i,N) {
    	if (A[i] % 2 == 0) {
    		ans *= 3;
    		minus *= 2;
    	} else {
    		ans *= 3;
    	}
    }

    cout << ans - minus << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i=0,j=0,k=0;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		long[] aa = new long[n];
		aa[0] = parseLong(sc.next());
		for(i=1;i<n;i++) {
			aa[i]=aa[i-1]+parseLong(sc.next());
		}
		sc.close();
		long mn = 1000000000L*200000L;
		long tmp = 0L;
		for (i = 0; i < n-1; i++) {
			tmp = abs(aa[n-1] - aa[i]*2);
			if(mn>tmp) mn=tmp;
		}
		out.println(mn);
	}
}


Measured memory_bytes: 60448
from collections import defaultdict
n=int(input())
a=[int(i) for i in input().split()]
INF=float('inf')
dp0=defaultdict(lambda: -INF)
dp1=defaultdict(lambda: -INF)
dp0[(0,0)]=0
for i in range(1,n+1):
  for j in range(i//2-1,(i+1)//2+1):
    dp0[(i,j)]=max(dp0[(i-1,j)],dp1[(i-1,j)])
    dp1[(i,j)]=dp0[(i-1,j-1)]+a[i-1]
print(max(dp0[(n,n//2)],dp1[(n,n//2)]))

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

int main(){
    ll n; cin>>n;
    vector<ll>a(n);
    vector<bool>b(n,false);
    rep(i,n)cin>>a[i];
    ll ans=0;
    ll c=1;
    while(1){
        if(b[c-1]==false){
        b[c-1]=true;
        if(a[c-1]==2)break;
        ans++;
        c=a[c-1];
        }
        else {
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans+1<<endl;
}








Measured memory_bytes: 1024
function main()
	s = collect(readline())
	l = length(s)-1
	flg = 0
	check = 0
	if s[1] != 'A'
		flg = 1
	end
	for i in 2:l
		for j in 65:90
			if s[i] == Char(j)
				if 3 <= i <= l-1 && check == 0 && s[i] == 'C'
					check += 1
				else
					flg = 1
				end
			end
		end
	end
	if check == 0
		flg = 1
	end
	if flg == 0
		print("AC")
	else
		print("WA")
	end
end
main()

Measured memory_bytes: 109724
import heapq

n, m = map(int, input().split())

w_list = []
pq = []

for i in range(n):
    a, b = map(int, input().split())
    w_list.append([a, b])
w_list.sort()

ptr = 0
ret = 0
for i in range(m):
    while True:
        if ptr < n and w_list[ptr][0] <= i + 1:
            heapq.heappush(pq, -w_list[ptr][1])
            ptr += 1
        else:
            break
    if pq:
        ret -= heapq.heappop(pq)

print(ret)


Measured memory_bytes: 23880
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
/*
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}
*/

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int n,k,s;
  cin >> n >> k >> s;
  rep(i,k){
    cout << s << ' ';
  }
  rep(i,n-k){
    if(s != 1000000000){
      cout << 1000000000 << ' ';
    }else{
      cout << 999999999 << ' ';
    }
  }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<unsigned P> struct ModInt {
  using M = ModInt;
  unsigned v;
  constexpr ModInt() : v(0) {}
  constexpr ModInt(auto x) : v(x >= 0 ? x % P : (P - -x % P) % P) {}
  constexpr ModInt(unsigned _v, int) : v(_v) {}
  static constexpr unsigned p() { return P; }
  M operator+() const { return *this; }
  M operator-() const { return {v ? P - v : 0, 0}; }
  explicit operator bool() const noexcept { return v; }
  bool operator!() const noexcept { return !(bool)*this; }
  M operator*(M r) const { return M(*this) *= r; }
  M operator/(M r) const { return M(*this) /= r; }
  M operator+(M r) const { return M(*this) += r; }
  M operator-(M r) const { return M(*this) -= r; }
  bool operator==(M r) const { return v == r.v; }
  bool operator!=(M r) const { return !(*this == r); }
  M& operator*=(M r) { v = (uint64_t)v * r.v % P; return *this; }
  M& operator/=(M r) { return *this *= r.inv(); }
  M& operator+=(M r) { if ((v += r.v) >= P) v -= P; return *this; }
  M& operator-=(M r) { if ((v += P - r.v) >= P) v -= P; return *this; }
  M inv() const {
    int a = v, b = P, x = 1, u = 0;
    while (b) {
      int q = a / b;
      swap(a -= q * b, b);
      swap(x -= q * u, u);
    }
    assert(a == 1);
    return x;
  }
  M pow(auto n) const {
    if (n < 0) return pow(-n).inv();
    M res = 1;
    for (M a = *this; n; a *= a, n >>= 1) if (n & 1) res *= a;
    return res;
  }
  friend M operator*(auto l, M r) { return M(l) *= r; }
  friend M operator/(auto l, M r) { return M(l) /= r; }
  friend M operator+(auto l, M r) { return M(l) += r; }
  friend M operator-(auto l, M r) { return M(l) -= r; }
  friend ostream& operator<<(ostream& os, M r) { return os << r.v; }
  friend istream& operator>>(istream& is, M& r) { lint x; is >> x; r = x; return is; }
  friend bool operator==(auto l, M r) { return M(l) == r; }
  friend bool operator!=(auto l, M r) { return !(l == r); }
};
using Mint = ModInt<998244353>;

template<class Z> V<Z> divisor(Z n) {
  V<Z> res;
  Z i;
  for (i = 1; i * i < n; ++i) if (n % i == 0) res.push_back(i), res.push_back(n / i);
  if (i * i == n) res.push_back(i);
  sort(begin(res), end(res));
  return res;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  string s; cin >> s;
  V<Mint> a(2 * n + 1);
  auto ds = divisor(2 * n);
  for (int d : ds) if (2 * n / d & 1) {
    string t = s.substr(0, d / 2);
    for (char c : t) {
      a[d] *= 2;
      a[d] += c == '1';
    }
    for (int _ = 0; _ < n / d; ++_) {
      for (int i = 0; i < d / 2; ++i) {
        t += '0' ^ '1' ^ t[i];
      }
      t += t.substr(0, d / 2);
    }
    a[d] += t <= s;
    for (int i : ds) if (2 * n / i & 1 and d % i == 0) {
      if (i >= d) break;
      a[d] -= a[i];
    }
  }
  Mint res;
  for (int d : ds) if (2 * n / d & 1) {
    res += d * a[d];
  }
  cout << res << '\n';
}

Measured memory_bytes: 2584
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

count=0
for i in range(n):
  if a[i]>b[i]:
    count+=b[i]
  else:
    b[i]-=a[i]
    count+=a[i]
    if a[i+1]>b[i]:
      count+=b[i]
      a[i+1]-=b[i]
    else:
      count+=a[i+1]
      a[i+1]=0
  
print(count)

Measured memory_bytes: 18624
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
    int n;
    cin >>n;
    string s;
    cin >>s;

    int ct = 0;
    for(int i = 0; i < n; i++){
        if(s.substr(i,3) == "ABC"){
            ct++;
        }
    }

    printf("%d\n", ct);
    return 0;
}

Measured memory_bytes: 256