akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string i_t_s(int x){
	string t="";
	while(x){
		t+=x%10+'0';
		x/=10;
	}
	reverse(all(t));
	re t;
}
int s_t_i(string t){
	int x=0;
	rep(i,sz(t)){
		x=x*10+(t[i]-'0');
	}
	re x;
}
int s;
ll dp[2000][2001],sm[2000][2001];
int main(){
	ios::sync_with_stdio(0);
	cin>>s;
	dp[0][0]=1;
	rep(i,s+1)
	sm[0][i]=1;
	forn(i,1,(s+2)/3+1){
		forn(j,3,s+1){
			dp[i][j]=sm[i-1][j-3];
		}
		sm[i][0]=dp[i][0];
		forn(j,1,s+1){
			sm[i][j]=sm[i][j-1]+dp[i][j];
			sm[i][j]%=mod;
		}
		
	}
	ll ans=0;
	forn(i,1,2000){
		ans+=dp[i][s];
		ans%=mod;
	}
	cout<<ans;
	re 0;
}


Measured memory_bytes: 24452
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll a; cin>>a;
	cout<<2*a/gcd(2,a);
	
	return 0;
}

Measured memory_bytes: 3624
/*

                                  In the name of Allah, Most Gracious, Most Merciful


*/
#include<bits/stdc++.h>
#include<numeric>
using namespace std;

//*** constant value ***
const long double PI = 3.141592653589793238;
const double EPS = 1e-6 ;
//*** constant value ***

//****** define ********
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define dd double
#define vll vector<ll>
#define vs vector<string>
#define fn(i,n) for(ll i = 0; i<n; i++)
#define f(i,a,b) for(i=a;i<b;i++)
#define f1(i,a,b) for(i=b-1;i>=a;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define vpl vector<pll>
#define pb push_back
#define mk make_pair
#define x first
#define y second
#define tt cout<<"Came here"<<endl;
//****** define ********
void solve()
{
  ll n,m,k;
  cin>>n>>m>>k;
  cout<<k<<" "<<n<<" "<<m<<endl;

}

int main()
{
    IOS;
    ll tc = 1;
    while(tc--)
    {
        solve();
    }


return 0;
}



Measured memory_bytes: 3576
import java.util.Scanner;

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

    public static void main(String[] args) {
        String t = sc.next();
        StringBuilder sb = new StringBuilder(t);
        for (int i = 0; i < t.length(); i++){
            if (t.charAt(i) == '?'){
                sb.setCharAt(i, 'D');
            }
        }

        System.out.println(sb);
    }
}

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


using ll = long long;
int H, W, K;
char S[10][1001];
int C[11][1001];


void solve()
{
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++)
            C[i][j] = C[i][j - 1] + (S[i - 1][j - 1] - '0');
    }
    for (int j = 1; j <= W; j++) {
        for (int i = 1; i <= H; i++)
            C[i][j] += C[i - 1][j];
    }

    int ans = 1e6;
    for (int m = 0; m < (1 << (H - 1)); m++) {
        vector<int> v{0};
        int x = m, t = 0;
        while (x > 0) {
            t++;
            if (x & 1)
                v.push_back(t);
            x >>= 1;
        }
        v.push_back(H);
        int lenv = v.size() - 1;
        //cout<<"v = ";for(int z=0;z<=lenv;z++) cout<<v[z]<<" ";cout<<endl;

        int idx = 0, num = lenv - 1;
        bool ok;
        for (int j = 1; j <= W; j++) {
            ok = true;
            //printf("j = %d\n",j);
            for (int k = 0; k < lenv; k++) {
                int c1 = C[v[k]][j] - C[v[k]][idx];
                int c2 = C[v[k+1]][j] - C[v[k+1]][idx];
                int c = c2 - c1;
                //printf("%d  ", c);
                if (c > K) {
                    ok = false;
                    break;
                }
            }
            //printf("\n");
            if (!ok) {
                if (j == idx + 1) {
                    num = 1e6;
                    break;
                } else {
                    num++;
                    idx = j - 1;
                }
            }
            //printf("num = %d\n",num);
        }

        ans = min(ans, num);
        //printf("NUM=%d\n",num);
    }
    cout << ans << endl;
}


int main()
{
    scanf("%d%d%d", &H, &W, &K);
    for (int i = 0; i < H; i++)
        scanf("%s", S[i]);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long n,a,b,l,k,m,s,h,total;
    cin>>n>>a>>b;
    l=a+b;
    k=n/l;
    m=n%l;
    if(m<=a)
    {
        h=m;
    }
    else
    {
        h=a;
    }
    total=(k*a)+h;
    cout<<total<<endl;
    return 0;
}

