akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{h:i64};
    let mut h = h;
    let mut ans = 0i64;
    let mut crt = 1i64;
    while h != 0 {
        h /= 2;
        //debug!(h, crt);
        ans += crt;
        crt *= 2;
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
package main

import "fmt"

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n, &s)
	if n%2 != 0 {
		fmt.Println("No")
		return
	}
	if s[:n/2] == s[n/2:] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var acc = new bool[n];
        var wac = new int[n];
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var p = int.Parse(line[0]) - 1;
            if (line[1] == "WA" && !acc[p]) wac[p]++;
            else if (line[1] == "AC" && !acc[p]) { acc[p] = true; }
        }
        var ans1 = 0;
        var ans2 = 0;
        for (int i = 0; i < n; i++)
        {
            if (acc[i]) ans1++;
            if (acc[i]) ans2 += wac[i];
        }
        Console.WriteLine("{0} {1}", ans1, ans2);
    }
}


Measured memory_bytes: 17504
import sys
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))

n = ri()
a = rl()
t = sum(a)
cnt_li = [0]*10**5
for i in a:
    cnt_li[i-1] += 1

for _ in range(ri()):
    b, c = rm()
    t += (c-b)*cnt_li[b-1]
    print(t)
    cnt_li[c-1] += cnt_li[b-1]
    cnt_li[b-1] = 0

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

using namespace std;

const unsigned long long MOD = 1e9+7;
vector <int> e[100005];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	int a, b;
	for (int i = 1; i < n; ++i){
		cin >> a >> b;
		e[a].emplace_back(b);
		e[b].emplace_back(a);		
	}
	vector <int> dist(n+1,-1);
	queue <int> q;
	q.push(1);		
	dist[1] = k;
	while (!q.empty()){
		int u = q.front();
		q.pop();
		int b = k - 1;
		if (u != 1){
			--b;			
		}
		for (auto v : e[u]){
			if (dist[v] == -1){
				dist[v] = b;
				b--;
				q.push(v);
			}
		}
	}	
	long long ans = 1;
	for (int i = 1; i <= n; ++i){
		ans = ans * dist[i]%MOD;
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 6904
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp
 
using namespace std;
 
typedef pair<int, int> P;
typedef long long ll;
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}
 
string grid[401];
int H, W;
ll result = 0;

vector<P> path[401][401]; // 各マスから移動できる経路
ll col[401][401] = {0}; // そのマスがどの連結成分に属するか
ll cnts = 0; // 連結成分のID
ll B[160802] = {0}; // 各連結成分ごとの黒の数
ll WW[160802] = {0}; // 各連結成分ごとの白の数
 
void dfs(int x, int y) {
    if (col[x][y] > 0) return;
    col[x][y] = cnts;
    if (grid[x][y] == '.') WW[cnts]++;
    if (grid[x][y] == '#') B[cnts]++;
    rep(i, path[x][y].size()) {
        dfs(path[x][y][i]._1, path[x][y][i]._2);
    }
}
 
int main() {
    cin >> H >> W;
    rep(i, H) {
        string si;
        cin >> si;
        grid[i] = si;
    }

    // 各マスの経路作成
    rep(i, H) {
        rep(j, W) {
            char ci = grid[i][j];
            rep(d, 4) {
                int x = i + dx[d];
                int y = j + dy[d];
                if (x < 0 || x >= H || y < 0 || y >= W) continue;
                if (ci == '.' && grid[x][y] == '#') {
                    path[i][j].pb(make_pair(x, y));
                }
                if (ci == '#' && grid[x][y] == '.') {
                    path[i][j].pb(make_pair(x, y));
                }
            }
        }
    }

    // 深さ優先探索で連結成分作成しつつ、白黒の数を深さ優先でカウント
    rep(i, H) {
        rep(j, W) {
            if (col[i][j] != 0) continue;
            cnts++;
            dfs(i, j);
        }
    }

    // 全ての連結成分の個数分 白 * 黒を足し合わせる
    for (int i = 1; i <= cnts; i++) {
        result += 1LL * B[i] * WW[i];
    }
 
    cout << result << endl;
}

