akhauriyash/Code-Regression huggingface dataset:
import Control.Applicative 
import Data.Char

getMax :: String -> Int
getMax (a:rest) =
    let figure = (length (a:rest)) - 1 
        top = (digitToInt $ a)
        ismax = all (\a -> a == '9') rest
        in if ismax then (figure * 9 + top) else (figure * 9 + (top - 1))
        

main = print =<< getMax <$> getLine


Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="a"||s=="e"||s=="i"||s=="o"||s=="u")
    {
        cout<<"vowel"<<endl;
    }
    else
    {
        cout<<"consonant"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
    int i,j,ch[1000000],max,max2;

    max=1000000;
    max2=sqrt(max);

    for(i=0;i<max;i+=2){ch[i]=0;ch[i+1]=1;}

    ch[1]=0;
    ch[2]=1;

    for(i=3;i<max2;i+=2) if(ch[i]) for(j=i+i;j<max;j+=i) ch[j]=0;

    for(i=3;i<max;i++) ch[i]+=ch[i-1];

    while(scanf("%d",&i)!=EOF) printf("%d\n",ch[i]);

    return 0;
}

Measured memory_bytes: 4500
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.IntMap as IM

type Map = IM.IntMap Int

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

solve :: Int -> Int -> Map -> [Int]
solve (-1) _ _ = []
solve n k m = min r1 r2 : solve (n - 1) k m
  where l = fromJust $ IM.lookup n m
        r = fromJust $ IM.lookup (n + k - 1) m
        r1 = abs l + abs (r - l)
        r2 = abs r + abs (r - l)

main :: IO ()
main = do
  [n, k] <- readIntsLine
  xs <- zip [0..] <$> readIntsLine
  print . minimum . solve (n - k) k $ IM.fromList xs

Measured memory_bytes: 18812
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll n;
    cin >> n;
    vector<ll> a(5);
    for (int i = 0; i < 5; i++) cin >> a[i];
    ll low = *min_element(a.begin(), a.end());
    ll neck = ceil((long double) n / (long double) low);
    ll ans = 4 + neck;
    cout << ans << '\n';
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <iomanip>
#include <cstdlib>
#include <climits>
#include <set>
using namespace std;

//関数getinputdata宣言
vector<vector<string>> getinputdata();
vector<vector<int>> getinputdata2();
vector<vector<double>> getinputdata3();

void abc131_b(vector<vector<int>> v) {

    int n = v[0][0];
    int l = v[0][1];
    vector<int>vec;

    for (int i = 1; i <= n; i++) {
        vec.push_back(i + l - 1);
    }

    int mindata = INT_MAX;
    int val = INT_MAX;
    
    int mysum = 0;
    for (int x : vec) {
        
        if(mindata>=abs(x)){
            mindata = min(mindata, abs(x));
            val=x;
        }
        mysum += x;
    }

    cout << mysum-val<< endl;


}

int main() {

    //        vector<vector <string>> vec_arr_result;
    vector<vector<int>> vec_arr_result;
    vec_arr_result = getinputdata2();

    abc131_b(vec_arr_result);

    return 0;
}

//関数getinputdata実装

vector<vector<double>> getinputdata3() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<double>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<double> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atof(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;
}

//関数getinputdata実装

vector<vector<int>> getinputdata2() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<int>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<int> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atoi(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;


}

//関数getinputdata実装

