akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

int main(){
	 int n, m; cin >> n >> m;
	 Yes(n == m);
}

Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    print(str(min(a,b))*max(a,b))
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define FASTBOI ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pll pair<long long, long long>
#define ll long long
#define f first
#define s second
#define mod 1000000007
const int inf = 1e9;

using namespace std;
bool isPerfectSquare(long double x)
{
  long double sr = sqrt(x);

  return ((sr - floor(sr)) == 0);
}
int main()
{
	FASTBOI;
	int n,d;
	cin>>n>>d;
	vector<int> arr[n];
	for(int y=0;y<n;y++)
	{
		for(int x=0;x<d;x++)
		{
			int m;cin>>m;
			arr[y].pb(m);
		}
	}
	int ans=0;
	for(int y=0;y<n;y++)
	{
		for(int x=y+1;x<n;x++)
		{
			long double val=0;
			for(int z=0;z<d;z++)
			{
				val+=(arr[y][z]-arr[x][z])*(arr[y][z]-arr[x][z]);
			}
			if(isPerfectSquare(val))
				ans++;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

ll dp[200010][5]={};

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;
  V<ll> v(n);rep(i,0,n)cin>>v[i];

  rep(i,1,n+1)rep(j,0,5)dp[i][j]=LINF;
  
  rep(i,0,n){
    chmin(dp[i+1][0],dp[i][0]+v[i]);
    chmin(dp[i+1][4],dp[i][4]+v[i]);

    if(v[i]%2){
      chmin(dp[i+1][1],dp[i][1]+1);
      chmin(dp[i+1][2],dp[i][2]);
      chmin(dp[i+1][3],dp[i][3]+1);

      chmin(dp[i+1][1],dp[i][0]+1);
      chmin(dp[i+1][2],dp[i][0]);
      chmin(dp[i+1][2],dp[i][1]);
      chmin(dp[i+1][3],dp[i][2]+1);

    }else if(v[i]){
      chmin(dp[i+1][1],dp[i][1]);
      chmin(dp[i+1][2],dp[i][2]+1);
      chmin(dp[i+1][3],dp[i][3]);

      chmin(dp[i+1][1],dp[i][0]);
      chmin(dp[i+1][2],dp[i][0]+1);
      chmin(dp[i+1][2],dp[i][1]+1);
      chmin(dp[i+1][3],dp[i][2]);
    }else{
      chmin(dp[i+1][1],dp[i][1]+2);
      chmin(dp[i+1][2],dp[i][2]+1);
      chmin(dp[i+1][3],dp[i][3]+2);

      chmin(dp[i+1][1],dp[i][0]+2);
      chmin(dp[i+1][2],dp[i][0]+1);
      chmin(dp[i+1][2],dp[i][1]+1);
      chmin(dp[i+1][3],dp[i][2]+2);
    }

    rep(j,1,4)chmin(dp[i+1][4],dp[i][j]+v[i]);
  }

  ll ans=LINF;
  rep(i,0,5){
    chmin(ans,dp[n][i]);
  }
  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 9600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };





ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll X[301][4];
int main() {
int N,A,B;
int P[101];
cin>>N>>A>>B;
REP(i,N)cin>>P[i];
int a=0,b=0,c=0;
REP(i,N){
if(P[i]<=A)a++;
else if(A<P[i]&&P[i]<=B)b++;
else c++;

}
int ans=min(min(a,b),c);
cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;

class Main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] dx = {-1, 0, 1, 0, -1, 1, 1, -1};
    public static int[] dy = {0, 1, 0, -1, 1, 1, -1, -1};
    public static int INF = 0x3f3f3f3f;
    public static long LINF = 0x3f3f3f3f3f3f3f3fL;
    public static int MOD = 1000000007;

    public static void main(String[] args) throws Exception{
        int N = Integer.parseInt(br.readLine());
        st = new StringTokenizer(br.readLine());
        long[] A = new long[N];
        for(int i = 0; i < N; i++){
            A[i] = Integer.parseInt(st.nextToken());
        }

        Arrays.sort(A);
        int last = 0;
        for(int i = 0; i < N-1; i++){
            if(A[i+1] > 2 * A[i]){
                last = i+1;
            }
            A[i+1] += A[i];
        }
        pw.print(N-last + "\n");
        
        pw.close(); 
        br.close();
    }
}

class Pair {
    public int a, b;

    Pair(int a, int b){
        this.a = a;
        this.b = b;
    }

}

Measured memory_bytes: 41936
def main():
    N = int(input())
    S = input()[::-1]
    digits_1 = [0] * 10
    digits_2 = [[0 for _ in range(10)] for _ in range(10)]
    digits_3 = [[[0 for _ in range(10)] for _ in range(10)] for _ in range(10)]
    for i, d in enumerate(S):
        d = int(d)
        for d1 in range(10):
            for d2 in range(10):
                if digits_2[d2][d1] == 1:
                    digits_3[d][d2][d1] = 1
        for d1 in range(10):
            if digits_1[d1] == 1:
                digits_2[d][d1] = 1
        digits_1[d] = 1
    ans = 0
    for d3 in range(10):
        for d2 in range(10):
            for d1 in range(10):
                ans += digits_3[d3][d2][d1]
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 80720
#include <bits/stdc++.h>
#include <math.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ept 1e-9

using namespace std;
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}


