akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
t,a = LI()
h = LI()
ans = inf
for i in range(n):
    if ans > abs(a-(t-h[i]*0.006)):
        ans = abs(a-(t-h[i]*0.006))
        idx = i+1
print(idx)

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

int main() {
  int N;
  cin >> N;
  int count = 0;
  int max = 100000000;

  for (int i = 0; i < N; i++){
    count = 0;
    int A;
    cin >> A;
    while (A % 2 == 0){
      A /= 2;
      count++;
    }
    if(count < max){
      max = count;
    }
  }
  cout << max << endl;
}

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

int a[100005],b[100005],c[100005];

int main(){
	int ans=0;
	int n;
	scanf("%d",&n);
	for(register int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int m=0;
	sort(a+1,a+n+1);
	for(register int i=1;i<=n;i++){
		if(a[i]!=c[m]){
			c[++m]=a[i];
			b[m]=1;
		}
		else{
			b[m]++;
		}
	}
	for(register int i=1;i<=m;i++){
		if(b[i]>=c[i]){
			ans+=b[i]-c[i];
		}
		else ans+=b[i];
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1280
#include <cstdio>

int main() {
	int h, w;
	while(scanf("%d%d", &h, &w) == 2 && (h || w)) {
		for(int i = 1; i <= h; i++) {
			for(int j = 1; j <= w; j++) putchar('#');
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 2612
#include <iostream>
#include <limits>
#include <cfenv>
#include <cmath>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <random>
#include <math.h>
#include <list>
#include <random>
#include <functional>


#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

using lli = long long int;
using pii = std::pair<int, int>;

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


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


constexpr long double EPS = 1e-8;
constexpr int inf = 2e9;
constexpr std::pair<int, int> id(inf, -inf);
std::array<std::pair<int, int>, 3> X{id, id, id}, Y{id, id, id};

void update(std::pair<int, int>& p, int v){
    if(p.first > v) p.first = v;
    if(p.second < v) p.second = v;
}

long double area(long double t){
    long double xmin = X[2].first, xmax = X[2].second;
    long double ymin = Y[2].first, ymax = Y[2].second;
    if(X[0].first  + t < xmin) xmin = X[0].first  + t;
    if(X[0].second + t > xmax) xmax = X[0].second + t;
    if(X[1].first  - t < xmin) xmin = X[1].first  - t;
    if(X[1].second - t > xmax) xmax = X[1].second - t;

    if(Y[0].first  + t < ymin) ymin = Y[0].first  + t;
    if(Y[0].second + t > ymax) ymax = Y[0].second + t;
    if(Y[1].first  - t < ymin) ymin = Y[1].first  - t;
    if(Y[1].second - t > ymax) ymax = Y[1].second - t;
    if(std::abs(xmax - xmin) < EPS) return 0;
    if(std::abs(ymax - ymin) < EPS) return 0;
    return (xmax - xmin) * (ymax - ymin);
}

int main(void){
    int n; scanf("%d", &n);
    REP(i, n){
        int x, y; char c; scanf("%d%d %c", &x, &y, &c);
        switch (c)
        {
        case 'R':
            update(X[0], x);
            update(Y[2], y);
            break;
        case 'L':
            update(X[1], x);
            update(Y[2], y);
            break;
        case 'U':
            update(Y[0], y);
            update(X[2], x);
            break;
        case 'D':
            update(Y[1], y);
            update(X[2], x);
            break;
        }
    }
    long double l = 0, r = 2e9;
    REP(_, 100){
        long double L = (2 * l + r) / 3;
        long double R = (l + 2 * r) / 3;
        long double Sl = area(L), Sr = area(R);
        if(Sl < Sr) r = R;
        else l = L;
        if(std::abs(r - l) < EPS) break;
    }
    printf("%.16Lf\n", area(l));

    

    return 0;
}


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

using namespace std;

int main()
{ 
  while(1){
    int n;
    cin>>n;

    if(n == 0){
      break;
    }

    vector<pair<int,int>> total_result;
    int result;
    vector<char> team;

    for(int i = 0;i < n;++i){
      int point = 0;
      char name;
      cin>>name;
      team.push_back(name);


      for(int j = 0;j < n - 1;++j){
        cin>>result;
        if(result == 0){
          point -= 100;
        }
        else if(result == 2){
          point -= 1;
        }
      }

      total_result.push_back(make_pair(point,i));
    }

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

    for(int i = 0;i < n;++i){
      cout<<team.at(total_result[i].second)<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>

using namespace std;

const int hoken = 10;

const double EPS = 1e-9;
const double PI = acos(-1);

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, int> AngleP;

int main() {
	int N;
	P engine[100 + hoken];
	AngleP angle[100 + hoken];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> engine[i].first >> engine[i].second;
		if (abs(engine[i].first) < EPS && abs(engine[i].second) < EPS) {
			angle[i].second = i, angle[i].first = 0;
		}
		else {
			angle[i].second = i, angle[i].first = atan2(engine[i].second, engine[i].first);
		}
	}
	sort(angle, angle + N);
	//ll tx = engine[angle[0].second].first, ty = engine[angle[0].second].second;
	/*
	double ans = sqrt(tx * tx + ty * ty);
	int r = 1;
	
	for (int l = 0; l < 2 * N; l++) {
		//[l, r)の番目のものをしゃくとり
		ans = max(ans, sqrt(tx * tx + ty * ty));
		while (r < 2 * N && r - l < N && 
			ans <= 
			sqrt(pow(tx + engine[angle[r % N].second].first, 2) + pow(ty + engine[angle[r % N].second].second, 2))
			+ EPS) {
			tx += engine[angle[r % N].second].first, ty += engine[angle[r % N].second].second;
			r++;
			ans = max(ans, sqrt(tx * tx + ty * ty));
		}
		ans = max(ans, sqrt(tx * tx + ty * ty));

		if (l == r)r++;
		else {
			tx -= engine[angle[l % N].second].first, ty -= engine[angle[l % N].second].second;
			ans = max(ans, sqrt(tx * tx + ty * ty));
		}
	}*/

	double ans = 0;
	for (int i = 0; i < N; i++) {
		ll tx = engine[angle[i].second].first, ty = engine[angle[i].second].second;
		ans = max(ans, sqrt(tx*tx + ty*ty));
		for (int j = i + 1; j < N + i; j++) {
			int k = j % N;
			tx += engine[angle[k].second].first, ty += engine[angle[k].second].second;
			ans = max(ans, sqrt(tx*tx + ty*ty));
		}
	}

	cout << setprecision(12) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            long need = 1;
            while (need * (need + 1) / 2 < n) need++;
            long prev = (need) * (need - 1) / 2;
            long shift = n - prev;
            long csum = 0;
            for (int i = 1; i < need - shift; i++) {
                out.println(i);
                csum += i;
            }
            for (long i = need; csum < n; i--) {
                csum += i;
                out.println(i);
            }


        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

ll N;

void solve() {
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    if (N % 2 == 0) {
        ll dp[N][2];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 2; j++) {
                dp[i][j] = -INF;
            }
        }
        
        for (int i = 0; i < 2; i++) dp[i][1 - i] = a[i];
        
        for (int i = 0; i < N - 2; i++) {
            for (int extras = 0; extras < 2; extras++) {
                if (extras == 0) {
                    chmax(dp[i + 2][0], dp[i][0] + a[i + 2]);
                } else {
                    chmax(dp[i + 2][1], dp[i][1] + a[i + 2]);
                    if (i < N - 3) chmax(dp[i + 3][0], dp[i][1] + a[i + 3]);
                }
            }
        }
        
        cout << max(dp[N - 2][1], dp[N - 1][0]);
    } else {
        if (N == 3) {
            cout << max(max(a[0], a[1]), a[2]);
            return;
        }
        
        // ll ans = -INF;
        ll dp[N][3];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 3; j++) {
                dp[i][j] = -INF;
            }
        }
        
        for (int i = 0; i < 3; i++) dp[i][2 - i] = a[i];
        
        for (int i = 0; i < N - 2; i++) {
            for (int extras = 0; extras < 3; extras++) {
                if (extras == 0) { 
                    chmax(dp[i + 2][0], dp[i][0] + a[i + 2]);
                } else if (extras == 1) {
                    chmax(dp[i + 2][1], dp[i][1] + a[i + 2]);
                    if (i < N - 3) chmax(dp[i + 3][0], dp[i][1] + a[i + 3]);
                } else {
                    chmax(dp[i + 2][2], dp[i][2] + a[i + 2]);
                    if (i < N - 3) chmax(dp[i + 3][1], dp[i][2] + a[i + 3]);
                    if (i < N - 4) chmax(dp[i + 4][0], dp[i][2] + a[i + 4]);
                }
            }
        }
        
        cout << max(max(dp[N - 3][2], dp[N - 2][1]), dp[N - 1][0]);
        
    }
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 9524
n,m,c = map(int,input().split())
b=list(map(int,input().split()))
ret = 0
for i in range(n):
    a = list(map(int,input().split()))
    cnt = c
    for j in range(m):
        cnt+=a[j]*b[j]
    if cnt > 0:
        ret+=1
print(ret)


Measured memory_bytes: 2940
/*  ex2_3
    B30095    */
#include <stdio.h>

int main(void){
    int n = 0, whiteNum = 0, blackNum = 0;

    scanf("%d", &n);
    scanf("%d", &whiteNum);

    blackNum = n * n - whiteNum;
    printf("%d\n", blackNum);

    return 0;
}

Measured memory_bytes: 128
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

vector<bool> IsPrime;

void sieve(int max) {
  if (max+1 > IsPrime.size()) {
    IsPrime.resize(max+1, true);
  }
  IsPrime[0] = false;
  IsPrime[1] = false;

  for (int i = 2; i*i <= max; i++) {
    if (IsPrime[i]) {
      for (int j = 2; i*j <= max; j++) {
        IsPrime[i*j] = false;
      }
    }
  }
}

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

  sieve(n);
  vector<ll> c(n + 1, 1);
  FOR(i, 2, n + 1) {
    int m = i;
    while (m != 1) {
      FOR(j, 2, n + 1) {
        if (IsPrime[j] && m % j == 0) {
          c[j]++;
          m /= j;
          break;
        }
      }
    }
  }

  ll ans = 1;
  rep(i, n + 1) ans = (ans * c[i]) % mod;
  cout << ans << endl;




  
  return 0;
}

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

constexpr int MAX = 100;

int n;
int maxtime;

int a[MAX], b[MAX], m[MAX];

int board[MAX * 6 + 1];

int compress() {
	std::vector<int> xs;

	for (int i = 0; i < n; ++i) {
		for (int d = -1; d <= 1; ++d) {
			int tx1 = a[i] + d, tx2 = b[i] + d;
			if (0 <= tx1&&tx1 <= maxtime)
				xs.emplace_back(tx1);
			if (0 <= tx2&&tx2 <= maxtime)
				xs.emplace_back(tx2);
		}
	}
	std::sort(xs.begin(), xs.end());
	for (int i = 0; i < n; ++i) {
		a[i] = std::lower_bound(xs.begin(), xs.end(), a[i]) - xs.begin();
		b[i] = std::lower_bound(xs.begin(), xs.end(), b[i]) - xs.begin();
	}
	return xs.size();
}

int main() {
	while (std::cin >> n) {
		if (n == 0)
			break;
		maxtime = 0;
		std::memset(board, 0, sizeof(board));
		for (int i = 0; i < n; ++i) {
			std::cin >> m[i] >> a[i] >> b[i];
			maxtime = std::max(maxtime, b[i]);
		}
		int mm = compress();
		for (int i = 0; i < n; ++i) {
			board[a[i]] += m[i];
			board[b[i]] -= m[i];
		}
		for (int i = 1; i < mm; ++i)
			board[i] += board[i - 1];
		for (int i = 0; i < mm; ++i) {
			if (board[i] > 150) {
				std::cout << "NG" << std::endl;
				goto a;
			}
		}
		std::cout << "OK" << std::endl;
	a:;
	}
	return 0;
}

Measured memory_bytes: 3148
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
print((n-1)//2)

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

int main() {
	string n;
	int sum = 0;
	cin >> n;

	for (int i = 0; i < n.size(); ++i) {
		sum += int(n[i]) - 48;
	}
	if (sum % 9 == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

c1 = a[0]
c2 = sum(a) - a[0]

ans = abs(c2 - c1)
for i in range(1, len(a) - 1):
    c1 += a[i]
    c2 -= a[i]
    ans = min(ans, abs(c2 - c1))
print(ans)


Measured memory_bytes: 24812
#include <stdio.h>

#define WHITE 0
#define BRACK 1
#define inf 1000000000
#define NIL -1

int n,d[101],pi[101],color[101],G[101][101],count = 0;

int dijkstra(int r)
{
  int u,mincost,i,v;
  for(u = 1;u <= n;u++)
    {
      d[u] = inf;
      pi[u] = NIL;
      color[u] = WHITE;
    }
  d[r] = 0;
  while(1)
    {
      mincost = inf;
      for(i = 1;i <= n;i++)
	{
	  if(color[i] != BRACK && d[i] < mincost)
	    {
	      mincost = d[i];
	      u = i;
	    }
	}
      if(mincost == inf)
	{
	  break;
	}
      color[u] = BRACK;
      for(v = 1;v <= n;v++)
	{
	  if(color[v] != BRACK && G[u][v] < d[v] && G[u][v] != -1 &&d[u] + G[u][v] < d[v])
	    {
	      pi[v] = u;
	      d[v] =d[u] + G[u][v];
	    }
	} 
    }
  for(i = 1;i <= n;i++)
	{
	  if(pi[i] != NIL)
	    {
	      count = count + G[i][pi[i]];
	    }
	}
  return count;
}

int main()
{
  int i,j,answer,u,k,v;
  
  scanf("%d",&n);
  for(i = 1;i <= n;i++)
    {
      for(j = 1;j <= n;j++)
	{
	  G[i][j] = -1;
	}
    }

  for(i = 1;i <= n;i++)
    {
      scanf("%d %d",&u,&k);
      for(j = 1;j <= k;j++)
	{
	  scanf("%d",&v);
	  scanf("%d",&G[i][v + 1]);
	}
    }

  dijkstra(1);

  for(v = 0;v < n;v++)
    {
      printf("%d %d\n",v,d[v + 1]);
    }
  
  return 0;
}



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

bool comp(string s, string t){
    if(s.length() == t.length())    return s < t;
    return s.length() < t.length();
}

int main(){
    int w, h;
    while(cin >> w >> h, w+h){
        char mat[h][w];
        for(int i = 0; i < w*h; i++)    cin >> mat[i/w][i%w];

        string s[h][w];
        for(int i = 0; i < h*w; i++)    s[i/w][i%w] = "";

        string ans = "";

        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(isdigit(mat[i][j])){
                    string prefix = "";
                    if(i != 0 && s[i-1][j] != "") prefix = s[i-1][j];
                    if(j != 0 && comp(prefix, s[i][j-1]))  prefix = s[i][j-1];
                    prefix += mat[i][j];
                    if(prefix == "0")   continue;
                    s[i][j] = prefix;
                    if(comp(ans, prefix))   ans = prefix;
                }
            }
        }

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


Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  
  cin >> A >> B >> C >> D;
  
  if (A + B < C + D)
    cout << "Right" << endl;
  
  else if ( A + B > C + D)
    cout << "Left" << endl;
  
  else
    cout << "Balanced" << endl;
  
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

//二項係数（nCk mod.p;1<=k<=n<=1e7,pは素数）
template <class T> struct Combination {
    const int MOD = 1000000007;
    vector<T> fac, finv, inv;
    Combination(const int MAX) : fac(MAX), finv(MAX), inv(MAX) {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for(int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    T comb(int n, int k) {
        if(n < k)
            return 0;
        if(n < 0 || k < 0)
            return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
};

ll PowMod(ll N, ll P, ll M) {
    if(P == 0)
        return 1;
    if(P % 2 == 0) {
        ll t = PowMod(N, P / 2, M);
        return t * t % M;
    }
    return N * PowMod(N, P - 1, M);
}

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if(b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK)
inline long long mod(long long a, long long m) { return (a % m + m) % m; }

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}

ll getComb(ll N, ll p) {
    if(p >= N / 2)
        p = N - p;
    ll over = 1;
    for(ll i = N; i >= N - p + 1; i--) {
        over = (over * i) % MOD;
    }
    ll under = 1;
    for(ll i = 1; i <= p; i++) {
        under = (under * i) % MOD;
    }
    under = modinv(under, MOD);
    return (over * under) % MOD;
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    ll ma = PowMod(2, N, MOD);
    ma = (ma - 1 + MOD) % MOD;
    Combination<ll> C(200000);
    ll nCA = getComb(N, A);
    ll nCB = getComb(N, B);
    ma = (ma - nCA + MOD) % MOD;
    ma = (ma - nCB + MOD) % MOD;

    cout << ma << endl;
    return 0;
}

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

int main(){

	int n;
	std::cin >> n;
	std::vector<int>v(n);

	for (int i = 0; i < n; i++)std::cin >> v[i];
	
	for (int i = n - 1; i >= 0; i--){
		if (i == 0)std::cout << v[i];
		else std::cout << v[i] << " ";
	}
	std::cout << std::endl;

	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int inf=1e18;
int32_t main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0),cin.tie(0);
    int n,k;
    cin >> n >> k;
    cout << min(n%k,k-n%k) ;
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int d;
    cin >> d;
    cout << "Christmas";
    rep(25-d) cout << " Eve";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second

typedef long long ll;

using namespace std;

int main()

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

    int a, b, k;

    cin >> a >> b >> k;

    for (int i = 0; i < k; i++) {

        if (i%2) {

            int z = b/2;
            b-=(b%2), b-=z, a+=z;
        } else {

            int z = a/2;
            a-=(a%2), a-=z, b+=z;
        }
    }

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

    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 998244353
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    srand(time(0));
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0&&c>0){
        c-=b;
        a-=d;
    }
    if(c<=0)cout<<"Yes";
    else cout<<"No";
        return 0;
    
}


Measured memory_bytes: 3652
s=input()

str_1 = s[:2]
flg_1=0
if str_1 in ['01','02','03','04','05','06','07','08','09','10','11','12']:
    flg_1=1

str_2 = s[2:]
flg_2=0
if str_2 in ['01','02','03','04','05','06','07','08','09','10','11','12']:
    flg_2=1

if flg_1==1 and flg_2==1:
    print('AMBIGUOUS')
elif flg_1==1 and flg_2==0:
    print('MMYY')
elif flg_1==0 and flg_2==1:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a, b, c, d, e;
	for (int h = 0; h < 3; h++) {
		cin >> n >> a >> b >> c >> d >> e;
		int sum = 0, num = 0, ans = 0;
		if (b > e) {
			ans = e + 60 - b;
			if (a > d - 1) {
				num = d + 59 - a;
				sum = c - 1 - n;
			}
			else {
				num = d - 1 - a;
				sum = c - n;
			}
		}
		else {
			ans = e - b;
			if (a > d) {
				num = d + 60 - a;
				sum = c - n - 1;
			}
			else {
				num = d - a;
				sum = c - n;
			}
		}
		cout << sum << ' ' << num << ' ' << ans << endl;
	}
	cin >> n;
}


Measured memory_bytes: 3088
def find(K,X):
    left=-10**6
    right=10**6
    ans=[]
    for i in range(X-K+1,X+K):
        if i>=left and i<=right:
            ans+=[str(i)]
    print(" ".join(ans))
K,X=list(map(int,input().strip().split(' ')))
find(K,X)

Measured memory_bytes: 38256
n = int(input())
R = [int(input()) for i in range(n)]

start = R[0]
max = R[1] - R[0]
for j in range(1, n):
    if (max < R[j] - start):
        max = R[j] - start
    if (R[j] < start):
        start = R[j]

print(max)


Measured memory_bytes: 13596
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    int K;
    cin>>K;
    //vector<vector<string> > v(9,vector<string>(K));
    queue<long long> que;
    vector<string> v,w;
    rep(i,9) que.push(i+1);
    int k=K-9;
    long long f=0,ans=0;
    while(k>0){
        f=que.front();
        if (f%10==0){
            que.push(10*f);
            k-=1;
            if (k==0){
                ans=10*f;
                break;
            }
            que.push(10*f+1);
            k-=1;
            if (k==0){
                ans=10*f+1;
                break;
            }
        }
        else if (f%10==9){
            que.push(10*f+f%10-1);
            k-=1;
            if (k==0){
                ans=10*f+f%10-1;
                break;
            }
            que.push(10*f+f%10);
            k-=1;
            if (k==0){
                ans=10*f+f%10;
                break;
            }
        }
        else{
            que.push(10*f+f%10-1);
            k-=1;
            if (k==0){
                ans=10*f+f%10-1;
                break;
            }
            que.push(10*f+f%10);
            k-=1;
            if (k==0){
                ans=10*f+f%10;
                break;
            }
            que.push(10*f+f%10+1);
            k-=1;
            if (k==0){
                ans=10*f+f%10+1;
                break;
            }
        }
        que.pop();
    }
    if (K<=9)    cout<<K<<endl;
    else    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4156
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int arr[n],i,j,k;
     int brr[n];
     for(i=0;i<n;i++)
     cin>>arr[i];
     brr[0]=0;
     brr[1]=brr[0]+abs(arr[1]-arr[0]);
     for(i=2;i<n;i++)
     brr[i]=min(brr[i-1]+abs(arr[i]-arr[i-1]),brr[i-2]+abs(arr[i]-arr[i-2]));
     cout<<brr[n-1];
     
     
     
     
     
     
     return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N;
ll A[100005];
ll sum;
bool solve(){
  if( sum % (N*(N+1LL)/2LL) ) return false;
  ll K = sum/(N*(N+1LL)/2LL);
  //cout << "sokve " << K <<  endl;
  ll cnt = 0;
  for(int i=0;i<N;i++){
    int nx = (i+1)%N;
    ll c = K - (A[nx]-A[i]);
    if( c < 0 ) return false;
    //cout << c << endl;
    if( c % N ) return false;
    cnt += c/N;
  }
  //cout << cnt << " " << K << endl;
  return cnt == K;
}
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i];
    sum += A[i];
  }

  if( solve() )
    cout << "YES" << endl;
  else
    cout << "NO" << endl;  
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int k;
    cin >> k;
    k--;
    rep(i,n){
        if(s[i] == s[k])cout << s[i];
        else cout << "*";
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    char x;
    cin >> x;
    char res;

    char c[27] = "abcdefghijklmnopqrstuvwxyz";
    for (int i = 0; i <= 26; i++) {
        if (c[i] == x) res = c[i+1];
    };
    cout << res << endl;
}

Measured memory_bytes: 256
def cmb(n, r):
    if n < r:
        return 0
    if r == 0 or r == n:
        return 1
    if r == 1 or r == n - 1:
        return n
    return f[n] * pow(f[r], MOD - 2, MOD) % MOD * pow(f[n - r], MOD - 2, MOD) % MOD


MOD = 10 ** 9 + 7

N, K = map(int, input().split())

f = [-1] * (N * 2 + 1)
f[0] = 1
t = 1
for i in range(1, N * 2 + 1):
    t *= i
    t %= MOD
    f[i] = t

print(N - K + 1)
for i in range(2, K + 1):
    print(cmb(K - 1, i - 1) * cmb(N - K + 1, i) % MOD)


Measured memory_bytes: 43632
#include <bits/stdc++.h>
#define llint long long int
#define ldouble long double

//setprecision()<<

using namespace std;

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

    ldouble sum=0.0;
    for(int i=0;i<N;i++){
        sum+=1/((ldouble)A.at(i));
    }
    cout<<fixed<<setprecision(10)<<1/sum<<endl;
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		System.out.println(solve());
	}
	
	public static int solve() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int min = 753;
		for (int i = 0; i < s.length() - 2; i++) {
			int sum = Math.abs(Integer.parseInt(s.substring(i, i + 3)) - 753);
			if (sum <= min ) {
				min = sum;
			}
		}
		return min;
	}
}


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

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

    int maxi = 0;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> p;
        sum += p;
        maxi = max(p, maxi);
    }

    cout << sum - maxi / 2 << endl;
}