vector<vector < string >> getinputdata() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector < string>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<string> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(ret);
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int x,y,z,A[1200],B[1200],C[1200],num,i,sum[1200];
	
	scanf("%d",&num);
	
	for(i=0;i<num;i++){
		scanf("%d %d %d",&x,&y,&z);
	A[i]=x*x;
	B[i]=y*y;
	C[i]=z*z;
	}
	
	
	for(i=0;i<num;i++){
		if((C[i]==B[i]+A[i])||(A[i]==B[i]+C[i])||(B[i]==A[i]+C[i])){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 592
sx,sy,tx,ty = map(int,input().split())

ans = 'U'*(ty-sy) + 'R'*(tx-sx) + 'D'*(ty-sy) + 'L'*(tx-sx) #1週目
ans = ans + 'L' + 'U'*(ty-sy+1) + 'R'*(tx-sx+1) + 'D'
ans = ans + 'R' + 'D'*(ty-sy+1) + 'L'*(tx-sx+1) + 'U'
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define rem 1000000007

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
#define v(x) vector<x>
#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define mii map<ll,ll>
#define umii unordered_map<ll,ll>
#define mxheap priority_queue<ll> // Max Heap
#define mnheap priority_queue<ll,vi,greater<ll> > // Min Heap
#define da(type,arr,size) type *arr = new type[n] // Dynamically allocated array


#define f(i,n) for(ll i=0;i<(n);i++)
#define fa(i,a,b) for(ll i=(a);i<(b);i++)
#define far(i,a,b) for(ll i=(a);i>(b);i--)
#define T ll t; cin>>t; while(t--)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define sz size()

#define setbits(x) __builtin_popcountll(x) // Total set bits in a number
#define zerobits(x) __builtin_ctzll(x) // This will tell me number of zeroes till first set bit
#define all(c) (c).begin(),(c).end()
#define setp(x,y) fixed<<setprecision(y)<<x
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define INF 2e18


ll mod(ll n) {
	return n > 0 ? n : -1 * n;
}
ld dist(ll x1, ll y1, ll x2, ll y2) {
	ld ans = round(pow(mod(x2 - x1), 2)) + round(pow(mod(y2 - y1), 2));
	ans = sqrt(ans);
	return ans;
}

ld dist(pii a, pii b) {
	ld ans = round(pow(mod(b.ff - a.ff), 2)) + round(pow(mod(b.ss - a.ss), 2));
	ans = sqrt(ans);
	return ans;
}
umii isPrime;
void SieveOfEratosthenes(ll n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));

	for (int p = 2; p * p <= n; p++)
	{
		if (prime[p] == true)
		{
			for (ll i = p * p; i <= n; i += p)
				prime[i] = false;
		}
	}
	for (ll p = 2; p <= n; p++)
		if (prime[p])
			isPrime[p] = 1;
}
int *dp;
ll maxCompositeSummands(ll n) {
	if (n == 2 || n == 1 || n == 3) {
		return INT_MIN;
	}
	if (dp[n] != -1) {
		return dp[n];
	}
	ll mexx = INT_MIN;
	for (ll i = 4; i <= n; i++) {
		if (!isPrime[i]) {
			mexx = max(mexx, maxCompositeSummands(n - i));
		}
	}
	return dp[n] = mexx == INT_MIN ? mexx : mexx + 1;
}
int main() {
	fast
	ll n, m;
	cin >> n >> m;
	ll sum = 0;
	for (ll i = 0; i < m; i++) {
		ll temp;
		cin >> temp;
		sum += temp;
	}
	ll ans = n - sum;
	ans < 0 ? cout << -1 << endl : cout << ans << endl;

}


Measured memory_bytes: 3676
n = int(input())
a = sorted(list(map(int,input().split())),reverse= True)
s = a[0]
if len(set(a)) == 1:
    print((n-1)*s)