#define N 200010
struct Node 
{
    int l, r;
} a[N];
int n, m, i, ans, now;

bool cmp(Node a, Node b) 
{
    if (a.l == b.l) return a.r > b.r;
    return a.l < b.l;
}

struct heap
{
    int val;
    bool operator < (const heap &t) const
    {
        return val > t.val;
    }
};

priority_queue <heap> Heap;

int main() 
{
    n = read(), m = read();
    rep(i, 1, n) a[i].l = read(), a[i].r = read();
    sort(a + 1, a + n + 1, cmp);  
    for (now = 1; now <= n; now ++) 
    	if (a[now].l) 
    		break;
    now --;
    rep(i, 1, now) Heap.push((heap){a[1].r});
    rep(i, 1, m)
    {
    	while (now < n && a[now + 1].l < i) now ++, Heap.push((heap){a[now].r});
        if (now < n) 
        {
            now ++;
            if (++ ans == n) break;
            continue;
        }
        if (!Heap.empty() && Heap.top().val <= i) 
        {
            Heap.pop();
            if (++ ans == n) break;
            continue;
        }
    }
    printf("%d\n", n - ans);
    return 0;
}


Measured memory_bytes: 2936
#include<iostream>
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<algorithm>
#include<math.h>
#include"boost/algorithm/string.hpp"

using namespace std;


int main(){
	/*Q2*/
	int n;
	cin >> n;
	
	string s;
	cin >> s;
	int k;
	cin >> k;
	k--;

	char c = s[k];

	for (int i = 0; i < s.size(); ++i){
		if (s[i]!= c){
			s[i] = '*';
		}
	}

	cout << s << endl;
	/*Q1*/
	/*
	int a, b, c;
	cin >> a >> b >> c;

	if (a < b){
		if (a < c && c < b){
			cout << "Yes" << endl;
			return 0;
		}
	}

	else{
		if (b < c && c < a){
			cout << "Yes" << endl;
			return 0;
		}


	}

	cout << "No" << endl;
	*/

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    ll X;
    cin >> X;

    ll a = 100;
    ll ans = 0;
    while(1){
        if(a >= X) break;
        a = a*1.01;
        //cout << a << endl;
        ans++;
    }

    cout << ans << endl;


}

Measured memory_bytes: 3648
package main

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

func main() {
	n := nextInt()
	m := nextInt()
	if n == m {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

var scanner *bufio.Scanner

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val s = readLine()!!
    var dic = Array(s.length) { mutableSetOf<Char>() }
    var flg = false

    for (i in 0 until s.length) {
        dic[i] = mutableSetOf(s[i])
    }

    while (true) {
        for (c in 'a'..'z') {
            var i = 0
            while (i < dic.size) {
                if (!dic[i].contains(c)) {
                    break
                }
                i++
            }
            if (i == dic.size) {
                flg = true
            }
        }
        for (i in 0 until dic.size - 1) {
            for (v in dic[i + 1]) {
                dic[i].add(v)
            }
        }
        if (flg) {
            break
        }
        dic = dic.slice(0 until dic.size - 1).toTypedArray()
    }
    println(s.length - dic.size)
}


Measured memory_bytes: 34076
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n+1);
    for(int i = 1; i <= n; i++) cin >> v[i];
    int pre[n+1];
    pre[1] = v[1];
    for(int i = 2; i <= n; i++)
    {
        pre[i] = pre[i-1] + v[i];
    }
    int s = 1, e = k, i = 1;
    while(e + i <= n)
    {
        if(s == 1){
            if(pre[e + i] - pre[s + i - 1] > pre[e])
            {
                // cout << pre[e+i] - pre[s+i-1] << ' ' << pre[e] - pre[s] << '\n';
                e += i;
                s += i;
                i = 1;
                continue;
            }
        }
        else{
        if(pre[e + i] - pre[s + i - 1] > pre[e] - pre[s - 1])
        {
            // cout << pre[e+i] - pre[s+i-1] << ' ' << pre[e] - pre[s-1] << '\n';
            e += i;
            s += i;
            i = 1;
            continue;
        }}
        i++;
    }
    double_t res = 0;
   // cout << s << ' ' << e << '\n';
    for(int i = s; i <= e; i++)
    {
        int t = v[i] * (v[i] + 1) / 2;
        // cout << t << ' ' << v[i] << '\n';
        res += float(t)/float(v[i]);
    }
    cout << setprecision(9);
    cout << res;
    return 0;
}

