akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <climits>
struct ValueCostPair {
	int value{ 0 }, cost{ 0 };
};
void setValueCostPair(const ValueCostPair item, std::vector<int> &memo) {
	//memo[value] :=> value時の最小コスト
	int g = memo.size(); int i = g - 1;
	for (; i >= g - item.value && i >= 0; --i) {
		if (memo[i] != INT_MAX && memo[g - 1] > memo[i] + item.cost) {
			memo[g - 1] = memo[i] + item.cost;
		}
	}
	for (; i >= 0; --i) {
		if (memo[i] != INT_MAX && memo[i + item.value] > memo[i] + item.cost) {
			memo[i + item.value] = memo[i] + item.cost;
		}
	}
}
void setItems(int value, int count, std::vector<int> &memo) {
	for (int i = 1; i < count; i <<= 1) {
		setValueCostPair({ value * i, i }, memo);
		count -= i;
	}
	auto rest = count;
	setValueCostPair({ value * rest, rest }, memo);
}
struct Prob {
	int size, value, bornus;
	int allScore() const {
		return size * value + bornus;
	}
};
int main() {
	long long int d, g; std::cin >> d >> g; g /= 100;
	std::vector<Prob> prob(d);
	for (auto i = 0; i < d; ++i) {
		prob[i].value = i + 1;
		std::cin >> prob[i].size >> prob[i].bornus;
		prob[i].bornus /= 100;
	}
	std::vector<std::vector<int>> memo(d + 1, std::vector<int>(g + 1, INT_MAX));
	memo[0][0] = 0;
	for (auto i = 1; i <= d; ++i) {
		memo[i] = memo[i - 1];
		setItems(prob[i - 1].value, prob[i - 1].size, memo[i - 1]);
		setValueCostPair({ prob[i - 1].allScore(), prob[i - 1].size }, memo[i]);
	}
	for (auto i = 0; i <= d; ++i) {
		for (auto j = g; j > 0; --j) {
			if (memo[i][j - 1] > memo[i][j]) memo[i][j - 1] = memo[i][j];
		}
	}
	int sum = 0;
	long long int sumCost = 0;
	for (int i = d - 1; i > 0; --i) {
		sum += prob[i].allScore();
		sumCost += prob[i].size;
		if (sum > g && memo[i - 1][g] > sumCost) {
			memo[i - 1][g] = sumCost;
		}
		else if (sum <= g && memo[i - 1][g] > memo[i - 1][g - sum] + sumCost) {
			memo[i - 1][g] = memo[i - 1][g - sum] + sumCost;
		}
	}
	int min = INT_MAX;
	for (auto i = 0; i <= d; ++i) {
		if (memo[i][g] < min) min = memo[i][g];
	}
	std::cout << min << std::endl;
}



Measured memory_bytes: 5248
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, A[1111][1111], a[1111] = {0}, c = 0, d = 1;

  std::cin >> N;

  for (int i = 0; i < N; i ++)
    for (int j = 0; j < N - 1; j ++) {
      std::cin >> A[i][j];

      A[i][j] --;
    }

  std::set<std::pair<int, int>> set;

  for (int i = 0; i < N; i ++) {
    int x = A[i][0], y = A[x][0];

    if (y == i) {
      if (x > y)
        std::swap(x, y);
    
      set.emplace(x, y);
    }
  }

  for ( ; ; d ++) {
    if (set.empty()) {
      std::cout << -1 << std::endl;

      return 0;
    }

    std::vector<std::pair<int, int>> add;

    while (! set.empty()) {
      auto it = std::begin(set);
      
      auto pair = *it;

      set.erase(it);

      a[pair.first ] ++;

      if (a[pair.first] < N - 1) {
        int x = A[pair.first][a[pair.first]], y = A[x][a[x]];

        if (y == pair.first) {
          if (x > y)
            std::swap(x, y);

          add.emplace_back(x, y);
        }
      }
      else {
        c ++;
      }
      
      a[pair.second] ++;
      
      if (a[pair.second] < N - 1) {
        int x = A[pair.second][a[pair.second]], y = A[x][a[x]];

        if (y == pair.second) {
          if (x > y)
            std::swap(x, y);
          
          add.emplace_back(x, y);
        }
      }
      else {
        c ++;
      }
    }

    for (const auto& pair : add)
      set.insert(pair);

    if (c == N)
      break;

  }

  std::cout << d << std::endl;

  return 0;
}


Measured memory_bytes: 4608
#include <stdio.h>

int gcd (int,int);

int main(){
  int x,y,d,h=0;

  scanf("%d %d",&x,&y);
 /* for(d=1;d <= x;d++){
    if(x%d == 0 && y%d == 0){
      if(h < d) h = d;
    }
    }*/
  
  h=gcd(x,y);
  
  printf("%d\n",h);
  return 0;
}

int gcd(int x,int y){
  int tmp,r;
  

  if(x<y){
    tmp = x;
    x = y;
    y = tmp;
  }
 
  
  r = x % y;
  while(r!=0){
    x = y;
    y = r;
    r = x % y;
  }
 

  
 
  return y;
}



Measured memory_bytes: 2108
#include<stdio.h>

