akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n, m; cin >> n >> m;
    vector<int> mp(n, 0);
    rep(i, m) {
        int a, b; cin >> a >> b;
        --a, --b;
        ++mp[a];
        ++mp[b];
    }
    for (auto &e: mp) {
        cout << e << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using std::cin;
using std::cout;
using std::endl;
using std::ios;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = std::min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = std::max(a, b); }

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

    int N;
    cin >> N;
    char S[N];
    int West = 0;
    int East = 0;
    rep(i, N) {
        cin >> S[i];
        if(S[i] == 'E') ++East;
        else ++West;
    }

    int answer = std::min(West, East);

    FOR(i, 1, N) {
        if(S[i - 1] == 'W') ++East;
        else --East;
        if(S[i] == 'E') answer = std::min(East - 1,answer);
        else answer = std::min(East,answer);
    }

    cout << answer << endl;
}

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

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int N;
    cin >> N;
    vector<lli> v(N);
    REP (i, 0, N) cin >> v[i];
    sort(v.begin(), v.end());
    int s = 0;
    int f = v.size() - 1;
    int ans = N;
    while (s <= f) {
        int mid = (s + f) / 2;
        vector<lli> temp;
        temp.reserve(N);
        REP (i, 0, N) if (i != mid) temp.push_back(v[i]);
        lli size = v[mid];
        int index = 0;
        while (index < N - 1 && temp[index] <= size * 2) {
            size += temp[index];
            index++;
        }

        bool check = index == N - 1;
        if (check) {
            f = mid - 1;
            ans = mid;
        } else {
            s = mid + 1;
        }
    }

    cout << N - ans << endl;

    return 0;
}


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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int main(){
    int n,l;
    cin >> n >> l;
    vector<string> v;

    rep(i,n){
        string s;
        cin >> s;
        v.push_back(s);
    }

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

    string ans("");
    rep(i,n){
        ans += v[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}


const ll MOD = (ll)1e9 + 7;
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}
ll rev(ll x) {
	return bin_pow(x, MOD - 2);
}


const int N = 5050;
int n;
vector<int> g[N];
vector<int> a;
int b[N];
int m;
int cmp;
bool used[N];
int sz;

void dfs(int v) {
	used[v] = 1;
	sz++;
	for (int u : g[v])
		if (!used[u])
			dfs(u);
}

void multBy(ll d) {
	m++;
	for (int i = m; i > 0; i--)
		b[i] = add(b[i - 1], mult(b[i], d));
	b[0] = mult(b[0], d);
}

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		if (x == -1) {
			a.push_back(i);
		} else {
			x--;
			g[i].push_back(x);
			g[x].push_back(i);
		}
	}

	b[0] = 1;
	m = cmp = 0;
	for (int v : a) {
		assert(!used[v]);
		sz = 0;
		dfs(v);
		multBy(sz);
	}
	for (int v = 0; v < n; v++) {
		if (used[v]) continue;
		cmp++;
		dfs(v);
	}
	ll ans = mult(sub(n, cmp), bin_pow(n - 1, m));
	ll f = 1;
	for (int k = 1; k <= m; k++) {
		ll cur = b[m - k];
		if (k == 1) cur = sub(cur, m);
		cur = mult(cur, f);
		cur = mult(cur, bin_pow(n - 1, m - k));
		ans = sub(ans, cur);
		f = mult(f, k);
	}
	printf("%lld\n", ans);

	return 0;
}


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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main() {
  rep(i,3){
    string s;
    cin >> s;
    cout << s[i];
  }
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
typedef long long int ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int a,b,c,d;

map<ll,ll> mem;
ll f(ll x) {
  if (!x) return 0;
  if (mem.count(x)) return mem[x];
  ll res = LINF;
  if (LINF/d > x) res = x*d;
  auto f2 = [&](ll y) {
    if (y >= x) return LINF;
    return f(y);
  };
  {
    ll l = x/2*2, r = l+2;
    mins(res, f2(l/2)+a+(x-l)*d);
    mins(res, f2(r/2)+a+(r-x)*d);
  }
  {
    ll l = x/3*3, r = l+3;
    mins(res, f2(l/3)+b+(x-l)*d);
    mins(res, f2(r/3)+b+(r-x)*d);
  }
  {
    ll l = x/5*5, r = l+5;
    mins(res, f2(l/5)+c+(x-l)*d);
    mins(res, f2(r/5)+c+(r-x)*d);
  }
  return mem[x] = res;
}

void solve() {
  ll n;
  cin>>n;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  mem = map<ll,ll>();
  cout<<f(n)<<endl;
}

int main() {
  int ts;
  scanf("%d",&ts);
  rep(ti,ts) solve();
  return 0;
}


Measured memory_bytes: 4896
#include<bits/stdc++.h>
const int MAXN=1e5+1;
int n,ans=0; 
char s[MAXN];
int main(){
    scanf("%d%s",&n,s+1);
    for(int i=1;i<=n;++i)
        if(s[i]!=s[i-1])
            ++ans;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 2e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n, a, b;
  cin >> n >> a >> b;
  vector<ll> h(n);
  for (int i = 0; i < n; i++){
    cin >> h[i];
  }

  ll l = 0, r = 2e9, mid;
  while (l + 1 < r){
    mid = (l + r) / 2;
    ll num = 0;
    for (int i = 0; i < n; i++){
      ll t = h[i] - b*mid;
      if (t > 0){
        if (t % (a - b) == 0)
          num += t / (a - b);
        else
          num += t / (a - b) + 1;
      }
    }
    if (num <= mid){
      r = mid;
    }
    else {
      l = mid;
    }
  }

  cout << r << endl;



  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int m,a,b,n,x,y;
    while(~scanf("%d%d",&x,&y))
    {
        if(x==1||x==3||x==5||x==7||x==8||x==10||x==12)
            m=1;
        if(x==4||x==6||x==9||x==11)
            m=2;
        if(x==2)
            m=3;
        if(y==1||y==3||y==5||y==7||y==8||y==10||y==12)
            n=1;
        if(y==4||y==6||y==9||y==11)
            n=2;
        if(y==2)
            n=3;
        if(n==m)
            printf("Yes\n");
        else
            printf("No\n");

    }
    return 0;
}


Measured memory_bytes: 128
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    #l,r,d=map(int,input().split())
    n,d=map(int,input().split())
    count=0
    dis=d**2
    for i in range(n):
        a,b=map(int,input().split())
        if a**2+b**2<=dis:
            count+=1
    print(count)


if __name__ == "__main__":

    main()


Measured memory_bytes: 74532
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
 
    // 出力
    if((a+b)>(a+c) && (b+c)>(a+c)){
    printf("%d\n",a+c);
    }else if((a+c)>(a+b) && (b+c)>(a+b)){
    printf("%d\n",a+b);
    }else{
    printf("%d\n",b+c);
    }
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <bitset>
#include <functional>
#include <iostream>
#include <memory>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
	string s;
	cin >> s;
	cout << (700 + count(s.begin(), s.end(), 'o') * 100);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void pre(){}
char inc(char c){
    return char(int(c)+1);
}
char dec(char c){
    return char(int(c)-1);
}
void solve(){
    long long int k;cin>>k;
    if(k<=9){
        cout<<k<<"\n";
        return;
    }
    long long int count = 9;
    vector<string>last,curr;
    for(long long int i=1;i<=9;i++){
        last.push_back(to_string(i));
    }
    string ans;
    while(count<k){
        curr.clear();
        for(auto i:last){
            if(i[i.size()-1]!='0'){
                curr.push_back(i+dec(i[i.size()-1]));
                count++;
                if(count==k){
                    ans=curr.back();
                }
            }
            curr.push_back(i+(i[i.size()-1]));
            count++;
            if(count==k){
                ans=curr.back();
            }
            if(i[i.size()-1]!='9'){
                curr.push_back(i+inc(i[i.size()-1]));
                count++;
                if(count==k){
                    ans=curr.back();
                }
            }
        }
        last=curr;
    }
    cout<<ans<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}


Measured memory_bytes: 13684
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int[] array = new int[200010];
		int[] count = new int[200010];

		for(int i =2;i<=n;i++) {

			array[i] = scan.nextInt();
		}

		for(int i=2;i<=n;i++) {
			count[array[i]]++;
		}


		for(int i=1;i<=n;i++) {
		System.out.println(count[i]);
		}
		scan.close();

	}

}


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

