akhauriyash/Code-Regression huggingface dataset:
N, X = map(int,input().split())
def dfs(L, X):
    if X == 1:
        if L == 0:
            return 1
        else:
            return 0
    elif 2 <= X <= 2 ** (L + 1) - 2:
        return dfs(L - 1, X - 1)
    elif X == 2 ** (L + 1) - 1:
        return 2 ** L
    elif 2 ** (L + 1) <= X <= 2 ** (L + 2) - 4:
        return 2 ** L + dfs(L-1, X - 2 ** (L + 1) + 1)
    else:
        return 2 ** (L + 1) - 1
print(dfs(N, X))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();

	if(-1000<=a && b<=1000){
		if(a<b){
			System.out.println("a < b");
		}
		else if (a > b){
			System.out.println("a > b");
		}
		else if (a == b){
			System.out.println("a == b");
		}
	}

	sc.close();
}
}

Measured memory_bytes: 26292
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    S = input()
    T = input()

    if S == T[:-1]:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 68736
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

    ll operator"" _64(unsigned long long x){ return ll(x); }
    ull operator"" _64u(unsigned long long x){ return ull(x); }

    template<typename T> vector<T> make_vector(size_t sz, T t){
        return vector<T>(sz, t);
    }

    template<typename T,typename... Ts>
    auto make_vector(size_t sz, Ts... ts){
        return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
    }

    template<class T>
    ostream& operator<<(ostream& os, const vector<T>& v){
        for (auto &&x : v) { os << x << ' '; } return os ;
    }
}
using namespace utils;

template<class T>
vector<T> make_vector(int n, T t){
    return vector<T>(n, t);
}
template<class ...Ts>
auto make_vector(int n, Ts ... ts){
    return vector<decltype(make_vector(ts...))>(n, make_vector(ts...));
}


class solver{

public:
    void run(istream &is, ostream& os){
        ll X, A;
        is >> X >> A;
        if(!is) return;
        cout << (X < A ? "0" : "10")  << endl;
    }
};

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_A.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        solver().run(fs, cout);
    }
    cout << "------#" << endl;
    if(lp <= 1) {
        while(cin) solver().run(cin, cout);
    }
#else
    solver().run(cin, cout);
#endif
    return 0;
}


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

const int maxv = 100010;
// 頂点数，辺数
int v, e;
vector<int> g[maxv];
bool used[maxv];
// トポロジカルソートされた数列
vector<int> ans;

void dfs(int u) {
    if (used[u]) return;
    used[u] = true;
    for (auto& i : g[u]) dfs(i);
    // 帰りがけ順で追加
    ans.push_back(u);
}

void tsort() {
    for (int i=0; i<v; ++i) dfs(i);
    reverse(ans.begin(), ans.end());
}

int main() {
    cin >> v >> e;
    for (int i=0; i<e; ++i) {
        int s, t;
        cin >> s >> t;
        g[s].push_back(t);
    }

    tsort();
    for (int i: ans) cout << i << endl;

    return 0;
}



Measured memory_bytes: 6004
x,y = map(int, input().split())

if (x+y)%3 != 0:
    print(0)
    exit()

if 2*y<x or y>2*x:
    print(0)
    exit()

