akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
int data[1000010],n;
long long ans;
vector <int> G;
int main()
{
	cin >> n;
	for(int i = 1; i <= n; ++i)
		scanf("%d",&data[i]);
	for(int h = 1; ;)
	{
		if(h > n)
			break;
		G.push_back(h);
		h = h*3+1;
	}
	for(int i = G.size()-1; i >= 0; --i)
	{
		for(int j = G[i]+1; j <= n; ++j)
		{
			int v = data[j];
			int k = j-G[i];
			while((k > 0) && (data[k] > v))
			{
				data[k+G[i]] = data[k];
				k -= G[i];
				++ans;
			}
			data[k+G[i]] = v;
		}
	}
	cout << G.size() << endl << G[G.size()-1];
	for(int i = G.size()-2; i >= 0; --i)
		printf(" %d",G[i]);
	cout << endl << ans << endl;
	for(int i = 1; i <= n; ++i)
		printf("%d\n",data[i]);
	return 0;
}


Measured memory_bytes: 7132
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define debug(x)			{ cerr << #x << " = " << x << endl; }
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define vi					vector<int>
#define vii					vector<vi>
#define max(x,y)			(x>y)?x:y
#define min(x,y)			(x<y)?x:y
#define mid(s,e)			(s+(e-s)/2)

using namespace std;

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	ll a,b,k;
	cin>>a>>b>>k;
	ll T = a, A = b;
	if(T>k) {
		T-=k;
	}else {
		k -= T;
		T = 0;
		if(A>k) {
			A -= k;
		}else {
			A = 0;
		}
	}
	cout<<T<<" "<<A<<endl;

	return 0;
}



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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << max(b+c-a, 0) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

int main()
{
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  int sum = a1+a2+a3;
  
  cout << (sum>=22 ? "bust" : "win") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll A,B,C;
  cin>>A>>B>>C;
  cout<<C<<" "<<A<<" "<<B;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

int main(){    
  long long N,count=0;
  cin >> N;
  long long P[N];
  long long D,minn=100000000;
  for(int i=0;i<N;i++){
    cin >> D;
    P[i] = D;
    minn = min(minn,P[i]);
    if(minn >= P[i]){
      count++;
    }
  }
  cout << count << endl;
  
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		sc.nextLine();

		String[] xstr = sc.nextLine().split(" ");
		String[] ystr = sc.nextLine().split(" ");

		double[] x = new double[n];
		double[] y = new double[n];
		for (int i=0; i < n; i++) {
			x[i] = Double.parseDouble(xstr[i]);
			y[i] = Double.parseDouble(ystr[i]);
		}

		double d1 = 0;
		double d2 = 0;
		double d3 = 0;
		double dinfi = 0;

		for (int i=0; i < n; i++) {
			double xy = Math.abs( x[i] - y[i] );

			d1 += xy;

			d2 += xy * xy;

			d3 += xy * xy * xy;

			if (xy > dinfi) dinfi = xy;
		}

		d2 = Math.sqrt(d2);
		d3 = Math.cbrt(d3);

		System.out.printf("%.6f\n", d1);
		System.out.printf("%.6f\n", d2);
		System.out.printf("%.6f\n", d3);
		System.out.printf("%.6f\n", dinfi);
	}

}

Measured memory_bytes: 26556
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N = I()
C = Line(N,1)

last = defaultdict(lambda:-1)

dp = [0]*N
dp[0] = 1
last[C[0]] = 0

for i in range(1,N):
    if C[i]==C[i-1]:
        dp[i] = dp[i-1]
    else:
        if last[C[i]]>=0:
            dp[i] = (dp[i-1] + dp[last[C[i]]])%mod
        else:
            dp[i] = dp[i-1]
    last[C[i]] = i

print(dp[-1])

Measured memory_bytes: 74588
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort()
p.reverse()
q.sort()
q.reverse()
r.sort()
r.reverse()
xp,yq = p[:X],q[:Y]
xp.extend(yq)
xp.extend(r)
xp.sort()
xp.reverse()
print(sum(xp[:(X+Y)]))

Measured memory_bytes: 22720
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>

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

using namespace std;

int N;
long long int C;
long long int x[100001];
long long int v[100001];

int main()
{
    scanf("%d %lld", &N, &C);
    REP(i, N)
        scanf("%lld %lld", &x[i], &v[i]);
    
    // OB, BO, OA

    // OAの最大値を求める
    long long int cost_OA[100001];
    cost_OA[0] = v[0] - x[0];
    FOR(i, 0, N-1)
        cost_OA[i+1] = cost_OA[i] + v[i+1] - (x[i+1] - x[i]);

    long long int max_OA[100001];
    max_OA[0] = cost_OA[0];
    REP(i, N-1)
        max_OA[i+1] = max(max_OA[i], cost_OA[i+1]);

    long long int cost_OB[100001];
    cost_OB[N-1] = v[N-1] - (C-x[N-1]);
    for (int i=N-1; i>0; i--)
        cost_OB[i-1] = cost_OB[i] + v[i-1] - (x[i] - x[i-1]);

    long long int max_OB[100001];
    max_OB[N-1] = cost_OB[N-1];
    for (int i=N-1; i>0; i--)
        max_OB[i-1] = max(max_OB[i], cost_OB[i-1]);

    long long int ans_BA = max(cost_OB[0], max_OB[0]);
    FOR(i, 1, N)
        ans_BA = max(ans_BA, cost_OB[i]-(C-x[i])+max_OA[i-1]);

    long long int ans_AB = max(cost_OA[N-1], max_OA[N-1]);
    REP(i, N-1)
        ans_AB = max(ans_AB, cost_OA[i]-x[i]+max_OB[i+1]);

    long long int ans = max(ans_BA, ans_AB);
    printf("%lld\n", max(ans, 0LL));

    

    // OA, AO, OB

    
    return 0;
}


