akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N, M; cin >> N >> M;
	vector<int> a(N + 1), b(M + 1);
	a[0] = 1e7, b[0] = 1e7;
	map<int, bool> ma, mb;
	bool flag = 0;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
		if (ma[a[i]])flag = true;
		ma[a[i]] = true;
	}
	
	for (int i = 1; i <= M; i++) {
		cin >> b[i];
		if (mb[b[i]])flag = true;
		mb[b[i]] = true;
	}

	if (flag)cout << 0 << endl;
	else {
		sort(a.begin(), a.end(), greater<int>());
		sort(b.begin(), b.end(), greater<int>());

		ll cnt = 1;
		ll ta = -1, yo = -1;
		for (int i = N * M; i >= 1; i--) {
			bool f1 = false, f2 = false;
			while (ta + 1 <= N && a[ta + 1] >= i) {
				ta++;
				if (a[ta] == i) {
					f1 = true;
					break;
				}
			}

			while (yo + 1 <= M && b[yo + 1] >= i) {
				yo++;
				if (b[yo] == i) {
					f2 = true;
					break;
				}
			}


			if (f1 && f2)cnt *= 1;
			else if (f1)cnt *= yo;
			else if (f2)cnt *= ta;
			else
				cnt *= (ta * yo - (N * M - i));
			cnt %= DIV;
			//cout << "ta=" << ta << " yo=" << yo << endl;
			//cout << "cnt=" << cnt << endl;
			if (cnt <= 0)break;
		}

		cout << max((ll)0, cnt) << endl;
	}
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}


int main() {
  int N, M;
  scanf("%d %d ",&N,&M);
  if (abs(N-M)>1){
    cout << 0 << endl;
    return 0;
  }
  int A = max(N, M);
  int B = min(N, M);
  ll ans = 1;
  if (A != B){
    for(int i=1;i<=B;i++){
      int num = i;
      num %= MOD;
      ans *= num;
      ans %= MOD;
    }
    for(int i=1;i<=A;i++){
      int num = i;
      num %= MOD;
      ans *= num;
      ans %= MOD;
    }
  }
  else{
    for(int i=1;i<=B;i++){
      int num = i;
      num %= MOD;
      ans *= num;
      ans %= MOD;
    }
    for(int i=1;i<=B;i++){
      int num = i;
      num %= MOD;
      ans *= num;
      ans %= MOD;
    }
    ans *= 2;
    ans %= MOD;
  }
  
  cout << ans << endl;
}

  



Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val a = sc.nextInt()
  val b = sc.nextInt()

  if (a % 2 != b %2) {
    println("IMPOSSIBLE")
  } else {
    println((a + b) / 2)
  }
}

Measured memory_bytes: 31008
# -*- coding: utf-8 -*-


def f(c, h_patterns, w_patterns, black_count):
    used = [[False for _ in range(len(w_patterns))]
            for _ in range(len(h_patterns))]

    for index, h_pattern in enumerate(h_patterns):
        if h_pattern != 1:
            continue

        for w_dash in range(len(w_patterns)):
            if not used[index][w_dash] and c[index][w_dash] == '#':
                used[index][w_dash] = True
                black_count -= 1

    for index, w_pattern in enumerate(w_patterns):
        if w_pattern != 1:
            continue

        for h_dash in range(len(h_patterns)):
            if not used[h_dash][index] and c[h_dash][index] == '#':
                used[h_dash][index] = True
                black_count -= 1

    return black_count


def main():
    from itertools import product

    h, w, k = map(int, input().split())
    c = [list(input()) for _ in range(h)]
    black_count = 0
    ans = 0

    for hi in range(h):
        for wi in range(w):
            if c[hi][wi] == '#':
                black_count += 1

    for h_patterns in product([1, 0], repeat=h):
        for w_patterns in product([1, 0], repeat=w):
            fi = f(c, h_patterns, w_patterns, black_count)

            if fi == k:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string a;
    cin>>a;
    int n=a.length();
    int k=0;
    for(int i=0;i<(n-1)/2;i++){
        if(a[i]==a[n-1-i]){
            
        }
        else{
            k=1;
        }
    }
    if(k!=1){
        if((n-1)/2%2==0){
            for(int i=0;i<(n-1)/4;i++){
                if(a[i]==a[(n-1)/2-1-i]){
                    
                }
                else{
                    k=1;
                }
            }
        }
        else{
            for(int i=0;i<((n-1)/2-1)/2;i++){
                if(a[i]==a[(n-1)/2-1-i]){
                    
                }
                else{
                    k=1;
                }
            }
        }
    }
    if(k!=1){
        if((n+3)/2%2==0){
            for(int i=0;i<(n-((n+3)/2-1)-1)/2;i++){
                if(a[(n+3)/2-1+i]==a[n-1-i]){
                    
                }
                else{
                    k=1;
                }
            }
        }
        else{
            for(int i=0;i<(n-((n+3)/2-1))/2;i++){
                if(a[(n+3)/2-1+i]==a[n-1-i]){
                    
                }
                else{
                    k=1;
                }
            }
        }
    }
    if(k!=1){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n,k,s;
  cin >> n >> k >> s;
  vll a(n);
  REP(i, k)
    a[i] = s;

  ll d;
  if(s==1)
    d = 2;
  else
    d = s-1;

  for(ll i = k; i<n; i++)
    a[i] = d;

  REP(i, n)
    cout << a[i] << " ";
  cout << endl;

}


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

