akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 1e7 + 5;
int fac[N], ifac[N], inv[N];

int mul(int x, int y) { return x * 1ll * y % mod; }
int add(int x, int y) { return x+y < mod ? x+y : x+y-mod; }
int sub(int x, int y) { return x-y < 0 ? x-y+mod: x-y; }
int norm(int x) { return x < 0 ? add(x, mod) : sub(x, mod); }
template<class T, class... O> int mul(T x, O... y) { return mul(x, mul(y...)); }

int main() {
  int n, a; cin >> n >> a;
  fac[0] = ifac[0] = 1;
  for (int i = 1; i <= n; i++) {
    fac[i] = mul(fac[i-1], i);
    inv[i] = i == 1 ? 1 : mod - mul(mod / i, inv[mod % i]);
    ifac[i] = mul(ifac[i-1], inv[i]);
  }
  int ans = 0;
  for (int i = 1; i <= a+1; i++) // [1 .. i-1]
    for (int j = 0; j+1 < i; j++) // j singletons before
      ans = norm(ans + ((j & 1) ? -1 : 1) * mul(fac[i-1], ifac[j], ifac[i-2-j], fac[n-j-1], i == a+1 ? 1 : inv[n-a+i-1-j]));
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 120716
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#define lowbit(x) ((x)&(-x))
#define sc scanf
#define debug1(x) cout<<x<<" "
#define debug2(x) cout<<x<<"\n"
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
typedef long long ll;
const ll inf=1e18;
const int N=2e5+10;
using namespace std;
ll arr[1010],brr[1010];
int gcd(int a,int  b){return b==0?a:gcd(b,a%b);}
int main()
{
	ll n,t,x=1,y=1;
	cin>>t;
	while(t--)
	{
		ll a,b;
		cin>>a>>b;
		n=max(x/a,y/b);
		while(n*a<x||n*b<y)n++;
		x=a*n,y=b*n;
	}
	cout<<x+y<<"\n";
	return 0;
}

Measured memory_bytes: 256
/**
*    created: 01.07.2020 15:42:49
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const int mod = 1000000007;
// const int MOD = 998244353;
const long double pi = acos(-1.0);
const int inf = 1LL << 60;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a,b) + min(c,d) << endl;
    return 0;
}

Measured memory_bytes: 3572
using System;

namespace AtCoderBiginnerContest179
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine();
			if (input.EndsWith("s"))
			{
				Console.WriteLine(input + "es");
			}
			else
			{
				Console.WriteLine(input + "s");
			}
		}
	}
}


Measured memory_bytes: 26204
#include <bits/stdc++.h>
using namespace std;
int dep[100005],n,u,v,c[100005],sp[30][100005],ans,t,m;
vector<int> d[100005],ch[100005];
queue<int> q;
queue<pair<int,int>> q1;
int main(){
    scanf("%d %d %d",&n,&u,&v);
    for(int i=1;i<n;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        d[a].push_back(b);
        d[b].push_back(a);
    }
    q.push(v);
    c[v]=1;
    while(!q.empty()){
        int x=q.front();
        q.pop();
        for(auto i:d[x])if(!c[i]){
            sp[0][i]=x,dep[i]=dep[x]+1;
            ch[x].push_back(i);
            c[i]=1;
            q.push(i);
        }
    }
    for(int i=1;i<25;i++)for(int j=1;j<=n;j++)sp[i][j]=sp[i-1][sp[i-1][j]];
    t=(dep[u]-1)/2;
    ans+=t;
    if(dep[u]%2==0)ans++;
    for(int i=25;i>=0;i--)if(t>=1<<i){
        u=sp[i][u];
        t-=1<<i;
    }
    q1.emplace(u,0);
    while(!q1.empty()){
        int x=q1.front().first, dist=q1.front().second;
        q1.pop();
        m=max(m,dist);
        for(auto i:ch[x])q1.emplace(i,dist+1);
    }
    ans+=m;
    printf("%d",ans);
}

Measured memory_bytes: 23424
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

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

int main() {

	int N, K;
	cin >> N >> K;

	int ans = 0;
	rep(i, N) {
		int tmp;
		cin >> tmp;
		if (tmp >= K)
			ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 4094, Mod = 1e9 + 7;
int n, tot, F[N + N], I[N + N], dp[N][N], M[N][N];
inline int Power(int a, int b)
{
    int ret = 1;
    for (; b; b >>= 1, a = 1LL * a * a % Mod)
        if (b & 1) ret = 1LL * ret * a % Mod;
    return (ret);
}
int main()
{
    for (int i = F[0] = 1; i < N + N; i ++)
        F[i] = 1LL * F[i - 1] * i % Mod;
    I[N + N - 1] = Power(F[N + N - 1], Mod - 2);
    for (int i = N + N - 2; ~ i; i --)
        I[i] = 1LL * I[i + 1] * (i + 1) % Mod;
    scanf("%d", &n);
    for (int i = 0; i < n; i ++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        tot = (tot + 1LL * F[a + a + b + b] * I[a + a] % Mod * I[b + b]) % Mod;
        dp[2009 - a][2009 - b] ++;
        M[2009 + a][2009 + b] ++;
    }
    tot = Mod - tot; tot %= Mod;
    for (int i = 1; i < N; i ++)
        for (int j = 1; j < N; j ++)
        {
            dp[i][j] += dp[i - 1][j] + dp[i][j - 1];
            if (dp[i][j] >= Mod)
                dp[i][j] -= Mod;
            tot = (tot + 1LL * M[i][j] * dp[i][j]) % Mod;
        }
    tot = tot * 1LL * (Mod + 1) / 2 % Mod;
    return !printf("%d\n", tot);
}

Measured memory_bytes: 100480
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int S,T,U,N,O,D;
	cin>>S>>T>>U>>N>>O>>D;
	vp tr(T);
	rep(i,T)cin>>tr[i].first>>tr[i].second;
	vvi dp1(S+1,vi(U+1));
	rep(i,T)for(int j=S;j>=0;j--)for(int k=U-1;k>=0;k--)if(tr[i].first+j<=S){
		if(k&&dp1[j][k]==0)continue;
		dp1[tr[i].first+j][k+1]=max(dp1[tr[i].first+j][k+1],dp1[j][k]+tr[i].second);
	}
	
	vp dn(N);
	rep(i,N)cin>>dn[i].first>>dn[i].second;
	vi dp2(10010);
	rep(i,N)rep(j,10010)if(dn[i].second+j<10010)
		dp2[dn[i].second+j]=max(dp2[dn[i].second+j],dp2[j]+dn[i].first);
	
	vvi dp(D+1,vi(S+1,-inf));
	dp[0][S]=0;
	rep(i,D)rep(j,S+1){
		int t=min(S,j+O);//hp
		rep(k,t+1){//use k
			int r=dp1[k][U];
			if(r==0)continue;
			r=dp2[r];
			dp[i+1][t-k]=max(dp[i+1][t-k],dp[i][j]+r);
		}
	}
	int out=-1;
	rep(i,S+1)out=max(out,dp[D][i]);
	cout<<out<<endl;
}

Measured memory_bytes: 3260
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());

        List<List<Integer>> graph = new ArrayList<>(N);

        for (int i=0; i<N; i++)
            graph.add(new LinkedList<>());

        for (int i = 0; i < M; i++) {
            st = new StringTokenizer(br.readLine());
            int src = Integer.parseInt(st.nextToken());
            int dest = Integer.parseInt(st.nextToken());
            List<Integer> lst = graph.get(src-1);
            lst.add(dest-1);
            graph.set(src-1, lst);
        }

        Integer[] dp = new Integer[N];
        boolean[] visited = new boolean[N];
        int ans = 0;
        for (int i = 0; i < N; i++) {
            if(!visited[i]){
                ans = Math.max(ans, dfs(i, graph, visited, dp));
            }
        }
        System.out.println(ans);
    }

    public static int dfs(int cur, List<List<Integer>> graph, boolean[] visited, Integer[] dp){
        int ans=0;
        for (int neigh: graph.get(cur)){
            if(visited[neigh]){
                ans = Math.max(dp[neigh], ans);
            }
            else{
                ans = Math.max(ans, dfs(neigh, graph, visited, dp));
            }
        }
        visited[cur] = true;

        if (graph.get(cur).size()==0){
            dp[cur] = ans;
        }
        else
            dp[cur] = ans+1;
        return dp[cur];
    }
}


Measured memory_bytes: 55984
import java.lang.Exception
import java.util.*

fun main() {
    val scanner = Scanner(System.`in`)

    val input = scanner.nextInt()

    val n = when(input.toString().length) {
        1 -> input
        2 -> input % 10
        3 -> input % 100 % 10
        else -> throw Exception("input number is unexpected")
    }

    when(n) {
        2, 4, 5, 7, 9 ->
            println("hon")
        0, 1,6, 8 ->
            println("pon")
        3 ->
            println("bon")
        else ->
            throw Exception("unexpected Exception")
    }
}

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

int main(){
  int n;
  std::cin >> n;
  ll ans=0;
  for (int i = 1; i <=n; i++) {
    if(i%3==0 || i%5==0)continue;
    ans+=i;
  }
  std::cout << ans << '\n';


  return 0;
}


Measured memory_bytes: 3604
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>

using namespace std;

int main()
{
	int x, y, s,ibox=0,jbox=0,s0=0;
	double a1=0, a2=0,box=0,value=0;
	bool judge = false;

	start:

	scanf("%d %d %d", &x,&y,&s);

	s0 = s;

	if (x == 0 && y==0 && s==0) {
		goto finish;
	}

	while (judge == false) {
		for (int i = 1; i < s0; i++) {
			for (int j = s0 - i; j == s0 - i ; j=0 ) {

				a1 = (i  *1.0 * (100 + x) / 100);
				a2 = (j * 1.0 * (100 + x) / 100);

				//cout << a1 << endl << a2 << endl;

				if (((int)a1) + ((int)a2) == s) {
					if (box < ((int)(i*(100+y)/100) + (int)(j*(100+y)/100))) {
						box = ((int)(i*(100 + y) / 100) + (int)(j*(100 + y) / 100));
						ibox = i;
						jbox = j;
					}
					judge = true;
				}

			}
		}
		s0--;
	}

	value = (int)(ibox * (100 + y) / 100) + (int)(jbox * (100 + y) / 100);

	//cout << ibox << endl << jbox << endl;
	
	cout << value << endl;

	a1 = 0;
	a2 = 0;
	s0 = 0;
	ibox = 0;
	jbox = 0;
	box = 0;
	value = 0;
	judge = false;

	goto start;

	finish:

	return 0;
}


Measured memory_bytes: 3284
#include <iostream>
        #include <vector>
        #include <string>
        #include <stack>
        #include <algorithm>
        using namespace std;

        int binarySearch(vector<int> input, int target){
            int start = 0;
            int end = input.size() -1;
            int result = -1;
            while(start<=end){
                int mid = end - (end-start)/2;
                if(input[mid]==target){
                    result = mid;
                    start = mid+1;
                }else if(input[mid]>target){
                    end = mid-1;
                }else{
                    start = mid+1;
                }
            }
            return result;
        }
        int lis(vector<int> v, int n, int maxVal){
            if(n==0)
                return 0;
            if(v[n-1]<maxVal){
                return max( 1+lis(v, n-1, v[n-1]), lis(v, n-1, maxVal) );
            }else
            return lis(v, n-1, maxVal);
        }
        void sw(string &s, int i, int j){
            char temp = s[i];
            s[i] = s[j];
            s[j] = temp;
        }
        void swap(string &s, int i, int j){
            for(int l=j; l>i; l--){
                sw(s, l, l-1);
            }
        }

        int get(int n){
            if(n%2==1)
                return n;
            return get(n/2);
        }

    int main(){
            #ifndef ONLINE_JUDGE
            freopen("input.in", "r", stdin);
            freopen("output.in", "w", stdout);
            #endif
    string s1, s2;
    cin>>s1>>s2;
    int n = s1.size();
    int m = s2.size();
    int dp[n+1][m+1];

    for(int i =0; i<n+1; i++){
        dp[i][0] = 0;
    }

    for(int i =0; i<m+1; i++){
        dp[0][i] = 0;
    }

    for(int i=1; i<n+1; i++){
        for(int j=1; j<m+1; j++){
            if(s1[i-1]==s2[j-1])
                dp[i][j] = 1 + dp[i-1][j-1];
            else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    // for(int i=0; i<n+1; i++){
    //     for(int j=0; j<m+1; j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<"\n";
    // }
    int i = n; int j = m ;
    string temp  = "";
    while(i>0 && j>0){
        if(s1[i-1]==s2[j-1]){
            temp =  s1[i-1] + temp;
            i--; j--;
        }else{
            if(dp[i-1][j]>dp[i][j-1]){

                i--;
            }else{

                j--;
            }
        }
    }
    cout<<temp<<"\n";

        }


Measured memory_bytes: 38732
#include<bits/stdc++.h>
using namespace std;
struct unionFind{
  vector<int>par;
  unionFind(int n):par(n){
    for(int i=0;i<n;i++)par[i]=i;
  }
  int find(int x){
    if(par[x]==x)return x;
    else return par[x]=find(par[x]);
  }
  void unite(int x,int y){
    int rx = find(x);
    int ry = find(y);
    if(rx==ry)return;
    else{
      par[rx]=ry;
      return;
    }
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
};

int main(){
  int n,m,k;
  cin >> n >> m >> k;
  int a[m];
  int b[m];
  vector<int>friendAmount(n,0);
  unionFind unif(n);
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];

    a[i]--;
    b[i]--;
    unif.unite(a[i],b[i]);
    friendAmount[a[i]]++;
    friendAmount[b[i]]++;
  }
  int c[k];
  int d[k];

  for(int i=0;i<k;i++){

    cin >> c[i] >> d[i];
    c[i]--;
    d[i]--;
  }

  map<int,set<int> >uniff;

  for(int i=0;i<n;i++){
    uniff[unif.find(i)].insert(i);
  }

  vector<int>ans(n,0);

  for(int i=0;i<n;i++){
    ans[i] += uniff[unif.find(i)].size() - friendAmount[i] - 1;
  }
  for(int i=0;i<k;i++){
    if(unif.same(c[i],d[i])){
      ans[c[i]]--;
      ans[d[i]]--;
    }
  }

  for(int i=0;i<n;i++)cout<<ans[i]<<" ";





}


Measured memory_bytes: 17152
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, k; cin >> n >> k;

    ll a[n];
    rep(i, n){
        cin >> a[i];
        a[i]--;
    }

    ll p[n];
    memset(p, -1, sizeof(p));

    ll pos = 0;
    p[0] = 0;
    bool is_period_checked = false;
    reps(t, 1, k + 1){
        pos = a[pos];
        // cout << "t: " << t << ", pos " << pos + 1 << endl;

        if(p[pos] == -1){
            p[pos] = t;
        }
        else if(!is_period_checked){
            ll period = t - p[pos];
            // cout << "period " << period << endl;

            ll n_loop_to_skip = (k - t) / period;
            t += n_loop_to_skip * period;

            is_period_checked = true;
        }
    }

    cout << pos + 1 << endl;

    return 0;
}

Measured memory_bytes: 6788
import java.io.*;
import java.util.StringTokenizer;

class Main {
	private static final double e = 3.305785;

	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			StringTokenizer st = new StringTokenizer(br.readLine());
			double a = Double.parseDouble(st.nextToken());
			double b = Double.parseDouble(st.nextToken());
			System.out.println(a*b/e);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 17064
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int an[SIZE];
int main(){
    string s;
    R(s);
    for(int i=0,j;i<SZ(s);i=j){
        int sep=SZ(s);
        for(j=i+1;j<SZ(s)&&s[j]<=s[j-1];j++){
            if(s[j]=='L')sep=min(sep,j);
        }
        for(j=i;j<SZ(s)&&(j==i||s[j]<=s[j-1]);j++){
            if((sep-j)%2)an[sep-1]++;
            else an[sep]++;
        }
    }
    W(VI(an,an+SZ(s)));
    return 0;
}


Measured memory_bytes: 1408
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=2005,MOD=998244353;

int C[MAXN*2][MAXN*2];

void Init()
{
    C[0][0]=1;
    for(int i=1;i<MAXN*2;i++)
    {
        C[i][0]=1;
        for(int j=1;j<=i;j++)
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
    }
}

inline int F(int n,int r)
{return C[n+r-1][n];}

int main()
{
    Init();

    int K,N;
    scanf("%d%d",&K,&N);
    for(int i=2;i<=2*K;i++)
    {
        int ans=F(N,K);
        int t=min(K-(i-1)/2,i/2);
        for(int j=1,flag=-1;j<=t&&j<=N/2;j++,flag=-flag)
            ans=(ans+1LL*flag*C[t][j]*F(N-j*2,K)%MOD)%MOD;
        ans=(ans+MOD)%MOD;
        printf("%d\n",ans);
    }

    return 0;
}


Measured memory_bytes: 61568
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void){
	int p,q,r;
	
	scanf("%d%d%d",&p,&q,&r);
	
	if(p>=q&&p>=r){
		printf("%d\n",q+r);
	}else if(q>=p&&q>=r){
		printf("%d\n",p+r);
	}else if(r>=p&&r>=q){
		printf("%d\n",p+q);
	}
	
	return 0;
}

Measured memory_bytes: 128
N,M = map(int,input().split())
requests = []
for _ in range(M):
        a,b = map(int,input().split())
        requests.append([a,b])

ans = 1
requests = sorted(requests, key=lambda x:(x[1],x[0]))
b = requests[0][1]
for i in range(M):
        if requests[i][0] < b:
                continue
        else:
                ans += 1
                b = requests[i][1]

print(ans)

Measured memory_bytes: 28492
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b == c || b + c == a || c + a == b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long L,A,B,M;
long power(long a,long b){return b?power(a*a%M,b/2)*(b%2?a:1)%M:1;}
long ten[99];
long n;
long sum(long k)
{
	long ret=0,p=1;
	for(int i=61;i--;)
	{
		if(k>>i&1)
		{
			(ret+=ten[i]*p)%=M;
			p=p*power(power(10,n),1LL<<i)%M;
		}
	}
	return ret;
}
long iten[99];
long isum(long k)
{
	long ret=0,p=1,g=0;
	for(int i=61;i--;)
	{
		if(k>>i&1)
		{
			(ret+=(iten[i]+ten[i]*g)%M*p)%=M;
			p=p*power(power(10,n),1LL<<i)%M;
			g=(g+(1LL<<i))%M;
		}
	}
	return ret;
}
long cnt[18],SUM[18];
main()
{
	cin>>L>>A>>B>>M;
	long pre=0,tmpten=1;
	long ans=0;
	for(n=0;n<18;n++)
	{
		long l=pre,r=L;
		tmpten*=10;
		while(r-l>1)
		{
			long m=(l+r)/2;
			if(A+B*m<tmpten)l=m;
			else r=m;
		}
		long k=l-pre;
		if(k<0||l>=L||A+B*l>=tmpten)
		{
			cnt[n]=1;
			continue;
		}
		pre=l+1;
		n++;
		ten[0]=1;
		for(int i=1;i<61;i++)ten[i]=(power(power(10,n),(1LL<<i-1))+1)%M*ten[i-1]%M;
		iten[0]=0;
		for(int i=1;i<61;i++)
		{
			iten[i]=((power(power(10,n),(1LL<<i-1))+1)%M*iten[i-1]+(1LL<<i-1)%M*ten[i-1]%M*power(power(10,n),(1LL<<i-1)))%M;
		}
		cnt[n-1]=power(power(10,n),k+1);
		SUM[n-1]=(((A+B*l)%M*sum(k+1)%M-B%M*isum(k+1))%M+M)%M;
		n--;
	}
	long p=1;
	for(int i=18;i--;)
	{
		ans=(ans+SUM[i]*p)%M;
		p=p*cnt[i]%M;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
using namespace std;
int main() {
    int N;
    cin >> N;
	string c;
    cin >> c;
    int i = 0;
	while(i != c.size()){
		if((c[i] + N <= 'Z')){
			c[i] += N;
		}
		else{
			c[i] = 'A' + N - ('Z' - c[i])-1;
		}
		printf("%c",c[i]);
        i++;
	}    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
deque<char> deq;
int on;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int q;
	cin>>q;
	for(auto tmp:s)
	{
		deq.push_back(tmp);
	}
	for(int i=1;i<=q;i++)
	{
		int t;
		cin>>t; 
		if(t==1) 
		on=(1-on);
		if(t==2)
		{
			int f;
			char c;
			cin>>f>>c;
			if(on^(f==1)) deq.push_front(c);
			else deq.push_back(c);
		}
	}
	string ans;
	for(auto tmp:deq)
	{
		ans.push_back(tmp);
	} 
	if(on) reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 1368
#include<stdio.h>
int main(){
	int t,n,s[11],f[11],i,a;
	
	while(1){
		scanf("%d%d",&t,&n);
		if(t==0){
			break;
		}
		
		for(i=0;i<n;i++){
			scanf("%d%d",&s[i],&f[i]);
		}
		
		a=0;
		for(i=0;i<n;i++){
			a+=f[i]-s[i];
		}
		
		if(t<=a){
			printf("OK\n");
		}else if(t>a){
			printf("%d\n",t-a);
		}
	}
	
return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define ALL(V) (V).begin(),(V).end()
using namespace std;
using ll = int64_t;
using TLL = tuple<ll, ll, ll>;
template <typename T> using V = vector<T>;

const ll inf = 5e15;

struct BIT {
    V<ll> data;

    BIT(ll N) {
        ll n = 1;
        while(n < N) n *= 2;
        data.resize(n + 1);
    }

    ll sum(ll pos) {
        ll ret = 0;
        while(pos > 0) {
            ret += data[pos];
            pos -= pos & (-pos);
        }
        return ret;
    }

    ll sum(ll l, ll r) { return sum(r) - sum(l); }

    void add(ll pos, ll delta) {
        pos++;
        while(pos <= data.size()) {
            data[pos] += delta;
            pos += pos & (-pos);
        }
    }
};

int main() {
    ll N;
    cin >> N;
    V<ll> A(N);
    for(auto &&ele : A) cin >> ele;
    {
        auto tmp = A;
        sort(ALL(tmp));
        auto ite = unique(ALL(tmp));
        tmp.erase(ite, tmp.end());
        auto get_id = [&](ll n) {
            return distance(tmp.begin(),
                            lower_bound(ALL(tmp), n));
        };
        for(ll &e : A) e = get_id(e);
    }

    V<ll> left(N + 1), right(N + 1);
    {
        BIT bt(N + 10);
        for(ll i = 0; i < N; i++) {
            left[i + 1] = bt.sum(A[i] + 1, N + 10);
            bt.add(A[i], 1);
        }
    }
    {
        reverse(ALL(A));
        BIT bt(N + 10);
        for(ll i = 0; i < N; i++) {
            right[i + 1] = bt.sum(A[i] + 1, N + 10);
            bt.add(A[i], 1);
        }
        reverse(ALL(A));
        reverse(ALL(right));
        for(ll i = N - 1; 0 <= i; i--) right[i + 1] = right[i];
        right[0] = 0;
    }
    
    ll ans = 0;
    for(ll i = 0; i <= N; i++) ans += min(left[i], right[i]);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 6120
//  Suraj Saste

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi pair<ll,ll>
#define in insert
#define fe first
#define se second
#define ms(x,i) memset(x,i,sizeof(x))
#define prec(x) cout<<std::setprecision(x)
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll fpow(ll n, ll k, ll p=mod) {ll r=1; n=n%p; while(k>0){ if(k&1){ r=(r*n)%p; } k=k>>1; n=(n*n)%p; } return r;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 || n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0||n%(i+2)==0)return false;}return true;}

vector<ll> v[200005];
ll vis[200005],inde[200005],dp[200005];

void init(ll n)
{
	for(ll i=0;i<=n;i++)
	{
		vis[i]=inde[i]=dp[i]=0;
	}
}

int main()
{
	fast;
	ll n,m;cin>>n>>m;
	init(n);
	while(m--)
	{
		ll a,b;cin>>a>>b;
		v[a].pb(b);
	}
	for(ll i=1;i<=n;i++)
	{
		for(auto j:v[i])inde[j]++;
	}
    queue<ll> q;
    for(ll i=1;i<=n;i++)
    {
    	if(inde[i]==0)
    	{
    		vis[i]=1;
    		q.push(i);
    	}
    }
    while(!q.empty())
    {
    	auto x=q.front();q.pop();
    	for(auto j:v[x])
    	{
    		if(!vis[j])
    		{
    			inde[j]--;
    			dp[j]=max(dp[x]+1,dp[j]);
    			if(inde[j]==0)
    			{
    				vis[j]=1;
    				q.push(j);
    			}
    		}
    	}
    }
    ll ans=-1;
    for(ll i=1;i<=n;i++)ans=max(ans,dp[i]);
    cout<<ans;
	return 0;
}


Measured memory_bytes: 12032
#####

import numpy as np
from numpy import newaxis, float32, float64, int32, int64, int16, int8, uint8, uint32, complex64, complex128

#####

def getIntList(inp):
	return [int(_) for _ in inp]


from sys import stdin
import sys

def getInputs():
	inputs=[]
	for line in stdin:
		line=line.split()
		inputs.append(line)
	return inputs


def main(inputs):
	a8,b10=getIntList(inputs[0])
	
	min8=int(np.ceil(a8/0.08))
	max8=int(a8/0.08+12)
	min10=b10*10
	max10=b10*10+9
	
	for i8 in range(min8, max8+1):
		if i8>=min10 and i8<=max10:
			print(i8)
			sys.exit(0)
	print(-1)

if __name__=="__main__":
	inputs=getInputs()
# 	inputs=simInputs()
	main(inputs)
	


Measured memory_bytes: 18484
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    int dig = to_string(N).length();
    int c = 0;
    FOR(i, 1, dig) {
        if (i % 2 == 1) {
            c += 9 * pow(10, i - 1);
        }
    }
    if (dig % 2 == 1) {
        c += N - pow(10, dig - 1) + 1;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"
import "strings"

func main() {
	var S string
	fmt.Scan(&S)

	ss := strings.Split(S, "")

	if len(ss) == 0 {
		fmt.Println(0)
		return
	}

	exS := ""
	newSS := []string{}
	for _, s := range ss {
		if s != exS {
			newSS = append(newSS, s)
			exS = s
		}
	}

	fmt.Println(len(newSS) - 1)
}

Measured memory_bytes: 8576
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//ll INF = 1000000000000000000;
ll gcd(ll n, ll m){
  if(n==0) return m;
  else return gcd(m%n,n);
}
ll lcm(ll n, ll m){
  ll tmp = m/gcd(n,m);
  return n*tmp;
}
int main(){
  int N;
  cin >> N;
  ll T[N];
  for(int i=0;i<N;i++){
    cin >> T[i];
  }
  ll ans = T[0];

  for(int i=1;i<N;i++){
    ans = lcm(ans, T[i]);
  }

  cout << ans <<endl;
  //cout << lcm(INF,INF) <<endl;

  
  
  return 0;
}

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

using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

#define MOD 1000000007

int main(){
    ll h, w, k;
    cin >> h >> w >> k;

    ll dp[110][10] = {};
    dp[0][0] = 1;

    rep(i, h)rep(j, w)rep(k,(1<<(w-1))){  
        bool isok = true;
        rep(l, w-2)if(k & (1<<l) && k & (1<<(l+1))){
            isok = false;
            break;
        }
        if(isok){
            if(j > 0 && (1<<(j-1) & k)){
                dp[i+1][j-1] += dp[i][j];
                dp[i+1][j-1] %= MOD;
            }
            else if(j < w-1 && (1<<j) & k){
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j+1] %= MOD;
            }
            else {
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }
        }
    }

    cout << dp[h][k-1] << endl;
    
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

public class Hello
{
    public static void Main()
    {
        string s = Console.ReadLine();
        char[] c = s.ToCharArray();
        Array.Sort(c);
        for(int i = 0;i < s.Length;i++){
            if(s.Count(co => co == c[i]) % 2 != 0){
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 11348
a, b, c = map(int, input().split())

if a == b == c:
	if a % 2 == 1:
		print(0)
	else:
		print(-1)

else:
	ans = 0
	while not (a % 2 == 1 or b % 2 == 1 or c % 2 == 1):
		ans += 1
		a, b, c = (b + c) // 2, (c + a) // 2, (a + b) // 2
	print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<bitset>
#include<vector>
using namespace std;

int const MAX_N = 1003;
int const MAX_X = 5003;
int x[MAX_X];
vector<int> g[MAX_N];
int dp[MAX_N];
bitset<5006> bit(5);

int main() {
	int n;
	cin >> n;
	for (int i = 2; i <= n; i++) {
		int a;
		cin >> a;
		g[a].push_back(i);
	}
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
	}
	for (int i = n; i >= 1; i--) {
		if (g[i].size() == 0) {
			dp[i] = 0;
		}
		else {
			int s, t;
			t = x[i];
			s = 0;
			for (int j = 0; j < g[i].size(); j++) {
				t -= dp[g[i][j]];
				s += x[g[i][j]];
			}
			if (t < 0) {
				cout << "IMPOSSIBLE" << endl;
				return 0;
			}
			else if (s <= x[i]) {
				dp[i] = -t + x[i];
			}
			else {
				bit = 1;
				for (int j = 0; j < g[i].size(); j++) {
					int shift = x[g[i][j]] - dp[g[i][j]];
					bit = bit | (bit << shift);
				}
				for (int k = t; k >= 0; k--) {
					if (bit[k] == 1) {
						dp[i] = s - k;
						break;
					}
				}
			}
			if (dp[i] > x[i]) {
				swap(dp[i], x[i]);
			}
			/*
			for (int j = 0; j < g[i].size(); j++) {
				s += x[g[i][j]];
				t += dp[g[i][j]];
				s -= x[i];
			}
			if (s <= 0) {
				dp[i] = t;
			}
			else if (x[i] < t) {
				cout << "IMPOSSIBLE" << endl;
				return 0;
			}
			else {
				bit = 1;
				for (int j = 0; j < g[i].size(); j++) {
					int shift = x[g[i][j]] - dp[g[i][j]];
					bit = (bit << shift) | bit;
				}
				bit >> s;
				while (bit[0] == 0) {
					s++;
					bit >> 1;
				}
				dp[i] = t + s;
			}
			*/
		}
	}
	cout << "POSSIBLE" << endl;
}

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



