akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())
#define MIN(vec) *min_element(vec.begin(), vec.end());
#define MAX(vec) *max_element(vec.begin(), vec.end());
#define IN(n,m)  (!(m.find(n) == m.end()))
#define TO_INT(vec,s) REP(i,s.length()){vec.push_back(s[i] - ‘0’);}
#define ENUM_v(vet) for (auto e : vec)
#define dump_MAP(m) for(auto itr = m.begin(); itr != m.end(); ++itr) { cerr << itr->first << " --> "  << itr->second << endl; }

using namespace std;
typedef vector<long> VI;
typedef vector<VI> VVI;


long long func(long b,long long n){
	if (b > n) return n;
	else return func(b,floor((double)n/(double)b)) + (n % b);
}
int main(void){
	long long n;
	long long s;
	cin >> n;
	cin >> s;

	if (n == s) {
		cout << (n+1) << endl;
		exit(0);
	}
	long iter_m = sqrt(n);
	FOR(b,2,iter_m+1){
		if (func(b,n) == s) {
			cout << b << endl;
			exit(0);
		}
	}

	//dump(iter_m);
	long ns = n-s;
	if (ns <= 0) cout << (-1) << endl;
	else {
		long m = sqrt(ns);
		long long ans = llINF;
		FOR(i,1,m+1){
			if (ns % i == 0){
				if ((ns/i) >= iter_m && (s-i) >= 0 && ((s-i) < (ns/i)+1)) ans = min(ans,(long long)(ns/i) + 1);
			}
		}
		if (ans == llINF) cout << (-1) << endl;
		else {
			cout << ans << endl;
			/*
			long long p = ns/(ans-1);
			long long q = s - p;
			dump(p);
			dump(q);*/
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

char s[1005];

int main(){
    int N=0, E=0, S=0, W=0;
    scanf("%s", s);
    for(int i=0; s[i]; i++){
        if(s[i] == 'N') N=1;
        if(s[i] == 'S') S=1;
        if(s[i] == 'E') E=1;
        if(s[i] == 'W') W=1;
    }
    if(((!N)&S) || (N&(!S))){ printf("No"); return 0; }
    if(((!W)&E) || (W&(!E))){ printf("No"); return 0; }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int digits(int x){
  int sum=0;
  while(x>0) {
    x/=10;
    sum++;
  }
  return sum;
}
int main() {
  int n;
  cin >> n;
  int ans=0;
  for(int i=1;i<=n;++i) {
    if(digits(i)%2!=0) ans++;
  }
  cout << ans << endl;
  return 0;
}
    


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize,
        av: [i64; n],
        q: usize,
        bcv: [(i64, i64); q]
    };

    let mut table = HashMap::new();
    let mut sum = 0_i64;
    for a in av {
        sum += a;
        *table.entry(a).or_insert(0) += 1;
    }
    for (b, c) in bcv {
        let bc = *table.get(&b).unwrap_or(&0);
        table.insert(b, 0);
        let cc = *table.get(&c).unwrap_or(&0);
        table.insert(c, bc + cc);
        sum -= b * bc;
        sum += c * bc;
        println!("{}", sum);
    }
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 8512
require 'pp'

n = gets.chomp!.to_i
a_n = gets.chomp!.split(" ").map(&:to_i)

count = 0
a_n.each {|x|
    num = x
    while num % 2 == 0
        num = num / 2
        count += 1
    end
}

puts count


Measured memory_bytes: 2684
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

#define bs(n) (1ull<<(ull)(n))
#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)


int main() {
    ll n, k;
    cin >> n >> k;
    n = n % k;
    cout << min(n, k - n) << endl;
}


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

#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    double d,t,s;
    cin>>d>>t>>s;
    if((d/s)>t)
    {
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3732
using System;

class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            String[] s = Console.ReadLine().Split(' ');
            int m = int.Parse(s[0]);
            int f = int.Parse(s[1]);
            int r = int.Parse(s[2]);

            //終了条件
            if (m == -1 && f == -1 && r == -1)
            {
                break;
            }

            //評価チェック
            if (m == -1 || f == -1)
            {
                Console.WriteLine("F");
            }
            else if (m + f >= 80)
            {
                Console.WriteLine("A");
            }
            else if (65 <= m + f && m + f < 80)
            {
                Console.WriteLine("B");
            }
            else if (50 <= m + f && m + f < 65)
            {
                Console.WriteLine("C");
            }
            else if (30 <= m + f && m + f < 50)
            {
                if (r >= 50)
                {
                    Console.WriteLine("C");
                }
                else
                {
                    Console.WriteLine("D");
                }
            }
            else
            {
                Console.WriteLine("F");
            }
        }
    }
    
}

Measured memory_bytes: 8884
#include <stdio.h>
int main(void)
{
	int count=0;
	char s[3];
	scanf("%s",s);
	for(int i=0;i<3;i++){
		if(s[i]=='1'){
			count+=1;
			
		}
	}
	printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = map(int, raw_input().split())
flag = [False] * (N + 1)
for i in range(M):
    num = input()
    flag[num] = True

DP = [0, 1] + [0] * N
for i in range(1, N + 1):
    if not flag[i]:
        DP[i + 1] = DP[i] + DP[i - 1]
        DP[i + 1] %= MOD
print DP[N + 1]


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

int main() {
    int n;
    vi p;
    int ptmp[3];

    int ans = 0;

    cin>>n;

    p.resize(n);
    REP(i,n) cin>>p[i];

    FOR(i,1,n-1)
    {
        ptmp[0]=p[i-1];
        ptmp[1]=p[i];
        ptmp[2]=p[i+1];

        sort(ptmp, ptmp+3);

        if (ptmp[1] == p[i])
            ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
 
int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a <= 0 && 0 <= b) {
        printf("Zero\n");
    }
    else if (0 < a) {
        printf("Positive\n");
    }
    else {
        printf((b - a + 1) % 2 == 0 ? "Positive\n" : "Negative\n");
    }
    return 0;
}

Measured memory_bytes: 128
n, h = gets.split.map(&:to_i)
swings = []
throwings = []
n.times do
  s, t = gets.split.map(&:to_i)
  swings << s
  throwings << t
end
swing = swings.max
throwings.sort! { |a, b| b <=> a }
ans = 0
until h <= 0 || throwings.empty?
  throwing = throwings.shift
  if throwing > swing
    h -= throwing
  else
    h -= swing
    throwings.clear
  end
  ans += 1
end
ans += (h / swing.to_f).ceil if h > 0
puts ans


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

# define F first
# define S second
# define mp make_pair
// everything go according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput (string in = "s") {
  if (fopen (in.c_str(), "r"))
    freopen (in.c_str(), "r", stdin);
  else
    cerr << "Input file not found" << endl;
}                
const int N = 1e3 + 1;
int n;

ll a[4][N];

ll V;

int main()
{                
  //localInput();
  Read_rap ();
  cin >> n >> V;
  for (int i = 0; i < 4; i++)
  	for (int j = 1; j <= n; j++)
  		cin >> a[i][j];

 	vec<ll> s;       
  for (int i = 1; i <= n; i++)
  	for (int j = 1; j <= n; j++)
  		s.pb (a[0][i] + a[1][j]);

  sort (s.begin(), s.end());
  ll ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			ll rem = V - (a[2][i] + a[3][j]);
			ans += upper_bound (s.begin(), s.end(), rem) - lower_bound (s.begin(), s.end(), rem);
		}
	}	
		

	cout << ans; 
	cout << endl;

  return 0;
}