Measured memory_bytes: 3644
T1,T2 = list(map(int,input().split()))
A1,A2 = list(map(int,input().split()))
B1,B2 = list(map(int,input().split()))

a1 = A1*T1
a2 = A2*T2
b1 = B1*T1
b2 = B2*T2

if a1+a2 < b1+b2:
  a1,b1 = b1,a1
  a2,b2 = b2,a2
#print(a1,a2,b1,b2)

if a1+a2 == b1+b2:
  print('infinity')
else:
  if a1 > b1:
    print(0)
  else:
    c = (b1-a1)/((a1+a2)-(b1+b2))
    print(int(c)*2 if c.is_integer() else int(c)*2+1)


Measured memory_bytes: 38384
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

string decode(string s, int v) {
    string ans = s;
    for(int i = 0; i < (int) s.size(); i++) {
        if(s[i] >= 'a' && s[i] <= 'z') {
            ans[i] = (s[i] + v) % 26 + 'a';
        }
    }
    return ans;
}

int main() {
    string s;
    while(getline(cin, s)) {
        for(int i = 0; 26; i++) {
            string tmp = decode(s, i);
            if(tmp.find("this") != string::npos || tmp.find("the") != string::npos || tmp.find("that") != string::npos) {
                cout << tmp << endl;
                break;
            }
         }
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 using namespace std;    
 int main()
{
    long long int n,k,i,j,p,a,c=0,nu;
    cin >> n >> k;
    long long int arr[n],vis[n];
    for(i=0;i<n;i++)
    {
        cin >> a;
        arr[i]=a-1;
        vis[i]=-1;
    }
    if(k<=n)
    {
        i=0;
        for(j=1;j<=k;j++)
            i=arr[i];
        cout << i+1;
    }
    else
    {
    vis[0]=0;
    i=0;
    while(1)
    {
        i=arr[i];
        c++;
        if(vis[i]!=-1)
        {
            nu=c-vis[i];
            break;
        }
        else
        {
            vis[i]=c;
        }
    }
    p=(k-c)%nu;
    for(j=1;j<=p;j++)
        i=arr[i];
    cout << i+1;
    }

}


Measured memory_bytes: 6764
//Robs Code

/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

/***********MACROS***************/
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>

using namespace std;

const int N = 1e5 + 1;
int n,m,i,j,k,l,x,y,z,cnt[3],sum[3];

/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	long double l;
	cin>>l;
	long double ans = (l/3.0)*(l/3.0)*(l/3.0);
	cout<<fixed<<setprecision(6)<<ans<<"\n";
}
//.........

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import collections
n = int(input())
a = [int(i) for i in input().split()]

count = 0
c = collections.Counter(a)
for i in set(a):
    if c[i] > 1:
        count += c[i] - 1
if count % 2 == 0:
    print(n - count)
else:
    print(n - count - 1)


Measured memory_bytes: 21084
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>

using namespace std;


int main() {

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

    vector<int> vs(N);

    for (int i = 0; i < K; ++i) {
        int d;
        cin >> d;
        for (int j = 0; j < d; ++j) {
            int A;
            cin >> A;
            vs[A - 1] += 1;
        }
    }

    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        if (vs[i] == 0) {
            cnt += 1;
        }
    }

    cout << cnt << endl;

    return 0;

}

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

