akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define N_MAX 500002

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];

void init(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        fac[i]=fac[i-1]*(ll) i%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll comb(ll n, ll r){
  ll ans;
  if(n < r){
      ans = 0;
  }else{
      ans = (fac[n]*finv[r])%MOD;
      ans = (ans*finv[n-r])%MOD;
      ans = (ans+MOD)%MOD;
  }
  return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    init();
    ll N, M;
    cin >> N >> M;
    ll ans = 0;
    init();
    for(ll i = 0; i <= N; i++){
        ll a = (((comb(N, i)*comb(M, i))%MOD)*fac[i])%MOD;
        ll b = (comb(M-i, N-i)*fac[N-i])%MOD;
        ll c = (b*b)%MOD;
        ll d = (a*c)%MOD;
        int sgn = i%2 == 0 ? 1 : -1;
        ans += sgn*d;
        ans %= MOD;
    }
    cout << (ans+MOD)%MOD << endl;
}

Measured memory_bytes: 15328
#include <bits/stdc++.h>
using namespace std;
vector<int>v;

int euclid(int x, int y){
	if(x < y) swap(x, y);
	while(y!=0){
		int p = x%y;
		x=y;
		y=p;
	}
        return x;
}

int main(){
	int ans = 0;
	int n = 0;
	cin >> n;
	for(int i =0; i < n;i++){
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
	sort(v.begin(), v.end());
	vector<int>b;
	for(int i = 1; i<=v[n-1]; i++){
		if(v[n-1]%i==0) b.push_back(i);
	}
	for(int i = 0; i < n-1;i++){
		auto it = lower_bound(b.begin(),b.end(),v[i]);
		ans +=*it - v[i];
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 3528
N=int(input())
TA=[list(map(int,input().split())) for i in range(N)]

NOW=(TA[0][0],TA[0][1])

def next(NOW,NEXT):
    i,j=NOW
    k,l=NEXT

    if k>=i and l>=j:
        return k,l

    MAX=max(-(-i//k),-(-j//l))

    return MAX*k,MAX*l

for i in range(1,N):
    NOW=next(NOW,TA[i])

print(sum(NOW))

Measured memory_bytes: 3188
from collections import deque

n, q = map(int, input().split())
a = deque([])
for i in range(n):
    a.append(list(input().split()))

end_time = 0
while len(a):
    e = a.popleft()
    if int(e[1]) - q > 0:
        e[1] = int(e[1]) - q
        a.append(e)
        end_time += q
    else:
        end_time += int(e[1])
        print(e[0], end_time)



Measured memory_bytes: 14596
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n / 2 - 15 << endl;
}


Measured memory_bytes: 3168
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  int m; rd(m);

  auto g=new int[][](n);
  foreach(i; 0..m){
    int a, b; rd(a, b);
    g[a-1]~=(b-1);
  }

  auto vis=new bool[](n), seq=new int[](0);
  bool multi=false;
  void dfs(int i){
    vis[i]=true;
    int cnt=0;
    foreach(j; g[i]){
      if(vis[j]) continue;
      cnt++; dfs(j);
    }
    if(cnt>1) multi=true;
    seq=i~seq;
  }
  
  foreach(i; 0..n)if(vis[i]==false) dfs(i);
  writefln("%(%s\n%)", seq.map!(i=>i+1));
  if(multi) writeln(1);
  else writeln(0);
}
void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}



Measured memory_bytes: 15040
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        double r = sc.nextDouble();
        double pi = Math.PI;
        
        double m = r*r*pi;
        double e = 2*pi*r;
        System.out.printf("%f %f",m,e);
    }
}


Measured memory_bytes: 28324
module Main where

import           Control.Monad
import           Data.List
import           Data.Ord
import           Data.List.Split
import           Data.Array.IO
import qualified Data.Vector            as V
import           Text.Printf

main :: IO ()
main = do
  [a, b, c] <- map read . words <$> getLine :: IO [Int]
  if (min a b <= c && max a b >= c)
    then putStrLn "Yes"
    else putStrLn "No"


Measured memory_bytes: 508
def main():
    M, D = map(int, input().split())

    if D < 20:
        print(0)
        exit()

    cnt = 0
    for i in range(1, M+1):
        for j in range(20,D+1):
            if i == int(str(j)[0]) * int(str(j)[1]):
                if int(str(j)[0]) >= 2 and int(str(j)[1]) >= 2:
                    cnt += 1

    print(cnt)
            


main()

Measured memory_bytes: 40304
import java.util.Scanner;

public class Main {

    private static int N;
    private static int M;
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        N = sc.nextInt();
        M = sc.nextInt();
        
        System.out.println(N==M ? "Yes" : "No");

    }

}