int main(){
    int N;
    string A, B, C;
    int c = 0;

    cin >> N;
    cin >> A;
    cin >> B;
    cin >> C;

    for(int i = 0; i < N; i++){
        if(A[i] != B[i]){
            c++;
        }
        if(A[i] != C[i] && B[i] != C[i]){
            c++;
        }
    }

    cout << c;

}

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

#define repi(i, a, b) for(long long i = (long long)(a); i < (long long)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

inline void Main() {
  // code
  long long l,r,k = 2020;
  cin>>l>>r;

  if(r - l > 2019) {
    cout << 0 << endl;
    return;
  } else {
    repi(i, l, r) {
      repi(j, i+1, r+1) {
        k = min(k, i*j % 2019);
      }
    }
  }

  cout << k << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let v = read_line () |> split_string ~pattern:" " |> List.map int_of_string

let rec take res n acc = match (n, acc) with
  | (_, []) | (0, _) -> List.rev res
  | (i, x :: xs) -> take (x :: res) (n - 1) xs
let take = take []

let rec split a b t = function
  | [] -> (a, b)
  | x :: xs -> if t then split (x :: a) b false xs else split a (x :: b) true xs

module IntMap = Map.Make(struct type t = int let compare = compare end)
let top acc =
  let map = List.fold_left (fun map n ->
    let i = 1 + try IntMap.find n map with Not_found -> 0 in
    IntMap.add n i map
  ) IntMap.empty acc in
  IntMap.bindings map |> List.sort (fun (_, a) (_, b) -> b - a) |> take 2 |> List.map fst

let solve a ta b tb =
  let cnt acc v = List.filter ((<>) v) acc |> List.length in
  List.map (fun x -> List.map (fun y -> (x, y)) tb) ta
    |> List.concat
    |> List.map (fun (x, y) -> if x = y then max_int else cnt a x + cnt b y)
    |> List.fold_left min max_int

let () =
  let a, b = split [] [] true v in
  let ta, tb = top a, top b in
  Printf.printf "%d\n" @@
  if List.length ta = 1 && List.length tb = 1 && List.hd ta = List.hd tb 
  then n / 2 else solve a ta b tb

Measured memory_bytes: 28292
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
const int MAX = 100;
const int MOD = 1e+9+7;
ll 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 L,R;
	ll dp[61][2][2][2]={};//dp[i][j][k][s]:後ろからi桁目まで見て、j:L<=xをすでに満たしているか、k:y<=Rをすでに満たしているか、s:先頭ビットが既に現れたか
	//条件は、(xのbit,yのbit)=(0,0),(0,1),(1,1)の3通りで、xとyの桁数が同じ
	dp[60][0][0][0]=1;
	scan(L>>R);
	for(int i=59;i>=0;i--){//桁の大きい方から見ていく
		int lb=(L>>i)&1;
		int rb=(R>>i)&1;
		rep(j,2){
			rep(k,2){
				rep(s,2){
					ll pre=dp[i+1][j][k][s];
					rep(x,2){
						rep(y,2){
							int nextj=j,nextk=k,nexts=s;

							if(x==1&&y==0) continue;//(xのbit,yのbit)=(0,0),(0,1),(1,1)の3通り
							if(s==0&&x!=y) continue;//xとyの最上位bitの位置は同じ
							if(x&&y) nexts=1;//xとyの最上位bitの位置が確定

							if(j==0&&x==0&&lb==1) continue;//x<Lは駄目
							if(x==1&&lb==0) nextj=1;//x>Lが確定

							if(k==0&&y==1&&rb==0) continue;//y>Rは駄目
							if(y==0&&rb==1) nextk=1;//y<Rが確定

							dp[i][nextj][nextk][nexts]+=pre;
							dp[i][nextj][nextk][nexts]%=MOD;
						}
					}
				}
			}
		}
	}
	ll ans=0;
	rep(j,2) rep(k,2) rep(s,2){
		ans+=dp[0][j][k][s];
		ans%=MOD;
	}
	prin(ans);
	return 0;
}


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

