akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <utility>
#include <algorithm>

using namespace std;

//pairを2つ操作。トラック辺り３位以下を保存しておく。

int main()
{
    pair<double,int> p1[8], p2[18];
    int repeat = 0;
    for( int i = 0; i < 8; i++ )
    {
        scanf( "%d %lf\n", &p1[i].second, &p1[i].first );
    }
    sort( p1, p1 + 8 );
    for( int i = 2; i < 8; i++ )
    {
        p2[i - 2].first = p1[i].first;
        p2[i - 2].second = p1[i].second;
    }
    printf( "%d %.2lf\n%d %.2lf\n", p1[0].second, p1[0].first, p1[1].second, p1[1].first );
    for( int i = 0; i < 8; i++ )
    {
        scanf( "%d %lf\n", &p1[i].second, &p1[i].first );
    }
    sort( p1, p1 + 8 );
    for( int i = 6; i < 12; i++ )
    {
        p2[i].first = p1[i - 4].first;
        p2[i].second = p1[i - 4].second;
    }
    printf( "%d %.2lf\n%d %.2lf\n", p1[0].second, p1[0].first, p1[1].second, p1[1].first );
    for( int i = 0; i < 8; i++ )
    {
        scanf( "%d %lf\n", &p1[i].second, &p1[i].first );
    }
    sort( p1, p1 + 8 );
    for( int i = 12; i < 18; i++ )
    {
        p2[i].first = p1[i- 10].first;
        p2[i].second = p1[i - 10].second;
    }
    printf( "%d %.2lf\n%d %.2lf\n", p1[0].second, p1[0].first, p1[1].second, p1[1].first );
    sort( p2, p2 + 18 );
    printf( "%d %.2lf\n%d %.2lf\n", p2[0].second, p2[0].first, p2[1].second, p2[1].first );
    return 0;
}


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

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> C(H);
    rep(i, H) cin >> C.at(i);
    int ans = 0;
    rep(i, 1<<H) rep(j, 1<<W) {
        int cnt = 0;
        rep(m, H) rep(n, W){
            if(i>>m&1) continue;
            if(j>>n&1) continue;
            if(C[m][n] == '#') cnt++;
        }
        if (cnt == K) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(int a, int b){
   return b ? GCD(b, a%b) : a;
}

int LCM(int a, int b){
   return (a * b)/(GCD(a, b));
}

int main(){
   int n, q;
   string s;
   cin >> n >> q >> s;
   vector<int> l(q), r(q);
   for(int i = 0; i < q; i++){
      cin >> l[i] >> r[i];
   }

   // TODO
   // 愚直に線形探索しては間に合わない。
   // 文字列の部分集合の個数を求めるような問題では
   // 累積和を用いることを考える

   // 愚直解(TLE)
//   for(int i = 0; i < q; i++){
//      int cnt = 0;
//      string subst = s.substr(l[i]-1, r[i] - l[i]+1);
//      for(int j = 0; j < subst.size(); j++){
//         if(subst[j] == 'A' and subst[j+1] == 'C'){
//            cnt++;
//         }
//      }
//      cout << cnt << endl;
//   }

   // 累積和
   vector<int> sum(n+1, 0);
   for(int i = 0; i < n; i++){
      if(i+1 < n and s[i] == 'A' and s[i+1] == 'C'){
         sum[i+1] = sum[i] + 1;
      }
      else{
         sum[i+1] = sum[i];
      }
   }

   for(int i = 0; i < q; i++){
      r[i]--, l[i]--;
      cout << sum[r[i]] - sum[l[i]] << endl;
   }

   return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;

struct threeElements{
int _1st,_2nd,_3rd;
};
vector<vector<int>>adj(10);
int sum,n,m,visited[11];
void dfs(int i){
    visited[i]=1;
    int flag=1;
    for(int j=1;j<=n;++j){
        if(!visited[j]){
            flag=0;
        }
    }
    if(flag){
        sum++;
        return;
    }
    for(auto x:adj[i]){
        if(!visited[x]){
            dfs(x);
            visited[x]=0;
        }
    }
}
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
   //18:17
   cin>>n>>m;
   char g[100][100],h[100][100];
   for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
        cin>>g[i][j];
   for(int i=0;i<m;i++)
    for(int j=0;j<m;j++)
        cin>>h[i][j];
    for(int i=0;i<n-m+1;i++)
        for(int j=0;j<n-m+1;j++)
        {
            bool f=1;
            for(int k=0;k<m;k++)
            {
                for(int z=0;z<m;z++)
                {
                    if(g[i+k][j+z]!=h[k][z])
                        f=0;
                }
            }
            if(f)
            {
                cout<<"Yes";
                return 0;
            }
        }
    cout<<"No";

}


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

int main() {
  int A,B,sum=0;
  
  cin >> A >> B;
  
  for (int i=0;i<2;i++){
    if (A > B) {
      sum += A;
      A--;
    } else {
      sum += B;
      B--;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int n, cnt = 0;
	int a[100000];
	cin >> n;
	lp(n)
		cin >> a[i];
	lp(n)
		if (a[a[i] - 1] == i+1)cnt++;
	cout << cnt / 2 << endl;
	return 0;
}

Measured memory_bytes: 640
import itertools
S = input()
op = ['+','-']

for o1,o2,o3 in itertools.product(op,repeat=3):
    formula = S[0]+o1+S[1]+o2+S[2]+o3+S[3]
    result = eval(formula)
    if result == 7:
        print(formula+"=7")
        break

Measured memory_bytes: 3060
using System.Collections.Generic;
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var a = getDiv(m);
        var b = m / n;
        var ans = 0;
        foreach (var x in a)
            if (x <= b) ans = Max(ans, x);
        Console.WriteLine(ans);
    }
    public static List<int> getDiv(int n)
    {
        var ans = new List<int>();
        for (int i = 1; i <= Sqrt(n) + 1; i++)
        {
            if (n % i == 0)
            {
                ans.Add(i);
                if (n != i * i) ans.Add(n / i);
            }
        }
        return ans;
    }
}


Measured memory_bytes: 13268
N = int(input())
a = [0] * N
b = [0] * N
for i in range(N):
    a1, b1 = map(int, input().split())
    a[i] = a1
    b[i] = b1

total = sum(a)
minans = total
for i in range(N):
    if a[i] > b[i]:
        minans = min(minans, b[i])

if minans == total:
    print(0)
else:
    print(total - minans)

Measured memory_bytes: 4596
import java.util.*;

public class Main{
	
	//0000 start
	int n;
	String [] data;
	ArrayList<HashSet<String>> data2;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			n= sc.nextInt();
			if(n == 0) break;
			int d = sc.nextInt();
			data = new String[n];
			HashSet<String> set = new HashSet<String>();
			for(int i = 0; i < n; i++){
				data[i] = sc.next();
				set.add(data[i]);
			}
			Arrays.sort(data);
			if(d == 0){
				System.out.println(0);
				continue;
			}
			
			data2 = new ArrayList<HashSet<String>>();
			for(int i = 0; i < n; i++){
				data2.add(new HashSet<String>());
				data2.get(i).add(data[i]);
				solve(i);
			}
			int count = 0;
			if(d == 1){
				for(int i = 0; i < n; i++){
					for(int j = i + 1; j < n; j++){
						if(data2.get(i).contains(data[j]) || data2.get(j).contains(data[i])){
							System.out.println(data[i] + "," + data[j]);
							count++;
						}
					}
				}
			}
			else{
				for(int i = 0; i < n; i++){
					for(int j = i + 1; j < n; j++){
						for(String k : data2.get(i)){
							if(data2.get(j).contains(k)){
								System.out.println(data[i] + ","+data[j]);
								count++;
								break;
							}
						}
					}
				}
			}
			System.out.println(count);
		}
	}

	private void solve(int ind) {
		StringBuilder sb = new StringBuilder(data[ind]);
		int len = sb.length();
		//delete
		for(int i = 0; i < len; i++){
			char c = sb.charAt(i);
			sb.deleteCharAt(i);
			data2.get(ind).add(sb.toString());
			sb.insert(i, c);
		}
		
		//insert
		for(int i = 0; i <= len; i++){
			for(int j = 'a'; j <= 'z'; j++){
				sb.insert(i, (char)j);
				data2.get(ind).add(sb.toString());
				sb.deleteCharAt(i);
			}
		}
		//replace
		for(int i = 0; i < len; i++){
			for(int j = 'a'; j <= 'z'; j++){
				char c = sb.charAt(i);
				sb.setCharAt(i, (char)j);
				data2.get(ind).add(sb.toString());
				sb.setCharAt(i, c);
			}
		}
		
		//swap
		for(int i = 1; i < len; i++){
			swap(sb, i-1, i);
			data2.get(ind).add(sb.toString());
			swap(sb, i-1, i);
		}
	}

	private void swap(StringBuilder sb, int i, int j) {
		char c = sb.charAt(i);
		sb.setCharAt(i, sb.charAt(j));
		sb.setCharAt(j, c);
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 31000
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int k, f, count = 10;
	cin >> k;
	queue<long long int> q;
	for(int i = 0;i < 9;i++){
		q.push(i + 1);
	}
	if(k <= 9){
		cout << k << endl;
		return 0;
	}
	while(1){
		f = q.front();
		q.pop();
		if(f % 10 != 0){
			if(count == k){
				cout << (f * 10 + (f % 10 - 1)) << endl;
				return 0;
			}
			q.push(f * 10 + (f % 10 - 1));
			count++;
		}
		if(count == k){
			cout << (f * 10 + (f % 10)) << endl;
			return 0;
		}
		q.push(f * 10 + (f % 10));
		count++;
		if(f % 10 != 9){
			if(count == k){
				cout << (f * 10 + (f % 10 + 1)) << endl;
				return 0;
			}
			q.push(f * 10 + (f % 10 + 1));
			count++;
		}
	}
}

