akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

int main()
{
     ll n;cin>>n;
     ll now=0,cnt=1;
     while(n>0)
     {
         n=(n/2);
         now+=cnt;
         cnt*=2;
     }
     cout<<now;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,n) for(lli i=0;i<n;i++)
#define repb(i,n) for(lli i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
#define all(X) X.begin(),X.end()
#define iterate(X) for(it=X.begin();it!=X.end();it++)
lli combi(lli n,lli k)
{
    lli ans=1;
    k=k>n-k?n-k:k;
    lli j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli findlcm(vector <lli> arr, lli n)
{
    lli ans = arr[0];
    for (lli i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n;
    cin>>n;
    vector <lli> arr;
    lli x;
    rep(i,n){
    	cin>>x;
    	arr.pb(x);
	}
	sort(all(arr));
	vect_lli_it it;
	lli choice=0;
	for(lli k=1;k<=arr[arr.size()-1];k++){
		it=lower_bound(all(arr),k);
		if(it!=arr.en()){
			lli ind=it-arr.bg();
			lli count=n-ind;
			if(count==ind)
			choice++;
		}
	}
	cout<<choice;
    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int n, i;
  cin >> n >> i;
  cout << n -i + 1 << endl;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: Removing Coins
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int INF = 1 << 30;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;

/* global variables */

vi nbrs[MAX_N];
int prts[MAX_N], ds[MAX_N], md0[MAX_N], md1[MAX_N], cns[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    nbrs[a].push_back(b);
    nbrs[b].push_back(a);
  }

  prts[0] = -1;
  ds[0] = md0[0] = md1[0] = 0;
  qi q;
  q.push(0);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int &up = prts[u], vd = ds[u] + 1;
    vi &nbru = nbrs[u];
    for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &v = *vit;
      if (v != up) {
	cns[u]++;
	prts[v] = u;
	ds[v] = md0[v] = md1[v] = vd;
	q.push(v);
      }
    }
  }

  for (int i = 0; i < n; i++)
    if (cns[i] == 0) q.push(i);

  int maxd = 0;
  while (! q.empty()) {
    int u = q.front(); q.pop();

    int d = md0[u] + md1[u] - ds[u] * 2;
    if (maxd < d) maxd = d;

    int &up = prts[u];
    if (up >= 0) {
      if (md0[up] < md0[u]) md1[up] = md0[up], md0[up] = md0[u];
      else if (md1[up] < md0[u]) md1[up] = md0[u];
      if (--cns[up] == 0) q.push(up);
    }
  }
  //printf("maxd=%d\n", maxd);

  if (maxd % 3 == 1) puts("Second");
  else puts("First");
  return 0;
}


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

int n,T;
int main() {
	scanf("%d%d",&n,&T);

	int mx=0,sum=0;
	for(int i=0,v;i<n;i++) {
		scanf("%d",&v);
		sum += min(T,v+T-mx);
		mx = v+T;
	}
	printf("%d\n",sum);
	
	return 0;
}


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

int main() {
    int h, w, n, r, c;
    string s, t;
    cin >> h >> w >> n >> r >> c >> s >> t;

    int ll = 1;
    int rl = w;
    int ul = 1;
    int dl = h;
    for (int i = n - 1; i >= 0; i--) {
        if (t[i] == 'L') {
            rl = min(w, rl + 1);
        } else if (t[i] == 'R') {
            ll = max(1, ll - 1);
        } else if (t[i] == 'U') {
            dl = min(h, dl + 1);
        } else if (t[i] == 'D') {
            ul = max(1, ul - 1);
        }
        if (s[i] == 'L') {
            ll = min(w, ll + 1);
        } else if (s[i] == 'R') {
            rl = max(1, rl - 1);
        } else if (s[i] == 'U') {
            ul = min(h, ul + 1);
        } else if (s[i] == 'D') {
            dl = max(1, dl - 1);
        }
        if (ll >= rl || ul >= dl) {
            break;
        }
    }
    if (ll > c || rl < c || ul > r || dl < r) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
}


Measured memory_bytes: 776
from dataclasses import dataclass, field

import scipy
import numpy as np
from numba import jit


@dataclass()
class Node:
    date: int
    value: int
    result: list = field(default_factory=list)

    def __lt__(self, other) -> bool:
        return self.value < other.value

    def output(self) -> str:
        assert len(self.result) == 365
        return '\n'.join(self.result)


D = int(input())  # 日数 D = 365
C = np.array(list(map(int, input().split())), dtype=int)  # 満足度の下がりやすさ 26個
S = np.array([list(map(int, input().split())) for _ in range(D)], dtype=int)  # d日目にコンテストiを行ったときの満足度

for d in range(D):
    t = 0
    max_s = 0
    for i, s in enumerate(S[d]):
        if s > max_s:
            t = i
            max_s = s

    print(t + 1)


