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

int n, a[1010];
int dp[1010][1010], dp2[1010] = {};

int ok(int l, int r){
    int &res = dp[l][r];
    if(res != -1) return res;
    res = false;
    if(l+0 == r) res = true;
    for(int i = l+2; i < r; i += 2) if(ok(l,i) && ok(i,r)) res = true;
    if(abs(a[l] - a[r-1]) <= 1 && ok(l+1, r-1)) res = true;
    return res;
}

int main(){
    while(cin >> n && n){
        rep(i, n) cin >> a[i];
        memset(dp, -1, sizeof dp);
        memset(dp2, 0, sizeof dp2);
        dp2[0] = 0;
        rep(i, n){
            dp2[i+1] = max(dp2[i+1], dp2[i]);
            for(int j = i + 2; j <= n; j += 2){
                if(ok(i, j)) dp2[j] = max(dp2[j], dp2[i] + j - i);
            }
        }
        cout << dp2[n] << endl;
    }
}

Measured memory_bytes: 7056
#include<iostream>
// Need start
#include<vector>
// Need end
using namespace std;

// Copy start
template <class T>
class Bellmanford {
    private:
        struct edge {
            int from, to;
            T cost;
            edge(int from, int to, T cost):
                from(from), to(to), cost(cost) {}
        };
        T identity_;
        vector<edge> edges_;
        vector<T> dist_;
        vector<bool> in_loop_;
        bool has_loop_;
    public:
        Bellmanford(int node_num, int edge_num, T identity):
            identity_(identity), dist_(vector<T>(node_num, identity)), in_loop_(vector<bool>(node_num, false)), has_loop_(false) {}
        void addEdge(int from, int to, T cost) {
            edges_.emplace_back(from, to, cost);
        }
        void _calcShortestPath(int start_node) {
            dist_[start_node] = 0;
            int n = (int)dist_.size();
            int m = (int)edges_.size();
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    edge now_edge = edges_[j];
                    if (dist_[now_edge.from] != identity_ && dist_[now_edge.to] > dist_[now_edge.from] + now_edge.cost) {
                        dist_[now_edge.to] = dist_[now_edge.from] + now_edge.cost;
                        if (i == n - 1) {
                            has_loop_ = true;
                            in_loop_[now_edge.to] = true;
                        }
                    }
                    if (in_loop_[now_edge.from]) {
                        in_loop_[now_edge.to] = true;
                    }
                }
            }
        }
        void calcShortestPath(int start_node) {
            _calcShortestPath(start_node);
            _calcShortestPath(start_node);
        }
        bool hasNegLoop() {
            return has_loop_;
        }
        bool inLoop(int node) {
            return in_loop_[node];
        }
        T getDist(int node) {
            return dist_[node];
        }
};
// Copy end

const int INF = 1 << 30;

int main() {
    // This sample is Atcoder Beginners Contest 137 E
    int N, M, P;
    cin >> N >> M >> P;
    Bellmanford<int> bellmanford(N, M, INF);
    int A, B, C;
    for (int i = 0; i < M; ++i) {
        cin >> A >> B >> C;
        --A, --B;
        bellmanford.addEdge(A, B, P - C);
    }
    bellmanford.calcShortestPath(0);
    if (bellmanford.inLoop(N - 1)) {
        cout << -1 << endl;
    }
    else {
        cout << max(-bellmanford.getDist(N - 1), 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		sc.close();
		Arrays.sort(A);
		if(A[N - 1] < K) {
			System.out.println("IMPOSSIBLE");
			System.exit(0);
		}
		if(N == 1) {
			if(A[0] == K) {
				System.out.println("POSSIBLE");
			}else {
				System.out.println("IMPOSSIBLE");
			}
			System.exit(0);
		}
		int g  = gcd(A[0], A[1]);
		for(int i = 2; i < N; i++) {
			g = gcd(g, A[i]);
		}
		if(K % g == 0) {
			System.out.println("POSSIBLE");
		}else {
			System.out.println("IMPOSSIBLE");
		}
	}
	static int gcd(int m, int n) {
		if(m < n) return gcd(n, m);
		if(n == 0) return m;
		return gcd(n, m % n);
	}
}

Measured memory_bytes: 51904
awk '$1<10{print $1}9<$1&&$1<100{print 9}99<$1&&$1<1000{print $1-99+9}999<$1&&$1<10000{print 909}9999<$1&&$1<100000{print 909+$1-9999}$1==100000{print 909+99999-9999}'

Measured memory_bytes: 680
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        System.out.println(z + " " + x + " " + y);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define int          long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define pi           pair<int,int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define FIO         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}


void solve()
{
     int d,t,s;
     cin>>d>>t>>s;
     if(t*s>=d)
     {
        cout<<"Yes\n";return;
     }
     cout<<"No\n";

}

signed main()
{
        FIO
         
        
        int t=1;
        //cin>>t;
        while(t--)
        solve();
        cerr<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

        return 0;
}