using namespace std;

#define li long long int

const int N = 1e5 + 5;

int n, m;
int a[N];
multiset <pair <int, int > > ms;
li tot = 0;

void solve() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		ms.insert({a[i] - a[i] / 2, i});
		tot += a[i];
	}
	for (int i = 1; i <= m; i++) {
		if (ms.empty()) continue;
		auto top = *(--ms.end());
		ms.erase(--ms.end());
		tot -= top.first;
		a[top.second] /= 2;
		ms.insert({a[top.second] - a[top.second] / 2, top.second});
	}
	cout << tot;
}

int main() {
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 5376
# 石が200万個
# 0を含めて座標が-100万から100万まで

input = gets.chomp.split(" ")

k = input[0].to_i
x = input[1].to_i

min = x - (k-1)
max = x + (k-1)
out = ""

while min <= max do
    out = out + min.to_s + " "
    min = min + 1
end

out.slice!(out.length()-1)
puts out

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
int main(){
 string s,t;
  cin>>s>>t;
  int m=100000;
  int n=s.size()-t.size()+1;
  for(int i=0;i<n;i++){
    int cnt=0;
    for(int j=0;j<t.size();j++){
    if(t[j]!=s[j+i])cnt++;
       }
     m=min(m,cnt);
}
  cout<<m<<endl;
}

Measured memory_bytes: 3632
#include<cstdio>
using namespace std;
int main(void)
{
	int a,b,x,y;
	double p,aa,bb;  
	scanf("%d %d",&a,&b);
	aa=a;
	bb=b;
	x=a/b;
	y=a%b;
	p=aa/bb;
	printf("%d %d %lf\n",x,y,p);
	return 0;
}
	
	

Measured memory_bytes: 1064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, X;
        public int[] C;
        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                X = line[1];
            }

            C = Input.ReadIntArray();
            for (int i = 0; i < N; i++)
            {
                C[i] -= X;
                C[i] = Math.Abs(C[i]);
            }


            int ret = C[0];
            for (int i = 1; i < N; i++)
            {
                ret = GCD(ret, C[i]);
            }

            Console.WriteLine(ret);

        }

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

        // libs ----------

    }

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 19680
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let v: Vec<usize> = read_vec();

    if (v[1] * 10 + v[2]) % 4 == 0 {
      println!("YES");
    } else {
      println!("NO");
    }
}


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

int main() {
    int N;
    cin >> N;
    int K;
    cin >> K;
    vector<int> h(N);
    rep(i,N) cin >> h[i];
    int ans=0;
    rep(i,N) if(h[i] >= K) ++ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include <float.h>
int main(){
  int n;
  int a[1000];
  double ans=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    ans+=(double)1/a[i];
  }
  printf("%le",(double)1/ans);
  return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.lang.*;
import java.util.*;

public class Main 
{
	static boolean[] p;
	static int[] s;
	static final int maxn = 110000;
	public static void main(String args[])
	{
		p = new boolean[maxn];
		s = new int[maxn];
		Scanner sc = new Scanner(System.in);
		for (int i = 2;i <= 100000;++i)
		{
			if (i > 5000) break;
			for (int j = i*i;j <= 100000;j += i)
				p[j] = true;
		}
		s[1] = 0;
		for (int i = 3;i <= 100000;i += 2)
		{
			if (p[i] == false && p[(i+1)>>1] == false) s[i] = 1;
		}
		for (int i = 3;i <= 100000;++i)
		{
			s[i] = s[i-1] + s[i];
		}
		int q = sc.nextInt();
		while (q-- != 0)
		{
			int l = sc.nextInt();
			int r = sc.nextInt();
			System.out.println(s[r]-s[l-1]);
		}
	}
}


Measured memory_bytes: 59292
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	int ret = 0;
	for (int i = 1; i <= N; i++) {
		int n = i;
		int cnt = 0;
		while (n) {
			cnt++;
			n /= 10;
		}
		if (cnt & 1) ret++;
	}

	cout << ret << endl;
}

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

