akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        long mod = (long)Math.pow(10,9)+7;
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        char[] s = sc.next().toCharArray();
        int len = s.length;
        long[][] dp = new long[len+1][13];
        dp[0][0] = 1;
        for(int i = 0; i < len; i++){
            char c = s[i];
            int now = c == '?' ? -1 : c - '0';
            for(int j = 0; j < 10; j++){
                if(now != -1 && now != j){
                    continue;
                }
                for(int k = 0; k < 13; k++){
                    int mod13 = (k*10+j) % 13;
                    dp[i+1][mod13] += dp[i][k];
                    dp[i+1][mod13] %= mod;
                }
            }
        }
        System.out.println(dp[len][5]);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

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

int main(){
    char map[6][5] = {
	{'a', 'b', 'c', 'd', 'e'},
	{'f', 'g', 'h', 'i', 'j'},
	{'k', 'l', 'm', 'n', 'o'},
	{'p', 'q', 'r', 's', 't'},
	{'u', 'v', 'w', 'x', 'y'},
	{'z', '.', '?', '!', ' '}};

    string s;
    while (cin >> s){
	bool err = false;
	for (int i = 0; i < s.size(); i++)
	    if (i % 2 && (s[i] > '5' || s[i] < '1')) err = true;
	    else if (i % 2 == 0 && (s[i] > '6' || s[i] < '1')) err = true;

	if (s.size() % 2 || err) cout << "NA" << endl;

	else {
	    for (int i = 0; i < s.size(); i+=2)
		 cout << map[s[i]-'0'-1][s[i+1]-'0'-1];
	    cout << endl;
	}
    }
}

Measured memory_bytes: 0
// #include {{{
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <random>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

#ifdef DEBUG
#include <fmt/format.h>
#endif
// }}}

using namespace std;

// macros {{{
template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

template<typename InputIt>
void PRINT_RANGE(InputIt first, InputIt last)
{
    for(; first != last; ++first)
        cout << *first << (first==last ? "" : " ");
    cout << "\n";
}

template<typename T>
void PRINT_MATRIX(T mat, size_t nr, size_t nc)
{
    for(size_t r = 0; r < nr; ++r) {
        for(size_t c = 0; c < nc; ++c) {
            cout << mat[r][c] << (c==nc-1 ? "" : " ");
        }
        cout << "\n";
    }
}

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)
// }}}

// types {{{
using s64 = int64_t;
using u64 = uint64_t;
// }}}

int N;
vector<vector<int>> T;

vector<int> D; // ???????????±???
vector<vector<int>> P; // P[v][i]: v??????2^i??????????????£?????????????????????
int P_NI;

void init()
{
    D.resize(N);

    P.resize(N);
    P_NI = 1 + static_cast<int>(log2(N));
    for(auto& pi : P) {
        pi.resize(P_NI);
    }
}

void dfs(int u, int p, int d)
{
    D[u] = d;
    P[u][0] = p;

    for(int v : T[u]) {
        if(v == p) continue;
        dfs(v, u, d+1);
    }
}

void make_p()
{
    REP(i, P_NI-1) {
        REP(v, N) {
            if(P[v][i] == -1) {
                P[v][i+1] = -1;
            }
            else {
                P[v][i+1] = P[P[v][i]][i];
            }
        }
    }
}

int lca(int u, int v)
{
    // ?°????????????? D[u] <= D[v] ??¨??????
    if(D[u] > D[v]) swap(u,v);

    // ??±??????????????????(D[u] == D[v] ??¨??????)
    for(int i = P_NI-1; i >= 0; --i) {
        int d = D[v] - D[u];
        if((d>>i) & 1) {
            v = P[v][i];
        }
    }

    // ?????´????????´??????????????\?????????????????????
    if(u == v) return u;

    // ????????¢?´¢
    for(int i = P_NI-1; i >= 0; --i) {
        if(P[u][i] != P[v][i]) {
            u = P[u][i];
            v = P[v][i];
        }
    }
    return P[u][0];
}

