akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

ll n, a, b;

vector<ll> com;

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

void calc_c() {
    com[0] = 1;
    ll j = 1;
    for (ll i = n; i >= n - b + 1; i--) {
        com[j] = ((com[j - 1] * i) % MOD * modpow(j, MOD-2, MOD)) % MOD;
        j++;
    }
}

int main()
{
    cin >> n >> a >> b;
    ll ans = 0;

    com.assign(b + 1, 0);
    calc_c();

    ll subtract = (com[a] + com[b]) % MOD;

    ans = modpow(2, n, MOD) - subtract - 1;

    if (ans < 0) cout << ans + MOD << endl;
    else cout << ans << endl;

    return 0;
}

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

int main() {
  int N, max, k, sub=0;
  cin >> N;
  vector<int> card(N);
  
  for(int i=0;i<N;i++){
    cin >> card.at(i);
  }
  
  for(int i=0;i<N;i++){
    max=0;
    for(int j=0;j<N;j++){
      if(max<card.at(j)){
        max = card.at(j);
        k=j;
      }
    }
    if(i % 2 == 0){
      sub += max;
    }else{
      sub -= max;
    }
    card.at(k) = 0;
  }
  
  cout << sub << endl;
  
  
}


Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int n;
    cin >> n;
    vector<int> c(n), w(n);
    vector<int> Wsum(n+1);
    for (int i = 0; i < n; ++i) {
        cin >> c[i] >> w[i];
        Wsum[i+1] = Wsum[i] + w[i];
    }

    auto dp = make_v(n, n, false);
    for (int i = 0; i < n; ++i) {
        dp[i][i] = 1;
    }
    for (int len = 1; len < n; ++len) {
        for (int i = 0, j = len; j < n; ++i, ++j) {
            if(dp[i+1][j] && Wsum[j+1]-Wsum[i+1] <= c[i]) dp[i][j] = true;
            if(dp[i][j-1] && Wsum[j]-Wsum[i] <= c[j]) dp[i][j] = true;
        }
    }
    vector<int> ans(n+1, INF<int>);
    ans[0] = 0;
    for (int i = 0; i < n; ++i) {
        int r = i+1;
        for (int j = i; j < n; ++j) {
            if(dp[i][j]) r = max(r, j+1);
        }
        for (int j = i+1; j <= r; ++j) {
            ans[j] = min(ans[j], ans[i]+1);
        }
    }
    cout << ans.back() << "\n";
    return 0;
}


Measured memory_bytes: 3196
fun main(args: Array<String>) {
        val n = nextInt()
        val xy = Array(n) { listOfLong(-1) }

        val sx = (0 until n).sortedBy { xy[it][0] }
        val sy = (0 until n).sortedBy { xy[it][1] }

        val edges = mutableListOf<Triple<Int, Int, Long>>()
        for (n in 1 until n) {
            val fx = sx[n]
            val tx = sx[n - 1]
            val dx = xy[fx][0] - xy[tx][0]
            edges.add(Triple(fx, tx, dx))

            val fy = sy[n]
            val ty = sy[n - 1]
            val dy = xy[fy][1] - xy[ty][1]
            edges.add(Triple(fy, ty, dy))
        }
        edges.sortBy { it.third }

        val uf = UnionFind(n)
        var ans = 0L
        for (n in edges.indices) {
            if (uf.unite(edges[n].first, edges[n].second)) {
                ans += edges[n].third
            }
        }

        println(ans)
    }





fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }
fun listOfLong(offset: Long = 0L) = listOfString().map { it.toLong() + offset}

class UnionFind(n: Int) {
    var rank: IntArray
    var par:  IntArray
    var size: IntArray
    init {
        this.rank = IntArray(n) { 0 }
        this.par  = IntArray(n) { it }
        this.size = IntArray(n) { 1 }
    }
    fun union(x: Int, y: Int): Boolean {
        var rx = this.root(x)
        var ry = this.root(y)
        if (rx == ry) return false
        if (this.rank[rx] < this.rank[ry]) {
            val w = rx
            rx = ry
            ry = w
        } else if (this.rank[rx] == this.rank[ry]) {
            this.rank[rx] += 1
        }
        this.par[ry] = rx
        this.size[rx] += this.size[ry]
        return true
    }
    fun find(x: Int): Int {
        if (this.par[x] == x) return x
        else {
            this.par[x] = this.find(this.par[x])
            return this.par[x]
        }
    }
    fun isSame(x: Int, y: Int) = this.root(x) == this.root(y)
    fun size(x: Int): Int = this.size[this.find(x)]
    fun root(x: Int): Int = this.find(x)
    fun unite(x: Int, y: Int) = this.union(x, y)
}