Measured memory_bytes: 93748
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<queue>
#include<unordered_map>
#include<map>
#include<stack>
#include<bits/stdc++.h>
#include<string.h>
#include <ext/pb_ds/assoc_container.hpp>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define f first
#define respr(fir,sec) for(int i=0;i<=fir;i++){for(int j=0;j<=sec;j++){cout << res[i][j] << " ";}cout << "\n";}
#define pb push_back
#define vint vector<int>
const int mod = 1000000007;
using namespace std;
const int maxsize=3005;
int dp[maxsize][maxsize];
int pref[maxsize][maxsize];


void assignee(int &x, int ans)
{
	x += ans;
	x %= mod;
}



int32_t main()
{
	//freopen("input.txt", "r" , stdin);
	int n;
	string s;
	cin >> n >> s;
	
	dp[1][1] = 1;
	
	for(int len=2; len <=n;len++)
	{
		for(int i=1;i<=len-1;i++)
		{
			pref[len-1][i] = (pref[len-1][i-1]+dp[len-1][i])%mod;
		}
		
		int L,R;
		for(int b=1;b<=len;b++)
		{
			if(s[len-2] == '<')
			{
				L=1;
				R = b-1;
			}
			else
			{
				L=b;
				R = len-1;
			}
			if(L<=R)
				assignee(dp[len][b], (pref[len-1][R]-pref[len-1][L-1]+mod)%mod);
		}
	}
	
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		assignee(ans,dp[n][i]);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 139648
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>
using namespace std;

#define int long long

signed main() {
    string s; cin >> s;
    string ans = "";

    for(int i = 0; i < s.size(); i++) {
        if(s[i] == '0') ans += '0';
        else if(s[i] == '1') ans += '1';
        else if(ans.size() >= 1 && s[i] == 'B') ans.erase(ans.size() - 1, 1);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    int n;cin>>n;
    ll sum=0;
    vector<ll>V(n);rep(i,n){cin>>V[i];sum+=V[i];}
    ll judge=0;ll ma=10000000000000000;
    rep(i,n-1){
        judge+=V[i];
        ma=min(ma,abs(judge-(sum-judge)));
    }
    cout<<ma<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
 
void solve() {
	string s;
    cin>>s;
    ll n=s.size(), mod10=1, ans=0;
    vector<ll> v(n), pref(n);
    reverse(s.begin(), s.end());
    v[0]=s[0]-'0';
    pref[0]=v[0];
    for(int i=1; i<n; i++) {
    	mod10=(mod10*10)%2019;
    	v[i]=((s[i]-'0')*mod10)%2019;
    	pref[i]=(pref[i-1]+v[i])%2019;
    }
    unordered_map<ll, ll> mp;
    for(int i=0; i<n; i++) {
    	if(pref[i]==0) ans++;
		ans+=mp[pref[i]];
 		mp[pref[i]]++;
    }
    cout<<ans<<"\n";
}
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(10);
	cout<<fixed;
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 6776
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int g[5][105];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	rep(i, 2) rep(j, n) cin >> g[i][j];
	int sum1 = 0, sum2 = 0;
	rep(j, n) sum2 += g[1][j];
	int ans = 0;
	rep(i, n){
		sum1 += g[0][i];
		ans = max(ans, sum1 + sum2);
		sum2 -= g[1][i];
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int N, Y;
    cin >> N >> Y;

    int x = 0;
    int y = 0;
    int x_true = -1;
    int y_true = -1;
    int z_true = -1;
    while(x <= N){
        while(y <= N - x){
            int sum = 10000 * x + 5000 * y + 1000 * (N - x - y);
            if (sum == Y){
                x_true = x;
                y_true = y;
                z_true = N - (x + y);
                break;
            }else
            {
                y = y + 1;
            }
        }
        y = 0;
        x = x + 1;
    }

    cout << x_true << " " << y_true << " " << z_true << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
left = []
midplus = []
midzero = []
midminus = []
right = []
L = []
R = []

for i in range(n):
    s = input()
    l = 0
    r = 0
    for x in s:
        if x == '(':
            l += 1
        else:
            if l > 0:
                l -= 1
            else:
                r += 1
    if l > 0 and r == 0:
        left.append((l, r))
    elif l > 0 and r > 0:
        if l > r:
            midplus.append((r, l))  # a,b-a
        elif l == r:
            midzero.append((r,l))
        else:
            midminus.append((r, l))
    elif l == 0 and r > 0:
        right.append((l, r))
    L.append(l)
    R.append(r)

if sum(L) != sum(R):
    print('No')
    exit()

A = 0
B = 0
for x in left:
    A += x[0]
for x in right:
    B += x[1]

midplus = sorted(midplus, key=lambda x: (x[0], -x[1]))
midminus = sorted(midminus, key=lambda x: -x[1])
mid = midplus + midzero + midminus

l = A
r = 0
for a, b in mid:
    if l < a:
        print('No')
        exit()
    l -= a
    l += b

print('Yes')


Measured memory_bytes: 181304
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_003;

alias Pair = Tuple!(long, "x", long, "y");


void main() {
    long n;
    scan(n);
    auto a = readln.split.to!(int[]);
    auto b = readln.split.to!(int[]);

    auto w1 = a.dup;
    auto v1 = [b[0] - a[0], b[1] - a[1], b[2] - a[2]];

    n += knapsack(3, n, w1, v1);

    auto w2 = b.dup;
    auto v2 = [a[0] - b[0], a[1] - b[1], a[2] - b[2]];

    n += knapsack(3, n, w2, v2);

    writeln(n);
}

long knapsack(int n, long cap, int[] w, int[] v) {
    auto d = new long[](cap.to!int + 1);

    foreach (i ; 0 .. n) {
        foreach (j ; w[i] .. cap.to!int + 1) {
            d[j] = max(d[j], d[j - w[i]] + v[i]);
        }
    }

    return d[cap.to!int];
}













int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 196308
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<=(end);i++)
#define REP(i, n) FOR(i,1,n)
#define IFOR(i, begin, end) for(int i=(end);i>=(begin);i--)
#define IREP(i, n) IFOR(i,1,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;

int main()
{
	ll H, W;
	cin >> H >> W;

	vector<string> a(H + 1);

	FOR(j, 0, H - 1) {
		cin >> a[j];
	}


	int routestartprev = -1;
	int routeendprev = -1;
	if (a[0][0] == '.' || a[H - 1][W - 1] == '.') {
		cout << "Impossible" << endl;
		return 0;
	}
	FOR(i, 0, H - 1) {
		int routestart = -1;
		int routeend = -1;
		if (i == 0) {
			FOR(j, 0, W - 1) {
				if (a[i][j] == '#') {
					if (routestart == -1) routestart = j;
					if (routeend != -1) {
						cout << "Impossible" << endl;
						return 0;
					}
				} else {
					if (routestart > -1 && routeend == -1) routeend = j - 1;
				}
			}
			if (routestart == -1) {
				cout << "Impossible" << endl;
				return 0;
			}
			else if (routeend == -1) routeend = W - 1;
			routestartprev = routestart;
			routeendprev = routeend;
		}

		else {
				// cout<<i<<routeendprev<<endl;
			if (routeendprev > 0) {
				FOR(j, 0, routeendprev - 1) {
					if (a[i][j] == '#') {
						cout << "Impossible" << endl;
						return 0;

					}

				}
			}
			if (a[i][routeendprev] == '#') routestart = routeendprev;
			else {
				cout << "Impossible" << endl;
				return 0;

			}
			FOR(j, routestart, W - 1) {
				if (a[i][j] == '#' && routeend > -1) {
					cout << "Impossible" << endl;
					return 0;

				}
				if (a[i][j] == '.' && routeend == -1) {
					routeend = j - 1;

				}
			}
			if (routestart == -1) {
				cout << "Impossible" << endl;
				return 0;
			}
			else if (routeend == -1) routeend = W - 1;
			routestartprev = routestart;
			routeendprev = routeend;

		}
	}


	cout << "Possible" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n;
  scanf("%d", &n);
  
  int a[n+1];
  int i, j;
  int min=31;
  a[0]=0;
  for(i=1; i<n+1; i++){
    scanf("%d",&a[i]);
    if(a[i]%2==1){
      min=0;
      break;
    }else{
      for(j=1; j<31; j++){
        if(a[i]/2==0 || a[i]%2==1){
          break;
        }else{
          a[i]/=2;
        }
      }
    }
    if(j-1 <= min){
      min=j-1;
    }
  }
  
  printf("%d\n", min);
  
  return 0;
}

Measured memory_bytes: 1680
#include <bits/stdc++.h>
using namespace std;
int main(){
	unsigned long long a,b,c,d,c1=0,c2=0,cd=0,res=0;
	cin>>a>>b>>c>>d;
	res=b-a+1;
	if (a%c==0) c1=a/c;
	else c1=a/c+1;
	c2=b/c;
	if (c2-c1+1>0) res-=(c2-c1+1);
	if (a%d==0) c1=a/d;
	else c1=a/d+1;
	c2=b/d;
	if (c2-c1+1>0) res-=(c2-c1+1);
	cd=c*d/__gcd(c,d);
	if (a%cd==0) c1=a/cd;
	else c1=a/cd+1;
	c2=b/cd;
	if (c2-c1+1>0) res+=(c2-c1+1);
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<unordered_map>
using namespace std;

int in[4][11]{
	{6,7,8,12,21,22,23,17,9,10,11},
	{8,5,2,18,27,24,21,11,12,13,14},
	{2,1,0,15,29,28,27,14,18,19,20},
	{0,3,6,9,23,26,29,20,15,16,17}
},
out[4][11]{
	{21,22,23,17,6,7,8,12,11,10,9},
	{27,24,21,11,8,5,2,18,14,13,12},
	{29,28,27,14,2,1,0,15,20,19,18},
	{23,26,29,20,0,3,6,9,17,16,15}
};
bool hantei(string a) {
	bool s = true;
	for (int i = 0; i < 8; i++) {
		if (a[i] != a[i + 1])s = false;
	}
	for (int i = 21; i < 29; i++) {
       if (a[i] != a[i + 1])s = false;
	}
	for (int i = 9; i < 20; i += 3) {
		if (a[i] != a[i + 1] || a[i + 1] != a[i + 2])s = false;
	}
	return s;
}
vector<string> kaiten(string a) {
	vector<string>b(4);
	b[0] = b[1] = b[2] = b[3] = a;
	for (int c = 0; c < 4; c++) {
		for (int d = 0; d < 11; d++) {
			b[c][out[c][d]] = a[in[c][d]];
		}
	}
	return b;
}
int main() {
	int a;
	cin >> a;
	for (int b = 0; b < a; b++) {
		string e;
		for (int c = 0; c < 30; c++) {
			char d; cin >> d; e += d;
		}
		unordered_map<string, int>U;
		U[e] = 1;
		queue<string>Q;
		Q.push(e);
		while (Q.size()) {
			string f = Q.front(); Q.pop();
			if (hantei(f)) { cout << U[f] - 1 << endl; break; }
			vector<string>g = kaiten(f);
			for (int i = 0; i < 4; i++) {
				if (U[g[i]] == 0) {
					U[g[i]] = U[f] + 1;
					Q.push(g[i]);
				}
			}
		}
	}
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }

const int maxn = 1e6 + 5;
int dp[maxn][2][2], n;

int f(int i, bool zero, bool nine) {
  if(i == n) return zero && nine;
  if(dp[i][zero][nine] != -1) return dp[i][zero][nine];
  int ret = 0;
  for(int j = 0; j <= 9; j++) {
    ret = add(ret, f(i + 1, (j == 0 ? true : zero), (j == 9 ? true : nine)));
  }
  return dp[i][zero][nine] = ret;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  cin >> n;
  memset(dp, -1, sizeof dp);
  cout << f(0, 0, 0);  
}

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

using namespace std;

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;
} /* }}} */

int main() {
  int N, H;
  cin >> N >> H;
  vector<int> A(N), B(N);
  int max_a = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
    chmax(max_a, A[i]);
  }
  sort(B.rbegin(), B.rend());
  vector<long long> BS(N + 1);
  for (int i = 0; i < N; i++) {
    BS[i + 1] = BS[i] + B[i];
  }
  long long ans = 1e15;
  for (int i = 1; i <= N; i++) {
    long long a = i + (H - BS[i] + max_a - 1) / max_a;
    if (BS[i] >= H) {
      a = i;
    }
    chmin(ans, a);
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
int main(void){
  int a,b,c,x,y;
  int min,cost;
  std::cin >> a >> b >> c >> x >> y;
  if(a+b <= c*2){
    printf("%d",a*x+b*y);
    return 0;
  }
  if(x < y){
    min = x;
  }else{
    min = y;
  }
  cost = 2*min*c;
  if(a < 2*c && min == y){
    cost += (x-y)*a;
  }else if(b < 2*c && min == x){
    cost += (y-x)*b;
  }else if(min == x){
    cost += 2*c*(y-x);
  }else if(min == y){
    cost += 2*c*(x-y);
  }
  printf("%d",cost);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int n, m, a, b, t, ans = 500000, color[705], s[705], ac;
bool line[705][705], dp[705] = {true};
int main(){
	scanf("%d%d", &n, &m);
	rep(i,n) line[i][i] = true;
	rep(i,m){
		scanf("%d%d", &a, &b);a--;b--;
		line[a][b] = line[b][a] = true;
	}
	rep(i,n){
		if(color[i]) continue;
		int d[4] = {};
		stack<int> st;
		st.push(i); d[color[i] = 2]++;
		while(!st.empty()){
			int it = st.top(); st.pop();
			rep(j,n){
				if(!line[it][j]){
					if(!color[j]){
						st.push(j); d[color[j] = color[it]^1]++;
					}else if(color[j] == color[it]) return 0*puts("-1");
				}
			}
		}
		if(d[2] < d[3]) swap(d[2], d[3]);
		ac += d[3]; s[t++] = d[2] - d[3];
	}
	rep(i,t) for(int j = n - s[i]; j >= 0; j--) dp[j+s[i]] |= dp[j];
	rep(i,n) if(dp[i]) ans = min(ans, (n-i-ac)*(n-i-ac-1)/2 + (i+ac)*(i+ac-1)/2);
	printf("%d\n", ans);
}

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

int main() {
    int X;
    cin >> X;
    if (X >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
        
    return 0;
}


Measured memory_bytes: 3632
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    a = new Array;
    a[0] = Number(input);
    for(i = 0;i < 1000000; i++){
        
        if(a.indexOf(a[i]) < i){
            answer = i
            break;
        }

        switch(true){
    

            case a[i]%2 == 0:
            a[i+1] = a[i]/2;
            break;

            case a[i]%2 !== 0:
            a[i+1] = 3*a[i] + 1;
            break;
        }
        

    }

    console.log(answer+1);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
def func():
    pass


def main():
    s = input()
    t = input()

    s_s = set(s)
    t_s = set(t)

    s_c = list()
    t_c = list()

    for si in s_s:
        s_c.append(s.count(si))

    for ti in t_s:
        t_c.append(t.count(ti))

    # print(s_c)
    # print(t_c)
    if sorted(s_c) == sorted(t_c):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> h(N + 2, 0);
  for (int i = 1; i <= N; i++){
    cin >> h[i];
  }
  int sum = 0;
  for (int i = 0; i <= N; i++){
    sum += abs(h[i + 1] - h[i]);
  }
  cout << sum / 2;
}

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

namespace mondai0003
{
	class Program
	{
		static void Main(string[] args)
		{
			var	n	= int.Parse( Console.ReadLine() );
			for( int i = 0; i < n; i++ ) {
				var	vtx	= Array.ConvertAll( Console.ReadLine().Split(), v => int.Parse( v ) );
				Array.Sort( vtx );
				if( vtx[ 0 ] * vtx[ 0 ] + vtx[ 1 ] * vtx[ 1 ] == vtx[ 2 ] * vtx[ 2 ] ) {
					Console.WriteLine( "YES" );
				} else {
					Console.WriteLine( "NO" );
				}
			}
		}
	}
}

Measured memory_bytes: 5556
// https://atcoder.jp/contests/abc175/tasks/abc175_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

// グローバル変数で宣言することで0で初期化
// 宝の場所と価値
int T[3030][3030];
// 同一行内での取得済みお宝数(0,1,2,3個)を状態に持たせる
int dp[3030][3030][4];

void solve() {
    int H, W, K;

    cin >> H >> W >> K;
    REP(i, K) {
        int y, x, r;
        cin >> y >> x >> r;
        T[y - 1][x - 1] = r;
    }
    REP(y, H) REP(x, W) {
        // お宝を拾う場合を処理
        if (T[y][x] > 0) {
            for (int i = 2; i >= 0; i--) {
                dp[y][x][i + 1] = max(dp[y][x][i + 1], dp[y][x][i] + T[y][x]);
            }
        }
        // 移動する場合を処理
        REP(i, 4) {
            // y方向へ移動する場合は、行の宝の数を0にリセット
            dp[y + 1][x][0] = max(dp[y + 1][x][0], dp[y][x][i]);
            // x方向へ移動する場合は、そのままシフト
            dp[y][x + 1][i] = max(dp[y][x + 1][i], dp[y][x][i]);
        }
    }
    cout << dp[H][W - 1][0] << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 358784
// inputに入力データ全体が入る
function Main(input) {
	input = input.split("\n");
 
	var line1 = input[0].split(" ");
	var num = Number(line1[0])
	var data = input[1].split(" ");
	for(var i = 0; i<num; i++){
	    data[i] = Number(data[i]);
	}
	
	var sum = 0;

	for(var i = 0; i<num; i++){
	    sum += data[i];
    }

    var leftSum = 0
    var diff = 1e30;
    var ans = 1e30;

	for(var ite=0; ite<num-1;ite++){
	    leftSum += data[ite];
	    diff = Math.abs((sum-leftSum) - leftSum);
//	    console.log("i:"+ite+" ls:"+leftSum+" sum:"+sum+" diff:"+diff);
	    if(diff<ans){
	        ans = diff;
	    }
	}	
    
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 28740
fun main(args: Array<String>) {
    val list = readLine()!!.split(" ").map(String::toInt)
    val a = list[0]
    val b = list[1]
    val prc = when {
        ( a >= 13 ) -> b
        ( a >= 6  && a <= 12 ) -> b / 2
        else        -> 0
    }
    println(prc)
}

Measured memory_bytes: 37804
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x; 
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x; 
        return true;
    }
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    int n, k; cin >> n >> k;
    vector<int> light(n); FOR(i, 0, n) cin >> light[i];
    vector<int> sum(n);

    for(int i = 0; i < std::min(k, 100); ++i) {
        sum.assign(n, 0);
        for(int j = 0; j < n; ++j) {
            auto left = std::max(0, j - light[j]);
            auto right = std::min(n - 1, j + light[j]);
            sum[left]++;
            if (right < n - 1) {
                sum[right + 1]--;
            }
        }
        FOR(j, 1, n) { sum[j] += sum[j-1]; }
        FOR(j, 0, n) { light[j] = sum[j]; }
    }

    FOR(i, 0, n) {
        cout << light[i] << " ";
    }
}

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

Measured memory_bytes: 4776
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    string s;
    cin>>s;
    
    int stk = 0;
    int ans = 0;
    rep(i,s.size()){
        if(s[i]=='S'){
            stk++;
        }else{
            if(stk==0)ans++;
            else stk--;
        }
    }
    cout<<ans+stk<<endl;
}

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

int main(){
	bool b[1000000] = {};
	for(int i = 2; i < 1000000; i++){
		b[i] = true;
	}
	for(int i = 2; i < 1000; i++){
		if(b[i]){
			for(int j = i * i; j < 1000000; j += i){
				b[j] = false;
			}
		}
	}

	int n;
	while(cin >> n){
		int count = 0;
		for(int i = 0; i <= n; i++){
			if(b[i]){
				count ++;
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 2140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI acos(-1.0)
#define INF 10000000

typedef long long ll;

string s;
int n,dp[10][1100], c = 0;

int main(){
	cin >> n >> s;
	dp[0][0] = 1;
	//0:J 1:JO 2:JI 3:JOI 4:OI 5:O 6:I
	REP(i, s.size()){
		if (s[i] == 'J'){
			dp[0][i + 1] = (dp[0][i] + dp[1][i] + dp[2][i] + dp[3][i]) % 10007;
			dp[1][i + 1] = (dp[0][i] + dp[1][i] + dp[2][i] + dp[3][i] + dp[4][i] + dp[5][i]) % 10007;
			dp[2][i + 1] = (dp[0][i] + dp[1][i] + dp[2][i] + dp[3][i] + dp[4][i] + dp[6][i]) % 10007;
			dp[3][i + 1] = (dp[0][i] + dp[1][i] + dp[2][i] + dp[3][i] + dp[4][i] + dp[5][i] + dp[6][i]) % 10007;
		}
		else if (s[i] == 'O'){
			dp[1][i + 1] = (dp[0][i] + dp[1][i] + dp[2][i] + dp[3][i] + dp[4][i] + dp[5][i]) % 10007;
			dp[3][i + 1] = (dp[0][i] + dp[1][i] + dp[2][i] + dp[3][i] + dp[4][i] + dp[5][i] + dp[6][i]) % 10007;
			dp[4][i + 1] = (dp[1][i] + dp[2][i] + dp[3][i] + dp[4][i] + dp[5][i] + dp[6][i]) % 10007;
			dp[5][i + 1] = (dp[1][i] + dp[3][i] + dp[4][i] + dp[5][i]) % 10007;
		}
		else{
			dp[2][i + 1] = (dp[0][i] + dp[1][i] + dp[2][i] + dp[3][i] + dp[4][i] + dp[6][i]) % 10007;
			dp[3][i + 1] = (dp[0][i] + dp[1][i] + dp[2][i] + dp[3][i] + dp[4][i] + dp[5][i] + dp[6][i]) % 10007;
			dp[4][i + 1] = (dp[1][i] + dp[2][i] + dp[3][i] + dp[4][i] + dp[5][i] + dp[6][i]) % 10007;
			dp[6][i + 1] = (dp[2][i] + dp[3][i] + dp[4][i] + dp[6][i]) % 10007;
		}
	}
	REP(i, 7){
		c += dp[i][n];
		c %= 10007;
	}
	cout << c << endl;
}

Measured memory_bytes: 1236
import java.util.*;
import java.lang.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int W = sc.nextInt();
		long[] w = new long[n + 1];
		long[] v = new long[n + 1];
		for (int i = 1; i <= n; i++) {
			w[i] = sc.nextLong();
			v[i] = sc.nextLong();
		}
		long[][][] dp = new long[n + 1][n + 1][500];
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= i; j++) {
				for (int k = 0; k < 500; k++) {
					if (k - (w[i] - w[1]) < 0) {
						dp[i][j][k] = dp[i - 1][j][k];
					} else {
						dp[i][j][k] = Math.max(dp[i - 1][j - 1][k - (int) (w[i] - w[1])] + v[i], dp[i - 1][j][k]);
					}
				}
			}
		}
		long max = 0;
		for (int i = 0; i <= n; i++) {
			if (W - w[1] * i >= 0) {
				max = Math.max(max, dp[n][i][Math.min(499,W - (int)w[1] * i)]);
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 83284
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
from collections import Counter


n = getN()
nums = getList()
ans = n
muda = 0
ans = 0

for k, v in Counter(nums).items():
    # print(k, v)
    if v >= 2:
        muda += v -1
    ans += 1

if muda % 2 == 1:
    print(ans - 1)
else:
    print(ans)


Measured memory_bytes: 61660
import sys
import random
test = False

if test == True:
    seed = 24
    random.seed(seed)
    d = 365
    c = [random.randrange(0, 101) for _ in range(26)]
    s = [[random.randrange(0, 20001) for _ in range(26)] for _ in range(d)]
    c_ = ' '.join(map(str, c))
    s_ = '\n'.join([' '.join(map(str, i)) for i in s])
    with open('./input.txt', 'w') as f:
        f.write('\n'.join([str(d), c_, s_]))
else:
    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _i in range(d)]

last_days = [-1 for _i in range(26)]
result = []
for today in range(d):
    checker = [s[today][j]-c[j]*(today-last_days[j]) for j in range(26)]
    x = checker.index(max(checker))
    last_days[x] = today
    result.append(x+1)

if test == True:
    with open('./output.txt', 'w') as f:
        f.write('\n'.join(map(str, result)))
else:
    for i in result:
        print(i)

Measured memory_bytes: 83752
from sys import stdin
input = stdin.buffer.readline

def main():
    n, m, q = map(int, input().split())

    # Two-dimensional Cumulative Sum
    cs = [[0] * (n+1) for _ in range(n+1)]

    for _ in range(m):
        l, r = map(int, input().split())
        cs[l][r] += 1

    for l in range(1, n+1):
        for r in range(1, n+1):
            cs[l][r] += cs[l][r-1]
        for r in range(1, n+1):
            cs[l][r] += cs[l-1][r]

    ans = [-1] * q
    for lap in range(q):
        l, r = map(int, input().split())
        ans[lap] = cs[n][r] - cs[l-1][r]

    for i in ans:
        print(i)

main()

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

void NextPrime()
{
  int x;
  cin >> x;
  while (1)
  {
    int count = 1;
    for (int i = 2; i < x; i++) 
    {
      if (x % i == 0)
      {
        count++;
        break;
      }
    }
    if(count==1)
    {
      cout << x << endl;
      break;
    }
    x++;
  }
  return;
}


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

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());
			int[] a = new int[N];
			int max1 = 0, max2 = 0;
			for (int i = 0; i < N; i++) {
				a[i] = int.Parse(Console.ReadLine());
				if (max1 == 0 || max1 < a[i]) {
					max2 = max1;
					max1 = a[i];
				} else if (max2 == 0 || max2 < a[i]) {
					max2 = a[i];
				}
			}
			for (int i = 0; i < N; i++) {
				if (a[i] != max1) {
					Console.WriteLine(max1);
				} else {
					Console.WriteLine(max2);
				}
			}
		}
	}
}


Measured memory_bytes: 17108
#include<iostream>
#include<algorithm>
#include<queue>
#include<deque>
#include<map>
#include<vector>
#include<math.h>
long long int mod = 1000000007;
long long modpow(long long a, long long n, long long mod);
long long modinv(long long a, long long mod);
using namespace std;
int main() {
	
	//B
	string s;
	cin >> s;
	int n = 0;
	int i;
	for (i = 0; i < s.length(); i++) {
		n = n + (s[i] - '0');
		n = n % 9;
	}
	if (n == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;

	}
	return 0;

	//A
	/*int n, x, t;
	cin >> n >> x >> t;
	cout << ((n - 1) / x) * t + t << endl;

	return 0;
	*/
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
	return modpow(a, mod - 2, mod);
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++)  cin >> a[i];
    for(int i = 0; i < n; i++)  cin >> b[i];
    for(int i = 0; i < n; i++){
        if(a[i] == b[i])    continue;
        if(a[i] > b[i]) swap(a, b);
        break;
    }
    int ret = 0;
    do{
        bool x = true;
        for(int i = 0; i < n; i++)  x &= a[i] == b[i];
        if(x)   break;
        ret++;
    }while(next_permutation(a.begin(), a.end()));
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
from collections import deque
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))
 
def end():
    print(-1)
    exit()
 
def main():
    n = I()
    a = deque(LI())
    if n==0:
        if a[0] == 1:
            print(1)
            exit()
        else:
            end()
    elif a[0]!=0:
        end()

    b = [0]*(n+1)
    for i in range(n,-1,-1):
        if i == n:
            b[i] = a[i]
        else:
            b[i] = min(b[i+1]+a[i],2**i)

    for i in range(n+1):
        if i!=0:
            b[i] = min(2*(b[i-1]-a[i-1]),b[i])
        if b[i]<a[i]:
            end()
    print(sum(b))
    return
 
if __name__=='__main__':
    main()

Measured memory_bytes: 82496
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

class D {
    static StreamWriter Out = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static void Main(string[] args) {
        int N, X, Y;
        Input(out N, out X, out Y);
        int[] count = new int[N];
        for(int i = 1; i <= N; i++) {
            for(int j = i + 1; j <= N; j++) {
                int distance = Math.Min(Math.Abs(i - j), Math.Min(Math.Abs(i - X) + 1 + Math.Abs(Y - j), Math.Abs(i - Y) + 1 + Math.Abs(X - j)));
                count[distance]++;
            }
        }
        for(int i = 1; i < N; i++) {
            Print(count[i]);
        }
        Out.Flush();
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void Inputs<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
    static void Print<T>(T s) => Out.WriteLine(s);
    static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s));
    static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e));
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
const double PI = 3.14159265358979323846;

