akhauriyash/Code-Regression huggingface dataset:
#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 N;
  cin >> N;

  int A;
  int min_a = INT_MAX;
  int max_a = -INT_MAX;
  rep(i, N) {
    cin >> A;
    min_a = min(min_a, A);
    max_a = max(max_a, A);
  }

  cout << max_a - min_a << endl;
  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
ll a[N];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) scanf("%lld",&a[i]);
	sort(a,a+n);
	int l=0,r=n-1,w=1;
	ll ans=1;
	if(k&1) ans=a[r--],k--,w=(ans<0?-1:1);
	while(k){
		ll x=a[l]*a[l+1],y=a[r]*a[r-1];
		if(x*w>y*w) ans=(ans*(x%mod))%mod,l+=2;
		else ans=(ans*(y%mod))%mod,r-=2;
		k-=2;
	}
	printf("%lld\n",(ans%mod+mod)%mod);
}


Measured memory_bytes: 5396
#include <iostream>
#include <vector>
#include <queue>
#include <iomanip>//cout << fixed << setprecision() <<
#include <set>
#include <map>
using ll = long long;
using namespace std;
vector<vector<int>> v;
vector<int> v2;
queue<int> q;

void monmo(int n){
    int momo;
    for(int i=0;i<v[n].size();i++){
        if(v2[v[n][i]]==0){
            v2[v[n][i]]=n;
            q.emplace(v[n][i]);
        }
    }
    if(!q.empty()){
        momo=q.front();q.pop();
        monmo(momo);
    }
}

int main(void){
    int n,m;
    int a,b;
    cin>>n>>m;
    v.emplace_back(); //v[0]は無視
    v2.push_back(0);//v2[0]は無視
    for(int i=0;i<n;i++){
        v.emplace_back();
        v2.push_back(0);
    }
    for(int i=0;i<m;i++){
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    
    monmo(1);
    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++){
        cout<<v2[i]<<endl;
    }
    
}


Measured memory_bytes: 10208
// void merge(int fromP,int toP)
// {
// 	fromP = find_set(fromP);
// 	toP = find_set(toP);

// 	//UNION by RANK
// 	if(nodes[fromP].rank > nodes[toP].rank)	//fromP has higher rank
// 		nodes[toP].parent = fromP;
// 	else if(nodes[fromP].rank < nodes[toP].rank)	//toP has higher rank
// 		nodes[fromP].parent = toP;
// 	else
// 	{
// 		//Both have same rank and so anyone can be made as parent
// 		nodes[fromP].parent = toP;
// 		nodes[toP].rank +=1;		//Increase rank of parent
// 	}
// }

// void merge_set(int a, int b){
//     a = find_set(a);
//     b = find_set(b);
//     if(a!=b){
//         if(nodes[a].rank<nodes[b].rank){
//             nodes[a].parent = b;
//         }
//         else if(nodes[a].rank<nodes[b].rank){
//             nodes[b].parent = a;
            
//         }
//         else{
//             nodes[b].parent = a;
//             nodes[a].rank+=1;
//         }
//     }
// }

#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

struct node{
    int parent = -1;
    int rank = 0;
};

vector<node> nodes;

void make_set(int x){
    nodes[x].parent = x;
    nodes[x].rank = 1;
}

int find_set(int v)
{
	if(nodes[v].parent==v)
		return v;
	return nodes[v].parent=find_set(nodes[v].parent);
}


void merge_set(int a, int b){
    a = find_set(a);
    b = find_set(b);
    if(a!=b){
        if(nodes[a].rank<nodes[b].rank)swap(a,b);
        nodes[b].parent = a;
        if(nodes[a].rank==nodes[b].rank)nodes[a].rank+=1;
    }
}

int main() {
    
    int N,M,a,b;
    cin>>N>>M;
    nodes.resize(N+1);
    
    for(int i=1;i<=N;++i){
        make_set(i);
    }
    
    for(int i=0;i<M;++i){
        cin>>a>>b;
        merge_set(a,b);
    }
    
    unordered_map<int,int> uomap;
    
    for(int i=1;i<=N;++i){
        ++uomap[find_set(nodes[i].parent)];
    }
    
    cout<<uomap.size()-1;
    
  	return 0;
}



Measured memory_bytes: 7500
<?php
fscanf(STDIN, '%d %d %d', $a, $b, $k);

if($k <= $a) {
    $a = $a  - $k;
} else if ($k <= $a + $b) {
   $b = $b- ($k - $a);
   $a = 0;
} else {
$a = 0;
$b = 0;
}
echo $a. " ".$b;
?>

Measured memory_bytes: 16108
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long LL;
const int MAXN = 3e5+10;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
int cnt[100];
signed main(){
    LL n; cin>>n;
    for(int i=1;i<=n;i++){
        LL x; cin>>x;
        for(int j=0;j<=61;j++) cnt[j] += x&(1LL<<j) ? 1:0;
    }
    LL res=0;
    for(int i=0;i<=61;i++)
        res=(res+(((cnt[i]%MOD*((n-cnt[i])%MOD))%MOD)*((1LL<<i)%MOD))%MOD)%MOD;
    cout<<res%MOD<<endl;
    return 0;
}


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