Measured memory_bytes: 160768
n,k = map(int, raw_input().split(' '))

left = n % k
cc = [0] * k
for ii in range(k):
	cc[ii] += n / k
	if 0<ii <= left: cc[ii] += 1


r = 0
for ii,vv in enumerate(cc):
	if (2*ii) % k == 0:
		jj = (k - ii) % k
		r += vv * ((cc[jj]) ** 2) 
print r

Measured memory_bytes: 70256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n) + 1; i++)
#define all(vecto) vecto.begin(), vecto.end()
#define max3(a, b, c) max(a, max(b, c))
#define min3(a,b,c) min(a,min(b,c))
typedef long long ll;

void ans(bool qus){
    if (qus == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Ans(bool qust){
    if (qust == true)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

////////////////---START---////////////////

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    bool s = a + b >= c;
    ans(s);
}


Measured memory_bytes: 256
n=gets.to_i
a=[0]+gets.split.map(&:to_i)+[0]

d=0
for i in 0..n
  d+=(a[i+1]-a[i]).abs
end
for i in 0..n-1
  p d-(a[i+1]-a[i]).abs-(a[i+2]-a[i+1]).abs+(a[i+2]-a[i]).abs
end


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

using namespace std;

#define int long long

int f(int a, int b) {

    if(b == 0)
        return 0;
    if(a == b)
        return b;
    int ans = 0;
    if(a % b == 0)
    ans += (2 * (a / b) - 1) * b;
    else
    ans += (2 * (a / b) ) * b;
    ans += f(b, a % b);

    return ans;
}


int32_t main()
{
    int n, x, ans;
    cin >> n >> x;
    ans = n;

    ans += f(max(x, n - x), min(x, n - x));

    cout << ans;


	return 0;
}


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


int main() {
  ll x;
  cin >> x;
  ll i=100;
  ll cnt=0;
  while (i<x){

       cnt++;
       i=i*1.01;

  }
  cout<<cnt;


}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = s.clone();

        int front = 0;
        for (int i = 0; i < s.length - 1; i++) {
            if (s[i] == s[i + 1]) {
                if (s[i + 1] == '0') {
                    s[i + 1] = '1';
                } else {
                    s[i + 1] = '0';
                }
                front++;
            }
        }

        int back = 0;
        for (int i = t.length - 1; i > 0; i--) {
            if (t[i] == t[i - 1]) {
                if (t[i - 1] == '0') {
                    t[i - 1] = '1';
                } else {
                    t[i - 1] = '0';
                }
                back++;
            }

        }

        System.out.println(Math.min(front, back));
    }
}

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

