akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {
 
  public struct City{
    public long num;
    public long year;
    public int ID;
    public City(long n, long y, int i){
      num = n;
      year = y;
      ID = i;
    }

  }

  public static void Main (string[] args) {
    var temp = Console.ReadLine().Split(' ').Select(long.Parse);
    var N = temp.ElementAt(0);
    var M = temp.ElementAt(1);
    var CityList = new List<City>();

    for(var i = 0; i < M; i++){
     var temp2 = Console.ReadLine().Split(' ').Select(long.Parse);
      CityList.Add(new City(temp2.ElementAt(0), temp2.ElementAt(1), i));
    }
    
    var ans = new List<string>();

    var sorted = CityList.OrderBy(x => x.num).ThenBy(x => x.year);
    var count = 0;
    var prev = sorted.First().num;


    foreach(var c in sorted){
      count = prev == c.num ? count + 1 : 1;
      ans.Add(String.Format("{0:000000}", c.num) + String.Format("{0:000000}", count) + String.Format("{0:000000}", c.ID));
      prev = c.num;
    }
    ans = ans.OrderBy(x => int.Parse(x.Substring(12))).Select(s => s.Substring(0,12)).ToList();

    ans.ForEach(Console.WriteLine);
  }
  
}

Measured memory_bytes: 43188
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define maxn 200005
#define ll long long
#define ld double
#define mod 1000000007 
using namespace std;
int cnt[30];
ll ans = 1;
char inp[maxn];
int main()
{
	int n;
	cin>>n;
	cin>>inp;
	for(int i = 0; i < n; i++)
		cnt[inp[i] - 'a']++;
	for(int i = 0; i < 30; i++)
		ans = ans * (cnt[i] + 1) % mod;
	ans--;
	if(ans < 0) ans += mod;
	cout<<ans<<endl;
	return 0;
}
 

Measured memory_bytes: 384
import collections as c
import math

def P(n, r):
  return math.factorial(n)//math.factorial(n-r)

def C(n, r):
  return P(n, r)//math.factorial(r)

N = int(input())
s = [input() for _ in range(N)]
count = []

for i in s:
  count.append(''.join(sorted(list(i))))

# print(count)

comb = [i[1] for i in c.Counter(count).most_common()]
print(sum([C(i, 2) for i in comb if i >= 2]))
  
  


Measured memory_bytes: 31644
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll A, B, C;
    cin >> A >> B >> C;
    if (A == B) {
        cout << C << endl;
    }
    else if (B == C) {
        cout << A << endl;
    }
    else {
        cout << B << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i = j; i < k; i += step)
#define loop(i, j, k) for (int i = j; i < k; i++)
#define rloop1(i, j, k, step) for (int i = j; i >= k; i -= step)
#define rloop(i, j, k) for (int i = j; i >= k; i--)
#define rep(i, k) for (int i = (0); i < (k); i++)
#define rrep(i, k) for (int i = k - 1; i >= 0; i--)