int main(){
  string s;
  cin >> s;
  int n = s.size();
  int minA, maxZ;
  for(int i = 0; i < n; i++){
    if(s[i] == 'A'){
      minA = i; 
      break;
    } 
   
  }
  for(int i = n-1; i >= 0; i--){
    if(s[i] == 'Z'){
      maxZ = i;
      break;
    }
  }
  int ans = maxZ - minA + 1;
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
//I will be AC I'm sure.
using namespace std;
int s;
int main()
{
	cin>>s;
	for(int i=1;i<=s;i++)
	{
		cout<<"ACL";
	}
	return 0;
}

Measured memory_bytes: 3560
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        long[] b = new long[n + 1];
        long[] w = new long[n + 1];
        for (int i = 1; i <= n; i++) {
            int a = scanner.nextInt();
            if (a < 0) {
                b[i] = -a;
            } else {
                w[i] = a;
            }
        }
        Arrays.parallelPrefix(b, Long::sum);
        Arrays.parallelPrefix(w, Long::sum);
        long m = Long.MAX_VALUE;
        for (int i = k; i <= n; i++) {
            m = Math.min(m, Math.min(b[i] - b[i - k], w[i] - w[i - k]));
        }
        System.out.println(w[n] - m);
    }
}

Measured memory_bytes: 60648
#include<bits/stdc++.h>
#define LL long long
#define MOD (LL)1000000007
#define pi acos(-1.0)
#define ULL unsigned long long
#define mem_1(str) memset(str,-1,sizeof(str))
#define mem0(str) memset(str,0,sizeof(str))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define INF 999999999999999
using namespace std;
int main()
{
    LL h,w,ans=INF;
    scanf("%lld%lld",&h,&w);
    for(int i=1;i<=h;i++)
    {
        LL a=i*w;
        LL b=((h-i)/2)*w;
        LL c=h*w-a-b;
        LL maxx=max(a,max(b,c));
        LL minn=min(a,min(b,c));
        ans=min(ans,abs(maxx-minn));
        a=i*w;
        b=(h-i)*(w/2);
        c=h*w-a-b;
        maxx=max(a,max(b,c));
        minn=min(a,min(b,c));
        ans=min(ans,abs(maxx-minn));
    }
    for(int i=1;i<=w;i++)
    {
        LL a=h*i;
        LL b=((w-i)/2)*h;
        LL c=h*w-a-b;
        LL maxx=max(a,max(b,c));
        LL minn=min(a,min(b,c));
        ans=min(ans,abs(maxx-minn));
        a=i*h;
        b=(w-i)*(h/2);
        c=h*w-a-b;
        maxx=max(a,max(b,c));
        minn=min(a,min(b,c));
        ans=min(ans,abs(maxx-minn));
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

        int n = sc.nextInt();

        List<Double> values = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            values.add(sc.nextDouble());
        }

        Collections.sort(values);

        double result = 0;
        for (int i = 0; i < n-1; i++) {
            double c = (values.get(i) + values.get(i+1)) / 2;
            result = c;
            values.set(i+1, c);
        }

        System.out.println(result);

    }
}