Measured memory_bytes: 4992
import itertools, heapq, bisect
from collections import defaultdict as ddic, deque, Counter

rr = raw_input
rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())
MOD = 10 ** 9 + 7

###
X, Y = rrm()
from fractions import gcd
def lcm(a,b):
    return a*b/gcd(a,b)
print lcm(X, Y)



Measured memory_bytes: 34792
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::min;

fn main() {
    let mut s: Vec<char> = read::<String>().chars().collect();
    let mut t: Vec<char> = read::<String>().chars().collect();
    let mut ans: &str = &String::new();

    s.sort();
    t.sort();
    t.reverse();

    for i in 0..min(s.len(), t.len()) {
        if s[i] < t[i] {
            ans = &"Yes";
            break;
        }
        if s[i] > t[i] {
            ans = &"No";
            break;
        }
    }

    if ans != "" {
        println!("{}", ans);
        return;
    }

    if s.len() < t.len() {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main() {
  int S;
  cin >> S;
  
  vector<int> vec = {0,0,0,0};
  vector<int> vecc = {0,0,0,0};

  int i,j;
  double x;
  for (i=0;i<4;i++) {
    x = i+1;
    x = std::pow(10,x);
    j=x;
    vec.at(i) = S % j ;
  }
  for (i=0;i<4;i++) {
    if ( i==0 ) {
      vecc.at(i)=vec.at(i);
    }
    else {
      x = i;
   	  x = std::pow(10,x);
      j = x;
      j = (vec.at(i)-vec.at(i-1))/j;
      vecc.at(i) = j ;
    }
  }
  string flag;
  flag = "Good";
  for (i=0;i<3;i++) {
    if ( vecc.at(i) == vecc.at(i+1) ) {
      flag = "Bad";
    }
  }
  cout << flag << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _itr ::iterator
#define forn(i, x, y) for (ll i = x; i < y; ++i)
#define ford(i, x, y) for (ll i = x; i > y; --i)
#define forne(i, x, y) for (ll i = x; i <= y; ++i)
#define forde(i, x, y) for (ll i = x; i >= y; --i)
#define rd(x) cin >> x; cin.ignore();
#define rdstr(x) getline(cin, x);
#define rdarr(x, y) for (ll i = 0; i < y; ++i) cin >> x[i];
#define rdmtr(x, y, z) for (ll i = 0; i < y; ++i) for (ll j = 0; j < z; ++j) cin >> x[i][j];
#define pb push_back

#define X first
#define Y second

#define MaxN 107
#define MaxM 507
#define Mdl 1000000007

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef ll arr[MaxN];

ll REPIT = 1;

const bool MQ = false;
ll cur, k, dist;
arr so;

void Solve()
{
    cin >> cur >> k >> dist;
    if (cur == 0)
    {
        if (k & 1) cout << dist;
        else cout << "0"; return;
    }
    ll req = abs(cur) / dist;
    if (k < req)
    {
        if (cur > 0) cout << abs(cur - dist * k);
        else cout << abs(cur + dist * k);
        return;
    }
    ll cnt;
    if (req % 2 == k % 2) cnt = abs(cur) / dist;
    else cnt = abs(cur) / dist + 1;
    if (cur > 0) cout << abs(cur - (cnt) * dist);
    else cout << abs(cur + (cnt) * dist);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifdef OFFLINE
    freopen("INPUT.inp", "r", stdin);
    #endif
    if (MQ == true)
    {
        rd(REPIT);
    }
    while (REPIT--) Solve();
    cout.flush();
    #ifdef OFFLINE
    fclose(stdin);
    #endif
}


Measured memory_bytes: 3624
#include<stdio.h>
int N,i,ans=0;
int main(){
scanf("%d",&N);
int l[N],r[N];
for(i=0;i<N;i++){
  scanf("%d %d",&l[i],&r[i]);
}
for(i=0;i<N;i++){
  ans=ans+r[i]-l[i]+1;
}
printf("%d",ans);
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
int main()
{
    int r,d,x;
    while (~scanf("%d %d %d", &r,&d,&x)) {
        REP(i,1,10) {
            x = r*x-d;
            printf("%d\n", x);
        }
    }
    return 0;
}


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

int main() {
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (s == u) a--;
    else b--;

    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
$hourToSec = 3600
$minToSec  = 60

def exchangeToDigitalTime(inputSec)
    hour = inputSec / $hourToSec
    swpTime  = inputSec % $hourToSec
    min  = swpTime / $minToSec
    sec  = swpTime % $minToSec
    
    return hour, min, sec
end

input_s = gets.to_i

h, m, s = exchangeToDigitalTime(input_s)

puts "#{h}:#{m}:#{s}"


Measured memory_bytes: 6868
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
typedef pair<int, int> P;
P p[100010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        cin >> p[i].second >> p[i].first;
    }
    sort(p, p + M);
    // rep(i, M) {
    //     cout << p[i].second << " " << p[i].first << endl;
    // }
    int b = -1;
    int ans = 0;
    rep(i, M) {
        if(b < p[i].second) {
            b = p[i].first - 1;
            ans++;
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 4436
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	lint A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;

	set<lint> wat, sug;
	for (int i = 0; i <= 3000; i++) {
		for (int j = 0; j <= 3000; j++) {

			if ((A * i + B * j) * 100 <= F) wat.emplace(A * i + B * j);
			if (C * i + D * j <= F) sug.emplace(C * i + D * j);

		}
	}

	double maxC = 0.0;
	pair<lint, lint> ans{100 * A, 0LL};
	for (const auto &w : wat) {
		for (const auto &s : sug) {
			if (s <= w * E && w * 100 + s <= F) {
				if (maxC < 1.0 * s / w) {
					maxC = 1.0 * s / w;
					ans = { 100 * w + s, s };
				}
			}
		}
	}
	
	cout << ans.first << " " << ans.second << "\n";

	return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

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

Measured memory_bytes: 256
import math
a,b,h,m = map(int, input().split())

x = (60*h+m)*11 /360
for i in range(1,23,2):
    if x < i:
        sita = x * math.pi
        ans_2 = a**2 + b**2 - 2*a*b * math.cos(sita)
        print(ans_2 ** 0.5)
        exit()
    elif i < x < i + 2:
        sita = abs(x-2*i) * math.pi
        ans_2 = a**2 + b**2 - 2*a*b * math.cos(sita)
        print(ans_2 ** 0.5)
        exit()

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

int main() {
  string s;int w;cin>>s>>w;
  for(int i=0;i<s.size();i+=w)cout<<s[i];
  cout<<endl;
}

Measured memory_bytes: 3572
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();

            int result = a - b;

            out.println(result <= 0 ? 0 : result);
        }

    }
}

Measured memory_bytes: 23124
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll h,w,k; cin >> h >> w >> k;
    ll sx,sy; cin >> sx >> sy;
    ll tx,ty; cin >> tx >> ty;
    sx--;sy--;tx--;ty--;

    ll dx[] = {0,0,1,-1};
    ll dy[] = {1,-1,0,0};
    auto is_out = [&](ll x, ll y){
       if(x < 0 || x >= h || y < 0 || y >= w)return true;
       return false;
    };

    vector<string> v(h);

    rep(i,0,h){
        cin >> v[i];
    }

    queue<Pll> que;
    vector dist(h, vector(w, INF));
    que.emplace(sx, sy);
    dist[sx][sy] = 0;
    while(!que.empty()){
        auto [x, y] = que.front();que.pop();
        ll c = dist[x][y];
        if(x == tx && y == ty){
            cout << c << "\n";
            return 0;
        }
        rep(i,0,4){
            ll nx = x, ny = y;
            rep(j,0,k){
                nx += dx[i], ny += dy[i];
                if(is_out(nx, ny))break;
                if(v[nx][ny] == '@')break;
                if(dist[nx][ny] <= c)break;
                if(chmin(dist[nx][ny], c + 1)){
                    que.emplace(nx, ny);
                }
            }
        }
    }

    debug(dist);

    cout << (dist[tx][ty] == INF ? -1 : dist[tx][ty]) << endl;

}

Measured memory_bytes: 19844
import java.util.*;

public class Main {

	int sq(int x){ return x*x; }

	class Point{
		int x, y;
		Point(int _x, int _y){
			this.x = _x;
			this.y = _y;
		}
		public boolean equals(Object a){
			return (a instanceof Point) && this.x == ((Point)a).x && this.y == ((Point)a).y;
		}
		public int hashCode(){
			return x*x ^12345678 - y*y;
		}
	}

	Point ps[];
	int N;

	void run(){
		Scanner in = new Scanner(System.in);
		for(;;){
			N = in.nextInt();
			if(N == 0) return ;
			ps = new Point[N];
			for(int i=0; i<N; i++){
				int x = in.nextInt(), y = in.nextInt();
				ps[i] = new Point(x<<1, y<<1);
			}
			System.out.println(solve()>>2);
		}
	}

	int solve(){
		HashSet<Point> set = new HashSet<Point>();
		for(int i=0; i<N; i++){
			set.add(ps[i]);
		}
		int ret = 0;
		for(int i=0; i<N; i++)for(int j=i+1; j<N; j++){
			Point V = new Point((ps[j].x - ps[i].x)>>1, (ps[j].y - ps[i].y)>>1);
			Point C = new Point(ps[i].x + V.x, ps[i].y + V.y);
			Point L = new Point(C.x-V.y, C.y+V.x), R = new Point(C.x+V.y, C.y-V.x);
			if(set.contains(L) && set.contains(R)){
				ret = Math.max(ret, sq(ps[i].x - L.x) + sq(ps[i].y - L.y));
			}
		}
		return ret;
	}

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

Measured memory_bytes: 13000
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);
        while (true) {
            int tmp = sc.nextInt();
            int L = sc.nextInt();
            if ((tmp | L) == 0)
                break;
            String key = String.format("%0" + L + "d", tmp);
            Map<String, Integer> map = new HashMap<String, Integer>();
            int c = 0;
            map.put(key, c);

            while (true) {
                c++;
                char tmps[] = key.toCharArray();
                Arrays.sort(tmps);
                StringBuilder sb = new StringBuilder();
                sb.append(tmps);
                String min = sb.toString();
                sb.reverse();
                String max = sb.toString();
                int na = Integer.parseInt(max) - Integer.parseInt(min);
                key = String.format("%0" + L + "d", na);
                if (map.containsKey(key)) {
                    break;
                } else
                    map.put(key, c);
            }
            int j = map.get(key);
            int i = c;
            int a = Integer.parseInt(key);
            System.out.printf("%d %s %d\n", j, a, i - j);
        }
    }
}

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

int main(void){
	vector<int>a(6);
	for(int i = 0 ; i < 6; ++i){
		int tmp;
		cin >> tmp;
		a[tmp-1]++;
	}
	sort(a.rbegin(),a.rend());
	if(a[0] == 2 && a[1] == 2 && a[2] == 1 && a[3] == 1){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from itertools import combinations
from math import gcd
from functools import reduce


def gcd3(cmb):
    return reduce(gcd, cmb)


k = int(input())
s1 = sum(range(1, k + 1))
s2 = 0
cmb2 = combinations(range(1, k + 1), 2)
for i, j in cmb2:
    s2 += gcd(i, j)
s3 = 0
cmb3 = combinations(range(1, k + 1), 3)
for i in cmb3:
    s3 += gcd3(i)

print(s1 + s2 * 6 + s3 * 6)

Measured memory_bytes: 9644
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		int r = 0;
		int b = 0;
		for (char c : s.toCharArray()) {
			if ('0' == c) {
				r++;
			} else {
				b++;
			}
		}
		
		int ans = Math.min(r, b);
		
		System.out.println(ans*2);
	}
}


Measured memory_bytes: 27220
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll K;
	cin >> K;
	if (K <= 10) {
		cout << K << endl;
		return 0;
	}

	vector<vll> t(999999, vll(10, 1));
	ll cnt = 9;
	ll i=0;
	while(true){
		i++;
		rep(j, 1, 10) {
			ll tmp = 0;
			if (j > 0) {
				tmp += t[i - 1][j - 1];
			}

			tmp += t[i - 1][j];

			if (j < 9) {
				tmp += t[i - 1][j + 1];
			}

			t[i][j] = tmp;
			cnt += tmp;
			if (cnt >= K) {
				cout << j;
				ll d = i - 1;
				ll l = tmp - (cnt-K);
				ll u = j;
				while (d >= 0) {
					tmp = 0;
					repeq(k, max(0LL, u - 1), min(9LL, u + 1)) {
						if (tmp+ t[d][k] >= l) {
							u = k;
							l = l - tmp;
							break;
						}
						tmp += t[d][k];
					}
					cout << u;
					d--;
				}

				cout << endl;
				return 0;
			}
		}

		t[i][0] = t[i - 1][0] + t[i - 1][1];
	}
	return 0;
}