void solve()
{
    init();

    dfs(0, -1, 0);

    make_p();

#ifdef DEBUG
    fmt::print("D:\n");
    PRINT_RANGE(begin(D), end(D));
    fmt::print("P:\n");
    PRINT_MATRIX(P, N, P_NI);
#endif

    int Q;
    cin >> Q;
    REP(_, Q) {
        int u, v;
        cin >> u >> v;

        cout << lca(u,v) << "\n";
    }
}

int main()
{
    cin >> N;
    T.resize(N);

    REP(u, N) {
        int k;
        cin >> k;
        REP(_, k) {
            int v;
            cin >> v;
            T[u].push_back(v);
            T[v].push_back(u);
        }
    }

    solve();

    return 0;
}

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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll x, k, d;
  cin >> x >> k >> d;
  bool flag = (x > 0);
  x = abs(x);
  ll cnt = min(k, x / d);

  x -= cnt * d;
  k -= cnt;

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

  if (k % 2 == 0) {
    cout << abs(x) << endl;
  } else {
    x -= d;
    cout << abs(x) << endl;
  }

  return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
typedef vector<bool> vb;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
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;}
void CumuSum(vl &A){rep(i,A.size())if(i)A[i]+=A[i-1];}
ll llpow(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;}return res;}
ll llpowMOD(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;res%=MOD;e%=MOD;}return res;}

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

    // solution comes here

    ll N;
    cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];

    ll eve2=0, eve4=0, odd=0;
    rep(i, N) {
        if(A[i]%4 == 0) eve4++;
        else if(A[i]%2==0)eve2++;
        else odd++;
    }

    if(!odd or odd<=eve4 or (odd-eve4==1 and !eve2)) cout << "Yes" << nl;
    else cout << "No" << nl;
}

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

const int N=2e5+100;
const int mod=1e9+7;
typedef long long ll;


typedef pair<int,int> pa;

char s[102][102];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n,m;cin>>n>>m;
    for(int i=1;i<=50;i++)
        for(int j=1;j<=100;j++) s[i][j]='.';

    for(int i=51;i<=100;i++) {
        for(int j=1;j<=100;j++) {
            s[i][j]='#';
        }
    }
    int x=1,y=2;
    for(int i=1;i<m;i++) {
        s[x][y]='#';
        if(y==100) x+=2,y=0;
        y+=2;

    }
    x=100,y=2;
    for(int i=1;i<n;i++){
        s[x][y]='.';
        if(y==100) x-=2,y=0;
        y+=2;
    }
    cout<<100<<" "<<100<<endl;

    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++)
             cout<<s[i][j];
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3660
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

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

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n, k := r.nextInt(), r.nextInt()
	r.Scan(true)
	h := r.nextStringArray().toInts()

	sort.Sort(sort.Reverse(sort.IntSlice(h)))

	ans := 0
	for i := k; i < n; i++ {
		ans += h[i]
	}

	fmt.Fprintln(stdout, ans)
}


Measured memory_bytes: 12800
n = int(input())
l = list(map(int, input().split()))
count = 0
for i in range(len(l)):
	for j in range(len(l)):
		for k in range(len(l)):
			if i < j and j < k \
			and l[i] != l[j] \
			and l[j] != l[k] \
			and l[i] != l[k] \
			and l[i]+l[j]+l[k] > 2*max(l[i], l[j], l[k]):
				count += 1
print(count)

Measured memory_bytes: 9064
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cmath>
#define endl "\n"
using namespace std;

void solve()
{   int x,y; cin >> x >> y;
    if ((y&1)) cout << "No";
    else (x<=y/2 &&2*x>=y/2) ? cout << "Yes" : cout << "No";
}

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


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define pll pair<long long,long long>
using namespace std;
bool prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k,n;
    cin>>k>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int x=INT_MAX;
    int z=1000;
    for(int i=100000;i>-100000;i--){
        bool b1=true;
        if(!(binary_search(a,a+n,i))){
            b1=false;
            x=min(x,abs(i-k));
        }
        if(!b1&&x==abs(i-k))z=i;
    }
    cout<<z;
    return 0;
}
    
    

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int* a;

void swap(int j, int k) {
    int temp = a[j];
    a[j] = a[k];
    a[k] = temp;
}

