akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=1e6+5;

bool visited[maxn];
int freq[maxn];

void help(int x){
	for (int i = x; i < maxn; i+=x)
	{
		visited[i] = 1;
	}
}

int32_t main(){
    fast_io;
    int n;
    cin>>n;
    set<int>s;
    for (int i = 0; i < n; ++i)
    {
    	int x;
    	cin>>x;
    	s.insert(x);
    	freq[x]++;
    }
    int ans = 0;
    for(auto it:s){
    	if(freq[it] == 1 and !visited[it]) ans++;
    	help(it);
    }
    show(ans);
    return 0;
}

Measured memory_bytes: 16948
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005
ll n,l,a[N];
int main()
{
	ios
	cin>>n>>l;
	ll idx=-1,i,j;
	for(i=1;i<=n;i++){
		cin>>a[i];
		if(i>1&&a[i]+a[i-1]>=l)idx=i-1;
	}
	if(idx==-1)cout<<"Impossible";else{
		cout<<"Possible\n";
		for(i=1;i<idx;i++)cout<<i<<"\n";
		for(i=n-1;i>idx;i--)cout<<i<<"\n";
		cout<<idx;
	}
	
	return 0;
}

Measured memory_bytes: 1664
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
S = list(rs())
ans = 0
cnt = 0
for i in range(len(S)):
    if S[i] == 'B':
        cnt += 1
    if S[i] == 'W':
        ans += cnt
print(ans)


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

int main() {
  int N;
  cin >> N;
  string s, t;
  cin >> s >> t;
  
  for(int i = 0; i < N; i++){
   cout << s.at(i) << t.at(i);
  }
  
  cout << endl;
}


Measured memory_bytes: 3560
#include<iostream>
#include<string>
#include <cmath>
#include <ctype.h>
#include<vector>
#include<algorithm>
using namespace std;
int N;
vector<int> v;
int main() {
    cin >> N;
    for(int i=0; i<N; ++i){
        int a; cin >> a;
        v.push_back(a);
    }
    int point=1, cnt=0;
    bool flag=false;
    for(int i=0; i<N; ++i){
        cnt++;
        point = v[point-1];
        if(point==2) {
            flag=true;
            break;
        }
    }
    if(flag) cout << cnt << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 892
#include <cstdio>
#include <cstdint>
#include <algorithm>

int main() {
  intmax_t n, a, b, c, d, e;
  scanf("%jd %jd %jd %jd %jd %jd", &n, &a, &b, &c, &d, &e);

  intmax_t m = std::min({a, b, c, d, e});
  printf("%jd\n", (n+m-1)/m+4);
}


Measured memory_bytes: 128
S = [int(a) for a in input()[::-1]]
m = 2019
N = len(S)
s = 0
p = 1
X = [0] * 2019
X[0] = 1
ans = 0
for a in S:
    s = (s + a * p) % m
    ans += X[s]
    X[s] += 1
    p = p * 10 % m
 
print(ans)

Measured memory_bytes: 10832
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector< vector< vector<int> > > a(4,vector< vector<int> >(3,vector<int>(10,0)));
  int n;
  cin >> n;
  for (int i = 0; i < n; i++){
    int b, f, r, v;
    cin >> b >> f >> r >> v;
    a[b - 1][f - 1][r - 1] += v;
  }
  for (int i = 0; i < 4; i++){
    for (int j = 0; j < 3; j++){
      for (int k = 0; k < 10; k++){
        cout << ' ' << a[i][j][k];
      }
      cout << endl;
    }
    if (i != 3){
      for (int j = 0; j < 20; j++){
        cout << '#';
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  rep(x, n + 1) {
    if (floor(x * 1.08) == n) {
      cout << x << endl;
      return 0;
    }
  }
  cout << ":(" << endl;


  
  return 0;
}

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

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int height[10];
	for (int i = 0; i < 10; i++)
		cin >> height[i];
	sort(height, height + 10);
	for (int i = 9; i >= 7; i--)
		cout << height[i] << endl;

	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h> 					
using namespace std;	
bool cmp(int a,int b){
	return a>b;
}
int main(void)	
{		long long n,k;
cin>>n>>k;
long long hea[200001];long long ans = 0;
	for(int i=0;i<n;i++){
	cin>>hea[i];
}
if(k>=n){
	

cout<<ans;
	return 0;
}else if(k==0){
	for(int i = 0;i<n;i++){
		ans+=hea[i];
	}
cout<<ans;
	return 0;
}else{
	sort(hea,hea+n,cmp);
for(int i=k;i<n;i++){
	ans+=hea[i];
}	
cout<<ans;	return 0;

}					
return 0;	 									
 } 

Measured memory_bytes: 1792
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    vector<int> d;
    cin >> n;
    int elem;
    F0R(i,n)
    {
        cin >> elem;
        d.pb(elem);
    }
    sort(d.begin(),d.end());
    int i=n/2+1;
    int first=-1;
    while(i<n && d[i]==d[n/2])
        i++;
    if(i<n && d[i]!=d[n/2])
        first=i;
    i=n/2-1;
    int second=-1;
    while(i>=0 && d[i]==d[n/2])
        i--;
    if(i>=0 && d[i]!=d[n/2])
        second=i;
    if(n/2-second!=1) 
    {
        cout << 0;
        return 0;
    }
    // cout << d[n/2-1] << endl;
    // cout << d[n/2] << endl;
    // cout << d[n/2+1] << endl;
    // cout << d[n/2+1]-(d[n/2-1]+1) << endl;
    cout << d[n/2]-(d[second]);

    return 0;
}


Measured memory_bytes: 892
s = input()
li = []
alf = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o",
"p","q","r","s","t","u","v","w","x","y","z"]
for x in alf:
    if x not in s:
        li.append(x)
if li == []:
    print("None")
else:
    print(min(li))

Measured memory_bytes: 39024
N, M = map(int, input().split())
A = [[0, 0] for i in range(M)]

for i in range(M):
    A[i][0], A[i][1] = map(int, input().split())

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

ans = 0
x = 0
for a in A:
    if x < a[0]:
        x = a[1] - 1
        ans += 1
print(ans)


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

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

  int k, x;
  cin >> k >> x;
  int r = min(1000000, x + k - 1);
  int l = max(-1000000, x - (k - 1));
  for (int i = l; i <= r; i++) {
    cout << i;
    char tail = (i == r) ? '\n' : ' ';
    cout << tail;
  }
  return 0;
}