#define forall(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define endl "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define lin puts("");
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
char ch[101][101];
char c;
int arr[105];
void solve()
{
    string s, t;
    cin >> s;
    cin >> t;
    rep(i, s.size())
    {
        if (s[i] != t[i])
        {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}
int main()
{
    auto start = clock();
    fast_io;
    //freopen("test.txt", "r", stdin);
    int t = 1;
    while (t--)
    {
        solve();
    }
    auto stop = clock();
    cerr << "time taken:" << double(stop - start) / double(CLOCKS_PER_SEC) << " s" << endl;
    return 0;
}

Measured memory_bytes: 3752
s=int(input())

if s<3:
    print(0)
    exit()

ans=0

mod = 10**9+7 #出力の制限
n = 10**4 # nの最大値を指定
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 
for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

for i in range(s//3):
    s-=3
    ans+=cmb(s+i,i)
    ans%=mod

print(ans)

Measured memory_bytes: 10284
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a,b = map(int, input().split())
    # 素因数分解
    def prime_decomp(n):
        i = 2
        res = []
        while i ** 2 <= n:
            while n % i==0:
                n //= i
                res.append(i)
            i += 1
        if n > 1:
            res.append(n)
        return res

    c = set(prime_decomp(a))
    d = set(prime_decomp(b))
    print(len(c&d)+1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int mod = 1000000007;

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

    string s, t;
    cin >> s >> t;

    ll ans = 1;
    int pre = 0;
    int i = 0;
    while (i < n) {
        if (s[i] == t[i]) {
            if (pre == 0) ans *= 3;
            if (pre == 1) ans *= 2;
            i++;
            pre = 1;
        } else {
            if (pre == 0) ans *= 6;
            if (pre == 1) ans *= 2;
            if (pre == 2) ans *= 3;
            i += 2;
            pre = 2;
        }
        ans %= mod;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#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 n;
    cin >> n;

    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    deque<int> d;
    rep(i, n) {
        int p = lower_bound(d.begin(), d.end(), a[i]) - d.begin();
        if(p == 0) {
            d.push_front(a[i]);
        }
        else {
            d[p-1] = a[i];
        }
    }

    int ans = d.size();

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

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

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int debt = 100000;

		Double interest = 1.05;

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

			debt *= interest;

			if (!(debt % 1000 == 0)) {
				debt /= 1000;
				debt++;
				debt *= 1000;
			}

		}

		System.out.println(debt);

	}

}

Measured memory_bytes: 24044
#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 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 10010
 
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;
}
 
int a[N],b[N];
int main(){
    //freopen("atlarge.in","r",stdin);
    //freopen("atlarge.out","w",stdout);
    //cout<<setprecision(9)<<fixed;
    int T,j,i,k,ca=0,K,n;
    scanf("%d",&n);
    rep(i,0,n)scanf("%d",&a[i]);
    rep(i,0,n)scanf("%d",&b[i]);
    ll m=0;k=0;
    rep(i,0,n)if(a[i]>b[i]){
        m+=a[i]-b[i];
    }
    else if(a[i]<b[i]){
        K=b[i]-a[i];
        m-=K/2;
        k++;
    }
    else k++;
    if(m>0){
        puts("No");
    }
    else puts("Yes");
    //cerr<<1.*clock()/CLOCKS_PER_SEC<<"ms"<<"\n";
    return 0;
}   

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

#define MAX (1000000)
#define INF (1<<30)

int main() {
  
  int dp_all[MAX+2], dp_odd[MAX+2];
  
  fill(dp_all, dp_all+MAX+1, INF);
  fill(dp_odd, dp_odd+MAX+1, INF);
  
  dp_all[0] = dp_odd[0] = 0;
  
  for(int i=1; ; i++) {
    int num = i*(i+1)*(i+2) / 6;
    if(num > MAX) break;
    for(int j=num; j<=MAX; j++) {
      dp_all[j] = min(dp_all[j], dp_all[j-num]+1);
      if(num % 2)
	dp_odd[j] = min(dp_odd[j], dp_odd[j-num]+1);
    }
  }
  
  int n;
  while(cin >> n && n) {
    cout << dp_all[n] << " " << dp_odd[n] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 8968
n=int(input())
l=list(map(int,input().split()))
l1={}
l2=[]
for i in l:
  if i in l1:
    if l1[i]%2==0:
      l1[i]+=1
    else:
      l2.append(i)
      l1[i]+=1
  else:
    l1[i]=1
if len(l2)<2:
  print(0)
else:
  m1=max(l2)
  del l2[l2.index(m1)]
  m2=max(l2)
  print(m1*m2)


Measured memory_bytes: 18216
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

int main(){
  int n;
  cin >> n;
  vector<ll> vec(n+1);
  rep(i,n) cin >> vec.at(i);
  vec.at(n) = 1'000'000'001;
  sort(vec.begin(),vec.end());
  int cnt = 1;
  int ans = 0;
  rep(i,n){
    /*cout << cnt << endl;
    cout << ans << endl;
    cout << vec.at(i) << endl;
    cout << endl;*/
    if (vec.at(i) == vec.at(i+1)){
      cnt++;
      continue;
    }
    else if (vec.at(i) > cnt) ans += cnt;
    else if (vec.at(i) < cnt) ans += cnt - vec.at(i);
    cnt = 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4048
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner (System.in);


		//トッピングの種類の数・生地の値段・トッピングの値段・生地のカロリーを入力
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		//トッピングのカロリー用配列
		int [] d = new int [n];

		//ループ・ソート用
		int i, j;
		int temp;

		//カロリー計算・カロリーの最大値用
		int calorie;
		int max = 0;

		//トッピングのカロリーを入力
		for (i = 0; i < n; i++) {
			d[i] = sc.nextInt();
		}
		
		//トッピングのカロリーを降順にソート
		for (i = 0; i < n - 1; i++) {
			for (j = i + 1; j < n; j++) {
				if (d[i] < d[j]) {
					temp = d[i];
					d[i] = d[j];
					d[j] = temp;
				}
			}
		}
		
		//「最高のピザ」を求めて出力
		if (n == 0) {
			System.out.println(a);
		} else {
			for (i = 0; i < n; i++) {
				int sum = c;
				for (j = 0; j < i; j++) {
					sum += d[j];
					calorie = (int) (sum / (a + i * b));
					if (max < calorie) {
						max = calorie;
					}
				}
			}
			System.out.println(max);
		}

	}

}

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

int main(){
    int n; cin >> n;
    vector<int> num(n+1); 

    for(int i=0; i<n-1; i++){
        int boss; cin >> boss;
        num[boss]++;
    }

    for(int i=1; i<=n; i++) cout << num[i] << endl;
}

Measured memory_bytes: 4052
h,w = gets.split.map(&:to_i)
s = []
h.times{s << gets.chomp}

ans = true
h.times do |i|
    w.times do |j|
        next if s[i][j] == "."
        k = true
        [[i-1,j],[i+1,j],[i,j-1],[i,j+1]].each do |xi,xj|
            next if xi < 0 || xj < 0 || xi >= h || xj >= w
            if s[xi][xj] == "#"
                k = false
                break
            end
        end

        if k
            ans = false
            break
        end
    end
end

puts ans ? "Yes" : "No"

Measured memory_bytes: 1788
N,A,B,C,D = map(int, input().split())

n = N-1

found = False

B = abs(A-B)
for i in range(0, n+1):
    if C*(n-i)-D*(i) <= B <= D*(n-i)-C*(i):
        found = True
        break

if found:
    print("YES")
else:
    print("NO")


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

B = [0 for i in range(N+1)]

for i in range(N):
    B[i+1] += B[i] + A[i]
    B[i+1] %= M

from collections import Counter

counterB = Counter(B)

ans = 0
for v in counterB.values():
    ans += v*(v-1)//2

print(ans)


Measured memory_bytes: 16552
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=200005;

int n,k,cnt;
int a[MAXN],ans[MAXN];
bool f[MAXN];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	a[0]=0;
	while(1){
		if(k<0) break;
		int pos=0;
		for(int i=1;i<=n;++i){
			if(!a[i]&&!f[i]){
				cout<<-1<<endl;
				return 0;
			}
			else if(!f[i]&&a[i]>a[pos]) pos=i;
		}
		
		if(pos==0){
			--k;
			for(int i=0;i<=n;++i) f[i]=false;
			f[ans[cnt]]=true;
		}
		else{
			ans[++cnt]=pos;a[pos]--;f[pos]=1;
		}
	}
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;++i) printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX=1000000007;
struct edge{int u,v,cost;};
int p[10001];
int r[10001];

void init(int n) {
  for(int i=0; i<n; i++) {
    p[i]=i;
    r[i]=0;
  }
}
int find(int x) {
  if(p[x]==x) return x;
  else return p[x]=find(p[x]);
}
void unite(int x,int y) {
  x=find(x);
  y=find(y);
  if(x==y) return;

  if(r[x]<r[y]) p[x]=y;
  else {
    p[y]=x;
    if(r[x]==r[y]) r[x]++;
  }
}
bool same(int x, int y) {
  return find(x)==find(y);
}

bool comp(const edge &e1,const edge &e2){
  return e1.cost < e2.cost;
}
 
int V,E;
edge es[10001];
int k;
int kruskal(){
  init(V);
  set<int> s;
  int ma=0,mi=MAX,cnt=0;
  for(int i = k ; i < E ; i++){
    edge e = es[i];
    if(!same(e.u,e.v)){
      unite(e.u,e.v);
      ma = max(ma,e.cost);
      mi = min(mi,e.cost);
      s.insert(e.u);
      s.insert(e.v);
      cnt++;
    }
  }
  if(s.size()!=V || cnt!=V-1) return MAX;
  return ma-mi;
}

int main() {
  while(cin >> V >> E && V) {
    for(int i=0; i<E; i++) {
      int x,y,z;
      cin >> x >> y >> z;
      x--;y--;
      es[i]=(edge){x,y,z};
    }
    if(V>E+1 || E==0) {
      cout << -1 << endl;
      continue;
    }
    sort(es,es+E,comp);
    int ans=MAX;
    for(k=0; k<E; k++) {
      ans=min(ans,kruskal());
    }
    if(ans!=MAX) cout << ans << endl;
    else cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 1280
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    System.out.println(Math.min(a, b) + Math.min(c, d));
  }
}

Measured memory_bytes: 21844
<?php
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner();
$w = $sc->nextInt();
$h = $sc->nextInt();
$x = $sc->nextInt();
$y = $sc->nextInt();

$lec_men = $w * $h ;
$lec_men_half = $lec_men / 2 ;

$hantei = 0 ;
if ($x == $w/2 && $y == $h/2){
  $hantei = 1;
}else{
  $hantei = 0;
}

out::println($lec_men_half);
out::println($hantei);


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

void a(){
    int N,K; cin >> N >> K;
    string S; cin >> S;

    if (S[K -1] == 'A') S[K-1] = 'a';
    if (S[K -1] == 'B') S[K-1] = 'b';
    if (S[K -1] == 'C') S[K-1] = 'c';

    cout << S;

}

void b(){
    string S; cin >> S;
    int fast = stoi(S.substr(0,2));
    int last = stoi(S.substr(2,2));

    bool may_yymm = (0 <= fast && fast <= 99)&&(1<= last && last <=12);
    bool may_mmyy = (0 <=  last && last  <= 99)&&(1<= fast && fast  <=12);

    if (may_yymm && !may_mmyy) cout << "YYMM";
    else if (!may_yymm && may_mmyy) cout << "MMYY";
    else if (may_mmyy && may_yymm) cout <<"AMBIGUOUS";
    else if (!may_mmyy && !may_yymm) cout << "NA";


}
int main(){
    b();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		String ans;
		if (a < b){
			ans = "a < b";
		} else if (a > b){
			ans = "a > b";
		} else {
			ans = "a == b";
		}
		System.out.println(ans);
	}
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x, y) x##y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

// util {{{
#define FOR(i, start, end) for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); i < CPP_CAT(i, xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f, c, ...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); })(c))
#define ll long long int
#define VI vector<int>
template <typename C>
i64 SIZE(const C &c)
{
    return static_cast<i64>(c.size());
}

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template <typename T, typename U, typename Comp = less<>>
bool chmax(T &xmax, const U &x, Comp comp = {})
{
    if (comp(xmax, x))
    {
        xmax = x;
        return true;
    }
    return false;
}

template <typename T, typename U, typename Comp = less<>>
bool chmin(T &xmin, const U &x, Comp comp = {})
{
    if (comp(x, xmin))
    {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit
{
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit()
    {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

bool isOK(int mid, double key)
{
}

int binary_search(double key)
{
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key))
            right = mid;
        else
            left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

bool isKaibun(string st)
{
    bool ans = true;
    int n = st.length();
    REP(i, n / 2)
    {
        if (st[i] != st[n - i - 1])
        {
            return false;
        }
    }
    return true;
}

int toInt(char a)
{
    return a - '0';
}

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

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

void solve()
{
    int N, X, T;
    cin >> N >> X >> T;
    cout << (int)ceil((double)N / X) * T;
}

signed main()
{

    solve();

    return 0;
}


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

int main(){

    int N, D, X;
    cin >> N >> D >> X;

    vector<int> A(N);
    for (int i=0; i<N; i++){
        cin >> A.at(i);
    }

    int cnt = 0, cnt_buf;
    for (auto x: A){
        cnt_buf = 0;

        while ((cnt_buf*x+1) <= D){
            cnt_buf++;
        }
        cnt += cnt_buf;
    }

    int ans;
    ans = cnt + X;

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

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

int main(){
    int n,a=0;
    cin >> n;
    vector<int>y(n);
    vector<int>z(n);
    for(int i=0;i<n;i++){
        cin >> y[i];
        cin >> z[i];
        a+=z.at(i)-y.at(i)+1;
    }
    cout << a << "\n"; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
long long a[2];
int main(){
  long long n,x;cin>>n>>x;
  
  for(int i = 0; n > i; i++){
    int tmp;cin>>tmp;
    a[tmp%2]++;
  }
  if(a[1]==0){
    if(x==0){
      cout << (long long)pow(2,n) << endl;
    }else{
      cout << 0 << endl;
    }
  }else{
  	cout << (long long)pow(2,n)/2 << endl;
  }
}
    

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	char a,b;
	scanf("%c %c",&a,&b);
	if (a=='H'&&b=='H'){
		printf("H\n");
		}
		else if(a=='H'&&b=='D'){
			printf("D\n");
			}
			else if(a=='D'&&b=='H'){
				printf("D\n");
				}
				else if(a=='D'&&b=='D'){
					printf("H\n");
					}
	return 0;
	}

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

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

int main() {
  int N = 0;
  std::cin >> N;
  std::vector<int> d;
  repeat(i, N) {
    int iBuffer = 0;
    std::cin >> iBuffer;
    d.push_back(iBuffer);
  }
  std::sort(d.begin(), d.end());
  int iUnderMochi = 0;
  int iCount = 0;
  repeat(i, N) {
    if(iUnderMochi == d[i]) {
      continue;
    }
    iUnderMochi = d[i];
    iCount++;
  }
  std::cout << iCount << std::endl;
  return 0;
}

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

int main() {
	int64_t N;
	cin >> N;
	int64_t M;
	for (M = 1; M < N; M++) {
		if (M * M > N) {
			break;
		}
	}
	for (int64_t m = M-1; m >= 1; m--) {
		if (N % m == 0) {
			int64_t i = N / m;
			cout << m + i - 2 << endl;
			return 0;
		}
	}
}

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

namespace IO {
    #define gc getchar()
    template <typename T>
    inline void read(T& x) {
        x = 0; bool f = 1; char ch;
        for (ch = gc; ch < '0' || '9' < ch; ch = gc) if (ch == '-') f ^= 1;
        for (; '0' <= ch && ch <= '9'; ch = gc) x = (x << 3) + (x << 1) + (ch ^ 48);
        x = f ? x : -x;
    }
    #undef gc
}

long long ans, a, b, c, d;

int main() {
    IO::read(a), IO::read(b), IO::read(c), IO::read(d);
    if ((a <= 0 && b >= 0) || (c <= 0 && d >= 0)) ans = 0;
    else ans = -LONG_LONG_MAX;
    printf("%lld\n", max(ans, max(a * c, max(a * d, max(b * c, b * d)))));
    return 0;
}

Measured memory_bytes: 3768
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<set>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
static const int N=114514;

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=1e9+7;
#define ll long long

int main(){
  cin.tie(0); ios::sync_with_stdio(false);
  ll n,k;
  ll ans;
  cin>>n>>k;
  if(k%2==0){
    k/=2;
    ll num1,x,y;
    num1=n/k;
    if(num1%2!=0){
    x=(num1-1)/2;
    y=num1-x;
    }
    else{
      x=num1/2;
      y=x;
    }
    ans=(x*x*x)+y*y*y;
  }
  else{
    ll num;
    num=n/k;
    ans=num*num*num;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <string>
#include <string.h>
#include <sstream>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <limits>
#include <list>
#include <functional>
#include <bitset>
#include <numeric>
#include <iomanip>
#include <ctime>
#include <ctype.h>
#include <stdio.h>

using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define sz size()

string s;
stack<char> st;

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

	st.push(s[0]);
	for (int i = 1; i < s.sz; i++) {
		if (!st.empty() && st.top() == 'S' && s[i] == 'T') {
			st.pop();	
		}
		else {
			st.push(s[i]);
		}
	}
	if (!st.empty()) {
		cout << st.sz;
	}
	else {
		cout << 0;
	}




	
	return 0;
	//cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;	                      	
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  vi arr(n);
  rep(i,n) cin >> arr[i];

  rep(i,n) arr[i] -= i;
  sort(all(arr));
  int med = n/2;
  ll ans = 0;
  rep(i,n) ans += abs(arr[i] - arr[med]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
//  RAKSHIT KADAM

 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the Size of arrayss!!!
    
// NUMERIC DEFINITIONS :
    #define INF 1000000000000000005
    #define inf 1000000037
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
                         #define ll long long
                         #define int long long
//  #define ll int
 #define present(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
    
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
 
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn =506003;

void solve()
{
    string a,b;
    cin>>a>>b;
    ll c=0;
    for(ll i=0;i<a.length();i++)
    {
        if(a[i]^b[i])c++;
    }
    cout<<c<<endl;
}
signed main()
{
   Need_for_speed(activated);
    
//satisfy
//    {
//  solve();
//   }
    solve();
    
    return 0;
}


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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define mk make_pair

typedef long long LL;
typedef pair<int,int> Interval;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){
    os << v.first <<" "<<v.second<<endl;
    return os;
}

const int maxn = 2e5+5;
int A[maxn],N,x;

int main()
{
    cin >> N >> x;
    if(x == 1 ||  x == 2*N-1){
        printf("No\n");
    }else{
        printf("Yes\n");
        int mid = N;
        int temp = x+1;
        int temp2 = x-1;
        if(x <= N){
            A[mid] = x;
            while(--x){
                A[--mid] = x;
            }
            while(--mid >= 1){
                A[mid] = temp++;
            }
            _rep(i,N+1,2*N-1){
                A[i] = temp++;
            }
        }
        else{
            A[mid] = x;
            while(++x <= 2*N-1){
                A[++mid] = x;
            }
            while(++mid <= 2*N-1){
                A[mid] = temp2--;
            }
            for(int i = 1;i < N;i++){
                A[i] = temp2--;
            }
        }
        _rep(i,1,2*N-1){
            printf("%d\n",A[i]);
        }

    }

    return 0;
}


Measured memory_bytes: 2304
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Debug = System.Diagnostics.Debug;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using static Reader;

static class P
{
    static void Main()
    {
        int n = NextInt;
        var q = NextInt;
        BIT<int> bit = new BIT<int>(n + 1, 0, (x, y) => x + y);
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < q; i++)
        {
            if (NextInt == 0)
            {
                bit.Operate(NextInt, NextInt);
            }
            else
            {
                builder.AppendLine((-bit.Query(NextInt - 1) + bit.Query(NextInt)).ToString());
            }
        }
        Console.Write(builder.ToString());
    }
}


static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = BUF_SIZE - 1;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }

    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (int)(Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }

    public static int NextSInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; int sign = 1; while (Buffer[ptr] < 45) Move();
            if (Buffer[ptr] == 45) { Move(); sign = -1; }
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res * sign;
        }
    }
}


class BIT<T>
{
    public readonly int Size;
    T Identity;
    T[] Elements;
    Func<T, T, T> Merge;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public BIT(int size, T identity, Func<T, T, T> merge)
    {
        Size = size;
        Identity = identity;
        Merge = merge;
        Elements = new T[Size + 1];
        for (int i = 0; i < Elements.Length; i++) Elements[i] = identity;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Query(int r)
    {
        T res = Identity;
        for (r++; r > 0; r -= r & -r) res = Merge(res, Elements[r]);
        return res;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Operate(int i, T x)
    {
        for (i++; i < Elements.Length; i += i & -i) Elements[i] = Merge(Elements[i], x);
    }
}



Measured memory_bytes: 17808
import itertools
def calc_num(S,S_len):
  result = 0;
  l = [3,5,7];
  i = 3;
  while i <= S_len:
    for v in itertools.product(l,repeat=i):
      if int("".join(map(str,v))) <= S and list(set(v) & set(l)) == l:
        result = result + 1;
    i = i + 1;
  return result
  
S = list(map(int,input()));
S_len = len(S);
S = int("".join(map(str, S)));
result = calc_num(S,S_len);
print(result)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e3 + 7;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;

int main(){
	int r;
	cin >> r;
	printf("%.6lf\n",2*pi*r);
	return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin>>n;

  for (int i = 1; i < 2 * n; i++)
  {
    if (n == (int)(i * 1.08))
    {
      cout << i << endl;
      return 0;
    }
  }

  cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x;
    return is;
}

ll gcd(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    while (m != n)
    {
        if (m > n)
            m = m - n;
        else
            n = n - m;
    }
    return m;
}

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

int ctoi(const char c)
{
    if ('0' <= c && c <= '9')
        return (c - '0');
    return -1;
}

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

    string s;
    cin >> s;

    int cntW=0, cntE=0;

    for (auto it : s){
        if(it == 'E')   cntE++;
    }

    int ans=INF;

    for (auto it : s){
        if(it == 'W'){
            ans = min(ans, cntW+cntE);
            cntW++;
        }else{
            cntE--;
            ans = min(ans, cntE+cntW);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 900
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;



llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

int N, K,A[100010], B;

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

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] == 1) B = i;
	}

	if (N == K) cout << 1;
	else {
		int ans = 0;
		
		ans = B / (K - 1) + (N - B - 1) / (K - 1) + (B % (K - 1) + (N - B - 1) % (K - 1)) / (K - 1);
		if ((B % (K - 1) + (N - B - 1) % (K - 1)) % (K - 1)) ans++;

		cout << ans;
	}
}

Measured memory_bytes: 640
n,a,b = gets.chomp.split(" ").map(&:to_i)
sum_total = 0
(0..n).each do |i|
  digits = i.to_s.split("").map(&:to_i)
  sum = digits.inject(:+)
  if a <= sum && sum <= b
    sum_total += i
  end
end

p sum_total

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define mod 1000000007
#define maxn 200001
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
#define pb(x) push_back((ll)(x))
#define pf(x) push_front((ll)(x))
#define nl cout << "\n";
 
void ini(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

int main(){
	ini();
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	ll x,n;
	cin >> x >> n;
	ll a[n];
	f(i,0,n){
		cin >> a[i];
	}

	sort(a,a+n);

	queue<ll> q;
	f(i,0,n){
		q.push(a[i]);
	}

	ll m=maxn,ans=0;
	f(i,0,110){
		//cout <<abs(i-x);nl;
		if(i==q.front()){
			//cout <<i;nl;
			q.pop();
		}else if(abs(i-x)<m){
			//cout <<i;nl;
			m=abs(i-x);
			ans=i;
		}
	}
	//cout <<m;nl;
	cout <<ans;

}

Measured memory_bytes: 3644
n=int(input())
a=map(int,input().split())
def valid():
    b = list(range((n+1)&1, n+1, 2))
    for i in range(len(b)-1, -1, -1):
        b.insert(i, b[i])
    if b[0] == 0:
        b = b[1:]
    return list(sorted(a)) == b
ans,mod = 1,10**9+7
for i in range(n//2):
    ans = (ans * 2) % mod
print(ans if valid() else 0)

Measured memory_bytes: 54540
#include <stdio.h>
#include <math.h>
int main(){
	int i=1,flag=0,x;
	while(flag==0){
		scanf("%d",&x);

		if (x==0)
		{
			flag=1;
			break;
		}
		printf("Case %d: %d\n",i,x );
		i++;
	}
	return 0;
}

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

const int N = 50;
int a[N], b[N];
int g[N][N];
int visited[N];

void dfs(int v) {
  visited[v] = 1;
  for (int vi = 0; vi < N; vi ++) {
    if (g[v][vi] == 0) continue;
    if (visited[vi] == 1) continue;
    dfs(vi);
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i ++) {
    cin >> a[i] >> b[i];
    a[i] --, b[i] --;
    g[a[i]][b[i]] = 1, g[b[i]][a[i]] = 1;
  }

  int ans = 0;
  for (int i = 0; i < m; i ++) {
    g[a[i]][b[i]] = 0, g[b[i]][a[i]] = 0;
    for (int i = 0; i < n; i ++) visited[i] = 0;

    dfs(0);
    for (int i = 0; i < n; i ++) {
      if (visited[i] == 0) {
        ans ++;
        break;
      }
    }

    g[a[i]][b[i]] = 1, g[b[i]][a[i]] = 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printdbl(a) printf("%lf\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
const int INF = 1001001001;
using namespace std;
void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
    return;
}
int gdc(int a, int b) {
    int r;
    if (a < b)
        swap(&a, &b);
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
int factorial(int a) {
    int ans = 1;
    for (int i = 1; i <= a; ++i) 
        ans *= i;
    return ans;
}

int main() {
    int n;
    scanInt(n);
    vector<int> p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    vector<int> tmp1(n), tmp2(n);
    rep(i,n) {
        tmp1[i] = i + 1;
        tmp2[i] = i + 1;
    }
    int count1, count2, p1, p2;
    count1 = count2 = p1 = p2 = 0;
    while(!tmp1.empty()) {
        auto res = find(tmp1.begin(), tmp1.end(), p[p1]);
        count1 += (res - tmp1.begin()) * factorial(tmp1.size() - 1);
        p1++;
        tmp1.erase(res);
        res = find(tmp2.begin(), tmp2.end(), q[p2]);
        count2 += (res - tmp2.begin()) * factorial(tmp2.size() - 1);
        p2++;
        tmp2.erase(res);
    }
    printInt(abs(count2 - count1));
    return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	string s, t;
	cin>>s>>t;
	int m=s.size();
	int n=t.size();
//	cout<<"m"<<m<<"n"<<n<<endl;
	int lcs[m+1][n+1]={0};
	
	memset(lcs,0,sizeof(lcs));
//	for(int i=0;i<=m;i++) lcs[i][0]=0;
//	for(int i=0;i<=n;i++) lcs[0][i]=0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(s[i-1]==t[j-1])
				{
				lcs[i][j]= 1+lcs[i-1][j-1];
			}
			else{
				lcs[i][j]= max(lcs[i-1][j], lcs[i][j-1]);
			}
		}
	}
//	cout<<lcs[m][n];
	string ans;
	int i=m, j=n;
	while(i>=1&&j>=1){
				if(s[i-1]==t[j-1]){
				ans.push_back(s[i-1]);
				i--; j--;	
				}
			else {
				if(lcs[i-1][j]>lcs[i][j-1]){
					i--;
				}
				else j--;
			}
	}
	reverse(ans.begin(), ans.end());
	for(char u: ans){
		cout<<u;
	}
	cout<<endl;
	
//	cout<<lcs[m][n]<<endl;
	return 0;
}


Measured memory_bytes: 38800
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b,c,count = 0;
    scanf("%d %d %d",&a,&b,&c);
    for(int i = a; i <= b; i++){
        if(c%i == 0) count++;
    }
    printf("%d\n",count);
}


Measured memory_bytes: 2760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;


vector<vector<int>> v(100010);
bool used[100010];

int dfs(int p){
    used[p] = true;
    int x = 0;
    for(auto i:v[p]){
        if(!used[i]){
            x ^= dfs(i) + 1;
        }
    }
    return x;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
 
    int n;
    cin>>n;
    for(int i=1;i<n;i++){
        int a,b; cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    ll ans = dfs(0);
    if(ans){
        cout << "Alice" << endl;
    }
    else cout << "Bob" << endl;
}

Measured memory_bytes: 8960
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

h = inp()

cnt = 1
while h > 1:
    h //= 2
    cnt += 1

print(2**cnt-1)

Measured memory_bytes: 31136
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

struct DSU{
	int S;
	struct node{
		int parent; ll sum;
	};
	vector<node> dsu;
	DSU(int n){
		S = n;
		rep(i, n){
			node tmp;
			tmp.parent = i; tmp.sum = 1;
			dsu.pb(tmp);
		}
	}
	void reset(int n){
		dsu.clear();
		S = n;
		rep(i, n){
			node tmp;
			tmp.parent = i; tmp.sum = 1;
			dsu.pb(tmp);
		}
	}
	int root(int u){
		if(dsu[u].parent == u) return u;
		dsu[u].parent = root(dsu[u].parent);
		return dsu[u].parent;
	}
	void merge(int u, int v){
		u = root(u); v = root(v);
		if(u == v) return;
		if(getsum(u) < getsum(v)) swap(u, v);
		dsu[v].parent = u;
		dsu[u].sum += dsu[v].sum;
	}
	bool sameset(int u, int v){
		if(root(u) == root(v)) return true;
		return false;
	}	
	ll getsum(int u){
		return dsu[root(u)].sum;
	}
};

bool cmp(pair<pair<ll, ll>, int> a, pair<pair<ll, ll>, int> b){
	if(a.fi.fi != b.fi.fi) return a.fi.fi < b.fi.fi;
	else return a.fi.se < b.fi.se;
}

bool cmp1(pair<pair<ll, ll>, int> a, pair<pair<ll, ll>, int> b){
	if(a.fi.se != b.fi.se) return a.fi.se < b.fi.se;
	else return a.fi.fi < b.fi.fi;
}

ll x[100005], y[100005];

ll cost(pi cur){
	return min(abs(x[cur.fi] - x[cur.se]), abs(y[cur.fi] - y[cur.se]));
}

bool cmp2(pi a, pi b){
	return cost(a) < cost(b);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vector<pair<pair<ll, ll>, int>> p(n);
	rep(i, n){
		cin >> p[i].fi.fi >> p[i].fi.se, p[i].se = i;
		x[i] = p[i].fi.fi;
		y[i] = p[i].fi.se;
	}
	sort(all(p), cmp);
	vector<pi> edges;
	repn(i, 1, n) edges.pb(mp(p[i].se, p[i - 1].se));
	sort(all(p), cmp1);
	repn(i, 1, n) edges.pb(mp(p[i].se, p[i - 1].se));
	sort(all(edges), cmp2);
	DSU dsu(n);
	ll minCost = 0;
	for(pi e : edges) if(!dsu.sameset(e.fi, e.se)){
		dsu.merge(e.fi, e.se);
		minCost += cost(e);
	}
	cout << minCost << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 10352
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

vector <int> linsieve(int n){
	vector <int> p,out(n + 1,-1);
	for(int i = 2;i <= n;++i){
		if(out[i] == -1){
			out[i] = i;
			p.push_back(i);
		}
		for(int j = 0;j < p.size() and p[j] <= out[i] and i * p[j] <= n;++j){
			out[i * p[j]] = p[j];
		}
	}
	return out;
}

void solve(){
	int n;
	cin >> n;
	vector <int> small = linsieve(n);
	lli count = 0;
	for(int i = 1;i <= n - 2;++i){
		map <int,int> mp;
		int num = n - i;
		while(num > 1){
			++mp[small[num]];
			num = num / small[num];
		}
		lli pro = 1;
		for(auto i : mp){
			//cout << i.first << " " << i.second << newl;
			pro = pro * (i.second + 1);
		}
		count = count + pro;
	}
	cout << count + 1 << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 7796
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
vector<int>vec[maxn];
int h[maxn];
int main()
{
   int n,m;cin>>n>>m;
   for(int i=1;i<=n;i++)cin>>h[i];
 for(int i=1;i<=m;i++)
 {
 	int x,y;cin>>x>>y;
 	vec[x].push_back(y);vec[y].push_back(x);
 }
   int num=0;
   for(int i=1;i<=n;i++)
   {
   	if(vec[i].size()==0)num++;
   	else
   	{
   		bool f=true;
   		for(int j=0;j<vec[i].size();j++)
   		{
   			if(h[i]<=h[vec[i][j]])
   			{
   				f=false;break;
			   }
		   }
		   if(f)num++;
	   }
   }
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 9176