int main() {
    int w, n;
    cin >> w >> n;
    a = new int[w];
    REP(i,w) {
        a[i] = i+1;
    }
    REP(i,n) {
        int j, k;
        scanf("%d,%d", &j, &k);
        swap(j-1, k-1);
    }
    REP(i,w) {
        cout << a[i] << endl;
    }
    delete[] a;
    return 0;
}

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

int main() {
  
  int N, L;
  cin >> N >> L;
  
  int abs_min = 0;
  
  if(L+N-1<0){
  	abs_min = L+N-1;
  }else if(L>0){
  	abs_min = L;
  }else{
  	abs_min = 0;
  }
  
  int res = N*(2*L+N-1)/2 -abs_min;
  
  cout << res << endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val array = IntArray(n){sc.nextInt()}
    for (i in array.indices) {
        val v = array[i]
        var j = i - 1
        while (j >= 0 && array[j] > v) {
            array[j+1] = array[j]
            j--
        }
        array[j+1] = v
        println(array.joinToString(" "))
    }
}


Measured memory_bytes: 31052
N = int(input())
A = list(map(int, input().split()))

x = A[0]
y = sum(A[1:])
ans = abs(x - y)

for i in range(1, N - 1):
    x += A[i]
    y -= A[i]
    ans = min(ans, abs(x - y))

print(ans)

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

int main(){
    string a;
    cin >> a;
    string dummy = a;
    transform(a.begin(), a.end(), a.begin(), ::tolower); 
    string lower = a;
    string upper;
    transform(a.begin(), a.end(), a.begin(), ::toupper); 
    upper = a;
    if (dummy==lower)cout<<"a"<<endl;
    else cout<<"A"<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using P = pair<int,int>;

int n;
vector<long long> v;

bool solve(int alina){
    if(v[alina-1] >= n)return true;
    else return false;
}

int main(void){
    cin >> n;
    
    v.resize(n+1,0);
    for(int i = 1;i <= n;i++)v[i] = v[i-1] + i;
    
    int ok = n+1,ng = 0;
    while((ok-ng) > 1){
        int alina = (ok+ng)/2;
        
        if(solve(alina))ok = alina;
        else ng = alina;
    }
    
    int num = n - ng,num2 = v[ng-1];
    for(int i = ng-1;i > 0;i--){
        if(num <= num2-i){
            num2 -= i;
        } else cout << i << endl;
    }
    cout << ng << endl;
}

Measured memory_bytes: 81360
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	double h, max = 0.0, min = 9999999.0;
	while (cin >> h)
	{
		if (cin.eof()) break;
		if (h > max) max = h;
		if (h < min) min = h;
	}
	printf("%.1lf\n", max - min);
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
typedef long long ll;
typedef unsigned long long ull;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()ss		
#define debug system("pause")				//デバッグ用


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

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

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];

    sort(ALL(a));

    int fst=0,scd=0;
    REP(i,N-1){
        if(a[i]==a[i+1]){
            scd=fst;
            fst=a[i];
            i++;
        }
    }
    cout<<fst*scd<<endl;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1001001001;
static const ll MOD = 1000000007;


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

    int range = 2 * d + 1;
    cout << (n + range - 1) / range << endl;
}



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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

struct edge{int to, cost;};


void dfs(){

}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<vector<edge>> graph(n);

    for(int i = 0; i < n-1; i++){
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        edge e = {b, c};
        graph[a].push_back(e);
        e = {a, c};
        graph[b].push_back(e);
    }

    int q, k; cin >> q >> k;
    k--;
    vector<int> x(q), y(q);
    for(int i = 0; i < q; i++){
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }

    //dijkstra
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pque;
    vector<ll> dist(n, LLONG_MAX);
    dist[k] = 0;

    pque.push(make_pair(0, k));
    while(!pque.empty()){
        pair<int, int> p = pque.top();
        pque.pop();
        int v = p.second;
        if(dist[v] < p.first) continue;
        for(int i = 0; i < graph[v].size(); i++){
            edge e = graph[v][i];
            if(dist[e.to] > dist[v] + e.cost){
                dist[e.to] = dist[v] + e.cost;
                pque.push(make_pair(dist[e.to], e.to));
            }
        }
    }

    for(int i = 0; i < q; i++) cout << dist[x[i]] + dist[y[i]] << endl;

    return 0;
}