// Coded by Z..



Measured memory_bytes: 11324
((input) => {
    const lines = input.split("\n");

    const A = lines[0].split(" ").map(x => x | 0)[0];
    const cond = lines[1].split("").find((e, idx) => idx === A ? e !== "-": e === "-") === undefined;

    console.log(cond ? "Yes" : "No");
})(require("fs").readFileSync("/dev/stdin", "utf8"));
//})(``);

Measured memory_bytes: 21956
#include<stdio.h>

#define X 100000000

int n;
int A[2000000];
int Count();
void maxHeapify(int i);
void increaseKey(int n, int k);
void insert(int k);
int extractMax();

int main(){
  int i,n;
  char dist[20];
  for (i=1;i<=2000000;i++){
    scanf("%s",dist);
    if(dist[0]=='i'){
      scanf("%d",&n);
      insert(n);
    }
    else if(dist[1]=='x'){
      printf("%d\n",extractMax());
    }
    else if(dist[1]=='n'){
      break;
    }
  }
  return 0;
}

int Count(){
  int i;
  for(i=1;A[i]!=0;i++)
  return i;
}

void maxHeapify(int i){
  int left,right,large,tmp,k;
  left=2*i;
  right=2*i+1;
  if(left<=n&&A[left]>A[i]){
    large=left;
  }
  else large=i;
  if(right<=n&&A[right]>A[large]){
    large=right;
  }
  if(large!=i){
    tmp=A[i];
    A[i]=A[large];
    A[large]=tmp;
    maxHeapify(large);
  }
}

void increaseKey(int n,int k){
  int tmp;
  A[n]=k;
  while(n>1&&A[n/2]<A[n]){
    tmp=A[n];
    A[n]=A[n/2];
    A[n/2]=tmp;
    n/=2;
  }
}

void insert(int k){
  int i;
  n++;
  A[n]=-X;
  increaseKey(n,k);
}