Measured memory_bytes: 18432
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int N=gi();
	    int H=gi();
	    int W=gi();
	    int c=0;
	    for (int i=0; i<N;i++) {
	    	int a=gi();
	    	int b=gi();
	    	if(a>=H && b>=W) c++;
	    }
	    

        System.out.println(c);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 38516
a, b, c, d = [int(i) for i in input().split()]
def check(a, b, c, d):
  if b <= c or d<=a:
    return 0
  elif c<=a and a<=d and d<=b: 
    return d-a
  elif a<=c and d<=b:
    return d-c
  elif c<=a and b<=d:
    return b-a
  elif a<=c and c<= b and b<=d:
    return b-c
print(check(a,b,c,d))



Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> input = Arrays.asList(br.readLine().split(" "));

            List<Integer> numbers = new ArrayList<>();
            for (String s : input) {
                numbers.add(Integer.parseInt(s));
            }

            int even = numbers.get(0);
            int odd = numbers.get(1);

            System.out.println(even * (even - 1) / 2 + odd * (odd - 1) / 2);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
#include <stdio.h>
#include <algorithm>

#define all(x) x.begin(),x.end()
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define pr(x) printf("%d",x)
#define prl(x) printf("%lld",x)
#define LL long long
#define pb push_back
#define PB pop_back
#define PF pop_front
#define F first
#define S second
#define inrow(vec)    for(int i=0;i<vec.size();i++)cout<<vec[i]<<" ";
#define incoloum(vec) for(int i=0;i<vec.size();i++)cout<<vec[i]<<endl;

const double PI=3.1415926;
const int KL=1e6;

using namespace std;

LL q,x,y,z,n,m,p[KL],mn=1e9,mx=-1e9,ans;
string t;
vector <LL> vec;
set <int> s;
map <int,int> M;


int main()
{
    scl(n);
    for(int i=0;i<n;i++)scl(p[i]);
    mn=1e18;
    for(LL i=1;i<=100;i++)
    {
        LL sum=0;
        for(int j=0;j<n;j++)
        {
            sum+=(p[j]-i)*(p[j]-i);
        }
        mn=min(mn,sum);
    }
    cout<<mn<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define ll          long long
#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)
#define track(x)                cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define ed(i)       i.end()
#define mem(a)      memset(a, 0, sizeof(a))
#define MOD         1000000007
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
void self_max(int &a, int &b) {a = max(a, b); }
void self_min(int &a, int &b) {a = min(a, b); }
#define hell        1000000007
bool isPrime(long int n) 
{
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}


ll power(int x, unsigned int y, int p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
        // y must be even now 
        y = y>>1; // y = y/2
        x = (x*x) % p;  
    } 
    return res;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int n, k;

void solve(){
	
	cin >> n >> k;
	vi arr(n);
	rep(i, 0, n)	cin >> arr[i];

	sort(all(arr));
	int ans=0;
	rep(i, 0, k)	ans += arr[i];
	cout << ans << endl;

}
int main() {
	// freopen("input.txt", "rt", stdin);
	// freopen("output.txt", "wt", stdout);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
}



// AGGC
// AGTC
// ATGC


Measured memory_bytes: 3608
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vi x(n), y(n);
    map<int, map<int, char>> d;
    rep(i, n){
        char c;
        cin >> x[i] >> y[i] >> c;
        d[y[i]][x[i]] = c;
    }

    map<int, set<int>> x2y_, y2x_, x2ny_, y2nx_;
    rep(i, n){
        int xx = x[i], yy = y[i];
        x2y_ [xx].insert( yy);
        x2ny_[xx].insert(-yy);
        y2x_ [yy].insert( xx);
        y2nx_[yy].insert(-xx);
    }

    int res = 0;
    rep(i, n){
        auto x2y = x2y_, y2x = y2x_, x2ny = x2ny_, y2nx = y2nx_;

        int cx = x[i], cy = y[i];
        int cur = 0;
        while(true){
            cur++;
            int nx = cx, ny = cy;
            switch(d[cy][cx]){
                case 'v': { auto ni = x2y [cx].upper_bound( cy); if(ni != end(x2y [cx])){ ny =   *ni ; } break; }
                case '^': { auto ni = x2ny[cx].upper_bound(-cy); if(ni != end(x2ny[cx])){ ny = -(*ni); } break; }
                case '>': { auto ni = y2x [cy].upper_bound( cx); if(ni != end(y2x [cy])){ nx =   *ni ; } break; }
                case '<': { auto ni = y2nx[cy].upper_bound(-cx); if(ni != end(y2nx[cy])){ nx = -(*ni); } break; }
            }
            x2y[cx].erase(cy); x2ny[cx].erase(-cy);
            y2x[cy].erase(cx); y2nx[cy].erase(-cx);

            if(nx == cx and ny == cy) break;
            cx = nx, cy = ny;
        }
        chmax(res, cur);
    }

    cout << res << endl;

    return 0;
}

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