using Graph = vector<vector<int>>;

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

using P = pair<ll, ll>;

int main()
{	
    ll n;
    cin >> n;
    ll zero = 0;
    map<pair<ll, ll>, P> mp;
    REP(i, n){
        ll x, y;
        cin >> x >> y;
        if(x == 0 && y == 0){
            zero++;
            continue;
        }
        ll g = gcd(x, y);
        x /= g;
        y /= g;
        if(y < 0) x = -x, y = -y;           //180°回転させる
        if(y == 0 && x < 0) x = -x, y = -y; //180°回転させる
        bool rot90 = (x <= 0);
        if(rot90){                          //90°回転させる
            ll tmp = x;
            x = y; y = -tmp;
        }
        if(rot90) mp[{x,y}].first++;
        else mp[{x,y}].second++;
    }

        Mint ans = 1;
        for(auto p : mp){
            ll s = p.second.first;          //90°回転させたものの総数
            ll t = p.second.second;         //90°回転させてないものの総数
            Mint now = 1;
            now += Mint(2).pow(s) - 1;
            now += Mint(2).pow(t) - 1;
            ans *= now;
        }
        
    ans -= 1;
    ans += zero;
    cout << ans << endl;
}


Measured memory_bytes: 19216
package main
 
import (
	"fmt"
)
 