long long h,w,r11=10000000000,r12=10000000000,r21=10000000000,r22=10000000000;

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

    cin>>h>>w;

    if(h==2&&w==2)
    {
        cout<<1<<endl;
        return 0;
    }
    if((h*w)%3==0)
    {
        cout<<0<<endl;
        return 0;
    }

    for(int i=3;i<=h;i++)
    {
        long long a,b,c;
        a=(h-i+1)*w;
        b=floor(1.0*(h-i)/2)*w;
        c=ceil(1.0*(h-i)/2)*w;
        if(max(abs(a-b),max(abs(b-c),abs(c-a)))<r11)
            r11=max(abs(a-b),max(abs(b-c),abs(c-a)));
    }
    for(int i=2;i<=h;i++)
    {
        long long a,b,c;
        a=(h-i+1)*w;
        b=floor(1.0*w/2)*(i-1);
        c=ceil(1.0*w/2)*(i-1);
        if(max(abs(a-b),max(abs(b-c),abs(c-a)))<r12)
            r12=max(abs(a-b),max(abs(b-c),abs(c-a)));
        //cout<<a<<" "<<b<<" "<<c<<endl;
    }
    swap(h,w);
    for(int i=3;i<=h;i++)
    {
        long long a,b,c;
        a=(h-i+1)*w;
        b=floor(1.0*(h-i)/2)*w;
        c=ceil(1.0*(h-i)/2)*w;
        if(max(abs(a-b),max(abs(b-c),abs(c-a)))<r21)
            r21=max(abs(a-b),max(abs(b-c),abs(c-a)));
    }
    for(int i=2;i<=h;i++)
    {
        long long a,b,c;
        a=(h-i+1)*w;
        b=floor(1.0*w/2)*(i-1);
        c=ceil(1.0*w/2)*(i-1);
        if(max(abs(a-b),max(abs(b-c),abs(c-a)))<r22)
            r22=max(abs(a-b),max(abs(b-c),abs(c-a)));
    }

    cout<<min(r11,min(r12,min(r21,r22)))<<endl;
    //cout<<r11<<r12<<r21<<r22<<endl;

    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <bitset>
