akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
    	// Solution sol = new Solution();
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	StringTokenizer st = new StringTokenizer(br.readLine());
    	int N = Integer.parseInt(st.nextToken());
    	st = new StringTokenizer(br.readLine());
    	HashMap<Integer, Integer> hm = new HashMap();
    	int[] arr = new int[N];
    	long[][] count = new long[N+1][3];
    	for(int i=0; i<N; i++){
    		arr[i]=Integer.parseInt(st.nextToken());
    		count[arr[i]][0]++;
    	}
    	long sum=0;
    	for(int i=1; i<=N; i++){
    		count[i][1]=count[i][0]*(count[i][0]-1)/2;
    		count[i][2]=(count[i][0]-1)*(count[i][0]-2)/2;
    		sum+=count[i][1];
    	}
    	for(int i=0; i<N; i++){
    		System.out.println(sum-count[arr[i]][1]+count[arr[i]][2]);
    	}

    }
}

Measured memory_bytes: 79008
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define TO_STRING(a) #a
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }
template<class T> void MSG(T a){ cout << TO_STRING(a) << " = " << a << endl; }


/// memo
const int MOD = 10000;
vint scj(100, -1);
vector<vector<vint> > memo(100, vector<vint>(3, vint(3, -1)));

// p : ê
// k : êÂOÌIð
// c : ÌA±
int rec(int& n, int p, int k, int c)
{
	if(p == n) return 1;
	if(0 <= memo[p][k][c]) return memo[p][k][c];
	
	
	int res = 0;
	
	// ùè
	if(0 <= scj[p])
	{
		if(k == scj[p] && c == 2)
			return 0;
		
		res = rec(n, p + 1, scj[p], (k == scj[p] ? c + 1 : 1));
	}
	// ¢è
	else
	{
		rep(i, 3)
		{
			if(k != i || c != 2)
			{
				(res += rec(n, p + 1, i, (k == i ? c + 1 : 1))) %= MOD;
			}
		}
	}
	
	return memo[p][k][c] = res;
}


int main()
{
	int n, k;
	cin >> n >> k;
	
	rep(i, k)
	{
		int a, b;
		cin >> a >> b;
		
		scj[a-1] = b-1;
	}
	
	cout << rec(n, 0, 0, 0) << endl;
}

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


int main(void) {
	char input[10];
	int n;
	int i;
	int temp;
	
	fgets(input, sizeof(input), stdin);
	n = atoi(input);
	
	for (i = 1; i <=n; i++){
		if (i % 3 == 0){
			printf(" %d", i);
		}else if (i % 10 == 3){
			printf(" %d", i);
		}else{
			temp = i / 10;
			while (temp){
				if (temp % 10 == 3){
					printf(" %d", i);
					break;
				}
				temp /= 10;
			}
		}
	}
	
	printf("\n");
	
	return 0;
}

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

int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  int sum;
  
  if (K <= N)
    sum = X * K + Y * (N - K);
  else sum = X * N;
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;

class LCS{
private:	
	char x[1000 + 1];
	char y[1000 + 1];
	int lcs[1000][1000];
public:
	LCS(const char x[], const char y[]);
	int calcLCS();
	int calcLCS(int i, int j);
};

LCS::LCS(const char x[], const char y[])
{
	strcpy(this->x, x);
	strcpy(this->y, y);
	for (int i = 0; (this->x)[i] != '\0'; i++) {
		for (int j = 0; (this->y)[j] != '\0'; j++) {
			lcs[i][j] = -1;
		}
	}
}

int LCS::calcLCS(){
	int i, j;
	for (i = 0; ; i++) {
		if (x[i + 1] == '\0') break;
	}
	for (j = 0; ; j++) {
		if (y[j + 1] == '\0') break;
	}
	return calcLCS(i, j);
}

int LCS::calcLCS(int i, int j)
{
	if (i < 0 || j < 0) return 0;

	if (lcs[i][j] != -1) return lcs[i][j];

	if (x[i] == y[j]) lcs[i][j] = calcLCS(i - 1, j - 1) + 1;
	else lcs[i][j] = max(calcLCS(i, j - 1), calcLCS(i - 1, j));
	return lcs[i][j];
}

