akhauriyash/Code-Regression huggingface dataset:
ii = lambda : int(input())
li = lambda : list(map(int,input().split()))

from collections import deque

class tree:
    def __init__(self,n):
        self.n = n
        self.arr = [[] for i in range(self.n)]
        self.root = [-1]*n

    def add_arr(self, u, v):
        if v[0] != 0:
            self.arr[u-1] = v[1:]

n = ii()
t = tree(n)
for i in range(n):
    uk = li()
    t.add_arr(uk[0],uk[1:])
l = deque()
l.append(0)
t.root[0] = 0
while len(l)>0:
    p = l.popleft()
    for i in t.arr[p]:
        if t.root[i-1] == -1:
            t.root[i-1] = t.root[p]+1
            l.append(i-1)

for k,i in enumerate(t.root):
    print(k+1,i)


Measured memory_bytes: 6036
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N, K;
    vector<int> v, sum;
    cin >> N >> K;
    string S;
    cin >> S;
    int cnt = 1;
    if(S[0] == '0') sum.push_back(0);
    for(int i = 1; i < S.size(); i++){
        if(S[i] != S[i-1]){
            v.push_back(cnt);
            sum.push_back(i);
            cnt = 1;
        }else{
            cnt++;
        }
    }
    sum.push_back(N);
    if(S[N-1] == '0') sum.push_back(N);
    
    int ans = 0;
    //if(S[0] == '1'){
    if(true){
        int l = 0, r = 2*K;
        if(r >= sum.size()){
            ans = N;
        }else{
            while(r < sum.size()){
                if(l != 0)ans = max(ans, sum[r]-sum[l-1]);
                if(l == 0)ans = max(ans, sum[r]);
                l+=2;
                r+=2;
               // cout << ans << endl;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1404
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
S = input().rstrip()
T = input().rstrip()

# set:T が set:S に含まれない => S にない文字を T で使っていたら
if not set(T) <= set(S):
    print(-1)
    sys.exit()

ind = -1
cnt = 0
for t in T:
    # 現在の index 以降から探索する
    ind = S.find(t,ind+1)
    # 見つからない場合は先頭から探索し直し, loop countを+1
    if ind == -1:
        cnt += 1
        ind = S.find(t)

print(len(S) * cnt + ind + 1)


Measured memory_bytes: 3444
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;

#define printLn(X) cout << X << endl
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main(){
	int N;
	cin >> N;

	int tNow = 0;
	int xNow = 0;
	int yNow = 0;
	bool ans = true;
	rep(i, N){
		int tNext;
		int xNext;
		int yNext;
		cin >> tNext >> xNext >> yNext;

		int t = tNext - tNow;
		int d = abs(xNext - xNow) + abs(yNext - yNow);
		if(d <= t && (d - t) % 2 == 0){
		}else{
			ans = false;
			break;
		}
		tNow = tNext;
		xNow = xNext;
		yNow = yNext;
	}
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


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

using namespace std;

template<typename T>
void fill_all(T& a, const T& b)
{
	a = b;
}
template<typename T, size_t N, typename U>
void fill_all(T(& a)[N], const U& b)
{
	for (auto& i : a)
	{
		fill_all(i, b);
	}
}

int h[100000];
int main() {
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		cin >> h[i];
	}
	std::sort(h, h + N);

	int ok=1111111111, ng=-1;
	while (ok - ng >= 2)
	{
		auto mid = ok - (ok - ng) / 2;

		bool suc = false;
		for (int i = 0; i < N; i++)
		{
			if (std::upper_bound(h+i, h+N, h[i]+mid)-(h + i)>=K) {
				suc = true;
				break;
			}
		}
		if (suc) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}
	cout << ok << endl;
}

#if 0
int P, R, Q;
int r_num[300];
std::vector<int> resolved[300][101];

int main()
{
	cin >> P >> R >> Q;
	for (int i = 0; i < R; i++)
	{
		cin >> r_num[i];
	}



}
#endif

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

using namespace std;

long long int dfs( long long int store, long long int sum,string s){
    if(s.size() == 1)return 10*store + sum + atoi(s.substr(0,1).c_str());
    return dfs(10*store+atoi(s.substr(0,1).c_str()),sum,s.substr(1)) 
                    + dfs(0,sum+10*store+atoi(s.substr(0,1).c_str()),s.substr(1));
}

int main(){
    string s;
    cin >> s;
    cout << dfs(0,0,s);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <algorithm>
#include <climits>

using namespace std;

int bit_array[15];

int main(){
    int N, K;
    cin >> N >> K;
    int ans = INT_MAX;
    
    for(int i = 1; i <= 10; i++){
        bit_array[i] = 1 << (i - 1);
    }
    
    for(int i = 0; i < (1 << N); i++){
        int sum = 1;
        
        for(int j = 1; j <= N; j++){
            if(i & bit_array[j]){
                sum *= 2;
            }
            else{
                sum += K;
            }
        }
        
        ans = min(ans, sum);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)            \
    cerr << #v << ": ";         \
    REP(__i, (v).size())        \
    cerr << ((v)[__i]) << ", "; \
    cerr << endl

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

int main()
{
    ios::sync_with_stdio(false);
    int M, K;
    cin >> M >> K;
    if (K >= pow(2, M) or (M == 1 and K == 1))
    {
        cout << -1 << endl;
    }
    else if (M == 1 and K == 0)
    {
        cout << "0 0 1 1" << endl;
    }
    else
    {

        cout << K;
        for (int i = 0; i < pow(2, M); ++i)
            if (i != K)
                cout << " " << i;
        cout << " " << K;
        for (int i = pow(2, M) - 1; i >= 0; --i)
            if (i != K)
                cout << " " << i;
        cout << endl;
    }

    return 0;
}


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

struct P
{
    int x,y;

    bool operator<(const P &a)const{

        if(y!=a.y) return y>a.y;
        return x>a.x;
    }

};

vector<int> v;

//bitset<4001000> b;
int i,n,d,m,k,a,b,c;

long long o[5222][4444];
int l[5111];
int j[5111];
int e;

//int dx[10]={2,2,-2,-2,1,1,-1,-1},dy[10]={1,-1,1,-1,2,-2,2,-2};

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000009,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
//stack<int> s;
//set<int> se;
//priority_queue<int> q;
//queue<int> q;
string r,r1;
//char r[1];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
/*
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> safe_map;
*/
//list<int> l;


//deque<int> de;
//srand((int)time(NULL));




bool as(P a,P b)
{
    return a.x<b.x;
}

long long f(int n,int m)
{
    if(m>l[n-1]||((n-1-m)>j[n-1])) return 0;
    if(n>r.size()*2) return 1;
    if(o[n][m]>=0) return o[n][m];
    return o[n][m]=(f(n+1,m)+f(n+1,m+1))%998244353;
}

int main()
{
    memset(o,-1,sizeof(o));
    cin>>r;
    for(int t=0;t<r.size();t++)
    {
        if(r[t]=='0') l[t+1]=l[t],j[t+1]=j[t]+2;
        if(r[t]=='1') l[t+1]=l[t]+1,j[t+1]=j[t]+1;
        if(r[t]=='2') l[t+1]=l[t]+2,j[t+1]=j[t];
    }
    for(int t=r.size();t<r.size()*2;t++)
        l[t+1]=l[t],j[t+1]=j[t];
    printf("%lld",f(1,0));
}


Measured memory_bytes: 181760
#   最初に合計値を計算　つぎにマイナスになるペアを見つけてはその絶対値の二乗を逐一足していく。

N = int(input())
A_lst = input().split()

abs_min = 10**9
count_minus = 0
abs_A_lst = []

for i in range(N):
    A_lst[i] = int(A_lst[i])
    abs_A_lst.append(abs(A_lst[i]))
    if abs_A_lst[-1] < abs_min:
        abs_min = abs_A_lst[-1]
    if A_lst[i] < 0:
        count_minus += 1

output = sum(abs_A_lst)
if count_minus % 2 == 1:
    output -= abs_min*2

print(output)

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



int main (void) {
    int N ;
    scanf ("%d",&N ) ;
    int heig[N] ;
    int cost[N] ;

    for (int i = 0 ; i<N ; i++ ) {
        scanf ("%d", &heig[i]) ;
    }

    int i = 2 ;
    int j = 0 ;
    cost[1] = abs(heig[1]-heig[0]) ;
    cost[0] = 0 ;


    for (;i<N;i++) {
        cost[i] = min(abs(heig[i]-heig[i-1])+cost[i-1],abs(heig[i]-heig[i-2])+ cost[i-2]) ;
    }

    cout << cost[N-1] ;
 }


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

#define MAX_N 20010

int f(int x) {
	return max(0, min(255, x));
}

signed main() {
	static int dp[MAX_N][256] = {};
	for (int N, M; cin >> N >> M&&N;) {
		memset(dp, 0x3f, sizeof(dp));
		dp[0][128] = 0;
		vector<int> C(M); rep(i, 0, M) { cin >> C[i]; }
		rep(i, 0, N) {
			int x; cin >> x;
			rep(j, 0, 256) {
				if (dp[i][j] == INF)continue;
				rep(k, 0, M) {
					int y = f(j + C[k]);
					dp[i + 1][y] = min(dp[i + 1][y], dp[i][j] + (y - x)*(y - x));
				}
			}
		}
		int ans = INF;
		rep(i, 0, 256) {
			ans = min(ans, dp[N][i]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 23064
#include<bits/stdc++.h>
using namespace std;
main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>>C(H,vector<char>(W));
  for(auto&i:C)for(auto&j:i)cin>>j;
  for(int i=1;i<=2*H;++i){
    for(int j=1;j<=W;++j){
      cout<<C[(i+1)/2-1][j-1];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repri(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define repr(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define reprs(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;
typedef vector<int> VI;
typedef vector<ll> VL;

auto mgcd=[](ll p, ll q) {return __gcd(p,q);};
auto mlcm=[](ll p, ll q) {return p*q/__gcd(p,q);};

int N, X;

void Main() {
	cin >> N >> X;
	int t;
	cin >> t;
	int ans = abs(t-X);
	rep(i,1,N) {
		cin >> t;
		ans = mgcd(ans, abs(t-X));
	}

	cout << ans << LF;

	return;
}

int main(){
	FAST;
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

void solve(long long N, std::vector<long long> W){
    vector<ll> cumw(N, W[0]);
    for(int i = 1; i < N; ++i) cumw[i] = cumw[i-1] + W[i];
    ll ans = INF;
    for(int i = 0; i < N; ++i){
        ans = min(ans, abs(cumw[i] - (cumw[N-1] - cumw[i])));
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> W(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&W[i]);
    }
    solve(N, std::move(W));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;
int n, m;
bool burik=1;
unordered_map<int, int>arr;

int main(){
	IOS
	cin >> n >> m;
	int s[m+5], c[m+5];
	for(int i=1;i<=m;i++){
		cin >> s[i] >> c[i];
		if(s[i]==1){
			burik=0;
		}
		if(arr[s[i]]!=0&&arr[s[i]]!=c[i]){
			cout << -1 << '\n'; return 0;
		}
		arr[s[i]]=c[i];
	}
	if(burik&&n>1){
		arr[1]=1;
	}
	if(arr[1]==0&&n>=2){
		cout << -1 << '\n'; return 0;
	}
	for(int i=1;i<=n;i++){
		cout << arr[i];
	}
	cout << endl;
}

Measured memory_bytes: 3640
#include <sstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <queue>
#include <bitset>
using namespace std;

#define int long long
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define REP(i, a) for (int i = 0, _a = (a); i < _a; ++i)
#define REPD(i,n) for(int i = (n)-1; i >= 0; --i)

#define DEBUG(X) { cerr << #X << " = " << (X) << endl; }
#define PR(A, n) { cerr << #A << " = "; FOR(_, 1, n) cerr << A[_] << ' '; cerr << endl; }
#define PR0(A, n) { cerr << #A << " = "; REP(_, n) cerr << A[_] << ' '; cerr << endl; }

#define sqr(x) ((x) * (x))
#define ll long long
#define double long double
typedef pair<int, int> II;
#define PI (2 * acos((double)0))
#define __builtin_popcount __builtin_popcountll
#define SZ(x) ((int)(x).size())
#define ALL(a) (a).begin(), (a).end()
#define MS(a,x) memset(a, x, sizeof(a))
#define next ackjalscjaowjico
#define prev ajcsoua0wucckjsl
#define y1 alkscj9u20cjeijc
#define y0 u9cqu3jioajc

double safe_sqrt(double x) { return sqrt(max((double)0.0, x)); }
int GI(int& x) { return scanf("%lld", &x); }

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << (fixed) << setprecision(9);
    int n;
    while (GI(n) == 1) {
        int cnt = 0;
        FOR(i,1,n) {
            int a; GI(a);
            if (a % 2) ++cnt;
        }
        if (cnt % 2 == 1) puts("NO");
        else puts("YES");
    }
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int N, M, C;
  cin >> N >> M >> C;
  vi b;
  REP(i, M) b.PB(read());
  int sum, ans = 0;
  REP(i, N) {
    sum = 0;
    REP(j, M) sum += b[j] * read();
    sum += C;
    if (sum > 0) ans++;
  }
  print(ans);
}


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

const int N = 2e5+1;
int a[N], b[N], c[N] = {0};

int bs(int l, int r){
	int x = 1, a = r;
	while(x <= b[r])
		x<<= 1;
	x = x-b[r];
	if(c[r] == 0)
		r--;
	else if(c[r] < 0)
		return 0;
	while(l <= r){
		int m = (l+r)/2;
		if(b[m] == x){
			c[a]--;
			if(c[m] >= 0){
				c[m]--;
				return 1;
			}else return 0;
		}else if(b[m] > x){
			r = m-1;
		}else l = m+1;
	}
	c[a]--;
	return 0;
}



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

	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a+n);
	int r = 0;
	b[0] = a[0];
	for(int i = 1; i < n; i++){
		if(a[i] == a[i-1])
			c[r]++;
		else b[++r] = a[i];
	}
	int ans = 0;
	for(int i = r; i >= 0; i--){
		ans += bs(0, i);
		if(c[i] >= 0)
			i++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: u64,
        a: [u64;5]
    }
    let m = a.into_iter().min().unwrap();
    println!("{}", (n + m-1) / m + 4);
}


Measured memory_bytes: 4352
A=["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"]
Num=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]

s=list(input())
K=int(input())

S=[]
for i in range(len(s)):
    for j in range(26):
        if s[i]==A[j]:
            S.append(Num[j])

for a in range(len(S)-1):
    if (26-S[a])%26<=K:
        K-=(26-S[a])%26
        S[a]=(S[a]+(26-S[a]))%26

S[len(S)-1]=(S[len(S)-1]+K)%26
#print(S)

for x in range(len(S)):
    for y in range(26):
        if S[x]==Num[y]:
            S[x]=A[y]
print("".join(S))
    

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

using namespace std;

int n, a, b;

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

	cin >> n >> a >> b;
	
	if (abs(b-a)%2 == 0) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Borys" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/ruby
a=[1,4,12,38]
n,m=gets.split.map(&:to_i)
if m==1
	1.step(100){|i|a[i]=2*a[i-1]}
else
	4.step(100){|i|a[i]=4*a[i-1]-3*a[i-2]+2*a[i-3]+a[i-4]}
end
p a[n]%1000000

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

int main()
{
	int n, m;
	cin >> n >> m;
	
	int num[n];
	
	for (int i = 0; i < n; i++)
	{
		cin >> num[i];	
	}
	
	sort(num, num+n);
	
	int d = log2(num[n-1]);
	//cout << d << "\n";
	
	for (int i = d; i >= -1; i--)
	{
		/*for (int j = 0; j < n; j++)
		{
			cout << num[j] << ' ';
		}*/
		for (int j = n-1; j >= 0; j--)
		{
			if (m == 0) break;
			if (num[j] > pow(2, i)) {
				//cout << j << "\n";
				num[j]/=2;
				m--;
			}
			//cout << m << "\n";
		}
		if (m==0) break;
		sort(num, num+n);
	}
	
	long long sum = 0;
	for (int i = 0; i < n; i++) sum+=num[i];
	
	cout << sum << "\n";
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	int a,b;
	bool s = true;
	while(1){
		cin >> a >> b;
		if(a*b==0) break;
		if(s) s = false;
		else cout << endl;
		bool n = true;
		for(int i=a;i<=b;i++){
			bool c = false;
			if(i%400==0) c = true;
			else if(i%100==0);
			else if(i%4==0) c = true;
			if(c) cout << i << endl;
			if(c) n = false;
		}
		if(n) cout << "NA" << endl;
	}
}

Measured memory_bytes: 1160
// atcoder/abc161/F/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  lli n;
  while (cin >> n) {
    set<lli> vis;
    for (lli i = 2; i * i <= n; ++i) {
      if ((n - 1) % i == 0) {
        vis.insert(i);
        vis.insert((n - 1) / i);
      }
    }

    for (lli i = 2; i * i <= n; ++i) {
      if (n % i == 0) {
        lli j = n / i;

        lli x = n; while (x % i == 0) x /= i;
        lli y = n; while (y % j == 0) y /= j;

        if (x % i == 1) vis.insert(i);
        if (y % j == 1) vis.insert(j);
      }
    }

    vis.insert(n);
    vis.insert(n - 1);
    vis.erase(1);
    // cout << "? " << vis << ", " << vis.size() << endl;

    cout << vis.size() << endl;

    // for (lli k = 2; k <= n; ++k) {
    //   lli x = n;
    //   while (k <= x) {
    //     if (x % k == 0) x /= k;
    //     else x -= k;
    //   }
    //   if (x == 1) cout << k << ", "<< vis.count(k) << endl;
    // }
    // cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define Would
#define you
#define please

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

	int N, A;
	cin >> N >> A;

	if (N % 500 <= A) co("Yes");
	else co("No");

	Would you please return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
"""考察
R R R L という例を考える

・i=0の人は最終的にどこにいるのか？
## 初期状態
i: 0 1 2 3
-----------
S: R R R L
   .

## 3回の操作のあと
i: 0 1 2 3
-----------
S: R R R L
         .

## 4回の操作のあと
i: 0 1 2 3
-----------
S: R R R L
       .

という風に、あとは奇数回の操作後はi=3のLに、偶数回の操作後はi=2のRにいることになる


・i=1の人は最終的にどこにいるのか？
## 初期状態
i: 0 1 2 3
-----------
S: R R R L
     .

## 2回の操作のあと
i: 0 1 2 3
-----------
S: R R R L
         .

## 3回の操作のあと
i: 0 1 2 3
-----------
S: R R R L
       .

という風に、あとは偶数回の操作の後はi=3のLに、奇数回の操作の後はi=2のRにいることになる。

以上の考察から、初期位置から移動を始めたあと、反対側に移動することになるまでの距離によって、偶数回後と奇数回後で位置が収束されることがわかる。

そして操作は10^100回行われるので、偶数回のみ考えれば良い。

ここで初期位置をstart, 反対側に移動することになるマスをendとする。

初期位置がstart=0の人の例で言うと、反対側に移動することになるend=3までの距離abc(start-end)=3が奇数の場合、この人は最終的にend-1(=2)にいることになる。

初期位置がstart=1の人の例で言うと、反対側に移動することになるend=3までの距離abc(start-end)=2が偶数の場合、この人は最終的にend(=3)にいることになる。

ということが言えそうである。

なのでシミュレーションしてやればよい。このシミュレーションはO(N)でできそうである
"""
def solve():
    S = input()
    N = len(S)

    ans = [0]*N  # 最終的に出力する答え（10**100操作後に、人がいる人数）
    # Rグループについて考える
    cnt = 0  # 現在のRグループの人数
    for i, moji in enumerate(S):
        if moji == "R":
            cnt += 1
            continue
        else:
            even_num = cnt//2  # 距離が偶数の人の数
            ans[i] += even_num # 距離が偶数の人は、ans[i]に収束する
            odd_num = cnt - even_num  # 距離が奇数の人の数
            ans[i-1] += odd_num       # 距離が奇数の人は、ans[i-1]に収束する
            cnt = 0

    # Lグループについて考える
    cnt = 0  # Lグループの人数
    for i in range(N-1, -1, -1):
        if S[i] == "L":
            cnt += 1
            continue
        else:
            even_num = cnt//2
            ans[i] += even_num
            odd_num = cnt - even_num
            ans[i+1] += odd_num
            cnt = 0

    print(*ans)


if __name__ == "__main__":
    solve()


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


int main(){
  int a,b,c;cin>>a>>b>>c;
  int tmp = a - (b + c);
  if (tmp < 0)
  {
    cout << abs(tmp) << endl;
  }
  else
  {
    cout << 0 << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main() {
    rep(i,5){
        int x;
        cin >> x;
        if (x==0) {
            cout << i+1 << endl;
            return 0;
        }
    } 
}

Measured memory_bytes: 3164
import java.util.*;
import static java.lang.Math.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        char s[] = new char[n];
        boolean flag = true;
        s = sc.next().toCharArray();
        if(c<d){
            for(int i = a; i<max(c,d); i++){
                if(s[i]=='#' && s[i+1]=='#'){
                    flag = false;
                }
            }
            if(flag){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
            return;
        }else{
            flag = false;
            for(int i = b-2; i< d-1; i++){
                if(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.'){
                    flag = true;
                }
            }
            for(int i = a; i<= n-1; i++){
                if(s[i]=='#' && s[i+1]=='#'){
                    flag = false;
                }
            }
            
            if(flag){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }  
    }
}


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

int main()
{
    int k;
    string s;
    cin>>k;
    cin>>s;
    if(s.size()<=k)
        cout<<s<<endl;
    else
        cout<<s.substr(0,k)<<"..."<<endl;
    return 0;
}


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

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  vector<int> hs(h), ws(w);
  set<P> s;
  rep(i,n) {
    int r, c;
    cin >> r >> c;
    --r; --c;
    hs[r]++;
    ws[c]++;
    s.emplace(r,c);
  }
  int mh = 0, mw = 0;
  rep(i,h) mh = max(mh, hs[i]);
  rep(j,w) mw = max(mw, ws[j]);
  vector<int> is, js;
  rep(i,h) if (mh == hs[i]) is.push_back(i);
  rep(j,w) if (mw == ws[j]) js.push_back(j);
  int ans = mh+mw;
  for (int i : is) for (int j : js) {
    if (s.count(P(i,j))) continue;
    cout << ans << endl;
    return 0;
  }
  --ans;
  cout << ans << endl;
  return 0;
}


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

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A,B,C,D,H,K,L,M,N,T,W,X;
  string S;
  cin >> N;
  A=0;
  for (int i=1;i<N+1;i++) {
    if (i%3>0 && i%5>0) {A+=i;}
  }
  cout << A << endl;
  
}

Measured memory_bytes: 3620
#include <iostream>
#include <numeric>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	int N, M;
	cin >> N >> M;
	priority_queue<int> vec;
	int q;
	for (int i = 0; i < N; i++) {

		cin >> q;
		vec.push(q);
	}

	rep(i, M) {
		q = vec.top();
		vec.pop();
		vec.push(q / 2);

	}
	long long sum = 0;
	rep(i, N) {
		sum += vec.top();
		vec.pop();
	}
	cout << sum << endl;
}



Measured memory_bytes: 892
N = int(input())

if 100 <= N and N <=999:
  N11 = str(N)
  N1 = int(N11[0])
  N2 = int(N11[1])
  N3 = int(N11[2])
  if N1 == 7 or N2 == 7 or N3 == 7:
    print('Yes')
  else:
    print('No')
  
  

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

import sys
import math
import itertools

def main():
    n = int(sys.stdin.readline())
    xs = map(int, sys.stdin.readline().split())

    for x in xs:
        if x % 2 == 0 and (x % 3 != 0 and x % 5 != 0):
            print('DENIED')
            return
    print('APPROVED')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
n, w = map(int, input().split())
item = [list(map(int, input().split())) for _ in range(n)]
dp = [[0 for _ in range(w+1)] for __ in range(n+1)]
for i in range(1,n+1):
    for j in range(w+1):
        if item[i-1][0] > j:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-item[i-1][0]]+ item[i-1][1])
print(dp[n][w])



Measured memory_bytes: 171656
#include <stdio.h>

int main(void)
{

	int n;
	int t[100];
	int m;
	int p[100];
	int x[100];

	scanf("%d", &n);

	for (int i = 0; i < n; i++){
		scanf("%d", &t[i]);
	}

	scanf("%d", &m);

	for (int i = 0; i < m; i++){
		scanf("%d %d", &p[i], &x[i]);
	}

	for (int i = 0; i < m; i++){
		int sum = 0;
		for (int k = 0; k < n; k++){
			if (p[i] - 1 == k ){
				sum += x[i];
			}
			else{
				sum += t[k];
			}
		}
		printf("%d\n",sum);
		sum = 0;

	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
int n, k, loc, ans;

int main(void)
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n>>k; int i, x;
	cout<<(n-1+k-2)/(k-1);
}

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

int main(){
	int s=0,m=0,h=0;
	cin>>s;
	h=s/3600;
	s-=h*3600;
	m=s/60;
	s-=m*60;
	cout<<h<<':'<<m<<':'<<s<<'\n';
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    int n;
    cin >> n;
    vs s(n);
    rep(i, n) cin >> s[i];

    vvi cnt(n, vi(26));
    rep(i, n) {
        rep(j, s[i].size()) {
            int c = s[i][j] - 'a';
            cnt[i][c]++;
        }
    }

    string ans = "";
    rep(i, 26) {
        int t = 114514;
        rep(j, n) {
            t = min(t, cnt[j][i]);
        }
        if(t == 0) continue;
        rep(k, t) {
            ans += char(i + 'a');
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    all_remark = []
    for i in inputs:
        all_remark.append(list(map(string_to_int, i)))
    n = len(all_remark)
    max_pattern = 2**n

    max_shojiki = 0
    for p in range(max_pattern):
        bits = list(bin(p)[2:])
        bits = ['0' for i in range(n-len(bits))] + bits
        shojiki = 0
        for b in bits:
            if b == '1':
                shojiki += 1

        for i, remarks in enumerate(all_remark):
            is_possible = True
            if bits[i] == '1':
                for r in remarks:
                    target = r[0]
                    w = r[1]
                    if bits[target - 1] != str(w):
                        is_possible = False
                        break
                if is_possible is False:
                    break
        if is_possible and max_shojiki < shojiki:
            max_shojiki = shojiki
    return max_shojiki


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    N = int(input())
    arg = []
    for i in range(N):
        A = int(input())
        arg.append(inputs(A))
    ret = solve(arg)
    print(ret)


Measured memory_bytes: 48860
#include <iostream>
#include <bitset>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <queue>
#include <string.h> 
using namespace std;
const int N = 1000+5;
int a[N];
int main() 
{
    int m,n,b,c;
    cin>>m>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>b>>c;
		a[b]++;
		a[c]++;
	} 
	for(int i=1;i<=m;i++)
	{
		cout<<a[i]<<endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 605

int N,M;
double dp[SIZE],dp2[SIZE];
vector<int> G[SIZE];

int main(){

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

	int from,to;

	for(int i = 0; i < M; i++){

		scanf("%d %d",&from,&to);
		from--;
		to--;
		G[from].push_back(to);
	}

	dp[N-1] = 0;

	for(int i = N-2; i >= 0; i--){
		double tmp = 0;
		for(int k = 0; k < G[i].size(); k++){

			tmp += dp[G[i][k]];
		}
		tmp /= (double)G[i].size();
		tmp += 1;

		dp[i] = tmp;
	}

	double ans = dp[0];

	for(int i = 0; i <= N-2; i++){
		if(G[i].size() == 1)continue;

		from = i;
		double maximum = -1.0;

		for(int k = 0; k < G[i].size(); k++){

			if(maximum < dp[G[i][k]]){
				maximum = dp[G[i][k]];
				to = G[i][k];
			}
		}

		dp2[N-1] = 0;
		for(int k = N-2; k >= 0; k--){

			double tmp = 0;

			for(int a = 0; a < G[k].size(); a++){
				if(k == from && to == G[k][a])continue;

				tmp += dp2[G[k][a]];
			}

			if(k == from){

				tmp /= (double)(G[k].size()-1);

			}else{

				tmp /= (double)G[k].size();
			}
			tmp += 1.0;

			dp2[k] = tmp;
		}
		ans = min(ans,dp2[0]);
	}

	printf("%.10lf\n",ans);

	return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>a>>b>>x;
      if(a+b<x)Cout("NO");
      else{
        if(a>x)Cout("NO");
        else Cout("YES");
      }
     

       
return 0;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <queue>
#include <set>
using namespace std;

struct shops
{
    int num;
    string name;
    int score;
};

bool cmp(const shops &a, const shops &b)
{
    if (a.name == b.name)
    {
        /* code */
        return a.score > b.score; 
    }else{
        return a.name < b.name;
    }
}


int main(){
    // std::cout << "a" < "b" << "\n";
    int N;
    std::cin >> N;
    std::vector<shops> shop_list(N);
    for (int i = 0; i < N; ++i)
    {
        shop_list[i].num = i + 1;
        std::cin >> shop_list[i].name >> shop_list[i].score;
    }
    sort(shop_list.begin(), shop_list.end(), cmp);
    for (int i = 0; i < N; ++i)
    {
        std::cout << shop_list[i].num << "\n";
    }
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

const string abcus[10] = {"* = ****","* =* ***","* =** **","* =*** *","* =**** "," *= ****"," *=* ***"," *=** **"," *=*** *"," *=**** "};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  bool f = false;
  while(cin >> s){
    if(f) cout << endl;
    while(s.size()<5){
      s = "0" + s;
    }
    rep(i,8){
      rep(j,5){
        cout << abcus[s[j]-'0'][i] ;
      }
      cout << endl;
    }
    f = true;
  }
  return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int cnt =0;
    cin>>n;
    int ara[n*2];
    for(int i=0; i<n*2; i++){
        cin>>ara[i];
    }
    sort(ara, ara+(2*n));
    for(int i=0; i<2*n; i+=2){
        cnt+=ara[i];
    }
    cout<<cnt<<endl;
    return 0;
}


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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 16050, M = 8001;

int n, x, y;
char s[M];
set<int> fx[2], fy[2];
vector<int> X, Y;

int main()
{
	scanf("%s%d%d", s, &x, &y);
	n = strlen(s);
	
	for (int i = 0, t = 0; i < n; i ++ , t ^= 1)
	{
		int j = i;
		while (j < n && s[j] != 'T') j ++ ;
		
		if (!t) X.push_back(j - i);
		else Y.push_back(j - i);
		i = j;
	}
	
	int tx = 0;
	if (X.size()) fx[tx].insert(X[0] + M);
	else fx[tx].insert(M);
	for (int i = 1; i < X.size(); i ++ )
	{
		tx ^= 1, fx[tx].clear();
		for (auto u : fx[tx ^ 1])
		{
			fx[tx].insert(u + X[i]);
			fx[tx].insert(u - X[i]);
		}
	}
	
	int ty = 0;
	fy[ty].insert(M);
	for (int i = 0; i < Y.size(); i ++ )
	{
		ty ^= 1, fy[ty].clear();
		for (auto u : fy[ty ^ 1])
		{
			fy[ty].insert(u + Y[i]);
			fy[ty].insert(u - Y[i]);
		}
	}
	
	if (fx[tx].count(x + M) && fy[ty].count(y + M)) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
using namespace std;
typedef long long int lli;
int main(void)
{
    map<int, int> x;
    int N;
    cin >> N;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        x[tmp]++;
    }
    int ans = 0;
    for (map<int, int>::iterator i = x.begin(); i != x.end(); ++i)
    {
        if (i->second % 2 == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8208
_, choice_count = gets.chomp.split.map(&:to_i)
dices = gets.chomp.split.map(&:to_i)

probabilities = []

c_sum = [0]

dices.each.with_index do |dice,i|
  probabilities << (1 + dice.to_f)/2
  c_sum[i+1] = c_sum[i] + probabilities[i]
  
end

v_sum = 0

0.upto(dices.length - choice_count) do |i|
  sum = c_sum[i + choice_count] - c_sum[i]
  v_sum = sum if sum > v_sum
end

p v_sum.to_f


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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll> v(N);
  for(ll i = 0LL; i < N; i++) cin>>v[i];
  sort(v.begin(),v.end());
  unordered_map<ll,ll> m;
  ll t = 0LL;
  ll ans=N;
  for(ll i = N-1LL; i >= 0LL; i--){
    if(v[i]>=K) {
      ans=i;
      continue;
    }
    for(auto x:m) chmax(t,x.first);
    if(t+v[i]>=K) ans=i;
    vector<ll> n;
    for(auto x:m){
      if(x.first+v[i]<K) n.push_back(x.first+v[i]);
    }
    for(auto x:n) m[x]=1;
    m[v[i]]=1;
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;

/* */

int main(){

    // 入力スタンダード（複数指定）
    int n;
    cin >> n;
    
    int joushi;
    int a[n+1] = {0};
    for(int i=2; i<n+1; i++) {
        cin >> joushi;
        a[joushi]++;
    }
    // **************************************

    
    for(int i=1; i<n; i++){
        cout << a[i] <<endl;
    }
    cout << 0 << endl;



    return 0;
}

Measured memory_bytes: 4428
#include <stdio.h>
long long n, q;
long long a[100000];
long long x[100000];
long long r[100000];
long long r0[100000];
long long xd, xu, xm;
long long yd, yu, ym;
long long z;
long long wd, wu;
int k;
int main() {
	scanf("%lld%lld", &n, &q);
	for (int i = 0; i < n; i++)scanf("%lld", a + i);
	for (int i = 0; i < q; i++)scanf("%lld", x + i);
	r[0] = a[0]; r[1] = a[0] + a[1];
	r0[0] = a[0]; r0[1] = a[1];
	for (int i = 2; i < n; i++) {
		r[i] = r[i - 1] + a[i];
		if (i % 2)r0[i] = r0[i - 2] + a[i];
		else r0[i] = r0[i - 2] + a[i];
	}
	for (int i = 0; i < q; i++) {
		xd = 0; xu = a[n - 1];
		while (xu - xd > 1) {
			xm = (xd + xu) / 2;
			z = xm + x[i];
			yd = 0; yu = n - 1;
			while (yu - yd > 1) {
				ym = (yd + yu) / 2;
				if (a[ym] < z)yd = ym;
				else yu = ym;
			}
			if (a[n - 1] <= z)yd = n - 1;
			wu = yd;
			z = x[i] - xm;
			yd = 0; yu = n - 1;
			while (yu - yd > 1) {
				ym = (yd + yu) / 2;
				if (a[ym] >= z)yu = ym;
				else yd = ym;
			}
			if (a[0] >= z)yu = 0;
			wd = yu;
			if (2 * wu - wd + 1 > n - 1)xu = xm;
			if (2 * wu - wd + 1 < n - 2) {
				if (wu < n&&a[wu + 1] == x[i] + xm)wu++;
			}
			if (2 * wu - wd + 1 < n - 2)xd = xm;
			if (2 * wu - wd + 1 == n - 1) {
				k = 0;
				break;
			}
			if (2 * wu - wd + 1 == n - 2) {
				k = 1;
				break;
			}
		}
		if (2 * wu - wd + 1 >= n)printf("%lld\n", r0[n - 1]);
		else {
			if (k)printf("%lld\n", r[n - 1] - r[wu] + r0[wd - 2]);
			else printf("%lld\n", r[n - 1] - r[wu] + r0[wd - 1]);
		}
	}
	return 0;
}

Measured memory_bytes: 4864