int main(){
    long long n; cin >> n;
    long long money=1000; long long stock=0;
    int before; cin>>before;
    int after;
    for (int i=1; i<n; i++){
        cin >> after;
        if(after>before){
            stock = money/before;
            money = money%before;
            money += stock * after;
            stock = 0;
        }
        
        before = after;
    }
    cout << money << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <cmath>
#include <cstring>

using namespace std;
#define int long long
const int mod = 1000000007;


signed main(){
	int N, a[101] = {};
	cin >> N;
	for (int i = 0; i < N; i++) cin >> a[i];
	sort(a, a + N);
	int ans = 999999999999;
	for (int i = a[0]; i <= a[N - 1]; i++) {
		int cost = 0;
		for (int j = 0; j < N; j++) {
			cost += ((a[j] - i)*(a[j] - i));
		}
		ans = min(ans, cost);
	}
	cout << ans << endl;

}


Measured memory_bytes: 768
#define mod 1000000007
#include<time.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<queue>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF=0x7fffffffffffffff;
const int inf=0x7fffffff;
const int N=1e5+5;
clock_t start,finish;
void time_in(){start=clock();}
void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}
ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}
ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}
ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
int t,cas;
int n,m;
int main()
{
	char s[N];
	while(~scanf("%d",&n))
	{
		scanf("%s",s);
		int ans=1;
		for(int i=1;i<n;i++)
		{if(s[i]!=s[i-1])ans++;}
		printf("%d\n",ans);
	}
}


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

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

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse

#endif

class ABC128D
{
public:
	ABC128D()
	{
		cin >> n >> k;
		k++;
		v.resize(n);
		rep(i, 0, n)
			cin >> v[i];
		vr = v;
		reverse(all(vr));
	}
	void Run(void)
	{
		ll best = 0;
		ll solve = 0;
		rep(li, 0, k)
		{
			rep(ri, 0, k - li)
			{

				solve = Solve(li, ri, k - li - ri - 1);
				if (best < solve)
					best = solve;

			}
		}

		cout << best;

	}
private:
	ll Solve(ll lmax, ll rmax, ll dmax)
	{
		ll sum = 0;
		vector<ll> ans(n);

		lmax = (n < lmax) ? n : lmax;
		rep(i, 0, lmax)
			ans.push_back(v[i]);

		rmax = (n - lmax < rmax) ? n - lmax : rmax;
		rep(i, 0, rmax)
			ans.push_back(vr[i]);
	
		sum = accumulate(all(ans), 0);
		sort(all(ans));

		dmax = (ans.size() < dmax) ? ans.size() : dmax;
		rep(i, 0, dmax)
		{
			if (ans[i] < 0)
				sum -= ans[i];
		}

		return sum;
	}
	ll n;
	ll k;
	vector<ll> v;
	vector<ll> vr;
};

int main(void)
{
	ABC128D abc128d;
	abc128d.Run();

	return 0;
}