int extractMax(){
  int i,max;
  maxHeapify(1);
  max=A[1];
  A[1]=A[n];
  n--;
  maxHeapify(1);
  return max;
}



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint K, N; cin >> K >> N;
    vec<lint> A_list(N + 1);
    range(i, 0, N) cin >> A_list.at(i);
    A_list.at(N) = A_list.at(0) + K;
    lint ans = 1LL << 59;
    range(i, 0, N) {
        lint diff = A_list.at(i + 1) - A_list.at(i);
        ans = min(ans, K - diff);
    }
    cout << ans << "\n";
}

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


int main() {
    long long a;
    double b;
    cin >> a >> b;
    long long ib = b * 100 + 0.5;
    a *= ib;
    a /= 100;
    printf("%lld\n", a);
}


Measured memory_bytes: 3784
import sys
input = sys.stdin.readline
from collections import deque

INF = float('inf')


if __name__ == '__main__':
    K = int(input())
    q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

    if K < 10:
        print(K)
        exit()

    counter = 0
    while True:
        counter += 1
        x = q.popleft()
        if counter != K:
            if x % 10 == 0:
                q.append(x * 10)
                q.append(x * 10 + 1)
            elif x % 10 == 9:
                q.append(x * 10 + 8)
                q.append(x * 10 + 9)
            else:
                q.append(x * 10 + (x % 10 - 1))
                q.append(x * 10 + (x % 10))
                q.append(x * 10 + (x % 10 + 1))
        else:
            print(x)
            exit()


Measured memory_bytes: 40944
s = input()

alphabets = 'abcdefghijklmnopqrstuvwxyz'
for i in s:
  alphabets = alphabets.replace(i, '')
  s = s.replace(i, '')

alphabets = [i for i in alphabets]
alphabets.sort()
if len(alphabets) > 0:
  print(alphabets[0])
else:
  print('None')

