akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;
const int maxn=1024;
const int mod=998244353;
int n,m,sg[200005];
long long f[3][2005],pw[100005],h[2005],B=1e18;
vector<int> G[100005];
long long ksm(long long x,long long n)
{
	long long ans=1;
	while(n)
	{
		if(n&1) ans=ans*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return ans;
}
void FWT(long long a[],int n,int ty)
{
	for(int i=1;i<n;i<<=1)
	for(int j=0;j<n;j++)
	{
		if(j&i)
		{
			long long t0=a[j-i],t1=a[j];
			a[j-i]=(t0+t1)%mod;a[j]=(t0-t1+mod)%mod;
		}
	}
	if(ty==-1)
	{
		long long rev=ksm(n,mod-2);
		for(int i=0;i<n;i++) a[i]=a[i]*rev%mod;
	}
}
int dfs(int x)
{
	if(sg[x]!=-1) return sg[x];
	map<int,bool> g;
	int sz=G[x].size();
	for(int i=0;i<sz;i++) g[dfs(G[x][i])]=1;
	int now=0;
	while(g[now]) now++;
	return sg[x]=now;
}
int main()
{
	B%=mod;
	scanf("%d",&n);
	pw[0]=1;
	for(int i=1;i<=n;i++) pw[i]=pw[i-1]*B%mod;
	for(int t=0;t<3;t++)
	{
		scanf("%d",&m);
		memset(sg,-1,sizeof(sg));
		for(int i=1;i<=n;i++) G[i].clear();
		for(int i=1;i<=m;i++)
		{
			int x,y;
			scanf("%d%d",&x,&y);
			if(x>y) swap(x,y);
			G[x].push_back(y);
		}
		for(int i=1;i<=n;i++) if(sg[i]==-1) dfs(i);
		for(int i=1;i<=n;i++) f[t][sg[i]]=(f[t][sg[i]]+pw[i])%mod;
		FWT(f[t],maxn,1);
	}
	for(int i=0;i<maxn;i++) h[i]=1;
	for(int t=0;t<3;t++)
	for(int i=0;i<maxn;i++) h[i]=h[i]*f[t][i]%mod;
	FWT(h,maxn,-1);
	printf("%lld\n",(h[0]%mod+mod)%mod);
}

Measured memory_bytes: 10348
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {


  var(ll, q, h, s, d, n);

  ll a = q * 4 * 2;
  ll b = h * 2 * 2;
  ll c = s * 2;
  ll mini = min({ a, b, c, d });
  ll tmp = n / 2;
  ll ans = tmp * mini;
  err(ans);
  if (n & 1)ans += min({ q * 4, h * 2,s });
  cout << (ans) << endl;



}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    string S;
    cin >> S;
    int N = stoi(S);
    int fX = 0;
    for (const char ch : S)
    {
        fX += static_cast<int>(ch - '0');
    }
    if (N % fX == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
AB = [[int(i) for i in input().split()] for i in range(N)] 

AB.sort(key=lambda x:(x[1], x[0]))

hour = 0
for a, b in AB:
  hour += a
  if hour <= b:
    continue
  else:
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 53852
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, L;
	cin >> N >> L;
	vector<string> v(N);
	for (int i = 0; i < N; i++)
		cin >> v[i];
	sort(v.begin(), v.end());
	for (int i = 0; i < N; i++)
		cout << v[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//-------------------------------------------MACROS---------------------------------------------
#define 	TIEMPO_CORRIDA		cerr << "tiempo: "<<1.0*clock()/CLOCKS_PER_SEC <<" seg.\n";
#define 	FILES				freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define 	FORIT(it,e)			for(it = e.begin() ; it != e.end() ; it++)
#define 	FOR(i,a,b)			for(i = a ; i < b ; i++)
#define 	RFOR(i,a,b)			for(i = a ; i >= b ;i--)
#define 	FORSW(i,a,b,sw)		for(i = a ; i < b && sw ; i++)
#define 	RFORSW(i,a,b,sw)	for(i = a ; i >= b && sw ; i--)
#define 	fast 				ios::sync_with_stdio(false),cin.tie(),cout.tie();
#define 	to_int(x) 			atoi(x.data())
#define 	to_long(x) 			atoll(x.data())
#define 	ALL(x) 				x.begin(),x.end()
#define 	RALL(x) 			x.rbegin(),x.rend()
typedef 	long long 			ll;
typedef 	pair<int,int> 		pi;
typedef 	pair<ll,ll> 		pl;
const		int 				modN = 1e9+7;
const		double 				PI = 3.1415926535897932384626433832795028841;
//---------------------------------------------------------------------------------------------

const int tam=6e5;
int day[tam][3];
int memo[tam][3];
int n;

int f(int i, int d){
	int j,ans = 0;
	if(memo[i][d]!=-1) return memo[i][d];
	if(i == n) return memo[i][d]=0;
	FOR(j,0,3)
		if(j!=d)
			ans=max(f(i+1,j)+day[i][j],ans);
	return memo[i][d]=ans;
}

int main(){
	int i;
	while(scanf("%d",&n)==1){
		memset(memo,-1,sizeof memo);
		FOR(i,0,n) scanf("%d %d %d",&day[i][0],&day[i][1],&day[i][2]);
		cout <<f(0,3)<<endl;
	}
	return 0;
}

Measured memory_bytes: 19648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
#define P pair<int,int>
typedef long long ll;
using namespace std;

int main(){
    int n,d; cin >> n >> d;
    int ans=0;
    while(n>0){
        n-=d*2+1;
        ans++;
    }
    cout << ans << endl;
return 0;
}


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

int main() {
 int N, K, ans;
  cin >> N >> K;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  ans=0;
  for (int i = 0; i < K; i++) {
    ans=ans+p.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3588
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <bitset>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define PR pair
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define REP(i, x, y)   for(int i = (int)(x); i <= (int)(y); i++)
#define FOR(i, x, y)   for(int i = (int)(x); i <  (int)(y); i++)
#define PER(i ,x, y)  for(int i = (int)(x); i >= (int)(y); i--)
#define CH	         ch = getchar()
#define Exit(...)    printf(__VA_ARGS__), exit(0)
#define dln()        fprintf(stderr,"\n")
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef double	  db;
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI > VII;
typedef PR<int,int> PII;
typedef vector<PII> VPI;
const	int inf=2e9;
const	LL Inf=1e10;
const	int P=1e9+7;
const	int N=505;

inline LL IN(){
	LL x = 0;
	int ch = 0, f = 0;
	for (CH; ch != -1 && (ch < 48 || ch > 57); CH) f = (ch == '-');
	for (; ch >= 48 && ch <= 57; CH) x = (x << 1) + (x << 3) + ch - '0';
	return f ? (-x) : x;
}
template<typename T> inline int chkmin(T &a, const T &b){if(b < a) return a = b, 1; return 0;}
template<typename T> inline int chkmax(T &a, const T &b){if(b > a) return a = b, 1; return 0;}

void renew(int &x, const int &y){
	x += y;
	if(x >= P) x -= P;
	if(x <  0) x += P;
}

int Pow(int x, int y, int p){
	int a = 1;
	for (; y; y >>= 1, x = (LL)x * x %p) if(y & 1) a=(LL)a * x%p;
	return a;
}

int n, x[N];
struct node{
	int r, cnt, id;
	bool operator <(const node &a)const{
		if(r != a.r) return r < a.r;
		if(cnt != a.cnt) return cnt < a.cnt;
		return id < a.id;
	}
};
multiset<node> st;
vector<node> fr[N * N];
int ans[N * N];

void ins(int l, int r, int cnt, int id){
	if(l > r){
		puts("No");
		exit(0);
	}
	fr[l].pb((node){r, cnt, id});
}

int main(){
	scanf("%d", &n);
	REP(i, 1, n) scanf("%d", x + i);
	REP(i, 1, n){
		if(i != 1) ins(1, x[i] - 1, i - 1, i);
		if(n != i) ins(x[i] + 1, n * n, n - i, i);
		ins(x[i], x[i], 1, i);
	}
	REP(i, 1, n * n){
		for(auto j : fr[i]) st.insert(j);
		auto u = *st.begin();
		if(u.r < i){
			puts("No");
			exit(0);
		}
		ans[i] = u.id;
		st.erase(st.find(u));
		u.cnt--;
		if(u.cnt) st.insert(u);
	}
	puts("Yes");
	REP(i, 1, n * n) printf("%d ", ans[i]); puts("");
	return 0;
}

Measured memory_bytes: 8192
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

----------------------------------------------------------------------

solve :: Int -> Int -> Int
solve n i = n - i + 1

tmain :: B.ByteString -> Int
tmain cont =
  let [n, i] = bsReadInts cont
  in solve n i

main = putStrLn . show . tmain =<< B.getContents


Measured memory_bytes: 380
#include <stdio.h>
#include <stdlib.h>

int compare(const void* a, const void* b) {
	return *(long long int*)a - *(long long int*)b;
}

int main() {
	int N, K, i = 0;
	long long int H[200000];
	scanf("%d%d",&N,&K);
	while (i<N) {
		scanf("%lld",&H[i]);
		i++;
	}

	qsort(H, N, sizeof(long long int), compare);

	long long int HA = 0;
	int d = 0;
	while (d<=N-K-1) {
		HA = HA + H[d];
		d++;
	}
	printf("%lld",HA);
	return 0;
}

Measured memory_bytes: 3324
#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 n;
  cin >> n;
  map<string, int> mp;
  rep(i,n) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  ll ans = 0;
  for(auto p : mp) {
    int m = p.second;
    ans += (ll)m*(m-1)/2;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define REP(i, b, e) for(int i = (int)(b); i < (int)(e); i++)
#define rep(i, n) REP(i, 0, n)
#define fi first
#define se second
#define pb push_back

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



int main(){
	int n, m;
	cin >> n >> m;
	vector<string> a(n), b(m);
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];
	bool f = false;
	rep(y, n - m + 1) rep(x, n - m  + 1){
		bool t = true;
		rep(i, m) rep(j, m) if(a[i+y][j+x] != b[i][j]) t = false;
		f |= t;
	}
	cout<<(f?"Yes":"No")<<endl;
}


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

int main() {
    int N, digit1, digit2, digit3, digit4;
    cin >> N;
    digit4 = N / 1000;
    N %= 1000;
    digit3 = N / 100;
    N %= 100;
    digit2 = N / 10;
    N %= 10;
    digit1 = N;
    if ((digit1 == digit2 && digit2 == digit3) || (digit2 == digit3 && digit3 == digit4)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main(void){
    int dp[100010];
    int n;cin>>n;
    fill(dp,dp+n,INF);
    int x;
    rep(i,n){
        cin>>x;
        *lower_bound(dp,dp+n,x)=x;
    }
    cout<<lower_bound(dp,dp+n,INF)-dp<<endl;
    //rep(i,n)cout<<dp[i]<<' ';
}


Measured memory_bytes: 3888
use proconio::{input, marker::Usize1};

fn main() {
    input! {
        n: usize, m: u64, q: usize,
        qs: [(Usize1, Usize1, u64, u64); q]
    }
    let mut g = G {
        n,
        m,
        qs,
        sq: Vec::new(),
    };
    println!("{}", g.dfs())
}

struct G {
    n: usize,
    m: u64,
    qs: Vec<(usize, usize, u64, u64)>,
    sq: Vec<u64>,
}

impl G {
    fn dfs(&mut self) -> u64 {
        if self.sq.len() == self.n {
            let ev = |&(a, b, c, d)| if self.sq[b] - self.sq[a] == c { d } else { 0 };
            self.qs.iter().map(ev).sum()
        } else {
            let last = *self.sq.last().unwrap_or(&1);
            (last..=self.m)
                .map(|x| {
                    self.sq.push(x);
                    let ret = self.dfs();
                    self.sq.pop();
                    ret
                })
                .max()
                .unwrap()
        }
    }
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << x << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ cout << (x[i]) << " ";} cout << endl;

typedef long long ll;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    int a[10001];
    cin >> N;
    rep(i,0,N){
        int tmp;
        cin >> tmp;
        a[i] = tmp;
    }
    int ans = 0;
    rep(i,0,N){
        while(a[i] % 2 == 0){
            a[i] /= 2;
            ans++;
        }
    }
    print(ans);

}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#define MAX 100;

using namespace std;
int main() {
    int i,j,k,ans=999999999,temps,templ;
    int n;
    cin>>n;
    vector<int> w(n);
    for(i=0;i<n;i++){
        cin>>w[i];
    }
    for(i=0;i<n;i+=1){
        templ=0;temps=0;
        for(j=0;j<n;j++){
            if(j>i)templ+=w[j];
            else temps+=w[j];
        }
        ans=min(ans,abs(templ-temps));
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool Grid[25][25];
const int INF = 1 << 30;

int main()
{
  int H, W, ans = 0;
  cin >> H >> W;
  char c;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin >> c;
      Grid[i][j] = c == '.';
    }
  }
  int dh[4] = {-1, 0, 0, 1};
  int dw[4] = {0, -1, 1, 0};
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (!Grid[i][j])
        continue;
      queue<pair<int, int>> que;
      vector<vector<int>> steps(H, vector<int>(W, INF));
      que.emplace(i, j);
      steps[i][j] = 0;
      while (que.size())
      {
        int h, w;
        tie(h, w) = que.front();
        que.pop();
        for (int k = 0; k < 4; k++)
        {
          int nh = h + dh[k], nw = w + dw[k];
          if (nh < 0 || nh >= H || nw < 0 || nw >= W)
            continue;
          if (!Grid[nh][nw])
            continue;
          if (steps[nh][nw] > steps[h][w] + 1)
          {
            steps[nh][nw] = steps[h][w] + 1;
            que.emplace(nh, nw);
          }
        }
      }
      int ma = 0;
      for (int k = 0; k < H; k++)
      {
        for (int l = 0; l < W; l++)
        {
          if (!Grid[k][l] || steps[k][l] == INF)
          {
            continue;
          }
          ma = max(ma, steps[k][l]);
        }
      }
      ans = max(ma, ans);
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define sz(x) (int)(x.size())
#define fr(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
//////////////////////

int const N = 1e5 + 41;

int n;
vector<int> e[N];

int dfs(int u){
	vector<int> st;
	fr(i, 0, sz(e[u])){
		int to = e[u][i];
		st.pb(dfs(to));
	}
	sort(st.begin(), st.end());
	int cur = 0;
	fr(i, 0, sz(st)){
		cur = max(cur, st[i]) + 1;
	}

	return cur;
}

void solve(){
	cin >> n;
	fr(i, 1, n){
		int p;
		cin >> p;
		--p;
		e[p].pb(i);
	}
	int ans = dfs(0);
	cout << ans << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

Measured memory_bytes: 15104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1_9_B
{
    class Program
    {
        static void Main(string[] args)
        {
            // 1行目：文字列の初期値
            // 2行目：シャッフル回数 m
            // 3～m＋2行目：シャッフルする場所 h
            // -：入力の終了
            // 文字列とシャッフル場所を読み込み、最終的な文字列を出力する

            string str;                                                             //1行目を読み込むためのstring型変数st

            while ((str = Console.ReadLine()) != "-")                               //取得した文字列strが-でないとき以下の処理を繰り返す
            {
                string strB;
                string strF;

                
                int m = int.Parse(Console.ReadLine());                          //2行目を読み込みシャッフル回数mを取得
                for (int i = 0; i < m; i++)                                     //シャッフル回数分以下を繰り返す
                {
                    int place = int.Parse(Console.ReadLine());                  //シャッフル場所を読み込む

                    strB = str.Substring(0, place);
                    strF = str.Substring(place);

                    str = strF + strB;

                }
                   

                    Console.WriteLine(str);
                }



                
            }

        }
    }




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

int main(){
  ll n, d, a; cin >> n >> d >> a;
  vector<pair<ll, ll>> v(n);
  rep(i, n) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end());
  ll ans = 0, sum = 0;
  queue<pair<ll, ll>> q;
  rep(i, n){
    ll x = v[i].first, h = v[i].second;
    while(q.size() > 0 && q.front().first < x){
      sum -= q.front().second;
      q.pop();
    }
    ll right = x + 2 * d;
    ll remain = max(0LL, h - sum);
    if(remain % a != 0){
      remain += (a - (remain % a));
    }
    sum += remain;
    ans += remain / a;
    if(remain != 0 && right <= v[n - 1].first) q.push(make_pair(right, remain));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7840
#include <bits/stdc++.h>
#define int long long
#define repn(i,j,n) for (int i = j; i <= n; ++i)

using namespace std;

int a[401],dp[401][401],sum[401];

int32_t main() 
{
    int n,j;
    cin>>n;
    memset(dp,0,sizeof(dp));
    memset(sum,0,sizeof(sum));
    repn(i,1,n){
        cin>>a[i];
        //dp[i][i]=a[i];
        sum[i]=sum[i-1]+a[i];
    }
    repn(len,2,n){
        for(int i=1;i+len-1<=n;i++){
            j=i+len-1;
            dp[i][j]=1e18;
            repn(k,i,j-1){
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]);
                //cout<<dp[i][j]<<" "<<i<<" "<<j<<endl;
            }
            dp[i][j]+=sum[j]-sum[i-1];
            //cout<<dp[i][j]<<" "<<i<<" "<<j<<endl;
        }
    }
    cout<<dp[1][n]<<endl;
}

Measured memory_bytes: 4876
<?php
fscanf(STDIN,"%d",$n);
$bs=explode(' ',trim(fgets(STDIN)));

$as = array();
for ($r = 0; $r < $n; $r++) {
  $as[] = 100000;
}

foreach ($bs as $i => $b) {
  if ($b <= $as[$i]) {
    $as[$i] = $b;
  }
  if ($i < $n - 1) {
    $as[$i + 1] = $b;
  }
}

echo array_sum($as);


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

int main(){
    int n,k;
    cin >> n >> k;
    int s =1;
    int a,b;
    for(int i=0;i<n;i++){
        a = s*2;
        b = s+k;
        if(a<b){
            s=a;
        }else{
            s=b;
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 3624
open Printf
open Scanf

let (d,g) = sscanf (read_line ()) "%d %d" (fun d g -> (d,g));;
let rec input_list num l =
if num = 0 then l
else 
    let (p,c) = sscanf (read_line ()) "%d %d" (fun d g -> (d,g)) in
    input_list (num-1) ((100 * (d-num+1), p, c) :: l);;

let list = input_list d [];;
let inf = 10000000000;;

let rec count_aux target i1 count =
if target <= 0 then count
else count_aux (target-i1) i1 (count+1);;

let solve list g =
    let rec loop l q_num sum tl =
    match l with
    | [] -> 
        (match tl with
        | [] ->  if sum >= g then q_num else inf
        | x::rest -> 
            let diff = g - sum in
            if diff <= 0 then q_num 
            else 
                let (i1,p1,c1) = List.hd (List.sort (fun (a,_,_) (b,_,_) -> -compare a b) tl) in
                if i1*(p1-1)+sum < g then inf
                else 
                let count = count_aux diff i1 0 in
                if count < p1 then q_num + count
                else inf
        )
    | (i1,p1,c1)::rest -> 
        let used_value = loop rest (q_num + p1) (sum + p1*i1 + c1) tl in
        let non_used_value = loop rest q_num sum ((i1,p1,c1) :: tl) in
        min used_value non_used_value
    in loop list 0 0 [];;

let ans = solve list g;;

let _ = printf "%d\n" ans;;

Measured memory_bytes: 896
import heapq

n=int(input())
pX = list(map(int,input().split()))
cnt = 0
for i in range(n-2):
    h = []
    heapq.heappush(h,pX[i])
    heapq.heappush(h,pX[i+1])
    heapq.heappush(h,pX[i+2])
    heapq.heappop(h)
    tgt = heapq.heappop(h)
    if tgt == pX[i+1]:
        cnt += 1

print(cnt)

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

int main(void){
	int n;
	while(1){
		cin >> n;
		vector<int> data;
		if(n == 0) break;

		for(int i=0; i<n; i++){
			int x;
			cin >> x;
			data.push_back(x);
		}
		sort(data.begin(), data.end());
		long long sum = 0;
		for(int i=1; i<n-1; i++){
			sum += data[i];
		}
		sum /= n-2;
		cout << sum << endl;
	}


	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k,now;
  cin >> n >> k;
  vector<int> p(n);
  priority_queue<int, vector<int>, greater<int> > pq;
  rep(i, n) {
    cin >> now;
    pq.push(now);
  }
  ll res = 0;
  rep(i, k) {
    res += pq.top();
    pq.pop();
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a, b,res;
  cin >> a >> b;
  if (a.size()>b.size()){
    res="GREATER";
  }
  if (a.size()<b.size()){
    res="LESS";
  }
  else{
    res="EQUAL";
    for (int i=0;i<min(a.size(),b.size());i++){
      if(a[i]>b[i]){
        res="GREATER";
        break;
      }
      if(a[i]<b[i]){
        res="LESS";
        break;
      }
    }
  }
  cout << res << endl;
}
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,S=0;
  cin>>N>>M;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    S+=A.at(i);
  }
  
  int count=0;
  for(int i=0;i<N;i++){
    if(A.at(i)*4*M>=S){
      count++;
    }
  }
  if(count>=M)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    string S;
    cin >> S;

    if(S.size()%2==0){
        rep(i,S.size()/2,S.size()){
            if(S[i]!=S[S.size()/2] or S[S.size()-i-1]!=S[S.size()/2] ){
                cout << i << endl;
                return;
            }
        }
        cout << S.size() << endl;
    }else{
        if(S[S.size()/2]!=S[S.size()/2-1] or S[S.size()/2]!=S[S.size()/2+1]){
            cout << (S.size()+1)/2 << endl;
            return;
        }
        rep(i,S.size()/2+2,S.size()){
            if(S[i]!=S[S.size()/2] or S[S.size()-1-i]!=S[S.size()/2]){
                cout << i << endl;
                return;
            }
        }
        cout << S.size() << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(auto &e : A) cin >> e;
    vector<int> ans;
    for(int i = N - 1; i >= 0; --i) {
        int n = i + 1;
        for(int j = i + n; j < N; j += n) A[i] ^= A[j];
    }
    rep(i, N) if(A[i]) ans.push_back(i + 1);
    cout << ans.size() << '\n';
    for(auto &e : ans) cout << e << " ";
    return 0;
}


Measured memory_bytes: 4584
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
#include <regex>
using namespace std;
using ll = int64_t;
using P = pair<int,int>;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
  int d,t,s;
  cin>>d>>t>>s;
  if(s*t>=d){
      cout<<"Yes"<<endl;
  }else{cout<<"No"<<endl;}
}




Measured memory_bytes: 3632
S=list(input())
T=list(input())
def ask_true(a,b):
    if a == b:
        return True
    else:
        return False
d=10000
for i in range(len(S)-len(T)+1):
    sum_=0
    for j in range(len(T)):
        if ask_true(S[i+j],T[j]):
            pass
        else:
            sum_ += 1
    d=min(sum_,d)
print(d)

Measured memory_bytes: 65832
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 

  int x, y, z;
  cin >> x >> y >> z;

  cout << (x - z) / (y + z) << "\n";
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
typedef long long ll;
using ld = long double;
const double  eps = 1e-8;
const double pi = acos(-1);
double a, b, x;
int main(){
	scanf("%lf%lf%lf", &a, &b, &x);
	double ans;
	if (a*a*b / 2.0 <= x)
		ans = atan(2 * (a*a*b - x) / (a*a*a));
	else ans = pi / 2 - atan(2 * x / (a*b*b));
	printf("%10f\n", ans*180.0/pi);
	return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

int main(){
  int n;
  cin >> n;
  pair<long long,long long> c[n];
  long long a,b;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    c[i] = make_pair(b,a);
  }
  long long count = 0;
  bool flag=true;
  sort(c,c+n);
  for(int i=0;i<n;i++){
    count += c[i].second;
    if(count > c[i].first){
      flag = false;
      break;
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k,res=1;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    if(res + k < res * 2){
      res += k;
    }else{
      res *= 2;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
n = input()
xs = map(float, input().split())
ys = map(float, input().split())
abs_d = [abs(x - y) for (x, y) in zip(xs, ys)]
d = [sum([i ** p for i in abs_d]) ** (1 / p) for p in range(1, 4)]
d.append(max(abs_d))

print(*d, sep='\n')


Measured memory_bytes: 5652
//#include<bits/stdc++.h> 
#include<iostream> 
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>  
#define Max int(2e5+10) 
using namespace std;  
int n,p[Max],a[Max],dp[Max];
vector<int> g[Max];
int dfs(int x)
{
	if(dp[x]>0)
	   return dp[x];
	dp[x]=1;
	for(int i=0;i<g[x].size();i++)
	    dp[x]=dfs(g[x][i])+1;
	 return dp[x];	  
}
int  main()  
{   
    while(~scanf("%d",&n))
    {
    	for(int i=1;i<=n;i++)
    	    g[i].clear();
    	for(int i=1;i<=n;i++)
    	   {
    	   	scanf("%d",&p[i]);
    	   	a[p[i]]=i;
		   }
    	for(int i=1;i<n;i++)
		    if(a[i]<a[i+1])
		       g[a[i]].push_back(a[i+1]);
	//	for(int i=1;i<=n;i++)
	//	   cout<<g[i][0]<<endl; 	       
		memset(dp,0,sizeof dp);   
		int ma=-1;      
    	for(int i=1;i<=n;i++)
		   ma=max(ma,dfs(i));
		//cout<<ma<<endl;   
		printf("%d\n",n-ma);   
	}
      
       
     return 0;     
} 

Measured memory_bytes: 22912
n = int(input())


dp = [-1 for _ in range(90)]

def rec(n):
    if dp[n] != -1:
        return dp[n]
    if n == 0:
        dp[n] = 2
    elif n == 1:
        dp[n] = 1
    else:
        dp[n] = rec(n - 1) + rec(n - 2)
    return dp[n]

print(rec(n))

Measured memory_bytes: 3064
#include<stdio.h>
    int main()
    {
    int s;
    scanf("%d",&s);
    if((s/100==0||s/100>12)&&(s%100==0||s%100>12)){
        printf("NA\n");
    }
    else if(s/100==0||s/100>12){
        printf("YYMM\n");
    }
    else if(s%100==0||s%100>12){
        printf("MMYY\n");
    }
    else printf("AMBIGUOUS\n");
     
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main() {
  int n;
  cin >> n;
  map<int,int> mp;
  rep(i,n){ 
    int a;
    cin >> a;
    mp[a]++;
  }
  
  int ans=0;
  for(auto it:mp){
    if(it.F<=it.S){
      ans += (it.S-it.F);
    } else {
      ans += it.S;
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace contest13
{
    class Program
    {
        static void Main(string[] args)
        {
            Stack<int> car_list = new Stack<int>();
            while (true)
            {
                var read_line_origin = Console.ReadLine();
                if (read_line_origin == null)
                {
                    break;
                }

                //FIFO
                int input = int.Parse(read_line_origin);


                //0なら車をだす
                //それ以外ならスタックに入れる

                if (input == 0)
                {
                    if (car_list.Count == 0)
                    {
                        return;
                    }
                    else
                    {
                        int car = car_list.Pop();
                        Console.WriteLine(car.ToString());
                    }
                }
                else
                {
                    car_list.Push(input);
                }

                

            }
        }
    }
}

Measured memory_bytes: 5900
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

void main()
{
    auto S = readln.chomp.to!(wchar[]);
    auto K = readln.chomp;

    int il;
    for (int i; i < S.length; ++i) {
        if (S[i] == '1') {
            ++il;
        } else break;
    }
    if (il == S.length) {
        writeln(1);
        return;
    } else if (!il) {
        writeln(S[0]);
        return;
    }
    auto n = S[il];

    if (K.length > 3 || K.to!int > il) {
        writeln(n);
    } else {
        writeln("1");
    }
}

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

int main(){
  int n, m;
  int temp;
  cin >> n >> m;
  priority_queue<int> price;
  for (int i = 0; i < n; i++){
    cin >> temp;
    price.push(temp);
  }
  for (int i = 0; i < m; i++){
    temp = price.top() / 2;
    price.pop();
    price.push(temp);
  }
  long long sum = 0LL;
  while(!price.empty()){
    sum += (long long)price.top();
    price.pop();
  }
  cout << sum << endl;
}

Measured memory_bytes: 892
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.stream.IntStream;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String line1 = input.readLine();
        String line2 = input.readLine();

        String[] h1 = line1.split(" ");
        long[] h2 = Arrays.stream(h1).mapToLong(Long::parseLong).toArray();

        String[] s1 = line2.split(" ");
        long[] s2 = Arrays.stream(s1).mapToLong(Long::parseLong).sorted().toArray();

        if(h2[0] > h2[1]){
            for(long i = 1; i < h2[1] +1 ; i++){
                s2[ (int) (h2[0] - i)] = 0;
            }
            long sum = Arrays.stream(s2).sum();
            System.out.println(sum);

        }else{
            System.out.println(0);

        }
    }
}



Measured memory_bytes: 68640
#include <bits/stdc++.h>
    #define int long long
    #define endl '\n'
    #define modulo 1000000007
    using namespace std;
    int power(int x,int y,int m)
        {
        int temp;
        if(y == 0)
        return 1;
        temp = (power(x, y/2,m))%m;
        if (y%2 == 0)
        return ((temp%m)*temp);
        else
        return ((x*temp%m)*temp%m)%m;
        }
    int32_t main()
    {
    iostream::sync_with_stdio(0);
    cin.tie(0);
    long double prob=0.0,d=1.0,realcounter2=0.0;
    int n,m,counter=0,maxer=INT_MIN;
    int realcounter=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
    int ii=i;
    while(ii<m){
    counter++;
    ii*=2;
    }
    maxer=max(maxer,counter);
    realcounter=power(2,maxer,(1e18));
    int newer=maxer-counter;
    int base=1;
    while(newer--){
    base*=2;
    }
    realcounter2+=base;
    counter=0;
    }
    cout<<fixed<<setprecision(12)<<(realcounter2/(realcounter*n));
    return 0;
}


Measured memory_bytes: 256
using System;

namespace abc052
{
    public class Program1
    {
        public static void Main(string[] args)
        {

            int n = Convert.ToInt32(Console.ReadLine());

            int x = n * 800;
            int y = (n / 15) * 200;

            Console.WriteLine((x - y).ToString());
        }
    }
}


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

int main()
{
    int N;
    cin>>N;
    map<int,int> A;
    for(int i=0;i<N;i++){
        int num;
        cin>>num;
        A[num] = i+1;
    }
    //sort(A,A+N);
    for(int i=0;i<N;i++){
        cout<<A[i+1]<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 5504
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ALDS1_5_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Program.PrintKoch(0.0, 0.0, 100.0, 0.0, n);

            Console.WriteLine(string.Format("{0} {1}", 100.0, 0.0));
        }

        private static void PrintKoch(double inpX1, double inpY1, double inpX2, double inpY2, int n)
        {
            double angle = Math.PI / 3.0;

            double midX1 = inpX1 + (inpX2 - inpX1) / 3.0;
            double midY1 = inpY1 + (inpY2 - inpY1) / 3.0;

            double midX3 = inpX1 + (inpX2 - inpX1) * 2 / 3.0;
            double midY3 = inpY1 + (inpY2 - inpY1) * 2 / 3.0;

            double midX2 = midX1 + ((midX3 - midX1) * Math.Cos(angle) - (midY3 - midY1) * Math.Sin(angle));
            double midY2 = midY1 + ((midX3 - midX1) * Math.Sin(angle) + (midY3 - midY1) * Math.Cos(angle));

            
            if (n == 0)
            {
                Console.WriteLine(string.Format("{0} {1}", inpX1, inpY1));
            }
            else if (n > 0)
            {
                Program.PrintKoch(inpX1, inpY1, midX1, midY1, n - 1);
                Program.PrintKoch(midX1, midY1, midX2, midY2, n - 1);
                Program.PrintKoch(midX2, midY2, midX3, midY3, n - 1);
                Program.PrintKoch(midX3, midY3, inpX2, inpY2, n - 1);
            }
        }
    }
}



Measured memory_bytes: 15920
S = str(input())
front = int(S[:2])
back = int(S[2:])
S_list = list(S)

if front > 12 or front == 0:
    if 0 < back <= 12 :
        print("YYMM")
    else:
        print("NA")
elif front <= 12 or front == 0:
    if 0 < back <= 12: 
        print("AMBIGUOUS")
    else:
        print("MMYY")

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

bool compare(pair<int, int> &x, pair<int, int> &y) {
    if (x.second != y.second) {
        return x.second >  y.second;
    } else {
        return x.first > y.first;
    }
}

void solve() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    vector<pair<int, int>> C(M);

    REP(i, N) cin >> A[i];
    REP(i, M) cin >> C[i].first >> C[i].second;

    sort(A.begin(), A.end(), greater<int>());
    sort(C.begin(), C.end(), compare);

    vector<int> D;
    int ai = 0;
    int ci = 0;
    int cj = 0;
    while (D.size() < N) {
        if (cj == C[ci].first) {
            ci++;
            cj = 0;
        }
        if (A[ai] >= C[ci].second) {
            D.push_back(A[ai]);
            ai++;
        } else {
            D.push_back(C[ci].second);
            cj++;
        }
    }
    
    ll ans = 0; REP(i, N) ans += D[i];
    print(ans);
}

signed main() {
    solve();
}


Measured memory_bytes: 2044
N = int(input())
def dfs(s):
    if int(s) > N:
        return 0
    if (s.count('3')>0)and(s.count('5')>0)and(s.count('7')>0):
        ans = 1
    else:
        ans = 0
    for c in '753':
        ans += dfs(s + c)
    return ans
print(dfs('0'))


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      std::string ss; scan(ss);
      long n = ss.size();
      puts((ss.size() + (ss[0] == ss[n-1] ? 1 : 0)) % 2 == 0 ? "Second" : "First");
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



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

class dice {
public:
	int getTopFace(void);
	void rotate(char dir);
	void setFaceNumber(int *number);
private:
	int face[6];
};

int dice::getTopFace(void) {
	return face[0];
}

void dice::rotate(char dir) {
	int temp;
	switch(dir) {
	case 'N' :
		temp=face[0];
		face[0]=face[1];
		face[1]=face[5];
		face[5]=face[4];
		face[4]=temp;
		break;
	case 'S' :
		temp=face[0];
		face[0]=face[4];
		face[4]=face[5];
		face[5]=face[1];
		face[1]=temp;
		break;
	case 'W' :
		temp=face[0];
		face[0]=face[2];
		face[2]=face[5];
		face[5]=face[3];
		face[3]=temp;
		break;
	case 'E' :
		temp=face[0];
		face[0]=face[3];
		face[3]=face[5];
		face[5]=face[2];
		face[2]=temp;
		break;
	}
}

void dice::setFaceNumber(int *number) {
	for(int i=0; i<6; ++i) {
		face[i]=*(number+i);
	}
}

int main() {
	int num[6];
	string str;
	dice d;
	cin >> num[0] >> num[1] >> num[2] >> num[3] >> num[4] >> num[5] >> str;
	d.setFaceNumber(num);
	for(int i=0; i<(int)str.length(); ++i) {
		d.rotate(str[i]);
	}
	cout << d.getTopFace() << endl;
	return 0;
}

Measured memory_bytes: 3148
n,k, q=map(int,input().split())
N=[0]*n
for i in range(q):
    N[int(input())-1]+=1
for i in range(n):
    N[i]=N[i]+k-q
for i in range(n):
    if(N[i]>0):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 7848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int a[3];
int main(void){
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<a[0]+a[1]<<endl;
    
}


Measured memory_bytes: 3632
s=input()
n=len(s)
Ans=[]
c=0
prev=None
while c<=n-3:
  s1,s2,s3=s[c],s[c+1],s[c+2]
  if s1!=prev:
    Ans.append(c+1)
    c+=1
    prev=s1
  else:
    Ans.append(c+2)
    c+=2
    prev=s1+s2
ans=len(Ans)
if n==1:
  print(1)
elif n==2:
  if s[0]!=s[1]:
    print(2)
  else:
    print(1)
elif n-Ans[-1]==3:
  s1,s2,s3=s[-3],s[-2],s[-1]
  if prev!=s1:
    if s1!=s2:
      if s2!=s3:
        print(ans+3)
      else:
        print(ans+2)
    else:
      print(ans+2)
  elif s2!=s3:
    print(ans+2)
  else:
    print(ans+1)
elif n-Ans[-1]==2:
  s1,s2=s[-2],s[-1]
  if prev!=s1 and s1!=s2:
    print(ans+2)
  else:
    print(ans+1)
else:
  print(ans+1)

Measured memory_bytes: 11112
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;


int main() {
    int n; cin >> n;
    vector<string> s(n);
    vector<int> t(n);

    int ans = 0;
    for (int i=0; i<n; i++) {
        cin >> s[i] >> t[i];
    }

    string key; cin >> key;

    bool calc = false;
    for (int i=0; i<n; i++) {
        if (s[i] == key) {
            calc = true;
            continue;
        }

        if (calc) ans += t[i];
    }

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



Measured memory_bytes: 888
#include<stdio.h>
int main(void){
	int a[101],b[101],n,i;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%d",&a[i]);
	}
	for(i = 0;i < n;i++){
		b[i] = a[n-(i+1)];
	}
	for(i = 0;i < n;i++){
		printf("%d",b[i]);
		if(i != n-1){
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
F = [LIST() for _ in range(N)]
P = [LIST() for _ in range(N)]

ans = -INF
for i in range(1, 1<<10):
	i = "{:b}".format(i).zfill(10)
	tmp = 0
	for j in range(N):
		cnt = 0
		for k in range(10):
			if int(i[k]) and F[j][k]:
				cnt += 1
		tmp += P[j][cnt]
	ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 3944
input = input()

pattern = []

for i in range(len(input) - 2) :
  temp = int(input[i]) * 100 + int(input[i+1]) * 10 + int(input[i+2])
  pattern.append(temp)

result = 10000

for i in pattern:
  hoge = abs(753 - i)
  if hoge < result:
    result = hoge
    
print(result)

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORE(i, a, b) for (int i = (a); i <= (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(v) (v).begin(), (v).end()
#define sp cout << fixed << setprecision(10)
typedef pair<int, int> P;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

    int n;
    cin >> n;
    int p[n];
    rep(i, n) cin >> p[i];

    int cnt = 0;
    int min = inf;
    rep(i, n) {
        if (p[i] < min) {
            min = p[i];
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

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

    for (int i=0; i<3; ++i) {
        int h1, m1, s1, h2, m2, s2;
        cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;
        int t = (h2 * 3600 + m2 * 60 + s2) - (h1 * 3600 + m1 * 60 + s1);
        cout << t / 3600 << " " << (t % 3600) / 60 << " " << (t % 60) << endl;
    }
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    string s; cin >> s;
    int cnt0 = 0,cnt1 = 0;
    for(char ch : s) {
        if(ch == '0') cnt0++;
        else cnt1++;
    }
    cout << min(cnt0, cnt1) * 2 <<'\n';
}

Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007

int main() {
  int N, D;
  cin >> N >> D;
  int d = 2 * D + 1;
  cout << (N + d - 1) / d << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9;
const int ZERO = 0;
const int MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

signed main() {
    string S;
    cin >> S;
    int ret = 0;
    for(int i = 0;i < S.size() / 2;i++) {
        if(S.at(i) != S.at(S.size() - 1 - i)) {
            ret++;
        }
    }
    cout << ret << endl;
}

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

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

  int ans = 0;
  for (int i = 0; i + 1 < S.size(); i++) {
    if (S[i] != S[i + 1]) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

void solve(istream &cin) {
    ll N;
    if (!(cin >> N)) { return; }
    double X;
    cin >> X;
    cout << N / X << endl;


}

int main(int argc, char *argv[]) {
    cout << setprecision(16) << scientific;
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    while (cin) { solve(cin); }
}


Measured memory_bytes: 256