func main() {
  var a, b, c int
  five := 0
  seven := 0
  
  fmt.Scanf("%d", &a)
  if a == 5 {
    five++
  }
  if a == 7 {
    seven++
  }
  fmt.Scanf("%d", &b)
  if b == 5 {
    five++
  }
  if b == 7 {
    seven++
  }
  fmt.Scanf("%d", &c)
  if c == 5 {
    five++
  }
  if c == 7 {
    seven++
  }
  
  ans := "NO"
  if five == 2 && seven == 1{
    ans = "YES"
  }
  
  fmt.Printf("%s", ans)
}

Measured memory_bytes: 1836
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
signed main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(min(abs(a - b) + abs(b - c), abs(a - c) + abs(b - c)), abs(a - b) + abs(a - c)) << "\n";
}


Measured memory_bytes: 256
import numpy as np

n=int(input())
a=np.array([int(input()) for i in range(n)])
a=np.sort(a)
ans=0
i=0
while(i<=n-1):
    c=1
    while(i<=n-2 and a[i]==a[i+1]):
        i+=1
        c+=1
    if(c%2==1):ans+=1
    #print(a[i],c)
    i+=1
print(ans)


Measured memory_bytes: 17128
#include <stdio.h>
int n, v, a[25][2], r; bool f[25];
void p1(int u) { if(!~u) return; printf(" %d", u), p1(a[u][0]), p1(a[u][1]); }
void p2(int u) { if(!~u) return; p2(a[u][0]), printf(" %d", u), p2(a[u][1]); }
void p3(int u) { if(!~u) return; p3(a[u][0]), p3(a[u][1]), printf(" %d", u); }
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &v), scanf("%d%d", a[v], a[v] + 1), f[a[v][0]] = f[a[v][1]] = true;
	for(int i = 0; i < n; i++) if(!f[i]) r = i;
	puts("Preorder"); p1(r); puts("");
	puts("Inorder"); p2(r); puts("");
	puts("Postorder"); p3(r); puts("");
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9 + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  int minv = INF;
  for (int i = 0; i < s.length() - 2; ++i) {
    minv = min(minv, abs(753 - stoi(s.substr(i, 3))));
  }
  cout << minv << "\n";
  return 0;
}