using namespace std;

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

    int hi;
    int ans = 0;
    int h = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> hi;
        if (h <= hi)
            ans++;
        else
            continue;

        h = max(h, hi);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
//
// Created by chuta on 2020/09/19.
//

#include <bits/stdc++.h>
//#include <atcoder/all>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    string s;
    cin >> s;
    if(s.back()=='s') cout << s << "es" << endl;
    else cout << s << "s" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int a,b; cin >> a >> b;
    ll ans = 1;
    ans *= b;
    ans *= pow(b-1,a-1);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 998244353
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
  long long n;
  cin>>n;
  long long l=n;
  int ans=0;
  while(l){
    l=l/10;
    ans++;
  }
  for(long long i=2;i<=sqrt(n);i++){
    if(n%i==0){
      long long c=i;
      long long d=n/i;
      int f=0;
      int g=0;
      while(c){
        c=c/10;
        f++;
      }
      while(d){
        d=d/10;
        g++;
      }
      ans=min(ans,max(f,g));
    }
  }
  cout<<ans<<"\n";



}


Measured memory_bytes: 3580
//全く思いつきもしない
//先に遷移行列をn乗したものを計算すれば良い
//NかけるNで行列作ると、行って戻るパターンは管理しきれない
//2*Nかける2*Nでいいのでは
//うーんわからん、辛いな
//今はどこにいるか次にどこに行きたいかで考えていたけど、それでは直前の情報を受け取れない
//どこにいたのか今どこにいるかを考える
//今いる位置を頂点 + どこから来たかで管理すれば良い．つまり，辺と向きで管理すれば良い．有向辺 (道 + 向き) に番号を振り，ある番号 (が表す辺) から次にどの番号 (があらわす辺) に行けるかを表すような遷移行列を作る
//頂点の個数ぶんの行と列を確保しようと考えていたが、今回は辺で確保する
//セグフォはくそ


#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<sstream>
#include<bitset>
using namespace std;

typedef vector<vector<int>> mat;

mat mat_transpose(mat m,int length){
  mat new_m(length,vector<int>(length,0));
  for(int i=0;i<length;i++){
    for(int j=0;j<length;j++){
      new_m[i][j]=m[j][i];
    }
  }
  return new_m;
}

mat mat_mat_mult(mat m1,mat m2,int length){
  mat new_m(length,vector<int>(length,0));
  m2=mat_transpose(m2,length);
  for(int i=0;i<length;i++){
    for(int j=0;j<length;j++){
      for(int k=0;k<length;k++){
        new_m[i][j]+=m1[i][k]*m2[j][k];
      }
    }
  }
  return new_m;
}

vector<int> mat_vec_mult(mat m,vector<int> v,int length){
  vector<int> new_v(length);
  for(int i=0;i<length;i++){
    for(int j=0;j<length;j++){
      new_v[i]+=v[j]*m[i][j];
    }
  }
  return new_v;
}





int main(){
  int N,M,Z;
  int d,s;
  while(cin >> N >> M >> Z && N!=0){
    //cout << "a" << endl;
    vector<int> da(2*M,0);
    mat dp(2*M,vector<int>(2*M,0));
    vector<pair<int,int>> dp_sub(2*M);
    for(int i=0;i<M;i++){
      cin >> s >> d;
      dp_sub[i]=make_pair(d-1,s-1);dp_sub[i+M]=make_pair(s-1,d-1);
    }
    //ここまではOK
    for(int i=0;i<2*M;i++){
      //インデックスミス(修正済み)
      for(int j=0;j<2*M;j++){
        //ここで帰るパターンもOKになってるじゃないか、アホなのか
        //反対にしてしまっていた
        //やっと答えがあった
        if(dp_sub[i].first==dp_sub[j].second && dp_sub[i].second!=dp_sub[j].first){
          dp[i][j]=1;
        }
      }
    }
    //初期化
    for(int i=0;i<2*M;i++){
      if(dp_sub[i].first==0){da[i]=1;}
    }
    //ここを、繰り返し自乗法でやる(元はZ回愚直に回してた)
    //おーー32以内でできるすごい
    stringstream bitsts;
    string bits;

    //Z=1の時を考えると、ベクトルの初期化の時点でその道を通っていることになるので、Z-1が正しい
    //bitなので若干頭が混乱して訳のわからないコードを書きかけた
    bitsts << bitset<32>(Z-1);
    bits = bitsts.str();

    mat bitmemory[32];
    bitmemory[31]= dp;
    for(int i=31;i>0;i--){bitmemory[i-1]=mat_mat_mult(bitmemory[i],bitmemory[i],2*M);}

    stringstream bitsts_sub;
    string bits_sub;

    for(int i=0;i<32;i++){
      if(bits[i]=='1'){
        da=mat_vec_mult(bitmemory[i],da,2*M);
      }
    }

    int che=0;
    for(int i=0;i<2*M;i++){
      if(da[i]!=0 && dp_sub[i].second==N-1){
        che=1;cout << "yes" << endl;break;
      }
    }
    if(che==0){cout << "no" << endl;}
  }
}