Measured memory_bytes: 21844
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            String ans = "";
            switch (N % 10) {
                case 2:
                case 4:
                case 5:
                case 7:
                case 9:
                    ans = "hon";
                    break;
                case 0:
                case 1:
                case 6:
                case 8:
                    ans = "pon";
                    break;
                case 3:
                    ans = "bon";
                    break;
            }
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 32660
import math
import copy

inputa = input().split()
# inputb = input().split()
# inputc = input().split()

# a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

a = inputa[0]
inputList = list(a)

# x = int(inputb[0])
# y = int(inputb[1])

# inputList=[]
# for i in range(a):
#     inputNum = input()
#     inputList.append(inputNum)
#
# inputList = [int(n) for n in inputList]

# b = [int(n) for n in inputb]
# c = [int(n) for n in inputc]

sum = 0
max = 0
ref = ["A", "C", "G", "T"]
for i in range(len(inputList)):
    flg = False
    for j in range(len(ref)):
        if inputList[i] == ref[j]:
            flg = True
            break

    if flg == False:
        if sum > max:
            max = sum
        sum = 0
    elif flg == True and i == len(inputList)-1:
        sum +=1
        if sum > max:
            max = sum
    elif flg == True:
        sum += 1
        
print(max)









Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, d;
    cin >> n >> d;
    
    int l,k,i=0;
    double a[n], b[n];
    double answer;
    int cnt = 0;
    while(cin>>l>>k){
        a[i] = l;
        b[i] = k;
        answer = sqrt(a[i]*a[i] + b[i]*b[i]);
        i++;
        if (answer <= d) {
            cnt++;
        }
    }
    std::cout << cnt << std::endl;
    return 0;
}

Measured memory_bytes: 6792
#include<iostream>
#include<stack>
using namespace std;
#define White 0
#define Black 1
#define Red 2
#define MAX 100
struct Queue {
	int color, d, f, relate[MAX], roots, id;
};
Queue Q[MAX];
stack<int> q;
stack<int> dmax;
int search(int deep) {
	while (!q.empty()) {
		int s = q.top();
		int whitecount = 0;
		for (int i = 0; i < Q[s - 1].roots; i++) {
			int nakami = Q[s - 1].relate[i];
			if (Q[nakami - 1].color == White) {
				whitecount += 1;
				deep += 1;
				Q[nakami - 1].color = Black;
				q.push(Q[nakami - 1].id);
				Q[nakami - 1].d = deep;
				search(deep);
			}
		}
		if (whitecount == 0) {
			deep += 1;
			Q[s - 1].f = deep;
			dmax.push(deep);
			Q[s - 1].color = Red;
			q.pop();
			search(deep);
		}
	}
	return dmax.top();
}
int main() {
	int n, u, k, v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		Q[i].color = White;
	}
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		Q[u - 1].id = u;
		Q[u - 1].roots = k;
		if (i == 0) {
			Q[u - 1].d = 1;
			Q[u - 1].color = Black;
			q.push(u);
		}
		if (k != 0) {
			for (int i = 0; i < k; i++) {
				cin >> v;
				Q[u - 1].relate[i] = v;
			}
		}
	}
	int max = search(1);
	for (int i = 0; i < n; i++) {
		if (Q[i].color == White) {
			Q[i].d = max + 1;
			q.push(Q[i].id);
			search(max+1);
			max = search(max);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << Q[i].id << " " << Q[i].d << " " << Q[i].f << endl;
	}

}


Measured memory_bytes: 3132
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := Scanner()
	if n[0] == n[2] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1772
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<set>

using namespace std;

int main() {
	int buf;
	int count = 0;
	int X, N, m = -100;
	bool flag = false;
	count = X * 2;
	set<int> dic;

	cin >> X >> N;
	for (int i = 0; i < N; i++) {
		cin >> buf;
		dic.insert(buf);
	}
	for (int i = X; i >= -1; i--) {
		if (dic.find(i) == dic.end()) {
			m = i;
			break;
		}
	}
	for (int i = X + 1;; i++) {
		if (dic.find(i) == dic.end()) {
			if (abs(X - m) > abs(X - i))m = i;
			break;
		}
	}
	cout << m;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 using namespace std;
int main(){
  int N;
  cin>>N;
  int p=0;
  while(p<N){
    string S;
    cin>>S;
    if (S=="Y"){
		cout<<"Four"<<endl;
        break;
    	}
    	p++;
 	 }
    if(p==N){
      cout<<"Three"<<endl;
  	}
  
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))

    ans = 0

    for i in range(n):
        ans += b[a[i] - 1]
        if i > 0 and a[i] == a[i - 1] + 1:
            ans += c[a[i - 1] - 1]

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38384
#include <iostream>
#include <unordered_map>

