akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef pair<int, int> P;

vector<vector<int>> c(10, vector<int>(10));

int dijkstra(int s) {
  vector<int> d(10, INF);
  vector<int> used(10, false);
  priority_queue<P, vector<P>, greater<P>> pq;
  d[s] = 0;
  pq.push(make_pair(0, s));
  while (pq.size() > 0) {
    int C = pq.top().first;
    int V = pq.top().second;
    pq.pop();
    if (used[V]) continue;
    rep(i, 10) {
      int alt = C + c[V][i];
      if (d[i] > alt) {
        d[i] = alt;
        pq.push(make_pair(alt, i));
      }
    }
    used[V] = true;
  }
  return d[1];
}

int main() {
  int H, W;
  cin >> H >> W;
  rep(i, 10) rep(j, 10) cin >> c[i][j];
  vector<vector<int>> A(H, vector<int>(W));
  rep(i, H) rep(j, W) cin >> A[i][j];
  
  vector<int> d(10);
  rep(i, 10) d[i] = dijkstra(i);
  int ans = 0;
  rep(i, H) rep(j, W) {
    if (A[i][j] != -1) ans += d[A[i][j]];
  }
  
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main()
{
    double n;
    cin>>n;
    int sum=0,c=0;
   for (int i=1;i<=n;i++)
    {
        sum+=i;
        if (i%2==1)
            c++;
    }
    cout<<fixed<<setprecision(10)<<c/n;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int x;
	cin>>x;
	for(int i=-1000;i<=1000;i++){
		for(int j=-1000;j<=1000;j++){
			if(1ll*i*i*i*i*i-1ll*j*j*j*j*j==x){
				cout<<i<<' '<<j<<endl;
				return 0;
			}
		}
	} 
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
int a;
cin>>a;
cout<<a/3;
system("pause");
return 0;
}

Measured memory_bytes: 884
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

vector<int> graph[100001];
vector<bool> visited;
vector<int> dp;

void dfs(int v,int par){
    for(auto elem : graph[v]){
        
        if(!visited[elem]){
            dfs(elem,v);
        }else{
            dp[v] = max(dp[v],dp[elem]+1);
        }
    }
    if(par > -1)dp[par] = max(dp[par],dp[v]+1);
    visited[v] = true;
}

int main(){
    int n,m;
    cin >> n >> m;
    int x=0,y=0;
    int ans = 0;
    visited.resize(n);
    dp.resize(n,0);
    rep(i,m){
        cin >> x >> y;
        x--; y--;
        graph[x].push_back(y);
    }
    rep(i,n){
        dfs(i,-2);
    }

    rep(i,n){
        ans = max(ans,dp[i]);
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    long long X;
    cin >> N >> X;
    vector<long long> sizes(N+1);
    vector<long long> patties(N+1);
    sizes[0] = 1;
    patties[0] = 1;
    for (int i = 1; i <= N; ++i) {
        sizes[i] = 2*sizes[i-1] + 3;
        patties[i] = 2*patties[i-1] + 1;
    }
    function<long long (int, long long)> count_patties = [&](int n, long long x) {
        if (n == 0) {
            assert (0 <= x && x <= 1);
            return (long long) (x == 1);
        }
        if (x == 1) {
            return 0LL;
        }
        if (x <= 1 + sizes[n-1]) {
            return count_patties(n-1, x-1);
        }
        if (x == 2 + sizes[n-1]) {
            return patties[n-1] + 1;
        }
        if (x <= 2 + 2*sizes[n-1]) {
            return patties[n-1] + 1 + count_patties(n-1, x - 2 - sizes[n-1]);
        }
        assert(x == 3 + 2*sizes[n-1]);
        return patties[n];
    };
    cout << count_patties(N, X) << endl;
    return 0;
}


Measured memory_bytes: 256
L = [int(input()) for i in range(5)]
LL = [i % 10 for i in L]
if LL == [0] * 5:
    print(sum(L))
else:
    L2 = LL[:]
    while 0 in L2:
        L2.remove(0)
    ma = min(L2)
    r = LL.index(ma)
    print(L[r] + sum([L[i] if L[i] % 10 == 0 else L[i] + 10 - L[i] % 10 for i in [j for j in range(5) if j != r]]))


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

int main()
{
    int n,i,ans = 0,j;
    cin >> n;
    vector<int> h(n);
    for(i = 0;i < n;++i){
        cin >> h.at(i);
    }
    for(i = 0;i < n;++i){
        int max = 0;
        for(j = 0;j <= i;++j){
            if(max < h.at(j)){
                max = h.at(j);
            }
        }
        if(max == h.at(i)){
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 100100100100100100;
const int mod = 1e9;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }




/* main */
int n, k;
int arr[50];
int dp[55][6000];

int dfs(int i, int s){

    if(dp[i][s+3000] > -1) return dp[i][s+3000];

    if(i == n){
        if(s == 0) return 1;
        else return 0;
    }

    return dp[i][s+3000] = dfs(i + 1, s + arr[i]) + dfs(i + 1, s);
    

}


signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n >> k;

    rep(i,0,n){
        cin >> arr[i]; 
        arr[i] -= k;
    }

    
    memset(dp, -1, sizeof(dp));

    print(dfs(0,0) -1 );
    

    

 
    
    


    

    
   
    













}






    










    




    










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

int main() {
	int n;
	cin >> n;
	int* a = new int[n];
	int* b = new int[n];
	int* c = new int[n];
	for (int i = 1; i < n + 1; i++) {
		cin >> a[i];
	}
	for (int i = 1; i < n + 1; i++) {
		cin >> b[i];
	}
	for (int i = 1; i < n; i++) {
		cin >> c[i];
	}
	int sum = 0;
	for (int i = 1; i < n + 1; i++) {
		sum += b[a[i]];
		if (i > 1) {
			if (a[i] - a[i - 1] == 1) sum += c[a[i] - 1];
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char str1[n],str2[n];//hmh uuu
    cin>>str1>>str2;
    for(int i=0;i<n;i++)
    {
        cout<<str1[i]<<str2[i];
    }
    
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace K
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long ret = 0;
            for (long i = 0; i < x[0]; i++)
            {
                long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
                for (long j = 0; j < x[1]; j++)
                {
                    ret += a[j] * (i + 1) * (x[0] - i) * (j + 1) * (x[1] - j);
                }
            }
            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 22588
#include <iostream>
#include <utility>
#include <queue>
using namespace std;

typedef long long lint;

int main(){
    lint N,T;
    lint A[100000],max[100000],prof[100000];

    cin >> N >> T;
    for(int i=0;i<N;i++) cin >> A[i];
    
    max[N-1]=A[N-1];
    prof[N-1]=0;

    lint pmax=0;
    priority_queue<int> buy,sell;
    buy.push(-1);
    sell.push(-1);
    sell.push(N-1);
    for(int i=N-1;i>=1;i--){
        if(A[i-1]>=max[i]){
            max[i-1]=A[i-1];
            sell.push(i-1);
        }
        else max[i-1]=max[i];
        prof[i-1]=max[i-1]-A[i-1];
        if(prof[i-1]>pmax) pmax=prof[i-1];
    }

    for(int i=0;i<N;i++){
        if(prof[i]==pmax) buy.push(i);
    }
    lint cost=0;
    while(!buy.empty() && !sell.empty()){
        int b,s;
        b=buy.top();
        s=sell.top();
        if(b==-1 || s==-1) break;
        while(!sell.empty() && A[s]!=A[b]+pmax){
            sell.pop();
            s=sell.top();
        }
        if(b>s){
            buy.pop();
            continue;
        }
        int sc=0,bc=0;
        while(!sell.empty() && s>b){
            sell.pop();
            s=sell.top();
            sc++;
        }
        while(!buy.empty() && b>s){
            buy.pop();
            b=buy.top();
            bc++;
        }
        cost+=(sc<bc?sc:bc);
    }

    cout << cost << endl;

    return 0;
}//

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

struct Date {

  int year,month,day;

  Date(string date) {
    rep(i,date.size()) if( date[i] == '/' ) date[i] = ' ';
    stringstream ss;
    ss << date;
    ss >> year >> month >> day;
  }
  
  bool operator <= ( const Date& data ) const  {
    if( year != data.year )   return year  < data.year;
    if( month != data.month ) return month < data.month;
    return day <= data.day;
  }

};

struct Book {
  string title,author;
  Date date;
  Book(string title,string author,string date) : title(title), author(author), date(date){}
};

void outputValidBooks(vector<Book> &books,string queryTitle,string queryAuthor,string queryDateFrom,string queryDateTo){
  rep(i,books.size()){
    Book book = books[i];
    if( queryTitle[0]  != '*' && book.title.find(queryTitle)   == string::npos  ) continue;
    if( queryAuthor[0] != '*' && book.author.find(queryAuthor) == string::npos ) continue;
    Date dateFrom(queryDateFrom);
    if( queryDateFrom[0] != '*' && !( dateFrom  <= book.date ) ) continue;
    Date dateTo(queryDateTo);
    if( queryDateTo[0]   != '*' && !( book.date <= dateTo )    ) continue;
    cout << book.title << endl;
  }
}

int main(){
  int n,q;
  string title,author,date;
  vector<Book> books;
 
  cin >> n;

  rep(i,n) {
    cin >> title >> author >> date;
    books.push_back(Book(title,author,date));
  }

  cin >> q;
  
  string queryTitle,queryAuthor,queryDateFrom,queryDateTo;
  rep(_,q){
    if( _ ) puts("");
    cin >> queryTitle >> queryAuthor >> queryDateFrom >> queryDateTo;
    outputValidBooks(books,queryTitle,queryAuthor,queryDateFrom,queryDateTo);
  }

  return 0;
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a;
  long double b;
  cin>>a>>b;
  cout<<(ll)(a*b)<<'\n';
  return(0);
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const int N = 5e5 + 100;
const int mod = 1e9 + 7;

int fac[N] , inv[N];
inline int mul(int a , int b){
	return a*1ll*b%mod;
}
inline int power(int a, int b){
	int res = 1;
	while(b){
		if(b&1)
			res = mul(res , a);
		a = mul(a , a);
		b >>= 1;
	}
	return res;
}
inline int add(int a , int b){
	a += b;
	if(a >= mod) a -= mod;
	return a;
}
inline int sub(int a , int b){
	a -= b;
	if(a < 0) a += mod;
	return a;
}

int nCr(int n , int r){
	if(r > n || r < 0) return 0;
	return mul(fac[n] , mul(inv[r] , inv[n-r]));
}
int main(){
	fio; cout<<fixed<<setprecision(25);	
	int n , m; cin >> n >> m;
	fac[0] = 1;
	inv[0] = 1;
	for(int i = 1 ;i < N ; ++i){
		fac[i] = mul(fac[i-1] , i);
		inv[i] = power(fac[i] , mod-2);
	}
	int ss = 0;
	for(int comm = 0 ; comm <= n ; ++comm){
		// int ways = mul( nCr(m , n), mul( nCr(n , comm) ,nCr(m-n , n-comm) ));
		int w = nCr(m , comm);
		int ww = nCr(n , comm);
		int zz = fac[comm];
		int tt = mul(w , mul( ww, zz));
		//num
		int pp = nCr(m-comm , n-comm);
		int mm = fac[n-comm];
		if(comm%2 == 0)
			ss = add(ss ,mul(tt ,  mul(pp , mul(pp , mul(mm , mm)) ) ) );
		else
			ss = sub(ss ,mul(tt ,  mul(pp , mul(pp , mul(mm , mm)) ) ) );

	}
	cout << ss << endl;





	return 0;
}


Measured memory_bytes: 7544
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[200100];
ll b=-1,n,ans;
int main()
{
  cin>>n;
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=1;i<=n;i++){
     b=max(b,a[i]);
     ans+=b-a[i];
  }
  cout<<ans;
  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

const string YES = "Yes";
const string NO = "No";

void solve(vector<vector<ll>> A, ll N, vector<ll> b) {
  for (auto i = 0; i != N; ++i) {
    for (auto j = 0; j != 9; ++j) {
      if (A[j / 3][j % 3] == b[i]) A[j / 3][j % 3] = 0;
    }
  }

  bool pred = (!A[0][0] && !A[0][1] && !A[0][2]) ||
              (!A[1][0] && !A[1][1] && !A[1][2]) ||
              (!A[2][0] && !A[2][1] && !A[2][2]) ||
              (!A[0][0] && !A[1][0] && !A[2][0]) ||
              (!A[0][1] && !A[1][1] && !A[2][1]) ||
              (!A[0][2] && !A[1][2] && !A[2][2]) ||
              (!A[0][0] && !A[1][1] && !A[2][2]) ||
              (!A[0][2] && !A[1][1] && !A[2][0]);
  cout << (pred ? YES : NO) << endl;
}

int main() {
  vector<vector<ll>> A(3, vector<ll>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A[i][j];
    }
  }
  ll N;
  cin >> N;
  vector<ll> b(N);
  for (int i = 0; i < N; i++) {
    cin >> b[i];
  }
  solve(move(A), N, move(b));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

/*double distance(double a,double b,double c,double d){
  double dis=sqrt(pow(c-a,2)+pow(d-b,2));
  return dis;
}*/

double S(double x,double y,double r){
  return x*y*sin(r)/2;
}
double L(double x,double y,double r){
  return x+y+sqrt(pow(x,2)+pow(y,2)-2*x*y*cos(r));
}
double h(double x,double y,double r){
  return y*sin(r);
}

int main(){
  double a,b;
  int c;
  cin >> a >> b >> c;

  double pi,rad;
  pi = acos(-1);
  rad = c*pi/180;

  cout << fixed << setprecision(5) << S(a,b,rad) << endl;
  cout << fixed << setprecision(5) << L(a,b,rad) << endl;
  cout << fixed << setprecision(5) << h(a,b,rad) << endl;

  return 0;
}



Measured memory_bytes: 3436
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;


int main() {
  int n;
  cin >> n;
 
 
  int q = n % 1000;
  
  cout << (1000 - q) % 1000 << endl;
  
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int N;
    cin >> N;
    
    vector<int> a(N);
    map<int, int> mp;
    bool allzero = true;
    bool zero = false;
    REP(i, N) {
        cin >> a[i];
        mp[a[i]]++;

        if (a[i] != 0) {
            allzero = false;
        } else {
            zero = true;
        }
    }

    bool can = false;
    if (allzero) can = true;

    if (N % 3 == 0) {
        int num = N / 3;

        if (zero) {
            int x = -1;
            REP(i, N) {
                if (a[i] != 0) {
                    x = a[i];
                }
            }
            if (mp[x] == num * 2 && mp[0] == num) {
                can = true;
            }
        } else {
            for(int i = 1; i < N; i++) {
                if (a[i] != a[0]) {
                    int x = a[0], y = a[i], z = x^y;
                    if (mp.count(z)) {
                        if (mp[x] == num && mp[y] == num && mp[z] == num) {
                            can = true;
                        }
                    }
                }
            }
        }
    }


    cout << (can ? "Yes" : "No") << endl;

    return 0;
}

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

int main() {
    while(true) {
        int nCard, cycle; cin >> nCard >> cycle;
        if(nCard == 0 && cycle == 0) return 0;
        vector<int> card(nCard);
        for(int i = 0; i < nCard; i++) card[i] = i+1;
        reverse(card.begin(), card.end());

        for(int i = 0; i < cycle; i++) {
            int loc, num; cin >> loc >> num;
            rotate(card.begin(), card.begin()+loc-1, card.begin()+loc-1+num);
        }
        cout << card[0] << endl;
    }
}



Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int N,M,K;
	cin>>N>>M>>K;

	REP(i,N+1){
		REP(j,M+1){
			int tem=i*(M-j)+(N-i)*j;
			if(tem==K){
				print("Yes");
				return 0;
			}
		}
	}
	print("No");

	return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String []args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int H = x / 3600;
    int M = (x - H * 3600) / 60;
    int S = (x - H * 3600) - (M * 60);

    System.out.println(H + ":" + M + ":" + S);
    sc.close();
  }
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n;

  scanf("%d", &n);

  if (n / 100 == (n / 10) % 10 && (n / 10) % 10 == n % 10)
    printf("%d\n", n);
  else {
    int zoro = (n / 100) * 100 + (n / 100) * 10 + (n / 100);
    if (n < zoro) {
      printf("%d\n", zoro);
    } else {
      int next = (n / 100) + 1;
      if (next == 10) printf("1111\n");
      else {
        printf("%d\n", next * 100 + next * 10 + next);
      }
    }
  }
}


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

const int mod = 1000000000+7;

int main(){
    int h,w;    cin >> h >> w;
    vector<vector<char> >a(h, vector<char>(w));
    rep(i, h)   rep(j, w)   cin >> a[i][j];
    vector<vector<int> >dp(h+1, vector<int>(w+1));
    dp[h-1][w-1] = 1;
    for(int i = h-1; i >= 0; i--){
        for(int j = w-1; j >= 0; j--){
            if(a[i][j] == '#')  continue;
            dp[i][j] += dp[i][j+1] + dp[i+1][j];
            dp[i][j] %= mod;
        }
    }
    cout << dp[0][0] << endl;
}


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


int main() {
    int n, w;
    scanf("%d %d", &n, &w);
    
    vector<vector<long long>> h(n, vector<long long>(2,INT_MAX));
    
    for(int i=0; i<n; i++) {
        scanf("%lld %lld", &h[i][0], &h[i][1]);
      //  printf("%d %d\n", h[i][0], h[i][1]);
    }
    vector<long long> dp(w+1);

    for(int i=0; i< n; i++) {
        for(int j = w-h[i][0]; j>=0; j--) {
            dp[j+h[i][0]] = max(dp[j+h[i][0]], dp[j]+h[i][1]);   
        }            
    }
    long long ans = 0;
    for(long long i:dp)
        ans = max(ans,i);
    printf("%lld\n", ans);
}

Measured memory_bytes: 4092
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;
const ll INF = 1e12;

int main() {
	int C[3][3];
	REP(i, 3)REP(j, 3)cin >> C[i][j];
	if (C[0][0] + C[1][1] + C[2][2] == C[0][1] + C[1][2] + C[2][0] && C[0][1] + C[1][2] + C[2][0] == C[0][2] + C[1][0] + C[2][1]) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,s,t) for(int (i) = (s); (i) <= (t); ++(i))
#define repD(i,t,s) for(int (i) = (t); (i) >= (s); --(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) ((a)^(b) & 1LL ^ 1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = 1e9 + 7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	ll ans = 0;
	char c[18],e[18];
	rep(i,n) cin>>c[i];
	rep(i,n) cin>>e[n - 1 - i];
	pair<string,string> ls[1 << 18];
	rep(s,1 << n){
		string a,b;
		rep(d,n){
			if(s & (1 << d)) a.pub(c[d]);
			else b.pub(c[d]);
		}
		ls[s] = {a,b};
	}
	sort(ls,ls + (1 << n));
	rep(s,1 << n){
		string a,b;
		rep(d,n){
			if(s & (1 << d)) a.pub(e[d]);
			else b.pub(e[d]);
		}
		ans += u_bnd(ls,ls + (1 << n),mkp(a,b)) - l_bnd(ls,ls + (1 << n),mkp(a,b));
	}
	cout<<ans<<endl;
	
	return 0;
}





Measured memory_bytes: 33792
def gcd(x,y):
    if y == 0:
        return x
    return gcd(y, x % y)

A, B, C, D = map(int, input().split())
lcm = (C * D) // gcd(C, D)
bsum = B - (B//C) - (B//D) + (B//lcm)
asum = (A - 1) - ((A - 1) // C) - ((A - 1) // D) + ((A - 1) // lcm)

print(bsum-asum)

Measured memory_bytes: 3060
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    lint x;
    cin >> x;

    for(lint i = 1 ; i <= x ; ++i){
        if(i * (i + 1LL) / 2LL >= x){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

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

using namespace std;
using ll = long long;

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

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

ll modpow(ll a, ll n, int mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) {
            res *= a;
            res %= MOD;
        }
        a *= a;
        a %= MOD;

        n >>= 1;
    }
    return res;
}

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

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

ll HCOM(int n, int k) {
    return (n == 0 && k == 0) ? 1 : COM(n+k-1, k);
}


int main() {
    ll n, k;
    cin >> n >> k;

    COMinit();

    ll x = 0;

    if (n < k) {
        x = n;
    } else {
        x = k;
    }

    ll ans = 0;
    
    for (ll i = 0; i <= x; ++i) {
        ll res = 0;
        res += COM(n, i);
        res %= MOD;

        res *= HCOM(n - i, i);
        res %= MOD;

        ans += res;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12160
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    x,y = LI()

    return x + y // 2


print(main())


Measured memory_bytes: 6468
#include<bits/stdc++.h>
using namespace std;
int main(){
    int r, g, b;
    cin >> r >> g >> b;
    if((r * 100 + g * 10 + b) % 4 == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#ABC057-B
n,m = map(int,input().split())
students = [list(map(int,input().split())) for _ in range(n)]
points = [list(map(int,input().split())) for _ in range(m)]
def manhattan(s,points):
    lst = []
    for i in points:
        lst.append(abs(s[0] - i[0]) + abs(s[1] - i[1]))
    return lst.index(min(lst))+1

for i in students:
    print(manhattan(i,points))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X, Y; cin >> X >> Y;
  int res = 0;
  if(X <= 3) res += (4 - X) * 100000;
  if(Y <= 3) res += (4 - Y) * 100000;
  if(X == 1 && Y == 1) res += 400000;
  
  cout << res << endl;
}

Measured memory_bytes: 256
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N, K = MI()
S = input()
T = S.lower()
S = list(S)
T = list(T)

S[K - 1] = T[K - 1]

print("".join(map(str, S)))

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int main() {
	int n, p;
	int a[50];
	
	cin >> n >> p;
	REP(i, n) scanf("%d", a + i);
	
	ll dp[5001] = {};
	dp[0] = 1;
	REP(i, n) for (int j = 5000; j >= a[i]; j--) {
		dp[j] += dp[j - a[i]];
	}
	
	ll ans = 0;
	REP(i, 5001) if (i % 2 == p) ans += dp[i];
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
def main
  s = gets.chomp
  islands = s.split('LR')
  results = []

  base = 0
  islands.each_with_index do |island, i|
    if islands.length > 1
      if i == 0
        island = island + 'L'
      elsif i == islands.length - 1
        island = 'R' + island
      else
        island = 'R' + island + 'L'
      end
    end
    i = 0
    while i < island.length do
      c = island[i]
      if (c == 'R' && c == island[i+1]) || (c == 'L' && c == island[i-1])
        results[i + base] = 0
      else c == 'R'
        results[i + base] = 1 + (i / 2).floor + ((island.length - i - 1) / 2).floor
      end
      i += 1
    end
    base += island.length
  end
  puts results.join(' ')
end

main if $0 == __FILE__

Measured memory_bytes: 7492
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int flag=0,i;
    map<char,int>x;
    for(i=0;i<a.size();i++)
    {
        x[a[i]]++;
        if(x[a[i]]==2)
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
        cout<<"no"<<endl;
    else
        cout<<"yes"<<endl;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    cin >> S;
    int ans = 0;
    for (int i = 0, R = 0; i < 3; ++i) {
        if (S[i] == 'R') {
            ++R;
            ans = max(R, ans);
        } else {
            R = 0;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3636
from math import gcd

# = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

flag = True
c2 = 0
c3 = 0
c5 = 0
for k in range(N):
  if A[k] %2 ==0:
    c2 += 1
    if c2 > 1:
      flag = False
      break
  elif A[k] %3 ==0:
    c3 += 1
    if c3 > 1:
      flag = False
      break
  elif A[k] %5 == 0:
    c5 += 1
    if c5 >1:
      flag = False
      break

if flag:
  mA = max(A)
  counter = [0 for _ in range(mA+1)]

  primenum = [2]
  sgn = [-1 for _ in range(int(mA**0.5)+1)]
  k = 3
  while k**2 <= mA:
    if sgn[k] == -1:
      primenum.append(k)
      add = k*k
      ok = k
      while ok**2 <= mA:
        sgn[ok] = 1
        ok += add
    k += 2
  #prime_num が用意されているとき
  def factorization(n):
    M = n
    for p in primenum:
      if p**2 > M:
        break
      else:
        if M%p == 0:
          if counter[p] == 0:
            counter[p] = 1
          else:
            return False
          while M%p == 0:
            M //= p

    if M > 1:
      if counter[M] == 0:
        counter[M] = 1
      else:
        return False
    return True

g = A[0]
for k in range(N):
  a = A[k]
  g = gcd(g, a)
  if flag:
    flag = factorization(a)
  if flag == False:
    if g == 1:
      break


if flag:
  print('pairwise coprime')
  exit()
if g == 1:
  print('setwise coprime')
else:
  print('not coprime')


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
const int maxi = 1e6+10;

vector<int> value;
Graph G;
// d: 頂点 v の深さ
void dfs(int now, int parent,int score) {
    value[now] += score;
    // for(auto nv : G[now]) {
    //     if (nv == parent) continue; 
    //     dfs(G,nv,now, value[now]);
    // }
    for (int i = 0; i < G[now].size(); i++) {
    if (G[now][i] == parent) continue;
    dfs(G[now][i], now, value[now]);
  }


}

int main(){
    // 頂点数と辺数
    int N, Q; 
    cin >> N >> Q;

    G.resize(N);
    value.resize(N);
    for(int i = 0; i < N - 1; i++){
        int a, b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);

    }
    for(int i = 0; i < Q; i++){
        int u, x;
        cin >> u >> x;
        u--;
        value[u] += x;
    }

    dfs(0,-1,0);

    for(int i = 0; i < N; i++){
        cout << value[i] << " ";
    }
    cout << endl;

}

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

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

    int even, odd;
    if (k%2 == 0) {
        even = k/2, odd = k/2;
    } else {
        even = k/2, odd = k/2 + 1;
    }

    int ans;
    ans = even * odd;
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define xx first
#define yy second
#define mxn 200005
using namespace std;
typedef pair<int, int>pi;
priority_queue<pi>pq;
int freq[mxn], ara[mxn], f[mxn], res[mxn];
int main()
{
    int n, x;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
    scanf("%d", &ara[i]), freq[ ara[i] ]++;
    for(int i=1; i<=n; i++)scanf("%d", &x), f[x]++;
    for(int i=1; i<=n; i++)
    if(f[i])pq.push({ freq[i], i });
    bool flag= 1;
    for(int i=0; i<n && flag; i++)
    {
        while(pq.top().xx!=freq[ pq.top().yy ])
        {
            int x= pq.top().yy;
            pq.pop();
            pq.push({ freq[x], x });
        }
        if(pq.top().yy==ara[i])
        {
            int p= pq.top().yy;
            pq.pop();
            while(pq.top().xx!=freq[ pq.top().yy ])
            {
                int x= pq.top().yy;
                pq.pop();
                pq.push({ freq[x], x });
            }
            if(pq.empty())flag= 0;
            else
            {
                freq[ ara[i] ]--;
                int x= pq.top().yy;
                pq.pop();
                res[i]= x;
                f[x]--;
                if(f[x])pq.push({ freq[x], x});
                pq.push({ freq[p], p });
            }
        }
        else
        {
            freq[ ara[i] ]--;
            int x= pq.top().yy;
            pq.pop();
            res[i]= x;
            f[x]--;
            if(f[x])pq.push({ freq[x], x});
        }
    }
    if(flag)
    {
        puts("Yes");
        for(int i=0; i<n; i++)
        printf("%d ", res[i]);puts("");
    }
    else puts("No");
    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef int64_t llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());


int main(){
    int n,m,ans=0;
    cin >> n >> m;
    int ikkai;
    ikkai= 1900* m + 100 * (n-m);
    int kai=1;
    REP(i,m) kai*=2;
    cout << ikkai * kai << endl;
}

Measured memory_bytes: 256
class Dice
  def initialize(a,b,c,d,e,f)
    @top   = a
    @down  = b
    @right = c
    @left  = d
    @up    = e
    @back  = f
  end
  attr_accessor :top,:down,:right,:left,:up,:back
  def move(dice,m)
    top=@top
    down=@down
    right=@right
    left=@left
    up=@up
    back=@back

    if m=="S"
      @top=  up
      @down= top
      @right=right
      @left= left
      @up=   back
      @back= down
    elsif m=="W"
      @top=  right
      @down= down
      @right=back
      @left= top
      @up=   up
      @back= left
    elsif m=="N"
      @top=  down
      @down= back
      @right=right
      @left= left
      @up=   top
      @back= up
    elsif m=="E"
      @top=  left
      @down= down
      @right=top
      @left= back
      @up=   up
      @back= right
    end
  end
  def printDice
#    puts "top:#{@top}  down:#{@down}  right:#{@right}  lefr:#{@left} up:#{@up} back:#{@back}"
     puts @top
  end
end

a,b,c,d,e,f=gets.split.map(&:to_i)
dice=Dice.new(a,b,c,d,e,f)
moves = gets.split("")
moves.each do |m|
  dice.move(dice,m)
end
dice.printDice()



Measured memory_bytes: 6876
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <iomanip>
#include <set>
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define SORT(s) sort((s).begin(),(s).end())

int main(){
    ll K; cin >> K;
    ll e = K/2;
    ll o;
    if(K%2==0) o = K/2;
    else o = K/2 + 1;
    cout << e*o << endl;
}


Measured memory_bytes: 3540
#define _CRT_SECURE_NO_WARNINGS

#define N (1<<18)
#define MODULO (1000000007)
#define HA1 (2420609)
#define HA2 (19260817)

#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <complex>
using namespace std;

namespace MRAND
{
	class MRNDS
	{
	public:
		int ngf;
		unsigned int lgf;
		MRNDS()
		{
			ngf = HA1*HA2;
			lgf = HA1 - HA2*ngf;
		}
		MRNDS(long long rgf)
		{
			lgf = rgf&((1LL << 32) - 1LL);
			ngf = (rgf >> 31);
			ngf += 2LL * lgf;
			ngf *= HA2;
			lgf += HA1;
		}
		MRNDS operator* (const MRNDS &mrs)const
		{
			MRNDS Res;
			Res.ngf += ngf*mrs.lgf;
			Res.ngf -= mrs.ngf*lgf;
			Res.ngf *= HA1;
			Res.lgf *= HA2;
			return Res;
		}
	}curl, curr;
	inline void InitRand(MRNDS &Lmrs, MRNDS &Rmrs)
	{
		curl = Lmrs;
		curr = Rmrs;
		curl = curl*curr;
		curl.ngf += HA2;
	}
	inline int GetRand()
	{
		curl = curl*curr;
		return (curl.lgf*HA1 - curr.ngf*HA2);
	}
}

#ifndef INT_MAX
#define INT_MAX (2147483647)
#endif

class INTERVAL
{
public:
	int mn, L, R;
	INTERVAL() {};
	bool operator< (const INTERVAL &seg)const
	{
		return mn > seg.mn;
	}
};

int n, cnt, nn;
int a[2][N], pos[N];
int Ans[N];
int tr[2][N << 1];
priority_queue<INTERVAL> PQ;

inline void SMTBuild()
{
	for (nn = 1;nn < n;nn <<= 1);
	for (int od = 0;od <= 1;od++)
	{
		for (int i = nn - 1;i < (nn << 1) - 1;i++)
		{
			tr[od][i] = a[od][i - nn + 1];
		}
		for (int i = nn - 2;i >= 0;i--)
		{
			tr[od][i] = min(tr[od][(i << 1) + 1], tr[od][(i << 1) + 2]);
		}
	}
}

inline int SMTQuery(int od, int L, int R, int X = 0, int Y = nn - 1, int pp = 0)
{
	if (Y<L || X>R)
	{
		return INT_MAX;
	}
	if (X >= L&&Y <= R)
	{
		return tr[od][pp];
	}
	return min(SMTQuery(od, L, R, X, X + ((Y - X) >> 1), (pp << 1) + 1),
		SMTQuery(od, L, R, X + 1 + ((Y - X) >> 1), Y, (pp << 1) + 2));
}

int main()
{
	scanf("%d", &n);
	for (int i = 0;i < n;i++)
	{
		int tmp;
		scanf("%d", &tmp);
		pos[tmp] = i;
		a[i & 1][i] = tmp;
		a[!(i & 1)][i] = INT_MAX;
	}
	SMTBuild();
	INTERVAL beg;
	beg.L = 0, beg.R = n - 1, beg.mn = SMTQuery(0, 0, n - 1);
	PQ.push(beg);
	while (!PQ.empty())
	{
		//throw;
		INTERVAL curi = PQ.top();
		PQ.pop();
		Ans[cnt++] = curi.mn;
		Ans[cnt++] = SMTQuery(!(pos[curi.mn] & 1), pos[curi.mn] + 1, curi.R);
		if (curi.L != pos[curi.mn])
		{
			INTERVAL tmp;
			tmp.L = curi.L, tmp.R = pos[curi.mn] - 1;
			tmp.mn = SMTQuery(curi.L & 1, curi.L, pos[curi.mn] - 1);
			PQ.push(tmp);
		}
		int vr = pos[Ans[cnt - 1]];
		if (pos[curi.mn] + 1 != vr)
		{
			INTERVAL tmp;
			tmp.L = pos[curi.mn] + 1, tmp.R = vr - 1;
			tmp.mn = SMTQuery(!(pos[curi.mn] & 1), pos[curi.mn] + 1, vr - 1);
			PQ.push(tmp);
		}
		if (vr != curi.R)
		{
			INTERVAL tmp;
			tmp.L = vr + 1, tmp.R = curi.R;
			tmp.mn = SMTQuery(!(vr & 1), vr + 1, curi.R);
			PQ.push(tmp);
		}
	}
	for (int i = 0;i < cnt - 1;i++)
	{
		printf("%d ", Ans[i]);
	}
	printf("%d\n", Ans[cnt - 1]);
	//system("pause");
	return 0;
}


Measured memory_bytes: 10232
# include <stdio.h>

int main()
{
	int cake[16];
	int A, B;
	scanf("%d %d", &A, &B);
	if (A > 8 || B > 8)
	{
		printf(":(");
		return 0;
	}
	
	printf("Yay!");
	return 0;
}

Measured memory_bytes: 128
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
use std::collections::VecDeque;
#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }
    let mut b: VecDeque<usize> = VecDeque::new();
    for i in 0..n {
        if i % 2 == 1 {
            b.push_back(a[i]);
        } else {
            b.push_front(a[i]);
        }
    }
    if n % 2 == 0 {
        for i in 0..n {
            print!("{} ", b[n - 1 - i]);
        }
    } else {
        for i in 0..n {
            print!("{} ", b[i]);
        }
    }
}


Measured memory_bytes: 7728
// ABC_116_B

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

int collatz(int n) {
	if(n % 2 == 0) {
		int tmp = n / 2;
		return tmp;
	}
	else {
		int tmp = 3 * n + 1;
		return tmp;
	}
}

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

	vector<int> v(1000000);

	int ans = 0;
	v[0] = s;

	bool flag = false;

	for(int i = 1; i < 1000000; ++i) {
		v[i] = collatz(v[i-1]);

		//cout << v[i] << "\n";

		for(int j = 0; j < i; ++j) {
			if(v[i] == v[j]) {                           
			ans = i + 1;
			flag = true;
			break;
			}
			else continue;
		}  

		if(flag) break;
		else continue;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 4096
n = gets.to_i
@n = n
a = Array.new n 
b = Array.new n 
c = {}
zerozero = 0
MOD = 1000000007
n.times do |i|
  _a, _b = gets.split.map(&:to_i)
  a[i] = _a
  b[i] = _b
  if _a == 0 && _b == 0
    zerozero += 1
  elsif _a == 0
    c[[0,-1]] ||= 0
    c[[0,-1]] += 1
  elsif _b == 0
    c[[1,0]] ||= 0
    c[[1,0]] += 1
  else
    if _a < 0
      _a = - _a
      _b = - _b
    end
    gcd = _a.gcd(_b)
    _a /= gcd 
    _b /= gcd
    c[[_a,_b]] ||= 0
    c[[_a,_b]] += 1
  end
end

result = 1
c.each do |(_a, _b), count|
  if _b < 0
    _a = - _a
    _b = - _b
  end
  if pair_count = c[[_b,- _a]]
    c.delete([_b,-_a])
    result *= (2**count - 1) + (2**pair_count -1) + 1
  else
    result *= (2**count)
  end
  result %= MOD
end

result += zerozero
result -= 1 # 何も選ばない時
result %= MOD
puts result 

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

#define rep(i,n) for(int i=0;i<(n);i++)

int main(){

  using i64=long long;
  i64 n, k; cin>> n>> k;

  i64 x=0;
  rep(_, n-1){
    x+=(x/(k-1))+1;
  }

  cout<< x <<endl;

  return 0;
}

/*

  i:   0 1 2 3 ... k-1 k k+1 k+2 ... k*2-1 k*2 k*2+1 ... k*3-1 k*3 k*3+1 ... k*4-1 k*4 k*4+1
  i+1:   0 1 2 ... k-2   k-1  k  ... k*2-3     k*2-2 ... k*3-4     k*3-3 ... k*4-5     k*4-4

  x in [(k-1)*m, (k-1)*(m+1)-1] => x+=(m+1)
  m=0, 1, 2, ...

*/


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int K, A, B; 
	cin >> K >> A >> B; 
	if(B <= A || K < A - 1) cout << K + 1 << endl; 
    else{long long int M = (K - A + 1) / 2; 
         cout << max(A + ((K - A + 1) % 2) + (B - A) * M, K + 1) << endl; 
    }
}

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

int main(void){
    int a,b,x;
    double p,q,thita;
    scanf("%d %d %d",&a,&b,&x);
    if(2*x <= a*a*b){
        p = (double)2*x / (b*a);
        thita = atan(b/p);
    }else{
        q = (double) 2*x / (a*a);
        q -= b;
        thita = atan((b - q) / a);
    }
    printf("%.10lf",thita * 180/ M_PI);
    return 0;
}

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

#define M 1000

int main() {
	char map[M+1][M+1];
	char field[4] = "JOI";
	static int dp[3][M+1][M+1], temp[3], ans;
	int m, n, k, a, b, c, d;
	cin >> m >> n >> k;
	for(int i=1; i<=m; ++i) {
		for(int j=1; j<=n; ++j) cin >> map[i][j];
	}
	for(int p=0; p<3; ++p) {
		for(int i=0; i<m+1; ++i) dp[p][i][0] = 0;
		for(int j=0; j<n+1; ++j) dp[p][0][j] = 0;
	}
	for(int i=1; i<=m; ++i) {
		for(int p=0; p<3; ++p) temp[p] = 0;
		for(int j=1; j<=n; ++j) {
			for(int p=0; p<3; ++p) {
				if(field[p]==map[i][j]) temp[p]++;
				dp[p][i][j] = dp[p][i-1][j] + temp[p];
			}
		}
	}
	for(int q=0; q<k; ++q) {
		cin >> a >> b >> c >> d;
		for(int p=0; p<3; ++p) {
			ans = dp[p][c][d] - dp[p][c][b-1] - dp[p][a-1][d] + dp[p][a-1][b-1];
			cout << (!p?"":" ") << ans;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 13848