Measured memory_bytes: 10100
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "Yes" : "No")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F first
#define S second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    int cur = 0, out = 0;
    string s;
    cin >> s;
    for(int i = 0; i < 3; i++)
    {
        if(s[i] == 'R')
        {
            cur++;
        }
        else
        {
            cur = 0;
        }
        out = max(out, cur);
    }
    cout << out << endl;
}   

// Main

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    PreProcessTables();

    int T = 1, t;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using Graph = vector<vector<int>>;
using P = pair<int,int>;
using ll =long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int A,B,M;
    cin >> A >> B >> M;
    vector<int> a(A),b(B);
    vector<tuple<int,int,int>> in(M);
    rep(i,A){
        cin >> a[i];
    }
    rep(i,B){
        cin >> b[i];
    }
    ll ans = INF;
    rep(i,M){
        int x,y,c;
        cin >> x >> y >> c;
        x--;y--;
        ans = min(ans,(ll)(a[x] + b[y] - c));
    }
    
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    ans = min(ans,(ll)a[0]+b[0]);
    cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

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

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

//-------------------------------------------------
//--Union Find tree
//-------------------------------------------------
class UnionFind
{
private:
    vector<int> par;
    vector<int> rank;
    vector<int> sz;
public:
    UnionFind(int n):par(n),rank(n),sz(n){
        for(int i=0; i<n; i++){
            par[i] = i;
            rank[i] = 0;
            sz[i] = 1;
        }
    }
    int root(int x){
        if (par[x]==x) return x;
        return par[x] = root(par[x]);
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if (rx==ry) return;
        if (rank[rx]<rank[ry]){
            par[rx] = par[ry];
            sz[ry] += sz[rx];
        }else{
            par[ry] = par[rx];
            sz[rx] += sz[ry];
            if (rank[rx]==rank[ry]) rank[rx]++;
        }
    }
    int size(int x){
        return sz[root(x)];
    }
};

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    using P = tuple<int,int,int>;
    vector<P> ps;
    rep(i,N){
        int x,y; cin>>x>>y; x--; y--;
        ps.pb({x,y,i});
    }
    sort(all(ps));

    UnionFind uf(N);
    set<pi> Set;
    rep(i,N){
        int x,y,idx;
        tie(x,y,idx) = ps[i];
        Set.ins({y,idx});
    }
    rep(i,N){
        // for(auto e:Set){
        //     cout<<e<<" ";
        // }cout<<endl;
        int x,y,idx;
        tie(x,y,idx) = ps[i];
        Set.erase(pi(y,idx));
        if (uf.size(idx)>1) continue;
        auto itr = Set.lower_bound(pi(y,0));
        while(itr!=Set.end()){
            uf.unite(idx, itr->se);
            itr++;
        }
        itr = Set.lower_bound(pi(y,0));
    }

    rep(i,N){
        cout<<uf.size(i)<<"\n";
    }
    return 0;
}


Measured memory_bytes: 17148
from collections import deque
N = int(input())
visited = [False]*N
tree = [[] for _ in range(N)]
tmp = []
for _ in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    tree[a].append(b)
    tree[b].append(a)
    tmp.append((a, b))  # 順番を保持するため

ans = {}  # 連想配列で保持する

q = deque([0])  # 開始のノード
colors = [-1]*N  # そのノードにささっている辺の色
visited[0] = True
while len(q):  # 幅優先探索を開始する
    v = q.pop()  # 部分木の親のノード
    color = 1
    for e in tree[v]:  # 子供に対して操作を行う
        if visited[e]:
            continue
        visited[e] = True
        if colors[v] == color:
            color += 1
        ans[(v, e)] = color
        colors[e] = color
        color += 1
        q.append(e)
print(max(colors))
for a, b in tmp:
    print(ans[(a, b)])


Measured memory_bytes: 45252
#include <iostream>