Measured memory_bytes: 4644
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int H, W, D;
    cin>>H>>W>>D;
    vvi A(H, vi(W, 0));
    vector<pint> B(H*W);
    REP(i, 0, H){
        REP(j, 0, W){
            int a;
            cin >> a;
            A[i][j] = a;
            a--;
            B[a] = {i, j};
        }
    }

    vl move(H*W);
    REP(i, 0, D){
        int count = i;
        while(count < H*W){
            if(count < D){
                move[count] = 0;
            }else{
                move[count] = move[count-D] + abs(B[count].first - B[count - D].first) + abs(B[count].second - B[count - D].second);
            }
            count += D;
        }
    }
    //REP(i, 0, H*W) cout << move[i] << endl;
    int Q, L, R;
    cin >> Q;
    REP(i, 0, Q){
        cin >> L >> R;
        L--; R--;
        long ans = move[R] - move[L];
        cout << ans << endl;
    }
}

Measured memory_bytes: 2944
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #ifdef ONLINE_JUDGE
        #pragma GCC target ("avx512f")
    #else
        #pragma GCC target ("avx")
    #endif
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

class UnionFind {
    private:
        vi par;    // x の親ノード
        vi rank;   // 木の高さ
        vi mem;    // メンバの数
        int sz;             // 集合の個数
    public:
        UnionFind(int n) :
            par(n, -1), rank(n, 0), mem(n, 1), sz(n) {
            REP(i,n) par[i] = i;
        }
    
    int size() { return sz; }

    // 集合の追加
    void makeset() {
        par.pb(par.size());
        rank.pb(0);
        mem.pb(1);
        sz++;
    }

    int find(int x) {
        if (par[x] == x)
            return x;
        else
            return par[x] = find(par[x]);
    }