int main(){
    int n,z,w;
    cin >> n >> z >> w;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    if(n==1) cout << abs(a[0] -w) << endl;
    else cout << max(abs(a[n-1] -w), abs(a[n-1] -a[n-2])) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <regex>
#include <stack>
#include <queue>
#include <vector>
#define MAX_N 100
#define INF 10000000

using namespace std;

string n,m;
int a[200000];

void solve() {
	int x=0, y=0;
	for (int i = 0; i < 4; i++) {
		if (n[i] == '+') x++;
		else y++;
	}
	cout << x - y << endl;
}

int main() {
	cin >> n ;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int a[10000];
	int n;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	int counter = 0;
	for (int i = 0; i < n; i++) {
		while ((a[i] & 1) == 0) {
			counter++;
			a[i] = a[i] >> 1;
		}
	}

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

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() -> () {
    input!{
        n: usize,
        t: u32,
        cts: [(u32, u32); n]
    }
    let mut cm = std::u32::MAX;
    for ct in cts {
        if ct.1 <= t {
            cm = std::cmp::min(cm, ct.0)
        }
    }
    if cm == std::u32::MAX {
        println!("TLE");
    } else {
        println!("{}", cm);
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int
selection_sort(int *A, int N)
{
    int i, j, minj, tmp;
    int cnt = 0;

    for (i = 0; i < N; i++) {
        minj = i;
        for (j = i + 1; j < N; j++) {
            if (A[j] < A[minj])
                minj = j;
        }
        if (A[i] != A[minj]) {
            tmp = A[i];
            A[i] = A[minj];
            A[minj] = tmp;
            cnt++;
        }
    }
    return cnt;
}

void
print_array(int *a, int n)
{
    int i;

    for (i = 0; i < n; i++) {
        printf("%d", a[i]);
        if (i != (n - 1))
            printf(" ");
    }
    printf("\n");
}

int
main()
{
    int N, i, cnt;
    int A[100];

    scanf("%d", &N);

    for (i = 0; i < N; i++)
        scanf("%d", &A[i]);

    cnt = selection_sort(A, N);
    print_array(A, N);
    printf("%d\n", cnt);
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int a,b,c,d,e,k;
	cin >>a >>b>>c>>d>>e>>k;
	cout << (e-a<=k ? "Yay!":":(");
}

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

#define range(i, n) for (i = 0; i < n; i++) 
#define rrange(i, n) for(i = n-1; i>=0; i--)

typedef long long int ll;


using namespace std;

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


int main() {
	int i, k, l;

	int A, B, C;

	cin >> A >> B >> C;


	if (B / A <= C) {
		cout << dec << B / A;
	}
	else {
		cout << dec << C;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define lli long long int
#define all(x) x.begin(),x.end()
#define siz(x) x.size()
#define prs(x,y) x.find(y)!=x.end()
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
inline int level(int n){int ans=0;while(n%2==0){n/=2;ans++;}return ans;}
lli a[200005], b[200005];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	sort(a,a+n);
	sort(b,b+n);
	lli ans=0;
	if(n%2==1)
	{
		lli low=a[(n+1)/2-1];
	lli hi=b[(n+1)/2-1];
		ans=1+hi-low;
	}	
	if(n%2==0)
	{
	    lli low=a[n/2]+a[n/2-1];
		lli hi=b[n/2]+b[n/2-1];
		ans=1+hi-low;
	}
	cout<<ans;
}



Measured memory_bytes: 6752
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int N = s.size();
    string s1=s.substr(0,(N-1)/2),s2=s.substr((N+1)/2);
    if(s1==s2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    string S;
    cin >> S;
    ll K;
    cin >> K;

    for (ll i = 0; i < min(K, (ll)S.size()); i++) {
        if (S[i] != '1') {
            cout << S[i] << endl;
            return 0;
        }
    }

    cout << 1 << endl;
}

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

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = in.nextInt();
        }

        int min = Integer.MAX_VALUE;

        for(int i=-100; i<=100; i++) {
            int sum = 0;
            for(int j=0; j<n; j++) {
                sum += (a[j] - i) * (a[j] - i);
            }
            min = Math.min(min, sum);
        }

        System.out.println(min);

        in.close();
    }
}


Measured memory_bytes: 9556
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if(C<=A+B) System.out.println("Yes");
        else System.out.println("No");
    }
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
		int a;
	string s;
	cin >> a >> s;
	if (a>=3200) {
		ce(s)
	}
	else {
		ce("red")
	}
    return 0;
}



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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

int main() {
    ll n, k;
    cin >> n >> k;

    // 2a = 2b = 2c = 0 (mod k)
    // (0) a = b = c = 0 mod k
    // (1) a = b = c = k/2 mod k

    ll x = n / k;
    ll ans = x * x * x; // (0)
    if (!(k & 1) && k / 2 <= n) {
        ll y = (n - k / 2) / k + 1;
        ans += y * y * y; // (0)+(1)
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        int tmpNum;
        ArrayList<Integer> list=new ArrayList<Integer>();
        
        for(int i=0; i<n; i++){
            switch(scan.nextInt()){
                case 0:
                    list.add(scan.nextInt());
                    break;
                case 1:
                    System.out.println(list.get(scan.nextInt()));
                    
                    break;
                case 2:
                    list.remove(list.size()-1);
                    break;
            }
            //System.out.println(list);
        }
    }
}


Measured memory_bytes: 140792
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::cmp::Ordering;

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

use std::collections::BinaryHeap;
use std::cmp;

