akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<stdlib.h>

int magicalTiles();

void listen_matrixSize(int &,int &);
void listen_matrix(std::vector<std::string> &,const int);
void calc_goalPosition(std::vector<std::string> &,int &,int &,const int,const int);
const int LOOPFLAG=999999;
bool is_loop(const int);

//--------------------------------main------------------------------------

int main()
{
	while(magicalTiles());
	
	return 0;
}

int magicalTiles()
{
	using namespace std;
	int height,width;
	listen_matrixSize(height,width);
	if(!height && !width)
	{
		return 0;
	}
	
	vector<string> matrix;
	listen_matrix(matrix,height);
	
	int goal_h,goal_w;
	if(calc_goalPosition(matrix,goal_h,goal_w,height,width),is_loop(goal_h))
	{
		cout<<"LOOP"<<endl;
	}
	else
	{
		cout<<goal_w<<" "<<goal_h<<endl;
	}
	
	return 1;
}

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

void listen_matrixSize(int &height,int &width)
{
	using namespace std;
	
	cin>>height>>width;
}

void listen_matrix(std::vector<std::string> &matrix,const int height)
{
	using namespace std;
	
	string tmp_tile;
	for(int loop_h=0;loop_h<height;loop_h++)
	{
		cin>>tmp_tile;
		matrix.push_back(tmp_tile);
	}
}

void calc_goalPosition(std::vector<std::string> &matrix,int &goal_h,int &goal_w,const int height,const int width)
{
	using namespace std;
	
	int reachedPosition[height][width];
	for(int init_h=0;init_h<height;init_h++)
	{
		for(int init_w=0;init_w<width;init_w++)
		{
			reachedPosition[init_h][init_w]=0;
		}
	}
	
	int current_h=0,current_w=0;
	for(;1;)
	{
		if(!reachedPosition[current_h][current_w])
		{
			reachedPosition[current_h][current_w]=1;
		}
		else
		{
			goal_h=LOOPFLAG;
			return;
		}
		switch(matrix[current_h].at(current_w))
		{
		case '^':
			current_h--;
			break;
		case 'v':
			current_h++;
			break;
		case '<':
			current_w--;
			break;
		case '>':
			current_w++;
			break;
		case '.':
			goal_h=current_h;
			goal_w=current_w;
			return;
		default:
			cout<<"unknown tile inputed"<<endl;
			abort();
		}
	}
}

bool is_loop(const int goal_h)
{
	if(goal_h==LOOPFLAG)
	{
		return true;
	}
	else
	{
		return false;
	}
}
	

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

const int N = 5005, P = 1000000007;
int n, f[N], dp[N][N], size[N];
vector<int> g[N];

void dfs(int u, int fa) {
	size[u] = 1;
	dp[u][1] = 1;
	for (int v : g[u])
		if (v != fa) {
			dfs(v, u);
			for (int i = size[u]; i; --i) {
				int sum = 0;
				for (int j = 1; j <= size[v]; ++j) {
					dp[u][i + j] = (dp[u][i + j] + 1ll * dp[u][i] * dp[v][j]) % P;
					sum = (sum - 1ll * dp[v][j] * f[j]) % P;
				}
				dp[u][i] = 1ll * sum * dp[u][i] % P;
			}
			size[u] += size[v];
		}
}

int main() {
	scanf("%d", &n);
	f[0] = 1;
	for (int i = 2; i <= n; ++i)
		f[i] = 1ll * (i - 1) * f[i - 2] % P;
	for (int i = 1, u, v; i < n; ++i) {
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1, 0);
	int sum = 0;
	for (int i = 1; i <= n; ++i) sum = (sum + 1ll * dp[1][i] * f[i]) % P;
	printf("%d\n", (sum + P) % P);
	return 0;
}


Measured memory_bytes: 97408
from itertools import*
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
for i,x in enumerate(permutations(range(1,n+1),n)):
	if x==p:
		a=i
	if x==q:
		b=i