    int member(int x){
        x = find(x);
        return mem[x];
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (rank[x] < rank[y]){
            par[x] = y;
            mem[x] += mem[y];
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
            mem[y] += mem[x];
        }
        sz--;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

int n,m,a,b;
vi h;
signed main(){
    I(n); I(m);
    h.resize(n);
    REP(i,n) I(h[i]);

    vi good(n,1);
    REP(i,m){
        I(a); I(b);
        a--; b--;
        auto ah = h[a];
        auto bh = h[b];
        if (ah < bh) good[a]=0;
        if (ah == bh) good[a] = good[b] = 0;
        if (ah > bh) good[b] = 0;
    }
    cout << accumulate(all(good), 0LL) << endl;
}

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

int main() {

	string s;
	cin >> s;

	if (s == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}

	return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n;
    cin >> n;
    WGraph G(n);
    for (int i=0; i<n-1; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        G.at(a-1).push_back({b-1, c});
        G.at(b-1).push_back({a-1, c});
    }
    int q, k;
    cin >> q >> k;
    --k;

    vector<ll> fromK(n, -1);
    fromK.at(k) = 0;
    queue<int> que;
    que.push(k);
    while (!que.empty()) {
        int cur = que.front(); que.pop();
        for (auto p : G.at(cur)) {
            if (fromK.at(p.first) == -1) {
                fromK.at(p.first) = fromK.at(cur) + p.second;
                que.push(p.first);
            }
        }
    }

    vector<ll> res(q);
    for (int i=0; i<q; ++i) {
        int x, y;
        cin >> x >> y;
        res.at(i) = fromK.at(x-1) + fromK.at(y-1);
    }
    for (ll x : res) cout << x << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 10752
import java.util.Scanner;

public class Main {

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

		while(stdIn.hasNext()){
			int a = stdIn.nextInt();
			int b = stdIn.nextInt();
			int n = stdIn.nextInt();
			int sum = 0;
			int tmp = a%b;
			for(int i=0;i<n;i++){
				sum+=tmp*10/b;
				tmp=tmp*10%b;
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 11000
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int length = Integer.parseInt(br.readLine());
	String strArray[] = br.readLine().split(" ");
	int intArray[] = new int[length];
	for (int i = 0; i < length; i++) {
	    intArray[i] = Integer.parseInt(strArray[i]);
	}

	Arrays.sort(intArray);
	String result = "YES";
	for (int j = 0; j < length - 1;) {
	    if (intArray[j] == intArray[j + 1]) {
		result = "NO";
		break;
	    } else {
		j++;
	    }
	}

	System.out.println(result);
    }
}

Measured memory_bytes: 49628
using System;

namespace ConsoleApp1
{
    class Program
    {

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine().Split(' ');
            var a = new int[n];
            int ashurui = 1;
            a[0] = int.Parse(s[0]);
            var savedas = new int[3] { a[0], 0, 0};
            var anum = new int[3] { 1, 0, 0 };
            for (int i = 1; i < n; i++)
            {
                a[i] = int.Parse(s[i]);
                bool isdifferent = true;
                for (int j = 0; j < ashurui; j++)
                {
                    if (a[i] == savedas[j])
                    {
                        isdifferent = false;
                        anum[j]++;
                        break;
                    }
                }
                if (isdifferent)
                {
                    if (ashurui == 3)
                    {
                        Console.WriteLine("No");
                        ashurui++;
                        break;
                    }
                    else
                    {
                        savedas[ashurui] = a[i];
                        anum[ashurui] = 1;
                        ashurui++;
                    }
                }
            }
            if (ashurui < 3)
            {
                if (ashurui == 1)
                {
                    Console.WriteLine(savedas[0] == 0 ? "Yes" : "No");
                }
                else if (anum[0] == anum[1] * 2)
                {
                    if (savedas[1] == 0)
                    {
                        Console.WriteLine("Yes");
                    }
                    else
                    {
                        Console.WriteLine("No");
                    }
                }
                else if (anum[0] * 2 == anum[1])
                {
                    if (savedas[0] == 0)
                    {
                        Console.WriteLine("Yes");
                    }
                    else
                    {
                        Console.WriteLine("No");
                    }
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
            else if (ashurui == 3)
            {
                if ((savedas[0] ^ savedas[1]) == savedas[2] && anum[0] == anum[1] && anum[1] == anum[2])
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}


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

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

    if(d == 0){
        if(n == 100){
            cout << "101" << endl;
        }
        else{
            cout << n << endl;
        }
    }
    else if(d == 1){
        if(n == 100){
            cout << "10100" << endl;
        }
        else{
            cout << n * 100 << endl;
        }
    }
    else{
        if(n == 100){
            cout << " 1010000" << endl;
        }
        else{
            cout << n * 10000 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import sys
import math
import numpy as np
from collections import defaultdict
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    np.set_printoptions(threshold=20)
    N = int(input())
    d = defaultdict(int)
    for i in range(2, math.ceil(math.sqrt(N))):
        while N % i == 0:
            d[i] += 1
            N //= i
    if N != 1:
        d[N] += 1

    ans = 0
    for key in d:
        val = d[key]
        tmp = 0
        count = 0
        for i in range(1, val):
            tmp += i
            count += 1
            if tmp == val:
                break
            elif tmp > val:
                count -= 1
                break
        ans += max(count, 1)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27172
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
string a;
signed main(){
  int b;
  double d;
  cin>>b;
  d=b;
  if(b%2>0){
    cout<<(b/2+1)/d<<"\n";
  }
  else{
    cout<<d/2/d<<"\n";
  }
  return(0);
}


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

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

int main() {
    ll A, X;

    cin >> X >> A;

    if(X < A) {
        cout << 0;
    } else {
        cout << 10;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for(int i=(l); i<(r); ++i)
typedef long long ll;
typedef unsigned long long ull;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

const ll inf = 1LL<<60;
int N, M, R;
vector<vector<ll>> d(330, vector<ll>(330, inf));

void floyd(){
    rep(k, 0, N){
        rep(i, 0, N){
            if(d[i][k]==inf) continue;
            rep(j, 0, N){
                if(d[k][j]==inf) continue;
                chmin(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}


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

    cin >> N >> M >> R;
    vector<int> r(R);
    rep(i, 0, R){ cin >> r[i]; --r[i]; }
    rep(i, 0, M){
        int a, b, c; cin >> a >> b >> c;
        --a; --b;
        d[a][b]=d[b][a]=c;
    }

    floyd();

    ll ans=1LL<<60;
    sort(r.begin(), r.end());
    do{
        ll tmp=0;
        rep(i, 0, R-1) tmp+=d[r[i]][r[i+1]];
        chmin(ans, tmp);

    }while(next_permutation(r.begin(), r.end()));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const int N = 2e5 + 5, MOD = 1e9+7;
 
int n, d[N], ans;
 
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        scanf("%d",d+i);
    }
    sort(d,d+n);
    printf("%d",d[n/2]-d[n/2-1]);
    return 0;
}

Measured memory_bytes: 640
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k, c) = (v[0], v[1], v[2]);
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut from_start = vec![];
    let mut cur = 0;
    while cur < n {
        if s[cur] == 'x' {
            cur += 1;
            continue;
        }
        from_start.push(cur);
        cur += c + 1;
    }

    let mut from_end = vec![];
    let mut cur = (n - 1) as i64;
    while cur >= 0 {
        if s[cur as usize] == 'x' {
            cur -= 1;
            continue;
        }
        from_end.push(cur as usize);
        cur -= (c + 1) as i64;
    }
    from_end.reverse();

    // debug!(from_start);
    // debug!(from_end);
    let mut answers = vec![];
    for i in 0..n {
        if s[i] == 'x' {
            continue;
        }
        let l_num = from_start.lower_bound(&i);
        let r_num = from_end.len() - from_end.upper_bound(&i);
        // debug!(i, l_num, r_num);
        if l_num + r_num < k {
            answers.push(i + 1);
        }
    }
    for ans in answers {
        println!("{}", ans);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

use std::cmp::Ordering;

pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}


Measured memory_bytes: 12484
#include <bits/stdc++.h>
#define MAX_N 200000L
using namespace std;

int find(int x, int par[], int ran[]) {
    if (x == par[x])
        return x;
    return par[x] = find(par[x], par, ran);
}

void unite(int x, int y, int par[], int ran[]) {
    x = find(x, par, ran);
    y = find(y, par, ran);
    if (x == y)
        return;
    if (ran[x] < ran[y]) {
        par[x] = par[y];
    } else {
        par[y] = par[x];
        if (ran[x] == ran[y])
            ran[x]++;
    }
}


int main() {
    int n, k, l;
    cin >> n >> k >> l;
    int r_par[n + 1], r_rank[n + 1], t_par[n + 1], t_rank[n + 1];
    for (int i = 1; i <= n; i++) {
        r_par[i] = i;
        r_rank[i] = 0;
        t_par[i] = i;
        t_rank[i] = 0;
    }
    for (int i = 0; i < k; i++) {
        int p, q;
        cin >> p >> q;
        unite(p, q, r_par, r_rank);
    }
    for (int i = 0; i < l; i++) {
        int r, s;
        cin >> r >> s;
        unite(r, s, t_par, t_rank);
    }
    unordered_map<long, int> mp;
    for (int i = 1; i <= n; i++) {
        mp[MAX_N * find(i, r_par, r_rank) + find(i, t_par, t_rank) - 1]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << mp[MAX_N * find(i, r_par, r_rank) + find(i, t_par, t_rank) - 1] << ((i == n) ? '\n' : ' ');
    }
    return 0;
}


Measured memory_bytes: 11336
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n, d;
  cin >> n >> d;
  ll cnt = 0;
  rep(i,n) {
    ll x, y;
    cin >> x >> y;
    if ((x*x + y*y) <= d*d) {
      ++cnt;
    }
  }
  cout << cnt << endl;
}


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

int main() {
	int x;
	deque<int> st;
	while (cin >> x) {
		if (x == 0) {
			cout << st.back() << endl;
			st.pop_back();
		}
		else {
			st.push_back(x);
		}
	}
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
using namespace std;
int main(){
  	int N;
  	cin >> N;
  	switch(N%10){
      case 2:
      case 4:
      case 5:
      case 7:
      case 9: cout << "hon";
        		break;
      case 0:
      case 1:
      case 6:
      case 8: cout << "pon";
        		break;
      case 3: cout << "bon";
        		break;
    }
  	cout << '\n';
 	return 0; 
}

Measured memory_bytes: 3588
// https://atcoder.jp/contests/arc059/tasks/arc059_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int len = s.length();
    REP(i, len - 1) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << "\n";
            return 0;
        } else if (i + 2 < len && s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << "\n";
            return 0;
        }
    }
    cout << "-1 -1\n";
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const long long LINF = 1000000000000000018ll;
const int INF = 1000000009;
const int mod = 1000000007;

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

  int n, k; cin >> n >> k;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    mp[a]++;
  }
  int s = mp.size(); // s: 種類
  vector<pair<int, int>> v(s);
  int i = 0;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    int fi = it->first;
    int se = it->second;
    v[i++] = make_pair(se, fi);
  }
  sort(v.begin(), v.end());

  if (s <= k) {
    cout << 0 << endl;
    return 0;
  }

  int ans = 0;
  for (int i = 0; i < s-k; i++) {
    ans += v[i].first;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define N 210
#define ll long long
using namespace std;
int n,f[N],a[N];
ll s;

int main(){
	scanf("%lld",&s);
	for (n=0;s;)
		if (!(s&1))
			s--,a[++n]=0;
		else
			s>>=1,a[++n]=1;
	int h=1,r=n;
	for (int i=1;i<=n;i++)
		if (a[i])
			f[r--]=n-i+1;
		else
			f[h++]=n-i+1;
	printf("%d\n",n*2);
	for (int i=1;i<=n;i++)
		printf("%d ",f[i]);
	for (int i=1;i<n;i++)
		printf("%d ",i);
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int n;
int w[100010];

int f(int m){
	int ans=0,temp=0;
	for(int i=0;i<n;i++){
		if(w[i]>m)return 1e9;
		if(temp+w[i]<=m)temp+=w[i];
		else{
			ans++;
			temp=w[i];
		}
	}
	return ans+1;
}

int main(){
	int k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)scanf("%d",w+i);
	int l=0,r=1e9;//lはng,rはok
	while(r-l>1){
		int m=(l+r)/2;
		if(f(m)<=k)r=m;
		else l=m;
	}
	printf("%d\n",r);
}


Measured memory_bytes: 2132
## H, Kの値が小さいので塗り方の全ての通りを調べる方針でよい(全探索)
## 各塗り方について全てのマスが黒いかどうか調べて、黒いマスがK個あればよい
## itertoolsモジュールを使ってみる
from itertools import product
H, W, K = (int(x) for x in input().split())
C = [list(input()) for _ in range(H)] #H行〇列の行列を格納する
answer = 0

for row_bit in product(range(2), repeat=H):
#"product(range(2), repeat=H)"で長さがHで、各要素が1か0であるすべての組み合わせがすべて列挙される.
## cf.) https://docs.python.org/ja/3/library/itertools.html#itertools.product
    for col_bit in product(range(2), repeat=W):
        cnt = 0
        for row in range(H):
            for col in range(W):
                if C[row][col] == "#" and (row_bit[row] and col_bit[col]):
                    cnt += 1
        if cnt == K:
            answer += 1
print(answer)
## 参考 : https://qiita.com/u2dayo/items/90a0693f31524e7b4cd0#c%E5%95%8F%E9%A1%8Ch-and-v


Measured memory_bytes: 9068
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
const int N = 2e5 + 50;
ll mod = 998244353;
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937_64 mt(seed);
int fac[N],invf[N];
inline int add(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
inline int sub(int x, int y) { return x - y >= 0 ? x - y : x - y + mod; }
inline int power(int x, int y, int res = 1) {
    for (; y; y >>= 1, x = 1ll * x * x % mod) {
        if (y & 1) { res = 1ll * res * x % mod; }
    } return res;
}
void initcombi(int n) {
    for (int i = fac[0] = 1; i <= n; i++) { fac[i] = 1ll * fac[i - 1] * i % mod; }
    invf[n] = power(fac[n], mod - 2);
    for (int i = n; i; i--) { invf[i - 1] = 1ll * invf[i] * i % mod; }
}
 
inline int NCR(int n, int m) {
    if (n < m) { return 0; }
    return 1ll * fac[n] * invf[m] % mod * invf[n - m] % mod;
}
bool ispal(string k) {
    cout << k << " ";
    for(int i = 0; i < k.size(); i++) {
        if(k[i] == k[k.size() - i - 1])
            continue;
        return false;
    }
    return true;
}
int main() {
    io();
    long double n;
    cin >> n;
    n = n / 3;
    cout << fixed << setprecision(18) << (n * n * n);



}


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

int solve(vector<int> p) {
    int n = p.size();
    vector<int> pos;
    for(int i = 0; i < n; ++i)
        if(p[i] == 1)
            pos.push_back(i);
    
    int ans = 0;

    for(int i = n - 1; i >= 0; --i) {
        if(i % 2 == 1) {
            ans += abs(i - pos.back()) % 2;
            pos.pop_back();
        }
    }

    return ans;
}

int main() {
    int n; cin >> n;
    vector<int> v(n, 0);
    for(int i = 0; i < n; ++i)
        cin >> v[i];

    vector<int> w = v;
    sort(w.begin(), w.end());
    map<int, int> M;
    for(int i = 0; i < n; ++i)
        M[w[i]] = i;
    
    vector<int> p(n, 0);

    for(int i = 0; i < n; ++i) {
        v[i] = M[v[i]];
        p[i] = v[i] % 2;
    }

    cout << solve(p) << "\n";
}

Measured memory_bytes: 6912
#include <iostream>

using namespace std;

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

    int bk_num, nx_num;
    bk_num = 0;
    nx_num = 1;

    for (int i = 0; i < N; ++i) {
        if (A[i] == nx_num) {
            nx_num += 1;
        } else {
            bk_num += 1;
        }
    }

    int res;

    if (bk_num == N) {
        res = -1;
    } else {
        res = bk_num;
    }

    cout << res << endl;
}

Measured memory_bytes: 1024
n = input()
n_last = int(n[-1])

hon = [2, 4, 5, 7, 9]
pon = [0, 1, 6, 8]
bon = [3]

if n_last in hon:
  print("hon")
elif n_last in pon:
  print("pon")
elif n_last in bon:
  print("bon")

Measured memory_bytes: 9036
use std::io;

fn main() {
    let n: u8 = read_a_line().parse().unwrap();
    let s: String = read_a_line();
    let s = s
        .chars()
        .map(|c| {
            let u: u8 = c as u8 + n;
            if u > 90 {
                return (u - 26) as char;
            }
            u as char
        })
        .collect::<String>();
    println!("{}", s);
}

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

Measured memory_bytes: 4352
from itertools import accumulate

N,M,Q=map(int,input().split())
ST=[[0 for x in range(N+2)]for y in range(N+2)]

for i in range(M):
  s,t=map(int,input().split())
  ST[1][t]+=1
  ST[s+1][t]-=1
  ST[1][N+1]+=1
  ST[s+1][N+1]-=1

ST1 = [list(accumulate(l)) for l in zip(*ST)]
ST2 = [list(accumulate(l)) for l in zip(*ST1)]

for i in range(Q):
  s,t=map(int,input().split())
  print(ST2[s][t])

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    int n, k, tmp, min0;
    vector<int> p;
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        cin >> tmp;
        p.push_back(tmp);
    }
    asort(p);
    min0 = 0;
    for(int i = 0; i < k; i++) {
        min0 += p[i];
    }

    cout << min0 << endl;
    return 0;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>

using namespace std;

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;

const int N = 1e5 + 10;
char s[N];
int main() {
  scanf("%s", s);
  int rock = 0, paper = 0;
  for (int i = 0; s[i]; ++i) {
    if (s[i] == 'g') ++rock;
    else ++paper;
  }
  int P = (paper + rock) / 2;
  printf("%d\n", P - paper);
  return 0;
}


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

int main(){
    int n;
    scanf("%d", &n);   
    for(long long i=-1000;i<=1000;i++){
        for(long long j=-1000;j<=1000;j++){
            if(i*i*i*i*i-j*j*j*j*j == n){
                printf("%lld %lld\n", i, j);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3796
N = int(input())
A = [0]*N
B = [0]*N
for i in range(N):
	A[i], B[i] = list(map(int, input().split()))

ans = 0
for i in reversed(range(N)):
	A[i] += ans
	if A[i] % B[i] != 0:
		ans += B[i] - (A[i] % B[i])

print(ans)

Measured memory_bytes: 14836
A,B,K=map(int,input().split())
a=[]
if A>=B:
  for i in range(B):
    if A%(i+1)==0 and B%(i+1)==0:
      a.append(i+1)
elif A<B:
  for n in range(A):
    if A%(n+1)==0 and B%(n+1)==0:
      a.append(n+1)
a=sorted(a,reverse=True)
print(a[K-1])

Measured memory_bytes: 3060