Measured memory_bytes: 3800
#include <stdio.h>
#define max(a, b) ((a) > (b) ? (a) : (b))
int r,c,s[10][10000],l[10],i,j;
int f(int n){
    int res=0;
    if (n==0) {
        int i,j;
        for (i=0; i<c; i++) {
            int k=0;
            for (j=0; j<r; j++) {
                if (s[j][i]==l[j]) {
                    k++;
                }
            }
            res+=max(k, r-k);
        }
        return res;
    }else{
        l[n-1]=0;
        res=f(n-1);
        l[n-1]=1;
        int x=f(n-1);
        res=max(res, x);
        return res;
    }
}
int main(){
    while (1) {
        scanf("%d%d",&r,&c);
        for (i=0; i<r; i++) {
            for (j=0; j<c; j++) {
                scanf("%d",&s[i][j]);
            }
        }
        if (r==0&&c==0) {
            return 0;
        }
        printf("%d\n",f(r));
    }
}

Measured memory_bytes: 988
#include <cstdio>
#include <algorithm>

using namespace std;

int S[10002];

int main(int argc, char const *argv[])
{
    int n;
    scanf("%d\n", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &S[i]);
    sort(S, S + n);

    int q, t, count = 0;
    scanf("%d\n", &q);
    for (int i = 0; i < q; ++i)
    {
        scanf("%d", &t);
        if (binary_search(S, S + n, t))
            count++;
    }

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

Measured memory_bytes: 1080
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
a = [list(map(int,input().split())) for i in range(n)]

import numpy as np
count = 0
b = np.array(b)
for i in range(n):
  ai = np.array(a[i])
  if np.dot(ai,b)+c > 0: count += 1
print(count)


Measured memory_bytes: 12464
import java.io.PrintWriter;
import java.util.*;

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

    public static void main(String[]$) {
        int n = Integer.parseInt(scanner.next());
        int q = Integer.parseInt(scanner.next());
        List<State> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int s = Integer.parseInt(scanner.next());
            int t = Integer.parseInt(scanner.next());
            int x = Integer.parseInt(scanner.next());
            list.add(new State(s - x, x, -1));
            list.add(new State(t - x, x, -2));
        }
        int[] ans = new int[q];
        for (int i = 0; i < q; i++) {
            list.add(new State(Integer.parseInt(scanner.next()), 0, i));
        }
        Collections.sort(list);
        TreeSet<Integer> set = new TreeSet<>();
        for (State s : list) {
            if (s.v == -1) {
                set.add(s.d);
            } else if (s.v == -2) {
                set.remove(s.d);
            } else {
                ans[s.v] = set.isEmpty() ? -1 : set.first();
            }
        }

        PrintWriter out = new PrintWriter(System.out);
        for (int i : ans) {
            out.println(i);
        }
        out.flush();
    }

    static class State implements Comparable<State> {
        int t, d, v;

        State(int t, int d, int v) {
            this.t = t;
            this.d = d;
            this.v = v;
        }

        @Override
        public int compareTo(State o) {
            return Integer.compare(t, o.t);
        }
    }
}

Measured memory_bytes: 129648
'''
CODE FESTIVAL 2016 Final
B - Exactly N points
'''

if __name__ == "__main__":
    N = int(input())
    ans = list()
    res = N
    tmp = 1
    while True:
        if res <= 0:
            if res == 0:
                break
            else:
                ans.pop(ans.index(abs(res)))
                break
        ans.append(tmp)
        res -= tmp
        tmp += 1

    for a in ans:
        print(a)


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
typedef long long ll;
#define pri(n) printf("%d\n",n)
#define lpri(n) printf("%lld\n",n);
#define rep(i,st,ed) for(int i=st;i<ed;i++)
#define var(n) int n; scn(n)
#define F first
#define S second 
#define pb(n) push_back(n)
#define pii pair<int,int> 
const int N=103;
const ll M=1e9+7;
const ll inf=1e18+5;

int main()
{
	var(n);
	int ans = 0;
	rep(i,0,n)
	{
		var(x);
		while(x%2==0)
		{
			x/=2;
			ans++;
		}
	}
	pri(ans);
}

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