Measured memory_bytes: 117376
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
const long long INF=1145141919,MOD=1e9+7;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int y,m,d;
        cin>>y>>m>>d;
        int ans=1;
        int Y=1000-y-1,M=m-1,D=d;
        ans+=590*(Y/3);
        if(Y%3!=0){
            ans+=200;
            if(Y%3==2) ans+=195;
            D+=39*(M/2);
            if(M%2==1) D+=20;
            ans+=195-D;
            cout<<ans<<endl;
        }else{
            D+=20*M;
            ans+=200-D;
            cout<<ans<<endl;
        }

    }
    return 0;
}



Measured memory_bytes: 3084
/**
 *      purpose : ABC 96 D
 *      author  : kyomukyomupurin
 *      created : 2018-11-12 06:56:28
**/

#include <bits/stdc++.h>
using namespace std;
#define int64 long long
#define print(x) cout << (x) << '\n'

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

    int N; scanf("%d", &N);
    int prime[55] = {11,31,41,61,71,101,131,151,191,211,241,251,271,311,331,401,421,431,461,491,521,541,571,601,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1301,1321,1361,1381,1451,1471,1481,1511,1531,1571};
    
    for (int i = 0; i < N; ++i){
        cout << prime[i] << " ";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int score[1000];
pair<int,int> dat[100000];
int now[1000];
pair<int,int> change[100000];
int rev[1000];
int main(){
	int a,b,c,d;
	while(scanf("%d%d%d%d",&a,&b,&c,&d),a+b+c+d){
		for(int i=0;i<a;i++)scanf("%d",score+i);
		for(int i=0;i<b;i++){
			int e,f;
			scanf("%d%d",&e,&f);
			dat[i]=make_pair(f,e);
		}
		std::sort(dat,dat+b);
		for(int i=0;i<a;i++)now[i]=i;
		for(int i=0;i<b;i++){
			int p=dat[i].second-1;
			int e=now[p];
			now[p]=now[p+1];
			now[p+1]=e;
			change[i]=make_pair(now[p],now[p+1]);
	//	printf("%d %d\n",now[p],now[p+1]);
		}
		
		int ret=0;
		for(int i=0;i<a;i++){
	//		printf("%d ",now[i]);
			if(now[i]<d){
				ret+=score[i];
			}
			rev[now[i]]=i;
		}
		int val=ret;
	//	printf("%d\n",ret);
		for(int i=0;i<b;i++){
			if(change[i].first<d&&change[i].second<d)continue;
			if(change[i].first>=d&&change[i].second>=d)continue;
			if(change[i].first<d)ret=min(ret,val-score[rev[change[i].first]]+score[rev[change[i].second]]);
			else ret=min(ret,val+score[rev[change[i].first]]-score[rev[change[i].second]]);
		//	printf("%d %d\n",i,ret);
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 2328
n = int(input())
d = list(map(int,input().split()))


d = sorted(d)
count = 0
if len(d)%2 == 0:
	if d[len(d)//2-1] == d[len(d)//2]:
		print(0)
	else:
		temp = d[len(d)//2]- d[len(d)//2-1]
		count += temp
		print(count)
else:
	print(0)


Measured memory_bytes: 14396
#include <iostream>

using namespace std;
const int N=1e5+55;
int dp[N];
int a[155];
int n,k;

bool bt(int i)
{
    if(dp[i]!=-1)
        return dp[i];
    bool q=0;
    for(int j=0;j<n;j++)
    {
        if(a[j]<=i&&bt(i-a[j])==0)
            q=1;
    }
    dp[i]=q;
    return q;
}

int main()
{
    for(int i=0;i<N;i++)
        dp[i]=-1;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    if(bt(k))
        cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;
    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>

class Point{
public:
	Point();
	Point(double _x, double _y);
	double x, y;
};

Point::Point() : x(0), y(0){}
Point::Point(double _x, double _y) : x(_x), y(_y){}

class Vector{
	//private:

public:
	Vector();
	Vector(double _x, double _y);
	Vector(Point p1, Point p2);
	double x, y;
};

Vector::Vector() : x(0), y(0){}
Vector::Vector(double _x, double _y) : x(_x), y(_y){}
Vector::Vector(Point p1, Point p2) : x(p1.x-p2.x), y(p1.y-p2.y){}

class Triangle{
public:
	Triangle();
	Triangle(Point _p1, Point _p2, Point _p3);
	Point p[3];
};

Triangle::Triangle(Point _p1, Point _p2, Point _p3){
	p[0] = _p1, p[1] = _p2, p[2] = _p3;
}

int extproduct(Vector v1, Vector v2){
	return v1.x*v2.y - v1.y*v2.x;
}

bool triangle_contains(Triangle t, Point p){
	int count = 0;
	for(int i=0;i<3;i++){
		Vector a = Vector(t.p[i], t.p[(i+1)%3]), b = Vector(p, t.p[i]);
		if(extproduct(a, b) > 0)count++;
		else count--;
	}
	return (count%3 != 0);
}

int main(){
	Point ps[4];
	while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &ps[0].x, &ps[0].y, &ps[1].x, &ps[1].y, &ps[2].x, &ps[2].y, &ps[3].x, &ps[3].y)){
		int i = 0;
		for(;i<4;i++){
			if(triangle_contains(Triangle(ps[(i+1)%4], ps[(i+2)%4], ps[(i+3)%4]), ps[i]) == false)break;
		}
		if(i == 4)puts("YES");
		else puts("NO");
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <ctime>
#include <cmath>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
struct P
{
    int x,y,z;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};
//vector<int> v[20056],v1[20020];

int a,b,c,i,k,o[100002],n,m,d,e,dy[15]={0,0,-1,1,-1,1,-1,1},dx[15]={-1,1,0,0,1,1,-1,-1};
int l[50005];
long long x,y,z,v1,v2;
P u[200600];
int j[6000000];
queue<int> q,q1;
stack<int> s;
//queue<P> q;

//deque<int> d;
//'1'==49;
//'A'==65;
//'a'==97;
map<int, int > p;
string r,r1,r2;
//char r[5000];

bool as(int a,int b)
{
     return a>b;

}

//2147483647
int main()
{
    scanf("%d",&a);
    for(int t=0;t<a;t++)
    {
        scanf("%d",&b);
        p[b]++;
    }
    scanf("%d",&a);
    for(int t=0;t<a;t++)
    {
        scanf("%d",&b);
        p[b]--;
        if(p[b]<0)
        {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	bool sn[n]={0};
	int cnt=0;
	for(int i=0;i<k;i++){
		int a;
		cin>>a;
		while(a--){
			int s;
			cin>>s;
			if(sn[s-1]==0){
				cnt++;
				sn[s-1]=1;
			}
		}
	}
	cout<<(n-cnt)<<endl;

}

Measured memory_bytes: 3672
#include <cstdio>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int vs[100];

int main(void) {
  int n, k;
  scanf("%d%d", &n, &k);
  REP(i, n) {
    scanf("%d", &vs[i]);
  }
  sort(vs, vs + n);
  int res = 0;
  REP(i, k) {
    res += vs[n-1-i];
  }
  printf("%d\n", res);
  return 0;
}


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

int main(void){
    int N;
    cin >> N;
  	int A[21];
  	int B[21];
  	int C[21];
  	for(int i=0;i<N;i++){
    	cin >> A[i];
    }
  	for(int i=0;i<N;i++){
    	cin >> B[i];
    }
  	for(int i=0;i<N-1;i++){
    	cin >> C[i];
    }
  	int ans = 0;
  	for(int i=0;i<N;i++){
    	ans += B[A[i]-1];
      	if(A[i+1]==A[i]+1){
        	ans += C[A[i]-1];
        }
    }
  
    cout << ans <<"\n";
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
a = [list(input()) for _ in [0]*h]
for j in range(w):
    if not any(a[i][j]=='#' for i in range(h)):
        for i in range(h):
            a[i][j] = ''
for i in a:
    if any(j=='#' for j in i):
        print(''.join(i))

Measured memory_bytes: 3060
// RAM RAM
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define bg begin()
#define ed end()
#define mp make_pair
#define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define pf(x) cout<<x<<endl;
#define N 55
const int MOD=1000000007;
using namespace std;
     

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

     
    // int t;cin>>t;
    // while(t--){

    // }
     
    int w,a,b;cin>>w>>a>>b;
    int res;
    if(a<b){
    	int end_f=a+w;
    	if(b>end_f){
    		res=end_f-b;
    	}else{
    		res=0;
    	}
    }else if(a>b){
    	int end_f=b+w;
    	if(a>end_f){
    		res=end_f-a;
    	}else{
    		res=0;
    	}
    }else{
    	res=0;
    }

    cout<<abs(res)<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=1e3+100,MOD=1e9+7;
int n,m,dp[N][N];
char grid[N][N];
int main(){
    cin.tie(NULL);
    cout.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
        cin>>grid[i][j];
    memset(dp,-1,sizeof dp);
    dp[0][0]=1;
    for(int i=0;i<n;i++)
    for(int j=0;j<m;j++){
        if(dp[i][j]==-1)
            continue;
        if(grid[i][j+1]=='.'){
            dp[i][j+1]=max(0,dp[i][j+1]);
            dp[i][j+1]+=dp[i][j];
            dp[i][j+1]=(dp[i][j+1]%MOD);
        }
        if(grid[i+1][j]=='.'){
            dp[i+1][j]=max(dp[i+1][j],0);
            dp[i+1][j]+=dp[i][j];
            dp[i+1][j]=(dp[i+1][j]%MOD);
        }
    }
    dp[n-1][m-1]=max(0,dp[n-1][m-1]);
    cout<<dp[n-1][m-1]<<'\n';
    return 0;
}


Measured memory_bytes: 6016
ip=[int(x) for x in input().split()]
a=ip[0];b=ip[1];k=ip[2]
ans=list()
for i in range(0,k):
    ans.append(a)
    ans.append(b)
    a=a+1
    b=b-1
    if((a>ip[1])|(b<ip[0])):
        break
res=list(set(ans))
res.sort()
for i in res:
    print(i)

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define o_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define int ll
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

signed main(){
		ios_base::sync_with_stdio(0);cin.tie(0);
		int N;
		cin>>N;
		vector<int> v,p;
		for(int i=0;i<N;i++){
      int a,b;
      cin>>a>>b;
      v.push_back(a);
      p.push_back(b);
		}
		sort(v.begin(),v.end());
		sort(p.begin(),p.end());
		if(N%2){
        cout<<p[N/2]-v[N/2]+1;
        return 0;
		}
		double a=v[N/2-1],b=p[N/2-1];
		double c=v[N/2],d=p[N/2];
		cout<<(int)(((b+d)/2.0-(a+c)/2.0)*2)+1;
}

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

int main(){
  int N;
  int m= 1;
  int ans, x= 0 ;
  cin >> N;
  if(N>1000 ){
    m=N/1000;
    if(N>1000*m) {
      m=m+1;
    }
  }
  x =1000*m;
  ans = x - N;

  cout << ans;
  return 0;
}

Measured memory_bytes: 3624
import java.util.*;
 
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double a = sc.nextInt();
    int a2 = (int)Math.pow(a, 2);
    int a3 = (int)Math.pow(a, 3);
    int ans = (int)(a+a2+a3);
    System.out.println(ans);
    
  }
}

Measured memory_bytes: 35800
import java.util.*;

class Reader {
  Scanner sc = new Scanner(System.in);

  public int ini() {
    return sc.nextInt();
  }

  public int[] vi(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++) a[i] = sc.nextInt();
    return a;
  }
}

public class Main extends Reader {
  public static void main(String[] args) {
    Main main = new Main();
    main.show(main.solve());
  }

  int n;

  public Main() {
    n = ini();
  }
  
  int solve() {
    int ans = 9999;
    for (int i = 1; i < n; i++) {
      int j = n - i;
      int cnt = digitsum(i) + digitsum(j);
      if (cnt < ans) ans = cnt;
    }
    return ans;
  }

  int digitsum(int n) {
    int ans = 0;
    while (n > 0) {
      ans += n % 10;
      n /= 10;
    }
    return ans;
  }

  void show(int ans) {
    System.out.println(ans);
  }
}


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

count = 0
count_ = 0
for i in range(n):
  if a[i] % 2 == 0:
    count += 1
    if a[i] % 3 == 0 or a[i] % 5==0:
      count_ += 1

if count == count_:
  print("APPROVED")
else:
  print("DENIED")

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

int		main(void)
{
	string o, e;
	cin >> o >> e;
	int i;
	for (i = 0; i < e.size(); i++)
		cout << o[i] << e[i];
	if (o.size() != e.size())
		cout << o[i];
	cout << endl;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    double a, b; cin >> a >> b;

    std::cout << Decimal << a / b << std::endl;

    return 0;
}


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

#include <algorithm>
#include <utility>
#include <vector>
#include <cstdio>
#include <random>



int main(){
  int N, Alice=0, Bob=0, dif;
  cin >> N;
  int v[N-1];
  for (int i = 0; i < N; i++) {
    cin >> v[i];
	}
  
  std::sort(v, v+N);
  if(N%2 == 0){
  for(int i = 0; i<=(N/2)-1;i++){
    Bob += v[i*2] ;
    Alice += v[i*2+1];
  }
  }else{
    for(int i = 0; i<=((N-1)/2)-1;i++){
    Alice += v[i*2];
    Bob = Bob + v[(i*2)+1];
    }
    Alice += v[N-1];
  }
    
    dif = Alice - Bob;
  
 cout << dif <<  endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int mo = 1e9 + 7;

const int N = 1e5 + 5;

int n, m, a[N], b[N];
struct P {
	int x, y;
} c[N]; int c0;
int d[N], d0;
map<int, int> bc;

bool operator < (P a, P b) {
	if(a.x == b.x) return a.y > b.y;
	return a.x < b.x;
}

bool operator == (P a, P b) {
	return a.x == b.x && a.y == b.y;
}
ll f[N];
#define low(x) ((x) & -(x))
void add(int x, int y) {
	for(; x <= n; x += low(x)) f[x] += y, f[x] %= mo;
}
ll sum(int x) {
	ll s = 0;
	for(; x; x -= low(x)) s += f[x];
	return s % mo;
}

int main() {
	scanf("%d %d", &n, &m);
	fo(i, 1, n) scanf("%d", &a[i]);
	fo(i, 1, m) scanf("%d", &b[i]);
	int l = 0; 
	fo(i, 1, n) {
		if(a[i] < b[1] || a[i] > b[m]) continue;
		while(l < m && b[l + 1] <= a[i]) l ++;
		if(a[i] == b[l]) continue;
		c[++ c0].x = a[i] - b[l];
		c[c0].y = b[l + 1] - a[i];
		d[++ d0] = c[c0].y;
	}
	sort(d + 1, d + d0 + 1);
	d0 = unique(d + 1, d + d0 + 1) - (d + 1);
	fo(i, 1, d0) bc[d[i]] = i;
	fo(i, 1, c0) c[i].y = bc[c[i].y];
	sort(c + 1, c + c0 + 1);
	c0 = unique(c + 1, c + c0 + 1) - (c + 1);
	ll ans = 1;
	fo(i, 1, c0) {
		ll t = sum(c[i].y - 1) + 1;
		add(c[i].y, t);
		ans = (ans + t) % mo;
	}
	pp("%lld\n", ans);
}


Measured memory_bytes: 7168
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define deb(x) cout<<#x<<" = "<<x<<"\n";
int dp[105][100005];

int knapsack(int w[], int v[], int idx, int cap)
{
	if(cap<=0 || idx <0)
		return 0;
	if(dp[idx][cap] != -1)
		return dp[idx][cap];
	
	int ans1 = knapsack(w, v, idx-1, cap);
	int ans2 = 0;
	if(cap>=w[idx])
	ans2 = v[idx] + knapsack(w, v, idx-1, cap-w[idx]);
	return dp[idx][cap] = max(ans1, ans2);
}
signed main()
{
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//#endif
	/************************************/
	
	int n, cap; cin>>n>>cap;
	memset(dp, -1, sizeof(dp));
	
	int w[n], v[n];
	for(int i=0; i<n; i++)
		cin>>w[i]>>v[i];
		
	int ans = knapsack(w, v, n-1, cap);
	cout<<ans;
	
return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<double> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p.at(i);
    }

    vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0));
    dp.at(0).at(0) = 1;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            dp.at(i).at(j) += dp.at(i - 1).at(j) * (1 - p.at(i - 1));
            if (j - 1 >= 0) {
                dp.at(i).at(j) += dp.at(i - 1).at(j - 1) * p.at(i - 1);
            }
        }
    }

    double ans = 0;
    for (int i = (N + 1) / 2; i <= N; i++) {
        ans += dp.at(N).at(i);
    }

    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 70784
#include<stdio.h>

#define MAX 500001
int A[MAX];
int h;

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}
void maxHeapify(int i){
  int l,r,largest,temp;
  
  l = left(i);
  r = right(i);
  
  // choose max node among left child, me, and right child
  
  if(l <= h && A[l] > A[i])
    largest = l;
  else 
    largest = i;
  
  if(r <= h && A[r] > A[largest])
    largest = r;
  
  if(largest != i){ // A[i] > A[l],A[r]
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(largest);
  }
}
void buildMaxHeap(){
  int i;
  for(i=h/2;i>0;i--)
    maxHeapify(i);
}


int main(){
  
  int i;
  
  
  // 入力
  scanf("%d",&h);
  for(i=1;i<=h;i++)
    scanf("%d",&A[i]);
  
  // 並び換え
  buildMaxHeap();
  
  // 出力
  for(i=1;i<=h;i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 2552
#include<cstdio>
const int mod=1e9+7;
int n,k,x,y,Ans;
int f[105][260];
int main(){
	scanf("%d%d",&n,&k);
	f[0][0]=y=1;
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		for(int j=i;j>=1;j--)
		for(int k=0;k<=255;k++)
		f[j][k]=(f[j][k]+f[j-1][k^x])%mod;
	}
	for(int i=1;i<=n;i++){
		y=1ll*y*i%mod;
		Ans=(Ans+1ll*f[i][k]*y%mod)%mod;
	}
	printf("%d\n",Ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))


SINT32 main() {
    SINT32 n,m;
    scanf("%d%d",&n,&m);

    SINT32 ans = -1;

    if (n == 1) {
        ans = m;
    } else {

        for (int i = 1; (i*n) < m+1 ; i++) {

            if ((m % i) == 0) {

                if ((m / i) >= n) {
                    ans = i;
                } else {
                    break;
                }
            }
        }
    }


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

Measured memory_bytes: 128
def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i+=1
            A[i],A[j]=A[j],A[i]
    
    A[i+1],A[r]=A[r],A[i+1]
    return i+1

#input
n=int(input())
data=list(map(int, input().split()))
q=partition(data,0,n-1)
data[q]="["+str(data[q])+"]"
print(*data)


Measured memory_bytes: 16392
#include <iostream>
#include <limits>
#include <queue>
#include <vector>

using namespace std;

struct Edge {
    int source, target, distance;
};

struct Node {
    int vertex, weight;
    bool operator > (const Node& node) const {
        return weight > node.weight;
    }
};


int main()
{
    int n_vertices, n_edges, source_node;
    cin >> n_vertices >> n_edges >> source_node;
    vector< vector<Edge> > adjlist(n_vertices);

    for (int i = 0; i < n_edges; ++i) {
        int source, target, distance;
        cin >> source >> target >> distance;
        adjlist[source].emplace_back(Edge{source, target, distance});
    }

    vector<int> closed(n_vertices, numeric_limits<int>::max());
    priority_queue<Node, vector<Node>, greater<Node> > open;

    open.push(Node{source_node, 0});
    while (!open.empty()) {
        auto node = open.top();
        open.pop();
        if (closed[node.vertex] != numeric_limits<int>::max()) continue;
        for (auto edge : adjlist[node.vertex]) {
            int child = edge.target;
            int distance = edge.distance;
            open.push(Node{child, node.weight + distance});
        }
        closed[node.vertex] = node.weight;
    }

    for (auto weight : closed) {
        if (weight == numeric_limits<int>::max()) {
            cout << "INF";
        } else {
            cout << weight;
        }
        cout << endl;
    }
}





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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

int main() {
    cout<<fixed<<setprecision(10);

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


    vint maxval(n);
    rep(i,n) maxval[i] = a[i][0];

    ll ans = n;
    set<ll> used;
    rep(zz, m-1){
        vint cnt(m,0);
        for(auto e:maxval) cnt[e]++;
        // cout<<ans<<endl;
        // printv(cnt);
        auto it = max_element(ALL(cnt));
        ll t = it - cnt.begin();
        used.insert(t);
        rep(i,n){
            rep(j,m){
                if(used.count(a[i][j])) continue;
                maxval[i] = a[i][j];
                break;
            }
        }
        chmin(ans, *it);
    }
    cout<<ans<<endl;


    return 0;

}

Measured memory_bytes: 1024