print(abs(a-b))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define pb push_back
#define pii pair<ll,ll>
#define mp make_pair
#define key first
#define price second
#define ll long long
#define INF 200000000000000
pii keys[1005];
ll dp[5000][1005];//consider the first j keys--> the min cost to have reach state i
bool engulf(ll a,ll b){//a enuglf b
        F(i,0,12){
                if(b&(1<<i)){
                        if(!(a&(1<<i))) return 0;
                }
        }
        return 1;
}
int main(){
        int n,m;
        while(~getII(n,m)){
                F(i,0,m){
                        ll price,num;
                        scanf("%lld%lld",&price,&num);
                        keys[i].price=price;
                        keys[i].key=0;
                        while(num--){
                                ll x;
                                scanf("%lld",&x);
                                x--;
                                keys[i].key|=(1<<x);
                        }
                }
                F(i,0,(1<<n)) F(j,0,m) dp[i][j]=INF;
                F(i,0,m) dp[0][i]=0;
                F(i,1,(1<<n)){
                        ll nowKey=keys[0].key,nowPrice=keys[0].price;
                        if(nowKey==i) dp[i][0]=nowPrice;
                        F(j,1,m){
                                nowKey=keys[j].key,nowPrice=keys[j].price;
                                if(!engulf(i,nowKey)) dp[i][j]=dp[i][j-1];
                                else{
                                        ll minV=INF;
                                        F(k,0,(1<<n)) if((k|nowKey)==i) minV=min(minV,dp[k][j-1]);
                                        dp[i][j]=min(dp[i][j-1],minV+keys[j].price);
                                }
                        }
                }
//              F(i,0,(1<<n)){
//                      F(j,0,m) printf("%15lld ",dp[i][j]);
//                      puts("");
//              }
                ll ans=dp[(1<<n)-1][m-1];
                printf("%lld\n",ans==INF?-1:ans);
        }
}


Measured memory_bytes: 33024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

//ここから
template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}
//繰り返し二乗法
template <typename T>
T doubling(T a, T p) {
	if (p == 0)return 1;//出口
	if (p % 2 == 0) {//pを半分にしていく
		T half = doubling<T>(a, p / 2);
		return half%mod * half % mod;
	}
	else {//pが奇数ならpを偶数にする
		return a * doubling<T>(a, p - 1)%mod;
	}
}
//combination その2(逆元) O(nlonP):PはmodP
template<typename T>
T combination(T n, T r) {
	if (r > n - r)return combination<T>(n, n - r);
	T mul = 1;
	T div = 1;
	for (unsigned long long int i = 0; i < r; i++) {
		mul *= n - i;
		div *= i + 1;
		mul %= mod;
		div %= mod;
	}
	//逆元
	T ans = mul * doubling(div, mod - 2) % mod;//a^(-1)=a^(p-2) (mod p)
	return ans;
}
void solve(){
  ll n,a,b;
  cin>>n>>a>>b;
  ll x=mod_pow(2LL,n,mod);
  x=(x-1+mod)%mod;
  ll s=combination(n,a);
  ll t=combination(n,b);
  cout<<(x-s-t+mod+mod)%mod;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
use std::io::Read;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let q: usize = iterator.next().unwrap().parse().unwrap();

    let mut ans = String::new();

    for _ in 0..q {
        let x: Vec<char> = iterator.next().unwrap().chars().collect();
        let y: Vec<char> = iterator.next().unwrap().chars().collect();
        let lcs = lcs(&x, &y);
        ans.push_str(&format!("{}\n", lcs));
    }

    return ans.trim().into();
}

fn lcs(x: &Vec<char>, y: &Vec<char>) -> usize {
    let mut dp: Vec<Vec<usize>> = vec![vec![0; x.len() + 1]; y.len() + 1];

    for i in 1..y.len() + 1 {
        for j in 1..x.len() + 1 {
            dp[i][j] = if x[j - 1] == y[i - 1] {
                dp[i - 1][j - 1] + 1
            } else {
                max(dp[i - 1][j], dp[i][j - 1])
            }
        }
    }

    return dp[y.len()][x.len()];
}



Measured memory_bytes: 13140
import sys

S = input()

def ticket_sum(i, s, num, memo):
    if i == len(S):
        if num == 7:
            memo.append(s+"=7")
            return memo
        else:
            return
    
    # 数字を分ける場所
    pos = i - len(S)

    # "+"を入れる場合
    ticket_sum(i+1, s[:pos]+"+"+s[pos:], num+int(s[pos]), memo)
    # "-"を入れる場合
    ticket_sum(i+1, s[:pos]+"-"+s[pos:], num-int(s[pos]), memo)

    return memo