Measured memory_bytes: 768
#include<cstdio>

const int N_MAX = 200000;
int A[N_MAX];

int main() {
	int n;
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		scanf("%d", &A[i]);
	}
	long long count = 0;
	int l = 0;
	int r = 0;
	int sum = A[0];
	while(true) {
		count += r - l + 1;
		r++;
		if(r >= n) break;
		while(sum & A[r]) {
			sum -= A[l];
			l++;
		}
		sum += A[r];
	}
	printf("%lld\n", count);
	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define int long long

using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k, s;
    cin >> n >> k >> s;
    
    if (s == 1)
    {
        for (int i = 0; i < k; i++)
            cout << 1 << ' ';
        for (int i = 0; i < n - k; i++)
            cout << 2 << ' ';
    }
    else
    {
        for (int i = 0; i < k; i++)
            cout << s << ' ';
        for (int i = 0; i < n - k; i++)
            cout << s - 1 << ' ';
    }
    cout << '\n';
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 

int main(){
	long long  A,B,K,ans=0,go=0;
	priority_queue<long long> que;
	cin >> A >> B >> K;
	go=max(A,B);
	for(int i=1; i<=go; i++){
		if(A%i==0 && B%i==0){
			que.push(i);
		}
	}
	for(int i=0; i<K-1; i++)
	que.pop();
	cout << que.top() << endl;
}