Measured memory_bytes: 256
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn           printf("\n")
#define nl           cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define S       second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define mod     1000000007
#define Inf     1000000000000000
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    string s;
    cin>>s;
    
    lli N=s.length();
    
    cout<<s[0]<<N-2<<s[N-1];
    
    




 return 0;
}


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

class cmp{
public:
  bool operator()(const string &a, const string &b){
    if(a.length() == b.length()){
      return a < b;
    }
    return a.length() < b.length();
  }
};

int main(){
  int n;

  while(cin >> n){
    map<string,int,cmp> mp;

    for(int i = 0; i < n; i++){
      string name;
      int x;
      cin >> name >> x;
      mp[name] += x;
    }
    for(map<string,int>::iterator iter = mp.begin(); iter != mp.end(); iter++){
      cout << (iter->first) << " " << (iter->second) << endl;
    }
  }
}

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

#define N 100
#define Gard 1000000000

int main(){
  int loop,result;
  int h,i,j,k;
  int Matrix[N];
  int Hairetu[N][N];
  
  scanf("%d",&loop);
  for(i=0;i<loop;i++){
    scanf("%d %d",&Matrix[i],&Matrix[i+1]);
  }

  for(i=1;i<=loop;i++){
    Hairetu[i][i]=0;
  }

  for(i=2;i<=loop;i++){
    
    for(j=1;j<=loop-i+1;j++){
      
      k=j+i-1;
      Hairetu[j][k]=Gard;
      
      for(h=j;h<=k-1;h++){
	result=Hairetu[j][h]+Hairetu[h+1][k]+Matrix[j-1]*Matrix[h]*Matrix[k];

	if(Hairetu[j][k]>result){
	  Hairetu[j][k]=result;
	}


	else{
	  Hairetu[j][k]=Hairetu[j][k];
	}
      }
    }
      
  }

  printf("%d\n",Hairetu[1][loop]);
  
 
  return 0;
}



Measured memory_bytes: 2104
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

double N;

double ans = 0;

void solve(){
	ans = N*2*3.14159265358979323846;
}
 