Measured memory_bytes: 256
import sys
import math
from decimal import Decimal
input = sys.stdin.readline

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

lst_1 = []
lst_2 = []

for _ in range(M):
    a,b = map(int, input().split())
    lst_1.append(a)
    lst_2.append(b)

if min(lst_2) < max(lst_1):
    print(0)
else:
    print(min(lst_2)-max(lst_1)+1)

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 998244353;
const double PI = 3.141592653589793238463;
const int MAXN = 1e5 + 5;

ll fastPow(ll x, ll b) {
    if (b == 0)
        return 1;
    else if (!(b & 1)) {
        return fastPow(x * x, b / 2);
    } else
        return x * fastPow(x * x, (b - 1) / 2);
}

//__builtin_popcount ();

int main(){
    FAST
    int n,m;
    cin>>n>>m;
    set<pair<int,int>> s;
    set<int>ch;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        s.insert({a,b});
    }

    vector<pair<int,int>>v(s.begin(),s.end());
    for(int i=0;i<=pow(10,n);i++)
    {
        string h=to_string(i);
        bool flag=0;
        if(h.size()==n)
        {

            for(int j=0;j<v.size();j++)
            {
                if(h[v[j].first-1]==(char)(v[j].second+'0'))
                {
                    continue;
                }
                else
                    flag=1;
            }
            if(!flag)
                return cout<<h,0;
        }

    }
    cout<<-1<<endl;
    return 0;
}

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

int main () {

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

    int odds = 0, evens = 0;
    for (int i = 0; i < N; i++) {
        int a;
        scanf("%d", &a);

        if (a % 2 == 0) evens++;
        else odds++;
    }

    printf((odds % 2 == 0)? "YES" : "NO");
    printf("\n");

    return 0;
}

Measured memory_bytes: 256