memo = []
print(ticket_sum(1, S, int(S[0]), memo)[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    int N, M;
    cin >> N >> M;
    Graph<int> G(N * 3);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a = (a - 1) * 3, b = (b - 1) * 3;
        G[a].push_back(b + 1);
        G[a + 1].push_back(b + 2);
        G[a + 2].push_back(b);
    }

    int S, T;
    cin >> S >> T;
    S = (S - 1) * 3, T = (T - 1) * 3;

    vector<int> dist(3 * N, 1e9);
    queue<int> que;
    dist[S] = 0;
    que.push(S);
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (auto nv : G[v]) {
            if (dist[nv] < 1e9)
                continue;
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }

    cout << (dist[T] < 1e9 ? dist[T] / 3 : -1) << endl;
    return 0;
}


Measured memory_bytes: 17792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N, Q, A, B;
int x[212345];
map<pii, ll> dp[2];

void add(int idx, pii p, ll sum) {
	map<pii, ll>::iterator it = dp[idx].find(p);
	if (it == dp[idx].end()) dp[idx][p] = sum;
	else if (it->se > sum) dp[idx][p] = sum;
}

int main() {
	cin >> N >> Q >> A >> B;
	REP(i, Q) scanf("%d", x + i);
	
	if (A > B) swap(A, B);
	
	dp[0][pii(A, B)] = 0;
	
	REP(i, Q) {
		int now = i & 1, nex = !now;
		
		for (map<pii, ll>::iterator it = dp[now].begin(); it != dp[now].end(); ++it) {
			int a = it->fi.fi, b = it->fi.se;
			ll c = it->se;
			
			if (x[i] <= a) add(nex, pii(x[i], b), c + a - x[i]);
			else if (b <= x[i]) add(nex, pii(a, x[i]), c + x[i] - b);
			else {
				add(nex, pii(x[i], b), c + x[i] - a);
				add(nex, pii(a, x[i]), c + b - x[i]);
			}
		}
		dp[now].clear();
	}
	
	ll ans = INF;
	for (map<pii, ll>::iterator it = dp[Q & 1].begin(); it != dp[Q & 1].end(); ++it)
		chmin(ans, it->se);
	
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	vector<int> v[20];
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		int x; cin>>x;
		for(int j = 0; j < 20; j++){
			if((x>>j)&1)v[j].push_back(i);
		}
		int l = 0;
		for(int j = 0; j < 20; j++){
			if(v[j].size() <= 1)continue;
			l = max(l, v[j][v[j].size() - 2]);
		}
		ans += i - l;
	}
	cout<<ans<<'\n';

	return 0;
}

Measured memory_bytes: 8276
from sys import exit
n = int(input())
ls = list(map(int,input().split()))
if sorted(ls)==ls:
    print("YES")
    exit()
for i in range(len(ls)-1):
    for j in range(i+1,len(ls)):
        l = list(ls)
        l[i],l[j]=l[j],l[i]
        if sorted(l)==l:
            print("YES")
            exit()
print("NO")

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int n, m;
    cin >> n >> m;
    int x = MAX(n, m);
    int y = MIN(n, m);

    vs64 p(x + 1);
    p[0] = 1;
    for (s64 i = 1; i <= x; ++i)
    {
        p[i] = (p[i - 1] * i) % MOD;
    }

    s64 times = 0;
    if (x == y) times = 2;
    else if (x == y + 1) times = 1;
    cout << (p[x] % MOD * p[y] % MOD * times) % MOD << "\n";
    return 0;
}



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

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

using namespace std;

inline void pon(int n){
    cout << n << endl;
    fflush(stdout);
}

inline int get(){
    int res;
    cin >> res;
    return res;
}

int main(){
    srand(time(0u)+getpid());

    int n; cin>>n;
    vector<string> win(n);
    rep(i,n)cin>>win[i];

    int me = rand()%n;
    rep(i,1000){
        pon(me+1);
        int ai = get()-1;
        if (win[me][ai] == 'x')me = rand()%n;
    }
}

Measured memory_bytes: 1328
Q = int(input())
LR = [list(map(int,input().split())) for _ in range(Q)]

prime = [1]*(10**5 + 10)
prime[1] = 0
for i in range(2,10**5+10):
    if prime[i]:
        for j in range(2*i,10**5 + 10,i):
            prime[j] = 0