int main(){
    cin >> N;
 
    solve();

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 3192
#include <stdio.h>

int main(void) {
    int x, y;
    while (1) {
        scanf("%d %d", &x, &y);
        if (x == 0 && y == 0) break;
        if (x > y) {
            printf("%d %d\n", y, x);
        } else {
            printf("%d %d\n", x, y);
        }
    }
    return 0;
}


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

int main()
{
  long long N;
  cin >> N;
  
  char name[30] = {0};
  
    
  for (int i = 0; i < 30; i++)
  {
    //cout << N << endl;
    if (N % 26 == 0) 
    {
      name[i] = 'z';
    }
    else
    {
      name[i] = N % 26 + 'a' -1 ;
    }
    
    //cout << name[i];
    
    if (N <= 26)
    {
      break;
    }
    else
    {
      if (name[i] == 'z')
      {
        N -= 26;
      }
      else
      {
        N -= N % 26;
      }
      
      N = N / 26;
      
    }
  }
  
  for (int i = 29; i >= 0; i--)
  {
    if(name[i])
    {
      cout << name[i];
    }
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;


int main(void){
  ll k;
  cin >> k;

  ll t = 0;
  for (ll i = 0; i < k; i++){
    t = (10*t + 7) % k;
    if (t == 0){
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  
  return 0;
}


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

#define dcm(x) cerr << #x << ": " << x << endl;

using namespace std;

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

int main() {
    //clock_t start = clock();
    ios::sync_with_stdio(false); cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s; cin >> s;
    string res;
    for (int i=0; i<s.size(); ++i) {
        if (s[i] == '0') res += "0";
        else if (s[i] == '1') res += "1";
        else if (s[i] == 'B' && res.size() != 0) res.erase(res.size()-1);
    }
    cout << res << endl;
    //clock_t stop = clock();
    //cout << (double)(stop-start)/CLOCKS_PER_SEC << " (s)" << endl;
    return 0;
}


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


using namespace std;

typedef pair<int, int> pii;
#define lp(i, s, e) for (int i = s; i < e; ++i)
#define lpi(i, s, e) for (int i = s;i <= e; ++i)
typedef long long ll;
#define pb push_back


const int maxn = 200;
int dist[maxn][maxn];

char color[maxn];

bool dfs(int v, int n) {
	for (int to = 0; to < n; ++to) {
		if (dist[to][v] == 1e9 || to == v) {
			continue;
		}
		if (color[to] == color[v]) {
			return false;
		}
		if (color[to]) {
			continue;
		}
		color[to] = 3 - color[v];
		if (!dfs(to, n)) {
			return false;
		}
	}
	return true;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
	int n;
	cin >> n;
	lp(i, 0, n) {
		lp(j, 0, n) {
			dist[i][j] = 1e9;
		}
	}
	lp(i, 0, n) {
		dist[i][i] = 0;
	}
	lp(i, 0, n) {
		lp(j, 0, n) {
			char x;
			cin >> x;
			if (x == '1') {
				dist[i][j] = 1;
			}
		}
	}
	color[0] = 1;
	if (!dfs(0, n)) {
		cout << -1;
		return 0;
	}
	lp(i, 0, n) {
		lp(u, 0, n) {
			lp(v, 0, n) {
				dist[u][v] = min(dist[u][v], dist[u][i] + dist[i][v]);
			}
		}
	}
	int ans = 0;
	lp(i, 0, n) {
		lp(j, 0, n) {
			ans = max(ans, dist[i][j]);
		}
	}
	cout << ans + 1;
	return 0;
}


Measured memory_bytes: 384
n=int(input())
a = []

for i in range(n):
  a.append(int(input()))
a.sort()
suma=sum(a)
if suma%10!=0:
  print(suma)
  exit()
else:
  for i in range(n):
    suma=suma-a[i]
    if suma%10!=0:
      print(suma)
      exit()
    else:
      suma=suma+a[i]
print(0)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll x,k,d,ans;
ll absl(ll a)
{
	return a>0?a:-a;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>x>>k>>d;
	ll t=absl(x)/d;
	if(x==0)
	{
		if(k%2==0)cout<<0<<endl;
		else cout<<d<<endl;
		return 0;
	}
	if(t>=k){                                       
		if(x<0)ans=x+d*k;
		else ans=x-d*k;
		ans=absl(ans);
		cout<<ans<<endl;
		return 0;			
	}
	ll r=absl(x)%d;
	if(r==0)
	{
		if((k-t)%2==0)cout<<0<<endl;
		else cout<<d<<endl;
		return 0;
	}
	if(t==k-1){
		ans=d-r;
	}
	if((k-t)%2==0)
	{
		ans=r;	
	}
	else
	{
		ans=d-r;
	}
	cout<<ans<<endl;
	//_+5_+4_+3_+2_+1_0_-1_-2_-3_-4_-5
	return 0;
 } 

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(void)
{
	int q;
	cin >> q;

	int n;
	for(int i = 0; i < q; i++)
	{
		cin >> n;
		
		int counter = 0;

		while(n >= 10)
		{
			int x, max = 0;

			for(int j = 10; j < n; j *= 10)
			{
				x = (n / j) * (n % j);

				if(x >= max)
					max = x;
			}
			n = max;
			counter++;
		}
		cout << counter << endl;
	}

	return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>
#include <cassert>
#include<map>
#include<bitset>

using lli = long long int;
lli inf = 1000000007;
using namespace std;


void solve() {
	int N;
	string S;
	cin >> N >> S;
	lli red = 0, green = 0, blue = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'R')red++;
		else if (S[i] == 'G')green++;
		else if (S[i] == 'B')blue++;
	}
	lli ans = red * green * blue;
	for (int skip = 1; skip < N; skip++) {
		for (int i = 0; i < N; i++) {
			if ((i + skip + skip) >= N)break;
			char si = S[i];
			char sj = S[i + skip];
			char sk = S[i + skip + skip];
			if (si != sj && si != sk && sj != sk) ans -= 1;
		}
	}
	cout << ans << endl;
}

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

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	
	stack<int> s;
	s.push(n);
	
	int a;
	while(cin >> a){
		if(a == 0){
			cout << s.top() << endl;
			s.pop();
		}
		else {
			s.push(a);
		}
	}
	
	return 0;
}

Measured memory_bytes: 1200
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a,b = [0],[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans,j = 0,M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)

Measured memory_bytes: 47312
s = input()

LR = "R"
memo = 0
memo2 = 0 #どこにRLがあるか
ans = [0 for i in range(len(s))]

j = 0
for i in s:
    if (i != LR) and (i == "L"):
        if memo%2 == 0:
            R_num = int(memo/2)
            ans[j] = R_num+1
            ans[j-1] = R_num
            
        elif memo%2 == 1:
            R_num = int(memo/2)
            ans[j] = R_num+1
            ans[j-1] = R_num+1
        
        LR = "L"
        memo2 = j-1
        
        
    elif (i != LR) and (i == "R"):
        LR = "R"
        memo = 1
        
    elif (i == LR) and (i == "L"):
        if ((memo2-j)%2) == 0:
            ans[memo2] += 1
        
        elif ((memo2-j)%2) == 1:
            ans[memo2+1] += 1
                
        
    elif (i == LR) and (i == "R"):
        memo += 1
        
    j += 1
    
    
for i in range(len(s)):
    print(ans[i],end ="")
    print(" ",end ="")    

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

int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> T(5,0);
  for(int i=0;i<N;i++){
    string S;
    cin >> S;
    if(S.at(0)=='M'){
      T.at(0)++;
    }
    else if(S.at(0)=='A'){
      T.at(1)++;
    }
    else if(S.at(0)=='R'){
      T.at(2)++;
    }
    else if(S.at(0)=='C'){
      T.at(3)++;
    }
    else if(S.at(0)=='H'){
      T.at(4)++;
    }
  }
  int64_t answer = 0;
  for(int i=0;i<3;i++){
    for(int j=i+1;j<4;j++){
      for(int k=j+1;k<5;k++){
        answer += T.at(i)*T.at(j)*T.at(k);
      }
    }
  }
  cout << answer << endl;
}

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

int main(){
    string s; cin>>s;
    int n=s.size()/2;
    for(int i=n-1;;i--){
        int j;
        for(j=0;j<i;j++){
            if(s[j]!=s[j+i])break;
        }
        if(j==i){
            cout<<2*i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
package main

import (
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	const mod = 998244353
	const mx = 2e5
	F := [mx + 1]int{1}
	for i := 1; i <= mx; i++ {
		F[i] = F[i-1] * i % mod
	}
	pow := func(x, n int) int {
		r := 1
		for ; n > 0; n >>= 1 {
			if n&1 == 1 {
				r = r * x % mod
			}
			x = x * x % mod
		}
		return r
	}
	c := func(n, k int) int { return F[n] * pow(F[k]*F[n-k]%mod, mod-2) % mod }

	var n, m, k, ans int
	Fscan(_r, &n, &m, &k)
	for i := 0; i <= k; i++ {
		ans = (ans + c(n-1, i)*pow(m-1, n-1-i)) % mod
	}
	Fprint(_w, ans*m%mod)
}

func main() { run(os.Stdin, os.Stdout) }


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

namespace ABC138A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            if (a < 3200)
                Console.WriteLine("red");
            else
                Console.WriteLine(s);

            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11092
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,r = inm()
if n>=10:
    x = r
else:
    x = r+100*(10-n)
print(x)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N, K;
  cin >> N >> K;
  set<i64> s;
  for (i64 i = 0; i < K; i++)
  {
    i64 d;
    cin >> d;
    for (i64 j = 0; j < d; j++)
    {
      i64 A;
      cin >> A;
      s.insert(A);
    }
  }
  cout << N - s.size() << endl;
  return 0;
}


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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

int sign_x[4] = {1, -1, +1, -1};
int sign_y[4] = {1, -1, -1, +1};

ll board[8][8];

ll queen[8]; // i行目のどこに置いたか

bool in_range(ll x, ll y){
    if(0<=x && x<8 && 0<=y && y<8){
        return true;
    }else{
        return false;
    }
}

// 盤面に置く or 取り除く
void put(ll x, ll y, ll add){
    // cout << "put " << x << " " << y << endl;
    if(add>0){
        queen[y] = x;
    }else{
        queen[y] = -1;
    }

    // row
    FOR(i, 0, 8){
        board[y][i] += add;
    }
    // column
    FOR(i, 0, 8){
        board[i][x] += add;
    }
    // 足しすぎを引く
    board[y][x] -= add;
    // diagonal
    FOR(i, 1, 8){ // 幅
        FOR(j, 0, 4){
            ll nx = x + i * sign_x[j];
            ll ny = y + i * sign_y[j];
            if(in_range(nx, ny)){
                board[ny][nx] += add;
            }
        }
    }
}

void printQueen(){
    FOR(y, 0, 8){
        FOR(x, 0, 8){
            if(queen[y]==x){
                cout << 'Q';
            }else{
                cout << '.';
            }
        }
        cout << endl;
    }
}

void debugBoard(){
    FOR(y, 0, 8){
        FOR(x, 0, 8){
            cout << setw(2) << board[y][x] << ' ';
        }
        cout << endl;
    }
}

void setQueen(ll y){
    // pn(y);
    if(y==8){
        printQueen();
        exit(0);
    }

    // すでに置かれている
    if(queen[y]!=-1){
        setQueen(y+1);
    }

    // p("where to put");
    // どこに置こうかな
    FOR(x, 0, 8){
        // 置いてみる
        if(board[y][x]==0){
            put(x, y, 1);
            setQueen(y+1);
            // キャンセル
            put(x, y, -1);
        }
        
    }
}

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

    // input
    ll N;
    cin >> N;

    FOR(i, 0, 8){
        queen[i] = -1;
    }

    while(N--){
        ll y, x;
        cin >> y >> x;
        put(x, y, 1);
    }

    // p("初期状態");
    // printQueen();
    // br();

    FOR(i, 0, 8){
        // pn(queen[i]);
    }

    setQueen(0);
    return 0;
}


Measured memory_bytes: 3192
function main(input) {
  const reverse = (s) => {
    return s.split("").reverse().join("");
  };

  const WORDS = ["dream", "dreamer", "erase", "eraser"].map(reverse);
  const S = reverse(input.split("\n")[0]);

  var index = 0;

  while (true) {
    var w = WORDS.find((w) => S.startsWith(w, index));
    if (!w) break;
    index += w.length;
  }

  if (S.length === index) {
    console.log("YES");
  } else {
    console.log("NO");
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 20936
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  ll N, K, S;
  cin >> N >> K >> S;

  ll mx = 1000000000;
  if (S < mx) {
    vector<ll> ans(N, mx);
    rep(i, K) {
      ans[i] = S;
    }
    rep(i, len(ans)) {
      cout << ans[i] << ((i == len(ans) - 1) ? "\n" : " ");
    }
    return 0;
  } else {
    vector<ll> ans(N, 1);
    rep(i, K) {
      ans[i] = S;
    }
    rep(i, len(ans)) {
      cout << ans[i] << ((i == len(ans) - 1) ? "\n" : " ");
    }
  }
}

Measured memory_bytes: 2176
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


int main(){
	string s;
	cin>>s;
	string ans;
	string aks="w kstnhmyr";
	string aiu="aiueo";
	for(int i=0;i<s.size();i+=2){
		if(s[i]=='0'&&s[i+1]=='U'){
			ans+="nn";
		}else{
			if(s[i]!='1'){
				ans+=aks[s[i]-'0'];
			}
			int ii=0;
			switch(s[i+1]){
			case 'T':
				ii=0;break;
			case 'L':
				ii=1;break;
			case 'U':
				ii=2;break;
			case 'R':
				ii=3;break;
			case 'D':
				ii=4;break;
			}
			ans+=aiu[ii];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1196
#include<stdio.h>
#include<string.h>//文字列の長さを知りたい
int main(void){
    int i=0;
    char S1[100]={},S2[100]={},P[100]={};
    scanf("%s",S2);
    strcpy(S1,S2);//文字列S1に文字列S2をコピー
    strcat(S1,S2);//文字列S1に文字列2を連結(リング上の文字から単語を探すため)
    scanf("%s",P);
    if(strstr(S1,P)==NULL) printf("No\n");
    else printf("Yes\n"); 


    return 0;
}


Measured memory_bytes: 2112
def main():
    # 下、右、上、左
    dy = (1, 0, -1, 0)
    dx = (0, 1, 0, -1)
    H, W, *s = open(0).read().split()
    H = int(H)
    W = int(W)
    s = ["." + si + "." for si in s]
    s.insert(0, "." * (W + 2))
    s.insert(-1, "." * (W + 2))
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if s[y][x] == "#" and\
                    "." == s[y + dy[0]][x + dx[0]]\
                    == s[y + dy[1]][x + dx[1]]\
                    == s[y + dy[2]][x + dx[2]]\
                    == s[y + dy[3]][x + dx[3]]:
                print("No")
                return
    print("Yes")
    return


main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
using namespace std;
ll x[100001], y[100001], n;

double give_radius(double xi, double j)
{

     double ans = 0, t;
     ll i ;
     for (i = 0; i < n; i++)
     {
          t = ((x[i] - xi) * (x[i] - xi) + (y[i] - j) * (y[i] - j));
          t = sqrt(t);
          ans = max(ans, t);
     }
     return ans;
}

int main()
{

     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     ll i, cp = 0, cn = 0;
     cin >> n;
     for (i = 0; i < n; i++)
     {
          cin >> x[i] >> y[i];
          if (y[i] < 0)
               cn++;
          else
               cp++;
     }
     if (cp > 0 and cn > 0)
     {
          cout << -1;
          return 0;
     }
     if (cn > 0)
     {
          for (i = 0; i < n; i++)
               y[i] *= -1;
     }

     double ans = 10000000000000000ll;

     double l1 = 0, h1 = 100000;
     while (h1 - l1 >= 0.00001)
     {
          double j1 = l1 + (h1 - l1) / 3;
          double j2 = h1 - (h1 - l1) / 3;

          double l = 0, r = 100000, m1, m2, r1, r2;
          double ans1 = 1e18, ans2 = 1e18;

          for (i = 0; i < 80; i++)
          {
               m1 = (r - l) / 3.0;
               m2 = l + 2 * m1;
               m1 = l + m1;

               r1 = give_radius(m1, j1);
               r2 = give_radius(m2, j1);

               if (r1 < r2)
               {
                    ans1 = min(ans1, r1);
                    r = m2;
               }
               else
               {
                    ans1 = min(ans1, r2);
                    l = m1;
               }
          }

          l = 0, r = 100000, m1, m2, r1, r2;
          for (i = 0; i < 80; i++)
          {
               m1 = (r - l) / 3.0;
               m2 = l + 2 * m1;
               m1 = l + m1;

               r1 = give_radius(m1, j2);
               r2 = give_radius(m2, j2);

               if (r1 < r2)
               {
                    ans2 = min(ans2, r1);
                    r = m2;
               }
               else
               {
                    ans2 = min(ans2, r2);
                    l = m1;
               }
          }

          if (ans1 > ans2)
          {
               l1 = j1;
               ans = min(ans, ans1);
          }
          else
          {
               h1 = j2;
               ans = min(ans, ans2);
          }


     }
     cout << setprecision(18) << fixed << ans;
     return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int n;
int id;
int t[100000];//parent
int u[100000];//left
int v[100000];//right
int w[100000];//depth
int tmp[100000];

void setdepth(int x){
  if(t[x]==-1){
    w[x]=0;
    return;
  }
  if(w[x]!=-1)return;
  setdepth(t[x]);
  w[x]=w[t[x]]+1;
}

void init(){
  int i;
  for(i=0;i<100000;i++){
    t[i]=-1;
    u[i]=-1;
    v[i]=-1;
    w[i]=-1;
  }
}

int main(){
  int i,j,k,pos;

  init();
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&tmp[j]);
      t[tmp[j]]=id;
      if(j>0)v[tmp[j-1]]=tmp[j];
    }
    if(k)u[id]=tmp[0];
  }


  for(i=0;i<n;i++){
    setdepth(i);
    printf("node %d: parent = %d, depth = %d, ",i,t[i],w[i]);
    if(w[i]==0)printf("root, ");
    else if(u[i]==-1)printf("leaf, ");
    else printf("internal node, ");
    pos=u[i];
    printf("[");
    if(pos!=-1){
      while(1){
	printf("%d",pos);
	pos=v[pos];
	if(pos==-1)break;
	printf(", ");
      }
    }
    printf("]\n");
    
  }
  return 0;
}

Measured memory_bytes: 2568
#include <stdio.h>

int abs(int x){
  if(x >= 0) return x;
  else return -x;
}
/*
int min(int a,int b){
  if(a > b) return b;
  else return a;
}
*/

int main(){
  int n;
  scanf("%d\n",&n);
  int a[n];
  for(int i = 0; i < n; ++i) scanf("%d",&a[i]);
  long answer = 0;
  int numminus = 0;
  int flag = 0;
  int min = abs(a[0]);
  for(int i = 0; i < n; ++i){
    if(a[i] < 0){
      numminus++;
      a[i] = -a[i];
    }
    if(min > a[i]) min = a[i];
    answer += (long)a[i];
    if(a[i] == 0) flag = 1;
  }
  if((numminus % 2 == 1) && (flag == 0)){
    answer -= 2 * (long) min;
  }
  
  printf("%ld\n",answer);
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int mod=1e9+7;
int n,a,b;

int fpow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=x*x%mod) if(y&1) res=res*x%mod;
	return res;
}

int C(int x,int y){
	if(x<y||x<0) return 0;
	int mul=1;
	for(int i=2;i<=y;i++) mul=mul*fpow(i,mod-2)%mod;
	for(int i=x-y+1;i<=x;i++) mul=mul*i%mod;
	return mul;
//	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}

signed main(){
	read(n);read(a);read(b);
//	fac[0]=1;
//	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
//	inv[n]=fpow(fac[n],mod-2);
//	for(int i=n-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	write(((fpow(2,n)-C(n,a)-C(n,b)-1)%mod+mod)%mod);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define ll long long int
#define pb push_back
#define test ll t; cin>>t; while(t--)

int main()
{
int n;
  cin>>n;
  ll a[n];
  ll ans=0,b;
  cin>>b;
  a[0]=b;
  for(int i=1;i<n;i++)
  { cin>>a[i];
   if(a[i]<b)
     ans+=(b-a[i]);
   else
     b=a[i];
  }
  cout<<ans;
}

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

int main(){
  int N;
  cin >> N;
  long long T,A;
  long long t=1;
  long long a=1;
  for (int i=0;i<N;i++){
    cin >> T >> A;
    long long j=max((t+T-1)/T,(a+A-1)/A);
    t=j*T;
    a=j*A;
  }
  cout << t+a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n;
    cin>>n;
    ll a[n+1];
    rep(i,n)cin>>a[i+1];
    int box[n+1]={};
    vector<int> res;
    for(int i=n;i>=1;i--){
        int cnt=0;
        for(int j=2;j*i<=n;j++){
           cnt += box[j*i]; 
        }
        if(cnt%2!=a[i]){
            box[i]=1;
            res.push_back(i);
        }
    }
    cout << res.size()<<endl;
    rep(i,res.size())cout << res[i] << endl;
    return 0;
}


Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
int n,a[100001];
vector<int> x,y;
vector<pair<int,int> > cntx,cnty;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	for(int i=1;i<=n;i+=2) x.push_back(a[i]);
	for(int i=2;i<=n;i+=2) y.push_back(a[i]);
	sort(x.begin(),x.end());sort(y.begin(),y.end());
	int curcnt=1;
	for(int i=1;i<(int)x.size();i++)
	{
		if(x[i]!=x[i-1])
		{
			cntx.push_back(make_pair(curcnt,x[i-1]));
			curcnt=0;
		}
		curcnt++;
	}
	if(curcnt) cntx.push_back(make_pair(curcnt,x[x.size()-1]));
	sort(cntx.begin(),cntx.end());reverse(cntx.begin(),cntx.end());
	curcnt=1;
	for(int i=1;i<(int)x.size();i++)
	{
		if(y[i]!=y[i-1])
		{
			cnty.push_back(make_pair(curcnt,y[i-1]));
			curcnt=0;
		}
		curcnt++;
	}
	if(curcnt) cnty.push_back(make_pair(curcnt,y[y.size()-1]));
	sort(cnty.begin(),cnty.end());reverse(cnty.begin(),cnty.end());
	if(cnty[0].second==cntx[0].second)
	{
		int ans=100000000;
		ans=min(ans,n/2-(cnty.size()==1?0:cnty[1].first)+n/2-cntx[0].first);
		ans=min(ans,n/2-(cntx.size()==1?0:cntx[1].first)+n/2-cnty[0].first);
		cout<<ans;return 0;
	}
	else
	{
		int ans=0;
		for(int i=1;i<(int)cnty.size();i++) ans+=cnty[i].first;
		for(int i=1;i<(int)cntx.size();i++) ans+=cntx[i].first;
		cout<<ans;return 0;
	}
}

Measured memory_bytes: 2168
let input = require('fs').readFileSync('/dev/stdin', 'utf8');
let num = input.split('\n').map(Number);
for (let i = 0; i < num.length; i++) {
    if (num[i] === 0) {
        break;
    }
    console.log('Case' + ' ' + (i + 1) + ':' + ' ' + num[i]);
}



Measured memory_bytes: 22500
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<iostream>
#include<unordered_map>

using namespace std;

int main()
{
  vector<int> group={1,3,1,2,1,2,1,1,2,1,2,1};
  int x,y;
  cin>>x>>y;
  x--; y--;
  if(group[x]==group[y]){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
  return 0;
}

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

using namespace std;


int main() {
    long long N, A, B;
    cin >> N >> A >> B;
    if( N == 1 && A != B ){
        cout << 0 << endl;
        return 0;
    }
    if( A > B ){
        cout << 0 << endl;
        return 0;
    }
    cout << (N-1) * B + A - (N-1) * A - B + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int count = 0;
    char c[4];

    for(int i = 0;i < 4;i++){
        cin >> c[i];
        if(c[i] == '+')
            count++;
        else 
            count--;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;

class Dice {
  private:
   int face[6];

  public:
    int getTop();
    void setFace(int label,int value);
    void turnOver(char dir);
    void debugOut();
};

int Dice::getTop(){
  return face[0];
}

void Dice::setFace(int label,int value){
  if(label>5) return;
  face[label] = value;
}

void Dice::turnOver(char c){
  int tmp;
  if(c=='N'){
    tmp = face[0];
    face[0] = face[1]; face[1] = face[5];
    face[5] = face[4]; face[4] = tmp; // face[0]
  }

  if(c=='S'){
    tmp = face[0];
    face[0] = face[4]; face[4] = face[5];
    face[5] = face[1]; face[1] = tmp; //face[0]
  }

  if(c=='E'){
    tmp = face[0];
    face[0] = face[3]; face[3] = face[5];
    face[5] = face[2]; face[2] = tmp; //face[4]
  }

  if(c=='W'){
    tmp = face[0];
    face[0] = face[2]; face[2] = face[5];
    face[5] = face[3]; face[3] = tmp; //face[4]
  }
}

void Dice::debugOut(){
    for(int i=0;i<6;i++)
      printf("%d,",face[i]);
}

int main(){
  Dice dice;
  int l;
  char d;

  for(int i=0;i<6;i++){
      scanf("%d ",&l);
      dice.setFace(i,l);
  }
  for(;;){
     if(scanf("%c",&d)==EOF) {
       printf("%d\n",dice.getTop());
       return 0;
     }
     dice.turnOver(d);
  }
   printf("%d\n",dice.getTop());
}


Measured memory_bytes: 3212
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int a[]=new int[100];
		int n=scan.nextInt();
		int i;
		for(i=0;i<n;i++)
			a[i]=scan.nextInt();
		
			
		for(i=0;i<n/2;i++){
			int temp=a[i];
			a[i]=a[n-1-i];
			a[n-1-i]=temp;
		}
		
		for(i=0;i<n-1;i++)System.out.printf("%d ",a[i]);
		System.out.printf("%d\n",a[n-1]);
	}
}


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

using namespace std;

#define LL long long
#define ULL unsigned LL
#define LD long double
#define debug(x) cerr << #x << " " << x << endl;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	int j = 1;
	while(a > 0 && c > 0) {
		if(j%2==0)
			a-=d;
		else
			c-=b;
		//cout<<a<<", "<<c<<endl;
		j++;
	}
	if(a <= 0)
		cout<<"No";
	else
		cout<<"Yes";
}


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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    string s;
    cin >> s;
    string t = "keyence";
    bool flag = false;
    
    //keyenceが固まって存在している場合
    REP(i,s.size()-7){
        string st = s.substr(i,7);
        if(st==t) flag = true;
    }
    //keyenceがばらけている場合
    FOR(i,1,7){
        string st1 = s.substr(0,i);
        string st2 = s.substr(s.size()-7+i,7-i);
        if(st1+st2==t) flag = true;
    }
    if(flag)COUT("YES");
    else COUT("NO");
    return 0;
}    


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {

	int d;
	cin >> d;
	int c[26];
	int i, j;
	for (i = 0; i < 26; i++) {
		cin >> c[i];
	}
	int s[365][26];
	for (i = 0; i < d; i++) {
		for (j = 0; j < 26; j++) {
			cin >> s[i][j];
		}
	}
	int last[26];
	for (i = 0; i < 26; i++) {
		last[i] = 0;
	}
	int jmax, jindex;
	for (i = 1; i <= d; i++) {

		jmax = 0;
		jindex = -1;
		for (j = 0; j < 26; j++) {
			if (c[j] *(i - last[j]) > jmax) {
				jmax = c[j] *(i - last[j]);
				jindex = j;
			}
			else if (c[j] *(i - last[j]) == jmax) {
				if (s[i - 1][j] > s[i - 1][jindex]) {
					jindex = j;
				}
			}
		}
		for (j = 0; j < 26; j++) {
			if (s[i - 1][j] + 2 * c[j] * (i - last[j]) >= jmax) {
				jmax = s[i - 1][j] + c[j] * (i - last[j]);
				jindex = j;
			}
		}
		last[jindex] = i;
		cout << jindex + 1 << endl;
		


	}
	return 0;


}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  string s;
  cin >> s;
  if( s == "Sunny" ){
    cout << "Cloudy";
  }else if(s == "Cloudy"){
    cout << "Rainy";
  }else{
    cout << "Sunny";
  }
  
}

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

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long int fac(int n)
{
      if(n==0)
        return 1;

        else
        return  (n*fac(n-1));
}
int main()
{
    int n;
      cin>>n;

      int arr[n],str[n];

      for(int i=0;i<n;i++)
        cin>>arr[i];

       for(int i=0;i<n;i++)
         cin>>str[i];

        long long int a=0,b=0;

        for(int i=0;i<n;i++)
        {
            int count=0;
           for(int j=i+1;j<n;j++)
            {
               if(arr[i] > arr[j])
                count++;
            }
              a+=count*fac(n-i-1);
        }
          a+=1;
        for(int i=0;i<n;i++)
        {
            int count=0;
            for(int j=i+1;j<n;j++)
             {
                if(str[i] > str[j])
                  count++;
             }
            b+=count*fac(n-i-1);
        }
         b+=1;
        cout<<abs(a-b);
}


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

signed main(){
	int A, B;
	scanf("%d%d", &A, &B);
	if(A >= 13){
		printf("%d\n", B);
	}
	else if(A >= 6){
		printf("%d\n", B / 2);
	}
	else{
		printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 3776
Imports System

Module Program
    Sub Main(args As String())

        Dim iDistance As Integer = Console.ReadLine
        Dim iDistanceFromTo As String() = (Console.ReadLine).Split(" ")
        Dim iFromDistance As Integer = iDistanceFromTo(0)
        Dim iToDistance As Integer = iDistanceFromTo(1)

        Dim sResult As String
        For i = 0 To (iToDistance - iFromDistance)
            If (iFromDistance + i) Mod iDistance = 0 Then
                sResult = "OK"
                Exit For
            End If
            sResult = "NG"
        Next
        Console.WriteLine(sResult)

    End Sub
End Module


Measured memory_bytes: 28324
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e18
typedef long long ll;
typedef pair<ll,ll> P;

ll digit[200010];

int main(void){
    ll n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    ll ans = 0;
    if(p==2 || p==5){
        for(ll i=n-1;i>=0;i--){
            ll x = s[i]-'0';
            if(x%p==0){
                ans+=i+1;
            }
        }
        cout<<ans<<endl;
    }
    else{
        ll power = 1;
        for(ll i=n-1;i>=0;i--){
            ll d =s[i]-'0';
            if(i!=n-1){
                power =(power*10)%p;
            }
            digit[(n-1)-i]=(d*power)%p;
        }
        for(ll i=0;i<n-1;i++)digit[i+1] = (digit[i+1]+digit[i])%p;
        map<ll,ll>m;
        for(ll i=0;i<n;i++)m[digit[i]]++;
        for(auto itr = m.begin();itr!=m.end();++itr){
            ll r = itr->first;
            ll cnt = itr->second;
            if(itr->first == 0)ans+=(cnt+1)*cnt/2;
            else ans += (cnt-1)*cnt/2;
        }
        cout<<ans<<endl;
    }
	return 0; 
}

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

using namespace std;

int n, k;
int a[105];
int dp[100005], mex[105];

int Mex(int x)
{
    fill(mex, mex + n, 0);
    for (int i = 1; i <= n && a[i] <= x; i++)
    {
        mex[dp[x - a[i]]] = 1;
    }
    for (int i = 0; i < n; i++)
    {
        if (mex[i] == 0)
        {
            return i;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= k; i++)
    {
        dp[i] = Mex(i);
    }
    cout << (dp[k] == 0 ? "Second" : "First");
    return 0;
}

Measured memory_bytes: 4020