using namespace std;

using P = pair<int, int>;
using Points = vector<P>;
using Used = bitset<120>;

int main()
{
  int n;
  Points reds;
  Points blues;
  Used usedReds;

  cin >> n;
  int x, y;
  for (int i = 0; i < n; ++i)
  {
    cin >> x >> y;
    reds.push_back(P(x, y));
  }
  for (int i = 0; i < n; ++i)
  {
    cin >> x >> y;
    blues.push_back(P(x, y));
  }
  sort(reds.begin(), reds.end());
  sort(blues.begin(), blues.end());

  int ans = 0;
  for (auto b : blues)
  {
    P max(-1, -1); // first = y, second = index
    for (int ri = 0; ri < reds.size(); ++ri)
    {
      if (usedReds.test(ri))
      {
        continue;
      }
      auto r = reds[ri];
      if (r.first < b.first && r.second < b.second)
      {
        if (r.second > max.first)
        {
          max.first = r.second;
          max.second = ri;
        }
      }
      else
      {
        if (r.first >= b.first)
        {
          break;
        }
      }
    }
    if (max.second != -1)
    {
      usedReds.set(max.second);
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main(int argc, char const *argv[]) {
    int n;
    pair<string, int> ans;
    vector<string> votes;
    map<string, int> candidates;
    vector<pair<string, int>> cmp_candidates;
    bool update = false;

    auto cmp = [](pair<string ,int> const & a, pair<string, int> const & b) { 
        return a.second != b.second ? a.second > b.second : a.first > b.first; 
    };


    while(cin>>n, n) {
        update = false;
        for (int i = 0; i < n; ++i) {
            string tmp;
            cin>>tmp;
            candidates[tmp]++;

            // comp
            int m = 0;
            string c;
            for (auto e : candidates) {
                cmp_candidates.push_back(e);
                if (e.second > m) {
                    m = e.second;
                    c = e.first;
                }
            }

            sort(cmp_candidates.begin(), cmp_candidates.end(), cmp);

            // cout<<endl;
            // for (auto e : cmp_candidates) {
            //     cout<<e.first<<" : "<<e.second<<endl;
            // }

            if (!update && cmp_candidates.size() == 1 
                && m > n - i - 1) {
                ans = make_pair(c, i+1);
                update = true;
                //cout<<"pre update"<<endl;
            } 
            else if (!update && m > cmp_candidates[1].second + (n - i - 1)) {
                ans = make_pair(c, i+1);
                update = true;
                //cout<<"update"<<endl;
            }

            cmp_candidates.clear();


        }

        if (update) cout<<ans.first<<" "<<ans.second<<endl;
        else cout<<"TIE"<<endl;

        candidates.clear();
        cmp_candidates.clear();
        votes.clear();
    }
    return 0;
}

Measured memory_bytes: 3140
#include <iostream>

using namespace std;

int N;
int T[105];
int M;
int P[105], X[105];

int main(void)
{
	cin >> N;
	for(int i = 1; i <= N; i++) cin >> T[i];
	cin >> M;
	for(int i = 0; i < M; i++){
		cin >> P[i] >> X[i];
	}
	
	int sum = 0;
	for(int i = 1; i <= N; i++) sum += T[i];
	
	for(int i = 0; i < M; i++){
		cout << sum + X[i] - T[P[i]] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a=inf
  b=0
  ans1=[]
  ans2=[]

  N,T=LI()
  l=LI()

  a=l[0]
  for x in l[1:]:
    if x<a:
      ans1.append([a,b])
      ans2.append(b-a)
      a=x
      b=x
    else:
      b=max(b,x)
  ans1.append([a,b])
  ans2.append(b-a)

  ans2.sort()
  return ans2.count(ans2[-1])

# main()
print(main())


Measured memory_bytes: 18968
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/abc114/tasks/abc114_c
# C - 755
"""
need to consider the case that ticket is not enough to lower everything
"""

N = gi()
H = gi()

A = [0] * N
B = [0] * N

for i in range(N):
    A[i] = -gi()
    B[i] = -gi()

A.sort()
B.sort()

ans = 0

for i in range(N):
    if -B[i] >= -A[0] and H > 0:
        H += B[i]
        ans += 1
    else:
        break

if H > 0:
    ans += H // -A[0]
    if H % -A[0]:
        ans += 1
print(ans)


Measured memory_bytes: 20744
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n;
  scanf("%d", &n);
  vi s(n);
  rep (i, n) {
    scanf("%d", &s[i]);
  }
  int sum = 0;
  rep (i, n) {
    sum += s[i];
  }
  if (sum % 10 != 0) {
    printf("%d\n", sum);
    return 0;
  }
  sort(all(s));
  rep (i, n) {
    if (s[i] % 10 != 0) {
      printf("%d\n", sum - s[i]);
      return 0;
    }
  }
  printf("0\n");

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


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


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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    for (int i = 0; i < N; ++i) cin >> P[i];

    int ans = 0;
    for (int i = 0; i < N - 2; ++i) {
        int minV = min(P[i], min(P[i + 1], P[i + 2]));
        int maxV = max(P[i], max(P[i + 1], P[i + 2]));
        if (P[i + 1] != minV && P[i + 1] != maxV) {
            ans++;
        }
    }

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

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

int main() {
    int K, X;
    cin >> K >> X;
    int S, E;
    if (X - K + 1 <= -1000000){
        S = -1000000;
    } 
    else {
        S = X - K + 1;
    }

    if (X + K -1 >= 1000000){
        E = -1000000;
    }
    else {
        E = X + K -1;
    }

    for(int i = S ; i < E; i++){
        cout << i << " ";
    }

    cout << E <<endl;

}


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

int main() { 
  ll q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;
  ll one = min({q*4, h*2, s});
  cout << min(one*n, d*(n/2)+one*(n%2)) << endl;
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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


  string t;
  cin >> s;
  cin >> t;
  rep(i, 3) if (s[i] == t[i]) ans++;
  cout << ans << endl;





  return 0;
}


Measured memory_bytes: 256
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
    cout<<fixed;
}
int main(){
    init();

    ll N;cin>>N;
    vector<ll>A(N);
    for(int i=0;i<N;i++)cin>>A[i];

    set<ll>set;
    for(int i=0;i<N;i++){
        set.insert(A[i]);
    }

    cout<<set.size()<<endl;
    
}


Measured memory_bytes: 8300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
const int maxn = 1e5+10;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
int d[4][2]={1,0,0,1,-1,0,0,-1};
int n,m;
bool vis[maxn];
ll val[maxn];
vector<int> V[maxn];
int main() {
    ios::sync_with_stdio(0);
    #ifdef Uncle_drew
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #else
    #endif
    cin>>n>>m;
    for(int i=1;i<=n;i++)   cin>>val[i];
    for(int i=0,u,v;i<m;i++){
        cin>>u>>v;
        V[u].pb(v);V[v].pb(u);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        bool mid=1;
        for(int j=0;j<V[i].size();j++){
            if(val[i]<=val[V[i][j]]){
                mid=0;
                break;
            }
        }
        if(mid==1){
            ans++;
            // cout<<i<<endl;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int N;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>N && N){
		vi b,nb;
		rep(i,N){
			int x;
			cin>>x;
			b.pb(x);
		}
		int turn=0,ans=-1;
		while(turn<=10000){
			int ok=1;
			rep(i,sz(b))if(b[i]!=i+1){
				ok=0;break;
			}
			if(ok){
				ans=turn;break;
			}
			nb.clear();
			rep(i,sz(b))if(b[i]>1){
				nb.pb(b[i]-1);
			}
			nb.pb(sz(b));
			b=nb;
			turn++;
		}
		cout<<ans<<endl;
	}
}

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

int main() {
  int n,a,b=1,c=1,d=0;
  cin>>n>>a;
  for(int i=0;c>0;i++){
    b*=a;
    c=n/b;
    d++;
  }
  cout<<d<<endl; 
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  if((n - n % 100) / 100 == n % 10){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
count = int(input())
number = input()
number_list = number.split(" ")
max = int(number_list[0])
min = max
sum = 0
for cur in number_list:
    int_cur = int(cur)
    if int_cur > max:
        max = int_cur
    if int_cur < min:
        min = int_cur
    sum += int_cur
print(str(min) + " " + str(max) + " " + str(sum))


Measured memory_bytes: 6340
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;
#define PI 3.14159265358979323846

using namespace std;
typedef long long ll;

signed main() {
  int r;
  cin >> r;
  printf("%.20f\n", (double)2 * (double)r * PI);
  return 0;
}


Measured memory_bytes: 3760
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)

const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
// long long dp[];

int main() {
    int N, D, X, A, o;
    cin >> N >> D >> X;
    rep(i, N) {
        cin >> A;
        X += (D + A - 1) / A;
    }
    cout << X << endl;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    static PrintWriter out;
    static Scanner sc;

    static void solve() {
        int a = nextInt();
        int b = nextInt();
        int k = nextInt();

        for (int i = a; i <= b; i++) {
            if (i - a + 1 <= k || b - i + 1 <= k) {
                out.println(i);
            }
        }
    }

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

    static long nextLong() {
        return Long.parseLong(sc.next());
    }

    static String nextString() {
        return sc.next();
    }

    static int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    static List<Integer> nextIntList(int n) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(nextInt());
        }
        return list;
    }

    static List<Long> nextLongList(int n) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(nextLong());
        }
        return list;
    }

    static <T extends Comparable<? super T>> void sort(List<T> list) {
        Collections.sort(list);
    }

    // greatest common divisor
    static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    // baseのn乗を計算を返す
    static int pow(int base, int n) {
        int ret = 1;
        for (int i = 0; i < n; i++) {
            ret *= base;
        }
        return ret;
    }

    // intをlength桁のbit文字列に変換
    static String toBinaryString(int input, int length) {
        return toBinaryString(input).substring(29 - length);
    }

    // intを29桁のbit文字列に変換
    static String toBinaryString(int input) {
        String ret = "";
        int max = 0x10000000;
        for (int i = 0; i < 29; i++) {
            int tmp = input / max;
            ret += tmp;
            input %= max;
            max /= 2;
        }
        return ret;
    }

    public static void main(String[] args) {
        out = new PrintWriter(System.out);
        sc = new Scanner(System.in);

        solve();

        out.flush();
        sc.close();
    }

}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



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

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b,a%b));
}

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,x,y;
    cin>>n;
    graph g(n+1);
    rrep(i,n-1){
        g[i].pb(i+1);
        g[i+1].pb(i);
    }
    cin>>x>>y;
    g[x].pb(y);
    g[y].pb(x);
    graph dist(n+1,vector<ll>(n+1,-1));
    
    rrep(i,n){
    queue<ll> que;
    dist[i][i] = 0;
    que.push(i); // 0 を橙色頂点にする

       // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        ll v = que.front(); // キューから先頭頂点を取り出す
        que.pop();
        
        // v から辿れる頂点をすべて調べる
            for (ll nv : g[v]) {
            if (dist[i][nv] != -1) continue; // すでに発見済みの頂点は探索しない

               // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[i][nv] = dist[i][v] + 1;
            que.push(nv);
            }
        }
    }
    vector<ll> l(n+1,0);
    rrep(i,n){
        for(ll j=i+1;j<=n;j++){
            l[dist[i][j]]++;
        }
    }
    rrep(i,n-1){
        cout<<l[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 31744
void main() {
	auto N = ri;
	auto A = readAs!(long[]);
	auto Q = ri;
	long[long] m;
	foreach(i, v; A) m[v]++;
	auto S = A.sum;
	foreach(q; 0..Q) {
		auto ip = readAs!(long[]), B = ip[0], C = ip[1];
		
		if(B !in m) m[B] = 0;
		long cnt = m[B];
		S = S + (cnt * C) - (cnt * B);
		if(C !in m) m[C] = 0;
		m[C] += m[B];
		m[B] = 0;
		S.writeln;
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

long rl() {
	return readAs!long;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 18828
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <limits>//setprecision
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a; else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;
    long long W;cin >> W;
    vector<long long> w0,w1,w2,w3;
    long long standard = -1;
    for(int i = 0;i<N;i++){
        long long w,v;cin >> w >> v;
        if(i == 0) standard = w;
        if(standard + 0 == w) w0.push_back(v);
        else if(standard + 1 == w) w1.push_back(v);
        else if(standard + 2 == w) w2.push_back(v);
        else if(standard + 3 == w) w3.push_back(v);
    }
    sort(w0.begin(),w0.end(),greater<long long>());
    sort(w1.begin(),w1.end(),greater<long long>());
    sort(w2.begin(),w2.end(),greater<long long>());
    sort(w3.begin(),w3.end(),greater<long long>());
    long long ans = 0;
    long long nowV = 0,nowW = 0;
    for(long long i = 0;i<=w0.size();i++){
        for(long long j = 0;j<=w1.size();j++){
            for(long long k = 0;k<=w2.size();k++){
                for(long long l = 0;l<=w3.size();l++){
                    if(w0.size() != 0)for(int a = 0;a<i;a++) nowV += w0.at(a);
                    nowW += standard*(i);
                    if(w1.size() != 0)for(int a = 0;a<j;a++) nowV += w1.at(a);
                    nowW += (standard+1)*(j);
                    if(w2.size() != 0)for(int a = 0;a<k;a++) nowV += w2.at(a);
                    nowW += (standard+2)*(k);
                    if(w3.size() != 0) for(int a = 0;a<l;a++) nowV += w3.at(a);
                    nowW += (standard+3)*(l);
                    if(nowW <= W) ans = max(ans,nowV);
                    nowW = 0,nowV = 0;
                }
                
            }
        }
    }
    cout << ans << endl;
}


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

int main(){
	int n,a[100],t,num,sum=0;
	cin >> n;
	for(int i=0;i<n;i++)cin >> a[i];

	for(int i=0;i<n;++i){
		int min = 100;
		for(int j=i;j<n;++j){
			if(a[j]<min){
				min = a[j];
				num = j;
			}
		}
		if(num != i){
			t = a[i];
			a[i] = a[num];
			a[num] = t;
			sum++;
		}
		if(i<n-1)cout << a[i] << " ";
	}

	cout << a[n-1] << "\n" << sum << endl;
	return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int ans = 0,cnt;
    for(int i = 1; i <= n; i++)
    {
        cnt = 0;
        for(int j = 1; j <= i; j++)
        {
            if(i%j == 0 && i%2 == 1)
                cnt++;
        }
        if(cnt == 8)
            ans++;
    }
    printf("%d\n",ans);
    return 0;
}


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

const int Maxn = 12;
const int Inf = 1000000000;

int n, m;
int dp[1 << Maxn];

int main()
{
    scanf("%d %d", &n, &m);
    fill(dp, dp + (1 << n), Inf); dp[0] = 0;
    for (int a = 0; a < m; a++) {
        int c, cnt; scanf("%d %d", &c, &cnt);
        int mask = 0;
        while (cnt--) {
            int b; scanf("%d", &b);
            mask |= 1 << b - 1;
        }
        for (int i = 0; i < 1 << n; i++)
            dp[i | mask] = min(dp[i | mask], dp[i] + c);
    }
    if (dp[(1 << n) - 1] >= Inf) printf("-1\n");
    else printf("%d\n", dp[(1 << n) - 1]);
    return 0;
}


Measured memory_bytes: 256
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]

    ac = collections.Counter(A)
    bc = collections.Counter(B)

    for i in range(1, N + 1):
        if ac[i] + bc[i] > N:
            print("No")
            return

    ma = 0
    cnta = 0
    cntb = 0
    for i in range(1, N + 1):
        cnta += ac[i]
        cntb += bc[i - 1]
        ma = max(ma, cnta - cntb)

    print("Yes")
    ans = []
    for i in range(N):
        ans.append(B[(i + N - ma) % N])
    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 57964
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
	int n;cin>>n;
	vector<int>a(n);rep(i,n)cin>>a[i];
	bool flag=true;
	int cnt=0;
	while(flag){
		rep(i,n){
			if(a[i]%2){
				flag=false;
				break;
			}else{
				a[i]=a[i]/2;
			}
		}
		if(flag)cnt++;
	}
	cout<<cnt<<endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll gcd(ll a, ll b) {
	if (a < b) return gcd(b, a);
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

int main(int argc, char **argv) {
	ll n, a, res;
	cin >> n >> res;
	REP(i, n-1) {
		cin >> a;
		res = gcd(res, a);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3628
t[65536];main(n,x,y,dx,dy,r,m,mx,my){
  for(scanf("%d\n",&n);n;printf("%d %d\n",mx,my),n--)
    for(x=y=m=0;scanf("%d%d",&dx,&dy),dx|dy;){
      x+=dx,y+=dy,r=x*x+y*y;
      if(r>m||(r==m&&mx<x))m=r,mx=x,my=y;
    }
}

Measured memory_bytes: 0
N=int(input())
a=[]
for _ in range(N): 
    b=list(map(int,input().split()))
    a.append(b)
dp=[]
for _ in range(N):
    dp.append([0,0,0])
dp[0][0]=a[0][0]
dp[0][1]=a[0][1]
dp[0][2]=a[0][2]
for i in range(1,N):
    dp[i][0]=max(dp[i-1][1]+a[i][0],dp[i-1][2]+a[i][0])
    dp[i][1]=max(dp[i-1][0]+a[i][1],dp[i-1][2]+a[i][1])
    dp[i][2]=max(dp[i-1][0]+a[i][2],dp[i-1][1]+a[i][2])
print(max(dp[N-1][0],dp[N-1][1],dp[N-1][2]))

Measured memory_bytes: 76348
#include <stdio.h>

int main()
{
    int A, B, MAX;
    scanf("%d", &A);
    scanf("%d", &B);

    if (A + B >= A - B)
        MAX = A + B;
    else
        MAX = A - B;

    if (MAX <= A * B)
        MAX = A * B;

    printf("%d\n", MAX);
    return 0;
}

Measured memory_bytes: 128