using ll = long long;
using ull = unsigned long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define bzero(p, n) memset(p, 0, n)
#define all(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(ALL(c)); c.erase(unique(ALL(c)), c.end()); }
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
inline ll powll(ll x,ll y) {ll p=1; while(y--) p*=x; return p;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    ll N; cin >> N;
    vector<pair<ll,ll>> BA(N);

    ll a, b;
    rep(i, N) {
        cin >> a >> b;
        BA[i] = make_pair(b, a);
    }
    sort(all(BA));

    bool f = true;
    ll t = 0;
    rep(i, N) {
        //cout << FMT3(t, BA[i].second, BA[i].first) << endl;
        if (t + BA[i].second > BA[i].first) {
            f = false;
            break;
        }
        t += BA[i].second;
    }
    cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3456
from collections import deque
from operator import itemgetter
n,m = map(int,input().split())
edge = [list(map(int,input().split())) for i in range(m)]

kyori =[[float("inf")]*n for i in range(n)]
for i in range(n):
  kyori[i][i] = 0
  
def dfs(start,goal):
  visited_cost = [float("inf")]*n
  visited_cost[start] = 0
  que = deque()
  que.append(start)
  while que:
    pos = que.pop()
    for [next_pos,cost] in tree[pos]:
      #print(next_pos,cost)
      if visited_cost[next_pos] > visited_cost[pos] + cost:
        visited_cost[next_pos] = visited_cost[pos] + cost
        que.append(next_pos)    
  return visited_cost[goal]

edge = sorted(edge, key=itemgetter(2))
tree = [[] for i in range(n)]

ans = m
for [start,goal,cost] in edge:
  start -= 1
  goal -= 1
  if cost <= dfs(start,goal):
    tree[start].append([goal,cost])
    tree[goal].append([start,cost])
    ans -= 1
    
print(ans)

Measured memory_bytes: 3692
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
			a[i] = scan.nextInt();
		}

		int[] cost = new int[201];
		int k = 0;
		for(int i = -100; i <= 100; i++){
			for(int j = 0; j < n; j++){
				cost[k] += (a[j] - i) * (a[j] - i);
			}
			k ++;
		}

		int min = cost[0];
		for(int i = 1; i < 201; i++){
			if(cost[i] < min){
				min = cost[i];
			}
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n,in,ans=1;
	vi v;
	bool det=false,s;
	cin >> n;
	rep(i, n) {
		cin >> in;
		v.push_back(in);
	}
	if (n != 1) {
		range(i, 1, n) {
			if (v[i]!=v[i-1]) {
				if (!det) {
					s = (v[i] < v[i - 1]);
					det = true;
				}
				else {
					if (s != (v[i] < v[i - 1])) {
						ans++;
						det = false;
					}
				}
			}
			//det = !det;
		}
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 892
n=int(input())
t,a=map(int,input().split())
ans=0
min=1000000000
h=list(map(int, input().split()))
for i in range(n):
  b=t-h[i]*0.006
  if min>abs(a-b):
    ans=i+1
    min=abs(a-b)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,M;
  cin>>N>>M;
  if(N%2)
  {
    for(int i=0;i<M;i++)
      cout<<i+1<<" "<<N-i<<endl;
    return 0;
  }
  else
  {
    int X=1;
    while(X+X-1<N+1-X-X&&M)
    {
      M--;
      cout<<X<<" "<<N-X+1<<endl;
      X++;
    }
    N--;
    while(M)
    {
      M--;
      cout<<X<<" "<<N-X+1<<endl;
      X++;
    }
    return 0;
  }
}

Measured memory_bytes: 3656
//***Little by little one travels far***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
    ll a,b;
    cin>>a>>b;
    if(a>b) swap(a,b);
    if((a==1)&&(b==2)) cout<<"3";
    if((a==1)&&(b==3)) cout<<"2";
    if((a==2)&&(b==3)) cout<<"1";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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(){
    ll n; cin>>n;
    ll a=n*100/108, b=(n+1)*100/108;
    if((n*100)%108==0) {cout<<a<<endl; return 0;}
    else if(((n+1)*100)%108==0 && a+1>=b) {cout<<":("<<endl; return 0;}
    else if(((n+1)*100)%108==0){cout<<b-1<<endl;}
  	else if(a==b){cout<<":("<<endl; return 0;}
    else cout<<b<<endl;
}

Measured memory_bytes: 256
s = list(input())
f1 = 0
f2 = 0
if int(s[0]) >=2:
    f1 =1
if int(s[0]) ==1 and int(s[1]) >= 3:
    f1 = 1
if int(s[0]) ==0 and int(s[1]) ==0:
    f1 =1

if int(s[2]) >=2:
    f2 =1
if int(s[2]) ==1 and int(s[2]) >= 3:
    f2 = 1
if int(s[2]) ==0 and int(s[3]) ==0:
    f2 =1

if (f1+f2) ==1:
    if f1 ==1:
        s = "YYMM"
    else:
        s = "MMYY"
else:
    if (f1+f2) ==2:
        s = "NA"
    else:
        s = "AMBIGUOUS"
print(s)


Measured memory_bytes: 3064
import java.math.BigInteger;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		List<String> s=new ArrayList<String>();
		List<Integer> t=new ArrayList<Integer>();
		int result=0;
		for(int i=0;i<n;i++) {
			s.add(sc.next());
			t.add(sc.nextInt());
		}
		String x=sc.next();
		int cc=0;
		for(cc=0;cc<n;cc++) {
			if(x.equals(s.get(cc))) {
				break;
			}
		}
		for(int i=cc+1;i<n;i++) {
			result+=t.get(i);
		}
		System.out.println(result);
		sc.close();
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll moder = 1000000007;
int main(){
	ll n,k;
	cin>>n>>k;
	long long ret = 0;
	for(ll i=k; i<=n+1; i++){
		ll lower = i*(i-1)/2;
		lower%=moder;
		ll upper = n*i-i*(i-1)/2;
		ret+=upper-lower+1;
		ret%=moder;
	}
	cout<<ret;
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
    return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
    return a / gcd(a, b) * b;
}

string IntToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}