int main(void)
{
  int a,b,k;
  scanf("%d%d%d",&a,&b,&k);

  int i,ans=0;
  for(i=a;i<b+1;i++)
    if((i<a+k)||(i>b-k))
      printf("%d\n",i);

  return 0;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    if(a>=10 || b>=10) cout << "-1" << endl;
    else cout << a*b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    int N,Y;

    cin >> N >> Y;
    int x = -1 , y = -1, z = -1;

    for(int a = 0; a <= N; a++)
    {
        for(int b = 0; b <= N - a; b++)
        {
            int c = N - a - b;
            int total = 10000 * a + 5000 * b + 1000 * c;
            if(total == Y)
            {
                x = a;
                y = b;
                z = c;
            }
        }
    }

    cout << x << " " << y << " " << z << endl;
    
    return 0;    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    int numEastRhs = 0;
    for(auto c : s)
    {
        if (c == 'E')
        {
            numEastRhs += 1;
        }
    }
    int ans = n;
    int numEastLhs = 0;
    for(int i = 0; i < n; ++i)
    {
        char c = s[i];
        if ( c == 'E' )
        {
            numEastRhs -= 1;
        }

        int nShouldMoveRight = numEastRhs;
        int nShouldMoveLeft  = i - numEastLhs;
        ans = min(ans, nShouldMoveLeft + nShouldMoveRight);
        if (c == 'E')
        {
            numEastLhs += 1;
        }
    }
    cout << ans << endl;
}

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

r,c,m=map(int,input().split())
q=set(tuple(map(lambda x :int(x)-1,input().split())) for _ in range(m))
rows = [0]*r
cols = [0]*c

for i,j in q:
    rows[i]+=1
    cols[j]+=1

MAXR = max(rows)
MAXC = max(cols)

ans = MAXR+MAXC-1

rlist=[]
clist=[]

for i in range(r):
    if rows[i]==MAXR:
        rlist.append(i)

for j in range(c):
    if cols[j]==MAXC:
        clist.append(j)
   
for i in rlist:
    for j in clist:
        if (i,j) in q:
            continue
        else:
            ans+=1
            print(ans)
            sys.exit()
print(ans)




    


Measured memory_bytes: 83668
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans = 0;
    rep(si,h)rep(sj,w){
            if(s[si][sj]=='#') continue;
            vector<vector<int>> dist(h, vector<int>(w, INF));
            //配列に初期値 vector<型>(要素数,初期値)
            queue<P> q;
            auto update = [&](int i, int j, int x){
                if(dist[i][j]!= INF) return;
                dist[i][j] = x;
                q.emplace(i,j); //push(P(i,j))
            
            };
            update(si,sj,0);
            while(!q.empty()){ 
                //qが空になるまで
                int i = q.front().first;
                int j = q.front().second;
                q.pop(); //ないとずっと回り続ける
                rep(dir,4){
                    int ni = i + di[dir];
                    int nj = j + dj[dir];
                    if(ni<0 || ni>=h || nj<0 || nj>w) continue;
                    if(s[ni][nj]=='#') continue;
                    update(ni, nj, dist[i][j]+1);
                }
            }
            rep(i,h)rep(j,w){
                if(dist[i][j] == INF) continue;
                ans = max(ans, dist[i][j]);

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


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

using namespace std;

vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+1, vector<int>(10, n));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 10; ++j) res[i][j] = res[i+1][j];
        res[i][S[i]-'0'] = i;
    }
    return res;
}

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


    // 前処理配列
    vector<vector<int> > next = calcNext(s);

    // DP
    vector<vector<long long>> dp(4, vector<long long> (n+1, 0));
    dp[0][0] = 1; // 初期化、空文字列 "" に対応
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 10; ++j) {
            if (next[i][j] >= n) continue; // 次の文字 j がもうない場合はスルー
            for (int k=0; k<3; k++)
                dp[k+1][next[i][j] + 1] += dp[k][i];
        }
    }

    // 集計
    long long res = 0;
    for (int i = 0; i <= n; ++i) res += dp[3][i];

    cout << res << endl;
    return 0;
}

//int main() {
//    int n;
//    string s;
//    map<string,bool> mp;
//    cin >> n >> s;
//
//    for (int i=0; i<(1<<n); i++) {
//        string t = "";
//        for (int j=n-1; j>=0; j--) {
//            if (t.size() >= 3) break;
//            if ((i>>j)&1) {
//                t += s[n-j-1];
//            }
//        }
//        if (t.size() == 3)
//            mp[t] = true;
//    }
//    for (auto p : mp) {
//        cout << p.first << " " << p.second << endl;
//    }
//    cout << mp.size() << endl;
//    return 0;
//}
/*
 * 123123
 * 112
 */

Measured memory_bytes: 3584
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer return cout << "NO", 0;
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 4e5 + 200;
const long long MNN = 4e2 + 200;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int n, k, a[MXN], dp[MXN];

int main () {
    ios;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> a[i];
    dp[0] = 0;
    for(int i = 0; i < k; i++){
        for(int j = 1; j <= n; j++){
            dp[i + a[j]] |= (dp[i] ^ 1);
        }
    }
    if(dp[k]) cout << "First";
    else cout << "Second";
}


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