fn main() {
    let n = get!(usize);
    let aa = get!(String).split_whitespace().map(|i| i.parse::<i64>().unwrap()).collect::<Vec<_>>();

    let mut sa = vec![0; n*3];
    let mut sh = BinaryHeap::new();
    let mut a: i64 = 0;
    for i in 0..n {
        a += aa[i];
        sh.push(Rev(aa[i]));
        sa[i] = a;
    }
    for ii in 0..n {
        let i = n + ii;
        a += aa[i];
        sh.push(Rev(aa[i]));
        if let Some(Rev(b)) = sh.pop() {
            a -= b;
        }
        sa[i] = a;
    }
    let mut ea = vec![0; n*3];
    let mut eh = BinaryHeap::new();
    a = 0;
    for ii in 0..n {
        let i = n*3 - ii - 1;
        a += aa[i];
        eh.push(aa[i]);
        ea[i] = a;
    }
    for ii in 0..n {
        let i = n*2 - ii - 1;
        a += aa[i];
        eh.push(aa[i]);
        if let Some(b) = eh.pop() {
            a -= b;
        }
        ea[i] = a;
    }

    let mut r = i64::min_value();
    for i in n-1..n*2 {
        r = cmp::max(r, sa[i] - ea[i+1]);
    }
    println!("{}", r);
}

Measured memory_bytes: 18292
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

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

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll n;
    cin >> n;
    map<ll,ll> cnt;
    vector<ll> a(n+1);
    rep0(i,n-1) cin >> a[i];    
    vector<ll> sum(n+1, 0);
    rep0(i,n-1) sum[i+1] = sum[i] + a[i];
    rep0(i,n) cnt[sum[i]]++;

    ll combination_num = 0;
    for(auto it: cnt){
        ll num = it.second;
        combination_num += num*(num-1)/2;
    }
    cout << combination_num << endl;
    return 0;
}

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

using namespace std;

const int P = 1000000007;

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

	int n;
	cin >> n;

	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	long long ans = 0;
	long long sum = 0;
	for(int i = 0; i < n; ++i) {
		ans = (ans + sum * a[i]) % P;
		sum = (sum + a[i]) % P;
	}

	cout << ans << '\n';

	return 0;
}


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

using namespace std;

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

template<typename T> struct edge {
  int from,to;
  T cost;

  edge(int from_,int to_,T cost_) : from(from_),to(to_),cost(cost_){};
};

template<typename T,template <typename ELEM> class C> struct Bellman_Ford {
  vector<C<T>> edges;
  int V;//0,...,|V|-1
  T INF;

  Bellman_Ford (int V_,T INF_ = 1e9) {
    init(V_,INF_);
  }

  void init(int V_,T INF_ = 1e9) {
    V = V_;
    INF = INF_;

    edges.clear();
  }

  void add_edge(int from,int to,T cost) {
    //edges.push_back(from,to,cost);
    edges.push_back(C<T>(from,to,cost));
  }

  bool shortest_path(int s,T *d) {
    fill(d,d+V,INF);
    d[s] = 0;

    int E = edges.size();

    rep(i,V) {
      bool update = false;
      rep(j,E) {
        auto e = edges[j];
        if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
          d[e.to] = d[e.from] + e.cost;
          update = true;
        }
      }
      if( !update) break;
      if(update && i == V - 1) {
        return false;;
      }
    }
    return true;
  }

};

using ll = long long;
ll d[1010];

int main() {
  ll V,E,r;
  cin >> V >> E >> r;
  Bellman_Ford<ll,edge> bf(V);
  rep(i,E) {
    ll s,t,dd;
    cin >> s >> t >> dd;
    bf.add_edge(s,t,dd);
  }

  if(bf.shortest_path(r,d)) {
    rep(i,V) {
      if(d[i] < 1e9)
        cout << d[i] << endl;
      else 
        cout << "INF" << endl;
    }
  }else {
    cout << "NEGATIVE CYCLE" << endl;
  }

  return 0;
}