int main()
{
    string s;
    ci >> s;

    int mx = 0;
    regex pat("[ACGT]");
    smatch sm;

    int cnt = 0;
    rep(i, s.size()) {
	string tmp = ""; tmp += s[i];

	if(regex_match(tmp, pat)) cnt++;
	else cnt = 0;

	mx = max(mx, cnt);
    }

    co << mx << en;
  
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		String num = in.next();
		num += in.next();
		num += in.next();
		int a = Integer.parseInt(num);
		if(a%4==0){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 23636
P = "perfect number"
D = "deficient number"
A = "abundant number"
while True:
    n = int(raw_input())
    if n==0:
        break
    if n==1:
        print D
        continue
    su = 1
    t = n
    i = 2
    while i**2<=t:
        if t%i==0:
            cnt = 0
            while t%i==0:
                t /= i
                cnt += 1
            su *= (i**(cnt+1)-1)/(i-1)
        i += 1
    if t>1:
        su *= (t**2-1)/(t-1)
    su -= n
    print P if n==su else (D if su<n else A)

Measured memory_bytes: 4228
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;


int main(){
  char a,b;
  cin>>a>>b;
  bool aa=(a=='H');
  bool bb=(b=='H');
  if(aa){
    if(bb) cout<<'H'<<endl;
    else cout<<'D'<<endl;
  }else{
    if(bb) cout<<'D'<<endl;
    else cout<<'H'<<endl;
  }

  return 0;
}


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

int n;

int main(){
	scanf("%d", &n);
	int left = 0, right = 1e9;
	while (left < right){
		int mid = left + right >> 1;
		if (1ll * mid * (mid + 1) >> 1 >= n){
			right = mid;
		}
		else{
			left = mid + 1;
		}
	}
	return printf("%d\n", left), 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}




signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N;
    cin >> N;
    vector<int> A(N);
    map<int,int> mp;
    REP (i, N) {
        cin >> A[i];
        mp[A[i]]++;
    }
    int M = *max_element(ALL(A));
    SORT(A);

    bitset<1000001> is_prime(0);
    for (auto i : mp) is_prime.set(i.first);
    for (auto i : mp) {
        if (is_prime[i.first]) {
            for (int j = i.first * 2; j <= M; j += i.first) {
                is_prime.reset(j);
            }
            if (i.second > 1) is_prime.reset(i.first);
        }
    }
    ans = is_prime.count();
    /*
    for (auto i : mp) {
        for (int j = 2*i.first; j <= M; j+=i.first) {
            mp[j] = 0;
        }
        if (i.second > 1) mp[i.first] = 0;
    }
    
    for (auto i : mp) {
        if (i.second > 1) ans--;
    }
    */
    
    pa;
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc170/abc170_d && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc170/abc170_d && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc170/abc170_d && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 17440
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
		int x =Integer.parseInt(br.readLine());

		int h = x/3600;
		int m = x/60%60;
		int s = x%60;

		System.out.println(h+":"+m+":"+s);







	}

}



Measured memory_bytes: 24456
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  int m;
  int total =0;
  cin >> n;
  string s = to_string(n);
  string t;
  for (size_t i = 0; i < s.size(); i++) {
    t = s.substr(i,1);
    total += stoi(t);
  }
  if(n%total==0){
    cout << "Yes" <<endl;
  }else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
from operator import itemgetter

n = int(input())
a = [0] + list(map(int, input().split())) + [0]

sougaku = 0
for i in range(n + 1):
	sougaku += abs(a[i] - a[i + 1])

for i in range(1, n + 1):
	print(sougaku - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]))

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