using namespace std;

int main(){
    unordered_map<int, int> mp;
    int n, k; cin>>n>>k;

    for(int i=0; i<k; i++){
        int d; cin>>d;
        for(int j=0; j<d; j++){
            int a; cin>>a;
            mp[a]++;
        }
    }
    cout<< n-mp.size();
 return 0;
}


Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define mp make_pair
#define pb push_back
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int x[10], y[10];

double dist(int i, int j) {
	double dx = x[i] - x[j];
	double dy = y[i] - y[j];
	return pow(dx*dx + dy*dy, 0.5);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];

	vector<int> v;
	int factorial = 1;
	for (int i = 1; i <=n; i++) {
		v.pb(i);
		factorial *= i;
	}

	double ans = 0;
	do {
		for (int i = 0; i < n-1; i++) ans += dist(v[i], v[i+1]);
	} while(next_permutation(ALL(v)));

	ans /= factorial;
	printf("%8lf\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


bitset<300> bs[300],ret;
int cnt[300];
int main(){
    int h,w;
    cin>>h>>w;
    string s[h];
    rep(i,h)cin>>s[i];
    rep(i,h)rep(j,w)bs[i][j]=(s[i][j]=='#');
    ll ans=0;
    rep(i,h)REP(j,i+1,h)REP(k,j+1,h){
        int x=j-i,y=k-j;
        if(x>=y)ret=bs[i]&(bs[j]<<x)&(bs[k]>>(x-y));
        else ret=bs[i]&(bs[j]<<(2*y-x))&(bs[k]<<(y-x));
        ans+=ret.count();
        if(x>=y)ret=bs[i]&(bs[j]>>x)&(bs[k]<<(x-y));
        else ret=bs[i]&(bs[j]>>(2*y-x))&(bs[k]>>(y-x));
        ans+=ret.count();
    }
    rep(i,h){
        rep(j,w)for(int k=2;j+k<w;k+=2){
            if(bs[i][j]&bs[i][j+k]){
                if(i+k/2<h)ans+=bs[i+k/2][j+k/2];
                if(i-k/2>=0)ans+=bs[i-k/2][j+k/2];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define fi first
#define se second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define RFor(i,b,a) for(ll i = b;i>=a;i--)
#define sz size()
#define PQ priority_queue
#define len length()
#define mll map<ll,ll>
#define mpll map<pll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pair<ll,ll> >
#define mp(x,y)  make_pair(x,y)
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define ALL(v) v.begin(),v.end()
#define LAPAK ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

const ll MOD = 1e9 + 7;
const ll INF = 2e18;
const ll MAX = 2e5 + 5;

class DSU{
    vector<ll> parent,size;
    ll m_count,m_total;
    vector<list<ll> > parts;
    public:
        DSU(ll n){
            m_count = m_total = n;
            parent.resize(n);
            size.resize(n);
            parts.resize(n);
            For(i,0,n){
                parent[i] = i;
                size[i] = 1;
                parts[i].pb(i);
            }
        }
        ll find_root(ll v){
            if(parent[v] == v)
                return v;
            return parent[v] = find_root(parent[v]);
        }
        ll count(){
            return m_count;
        }
        ll total(){
            return m_total;
        }
        void join(ll a, ll b){
            a = find_root(a);
            b = find_root(b);
            if(a!=b){
                if(size[a] < size[b]){
                    swap(a,b);
                }
                parent[b] = a;
                size[a] += size[b];
                parts[a].splice(parts[a].end(),parts[b]);
                --m_count;
            }
        }
        bool is_connected(ll u,ll v){
            return find_root(u) == find_root(v);
        }
        int print(){
            int ans = 0;
            for(ll i = 0;i<parts.sz;i++){
                ans = max(ans, (int)parts[i].sz);
            }
            //cout<<--j;
            return ans;
        }
};

int main() {
    LAPAK
    
    int n,m;
    cin>>n>>m;
    
    DSU dsu = DSU(n);
    For(i,0,m){
        int a,b;
        cin>>a>>b;
        --a,--b;
        dsu.join(a,b);
    }
    cout<<dsu.print();
    
    return 0;
}

Measured memory_bytes: 17176
#include<bits/stdc++.h>
#define M 502
#define mo 1000000007
#define LL long long
using namespace std;

int ksm(int a,int b){
	int ans=1,c=a;
	for (; b>0; ){
		if (b%2==1)ans=(1LL*ans*c)%mo;
		c=1LL*c*c%mo;
		b=b/2;
	}
	return ans;
}


void read(int &x){
    char c; x=0;
    for (c=getchar(); c<48;)c=getchar();
    for (; c>=48; c=getchar())x=(x<<1)+(x<<3)+(c^48);    
}
int nu,n,num,t[200005],a[200005];
int i,j,tt=1,ans[200005];
int main(){
	//freopen("input.txt","r",stdin);
	read(n); n++;
	for (i=1; i<=n; i++){
		read(a[i]);
	}
	int l,r;
	nu=n+1;
	for (i=1; i<=n; i++){
		if (t[a[i]])num++;
		if ((num>0)&&(nu==n+1)){l=t[a[i]]; r=i; nu=(n-r+1)+(l-1);}
		t[a[i]]=i;
	}
	
	ans[0]=1; ans[1]=n;
	for (i=2; i<=n/2; i++) ans[i]=(1LL*ans[i-1]%mo*(n-i+1)%mo*ksm(i,mo-2))%mo;
	for (; i<=n; i++)ans[i]=ans[n-i];
	
	//for (i=1; i<=n; i++)printf("%d ",ans[i]); printf("\n");
	
	printf("%d\n",ans[1]-num);
	
	//printf("%d ",nu);
	for (i=2; i<=nu; i++){
		num=1LL*num*(nu+1-i)%mo*ksm(i-1,mo-2)%mo;
		printf("%d\n",1ll*(ans[i]-num+mo)%mo);
	}
	
	for (; i<=n; i++)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define debug(x) cout << "debug: " << x << endl
#define MOD 1e9 + 7
#define INF 1e9

template <class T>
inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T>
inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

//const double pi = 3.1415926535; //10^-10までの円周率

int main(){
    int x, y;
    cin >> x >> y;
    cout << GCD(x, y) << endl;
}


Measured memory_bytes: 3096
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
signed main(){

	char a;
	cin>>a;
	a++;
	cout<<char(a)<<endl;

	return 0;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)

ss = Array.new(n+1, 0)

k.times do
  d = gets.to_i
  as = gets.split.map(&:to_i)
  as.each do |a|
    ss[a + 1] = 1
  end
end

p n - ss.reduce(&:+)


Measured memory_bytes: 14368
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

struct edge {
    int to;
    ll dist;
    edge() {}
    edge(int to, ll dist): to(to), dist(dist) {}

};

struct state {
    int pos;
    ll dist;
    state() {}
    state(int pos, ll dist): pos(pos), dist(dist) {}

    bool operator < (const state& o) const {
        return dist > o.dist;
    }
};

int N, M, S, T;

vector<edge> graph[101010];
ll d[101010];
priority_queue<state> pq;

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

    cin >> N >> M >> S >> T;
    --S; --T;
    for (int j = 0; j < M; ++j) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        --a; --b; --c;

        graph[a].emplace_back(b, d);
        graph[a].emplace_back(c, d);
        graph[b].emplace_back(a, d);
        graph[b].emplace_back(c, d);
        graph[c].emplace_back(a, d);
        graph[c].emplace_back(b, d);
    }

    fill(d, d+N, 1LL << 60);
    d[S] = 0;

    pq.emplace(S, 0);
    while (!pq.empty()) {
        state st = pq.top(); pq.pop();
        if (st.dist > d[st.pos]) continue;

        for (edge e : graph[st.pos]) {
            if (d[e.to] > st.dist + e.dist) {
                d[e.to] = st.dist + e.dist;
                pq.emplace(e.to, d[e.to]);
            }
        }
    }

    cout << d[T] << endl;

    return 0;
}



Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const ll INF = 1000000000000000000;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    bool f = false;
    rep (i, n) {
        cin >> a[i];
        if (a[i] == 0) {
            f = true;
        }
    }
    if (f) {
        cout << 0 << endl;
        exit(0);
    }
    ll ans = 1;
    long double p = 1.0;
    rep (i, n) {
        if (p * INF / a[i] < p * ans) {
            cout << -1 << endl;
            exit(0);
        }
        ans *= a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4356
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

char s[200000+10];
char t[200000+10];
int n;

char conv[30];

bool isOK(void) {
  REP(i, n) {
    if(conv[s[i]-'a']) {
      if(conv[s[i]-'a'] != t[i]) {
        return false;
      }
    } else {
      REP(j, 26) {
        if(conv[j] == t[i]) {
          return false;
        }
      }
      conv[s[i]-'a'] = t[i];
    }
  }
  return true;
}

int main(void) {
  scanf("%s%s", s, t);
  n = strlen(s);
  bool res = isOK();
  puts(res ? "Yes" : "No");
  return 0;
}



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

#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define endl "\n"

#define for0(i, n) for (int i = 0; i < n; i++)
#define loop(i, a, b) for(int i = a;i <= b; i++)
#define forrev(i, n) for(int i = n; i >= 0; i--)
#define test_case(t) int t; cin >> t; while (t--)
#define debug(x) cout<< #x << "=" << x <<"\n";

typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;

#define prec(n) fixed<<setprecision(n)
#define inf (int)(1e18)
#define MAX 1000002
#define MOD 1e9 + 7

long long int max(long long int a,long long int b){if(a>b) return a; else return b;}
long long int min(long long int a,long long int b){if(a<b) return a; else return b;}
bool isPrime(int N){
for(int i=2;i*i<=N;++i){
    if(N%i==0) return false;
    }
    return true;
}        

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

    int n;
    cin>>n;

    double x = ceil(n / (double)1000);

    int y = 1000 * x;

    cout<<abs(n - y)<<endl;
      
    return 0;
}
//g++ -std=c++17 -Wshadow -Wall -O2 -Wno-unused-result



Measured memory_bytes: 3656
K = int(input())
As = list(map(int, input().split()))

def f(n):
    for a in As:
        n = a * (n//a)
    return n

ng,ok = 1, 10**20
while ok-ng > 1:
    m = (ok+ng)//2
    if f(m) >= 2: #2以上ならTrue
        ok = m
    else:
        ng = m
mn = ok
# print(ng,ok)

ok,ng = 1, 10**20
while ng-ok > 1:
    m = (ok+ng)//2
    if f(m) <= 2: #2以下の範囲
        ok = m
    else:
        ng = m
mx = ok

# print(ok,ng)
if mn > mx:
    print(-1)
else:
    print(mn,mx)


Measured memory_bytes: 20512
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
	int n;
	int house[4][3][10] = {};

	cin >> n;
	for(int i=0;i<n;i++){
		int b,f,r,v;
		cin >> b >> f >> r >> v;
		house[b-1][f-1][r-1] += v;
	}

	for(int i=0;i<4;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<10;k++){
				cout << " " << house[i][j][k];
			}
			cout << endl;
		}
		if(i != 3){
			for(int s=0;s<20;s++) cout << "#";
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 1000000100000000000
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define st size_t
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=1005;
const int NN=1000001;
const ll md=998244353;



int main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    int n,m,k;
    cin >> n >> m >> k;
    int a[15][N]={0};
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            char z;
            cin >> z;
            a[i][j]=z-'0';
        }
    }
    ll ans=n-1+m-1;
    for (int s=0;s<(1<<(n-1));s++){
        ll ta=0;
        int r[15]={0};
        for (int i=1;i<n;i++){
            if (((s>>(i-1))&1)){r[i]=1;ta++;}
            //cout << r[i] << " ";
        }
        //cout << E;
        r[n]=1;
        int klp=1;
        vii p[15];
        for (int i=1;i<=n;i++){
            if (r[i]){
                p[klp].push_back(i);
                klp++;
            }else{
                p[klp].push_back(i);
            }
        }
        klp--;
        //cout << "=====" << E;
        for (int o=1;o<=klp;o++){
            for (auto x:p[o]){
                //cout << x << " ";
            }
            //cout << E;
        }
        int prefs[15]={0};
        for (int i=1;i<=m;i++){
            for (int j=1;j<=klp;j++){
                int qq=0;
                for (auto x:p[j]){
                    qq+=a[x][i];
                }
                //cout << qq << E;
                if (qq>k){
                    ta=oo;
                    break;
                }else {
                    if (prefs[j]+qq>k){
                        ta++;
                        //cout << "===" << i << " " << j << E;
                        for (int o=1;o<=klp;o++){

                            prefs[o]=0;
                            for (auto x:p[o]){
                                prefs[o]+=a[x][i];
                            }

                        }
                        break;
                    }else {
                        prefs[j]+=qq;

                    }
                    //cout << prefs[j] << " ";
                }
            }
            if (ta==oo)break;


        }
        //cout << E;
        //cout << ta << E;
        ans=min(ans,ta);
    }
    cout << ans << E;
    r0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll a, b;
    cin >> a >> b;
    ll cnt = 0;

    for (ll i = a; i <= b; i++)
    {
        if (i == 0)
        {
            cout << "Zero" << endl;
            exit(0);
        }
        if (i < 0)
        {
            cnt++;
        }
    }
    if (cnt % 2 == 0)
    {
        cout << "Positive" << endl;
    }
    else
    {
        cout << "Negative" << endl;
    }
    
}

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

using namespace std;

constexpr int MAXN = 2e5 + 5, MOD = 1e9 + 7;

int n, m, q, x, y;
array<int, MAXN> arr, brr;
string s;

int main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i] >> brr[i];
        if (i >= 3) {
            bool judge = true;
            for (int j = i; j >= i - 2; j--) {
                if (arr[j] != brr[j]) judge = false;
            }
            if (judge) return cout << "Yes" << endl, 0;
        }   
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3656
n = int(input())
h = list(map(int, input().split()))

dp = [0] * n
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
    dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),
                dp[i - 1] + abs(h[i] - h[i - 1]))