dan = (x+y)//3+1
num=y-dan+1

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def comb(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

ans = comb(dan-1,num)
print(int(ans))

Measured memory_bytes: 40172
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
int ans[51][51];
int main(){
	int H,W;
	cin>>H>>W;
	string S[50];
	rep(i,H)cin>>S[i];
	int dy[8]={1,1,1,0,0,-1,-1,-1};
	int dx[8]={-1,0,1,-1,1,-1,0,1};
	rep(i,H){
		rep(j,W){
			rep(k,8){
				if(i+dy[k]<0||i+dy[k]>=H)continue;
				if(j+dx[k]<0||j+dx[k]>=W)continue;
				if(S[i+dy[k]][j+dx[k]]=='#'){
					ans[i][j]++;
				}
			}
		}
	}
	rep(i,H){
		rep(j,W){
			if(S[i][j]=='#'){
				cout<<S[i][j];
				continue;
			}
			cout<<ans[i][j];
		}
		cout<<endl;
	}
	return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
vector<int> E[606];
double dp[606],dp2[606];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
	}
	
	for(i=N-2;i>=0;i--) {
		FORR(e,E[i]) dp[i]+=1+dp[e];
		dp[i]/=E[i].size();
	}
	
	FOR(i,N) dp2[i]=dp[i];
	
	double ret=dp[0];
	for(i=N-2;i>=0;i--) if(E[i].size()>=2) {
		vector<double> V;
		FORR(e,E[i]) V.push_back(dp[e]);
		sort(ALL(V));
		V.pop_back();
		
		dp2[i]=0;
		FORR(v,V) dp2[i]+=1+v;
		dp2[i]/=V.size();
		
		for(j=i-1;j>=0;j--) {
			dp2[j]=0;
			FORR(e,E[j]) dp2[j]+=1+dp2[e];
			dp2[j]/=E[j].size();
		}
		ret=min(ret,dp2[0]);
		

		
		for(j=i;j>=0;j--) dp2[j]=dp[j];
	}
	
	_P("%.12lf\n",ret);
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1408
x1,y1,x2,y2 = map(int, input().split())
ylen = y2 - y1
xlen = x2 - x1

x3 = x2 - ylen
y3 = y2 + xlen
x4 = x3 - xlen
y4 = y3 - ylen

print(str(x3) + " " + str(y3) + " " + str(x4) + " " + str(y4))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int h,w;
char c[110][110];
int d[110][110];
signed main(){
    cin>>h>>w;
    rep(i,h){
        rep(j,w){
            cin>>c[i][j];
            d[i][j]=INF;
        }
    }
    if(c[0][0]=='#')d[0][0]=1;
    else d[0][0]=0;
    rep(i,h){
        rep(j,w){
            if(i)chmin(d[i][j],d[i-1][j]+(c[i-1][j]=='.'&&c[i][j]=='#'));
            if(j)chmin(d[i][j],d[i][j-1]+(c[i][j-1]=='.'&&c[i][j]=='#'));
        }
    }
    cout<<d[h-1][w-1]<<endl;
    return 0;
}


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

using namespace std;

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

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

   rep(i,s.size()){
      int cnt = 0;
      rep(j,s.size()){
         if(s[i] == s[j]) cnt++;
      }
      if(cnt % 2 != 0){
         cout << "No" << endl;
         return 0;
      }
   }
   cout << "Yes" << endl;

   return 0;
}

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

int main() {
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3852
import java.util.ArrayList;
import java.util.Scanner;

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

		String string = sc.nextLine();
		String[] a = string.split(" ");
		ArrayList<Integer> number = new ArrayList<>();

		for (int i = 0; i < a.length; i++) {

			if (a[i].equals("+")) {
				int p = number.get(number.size() - 1);
				number.remove(number.size() - 1);
				int q = number.get(number.size() - 1);
				number.remove(number.size() - 1);
				number.add(p + q);
				continue;

			}
			if (a[i].equals("-")) {
				int p = number.get(number.size() - 2);
				number.remove(number.size() - 2);
				int q = number.get(number.size() - 1);
				number.remove(number.size() - 1);
				number.add(p - q);
				continue;
			}
			if (a[i].equals("*")) {
				int p = number.get(number.size() - 1);
				number.remove(number.size() - 1);
				int q = number.get(number.size() - 1);
				number.remove(number.size() - 1);
				number.add(p * q);
				continue;
			}

			int n = Integer.parseInt(a[i]);
			number.add(n);

		}

		System.out.println(number.get(0));

	}
}

Measured memory_bytes: 26128
#include <bits/stdc++.h>
#define MOD 1000000007
#define MAX	200000
typedef long long int ll;            
using namespace std;

ll invs[MAX+1];

ll power( ll base, ll pow){
    if( pow == 0 ) return 1;
    if( pow % 2 == 0 ){
        ll tmp = power( base, pow/2);
        return (tmp * tmp) % MOD;
    }
    else{
        return (base * power( base, pow - 1)) % MOD;
    }
}
ll divide_mod( ll a, ll b )
{
	return (a*power(b,MOD-2))%MOD ;
}

int main(){
   // We have to Find the No of Ways to go from (0,0) to (k,B-1) {where K < H-A} , Suppose it is a list P[k]
   // Then we have to find the No of Ways to go from (k,B) to (H-1,B-1), Suppose it is a list R[k]
   // Then the Answer is Sum of P[k]*R[k] for all values of k
   ll H,W,A,B,res=0,P,Q;
   cin>>H>>W>>A>>B;
   ll N = H+W;
	vector<ll> factorial(N+1,1);
	for( int i = 2 ; i <= N ; ++i ) {
		factorial[i] = i*factorial[i-1] ;
		factorial[i] %= MOD ;
	}
   for(int i=0;i<H-A;i++){
       P= divide_mod(factorial[B-1+i],(factorial[B-1]*factorial[i])%MOD);// We have to count the No of Ways from 0,0 to i,B-1
       Q= divide_mod(factorial[W-B-1+H-1-i],(factorial[W-B-1]*factorial[H-1-i])%MOD);    
       res=(res%MOD+(P%MOD*Q%MOD)%MOD)%MOD;              
   }
   cout<<res;
   return 0;
}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

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

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