using namespace std;

int main() {

    int A, B;
    cin >> A >> B;

    if(A >= 13) {
        cout << B << endl;
    }
    else if(A >= 6) {
        cout << (B / 2) << endl;
    }
    else {
        cout << "0" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define rint register int
#define INF ((1 << 30) - 1)
#define FI(n) FastIO::read(n)
#define FO(n) FastIO::write(n)
#define Pair pair < int, int >
#define mst(a,b) memset(a,b,sizeof(a))
#define foR(i, k, j) for(rint i = (k); i >= (j); i--)
#define For(i, k, j) for(rint i = (k); i <= (j); i++)
#define Foe(i, u) for(rint i = lst[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout)
#define ull unsigned ll
const int P = 998244353; //
using namespace std;
inline void ckmax(int &a, int b) {a = max(a, b);}
inline void ckmin(int &a, int b) {a = min(a, b);}
inline void mulmod(int &a, int b) {a = 1ll * a * b % P;}
inline void addmod(int &a, int b) {int t = a + b; a = (t >= P ? t - P : t); }
inline int ksm(int a, int b) {int ans=1; for(;b;b>>=1) {if(b&1) ans=1ll*ans*a%P;a=1ll*a*a%P;}return ans;}
inline int inv(int a) {return ksm(a, P-2);}

inline void printarray(int *a, int n) {For(i, 1, n) fprintf(stderr, "%d ", a[i]); fprintf(stderr, "\n");}
namespace FastIO {
    const int SIZE=1<<16; char buf[SIZE], obuf[SIZE], str[64]; int bi=SIZE, bn=SIZE, opt;
    int read(char *s) {
        while (bn) {for (;bi<bn&&buf[bi]<=' ';bi++);if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}
        int sn=0;while (bn) {for (;bi<bn&&buf[bi]>' ';bi++) s[sn++]=buf[bi];if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}s[sn]=0;return sn;
    }
    bool read(int& x) {if(x)x=0;int bf=0,n=read(str); if(!n) return 0; int i=0; if (str[i]=='-') bf=1,i=1; for(x=0;i<n;i++) x=x*10+str[i]-'0'; if(bf) x=-x; return 1;}
    void write(int x) {
        if(!x) obuf[opt++] = '0'; else {if(x<0) obuf[opt++]='-',x=-x;int sn=0; while(x)str[sn++]=x%10+'0',x/=10;for (int i=sn-1;i>=0;i--) obuf[opt++]=str[i];}
        if (opt>=(SIZE>>1)){fwrite(obuf, 1, opt, stdout); opt=0;}
    }
    void write(char x) {obuf[opt++]=x;if (opt>=(SIZE>>1)){fwrite(obuf, 1, opt, stdout); opt=0;}}
    void Fflush() { if (opt) fwrite(obuf, 1, opt, stdout); opt=0;}
};
const int MAXN = 3e3 + 5;
int A, B, C, D, f[MAXN][MAXN];
int mul(int a, int b) {
	return 1ll * a * b % P;
}
signed main()
{
    #ifndef ONLINE_JUDGE 
        file("pro");
    #endif
    cin >> A >> B >> C >> D;
	f[A][B] = 1;
	For(i, 1, C) {
		For(j, 1, D) {
			if(i == A && j == B) continue;
			f[i][j] = ((mul(f[i-1][j], j) + mul(f[i][j-1], i) - mul(mul(f[i-1][j-1], i-1), j-1)) % P + P) % P;
		}
	}
	cout << f[C][D] << endl;
    return FastIO::Fflush(), 0;
}
/*
Think twice :
mod ?
INF ?
n = 1 ?
long long ?
Fastio::Fflush() ?
*/


Measured memory_bytes: 38808
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n;cin >> n;
  string s;cin >> s;
  rep(i,s.size()){
    int x = s[i]-'A';
    x = (x+n)%26;
    char c = 'A'+x;
    s[i] = c;
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 256
//g++  5.4.0

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

#define ff first
#define ss second
#define int long long
#define ld long double
#define pb push_back
#define pii pair< int,int >
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;



signed main()
{
    fast;
    int n;
    cin >> n ;
    vector<int> a(n+1,0) ;
    for(int i=1 ; i<=n ; i++ )
    {
        cin >> a[i];
        a[i] += a[i-1];
    }
    int dp[n+1][n+1];
    memset( dp,0,sizeof(dp) );
    
    for(int i=1 ; i<=n ; i++ )
        dp[i][i] = a[i]-a[i-1];
    
    for(int len=2 ; len<=n ; len++ )
    {
        for(int st=1 ; st+len-1<=n ; st++ )
        {
            int i = st;
            int j = st+len-1;
            dp[i][j] = max( -a[i-1] + a[j] - dp[i+1][j] , a[j] - a[i-1] - dp[i][j-1] );
        }
    }
    //cout << dp[1][n] << "\n";
    cout << dp[1][n] - ( a[n]-dp[1][n] ) << "\n";
}





Measured memory_bytes: 70656
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

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

template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define F0Rd(i,a) for (int i = a - 1; i >=0 ; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'

const int MXN = 1e5 + 5;
const ll MOD = 998244353;
const ll INF = 1000000007;



string alph = "abcdefghinklmnopqrstuvwxyz";


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	//ifstream cin("/Users/konwoo/input.txt");
	//ofstream cout("/Users/konwoo/output.txt");

	char c;
	cin >> c;
	cout << alph[c-'a'+1] << newl;






















	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using T = tuple<int, int, int>;

struct UnionFind{
    vector<int> par, sz;
    vector<long long> sum;
    UnionFind(){}
    UnionFind(int n, vector<long long> x):par(n), sz(n, 1), sum(x){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){
        if(x == par[x]) return x;
        return find(par[x]);
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return;
        if(sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        sum[x] += sum[y];
        par[y] = x;
    }
    void split(int x, int y){
        sz[x] -= sz[y];
        sum[x] -= sum[y];
        par[y] = y;
    }
};

struct edge{
    int u, v, w;
    bool operator<(const edge &e) const{
        return w < e.w;
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    vector<long long> x(n);
    for(int i = 0; i < n; i++) cin >> x[i];
    UnionFind uf(n, x);
    vector<edge> es(m);
    for(int i = 0; i < m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        es[i] = {u - 1, v - 1, w};
    }
    sort(es.begin(), es.end());

    vector<T> h;
    for(auto e : es){
        int u = uf.find(e.u);
        int v = uf.find(e.v);
        if(u == v) continue;
        if(uf.sz[u] < uf.sz[v]) swap(u, v);
        uf.unite(u, v);
        h.push_back(T(u, v, e.w));
    }
    reverse(h.begin(), h.end());
    for(auto e : h){
        int u, v, w;
        tie(u, v, w) = e;
        int p = uf.find(u);
        if(uf.sum[p] >= w) continue;
        uf.split(u, v);
    }
    int ans = 0;
    for(auto e : es){
        int p = uf.find(e.u);
        if(uf.sum[p] >= e.w) ans++;
    }
    cout << m - ans << endl;
}

Measured memory_bytes: 6128
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int main()
{
    int a, b, c, x, y;

    scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);

    int ans = max({ a,b,c }) * (x + y) + 1;

    for (int ab = 0; ab <= max(x, y); ab++)
    {
        int now = c * 2 * ab + max(0, x - ab) * a + max(0, y - ab) * b;

        ans = min(now, ans);
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
typedef long long int ll;
int main()
{

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


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

/*
 
 ######.
 #......
 ######.
 #......
 ######.
 
 */

int board[100][100];

void printb() {
    REP(i,100) {
        REP(j,100) {
            if (board[i][j]) {
                cout << "#";
            } else {
                cout << ".";
            }
        }
        cout << endl;
    }
}

int main() {
    REP(i,100) {
        if (i % 2 == 0) {
            REP(j,99) board[i][j] = 1;
        } else {
            board[i][0] = 1;
        }
    }
//    printb();
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    cout << 100 << " " << 100 << endl;
    int x = 1, y = 2;
    while (a) {
        board[x][y] = 1;
        if (y > 40) {
            y = 2;
            x += 2;
        } else {
            y += 2;
        }
        a--;
    }
    
    x = 0; y = 97;
    while (b) {
        board[x][y] = 0;
        if (y < 50) {
            y = 97;
            x += 2;
        } else {
            y -= 2;
        }
        b--;
    }
    printb();
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;


const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    
    COMinit();
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    long long int ans = 0;
    for (int i = 0; i < h - a; i++) {
        ans = (ans+COM(i+b-1, i) * COM(h-i-1+w-b-1,w-b-1) % MOD)%MOD;
    }
    cout << ans;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int R; cin >> R;
    if(R < 1200) cout << "ABC";
    else if(R < 2800) cout << "ARC";
    else cout << "AGC";
    cout << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

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

    for (int i = 1; i <= B; i++) {
        if ((A*i)%B == C){
            cout << "YES" << endl; 
            return 0;
        }
    }

    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int main(){
    string s;
    cin >> s;
    ll n = s.length();
    ll a[26] = {};
    REP(i,n){
        a[s[i]-'a']++;
    }
    ll ans = n * (n-1) / 2 + 1;
 
    REP(i,26){
        ans -= a[i] * (a[i] - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N;
  double maxn;
  cin >> N;
  double a[N];
  
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
   sort(a,a+N);

   maxn = (a[0]+a[1])/2;
   
  for(int i=1;i<N-1;i++){
    maxn = (maxn+a[i+1])/2;
    }
  cout << maxn << endl;
}


Measured memory_bytes: 256
from sys import stdin

def main():
    S = int(input())

    n1, n2 = divmod(S, 100)
    flag = [0, 0]
    if 0 < n1 <= 12:
        flag[0] = 1
    if 0 < n2 <= 12:
        flag[1] = 1

    if sum(flag) == 1:
        if flag[0]:
            print('MMYY')
        else:
            print('YYMM')
    elif sum(flag) == 0:
        print('NA')
    else:
        print('AMBIGUOUS')

input = lambda: stdin.readline()
main()


Measured memory_bytes: 3060
#include<stdio.h>

int main(){
  int i, b, st = 0;
  for ( i = 0; i < 3; i++ ){
    scanf("%d", &b);
    if ( b == 1 ) st += (1<<i);
  }
  if ( st >= 3 ) printf("Open\n");
  else printf("Close\n");
  return 0;
}



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

using namespace std;

const int MOD = 1000 * 1000 * 1000 + 7;

int sub(int a, int b)
{
	return (1LL * a - b + MOD) % MOD;
}

int mul(int a, int b)
{
	return (1LL * a * b) % MOD;
}

int pow(int x, int n)
{
	if (n == 0) {
		return 1;
	}
	else if (n % 2 == 0) {
		int t = pow(x, n / 2);
		return mul(t, t);
	}
	else {
		return mul(x, pow(x, n - 1));
	}
}

vector<int> make_f(int n)
{
	vector<int> f(n + 1);
	f[0] = 1;
	for (int i = 1; i <= n; ++i) {
		f[i] = mul(f[i - 1], i);
	}
	return f;
}

vector<int> make_inv(const vector<int> &v)
{
	vector<int> a;
	for (auto x : v) {
		a.push_back(pow(x, MOD - 2));
	}
	return a;
}

int main()
{
	int n;
	cin >> n;
	vector<int> a(n + 1);
	for (auto &a_i : a) {
		cin >> a_i;
		--a_i;
	}
	int l, r;
	vector<bool> used(n, false);
	for (r = 0; !used[a[r]]; ++r) {
		used[a[r]] = true;
	}
	l = find(a.begin(), a.end(), a[r]) - a.begin();

	auto f = make_f(n + 1);
	auto f_inv = make_inv(f);

	auto c = [&f, &f_inv](int n, int r) {
		if (n < r) {
			return 0;
		}
		return mul(f[n], mul(f_inv[n - r], f_inv[r]));
	};

	for (int k = 1; k <= n + 1; ++k) {
		int ans = sub(c(n + 1, k), c(l + n - r, k - 1));
		cout << ans << endl;
	}
}


Measured memory_bytes: 2556
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n; cin >> n;
  vector<long long> a(n);
  vector<long long> s(n); // 累積和
  for(int i=0;i<n;i++) cin >> a[i];
  s[0] = a[0];
  for(int i=1;i<n;i++){
    s[i] = s[i-1] + a[i];
  }
  long long ans = abs(s[0]*2 - s[n-1]);
  // 両者とも1枚はとらなければならない
  for(int i=0;i<n-1;i++){
    ans = min(ans,abs(s[i]*2 - s[n-1]));
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define F first
#define S second
using namespace std;

int Q = 1e7, h1, h2, cut = 5;
int n, s, D, l, r, up, mx, cnt, mxx, xx, a[30], b[400][30], la[400], u[400], ans[400], o[400];
pair<int, int> c[400][30];
bool v[400][30];

int f(int p, int q1, int q2) {
	int sz = q2 - q1 + 1;
	return p * sz * (sz + 1) / 2;
}

int main()
{
	int i, j, k, t, x, t1, t2;
	srand(time(NULL));
	cin >> D;
	for (i = 0; i < 26; i++) {
		scanf ("%d", &a[i]);
	}
	for (i = 1; i <= D; i++) {
		mxx = -2e9;
		for (j = 0; j < 26; j++) {
			scanf ("%d", &b[i][j]);
		}
		for (j = 0; j < 26; j++) {
			cnt = b[i][j];
			for (k = 0; k < 26; k++) {
				if (k == j) continue;
				cnt -= (i - o[k]) * a[k];
			}
			if (cnt > mxx) {
				xx = j;
				mxx = cnt;
			}
		}
		o[xx] = i;
		ans[i] = u[i] = xx;
	}
//	for (i = 1; i <= D; i++) {
//		ans[i] = u[i] = 1;
//	}
//	for(i = 1; i <= D; i++) {
//		printf("%d\n", ans[i] + 1);
//	}

	for (i = 1; i <= D; i++){
//		scanf ("%d", &t);
		t = u[i];
		s += b[i][t];
		la[t] = i;

		for (j = 0; j < 26; j++) {
			s -= a[j] * (i - la[j]);
		}
		v[i][t] = 1;
	}
//	cout << s << endl;
//	cin >> Q;
	for (i =0; i < 26; i++) {
		v[0][i] = 1;
		v[D + 1][i] = 1;
	}
	mx = s;
	while (Q--) {
//		scanf ("%d %d", &t1, &t2);
		t1 = rand() % D + 1;
		t2 = rand() % 26;
		if (u[t1] == t2) t2 = (t2 + 1) % 26;
		x = u[t1];
		s -= b[t1][x];
		v[t1][x] = 0;
		v[t1][t2] = 1;
		u[t1] = t2;
		s += b[t1][t2];
		for (l = t1 - 1; l >= 0; l--) if (v[l][x]) break;
		for (r = t1 + 1; r <= D + 1; r++) if (v[r][x]) break;
		s += f(a[x], l + 1, t1 - 1);
		s += f(a[x], t1 + 1, r - 1);
		s -= f(a[x], l + 1, r - 1);
		for (l = t1 - 1; l >= 0; l--) if (v[l][t2]) break;
		for (r = t1 + 1; r <= D +1; r++) if (v[r][t2]) break;
		s += f(a[t2], l + 1, r - 1);
		s -= f(a[t2], l + 1, t1 - 1);
		s -= f(a[t2], t1 + 1, r - 1);
		if (s > mx) {
			up = 0;
			for (i = 1; i <= D; i++) {
				ans[i] = u[i];
			}
			mx = s;
		} else up++;
		if (up == cut) {
			up = 0;
			memset(v, 0, sizeof(v));
			for (i =0; i < 26; i++) {
				v[0][i] = 1;
				v[D + 1][i] = 1;
			}
			for (i = 1; i <= D; i++) {
				u[i] = ans[i];
				v[i][ans[i]] = 1;
			}
			s = mx;
		}
	}
	for (i = 1; i <= D; i++) {
		printf("%d\n", ans[i] + 1);
	}
    return 0;
}


Measured memory_bytes: 3868
listA = list(input())
listA = list(map(int,listA))
A,B,C,D = listA
s1,s2,s3 = 0,0,0
for i in range(2):
    for j in range(2):
        for k in range(2):
            total = 0
            if i == 0:
                s1 = "-"
                total = A - B
            else:
                s1 = "+"
                total = A + B
            if j == 0:
                s2 = "-"
                total = total - C
            else:
                s2 = "+"
                total = total + C
            if k == 0:
                s3 = "-"
                total = total - D
            else:
                s3 = "+"
                total = total + D
            if total == 7:
                print(str(A)+s1+str(B)+s2+str(C)+s3+str(D)+"=7")
                exit()

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        int seven = 0;
        long count = 1;
        if(K%2 != 0 && K%5 != 0){
            while(true){
                seven = (10*seven + 7) % K;
                if(seven == 0){
                  System.out.println(count);
                  return;
                } 
                count++;
            }
        }
        System.out.println("-1");
    }
}

Measured memory_bytes: 35812
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
 
  val nums = inputs.head.split(" ").map(_.toLong)
  val a = nums(0)
  val b = nums(1)
  val x = nums(2)

  println(solve(a, b, x))

  private def solve(a: Long, b: Long, x: Long): Long = {
    val sur = a % x
    val firstDiv = a + (x - sur) % x

    if (b < firstDiv) {
      return 0
    }

    return (b - firstDiv) / x + 1
  }
}

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

using namespace std;

int N, A, B, C;
vector<int> bamboo;

int dfs(int n, int a, int b, int c) {
  if (n == N) {
    return min(a, min(b, c)) > 0 ? abs(A - a) + abs(B - b) + abs(C - c) - 30 : 0x7FFFF;
  }
  
  return min(dfs(n + 1, a, b, c),
         min(dfs(n + 1, a + bamboo[n], b, c) + 10,
         min(dfs(n + 1, a, b + bamboo[n], c) + 10,
             dfs(n + 1, a, b, c + bamboo[n]) + 10)));
}

int main() {
  cin >> N >> A >> B >> C;
  
  for (int i = 0; i < N; i++) {
    int in;
    
    cin >> in;
    
    bamboo.push_back(in);
  }
  
  int result = dfs(0, 0, 0, 0);
  
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
#define pb push_back
 const ll mod = 1000000007;

int main() {
	int N;
	cin >> N;
	vector<int> D;
	for (int i = 0; i < N; i++) {
		int d;
		cin >> d;
		D.push_back(d);
	}
	sort(D.begin(), D.end());

	if (N % 2 == 1) {
		cout << 0 << endl;
		return 0;
	}

	int ans = D[N / 2] - D[N / 2 - 1];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 892
BTCIN = 'BTC'
BTCTAN = 380000.0
inNinzu = int(input())
okaneList = [[0 for i in range(2)] for j in range(inNinzu)]
okaneAns = 0.0
for i in range(0, inNinzu):
    inOkane = input().split(' ')
    if inOkane[1] == BTCIN:
        okaneAns += float(inOkane[0]) * BTCTAN
    else:
        okaneAns += float(inOkane[0])

print(okaneAns)


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

typedef long long ll;
typedef vector<int> vi;

const int M = 1000000007, BIG = 0x3f3f3f3f;

string s;
int n;

int Process() {
  n = s.length();
  int ans = 0;
  int streak = 0;

  for (int i = 0; i < n; i++) {
    if (s[i] == 'R')
      streak++;
    else
      streak = 0;
    ans = max(ans, streak);
  }
  
  return ans;
}

void Output() { cout << Process() << "\n"; }

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

  while (cin >> s)
    Output();

  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  ll n,m,kl;
  cin>>n>>m>>kl;
  ll ans=0;
  ll a[n],b[m];
  rep(i,0,n) cin>>a[i];
  rep(i,0,m) cin>>b[i];
  vector<ll> pre(n+1,0),pre1(m+1,0);
  rep(i,1,n+1) pre[i]=pre[i-1]+a[i-1];
  rep(i,1,m+1) pre1[i]=pre1[i-1]+b[i-1];
  rep(i,0,m+1){
    if(kl<pre1[i]) break;
    ll left=kl-pre1[i];
    ll temp_ans=i;
    ll z=(upper_bound(all(pre),left)-pre.begin());
    temp_ans+=(z-1);
    ans=max(ans,temp_ans);
  }
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


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

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

	int N, M;
	int A[100];
	cin >> N >> M;
	double b = 1/double(4*M);
  	ll total = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
      	total += A[i];
	}
	
	sort(A, A+N, greater<int>());

	string ans = "Yes";
  	
	for (int i = 0; i < M; i++)
	{
		if(A[i]<total*b)ans = "No";
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a>b?b:a)
#define INF 0x3f3f3f3f
#define sz size()
#define pb push_back
#define ph push
#define mem(x, y) memset(x, y, sizeof(x));
#define mem0(x) mem(x,0)
#define mem1(x) mem(x,-1)
#define memINF(x) mem(x,INF)
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define setI freopen("input.txt","r",stdin);
#define setIO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
using namespace std;
typedef long long ll;

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

int const Max_N = 3e3+50;

ll d1[305][305];
ll d2[305][305];
int n;
bool check()
{
    rep(k,1,n+1) rep(i,1,n+1) rep(j,1,n+1)
    {
        d2[i][j] = min(d2[i][k]+d2[k][j],d2[i][j]);
    }
    //rep(i,1,n+1) {rep(j,1,n+1) cout << d2[i][j] << ' '; cout <<endl; }
    rep(i,1,n+1) rep(j,1,n+1) if(d1[i][j]!=d2[i][j]||d1[i][j]!=d1[j][i]) return false;
    return true;
}


int main()
{
    #ifdef Anani_leaf
      setI;
    #endif
    scanf("%d",&n);
    rep(i,1,n+1)rep(j,1,n+1) scanf("%lld",d1[i]+j);
    rep(i,1,n+1)rep(j,1,n+1) d2[i][j] = d1[i][j];
    if(!check())
    {
        printf("-1\n");
        return 0;
    }

   ll ans = 0;
   bool vis[305][305] = {false};
   rep(k,1,n+1) rep(i,1,n+1) rep(j,1,n+1)
    {
        if(d2[i][k]+d2[k][j]==d2[i][j]&&k!=i&&k!=j) vis[j][i] = vis[i][j] = true;
    }
   rep(i,1,n+1) rep(j,i+1,n+1)
   {
       if(!vis[i][j]) ans += d2[i][j];
   }

    printf("%lld\n",ans);

    return 0;
}
    //freopen("in.txt","r",stdin);
//std::ios::sync_with_stdio(false);


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

using namespace std;

int main(){
	string s, t;
	vector<string> sol;
	cin >> s;
	cin >> t;
	int S=s.size(), T=t.size(), u;
	for(int i=0;i<S;i++){
		if(s[i] == t[0] && S-i >= T || s[i] == '?' && S-i >= T){
			u = 1;
			for(int j=0;j<T;j++){
				if(s[i+j] != t[j] && s[i+j] != '?'){
					u=0;
					break;
				}
			}
			if(u){
				string s2="";
				for(int j=0;j<i;j++) s2+=s[j];
				for(int j=i;j<i+T;j++) s2+=t[j-i];
				for(int j=i+T;j<S;j++) s2+=s[j];
				sol.push_back(s2);
				//cout << s2 << endl;
			}
		}
	}
	sort(sol.begin(), sol.end());
	if(sol.size()!=0){
		string s3 = sol[0];
		for(int i=0;i<S;i++){
			if(s3[i] == '?') s3[i] = 'a';
		}
		cout << s3;
	}
	else cout << "UNRESTORABLE";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int n,q;
int find(int u,int v){
	while(u!=v){
		while(u>v)
			u= u%n<=1 ? u/n : u/n+1;
		while(v>u)
			v= v%n<=1 ? v/n : v/n+1;
	}
	return u;
}
int main(){
	scanf("%d%d",&n,&q);
	for(register int i=1;i<=q;++i){
		int u,v;
		scanf("%d%d",&u,&v);
		if(n==1)printf("%d\n",min(u,v));
		else printf("%d\n",find(u,v));
	}
	return 0;
}	


Measured memory_bytes: 1280
#include <iostream>
#include <cstring>
#include <sstream>
#include <cctype>
#include <cmath>
#include <cstdio>
using namespace std;
#define MPI  3.14159265358979323846

struct Dice{
	int num[6];
	void roll(char);
};

void Dice::roll(char c){
	switch (c) {
		int tmp;
	case'N':
		tmp = num[0];
		num[0] = num[1];
		num[1] = num[5];
		num[5] = num[4];
		num[4] = tmp;
		break;
	case'S':
		tmp = num[0];
		num[0] = num[4];
		num[4] = num[5];
		num[5] = num[1];
		num[1] = tmp;
		break;
	case'E':
		tmp = num[0];
		num[0] = num[3];
		num[3] = num[5];
		num[5] = num[2];
		num[2] = tmp;
		break;
	case'W':
		tmp = num[0];
		num[0] = num[2];
		num[2] = num[5];
		num[5] = num[3];
		num[3] = tmp;
		break;
	default:break;
	}
}

int main(){

	Dice Dice1;

	for (int i = 0; i < 6; i++){
		cin >> Dice1.num[i];
	}
	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i++){
		Dice1.roll(s[i]);
	}

	cout << Dice1.num[0] << endl;

	return 0;
}


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

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

  for (int i = 1; i < A * B; i++) {
    if (i * A % B == C) {

      puts("YES");
      return 0;
    } else
      continue;
  }
  puts("NO");
}

Measured memory_bytes: 384
#define MYDEBUG
//
#include <bits/stdc++.h>
#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using namespace std;
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last) {
      out << ",";
    }
  }
  out << "]";
  return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i] << endl;
  }
  return out;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
  out << "{" << p.first << "," << p.second << "}";
  return out;
}

static const int M = 1046597;
static const int L = 12;
char T[M][L];
char com[6], word[L];
int getChar(char ch) {
  if (ch == 'A') {
    return 1;
  } else if (ch == 'C') {
    return 2;
  } else if (ch == 'G') {
    return 3;
  } else {
    return 4;
  }
}

ll getKey(char str[]) {
  ll key = 0, i = 0, p = 1;
  for (i = 0; i < (ll) strlen(str); ++i) {
    key += p * getChar(str[i]);
    key *= 5; //左シフト(5進数)
  }
  return key;
}

int h1(int key) {
  return key % M;
}

//mとh2は互いに素に
int h2(int key) {
  //素数Mより小さい数はみなMと互いに素
  //h2の周期はM未満であればなんでも可
  //1を加えるのはkey%(M-1) == 0のときにずれなくなるため
  //この関数は1 ~ M-1の間の値をとる
  return 1 + (key % (M - 12409));
}

int insert(char str[]) {
  ll key, i, h;
  key = getKey(str);
  for (i = 0;; ++i) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(T[h], str) == 0) {
      return 1; //すでに格納済
    } else if (strlen(T[h]) == 0) {
      strcpy(T[h], str);
      return 0;
    }
  }
  return 0;
}

bool find(char str[]) {
  ll key, i, h;
  key = getKey(str);
  for (i = 0;; ++i) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(T[h], str) == 0) {
      return true;
    } else if (strlen(T[h]) == 0) {
      return false;
    }
  }
  return false;
}