Measured memory_bytes: 3624
local N, M, X, Y = io.read("n", "n", "n", "n")
local x = {} for i=1,N do x[i]=io.read("n") end x[#x+1]=X table.sort(x)
local y = {} for i=1,M do y[i]=io.read("n") end y[#y+1]=Y table.sort(y)
if x[#x] < y[1] then
  print("No War")
else
  print("War")
end

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X; cin>>X;
    X-=400;
    X/=200;
    cout<<8-X<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  n = n%10;
  if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
  {
    cout << "hon" << endl;
  }else if (n == 0 || n == 1 || n == 6 || n == 8)
  {
    cout << "pon" << endl;
  }else
  {
    cout << "bon" << endl;
  }
  
  
  
  return 0;
}

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

#define F first
#define S second
#define ll long long
#define int long long
#define pb push_back
#define ld long double

using namespace std ; 

const int N = 1001 * 1001  , MOD = 1e9 + 7 ; 

int ask(int i)
{
	cout << i << endl ; 
	string s ;
	cin >> s ;
	if(s[0]=='V') exit(0) ; 
	if(s[0]=='M') return 0 ; 
	return 1 ; 
}

int32_t main()
{
	ios::sync_with_stdio(0) ;cin.tie(0) ; 
	int n ; 
	cin >> n ; 
	int l = 0 , r = n - 1 ; 
	int x = ask(0) ; 
	ask(n-1) ; 
	while(r-l>1)
	{
		int mid = (l+r) / 2 ; 
		int y = ask(mid) ^ x ; 
		if((mid-l+1)%2!=y)
		{
			x = y ^ x ; 
			l = mid ; 
		}
		else
		{
			r = mid ; 
		}
	}
	ask(l) ; 
	ask(r); 
}	

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main() {
    int n;
    cin >> n;
    double d;
    cin >> d;
    int cnt = 0;
    rep(i, n){
        double x, y;
        cin >> x >> y;
        if(sqrt(x*x+y*y) <= d) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3840
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var s = input.trim();
while (s.match(/\(\)/)) s = s.replace(/\(\)/g, "");
var arr = s.split("*");
if (arr.length < 2) console.log(0);
else console.log(Math.min(arr[0].replace(/[^\(]/g, "").length, arr[1].replace(/[^\)]/g, "").length));


Measured memory_bytes: 17164
n = int(input())
c = 0

def isPrime(x:int):
    if x < 2 or x == 9:
        return False
    if x == 2 or x == 3:
        return True
    if x%2 == 0:
        return False
    i = 2
    while True:
        i += 1
        if x%i == 0:
            return False
        if x <= i**2 :
            return True

for _ in range(n):
    if isPrime(int(input())):
        c += 1

print (c)



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

int main() {
	int n, a[100010] = { 0 }, sum = 0;
	cin >> n;
	rep(i, n + 2) {
		if (i == 0) continue;
		else if (i != n + 1) cin >> a[i];
		sum += abs(a[i] - a[i - 1]);
	}
	rep(i, n + 1) {
		if (i == 0) continue;
		cout << sum - (abs(a[i + 1] - a[i]) + abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i - 1])) << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

void solve(){
    int N,L;
    cin>>N>>L;
    int mini=INT_MAX;
    int sum=0;
    for(int i=1;i<=N;i++){
        if(abs(L+i-1)<abs(mini)){
            mini=L+i-1;
        }
        sum+=(L+i-1);
    }
    out(sum-mini);
}

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

Measured memory_bytes: 256
H, W, K = map(int, input().split())
mod = 1000000007

draw_line = [0 for _ in range(W)]
draw_line[0] = 1
if W > 1:
    draw_line[1] = 1
for i in range(2, W):
    draw_line[i] = draw_line[i-1] + draw_line[i-2]

dp = [[0 for _ in range(W)] for _ in range(H+1)]
dp[0][0] = 1
for h in range(1, H+1):
    for w in range(W):
        # from left
        if w > 0:
            dp[h][w] += dp[h-1][w-1] * draw_line[w-1] * draw_line[W-w-1]
        # from up
        dp[h][w] += dp[h-1][w] * draw_line[w] * draw_line[W-w-1]
        # from right
        if w < W-1:
            dp[h][w] += dp[h-1][w+1] * draw_line[w] * draw_line[W-w-2]

print(dp[H][K-1]%mod)


Measured memory_bytes: 3064
// -- Nitin
#include <bits/stdc++.h>
#define pb push_back
#define mkp make_pair
#define llu unsigned long long int
#define ll long long
#define ld long double
#define foi(a,n) for(int i = a; i < (int)n; i++)
#define foj(a,n) for(int j = a; j < (int)n; j++)
#define foin(a,n) for(int i = n; i >= a; i--)
#define fojn(a,n) for(int j = n; j >= a; j--)
#define bug(x) cerr << #x << " is " << x << endl;
#define isp2(x) x&&(!(x&(x-1)))
#define ln '\n'
#define ee 1000000007
#define eem 998244353
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define cases int tests; cin >> tests; while(tests--)

using namespace std;

// Union find
#define MAXN 200002
int parent[MAXN], sz[MAXN];
int fset(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = fset(parent[v]);
}
void mkset(int v) {
    parent[v] = v;
    sz[v] = 1;
}
void usets(int a, int b) {
    a = fset(a);
    b = fset(b);
    if (a != b) {
        if (sz[a] < sz[b])
            swap(a, b);
        parent[b] = a;
        sz[a] += sz[b];
    }
}

int main(){
    fio;
	ll n, m, k;
	
    //~ cases
    
    {	
		cin >> n >> m;
		ll a, b;
		for(int i = 1; i <= n; i++){
			mkset(i);
		}
		foi(0, m) {
			cin >> a >> b;
			usets(a, b);
		}
		ll mx = 0;
		for(int i = 1; i <= n; i++){
			if(parent[i] == i)mx = max(mx, (ll)sz[i]);
		}
		cout << mx;
		cout << "\n";
	
	
	}
}
       
        


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


typedef long long ll;
typedef pair<ll,int> P;

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n, k;
  cin >> n >> k;
  set<int> st;
  for(int i=0; i<k; i++){
    int d;
    cin >> d;
    for(int j=0; j<d; j++){
      int a;
      cin >> a;
      st.insert(a);
    }
  }
  int ans = n - st.size();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <cstdio>
#include <cstdlib>
#include <cstring>

const char *com1 = "insert";
const char *com2 = "delete";
const char *com3 = "deleteFirst";
const char *com4 = "deleteLast";

struct Node {
	int key;
	Node *next, *prev;
};

Node *nil;

void init() {
	nil = (Node *)malloc( sizeof(Node) );
	nil -> next = nil;
	nil -> prev = nil;
}

void insert(int key) {
	Node *x = (Node *)malloc( sizeof(Node) );
	x -> key = key;
	x -> next = nil -> next;
	nil -> next -> prev = x;
	x -> prev = nil;
	nil -> next = x;
}

Node* listSearch(int key) {
	Node *cur = nil -> next;
	while(cur != nil && cur -> key != key)
		cur = cur -> next;
	return cur;
}

void deleteNode(Node *t) {
	if( t == nil) return;
	t -> next -> prev = t -> prev;
	t -> prev -> next = t -> next;
	free(t);
}

void deleteKey(int key) {
	deleteNode(listSearch(key));
}

void deleteFirst() {
	deleteNode(nil -> next);
}

void deleteLast() {
	deleteNode(nil -> prev);
}

void printList() {
	Node *cur = nil -> next;
	int isf = 0;
	while(cur != nil) {
		if(isf++ > 0) printf(" ");
		printf("%d", cur -> key);
		cur = cur -> next;
	}
	printf("\n");
}

int main()
{
	int n, key;
	char com[20];
	scanf("%d", &n);
	init();

	for( int i = 0; i < n; i++ ) {
		scanf("%s", com);
		if( !strcmp(com, com1) ) {
			scanf("%d", &key);
			insert(key);
		}
		else if( !strcmp(com, com2)) {
			scanf("%d", &key);
			deleteKey(key);
		}
		else if( !strcmp(com, com3)) {
			deleteFirst();
		}
		else if( !strcmp(com, com4)) {
			deleteLast();
		}
	}

	printList();

	return 0;
}


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

#define int long long

int a[102400],b[102400],m[102400];
int x[102400],y[102400],c[102400];

signed main(){
    int A,B,M;


    cin >>A >>B >>M;
    for(int i=0;i<A;i++){
        cin >> a[i];
    }
    for(int i=0;i<B;i++){
        cin >> b[i];
    }
    for(int i=0;i<M;i++){
        cin >>x[i] >>y[i] >>c[i];
    }

    int min = 1145141919810;
    for(int i=0;i<M;i++){
        if(a[x[i]-1] + b[y[i]-1] - c[i] < min){
 //           cout <<a[x[i]] <<" " << b[y[i-1]] <<" " <<c[i] <<endl;
            min = a[x[i]-1] + b[y[i]-1] - c[i];
        }
 //                   cout <<min <<endl;
    }
 //   cout <<min <<endl;
    sort(a,a+A);
 //   cout << "sorted a:" << a[0] <<endl;
    sort(b,b+B);
//        cout << "sorted b:" << b[0] <<endl;
    if(a[0] + b[0] < min){
        min = a[0] + b[0];
    }
    cout <<min <<endl;


    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n, k;
  cin >> n >> k;

  ll ans = 0;
  for(ll i = k; i <= n+1; i++){
    ans = (ans + i*(2*n-i+1)/2 - i*(i-1)/2 + 1) % mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<stdlib.h>
#define MAX 500000

struct NODE{
  int key;
 struct NODE *parent;
 struct NODE *left;
 struct NODE *right;
};

typedef struct NODE NODE;

NODE T[MAX];
NODE *root,*NIL;

int scancommand(char *);
void insert(int);
void inorder(NODE *);
void preorder(NODE *);

int main()
{
  int n;
  int i,j;
  int x;
  char command[30];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",command);
    //printf("%s\n",command);
    
    if(scancommand(command) == 1){
      scanf("%d",&x);
      insert(x);
      //printf("%d\n",x);
    }
    else if(scancommand(command) == 2){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}

int scancommand(char *com)
{
  if(com[0] == 'i') return 1;
  else if(com[0] == 'p') return 2;
  else return 0;
}

void insert(int k)
{
  //printf("===insert===\n");
  NODE *y = NIL; // xの親
  NODE *x = root; //Tの根
  NODE *z;

  z = (NODE *)malloc(sizeof(NODE));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x; //親を設定
    if(z->key < x->key) x = x->left;
    else x = x->right;
       }
  z->parent = y;

  if (y == NIL){ //Tが空の場合
    root = z;
  }
  else if (z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(NODE *u){
  if( u == NIL ) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(NODE *u){
  if( u == NIL ) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}




Measured memory_bytes: 25140
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
int gcd(int a,int b){if(a<b)swap(a,b);int c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int n; cin >> n;
  int ans;
  rep(i, n){
    int a; cin >> a;
    if(i == 0) ans = a;
    else ans = gcd(ans, a);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

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

	cout << max(max(a - b, a + b), a * b)<< endl;

	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "ctime"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	if (M%N == 0)M += N;
	else M -= N;
	cout << M << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

N,K=map(int,input().split())
A=list(map(int,input().split()))

d={}
for i in range(N):
    if A[i] in d.keys():
        d[A[i]]+=1
    else:
        d[A[i]]=1

dic=sorted(d.items(), key=lambda x:x[1])
if len(dic)<=K:
    print(0)
else:
    ans=0
    cnt=len(dic)
    for key,value in dic:
        if cnt-1==K:
            ans+=value
            print(ans)
            break
        else:
            ans+=value
            cnt-=1

Measured memory_bytes: 39320
n = int(input())
t,a = map(int,input().split())
h= list(map(int,input().split()))

ts = []
for sh in h:
    ts.append(t - 0.006 * sh)

sabun  = 1000000000000
res = 0
for i in range(n):
    if abs(ts[i]-a) < sabun:
        sabun = abs(ts[i]-a)
        res = i+1

print(res)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

struct edge_t {
	int from;
	int to;
	int cost;
};
typedef struct edge_t Edge;

int main(void) {
	int num, i, k, from, to, cost, update, nedge = 0;
	int dis[10000];
	Edge *edges, *p;

	edges = malloc(sizeof(Edge)*500000);

	scanf("%d", &num);

	for (i = 0; i < num; i++) {
		scanf("%d %d", &from, &k);

		while (k--) {
			scanf("%d %d", &to, &cost);

			p = &edges[nedge++];
			p->from = from;
			p->to = to;
			p->cost = cost;
		}

		dis[i] = INT_MAX;
	}
	dis[0] = 0;

	update = 1;
	while (update) {
		update = 0;
		for (i = 0; i < nedge; i++) {
			from = edges[i].from;
			to = edges[i].to;
			cost = edges[i].cost;
			if (dis[from] < INT_MAX && dis[to] > cost + dis[from]) {
				dis[to] = cost + dis[from];
				update = 1;
			}
		}
	}

	for (i = 0; i < num; i++) {
		printf("%d %d\n", i, dis[i]);
	}
	return 0;
}



Measured memory_bytes: 7576
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  int left,right;
  cin >> A >> B >> C >> D;
  
  left = A+B;
  right = C+D;
  
  if(left < right){
    cout << "Right" <<endl;
  }else if(left > right){
    cout << "Left" << endl;
  }else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256