Measured memory_bytes: 24144
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;
const lint mod = 1e9 + 7;

lint solve(int n, lint ga, lint sa, lint ba, lint gb, lint sb, lint bb){
    lint dp[n+1];
    rep(i, n+1) dp[i] = -1;
    dp[0] = 0;
    rep(i, n+1)if(dp[i] >= 0){
        if(i+ga <= n) dp[i+ga] = max(dp[i+ga], dp[i] + gb);
        if(i+sa <= n) dp[i+sa] = max(dp[i+sa], dp[i] + sb);
        if(i+ba <= n) dp[i+ba] = max(dp[i+ba], dp[i] + bb);
    }
    lint ret = 0;
    rep(i, n+1) ret = max(ret, dp[i] + n-i);
    return ret;
}

int main(){
    int n;
    scanf("%d", &n);
    lint g[2], s[2], b[2];
    rep(i, 2) scanf("%lld%lld%lld", &g[i], &s[i], &b[i]);
    printf("%lld\n", solve(solve(n, g[0], s[0], b[0], g[1], s[1], b[1]), g[1], s[1], b[1], g[0], s[0], b[0]));
}

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

using   namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define  all(v)       (v).begin(),(v).end()
#define  rall(v)      (v).rbegin(),(v).rend()
#define  pb           push_back  
#define  eb           emplace_back
#define  mp           make_pair
#define  ff           first
#define  ss           second
#define  pf           push_front
#define  bs           binary_search
#define  lb           lower_bound
#define  ub           upper_bound
#define  umap         unordered_map
#define  uset         unordered_set
#define  dec(x)       fixed<<setprecision(x)
#define  lcm(a,b)    (a*b/__gcd(a,b))