void solve() {
  rep(i,0,M)
  {
    T[i][0] = '\0'; //すべて空文字列で初期化
  }
  int n;
  scanf("%d", &n);
  rep(i,0,n)
  {
    scanf("%s %s", com, word);
    if (com[0] == 'i') {
      insert(word);
    } else {
      if (find(word)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
}
int main() {
  solve();
  return 0;
}



Measured memory_bytes: 15420
f = lambda:map(int,input().split())
n,x = f()
l = [x]+list(f())
m = [abs(l[i+1]-l[i]) for i in range(n)]
def gcd(a,b):
  while b:
    a,b = b,a%b
  return a
ans = m.pop()
for i in m:
  ans = gcd(ans,i)
print(ans)

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

void solve(){
    int k;
    cin>>k;
    vector<ll> a(k);
    rep(i,k) cin>>a[i];
    reverse(all(a));
    if(a[0] != 2) {
        cout<<-1<<endl;
        return;
    }
    ll l=2,r=2;
    rep(i,k){
        if(a[i]>r || l>r) {
            cout<<-1<<endl;
            return;
        }
        if(l%a[i]>0){
            l = l-l%a[i]+a[i];
        }
        r = r-r%a[i]+a[i]-1;
    }
    if(l>r) {
        cout<<-1<<endl;
        return;
    }
    cout<<l<<" "<<r<<endl;
}

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

Measured memory_bytes: 1024
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int n,cnt = 0;
  cin >> n;
  
  if(n < 105){
      cout << 0 << endl;
      return 0;
  }
  
  for(int i = 105;i <= n;i+=2){
      int m = i,tmp = 0;
      for(int j = 3;j <= i;j++){
          if(m % j == 0){
              m /= j;
              tmp++;
          }
      }
      if(tmp == 3) cnt++;
  }
  
  cout << cnt << endl;
  return 0;
}

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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    int n;
    cin >> n;
    vi l(2 * n);
    rep (i, 2 * n) cin >> l[i];
    sort(all(l));

    ll ans = 0;
    for (int i = 0; i < 2 * n; i += 2) ans += l[i];
    cout << ans << endl;
}

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

int yuguri(int,int);

int main(){

  int N;

  cin>>N;

  long long ans=1;
  for(int i=1;i<=N;i++){
    // cout<<yuguri(ans,1000000007)<<endl;
    ans=i*ans%1000000007;
  }

  cout<<ans<<endl;

}


int yuguri(int a,int b){

  int r;
  if(a<b)
  swap(a,b);

  while((r=a%b)){
    a=b;
    b=r;
  }
  return b;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
drink = [list(map(int,input().split())) for _ in range(n)]
drink = sorted(drink, key=lambda drink:drink[0])
money = 0
total = 0
for i in range(n):
  if total+drink[i][1]<m:
    total += drink[i][1]
    money += drink[i][1]*drink[i][0]
  else:
    money += drink[i][0]*(m-total)
    print(money)
    exit()

Measured memory_bytes: 29796