Measured memory_bytes: 256
/*╔═══╗──╔╗╔╗───────────────────╔╗────────╔═══╦═══╗
  ║║─║╠╗╠╗╔╣╚═╦══╦═╗╔╦╗╔═╗╔══╦══╣╚═╦╦══╦══╣║─║║║─╚╝
  ║╔═╗║╚╝║╚╣║║║╚╝║║─╔╦╗║║║║╚╝║╚╝║╚╝║║║═╬══║╔═╗║╚╩═║
  ╚╝─╚╩══╩═╩╝╚╩══╩╝─╚╩╝╚╝╚╩══╩══╩══╩╩══╩══╩╝─╚╩═══╝*/
#include<bits/stdc++.h>
#define mod 1000000007
#define modc 998244353
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define deb(x) cout << #x << " " << x << endl;
#define deb2(x,y) cout << #x << " " << x << " " <<  #y << " " << y << endl
#define deb3(x,y,z) cout << #x << " " << x << " " << #y << " " << y << " " << #z << " "  << z << endl;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
using namespace std;
template <class T>
string to_binary(T n)
{
	string binaryNum;
	int i = 0;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
		i++;
	}
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
template<class T>
bool perfectSq(T n)
{
	if(sqrt(n) == floor(sqrt(n)))
		return true;
	else
		false;
}
ll fifth(ll a)
{
	ll i;
	for(i=-1000;i<=1000;i++)
	{
		if((ll)pow(i,5) == a)
			return i;
	}
}
void solve()
{
	int i,j;
	ll sum = 0,prod = 1;
	map<ll,int>b;
	for(i=-1000;i<=1000;i++)
		b[(ll)pow(i,5)] = 1;
	ll x;
	cin >> x;
	for(i=-1000;i<=1000;i++)
	{
		if(b[x+(ll)pow(i,5)])
		{
			cout << fifth(x+(ll)pow(i,5)) << " " << i << endl;
			return;
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	while(t--)
	{
		solve();
	}
}


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

//#define int long long

using namespace std;

int a[100001];

int main () {
	int l, r;
	cin >> l >> r;
	if (r >= 0 && l <= 0) {
		cout << "Zero";
		return 0;
	}
	int len = (r - l + 1);
	if (l > 0) cout << "Positive";
	else {
		if (len % 2 == 0) cout << "Positive";
		else cout << "Negative";
	} 
    return 0;
}

Measured memory_bytes: 256
#include<set>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int m,n;
int a[10][10],c[10][10];
pair<int,pair<int,int> > b[64];
int fn(int);
int fm(int,int,int,int);
int fn(int p){
  int i,j;
  if(p==m){
    for(i=1;i<n+1;i++){
      for(j=1;j<n+1;j++){
	if(a[j][i]>0&&c[j][i]==-1)
	  break;
      }
      if(j!=n+1)
	break;
    }
    if(i==n+1)
      return 1;
  }else{
    if(fm(b[p].first,b[p].second.first-1,b[p].second.second,p))
      return 1;
    if(fm(b[p].first,b[p].second.first+1,b[p].second.second,p))
      return 1;
    if(fm(b[p].first,b[p].second.first,b[p].second.second-1,p))
      return 1;
    if(fm(b[p].first,b[p].second.first,b[p].second.second+1,p))
      return 1;
  }
  return 0;
}
int fm(int w,int x,int y,int p){
  if(a[x][y]>0&&w>=a[x][y]&&c[x][y]==-1){
    c[x][y]=p;
    if(w==a[x][y]){
      if(fn(p+1))
	return 1;
    }else{
      if(fm(w-a[x][y],x-1,y,p))
	return 1;
      if(fm(w-a[x][y],x+1,y,p))
	return 1;
      if(fm(w-a[x][y],x,y-1,p))
	return 1;
      if(fm(w-a[x][y],x,y+1,p))
	return 1;
    }
    c[x][y]=-1;
  }
  return 0;
}
int main(){
  int i,j;
  while(cin>>n&&n){
    memset(a,-1,sizeof(a));
    m=0;
    for(i=1;i<n+1;i++){
      for(j=1;j<n+1;j++){
	cin>>a[j][i];
	if(a[j][i]<0){
	  b[m]=make_pair(-a[j][i],make_pair(j,i));
	  m++;
	}
      }
    }
    sort(b,b+m);
    memset(c,-1,sizeof(c));
    if(fn(0))
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 872
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main() {
ll N, P = 0;;cin >> N;
rep(i, 0, N){
ll a;cin >> a;

if(a%2 == 0 && a%4 != 0)P+=1;
if(a%4 == 0)P+=2;
}

if(N%2 == 0 && P >= N){cout << "Yes";exit(0);}
if(N%2 != 0 && P >= N - 1){cout << "Yes";exit(0);}
cout << "No";
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    ll T1,T2,A1,A2,B1,B2;
    Scll2(T1,T2);
    Scll2(A1,A2);
    Scll2(B1,B2);

    if( T1*A1+T2*A2==T1*B1+T2*B2 ) {
        printf ("infinity\n");
        return 0;
    }

    if( A1 < B1 ){
        swap(A1,B1);
        swap(A2,B2);
    }

    if( A1 > B1 && A2 > B2 ) {
        printf ("%d\n", 0);
        return 0;
    }

    ll AT1 = A1*T1;
    ll AT2 = A2*T2;
    ll BT1 = B1*T1;
    ll BT2 = B2*T2;
    ll dif = BT1+BT2-AT1-AT2;

    if( AT1+AT2 > BT1+BT2 ){
        printf ("%d\n", 0);
        return 0;
    }

    ll ans = 0;

    // AT1>BT1
    // AT2<BT2
    // dif>0
    // printf ("%lld/", AT1-BT1);
    // printf ("%lld\n", dif );
    ans += (AT1-BT1)/dif+1;
    ans += ans;
    if( (AT1-BT1)%dif == 0 ) ans--;
    ans--;

    printf ("%lld\n", ans );

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a;
	while(cin>>a){
		a = a%39;
		if(a==0)
			cout << "3C39" << endl;
		else if(a<10)
			cout << "3C0" << a << endl;
		else
			cout << "3C" << a << endl;
	}
}

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

int main()
{
    int n;
    std::cin>>n;
    std::vector<int> arr(n);
    for (int i = 0; i < n; ++i)
    {
        std::cin >> arr[i];
    }

    const auto it_min = std::min_element(arr.begin(), arr.end());
    const auto it_max = std::max_element(arr.begin(), arr.end());
    std::cout << *it_max - *it_min << std::endl;

    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<ll> cnt(60);
    for (int i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        for (int j = 0; j < 60; ++j) {
            if(x & (1LL << j)){
                cnt[j]++;
            }
        }
    }
    ll ans = 0;
    ll t = 1;
    for (int i = 0; i < 60; ++i) {
        (ans += cnt[i]*(n-cnt[i])%MOD*t%MOD) %= MOD;
        (t *= 2) %= MOD;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int degree = in.nextInt();
        String ans = Ac(degree);
        System.out.println(ans);
    }

    public static String Ac(int degree) {
        String result;
        if (degree >= 30) {
            result = "Yes";
        } else {
            result = "No";
        }
        return result;
    }
}



Measured memory_bytes: 35676
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;

int main(){
  int H,A;
  cin>>H>>A;
  if(H%A==0){
    cout<<H/A<<endl;
  }else{
    cout<<H/A+1<<endl;
  }
}

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

using namespace std;

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

	// vector<int> S;
	// vector<int> P;
	string s;
	int p;

	vector<pair<string, int>> pairs(N);
	vector<size_t> indices(N);
	iota(indices.begin(), indices.end(), 0);

	for (int n=0; n<N; n++){
		cin >> s >> p;
		pairs[n] = make_pair(s, p); 
	}

	sort(indices.begin(), indices.end(), [&pairs](size_t i1, size_t i2) {
		if (pairs[i1].first != pairs[i2].first){
			return pairs[i1] < pairs[i2];
		}
		else{
			return pairs[i1].second > pairs[i2].second;
		}
    });


 	// for (int n = 0; n < N; n++) {
 	// 	cout << pairs[n].first << pairs[n].second << endl;
  // 	}

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

Measured memory_bytes: 256
//@Author- sitanshu
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair 
#define mii map<int, int>
#define umii unordered_map<int, int>
#define vi vector<int>
#define vl vector<ll>
#define clr(val) memset(val,0,sizeof(val))
const ll MAX = 1000009, MOD = 1e9 + 7;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);


void solve()
{
    int n, w;
    cin >> n >> w;
    ll weight[n], value[n];
    int x, y;
    for(int i = 0; i < n; i++)
    {
        cin >> weight[i] >> value[i];
    }

    ll dp[n+1][w+1];
    for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= w; j++)
        {
            if (i == 0 || j == 0)
            dp[i][j] = 0;
            else
            {
                if (j < weight[i-1])
                dp[i][j] = dp[i-1][j];
                else
                {
                    dp[i][j] = max(dp[i-1][j], value[i-1]+dp[i-1][j-weight[i-1]]);
                }
                
            }
            
        }
    }
    cout << dp[n][w] << endl;
}



int main()
{
    //OJ;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    t = 1;
    while(t--)
    {
        solve();
    }  
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

int solve(int N) {
  int retv = 0;
  for (int A = 1; A < N; A++) {
    retv += (N - 1) / A;
  }

  return retv;
}

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  // main procedure
  int ans = solve(N);

  // output
  cout << ans << endl;

  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

int N, K;

ll solve() {
    int ans = 0;
    while (N) {
        N /= K;
        ans++;
    }
    return ans;
}

int main() {
    cin >> N >> K;
    cout << solve() << endl;
}

Measured memory_bytes: 256
def main():
  a = input()
  a = list(a)
  t = True
  while len(a) != 0:
    b = a.pop(0)
    c = ""
    if len(a) > 0:
      c = a.pop(0)
    if b != "h" or c != "i":
      t = False
      break
    
  if t:
    print("Yes")
  else:
    print("No")


if __name__ == "__main__":
  main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) x.begin(),x.end()
const int maxn = 100010;

int X,Y,A,B,C;
vector <pi> v;

int32_t main() {
	FAST
	cin >> X >> Y >> A >> B >> C;
	for (int i =0;i<A;i++){
		int a; cin >> a;
		v.push_back(pi(a,0));
	}
	for (int i =0;i<B;i++) {
		int a; cin >> a;
		v.push_back(pi(a,1));
	}
	for (int i =0;i<C;i++) {
		int a; cin >> a;
		v.push_back(pi(a,2));
	}
	
	sort(all(v),greater<pi>());
	int ans = 0,taken = 0;
	int x = 0, y = 0;
	
	for (auto cur: v) {
		if (x + y + taken >= X + Y) break;
		if (cur.s == 0) {
			if (x == X) continue;
			x++;
			ans += cur.f;
		} else if (cur.s == 1) {
			if (y == Y) continue;
			y++;
			ans += cur.f;
		} else {
			taken++;
			ans += cur.f;
		}
	}

	cout << ans;
}









Measured memory_bytes: 10604
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


n = int(input())
s = input()

a = []

for i in range(n+1):
    a.append(len(set(s[:i]) & set(s[i:])))
print(max(a))


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

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

int main() {
    ll n; cin >> n;
    int cnt = 0;
    int MIN = 200010;
    rep(i,n){
        int p; cin >> p;
        if(p <= MIN) cnt++;
        MIN = min(MIN,p);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.stream.*;

class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a =saori.saori_hayami();
		int b = saori.saori_hayami();
		int c = saori.saori_hayami();
		int k = saori.saori_hayami();
		int ans = 0;
		for(int i = 0;i < k;i++){
			if(a > 0){
				ans++;
				a--;
			} else if(b > 0){
				b--;
			} else {
				c--;
				ans--;
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

import sys
import os


lst = input().split()
stack = []

for c in lst:
    if c == '+':
        a = stack.pop()
        b = stack.pop()
        stack.append(b + a)
    elif c == '-':
        a = stack.pop()
        b = stack.pop()
        stack.append(b - a)
    elif c == '*':
        a = stack.pop()
        b = stack.pop()
        stack.append(b * a)
    else:
        stack.append(int(c))
print(stack[0])

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

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

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

    UnionFind uf(n);
    rep(i,m){
        int x,y,z;
        cin>>x>>y>>z;
        x--,y--;
        uf.merge(x,y);
    }

    set<int> st;
    rep(i,n){
        int p=uf.root(i);
        st.insert(p);
    }

    cout<<st.size()<<endl;
}

Measured memory_bytes: 8268
#include <iostream>

using namespace std;

int main() {
  int X; cin >> X;
  int ans = 0;
  for(int i = 1; i <= 1000; i++) {
    int b = i;
    if (b * b > X) continue;
    b *= b;
    for(int j = 2; j <= 1000; j++) {
      ans = max(ans, b);
      if (b * i > X) break;
      b *= i;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
const int INF = 1145141919;

int color(int init, int pos) {
    if (init < pos)swap(init, pos);
    return (init - pos) % 2;
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> card(n, vector<int>(2));
    for (int i = 0; i < n; i++)cin >> card[i][0];
    for (int i = 0; i < n; i++)cin >> card[i][1];

    vector<vector<int>> dp(1 << n, vector<int>(n, INF));
    dp[0][0] = 0;
    for (int nowBit = 0; nowBit < 1 << n; nowBit++) {
        int bitCount = 0;
        for (int i = 0; i < n; i++) {
            if (nowBit & (1 << i))bitCount++;
        }

        if (nowBit == 0) {
            for (int next = 0; next < n; next++) dp[1 << next][next] = dp[0][0] + next;
        } else {
            for (int prev = 0; prev < n; prev++) {
                if ((nowBit & (1 << prev)) == 0)continue;

                int notused = 0;
                for (int next = 0; next < n; next++) {
                    if (nowBit & (1 << next))continue;

                    int prevnum = card[prev][color(prev, (bitCount - 1) % 2)];
                    int nextnum = card[next][color(next, bitCount % 2)];
                    if (prevnum <= nextnum) {
                        int nextBit = nowBit | (1 << next);
                        dp[nextBit][next] = min(dp[nextBit][next], dp[nowBit][prev] + notused);
                    }
                    notused++;
                }
            }
        }
    }

    int ret = INF;
    for (auto x:dp[(1 << n) - 1])ret = min(ret, x);
    cout << (ret == INF ? -1 : ret) << endl;
    return 0;
}

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


int main(){

int N;
cin>>N;
long long A[N];
long long s[N+1];
s[0]=0;
rep(i,N){
    cin>>A[i];
    s[i+1]=s[i]+A[i];
}
long long b[N+1];
b[N]=0;
for(int i=N;i>0;i--){
b[i-1]=b[i]+A[i-1];
}
long long ans=INF;

for(int i=1;i<N;i++){
    ans=min(ans,abs(s[i]-b[i]));
}
cout<<ans;
 return 0;
}
/*
3
2 4 3

3

12
100 104 102 105 103 103 101 105 104 102 104 101

0
*/

Measured memory_bytes: 4992
n = gets.to_i

digits = n.to_s.chars.map(&:to_i)

ans = 0
digits.each_with_index do |x, i|
  digits[i] = 9 if i > 0
  ans += digits[i]
end

num = digits.inject{|result,x| result * 10 + x}
if num <= n
  puts ans
  exit
end

ans = 0
digits.each_with_index do |x, i|
  digits [i] -= 1
  s = digits.inject{|result,x| result + x}
  num = digits.inject{|result,x| result * 10 + x}
  if num <= n
    ans = [s, ans].max
  end
  digits[i] += 1
end

puts ans

Measured memory_bytes: 1788
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;


int main(){
    int N, K, X,Y;
    scanf("%d%d%d%d",&N,&K,&X,&Y);
    int ans = 0;
    for(int i=1;i<=N;i++){
        if(i<=K)
            ans += X;
        else ans += Y;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
N = int(input())
*A, = map(int, input().split())
dp = [[0] * (N+1) for _ in range(N+1)]
for n in range(1, N+1):
    for i in range(N-n+1):
        j = i + n
        if (N - n) % 2 == 0: # first player
            dp[i][j] = max(dp[i+1][j] + A[i], dp[i][j-1] + A[j-1])
        else: # second player
            dp[i][j] = min(dp[i+1][j] - A[i], dp[i][j-1] - A[j-1])
print(dp[0][N])

Measured memory_bytes: 113244
n = int(input())
h = list(map(int, input().split()))

max_ = 0
cnt = 0
for i in range(n - 1):
    if h[i] >= h[i + 1]:
        cnt += 1
    else:
        max_ = max(max_, cnt)
        cnt = 0   
max_ = max(max_, cnt)
print(max_)

Measured memory_bytes: 15020
program main
  implicit none
  
  integer :: n,i,j,t,a(100)
  read(*,*)n
  read(*,*)(a(i),i=1,n)
  
  do i=1,N-1
     do j=i+1,N
        if(a(i) .gt. a(j))then
           t=a(i)
           a(i)=a(j)
           a(j)=t
        end if
     end do
  end do
  
  write(*,*)abs(a(n) - a(1))
end program main

Measured memory_bytes: 256
n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))

a=[abs(x[i]-y[i]) for i in range(n)]

for i in range(1,4):
    D=0
    for d in a:
        D+=d**i
    print(float(D**(1/i)))

print(max(a))


Measured memory_bytes: 5652
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>


/* ----- Type Alias ----- */
using Bool = bool;
using Int = long long int;
using Real = long double;
using Char = char;
using String = std::string;
template <class T, class U>
using Pair = std::pair<T, U>;
template <class... Ts>
using Tuple = std::tuple<Ts...>;

template <class T>
using Vector = std::vector<T>;
template <size_t N>
using Bits = std::bitset<N>;
template <class T>
using Queue = std::queue<T>;
template <class T>
using Stack = std::stack<T>;
template <class T>
using Deque = std::deque<T>;

template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
using Set = std::set<T>;
template <class T, class U>
using Map = std::map<T, U>;

template <class T, class... Us>
using Func = std::function<T(Us...)>;

template <class T>
T genv(T v) { return v; }

template <class T, class... Ts>
auto genv(size_t l, Ts... ts) {
    return Vector<decltype(genv<T>(ts...))>(l, genv<T>(ts...));
}

template <class Cost = Int>
struct Edge {
    Int src, dst;
    Cost cost;
    Edge(Int src = -1, Int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = Int>
using Edges = Vector<Edge<Cost>>;
template <class Cost = Int>
using Graph = Vector<Vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    Int precision;
    Fout(Int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}


/* ----- Constants ----- */
// constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// constexpr Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

int main() {
    Int n;
    std::cin >> n;

    Vector<Int> a(n + 1), b(n);
    for (auto& x : a) std::cin >> x;
    for (auto& x : b) std::cin >> x;

    Int ans = 0;
    for (Int i = 0; i < n; ++i) {
        if (b[i] < a[i]) {
            ans += b[i];
        } else if (b[i] < a[i] + a[i + 1]) {
            ans += b[i];
            a[i + 1] -= b[i] - a[i];
        } else {
            ans += a[i] + a[i + 1];
            a[i + 1] = 0;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(void){
	int in[10]={},out[10]={};
	int i=0,j=0,tmp;
	
	while(scanf("%d",&tmp)!=EOF){
		if(tmp!=0){
			in[i]=tmp;
			i++;
		}
		else{
			i--;
			printf("%d\n",in[i]);
		}
        }
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vi a(n);
    REP(i, n) cin >> a[i];
    int p = 0;
    vvi ans(h, vi(w));
    int r = 0;
    int c = 0;
    int t = 0;
    while (t < h * w) {
        if (a[p] == 0) p++;
        ans[r][c] = p + 1;
        a[p]--;
        if (r % 2 == 0) {
            if (c == w - 1) {
                r++;
            } else {
                c++;
            }
        } else {
            if (c == 0) {
                r++;
            } else {
                c--;
            }
        }
        t++;
    }
    printvv(ans);
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int n;
	cin >> n;
	cout << fixed << setprecision(16);
	int f = (n + 1) / 2;
	cout << (double)f / n << endl;
}


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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  ll D,T,S; cin >> D >> T >> S;
  cout << (T*S >= D ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3588