int num_count[11];

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    num_count[a]++;
    num_count[b]++;
    num_count[c]++;
    if (num_count[5] == 2 && num_count[7] == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a,b;
inline int calc(int x,int y)
{
    return x*1000+y*100+(x%10)*10+x/10;
}
int main()
{
    cin>>a>>b;
    int ans=0;
    for(int i=10;i<=99;i++)
        for(int j=0;j<=9;j++)
        {
            int t=calc(i,j);
            if(a<=t&&t<=b) ans++;
        }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using ll=long long;
using namespace std;
int main(){
int n,m,k;
 cin>>n>>m>>k;
  long long t=0;
  int a[n],b[m];
  rep(i,n){
  cin>>a[i];
    
  }
rep(i,m){
cin>>b[i];
t+=b[i];//tにbを全部入れる
}
  int j=m;
  int ans =0;//カウント用
  rep(i,n+1){
  while(j>0&&t>k){//配列のjが負にならない範囲かつ制限時間k内におさまるとき
    --j;
    t-=b[j];
    
  // cout<<j<<endl;
  }
    //cout<<j<<endl;
    if(t>k)break;//a[i]を足していった結果、b[j]をいくら減らしてもkをどうしても超えてしまう場合、breakする
    //cout<<i+j<<endl;
    ans=max(ans,i+j);//過去のansとi+jのうち大きい方をansに代入する
    if(i==n) break;
  t+=a[i];//a[i]を足す
    //cout<<ans<<endl;
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 5156
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;

signed main(){

    int n;
    cin >> n;
    vector<int> a(n+1);
    rep(i,n)cin >> a[i];
    a[n] = 0;
    int ans = 0;
    if(a[0] != 0){
        cout << -1 << endl;
        return 0;
    }
    
    for(int i = 0;i <= n-1;i++){
        if(a[i] >= a[i+1])ans += a[i];
        else if(a[i]+1 != a[i+1]){
            cout << -1 << endl;
            return 0;
        }
        //cerr << i << endl;
    }
    cout << ans << endl;
    
    return 0;   
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://agc024.contest.atcoder.jp/tasks/agc024_c
// rm -r -f test;oj dl http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c

Measured memory_bytes: 1920
#include <iostream>
#include <set>
using namespace std;
int main(){
	set<string> se;
	string s;
	int k;
	cin >> s >> k;
	for(int i=0;i<s.size();i++){
		for(int j=1;j+i<=min(i+5,(int)s.size());j++){
			se.insert(s.substr(i,j));
		}
	}
	auto itr = se.begin();
	for(int i=0;i<k-1;i++)++itr;
	cout << *itr << endl;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    ll n,x;
    cin >> n >> x;
    vector<ll> b(n),l(n),u(n);
    rep(i,n)cin >> b[i] >> l[i] >> u[i];
    //priority_queue<pair<pair<ll,ll>,int> > pq;
    vector<pair<ll,ll> > v(n);
    ll tar = 0;
    rep(i,n){
        //pq.push(MP(MP((x-b[i])*u[i]+b[i]*l[i],u[i]),i));
        v[i] = MP((x-b[i])*u[i]+b[i]*l[i],i);
        tar += b[i]*l[i];
    }
    sort(v.rbegin(),v.rend());
    ll s = 0;
    set<int> st;
    int spe = -1;
    for(auto x:v){
        ll ss = x.first;
        int id = x.second;
        if(s+ss>=tar){
            s += ss;
            spe = id;
            break;
        }else{
            s += ss;
            st.insert(id);
        }
    }
    ll cnt = st.size();
    
    ll res = x*cnt;
    ll ans = 1ll<<60;
    rep(i,n){
        if(st.count(i)==1){
            ll ss = s-((x-b[i])*u[i]+b[i]*l[i]);
            ll sss = tar-ss;
            //cerr << s << " " << ss << " " << tar << endl;
            if((sss+l[i]-1)/l[i]<=b[i]){
                ans = min(ans,res+(sss+l[i]-1)/l[i]);
            }else{
                ans = min(ans,res+b[i]+(sss-b[i]*l[i]+u[i]-1)/u[i]);
            }
        }else{
            ll ss = s-((x-b[spe])*u[spe]+b[spe]*l[spe]);
            ll sss = tar-ss;
            //cerr << s << " " << ss << " " << sss << endl;
            if((sss+l[i]-1)/l[i]<=b[i]){
                ans = min(ans,res+(sss+l[i]-1)/l[i]);
            }else{
                ans = min(ans,res+b[i]+(sss-b[i]*l[i]+u[i]-1)/u[i]);
            }
        
        }
    }
    cout << ans << endl;
    // while(!pq.empty()){
    //     auto y = pq.top();
    //     pq.pop();
    //     int id = y.second;
    //     ll pp = y.first.first;
    //     if(s+pp<tar){
    //         s += pp;
    //         res += x;
    //     }else{
    //         if((tar-s+l[id]-1)/l[id]<=b[id]){
    //             ans = min(ans,res+(tar-s+l[id]-1)/l[id]);
    //         }else{
    //             ans = min(ans,res+b[id]+(tar-s-b[id]*l[id]+u[id]-1)/u[id]);
    //         }
    //     }
    //     cerr << id << " " << s << " " << tar << " " << res << endl;
    // }
    return 0;
}

Measured memory_bytes: 8832
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
//#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);

int main() {
    std::array<std::array<int, 3>, 3> c;
    for(int i = 0; i < 3; ++i) {
        for(int j = 0; j < 3; ++j) {
            std::cin >> c[i][j];
        }
    }

    if(c[1][0]-c[0][0] == c[1][1]-c[0][1] && c[1][1]-c[0][1] == c[1][2]-c[0][2] && c[2][0]-c[0][0] == c[2][1]-c[0][1] && c[2][1]-c[0][1] == c[2][2]-c[0][2]) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int n; cin >> n;
	vector<int> l(n);
	for (int i = 0; i < l.size(); ++i) cin >> l[i];
	sort(all(l));
	int sum = 0;
	int max = l[l.size() - 1];
	for (int i = 0; i < l.size() - 1; ++i) sum += l[i];
	if (max < sum) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return;
}
int main() {
	solve();
	return 0;
}

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

using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0; i<10000; i++)
    {
        if((int)(i*.08)==n && (int)(i*.1)==k){
            cout<<i;
        return 0;
        }
    }
    cout<<-1;

}


Measured memory_bytes: 3592
package main

import (
	"bufio"
	"os"
	"strconv"
	"math"
	"fmt"
)

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

func nextInt() int {
	if !sc.Scan() {
		panic("failed scan int")
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	s := nextString()

	min := math.MaxInt32

	for i := 0; i < len(s)-2; i++ {
		n, _ := strconv.Atoi(s[i : i+3])
		a := abs(753 - n)
		if a < min {
			min = a
		}
	}
	fmt.Println(min)
}

func abs(n int) int {
	if n < 0 {
		n = -n
	}
	return n
}


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

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

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

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	ll n, m;
	cin >> n >> m;
	vector<pair<ll, ll>> v(n);
	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		v[i] = make_pair(a, b);
	}
	sort(v.begin(), v.end());
	ll num = 0;
	ll cost = 0;
	for (auto p : v)
	{
		if (num + p.second < m)
		{
			num += p.second;
			cost += p.first * p.second;
		}
		else
		{
			cost += p.first * (m - num);
			cout << cost << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MAXN 3030
using namespace std;
typedef long long int lli;
typedef pair<lli,lli> pll;
pll pd[MAXN][MAXN];
bool vis[MAXN][MAXN];
lli seq[MAXN];
int n;

pll solve(int i, int j, int jog){
	
	if(i == j && jog==1) return pll(seq[i],0);
	if(i==j && jog==2) return pll(0,seq[j]);
	
	if(vis[i][j]) return pd[i][j];
	
	if(jog == 1){
		pll a = solve(i+1,j,2);
		a.first += seq[i];
		pll b = solve(i,j-1,2);
		b.first += seq[j];
		vis[i][j] = 1;
		if(a.first - a.second > b.first - b.second) return pd[i][j] = a;
		else return pd[i][j] = b;
	}else{
		pll a = solve(i+1,j,1);
		a.second += seq[i];
		pll b = solve(i,j-1,1);
		b.second += seq[j];
		vis[i][j] = 1;
		if(a.first - a.second < b.first - b.second) return pd[i][j]= a;
		else return pd[i][j] = b;
	}
	
	
	
}

int main (){
	int i;
	cin >> n;
	
	for(i = 1; i <= n; i++){
		cin >> seq[i];
	}
	
	cout << solve(1,n,1).first - solve(1,n,1).second << endl;
	
	
}


Measured memory_bytes: 152064
object Main extends App {
  val src = io.Source.stdin.getLines

  def checkRTriangle(a: Int, b: Int, c: Int): String = {
    if (a*a + b*b == c*c || a*a + c*c == b*b || b*b + c*c == a*a) "YES"
    else "NO"
  }

  for (i <- 1 to src.next.toInt) {
    val Array(a, b, c) = src.next.split(" ").map(_.toInt)
    println(checkRTriangle(a, b, c))
  }
}

Measured memory_bytes: 45464
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    if(s.length() <= n){
    	cout << s << endl;
    }else{
    	s = s.substr(0, n);
    	cout << s << "..."<< endl;
    }
    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int gcd(int a, int b) {
  int r = 1;

  if (a < b) {
    int tmp = a;
    a = b;
    b = tmp;
  }

  while (r) {
    r = a % b;
    a = b;
    b = r;
  }

  return a;
}

int main(void) {
  int k;
  scanf("%d", &k);

  long long int sum = 0;
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= k; j++) {
      for (int l = 1; l <= k; l++) {
        int tmp_gcd = gcd(i, j);
        sum += gcd(tmp_gcd, l);
        // printf("%lld\n", sum);
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 1732
/* author   : mpily :-()
title : Competing.cpp
time :Sun Sep 29 14:50:44 2019

*/
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
	int N;
	cin>>N;
	if(!(N%2))cout<<setprecision(9)<<fixed<<0.50000000;
	else{
		int temp = N/2+1;
		double ans = double(temp)/double(N);
		cout<<setprecision(9)<<ans;
	}
	return 0;
}


Measured memory_bytes: 256
import javax.sound.midi.Soundbank;
import java.util.*;
import java.util.stream.IntStream;

class Exam{
    private final int index;
    private final int actual;
    private int expected;
    private int difference;

    Exam(int index,int actual){
        this.index = index;
        this.actual = actual;
    }

    public void setExpected(int expected) {
        this.expected = expected;
        this.difference = actual - expected;
    }

    public int getExpected() {
        return expected;
    }

    public int getDifference() {
        return difference;
    }

    public int getIndex() {
        return index;
    }
}

class Solver {

    private final int[] A;
    private final int[] B;
    private final int N;
    private final Exam[] E;

    Solver(Scanner in){
        N = in.nextInt();
        A = new int[N];
        E = new Exam[N];
        for (int i = 0; i < N; i++) {
            int a = in.nextInt();
            E[i] = new Exam(i, a);
            A[i] = a;
        }
        B = new int[N];
        for (int i = 0; i < N; i++) {
            int a = in.nextInt();
            E[i].setExpected(a);
            B[i] = a;
        }
    }

    void solve() {
        Arrays.sort(E, Comparator.comparingInt(Exam::getDifference));
        Deque<Exam> exams = new ArrayDeque<>(Arrays.asList(E));

        Exam lower = exams.removeFirst();
        long diff = lower.getDifference();
        if (diff >= 0) {
            System.out.println(0);
            return;
        }
        int counter = 1;
        while (!exams.isEmpty() && diff < 0) {
            Exam higher = exams.removeLast();
            int plus = higher.getDifference();
            if (plus <= 0) break;
            diff += plus;
            counter++;
            while (!exams.isEmpty() && diff > 0) {
                lower = exams.removeFirst();
                int minus = lower.getDifference();
                if (minus >= 0) break;
                diff += minus;
                counter++;
            }
        }
        if (diff < 0) System.out.println(-1);
        else System.out.println(counter);
    }
}

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

        new Solver(in).solve();

        in.close();
    }
}

Measured memory_bytes: 96936
import math
def get_prime(n):
    if n <= 1:
        return []
    prime = [2]
    if n > 2:
        limit = int(math.sqrt(n))
        odd = [i for i in range(3, n + 1, 2)]
        while limit >= odd[0]:
            prime.append(odd[0])
            odd = [j for j in odd if j % odd[0] != 0]
        prime += odd
    return prime

from collections import defaultdict
def prime_factorization(n):
    if n <= 1:
        return {}
    else:
        # print(int(math.sqrt(n)))
        prime = get_prime(int(math.sqrt(n)))
        dct = defaultdict(int)
        for p in prime:
            while n % p == 0:
                dct[p] += 1
                n //= p
        if n != 1:
            dct[n] += 1
        dct = dict(dct)
        return dct

n = int(input())
pf = prime_factorization(n)

Z = []
for k, v in pf.items():
    for i in range(1, v + 1):
        Z.append(k ** i)
Z.sort()
count = 0
for z in Z:
    if n % z == 0:
        count += 1
        n //= z


print(count)

Measured memory_bytes: 31724
#include <iostream>
#include <vector>


using namespace std;


void atcoder_beginner_contest999()
{
  string n;
  cin >> n;

  for (int i = 0; i < n.size(); ++i)
  {
    if (n[i] == '1') n[i] = '9';
    else if (n[i] == '9') n[i] = '1';
  }
  cout << n << "\n";
}


void programming_education()
{
  int n;
  cin >> n;
  
  if (n == 1)
  {
    cout << "Hello World\n";
    return;
  }
  else
  {
    int a, b;
    cin >> a >> b;
    cout << a + b << "\n";
  }
}


int main()
{
  //atcoder_beginner_contest999();
  programming_education();

}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int K, A, B; cin >> K >> A >> B;

  for (int i = A; i <= B; i++){
    if (i % K == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;

  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	int mod = 0;
	for (int i = 0; i < s.size(); i++) {
		mod += s[i] - '0';
		mod %= 9;
	}
	cout << (mod == 0 ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 3656
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
h1, m1, h2, m2, k = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

import datetime as dt
dt1 = dt.datetime.strptime(f'{h1}:{m1}', '%H:%M')
dt2 = dt.datetime.strptime(f'{h2}:{m2}', '%H:%M')
td = dt2 - dt1
print(td.seconds // 60 - k)


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

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

    long x, y;
    std::vector<std::vector<long>> students(n, std::vector<long>(2));
    for(int i = 0; i < n; ++i){
        std::cin >> x >> y;
        students.at(i).at(0) = x;
        students.at(i).at(1) = y;
    }

    std::vector<std::vector<long>> points(m, std::vector<long>(2));
    for(int i = 0; i < m; ++i){
        std::cin >> x >> y;
        points.at(i).at(0) = x;
        points.at(i).at(1) = y;
    }

    std::vector<long> distance(m);
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            distance.at(j) = abs(students.at(i).at(0) - points.at(j).at(0)) + abs(students.at(i).at(1) - points.at(j).at(1));
        }

        std::cout << std::distance(distance.begin(), std::min_element(distance.begin(), distance.end())) + 1 << std::endl;
    }

    return 0;
}


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

string s;

int fall(int index,vector<char> v){//調べる位置、呪文
    for(int i=0;i < v.size();i+=2){
        if(s.at(index)==v.at(i)){
            if(v.at(i+1)=='L'){
                index--;
                if(index<0){
                    return 1;
                }
            }
            else{
                index++; 
                if(index>=s.size()){
                    return 2;
                }
            }
        }
    }
    return false;
}//indexの位置のゴレムが左に落ちるなら1,右なら2,そうでないなら0を返す

int main(){
    //実験で相対位置関係の不変性に気が付くべきだった
    //左に落ちる境界と右に落ちる境界が分かれば解ける
    int n,q,lb,rb;
    cin >> n >> q;
    cin >> s;
    vector<char> v(2*q);
    for(int j=0;j < v.size();j++){
        cin >> v.at(j);
    }//input

    int ok = -1,ng = s.size();//条件を満たすほうをok、そうでない方をngとする
    
    while(abs(ok-ng)>1){
        int mid = (ok+ng)/2;
        
        if(fall(mid,v)==1){
            ok=mid;
        }
        else{
            ng=mid;
        }
    }
    lb = ok;

    ng = -1;
    ok = s.size();
    
    while(abs(ok-ng)>1){
        int mid = (ok+ng)/2;
        
        if(fall(mid,v)==2){
            ok=mid;
        }
        else{
            ng=mid;
        }
    }
    rb = ok;
    

    cout << s.size()-min(lb+1+s.size()-rb,s.size())<< endl;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;
#define INF 0X3f3f3f3f
#define M 1000000007
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define mp make_pair
#define pb push_back 
#define fi first
#define se second
#define endl "\n"
#define PI acos(-1)
#define fastcin ios_base::sync_with_stdio(false);
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> ii;
typedef complex<double> base;

const int N = 100002;
int n;
pair<int, ii> v[N];

int main(void){
	scanf("%d", &n);

	v[0].fi = 0;
	v[0].se.fi = 0;
	v[0].se.se = 0;

	for(int i = 1; i <= n; i++){
		scanf("%d%d%d", &v[i].fi, &v[i].se.fi, &v[i].se.se);
	}

	bool ans = 1;
	for(int i = 0; i < n; i++){
		int t = abs(v[i+1].fi - v[i].fi);
		int d = abs(v[i+1].se.fi - v[i].se.fi) + abs(v[i+1].se.se - v[i].se.se);

		if(!(t == d or (t > d and t%2 == d%2))){
			ans = 0;
			break;
		}
	}

	if(ans){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

void solve();

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

int dp[10000000+1][2];

void solve() {
  string S; cin >> S;

  reverse(S.begin(), S.end());

  dp[0][0] = S[0] - '0';
  dp[0][1] = 10 - (S[0] - '0');

  for (int i = 1; i < S.size(); i++) {
    int s = S[i] - '0';
    if (0 < s && s < 9) {
      dp[i][0] = min(dp[i-1][0] + s, dp[i-1][1] + s + 1);
      dp[i][1] = min(dp[i-1][0] + (10 - s), dp[i-1][1] + (10 - (s + 1)));
    } else if (s == 0) {
      dp[i][0] = min(dp[i-1][0], dp[i-1][1] + 1);
      dp[i][1] = dp[i-1][1] + 9;
    } else if (s == 9) {
      dp[i][0] = dp[i-1][0] + 9;
      dp[i][1] = min(dp[i-1][0] + 1, dp[i-1][1]);
    }
  }

  cout << min(dp[S.size()-1][0], dp[S.size()-1][1]+1) << endl;
}

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

int main(){
  while(1){
    int n,m,p;
    cin>>n>>m>>p;
    if(n==0&&m==0&&p==0)break;
    vector<int> a(n);
    int sum=0;
    for(int i=0;i<n;i++){
      cin>>a[i];
      sum+=a[i];
    }
    if(a[m-1]!=0){
      cout<<(sum*(100-p))/a[m-1]<<endl;
    }else{
      cout<<0<<endl;
    }
  }
  return 0;
}

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

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int ans;

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N+1, 0);
    rep(i, 1, N+1) cin >> A[i];

    rep(i, K+1, N+1) {
        if (A[i]>A[i-K]) puts("Yes");
        else puts("No");
    }


    return 0;
}



Measured memory_bytes: 4832
#include<bits/stdc++.h>
#pragma comment(linker, "/STACK:16000000")
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
const int inf=0x3f3f3f3f;
const long long inf2=0x3f3f3f3f3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
const int MX=1e6+5;
vector<int> g[(int)5e5];
int id[5555555];
int dp[5555555];
int n,m;
vector<pair<int,int> > graph[(int)5e6];
struct UF
{
	int par[MX],rank[MX];
	void init()
	{
		for(int i=0;i<MX;i++)
		{
			par[i]=i;
			rank[i]=0;
		}
	}
	void remove(int i)
	{
		par[i]=i;
		rank[i]=0;
	}
	int find(int x)
	{
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}
	void unite(int x,int y)
	{
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y])
		{
			par[x]=y;
		}
		else
		{
			par[y]=x;
			if(rank[x]==rank[y]) rank[x]++;
		}
	}
	bool same(int x,int y)
	{
		return find(x)==find(y);
	}
}uf;
void bfs(){
	queue <int> que;
	que.push(0);
	memset(dp,-1,sizeof(dp));
	dp[0]=0;
	while(!que.empty())
	{
		int v=que.front();que.pop();
		for(int i=0;i<g[v].size();i++)
		{
			int to=g[v][i];
			if(dp[to]==-1)
			{
				dp[to]=dp[v]+1;
				que.push(to);
			}
		}
	}
	if(dp[n-1]==-1) cout<<-1<<endl;
	else cout<<dp[n-1]/2<<endl;
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;c--;
		graph[c].push_back(make_pair(a,b));
	}
	int sz=n;
	for(int i=0;i<2e6;i++){
		if(!graph[i].size())continue;
		for(int j=0;j<graph[i].size();j++){
			uf.remove(graph[i][j].second);uf.remove(graph[i][j].first);
			id[graph[i][j].first]=id[graph[i][j].second]=-1;
		}
		for(int j=0;j<graph[i].size();j++)uf.unite(graph[i][j].first,graph[i][j].second);
		for(int j=0;j<graph[i].size();j++){
			pair<int,int> P=graph[i][j];
			int r=uf.find(P.first);
			if(id[r]==-1)id[r]=sz++;
			g[id[r]].push_back(P.first);
			g[P.first].push_back(id[r]);
			g[P.second].push_back(id[r]);
			g[id[r]].push_back(P.second);
		}
	}
	bfs();
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	ll cnt=0;

	for(int a=1; a<n; a++) cnt += ((n-1)/a);
	cout << cnt << endl;


	return 0;
}


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

int main(void) {

    int N;
    cin >> N;
    int buka[N] = {0};
    for (int i = 0; i < N - 1; i++) {
        int b;
        cin >> b;
        buka[(b-1)]++;
    }
    for (int i = 0; i < N; i++) {
        printf("%d\n", buka[i]);
    }
    return 0;
}

Measured memory_bytes: 4532
w,h,n = map(int,input().split())
x,y = 0,0
X,Y = w,h
for i in range(n):
    a,b,c = map(int,input().split())
    if c == 1 and x < a:
        x = a
    elif c == 2 and a < X:
        X = a
    elif c == 3 and y < b:
        y = b
    elif c == 4 and b < Y:
        Y = b
print(max(X-x,0)*max(Y-y,0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
   int N, M;
   cin >> N >> M;
   vector<int> ac(N);
   vector<int> wa(N);
   REP(i, M) {
       int p;
       cin >> p;
       p--;
       string S;
       cin >> S;
       if(S == "AC") {
           ac[p] = 1;
       } else {
           if(ac[p] == 0) wa[p]++;
       }
   }
   int acsum = 0;
   int wasum = 0;
   REP(i, N) {
       acsum += ac[i];
       if(ac[i] == 1) wasum += wa[i];
   }
   cout << acsum << " " << wasum << endl;
}

Measured memory_bytes: 1024
N = int(input())
info = []
arrive = []
for i in range(N-1):
	info.append(list(map(int,input().split(" "))))


for i in range(N-1):
	C = info[i][0]
	S = info[i][1]
	F = info[i][2]
	next_arrive = []
	for j in arrive:
		if j <= S:
			next_arrive.append(S+C)
		else:
			if j % F == 0:
				next_arrive.append(j+C)
			else:
				cnt = F * ((j // F) + 1)
				next_arrive.append(cnt+C)

	next_arrive.append(S+C)
	arrive = next_arrive[:]

arrive.append(0)

for ans in arrive:
	print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 100000007

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

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

llong gcd(llong a, llong b) {
    return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,d; cin>>n>>d;
    int ans=0;
    int x[n][d];
    REP(i,n)
    {
        REP(j,d)
        {
            cin>>x[i][j];
        }
    }
    for(int i=0; i<n-1; i++)
    {

        for(int k=i+1; k<n; k++)
        {
            llong cnt=0;
            for(int j=0; j<d; j++)
            {
                cnt+=(x[i][j]-x[k][j])*(x[i][j]-x[k][j]);
            }
            int v=(int)sqrt((double)cnt);
            if(v*v==cnt) ++ans;
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, T, preT, t, ans int
	fmt.Scan(&N, &T)
	fmt.Scan(&preT)
	for i := 1; i < N; i++ {
		fmt.Scan(&t)
		ans += min(T, t-preT)
		preT = max(t, t-preT)
	}
	ans += T
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 5504
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int k = scan.nextInt();
      	int[] a = new int[k];
      	int ans = 0;
      	for(int i = 0; i < k; i ++){
        	a[i] = scan.nextInt();
        }
      	Arrays.sort(a);
      	int b = k / 2;
      	if(a[b - 1] == a[b]){
        	ans = 0;
        }
      	else{
        	ans = a[b] - a[b-1] ;
        }
      	System.out.print(ans);
    }
 
}

Measured memory_bytes: 50628
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define loop(i,n) for(ll i=0;i<n;i++)
#define cloop(i,m,n) for(ll i=m;i<n;i++)
#define Matrix vector<vector<ll>>
#define Point pair<ll,ll>
#define Coordinates vector<Point>
ll global =0;
using namespace std;

ll gcd(ll a, ll b){
    /*
    return gcd of a,b
    */
    if(b>a)return gcd(b,a);
    if(a%b)return gcd(b,a%b);
    return b;
}
void init_matrix( Matrix& graph, ll num){
    /*
    Initialize Matrix elements with num rows 
    */
    loop(i,num) graph.push_back(vector<ll>(1,LLONG_MAX));
}
auto max_mp(map<ll,ll>&mp){
    /*
    return max element of map in form pair<key,val>
    */
    auto max_e = mp.begin();
    auto it = mp.begin();
    while(it!=mp.end()){
        if(it->second > max_e->second){
            max_e = it;
        }
        it++;
    }
    return *max_e;
}

auto min_mp(map<ll,ll>&mp){
    /*
    return min element of map in form pair<key,val>
    */
    auto min_e = mp.begin();
    auto it = mp.begin();
    while(it!=mp.end()){
        if(it->second < min_e->second){
            min_e = it;
        }
        it++;
    }
    return *min_e;
}
vector<ll> generate_prime(ll n) { 
    /*
    generate all primes number less than equal to n
    */
    vector<bool> prime(n+1,true);
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    vector<ll> pr;
    for (ll p=2; p<=n; p++) 
       if (prime[p]) 
          pr.push_back(p);
    return pr;
}



int main(){
    ll x,y,a,b,c;
    cin >> x >>y >> a >> b >> c;
    ll A[a],B[b],C[c];
    loop(i,a)cin >> A[i];
    loop(i,b)cin >> B[i];
    loop(i,c)cin >> C[i];

    sort(A,A+a);
    sort(B,B+b);
    sort(C,C+c);

    vector<ll> de;
    for(ll i=a-1;i>=a-x;i--){
        if(i >=0 )de.push_back(A[i]);
    }
    for(ll j=b-1;j>=b-y;j--){
        if( j >= 0)de.push_back(B[j]);
    }

    for(ll i =0 ;i<c;i++){
        de.push_back(C[i]);
    }

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

    ll sum =0;
    for(ll i = de.size()-1; i>=de.size()-x-y;i--){
        if(i>=0)sum += de[i];
    }
    cout << sum << endl;

    return 0;
}
	
/*
input:

*/

/*
output:

*/	


Measured memory_bytes: 8432
using System;

namespace tes
{
    class Program
    {
        public static void Main()
        {
            double s = int.Parse(Console.ReadLine());
            double temp_h = s / 3600;
            int jam = (int)temp_h;
            temp_h = temp_h - (int)temp_h;
            double temp_menit = temp_h * 60;
            int menit = (int)temp_menit;
            temp_menit = temp_menit - (int)temp_menit;
            int detik = (int)Math.Round(temp_menit * 60);

            Console.WriteLine(jam+":"+menit+":"+detik);
        }
    }
}

Measured memory_bytes: 5624
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
typedef long long ll;
using namespace std;

void solve(){
  int q; cin >> q;
  vector<bool> sosu(100001, false);
  vector<ll> v, sum(100001, 0), ans(q);
  v.push_back(2);
  sosu[2] = true;
  for(int i = 3; i <= 100000; i += 2){
    //cout << i << endl;
    int j;
    for(j = 0; j < v.size(); j++){
      if(i % v[j] == 0) break;
    }
    if(j == v.size()){
      v.push_back(i);
      sosu[i] = true;
    }
  }
  sum[1] = sum[2] = 0;
  for(int i = 3; i <= 100000; i += 2){
    sum[i] = sum[i - 2];
    if(sosu[i] == true && sosu[(i + 1) / 2] == true) sum[i]++;
  }
  for(int i = 0; i < q; i++){
    int l, r; cin >> l >> r;
    ans[i] = sum[r];
    if(l != 1) ans[i] -= sum[l - 2];
    //cout << sum[r] << " " << sum[l - 2] << endl;
  }
  for(int i = 0; i < ans.size(); i++){
    cout << ans[i] << endl;
  }
  return;
}

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


Measured memory_bytes: 2432
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n,h;
cin >> n >> h;
vector<ll> swing(n),throws(n);
for(ll i = 0; i < n; i++){
    cin >> swing[i] >> throws[i];
}
sort(swing.begin(),swing.end());
sort(throws.begin(),throws.end());
ll ans = 0;
ll criteria = swing[n - 1];
ll sum = 0;
for(ll i = n - 1; 0 <= i; i--){
    if(criteria < throws[i]){
        ans++;
        h -= throws[i];
    }
    if(h <= 0){
        cout << ans << endl;
        return 0;
    }
}
if(h % criteria)
    ans++;
ans += h / criteria;
cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
    int a[3];
    for(int i=0;i<3;i++){
        cin >>a[i];
    }
    sort(a,a+3);
    if(a[0]==5&&a[1]==5&&a[2]==7){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256