Measured memory_bytes: 3328
from itertools import accumulate
N = int(input())
a = list(map(int,input().split()))
acc = list(accumulate(a))
m = float("inf")
for i in range(0, N-1):
    x = acc[i]
    y = acc[-1]-x
    m = min(abs(x-y), m)
print(m)

Measured memory_bytes: 25336
using namespace std;

#include <bits/stdc++.h>

int main(){
    int N;
    cin >> N;
    int D;
    cin >> D;
    if ( N % ( 2 * D + 1) == 0 ) cout << N / ( 2 * D + 1 );
    else cout << N / ( 2 * D + 1 ) + 1;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int N, K, h[100000], i, count=0;

    cin >> N >> K;

    for(i=0; i<N; i++){
        cin >> h[i];

        if(h[i] >= K){
            count++;
        }
    }

    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 640
n = int(input())

i = 0
answer = 0
while n >= 10 ** (2*i + 1):
  answer += 10 ** (2*i + 1) - 10 ** (2*i)
  i += 1
answer += max(0, n - 10 ** (2*i) + 1)

print(answer)

Measured memory_bytes: 2940
from collections import Counter


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    1 2 3 4 5 6
    """
    N = read_int()
    divisors = [[] for _ in range(N+1)]
    modulo = 10**9+7
    for i in range(2, N+1):
        if len(divisors[i]) == 0: # if prime
            for j in range(i, N+1, i):
                divisors[j].append(i)
    counter = Counter()
    for i in range(1, N+1):
        j = 0
        temp = i
        while temp != 1 and j < len(divisors[i]):
            if temp%divisors[i][j] == 0:
                counter[divisors[i][j]] += 1
                temp //= divisors[i][j]
            else:
                j += 1
    answer = 1
    for v in counter.values():
        answer = (answer*(v+1))%modulo
    return answer


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 70028
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()
#define INF 10101010101

struct FastIO
{
  FastIO() {
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(0); 
  }
}fastio;

struct UnionFind
{
  int n;
  std::vector<int> par,size;
  UnionFind(int sz) : n(sz), par(sz,0), size(sz,1) {
    std::iota(par.begin(),par.end(),0);
  }
  int find(int x) {
    if(par[x]==x) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x=find(x);y=find(y);
    if(x==y) return;
    if(size[x]<size[y]) std::swap(x,y);
    size[x]+=size[y];
    par[y]=x;
  }
};
signed main() {
	int n,m;
	std::cin >> n >> m;
	std::vector<std::vector<int> > connected(n,std::vector<int>());
	UnionFind uf(n);
	rep(i,m) {
		int u,v;
		std::cin >> u >> v;
		u--;v--;
		connected[u].emplace_back(v);
		uf.unite(u,v);
	}
	int s,t;
	std::cin >> s >> t;
	s--;t--;
	if(uf.find(s)!=uf.find(t)) {
		print(-1);
		return 0;
	}
	std::vector<int> minc(n,INF);
	std::vector<int> que;
	que.emplace_back(s);
	minc[s] = 0;
	for(int i=0;i<que.size();i++){
		auto j=que[i];
		for(auto a:connected[j]) for(auto b:connected[a]) for(auto c:connected[b]) {
			if(minc[c]!=INF) continue;
			if(c==t) {
				print(minc[j]+1);
				return 0;
			}
			minc[c] = minc[j]+1;
			que.emplace_back(c);
		}
	}
	print(-1);
	return 0;
}


Measured memory_bytes: 9208
fn main() {
  let (n, m): (usize, usize) = get::tuple();

  let ans = (1900*m + 100*(n-m)) * 2usize.pow(m as u32);
  println!("{}", ans)
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }

  pub fn chars() -> Vec<char> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().chars().collect()
  }
}

Measured memory_bytes: 4352
def comb2(num):
    return num * (num - 1) // 2


n = int(input())
a = list(map(int, input().split()))

# create hash table
table = {}
for i in range(n):
    if a[i] not in table:
        table[a[i]] = 1
    else:
        table[a[i]] += 1

total = 0
for idx in table:
    total += comb2(table[idx])

for i in range(n):
    sub = comb2(table[a[i]])
    add = comb2(table[a[i]] - 1)
    print(total - sub + add)


Measured memory_bytes: 26140
n, m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]

flg = True
for ci in range(0, 10**n):
    cis = str(ci)
    if len(cis) != n:
        continue
    for j in range(m):
        s, c = sc[j][0]-1, sc[j][1]
        if int(cis[s]) != sc[j][1]:
            flg = False
            break
            
        if j == m-1:
            flg = True
    if flg == True:
        break
print(ci) if flg else print(-1)        

Measured memory_bytes: 9156
#include<stdio.h>
#include<stdlib.h>
#define df 0
typedef struct{
  int x;
  int y;
}pair;

int c(const void* a,const void* b){
  if(((pair*)a)->x>((pair*)b)->x) return 1;
  if(((pair*)a)->x<((pair*)b)->x) return -1;
  if(((pair*)a)->y>((pair*)b)->y) return 1;
  if(((pair*)a)->y<((pair*)b)->y) return -1;
  return 0;
}
int main (){
  int n;
  scanf("%d",&n);
  int i,j;
  pair pos[n],dif[n*n];
  for(i=0;i<n;i++){
    scanf("%d%d",&pos[i].x,&pos[i].y);
  }
  if(n==1) {
    printf("1");
    return 0;
  }
  int k=0;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(i==j)continue;
      dif[k].x=pos[i].x-pos[j].x;
      dif[k].y=pos[i].y-pos[j].y;
      k++;
    }
  }
  qsort(dif,k,sizeof(pair),c);
  int max=1,temp=1;
  for(i=1;i<k;i++){
    if(c(&(dif[i]),&(dif[i-1]))==0)temp++;
    else temp=1;
    if(max<temp)max=temp;
  }
  printf("%d",n-max);
}


/// check df==0 ///


Measured memory_bytes: 252
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,sum;
    string s;
    while(true){
        sum=0;
        cin>>s;
        if(s[0]=='0')
            break;
        for(int i=0;i<s.size();i++){
            n=(int)(s[i]-'0');
            sum+=n;
        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;

LL inf = 1000000000000;
LL mod = 1000000007;

map<string, LL> mp;

bool stran(string a, string b) {
	if (mp[a] == mp[b]) {
		return a < b;
	}
	else {
		return mp[a] > mp[b];
	}
}

int main()
{
	LL n;
	cin >> n;
	vector<string> s(n);

	LL mx = 0;

	for (auto &e : s) {
		cin >> e;
		mp[e]++;
		mx = max(mx, mp[e]);
	}

	set<string> ss;

	for (LL i = 0; i < n; ++i) {
		if (mp[s[i]] == mx) {
			ss.insert(s[i]);
		}
	}
	//sort(ss.begin(), ss.end());

 	for (auto e : ss) {
		cout << e << "\n";
	}
	
}

Measured memory_bytes: 36096
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
typedef pair<int,int>P;
 
int dp[100009][2];
int c[100009];
vector<int>v[100009];
bool so[2000009];
bool used[100009][2];
 
 
int main(){
 
  so[0]=so[1]=1;
 
  for(int i=2;i<=2000000;i++)if(!so[i]){
    for(int j=i+i;j<=2000000;j+=i) so[j]=1;
  }
 
 
  int n,m,s,t;
  cin>>n>>m>>s>>t;s--;t--;
  r(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
 
  queue<P>q;
  q.push(P(s,0));
  used[s][0]=1;
  while(!q.empty()){
    int x=q.front().first;
    int y=q.front().second;q.pop();
    r(i,v[x].size()){
      int nex=v[x][i];
      int cost=dp[x][y]+1;
      if(!used[nex][cost%2]){
        used[nex][cost%2]=1;
        dp[nex][cost%2]=cost;
        q.push(P(nex,cost%2));
      }
    }
  }
  if(dp[t][0]==2)cout<<2<<endl;
  else if(!used[t][1])cout<<-1<<endl;
  else{
    while(so[dp[t][1]])dp[t][1]+=2;
    cout<<dp[t][1]<<endl;
  }
}


Measured memory_bytes: 11576
n = int(input())

d = {}
m = 0
for i in range(n):
    s = input()
    if s not in d:
        d[s] = 0
    d[s] += 1
    if d[s] > m:
        m = d[s]
al = []
for t in d:
    if d[t] == m:
        al.append(t)
al.sort()
for t in al:
    print(t)




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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		100050

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//




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

	int N = S.size();

	int cnt=0;
	REPS(i,1,N){
		if(S[i-1]==S[i]){
			++cnt;
			S[i] = (S[i]=='0' ? '1' : '0');
		}
	}

	cout << min(cnt,N-cnt) << endl;

	return 0;
}




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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


template<class T>
vector<T> Dijkstra(int s, const vector<vector<pair<T,int>>> &g, vector<int> &prev = {}) {

    using pi = pair<T,int>;

    vector<T> dis(g.size(), inf);
    dis[s] = 0;    

    prev.assign(dis.size(), -1);    

    priority_queue<pi, vector<pi>, greater<pi>> que; // pair = (cost, v);
    que.emplace(0,s);

    while(!que.empty()) {
        P p = que.top(); que.pop();
        int now = p.second;
        if(dis[now] < p.first) continue;
        for(P np : g[now]) {
            int next = np.second;
            if(dis[next] > dis[now] + np.first) {
                prev[next] = now;
                dis[next] = dis[now] + np.first;
                que.emplace(dis[next], next);
            }
        }
    }
    return dis;
}



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

    V<V<P>> g(n);

    rep(i,m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        g[a].emplace_back(c,b);
        g[b].emplace_back(c,a);
    }

    set<P> edges;

    rep(i,n) {
        V<int> prev(n);
        Dijkstra(i, g, prev);
        rep(j,n) {
            if(i == j) continue;
            int v = j;
            while(v != i) {
                edges.emplace(min(v, prev[v]), max(v, prev[v]));
                v = prev[v];
            }
        }
    }

    int ans = m - sz(edges);
    cout << ans << endl;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#include <set>
#include <vector>
using namespace std;
#define rep(i,n) for(ll i = 0; i < n; ++i)
#define Rep(i,n) for(ll i = 0; i <= n; ++i)
#define yes "yes"
#define Yes "Yes"
#define no "no"
#define No "No"

namespace mydef
{
  void say(string some){
    cout << some << "\n";
  }
} // namespace mydef
using namespace mydef;
typedef long long ll;
const int INF = 1001001001;
const long double PI=3.14159265358979323846;

//ここからいじる
signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  

  vector<int> x(5);
  rep(i, 5) cin >> x[i];

  int ans = 0;
  rep(i, 5) ans += x[i];
  cout << 15-ans << "\n";
  

    return 0;
}




Measured memory_bytes: 3600
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
#define next _next
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 100010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}


int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

char s[110][110];
struct node{
	int v,c,next;
}g[N<<1];
int head[N],cnt,cur[N],d[N];
void add(int a,int b,int c){
	g[cnt]={b,c,head[a]};head[a]=cnt++;
	g[cnt]={a,0,head[b]};head[b]=cnt++;
}
bool bfs(int s,int t){
	rep(i,0,t+1)d[i]=-1,cur[i]=head[i];
	queue<int>q;q.push(s);d[s]=0;
	while(!q.empty()){
		int u=q.front();q.pop();
		for(int i=head[u];~i;i=g[i].next){
			int j=g[i].v;
			if(g[i].c&&d[j]==-1){
				d[j]=d[u]+1;q.push(j);
			}
		}
	}
	//DBG(d[t])
	return d[t]>=0;
}
int dfs(int u,int t,int lim){
	if(u==t||lim==0)return lim;
	int ans=0,f;
	for(int &i=cur[u];~i;i=g[i].next){
		int j=g[i].v;
		if(d[j]==d[u]+1&&(f=dfs(j,t,min(g[i].c,lim)))){
			ans+=f,lim-=f;
			g[i].c-=f,g[i^1].c+=f;
			if(lim==0)break;
		}
	}
	d[u]=-1;
	return ans;
}
int dinic(int s,int t){
	int ans=0;
	while(bfs(s,t))ans+=dfs(s,t,inf);
	return ans;
}
int n,m,dx[]={-1,0,1,0},dy[]={0,-1,0,1};
int get(int i,int j){return i*m+j;}
int main(){
    int T,i,j,k,ca=0,K;
    //cout<<setprecision(10)<<fixed;
    scanf("%d%d",&n,&m);
    rep(i,0,n)scanf("%s",s[i]);
    int S=n*m*2;T=S+1;
    memset(head,-1,sizeof(head));
    rep(i,0,n){
    	if(s[i][0]=='X'||s[i][m-1]=='X'){puts("-1");return 0;}
    	add(S,get(i,0)*2,inf);add(S,get(i,m-1)*2,inf);
    }
    rep(i,0,m){
    	if(s[0][i]=='X'||s[n-1][i]=='X'){puts("-1");return 0;}
    	if(i&&i<m-1)add(S,get(0,i)*2,inf),add(S,get(n-1,i)*2,inf);
    }
    rep(i,0,n)rep(j,0,m){
    	if(s[i][j]=='X'){
    		add(get(i,j)*2,T,inf);
    	}
    	else{
    		add(get(i,j)*2,get(i,j)*2+1,1);
    	}
    	rep(k,0,4){
    		int x=i+dx[k],y=j+dy[k];
    		if(x>=0&&x<n&&y>=0&&y<m)add(get(i,j)*2+1,get(x,y)*2,inf);
    	}
    }
    int ans=dinic(S,T);
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int h, w;
    cin >> h >> w;

    char board[h][w];
    rep(i, h) {
        rep(j, w) {
            char a;
            cin >> a;
            board[i][j] = a;
        }
    }

    int check[h][w];
    rep(i, h) {
        rep(j, w) {
            check[i][j] = 1;
        }
    }
    
    rep(i, h) {
        int flag = 1;

        rep(j, w) {
            if(board[i][j] == '#') {
                flag = 0;
            }
        }

        if(flag) {
            rep(j, w) {
                check[i][j] = 0;
            }
        }
    }

    rep(j, w) {
        int flag = 1;

        rep(i, h) {
            if(board[i][j] == '#') {
                flag = 0;
            }
        }

        if(flag) {
            rep(i, h) {
                check[i][j] = 0;
            }
        }
    }

    rep(i, h) {
        int flag = 0;

        rep(j, w) {
            if(check[i][j]) {
                cout << board[i][j];
                flag = 1;
            }
        }

        if(flag || i == h-1) {
            cout << "\n";
        }
    } 

    return 0;
}

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


int main() {
  int n;
  cin >> n;
  int H[n+1];
  rep(i, n) cin >> H[i];
  H[n] = Inf;
  int max = 0;
  int i, j;
  i = j = 0;
  while (j < n) {
    i = j;
    while (H[j] >= H[j+1]) ++j;
    if (j-i > max) max = j-i;
    ++j;
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 640
open System
open System.Linq

#nowarn "25"

let inline readLine _ = stdin.ReadLine()
let inline readInt<'a> = readLine >> int
let inline readLong<'a> = readLine >> int64
let inline readFloat<'a> = readLine >> float
let inline readArray _ = readLine().Split ' '
let inline readArrayInt _ = readArray() |> Array.map (int)

type Int32 =
    static member OfChar ch =
        int ch - int '0'

[<EntryPoint>]
let main _ =
    let n = readInt()
    let cnt = Array2D.zeroCreate<Int64> 10 10
    for i in 1..n do
        let head = (i
            |> string
            |> Enumerable.First
            |> Int32.OfChar)
        let tail = i % 10
        cnt.[head, tail] <- cnt.[head, tail] + 1L
    Seq.init 10 (fun i ->
        Seq.init 10 (fun j ->
            cnt.[i, j] * cnt.[j, i]))
    |> Seq.sumBy (Seq.sum)
    |> printfn "%d"

    0 // return an integer exit code


Measured memory_bytes: 18380
// -*- coding:utf-8-unix -*-

use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: usize
    }
    if s < 3 {
        println!("0");
        return;
    }
    let mut patnum = vec![ModP(0); s + 1];
    patnum[0] = ModP(1);
    patnum[3] = ModP(1);
    for i in 4..=s {
        let mut patnumi = ModP(0);
        for j in 3..=s {
            if i < j {
                break;
            }
            patnumi = patnumi + patnum[i - j];
        }
        patnum[i] = patnumi;
    }
    println!("{}", patnum[s].0);
}

use num_traits::{pow, One};
use std::ops::{Add, Div, Mul, Sub};

const MODULUS: usize = 1000000007;

#[derive(Clone, Copy, PartialEq, Debug)]
struct ModP(usize);

impl One for ModP {
    fn one() -> Self {
        return ModP(1);
    }
}
impl Add for ModP {
    type Output = Self;
    fn add(self, rhs: Self) -> Self {
        return ModP((self.0 + rhs.0) % MODULUS);
    }
}
impl Sub for ModP {
    type Output = Self;
    fn sub(self, rhs: Self) -> Self {
        return ModP((self.0 + MODULUS - rhs.0) % MODULUS);
    }
}
impl Mul for ModP {
    type Output = Self;
    fn mul(self, rhs: Self) -> Self {
        return ModP((self.0 * rhs.0) % MODULUS);
    }
}
impl Div for ModP {
    type Output = Self;
    fn div(self, rhs: Self) -> Self {
        if rhs.0 == 0 {
            panic!("Tried to divide by ModP(0)!");
        }
        let rhs_inv = pow(rhs, MODULUS - 2);
        return self * rhs_inv;
    }
}


Measured memory_bytes: 2152
from sys import stdin
from collections import deque

n, q = map(int,stdin.readline().split())
queries = stdin.readlines()
A = [deque() for _ in range(n)]

#count = 0
for query in queries:
    #print(count)
    #count += 1
    query = query.split()
    if query[0] == '0':
        A[int(query[1])].append(query[2])
    elif query[0] == '1':
        print(' '.join(list(A[int(query[1])])))
    else:
        A[int(query[1])].clear()




Measured memory_bytes: 81760
// package other2017.codefestival2017.quala;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        
        boolean isok = false;
        for (int r = 0 ; r <= n ; r++) {
            for (int c = 0 ; c <= m ; c++) {
                int w = r * m + c * n - r * c * 2;
                if (w == k) {
                    isok = true;
                }
            }
        }

        out.println(isok ? "Yes" : "No");
        out.flush();
    }

    public static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }

    public static class InputReader {
        private static final int BUFFER_LENGTH = 1 << 12;
        private InputStream stream;
        private byte[] buf = new byte[BUFFER_LENGTH];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int next() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            return (char) skipWhileSpace();
        }

        public String nextToken() {
            int c = skipWhileSpace();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public long nextLong() {
            int c = skipWhileSpace();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            return Double.valueOf(nextToken());
        }

        int skipWhileSpace() {
            int c = next();
            while (isSpaceChar(c)) {
                c = next();
            }
            return c;
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}

Measured memory_bytes: 21460
from queue import deque
 
    
S = deque(input())
y = 2019
U = [0] * y
t = 0
U[0] = 1
k = 1

for s in reversed(S):
    t = t + int(s) * k
    t %= y
    U[t] += 1
    k *= 10
    k %= y

cnt = 0
for u in U:
    cnt = cnt + u * (u - 1) // 2

print(cnt)

Measured memory_bytes: 10848
/*
{

AuThOr Gwj
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define int LL
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int n,a[200000+20];
double a_[200000+20];
int all[65][65];
signed main(){
	fastio;
	R(n);
	LL res=0;
	rb(i,1,n){
		R(a_[i]);
		;
		a[i]=llround(a_[i]*=1000000000.0);
		int A,B;
		A=B=0;
		while(a[i]%5==0){
			a[i]/=5;
			A++;
		}
		while(a[i]%2==0){
			a[i]/=2;
			B++;
		}
//		cout<<A<<" "<<B<<endl;
		rb(k,0,64)
			rb(j,0,64){
				if(k+A>=18&&j+B>=18){
					res+=all[k][j];
				}
		}
		all[A][B]++;
	}	
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 6796
N = int(input())
A = list(map(int, input().split()))

a = []
i = 1
while True:
  if A[0] % i == 0:
    a += [i, A[0]//i]
  i += 1
  if i**2 > A[0]:
    break
    
b = []
i = 1
while True:
  if A[1] % i == 0:
    a += [i, A[1]//i]
  i += 1
  if i**2 > A[1]:
    break
#print(a, b)
ans = 1
for i in a:
  counter = 0
  for p in A:
    if p % i == 0:
      counter += 1
  if counter >= N-1:
    ans = max(ans, i)
for i in b:
  counter = 0
  for p in A:
    if p % i == 0:
      counter += 1
  if counter >= N-1:
    ans = max(ans, i)
      
print(ans)

Measured memory_bytes: 63856
#include <algorithm>
#include <bitset>
#include <iostream>
#include <vector>

using namespace std;

inline int popcount(int x) {
  int ret{};
  while (x) ret += x % 2, x >>= 1;
  return ret;
}

int main() {
  int N;
  cin >> N;
  string X;
  cin >> X;
  int p = count(begin(X), end(X), '1') - 1, r = p + 2;

  if (p == -1) {
    for (int i = 0; i != N; ++i) {
      cout << 1 << endl;
    }
    return 0;
  } else if (!p) {
    // only a bit is 1
    int f = X.find('1');
    if (f == N - 1) {
      for (int i = 0; i != N; ++i) {
        cout << (i != f) << endl;
      }
    } else {
      for (int i = 0; i != N; ++i) {
        if (i==f) cout << 0 << endl;
        else if (i == N-1) {
          cout << 2 << endl;
        } else {
          cout << 1 << endl;
        }
      }
    }
    return 0;
  }

  vector<int> a(N), b(N);
  a[0] = b[0] = 1;
  for (int i = 1; i < N; ++i) {
    a[i] = (2 * a[i - 1]) % p;
    b[i] = (2 * b[i - 1]) % r;
  }

  int x{}, y{};
  for (int i = 0; i != N; ++i) {
    x = (x + a[N - 1 - i] * (X[i] - '0')) % p;
    y = (y + b[N - 1 - i] * (X[i] - '0')) % r;
  }

  for (int i = 0; i != N; ++i) {
    if (X[i] == '0') {
      int w = (y + b[N - 1 - i]) % r;
      int ans{1};
      while (w) w %= popcount(w), ++ans;
      cout << ans << endl;
    } else {
      int w = (x + p - a[N - 1 - i]) % p;
      int ans{1};
      while (w) w %= popcount(w), ++ans;
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 5244
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
using std::cin; using std::cout;
using std::endl;
using std::bitset; using std::map;
using std::queue; using std::priority_queue;
using std::set; using std::string;
using std::stringstream; using std::vector;
using std::pair; using std::make_pair;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<ULL, ULL> puu;
#ifdef DEBUG
using std::cerr;
#define pass cerr << "[" << __FUNCTION__ << "] : line = " << __LINE__ << endl;
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)                                                     \
  {                                                                            \
    cerr << #a << " = {";                                                      \
    for (int qwq = (st); qwq <= (n); ++qwq)                                    \
      if (qwq == (st))                                                         \
        cerr << a[qwq];                                                        \
      else                                                                     \
        cerr << ", " << a[qwq];                                                \
    cerr << "}" << endl;                                                       \
  }
#define displayv(a) displaya(a, 0, (int)(a.size() - 1))
#include <ctime>
class MyTimer {
    clock_t st;
public:
    MyTimer() { cerr << std::fixed << std::setprecision(0); reset(); }
    ~MyTimer() { report(); }
    void reset() { st = clock_t(); }
    void report() {  cerr << "Time consumed: " << (clock() - st) * 1e3 / CLOCKS_PER_SEC << "ms" << endl; }
} myTimer;
#else
#define cerr if(false) std::cout
#define pass ;
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(a) ;
class MyTimer {
public: void reset() {} void report() {}
} myTimer;
#endif

template<typename A, typename B>
std::ostream& operator << (std::ostream &cout, const pair<A, B> &x) {
    return cout << "(" << x.first << ", " << x.second << ")";
}
template<typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) { return a > b ? a = b, true : false; }
template<typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) { return a < b ? a = b, true : false; }

LL K, A, B;

int main() {
    cin >> K >> A >> B;
    LL now = 1;
    if(A - now < K) {
        K -= (A - now);
        now = A;
    } else {
        now += K;
        cout << now << endl; return 0;
    }
    if(A + 2 < B) {
        now += (B - A) * (K / 2);
        K -= K / 2 * 2;
    }
    now += K; K = 0;
    cout << now << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N;
    int cnt[100010] = {};
    cin >> N;
    for(int i = 0;i < N;i++){
        int a;
        cin >> a;
        cnt[a]++;
    }
    for(int i = 1;i <= 100000;i++){
        if(!cnt[i])continue;
        cnt[i] = (cnt[i]+1) % 2 + 1; 
    }
    int tcnt = 0,ans = 0;
    for(int i = 1;i <= 100000;i++){
        if(cnt[i] == 2)tcnt++;
        ans += cnt[i];
    }
    ans -= tcnt + (tcnt&1);
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){

 int a,b,c,x=0;
      scanf("%d %d %d",&a,&b,&c);
  while(a!=b){
      if(c%a==0){
            x++;
      }
           a++;
  }
  if(a==b){
     if(c%a==0){
      x++;
      }
   }
      printf("%d\n",x);

}




Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    map<ll,ll> mp;
    vector<pair<ll,ll>> ab;
    rep(i,n){
        ll a,b;cin>>a>>b;
        mp[a] += b;
        ab.emplace_back(a,b);
    }
    function<ll(ll)> solve = [&](ll b){
        ll res;
        if(b>1){res = solve(b-1);}
        else{
            res = 0;
            rep(i,n){
                if((k|ab[i].first)==k){
                    res += ab[i].second;
                }
            }
        }
        if((k>>(b-1)&1)==0){
            return res;
        }
        ll bit = 1LL<<(b-1);
        ll mask = ((1LL<<32)-1)&k^bit|(bit-1);
        DEBUG{
            printf("mask: %lld\n",mask);
        }
        ll tmp=0;
        rep(i,n){
            if((mask|ab[i].first)==mask){
                tmp += ab[i].second;
            }
        }
        return max(res, tmp);
    };
    cout << solve(32) << endl;
    return 0;
}


Measured memory_bytes: 8048
//##MohK..
//22/05/2020   ...   5,00
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a;
    cin>>a;
    ll c=a%10;
    if(c==2||c==4||c==5||c==7||c==9)cout<<"hon"<<endl;
    else if(c==0||c==1||c==8||c==6)cout<<"pon"<<endl;
    else if(c==3)cout<<"bon"<<endl;

    return 0;
}



Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
#define MP make_pair
#define PB push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
#define mod 1000000007

int a[200005],b[200005];
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	f(i,0,n)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(&b[0],&b[n]);
	f(i,0,n)
	{
		if(a[i]==b[n-1])
		{
			cout<<b[n-2]<<'\n';
		}
		else
		{
			cout<<b[n-1]<<'\n';
		}
	}
	return 0;
}

Measured memory_bytes: 4736
#include<stdio.h>
int main(){
    int a,b,c,i=3;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b){
        i--;
    }
    if(a==c){
        i--;
    }
    if(b==c){
        i--;
    }

    if(i==0){
        printf("1\n");
    }
    else{
        printf("%d\n",i);
    }
    return 0;
}

Measured memory_bytes: 128