typedef  priority_queue<ll>  pq;
typedef  priority_queue<ll,vector<ll>,greater<ll>> pqmn;
typedef  pair<ll,ll> pll;

const    ll inf=LLONG_MAX;
const    ll mod=1e9+7;
const    ld pi=acos(-1);
                    
void solution(){

    string s;
    cin>>s;
    if(s[s.size()-1]=='s'){
        cout<<s<<'e'<<'s';
    }
    else{
        cout<<s<<'s';
    }


}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        solution();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3660
import sys
import math
import itertools
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
import bisect
X,N = I()
if N == 0:
    print(X)
    exit()
p = l()
A = [i for i in range(-1,102)]
for i in range(N):
    if p[i] in A:
        A.remove(p[i])
i = bisect.bisect_left(A,X)
if abs(A[i-1]-X) > abs(A[i]-X):
    print(A[i])
else:
    print(A[i-1])

Measured memory_bytes: 10080
n, m = gets.chomp.split(" ").map(&:to_i)
inputs = gets.chomp.split(" ").map(&:to_i)
flag = false

if m%2 == 1 #奇数の時
	for i in 0..n-1
		if inputs[i] %2 != 0
			flag = true
		end
	end

	if flag
		result = 2**(n-1)
	else
		result = 0
	end

else
	for i in 0..n-1
		if inputs[i] %2 !=0
			flag = true
		end
	end

	if flag
		result = 2**(n-1)
	else
		result = 2 ** n
	end