Measured memory_bytes: 3140
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define INF 1000000007
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main(){
    int n,m;
    cin>>n>>m;
    vector<ll> w(n);
    vector<ll> v(n);
    for(int i=0;i<n;i++)cin>>w[i]>>v[i];
    vector<vector<ll>> dp(n+1,vector<ll>(m+1,0));
    for(int i=n-1;i>=0;i--){
        for(int j=0;j<=m;j++){
            if(w[i]>j)dp[i][j]=dp[i+1][j];
            else dp[i][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
        }
    }
    cout<<dp[0][m]<<endl;
    return 0;
}


Measured memory_bytes: 80256
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
struct Trie {
	int cnt;
	Trie* ptr[29];
	Trie() { cnt = 0; fill(ptr, ptr + 27, (Trie*)0); }
};
Trie* root = new Trie;
void add(string str) {
	Trie* pos = root; pos->cnt++;
	for (int i = 0; i < str.size(); i++) {
		if (!pos->ptr[str[i] - 96]) pos->ptr[str[i] - 96] = new Trie;
		pos = pos->ptr[str[i] - 96];
		pos->cnt++;
	}
}
int N, Q, x, val[100009][29][29]; string s[100009], t;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s[i]; s[i] += '`';
		add(s[i]);
	}
	for (int i = 0; i < N; i++) {
		Trie* pos = root;
		for (int j = 0; j < s[i].size(); j++) {
			for (int k = 0; k < 27; k++) {
				if (pos->ptr[k]) val[i][s[i][j] - 96][k] += pos->ptr[k]->cnt;
			}
			pos = pos->ptr[s[i][j] - 96];
		}
	}
	cin >> Q;
	while (Q--) {
		cin >> x >> t; x--;
		t = '`' + t;
		int ret = N;
		for (int i = 0; i < 27; i++) {
			for (int j = i + 1; j < 27; j++) {
				ret -= val[x][t[i] - 96][t[j] - 96];
			}
		}
		cout << ret << "\n";
	}
	return 0;
}

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

using namespace std;

int main() {

	int n;
	cin >> n;

	int nn = int(n / 4) + 1;
	for (int i = nn; i >= 0; i--) {
		if (i * 4 == n) { cout << "Yes" << endl; return 0; }
		else if ((n-i*4)%7==0) { cout << "Yes" << endl; return 0; }
	}
	cout << "No" << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      //数字の数を入力
		String n = sc.next();
	//n
      int len = n.length();
      switch(n.charAt(len -1 )){
          case '2':
            case '4':
              case '5':
                case '7':
                  case '9':
                    System.out.println("hon");break;
                    case '0':
                      case '1':
                        case '6':
                          case '8':
                            System.out.println("pon");break;
                            case '3':
                              System.out.println("bon");break;
                              
                            
      }
      
	}

}


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

 
int main(){
    int N;
    int K;
    int x[110];
  
    cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> x[i];

    int ans = 0;

    for (int i = 0; i < N; ++i) {
        if ((x[i] - 0) > (K - x[i])){
            ans = ans + (K - x[i])*2;
        }
        else{
            ans = ans + (x[i] - 0)*2;
        }
    }

    cout << ans << endl;
    
   
}

Measured memory_bytes: 256
# bit全探索
# d = 4
# for mask in range(1 << d):  # 2のd乗になる
#     print("mask =", mask)
#     for i in range(d):
#         print("(mask >>", i, ") & 1 = ", (mask >> i) & 1)
#         # 1のビットが立つかどうかでT/F判断した方が個人的に分かりやすいから(mask >> i) & 1と書いている


# まずスイッチの状態を全て表す
N, M = map(int, input().split())  # N個スイッチとM個の電球

connect_infos = []
# それぞれの電球が繋がっているスイッチの情報が与えられる
for i in range(M):
    k, *S = list(map(lambda x: int(x)-1, input().split()))
    connect_infos.append(S)

# print(connect_info)
# 電球が灯されるかの判断材料
P = list(map(int, input().split()))
# print(P)


switches_status = [[] for _ in range(1 << N)]
# print(switches_status)
for mask in range((1 << N)):  # 2のd乗になる
    for i in range(N):
        switches_status[mask].append((mask >> i) & 1)

# print(switches_status)

ans = 0
# 全てのスイッチの状態ついてループを回す
for status in switches_status:
    shine = 0
    # statusは1次元リスト
    for i, connect_info in enumerate(connect_infos):
        # connect_infoにはそれぞれの電球がどのスイッチに接続されているかの情報がある
        on_count = 0
        for j in connect_info:
            on_count += status[j]
        # 接続しているスイッチのon状態を個数を獲得できた
        if on_count % 2 == P[i]:
            shine += 1
    if shine == M:  # 光っている電球の数 と 電球の個数Mが等しいならansをインクリメントする
        ans += 1

print(ans)


Measured memory_bytes: 3188
A, B, C = input().split()
if A == B:
  if B != C:
    print("Yes")
  else:
    print("No")
  exit()

if B == C:
  if A != B:
    print("Yes")
  else:
    print("No")
  exit()

if C == A:
  if A != B:
    print("Yes")
  else:
    print("No")
  exit()