int main(void)
{
	int q;
	cin >> q;
	cin.ignore(1);
	for (int i = 0; i < q; i++) {
		char x[1000 + 1] = "\0";
		char y[1000 + 1] = "\0";
		cin.getline(x, 1000 + 1);
		cin.getline(y, 1000 + 1);
		LCS *lcs = new LCS(x, y);
		cout << lcs->calcLCS() << endl;
		delete lcs;
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int x,a,b;cin>>x>>a>>b;

  out((x-a)%b);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define IM 3956649

#define N_MAX 50
#define M_MAX 50

typedef struct {
	int w;
	int b;
	int r;
} tricoro;

tricoro color[N_MAX];

int n, m;

int solve(){
	int answer = IM;

	int whitecost = 0, whitediff, isdiff;
	int bluebegin = 0;
	int redsbegin = 0;
	int redblues, lowestrb;
	for (;;) {
		// whitediff = 0;
		// isdiff = 0;
		// while (bluebegin < n - 1 && (!isdiff || whitediff > 0)) {
		// 	whitecost += color[bluebegin].w;
		// 	whitediff += color[bluebegin].w - color[bluebegin].b;
		// 	bluebegin++;
		// 	isdiff = 1;
		// 	fprintf(stderr, "cost: %d, diff:  %d, begin: %d\n", whitecost, whitediff, bluebegin);
		// }
		
		whitecost += color[bluebegin++].w;

		if (bluebegin >= n - 1) break;

		// fprintf(stderr, ":: [%d]) %d\n", bluebegin, whitecost);

		redblues = 0;
		redsbegin = n;
		while (--redsbegin >= bluebegin) {
			redblues += color[redsbegin].r;
		}

		lowestrb = redblues;
		redsbegin++;
		while (redsbegin + 1 <= n - 1) {
			redblues -= color[redsbegin].r;
			redblues += color[redsbegin].b;
			redsbegin++;

			if (lowestrb > redblues) {
				lowestrb = redblues;
				// fprintf(stderr, "::: %d)...\n", redsbegin);
			}
		}

		// fprintf(stderr, "::: %d\n", lowestrb);

		if (answer > whitecost + lowestrb) answer = whitecost + lowestrb;
	}


	return answer;
}

int main(void){
	char str[M_MAX + 1];
	int i;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		int j;
		scanf("%s", str);
		color[i].w = color[i].b = color[i].r = m;
		for (j = 0; j < m; j++) {
			switch (str[j]) {
			case 'W':
				color[i].w--;
				break;
			case 'B':
				color[i].b--;
				break;
			case 'R':
				color[i].r--;
				break;
			}
		}
	}

	printf("%d\n", solve());

	return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define CON 1000000000000
#define SIX 1000000
using namespace std;

int main() {
  int a,b;
  string s = "No";
  cin >> a >> b;
  if(b % a == 0) {
    cout << a + b << endl;
    return 0;
  }
  cout << b-a << endl;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;


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

map<ll,ll> primes(ll n){
    map<ll, ll> r;
    for(int i=2; i*i<=n; i++){
        while(n %i ==0){
            r[i]++;
            n /= i;
        }
    }

    if(n != 1) r[n] = 1;
    return r;
}

ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

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

    ll n, x=1, ans=0;
    cin >> n;
    vll a(n);
    map<ll,ll> l;

    REP(i,n){
        cin >> a[i];
        map<ll,ll>r = primes(a[i]);

        for(auto p: r){
            if(!l.count(p.first)) l[p.first] = p.second;
            else l[p.first] = max(l[p.first], p.second); 
        }
    }

    for(auto p:l){
        REP(i,p.second){
            x *= p.first;
            x %= mod;
        }
    }
    // cout << x << endl;
    REP(i,n){
        ans += x * power(a[i], mod-2);
        ans %= mod;
    }

    cout << ans << endl;
    return 0;
    
}



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

using namespace std;

int gcd(int a, int b) {
	if (!a) return b;
	return gcd(b%a,a);
}

int main() {
	int i, m = 0, g = 0, n, k;

	scanf("%d%d",&n,&k);
	for (i=0;i<n;i++) {
		int a;
		scanf("%d",&a);
		m = max(m,a); g = gcd(g,a);
	}
	if (k<=m&&k%g==0) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 500000
ll MOD=1e9+7;
vec mem(20,-1);
main(){
    int n=in();
    ll x=in();
    vector<ll> b,l,r,t;
    rep(i,n){
        b.pb(in());
        l.pb(in());
        r.pb(in());
        t.pb(l[i]*b[i]+(r[i])*(x-b[i]));
    }
    vec ind;
    rep(i,n)ind.pb(i);
    sort(all(ind),[&](int y,int z){
        return t[y]>t[z];
    });
    //cout<<t[0]<<" "<<t[1]<<endl;
    ll left=-1,right=n*x;
    while(left<right-1){
        ll mid=(left+right)/2;
        ll mm=mid;
        ll tmp=0;
        rep(i,n){
            tmp-=b[i]*l[i];
        }
        int now=0;
        bool flag=false;
        while(mid>=x){
            tmp+=t[ind[now]];
            if(tmp>=0){
                flag=true;break;
            }
            mid-=x;
            now++;
        }
        if(flag){
            right=mm;continue;
        }
        ll MAX=0;
        ll T=1e11;
        rep2(j,0,now-1){
            int i=ind[j];
            if(mid>=b[i]){
                T=min(T,(x-mid)*r[i]);
            }
            else{
                T=min(T,(x-b[i])*r[i]+(b[i]-mid)*l[i]);
            }
        }
        rep2(j,now,n-1){
            int i=ind[j];
            if(mid>=b[i]){
                MAX=max(MAX,b[i]*l[i]+(mid-b[i])*r[i]);
            }
            else{
                MAX=max(MAX,l[i]*mid);
            }
            MAX=max(MAX,t[i]-T);
        }
        tmp+=MAX;
        if(tmp>=0)right=mm;
        else left=mm;
    }
    cout<<right;
}



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

int main (){

  int N = 0;
  scanf("%d", &N);

  if( N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9 ){
    printf("hon \n");
  }
  else if( N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8 ){
    printf("pon \n");
  }
  else if( N % 10 == 3 ){
    printf("bon \n");
  }

  return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <string>

using namespace std;

int main(){

   string str;
   int n, a, b;
   string cmd, p;

   cin >> str;
   cin >> n;

   for(int i = 0; i < n; i++){
      cin >> cmd;
      if(cmd == "replace"){
         cin >> a >> b >> p;
      }
      else{
         cin >> a >> b;
      }

      if(cmd == "print"){
         cout << str.substr(a, b - a + 1) << endl;
      }
      else if(cmd == "reverse"){
         string sub_str = str.substr(a, b - a + 1);
         for(int j = 0; j < b - a + 1; j++){
            str[a + j] = sub_str[b - a - j];
         }
      }
      else{
         for(int j = 0; j < b - a + 1; j++){
            str[a + j] = p[j];
         }
      }
   }

   return 0;
}


Measured memory_bytes: 3208
#include <stdio.h>
#include <math.h>
#define PI (3.141592653589)
int main(void){
	int n;
	int p[1000];
	
	int i;
	
	int goukei = 0;
	double heikin;
	
	double result;
	double sig = 0;
	
	while(1){
		scanf("%d",&n);
		if(n == 0)break;
		
		for(i = 0;i < n;i++){
			scanf("%d",&p[i]);
			goukei += p[i];
		}
		
		heikin = (double)goukei/n;
		
		for(i = 0;i < n;i++){
			sig += pow(p[i]-heikin,2);
		}
		
		result = sqrt(sig/n);
		
		printf("%6.8lf\n",result);
		goukei = 0;
		sig = 0;
	}
	return 0;
}

Measured memory_bytes: 640
def judge(one, two, four):
	if two == 0 and one - four == 1: return 'Yes'
	elif one > four: return 'No'
	else: return 'Yes'	

N = int(raw_input())
a = map(int, raw_input().split())
one = 0
two = 0
four = 0

for i in range(0, N):
	if a[i] % 4 == 0: four = four + 1
	elif a[i] % 2 == 0: two = two + 1
	else: one = one + 1

print judge(one, two, four)

Measured memory_bytes: 11320
X, Y = map(int, input().split())
if (X + Y) % 3 != 0:
    print(0)
    exit()
# n + 2m = X
# 2n + m = Y
# n = X - 2m
# 2(X - 2m) + m = Y
# 2X - 4m + m = Y
# -3m = Y - 2X
m = (2 * X - Y) // 3
# n = X - 2m = X - 2(2X - Y) / 3 = X - 4/3X + 2/3Y = -1/3X + 2/3Y
n = (-X + 2 * Y) // 3

if n < 0 or m < 0:
    print(0)
    exit()

MAX = 10**6
MOD = 10**9 + 7
 
fac = [0] * (MAX + 1)
faci = [0] * (MAX + 1)
inv = [0] * (MAX + 1)
 
fac[0] = fac[1] = 1
faci[0] = faci[1] = 1
inv[1] = 1
 
for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
    faci[i] = faci[i - 1] * inv[i] % MOD
 
def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0 
    return fac[n] * (faci[k] * faci[n - k] % MOD) % MOD
   
print(comb(n + m, n))

Measured memory_bytes: 121716
import sys
sys.setrecursionlimit(10**8)
stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


K = ni()

if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()

start = 0
for i in range(1, 2*10**6):
    start = (start * 10 + 7) % K
    if start == 0:
        print(i)
        exit()
print(-1)


Measured memory_bytes: 63092
#include <iostream>
#include <vector>
#include <cstring>
#include <map>
#include <utility>

using namespace std;

static const long long INF = 1ll << 50;
int n, m;
map<pair<int, int>, long long> dp;
vector<int> money;
vector<int> key;

long long dfs(int now, int bit){
    if(bit == ((1 << n) - 1)){
        return 0;
    }
    if(now == m){
        return INF;
    }
    auto status = make_pair(now, bit);
    if(dp.count(status)) return dp[status];
    return dp[status] = min(dfs(now + 1, bit | key[now]) + money[now], dfs(now + 1, bit)); 
}

int main(){
    cin >> n >> m;
    money.resize(m);
    key.resize(m);
    for(int i = 0; i < m; i++){
        int b;
        cin >> money[i] >> b;
        for(int j = 0; j < b; j++){
            int c;
            cin >> c;
            key[i] += (1 << (c - 1));
        }
    }
    long long ans = dfs(0, 0);
    if(INF == ans){
        ans = -1;
    }
    cout << ans << "\n";
}

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

int main(void){
	int d;
	cin >> d;
	if(d == 25) cout << "Christmas" << endl;
	if(d == 24) cout << "Christmas Eve" << endl;
	if(d == 23) cout << "Christmas Eve Eve" << endl;
	if(d == 22) cout << "Christmas Eve Eve Eve" << 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;
typedef long long int ll;

int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int cnt = 0, num = 1;
  rep(i, n) {
    if (a[i] == num) {
        num++;
        cnt++;
    }
  }
  if (cnt != 0) cout << n - cnt;
  else cout << -1;
  return 0;
}

Measured memory_bytes: 1024
N =gets.to_i
balls = N.times.map do
  gets.split.map(&:to_i)
end

distances = {}

index = 0
while(balls.count != index)
  target_ball = balls[index]

  balls.each do |ball|
    dif_pos = [
      ball.first - target_ball.first,
      ball.last - target_ball.last
    ]
    distances[dif_pos] = (distances[dif_pos] || 0) + 1
  end
  index += 1
end
distances[[0, 0]] = 0
puts N - (distances.values.max || 0)

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

int a[110];
int dp[100010];

bool solve(int rest, int n){
    if (dp[rest] != 0) {
        return (dp[rest] > 0);
    }
    bool ret = false;
    for (int i = 0; i < n; i++) {
        if (rest - a[i] >= 0) {
            ret += !solve(rest-a[i], n);
        }
    }
    if (ret == false) dp[rest] = -1;
    else dp[rest] = 1;
    return ret;
}

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

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

int main(){
    string s;
    int k;
    ll ans1=0, ans2=0, left=0, right=0;
    char bgn = 0;
    cin >> s;
    cin >> k;

    bool b = true;
    for(int i = 0; i<sz(s)-1; i++){
        if(s.at(0)!=s.at(i+1)){b=false;}
    }

    if(b){
        long long lk = k;
        cout << sz(s)*lk/2 << endl;
        return 0;
    }

    while(!s.empty()){
        if((sz(s)>=2&&s.at(0)==s.at(sz(s)-1)&&bgn==0)||(sz(s)>=2&&bgn==s.at(0)&&bgn==s.at(sz(s)-1))){
            ans1 = ans1 + 2;
            left++; right++;
            s.erase(s.begin()); bgn = s.back(); s.pop_back();
           // cout << "type A " << s << endl;
            continue;
        }else if(bgn==s.at(0)){
            ans1++;
            left++;
            s.erase(s.begin());
          //  cout << "type B " << s << endl;

            continue;

        }else if(bgn==s.at(sz(s)-1)){
            ans1++;
            right++;
            s.pop_back();
          //  cout << "type C " << s << endl;

            continue;
        }else{
            break;
        }
    }

    ans1 = ans1 / 2;

    bgn=0;
    int temp = 0;

    while(!s.empty()){
        if(bgn==0){
            bgn=s.back(); temp++; s.pop_back();
        }else{
            if(bgn==s.back()){
                temp++; s.pop_back();
            }else{
                ans2 += temp / 2;
                bgn=s.back();
                s.pop_back();
                temp = 1;
            }
        }
    }

    ans2 += temp / 2;


   // cout << ans1 << " " << ans2 << endl;

    cout << ans2*k + ans1*(k-1) + left/2 + right/2 << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

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

    cout << N-G+1;
    
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <sstream>
#include <limits>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>
#define PI (acos(-1.0))
#define Abs(a) (((a)<0) ? (-(a)) :(a) )
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define Rep(i,n) for(int i=0;i<(n);i++)
#define Rrep(i,n) for(int i=((n)-1);i>=0;i--)
#define rrep(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define Pii pair<int,int>
#define PB push_back
#define Size(x) ((int)(x.size()))
using namespace std;
typedef long long mint;
typedef unsigned long long umint;
int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("in.txt","r",stdin);
    int n;
    cin >> n;
    mint rmax, rmin, bmax, bmin;
    rmax = bmax = numeric_limits<int>::min();
    rmin = bmin = numeric_limits<int>::max();
    int mnball = 0, mxball = 0;
    vector<pair<mint,mint> > arr(n);
    Rep(i,n)
    {
        cin >> arr[i].first >> arr[i].second;
        if(arr[i].first < arr[i].second)
            swap(arr[i].first, arr[i].second);
        if(arr[i].first > arr[mxball].first)
        {
            mxball = i;
        }
        if(arr[i].second < arr[mnball].second)
        {
            mnball = i;
        }
        rmax = max(arr[i].first, rmax);
        rmin = min(arr[i].first, rmin);
        bmax = max(arr[i].second, bmax);
        bmin = min(arr[i].second ,bmin);
    }
    
    mint ans = (rmax - rmin) * (bmax - bmin);
    
    
    rmin = bmin;
    mint mul = (rmax - rmin);
    if(mxball == mnball)
    {
        cout << ans << endl;
        return 0;
    }
    mint omax = max(arr[mxball].second, arr[mnball].first);
    mint omin = min(arr[mxball].second, arr[mnball].first);
    arr.erase(arr.begin() + max(mxball,mnball));
    arr.erase(arr.begin() + min(mxball,mnball));
    
    multiset<mint> s;
    sort(arr.begin(), arr.end(), greater<pair<mint,mint> > ());
    Rep(i,arr.size())
    {
        s.insert(arr[i].first);
    }
    bmax = numeric_limits<int>::min();
    bmin = numeric_limits<int>::max();
    for(int i = 0; i < arr.size(); i++)
    {
        mint mn = min(omin, *s.begin());
        mint mx = max(omax, arr[i].first);
        ans = min(ans, mul * (mx - mn));
        s.erase(s.find(arr[i].first));
        omin = min(omin, arr[i].second);
        omax = max(omax, arr[i].second);
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 12800
// Expired?

#include <iostream>

using namespace std;

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

	if (B <= A)
		cout << "delicious" << endl;
	else if (A < B && B <= A+X)
		cout << "safe" << endl;
	else
		cout << "dangerous" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 100

int main()
{
  int i,j,key,n,l;
  int A[N];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf("%d",&A[i]);
  }
  for(l = 0 ; l < n - 1 ; l++){
    printf("%d ",A[l]);
  }
  printf("%d\n",A[n-1]);

  for(i = 1 ; i <= n-1 ; i++){
    key = A[i];
    j = i - 1;

    while(j >= 0 && A[j] > key){
      A[j + 1] = A[j];
      j--;
      A[j + 1] = key;
    }
      for(l = 0 ; l < n-1 ; l++){
	printf("%d ",A[l]);
      }
      printf("%d\n",A[n-1]);
  
    }
  return 0;
}

Measured memory_bytes: 1028
import math
n = int(input())
ans = 0

def is_prime(a):
    if a < 2: return False
    for i in range(2, int(math.sqrt(a)) + 1):
        if a % i == 0: return False
    return True

for i in range(n):
    a = int(input())
    if is_prime(a): ans += 1

print(ans)


Measured memory_bytes: 5672
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll x;
	cin >> x;
	repn(i, x/100){
		ll r = x-i*100;
		if(r >= 0 && r <= i*5){
			co(1);
			return 0;
		}
	}

	co(0);
	return 0;
}


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

namespace Practice
{
    class Program
    {

        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            int.Parse(Console.ReadLine());
            long[] a = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            for(int i=0;i<a.Length;++i)
            {
                long key = a[i];
                long node = i + 1;
                string sz = string.Format("node {0}: key = {1}, ", node, key);

                long pkidx = (long)Math.Floor((double)node / 2.0) - 1;

                if (0 <= pkidx && pkidx < a.Length)
                {
                    sz += "parent key = " + a[pkidx] + ", ";
                }
                long idx = node * 2 - 1;
                if (0 <= idx && idx < a.Length)
                {
                    sz += "left key = " + a[idx] + ", ";
                 }
                idx = node * 2;
                if( 0 <= idx && idx < a.Length)
                {
                    sz += "right key = " + a[idx] + ", ";
                }
                Console.WriteLine(sz);
            }
        }
    }

}



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

int  main()
{
	string s; cin >> s;
	int ans = 753;
	rep(i, s.size() - 2)
		ans = min(abs(stoi(s.substr(i, 3)) - 753), ans);
	cout << ans << endl;
	return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  ll ans = INF;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ll j = n / i;
      ans = min(ans, i + j - 2);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  bool flag = true;
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    if(A.at(i) % 2 == 0){
      if(A.at(i) % 3 != 0 && A.at(i) % 5 != 0) flag = false;
    }
  }
  cout << (flag? "APPROVED": "DENIED") << endl;
}

Measured memory_bytes: 256
// Written by newbiechd
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;

const int BUF = 1000003;
inline char getChar() {
  static char buf[BUF], *bufS, *bufT;
  if (bufS == bufT) {
    bufT = (bufS = buf) + fread(buf, 1, BUF, stdin);
    if (bufS == bufT)
      return EOF;
  }
  return *bufS++;
}
inline int read() {
  int f = 0;
  bool b = 1;
  char ch;
  while (!isdigit(ch = getChar()))
    if (ch == 45)
      b = 0;
  do f = f * 10 + (ch ^ 48);
  while (isdigit(ch = getChar()));
  return b ? f : ~f + 1;
}

const int maxN = 100003, maxE = 1000003, S = maxN - 2, T = maxN - 1;
const long long inf = 0x3f3f3f3f3f3f3f3f;
int cntNode;

int h[maxN], cntE = 1;
struct Edge {
  int tar, val, cost, nxt;
  Edge() {}
  Edge(int tar, int val, int cost, int nxt)
    : tar(tar), val(val), cost(cost), nxt(nxt) {}
}ed[maxE];
inline void addEdge(int x, int y, int z, int w) {
  ed[++cntE] = Edge(y, z, w, h[x]), h[x] = cntE;
  ed[++cntE] = Edge(x, 0, -w, h[y]), h[y] = cntE;
}

int dis[maxN], cur[maxN], pre[maxN];
inline bool SPFA() {
  static int que[maxN];
  static bool inq[maxN];
  int hd = 1, tl = 0, i, x, y;
  memset(dis + 1, -0x3f, sizeof(int) * cntNode);
  memcpy(cur + 1, h + 1, sizeof(int) * cntNode);
  dis[S] = 0, dis[T] = -inf, cur[S] = h[S], que[++tl] = S, inq[S] = 1;
  while (hd <= tl) {
    x = que[hd++], inq[x] = 0;
    for (i = h[x]; i; i = ed[i].nxt)
      if (ed[i].val && dis[y = ed[i].tar] < dis[x] + ed[i].cost) {
        dis[y] = dis[x] + ed[i].cost, pre[y] = x;
        if (!inq[y])
          que[++tl] = y, inq[y] = 1;
      }
  }
  return dis[T] > -inf;
}
int dfs(int x, int flow) {
  if (x == T)
    return flow;
  int i, y, k, res = flow;
  for (i = cur[x]; i && res; i = ed[i].nxt) {
    if (ed[i].val && pre[y = ed[i].tar] == x
        && (k = dfs(y, min(res, ed[i].val))))
      ed[i].val -= k, ed[i ^ 1].val += k, res -= k;
    cur[x] = i;
  }
  return flow - res;
}
int maxCost;
inline void Dinic() {
  while (SPFA())
    maxCost += dfs(S, inf) * dis[T];
}

signed main() {
  int n = read(), i, x, y, z;
  int p[4] = {2 * n + 1, 2 * n + 2, 2 * n + 3, 2 * n + 4};
  cntNode = 2 * n + 4;
  for (i = 1; i <= n; ++i) {
    x = read(), y = read(), z = read(), addEdge(S, i, z, 0);
    addEdge(i, p[0], inf, x + y), addEdge(i, p[1], inf, -x - y);
    addEdge(i, p[2], inf, x - y), addEdge(i, p[3], inf, y - x);
  }
  for (i = 1; i <= n; ++i) {
    x = read(), y = read(), z = read(), addEdge(i + n, T, z, 0);
    addEdge(p[0], i + n, inf, -x - y), addEdge(p[1], i + n, inf, x + y);
    addEdge(p[2], i + n, inf, y - x), addEdge(p[3], i + n, inf, x - y);
  }
  
  Dinic(), printf("%lld\n", maxCost);
  return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  bool app[26];
  
  for (int i = 0; i < 26; i++) {
		app[i] = false;
  }
  
  for (int i = 0; i < S.size(); i++) {
		app[S.at(i) - 'a'] = true;
  }
  
  for (int i = 0; i < 26; i++) {
 	if (!app[i]) {
	  cout << char (i + 'a') << endl; 
      return 0;
 	}
  }
  
  cout << "None" << endl; 
  return 0;
       
}

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


int main() {
	int H, N;
	cin >> H >> N;
	vector<int> A(N);
	rep(i, N) {
		cin >> A[i];
	}

	rep(i, N) {
		H -= A[i];
		
	}
	if (H <= 0) {
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}



	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  cout << (N-30)/2 << endl;
  return 0;
}



Measured memory_bytes: 3100
(let* ((a (list (cons (read) (read)) (cons (read) (read)))))
  (princ (if (plusp (- (cdar (sort a #'< :key #'cdr)) (caar (sort a #'> :key #'car))))
             (- (cdar (sort a #'< :key #'cdr)) (caar (sort a #'> :key #'car)))
             0)))

Measured memory_bytes: 3304
S=input()
ans = len(S)
for a in [chr(i+ord("a"))for i in range(26)]:
    if a not in S:
        continue
    I = [-1]+[i for i,s in enumerate(S) if s==a]+[len(S)]
    ans=min(ans, max(j-i-1 for i,j in zip(I,I[1:])))
print(ans)

Measured memory_bytes: 3060
n=int(input())
a,b=map(int,input().split())
for i in range(n-1):
  x,y=map(int,input().split())
  if x*b>y*a:
    if b%y!=0:
      b+=y-(b%y)
    r=b//y
    a=x*r
  else:
    if a%x!=0:
      a+=x-(a%x)
    r=a//x
    b=y*r
print(a+b)
   


Measured memory_bytes: 71760
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
ll h[100005];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1; i<=n; i++)
    {
        scanf("%lld",&h[i]);
    }
    sort(h+1,h+1+n);
    ll ans=inf;
    for(int i=1; (i+k-1)<=n;i++)
    {
        ans=min(ans,(h[k+i-1]-h[i]));
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
p = [0]*m
s = [0]*m
fa = [0]*n
fw = [0]*n
for i in range(m):
    p[i], s[i] = input().split() 
p = [int(s) for s in p]

for i in range(m):
    if fa[p[i]-1] == 0:
        if s[i] == 'AC':
            fa[p[i]-1] = 1
        else:
            fw[p[i]-1] += 1
for i in range(n):
    if fa[i] == 0:
        fw[i] = 0
print(sum(fa), sum(fw))

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

int main(int argc, char const *argv[])
{
    int a;
    string s;

    cin >> a;
    cin >> s;

    if (a >= 3200)
        cout << s << endl;
    else
        cout << "red" << endl;

    return 0;
}

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

class Mondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var ans = int.MaxValue;
        for (int i=-100;i<=100;++i)
        {
            var s = a.Select(x => (x - i) * (x - i)).Sum();
            if (s < ans) ans = s;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
S = input()
T = input()

if(len(T) - len(S) == 1):
  flag = 1
  for i in range(len(S)):
   flag = flag*(S[i]==T[i])
else: 
  flag = 0
  
if(flag == 1):
  print('Yes')
else:
  print('No')
  

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

string s[59];
int t[59];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; i++)
		cin >> s[i] >> t[i];
	string x; cin >> x;
	bool f = false;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (f) ans += t[i];
		if (s[i] == x) f = true;
	}
	cout << ans << '\n';
	return 0;
}	

Measured memory_bytes: 256
import collections
n = int(input())

def factorization(n):
    arr = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt
    if temp!=1:
        arr[temp] = 1
    if arr==[]:
        arr[n] = 1
    return arr


summary = collections.Counter()
for i in range(1, n+1):
    summary = summary + collections.Counter(factorization(i))

ans = 1
for j in summary.values():
    ans *= j + 1

print(ans % (pow(10, 9)+7))

Measured memory_bytes: 41200
def main():
    import sys
    input = sys.stdin.readline
    N,M = map(int,input().split())
    
    A = [list(map(int,input().split())) for i in range(M)]
    A = sorted(A, key=lambda x:x[1])
    A = sorted(A, key=lambda x:x[0])
    
    maxmin = float("inf")
    ans = 0
    for i in range(M):
        a,b = A[i]
        if maxmin <= a:
            ans += 1
            maxmin = b
        elif b < maxmin:
            maxmin = b
    ans += 1
    print(ans)
    
    
    
    
main()

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int N = 5e5 + 10;

int n, k, p[N], q[N];

int t[N << 2], cnt;

int get(int x, int y)
{
	if (!x) return y;
	if (!y) return x;
	return min(x, y);
}

void modify(int x, int v)
{
	t[x += cnt] = v;
	for (x >>= 1; x; x >>= 1)
		t[x] = get(t[x << 1], t[x << 1 | 1]);
}

int query(int l, int r)
{
	int ans = 0;
	l = max(l, 1);
	r = min(r, n);
	if (l > r) return 0;
	for (l += cnt - 1, r += cnt + 1; l ^ r ^ 1; l >>= 1, r >>= 1)
	{
		if (~l & 1) ans = get(ans, t[l ^ 1]);
		if ( r & 1) ans = get(ans, t[r ^ 1]);
	}
	return ans;
}

vector<int> edge[N];

int deg[N];

priority_queue<int> pq;

int ans[N];

int main()
{
	gii(n, k);
	for (int i = 1; i <= n; ++i) gi(p[i]), q[p[i]] = i;
	for (cnt = 1; cnt < n + 2; cnt <<= 1); --cnt;
	for (int i = n; i; --i)
	{
		int x = q[query(q[i] - k + 1, q[i] - 1)];
		if (x) edge[q[i]].pb(x), ++deg[x];
		x = q[query(q[i] + 1, q[i] + k - 1)];
		if (x) edge[q[i]].pb(x), ++deg[x];
		modify(q[i], i);
	}
	for (int i = 1; i <= n; ++i)
		if (!deg[i]) pq.push(-i);
	int cur = 0;
	while (!pq.empty())
	{
		int u = -pq.top(); pq.pop();
		ans[u] = ++cur;
		for (auto v : edge[u])
		{
			--deg[v];
			if (!deg[v])
				pq.push(-v);
		}
	}
	for (int i = 1; i <= n; ++i)
		printf("%d\n", ans[i]);
	return 0;
}



Measured memory_bytes: 44416
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int n,m,used[101010],cmp[101010];
vector<int> v[101010],rv[101010],vs;

void dfs(int x){
   used[x]=true;
   rep(i,v[x].size())if(!used[v[x][i]])dfs(v[x][i]);
   vs.push_back(x);
}

void rdfs(int x,int k){
   used[x]=true;
   cmp[x]=k;
   rep(i,rv[x].size())if(!used[rv[x][i]])rdfs(rv[x][i],k);
}

int scc(){
   rep(i,n)if(!used[i])dfs(i);
   rep(i,n)used[i]=0;
   reverse(vs.begin(),vs.end());
   int k=0;
   rep(i,vs.size())if(!used[vs[i]])rdfs(vs[i],k++);
   return k;
}



int main(){
    cin>>n>>m;
    rep(i,m){
        int s,t;
        cin>>s>>t;
        v[s].push_back(t);
        rv[t].push_back(s);
    }
    scc();
    int q;
    cin>>q;
    rep(i,q){
        int s,t;
        cin>>s>>t;
        cout<<(cmp[s]==cmp[t])<<endl;
    }
    return 0;
}


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

int main(void)
{
    string s;
    cin >> s;

    if(s=="A"){
        cout << "T" << endl;
    }
    if(s=="T"){
        cout << "A" << endl;
    }
    if(s=="C"){
        cout << "G" << endl;
    }
    if(s=="G"){
        cout << "C" << endl;
    }
    
}

Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  ll s;
  cin >> s;
  ll x = 1;
  while(x * x < s) x++;
 
  ll x1, x2, y1, y2;

  if(x * (x - 1) >= s) {
    x1 = x;
    y2 = x - 1;

    x2 = x * x - x - s;
    y1 = 1;
  } else {
    x1 = x;
    y2 = x;

    x2 = x * x - s;
    y1 = 1;
  }

  assert(abs(x1 * y2 - x2 * y1) == s);
  assert(0 <= x1 && x1 <= int(1e9));
  assert(0 <= x2 && x2 <= int(1e9));
  assert(0 <= y1 && y1 <= int(1e9));
  assert(0 <= y2 && y2 <= int(1e9));

  cout << "0 0 ";
  cout << x1 << " " << y1 << " ";
  cout << x2 << " " << y2 << endl;
  return 0;
}


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

struct Problem {

	static ULL gcd(ULL a, ULL b) { return b ? gcd(b, a % b) : a; }
	static const ULL M = 1000000007;

	void Solve() {
		UL N; cin >> N;
		vector<ULL> A(N); rep(i, N) cin >> A[i];
		vector<ULL> iF(N + 1); iF[N] = 1;
		for (UL i = N; i > 0; i--) iF[i - 1] = iF[i] * i % M;
		vector<ULL> F(N + 1); F[0] = 1; rep(i, N) F[i + 1] = F[i] * (i + 1) % M;
		for (UL i = 1; i <= N; i++) iF[i] = iF[i] * F[i - 1] % M;
		ULL ans = 0;
		rep(i, N) ans += A[i] * iF[1] % M;
		ans %= M;
		vector<ULL> SF(N + 1); SF[1] = 0;
		for (UL i = 2; i <= N; i++) SF[i] = (SF[i - 1] + iF[i]) % M;
		//rep(i, N) cout << SF[i + 1] << " "; cout << endl;
		for (UL i = 0; i < N; i++) {
			UL l = i + 1, r = N - i;
			ans += (SF[l] + SF[r]) * A[i] % M;
		}
		ans %= M;
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

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

int main() {
	long n,m,i,j,k,b,ans,cur,res;
	cin >> n >> m;
	vector<long> c(m),dp(n+1,n);
	for(i=0; i<m; i++){
		cin >> c[i];
	}
	sort(c.begin(), c.end());
	
	ans=n;
	dp[0]=0;
	for(i=0; i<m; i++){
		for(j=c[i]; j<=n; j++){
			dp[j]=min(dp[j],dp[j-c[i]]+1);
		}
	}
	cout << dp[n] << endl;
	return 0;
}


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

const int INF = 1<<28;

struct E {
  int to, cost, cap, rev;
  E(int to, int cost, int cap, int rev)
    : to(to), cost(cost), cap(cap), rev(rev) {}
  E() {}
};

typedef vector<vector<E> > G;

void addEdgeF(int from, int to, int cost, int cap, G &g) {
  g[from].push_back(E(to,cost,cap,g[to].size()));
  g[to].push_back(E(from,cost,0,(int)g[from].size()-1));
}

bool used[2000];
G g;

int dfsF(int v, int t, int f) {
  if(v == t) return f;
  used[v] = true;
  for(int i = 0; i < g[v].size(); ++i) {
    E &e = g[v][i];
    if(!used[e.to] && e.cap > 0) {
      int d = dfsF(e.to, t, min(f, e.cap));
      if(d > 0) {
        e.cap -= d;
        g[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int maxFlow(int s, int t) {
  int flow = 0;
  while(1) {
    fill(used, used+2000, 0);
    int f = dfsF(s, t, INF);
    if(f == 0) break;
    flow += f;
  }
  return flow;
}

int gcd(int a, int b) {
  return b == 0 ? a : gcd(b, a%b);
}

int main() {
  int m, n, tmp;
  vector<int> b, r;
  while(cin >> m >> n && (m|n)) {
    b.resize(m);
    r.resize(n);
    for(int i = 0; i < m; ++i) {
      cin >> b[i];
    }
    for(int i = 0; i < n; ++i) {
      cin >> r[i];
    }

    g = G(m+n+2);
    for(int i = 0; i < m; ++i) {
      addEdgeF(m+n, i, 0, 1, g);
    }
    for(int i = 0; i < m; ++i) {
      for(int j = 0; j < n; ++j) {
        if(gcd(b[i], r[j]) != 1) {
          addEdgeF(i, m+j, 0, 1, g);
        }
      }
    }
    for(int i = 0; i < n; ++i) {
      addEdgeF(m+i, m+n+1, 0, 1, g);
    }
    cout << maxFlow(m+n, m+n+1) << endl;
  }
  return 0;
}

Measured memory_bytes: 9188
import java.util.Scanner;

public class Main {

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

	Scanner sc = new Scanner(System.in);

	void run() {

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

		int[] x = new int[n];

		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}

		int min = Integer.MAX_VALUE;
		for (int i = 0; i + k - 1 < n; i++) {
			int ii = i;
			int jj = i + k - 1;
			int ij = 0;

			if ( (long)x[ii] * (long)x[jj] >= 0L) {
				ij = Math.max(Math.abs(x[ii]), Math.abs(x[jj]));
			} else {
				int m1 = Math.max(Math.abs(x[ii]), Math.abs(x[jj]));
				int m2 = Math.min(Math.abs(x[ii]), Math.abs(x[jj]));
				ij = m1 + m2 * 2;
			}
			min = Math.min(ij, min);
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 51484
n = int(input())
s =[[0]*26 for i in range(n)]
a =[50]*26
sa=''
for i in range(n):
    s1=list(input())
    for j in s1:
        s[i][ord(j)-ord('a')]+=1
for j in range(26):
    for i in range(n):
        if a[j]>s[i][j]:
            a[j]=s[i][j]
for i in range(26):
    sa+=chr(ord('a')+i)*a[i]
print(sa)


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

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;

signed main()
{

    double a, b, c, d;
    cin >> a >> b >> c >> d;

    int takahashi = ceil(c / b);
    int aoki = ceil(a / d);

    if (takahashi <= aoki)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3848
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1000000007;const int MAX = 50000;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;

void solve() {
	int N; cin >> N;
	print((N - 1) / 2);
}


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

	solve();
}




Measured memory_bytes: 256
import itertools
n,m,q = map(int,input().split())
abcd = [list(map(int,input().split())) for _ in range(q)]
maxpt = 0
for lis in itertools.combinations_with_replacement(range(1, m+1), n):
    forpt = 0
    for i in range(q):
        if lis[abcd[i][1]-1] - lis[abcd[i][0]-1] == abcd[i][2]:
            forpt += abcd[i][3]
    maxpt = max(maxpt,forpt)
print(maxpt)

Measured memory_bytes: 9208
#  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_C&lang=jp
#  Counter-Clockwise : python3
#  2018.12.11 yonezawa

#from collections import deque
import sys
input = sys.stdin.readline
#import cProfile
from math import cos,sin,radians,sqrt

def crossProduct(s1,s2,s3):
    (x1,y1) = s1
    (x2,y2) = s2
    (x3,y3) = s3
    x1 = x1 - x2
    y1 = y1 - y2
    x3 = x3 - x2
    y3 = y3 - y2
    d = x1 * y3 - y1 * x3
    return d
def distance(s1,s2):
    (x1,y1) = s1
    (x2,y2) = s2
    return sqrt(pow((x1-x2),2) + pow((y1-y2),2))

    

    

def main():
    (x1,y1,x2,y2) = map(int,input().split())
    for i in range(int(input())):
        (x3,y3) = map(int,input().split())
        n = crossProduct((x1,y1),(x2,y2),(x3,y3))
        if n == 0:
            d1 = distance((x1,y1),(x2,y2))
            d2 = distance((x1,y1),(x3,y3))
            d3 = distance((x2,y2),(x3,y3))
            #print (d1,d2,d3,"p1:",x1,y1,"p2:",x2,y2,"p3:",x3,y3)
            #print (round(d1+d2,10),round(d3,10))
            if round(d1 + d2,5) == round(d3,5) and d1 != 0 and d2 != 0:
                print ("ONLINE_BACK")
            elif d1 >= d2 :
                print ("ON_SEGMENT")
            else:
                print ("ONLINE_FRONT")
        elif n > 0:
            print ("CLOCKWISE") 
        elif n < 0:
            print ("COUNTER_CLOCKWISE")


if __name__ == '__main__':
    main()
    #pr = cProfile.Profile()
    #pr.runcall(main)
    #pr.print_stats()


Measured memory_bytes: 5828