print(dp[n - 1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
 
const int inf = int(1e9);
const int mod = 1e9 + 7;
const int N = 1e6 + 555;
const long double PI = acos(-1.0);
void solve()
{	
	double sum = 0;
	int n;
	cin >> n;
	rep(i, n){
		double x;
		cin >> x;
		sum += 1.0 / x;
	}
	cout << fixed << setprecision(5) << 1.0 / sum;
}
int main()
{
	Red;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 20)

ll a[MAXN];
ll n, k;
multiset<ll> s;
ll ss[MAXN];

map<int, int> cnt;

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] = (a[i] + k - 1) % k;
	}
	ll sum = 0;
	cnt[0]++;	
	ll ret = 0;
	for (int i = n - 1; i >= 0; i--) {
		sum += a[i];
		sum %= k;
		ss[i] = sum;
		if (i + k <= n) {
			cnt[ss[i + k]]--;
		}
		//cerr << s.count(sum);
		ret += cnt[sum];
		cnt[sum]++;
	}
	cout << ret << endl;
	return 0;
}


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

int main() {
	int n; cin >> n;
	vector<long long>a(n); for (auto&& x : a)cin >> x;
	bool done = false;
	long long ans = 0;
	while (!done) {
		done = true;
		for (int i = 0; i < n; i++) if (a[i] >= n) {
			done = false;
			long long del = a[i] / n;
			ans += del;
			a[i] -= del * n;
			for (int j = 0; j < n; j++) if (j != i) a[j] += del;
		}
	}
	cout << ans << endl;

	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 n = sc.nextInt();
    int m = sc.nextInt();
    int l = sc.nextInt();
    long sum;
    int[][] a = new int[n][m];
    int[][] b = new int[m][l];
    long[][] c = new long[n][l];
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < m; j++) {
        a[i][j] = sc.nextInt();
      }
    }
    for(int i = 0; i < m; i++) {
      for(int j = 0; j < l; j++) {
        b[i][j] = sc.nextInt();
      }
    }
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < l; j++) {
        sum = 0;
        for(int k = 0; k < m; k++) {
          sum += a[i][k] * b[k][j];
        }
        c[i][j] = sum;
        if(j == l - 1) {
          System.out.println(c[i][j]);
        } else {
          System.out.print(c[i][j] + " ");
        }
      }
    }
  }
}



