akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr); 
	cout.setf(ios::fixed); 
	cout.precision(20);

	/*ll n, m;
	cin >> n >> m;
	vi a(n), b(n), c(n), maxa;
	rep(i, n) {
		cin >> a[i] >> b[i] >> c[i];
	}
	rep(i, n-2) {
		ll im;
		REP(j,i+2,n) {
			cout << i << " " << (j - i) << " " << j << " ";
			cout << a[i] << " " << b[(j - i) ] << " " << c[j] << endl;
			im = a[i] + b[i + (j - i)] + c[j];
			maxa.pb(abs(im));
		}
	}
	sort(reall(maxa));
	ll ans = 0;
	rep(i, m) ans += maxa[i];
	cout << ans << endl;*/
	ll n, ans=0,a,b;
	string s;
	cin >> a >> b;
	if (b == 100) b++;
	if (a == 0) {
		cout << b;
	}
	else {
		ans = (int)pow(100, a) * b;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 5001;
const int MOD = (int)1e9 + 7;

char s[N];
int two[N], dp[2][N];

void update(int& x, int a)
{
    x += a;
    if (x >= MOD) {
        x -= MOD;
    }
}

int main()
{
    two[0] = 1;
    for (int i = 1; i < N; ++ i) {
        two[i] = two[i - 1] * 2 % MOD;
    }
    int m;
    scanf("%d%s", &m, s);
    int n = strlen(s);
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int i = 0; i < m; ++ i) {
        memset(dp[i + 1 & 1], 0, sizeof(dp[i + 1 & 1]));
        for (int j = 0; j <= m; ++ j) {
            update(dp[i + 1 & 1][std::max(j - 1, 0)], dp[i & 1][j]);
            if (j < m) {
                update(dp[i + 1 & 1][j + 1], dp[i & 1][j] * 2);
            }
        }
    }
    int result = dp[m & 1][n];
    for (int i = 0; i < n; ++ i) {
        result = result * 500000004LL % MOD;
    }
    printf("%d\n", result);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  	string S;
 
  	cin >> S;
  	for (int i = 1; i < 3; i++) {
      if (S[0] != S[i]) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  
	
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 24.12.2019 19:44:51       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  vector<long long> sub(1 << n);
  for (int t = 1; t < (1 << n); t++) {
    int i = 0;
    while (!(t & (1 << i))) {
      ++i;
    }
    sub[t] = sub[t ^ (1 << i)];
    for (int j = i + 1; j < n; j++) {
      if (t & (1 << j)) {
        sub[t] += a[i][j];
      }
    }
  }
  vector<long long> dp(1 << n);
  for (int t = 1; t < (1 << n); t++) {
    int i = 0;
    while (!(t & (1 << i))) {
      ++i;
    }
    int nt = t ^ (1 << i);
    int u = nt;
    while (true) {
      dp[t] = max(dp[t], dp[t ^ (1 << i) ^ u] + sub[(1 << i) ^ u]);
      if (u == 0) {
        break;
      }
      u = (u - 1) & nt;
    }
  }
  cout << dp.back() << '\n';
  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main()
{
	int A, B, N;
	cin >> N >> A >> B;
	if (N == 1)
	{
		if (A == B)
			printf("1\n");
		else
			printf("0\n");
	}
	else
	{
		if (A > B)
			printf("0\n");
		else
			cout<<(long long)(B - A)*(N - 2) + 1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
countr = 0
countl = 0
r = [0 for i in range(n-1)]
l = [0 for i in range(n-1)]
for i in range(n-1):
    if s[i] == 'W':
        countr += 1
    if s[n-i-1] == 'E':
        countl += 1
    r[n-i-2] = countr
    l[i] = countl
mi = min(countl,countr)
for i in range(n-1):
    mi = min(mi,r[i]+l[i])
print(mi)


Measured memory_bytes: 17868
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

std::vector<int> Z_construct(const std::string& S){
  int ns = S.size();
  std::vector<int> Z(ns);
  int L = 0, R = 0;
  for(int i = 0; i < ns; i++){
    if(i > R){
      L = R = i;
      while(R < ns && S[R-L] == S[R]) R++;
      Z[i] = R-L;
      R--;
    }else{
      int k = i-L;
      if(Z[k] < R-i+1){
        Z[i] = Z[k];
      }else{
        L = i;
        while(R < ns && S[R-L] == S[R]) R++;
        Z[i] = R-L;
        R--;
      }
    }
  }
  return Z;
}

std::vector<int> Z_alg(const std::string& S, const std::string& T){
  std::string C = T+"$"+S;
  auto Z = Z_construct(C);
  std::vector<int> ans(S.size());
  for(int i = 0; i < C.size(); i++){
    if(Z[i] == T.size()){
      ans[i-T.size()-1] = 1;
    }
  }
  return ans;
}

int main(){
  std::string S,T;
  std::cin >> S;
  std::cin >> T;

  int ns = S.size(), nt = T.size();
  std::string S2(S);
  while(S2.size() < ns+nt-1){
    S2 += S;
  }
  std::vector<int> f_arr = Z_alg(S2, T);
  std::vector<int> l_arr(ns);
  int ans = 0;
  for(int ni = 0; ni < ns; ni++){
    if(f_arr[((ni-nt)%ns+ns)%ns] == 1) continue;
    int n = ni, i = 0;
    while(true){
      l_arr[n] = 1;
      if(f_arr[n] == 0) break;
      n = (n+T.size())%S.size();
      i++;
    }
    ans = std::max(ans, i);
  }
  for(int i = 0; i < ns; i++){
    if(l_arr[i] == 0){
      std::cout << -1 << std::endl;
      return 0;
    }
  }
  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 18868
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

struct UnionFind{
    v: Vec<usize>
}

impl UnionFind{
    fn new(n: usize) -> UnionFind{
        let mut v: Vec<usize> = Vec::new();
        for i in 0..n{
         v.push(i);
        }
        UnionFind{v:v}
    }

    fn find(&mut self, i: usize) -> usize{
        if self.v[i] == i{
            i
        }else{
            let ni = self.v[i];
            self.v[i] = self.find(ni);
            self.v[i]
        }
    }

    fn union(&mut self, i: usize, j: usize){
        let root_i = self.find(i);
        let root_j = self.find(j);
        self.v[root_i] = root_j;
    }
    
}

fn main(){
    let n: usize = read_as_vec()[0];
    let heights: Vec<i32> = read_as_vec();
    let mut ans = 1;

    for i in 1..n{
        let mut is_ans = true;
        for j in 0..i{
            if heights[i] < heights[j]{
                is_ans = false;
            }
        }

        if is_ans{
            ans += 1;
        }
    }
    println!("{}", ans);
    
}


Measured memory_bytes: 4352
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

if n >= m:
    print(0)
    exit()
    
sub = [0]*(m-1)
for i in range(m-1):
    sub[i] = x[i+1] - x[i]
sub.sort()

ass = 0
for i in range(m-n):
    ass += sub[i]
print(ass)

Measured memory_bytes: 13968
a, b, c = input(), input(), input()
req = a
a = a[1:]
ans = ""
while True:
    if req[:1] == "a":
        ans = "A"
        req = a
        a = a[1:]
    elif req[:1] == "b":
        ans = "B"
        req = b
        b = b[1:]
    else:
        ans = "C"
        req = c
        c = c[1:]
    if not req:
        break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll b[2010],a[2010];
int main()
{
    ll i,j,k,m,n,x;
    ll cnt,ans=1ll * 2010 * 1e9;
    memset(a,0x3f,sizeof(a));
    cin>>n>>x;
    for(i=0; i<n; i++)
        cin>>b[i];
    for(i=0; i<n; i++)
    {
        cnt=0;
        for(j=0; j<n; j++)
            a[j]=min(a[j],b[(j-i+n)%n]);
        for(j=0; j<n; j++)
            cnt+=a[j];
        ans=min(ans,i*x+cnt);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n; cin >> n;
	int t[100];
	int sum = 0;
	rep(i, n) {
		cin >> t[i]; sum += t[i];
	}
	int m; cin >> m;
	rep(i, m) {
		int p, x; cin >> p >> x; p--;
		cout << sum + x - t[p] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
let rec loop array =
  let line,eof = try read_line (), false with End_of_file -> "", true in
  if eof then
    begin
      Array.iteri (fun i n -> Printf.printf "%c : %d\n" (Char.chr (i + (Char.code 'a'))) n) array;
      flush stdout;
    end
  else
    begin
      let input = String.lowercase line in
      String.iter (fun char ->
          let index = (Char.code char) - (Char.code 'a') in
          if 0 <= index && index < 26 then
            begin
              let n = Array.get array index in
              Array.set array index (n+1)
            end
          else ()
        ) input;
      loop array
    end
;;

let () =
      let array = Array.make 26 0 in
      loop array;;


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

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

Measured memory_bytes: 3592
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = [0 for _ in range(n)]
f[0] = 1

v = [1]
s = 0
idx = 0
loop = 0
last = 1
for i in range(k):
    vi = a[last - 1]
    if not f[vi - 1]:
        f[vi - 1] = 1
        last = vi
        s += 1
        v.append(vi)
    else:
        s += 1
        idx = v.index(vi)
        loop = s - idx
        break
else:
    print(vi)
    exit()
remain = k - s
print(v[idx:][remain % loop])


Measured memory_bytes: 112632
#include <iostream>

int main()
{
    uint64_t m, n, q = 1000000007, nl;
    std::cin >> m >> n;

    uint64_t r = 1;
    int64_t j = 1;
    while (j <= n)
    {
        if ((j & n) != 0)
        {
            r = (r * m) % q;
        }
        j *= 2;
        m = (m * m) % q;
    }
    std::cout << r << "\n";
    return 0;
}



Measured memory_bytes: 3120
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = n / 15 * 200;

        System.out.println(800 * n - y);
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


Measured memory_bytes: 21332
use std::io::{stdin, Read};

fn main() {
    println!("{}", solve(&get_param()));
}

fn get_param() -> Vec<u32> {
    let mut s = String::new();
    let stdin = stdin();
    stdin.lock().read_to_string(&mut s).ok();
    s.split_whitespace()
        .skip(1)
        .map(|a| a.parse().unwrap())
        .collect()
}

fn solve(v: &[u32]) -> u32 {
    v.iter().map(|a| a.trailing_zeros()).min().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
int N,K;
string D[10];

int main(){
    cin >> N >> K;
    rep(i,K) cin >> D[i];
    int n = N;
    
    while(1){
        string S = to_string(n);
        bool flag = true;
        rep(i,K) if(S.find(D[i]) != -1) flag = false;
        if(flag) break;
        n++;
    }
    
    cout << n << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = Integer.parseInt(sc.next());
        int W = Integer.parseInt(sc.next());

        String[] F = new String[H];
        for (int h = 0; h < H; h++) {
            F[h] = sc.next();
        }

        Graph g = new Graph(H, W, F);
        int res = 0;
        for (int h = 0; h < H; h++) {
            for (int w = 0; w < W; w++) {
                if (F[h].charAt(w) != '.') {
                    continue;
                }
                
                int r = g.wfs(h, w);
                if (r > res) {
                    res = r;
                }
            }
        }
        
        System.out.println(res);
    }
}

class Graph {
    private int H;
    private int W;
    private String[] F;
    
    public Graph(int H, int W, String[] F) {
        this.H = H;
        this.W = W;
        this.F = F;
    }
    
    class Node {
        public int h;
        public int w;
        public int c;

        public Node(int h, int w, int c) {
            this.h = h;
            this.w = w;
            this.c = c;
        }
    }
    
    public int wfs(int h0, int w0) {
        int[][] cost = new int[H][W];
        for (int h = 0; h < H; h++) {
            Arrays.fill(cost[h], -1);
        }
        
        Queue<Node> q = new ArrayDeque<>();
        q.add(new Node(h0, w0, 0));
        while (!q.isEmpty()) {
            Node n = q.poll();
            int h = n.h;
            int w = n.w;

            if (cost[h][w] != -1) {
                continue;
            }
            
            cost[h][w] = n.c;
            
            if (h != 0 && F[h - 1].charAt(w) == '.' && cost[h - 1][w] == -1) {
                q.add(new Node(h - 1, w, n.c + 1));
            }

            if (h != H - 1 && F[h + 1].charAt(w) == '.' && cost[h + 1][w] == -1) {
                q.add(new Node(h + 1, w, n.c + 1));
            }            

            if (w != 0 && F[h].charAt(w - 1) == '.' && cost[h][w - 1] == -1) {
                q.add(new Node(h, w - 1, n.c + 1));
            }           
            
            if (w != W - 1 && F[h].charAt(w + 1) == '.' && cost[h][w + 1] == -1) {
                q.add(new Node(h, w + 1, n.c + 1));
            } 
        }
        
        int res = 0;
        for (int h = 0; h < H; h++) {
            int r = Arrays.stream(cost[h]).max().getAsInt();
            if (r > res) {
                res = r;
            }
        }
        
        return res;
    }
}




Measured memory_bytes: 37976
#include <iostream>
using namespace std;
int main()
{
    long long int ac = 0;
    long long int wa = 0;
    long long int tle = 0;
    long long int re = 0;
    long long int n;
    cin >> n;
    for (long long int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if (s == "AC")
        {
            ac++;
        }
        else if (s == "WA")
        {
            wa++;
        }
        else if (s == "TLE")
        {
            tle++;
        }
        else
        {
            re++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int W, H;

pll dfs(int x, int y, bool isWhite, vector<vector<char>> &mp,
        vector<vector<int>> &used) {
    used[y][x] = 1;
    pll ret = MP(mp[y][x] == '.', mp[y][x] == '#');
    rep(i, 4) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(0 <= nx && nx < W && 0 <= ny && ny < H && used[ny][nx] == 0) {
            if((isWhite && (mp[ny][nx] == '.')) ||
               (!isWhite && (mp[ny][nx] == '#')))
                continue;
            if(mp[ny][nx] == '.') {
                pll tmp = dfs(nx, ny, 1, mp, used);
                ret.first += tmp.first;
                ret.second += tmp.second;
            } else {
                pll tmp = dfs(nx, ny, 0, mp, used);
                ret.first += tmp.first;
                ret.second += tmp.second;
            }
        }
    }
    return ret;
}

int main() {
    cin >> H >> W;
    vector<vector<char>> S(H, vector<char>(W));
    rep(i, H) rep(j, W) cin >> S[i][j];
    vector<vector<int>> used(H, vector<int>(W, 0));

    ll res = 0;
    rep(i, H) rep(j, W) {
        if(used[i][j] == 0) {
            bool isWhite = (S[i][j] == '.');
            // cout << i << " : " << j << " : isWhite: " << isWhite << endl;
            pll a = dfs(j, i, isWhite, S, used);
            res += a.first * a.second;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 16000
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    K = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    c=1
    for _ in range(N):
        c=min(c+K,c*2)
    print(c)



if __name__ == "__main__":
    main()

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int z = d - b;
    if(z < 0) 
    {
    	z += 60;
    	c--;
    }
    z += (c-a)*60;
    cout << z - e<< "\n";
    return 0;
}



Measured memory_bytes: 3692
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

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

using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

long long int check(long long int p,vector<int> &load){
	long long int s = 0;
	long long int k = 1;
	rep(i, load.size())
	{
		s += load[i];
		if (s > p)
		{
			s = load[i];
			k++;
			if (s > p)
				return Inf;
		}
	}
	return k;
}

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> load(n);
	rep(i, n) cin >> load[i];
	long long int l = 0;
	long long int r = 1e18;
	while(l + 1 < r){
		long long int mid = (l + r) / 2;
		if (check(mid,load) > k){
			l = mid;
		} else {
			r = mid;
		}
	}
	cout << r << endl;

	return 0;
}




Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)

ll modPow(ll base, ll ex, ll m) {
	ll ret = 1;
	while(ex){
		if(ex & 1){
			ret = ret * base % m;
		}
		ex >>= 1;
		base = base * base % m;
	}
	return ret;
}

int main(){
    int n; cin >> n;
    map<int, int> mp;
    for(int i=0;i<n;i++){
        int a; cin >> a;
        mp[a]++;
    }
    bool zero = false;
    if(n % 2 == 0){
        for(int i=1;i<n;i+=2){
            if(mp[i] != 2){
                zero = true;
                break;
            }
        }
    }else{
        if(mp[0] != 1){
            zero = true;
        }
        for(int i=2;i<n;i+=2){
            if(mp[i] != 2){
                zero = true;
                break;
            }
        }
    }
    cout << (zero ? 0 : modPow(2, n / 2, M)) << '\n';
    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>


using namespace std;


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

	char tmp;

	vector<vector<int>> N(H + 2, vector<int>(W + 2));
	vector<vector<char>> ans(H, vector<char>(W));

	for (int i = 0; i <= H + 1; i++) {
		for (int j = 0; j <= W + 1; j++) {
			if (i == 0 || j == 0 || i == H + 1 || j == W + 1) {
				N[i][j] = 0;
			}
			else {
				cin >> tmp;
				if (tmp == '.') {
					N[i][j] = 0;
				}
				else {
					N[i][j] = 1;
				}
			}
		}
	}

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (N[i][j] == 1) {
				ans[i - 1][j - 1] = '#';
			}
			else {
				TMP = 0;
				for (int x = -1; x <= 1; x++) {
					for (int y = -1; y <= 1; y++) {
						TMP += N[i + x][ j + y];
					}
				}
				ans[i - 1][j - 1] = TMP + 48;
			}
		}
	}


	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << ans[i][j];
		}
		cout << "\n";
	}

	return 0;
}


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

int main(int argc , char* argv[]){
	int r , d , x2000;
	cin  >> r >> d >> x2000;
	vector<int> v;
	v.push_back(x2000);
	for(int i=0;i<=10;++i){
		v.push_back(v[i]*r-d);
	}
	for(int i=1;i<=10;++i){
		cout << v[i] << endl;
	}
}
	

Measured memory_bytes: 256
n = int(input())
c_list = []
s_list = []
f_list = []
for _ in range(n-1):
    c, s, f = list(map(int,input().split()))
    c_list.append(c)
    s_list.append(s)
    f_list.append(f)

for i in range(n):
    t = 0
    for j in range(i,n-1):
        c = c_list[j]
        s = s_list[j]
        f = f_list[j]
#         print(c,s,f)
        if t < s:
            t = s
        elif t%f == 0:
            pass
        else:
            t = f * (t//f+1)
        t += c
        
    print(t)

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

using namespace std;

int main(){


int n;
cin >> n;
int a = n%10;


if(a == 3){
	cout << "bon" <<endl;
}

else if(a == 0|| a== 1|| a==6|| a== 8){
	cout << "pon" <<endl;
}
else{
	cout << "hon" <<endl;
}
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
char s[200010];
int main() {
    scanf("%s",s+1);
    int n=strlen(s+1);
    long long ans=0;
    for(int i=n,j=0;i;i--) {
	if(s[i]=='W') ++j;
	else ans+=j;
    }
    cout<<ans;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int>A(N);
    for (int i = 0; i < N; i++) cin >> A.at(i);
    int Q;
    cin >> Q;
    vector<int>S(Q);
    for (int i = 0; i < Q; i++) cin >> S.at(i);
    vector<long long>Sum((1 << N), 0);
    for (int i = 0; i < (1 << N); i++) {
        for (int j = 0; j < N; j++) {
            if ((i >> j) & 1) Sum.at(i) += A.at(j);
        }
    }
    for (int i = 0; i < Q; i++) {
        bool check = false;
        for (int j = 0; j < (1 << N); j++) {
            if (Sum.at(j) == S.at(i) && !check) {
                cout << "yes" << endl;
                check = true;
            }
        }
        if (!check) {
            cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 10924
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  cout << max(A*B, C*D) << endl;
  
  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
#define allsortg(v)sort(v.begin(),v.end(),greater<int>());
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int>a(N);
	rep(i, N)cin >> a[i];
	int c2 = 0, c4 = 0;
	rep(i, N) {
		if (a[i] % 4 == 0)c4++;
		else if (a[i] % 2 == 0)c2++;
	}
	if (c2 % 2 != 0)c2--;
	N -= c2 + c4;
	N -= c4 + 1;
	if (N <= 0)cout << "Yes" << "\n";
	else cout << "No" << "\n";
	
	return 0;
}

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


int main(){
	int a,b,ans=0;
	cin >> a >> b;
	if(a==1) ans+=300000;
	if(b==1) ans+=300000;
	if(a==2) ans+=200000;
	if(b==2) ans+=200000;
	if(a==3) ans+=100000;
	if(b==3) ans+=100000;
	if(a==1&&b==1) ans+=400000;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val t = (1..5).map {
        val x = sc.nextInt()
        val mod = if (x % 10 == 0) 10 else x % 10
        Pair(mod, x)
    }.sortedBy { it.first }

    val sum = t.map { it.second + (10 - it.first) }.sum() - (10 - t[0].first)
    println(sum)
}

Measured memory_bytes: 35916
#include<stdio.h>
#include<string.h>
int main(){
	char A[11],B[11],C[11],a,b,c;
	int a1,b1,c1;

	scanf("%s %s %s",A,B,C);
	a1=strlen(A);
	b1=strlen(B);
	c1=strlen(C);
	if(A[a1-1]==B[0]&&B[b1-1]==C[0]){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int K = sc.nextInt();
		int[] map = new int[H];
		for (int i = 0; i < H; i++) {
			String s = sc.next();
			for (int j = 0; j < W; j++) {
				map[i] = map[i] * 2 + (s.charAt(j) == '#' ? 1 : 0);
			}
		}
		int ans = 0;
		for (int S = 0; S < 1 << W; S++) {
			int[] dp = new int[K + 1];
			dp[0] = 1;
			for (int i = 0; i < H; i++) {
				int[] ndp = new int[K + 1];
				int off = Integer.bitCount(~S & map[i]);
				int on = 0;
				for (int j = 0; j <= K; j++) {
					if (j + off <= K) {
						ndp[j + off] += dp[j];
					}
					ndp[j + on] += dp[j];
				}
				dp = ndp;
			}
			ans += dp[K];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35808
#include <cstdio>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
#define MINF -1e12

vector<pair <int, long long> > v[100001];
long long d[100001];

int s(int i){
  int val = 0;
  for (int j = 0; j < v[i].size(); j++){
    if (d[v[i][j].first] == MINF) {
      d[v[i][j].first] = d[i] + v[i][j].second;
      val += s(v[i][j].first);
    }
    else {
      if (d[v[i][j].first] != d[i] + v[i][j].second){
        return -1;
      }
    }
  }
  return val;
}

int main(){


  int n, m;
  cin >> n >> m;
  for (int cas = 0; cas < m; cas++){
    int l, r; long long d;
    cin >> l >> r >> d;
    v[l].push_back(make_pair(r, d));
    v[r].push_back(make_pair(l, -d));
  }

  for (int i = 0; i < n; i++){
    d[i+1] = MINF;
  }

  int u;
  for (int i = 1; i <= n; i++){
    if (d[i] == MINF) {
      d[i] = 0;
      u = s(i);
    }
    if (u < 0){
      printf("No\n");
      return 0;
    }
  }


  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 17408
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

n, k = map(int, input().split())

c = Base_10_to_n(n, k)

print(len(str(c)))


Measured memory_bytes: 2940
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		int K = Integer.parseInt(in.readLine());
		String S = in.readLine();
		if (K >= S.length()) {
			System.out.println(S);
		} else {
			StringBuilder strBuilder = new StringBuilder();
			strBuilder.append(S.substring(0, K));
			for (int i = 0; i < 3; ++i) {
				strBuilder.append(".");
			}
			System.out.println(strBuilder.toString());
		}

	}

	void calc() {
	}

	void showResult() {
	}

}


Measured memory_bytes: 32364
#! /usr/bin/env python3
import sys
sys.setrecursionlimit(10**9)


INF=10**20
class Counter:
    def __init__(self):
        self.dict = {}

    def add(self,x):
        if x in self.dict: self.dict[x] += 1
        else: self.dict[x] = 1

    def decrement(self,x):
        self.dict[x] -= 1
        if self.dict[x] <= 0:
            del self.dict[x]

    def get_dict(self):
        return self.dict



def solve(N: int, S: "List[str]"):
    counter = Counter()
    for s in S:
        counter.add(s)
    
    print(len(counter.get_dict().keys()))
        
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)



if __name__ == "__main__":
    main()


Measured memory_bytes: 130368
s = input()
s_1 = int(s[:2])
s_2 = int(s[2:])
if 0 < s_1 < 13:
    if 0 < s_2 < 13:
        ans = 'AMBIGUOUS'
    else:
        ans = 'MMYY'
else:
    if 0 < s_2 < 13:
        ans = "YYMM"
    else:
        ans = "NA"
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    int a, mini=1e9, ans, cur;
    cin>>a;
    int arr[a];
    for (int i=0; i<a; i++) cin>>arr[i];
    for (int i=1; i<=100; i++){
        cur=0;
        for (int j=0; j<a; j++){
            cur+=abs(arr[j]-i)*abs(arr[j]-i);
        }
        if (cur<mini) mini=cur;
    }
    cout<<mini<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict
import math
n = int(input())

def primelist(num):
    if num < 2:
        return []

    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]

def prime_factorization(num):
    if num <= 1:
        return False
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = primelist(num_sqrt)

        dict_counter = defaultdict(int)
        for prime in prime_list:
            while num % prime == 0:
                dict_counter[prime] += 1
                num //= prime
        if num != 1:
            dict_counter[num] += 1

        dict_counter = dict(dict_counter)

        return dict_counter

def search_divisor_num(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        divisor_num = 1
        dict_fact = prime_factorization(num)
        for value in dict_fact.values():
            divisor_num *= (value + 1)
        return divisor_num

cnt = 0
for i in range(1, n+1):
    if i%2 != 0:
        if search_divisor_num(i) == 8:
            cnt+=1
print(cnt)

exit(0)

Measured memory_bytes: 3444
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back

main(){
  int n;
  cin>>n;
  while(n--){
    string str;
    cin>>str;
    set<string> ans;

    for(int i=1;i<str.size();i++){
      string l,r;
      l=str.substr(0,i);
      r=str.substr(i,str.size()-i);
      ans.insert(l+r);
      ans.insert(r+l);
      reverse(l.begin(),l.end());
      ans.insert(l+r);
      ans.insert(r+l);
      reverse(l.begin(),l.end());
      reverse(r.begin(),r.end());
      ans.insert(l+r);
      ans.insert(r+l);
      reverse(l.begin(),l.end());
      ans.insert(l+r);
      ans.insert(r+l);
    }
    cout<<ans.size()<<endl;
  }
}

Measured memory_bytes: 1000
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll n;
map<string, ll> m;
int main() {
	cin >> n;
	REP(i, n) {
		string s;
		cin >> s;
		sort(ALL(s));
		m[s]++;
	}
	ll ans = 0;
	for (auto& i : m)
	{
		ans += i.second * (i.second - 1) / 2;
	}
	cout << ans << endl;
}
	

Measured memory_bytes: 11136
#ifndef ___Class_RangeTree
#define ___Class_RangeTree

// ------ Includes ------ //
#include <limits>
#include <vector>
#include <algorithm>

template<typename Type> class RangeTree {
private:
	int size_;
	std::vector<std::vector<Type> > dat;
	std::vector<std::vector<int> > vl;
	inline int query_(int a, int b, Type x, int k, int l, int r, int e) {
		// Find range [a, b) : value < x : Now k-th node and the range is [l, r) and e integers below x in the range
		if (r <= a || b <= l || e == 0) return 0;
		if (a <= l && r <= b) return e;
		int lc = query_(a, b, x, k << 1, l, (l + r) >> 1, vl[k][e - 1]);
		int rc = query_(a, b, x, k << 1 | 1, (l + r) >> 1, r, e - vl[k][e - 1]);
		return lc + rc;
	}
public:
	RangeTree() : size_(0), dat(std::vector<Type>()) {};
	template<class T>
	RangeTree(T begin_, T end_) {
		int n = (end_ - begin_);
		for (size_ = 1; size_ < n; size_ <<= 1);
		dat.resize(size_ << 1, std::vector<Type>());
		vl.resize(size_, std::vector<int>());
		for (int i = 0; i < n; i++) dat[i + size_].push_back(*(begin_ + i));
		for (int i = size_ - 1; i > 0; i--) {
			dat[i].resize(dat[i << 1].size() + dat[i << 1 | 1].size());
			vl[i].resize(dat[i].size());
			int cl = 0;
			for (int j = 0; j < dat[i].size(); j++) {
				if (j - cl == dat[i << 1 | 1].size() || (cl != dat[i << 1].size() && dat[i << 1][cl] < dat[i << 1 | 1][j - cl])) dat[i][j] = dat[i << 1][cl++];
				else dat[i][j] = dat[i << 1 | 1][j - cl];
				vl[i][j] = cl;
			}
		}
	}
	inline int size() { return size_; }
	inline int query(int l, int r, Type x) {
		// Find range [a, b) : value < x
		int ptr = lower_bound(dat[1].begin(), dat[1].end(), x) - dat[1].begin();
		return query_(l, r, x, 1, 0, size_, ptr);
	}
};

#endif

#include <cstdio>
#include <vector>
#pragma warning(disable : 4996)
using namespace std;
int N, Q, xl, yl, xr, yr;
int main() {
	scanf("%d%d", &N, &Q);
	vector<pair<int, int> > p(N);
	for (int i = 0; i < N; i++) scanf("%d%d", &p[i].first, &p[i].second);
	sort(p.begin(), p.end());
	vector<int> z1(N), z2(N);
	for (int i = 0; i < N; i++) {
		z1[i] = p[i].first;
		z2[i] = p[i].second;
	}
	RangeTree<int> seg(z2.begin(), z2.end());
	while (Q--) {
		scanf("%d%d%d%d", &xl, &yl, &xr, &yr);
		int ptr1 = lower_bound(z1.begin(), z1.end(), xl) - z1.begin();
		int ptr2 = lower_bound(z1.begin(), z1.end(), xr + 1) - z1.begin();
		int res1 = seg.query(ptr1, ptr2, yl);
		int res2 = seg.query(ptr1, ptr2, yr + 1);
		printf("%d\n", res2 - res1);
	}
	return 0;
}

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

int main() {
    // insert code here...
    int a,b;
    cin >> a >> b;
    
    if(a==b){
        
        cout << "Yes" << endl;
        
    }
    
    else {
        
        cout <<"No" << endl;
        
    }
}

Measured memory_bytes: 256
def gcd(a, b):
    if a < b:
        a, b = b, a
    while b != 0 :
        a, b = b, a % b
    return a

def lcm(a, b):
    return (a * b) // gcd(a, b)

a , b = map(int, input().split())
print(lcm(a, b))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <tuple>
#include <cmath>
#include <cassert>
#include <string>

using namespace std;

typedef long long ll;

ll f(ll b, ll n) {
  if (n < b) return n;
  return f(b, n/b) + n%b;
}

vector<int> V[100010];

int main() {
  ll n, s;
  cin >> n >> s;
  if (s == n) {
    cout << n+1 << endl;
    return 0;
  }
  ll sq = sqrt(n);
  // cerr << sq << endl;
  for (auto i = 2; i < sq+10; i++) {
    if (f(i, n) == s) {
      cout << i << endl;
      return 0;
    }
  }
  ll ans = 1000000000000;    
  for (ll p = 1; p < sq+10; p++) {
    ll q = s - p;
    ll b = (n - q)/p;
    if (0 <= q && q < b && p < b && f(b, n) == s) {
      ans = min(b, ans);
    }
  }
  if (ans == 1000000000000) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}

// V[138] : 100 118 133 144 154 157 188 199 205 287 664 749 859 885 1123 1288 1327 1684 1717 1990 2245 2432 2575 2653 3367 3979 4863 5149 6733 7294 7957 9725 14587 21880 29173 43759 87517 


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define LL long long

using namespace std;

const LL mod = 1e9+7;

LL fact[200010];
LL invfact[200010];

template <typename T>
T extgcd(T a, T b, T &x, T &y){
	if(b == 0){
		x = 1; y = 0; return a;
	}
	LL g = extgcd(b, a % b, x, y);
	LL nextx = y, nexty = x-(a/b)*y;
	x = nextx; y = nexty;
	return g;
}

LL nCr(int n, int r){
	LL ret = fact[n];
	(ret *= invfact[n-r]) %= mod;
	(ret *= invfact[r]) %= mod;
	return ret;
}

int main(){
	int H, W, A, B;
	LL ans = 0;
	cin >> H >> W >> A >> B;
	fact[0] = 1;
	for(LL i = 1; i <= 200000; ++i){
		fact[i] = (fact[i-1] * i) % mod;
	}
	for(LL i = 0; i <= 200000; ++i){
		LL x, y;
		LL g = extgcd(fact[i], mod, x, y);
		while(x < 0) x += mod;
		x %= mod;
		invfact[i] = x;
	}
	for(LL x = B+1; x <= W; ++x){
		(ans += (nCr(x+(H-A)-2,(H-A)-1) * nCr(A+(W-x+1)-2,A-1)) % mod) %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int q;cin>>q;
    map<string,int> mp;
    rep(i,0,q){
        int cmd;cin>>cmd;
        if(cmd==0){
            string key;int x;cin>>key>>x;
            mp[key]=x;
        }else {
            string key;cin>>key;
            cout<<mp[key]<<endl;
        }
    }
    
    
}



/*

*/



Measured memory_bytes: 27736
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int x,y,ans=2000000003;
  scanf("%d %d",&x,&y);
  if(x<=y)
    ans=y-x;
  if(-1*x<=y)
    ans=min(ans,y+x+1);
  if(x<=-1*y)
    ans=min(ans,-1*y-x+1);
  if(-1*x<=-1*y)
    ans=min(ans,-1*y+x+2);
  printf("%d\n",ans);
}
  

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

int main(){
  int a,b; cin >> a >> b;
  string ret;

  //string sa ,sb;
  if(a<=b){
    rep(i,b){
      ret+=to_string(a);
    }
  }else{
    rep(i,a){
      ret+=to_string(b);
    }
  }
  cout << ret;

}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (w, h, n) = readLine()!!.split(" ").map(String::toInt)
    var top = h
    var bottom = 0
    var left = 0
    var right = w
    for (i in 1..n) {
        val (x, y, a) = readLine()!!.split(" ").map(String::toInt)
        if (a == 1 && left < x) {
            left = x
        } else if (a == 2 && x < right) {
            right = x
        } else if (a == 3 && bottom < y) {
            bottom = y
        } else if (a == 4 && y < top) {
            top = y
        }
    }
    val height = top - bottom
    val width = right - left
    val area = if (height <= 0 || width <= 0) 0 else height * width
    println(area)
}


Measured memory_bytes: 37928
#include<bits/stdc++.h>
using namespace std;
int a,b,c,len;
int main()
{
    cin>>a>>b;c=b;
    while(c){
        c/=10,len++;
    }
    a=a*pow(10,len)+b;
    if(sqrt(a)==floor(sqrt(a)))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s;
  std::cin >> s;

  int count0 = 0;
  int count1 = 0;
  for(int idx = 0; idx < s.size(); idx++){
    if(s.at(idx) == '0'){
      count0 += 1;
    }else{
      count1 += 1;
    }
  }

  std::cout << min(count0, count1) * 2 << '\n';

  return 0;
}


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

using namespace std;

int main() {
	vector<int> num;
	int n;
	for(int i=0; i<5; i++)cin>>n,num.push_back(n);
	sort(num.rbegin(), num.rend());
	for(int i=0; i<4; i++){
		cout<<num[i]<<" ";
	}

	cout<<num[4]<<endl;

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,ou=0,ji=0;
    int a[100005];
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]%2==0) ou++;
        else ji++;
    }
    if(ji%2==1)
    {
        cout<<"NO"<<endl;
    }
    else
    {
    cout<<"YES"<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    
    int a, b, c;
    cin >> a >> b >> c;
    
    if(a > b){
        int tmp = a;
        a = b;
        b = tmp;
    }
    
    if(a > c){
        int tmp = a;
        a = c;
        c = tmp;        
    }
    
    if(b > c){
        int tmp = b;
        b = c;
        c = tmp;
    }
    
    cout << a << " " << b << " " << c << endl;
    
}



Measured memory_bytes: 3096
#include <iostream>
#include <set>
using namespace std;
 
int main() {
    int n,q,s,t,i,ans=0;
    cin>>n;
    set<int> S = set<int>();
    for (i=0;i<n;i++) {
        cin>>s;
        S.insert(s);
    }
    cin>>q;
    for (i=0;i<q;i++) {
        cin>>t;
        if (S.count(t)>0) {
            ans++;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3156