print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end(), greater<int>());
    vector<int> score(2, 0);
    for(int i = 0; i < a.size(); i++) {
        int si = i % 2;
        score.at(si) += a.at(i);
    }
    cout << (score.at(0) - score.at(1)) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define absl(v) labs((v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp;
  ll a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld",&n);
  rep(i,5){
    scanf("%lld",&a[i]);
    if(i==0) tmp=a[i];
    else tmp=min(tmp,a[i]);
  }
  result = (ll)ceill((ld)n/tmp)+4;
  printf("%lld", result);
  
  return 0;
}

Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {
			String x = scan.next();

			if ( x.equals("0") ) {break;}

			char[] xx = x.toCharArray();
			int l = xx.length;
			int sum = 0;
			for (int i = 0; i < l; i++) {
				sum += Character.getNumericValue(xx[i]);
			}
			sb.append(sum + "\n");
		}
		System.out.print(sb);
	}

}

Measured memory_bytes: 26416
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;

void solve() {
	double t1, t2;
	cin >> t1 >> t2;
	double res = (t2 - t1) / 2.0;
	double ret = res;
	if (abs(res + 180) < abs(ret)) ret = res+180;
	if (abs(res - 180) < abs(ret)) ret = res - 180;
	ret += t1;
	if (ret >= 360)ret -= 360;
	if (ret < 0)ret += 360;
	cout << ret << endl;
}

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


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

int main() {
  int N;
  cin >> N;
  vector<int>T(N);
  for(int i=0; i<N; i++)cin >> T.at(i);
  int M;
  cin >> M;
  vector<vector<int>>PX(M, vector<int>(2));
  for(int i=0; i<M; i++)cin >> PX.at(i).at(0) >> PX.at(i).at(1);
  
  int goukei=0;
  for(int i=0; i<N; i++)goukei += T.at(i);
  
  for(int i=0; i<M; i++){
    cout << goukei -T.at(PX.at(i).at(0)-1) + PX.at(i).at(1) << endl;
  }
  
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
#include <stack>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF INT_MAX>>1 //要climits#includ
#define SIZE 100001;
#define MOD 1000000007

typedef long long ll;

using namespace std;

int main(void){
	int n; cin >> n;
	int a[100];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}

	int ans = 0;
	for(int i=1; i<n-1; i++){
		int ma = max(a[i-1], max(a[i], a[i+1]));
		int mi = min(a[i-1], min(a[i], a[i+1]));
		if(a[i] != ma && a[i] != mi) ans++;
	}
	
	cout << ans << endl;
}