int main() {
  int h, w;
  cin >> h >> w;
  vector<string> org(h);
  rep(i, h) {
    cin >> org[i];
  }
  rep(i, h) {
    cout << org[i] << endl;
    cout << org[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int l=a+b;
  int r=c+d;
  if(l==r)cout<<"Balanced"<<endl;
  else if(l>r)cout<<"Left"<<endl;
  else cout<<"Right"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

ll calc(vector<PP> a,ll m) {
  sort(all(a));
  int n=a.size();
  priority_queue<ll> que;
  ll ans=0;
  rep(i,n) {
    ll k=a[i].F,l=a[i].S.F,r=a[i].S.S;
    ans+=l;
    que.push(r-l);
    while(que.size()>m+1||que.size()>k+1) {
      ans+=que.top();que.pop();
    }
  }
  return ans;
}

void Main() {
  ll T;
  R T;
  while(T--) {
    ll n;
    R n;
    vector<PP> a,b;
    rep(i,n) {
      ll k,l,r;
      cin >> k >> l >> r;
      k--;
      if(l>=r) a.pb(PP(k,P(l,r)));
      else b.pb(PP(n-2-k,P(r,l)));
    }
    sort(all(a));
    sort(all(b));
    ll l=0,r=n;
    while(l+3<r) {
      ll m1=(l*2+r)/3,m2=(l+r*2)/3;
      ll d1=calc(a,m1)+calc(b,n-m1);
      ll d2=calc(a,m2)+calc(b,n-m2);
      if(d1<d2) l=m1;
      else r=m2;
    }
    ll ans=0;
    REP(i,-5,5) {
      ll m=i+l;
      if(m>=-1&&m<n) {
        ll d=calc(a,m)+calc(b,n-m);
        ans=max(ans,d);
      }
    }
    pr(ans);
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 14548
use std::cmp::*;
use std::io::Read;
use std::iter::Scan;

trait Ext {
    fn try_fold_<B, F>(&mut self, init: B, mut f: F) -> Option<B>
    where
        Self: Sized + Iterator,
        F: FnMut(B, Self::Item) -> Option<B>,
    {
        let mut accum = init;
        while let Some(x) = self.next() {
            if let Some(new_accum) = f(accum, x) {
                accum = new_accum;
            } else {
                return None;
            }
        }
        Some(accum)
    }
}
impl<I, St, F> Ext for Scan<I, St, F> {}

fn cost(a: &[i64], bits: u32) -> Option<i64> {
    let mut cur_height = 0;
    let mut cost = 0;
    for (i, &height) in a.iter().enumerate() {
        if (bits >> i) & 1 != 0 {
            let expected_height = max(cur_height + 1, height);
            cur_height = expected_height;
            cost += expected_height - height;
        } else if height > cur_height {
            return None;
        }
    }
    Some(cost)
}

fn solve(n: usize, k: usize, a: Vec<i64>) -> i64 {
    (0u32..(1 << n))
        .filter(|&bits| bits.count_ones() >= (k as u32))
        .filter_map(|bits| cost(&a, bits))
        .min()
        .unwrap()
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let k: usize = iter.next().unwrap().parse().unwrap();
    let a = (0..n)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect();
    let r = solve(n, k, a);
    println!("{}", r);
}


Measured memory_bytes: 4352
//============================================================================
// Name        : HelloCPP.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

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

int main() {

	int a;
	long long b;
	long long min = 1000000 ,max=-1000000;
	long long sum= 0;
	cin >> a;
	for(int i = 0; i < a; i++){
		cin >> b;

		if(b < min)min = b;
		if(b > max)max = b;

		sum = sum + b;
	}

	//printf("%d %d %d\n",min ,max, sum);
	cout << min <<  " " << max << " " << sum << endl;

	return 0;
}

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

int main() {
    int n;
    cin>>n;
    if(n<=1000 && n>=1) cout<<1000-n;
    if(n<=2000 && n>1000) cout<<2000-n;
    if(n<=3000 && n>2000) cout<<3000-n;
    if(n<=4000 && n>3000) cout<<4000-n;
    if(n<=5000 && n>4000) cout<<5000-n;
    if(n<=6000 && n>5000) cout<<6000-n;
    if(n<=7000 && n>6000) cout<<7000-n;
    if(n<=8000 && n>7000) cout<<8000-n;
    if(n<=9000 && n>8000) cout<<9000-n;
    if(n<=10000 && n>9000) cout<<10000-n;
	return 0;
}


Measured memory_bytes: 3576
def S(): return input()


def main():
    s = [ord(c) - 97 for c in S()]
    t = [ord(c) - 97 for c in S()]
    sl = len(s)
    tl = len(t)
    rr = [[0] * (tl) for _ in range(sl)]
    t0 = t[0]
    for i in range(sl):
        if s[i] == t0:
            for k in range(i,sl):
                rr[k][0] = 1
            break

    rr0 = rr[0]
    s0 = s[0]
    for j in range(tl):
        if s0 == t[j]:
            for k in range(j,tl):
                rr0[k] = 1
            break

    ta = [(i,t[i]) for i in range(1, tl)]
    for i in range(1, sl):
        rri = rr[i]
        rri1 = rr[i-1]
        si = s[i]
        for j, tj in ta:
            if si == tj:
                rri[j] = rri1[j-1] + 1
            else:
                rri[j] = rri1[j]
                if rri[j] < rri[j-1]:
                    rri[j] = rri[j-1]

    i = sl-1
    j = tl-1
    r = []
    while i >= 0 and j >= 0:
        if s[i] == t[j]:
            r.append(s[i] + 97)
            i -= 1
            j -= 1
            continue
        if rr[i][j] == 0:
            break
        if i > 0 and rr[i-1][j] == rr[i][j]:
            i -= 1
        else:
            j -= 1

    return ''.join(map(chr,r[::-1]))


print(main())


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

const int maxN = 1e5 + 10;
typedef long long ll;

int main(){
    string str;
    cin >> str;
    if(str[2] == str[3] && str[4] == str[5]) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<cstdlib>

using namespace std;
 
typedef long long ll;
  
ll expression();
ll term();
ll factor();
ll number();
  
int now;
string s;
ll P;
bool fg;
 
ll extgcd(ll a, ll b, ll& x, ll& y){
  ll d = a;
  if(b!=0){
    d=extgcd(b, a%b ,y,x);
    y-=(a/b)*x;
  }
  else{
    x=1; y=0;
  }
  return d;
}
 
ll mod_inverse(ll a,ll m){
  ll x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}
 
ll expression(){
  if(fg)return 0;
    ll res=term();
        while(true){
      if(s[now]=='+')now++,(res+=term())%=P;
      else if(s[now]=='-')now++,(res+=P-term())%=P;
      else break;
    }
    return res;
}
 
ll term(){
  ll res=factor();
  while(true){
    if(s[now]=='(')res+=factor();
    else if(s[now]=='*')now++,(res*=factor())%=P;
    else if(s[now]=='/'){
      now++;
      ll tmp=factor();
      if(tmp==0)fg=true;
      res=((res%P)*mod_inverse(tmp,P)%P)%P;
    }
    else break;
  }
  return res;
}
 
ll factor(){
    ll res=0;
    if(s[now]=='('){
        now++;
        res=expression()%P;
        now++;
    }
    else return number();
      
    return res%P;
}
  
ll number(){
    ll res=0;
    while('0'<=s[now] && s[now]<='9'){
        res*=10;
        res+=s[now++]-'0';
    }
    return res%P;
}
 
/*
int main(void){
   
  string p,in;
  while(cin >> p){
    if(p[0]=='0')break;
     
    fg=false;
    now=0;
    P=0;
    while('0'<=p[now] && p[now]<='9'){
      P*=10;
      P+=p[now++]-'0';
    }
 
    now=0;
    getline(cin,in);
    s.clear();
    for(int i=0;i<in.size();i++)
      if(in[i]!=' ')s+=in[i];
     
    ll ans = expression();
     
    if(fg)cout << "NG" << endl;
    else cout << s << " = " << ans%P << " (mod " << P  << ")"<< endl;
  }
  return 0;
}
*/

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)

int main(){
  string tmp;
  while(getline(cin,tmp)){
    if(tmp[0] == '0')break;
    rep(i,tmp.size())if(tmp[i] == ':'){
      tmp[i] = ' ';
      break;
   }

    string text;

    now = 0;
    text.clear();
    stringstream ss;
    ss << tmp;
    ss >> tmp;
    P = (atol)(tmp.c_str());
    while(!(ss >> tmp).fail()){
      text += tmp;
    }
    s=text;
    fg = false;
    ll ans = expression();
    if(fg) cout << "NG" << endl;
    else    cout << text << " = " << ans << " (mod " << P << ")" << endl;
 
  }
 
  return 0;
}

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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

ll xp(ll b, ll e) {
	if (e == 0) return 1;
	if (e == 1) return b;
	ll c = xp(b, e >> 1);
	c *= c;
	c %= mod;
	if (e & 1) c *= b, c %= mod;
	return c;
}

pair<ll, ll> eucl(ll a, ll b) {
	if (!b) return {1ll, 0ll};
	ll x, y;
	tie(x, y) = eucl(b, a % b);
	return {y, x - a / b * y};
}

ll inv(ll x) {
	ll n, m;
	tie(n, m) = eucl(x, mod);
	if (n < 0) {
		n %= mod;
		if (n < 0) n += mod;
	}
	return n;
}

ll choose(ll n, ll k) {
	ll a = 1, b = 1;
	loop(k) {
		a *= n - i;
		a %= mod;
		b *= i + 1;
		b %= mod;
	}
	return a * inv(b) % mod;
}

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

	int n, a, b;
	cin >> n >> a >> b;
	ll ans = xp(2, n) - 1;
	ans -= choose(n, a) + choose(n, b);
	ans %= mod;
	if (ans < 0) ans += mod;
	cout << ans << endl;
	return 0;
}



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

int main() {
int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A+B ;
  R = C+D ;
  if(L<R){
    cout << "Right" << endl;
  }
  else if(L>R){
    cout << "Left" << endl;
  }
  else if(L==R){
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(X: int):
    x = X - 400
    i = x//200
    print(8-i)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61708
#include <iostream>
#include <string>
#include <cctype>

#define rep(i,n)  for(int i=0;i<n;++i)

using namespace std;

string src;
int pos;

bool end() { return pos >= src.length(); }
char peek() { return src[pos]; }
void succ() { if (!end()) ++pos; }

int parse_expr();

int lex_number()
{
	int val = 0;
	char c = peek();
	do
	{
		val = 10 * val + (c - '0');
		succ();
	}
	while (!end() && isdigit(c = peek()));
	return val;
}

int parse_primary()
{
	int ret;

	char c = peek();
	switch (c)
	{
	case '(':
		succ();
		ret = parse_expr();
		succ();
		break;
	default:
		ret = lex_number();
		break;
	}
	return ret;
}

int parse_term()
{
	int x = parse_primary();
	while (!end() && (peek() == '*' || peek() == '/'))
	{
		char op = peek();
		succ();
		int y = parse_primary();
		x = (op == '*' ? x * y : x / y);
	}
	return x;
}

int parse_expr()
{
	int x = parse_term();
	while (!end() && (peek() == '+' || peek() == '-'))
	{
		char op = peek();
		succ();
		int y = parse_term();
		x = (op == '+' ? x + y : x - y);
	}
	return x;
}

int parse()
{
	pos = 0;
	return parse_expr();
}

int main()
{
	int N;
	cin>>N;
	while(N--)
	{
		cin >> src;
		cout << parse() << endl;
	}
	return 0;
}

Measured memory_bytes: 0
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	A, B, C := getStdinInt3()
	K := getStdinInt()

	AOri := A
	BOri := B
	COri := C

	for a := 0; a <= K; a++ {
		for b := 0; b <= K; b++ {
			for c := 0; c <= K; c++ {
				if a+b+c != K {
					continue
				}
				A = AOri
				B = BOri
				C = COri
				for n := 0; n < a; n++ {
					A = A * 2
				}
				for n := 0; n < b; n++ {
					B = B * 2
				}
				for n := 0; n < c; n++ {
					C = C * 2
				}
				if A < B && B < C {
					fmt.Printf("Yes\n")
					return
				}
			}
		}
	}
	fmt.Printf("No\n")
	return
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2156
#include<stdio.h>
int main(void){
int N ,M ,sum=0, count=0;
scanf("%d%d",&N,&M);
int A[N];
for(int i=0;i<N;i++) {
    scanf("%d",&A[i]);
    sum+=A[i];//総得票数
}
for(int i=0;i<N;i++){
    if(A[i]*(4*M) >= sum ) count++;
}
if(count>=M) printf("Yes\n");
else printf("No\n");
return 0;
}

Measured memory_bytes: 128
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}


int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

int n;
int a[M],b[M];

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    vpii v;
    rep(i,1,n+1){
        cin >> a[i] >> b[i];
        v.push_back({a[i],b[i]});
    }
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    if(n&1){
        int min_ans=a[(n+1)/2];
        int max_ans=b[(n+1)/2];
        int ans=(max_ans-min_ans+1);
        cout << ans;
    }
    else{
        int min_ans=(a[n/2]+a[n/2 + 1]);
        int max_ans=(b[n/2]+b[n/2 + 1]);
        int ans=(max_ans-min_ans+1);
        cout << ans;
    }
    return 0;
}


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

int main()
{
	string S;
	cin >> S;

	for (int i = S.length()-3; i >= 0; i-=2) {
		for (int j = 0; j < (i + 1) / 2; j++) {
			if (S[j] != S[j + ((i + 1) / 2)]) {
				break;
			}
			if (j == ((i + 1) / 2 - 1)) {
				cout << i + 1 << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  int x, a, b;
  cin >> x >> a >> b;
  int sa = b - a;
  if (sa <= 0) cout << "delicious\n";
  else if (sa > 0 && sa <= x) cout << "safe\n";
  else if (sa > 0 && sa > x) cout << "dangerous\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for(int i = 0;i < n; i++)
using namespace std;
const int MAX = 10000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    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;
    }
}
long long COM(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;
}
int main() {
    COMinit();
    ll n, k,m,a; cin >> n >> k;
    if ((n + k) % 3 != 0)
        cout << 0 << endl;
    if ((n + k) % 3 == 0) {
        m = n - (n + k) / 3;
        a = k - (n + k) / 3;
        cout << COM(m + a, a) << endl;
    }
}

Measured memory_bytes: 234752
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  if(N >= 10) cout << R << endl;
  else cout << R + 100*(10-N) << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int Max = 100005;
typedef long long LL;

LL w[Max];
int flag[Max];

int check(int p, LL w[], int k, int n)
{
    int i = 0;
    for(int j=0; j<k; j++)
    {
        LL s = 0;
        while(s+w[i]<=p)
        {
            s += w[i++];
            if(i==n) return n;
        }
    }
    return i;
}

LL solve(LL w[], int n, int k)
{
    LL left = 0;
    LL right = 10000*100000;
    while(left<right)
    {
        LL mid = (left+right)/2;
        int v = check(mid, w, k, n);
        //cout << v << endl;
        if(v>=n) right = mid;
        else     left = mid+1;
    }
    return right;
}
int main()
{
    int n, k;
    cin >> n >> k;
    memset(flag, 0, sizeof(flag));
    for(int i=0; i<n; i++)
        cin >> w[i];

    cout << solve(w, n, k) << endl;
    return 0;
}



Measured memory_bytes: 4276
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
const ll INF = 1LL << 60;

void add_edge(vector<vll> &G, ll u, ll v){
    G[u].push_back(v); G[v].push_back(u);
}

bool dfs(vector<vll> &G, vb &checked, vll &match, ll v){
    //* match is initialized -1 outside
    checked[v] = true;
    REP(i, G[v].size()){
        ll u = G[v][i], w = match[u];
        if(w < 0 || !checked[w] && dfs(G, checked, match, w)){
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

ll BipartiteMatching(vector<vll> &G){
    ll N = G.size();
    vb checked(N, false);
    vll match(N, -1);
    ll res = 0;
    REP(v, N){
        if(match[v] < 0){
            fill(ALL(checked), false);
            if(dfs(G, checked, match, v)){
                res++;
            }
        }
    }
    return res;
}

int main(){
    ll N, M; cin >> N>>M;
    vector<vll> G(N+M);
    REP(i, N){
        ll K; cin >> K;
        REP(j, K){
            ll v; cin >> v; v --;
            add_edge(G, i, v+N);
        }
    }
    ll num_match=0;
    num_match = BipartiteMatching(G);
    if(num_match < M){
        cout<< "Alice"<<endl;
    }
    else{
        cout<< "Bob"<<endl;
    }

    return 0;
}


Measured memory_bytes: 7016
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }



int main() {
	int n, q;
	scanf("%d%d", &n, &q);
	n -= 2;
	int H = n, W = n;
	vector<int> height(n, n);
	vector<int> width(n, n);
	long long answer = 0;
	while(q--) {
		int type, x;
		scanf("%d%d", &type, &x);
		x -= 2;
		assert(0 <= x && x <= n - 1);
		if(type == 2) {
			swap(H, W);
			height.swap(width);
		}
		if(x < W) {
			answer += min(H, height[x]);
			height[x] = -1; // will not use this again
			// debug() << imie(x) imie(height[x]);
			for(int i = x + 1; i < W; ++i) {
				height[i] = H;
			}
			W = x;
		}
		else {
			answer += height[x];
			height[x] = -1;
		}
		if(type == 2) {
			swap(H, W);
			height.swap(width);
		}
	}
	printf("%lld\n", (long long) n * n - answer);
}


Measured memory_bytes: 4848