else:
    l = (n-2)//2
    for i in range(1,l+1):
        s += a[i]*2
    print(s+a[n//2] if n%2 else s) 

Measured memory_bytes: 32892
#include<bits/stdc++.h>
#define up(j,k,i) for(i=j;i<k;i++)
#define down(j,k,i) for(i=j;i>k;i--)
#define ipp(n) printf("%d\n",n)
#define pp(n) printf("%lld\n",n)
#define pps(n) printf("%lld ",n)
#define ipps(n) printf("%d ",n)
#define all(x) x.begin(),x.end()
#define ps(s) printf("%s",s)
#define is(n) scanf("%lld",&n)
#define iis(n) scanf("%d",&n)
#define ips(n) scanf("%lld",n)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i) cout<<i<<endl;
#define pll pair<lld,lld> 
#define pi acos(-1)
#ifdef G
#define dg(x) cout<<#x<<' '<<x<<endl;
#define dg2(x,y) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<endl;
#define dg3(x,y,z) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<' '<<#zz<<' '<<zz<<endl;
#else
#define dg(x) ;
#define dg2(x,y) ;
#define dg3(x,y,z) ;
#define dg4(x,y,z,zz) ;
#endif
#define ds(n,m) scanf("%lld %lld",&n,&m)
#define ids(n,m) scanf("%d %d",&n,&m)
#define ts(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
#define its(n,m,k) scanf("%d %d %d",&n,&m,&k)
#define yes printf("YES\n")
#define no printf("NO\n")
#define isset(num,i) ((num&(1LL<<i))!=0)
typedef long double ld;
typedef long long int lld;
using namespace std;
const lld M =2e5+10;
const lld mod=1e9+7;
const lld infi =LLONG_MAX;
lld ans,k,n,x,y,m,mymax=LLONG_MIN,mymin=LLONG_MAX,c,z,sum;
lld b[M],s[M];
lld binpow(lld base,lld pow,lld modulus)
{
    lld ans=1;
    base=base%modulus;
    while(pow>0)
    {   
        while(pow%2==0)
        {
            base=(base*base)%modulus;
            pow/=2;
        }
        ans=(ans*base)%modulus;
        pow--;
        
    }
    return ans;
}
lld fact(lld n)
{
    if(n<2)return 1;
    return (fact(n-1)*n)%mod;
}
int main()
{
    lld i,j;
    is(n);
    up(1,n+1,i){
    	is(b[i]);
    }
    s[1]=0;
    up(2,n+1,i){
        s[i]=(binpow(i,mod-2,mod)+s[i-1])%mod;
    }
    up(1,n+1,i){
        x=(s[i]+s[n-i+1])%mod;
        // x=(x-2+mod)%mod;
        x=(b[i]*x)%mod;
        ans=(ans+(x+b[i])%mod)%mod;
    }
    ans=(ans*fact(n))%mod;
    // ans=(ans+)
    pp(ans);
    return 0;
}

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

int main() {
  //input
  int N, Y;
  cin >> N >> Y;
  
  int x = 0;
  int y = 0;
  int z = 0;
  
  for (int i = 0; i < N + 1; i++){
      for (int j = 0; j < N + 1 - i; j++){
          if (Y == 10000 * i + 5000 * j + 1000 *(N-i-j)){
            x = i;
            y = j;
            z = N-i-j;
            cout << x << " " << y << " " << z << endl;
            break;
          }
      }
     if (Y == 10000 * x + 5000 * y + 1000 * z) break;
    }
    
    if(x==0 && y==0 && z==0) cout << -1 << " " << -1 << " " << -1 << endl;
  
//  cout << 10000 * x + 5000 * y + 1000 * z << " "<< x + y + z << endl;
}


Measured memory_bytes: 3564
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <time.h>
#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
const ll mod = 1e9+7;


int main(){

    int n;
    string s1,s2;
    cin >> n >> s1 >> s2;
    ll cnt = 1;
    int tate = 0,yoko =0;
    rep(i,n){
        if(s1[i] ==s2[i]){//|を発見
            if(i == 0){
                cnt = ((cnt % mod) * (3 % mod)) %mod;
            }else{
                if(yoko > 0){//-のカウント中だったか？
                    yoko = 0;
                }else{
                    cnt = ((cnt % mod) * (2 % mod)) %mod;
                }
            }
            tate++;
        }else {//-を発見
            if(i == 0){
                cnt = ((cnt % mod) * (6 % mod)) %mod;
            }else{
                if(tate > 0){//｜のカウント中だったか?
                    cnt = ((cnt % mod) * (2 % mod)) %mod;
                    tate = 0;
                }else{
                    cnt = ((cnt % mod) * (3 % mod)) %mod;

                }
            }
            yoko++;
            i++;
        }
    }

    cout << cnt << endl;
    return 0;
}

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

public class Main{
        public static void main(String[] args){
                Scanner scanCnt = new Scanner(System.in);
                int N = scanCnt.nextInt();
                int M = scanCnt.nextInt();

                int Array[] = new int[M];

                int ans=0;

                for(int i = 0 ; i < N ; i++ ){
                        int K = scanCnt.nextInt();
                        for(int j = 0 ; j < K ; j++ ){
                                int num = scanCnt.nextInt();
                                for(int p=0 ; p < M ; p++){
                                        if(num==p+1){
                                                Array[p]+=1;
                                        }
                                }
                        }
                }
                for(int p=0 ; p < M ; p++){
                        if(Array[p]==N){
                                ans++;
                        }
                }

                System.out.println(ans);

        }
}

Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,i,p,t;
    t=0;
    cin>>n;
    for(i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            p=n/i;
            if(p<=9&&i<=9)
            {
                t++;
                cout<<"Yes"<<endl;
                break;
            }
        }
    }
    if(t==0)
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;


int main(){
    int n;
    cin>>n;
    vector<long long> a(n);
    rep(i,n) cin>>a[i];
    sort(ALL(a));
    rep(i,n-1) if(a[i]==a[i+1]){
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl;
    return 0;
}

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

using namespace std;

long long int N,M,L,R,K,H,W;
constexpr long long int MOD=1000000007;

int main(){
	cin>>N;
	vector<string>s(N);
	for(auto &i:s)cin>>i;
	vector<vector<int>>v(N);
	for(int i=0;i<N;i++){
		for(auto j:s[i])v[i].push_back(j-'0');
	}
	vector<vector<bitset<17>>>edge(N,vector<bitset<17>>(N));//iの末尾k文字がはみでてるときにjを置けるか
	vector<vector<pair<int,int>>>conv(17,vector<pair<int,int>>(1<<16,{-1,-1}));
	vector<vector<int>>vbit(N,vector<int>(16));
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			int num=0;
			for(int k=0;k<v[i].size();k++){
				num<<=1;
				num|=v[i][k];
			}
			int mask=(1<<(int)v[i].size())-1;
			for(int k=0;k<v[i].size();k++){
				bool flag=true;
				vbit[i][v[i].size()-k]=num;
				conv[v[i].size()-k][num]={i,k};
				mask>>=1;
				num&=mask;
				int num=min(v[i].size()-k,v[j].size());
				for(int l=0;l<num;l++){
					flag&=v[i][k+l]==v[j][l];
				}
				if(flag)edge[i][j].flip(v[i].size()-k);
			}
		}
	}
	vector<vector<int>>dp(16,vector<int>(1<<16,MOD));
	priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>>PQ;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(!edge[i][j].test(v[i].size()))continue;
			if(v[i].size()==v[j].size())continue;
			if(v[i].size()>v[j].size()){
				if(dp[v[i].size()-v[j].size()][vbit[i][v[i].size()-v[j].size()]]>v[i].size()){
					dp[v[i].size()-v[j].size()][vbit[i][v[i].size()-v[j].size()]]=v[i].size();
					PQ.push({(int)v[i].size(),{(int)v[i].size()-v[j].size(),vbit[i][v[i].size()-v[j].size()]}});
				}
			}
			else{
				swap(i,j);
				if(dp[v[i].size()-v[j].size()][vbit[i][v[i].size()-v[j].size()]]>v[i].size()){
					dp[v[i].size()-v[j].size()][vbit[i][v[i].size()-v[j].size()]]=v[i].size();
					PQ.push({(int)v[i].size(),{(int)v[i].size()-v[j].size(),vbit[i][v[i].size()-v[j].size()]}});
				}
				swap(i,j);
			}
		}
	}
	while(!PQ.empty()){
		int c=PQ.top().first;
		int ca=PQ.top().second.first;
		int cb=PQ.top().second.second;
		PQ.pop();
		if(!ca)continue;
		if(dp[ca][cb]!=c)continue;
		int vnum=conv[ca][cb].first;
		for(int i=0;i<N;i++){
			if(edge[vnum][i].test(ca)){
				if(ca>v[i].size()){
					if(dp[ca-v[i].size()][vbit[vnum][ca-v[i].size()]]>c){
						dp[ca-v[i].size()][vbit[vnum][ca-v[i].size()]]=c;
						PQ.push({c,{ca-v[i].size(),vbit[vnum][ca-v[i].size()]}});
					}
				}
				else{
					if(dp[v[i].size()-ca][vbit[i][v[i].size()-ca]]>c+v[i].size()-ca){
						dp[v[i].size()-ca][vbit[i][v[i].size()-ca]]=c+v[i].size()-ca;
						PQ.push({c+v[i].size()-ca,{v[i].size()-ca,vbit[i][v[i].size()-ca]}});
					}
				}
			}
		}
	}
	if(dp[0][0]==MOD)dp[0][0]=0;
	cout<<dp[0][0]<<endl;
}



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


