akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

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

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

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


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

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



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

    string s; cin >> s;
    if(s == string(3, 'A') || s == string(3, 'B')) cout << "No" << endl;
    else cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
A,B,C,D=map(int, input().split())
while C>0 and A>0:
	C=C-B
	A=A-D

if C<=0 and A<=0:
	print("Yes")
elif C<=0 and A>=0:
	print("Yes")
elif C>=0 and A<=0:	
	print("No")

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int d=n,i=1;
  while(d/10!=0)
  {
    i++;
    d=d/10;
  }
  d=0;
  for(int j=1;j<i;j+=2)
  {
   d+=pow(10,j)-pow(10,j-1);
  }
  if(i%2!=0)
    d+=n-pow(10,i-1)+1;
  cout<<d;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    string s;
    int n;
    char ans='z';
    cin>>s;
    cin>>n;
    for(int i=0; i<n; i++){
        if(s[i]!='1'){
            ans=s[i];
            break;
        }
    }
    if(ans=='z')
        cout<<1<<endl;
    else
        cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long a,b,c,d,e,f,i,j,dp1[3005],dp2[3005],s1,s2;
vector<long long> can;
long long nd(long long x,long long y,long long a,long long b)
{
	if (!y) return 1;
	if (!b) return 0;
	return (100*b)*(x+y)>(100*y)*(a+b);
}
int main()
{
	cin>>a>>b>>c>>d>>e>>f;
	dp1[0]=1;a*=100;b*=100;
	for (i=1;i<=f;i++)
	{
		if (i>=a) dp1[i]|=dp1[i-a];
		if (i>=b) dp1[i]|=dp1[i-b];
	}
	dp2[0]=1;
	for (i=1;i<=f;i++)
	{
		if (i>=c) dp2[i]|=dp2[i-c];
		if (i>=d) dp2[i]|=dp2[i-d];
	}
	s1=a;
	for (i=1;i<=f;i++)
	{
		if (dp1[i])
		{
			for (j=1;j+i<=f;j++)
			{
				if (dp2[j])
				{
					if (i*e>=100*j&&nd(s1,s2,i,j))
					{
						s1=i;
						s2=j;
					}
				}
			}
		}
	}
	cout<<s1+s2<<' '<<s2;
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

const int N_MAX = 3010;
const int T_MAX = 3010;
int N, T;
vector<vector<int>> dp(N_MAX, vector<int>(T_MAX,-1));
vector<vector<int>> keep(N_MAX, vector<int>(T_MAX,-1));

struct food { int a, b; };
vector<food> f;

int dfs(int n, int t) {
  if (dp[n][t]!=-1) return dp[n][t];
  if (n==0) { keep[n][t] = 0; return dp[n][t] = 0; }
  int result = 0;
  result = dfs(n-1,t); keep[n][t] = max(keep[n-1][t], f[n-1].b);
  if (t>=f[n-1].a) {
    int tv = dfs(n-1,t-f[n-1].a) + f[n-1].b;
    int tk = keep[n-1][t-f[n-1].a];
    if (result+keep[n][t] < tv+tk) {
      result = tv; keep[n][t] = tk;
    }
    else if (result+keep[n][t] == tv+tk) {
      if (keep[n][t]>tk) {
        result = tv; keep[n][t] = tk;
      }
    }
  }
  // cout << n << " " << t << " " << result << " " << keep[n][t] << endl;
  return dp[n][t] = result;
}

int main() {
  cin >> N >> T; T--;
  rep(i,N) { int A, B; cin >> A >> B; f.push_back({A,B}); }
  int result = dfs(N,T); result += keep[N][T];
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 71552
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int INF=1e10;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	int next=1,ans=0;
	rep(i,n){
		if(next==a[i]){
			next++;
		}else ans++;
	}
	if (ans == n)ans=-1;
	cout << ans << endl;
}

Measured memory_bytes: 4028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}



Measured memory_bytes: 3624
package main

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

const mod = 998244353
const facNum = 300001

type edge struct {
	p  int
	to int
	c  int
}

func main() {
	sc := newScanner(os.Stdin)
	N, X, Y := sc.i(), sc.i(), sc.i()
	to := make([][]int, N)
	for i := 0; i < N; i++ {
		if i != N-1 {
			to[i] = append(to[i], i+1)
		}
		if i != 0 {
			to[i] = append(to[i], i-1)
		}
	}
	X--
	Y--
	to[X] = append(to[X], Y)
	to[Y] = append(to[Y], X)

	count := make([]int, N-1)
	for i := 0; i < N; i++ {
		q := make([]edge, 0)
		visit := make([]bool, N)
		for _, t := range to[i] {
			q = append(q, edge{i, t, 1})
		}
		visit[i] = true
		for len(q) > 0 {
			e := q[0]
			q = q[1:]
			if visit[e.to] {
				continue
			}
			count[e.c-1] += 1
			visit[e.to] = true
			for _, t := range to[e.to] {
				if visit[t] {
					continue
				}
				q = append(q, edge{e.to, t, e.c + 1})
			}
		}
	}
	for _, c := range count {
		fmt.Println(c / 2)
	}

}