Ans = [0]*(10**5 + 10)

for a in range(2,10**5 + 9):
    if prime[a] and prime[int((a+1)/2)]:
        Ans[a] = 1
    Ans[a] += Ans[a-1]

for l,r in LR:
    print(Ans[r]-Ans[l-1])



Measured memory_bytes: 32008
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B;
  cin>>N>>A>>B;
  string S;
  cin>>S;
  int sum=A+B;
  for(int i=0;i<N;i++){
    
    if(S.at(i)=='a'){if(sum>0){sum--;cout<<"Yes"<<endl;}
                     else{cout<<"No"<<endl;}}
    if(S.at(i)=='b'){if(sum>0&&B>0){sum--;B--;cout<<"Yes"<<endl;}
                     else{cout<<"No"<<endl;}}
    if(S.at(i)=='c'){cout<<"No"<<endl;}
    
  }
  return 0;
}

Measured memory_bytes: 896
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^8 -> 8回
// double pi = M_PI or acos(-1)
// printf("%.10f\n", ans);

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

    char lastC = s.at(0);
    string cvtS;

    // 番兵
    s.push_back('A');
    rep(i, n + 1) {
        if(s.at(i) != lastC) {
            cvtS.push_back(s.at(i - 1));
            lastC = s.at(i);
        }
    }

    int ans = cvtS.size();
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3744
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int n, d;
    cin >> n >> d;
    int mx = 16000; // 取りうる最大の値
    set<int> st;
    int c = 1;
    while (true) {
        int tmp = pow(c, 2);
        st.insert(tmp);
        c++;
        if (tmp > mx) {
            break;
        }
    }
    int a[11][11];
    REP(i, n) {
        REP(j, d) {
            cin >> a[i][j];
        }
    }
    int res = 0;
    FOR(i, 0, n-2) {
        FOR(j, i+1, n-1) {
            int tot = 0;
            FOR(k, 0, d-1) {
                tot += pow(a[i][k] - a[j][k], 2);
            }
            if (st.find(tot) != st.end()) {
                res++;
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int h[60][60][60][60];
int main(){
	int n,m;
	while(cin>>m>>n,n||m){
		rep(i,60)rep(j,60)rep(k,60)rep(l,60)h[i][j][k][l]=false;
		int sx,sy,gx,gy;
		cin>>sy>>sx>>gy>>gx;
		vvi in(n+2,vi(m+2,1));
		rep(i,n)rep(j,m)cin>>in[i+1][j+1];
		queue<pair<pii,pii> >q;
		q.push(pair<pii,pii>(pii(sx,sy),pii(gx,gy)));
		h[sx][sy][gx][gy]=true;
		int out=0;
		while(1){
			out++;
			queue<pair<pii,pii> >nex;
			while(q.size()){
				pair<pii,pii>now=q.front();q.pop();
				pii ta=now.first,ka=now.second;
				rep(i,4){
					int tx=ta.first+dx[i],ty=ta.second+dy[i];
					int kx=ka.first+dx[(i+2)%4],ky=ka.second+dy[(i+2)%4];
					if(in[tx][ty]==1){
						tx-=dx[i];ty-=dy[i];
					}
					if(in[kx][ky]==1){
						kx-=dx[(i+2)%4];ky-=dy[(i+2)%4];
					}
					if(kx==tx&&ky==ty)goto end;
					if(h[tx][ty][kx][ky])continue;
					h[tx][ty][kx][ky]=true;
					nex.push(pair<pii,pii>(pii(tx,ty),pii(kx,ky)));
				}
			}
			q=nex;
			if(q.size()==0){
				cout<<"NA"<<endl;
				goto br;
			}
		}
		end:;
		cout<<out<<endl;
		br:;
	}
}

Measured memory_bytes: 52332
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int n, k; cin >> n >> k;
  i64 ans = k;
  for (int i = 1; i < n; ++i) ans *= (k-1);

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define pii pair<int,int>

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

using namespace std;

int main(){

  int n;
  int alf[50][26] = {};
  char s[50][51];

  scanf("%d", &n);
  REP(i,n){
    scanf("%s", s[i]);
  }

  REP(i,n){
    REP(j,strlen(s[i])){
      alf[i][s[i][j] - 97]++;
    }
  }

  int res[26];
  fill(res, res + 26, INF);

  REP(i,26){
    REP(j,n){
      res[i] = min(res[i], alf[j][i]);
    }
    REP(j,res[i]){
      printf("%c", i + 97);
    }
  }

  printf("\n");

  return 0;
}



Measured memory_bytes: 256
s=input()
A_ind=None
Z_ind=None
for i in range(len(s)):
    if s[i]=="A":
        A_ind=i
        break
for j in range(len(s)-1,0,-1):
    if s[j]=="Z":
        Z_ind=j
        break
print(Z_ind-A_ind+1)

Measured memory_bytes: 3516
using namespace std; 
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vect vector<ll>
#define maap map<ll,ll>  
#define MOD 998244353
#define mit map::iterator
#define pii pair<ll,ll>
#define rep(i,a,b)	for(ll i=a;i< b;i++)
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
typedef  long long   int  ll;
//stringstream convert; 
  //  convert << number; 
  //  string s = convert.str();
 ll fact[500005],invfact[500005]; 
 ll power(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
 ll inv(ll x)
{
	return power(x,MOD-2);
}
ll divide(ll x, ll y)
{
	return (x*inv(y))%MOD;
}
ll C(ll n, ll k)
{
	if(k > n) return 0;
	return divide(fact[n], (fact[n - k]*fact[k])%MOD);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
} 
void init(){
	ll p=MOD;
	fact[0]=1;
	ll i;
	for(i=1;i<500005;i++){
		fact[i]=(i*fact[i-1])%p;
	}
	i--;
	invfact[i]=power(fact[i],p-2);
	for(i--;i>=0;i--){
		invfact[i]=(invfact[i+1]*(i+1))%p;
	}
}
ll s;
ll fun(ll a)
{
	if(a==0)
	return 0;
	return a+fun(a-1);
}
priority_queue < pair<ll,ll> , vector<pair<ll,ll> >,greater<pair<ll,ll> > > gq;

#define MAXN   10000001 
ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (ll i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
set<ll> getFactorization(ll x) 
{ 
    set<ll> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 
void ghost()
{   
  	ll i=0,j=0,k=0,l=0,n,r=-10000000000,t=0,q=0,x,y=100000000000,m;
    char ch;
    cin>>ch;
    l=ch;
    if(l<97)
    {
    	cout<<"A";
	}
	else
	cout<<"a";
    
    
}
signed main()
{int test=1;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
//cin>>test;
while(test--)
ghost();
return 0;
}

  

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

int main(){
	int a,b;
	cin>>a>>b;
	char d[100][100];
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			cin>>d[i][j];
		}
	}
	for(int k=0;k<a+2;k++){
		for(int l=0;l<b+2;l++){
			if(k==0||k==a+1||l==0||l==b+1){
				cout<<"#";
			}
			else{
				cout<<d[k-1][l-1];
			}
		}
		cout<<endl;
	}
}


Measured memory_bytes: 256
a, b, c, d, e, f = map(int, input().split())
a_list = set([])
b_list = set([])
for i in range((f // a) + 1):
    for j in range((f // b) + 1):
        if 0 < ((a*i) + (b*j)) * 100 <= f:
            a_list.add(((a*i)+(b*j))*100)
for i in range((f // c) + 1):
    for j in range((f // d) + 1):
        if ((c*i) + (d*j)) <= f:
            b_list.add((c*i)+(d*j))
ans = 0
ans_1 = 0
ans_2 = 0
for aa in a_list:
    for bb in b_list:
        if (aa + bb <= f) & ((bb / aa) <= e * 0.01):
            if ans <= (bb / aa) * 100:
                ans = (bb / (aa)) * 100
                ans_1 = aa + bb
                ans_2 = bb
print(str(ans_1) + " " + str(ans_2))

Measured memory_bytes: 3188
#include <iostream>

int main()
{
	long A;
	long B;
	long C;
	std::cin >> A;
	std::cin >> B;
	std::cin >> C;
	if (A+B<=C)
	{
		A = 0;
		B = 0;
	}
	else
	{
		if (A < C)
		{
			C = C - A;
			A = 0;
			B = B - C;
		}
		else
		{
			A = A - C;
		}
	}
    std::cout << A<<' '<<B;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 1 << 60


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


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


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    return S + ('es' if S[-1] == 's' else 's')


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 78292
import math

n = int(input())
A=list(map(int, input().split()))

ans = [0] * n
if (n % 2 == 0):
    for i in range(n):
        if (i%2 == 0):
            ans[n//2+i//2] = A[i]
        else:
            ans[n//2-(i+2)//2] = A[i]
if (n % 2 != 0):
    for i in range(n):
        if (i%2 == 0):
            ans[n//2-i//2] = A[i]
        else:
            ans[n//2+(i+2)//2] = A[i]

print(*ans)

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

using namespace std;

int main() {
    int A ,B;
    cin >> A >> B;
    int ans = 0;
    for (size_t i = A; i < B+1; i++)
    {
        /* code */
        if(i/10000 != i%10)continue;
        if ((i/1000)%10 != (i%100)/10)continue;
        ans++;
        
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3672
#include<stdio.h>

int main(void){

	int S,h,m,s=0;
	scanf("%d",&S);
		h=S/3600;
		m=(S%3600)/60;
	    s=(S%3600)%60;
	printf("%d:%d:%d\n",h,m,s);
	
return 0;
}


Measured memory_bytes: 2100
def main():
    from collections import Counter as ct
    from bisect import bisect_left as bl

    n = int(input())
    max_a = sorted(ct(list(map(int, input().split()))).values())
    now_a = [i for i in max_a]
    m = len(max_a)
    cnt = m
    ans = 0
    ans_list = []

    for use in range(n, 0, -1):
        rest = ans
        nex = now_a[0]
        # restの分だけ戻す
        while rest:
            val = nex
            start = bl(now_a, val+1)
            nex += 1
            for i in range(start-1, -1, -1):
                if now_a[i] == max_a[i]:
                    if start != m:
                        nex = now_a[start]
                    break
                elif now_a[i] == 0:
                    cnt += 1
                now_a[i] += 1
                rest -= 1
                if rest == 0:
                    break
        # 大きい方から使っていく
        while True:
            if cnt < use:
                ans_list.append(ans)
                break
            ans += 1
            rest = use
            nex = now_a[-1]
            end = m
            while rest:
                val = nex
                start = bl(now_a, val)
                if start != 0:
                    nex = now_a[start-1]
                for i in range(start, end):
                    if now_a[i] > val:
                        break
                    elif now_a[i] == 1:
                        cnt -= 1
                    now_a[i] -= 1
                    rest -= 1
                    if rest == 0:
                        break
                end = start
    for i in ans_list[::-1]:
        print(i)


main()


Measured memory_bytes: 120348
n = int(input())
l = list(map(int, input().split()))
count = 0
l.sort()

for l1 in range(len(l)):
    for l2 in range(l1+1, len(l)):
        for l3 in range(l2+1, len(l)):
            if len({l[l1], l[l2], l[l3]}) == 3 and l[l3] <l[l1]+l[l2]:
                count += 1
print(count)





Measured memory_bytes: 9188
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void)
{
    char S[5];
    cin >> S;
    //scanf("%s",S);                                                            
    if((S[0]==S[1]&&S[1]!=S[2]&&S[2]==S[3])||
       (S[0]==S[2]&&S[1]==S[3]&&S[2]!=S[3])||
       (S[0]==S[3]&&S[1]!=S[3]&&S[2]==S[1]))cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

#define all_of(x) std::begin(x), std::end(x)
#ifdef _GLIBCXX_DEBUG
    #define debug(x) cerr << #x << ": " << x << endl
#else
    #define debug(x) 
#endif

using namespace std;

using LL = long long;

template<typename T>
ostream& operator << (ostream& out, const vector<T>& v) {
    out << "[";
    for(const auto& x : v) {
        out << x << ", ";
    }
    return out << "]";
}
template<typename T>
istream& operator >> (istream& in, vector<T>& v) {
    for(auto& x : v) {
        in >> x;
    }
    return in;
}

template<typename S, typename T>
ostream& operator << (ostream& out, const pair<S, T>& p) {
    return out << "{" << p.first << ", " << p.second << "}";
}

LL dp[1000100][2][2];

constexpr int MOD = 1000000007;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int N;
    cin >> N;
    dp[0][0][0] = 1;
    for(int n = 1; n <= N; ++n) {
        dp[n][0][0] = (dp[n - 1][0][0] * 8) % MOD;
        dp[n][1][0] = (dp[n - 1][1][0] * 9 + dp[n - 1][0][0]) % MOD;
        dp[n][0][1] = (dp[n - 1][0][1] * 9 + dp[n - 1][0][0]) % MOD;
        dp[n][1][1] = (dp[n - 1][1][1] * 10 + dp[n - 1][1][0] + dp[n - 1][0][1]) % MOD;
    }
    cout << dp[N][1][1] << "\n";
    
    return 0;
}


Measured memory_bytes: 34824
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("Ofast")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;
using ull = unsigned long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}


double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

template<typename T>
T chmin(T& a, const T& b) {
	if (a > b)a = b;
	return a;
}

template<typename T>
T chmax(T& a, const T& b) {
	if (a < b)a = b;
	return a;
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int k;
	scanf("%d", &k);
	if (k % 2 == 0 or k % 5 == 0) {
		puts("-1");
		return 0;
	}
	else if (k % 7 == 0) {
		k /= 7;
	}
	ll sum = 1, r = 1;
	ll ans = 1;
	while (sum % k) {
		r *= 10;
		r %= k;
		sum += r;
		sum %= k;
		++ans;
		if (ans >= 1e8) {
			ans = -1;
			break;
		}
	}
	printf("%lld\n", ans);

	Please AC;
}


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

#define maxn 200010
#define INF 1e9
#define int ll
typedef long long ll;

int N,A[maxn],B[maxn];
int total = 0;

int32_t main(){
	cin>>N;
	
	int ans = INF;
	
	for (int i=0;i<N;i++){
		int a,b;
		
		cin>>a>>b;
		total += a;
		
		if (a > b) ans = min(ans,b);
		
	}
	
	if (ans == INF) cout<<0;
	else cout<<total - ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];
    REP(i, N) cin >> C[i];
    sort(ALL(B));
    sort(ALL(C));
    vector<ll> cnt(N);
    REP(i, N) {
        cnt[i] = C.end() - upper_bound(ALL(C), B[i]);
    }
    for (int i = N - 2; i >= 0; i--) {
        cnt[i] += cnt[i + 1];
    }
    ll ans = 0;
    REP(i, N) {
        int j = upper_bound(ALL(B), A[i]) - B.begin();
        if (j != N) ans += cnt[j];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2176
def dfs(x, y): 
    if x == h-1 and y == w-1:
        a[x][y] = "."
        # print(a)
        for i in range(h):
            if "#" in a[i]:
                print("Impossible")
                exit()
        print("Possible")
        exit()
    
    if a[x][y] == "#":
        a[x][y] = "."

    if y+1 < w and a[x][y+1] != ".":
        dfs(x, y+1)#右
    
    if x+1 < h and a[x+1][y] != ".":
        dfs(x+1, y)#下
    
    for i in range(h):
        if "#" in a[i]:
            print("Impossible")
            exit()
    print("Possible")
    exit()

h, w = map(int, input().split())
a = []
for i in range(h):
    a.append(list(input()))

dfs(0, 0)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> p(N);
    for (int i = 0; i < N; ++i) {
        cin >> p[i];
    }
    std::sort(p.begin(), p.end());
    int ans = p[N - 1] / 2;
    for (int i = 0; i < N - 1; ++i) {
        ans += p[i];
    }
    cout << ans;
    return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K,X; cin >> K >> X;
    for (int i=X-K+1;i<X+K;++i){
        cout << i << (i!=X+K-1?' ':'\n');
    }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

        final int[] a = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        final int[] b = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        final int[] c = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        int previous = -2;
        int sum = 0;
        for (int i = 0; i < a.length; i++) {
            int eat = a[i] - 1;
            sum += b[eat];
            if (eat - 1 == previous) {
                sum += c[previous];
            }

            previous = eat;
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 28372
#include <stdio.h>
#include <stdlib.h>
#define MAX_NUM (100)

int compare(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

int main(void) {
	int n, order, pt, i;
	int results[MAX_NUM][2];

	for (i = 0;; i++) {
		scanf(" %d,%d ", &results[i][1], &results[i][0]);
		if (results[i][0] == 0 && results[i][1] == 0)
			break;
	}
	for (; i < MAX_NUM; i++) {
		results[i][0] = results[i][1] = 0;
	}

	qsort(results, MAX_NUM, sizeof(int)*2, compare);
	while (scanf(" %d ", &n) != EOF) {
		pt = order = 0;
		for (i = 0; i < MAX_NUM; i++) {
			if (pt != results[i][0]) {
				pt = results[i][0];
				order += 1;
			}
			if (n == results[i][1])
				break;
		}
		printf("%d\n", order);
	}
	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;

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

    int num;
    vector<int> v;
    REP(_,3){
        cin >> num;
        v.PB(num);
    }
    SORT(v);
    cout << v[2]*10+v[1]+v[0];
}

Measured memory_bytes: 256
#include<stdio.h>

int main()

{
    int x,y;
    char operator;


    while(scanf("%d %c %d", &x, &operator, &y)!=EOF)
    {
        if(operator=='?')
        {
            break;
        }

        switch(operator)
       {
        case'+':
        printf("%d\n", x+y);
        break;

        case'-':
        printf("%d\n", x-y);
        break;

        case'*':
        printf("%d\n", x*y);
        break;

        case'/':
        printf("%d\n", x/y);
        break;

    }
}

    return 0;



}



Measured memory_bytes: 2056
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
using static System.Array;

class MainClass : Scanner
{
    static void Main()
    {
        int N = RInt();
        bool frag = false;
        for (int i = 1; i < 10; i++)
        {
            if (N % i == 0 && N / i <= 9) frag = true;
        }
        if (frag) WriteLine("Yes");
        else WriteLine("No");
    }
}

class Scanner
{
    public static int RInt() => int.Parse(Console.ReadLine());
    public static long RLong() => long.Parse(Console.ReadLine());
    public static string RString() => Console.ReadLine();
    public static double RDouble() => double.Parse(Console.ReadLine());

    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static string[] RStrings() => Console.ReadLine().Split();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static T1 ReadStream<T1>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadStream<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadStream<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadStream<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}

Measured memory_bytes: 27556
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int w, a, b; cin >> w >> a >> b;
    int ans;
    if(a < b){
        int rt = a + w; // right
        if(b < rt) ans = 0;
        else ans = b - rt;
    }
    else{
        int rt = b + w;
        if(a < rt) ans = 0;
        else ans = a - rt;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int A,B,H,M;
	scan(A>>B>>H>>M);
	double hx=A*cos(360/12*(H+(double)M/60)*M_PI/180),hy=A*sin(360/12*(H+(double)M/60)*M_PI/180);
	double mx=B*cos(360/60*M*M_PI/180),my=B*sin(360/60*M*M_PI/180);
	prin(setprecision(11)<<sqrt((hx-mx)*(hx-mx)+(hy-my)*(hy-my)));
	return 0;
}


Measured memory_bytes: 4100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(i%2 == 0 && a[i]%2 != 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    static class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var N = IO.GetInt();
            var S = IO.GetString();
            var ans = "Yes";
            if (N % 2 != 0)
            {
                ans = "No";
            }
            else
            {
                for (int i = 0; i < N / 2; i++)
                {
                    if (S[i] != S[i + N / 2])
                    {
                        ans = "No";
                        break;
                    }
                }
            }


            Console.WriteLine(ans);
        }

    }

    static class IO
    {
        static public string GetString() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> GetStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> GetIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> GetLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteStrings<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
    }
}

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

int main() {
  int A,B,C,D,left,right;
  cin >> A >> B >> C >> D;
  left = A + B;
  right = C + D;
  if (left < right)
    cout << "Right" << endl;
  else if (left == right)
    cout << "Balanced" << endl;
  else
    cout << "Left" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	rep(i,n) cin >> c[i];
	sort(a.begin(), a.end());
	sort(c.begin(), c.end());
	ll ans = 0;
	rep(i,n){
		ll up = upper_bound(a.begin(), a.end(), b[i]-1) - a.begin();
		ll lo = lower_bound(c.begin(), c.end(), b[i]+1) - c.begin();
		lo = n - lo;
		ans += up * lo;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
N, X = map(int, input().split())

a, p = [1], [1]
for i in range(N):
        a.append(a[i] * 2 + 3)
        p.append(p[i] * 2 + 1)
def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))

Measured memory_bytes: 3064