end

puts result


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

int main() { 	
 int N,Max,Min,sa,a;
	cin >> N;
    vector<int> vec(N+2);
	for(int i=0;i<N;i++){
    cin >> vec.at(i);
     Max+=vec.at(i);
    }
  
  sa=Max;
  Min =0;

  	for(int x=0;x<N;x++){

    Min +=vec.at(x);
    Max -=vec.at(x);
      if(Max>Min){
      a=Max-Min;}else{
      a=Min-Max;
      }
            if(a < sa && a>=0){
     
      sa=a;
      }
        
    }
  
  cout << sa<<endl;
}

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

// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std

Jehian Norman Saviero;

// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;

// MACROS FOR ATTRIBUTE
#define fi first
#define se second

// MACROS FOR FUNCTION AND METHOD
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define RESET(x) memset((x), 0, sizeof(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define ALL(x) (x).begin(), (x).end()
#define ALLSIZE(x,n) (x), (x)+(n)
#define SQR(x) ((x)*(x))
#define CUBE(x) (SQR(x)*(x))

// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main(){
	int A, B;
	cin >> A >> B;
	puts(A > 8 || B > 8 ? ":(" : "Yay!");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdint>
#include <algorithm>

int main() {
	std::string a;
	std::cin >> a;

	std::int64_t ans = a.size() * (a.size() - 1) / 2 + 1;
	for (char c = 'a'; c != 'z' + 1; ++c) {
		std::int64_t num = std::count(a.begin(), a.end(), c);

		ans -= num * (num - 1) / 2;
	}

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

Measured memory_bytes: 640
n = gets.to_i
a = gets.split.map(&:to_i)
min = 10**10
cnt = 0
ans = 0
a.each do |v|
  if v < 0
    cnt += 1
  end
  t = v.abs
  ans += t
  min = t if min > t
end
p cnt.odd? ? ans-2*min : ans


Measured memory_bytes: 10268
#include <stdio.h>
#include <limits.h>
int A[100][100];
int d[100];
int v[100];

void getMST(int n){
	int i,j,k=1;
	int minCost,min,result=0;

	d[0] = 0;
	v[0] = 1;
	for(i=1;i<n;i++) v[i]=0;

	while(1){
		minCost = 2001;
		for(i=0;i<k;i++){
			for(j=0;j<n;j++){
				if( A[d[i]][j]<minCost && A[d[i]][j] != -1 && v[j] != 1){
					minCost = A[d[i]][j];
					min = j; 
				}
			}
		}

		if(k != n){
			d[k] = min;
			v[min] = 1;
			result += minCost;
			k++;
		}
		else break;
	}
	printf("%d\n",result);
}

int main(){
	int n;
	int i,j;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			scanf("%d",&A[i][j]);
			//A[i][j] = A[i][j]==-1?INT_MAX:A[i][j];
		}
	}
	getMST(n);

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll p = 1e9 + 7;
#define DEBUG(x) cout << (x) << '\n'
#define fi first
#define se second

int n, m, f[MAXN], cnt[MAXN];
int find(int x){ return x == f[x] ? x : f[x] = find(f[x]); }
void run(){
    cin >> n >> m;
    iota(f + 1, f + n + 1, 1);
    fill(cnt + 1, cnt + n + 1, 1);
    int x, y;
    for(int i = 1; i <= m; i++){
        cin >> x >> y;
        x = find(x), y = find(y);
        if(x == y) continue;
        f[y] = x, cnt[x] += cnt[y];
    }
    DEBUG(*max_element(cnt + 1, cnt + n + 1));
}
int main(){
#ifdef Irene
    freopen("in.txt", "r", stdin);
#endif // Irene
    ios_base::sync_with_stdio(false);

    run(); return 0;
}


Measured memory_bytes: 5212
import math
N = int(input())
A = list(map(int,input().split()))
l = list()
ll = list()
for i in range(len(A)):
  if A[i]%4 == 0:
    l.append(A[i])
  if A[i]%2 == 0:
    ll.append(A[i])
four = len(l)
two = len(ll)-four
zero = N-two
a = math.floor(N/2)
if a <= four:
  print("Yes")
elif 2*a-two <= 2*four:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 96012
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int part[3][100002];
int cnt[100002];

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

    for(int j=0;j<3;j++){
        for(int i=0;i<N;i++){
            cin >> part[j][i];
        }
        sort(part[j], part[j] + N);
    }

    int j = 0;
    for(int i=0;i<N;i++){
        while(j < N && part[0][j] < part[1][i]) j++;
        cnt[i] = j;
    }

    ll ans = 0;
    ll tmp = 0;
    j = 0;
    for(int i=0;i<N;i++){
        while(j < N && part[1][j] < part[2][i]){
            tmp += cnt[j];
            j++;
        }
        ans += tmp;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

int S(ll x)
{
    int ans = 0;
    while (x)
    {
        ans += x % 10;
        x /= 10;
    }
    return ans;
}

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
    freopen("a.out", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    vector <ll> ans;
    for (int d1 = 0; d1 < 10; d1++)
    {
        for (int d2 = 0; d2 < 10; d2++)
        {
            for (int d3 = 0; d3 < 10; d3++)
            {
                ll cur = 0;
                cur = cur * 10 + d1;
                cur = cur * 10 + d2;
                cur = cur * 10 + d3;
                for (int it = 0; it < 13; it++)
                {
                    if (cur != 0)
                        ans.push_back(cur);
                    cur = cur * 10 + 9;
                }
            }
        }
    }
    sort(ans.begin(), ans.end());
    ans.resize(unique(ans.begin(), ans.end()) - ans.begin());
    vector <ll> res;
    for (int i = 0; i < (int) ans.size(); i++)
    {
        bool bad = false;
        for (int j = i + 1; j < (int) ans.size(); j++)
        {
            if (ans[i] * S(ans[j]) > ans[j] * S(ans[i]))
            {
                bad = true;
                break;
            }
        }
        if (!bad)
        {
            res.push_back(ans[i]);
        }
    }
    sort(res.begin(), res.end());
    int k;
    cin >> k;
    for (int i = 0; i < k; i++)
    {
        cout << res[i] << '\n';
    }
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
vvi id();
int num(int &);
vvi seq(int &);
vvi rep(int &);
vvi operation(int &);
string s;
int n, l;
int num(int &i) {
	int ret = 0;
	while (i < l&&isdigit(s[i])) {
		ret *= 10;
		ret += s[i] - '0';
		++i;
	}
	return ret;
}

vvi operation(int &i) {
	char c = s[i];
	++i;
	int a = num(i);
	vvi ret(n, vi(n));
	REP(k, n) {
		REP(j, n) {
			ret[k][j] = k*n + j;
		}
	}
	if (c == 'R') {
		REP(k, n - 1) {
			ret[a - 1][k + 1] = (a - 1)*n + k;
		}
		ret[a - 1][0] = (a - 1)*n + n - 1;
	}
	else if (c == 'L') {
		REP(k, n - 1) {
			ret[a - 1][k] = (a - 1)*n + k + 1;
		}
		ret[a - 1][n - 1] = (a - 1)*n;
	}
	else if (c == 'D') {
		REP(k, n - 1) {
			ret[k + 1][a - 1] = k*n + a - 1;
		}
		ret[0][a - 1] = (n-1)*n+a-1;
	}
	else if (c == 'U') {
		REP(k, n - 1) {
			ret[k][a - 1] = (k + 1)*n + a - 1;
		}
		ret[n - 1][a - 1] = a-1;
	}
	return ret;
}

vvi con(vvi b, vvi a) {
	vvi ret(n, vi(n));
	REP(i, n) {
		REP(j, n) {
			int c = a[i][j];
			int e = c%n, d = c / n;
			int f = b[d][e];
			ret[i][j] = f;
		}
	}
	return ret;
}

vvi rep(int &i) {
	++i;
	vvi ret = seq(i);
	++i;
	int a = num(i);
	int c = ceil(log2(a));
	vector<vvi> x(c+1);
	x[0] = ret;
	int j = 0;
	REP(k, c) {
		x[k + 1] = con(x[k], x[k]);
	}
	vvi ans = id();
	//cout << a <<" "<<c<< endl;
	REP(k, c+1) {
		if (a&(1 << k)) {
			ans = con(ans, x[k]);
			j += (1 << k);
		}
		
	}
	//cout << j << endl;
	return ans;
}
vvi seq(int &i) {
	if (i == l || s[i] == ')') {
		return id();
	}
	vvi a;
	if (s[i] == '(') {
		a = rep(i);
	}
	else {
		a = operation(i);
	}
	vvi ret = con(a, seq(i));
	return ret;
}
vvi id() {
	vvi a(n, vi(n));
	REP(i, n) {
		REP(j, n) {
			a[i][j] = i*n + j;
		}
	}
	return a;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> n >> l;
	cin >> s;
	int i = 0;
	vvi a = seq(i);
	REP(k, n) {
		REP(j, n) {
			cout << a[k][j] + 1;
			if (j != n - 1)cout << " ";
			else cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 11056