W,a,b = inputIL()

if a < b:
  if a+W < b:
    print(b-(a+W))
    exit()
if b < a:
  if b+W < a:
    print(a-(b+W))
    exit()
print(0)

Measured memory_bytes: 38256
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 read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n = read::<u64>();
    let mut v = Vec::new();
    for _ in 0..n{
        v.push(read::<u64>()-1);
    }
    let mut m = 0;
    for i in 0..n {
        m = v[m as usize];
        if m == 1 {
            println!("{}",i+1);
            return;
        }
    }
    println!("-1");
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll N = 100030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
ll n,k;
vector<ll> v(N);
long po(long a,long b){return b?po(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
int main()
{  fast
cin>>n>>k;


ll ans=0;
for(ll i=k;i>=1;i--)
{
	v[i]=po(k/i,n);
	ll sum=v[i];
	for(ll j=i+i;j<=k;j+=i)
	{
		v[i]-=v[j];
	}
	ans+=i*v[i]%mod;
}
cout<<ans%mod<<endl;
}


Measured memory_bytes: 3840
I=input;R=range;n=int(I())
lf=[int(I()[::2],2) for _ in R(n)]
lp=[list(map(int,I().split())) for _ in R(n)]
print(max(sum(p[bin(i&f).count('1')] for f,p in zip(lf,lp)) for i in R(1,1024)))


Measured memory_bytes: 3188
import numpy as np

n = int(input())
a = np.array([int(x) for x in input().split()])
mod = 10**9+7
mod_sum = 0
a_sum = sum(a)
for i in range(n-1):
    a_sum -= a[i]
    mod_sum += (a[i] % mod) * (a_sum % mod) % mod

print(mod_sum%mod)


Measured memory_bytes: 49920
#include <stdio.h>

int main(){
   int n,i,a[100001],b[100000];
   long s;
    
   scanf("%d",&n);
   for (i=0;i<=n;i++) scanf("%d",&a[i]);
   for (i=0;i<n;i++) scanf("%d",&b[i]);
   for (s=i=0;i<n;i++)
      if (a[i]<=b[i]) {
         s+=a[i];b[i]-=a[i];
         if (a[i+1]<=b[i]) {
            s+=a[i+1];
            a[i+1]=0;
         } else {
            s+=b[i];
            a[i+1]-=b[i];
         }
      } else
         s+=b[i];
   printf("%ld\n",s);
   return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
#define NIL -1

typedef struct {
  int p, l, r;
}Tree;

Tree T[100000];
int n, s[100000];

void func1(int);
int func2(int);


int main(){
  int i, j;
  int d, v, c, l, r;

  scanf("%d", &n);

  for(i = 0 ; i < n ; i++){
    T[i].p = T[i].l = T[i].r = NIL;
  }

  for(i = 0 ; i < n ; i++){
    scanf("%d %d", &v, &d);
    for(j = 0 ; j < d ; j++){
      scanf("%d", &c);
      if(j == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }

  for(i = 0 ; i < n ; i++){
    if(T[i].p == NIL) r = i;
  }

  for(i = 0 ; i < n ; i++){
      func1(i);
  }
  return 0;
}

void func1(int i){
  int j, m;

  printf("node %d: parent = %d, depth = %d, ", i, T[i].p, func2(i));

  if(T[i].p == NIL) printf("root, [");
  else if(T[i].l == NIL) printf("leaf, [");
  else printf("internal node, [");


  if(T[i].l != NIL){
            printf("%d",T[i].l);
            m = T[i].l;
            while(1){
                if(T[m].r == NIL) break;
                printf(", %d", T[m].r);
                m = T[m].r;
            }
        }
  printf("]\n");
}

int func2(int i){
  if(T[i].p == NIL) return 0;
  return func2(T[i].p) + 1;
}



Measured memory_bytes: 2912
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	string S;
	cin >> S;
	int i;
	char s[4];
	int t = 0;
	int count1 = 0, count2 = 0;
	s[0] = S[0];
	if (S[0] == S[1]) {
		if (S[2] == S[3]) {
			if(S[0]!=S[2])
			cout << "Yes";
			else
			cout << "No";

		}
		else {
			cout << "No";
		}
	}
	else if (S[0] == S[2]) {
		if (S[1] == S[3]) {
			if(S[0]!=S[1])
			cout << "Yes";
			else
			cout << "No";
		}
		else {
			cout << "No";
		}
	}
	else if (S[0] == S[3]) {
		if (S[1] == S[2]) {
			if(S[0]!=S[1])
			cout << "Yes";
			else
				cout << "No";
		}
		else {
			cout << "No";
		}
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	long long int h,w,x;
	scanf("%lld %lld",&h,&w);
		if(h==1||w==1)
	{
		printf("1");
		return 0;
	}
	x=h*w;
	if(x%2==0)
	x=x/2;
	else
	x=x/2+1;
	printf("%lld",x);
	return 0;
}


Measured memory_bytes: 128
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)
ans = 'No'
N = int(input())
digitSum = digitSum(N)
if digitSum % 9 == 0:
    ans = 'Yes'
print(ans)


Measured memory_bytes: 11156
s =list(input())
 
a=[0]*2
b=[0]*2
 
for i in range(2):
  s[i]=str(s[i])
  s[i+2]=str(s[i+2])
  a[i]=s[i]
  b[i]=s[i+2]
 
c = int(''.join(a))
d = int(''.join(b))
cnc=0
cnd=0
 
if c>0:
  if c<13:
    cnc=2
  else:
    cnc=1
 
if d>0:
  if d<13:
    cnd=2
  else:
    cnd=1
 
if cnc==0:
  if cnd==2:
    print("YYMM")
  else:
    print("NA")
    exit()
if cnc==1:
  if cnd==1:
    print("NA")
  elif cnd==2:
    print("YYMM")
  else:
    print("NA")
elif cnc==2:
  if cnd==1:
    print("MMYY")
  elif cnd==2:
    print("AMBIGUOUS")
  else:
    print("MMYY")

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX

typedef long long ll;
typedef pair<int, int> ii;

int main(){

  int a, b, h;
  cin >> a >> b >> h;
  cout << (a+b)*h/2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;


int main(void) {
    string s, t;
    cin >> s >> t;
    if (t.find(s) == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <utility>
#include <queue>
using namespace std;

int H, W, N, sy, sx, ans, d[10000][10000];
char c[10000][10000];
int dy[4] = {1, -1, 0, 0}, dx[4] = {0, 0, 1, -1};

void bfs() {
    ans = 0;
    for (int i = 1; i <= N; ++i) {
        queue< pair<int, int> > que;
        que.push(pair<int, int>(sy, sx));
        for (int y = 0; y < H; ++y) {
            for (int x = 0; x < W; ++x) d[y][x] = -1;
        }
        d[sy][sx] = 0;
        while (que.size()) {
            pair<int, int> p = que.front();
            que.pop();
            if (c[p.first][p.second] - '0' == i) {
                sy = p.first;
                sx = p.second;
                ans += d[p.first][p.second];
                break;
            }
            for (int j = 0; j < 4; ++j) {
                int ny = p.first + dy[j], nx = p.second + dx[j];
                if (ny >= 0 && ny < H && nx >= 0 && nx < W && c[ny][nx] != 'X' && d[ny][nx] == -1) {
                    que.push(pair<int, int>(ny, nx));
                    d[ny][nx] = d[p.first][p.second] + 1;
                }
            }
        }
    }
}

int main() {
    cin >> H >> W >> N;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> c[i][j];
            if (c[i][j] == 'S') {
                sy = i;
                sx = j;
            }
        }
    }
    bfs();
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MAX_COMB = 4e5 + 3;
const LL mod = 1e9 + 7;
LL fct[MAX_COMB+1];
LL invfct[MAX_COMB+1];

void build(){
	fct[0] = fct[1] = 1;
	repp(i,2,MAX_COMB+1){
		fct[i] = fct[i-1] * i % mod;
	}
	LL x = fct[MAX_COMB];
	invfct[MAX_COMB] = 1;
	for(int i = mod - 2 ; i > 0 ; i >>= 1){
		if(i % 2 == 1) (invfct[MAX_COMB] *= x) %= mod;
		(x *= x) %= mod;
	}
	repm(i,MAX_COMB,0){
		invfct[i-1] = invfct[i] * i % mod;
	}
}

LL comb(int x, int y){
	if(x < 0 || y < 0 || x < y) return 0;
	return fct[x] * invfct[y] % mod * invfct[x-y] % mod;
}

int main(){
	build();
	int B,W; cin >> B >> W;
	LL half = (mod+1)/2;
	LL ans = half;
	LL z = 1;
	repp(i,0,B+W){
		z = z*half%mod;
		ans = (ans+z*(comb(i-1,W-1)+mod-comb(i-1,B-1)))%mod;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 8448
N, T = map(int, input().split())
A = [int(i) for i in input().split()]

B = []
for i in range(N - 1):
    B.append(A[i + 1] - A[i])
    
ans = T
for i in range(N - 1):
    ans += min(B[i], T)
    
print(ans)

Measured memory_bytes: 25196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll, ll, ll>>>;

// MOD確認

ll tableF[200010];
ll tableI[200010];

ll modfact(ll a,ll m){
   if(tableF[a] != -1){
      return tableF[a];
   }
   if(a == 1){
      tableF[a] = 1;
      return tableF[a];
   }
   ll res = 1;
   res = a * modfact(a-1,m);
   res %= m;
   tableF[a] = res;
   return res;
}

ll modpow(ll a,ll n,ll m){//modpow(a,n,m) := a ^ n (mod m)
  ll res = 1;
  while(n > 0){
    if(n & 1)res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a,ll p){//modinv(a,p) := pを法とするaの逆元(※pは素数でなければならない)
    ll res = modpow(a,p-2,p);
    return res;
}

ll modCON(ll n,ll r,ll m){
   if(n < 200010){
   ll res = 1;
   if(n < 0 || r < 0 || n < r){
      return 0;
   }
   res *= tableF[n];
   res %= m;
   res *= tableI[r];
   res %= m;
   res *= tableI[n-r];
   res %= m;
   return res;
   }else{
   ll res = 1;//tableを持ってないときよう
   for(int i = 1;i <= n;i++){
      res *= i;
      res %= m;
   }
   for(int i = 1;i <= r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   for(int i = 1;i <= n-r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   return res;
   }
}

void modfill(ll m){//忘れない　約200ms
   fill(tableF,tableF+200010,-1);
   fill(tableI,tableI+200010,-1);
   tableF[0] = 1;
   tableI[0] = 1;
   for(int i = 1;i < 200010;i++){
      tableF[i] = modfact(i,m);
      tableI[i] = modinv(tableF[i],m);
   }
}

int main(){
   char S;
   cin >> S;
   rep(i,26){
      if(S == char('a' + i)) {
         cout << 'a' << endl;
         return 0;
      }
   }
   cout << 'A' << endl;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  if (n % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[(int)(n / 2) + i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int a;
  int b;
  int c;
  int d;

  scanf("%d%d",&a,&b);

  if(a<b){
    c = a;
    a = b;
    b = c;
  }

  d = a % b;
  while(d!=0){
  a = b;
  b = d;
  d = a % b;
  }
  
    printf("%d\n",b);

    return 0;
  }

Measured memory_bytes: 592
use proconio::marker::*;
use proconio::*;

fn main() {
    input! {
        n: usize,
        mut c: Chars,
    };
    let mut l: usize = 0;
    let mut r: usize = c.len() - 1;
    let mut ans = 0;

    'outer: while l < r {
        while c[l] == 'R' {
            l += 1;
            if l == c.len() || l >= r {
                break 'outer;
            }
        }

        while c[r] == 'W' {
            if r == 0 || l >= r {
                break 'outer;
            }
            r -= 1;
        }

        c.swap(l, r);
        ans += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 3024
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N, X, T = MI()
    print(T * ceil(N / X))

if __name__ == '__main__':
    solve()



Measured memory_bytes: 9220
n = int(input())
a = list(map(int, input().split()))
result = []
i = n - 1
while i >= 0:
  result.append(a[i])
  i -= 2
i += 1
if i < 0:
  i += 2
while i < n:
  result.append(a[i])
  i += 2
print(*result)


Measured memory_bytes: 26180
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
ll INF = 9999999999999999;

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;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}
 
int main(void){
    int N; cin >> N;
    int t1 = 0, x1 = 0, y1 = 0;
    
    bool OK = true;
    for(int i = 0; i < N; i++){
        int t2, x2, y2; cin >> t2 >> x2 >> y2;
        int delta_t = abs(t2 - t1);
        if(abs(x2 - x1) > delta_t) OK = false;
        if(abs(y2 - y1) > delta_t) OK = false;
        if( (abs(x2 - x1) + abs(y2 - y1)) % 2 != delta_t % 2) OK = false;
        if(!OK) break;
        t1 = t2;
        x1 = x2;
        y1 = y2;
    }
    if(OK) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
s=list(input())
t=list(input())
flag=0
for i in range(0,len(s)):
    if s==t:
        flag=+1
        break
    else:
        s.insert(0,s.pop())
if len(s)==2:
    if s==t:
        flag=+1
    else:
        s.insert(0,s.pop())
        if s == t:
            flag = +1
if flag>0:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<vector>

using namespace std;

void solve(string s){
    int a[2] = {};
    for(int i = 1; i < s.size(); i++){
        a[s[i]-'A']++;
    }
    a[0]<a[1] ? a[1]++ : a[0]++;
    cout << a[0] << " " << a[1] << endl;

}


int main(){
    string s;
    while(cin >> s, s != "0"){
        solve(s);
        cin >> s;
        solve(s);
        cin >> s;
        solve(s);
    }
}



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

using namespace std;

#define ll long long 
#define REPL(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 10010;
static const ll INFTY = 1e12;
static const ll NUMMAX = 1000000007;
static const ll MOD = 1000000007;
 #define LOOP 10000000

int main() {

    int N;
    vector<int> a;
    int num = 1;
    int count = 0;

    cin >> N;
    a.resize(N);

    REP(i, N){
        cin >> a[i];
    }

    REP(i, N){
        if( a[i] == num ){
            num++;
        } else {
            count++;
        }
    }
    if( count == N )count = -1;

    cout << count << endl;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 1024
n, k = map(int, input().split())

X = list(map(int, input().split()))
ans = 10**9
start= 0
end=k
n+=1
X.append(0)
X.sort()
for i in range(n-k):
  maximam = X[end]
  minimam = X[start]
  if maximam > 0 and  minimam < 0:
    ans = min(ans, maximam+abs(minimam)+min(maximam, abs(minimam)))
  elif minimam == 0:
    ans = min(maximam, ans)
  elif maximam == 0:
    ans = min(abs(minimam), ans)
  start+= 1
  end+=1
print(ans)

Measured memory_bytes: 14568
import java.io.*;
import java.util.*;
import java.util.function.DoublePredicate;
import java.util.function.DoubleUnaryOperator;
 
public class Main{
	public void solve(){
		int N = nextInt();
		int K = nextInt();
		boolean[] kirai = new boolean[11];
		
		for(int i = 0; i < K; i++){
			kirai[nextInt()] = true;
		}
		
		
		while(true){
			int tmp = N;
			boolean clear = true;
			while(tmp > 0){
				int t = tmp % 10;
				if(kirai[t]){
					clear = false;
					break;
				}
				tmp = tmp / 10;
			}
			if(clear){
				out.println(N);
				break;
			}
			N++;
		}
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

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

#define mod 1000000007

bool able(std::vector<int>&);

int main()
{
	int n;
	scanf("%d", &n);
	std::vector<int> a(n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	if (n % 2) a.push_back(0);
	std::sort(a.begin(), a.end());
	if (able(a))
	{
		long long ans{1};
		n /= 2;
		for (int i = 0; i < n; i++)
		{
			ans *= 2;
			ans %= mod;
		}
		printf("%lld\n", ans);
	}
	else
		printf("0\n");

	return 0;
}

bool able(std::vector<int>& a)
{
	int odd{a[0]};
	for (unsigned int i = 0; i < a.size(); i++)
	{
		if (a[i] != i / 2 * 2 + odd) return false;
	}
	return true;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main()
{

  string S, T;
  cin >> S >> T;
  vector<int> start(26, -1);
  vector<int> goal(26, -1);

  for (int i = 0; i < S.size(); i++)
  {

    int a = S[i] - 'a';
    int b = T[i] - 'a';

    if (start[a] != -1 || goal[b] != -1)
    {
      if (start[a] != b || goal[b] != a)
      {
        cout << "No" << endl;
        return 0;
      }
    }
    else
    {
      start[a] = b;
      goal[b] = a;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 776
// Problem : E - Independence
// Contest : AtCoder Regular Contest 099
// URL : https://atcoder.jp/contests/arc099/tasks/arc099_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()

const int N = 777, mod = 1e9 + 7;

set<int> s0, s1;
vector<int> adj[N];
bool vis[N], dp[N][N];
map<pair<int, int>, bool> meme;
int n, m, ans = 0, col[N];

void dfs(int v, int c = 1) {
	vis[v] = 1;
	col[v] = c;
	if (c) {
		s1.insert(v);
	} else {
		s0.insert(v);
	}
	for (auto u : adj[v]) {
		if (vis[u]) {
			if (col[u] != 1 - c) {
				cout << -1;
				exit(0);
			}
			continue;
		}
		dfs(u, 1 - c);
	}
}

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	for (int i = 1, u, v; i <= m; i++) {
		cin >> u >> v;
		meme[{u, v}] = meme[{v, u}] = 0;
	}
	for (int u = 1; u <= n; u++) {
		for (int v = u + 1; v <= n; v++) {
			if (meme.find({u, v}) == meme.end()) {
				adj[u].push_back(v);
				adj[v].push_back(u);
			}
		}
	}
	memset(col, -1, sizeof col);
	int t = 0;
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) {
			s0.clear();
			s1.clear();
			dfs(i);
			int a = size(s0), b = size(s1);
			t++;
			for (int k = 1; k <= n; k++) {
				if (k >= a) {
					dp[t][k] |= dp[t - 1][k - a];
				}
				if (k >= b) {
					dp[t][k] |= dp[t - 1][k - b];
				}
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		if (dp[t][i]) {
			ans = max(ans, i * (n - i));
		}
	}
	cout << n * (n - 1) / 2 - ans;
}


Measured memory_bytes: 31360
n,k=map(int,input().split())
a=list(map(int,input().split()))

c=[[0 for _ in range(2)] for _ in range(64)]

for i in range(n):
    for j in range(60):
        c[j][a[i]>>j&1] += 1
x=0
for i in range(59,-1,-1):
    if(c[i][0] > c[i][1] and x|(1<<i) <= k):
        x |= 1<<i

sum = 0
for i in range(n):
    sum += a[i]^x
print(sum)

Measured memory_bytes: 14620
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    int t,i,j,n,m,l,r;
    char a;
    cin>>a;
    if(a>='A' && a<='Z')
    {
        cout<<"A\n";
    }
    else
    {
        cout<<"a\n";
    }
    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> pii;
vector<int> x(10), y(10);

double distance(int i, int j){
    double dx = x.at(i) - x.at(j);
    double dy = y.at(i) - y.at(j);
    return sqrt(dx * dx + dy * dy);
}

int main() {
    int n; cin >> n;
    rep(i, n) cin >> x.at(i) >> y.at(i);
    vector<int> vec(n);
    rep(i, n) vec.at(i) = i;
    double dis_sum = 0;
    do{
        for(int i = 0; i < n-1; i++){
            dis_sum += distance(vec.at(i), vec.at(i+1));
        }
    }while(next_permutation(vec.begin(), vec.end()));
    int pattern = 1;
    for(int i = 1; i <= n; i++) pattern *= i;
    printf("%.10lf", dis_sum/pattern);
    return 0;
}


Measured memory_bytes: 3860
N, A, B = map(int,input().split())
S = input()
x = 0
y = 0
z = x + y

for i in range(N):
    if S[i] == 'a':
        if z < A + B:
            print('Yes')
            x += 1
            z = x + y
        else:
            print('No')
    elif S[i] == 'b':
        if z < A + B and y < B:
            print('Yes')
            y += 1
            z = x + y
        else:
            print('No')
    else:
        print('No')


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
double pi = acos(-1);
int main(){ 
  double r;
  cin >> r;
  printf("%.12f\n", 2.0 * r * pi);
  return 0;
} 

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int n, k;
	cin >> n >> k;
	
	if (k == 1) {
		cout << 0 << endl;
	}
	else {
		cout << n - k << endl;
	}
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple


int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int h,n; cin>>h>>n;
	vector < pair <ll,ll> > v;
	for(int i=0;i<n;i++)
	{
	    ll p,q; cin>>p>>q; 
	    v.pb(mp(p,q));
	}

    ll ans[h+1]; ans[0]=0;
    for(int i=1;i<=h;i++)
    {
        ans[i]=1e9;
        for(int j=0;j<n;j++)
        {
            
            if( i>=v[j].first )
            {
                ans[i] = min( ans[i-v[j].first]+v[j].second , ans[i]);
            }
            else ans[i]=min(ans[i],v[j].second);
        }
    }
	
	cout<<ans[h];
	
	
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
typedef long long ll;
using namespace std;

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

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

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans1=ll(b/c)-ll((a-1)/c); //cで割り切れる
    ll ans2=ll(b/d)-ll((a-1)/d); //dで割り切れる
    ll ans3=ll(b/lcm(c,d))-ll((a-1)/lcm(c,d)); //cでもdでも割り切れる
    cout << (b-a+1)-ans1-ans2+ans3<< endl;
}

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

int main()
{
  int a,b;
  cin >> a >> b;
  
  int x = 0;
  for(x = 0; x <= 1000; x++){
    if( ((int)(x*0.08) == a ) && ((int)(x * 0.1) == b ) ){
      break;
    }
  }
  
  if(x > 1000){
    x = -1;
  }
  
  cout << x << endl;
}

Measured memory_bytes: 3648
n = int(input())
a = [int(input()) for _ in range(n)]

def f(a, offset=0):
    global n
    ans = 0
    # if len(a) % 2 == 0:
    #     last = a[0]
    # else:
    init = min(n // 2 + offset, n - 1)
    last = a[init]
    for i in range(n - 1):
        j = i // 2 if i % 2 == 0 else n - 1 - i // 2
        if j == init:
            break
        ans += abs(a[j] - last)
        last = a[j]
    return ans

# print(f(sorted(a)))
# print(f(sorted(a, reverse=True)))
a = sorted(a)
arev = sorted(a, reverse=True)
print(max(
    f(a),
    f(arev),
    f(a, offset = 1),
    f(arev, offset = 1),
))


Measured memory_bytes: 8284
//「場所iにいるとき、場所0～iのいずれかから買うことができる（ただし売り切れていなければ）」としても答えは変わらない.
//場所iでの行動は、「売り切れてない最安値を買う」→「移動する」が最適っぽい。
//B_i = (場所iで買える ? A_i : ∞）とし、B_iをRMQで管理すれば、最安値はO(logN)で求まる。B_iの更新をするために在庫管理をしたい。
//在庫管理は「StarrySky木」を用いるとO(logN)。（場所iでx_i本買うとして、y_i = x_0+…+x_iとおき、{y_i}を管理する。）
//よって、この問題はO(NlogN)で解けた。考察は簡単だけどStarrySky木の実装が初めてなので厳しい。
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define rep(i, n) for(i = 0; i < (n); i++)
#define int long long
using namespace std;
typedef pair<int, int> P;

namespace std {
	P operator+(const P &l, const P &r) {
		return P(l.first + r.first, l.second + r.second);
	}
}

//区間加算, 区間最小
const int DEPTH = 17;
const int INF = 1e+15;
struct StarrySky {
	int valAdd[1 << (DEPTH + 1)];	//valAdd[i] = ノードiに一様加算された値
	P   valMin[1 << (DEPTH + 1)];	//valMin[i] = (ノードiより上のvalAddを無視したときの、ノードiと対応する区間の最小値, 最小値の場所）
	
	StarrySky() {
		int i;
		rep(i, 1 << (DEPTH + 1)) { valAdd[i] = 0; valMin[i] = P(0, i - (1 << DEPTH) + 1); }
	}
	
	P add(int l, int r, int val, int a = 0, int b = (1 << DEPTH), int id = 0) {
		if (a >= r || b <= l) { return valMin[id]; }
		if (l <= a && b <= r) {
			valAdd[id] += val;
			valMin[id].first += val;
			return valMin[id];
		}
		
		P u = add(l, r, val, a, a + (b - a) / 2, id * 2 + 1);
		P v = add(l, r, val, a + (b - a) / 2, b, id * 2 + 2);
		return valMin[id] = min(u, v) + P(valAdd[id], 0);
	}
	
	void update(int pos, int x) {
		int leaf = pos + (1 << DEPTH) - 1;
		add(pos, pos + 1, x - valMin[leaf].first);
	}
	
	P getMin(int l, int r, int a = 0, int b = (1 << DEPTH), int id = 0) {
		if (a >= r || b <= l) { return P(INF, -1); }
		if (l <= a && b <= r) { return valMin[id]; }
		P u = getMin(l, r, a, a + (b - a) / 2, id * 2 + 1);
		P v = getMin(l, r, a + (b - a) / 2, b, id * 2 + 2);
		return min(u, v) + P(valAdd[id], 0);
	}
};

//問題
int n, q;
int t, l, r, x;
StarrySky sky;

signed main() {
	int i;
	
	cin >> n >> q;
	rep(i, q) {
		cin >> t >> l >> r; r++;
		if (t == 0) {
			cin >> x;
			sky.add(l, r, x);
		}
		else {
			cout << sky.getMin(l, r).first << endl;
		}
	}
	return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int a[maxn], b[maxn], c;

void solve() {
    int A, B, M, res = inf, tmp, q = inf, p = inf;
    cin >> A >> B >> M;
    for (int i = 1; i <= A; i++) cin >> a[i], q = min(q, a[i]);
    for (int i = 1; i <= B; i++) cin >> b[i], p = min(p, b[i]);
    for (int i = 1, x, y; i <= M; i++) {
        cin >> x >> y >> c;
        tmp = a[x] + b[y];
        res = min(res, tmp - c);
    }
    res = min(res, q + p);
    cout << res << endl;
}

int main() {
	header();
	solve();
	return 0;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k;scanf("%d",&k);
    int ans=0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                ans+=gcd(i,gcd(j,l));
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
    ll m1,m2,d1,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    cout << (m1==m2?0:1) << endl;
    return 0;
}


Measured memory_bytes: 256