// fmt.Println("Yes")
// fmt.Println("No")

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

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

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

func abs(i int) int {
	if i < 0 {
		return -i
	}
	return i
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

// vs: sorted slice int value
func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n
			//m = m
		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func IntSlice(n, init int) []int {
	r := make([]int, n)
	for i := range r {
		r[i] = init
	}
	return r
}


Measured memory_bytes: 8568
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            if (in.next().equals("H"))
                out.println(in.next());
            else
                out.println(in.next().equals("H") ? "D" : "H");
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isPrintableChar(int c) {
            return c >= 33 && c <= 126;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



Measured memory_bytes: 21332
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

bool check[30][30];

typedef pair<int, string> P;

int main(){
	
	int n;
	
	while(true){
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		string str[30];
		
		for(int i = 0; i < 30; i++){
			for(int j = 0; j < 30; j++){
				check[i][j] = false;
			}
		}
		
		for(int i = 0; i < n; i++){
			int m;
			cin >> str[i] >> m;
			for(int j = 0; j < m; j++){
				int num;
				cin >> num;
				check[i][num] = true;
			}
		}
		
		int score[30];
		
		for(int i = 0; i < 30; i++){
			int count = 0;
			for(int j = 0; j < n; j++){
				if(check[j][i]){
					count++;
				}
			}
			score[i] = n + 1 - count;
		}
		
		vector<P> v;
		
		for(int i = 0; i < n; i++){
			P p;
			p.second = str[i];
			p.first = 0;
			for(int j = 0; j < 30; j++){
				if(check[i][j]){
					p.first += score[j];
				}
			}
			v.push_back(p);
		}
		
		sort(v.begin(), v.end());
		
		cout << v[0].first << " " << v[0].second << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3188
#include<stdio.h>
main(){
  int a=0;
  int b=0;
  int c=0;
  int d=0;
  int e=0;
  scanf("%d %d %d",&a,&b,&c);
  for(d=a;d<b+1;d++){
    if(c%d==0){
      e=e+1;
    }
  }
  printf("%d\n",e);
  return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
int main(void) {
	int x, y, replace;
	while (scanf("%d %d", &x, &y) == 2) {
		if (x == 0 && y == 0) break;
		if (x > y) {
			replace = x;
			x = y;
			y = replace;
		}
		printf("%d %d\n", x, y);
	}
	return 0;
}

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

signed main(){
	int n;string s;
	cin>>n>>s;
	int cnt=0,cp=0,cm=0;
	rep(i,n){
		if(s[i]=='('){
			cnt++;
			}
		else{
			cnt--;
			}	
		if(cnt<0){
			cnt++;
			cp++;
			}	
		}
	rep(i,cp)cout<<'(';
	cout<<s;
	rep(i,cnt)cout<<')';
	cout<<endl;	
	}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  int h, w, n;
  int st_x, st_y;
  cin >> h >> w >> n;
  cin >> st_x >> st_y;
  st_x--;
  st_y--;
  std::string s, t;
  cin >> s >> t;

  // For up/down, we want 0 <= st_x < n
  // --> [lower, upper]
  auto check = [&](char pos, char neg, int lower, int upper, int cur_balance) {
    for (int i = 0; i < n; i++) {
      bool s_is = s[i] == pos;
      bool t_is = t[i] == neg;

      cur_balance += s_is;
      if (cur_balance > upper) {
        return true;
      }
      if (cur_balance > lower) {
        cur_balance -= t_is;
      }
    }
    return false;
  };

  auto res1 = check('U', 'D', 0, h - 1, h - 1 - st_x);
  auto res2 = check('D', 'U', 0, h - 1, st_x);
  auto res3 = check('L', 'R', 0, w - 1, w - 1 - st_y);
  auto res4 = check('R', 'L', 0, w - 1, st_y);
  if (res1 || res2 || res3 || res4) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
}

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

int k,a, b;

int main() {
  cin >> k >> a >> b;
  string ans = "NG";
  for (size_t i = a; i <= b; i++) {
    if (i % k == 0) ans = "OK";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n, d;
  cin >> n >> d;
  cout << (n + d * 2) / (d * 2 + 1) << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int N;
ll L;
ll a[100050];

int main(){
    cin >> N >> L;
    FOR(i,1,N+1)cin >> a[i];
    int cnt=-1;
    FOR(i,1,N)
    {
        if(a[i]+a[i+1]>=L){cnt=i;break;}
    }
    if(cnt==-1)
    {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    FOR(i,1,cnt)
    {
        cout << i << endl;
    }
    FORR(i,N-1,cnt+1)
    {
        cout << i << endl;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int64_t N,M,ans=0; cin>>N>>M;
  vector<int64_t> X(N),Y(N),Z(N);
  rep(i,N) cin>>X[i]>>Y[i]>>Z[i];
  for(int temp=0; temp<(1<<3);temp++){
    bitset<3> s(temp);
    vector<int64_t> A(N,0);
    rep(i,N){
      int64_t t=0;
      if(s.test(0)) t+=X[i];
      else t-=X[i];
      if(s.test(1)) t+=Y[i];
      else t-=Y[i];
      if(s.test(2)) t+=Z[i];
      else t-=Z[i];
      A[i]=t;
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    int64_t k=0;
    rep(i,M) k+=A[i];
    ans=max(ans,k);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N, K = map(int, input().split())
A = list(sorted(map(int, input().split())))

left = -INF
right = INF
while right - left > 1:
    x = (left + right) // 2
    s = 0 # num of less than or equal to x
    t = 0 # duplication
    for a in A:
        if a > 0:
            l = -1
            r = N
            while r - l > 1:
                m = (l + r) // 2
                if A[m] * a <= x:
                    l = m
                else:
                    r = m
            s += r
        elif a < 0:
            l = -1
            r = N
            while r - l > 1:
                m = (l + r) // 2
                if A[m] * a <= x:
                    r = m
                else:
                    l = m
            s += N - r
        elif a == 0 and x >= 0:
            s += N

        if a * a <= x:
            t += 1
    count = (s - t) // 2
    if count >= K:
        right = x
    else:
        left = x
print(right)


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

int main(){
  int N;
  cin >> N;
  string hina;
  bool color = false;
  for(int i=0;i<N;i++){
    cin >> hina;
    if(hina == "Y"){
      color = true;
      break;
    }
  }
  if(color){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);
    int n;
    cin >> n;
    bool b = false;
    REP(i,1,10) REP(j,1,10){
        if(i * j == n) b = true;
    }
    Yes(b);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cctype>
using namespace std;
typedef long long ll;

/*string toLower( string s ) {
    for( int i = 0; i < s.length(); ++i ) {
        if( s[i] >= 'A' && s[i] <= 'Z' ) s[i] += 32;
    }
    return s;
}*/

int main( void ) {
    string s;
    while( cin >> s && s != "-" ) {
        int n, num, sum = 0;
        cin >> n;
        for( int i = 0; i < n; ++i ) cin >> num, sum += num;
        int len = s.length();
        sum %= len;
        for( int i = sum; i < len; ++i ) cout << s[i];
        for( int i = 0; i < sum; ++i ) cout << s[i];
        cout << '\n';
    }
    return 0;
}



Measured memory_bytes: 3168
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#include <queue>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int inf=1e9;

int main(){
    int n,m,a,b;
    cin >> n>>m;
    vector<vector<int>> path(n,vector<int>(0));
    rep(i,m){
        cin >> a>>b;
        path[a-1].push_back(b-1);
        path[b-1].push_back(a-1);
    }
    vector<int> res(n,inf);
    queue<int> q;
    res[0]=0;
    q.push(0);
    while(!q.empty()){
        int a = q.front();
        for(int i=0,sz=path[a].size(); i<sz; ++i){
            int b=path[a][i];
            if(res[b]==inf){
                res[b]=a+1;
                q.push(b);
            }
        }
        q.pop();
    }

    rep(i,n){
        if(res[i]==inf){
            cout << "No"<<endl;
            return 0;
        }
    }
    cout <<"Yes"<<endl;
    rep(i,n-1){
        cout << res[i+1] << endl;
    }

    return 0;
}


Measured memory_bytes: 10216
import sys
input = sys.stdin.readline

A = int(input())
      
B = A // 10
C = B // 10
 
if A % 10 == 7:
  print ("Yes")
elif B % 10 == 7:
  print ("Yes")
elif C % 10 == 7:
  print ("Yes")
else:
  print ("No")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////

int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;  cin>>n>>k;
    int arr[n];
    f(n)cin>>arr[i];
    ll dp[n];
    f(n)dp[i] = LONG_MAX;
    dp[0] = 0;
    dp[1] = abs(arr[1]-arr[0]);
    for(int i =2;i<n;i++)
    {
        int x = i-k;
        if(x < 0)x=0;
        for(int j = i-1;j>=x;j-- )
        {
            dp[i] = min(dp[i],dp[j] + abs(arr[j]-arr[i]));
        }
    }
    cout << dp[n-1] << "\n";
    
    return 0;
 }

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

void makeboard(string jfen, vector<string> &b)
{
    string line = "";
    for (char c : jfen)
    {
        if (c == 'b')
        {
            line += "b";
        }
        else if (c == '/')
        {
            b.push_back(line);
            line = "";
        }
        else
        {
            rep(i, c - '0')
                line += ".";
        }
    }
    b.push_back(line);
}

string makejfen(vector<string> &board)
{
    string ret = "";
    int h = board.size();
    int w = board[0].size();
    rep(i, h)
    {
        int tmp = 0;
        for (char c : board[i])
        {
            if (c == 'b')
            {
                if (tmp != 0)
                {
                    ret += to_string(tmp);
                }
                ret += "b";
                tmp = 0;
            }
            else
            {
                tmp++;
            }
        }
        if (tmp != 0)
        {
            ret += to_string(tmp);
        }
        if (i != h - 1)
            ret += "/";
    }
    return ret;
}
bool solve()
{
    string jfen;
    cin >> jfen;
    if (jfen == "#")
        return false;
    vector<string> board;
    makeboard(jfen, board);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    board[a][b] = '.';
    board[c][d] = 'b';
    cout << makejfen(board) << endl;
    ;
    return true;
}

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


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
int main (){
    int n,a[4]={0};
    string s;
    cin >> n;
    for (int i=0; i<n; i++){
        cin >> s;
        switch (s[0]){
        case 'A':
            a[0]++;
            break;
        case 'W':
            a[1]++;
            break;
        case 'T':
            a[2]++;
            break;
        case 'R':
            a[3]++;
            break;
        }
    }
    cout << "AC x " << a[0] << endl << "WA x " << a[1] << endl << "TLE x " << a[2] << endl << "RE x " << a[3] << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 998244353;
using ll = long long;
using namespace std;

const int bound = 200100;
ll fact[bound], fact_inv[bound];

ll power( ll a, ll b ){
	ll res = 1;
	while( b > 0 ){
		if( b & 1 ) res = res*a % mod;
		a = a*a % mod;
		b >>= 1;
	}
	return res;
}

void init(){
	fact[0] = 1;
	int b = bound-10;
	for( int i = 0; i < b; ++i ){
		fact[i+1] = fact[i]*(i+1) % mod;
	}
	fact_inv[b] = power(fact[b], mod-2);
	for( int i = b-1; i >= 0; --i ){
		fact_inv[i] = fact_inv[i+1]*(i+1) % mod;
	}
}

ll comb( ll n, ll r ){
	if( n < r or r < 0 ) return 0;
	return ( fact[n]*fact_inv[r] ) % mod * fact_inv[n-r] % mod;
}

int main(){
	init();	// Nicht vergessen!!
	ll n, m, k; cin >> n >> m >> k;
	ll ans = 0;
	for( ll i = 0; i <= k; ++i ){
		ans += m*power(m-1, n-1-i)%mod*comb(n-1, n-1-i)%mod;
		ans %= mod;
	}
	cout << ans << endl;
}

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

int main() {
    char c;
    cin >> c;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        cout << "vowel" << endl; 
    }
    else {
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

l = []
for i in range(len(a)):
  for j in range(len(b)):
    l.append(a[i]+b[j])

l.sort(reverse=True)
if k <= len(l):
  l = l[:k]

m = []
for i in range(len(l)):
  for j in range(len(c)):
    m.append(l[i]+c[j])

m.sort(reverse=True)   
for i in range(k):
  print(m[i])



Measured memory_bytes: 147772
def main():
    N = int(input())
    A = [int(input()) for i in range(N)]
    ans = 0
    for i in range(1, N):
        if A[i-1] > 1:
            ans += A[i-1] // 2
            A[i-1] %= 2
        if A[i-1] & 1 and A[i] > 1:
            ans += 1
            A[i-1] -= 1
            A[i] -= 1
    ans += A[-1] // 2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 50264
#include <stdio.h>
 
int main(void) {
  int N;
  int K;
  int D;
  int A;
  int okashi[256] = {0};
  int cnt = 0;
  scanf("%d", &N);
  scanf("%d", &K);
  for (int i = 0; i < K; i++) {
    scanf("%d", &D);
    for (int j = 0; j < D; j++) {
      scanf("%d", &A);
      okashi[A - 1] = 1;
    }
  }
  for (int p = 0; p < N; p++) {
    if (okashi[p] == 0) {
      cnt++;
    }
  }
  printf("%d\n", cnt);
  return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

using ll    = long long;
using vll   = vector<ll>;
using pll   = pair<ll,ll>;
using ld    = long double;

const ll mod = (ll)1e9 + 7;

void solve() {
	ll n;cin>>n;
string ans="";
    while(n){
        int rem=n%26;
        if(rem){
            char c=rem-1+'a';
            string s;
            s.push_back(c);
            ans.insert(0,s);
            n=n/26;
        }
        else{
            ans.insert(0,"z");
            n=n/26-1;
        }
    }
	cout<<ans<<"\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
//	pre();
//	ll t;cin>>t;while (t--)
		solve();
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
const int maxn=2005;
queue<int>qx,qy;
int map[maxn][maxn],n,m,sum[maxn][maxn],edge[maxn][maxn],dx[4]={1,-1,0,0},dy[4]={0,0,1,-1},X1,Y1,X2,Y2,q;
int shang[maxn][maxn],zuo[maxn][maxn];
int haha()
{
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)scanf("%1d",&map[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            sum[i][j]=sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1]+map[i][j];edge[i][j]=edge[i-1][j]+edge[i][j-1]-edge[i-1][j-1];
            if(map[i][j]&&map[i][j-1])edge[i][j]++,zuo[i][j]++;
            if(map[i][j]&&map[i-1][j])edge[i][j]++,shang[i][j]++;
        }
    for(int i=n;i;i--)
        for(int j=m;j;j--)shang[i][j]+=shang[i][j+1],zuo[i][j]+=zuo[i+1][j];
    while(q--)
    {
        scanf("%d%d%d%d",&X1,&Y1,&X2,&Y2);
        int num=sum[X2][Y2]-sum[X1-1][Y2]-sum[X2][Y1-1]+sum[X1-1][Y1-1],cnt=edge[X2][Y2]-edge[X1-1][Y2]-edge[X2][Y1-1]+edge[X1-1][Y1-1];
        int scnt=shang[X1][Y1]-shang[X1][Y2+1]+zuo[X1][Y1]-zuo[X2+1][Y1];cnt-=scnt;
        printf("%d\n",num-cnt);
    }
}
int sb=haha();
int main(){;}


Measured memory_bytes: 80256
<?php

  $kotae=trim(fgets(STDIN));
list($a,$b) = explode(' ',$kotae);
  if($a%2 == 0){
    echo 'Even';
    return;
  }
  if($b%2 == 0){
    echo 'Even';
    return;
  }
  echo 'Odd'
?>

Measured memory_bytes: 3828
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

N = int(input())

ans = num2alpha(N)
print(ans.lower())

Measured memory_bytes: 9184
#define _USE_MATH_DEFINES
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <typeinfo>

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REP1(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
//#define YES(ans) ans?cout<<"YES":cout<<"NO"

/*
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

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

using namespace std;

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

    string s;
    cin >> s;
    bool ans = true;
    int C = 0;
    if (s[0] != 'A')
        ans = false;
    for (int i = 2; i < s.size() - 1; i++)
    {
        if (s[i] == 'C')
            C++;
    }
    if (C != 1)
        ans = false;
    for (int i = 1; i < s.size(); i++)
    {
        switch (s[i])
        {
        case 'C':
            if (i < 2 || i >= s.size() - 1)
                ans = false;
            break;
        default:
            if (!('a' <= s[i] && s[i] <= 'z'))
                ans = false;
            break;
        }
    }
    if (ans)
        cout << "AC";
    else
        cout << "WA";
}

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

int main() {
  int N, A;
  cin >> N >> A;
  
  if(1 <= N && 100 >= N){
    if(0 <= A && N * N >= A){
      cout << N * N - A << endl;
    }else{
      cout << "Number is overfloating by chart. Please put nember under =>" << N * N << endl;
    }
  }else{
  cout << "Please put number 1 to 100." << endl;
  }
 }

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,x) for(int i=0; i<(int) (x); i++)
#define PI 3.14159265359
using namespace std;
 
int main()
{
  int n; cin>>n;
  n-=(n/1000*1000);
  if (n==0)cout<<"0\n";
  else cout << 1000-n << "\n";
  return 0;
}

Measured memory_bytes: 3556
#include <iostream>
using namespace std;
int n, m, q, ar[12], qry[52][4] = {}, mx = 0;
void rs(int d)
{
	if (d <= n)
	{
		for (int i = ar[d - 1]; i <= m; i++)
		{
			ar[d] = i;
			rs(d + 1); 
		}
	}
	else
	{
		int to = 0;
		for (int i = 0; i < q; i++)
		{
			if (ar[qry[i][1]] - ar[qry[i][0]] == qry[i][2]) {to += qry[i][3];}
		}
		mx = max(mx, to);
	}
}
int main()
{
	ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> q;
	for (int i = 0; i < q; i++)
	{
		for (int j = 0; j < 4; j++) {cin >> qry[i][j];}
	}
	ar[0] = 1;
	rs(1);
	cout << mx << "\n";
	return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>

int main(){
	int n;
	scanf("%d",&n);
	char str[n];
	scanf("%s",str);
	int count = 0;
	for (int i=0;i<1000;i++){
		int c[3] = { i/ 100,(i/10)%10,i%10};
		int f = 0;
		for(int j=0;j<n;j++){
			if(str[j]==('0'+c[f])){
				f++;
			}
			if(f==3){
				break;
			}
		}
		if(f==3){
			count++;
		}
	}
	printf("%d",count);
}

Measured memory_bytes: 1712
fun main(args:Array<String>) {
    println(if(is81(readLine()!!.toInt())) "Yes" else "No")
}

fun is81(num:Int):Boolean {
    for(i in (1..9)) {
        for(j in (1..9)) {
            if(i*j == num) {
                return true
            }
        }
    }
    return false
}

Measured memory_bytes: 31740
#include<iostream>
#include<string>
#include<stack>
using namespace std;

int main()
{
	for(;;)
	{
		stack<int> S;
		string str;
		getline(cin,str);
		if(str==".")break;
		int n=str.size();
		int f=0;
		for(int i=0;i<n;i++)
		{
			if(str[i]=='(')
			{
				S.push(1);
			}
			else if(str[i]=='[')
			{
				S.push(0);
			}
			else if(str[i]==')')
			{
				if(S.empty())
				{
					f=1;
					break;
				}
				if(S.top()==1)
				{
					S.pop();
				}
				else
				{
					f=1;
					break;
				}
			}
			else if(str[i]==']')
			{
				if(S.empty())
				{
					f=1;
					break;
				}
				if(S.top()==0)
				{
					S.pop();
				}
				else
				{
					f=1;
					break;
				}
			}
		}
		if(!S.empty())f=1;
		if(f==1)cout<<"no"<<endl;
		else cout<<"yes"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3168
#include<cstdio>
int n,a,b,c,d,t=-1;
char s[200000];
int main()
{
	scanf("%d%d%d%d%d%s",&n,&a,&b,&c,&d,s+1);
	for(int i=a;i<c;i++)
		if(s[i]==s[i+1]&&s[i]=='#')
		{
			puts("No");
			return 0;
		}
	for(int i=b;i<d;i++)
		if(s[i]==s[i+1]&&s[i]=='#')
		{
			puts("No");
			return 0;
		}
	if((a>=b&&c<=d)||(b>=a&&c>=d))
	{
		t=0;
		for(int i=(a>b?a:b);i<=(c>d?d:c);i++)
			if(s[i]==s[i-1]&&s[i]==s[i+1]&&s[i]=='.')t=1;
	}
	if(!t)
	{
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
 int A, B;
 cin >> A >> B;
 int ans;
 ans = max(A+B, A-B);
 ans = max(ans, A*B);
 cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
#define ull unsigned long long int
using namespace std;

ll n,m,ar[N],sum,t;



int main()
{
	fast;
	cin>>n;
	fs(ar,n);
	sort(ar+1,ar+n+1);
	for(int i=2;i<=n;i++)
		if(ar[i]==ar[i-1])
			return cout<<"NO",0;
		cout<<"YES";
}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

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

int main() {
  
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if(a*b >= d*c) cout << a*b << endl;
  else cout << d*c << endl;
  
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,a,b;
    double x;
    scanf("%d",&n);
    a = 1;
    b = 2;

    if((n%2) == 0){
        //nが偶数の場合
        x = (double)a/(double)b;
    }
    
    else{
        x = (double)(n+1)/(double)(2*n);
    }
    printf("%1.10f\n",x);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <vector>
#include <map>
#include <list>
#include <set>

using namespace std;

typedef long long ll;
#define rep(i, s, n) for(int i=(s); i<(int)(n); i++)
#define endl "\n"

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

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

    double A[n], sum=0.0;
    rep(i, 0, n){
        A[i] = (double)1/a[i];
        sum += A[i];
    }
    double result=1.0/sum;

/*
    ll sum=0, product=1;
    rep(i, 0, n){
        sum += a[i];
        product *= a[i];
    }

    double result=(double)product/sum;
*/
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
from math import factorial as f

N = int(input())

primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
divs = []
for i in range(1,101):
    tmp = [0 for _ in range(len(primes))]
    for j in range(len(primes)):
        p = primes[j]
        tmp[j] = 0
        while(i//p==i/p):
            i = i//p
            tmp[j] += 1
    divs.append(tmp)
#print(divs)

divsum = [0 for _ in range(len(primes))]
for i in range(1, N+1):
    for j in range(len(primes)):
        divsum[j] += divs[i-1][j]
#print(divsum)

def num(n):
    return len(list(filter(lambda x:x>=n-1, divsum)))

ans = 0

# >=74
ans += num(75)

# >=14 & 13~4
ans += num(15)*(num(5)-1)

# >=24 & 23~2
ans += num(25)*(num(3)-1)

# >=4,>=4 & >=2
ans += num(5) * (num(5)-1) * (num(3)-2) // 2 
print(int(ans))


Measured memory_bytes: 3064
import           Data.Char
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed   as U

main :: IO ()
main = do
  n <- readLn
  [a, b] <- map read . words <$> getLine
  ps <- U.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
  print $ solve a b ps

solve :: Int -> Int -> U.Vector Int -> Int
solve a b = minimum . U.foldl' f [0, 0, 0]
  where
    f [x, y, z] p
      | p <= a    = [x + 1, y, z]
      | p <= b    = [x, y + 1, z]
      | otherwise = [x, y, z + 1]

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

vector<ll> a = {1};
vector<ll> p = {1};

ll dfs(ll N, ll X) {
    if (X == 0) return 0;
    if (N == 0) return 1;
    if (X <= 1 + a[N - 1]) return dfs(N - 1, X - 1);
    else return p[N - 1] + 1 + dfs(N - 1, X - a[N - 1] - 2);
}

int main() {
    ll N, X; cin >> N >> X;
    a.resize(N + 1);
    p.resize(N + 1);
    for (int i = 0; i < N; ++i) {
        a[i+1] = 2 * a[i] + 3;
        p[i+1] = 2 * p[i] + 1;
    }
    cout << dfs(N, X) << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<stdio.h>
#include<string.h>
typedef struct{
  char X[1001];
  char Y[1001];
  int xlen;
  int ylen;
}Q;

main(){
  int a,b,i,j,k,q,xlen,ylen,z[1001][1001];
  Q n[300];
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%s",n[i].X);
    scanf("%s",n[i].Y);
    n[i].xlen = strlen(n[i].X);
    n[i].ylen = strlen(n[i].Y);
  }
  for(i=0;i<q;i++){
    for(j=1;j<=n[i].xlen;j++)z[j][0]=0;
    for(k=1;k<=n[i].ylen;k++)z[0][k]=0;

    for(a=1;a<=n[i].xlen;a++){
      for(b=1;b<=n[i].ylen;b++){
        if(n[i].X[a-1] == n[i].Y[b-1])
          z[a][b] = z[a-1][b-1] + 1;
        else if(z[a-1][b]>=z[a][b-1])
          z[a][b] = z[a-1][b];
        else
          z[a][b] = z[a][b-1];
      }}
    printf("%d\n",z[n[i].xlen][n[i].ylen]);
  }

return 0;
}

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

int INF = 100000;

int min(int a, int b) {
  return a > b ? b : a;
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M), c(M);
  int dist[100][100];

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) {
        dist[i][j] = 0;
      } else {
        dist[i][j] = INF;
      }
    }
  }

  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
    dist[a[i]][b[i]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }
  
  
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  
  int res = M;
  for (int k = 0; k < M; k++) {
    bool flag = false;
    for (int i = 0; i < N; i++) {
      if (dist[i][a[k]]+c[k] == dist[i][b[k]]) {
        flag = true;
      }
    }
    if (flag) res--;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;
int main()
{
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;

    return 0;
}


Measured memory_bytes: 3632
import std.stdio;
import std.string;
import std.algorithm;
import std.array;
import std.conv;
import std.typecons;

long n, m;
long[string] assoc;
string[] cands;

string[long] dp;

string solve(long x) {
  if (x in dp) {
    return dp[x];
  }
  if (x < 0) {
    return "-";
  }

  string max = "-";
  foreach (c; cands) {
    auto r = solve(x - assoc[c]) ~ c;
    if (r[0] != '-' && (r.length > max.length || (r.length == max.length && r > max) || max == "-")) {
      max = r;
    }
  }
  dp[x] = max;

  return dp[x];
}

void main() {
  foreach (i, x; [2,5,5,4,5,6,3,7,6]) {
    assoc[(i+1).to!string] = x;
  }

  readf("%d %d\n", &n, &m);
  cands = readln.strip.split(" ").array;
  dp[0] = "";
  writeln(solve(n));
}


Measured memory_bytes: 88572
s = input()
t = input()

dict_st = {}
dict_ts = {}
ans = "Yes"
for x, y in zip(s, t):
  if x not in dict_st:
    dict_st[x] = y
  else:
    if dict_st[x] != y:
      ans = "No"
      break
  if y not in dict_ts:
    dict_ts[y] = x
  else:
    if dict_ts[y] != x:
      ans = "No"
      break
      
print(ans)
      


Measured memory_bytes: 3632
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
if B<A:
    B=-B
    A=-A

#以降はA<B
#A+Vt
#B+Wt
if A+V*T>=B+W*T:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define ld long double
#define si(x) (ll)((x).size())
#define pb push_back
#define F first
#define S second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
#define all(x) (x).begin(), (x).end()
#define make_unique(x) (x).resize(unique(all(x))-(x).begin())
#define pr_vec(v) for(ll _=0;_<v.size();_++) cout << v[_] << " " ;
const int N = 3e5 + 7;
#define log 26

void solve()
{
    ll n, k;
    cin >> k >> n;

    std::vector<pair<ll, ll>> v(n);
    rep(i, n) cin >> v[i].F >> v[i].S;
    std::vector<ll> dp(k+1,1e18);
    dp[0]=0;
    rep(_,n)
    {
        ll x=v[_].F,y=v[_].S;
        std::vector<ll> t=dp;
        for(ll i=0;i<=k;i++)
            if(i+x<=k)
                t[i+x]=min(t[i+x],t[i]+y);
            else
                t[k]=min(t[k],t[i]+y);

    

        // pr_vec(t);
        // cout<<endl;    
        dp=t;    
    }    
    cout<<dp[k];

}


int main()
{




    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t = 1;
    // cin >> t;


    rep1(i, t)
    {
        // cout << "Case #" << i << ": ";
        solve();
        cout << endl;
    }


}

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

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	vector<int> v(n), ans(n);
	for(int i=0;i<n;i++){
		cin >> v[i];
		ans[v[i]-1] = i+1;
	}
	for(int i=0;i<n;i++){
		cout << ans[i] << " ";
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 1664
import Data.Bits
import Data.List
import Control.Monad
import qualified Data.Vector.Unboxed as V
import Control.Monad.ST
import Data.Maybe (fromMaybe)
import qualified Data.ByteString.Lazy.Char8 as B
import Debug.Trace

check :: [Int] -> [Int] -> Bool
check xs ys = (foldl (\x (y,y') -> x + (y-y')^2) 0 (zip xs ys)) == (((^2) . floor . sqrt . fromIntegral) $ foldl (\x (y,y') -> x + (y-y')^2) 0 (zip xs ys))

main :: IO ()
main = do
  [n,d] <- map read.words <$> getLine :: IO [Int]
  xss <- replicateM n $ map read.words <$> getLine
  print $ length [1 | xs <- xss, xs' <- xss, xs < xs', check xs xs']


Measured memory_bytes: 1020
N=int(input())
x=[int(i) for i in input().split()]
d=[x[i+1]-x[i] for i in range(N-1)]
ans=0
tmp=0
N1fact=1
mod=10**9+7
def inv(x):
    return pow(x,mod-2,mod)
for i in range(1,N):
    N1fact=(i*N1fact)%mod
for k in range(1,N):
    tmp+=inv(k)
    tmp%=mod
    a1=tmp
    a2=(d[k-1]*N1fact)%mod
    #print(a1,a2)
    ans+=(a1*a2)%mod
    ans%=mod
print(ans)
#print(N1fact)
#print((ans*N1fact)%mod)

Measured memory_bytes: 63768
a = "ATGC"

inp = input()

ans = 0

for i in range(len(inp)):
	if inp[i] in a:
		cnt, j = 0, i
		while j < len(inp) and inp[j] in a:
			cnt += 1
			j += 1
		ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define all(v) v.begin(), v.end()
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n;
    n = s.size();
    int k;
    cin >> k;

    set<string> se;
    for(int l = 1; l<=5; l++){
        for(int i=0; i<n; i++){
            string ss = s.substr(i,l);
            se.insert(ss);
        }
    }
    vector<string> v;
    for(auto sss : se){
        v.push_back(sss);
    }
    sort(all(v));

    // dump(v);
    cout << v[k-1] << endl;
    return 0;
}

Measured memory_bytes: 1920