Measured memory_bytes: 256
'use strict'
 
function main(n) {
  let num = n.split("\n")[0]*1;
  let t = n.split("\n")[1].split(" ")[0]*1;
  let A = n.split("\n")[1].split(" ")[1]*1;
  let H = n.split("\n")[2].split(" ").map((e)=>{return (t - e*0.006)});
  let diff =[];
  let ans = 0;
  for(let i = 0; i < num; i++){
  	diff.push(Math.abs(H[i] - A));
  }
  let Min = Math.min(...diff);
  ans = diff.indexOf(Min);
  console.log(ans+1);
  
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7604
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Dice dice = new Dice(sc);
        String[] point = sc.next().split("");
        for(String p:point){
            switch(p){
                case "E": dice.east(); break;
                case "W": dice.west(); break;
                case "S": dice.south(); break;
                case "N": dice.north(); break;
            }
        }
        System.out.println(dice.dice.get(0));
    }
}

class Dice{
    // dice<0>?????¢ <1>?????¢ <2>??±??¢ <3>?\???¢ <4>?????¢ <5>?????¢
    static ArrayList<String> dice = new ArrayList<String>();
    static int[] east = {2,5,3,0};
    static int[] west = {3,5,2,0};
    static int[] south = {1,5,4,0};
    static int[] north = {4,5,1,0};
    static String g;
    
    public Dice(Scanner sc){
        for(int i = 0; i < 6; i++){
            dice.add(sc.next());
        }
    }
    public static void east(){
        g = dice.get(0);
        for(int i:east){
            g = dice.set(i,g);
        }
    }
    public static void west(){
        g = dice.get(0);
        for(int i:west){
            g = dice.set(i,g);
        }
    }
    public static void south(){
        g = dice.get(0);
        for(int i:south){
            g = dice.set(i,g);
        }
    }
    public static void north(){
        g = dice.get(0);
        for(int i:north){
            g = dice.set(i,g);
        }
    }
}

Measured memory_bytes: 26072
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

unordered_map<ll, unordered_set<ll>> sources;
unordered_map<ll, ll> memo;

ll rec(ll n) {
  if (memo.count(n)) return memo[n];
  ll ans = 0;
  for (auto it: sources[n]) ans = max(ans, rec(it) + 1);
  memo[n] = ans;
  return ans;
}