int main() {
    int N;
    int L[110];  // 最大 100 個ですが余裕をもたせます
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> L[i];

    sort(L, L + N, greater<int>());  // a[0:N] を大きい順にソート
    int MaxL=L[0];
    int sumNokori=0;
    for(int i=1;i<N;i++) sumNokori += L[i];
    if(MaxL<sumNokori) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

char str[301000];
int n,e_sum,e_now,w_now,i,j,ans=1000000000;

int main(){

	scanf("%d %s",&n,str);
	
	for(i = 0;i < n;i++){
		if(str[i] == 'E'){
			e_sum++;
		}
	}
	
	for(i = 0;i < n;i++){
		if(str[i] == 'E')e_now++;
		
		if(ans > w_now + (e_sum - e_now)){
			ans = w_now + (e_sum - e_now);
		}
		
		if(str[i] == 'W')w_now++;
	}
	
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>

const long long INF = 1LL << 60;

int min (int a, int b) {
    if (a < b) return a;
    return b;
}

int main () {
    int n;
    std::cin >> n;
    int h[n], dp[n];
    for (int i = 0; i < n; ++i){
        std::cin >> h[i];
        dp[i] = INF;
    }
    dp[0] = 0;
    dp[1] = std::abs(h[0] - h[1]);

    for (int i = 2; i < n; ++i){
        int x = std::abs(h[i-1] - h[i]);
        int y = std::abs(h[i-2] - h[i]);
        dp[i] = min(dp[i-1]+x, dp[i-2] + y);
    }

    std::cout << dp[n-1] << std::endl;
}

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

using namespace std;

int main()
{
   int p, q, r;
   cin >> p >> q >> r;
   int sum;
   int a = p + q;
   int b = p + r;
   int c = q + r;

   if(a < b){
      if(a < c) sum = a;
      else sum = c;
   }else{
      if(b < c) sum = b;
      else sum = c;
   }
   
   cout << sum << endl;

   return 0;
}



Measured memory_bytes: 256
//If you are reading this then you are at wrong place.
#include<bits/stdc++.h>
#define mod 1000000007
#define lli long long int
using namespace std;
bool prime [1000001];
void debug(lli a){cout<<a<<endl;}
vector<int>answer[100001];
		
lli sieve(lli a){memset(prime,true,sizeof(prime));lli p,i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
int main()
{
	//ifstream cin("testcase.txt");
	//ofstream cout("output.txt");	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);	
	cout.precision(20);
	lli t,i,j;
	//cin>>t;
	//memset(dp, -1, sizeof dp);
	t=1;
	lli counter1=0;
	while(t--)
	{
		counter1++;
		int n,m;
		cin>>n>>m;
		int x,y;
		while(m--)
		{
			cin>>x>>y;
			answer[x].push_back(y);
			answer[y].push_back(x);
		}
		for(i=1;i<=n;i++)
			cout<<answer[i].size()<<endl;
		
		//cout<<"Case #"<<counter1<<" ";
		//cout<<endl;	
	}	
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define debug(a) cout<<a<<endl
#define clr(a) memset(a,0,sizeof(a))
#define clrne(a) memset(a,-1,sizeof(a))
#define clrinf(a) memset(a,0x3f,sizeof(a))
#define clrneinf(a) memset(a,0xc0,sizeof(a))
#define pb(a) push_back(a)
#define maxn 10001
#define mod 1000000007
#define eps 1e-9
#define inf 0x7fffffff
map<int,int> mp;
int n,c,k;

int main()
{
//  freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
    scanf("%d%d%d",&n,&c,&k);
    for (int i  =0 ; i<n; i++)
    {
        int temp;
        scanf("%d",&temp);
        mp[temp]++;
    }
    int ans = 0;
    int now =0 ;
    int la = 0;
    map<int,int> ::iterator it;
    for (it = mp.begin(); it!=mp.end(); it++)
    {
        if (now == 0||(now!=0&&it->first-la>k))
        {
//            cout<<'!'<<' '<<it->first<<endl;
//            cout<<la<<' '<<now<<endl;
            ans++;
            now = 0;
            int tt = min(it->second,c);
            now+=tt;
            it->second-=tt;
            la = it->first;
        }
        else
        {
            int tt = min(it->second,c-now);
            now+=tt;
            it->second-=tt;
        }
        now%=c;
        if (it->second!=0)  it--;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 4992
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int n) {
    int ans = 0;
    for (int i = 1; i <= n; i += 2) {
        int x = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) x++;
        }
        if (x == 8) ans++;
    }
    return ans;
}

void main() {
    int n = readint;
    writeln(calc(n));
}


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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)

int a,b,c;


int main(){
  int ans=0;
  cin >> a >> b>>c;
  ans=min(c,b/a);

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int a,b,c,d;
	cin>>a>>b>>c>>d;
	long long int ac=(a*c), ad=(a*d), bc=(b*c), bd=(b*d);
	long long int ans1=max(ac, ad);
	long long int ans2=max(bc,bd);
	cout<<max(ans1, ans2)<<endl;


}

Measured memory_bytes: 3632
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    P = [[int(p) for p in input().split()] for _ in range(N)]
    Ans = [None, None, None]
    for x in range(101):
        for y in range(101):
            hight = 10 ** 20
            fixed = False
            for cx, cy, ch in P:
                if ch == 0: 
                    tempH = abs(x - cx) + abs(y - cy)
                    if not fixed: hight = min(hight, tempH)
                    else:
                        if tempH < hight: break
                else: 
                    tempH = ch + abs(x - cx) + abs(y - cy)
                    if not fixed: 
                        if hight < tempH: break
                        else: 
                            hight = tempH
                            fixed = True
                    else:
                        if hight != tempH: break
            else:
                Ans = [x, y, hight]
                break
        if Ans[0] != None: break

    print(" ".join(map(str, Ans)))
    
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define Rep(i, a, b) for (int (i) = (a) - 1; (i) < (b); (i)++)
#define REP(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define Sort(a, len, cmp) sort(a + 1, a + len + 1, cmp)
#define ass(a, sum) memset(a, sum, sizeof(a))
#define ls ((rt) << 1)
#define rs ((rt) << 1 | 1)
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
#define ENDL cout << endl
#define SZ(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef pair <ll, ll> pll ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
typedef map <ll, ll> mll ;
const int N = 100010 ;
const double eps = 1e-8 ;
const int iinf = INT_MAX ;
const ll linf = 2e18 ;
const double dinf = 1e30 ;
const int MOD = 1000000007 ;
inline int read(){
    int X = 0, w = 0 ;
    char ch = 0 ;
    while (!isdigit(ch)) { w |= ch == '-' ; ch = getchar() ; }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar() ;
    return w ? - X : X ;
}

void write(int x){
     if (x < 0) putchar('-'), x = - x ;
     if (x > 9) write(x / 10) ;
     putchar(x % 10 + '0') ;
}

void print(int x) {
    cout << x << endl ;
    exit(0) ;
}
void PRINT(string x) {
    cout << x << endl ;
    exit(0) ;
}
void douout(double x){
     printf("%lf\n", x + 0.0000000001) ;
}
int n ;
int a[N] ;
string s ;
void get(int x) {
    printf("%d\n", x) ; fflush(stdout) ;
    cin >> s ;
    if (s[0] == 'M') a[x] = 1 ;
    if (s[0] == 'F') a[x] = 2 ;
    if (s[0] == 'V') a[x] = -1, exit(0) ;
}
signed main(){
    cin >> n ;
    int l = 0, r = n - 1 ;
    get(l) ; get(r) ;
    while (l + 1 < r) {
        int mid = (l + r) >> 1 ;
        get(mid) ;
        if ((r - mid - 1) & 1) {
            if (a[mid] == a[r]) r = mid ;
            else l = mid ;
        }
        else {
            if (a[mid] != a[r]) r = mid ;
            else l = mid ;
        }
    }
}



Measured memory_bytes: 852
H, W = map(int, input().split())
S = ["#" * (W + 2)] + ["#" + input() + "#" for _ in range(H)] + ["#" * (W + 2)]

LEFT = [[0 for j in range(W+2)] for i in range(H+2)]
RIGHT = [[0 for j in range(W+2)] for i in range(H+2)]
UP = [[0 for j in range(W+2)] for i in range(H+2)]
DOWN = [[0 for j in range(W+2)] for i in range(H+2)]

for h in range(H+2):
  for w in range(W+2):
    if S[h][w] == ".":
      LEFT[h][w] = LEFT[h][w-1] + 1
    else:
      LEFT[h][w] = 0

for h in range(H+2):
  for w in range(W+2)[::-1]:
    if S[h][w] == ".":
      RIGHT[h][w] = RIGHT[h][w+1] + 1
    else:
      RIGHT[h][w] = 0

for h in range(H+2)[::-1]:
  for w in range(W+2):
    if S[h][w] == ".":
      UP[h][w] = UP[h+1][w] + 1
    else:
      UP[h][w] = 0

for h in range(H+2):
  for w in range(W+2):
    if S[h][w] == ".":
      DOWN[h][w] = DOWN[h-1][w] + 1
    else:
      DOWN[h][w] = 0

ans = -1

for h in range(H+2):
  for w in range(W+2):
    value = RIGHT[h][w] + LEFT[h][w] + UP[h][w] + DOWN[h][w] - 3
    ans = max(ans, value)

print(ans)

Measured memory_bytes: 184580
import java.util.*;
import java.io.*;
 
public class Main{
    public static void main(String[] args){
        Main m = new Main();
        m.input();
    }
 
    
    public void input(){
        Scanner sc = new Scanner(System.in);
        int ans;
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int now = a + b + c;
        int max3 = a * 3;
        if(max3 < b * 3){
            max3 = b * 3;
        }
        if(max3 < c * 3){
            max3 = c * 3;
        }
        if((max3 - now) % 2 == 0){
            ans = (max3 - now)/2;
        }else{
            ans = (max3 - now)/2 + 2;
        }
        System.out.println(ans);
        sc.close();
    }

}

Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n; cin >> n;
    vector<long long int> s(n); rep(i,n) cin >> s[i];
    ll ans = 0;

    for(int k=1;k<n;k++){
        set<long long int> st; 
        ll t = 0;
        ll x = 0;
        while((x+1)*k < n){
            int a = (n-1)-x*k;
           // int b = a - k; if(b <= 0) break;
            if(st.count(x*k) > 0 || st.count(n-1-x*k) > 0 || x*k == n-1-x*k) break;
            st.insert(x*k); st.insert(n-1-x*k); 
            t += s[n-1-x*k] + s[x*k];
            ans = max(ans, t);
            x++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7808
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())


int main() {

	std::cin.tie(0);

	long double tmp,len;
	double l;

	cin >> l ;

	len = l/3;
//	cout << len  << endl;
	tmp = len * len * len;

	std::cout << std::fixed;
	std::cout << std::setprecision(12) << tmp ;

    //cout << tmp << endl;

    return 0;
}


Measured memory_bytes: 256
const lines = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .trim()
  .split("\n");

const [a, b] = lines[0].split(" ").map(n => Number.parseInt(n));

const solver = () => {
  const answer = (a + b) / 2;
  if (answer !== Math.floor(answer)) {
    return "IMPOSSIBLE";
  } else {
    return answer;
  }
};

console.log(solver());


Measured memory_bytes: 7372
#include <iostream>
#include <math.h>
#include<algorithm>
#include <stdio.h>
using namespace std;
const int N = 2e5 + 50;
#define pi acos(-1.0)
#define ll long long
struct point
{
    int x, y;
    double r;
} poi[2 * N];
bool cmp(const point &p1, const point &p2)
{
    return p1.r < p2.r;
}
int n;
ll sx[N * 2], sy[N * 2];
double ans = 0;
void calc(int i, int j)
{
    //cout<<i<<" "<<j<<endl;
    ll t1 = sx[j] - sx[i-1];
    ll t2 = sy[j] - sy[i-1];
    ans = max(ans, sqrt(t1 * t1 + t2 * t2));
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d%d", &poi[i].x, &poi[i].y), poi[i].r = atan2(poi[i].y, poi[i].x);
    sort(poi + 1, poi + 1 + n,cmp);
    for (int i = 1; i <= n; i++)
        poi[i + n] = poi[i], poi[i + n].r += 2.0 * pi;
    for (int i = 1; i <= 2 * n; i++)
        sx[i] = sx[i - 1] + poi[i].x, sy[i] = sy[i - 1] + poi[i].y;
    for (int l = 1, r = 1; l <= n; l++)
    {
        while (r - l < n && poi[r].r <= poi[l].r + pi)
            calc(l,r),r++;
        calc(l+1,r-1);
    }
    printf("%.20f", ans);
    //system("pause");
    return 0;
}

Measured memory_bytes: 4480
import Control.Monad
import Data.Maybe
import Data.List

getLineToIntList = map read . words <$> getLine :: IO[Int]

minimumIndex :: [Int] -> Int
minimumIndex a = (fromJust $ elemIndex (minimum a) a) + 1

main = do
 [n,m] <- getLineToIntList 
 abList <- replicateM n getLineToIntList 
 cdList <- replicateM m getLineToIntList
 forM_ [0..(n-1)] $ \i -> do
  print $ minimumIndex $ map (sum . zipWith (\x y -> abs(x - y)) (abList !! i)) (cdList)

Measured memory_bytes: 4976
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<cmath>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  1000007
#define md 1000000007ll
///////////////////////////
///////////////////////////

int main(){
    int n;
    I(n);
    int ar[n+2];
    for(int i= 1;i<=n;i++)I(ar[i]);
    sort(ar + 1, ar + n+ 1);
    int ans =0;
    for(int i = 1; i<= n; i++) {
        ans += ar[i] - 1;
        
    }
    PI(ans);
    return 0;
}

Measured memory_bytes: 3828
from collections import Counter
N = int(input())
v = list(map(int, input().split()))
e = []
o = []
for idx, i in enumerate(v):
    if idx % 2 == 0:
        o.append(i)
    else:
        e.append(i)

e = Counter(e).most_common()
o = Counter(o).most_common()
e1 = e[0][1]
e2 = e[1][1] if len(e) > 1 else 0
o1 = o[0][1]
o2 = o[1][1] if len(o) > 1 else 0
cnt = 0
if e[0][0] != o[0][0]:
    cnt = N - e1 - o1
else:
    o = N - e1 - o2
    e = N - e2 - o1
    cnt = min(o, e)
print(cnt)


Measured memory_bytes: 20844
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <vector>

using namespace std;
typedef long long LL;

const int maxn = 10005;
const int mod = 1e9+7;

int f[maxn],num[maxn],tot,n,K,ans;
int fpm(LL p,LL k) {
	LL res=1ll;
	while (k) {
		if (k&1) (res*=p)%=mod;
		(p*=p)%=mod;k>>=1;
	}
	return res;
}
int calc(int n) {
	return n&1?n:n>>1;
}

int main()
{
	#ifdef Amberframe
		freopen("arc064f.in","r",stdin);
		freopen("arc064f.out","w",stdout);
	#endif
	scanf("%d %d",&n,&K);
	for (int i=1;i*i<=n;i++)
	if (n%i==0) {
		num[++tot]=n/i;
		if (i*i!=n) num[++tot]=i;
	}
	sort(num+1,num+tot+1);
	for (int i=1;i<=tot;i++)
	{
		f[i]=fpm(K,num[i]+1>>1);
		for (int j=1;j<i;j++)
		if (num[i]%num[j]==0)
			f[i]=(f[i]-f[j])%mod;
		ans=(ans+(LL)f[i]*calc(num[i]))%mod;
	}
	printf("%d",ans<0?ans+mod:ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef    long long          ll;
typedef    vector<long long>    vi; 
typedef    vector<vi>         vvi; 
typedef    pair<long,long>      ii; 
#define    sz(a)              long((a).size()) 
#define    pb                 push_back 
#define    mp                   make_pair
#define    all(c)             (c).begin(),(c).end() 
#define    tr(c,i)            for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define    present(c,x)       ((c).find(x) != (c).end()) 
#define    cpresent(c,x)      (find(all(c),x) != (c).end())  
#define    input(v,n)           for(ll i = 0 ; i<n ; i++) cin>>v[i]
#define    output(v,n)          for(ll i = 0 ; i<n ; i++) cout<<v[i]<<" "

 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ll n,w,i,j;
    cin>>n>>w;
  ll ww[n+1]={};
  ll v[n+1]={};
  ll dp[n+2][w+2]={};

  for(i=1;i<=n;i++){
    cin>>ww[i];
      cin>>v[i];
  }

 

  for(i=1;i<=n;i++)
  {
    for(j=1;j<=w;j++){

      if(i)dp[i][j]=dp[i-1][j];
      if(ww[i] <=j ){
        dp[i][j]=max(dp[i][j],dp[i-1][j-ww[i]] + v[i]);
      }
    }
  }

  cout<<dp[n][w]<<"\n";



  return 0;
}


Measured memory_bytes: 80000
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, K;
//---------------------------------------------------------------------------------------------------
string ask(int x) {
    printf("%d\n", x + 1);
    fflush(stdout);

    string s; cin >> s;
    return s;
}
//---------------------------------------------------------------------------------------------------
void solve1() {
    printf("0\n");
    fflush(stdout);

    rep(k, 0, K) rep(i, 0, N) if (ask(i) == "Yes") break;
}
void solve2() {
    vector<pair<int, int>> v;
    rep(i, 8, N) rep(d, 0, 8) if (i & (1 << d)) v.push_back({ d, i });
    int n = v.size();
    printf("%d\n", n);
    fore(p, v) printf("%d %d\n", p.first + 1, p.second + 1);

    rep(k, 0, K) {
        int ans = 0, ng = 1;
        rep(d, 0, 8) {
            string res = ask(d);

            if (res == "Yes") {
                ng = 0;
                break;
            }
            if (res == "Near") ans += 1 << d;
        }
        if (ng) ask(ans);
    }
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;

    if (N <= 10) solve1();
    else solve2();
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

int main() {
    int n, a;
    cin >> n >> a;
    cout << n * n - a << endl;
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    map<int, int> anss;
    for(int i=1;i<n;i++){
        cin >> a[i];
        anss[a[i]]++; 
    }

    for(int i=1;i<=n;i++){
        cout << anss[i] << endl;
    }

}

Measured memory_bytes: 13756
import numpy as np
n,m = map(int,input().split())
a = np.zeros(m)
b = np.zeros(m)
for i in range(m):
    a[i] , b[i] = map(int ,input().split())

a -= 1
b -= 1 
cnt = 0

while(a.shape[0]):
    out_of_task = (a >= np.min(b)).astype(np.bool)
    cnt += 1
    a = a[out_of_task]
    b = b[out_of_task]
    
print(cnt)

Measured memory_bytes: 15032
#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() {
	
	ll n, m;
	cin >> n >> m;
	ll ans;
	if(n == 1){
		ans = abs(m - 2);
	}else if(m == 1){
		ans = n - 2;
	}else{
		ans = (n - 2) * (m - 2);
	}
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

void dfs(vector<vector<long long int>> &dp,vector<vector<long long int>> &adj,long long int i,long long int parent){
  dp[i][0] = 1;
  dp[i][1]=1;
  for(auto e: adj[i]){   
    if(e == parent) continue;
    dfs(dp,adj,e,i);
    dp[i][1] = ((dp[i][1]%1000000007) * (dp[e][0]%1000000007))%1000000007;
    dp[i][0] = ((dp[i][0]%1000000007) * ((dp[e][0]%1000000007 + dp[e][1]%1000000007)%1000000007))%1000000007;
  }
  return;
}

int main(){
  int n;
  long long int a,b;
  cin >> n;
  vector<vector<long long int>> adj(n+1);
  for(int i=0;i<n-1;i++){
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  
  vector<vector<long long int>> dp(n+1,vector<long long int>(2,0));
  dfs(dp,adj,1,-1);
  cout << (dp[1][0] + dp[1][1])%1000000007 << endl;
  return 0;
}


Measured memory_bytes: 22452
n = int(input())

xy = [[-1 for i in range(101)] for j in range(101)]

x = []
y = []
h = []
for i in range(n):
  xx, yy, hh = map(int, input().split())
  x.append(xx)
  y.append(yy)
  h.append(hh)
  if hh > 0:
    x0, y0, h0, = xx, yy, hh

for i in range(101):
  for j in range(101):
    flg = 0
    tmp = h0 + abs(x0-i) + abs(y0-j)
    for k in range(n):
      if h[k] != max(tmp - abs(x[k]-i) - abs(y[k]-j),0):
        flg = 1
        break
    if flg == 0:
      print (i,j,tmp)
      exit()

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

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

  int64_t ans = k;
  for (int i = 1; i < n; i++) {
    ans *= k - 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
s = gets.chomp
ans = 'NA'
if (1..12).include? (s[0] + s[1]).to_i
    if (1..12).include? (s[2] + s[3]).to_i
        ans = 'AMBIGUOUS'
    else
        ans = 'MMYY'
    end
elsif (1..12).include? (s[2] + s[3]).to_i
    ans = 'YYMM'
end
puts ans

Measured memory_bytes: 1788
import Control.Applicative
import Control.Monad
import Data.Array
import Data.Array.ST
import Data.Char
import Data.List
import qualified Data.Map as M
import qualified Data.Set as S
import Text.Printf

readInts :: IO [Int]
readInts = map read . words <$> getLine

main :: IO ()
main = do
  [a,b,c] <- map read . words <$> getLine
  let (s,l,h) = solve a b c
  print s
  print l
  print h

solve :: Double -> Double -> Double -> (Double, Double, Double)
solve a b c = (s, l, h)
 where
  s = 0.5 * a * b * sin th
  l = a + b + sqrt (a^2 + b^2 - 2 * a * b * cos th)
  h = s * 2 / a
  th = c * pi / 180



Measured memory_bytes: 4212
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll N, vector<ll> a) {
  vector<pair<ll,ll>> vec;
  REP(i,N) vec.emplace_back(a[i], i);
  sort(vec.rbegin(), vec.rend());
  vector<ll> res(N);
  ll now = vec.front().second, val = vec.front().first, cnt = 0;
  for (auto p: vec) {
    // cout << now << " " << val << " " << cnt << endl;
    if (p.second >= now) {
      res[now] += (val - p.first) * cnt;
      ++cnt;
      val = p.first;
    }
    else {
      res[now] += (val - p.first) * cnt;
      now = p.second;
      val = p.first;
      ++cnt;
    }
    // for (ll i: res) cout << i << " ";
    // cout << endl;
  }
  res[0] += val * cnt;
  for (ll i: res) cout << i << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> a(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &a[i]);
	}
	solve(N, a);
	return 0;
}


Measured memory_bytes: 4976
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <stack>
using namespace std;

int main() {
    int N; cin >> N;
    vector<int> p(N);
    for (int i = 0; i < N; ++i) {
        cin >> p[i];
    }
    bool flag = true;
    bool flag2 = true;

    for (int i = 0; i < N; ++i) {
        if (p[i] != i + 1) {
            flag = false;
            for (int j = 0; j < N; ++j) {
                if (p[j] == i + 1) {
                    swap(p[i], p[j]);
                }
            }
            for (int k = 0; k < N-1; ++k) {
                if (p[k] > p[k+1]) {
                    flag2 = false;
                    break;
                }
                flag = true;
            }
        }
    }

    if (flag && flag2)  cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
/*---------------------------*\
____________Mari000____________         
________Mostafa  Shehab________    
\*---------------------------*/

#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
typedef long long ll;
typedef long double ld;
//template <class Type>

ll power(ll x,ll y,ll p);
int Bit(ll x);
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}

const int N=1e6;
ll arr[N];



int n;
ll l,r,cnt,Sum,h;
vector<pair<int,int>> vec;
vector<int> v;


int main(){
	scanf("%d%lld",&n,&h);
	for(int i=0;i<n;++i)
		vec.push_back({D(),D()});
	
	sort(vec.begin(),vec.end());
	int idx=0;
	for(int i=1;i<n;++i)
		if(vec[i].first>vec[idx].first)
			idx=i;
			
	for(int i=0;i<n;++i)
		if(vec[i].second>= vec[idx].second || vec[i].second>vec[idx].first)
			v.push_back(vec[i].second);
	
		
			
	sort(v.rbegin(),v.rend());
	
	for(int i=0;i<v.size() && h>0;++i)
		h-=v[i],++cnt;
		

	if(h>0)
		cnt+=ceil(1.0*h/vec[idx].first);

	printf("%lld",cnt);
	

	

}










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


int Bit(ll x){
	if(!x)
		return 0;
	return 1+Bit(x>>1);
}


















Measured memory_bytes: 1908
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 998244353
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

ll pow_mod(ll a, ll b, ll m = mod){
    ll ret = 1;
    while (b > 0) {
        if (b & 1) {
            ret = ret * a % m;
        }
        a = a * a % m;
        b >>= 1;
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> B(N);
    rep(i, N) B[A[i]]++;
    if(A[0] != 0) {
        output(0);
        return 0;
    }
    rep(i, 1, N) {
        if(A[i] == 0) {
            output(0);
            return 0;
        }
    }
    
    ll ans = 1;
    rep(i, N - 1) {
        ans *= pow_mod(B[i], B[i + 1]);
        ans %= mod;
    }
    output(ans);
    return 0;
    
}


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

int main(){
  int N;
  cin >> N;
  if(N==100000){
    cout << 10;
  }
  else{
  int a[5]={};
  int b[5]={};
  int i=4;
  int sum = 0;
  while(N>0){
    a[i]=N%10;
    sum += a[i];
    N /= 10;
    i--;
  }
  
  int counter = 0;
  for(int j=0;j<5;j++){
    if(a[j]==0){
      counter++;    
    }
  }
  if(counter == 4){
      int c;
      for(int i=0;i<5;i++){
        if(a[i] !=0){
          c = a[i];
        }
      }
      if(c>=2){
        cout <<sum;
      }
      else{
        cout << 10;
      }
  }
else{
  cout << sum;
}
}
return 0;
}





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

int main(){
  bitset<100> snukes;
  int n,k; cin >> n >> k;
  for(int i = 0; i<k; i++){
    int d; cin >> d;
    for(int j = 0; j<d; j++){
      int a; cin >> a;
      snukes[a-1] = 1;
    }
  }
  cout << n - snukes.count() << endl;
}

Measured memory_bytes: 3596
;;(declaim (optimize (speed 0) (safety 3) (debug 3)))
#+sbcl (declaim (sb-ext:unmuffle-conditions sb-ext:compiler-note))
(declaim (optimize (speed 3) (safety 0) (debug 0)))

(declaim (type fixnum *sunuke-n* *okashi-n*))
(defvar *sunuke-n* (read))
(defvar *okashi-n* (read))

(declaim (type (simple-array boolean (*)) *victims*))
;; sunuke n is a victim when (aref *victims* (1- n))
(defvar *victims* (make-array *sunuke-n*
			      :initial-element t
			      :element-type 'boolean))

(dotimes (okashi-i *okashi-n*)
  (let ((d (read)))
    (declare (type fixnum d))
    (dotimes (i d)
      (let ((sunuke-id (read)))
	(declare (type fixnum sunuke-id))
	(setf (aref *victims* (1- sunuke-id)) nil)))))

(princ (count t *victims*))


Measured memory_bytes: 29828
from collections import deque

n, m = map(int, input().split())
eg = [[] for _ in range(n + 1)]

al = [0] * m
bl = [0] * m

for i in range(m):
    a, b = map(int, input().split())
    eg[a].append(b)
    eg[b].append(a)
    al[i], bl[i] = a, b

ans = 0
for i in range(m):
    x, y = al[i], bl[i]
    q = deque()
    q.append(1)
    seen = {1}
    while q:
        v = q.pop()
        for t in eg[v]:
            if t in seen:
                continue
            elif (v == x and t == y) or (v == y and t == x):
                continue
            q.append(t)
            seen.add(t)
    if len(seen) != n:
        ans += 1
print(ans)


Measured memory_bytes: 82632
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
int n, a[N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n;
 	for(int i=1; i<=n; i++) cin >> a[i];
 	sort(a+1, a+n+1);
 	bool ok = 1;
 	for(int i=2; i<=n; i++) if(a[i]==a[i-1]) ok = 0;
 	if(ok) cout << "YES\n";
 	else cout << "NO\n";
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int n;
  cin >> n;
  long long int a[n],b[n];
  vector<long long int> s(n);
  long long int asum=0,bsum=0;
  long long int samax = 0;
  long long int saind = 0;
  long long int gkk=0;
  for(int i=0; i<n; i++){
    cin >> a[i];
    asum += a[i];
  }
  for(int i=0; i<n; i++){
    cin >> b[i];
    s.at(i) = a[i]-b[i];
    bsum += b[i];
    if(a[i] >= b[i]){
      gkk++;
    }
  }
  
  sort(s.begin(),s.end());
  reverse(s.begin(),s.end());
  long long int fgkksum=0;
  long long int gkksum=0;
  long long int kubar=0;
  
  if(asum < bsum){
    cout << -1 << endl;
  }else{
    if(gkk == n){
      cout << 0 << endl;
    }else{
      for(int i=0; i<n; i++){
        if(s.at(i) < 0){
          fgkksum -= s.at(i);
        }
      }
      for(int i=0; i<n; i++){
        if(s.at(i) > 0){
          gkksum += s.at(i);
          kubar++;
        }
        if(gkksum >= fgkksum){
          break;
        }
      }
      cout << kubar+n-gkk << endl;
    }
  }
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();
            p.Solve();
        }

        void Solve()
        {
            int n = int.Parse(Console.ReadLine());
            Console.WriteLine(GetNum(n).ToString());
        }

        private long[] x = new long[87];

        long GetNum(int n)
        {
            x[0] = 2;
            x[1] = 1;
            if (n == 0)
                return x[0];
            else if (n == 1)
                return x[1];

            for (int i = 2; i <= n; i++)
            {
                x[i] = x[i - 1] + x[i - 2];
            }
            return x[n ];
        }

    }
}


Measured memory_bytes: 13268
n = int(input())
p = list(map(int,input().split()))
l = []
for i in range(n):
    if i+1==p[i]:
        l.append(i)
ans = len(l)
cnt = 0
for i in range(len(l)):
    if l[i]-1==l[i-1]:
        cnt += 1
    elif cnt>0:
        ans -= cnt//2+cnt%2
        cnt = 0
    if i==len(l)-1 and cnt>0:
        ans -= cnt//2+cnt%2
print(ans)


Measured memory_bytes: 56172
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)
def rec(v):
    if dp[v]!=-1:return dp[v]
    res=0
    for nv in graph[v]:
        res=max(res,rec(nv)+1)
    dp[v]=res
    return res
def main():
    n,m=map(int,input().split())
    XY=[tuple(map(int,input().split())) for i in range(m)]
    global dp,graph
    graph=[[]for _ in range(n)]
    for x,y in XY:
        graph[x-1].append(y-1)
    dp=[-1]*n #頂点i(0-)を始点としたときの有効パスの長さの最大値
    ans=0
    for v in range(n):
        ans=max(ans,rec(v))
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 141960
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"4 3 6"# => "safe",
// r#"6 5 1"# => "delicious",
// r#"3 7 12"# => "dangerous",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: i64,
        b: i64,
        c: i64,
    }

    std::cmp::min(std::cmp::min(a + b, a + c), b + c).to_string()
}

Measured memory_bytes: 4352
import Data.List
import Data.Array
import Data.Maybe
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8

getInt :: IO Int
getInt = read <$> getLine

getInts :: IO [Int]
getInts = (map parseInt . BS8.words) <$> BS.getLine 
    where parseInt = fst . fromJust . BS8.readInt

solve :: Int -> Int -> [Int] -> Int
solve n k ls = foldl (+) 0 $ take (length v - k) v
    where v = sort $ map length $ group (sort ls)

main :: IO ()
main = do
    [n, k] <- getInts
    ls <- getInts
    print (solve n k ls)

Measured memory_bytes: 32124
n = int(input())
if n == 1:
    print(1)
else:
    buf = []
    for i in range(n):
        x,y = map(int,input().split())
        buf.append([x,y])
    
    buf.sort()
    
    ans = 1e9
    for i in range(n):
        for j in range(i+1,n):
            p,q = buf[j][0]-buf[i][0],buf[j][1]-buf[i][1]
    
            ind = 0
            used = set()
            tcost = 0
            befx = 0
            befy = 0
            flag = False
            while True:
                befx,befy = buf[ind][0],buf[ind][1]
                tcost += 1
                for l in range(n):
                    if l not in used:
                        tx,ty = buf[l][0],buf[l][1]
                        if tx-befx == p and ty-befy == q:
                            befx = tx
                            befy = ty
                            used.add(l)
                while True:
                    ind += 1
                    if ind == n:
                        flag = True
                        break
                    if ind in used:
                        continue
                    else:
                        break
                if flag:
                    break
            if ans > tcost:
                # print(used)
                # print(p,q,tcost)
                ans = tcost
    
    print(ans)





Measured memory_bytes: 45676
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function bsearch(a,x);l,r=0,length(a)+1;while r-l>1;m=(r+l)>>1;if a[m]<=x;l=m;else;r=m;end;end;l;end

function main()
	n = readline() |> parseInt
	a = zeros(Int,n)
	for i in 1:n
		a[i] = readline() |> parseInt
	end
	push!(a,0)
	a = sort(a,rev=true)
	b = Tuple{Int,Int}[(a[1],1)]
	l = 1
	k = 1
	for i in 2:n
		if a[i]==b[l][1]
			b[l]=(a[i],b[l][2]+1)
			k += 1
		else
			k+=1
			push!(b,(a[i],k))
			l+=1
		end
	end
	if l==1
		println(b[1][1]%2==1?"first":"second")
	else
		x = 0
		for i in 1:l-1
			k=b[i][1]-b[i+1][1]
			if k%2==1
				x=x$b[i][2]
			end
		end
		if b[l][1]%2==1
			x=x$b[l][2]
		end
		println(x==0?"second":"first")
	end
end

main()

Measured memory_bytes: 130432