Measured memory_bytes: 53568
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int solve(long long int n){
	if(n==2){return 3;}
	else if(n==4||n==6||n==9||n==11){return 2;}
	else{return 1;}
}

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b;
	if(a==b){cout<<"Draw";}
	else if(a==1){cout<<"Alice";}
	else if(b==1){cout<<"Bob";}
	else if(a>b){cout<<"Alice";}
	else {cout<<"Bob";}



	cout<<endl;
} 


Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <iomanip>
#include <bitset>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
ll mod=1e9+7;
ll powMod(ll x, ll y)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = x*x % mod;
    }
    return res;
}

ll modInv(ll a){
	return powMod(a,mod-2);
}
ll nCr(ll n,ll r){
	ll den=1,num=1;
	loop(r,i,0){
		den=den*(i+1)%mod;
		num=num*(n-i)%mod;
	}
	return num*modInv(den)%mod;
}
int main() {
	ll n,a,b;cin>>n>>a>>b;
	ll res=powMod(2,n)-nCr(n,a)-nCr(n,b)-1;
	while(res<0)res+=mod;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
using namespace std;

int main(){
    string s;
    cin >> s;
    int l;
    l = s.length();
    for (int i = 0; i < l-8; i++){
        cout << s[i];
    }
    cout << " ";
    for (int i = l-8; i < l; i++){
        cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n;
    cin>>n;
    int l,r;
    int a=0;
    for(int i=0;i<n;i++){
        cin>>l>>r;
        a+=r-l+1;
    }
    cout<<a;
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s; cin >> s;
  ll ans=1,pos=1,n=s.size();
  string s_i   = to_string(s[0]);
  string s_i_1 = to_string(s[pos]);
  while (pos < n) {
    s_i_1 = to_string(s[pos]);
    if (s_i_1 != s_i) ans+=1;
    if (s_i_1 == s_i && pos < n-1) {
      while (pos < n-1 && s_i_1 == s_i) { s_i_1 += to_string(s[pos+1]); pos+=1;}
      ans += 1;
    }
    s_i = s_i_1; pos+=1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  string b;
  cin >> b;
  for(int i = 0;i < b.length() && i < a;i++)
  {
    cout << b[i];
  }
  if(a < b.length()){
    cout << "...";
  }
  return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <climits>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string.h>
#include <utility>
#include <vector>
using namespace std;

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define REPR(i, n) for(int i = n-1; 0 <= i; i--)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define FORR(i, s, e) for(int i = s; e <= i ; i--)
#define LLI long long int
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main(){
    int M;
    cin>>M;
    cout<<48-M;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
int n,p[101000],s[101000],vis[101000];
ll a[101000];
vector<pair<int,int> > ans;
map<ll,int> mp;
int main(){
	read(n);
	for(int i=1;i<=n;i++){
		read(a[i]);mp[a[i]]=i;
		p[i]=i;s[i]=1;
	}
	sort(p+1,p+n+1,[&](int x,int y){
		return a[x]>a[y];
	});
	ll res=0;
	for(int i=1;i<n;i++){
		int x=p[i];
		mp.erase(a[x]);
		ll pos=a[x]+s[x]-(n-s[x]);
		if(!mp.count(pos)){puts("-1");return 0;}
		ans.emplace_back(x,mp[pos]);
		s[mp[pos]]+=s[x];res+=s[x];
	}
	if(a[p[n]]!=res){puts("-1");return 0;}
	for(auto pr:ans){
		cout<<pr.first<<' '<<pr.second<<'\n';
	}
	return 0;
}


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

using namespace std;


bool used[14];
int num[14];

bool ok;

int glv;

int ccc=0;

bool dfs(){
	if(ok)
		return true;

	vector<int> idxs;
	for(int i = 0; i < 14; i++){
		if(!used[i])
			idxs.push_back(i);
	}
	if(idxs.size()==2){
		if(num[idxs[0]]==num[idxs[1]]){
			if(glv==7){
			//	cout<<endl;
			}
			ok=true;
			return true;
		}
	}
	else{
		for(int k = 0; k < idxs.size(); k++){
			// OÂIÔ
			int idx = idxs[k];
			int idx2=-1;
			for(int i = 0; i < 14; i++){
				if(num[i]==num[idx]+1&&!used[i]){
					idx2=i;
				}
			}
			int idx3=-1;
			for(int i = 0; i < 14; i++){
				if(num[i]==num[idx2]+1&&!used[i]){
					idx3=i;
				}
			}
			if(!(idx2==-1||idx3==-1)){
				used[idx]=true;
				used[idx2]=true;
				used[idx3]=true;
				bool r = dfs();
				if(r)
					return true;
				used[idx]=false;
				used[idx2]=false;
				used[idx3]=false;
			}
			
			// ¯¶âÂðÝÁÂIÔ
			idx2=idx3=-1;
			for(int i = 0; i < 14; i++){
				if(!used[i]&&num[idx]==num[i]&&i!=idx){
					if(idx2==-1){
						idx2=i;
					}
					else{
						idx3=i;
						break;
					}
				}
			}
			if(!(idx2==-1||idx3==-1)){
				used[idx]=true;
				used[idx2]=true;
				used[idx3]=true;
				bool r = dfs();
				if(r)
					return true;
				used[idx]=false;
				used[idx2]=false;
				used[idx3]=false;
			}
		}
	}	
	return false;
}

int main(){

	int cnt[10];

	while(1){
		fill(cnt,cnt+10,0);
		vector<int> v;
		bool f=false;
		for(int i = 0; i < 13; i++){
			char ch;
			cin>>ch;
			num[i]=ch-'0';
			cnt[num[i]]++;
		}
		if(cin.eof())
			break;
		for(int i = 1; i <= 9; i++){
			ok=false;
			if(cnt[i]==4)
				continue;
			num[13]=i;
		//	sort(num,num+14);
			// ðªÅ«Ä¢é©Ç¤©
			fill(used,used+14,false);

			glv=i;
			// ðªÅ«½ê
			if(dfs()){
				v.push_back(i);
			}
		}
		if(v.size()==0)
			cout<<0<<endl;
		else{
			for(int i = 0; i < v.size(); i++){
				cout<<v[i];
				if(i==v.size()-1)
					cout<<endl;
				else
					cout<<" ";
			}
		}
		ccc++;
		if(ccc==4){
//			cout<<endl;
		}
	}

	return 0;
}

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

counter_min = n

for i in range(n+1):
  counter = 0
  n_six = i
  n_nine = n-i

  # 6
  j = 1
  while True:
    if  n_six >= 6**j:
      j += 1
    else:
      div_n = 6**(j-1)
      break
  
  while n_six > 0:
    counter += n_six // div_n
    n_six %= div_n
    div_n //= 6 
    
  # 9
  j = 1
  while True:
    if  n_nine >= 9**j:
      j += 1
    else:
      div_n = 9**(j-1)
      break
        
  while n_nine > 0:
    counter += n_nine // div_n
    n_nine %= div_n
    div_n //= 9
  
  counter_min = min(counter, counter_min)

print(counter_min)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::pair;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=pair<ll,ll>;
const ll MOD=1e9+7;//998244353;
const int MAX=1e5;
const ll INF=(1ll<<62)-1;
bool judge(int N,vi &A,int X){
    if(X==1){
        rep(i,1,N){
            if(A[i-1]>=A[i]) return 0;
        }
        return 1;
    }
    std::map<int,int,std::greater<int>> num;
    rep(i,1,N){
        if(num.size()==0){
            if(A[i-1]>=A[i]) num[A[i]]++;
        }
        else if(A[i-1]>=A[i]){
            for(auto p:num){
                if(p.first>A[i]) num.erase(p.first);
                else break;
            }
            num[A[i]]++;
            per(j,A[i],1){
                if(num[j]==X){
                    num.erase(j);
                    num[j-1]++;
                }
                else break;
            }
            if(num[0]==1){
                return 0;
            }
        }
    }
    return 1;
}
signed main(){
    int N; cin>>N;
    vi len(N);
    rep(i,0,N) cin>>len[i];
    int left=1,right=N;
    while(left+1<right){
        int mid=(left+right)/2;
        if(judge(N,len,mid)) right=mid;
        else left=mid;
    }
    int ans=right;
    if(judge(N,len,left)) ans=left;
    cout<<ans<<endl;
}
 
 



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);

void solve(){
    int n ,m; cin >>n>>m;
    //vector<int> a(n+1);
    int tmpl = 1, tmpr = n;
    REP(i, m){
        int l, r;
        cin >> l >> r;
        tmpl = max(tmpl, l);
        tmpr = min(tmpr, r);
    }
    if(tmpl == tmpr) cout << 1 << endl;
    else if(tmpl < tmpr) cout << tmpr - tmpl + 1 << endl;
    else cout << 0 << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if( A+B-C-D >0 ){
    cout << "Left" << endl;
  }
  else if( A+B-C-D <0 ){
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
int main(){
int a,b;scanf("%d%d",&a,&b);
double ret=0;
for(int i=1;i<=a;i++){
double tmp=1.0/a;
int now=i;
while(now<b){
now*=2;
tmp/=2;
}
ret+=tmp;
}
printf("%.12f\n",ret);
}

Measured memory_bytes: 256
N = int(input())
S = str(input())
# '.'の場合は白, '#'の場合は黒

if S[0] == '.':
    count_white = [1]
    count_black = [0]
else:
    count_white = [0]
    count_black = [1]


for i in range(1, N):
    if S[i] == '.':
        # 見ている石が白なら
        count_white.append(count_white[i-1]+1)
        count_black.append(count_black[i-1])
    else:
        # 見ている石が黒なら
        count_white.append(count_white[i-1])
        count_black.append(count_black[i-1]+1)

tmp = 9999999999
for i in range(1, N):
    min_sum = 0
    min_sum += count_black[i-1]
    min_sum += (count_white[N-1] - count_white[i])
    tmp = min(tmp, min_sum)

# print(tmp)

cnt = 0
target = S[0]
for i in range(1, N):
    if target == '#' and S[i] == '.':
        cnt += 1
        target = '#'  # 黒に変える
        continue

    if S[i] == '#':
        target = '#'
    else:
        target = '.'

cnt_2 = 0
aim = S[-1]
for i in range(N-1, -1, -1):
    if aim == '.' and S[i] == '#':
        cnt_2 += 1
        aim = '.'
        continue

    if S[i] == '#':
        aim = '#'
    else:
        aim = '.'


print(int(min(cnt, cnt_2, tmp)))



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

int main() {
    int N, K, x;
    cin >> N >> K;
    int S=0;
    for(int i = 0; i < N; ++i) {
        cin >> x;
        if(K/2.0 > x){
            S += 2*x;
        } else {
            S += K*2 - x*2;
        }
    }
    cout << S << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
int a;
int b;
char op;
scanf("%d %c %d",&a,&op,&b);

while (op != '?'){
if (op == '+'){
printf("%d\n",a+b);
}else if (op == '-'){
printf("%d\n",a-b);
}else if (op == '*'){
printf("%d\n",a*b);
}else if (op == '/'){
printf("%d\n",a/b);
}
scanf("%d %c %d",&a,&op,&b);
}

return 0;
}


Measured memory_bytes: 2044
n = int(input())
a = list(map(int,input().split()))
ans = 0
now = 1
if 1 in a:
    for i in range(n):
        a_ = a[i]
        if a_ == now:
            now += 1
        else:
            ans += 1
    print(ans)
else:
    print(-1)

Measured memory_bytes: 24744