void solve() {
  ll N, M;
  cin >> N >> M;
  rep (i, M)  {
    ll x, y;
    cin >> x >> y;
    sources[y].insert(x);
  }
  ll ans = 0;
  rep (i, N) ans = max(ans, rec(i+1));
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 23972
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 1000005;
int st[4 * MX], lz[4 * MX];

void push (int i, int j, int pos) {
	if (i < j) {
		lz[pos * 2] += lz[pos];
		lz[pos * 2 + 1] += lz[pos];
	}

	st[pos] += lz[pos];
	lz[pos] = 0;
}

void update (int i, int j, int pos, int a, int b, int k) {
	push(i, j, pos);

	if (j < a || b < i) return;
	
	if (a <= i && j <= b) {
		lz[pos] = k;
		push(i, j, pos);
		return;
	}

	int m = (i + j) / 2;
	update(i, m, pos * 2, a, b, k);
	update(m + 1, j, pos * 2 + 1, a, b, k);

	st[pos] = max(st[pos * 2], st[pos * 2 + 1]);
}

int n;
string s;

int solve (int mx) {
	memset(st, 0, sizeof(st));
	memset(lz, 0, sizeof(lz));

	int acu = 0, mn = 0;

	forn (i, n) {
		char c = s[i];

		if (c == '1') acu++;
		else acu--;
		update(1, n, 1, i + 1, i + 1, acu);
	}

	acu = 0;
	forn (i, n) {
		char c = s[i];

		if (c == '1') acu++;
		else if (c == '0') acu--;
		else {
			update(1, n, 1, i + 1, n, 2);
			
			if (st[1] <= mx) {
				acu++;
			} else {
				update(1, n, 1, i + 1, n, -2);
				acu--;
			}
		}

		mn = min(mn, acu);
	}

	return mn;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> s;
	n = s.size();

	int acu = 0, mx = 0;

	for (int c : s) {
		if (c == '1') acu++;
		else acu--;
		mx = max(mx, acu);
	}

	cout << min(mx - solve(mx), mx + 1 - solve(mx + 1)) << endl;

	return 0;
}


Measured memory_bytes: 35668
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

int k;
bool vis[50][100000];

void solve(int s, int r) {
  if(s > 45) return;
  if(vis[s][r]) return;
  vis[s][r] = true;
  rep(i,0,10) {
    solve(s + i, (r * 10 + i) % k);
  }
}

int main() {
  S(k);
  solve(0,0);
  rep(i,1,46) if(vis[i][0]) {
    P(i);
    return 0;
  }
  return 0;
}

Measured memory_bytes: 107392
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int main() {
	int x,y,z;
	cin >> x >> y >> z;
	swap(x,y);
	swap(x,z);
	cout << x << ' ' << y << ' ' << z << endl;
  return 0;
}

Measured memory_bytes: 3560
#include <stdio.h>

int main(void)
{
	int i, j, n, m;
	char display[7];
	char segment[10][7] = {
		{0, 1, 1, 1, 1, 1, 1},
		{0, 0, 0, 0, 1, 1, 0},
		{1, 0, 1, 1, 0, 1, 1},
		{1, 0, 0, 1, 1, 1, 1},
		{1, 1, 0, 0, 1, 1, 0},
		{1, 1, 0, 1, 1, 0, 1},
		{1, 1, 1, 1, 1, 0, 1},
		{0, 1, 0, 0, 1, 1, 1},
		{1, 1, 1, 1, 1, 1, 1},
		{1, 1, 0, 1, 1, 1, 1}
	};
	
	while(scanf("%d", &n), n != -1){
		for (i = 0; i < 7; i++){
			display[i] = 0;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d", &m);
			
			for (j = 0; j < 7; j++){
				if (display[j] != segment[m][j]){
					display[j] = segment[m][j];
					printf("1");
				}
				else {
					printf("0");
				}
			}
			
			puts("");
		}
	}
	
	return (0);
}

Measured memory_bytes: 588
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt() * sc.nextInt();
    int B = sc.nextInt();
    if (A >= B) {
      System.out.println(B);
    } else {
      System.out.println(A);
    }
  }
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};