/*
int main(void){
	string str;
	cin >> str;
	char ch1=NULL, ch2=NULL;
	for(int i=0; i<str.length(); i++){
		if(str[i] != ch1){
			if(ch1 == NULL){
				ch1 = str[i];
			}else if(str[i] != ch2){
				if(ch2 != NULL){
					cout << "No" << endl;
					return 0;
				} else ch2 = str[i];
			}
		}
	}
	if(ch2 == NULL) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}
*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include<cassert>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

/////////////////////////////////////


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

	ll N;
	cin >> N;
	vll A(N + 1);
	repn(i, N)cin >> A[i];

	ll M = 1000000;
	vll cnt(M + 1, 0);
	repn(i, N)cnt[A[i]]++;

	ll mx = 0;

	repn(i, M) {
		if (i == 1) { continue; }

		ll c = 0;
		for (ll j = i; j <= M; j += i) {
			c += cnt[j];
		}
		mx = max(c, mx);
	}

	if (mx <= 1) { cout << "pairwise coprime" << endl; }
	else if (mx < N) { cout << "setwise coprime" << endl; }
	else { cout << "not coprime" << endl; }
}


Measured memory_bytes: 18772
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <functional>
#define pb push_back
#define fi first
#define sec second
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;

int main(){
	int n, m, a;
	while(scanf("%d%d%d", &n, &m, &a),n||m||a){
		vector<PP> v;
		for(int i = 0; i < m; i++){
			int h,p,q;
			scanf("%d%d%d", &h, &p, &q);
			v.pb(PP(h,P(p,q)));
		}
		sort(v.begin(),v.end(),greater<PP>());
		for(int i = 0; i < m; i++){
			if(a == v[i].sec.fi) a = v[i].sec.sec;
			else if(a == v[i].sec.sec) a = v[i].sec.fi;
		}
		printf("%d\n", a);
	}
}

Measured memory_bytes: 1060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	int n,h,w;
	cin>>n>>h>>w;
	vector<int> x(n);
	for(int i=0;i<n;i++)cin>>x[i];
	vector<bool> used(w*n,false);
	for(int i=0;i<n;i++){
		if(i%2==0){
			for(int j = w*i+x[i];j<w*i+x[i]+w;j++){
				used[j] = true;
			}
		}else{
			for(int j = w*i-x[i];j<w*i-x[i]+w;j++){
				used[j] = true;
			}
		}
	}
	int cnt = 0;
	for(int i=0;i<w*n;i++)if(!used[i])cnt++;
	cout<<cnt*h<<endl;


	return 0;
}



Measured memory_bytes: 3108
#include <stdio.h>
int main(){
  int a[3],f=0,n,i,j;
  scanf("%d",&n);
  for(j=0;j<n;j++){
    for(i=0;i<3;i++)scanf("%d",&a[i]);
    for(i=0;i<3;i++){
      if(a[i%3]*a[i%3]+a[(i+1)%3]*a[(i+1)%3]==a[(i+2)%3]*a[(i+2)%3])f=1;
    }
    if(f==0)printf("NO\n");
    else printf("YES\n");
    f=0;
  }
  return 0;
}

Measured memory_bytes: 580
N, K = map(int, raw_input().split())
ps = []
for i in xrange(N):
  ps.append(map(int, raw_input().split()))

xsorted = zip(*sorted(ps, key=lambda p: p[0]))[0]
ysorted = zip(*sorted(ps, key=lambda p: p[1]))[1]

ans = float('inf')
for i in xrange(N):
  bottom = ysorted[i]
  for j in xrange(i+K-1, N):
    top = ysorted[j]
    for k in xrange(N):
      if k+K-1 >= N:
        break
      right = xsorted[k]
      # 2 bun tansaku
      f, t = k+K-1, N
      sol = None
      while True:
        mid = (f+t)//2
        left = xsorted[mid]
        c = 0
        for p in ps:
          if right <= p[0] <= left and bottom <= p[1] <= top:
            c += 1
            if c >= K: break
        else:
          if f+1 >= t:
            break
          f = mid
          continue
        sol = mid
        if f+1 >= t:
          break
        t = mid
      if sol:
        area = (xsorted[sol] - right) * (top - bottom)
        if area < ans:
          ans = area

print ans

Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    int x, n;
    cin >> x >> n;
    set<int> st;
    rep(i, n){
        int num;
        cin >> num;
        st.insert(num);
    }
    int smallest = 10000;
    int index;
    for(int i=-10; i<=110; i++){
        if(st.find(i) == st.end()){
            if(abs(i-x) < smallest){
                smallest = abs(i-x);
                index = i;
            }
        }
    }
    cout << index << endl;
    return 0;
}

Measured memory_bytes: 3632
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-4-21 20:42:39
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

ll A, B, C, X, Y;

int main()
{
  cin >> A >> B >> C >> X >> Y;
  if (A + B <= 2 * C) {
    cout << A * X + B * Y << endl;
    return 0;
  }
  ll Z = 2 * min(X, Y);
  X -= Z/2;
  Y -= Z/2;
  if (A > 2 * C) {
    Z += 2 * X;
    X = 0;
  }
  if (B > 2 * C) {
    Z += 2 * Y;
    Y = 0;
  }
  cout << A * X + B * Y + C * Z << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            int n = Integer.parseInt(in.readLine());
            int[] A = Arrays.stream(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();

            for (int i = 0; i < n; i++) {
                int v = A[i];
                int j = i - 1;
                while (j >= 0 && A[j] > v) {
                    A[j + 1] = A[j];
                    j--;
                }
                A[j + 1] = v;
                System.out.println(Arrays.stream(A).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 32448
let n = int64(stdin.ReadLine())
let a = stdin.ReadLine().Split() |> Array.map(int64)

let inf = 1_000_000_000_000_000_000L
let sorted = Array.sort(a) // benchmarking

let res =
    Array.fold (
        fun accum x ->
            if x = 0L then
                0L
            else if accum <= inf / x && accum >= 0L then
                accum * x
            else 
                -1L
        )
        1L
        a
 
printfn "%i" res


Measured memory_bytes: 43984
n, d   = gets.split.map(&:to_i) # n個の点、d次元空間
points = [] # 点の配列
n.times { points << gets.split.map(&:to_i) }
ans = 0 # 答え
(0 .. n - 1).each do |i| # i番目の点
  (0 .. n - 1).each do |j| # j番目の点
    next if i >= j # 同じ点を除く
    sq = 0 # 自乗の合計
    (0 .. d - 1).each do |k| # k番目の次元
      s  = (points[i][k] - points[j][k]) #対応する座標の差
      sq += s * s # 差の自乗を合計 
    end
    s   = Math.sqrt(sq) + 0.5 # 自乗の合計の平方根を整数化
    ans += 1 if s.to_i ** 2 == sq # 整数化の自乗が差の合計になればok
  end
end
p ans



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

#define MAX 102
int n;
vector<int> A;

struct MaximumFlow {
	typedef int Index;
	typedef long long int Flow;
	static const Flow InfCapacity = LLONG_MAX;
	struct Edge {
		Index to;
		Flow capacity;
		Index rev;
	};
	vector<vector<Edge> > g;
	void init(Index n) { g.assign(n, vector<Edge>()); }
	void add(Index i, Index j, Flow capacity) {
		Edge e, f; e.to = j, f.to = i; e.capacity = capacity, f.capacity = 0;
		g[i].push_back(e); g[j].push_back(f);
		g[i].back().rev = (Index)g[j].size() - 1; g[j].back().rev = (Index)g[i].size() - 1;
	}
	void addB(Index i, Index j, Flow capacity) {  //双方向
		Edge e, f; e.to = j, f.to = i; e.capacity = capacity, f.capacity = capacity;
		g[i].push_back(e); g[j].push_back(f);
		g[i].back().rev = (Index)g[j].size() - 1; g[j].back().rev = (Index)g[i].size() - 1;
	}
	//gを破壊する
	Flow maximumFlow(int s, int t) {
		int n = g.size();
		vector<Index> level(n);
		Flow total = 0; bool update;
		do {
			update = false;
			fill(level.begin(), level.end(), -1); level[s] = 0;
			queue<Index> q; q.push(s);
			for (Index d = n; !q.empty() && level[q.front()] < d;) {
				int u = q.front(); q.pop();
				if (u == t) d = level[u];
				for (auto e = g[u].begin(); e != g[u].end(); e++) if (e->capacity > 0 && level[e->to] == -1)
					q.push(e->to), level[e->to] = level[u] + 1;
			}
			vector<Index> iter(n);
			for (Index i = 0; i < n; i++) iter[i] = (int)g[i].size() - 1;
			while (1) {
				Flow f = augment(level, iter, s, t, InfCapacity);
				if (f == 0) break;
				total += f; update = true;
			}
		} while (update);
		return total;
	}
	Flow augment(vector<Index> &level, vector<Index> &iter, Index u, Index t, Flow f) {
		if (u == t || f == 0) return f;
		Index lv = level[u];
		if (lv == -1) return 0;
		level[u] = -1;
		for (; iter[u] >= 0; --iter[u]) {
			Edge &e = g[u][iter[u]];
			if (level[e.to] <= lv) continue;
			Flow l = augment(level, iter, e.to, t, min(f, e.capacity));
			if (l == 0) continue;
			e.capacity -= l; g[e.to][e.rev].capacity += l;
			level[u] = lv;
			return l;
		}
		return 0;
	}
};

int main() {
	cin >> n;
	vector<int> pos;
	vector<int> neg;
	long long int sum = 0;
	A.push_back(0);
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		A.push_back(a);
		sum += max(0, a);
		if (a < 0) {
			neg.push_back(i+1);
		}
		else {
			pos.push_back(i+1);
		}
	}
	MaximumFlow mf;
	mf.init(pos.size() + neg.size() + 2);
	int star = pos.size() + neg.size();
	int en = star + 1;
	for (int i = 0; i < neg.size(); i++) {
		for (int j = 0; j < pos.size(); j++) {
			if (pos[j] % neg[i] == 0) {
				mf.add(i, neg.size() + j, sum + 2LL);
			}
			if (i == 0) {
				mf.add(neg.size()+j, en, A[pos[j]]);
			}
		}
		mf.add(star, i, -A[neg[i]]);
	}
	long long int u = mf.maximumFlow(star, en);
	sum -= u;
	printf("%lld\n", sum);
	return 0;
}

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

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
//int choose2(ll x){
	//	return x*(x-1)/2;}
const int INF = 1001001001;

int main() {
	int N,M;
		cin >> N>>M;
		vector<int> A(M);
		int tmp = 0;
		rep(i, M) {
			cin >> A[i];
			tmp += A[i];
		}
		if (tmp > N)cout << "-1";
		else cout << N - tmp;
		
	
}

Measured memory_bytes: 3668
package main

import "fmt"

var S string

func main() {
	fmt.Scanf("%s", &S)

	s := []rune(S)

	ans := 700
	for i := 0; i < len(s); i++ {
		if s[i] == 'o' {
			ans += 100
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512