Measured memory_bytes: 9096
n, m, q = map(int, input().split())
d = [[0] * (n + 1) for _ in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    d[a][b] += 1
for i in range(n + 1):
    for j in range(n):
        d[i][j + 1] += d[i][j]
for i in range(n):
    for j in range(n + 1):
        d[i + 1][j] += d[i][j]
for i in range(q):
    a, b = map(int, input().split())
    print(d[n][b] - d[a - 1][b])

Measured memory_bytes: 13268
/*input
100000 50000
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
#define version 20190713
//}}}
const ll maxn=4000005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

inline ll inv(ll n){
	return mypow(n,MOD-2);
}

ll fac[maxn];
ll in[maxn];
inline ll f(ll n,ll m){
	return fac[n+m-1]*in[n]%MOD*in[m-1]%MOD;
}
inline ll C(ll n,ll m){
	return fac[n]*in[m]%MOD*in[n-m]%MOD;
}

int main(){
	IOS;
	ll n,m;
	cin>>n>>m;

	fac[0]=1;
	in[0]=1;
	for(int i=1;i<maxn;i++) fac[i]=fac[i-1]*i%MOD,in[i]=inv(fac[i]);

	ll ans=f(3*m,n);
	ll tmp=0;
	for(ll i=0;i<m;i++){
		tmp+=f(i,n-1);
		tmp%=MOD;
	}
	ans=(ans-n*tmp%MOD+MOD)%MOD;

	for(ll odd=m+1;odd<=3*m;odd++) if(m%2==odd%2) if(n>=odd){
		ans=(ans-C(n,odd)*f((3*m-odd)/2,n)%MOD+MOD)%MOD;
		// cout<<odd<<' '<<C(n,odd)*f((3*m-odd)/2,n)%MOD<<'\n';
	}
	cout<<ans<<'\n';
	return 0;
}


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

using namespace std;

double memo[1<<15][15];
int prev[1<<15][15];
double speed[1<<15];
int dist[15];
int weight[15];
int id[15];
int N;

double solve(int state, int pos) {
    double &res = memo[state][pos];
    if(res >= 0) return res;

    res = 1e30;
    const int prev_state = state & ~(1<<pos);
    for(int i = 0; i < N; ++i) {
        const int mask = 1<<i;
        if(prev_state & mask) {
            const double t = solve(prev_state, i) + abs(dist[pos]-dist[i]) / speed[prev_state];
            //cout << state << ' ' << pos << ' ' << i << ' ' << t << endl;
            if(t < res) {
                res = t;
                prev[state][pos] = i;
            }
        }
    }
    //cout << state << ' ' << pos << ' ' << res << endl;
    return res;
}

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

    cin >> N;
    for(int i = 0; i < N; ++i) {
        cin >> id[i] >> dist[i] >> weight[i];
    }
    const int TERMINAL = (1<<N)-1;
    for(int i = 0; i <= TERMINAL; ++i) {
        for(int j = 0; j < N; ++j) {
            memo[i][j] = (i == (1<<j)) ? 0 : -1;
            prev[i][j] = -1;
        }
    }
    for(int i = 0; i <= TERMINAL; ++i) {
        int sum = 0;
        for(int j = 0; j < N; ++j) {
            if(i & (1<<j)) sum += weight[j];
        }
        speed[i] = 2000.0 / (70+sum*20);
        //cout << speed[i] << endl;
    }
    for(int i = 0; i < N; ++i) {
        solve(TERMINAL, i);
    }
    int cur = 0;
    for(int i = 1; i < N; ++i) {
        if(memo[TERMINAL][i] < memo[TERMINAL][cur]) {
            cur = i;
        }
    }
    int state = TERMINAL;
    vector<int> ans;
    while(cur != -1) {
        ans.push_back(id[cur]);
        int next = prev[state][cur];
        state &= ~(1<<cur);
        cur = next;
    }
    reverse(ans.begin(), ans.end());
    for(int i = 0; i < N; ++i) {
        if(i > 0) cout << ' ';
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

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

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

 int v,w,y,z;
 int ans = 0;

 for (int i = A; i <= B; i++) {

  v =  A / 10000;
  w = (A % 10000)/1000;
  y = (A % 100)/10;
  z =  A % 10;

  if ((v != z) || (w != y)) {
     A++;
   }
  
  else if ((v == z) && (w == y)) {
   ans++;
   A++;
   }

  }

  cout << ans << endl;

return 0;

}


Measured memory_bytes: 384
//Apparat : drobucs, aleonov, vit_72
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <iomanip>
#include <algorithm>
#include <string>
#include <queue>
#include <numeric>

//pragma warning(disable : 4996)
//#pragma GCC optimize("O3")

#define nptr nullptr
#define all(x) (x).begin(), (x).end()
#define drobucs ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define ff first
#define ss second
#define pb push_back

using namespace std;

typedef long long ll;

const int maxn = (int)1e6 + 13;
const ll INFL = 9223372036854775807;
const int INF = 2147483647;
const ll MOD = (int)1e9 + 93, MOD2 = 1e9 + 21;//1e9 + 21, 1e9 + 33, 1e9 + 87, 1e9 + 93
const ll base = 101, base2 = 37;
const long double pi = 3.1415926535897932;



int main() {
	drobucs;
	
	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	if (a >= k) {
		cout << k << "\n";
	}
	else {
		k -= a;
		if (k <= b) {
			cout << a << "\n";
		}
		else {
			k -= b;
			cout << a - k;
		}
	}
	
	return 0;
}

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

int main(void) {
    int N, K;
    cin >> N >> K;
    vector< int > D(N);
    for (int i = 0; i < N; ++i) {
        cin >> D[i];
    }
    int ans = 0;
    for (int l = 0; l <= min(N, K); ++l) {
        for (int r = 0; r <= min(N, K) - l; ++r) {
            vector< int > l_minus;
            int l_score = 0;
            for (int i_l = -1; i_l < l; ++i_l) {
                if (i_l >= 0) {
                    l_score += D[i_l];
                    if (D[i_l] <= 0) {
                        l_minus.push_back(D[i_l]);
                    }
                }
                vector< int > r_minus;
                int r_score = l_score;
                for (auto e : l_minus) {
                    r_minus.push_back(e);
                }
                for (int i_r = -1; i_r < r; ++i_r) {
                    if (i_r >= 0) {
                        r_score += D[N - 1 - i_r];
                        if (D[N - 1 - i_r] <= 0) {
                            r_minus.push_back(D[N - 1 - i_r]);
                        }
                    }
                    sort(r_minus.begin(), r_minus.end());
                    int size = r_minus.size();
                    int tmp  = r_score;
                    for (int i = 0; i < K - l - r; ++i) {
                        if (i >= size) {
                            break;
                        }
                        tmp -= r_minus[i];
                    }
                    ans = max(ans, tmp);
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#define mod 998244353
#define maxn 8200
using namespace std;
typedef long long ll;
int n,m,dp[210][maxn<<1],wn[2][maxn<<1],bh[maxn<<1];
int A[maxn<<1],M,fac[maxn<<1],k,inv[maxn<<1];
int qpow(int a,int b){
    int ans=1;
    for(;b;b>>=1,a=1ll*a*a%mod)
        if(b&1)ans=1ll*ans*a%mod;
    return ans;
}
void init(){
    for(int i=1,p;i<M;i<<=1){
        wn[0][i]=1,p=qpow(3,(mod-1)/(i<<1));
        for(int j=1;j<i;++j)wn[0][i+j]=(ll)wn[0][i+j-1]*p%mod;
        wn[1][i]=1,p=qpow(3,mod-1-(mod-1)/(i<<1));
        for(int j=1;j<i;++j)wn[1][i+j]=(ll)wn[1][i+j-1]*p%mod;
    }
}
void fft(int h[],int len,int flag){
    for(int i=0;i<len;++i)if(i<bh[i])swap(h[i],h[bh[i]]);
    for(int i=1;i<len;i<<=1)
        for(int j=0;j<len;j+=(i<<1))
            for(int k=0;k<i;++k){
                int x=h[j+k],y=(ll)h[j+k+i]*wn[flag][i+k]%mod;
                h[j+k]=(x+y)%mod,h[j+k+i]=(x-y+mod)%mod;
            }
    if(flag==1){
        int iv=qpow(len,mod-2);
        for(int i=0;i<len;++i)h[i]=1ll*h[i]*iv%mod;
    }
}
int C(int x,int y){
    if(x>y||x<0)return 0;
    return (ll)fac[y]*inv[x]%mod*inv[y-x]%mod;
}
int main(){
    scanf("%d%d",&n,&m),M=1,k=0,fac[0]=inv[0]=1;
    while(M<2*n)M<<=1,k++;
    for(int i=1;i<=n+2;++i)fac[i]=1ll*fac[i-1]*i%mod;
    inv[n+2]=qpow(fac[n+2],mod-2);
    for(int i=n+1;i>=1;--i)inv[i]=1ll*inv[i+1]*(i+1)%mod;
    for(int i=0;i<M;++i)bh[i]=(bh[i>>1]>>1)|((i&1)<<(k-1));
    init();
    dp[0][0]=1;
    for(int i=0;i<m;++i){
        for(int j=0;j<=n;++j)
            dp[i+1][j]=(ll)(j*(j+1)/2+1)*dp[i][j]%mod,
            dp[i][j]=(ll)dp[i][j]*inv[j]%mod;
        for(int j=0;j<=M;++j)A[j]=0;
        for(int j=1;j<=n;++j)A[j]=inv[j+2];
        fft(dp[i],M,0),fft(A,M,0);
        for(int j=0;j<M;++j)A[j]=(ll)A[j]*dp[i][j]%mod;
        fft(A,M,1);
        for(int j=1;j<=n;++j)
            dp[i+1][j]=(dp[i+1][j]+(ll)A[j]*fac[j+2])%mod;
    }
    int ans=0;
//  for(int i=0;i<=n;++i)printf("[%d]",dp[m][i]);
    for(int i=0;i<=n;++i)ans=(ans+(ll)C(i,n)*dp[m][i])%mod;
    printf("%d",ans);
} 

Measured memory_bytes: 13440
#include <bits/stdc++.h>
using namespace std;
pair <int, int> p[200100];
int n[200100], d[200100];
int main() {
int N; cin >> N;
for (int i = 0; i < N; i++) cin >> p[i].first >> p[i].second;
sort (p, p + N);
d[N] = 1;
for (int i = N - 1; i >= 0; i--) {
int c = i + 1;
while (c < N && p[c].first < p[i].first + p[i].second) c = n[c];
d[i] = (d[i+1] + d[n[i] = c]) % 998244353;
}
cout << d[0] << "\n";
}

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

def main():
    N = int(input())
    S = "_" + input()

    dp = [[0 for k in range(N+1)] for l in range(N+1)]
    for k in range(1,N):
        for l in range(k+1,N+1):
            if S[k] == S[l]:
                dp[k][l] = dp[k-1][l-1] + 1

    ans = 0
    for k in range(1,N):
        for l in range(k+1,N+1):
            if l-k >= dp[k][l]:
                ans = max(ans,dp[k][l])

    print(ans)

if __name__ == '__main__':
    main()



Measured memory_bytes: 245384
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

int main() {
  string s;
  cin >> s;
  if(s[0] != 'A') {
    printf("WA\n");
    return 0;
  }
  int cnt = 0;
  rep(i,1,s.size()) {
    if(s[i] == 'A') continue;
    if(s[i] == 'C') {
      cnt++;
      if(i < 2 || i + 1 == s.size()) {
        printf("WA\n");
        return 0;
      }
    } else if(s[i] >= 'A' && s[i] <= 'Z') {
      printf("WA\n");
      return 0;
    }
  }
  if(cnt != 1) {
    printf("WA\n");
    return 0;
  }
  printf("AC\n");
  return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<vector<ll>> a(n, vector<ll> (3));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	vector<vector<ll>> dp(n, vector<ll> (3, 0));
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (k == j) {
					continue;
				}
				dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
			}
		}
	}
	cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});

	return 0;
}

Measured memory_bytes: 11264
S=input()
if 'keyence'==S[:7] or 'keyence'==S[-7:]:
    print('YES')
    exit()
if 'k'==S[:1] and 'eyence'==S[-6:]:
    print('YES')
    exit()
if 'ke'==S[:2] and 'yence'==S[-5:]:
    print('YES')
    exit()
if 'key'==S[:3] and 'ence'==S[-4:]:
    print('YES')
    exit()
if 'keye'==S[:4] and 'nce'==S[-3:]:
    print('YES')
    exit()
if 'keyen'==S[:5] and 'ce'==S[-2:]:
    print('YES')
    exit()
if 'keyenc'==S[:6] and 'e'==S[-1:]:
    print('YES')
    exit()
print('NO')

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


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

	ll ans = 0;
	int cnt = 0;
	for(int i=0;i<S.size();i++) {
		if(S[i] == 'B') {
			cnt++;
		}else {
			ans += cnt;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1)
	{
		c-=b;
		if(c<=0)
		{
		    cout<<"Yes";
		    return 0;
	    }
	    a-=d;
	    if(a<=0)
	    {
	    	cout<<"No";
	    	return 0;
		}
	}
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;
 
int main() {
    
    int N;
    int P;
    long long ans = 0;
    
    vector<int> A;
    
    cin >> N;
    cin >> P;
    
    int n_even = 0;
    
    for ( int i = 0; i < N; i++ ) {
        int t;
        cin >> t;
        
        if ( t%2 == 0 ) { n_even++; }
    }
    
    
    long long combination[N+1][N+1];
    
    for ( int i = 0; i <= N; i++ ) {
        for ( int j = 0; j <= i; j++ ) {
            
            if ( i == j || j == 0 ) { combination[i][j] = 1; }
            else {
                combination[i][j] = combination[i-1][j] + combination[i-1][j-1];
            }
        }
    }
    
    
    if ( P ) {
        
        
        for ( int i = 1; i <= N-n_even; i+=2 ) {
            ans += combination[N-n_even][i];
        }
        
        ans *= pow(2,n_even);
        
        
    }
    else {
        
        
        for ( int i = 0; i <= N-n_even; i+=2 ) {
            ans += combination[N-n_even][i];
        }
        
        ans *= pow(2,n_even);
        
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())


def base_10_to_n(X, n):
    if (int(X / n)):
        return base_10_to_n(int(X / n), n) + str(X % n)
    return str(X % n)


ans = base_10_to_n(N, K)
print(len(str(ans)))


Measured memory_bytes: 61816
#!/usr/bin/env python3

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N, K = MII()
    R, S, P = MII()
    T = list(input())

    ans = 0
    for i, t in enumerate(T):
        if i >= K and T[i-K] == t:
            T[i] = 'x'
        elif t == 'r':
            ans += P
        elif t == 's':
            ans += R
        elif t == 'p':
            ans += S
    
    print(ans)
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 4084
#include <stdio.h>

void call(int n)
{
    int i = 1;
    int x;
 
    do {
        x = i;
        if (x % 3 == 0) {
            printf(" %d", i);
        }
        else {
            do {
                if (x % 10 == 3) {
                    printf(" %d", i);
                    x = 0;
                }
                else x /= 10;
            } while (x);
        }
    } while (++i <= n);
    puts("");
}
 

int main(void)
{
	int n;
	scanf("%d", &n);
	call(n);
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  char str[n+1];
  int total=0;
  cin>>str;
  int i=0;
  while(str[i]!='\0')
  {
   int count_=0,j=i;
    char temp=str[i];
    while(str[j]!='\0' && str[j]==str[i]) {count_++; j++;}
    total++;
    i=j;
  }
  cout<<total;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <memory>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
const double pi = 3.141592653589793;




void coch(int d, double p1[2], double p2[2]){
    if (d == 0) return ;
    double s[2], u[2], t[2];
    s[0] = (2*p1[0]+p2[0])/3;
    s[1] = (2*p1[1]+p2[1])/3;
    coch(d-1, p1, s);
    cout << fixed << setprecision(8) << s[0] << " " << s[1] << endl;
    u[0] = s[0]+(s[0]-p1[0])/2-(s[1]-p1[1])*sin(pi/3);
    u[1] = s[1]+(s[0]-p1[0])*sin(pi/3)+(s[1]-p1[1])/2;
    coch(d-1, s, u);
    cout << fixed << setprecision(8) << u[0] << " " << u[1] << endl;
    t[0] = (p1[0]+2*p2[0])/3;
    t[1] = (p1[1]+2*p2[1])/3;
    coch(d-1, u, t);
    cout << fixed << setprecision(8) << t[0] << " " << t[1] << endl;
    coch(d-1, t, p2);
}


int main(){
    int n;
    cin >> n;
    double p1[2], p2[2];
    p1[0] = 0;
    p1[1] = 0;
    p2[0] = 100.0;
    p2[1] = 0;
    cout << fixed << setprecision(8) << p1[0] << " " << p1[1] << endl;
    coch(n, p1, p2);
    cout << fixed << setprecision(8) << p2[0] << " " << p2[1] << endl;
    

    return 0;
}



Measured memory_bytes: 3288
package main

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

const inf = 1 << 60

func main() {
	n := getInt()
	dp := make([]int, n+10)
	for i := range dp {
		dp[i] = inf
	}
	dp[0] = 0

	for i := 0; i < n; i++ {
		dp[i+1] = min(dp[i+1], dp[i]+1)
		for x := 6; x <= n-i; x *= 6 {
			dp[i+x] = min(dp[i+x], dp[i]+1)
		}
		for x := 9; x <= n-i; x *= 9 {
			dp[i+x] = min(dp[i+x], dp[i]+1)
		}
	}

	fmt.Println(dp[n])
}

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

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 1408
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(c<=b&&a<=c){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }

  }
  

  
}


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

typedef long long ll;
typedef long double ld;
typedef string str;

#define f(i, begin, end) for (__typeof(i) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(v) for (auto &x : v)
#define dis(v) trav(v) cout << x << " ";
#define deb(x) cerr << #x << ":" << x << "\n"
#define debv(v) trav(v) cerr << x << " ";
#define all(v) v.begin(), v.end()
#define nl cout << "\n"

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1;
    // cin >> t;
    while (t--)
    {
        ll i, j, k;
        ll n, total = 0;
        char c;
        cin >> c;
        cout << (char)(c + 1) << "\n";
        //vector<ll> v(n);
    }
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	fmt.Println(readInt() * readInt())
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 1752
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int n, m, root;
	scanf("%d%d", &n, &m);
	vector<vector<int>> a(n, vector<int>(0));
	vector<int> b(n, 0), c, par(n, -1);
	for(int i = 0, j, k; i < n - 1 + m; ++i)
	{
		scanf("%d%d", &j, &k);
		a[j - 1].push_back(k - 1);
		++b[k - 1];
	}
	for(int i = 0; i < n; ++i)
	{
		if(!b[i])
		{
			root = i;
			break;
		}
	}
	queue<int> q;
	q.push(root);
	for(int t; !q.empty(); )
	{
		t = q.front();
		q.pop();
		c.push_back(t);
		for(int i = 0; i < a[t].size(); ++i)
		{
			if(--b[a[t][i]] == 0)
			{
				q.push(a[t][i]);
			}
		}
	}
	for(int i : c)
	{
		for(int j = 0; j < a[i].size(); ++j)
		{
			par[a[i][j]] = i;
		}
	}
	for(int i : par)
	{
		printf("%d\n", i + 1);
	}
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll dis=INF;
    ll n;
    cin>>n;
    ll sum=0;
    vl W(n);
    rep(i,n){
        cin>>W[i];
        sum+=W[i];
    }
    ll sum2=0;
    rep(i,n-1){
        sum2+=W[i];
        sum-=W[i];
        chmin(dis,abs(sum-sum2));
    }
    cout<<dis<<endl;
}

Measured memory_bytes: 3668
#include<iostream>
main(){int a,c,i,j,k;for(std::string s,t;std::cin>>s>>t;printf("%d\n",a))for(a=k=0;k++<2;swap(s,t))for(i=s.size();i-->0;)for(j=c=0;j<s.size()-i;)s[j+i]-t[j++]?c=0:a=std::max(a,++c);}

Measured memory_bytes: 940
// In The Name Of Allah
// Mehrkish Makuei
// Islamic Republic Of Iran

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

typedef long long ll;

const int maxx = 1e6 + 19;
int k, n, a, b, c, d, x, y;
string s;

void Input(){
	cin >> s;
}

void Solve(){
	a = s[0] - '0';
	b = s[1] - '0';
	c = s[2] - '0';
	d = s[3] - '0';
	x = (a * 10) + b;
	y = (c * 10) + d;
	if ( x == 0 and y == 0 )
		cout << "NA" << endl;
	if ( x == 0 and y > 12 )
		cout << "NA" << endl;
	if ( y == 0 and x > 12 )
		cout << "NA" << endl;
  	if ( y > 12 and x > 12 )
        cout << "NA" << endl;
	if ( ( x == 0 or x > 12 )and ( y <= 12 and y > 0 ))
		cout << "YYMM" << endl;
	if ( (y == 0 or y > 12 ) and ( x <= 12 and x > 0 ))
		cout << "MMYY" << endl;
	if ( y > 0 and y <= 12 and x > 0 and x <= 12 )
		cout << "AMBIGUOUS" << endl;
}

int main(){
	ios::sync_with_stdio(false),	cin.tie(0),		cout.tie(0);
	Input(),	Solve();
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        a: i64, b: Bytes,
    }

    let mut c = 0;
    for b in b {
        if b == b'.' {
            continue;
        }
        c *= 10;
        c += (b - b'0') as i64;
    }
    println!("{}", a * c / 100);
}


Measured memory_bytes: 2168
using System;

namespace C___Dice_and_Coin
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var n = double.Parse (input[0]);
            var k = int.Parse (input[1]);
            var ans = 0.0;
            for (var i = 1; i <= n; i++)
            {
                var probability = 1 / n;
                var point = i;
                while (point <= k - 1)
                {
                    point *= 2;
                    probability *= 0.5;
                }
                ans += probability;
            }
            Console.WriteLine (ans);
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>

int main(void)
{
	int N, K, i, j;
	int p[1000];
	int tmp, sum;

	scanf("%d %d", &N, &K);

	for (i=0; i<N; i++) {
		scanf("%d", &p[i]);
	}
	for (i=0; i<N; ++i) {
    	for (j=i+1; j<N; ++j) {
      		if (p[i] > p[j]) {
        		tmp =  p[i];
		        p[i] = p[j];
				p[j] = tmp;
      		}
    	}
    }
    sum = 0;
    for (i=0; i<K; i++) {
    	sum += p[i];
    }
    printf("%d\n", sum);
}

Measured memory_bytes: 1728
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
long long data[200000] = {};
vector<int> vertexs[200000];
long long solver(int now){
	if(data[now] <= 9) return data[now];
	long long ans = 0;
	if(data[now] == 10){
		for(int i = 0;i < vertexs[now].size();++i){
			ans += solver(vertexs[now][i]);
		}
	}else if(data[now] == 11){
		ans = 1;
		for(int i = 0;i < vertexs[now].size();++i){
			ans *= solver(vertexs[now][i]);
		}
	}
	return ans;
}
int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0) return 0;
		vector<string> hoget;
		hoget.push_back("+");
		for(int i = 0;i < n;++i){
			string s;
			cin >> s;
			hoget.push_back('.'+s);
		}
		n++;
		stack<pair<int,int>> geko;
		geko.push(make_pair(0,0));
		data[0] = 10;
		for(int i = 1;i < n;++i){
			int nested = hoget[i].length()-1;
			while(geko.empty() == false&&geko.top().second >= nested){
				geko.pop();
			}
			vertexs[geko.top().first].push_back(i);
			geko.push(make_pair(i,nested));
			if(hoget[i][nested] == '+'){
				data[i] = 10;
			}else if(hoget[i][nested] == '*'){
				data[i] = 11;
			}else data[i] = hoget[i][nested] - '0';
		}
		cout << solver(0) << endl;
		for(int i = 0;i < 200000;++i){
			data[i] = 0;
			vertexs[i].clear();
		}
	}
}


Measured memory_bytes: 9428
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int ggcd(int a, int b)
{
	if (b == 0)
	{
		return a;
	}
	return ggcd(b, a%b);
}

int main()
{
	int x, y;
	cin >> x >> y;
	if (x < y)
	{
		swap(x, y);
	}

	int ans = ggcd(x, y);

	cout << ans << endl;


	return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	int A0;
	int A1=101;
	int AA=0;
	for (int i=0; i<N; i++) {
		int A;
		cin >>A;
		AA +=A;
		if (0!=A%10)
			A1=min(A1, A);
	}
	if (0==AA%10) {
		if (101!=A1)
			AA -=A1;
		else
			AA =0;
	}
	cout <<AA <<endl;
	return 0;
}



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

int main() {
  int A,B,C,D,E,F; cin >> A >> B >> C >> D >> E >> F;
  double maxP = -1.0;
  int ans1,ans2;
  for ( int i = 0; i < 31; i++ ) {
    for ( int j = 0; j < 31; j++ ) {
      if ( i == 0 && j == 0 ) continue;      
      for ( int k = 0; k < 101; k++ ) {
	for ( int l = 0; l < 101; l++ ) {
	  int water = 100*A*i + 100*B*j;
	  int sugar = k * C + l * D;
	  int sum = water + sugar;
	  if ( sum > F ) continue;
	  int X = water/100;
	  if ( sugar > E*X  )continue;
	  double p = 100.0*sugar/sum;
	  if (  maxP < p ) {
	    maxP = p;
	    ans1 = sum;
	    ans2 = sugar;
	  }
	}
      }
    }
  }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;
	std::vector<LL>A(N);
	rep(i, N) in >> A[i];

	LL border = -1;
	std::sort(A.begin(), A.end());
	rep(i, N - 1)
	{
		if (A[i] < 0 && A[i + 1] >= 0)
		{
			border = i;
			break;
		}
	}
	if (border == -1)
	{
		if (A[0] >= 0) border = 0;
		else border = N - 2;
	}

	std::vector<std::pair<LL, LL>>xy;
	for (LL i = border + 2; i < N; ++i)
	{
		xy.push_back(std::make_pair(A[border], A[i]));
		A[border] -= A[i];
	}
	rep(i, border + 1)
	{
		xy.push_back(std::make_pair(A[border + 1], A[i]));
		A[border + 1] -= A[i];
	}

	out << A[border + 1] << std::endl;
	rep(i, N - 1) out << xy[i].first << " " << xy[i].second << std::endl;
}


Measured memory_bytes: 4336