int main() {
    int n, w; cin >> n >> w;
    ll dp[w + 1]; rep(i, w + 1) dp[i] = 0;
    rep(i, n) {
        ll ww, v; cin >> ww >> v;
        for (int j = w; j >= 0; --j) {
            if (j + ww <= w) {
                dp[j + ww] = max(dp[j + ww], dp[j] + v);
            }
        }
        //rep(j, w + 1) cout << dp[j] << " "; cout << endl;
    }
    
    cout << dp[w] << endl;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  vector<bool> g1(n,false);
  vector<bool> g2(n,false);
  int a,b;
  for(int i=0; i<m; i++){
    cin >> a >> b;
	if(a==1) g1[b-1] = true;
    if(b==n) g2[a-1] = true;
  }
  
  bool c = false;
  for(int i=0; i<n; i++){
    if(g1[i] && g2[i]){
      c = true;
      break;
    }
  }
  if(c) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}
    

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
struct state { long long a, b; };
struct comparer {
	inline bool operator()(const state& s1, const state& s2) const {
		return s1.a < s2.a;
	}
};
int N; long long D, A[33], B[33];
state vl[7777777], vr[7777777]; // meet-in-the middle
int que[14348922]; // searching deque
int main() {
	scanf("%d%lld", &N, &D);
	for (int i = 0; i < N; i++) scanf("%lld%lld", &A[i], &B[i]);

	// Calculate sum with bitmasking
	int sep1 = (N >> 1), sep2 = N - sep1;
	vector<long long> sa1(1 << sep1), sb1(1 << sep1);
	vector<long long> sa2(1 << sep2), sb2(1 << sep2);
	for (int i = 0; i < sep1; i++) {
		int b1 = (1 << i), b2 = (1 << (i + 1));
		for (int j = b1; j < b2; j++) {
			sa1[j] = sa1[j - b1] + A[i];
			sb1[j] = sb1[j - b1] + B[i];
		}
	}
	for (int i = 0; i < sep2; i++) {
		int b1 = (1 << i), b2 = (1 << (i + 1));
		for (int j = b1; j < b2; j++) {
			sa2[j] = sa2[j - b1] + A[i + sep1];
			sb2[j] = sb2[j - b1] + B[i + sep1];
		}
	}

	// Meet-in-the-middle Algorithm
	int cnt1 = 0, cnt3 = 0;
	for (int i = 0; i < 1 << sep1; i++) {
		int r = (1 << sep1) - i - 1, j = r;
		do {
			// i -> remain, j -> anna, k -> bruno
			int k = r - j;
			long long r1 = sa1[k] - sa1[j];
			long long r2 = sb1[k] - sb1[j];
			if (r1 >= 0) vl[cnt1++] = state{ r1, r2 };
			if (r1 > 0) cnt3++;
			j = (j - 1) & r;
		} while (j != r);
	}
	int cnt2 = 0, cnt4 = 0;
	for (int i = 0; i < 1 << sep2; i++) {
		int r = (1 << sep2) - i - 1, j = r;
		do {
			// i -> remain, j -> anna, k -> bruno
			int k = r - j;
			long long r1 = sa2[k] - sa2[j];
			long long r2 = sb2[k] - sb2[j];
			if (r1 >= 0) vr[cnt2++] = state{ r1, r2 };
			if (r1 > 0) cnt4++;
			j = (j - 1) & r;
		} while (j != r);
	}

	// Sorting
	sort(vl, vl + cnt1, comparer()); cnt1 += cnt3;
	sort(vr, vr + cnt2, comparer()); cnt2 += cnt4;

	int cnt5 = cnt1 - cnt3;
	int cnt6 = cnt2 - cnt4;
	vector<state> wl(cnt1), wr(cnt2);
	for (int i = 0; i < cnt3; i++) wl[i] = state{ -vl[cnt5 - i - 1].a, -vl[cnt5 - i - 1].b };
	for (int i = 0; i < cnt4; i++) wr[i] = state{ -vr[cnt6 - i - 1].a, -vr[cnt6 - i - 1].b };
	copy(vl, vl + cnt5, wl.begin() + cnt3);
	copy(vr, vr + cnt6, wr.begin() + cnt4);

	// Searching with deque
	int cl = 0, cr = 0, dl = 0, dr = 0;
	long long ret = 0;
	for (int i = cnt2 - 1; i >= 0; i--) {
		while (cr < cnt1 && wl[cr].a + wr[i].a <= D) {
			while (dr - dl && wl[que[dr - 1]].b <= wl[cr].b) dr--;
			que[dr++] = cr++;
		}
		while (cl < cnt1 && wl[cl].a + wr[i].a < -D) {
			if (dr - dl && que[dl] == cl) dl++;
			cl++;
		}
		if (dr - dl) ret = max(ret, wr[i].b + wl[que[dl]].b);
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 681848
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
  int N;
  cin >> N;
  int a[N][3];
  REP(i,N) cin >> a[i][0] >> a[i][1] >> a[i][2];
  vector<vector<int>> dp(N+1,vector<int>(3));
  
  REP(now,N){
    REP(i,3){
      REP(j,3){
        if(i == j)continue;
        chmax(dp[now+1][j],dp[now][i]+a[now][j]);
      }
    }
  }
  
  cout << max({dp[N][0],dp[N][1],dp[N][2]}) << endl;
}

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

int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for(auto i = 0; i < n; ++i){
		int a;
		cin >> a;
		while(a % 2 == 0){
			++ans;
			a /= 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll              long long
#define l1(i, n)        for (ll i = 1; i <= n; i++)
#define l0(i, n)        for (ll i = 0; i < n; i++)
#define lo(i, s, n)     for (ll i = s; i <= n; i++)
#define sca(n)          scanf("%lld", &n)
#define pri(n)          printf("%lld", n)
#define pb              push_back
#define mp              make_pair
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define ms(a, b)        memset(a, b, sizeof(a));
#define cases(tc)       cout<<"Case "<<tc<<": "
#define nl              cout<<"\n";
#define pnl             printf("\n");
#define pi              acos(-1)
#define mod             1000000007
#define inf             999999999999999999
			
 


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

    /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    */

    ll t;
    t=1;
    while(t--){
        ll x, k, d;
        cin>>x>>k>>d;
        x=abs(x);
        if(x==0){
            if(k%2==0) cout<<0;
            else cout<<d;
        }
        else{
            if(x/d>=k){
                cout<<x-d*k;
            }
            else{
                if((k-x/d)%2==0){
                    cout<<x-(x/d)*d;
                }
                else{
                    cout<<abs(x-(x/d+1)*d);
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
void check(int z);
bool flg[10]={0};
int W_book[10]={0};
int bookcheck[1000][10]{{0}};
int sum=0;
int n,s;
int ans=0;
int main(void){
	for(;;){
        cin>>n>>s;
        if(n==0)break;
        for(int i=0;i<10;i++)W_book[i]=-1,flg[i]=0;
        ans=0,sum=0;
        check(0);
        cout<<ans<<endl;
	}

	return 0;
}
void check(int z){
    if(n==z){
        if(sum==s){
            for(int i=0;i<n;i++){
                bookcheck[ans][i]=W_book[i];

               sort(bookcheck[ans],bookcheck[ans]+n);
               reverse(bookcheck[ans],bookcheck[ans]+n);

            }
            bool notcnt=0;
            for(int i=0;i<ans;i++){
                bool W_flg=0;
                for(int j=0;j<n;j++){
                    if(bookcheck[ans][j]!=bookcheck[i][j]){
                        W_flg=1;
                        break;
                    }
                }
                if(W_flg==0)notcnt=1;
            }
            if(notcnt==0){
                int q=0;
                for(int i=0;i<n;i++){
                    q+=bookcheck[ans][i];
                   //cout<<bookcheck[ans][i];
                }
                //cout<<endl;
                if(q==s)ans++;
            }
        }
        return;
    }
    else {
        for(int i=0;i<10;i++){
            if(flg[i]==0&&sum+i<=s){
               // cout<<i<<"."<<z<<endl;
                sum+=i,flg[i]=1;
                W_book[z]=i,check(z+1),W_book[z]=-1;
                sum-=i,flg[i]=0;
            }
            /*else if(z==n-1&&flg[i]==0&&sum+i==s){
               // cout<<i<<"."<<z<<endl;
                sum+=i,flg[i]=1;
                W_book[z]=i,check(z+1),W_book[z]=-1;
                sum-=i,flg[i]=0;
            }*/
        }
    }

}

Measured memory_bytes: 1184
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var charMap = map[string]string{
		"A": "T",
		"T": "A",
		"C": "G",
		"G": "C",
	}
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	input := stdin.Text()
	fmt.Println(charMap[input])
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
  long long int a,b,x,ans;
  scanf("%lld %lld %lld",&a,&b,&x);
  if(a % x == 0){
    ans = a / x - 1;
  }else{
    ans = a / x;
  }
  printf("%lld",b / x - ans);
  return 0;
}

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

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

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

    sort(A, A + N);

    for (int i = 0; i < N - 1; ++i) {
        if (A[i] == A[i + 1]) {
            cout << "NO" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		System.out.println((A == B && A == C) || (A != B && B != C && C != A) ? "No" : "Yes");
	}
}

Measured memory_bytes: 23892
#include <cstdio>
#include <vector>

using namespace std;

int main(){
	int n;
	while(scanf("%d",&n) != EOF && n != 0){
		int max,id;
		int self;
		int p,d1,d2;
		max = -1;
		id = -1;
		for(int i=0;i<n;i++){
			scanf("%d %d %d",&p,&d1,&d2);
			self = d1+d2;
			if( max < self){
				max = self;
				id = p;
			}
		}
		printf("%d %d\n",id,max);
		
	}
	return 0;
}

Measured memory_bytes: 764
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var C = one[1];
  var len = 100005;
  var list = new Array(len);
  for(var i = 0; i < len; i++){
    list[i] = new Array(C + 1).fill(0);
  }
  for(var i = 0; i < N; i++){
    var tmp = nextIntArray();
    var L = tmp[0] - 1;
    var R = tmp[1];
    var cc = tmp[2];
    for(var j = L; j < R; j++){
      list[j][cc]++;
    }
  }
  
  var output = 0;
  for(var i = 0; i < len; i++){
    var sum = 0;
    for(var j = 1; j <= C; j++){
      sum += (list[i][j] > 0) ? 1 : 0;
    }
    output = Math.max(output, sum);
  }
  myout(output);
}


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

 int main()
 {
   int n,sum=0;
   cin>>n;
   
   int a[n];
   
   for(int i=0;i<n;i++)
   {
   	cin>>a[i];
   }
    
    for(int i=0;i<n;i++)
    {
    	for(int j=i+1;j<n;j++)
    	{
    		sum=sum+a[i]*a[j];
		}
	}
	
	cout<<sum<<endl;
   
   
   
  return 0;
}
      

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<fstream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	char c[n+1];
	int maxs=0;
	int now=0;
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
		if(c[i]=='I')
		{
			now++;
		}
		else
		{
			now--;
		}
		maxs=max(maxs,now);
	}
	cout<<maxs<<endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    #inf = 10**17
    mod = 10**9 + 7
    def ncr(n, r, mod):
        r = min(r, n-r)
        numer = denom = 1
        for i in range(1, r+1):
            numer = numer * (n+1-i) % mod
            denom = denom * i % mod
        return numer * pow(denom, mod-2, mod) % mod

    n = input().rstrip()
    k = int(input())
    ln = len(n)
    if ln < k:
        print(0)
        exit()
    res = 0
    if k == 1:
        if ln >= 2:
            res += ncr(ln-1, 1, mod) * 9
        res += int(n[0])
    if k == 2:
        if ln >= 3:
            res += ncr(ln-1, 2, mod) * (9**k)
        res += ncr(ln-1, 1, mod) * 9 * (int(n[0])-1)
        for i in range(1, ln):
            if n[i] != '0':
                if i == ln-1:
                    res += int(n[i])
                else:
                    res += ncr(ln-i-1, 1, mod) * 9
                    res += int(n[i])
                break
    if k == 3:
        if ln >= 4:
            res += ncr(ln-1, 3, mod) * (9**k)
        res += ncr(ln-1, 2, mod) * 81 * (int(n[0])-1)
        for i in range(1, ln-1):
            if n[i] != '0':
                if ln-i-1 >= 2:
                    res += ncr(ln-i-1, 2, mod) * 81
                res += ncr(ln-i-1, 1, mod) * 9 * (int(n[i])-1)
                for j in range(i+1, ln):
                    if n[j] != '0':
                        if j != ln-1:
                            res += ncr(ln-j-1, 1, mod) * 9 
                        res += int(n[j])
                        break
                break
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <stdio.h>

#define swap(x,y) do{int n;n=x;x=y;y=n;}while(0)

int main()
{
    int i,j;
    int v[10];
    int flag;
    
    for(i=0;i<10;i++){
        scanf("%d",&v[i]);
    }
 
    for(i=0;i<9;i++){
        flag = 0;
        for(j=9;j>i;j--){
            if(v[j]>v[j-1]){
                swap(v[j],v[j-1]);
                flag = 1;
            }
        }
        if(flag==0){
            break;
        }
    }
            
   
    for(i=0;i<3;i++){ 
        printf("%d\n",v[i]);
    }
    
    return 0;
}

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

int main() {
    int N,A,B,C,D;
    string S;
    cin >> N >> A >> B >> C >> D >> S;



    bool three_dot_exists = false;
    bool two_sharp_exists = false;
    for (int i = A+1; i < max(C,D); ++i){
    	if (S[i] == 35 && S[i-1] == 35) two_sharp_exists = true;
    	if (B <= i 
    		&& S[i] == 46 
    		&& S[i-1] == 46 
    		&& S[i-2] == 46 
    		&& i <= D) three_dot_exists = true;
    }

    bool ans = false;
    if (C < D){
    	ans = !two_sharp_exists;
    }else{
    	ans = three_dot_exists && !two_sharp_exists;
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
signed main(){
  char a[10];
  cin>>a;
  if(a[0]==a[1]){
    if(a[0]==a[3])
      cout<<"No"<<endl;
    else if(a[2]==a[3])
	cout<<"Yes"<<endl;
      else
	cout<<"No"<<endl;
  }
  else{
    if(a[0]==a[2] && a[3]==a[1])
      cout<<"Yes"<<endl;
    else if(a[0]==a[3] && a[1]==a[2])
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	try {
    		final int M = sc.nextInt();
    		final int D = sc.nextInt();

    		int count = 0;
    		for (int m=1; m<=M; m++) {
    			for (int d=11; d<=D; d++) {
    				int d1  = d%10;
    				int d10 = d/10;
    				int multi = d1 * d10;
    				if (d1 >=2 && d10 >= 2 && m == multi) {
    					// System.out.println(String.format("%d/%d, %d %d", m, d, d1, d10));
    					count++;
    				}
    			}
    		}

    		System.out.println(count);

    	} finally {
    		sc.close();
    	}
    }
}



Measured memory_bytes: 25172
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
  
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;

ll pref[N + 1];

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, m, v, p;
    cin >> n >> m >> v >> p;
    int a[n];
    rep(i, 0, n) {
        cin >> a[i];
    }
    sort(a, a + n);
    reverse(a, a + n);
    /*rep(i, 0, n) {
        cout << a[i] << " ";
    }
    cout << "\n";*/
    pref[0] = 0;
    rep(i, 0, n) {
        pref[i + 1] = pref[i] + a[i];
    }
    int ans = 0;
    rep(i, 0, n) {
        //cout << i << endl;
        if (i < p) {
            ans++;
            continue;
        }
        int V = max(0, v - (n - i) - (p - 1));
        V = (i - (p - 1)) - V;
        int l = p - 1, r = i - 1;
        ll tot = (pref[r + 1] - pref[l]) - 1LL * (i - (p - 1)) * a[i];
        /*cout << "! " << tot << endl;
        cout << V << endl;
        cout << "? " << p - 1 << " " << i << endl;*/
        ll need = max((tot + V - 1) / V, (ll)(a[p - 1] - a[i]));
        if (need <= m) {
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1408
from collections import deque,defaultdict
def solve():
    N = int(input())
    S = list(input())
    dic = defaultdict(lambda: False)
    ans = 0
    d = deque()
    for s in S:
        for _ in range(len(d)):
            t = d.popleft()
            d.append(t)
            if len(t)==1:
                u = t+s
                if dic[u]==False:
                    dic[u] = True
                    d.append(u)
            if len(t)==2:
                u = t+s
                if dic[u]==False:
                    dic[u] = True
                    ans += 1
        if dic[s]==False:
            dic[s] = True
            d.append(s)
    return ans
print(solve())

Measured memory_bytes: 71132
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long A,B;
	A=1;
	B=1;
	int N;
	cin>>N;
	while(N--)
	{
		long long a,b;
		cin>>a>>b;
		long long x=max((A+a-1)/a,(B+b-1)/b);
		A=x*a;
		B=x*b;
	}
	cout<<A+B<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
int main(){
    int n;cin >> n;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        bool higher = true;
        for(int j=0;j<i;j++){
            if(h[i] < h[j]){
                higher = false;
                break;
            }
        }
        if(higher){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lson now<<1
#define rson now<<1|1
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int mod=1e9+7;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=2e5+10;
const ll inf=0x3f3f3f3f;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    string a,b;
    cin>>a>>b;
    map<string,int> m;
    int x,y;
    cin>>x>>y;
    m[a]=x,m[b]=y;
    string s;
    cin>>s;
    m[s]--;
    cout<<m[a]<<' '<<m[b]<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
using namespace std;
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
typedef long long ll;
typedef unsigned long long ull;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<double,double>
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-6;
const int MAX=5e5+10;
const ll mod=1e9+7;
int main()
{
	ll x,y,ans;
	while(~scanf("%lld%lld",&x,&y))
	{
		ans=0;
		y/=x;
		while(y)
		{
			ans++;
			y>>=1;
		}
		printf("%lld\n",ans);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define nl "\n" 
#define pb push_back
#define sz(a) (int)a.size()

void solve(){
	int n;
	cin >> n;
	vi dp(3,0);
	for(int i=0;i<n;++i){
		vi a(3);
		vi new_dp(3,0);
		for(int j=0;j<3;++j){
			cin >> a[j];
		}
		for(int j=0;j<3;++j){
			for(int k=0;k<3;++k){
				if(j!=k) new_dp[k]=max(new_dp[k],dp[j]+a[k]);
			}
		}
		dp=new_dp;
	}
	cout << max({dp[0],dp[1],dp[2]}) << nl;
}

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

	solve();
	
	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          998244353
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e18
 #define sm         -1e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   
    #endif
}

string s;

int nCrModpDP(int n, int r, int p) 
{ 
    int C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; // Top row of Pascal Triangle 
  
    for (int i = 1; i <= n; i++) 
    { 
        for (int j = min(i, r); j > 0; j--) 
  
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 
   
int nCrModpLucas(int n, int r, int p) 
{ 
   if (r==0) 
      return 1; 
   int ni = n%p, ri = r%p; 
  
   return (nCrModpLucas(n/p, r/p, p) * // Last digits of n and r 
           nCrModpDP(ni, ri, p)) % p;  // Remaining digits 
} 

bool ok()
{
  int pr = 0,n=sz(s);
  for(int i=0;i<sz(s);i++)
  {
    pr += (nCrModpLucas(n-1,i,2)*(s[i]-'0') )%2 ;
    
  }
  if(pr%2!=0) return 1;
  return 0;
}
void solve()
{
  
 int n;
 cin >> n ;
 cin >> s; 

 forf(i,0,sz(s))
 {
  s[i] = (int)(s[i]-'0')-1 + '0';
 } 
 
 
 if(ok())
 {
  cout<<"1\n";
  return;

 }
 
 int bl = 0;
 forf(i,0,n)
 {
  if(s[i] == '1') 
  {
    cout<<"0\n";
    return;
  }
  s[i] = (s[i]-'0')/2 + '0';
 }
 
if(ok())
{
  cout<<"2\n";
  return ;
} 

cout<<"0\n";

}

int32_t main()
{
  //pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

 }

Measured memory_bytes: 1948
N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(M)]

visited = [False] * N
visited[0] = True
d = {}
for a, b in A:
    d.setdefault(b-1, []).append(a-1)
    d.setdefault(a-1, []).append(b-1)

l = sorted(d.items())

def dfs(v, seen):
    if False not in seen: return 1
    
    c = 0
    for i in d[v]:
        if (seen[i]): continue
        seen[i] = True
        c += dfs(i, seen)
        seen[i] = False
    return c
    
print(dfs(0, visited))



Measured memory_bytes: 3064
n, k = map(int, input().split(' '))

if n < k:
    while(True):
        prev_n = n
        n = abs(n - k)
        if prev_n <= n:
            print(prev_n)
            break
else:
    tmp = n % k
    while(True):
        prev_n = tmp
        tmp = abs(tmp - k)
        if prev_n <= tmp:
            print(prev_n)
            break

Measured memory_bytes: 3064
g(){int x;scanf("%d",&x);return x;}
main(m,v,x){
  for(;;){double s=0,t=0,z=.01745329,e=.000001;
    scanf("%d",&m);if(!m)return 0;
    for(v=360;--m;s+=sin(x*z))v-=(x=g());s+=sin(v*z);
    scanf("%d",&m);
    for(v=360;--m;t+=sin(x*z))v-=(x=g());t+=sin(v*z);
    puts(s>t+e?"1":s+e<t?"2":"0");
  }
}

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


int main(){
    int a, b;
    cin >> a >> b;
    if (a < b){
        swap(a, b);
    }

    for (int i=0; i<a; i++){
        cout << b;
    }
    cout << endl;
    return 0;
}

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

using namespace std;


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

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

  if(b >= a){
    cout << a << endl;
  }else{
    cout << a - 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static void main(String[] args) {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);

        String s = null;
        try {
            s = br.readLine();
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");

        // Date型変換
        Date formatDate = null;
        try {
            formatDate = sdf.parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        Date compareDate = null;
        try {
            compareDate = sdf.parse("2019/04/30");
        } catch (ParseException e) {}

        if (formatDate.after(compareDate)) { // formatDate(2019/05/01...) > compareDate(2019/04/30)
            System.out.println("TBD");
        } else {
            System.out.println("Heisei");
        }
    }
}


Measured memory_bytes: 21840
n=gets.to_i
a=gets.split.map(&:to_i)

color=a.map{|e| e/400<=8? e/400 : 8}
any=color.inject(0){|res, e| res+=e>=8? 1: 0}

if any==color.size
  puts "1 #{any}"
else
  cnt=color.uniq.size-(any>0? 1: 0)
  puts"#{cnt} #{cnt+any}"
end


Measured memory_bytes: 1788