int main(){
    int n, m;
    std::cin >> n >> m;
    int a[m+1];
    for(int i = 1; i <= m; i++){
        std::cin >> a[i];
        n -= a[i];
        if(n < 0){
            std::cout << -1 << std::endl;
            return 0;
        }
    }
    std::cout << n << std::endl;
}

Measured memory_bytes: 3556
#include <algorithm>
#include <iostream> //標準入出力
#include <fstream>  //ファイルでの入出力
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <utility> //pair
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define MAX 1000000007
#define pair(a) pair<a,a>

void _main(){
    ll out = 0;
    ll n; cin >> n;
    vector<ll>  as(n);
    ll sum=0;
    rep(i,n) {
        cin >> as[i];
        sum+=as[i];
        sum%=MAX;
    }
    rep(i,n-1){
        sum = (sum - as[i] + MAX)%MAX;
        out += (as[i]*sum)%MAX;
        out %= MAX;
    }
    cout << out << endl;
    return;
}
int main() {
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

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

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int gcd(int a, int b){
  if(a<b) swap(a, b);
  if(b==0) return a;
  return gcd(b, a%b);
}

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

int main(){
  int m, n;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  int x = gcd(n,m);
  bool exist = true;
  for(int i=0; i<x; i++) if(s[i*(n/x)]!=t[i*(m/x)]) exist = false;
  cout << (exist ? lcm(n,m) : -1) << endl;
  return 0;
}

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

typedef long long ll;
ll n, s, s2, a, num, z, z2, cnt, cnt2;
int main()
{
	ll i;
	cin >> n >> s;
	if (s == 0) {
		z = 1;
		z2 = -1;
		cnt = cnt2 = 1;
		s = 1;
		s2 = -1;
	} else {
		if (s > 0) z = 1;
		else z = -1;
		if (s > 0) {
			s2 = -1;
			cnt2 = s + 1;
		} else {
			s2 = 1;
			cnt2 = -s + 1;
		}
		z2 = -z;
	}
	for (i = 1; i < n; i++) {
		scanf ("%lld", &a);
		z = -z;
		z2 = -z2;
		s += a;
		s2 += a;
		if (z == 1 && s <= 0) {
			cnt += (1 - s);
			s = 1;
		} else if (z == -1 && s >= 0) {
			cnt += (s + 1);
			s = -1;
		}
		if (z2 == 1 && s2 <= 0) {
			cnt2 += (1 - s2);
			s2 = 1;
		} else if (z2 == -1 && s2 >= 0) {
			cnt2 += (s2 + 1);
			s2 = -1;
		}
	}
	cout << min(cnt, cnt2);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> t(N+1),x(N+1),y(N+1);
  t.at(0) = x.at(0) = y.at(0) = 0;
  for(int i = 0; i < N; i++){
    cin >> t.at(i+1) >> x.at(i+1) >> y.at(i+1);
  }
  bool flg = true;
  for(int i = 0; i < N; i++){
    int dx,dy,dt,dist;
    dx = std::abs(x.at(i+1) - x.at(i));
    dy = std::abs(y.at(i+1) - y.at(i));
    dt = t.at(i + 1) - t.at(i);
    dist = dt - dx - dy;
    if(dist < 0 || (dist & 1)){
      cout << "No" << endl;
      flg = false;
      break;
    }
  }
  
  if(flg == true){
    cout << "Yes" << endl;
  } 
}

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

n,m=map(int,input().split())
g=[list(map(int,input().split())) for _ in range(n)]
c=[list(map(int,input().split())) for _ in range(m)]

for i in g:
    a,b=i[0],i[1]
    dis=10**10
    ind=1
    for j in range(m):
        x,y=c[j][0],c[j][1]
        now=abs(a-x)+abs(b-y)
        if now<dis:
            dis=now
            ind=j+1
    print(ind)

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

#define mp make_pair
#define pb push_back

using namespace std;

vector<int> g[111111];
int chk[111111];
int n, q, f, cnt;

void dfs(int u){
	g[0].pb(u);
	chk[u] = 1;
	if (u == n){
		f = 1;
		return;
	}
	for(int i = 0; i < g[u].size(); ++i){
		int v = g[u][i];
		if (!chk[v]){
			dfs(v);
			if (f) return;
			g[0].pop_back();
		}
	}
}

void go(int u){
	chk[u] = 1;
	++cnt;
	for(int i = 0; i < g[u].size(); ++i){
		int v = g[u][i];
		if (!chk[v]) go(v);
	}
}

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d",&n);
	for(int i = 1; i < n; ++i){
		int x, y;
		scanf("%d%d",&x,&y);
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1);
	memset(chk, 0, sizeof(chk));
	chk[g[0][(g[0].size() - 1) / 2]] = 1;
	go(g[0][(g[0].size() - 1) / 2 + 1]);
	if (cnt < n - cnt) printf("Fennec");
	else printf("Snuke");
	return 0;
}