int n,x,m;
int A[20];
bool ok;
int l[20],r[20],s[20];

bool check(){
  for(int i=0; i<m; i++){
    int sum = 0;
    for(int j=l[i]; j<=r[i]; j++){
      sum += A[j];
    }

    if(sum != s[i]) return false;

  }
  return true;
}

void f(int N){

  if(N == n){
    if(check()){
      ok = true;    
    } 
      return;
  }

  if(ok) return;


  for(int i=x; i>=0; i--){
    if(ok) return;
    A[N] = i;
    f(N+1);
  }

}


int main(){

  cin >> n >> x >> m;

  for(int i=0; i<m; i++){
    cin >> l[i] >> r[i] >> s[i];
    l[i]--,r[i]--;
  }

  ok = false;
  
  f(0);
  if(!ok) cout << -1 << endl;
  
  else {

    for(int i=0; i<n; i++){
      if(i == 0) cout << A[i];
      else cout << " " << A[i];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1164
import sys
readline = sys.stdin.readline

MOD = 10**9+7
def comb(a, b):
    res = 1
    pres = 1
    for i in range(b):
        res = (res*(a-i))%MOD
        pres = (pres*(i+1))%MOD
    return res*pow(pres, MOD-2, MOD) % MOD


N, A, B = map(int, readline().split())
ans = pow(2, N, MOD) - 1 - comb(N, A) - comb(N, B)
print(ans%MOD)


Measured memory_bytes: 39152
class Dice:
    def __init__(self, x):
        self.top = x[0]
        self.front = x[1]
        self.right = x[2]
        self.left = x[3]
        self.back = x[4]
        self.bottom = x[5]

    def N(self):
        self.top, self.front, self.bottom, self.back = self.front, self.bottom, self.back, self.top

    def E(self):
        self.top, self.right, self.bottom, self.left = self.left, self.top, self.right, self.bottom

    def S(self):
        self.top, self.front, self.bottom, self.back = self.back, self.top, self.front, self.bottom

    def W(self):
        self.top, self.right, self.bottom, self.left = self.right, self.bottom, self.left, self.top

    def up_front_to_right(self, top, front):
        if (top, front) in [(self.top, self.front), (self.front, self.bottom), (self.bottom, self.back), (self.back, self.top)]:
            return self.right
        if (top, front) in [(self.front, self.top), (self.bottom, self.front), (self.back, self.bottom), (self.top, self.back)]:
            return self.left
        if (top, front) in [(self.left, self.front), (self.front, self.right), (self.right, self.back), (self.back, self.left)]:
            return self.top
        if (top, front) in [(self.front, self.left), (self.right, self.front), (self.back, self.right), (self.left, self.back)]:
            return self.bottom
        if (top, front) in [(self.top, self.left), (self.left, self.bottom), (self.bottom, self.right), (self.right, self.top)]:
            return self.front
        if (top, front) in [(self.left, self.top), (self.bottom, self.left), (self.right, self.bottom), (self.top, self.right)]:
            return self.back
            
*x,=map(int,input().split())
dice=Dice(x)
q=int(input())
for _ in range(q):
    a,b=map(int,input().split())
    print(dice.up_front_to_right(a,b))


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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll k,a,b;cin>>k>>a>>b;

  ll money=0;

  if(b-a<=2){
    out(1+k);
  }
  else{
    ll n=k-(a-1);
    if(n<=0){
      out(1+k);
      // out("a");
    }
    else{
      if(n%2){
        out(a+(n/2)*(b-a)+1);
        // out("b");
      }else{
        out(a+(n/2)*(b-a));
        // out("c");
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a,b) ((a)>(0)?(a):-(a))

void run(void){
  int s[3]={0};
  int i;
  for(i=0;i<3;i++){
    char c;
    scanf("%c",&c);
    s[c-'a']++;
  }
  for(i=0;i<3;i++){
    if(s[i]!=1){
      printf("No\n");
      return;
    }
  }
  printf("Yes\n");
  return;
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  long long n,a,b,cnt,ans=100;
  cin >> n;
  for(a=1; a*a<=n; a++) {
    if(n%a==0) {
      b=n/a;
      int cnt_b=0;
      while(b>0) {
        b/=10;
        cnt_b++;
      }
      if(ans>cnt_b) {
        ans=cnt_b;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=105;
int l[2*N];
int main()
{  
     int n;
    scanf("%d",&n);
    n*=2;
    for(int i=1;i<=n;i++)
    scanf("%d",&l[i]);
    sort(l+1,l+n+1);
    int megh=0;
    for(int i=1;i<=n;i+=2)
    megh+=l[i];
    printf("%d\n",megh);
    















return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author KY2001
 */


#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, int y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  int ans = 1;
  x %= MOD;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = x * x;
    x %= MOD;
  }
  return ans;
}

class CKThSubstring {
public:
  int solve(std::istream &cin, std::ostream &cout) {
    string s;
    int K;
    cin >> s;
    cin>> K;
    vector<string> ans;
    rep(k, K) {
      rep(i, s.size() - k) {
        string temp = "";
        rep(j, k + 1) {
          temp += s[i + j];
        }
        ans.emplace_back(temp);
      }
    }
    sort(ALL(ans));
    vector<string> ans2 = {ans[0]};
    rep(i, ans.size()-1){
      if (ans[i] != ans[i+1]){
        ans2.emplace_back(ans[i+1]);
      }
    }
    cout << ans2[K-1] << endl;
  }
};


signed main() {
	CKThSubstring solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

#define N ((int)1e5 + 1)
#define forn(i,x,y) for(int i = int(x); i<int(y); i++)
#define debug(x) cerr << #x << " == " << (x) << '\n';
#define all(V) V.begin(), V.end()

template<typename T> ostream &operator<<(ostream &out, const pair<T, T> &P){ out << P.first << ' ' << P.second; return out; }
template<typename T> ostream &operator<<(ostream &out, const vector<T> &V){ for(int i = 0; i<V.size(); ++i) out << V[i] << ' '; return out; }
template<typename T> istream &operator>>(istream &in, vector<T> &V){ for(T &i : V) in >> i; return in; }
template<typename T> istream &operator>>(istream &in, pair<T,T> &P){ in >> P.first >> P.second; return in; }

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

    int n; cin >> n;
    string s,t; cin >> s >> t;
    string ret = "";

    for(int i = 0; i < n; i++) {
        ret += s[i];
        ret += t[i];
    }
    cout << ret << '\n';

    return 0;
}

/* don't forget to check:
   int overflow
   min/max cases (n = 1)
   printing index of sorted array
   limits for ans (start with inf)
 */



Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int k = int.Parse(input[1]);
		double answer = 0;

    for(int i = 0; i < n; i++)
    {
      long nowNum = i+1;
      long multipleCount = 0;
      while(true)
      {
        if(nowNum >= k) break;
        nowNum *= 2;
        multipleCount++;
      }
      answer += (double)1 / (n*(double)Math.Pow(2,multipleCount));
    }

		Console.WriteLine(answer);
	}
}

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

int main(){
	int x1, y1, x2, y2, x3, y3, x4, y4;
	cin >> x1 >> y1 >> x2 >> y2;
	x3 = x2 - (y2 - y1);
	y3 = y2 + (x2 - x1);
	x4 = x1 - (y2 - y1);
	y4 = y1 + (x2 - x1);
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	return 0;
} 

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

int main() {
  
  int N;
  cin >> N;
  
  int a, b, c, d; //一，十，百，千の位
  
  a = N % 10;
  N /= 10;
  b = N % 10;
  N /= 10;
  c = N % 10;
  N /= 10;
  d = N % 10;
  
  if ((a == b && b == c) || (b == c && c == d)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
          using namespace std;
          #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
          #define M_PI 3.14159265358979323846
          #define data data_
          #define ff first
          #define ss second

          long long const K = 100009;
          bool dp[K];
          int main()
          {
          // clock_t begin = clock();
          // #ifndef ONLINE_JUDGE
          // freopen("input.txt", "r", stdin);
          // freopen("output.txt", "w", stdout);
          // #endif
          tani_nachi_ke  

          int n,k;
          cin >> n >> k;
          int a[n];
          for(int i = 0; i < n; i++)
               cin >> a[i];
          sort(a, a + n);
          for(int i = 0; i < a[0]; i++)
               dp[i] = 0;
          for(int i = a[0]; i <= k; i++)
          {
               bool t = 1;
               for(int j = 0; j < n; j++)
               {
                    if(a[j] <= i)
                         t &= (dp[i - a[j]]);
               }
               dp[i] = (!t);
          }
          if(dp[k])
               cout << "First\n";
          else
               cout << "Second\n";
          




          // #ifndef ONLINE_JUDGE 
          // clock_t end = clock();
          // cout<<endl<<double(end - begin) / CLOCKS_PER_SEC*1000<<" ms";
          // #endif 
          // return 0;
          }

Measured memory_bytes: 384
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

k = ni()

n = 50
a = [i for i in range(n)]

for i in range(n):
    a[i] += (k//n)
    
for i in range(k%n):
    a[i] += n
    for j in range(n):
        if i != j:
            a[j] -= 1
            
print(n)
print(*a)

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

int main(){
  int a, b;
  cin >> a >> b;   
  if(a == b){
    cout << "Draw" << endl;
  } else if(a > b && b != 1){
    cout << "Alice" << endl;
  } else if(a < b && a != 1){
    cout << "Bob" << endl;
  } else if(a == 1){
    cout << "Alice" << endl;
  } else if(b == 1){
    cout << "Bob" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<vector>

using namespace std;

int main(){

  vector<int> v;
  int N,M; cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> M;
    v.push_back(M);
  }
  cout << *max_element(v.begin(),v.end()) - *min_element(v.begin(),v.end()) << endl;
  return 0;
}


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

int main () {
    char str [222];
    scanf ("%s", str ) ;
    int n= strlen (str ) ;
    for (int i=n -2; i; i -=2) {
    if( strncmp (str , str +i/2 , i/2) ==0) {
    printf ("%d\n" ,i) ;
    return 0;
    }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N=int(input())
S=list(map(int,input().split()))
T=list(map(int,input().split()))
U=list(map(int,input().split()))
S.sort()
T.sort()
U.sort()
#print(S)
#print(T)
#print(U)


count=0
def is_ok(index,key):
    if key>S[index]:
        return True
    else:
        return False


def meguru_bisect(key):
    ng=N
    ok=-1
    
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid,key):
            ok = mid
        else:
            ng = mid
    return ok

def is_ok2(index,key):
    if key<U[index]:
        return True
    else:
        return False


def meguru_bisect2(key):
    ng=-1
    ok=N
    
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok2(mid,key):
            ok = mid
        else:
            ng = mid
    return ok
ans=0
for i in range(N):
    ans+=(N-meguru_bisect2(T[i]))*(meguru_bisect(T[i])+1)
print(ans)



Measured memory_bytes: 29188
N=int(input())
list1=[]
list2=[]
for i in map(int,input().split()):
    if i % 2 == 0:
        list1.append(i)
    if i % 2 == 0 and (i % 3 == 0 or i % 5 ==0):
        list2.append(i)
if list1 == list2:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 61900
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    h1, m1, h2, m2, k = map(int, input().split())

    t1 = h1*60+m1
    t2 = h2*60+m2
    print(t2-t1-k)


if __name__ == '__main__':
    main()


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


int main(){
    int N; cin >> N;
    string S; cin >> S;
    
    vector<int> L(N+1), R(N+1);
    if(S[0]=='W'){
        L[0]=1;
        R[0]=0;
    }
    else {
        L[0]=0;
        R[0]=1;
    }
    
    for(int i=1; i<N; i++){
        if(S[i]=='W'){
            L[i] = L[i-1] + 1;
            R[i] = R[i-1];
        }
        else {
            L[i] = L[i-1];
            R[i] = R[i-1] + 1;
        }
        //cout << L[i] <<" "<< R[i] << endl;
    }
    int cnt, mi=1e9;
    for(int i=0; i<N; i++){
        cnt=0;
        if(i==0){
            cnt = R[N-1] - R[i];
        }
        else {
            cnt = L[i-1] + R[N-1] - R[i];
        }
        //cout << cnt << endl;
        mi = min(mi, cnt);
    }
    cout << mi << endl;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
//#define m 1000000000000000007
/*vector<ll>prime(10000001,1);
vector<ll>sdf(10000001);
ll C[101][101];
int isprime(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
            {//cout<<i<<endl;
            return 0;}
    }
    return 1;
}
int isperfectsq(ll n)
{


    long double x;
    x=(long double)(sqrt((long double )(n)));
    ll y=sqrt(n);
    if(x==y)
        return 1;
        else
            return 0;
}
void ncr()
{
    C[0][0] = 1;
    for (int n = 1; n <= 100; ++n) {
        C[n][0] = C[n][n] = 1;
        for (int k = 1; k < n; ++k)
            C[n][k] = C[n - 1][k - 1] + C[n - 1][k];
    }
}
void sieve()
{
    //cout<<"in1";
    ll i;
    for(i=0;i<=10000000;i++)
        sdf[i]=i;
    ll j;
    prime[0]=prime[1]=0;
    for(i=2;i*i<=10000000;i++)
    {
        if(prime[i]==1)
        {
            //isprime.push_back(i);
            for(j=i*i;j<=10000000;j+=i)
            {
                prime[j]=0;
                if(sdf[j]==j)
                {
                    sdf[j]=i;
                }
            }
        }
    }
}
long long modular_expo(long long x,long long y)
{

    if(y==0)
        return 1;
    if(y%2==0)
        return modular_expo(x*x,y/2);
    if(y%2==1)
        return x*modular_expo(x*x,(y-1)/2);


}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);


    int a;
    cin>>a;
    cout<<a+a*a+a*a*a;

}


Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>
char aa[9999][9999];
char tem[99999];
main()
{
long long 	int a,b;
	while(~scanf("%lld%lld",&a,&b))
	{
		int i;
		for(i=0;i<a;i++)
		{
			scanf("%s",aa[i]);
		}
		int q,w,e;
		for(q=0;q<a-1;q++)
		{
			for(w=q+1;w<a;w++)
			{
				for(e=0;e<b;e++)
				{
					if(aa[q][e]>aa[w][e])
					{
						strcpy(tem,aa[q]);
						strcpy(aa[q],aa[w]);
						strcpy(aa[w],tem);break;
					}else if(aa[q][e]<aa[w][e])break;
				} 
			}
		}
		
		for(i=0;i<a;i++) 
		{
			printf("%s",aa[i]);
		}
		printf("\n");
		
	}
}

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


int main(void){
  long long n;
  long long x=0,y=0,z=0;
  
  cin >> n;
  for (long long i=1; i<=3500; i++){
    for (long long j=i; j<=3500; j++){
      // 4/N = 1/h + 1/n + 1/w
      // .: w = Nnh/(-nN - hN + 4nh)
//      cout << i << " " << j << ": ";
//      cout << (n*i*j) << " " << (-n*i-n*j+4*i*j) << endl;
      if (-n*i-n*j+4*i*j<=0) continue;
      if ((n*i*j)%(-n*i-n*j+4*i*j)!=0) continue;
      x = i, y=j, z = (n*i*j)/(-n*i-n*j+4*i*j);
//      cout << x << " " << y << " " << z << "  /  ";
//      cout << (n*i*j) << " " << (-n*i-n*j+4*i*j) << endl;
    }
  }
  cout << x << " " << y << " " << z << endl;
  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

int main()
{
  ll m,n;
  cin>>n>>m;
  ll mn=min(m,n);
  ll mx=max(m,n);
  for(ll i=0;i<mx;i++)
    cout<<mn;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
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;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int x; cin >> x;
    if(x==0) cout<<1<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    ll N, P; cin >> N >> P;
    string S; cin >> S;
    ll ans = 0;
    if(P == 2 || P == 5){
        rep(i,N){
            if( (S[i] - '0') % P == 0 ) ans += i + 1;
        }
    }
    else{
        unordered_map<ll,ll>Remainders;
        Remainders[0] = 1;
        ll _10Power = 1, number = 0, remainder;
        
        for(ll i = S.size() - 1; ~i; --i){
            number += (S[i] - '0') * _10Power;
            remainder = number % P;
            ++Remainders[remainder];
            _10Power *= 10;
            _10Power %= P; number %= P;
        }
        for(auto rem : Remainders){
        ans += (rem.second * (rem.second - 1)) / 2;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 916
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
  int N;
  cin>>N;
  	if(N<105) cout<<0;
  else if(N<135) cout<<1;
  else if(N<165) cout<<2;
  else if(N<189) cout<<3;
  else if(N<195) cout<<4;
  else cout<<5;
}


Measured memory_bytes: 384
max = 0
val = 0
dis = 0
lst = []
valdis = 0

for i in range(5):
    num = int(input())
    val = 0
    while num > val:
        val += 10

    dispre = val - num

    if dis < dispre:
        dis = dispre
        max = num
        lst.append(valdis)
        valdis = val
    else:
        lst.append(val)

print(sum(lst) + max)

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

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

    int p = 0, g = 0;
    for(int i = 0; i < s.size(); ++i){
        if(s[i] == 'p') p++;
        else g++;
    }
    
    cout << (g - p) / 2 << endl;

    return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int A, B;

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

  std::cin >> A >> B;

  std::string S(B, (char)(A + '0')), T(A, (char)(B + '0'));
  
  if(S < T){
      std::cout << S << std::endl;
  }else{
      std::cout << T << std::endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int N;
    scanf("%d",&N);
    int p[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
        scanf("%d",&p[i]);
        sum += p[i];
    }
    int max = p[0];
    for(int i = 1; i < N; i++){
        if(max < p[i]) max = p[i];
    }
    sum -= max /2;
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
/*
PROG: acfqcd
LANG: C++
    _____
  .'     '.
 /  0   0  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
*/
#include <bits/stdc++.h>
 
using namespace std;
 
long long readi()
{
	long long input = 0;
	char c = ' ';
	while (c < '-')
	{
		c = getchar();
	}
	bool negative = false;
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	while (c >= '0')
	{
		input = 10 * input + (c - '0');
		c = getchar();
	}
	if (negative)
	{
		input = -input;
	}
	return input;
}
void printi(long long output)
{
	if (output == 0)
	{
		putchar('0');
		return;
	}
	if (output < 0)
	{
		putchar('-');
		output = -output;
	}
	int aout[20];
	int ilen = 0;
	while(output)
	{
		aout[ilen] = ((output % 10));
		output /= 10;
		ilen++;
	}
	for (int i = ilen - 1; i >= 0; i--)
	{
		putchar(aout[i] + '0');
	}
	return;
}
string reads()
{
	string input = "";
	char c = ' ';
	while (c <= ' ')
	{
		c = getchar();
	}
	while (c > ' ')
	{
		input += c;
		c = getchar();
	}
	return input;
}
void prints(string output)
{
	for (int i = 0; i < output.length(); i++)
	{
		putchar(output[i]);
	}
	return;
}

#define MP make_pair
#define PB push_back
#define PF push_front
#define MT make_tuple
#define LB lower_bound
#define UB upper_bound

#define SINF 10007
#define MOD 1000000007
#define INF 1000000861
#define LLINF 1000000000000000861ll
#define CO 1000861
#define EPS 0.000000000000001
#define PI 3.141592653589793
#define MAXN 200010
#define MAXM 70000010

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

int N;
int arr[MAXN];
int late[MAXN];
int pref[MAXN];
int dp[MAXM];
int ans;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	srand(time(NULL));
//	cout << fixed << setprecision(10);	
//	cerr << fixed << setprecision(10);
//	if (fopen("acfqcd.in", "r"))
//	{	
//		freopen ("acfqcd.in", "r", stdin);
//		freopen ("acfqcd.out", "w", stdout);
//	}
	string s;
	cin >> s;
	N = s.length();
	for (int i = 1; i <= N; i++)
	{
		arr[i] = (s[i - 1] - 'a');
	}
	pref[0] = 0;
	for (int i = 1; i <= N; i++)
	{
		pref[i] = pref[i - 1] xor (1 << arr[i]);
	}
	for (int i = 0; i < (1 << 26); i++)
	{
		dp[i] = INF;
	}
	dp[0] = 0;
	for (int i = 1; i <= N; i++)
	{
		for (int j = 0; j < 26; j++)
		{
			dp[pref[i]] = min(dp[pref[i]], dp[pref[i] xor (1 << j)] + 1);
		}
	}
	cout << max(1, dp[pref[N]]) << '\n';
	return 0;
}


Measured memory_bytes: 267600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  queue<char> q;
  ll cnt = 0;
  for (ll i = 0; i < n; i++) {
    if (s[i] == '(') q.push(s[i]);
    else if (q.size() > 0) q.pop();
    else cnt++;
  }

  for (ll i = 0; i < cnt; i++) cout << '(';
  cout << s;
  for (ll i = 0; i < q.size(); i++) cout << ')';
  cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int a = scanner.nextInt();
        int b = scanner.nextInt();

        
        if (a <= b) {
            StringBuilder builder = new StringBuilder();
            for (int i = 0 ; i < b ; i++) {
                builder.append(a);
            }
            System.out.println(builder.toString());
        } else {
            StringBuilder builder = new StringBuilder();
            for (int i = 0 ; i < a ; i++) {
                builder.append(b);
            }
            System.out.println(builder.toString());
        }
    }
}


Measured memory_bytes: 35640
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};


int main() {
    int a,b,c,x;cin>>a>>b>>c>>x;
    int count=0;
    repsg(i,0,a+1)repsg(j,0,b+1){if((x-500*i-100*j)>=0 &&(x-500*i-100*j)%50 == 0 && (x-500*i-100*j)/50<=c){ count++;}}
    cout<<count<<endl;
    return 0;
}







Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//符号反転
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(ll n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
     mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
int main(){
   ll n,k;
   cin>>n>>k;
   mint ans=0;
   ll ma=0,mi;
   for(ll i=n;i>(n-k+1);i--){
       ma+=i;
   }
   for(ll i=k;i<=n;i++){
       ma+=(n-i+1);
       ans+=mint(ma-i*(i-1)/2+1);
      // cout<<ma<<"\n";
   }
   ans+=mint(1);
   cout<<ans<<"\n";
}

Measured memory_bytes: 3608