Measured memory_bytes: 10104
#pragma GCC optimize "trapv"
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
int main()
{
    fio;
    ll x;
    cin>>x;
    if(x>=30)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3652
import sys
H, W = list(map(int, input().split()))


if H == 1:
    print(1)
    sys.exit(0)
if W == 1:
    print(1)
    sys.exit(0)

if W % 2 == 0:
    kisu = W // 2
    gusu = W // 2
else:
    kisu = W // 2 + 1
    gusu = W // 2

if H % 2 == 0:
    ans = (kisu + gusu) * (H // 2)
else:
    ans = (kisu + gusu) * (H // 2) + kisu

print(ans)


Measured memory_bytes: 38256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int X, t;
	cin >> X >> t;
	cout << max(X - t, 0ll);
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>

using namespace std;

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

int INF = 10e8;
int d[100][100];
int n, m, l, k, a, h;
bool cold[100];

int main(){
    while(1){
        cin >> n >> m >> l >> k >> a >> h;
        
        if(n==0) break;

        REP(i, n){
            REP(j, n){
                if(i==j){
                    d[i][j] = 0;
                } else {
                    d[i][j] = INF;
                }
            }
        }

        REP(i, n) cold[i] = false;
        REP(i, l){
            int cold_ind;
            cin >> cold_ind;
            cold[cold_ind] = true;
        }
        cold[a] = true;
        cold[h] = true;

        REP(i, k){
            int x, y, t;
            cin >> x >> y >> t;
            d[x][y] = t;
            d[y][x] = t;
        }

        REP(i, n){
            if(!cold[i]){
               REP(j, n){
                   REP(k, n){
                       d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
                       d[k][j] = d[j][k];
                   }
               }
            }
        }
        REP(i, n){
            if(!cold[i]){
                REP(j, n){
                    d[i][j] = INF;
                    d[j][i] = INF;
                }
            }
        }

        /*
        REP(i, n){
            REP(j, n){
                cout << d[i][j] << " ";
            }
            cout << endl;
        }
        */

        REP(i, n){
            REP(j, n){
                if(d[i][j] > m){
                    d[i][j] = INF;
                }
            }
        }

        REP(k, n){
            REP(i, n){
                REP(j, n){
                    d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
                }
            }
        }

        if(d[a][h] == INF){
            cout << "Help!" << endl;
        } else {
            int output = d[a][h] + max(0, d[a][h] - m);
            cout << output << endl;
        }
    }
}

Measured memory_bytes: 3112
#include<cstdio>
 
int main(){
 
	int a, b, c, d;
	scanf("%d %d %d",&a,&b,&c);
	if (a == b)  d = c ;
	else if (a == c) d = b;
        else d =a;
	printf("%d",d);
	return 0;
}

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

int main()
{
	int A, B,C;
	cin >> A;
	cin >> B;

	C = A - (2 * B);

	if (A - (2 * B) < 0)
		C = 0;

	cout << C;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		while(true){
			int n=0,p=0,o=0,x=0,flag=0;
			n=scan.nextInt();
			p=scan.nextInt();
			if(n==0 && p==0){
				break;
			}
			o=p;
			int[] list;
			list = new int[n];
			for(int i=0;i<n;i++){
				list[i]=0;
			}
			while(true){
				for(int i=0;i<n;i++){
					if(p==0){
						p+=list[i];
						list[i]=0;
					}else{
						list[i]+=1;
						p--;
						if(list[i]==o){
							x=i;
							flag=1;
							System.out.println(x);
							break;
						}
					}
				}
				if(flag==1){
					break;
				}
			}
		}
	}
}



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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

int main(){
    int cost;
    int money[6]={500, 100, 50, 10, 5, 1};
    while(cin >> cost && cost){
        int change=1000-cost;
        int ans=0;
        for(int i=0; i<6; i++){
            if(change == 0) break;
            ans+=change/money[i];
            change=change%money[i];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3012
import java.util.Scanner;

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

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        System.out.println((n - h + 1) * (n - w + 1));
    }
}


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

using namespace std;

typedef long long ll;

ll n, ans = 0;

map <ll, bool> used;

void check(ll x)
{
	// cout << x << endl;
	if(x == 1) return;
	ll m = n;
	while(m % x == 0) m /= x;
	m %= x;
	if(m == 1) 
	{
		if(!used[x])
		{
			ans++;
			used[x] = 1;
		}
	}
}

int main()
{
	cin >> n;
	for(ll i = 1; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			check(i); check(n / i);
		}
	}
	ll m = n - 1;
	for(ll i = 1; i * i <= m; i++)
	{
		if(m % i == 0)
		{
			check(i), check(m / i);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;
//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

int n,x,ret,t;
vi a;

int main(){
    I(n); I(x);
    REP(i,n){
        I(t);
        a.pb(t);
    }
    sort(a.begin(),a.end());
    for (auto v:a){
        x -= v;
        if(x < 0) break;
        ret++;
    }
    if(x > 0) ret--;
    cout << ret << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
int A,B,C,D,E,N,M,x,y,cou=0,cou2,v[1000000],w[1000000],min_i,en=0;
    char S[10],W[10],s[10],X,Y;
   scanf("%d",&A);
   if(A<1200){
       printf("ABC");
   }else{
       printf("ARC");
   }
    return 0;
}

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

#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<ll,ll> ii;
const ll INF = 0x3f3f3f3f3f3f3f;
const double PI = acos(-1.0);

const int T = 2512;
vector<ii> g[T];
ll dist[T];
ll n,m,p;

void bellman() {
    for(int i = 0; i < n-1; i++)
        for(int u = 1; u <= n; u++)
            for(ii v : g[u])
                if(dist[u] < INF)
                    dist[v.fi] = min(dist[v.fi],dist[u]+v.se);
}

void cycle() {
    for(int i = 0; i < n-1; i++)
        for(int u = 1; u <= n; u++)
            for(ii v : g[u])
                if(dist[u] < INF and dist[u]+v.se < dist[v.fi])
                    dist[v.fi] = -INF;
    }


int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> m >> p;
    for(int i = 0; i < m; i++) {
        ll a,b,c;
        cin >> a >> b >> c;
        g[a].eb(b,p-c);
    }

    for(int i = 1; i <= n; i++) dist[i] = INF;
    dist[1] = 0;
    bellman();
    cycle();
    //bellman();

    cout << (dist[n] <= -INF? -1 : dist[n] > 0? 0 : abs(dist[n])) << endl;
    return 0;
}



Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
  const int A = 4;
  const int B = 7;
  int N;
  cin >> N;

  bool ok = false;
  for (int a = 0; a * A <= N; ++a) {
    for (int b = 0; (a * A + b * B) <= N; ++b) {
      if (a * A + b * B == N) {
        ok = true;
        goto LOOPEND;
      }
    }
  }

LOOPEND:
  if (ok) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
#define MOD (ll)(1e9+7)
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

ll n,x,ans = 0;

void dfs(ll k,ll cnt){ //k:レベル,cnt:残り枚数
    if(k == 0){
        ans++;
        return;
    }

    if(cnt <= 1);
    else if( cnt <= (ll)pow(2,k+1) - 2){
        dfs(k-1,cnt-1);
    }
    else if(cnt == (ll)pow(2,k+1) - 1){
        ans += pow(2,k);
    }
    else if(cnt <= (ll)pow(2,k+2) - 4){
        ans += pow(2,k);
        dfs(k-1,cnt - (ll)pow(2,k+1) + 1);
    }
    else{
        ans += (ll)pow(2,k+1) - 1;
    }

    return;
}

signed main(){
    cin >> n >> x;
    dfs(n,x);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::io::Write;

fn main() {
    let mut first_line = String::new();
    let mut second_line = String::new();

    io::stdin().read_line(&mut first_line)
        .expect("Failed to read line");

    let first_line: usize = first_line.trim().parse()
        .expect("Failed to read number");

    io::stdin().read_line(&mut second_line)
        .expect("Failed to read line");

    let second_line: Vec<usize> = second_line
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();
        
    let mut result_vector : Vec<usize> = vec![0; first_line];

    for index in 0..second_line.len() {
        let result_index: usize = second_line[index] - 1;
        result_vector[result_index] = index + 1;
    }

    for number in result_vector.iter() {
        print!("{} ", number);
        io::stdout().flush().unwrap();
    }
}


Measured memory_bytes: 8956
import sys
from fractions import gcd
A, B = map(int, input().split())

glst = []
tmp = gcd(A, B)
for i in range(1, int(tmp ** 0.5) + 1):
    if tmp % i == 0:
        glst.append(i)
        if i != tmp // i:
            glst.append(tmp // i)

glst.sort()
cnt = 0
for i in range(1, len(glst) + 1):
    cntF = True
    for j in range(i + 1, len(glst) + 1):
        if gcd(glst[-i], glst[-j]) != 1:
            cntF = False
            break

    if cntF:
        cnt += 1

print(cnt)


Measured memory_bytes: 5216
from collections import deque

s = input()
q = int(input())

query = [input().split() for i in range(q)]

a = deque([s])

flag = True

for i in range(q):
    if query[i][0] == "1":
        flag = not(flag)
    else:
        if (query[i][1] == "1" and flag) or (query[i][1] != "1" and not(flag)):
            a.appendleft(query[i][2])
        else:
            a.append(query[i][2])

b = "".join(a)
if not(flag):
    b = b[::-1]

print(b)

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int x;
	cin >> x;
	if(x == 7 || x == 5 || x == 3){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b; char c; scanf("%d %c %d", &a, &c, &b);
	
	if(c == '+') printf("%d\n", a + b);
	else printf("%d\n", a - b);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,m;cin>>n;
    vint a(n);
    int cou = 0;
    rep(i, n){
        cin>>a[i];
        if(a[i]!=i+1)cou++;
    }
    if(cou<=2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    /*rep(i, n-1){
        for(int j = i;j<n;j++){
            int t = a[i];
            a[i] = a[j];
            a[j] = t;
            bool flag = true;
            rep(k, n-1){
                if(a[k]>)
            }
            t = a[i];
            a[i] = a[j];
            a[j] = t;
        }
    }*/

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  
  cin >> n;
  while(n != 0){
    char a[n+1],b[n+1];
    for(int i = 0;i < n;i++) cin >> a[i] >> b[i];
    
    cin >> m;
    char ans[m+1];
    for(int i = 0;i < m;i++){
      cin >> ans[i];
      
      for(int j = 0;j < n;j++){
	if(ans[i] == a[j]){
	  ans[i] = b[j];
	  break;
	}
      }
    }
    
    ans[m]='\0';
    cout << ans << endl;
    cin >> n;
  }
    
  return (0);
}

Measured memory_bytes: 3164
#include <stdio.h>

int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (((a != b) && (a != c) && (b != c)) || ((a == b) && (a == c)))
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))

A.sort()
tmp = A[0]
ans = 1
for i in range(1, N):
  if tmp*2 >= A[i]:
    tmp += A[i]
    ans += 1
  else:
    tmp += A[i]
    ans = 1
print(ans)

Measured memory_bytes: 20712
# ARC058C - こだわり者いろはちゃん / Iroha's Obsession (ABC042C)
def main():
    n, k = list(map(int, input().rstrip().split()))
    D = set(map(int, input().rstrip().split()))
    ans = n
    while any(int(i) in D for i in str(ans)):
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060