akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(void){
   long long A,B,C,K;
   cin>>A>>B>>C>>K;
   long long count=0;
   if(K<=A){
      count=K;
      cout<<count<<endl;
      return 0;
   }else{
      count=A;
      K=K-A-B;
      if(K>=0){
         cout<<count-min(K,C)<<endl;
      }else{
         cout<<count<<endl;
      }
   }

   return 0;
}



Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
typedef vector<int> vi;

int main(void){
	char n,m;
	cin >> n;
	cin >> m;
	if (n<m){
		cout << '<' << endl;
	}else if(n > m){
		cout << '>' << endl;
	}else{
		cout << '=' << endl;
	}
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define    fio     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define    eps     1e-9
#define    pi      acos(-1.0)
#define    mod     1e9+7

using namespace std;
typedef long long ll;

int a[10000];

void solve()
{
    int n;
    cin>>n;
    vector <int> v;
    for(int x=1;x<=100;x++)
    {
        for(int y=1;y<=100;y++)
        {
            for(int z=1;z<=100;z++)
            {
                if((x*x+y*y+z*z+x*y+y*z+z*x)<=n)
                {
                    v.push_back((x*x+y*y+z*z+x*y+y*z+z*x));
                }
                else
                {
                    break;
                }
            }
        }
    }
    sort(v.begin(),v.end());
    int l=v.size();
    for(int i=0,j=0;i<l;i=j)
    {
        while(v[i]==v[j])
        {
            j++;
        }
        a[v[i]-1]=(j-i);
    }
    for(int i=0;i<n;i++)
    {
        cout<<a[i]<<endl;
    }
}

int main()
{
    fio;
///    freopen ("output.txt","w",stdout);
///    freopen ("input.txt","r",stdin);
    int tc=1;
///    cin>>tc;
///    int i=0;
    while(tc--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 4132
using System;
using System.Collections.Generic;
using System.Linq;

namespace BlackJack
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputNums = Console.ReadLine().Split(); 
            if (int.Parse(inputNums[0]) + int.Parse(inputNums[1]) + int.Parse(inputNums[2]) >= 22)
            {
                Console.WriteLine("bust");
            } else
            {
                Console.WriteLine("win");
            }
        }
    }
}


Measured memory_bytes: 11092
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	set<string> a;
	for (ll i = 0; i < n; i++)
	{
		string s;
		cin >> s;

		a.insert(s);
	}

	println(a.size());
}

Measured memory_bytes: 19124
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int64 solve(int I, int J, int L, int cnt) {
  I -= cnt;
  J -= cnt;
  L -= cnt;
  return I / 2 * 2LL + J / 2 * 2LL + L / 2 * 2LL + cnt * 3LL;
}

int main() {
  int I, O, T, J, L, S, Z;
  cin >> I >> O >> T >> J >> L >> S >> Z;
  int cnt = min(I, min(J, L));
  int64 ret = solve(I, J, L, cnt);
  if (cnt) ret = max(ret, solve(I, J, L, cnt - 1));
  ret += O;
  cout << ret << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
ll x;

template <class T>
void read(T &x, T f = 1) {
    char ch = getchar();
    x = 0;
    while (ch < '0' || ch > '9') f = (ch == '-' ? -1 : 1), ch = getchar();
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> x;
    if(x<=599) cout<<8;
    else if(x<=799) cout<<7;
    else if(x<=999) cout<<6;
    else if(x<=1199) cout<<5;
    else if(x<=1399) cout<<4;
    else if(x<=1599) cout<<3;
    else if(x<=1799) cout<<2;
    else if(x<=1999) cout<<1;
    return 0;
}

Measured memory_bytes: 3644
// 二分探索 + 桁DP
#include <iostream>
#include <vector>
#include <sstream>
#include <string>
 
using namespace std;
using ll = long long;
 
ll f(ll x) {
  // x以下のlunlun数の数を返す
  stringstream ss;
  ss << x;
  string str = ss.str();
  int len = str.size();
  ll dp[len+1][2][11] = {0};
  dp[0][0][10] = 1;
  for (int i = 0; i < len; i++) {
   int d = str[i] - '0';
   for (int j = 0; j < 2; j++) {
    for (int k = 0; k <= 10; k++) {
      if (k == 10) {
        for (int l = 1; l <= 10; l++) {
          if (!j && l != 10 && l > d) continue;
          dp[i+1][j || (l < d || l == 10)][l] += dp[i][j][k];
        }
        continue;
      }
      
      for (int l = -1; l <= 1; l++) {
        int nx = k + l;
        if (nx < 0 || nx >= 10 || (!j && nx > d)) continue;
        dp[i+1][j || nx < d][nx] += dp[i][j][k];
      }
    }
   }
  }
  ll ret = 0;
  for (int j = 0; j < 2; j++) for (int k = 0; k < 10; k++) ret += dp[len][j][k];
  return ret;
}
 
int main() {
  int K;
  cin >> K;
  ll lb = 0;
  ll ub = 1LL << 60;
  while (ub - lb > 1) {
    ll mid = (ub + lb) / 2;
    if (f(mid) >= K) ub = mid;
    else lb = mid;
  }
  cout << ub << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll A, B, N;
    cin >> A >> B >> N;
    ll ans = 0;
        if (N <= 10000){
    for(int i = 1; i <= N; i++) {
        if (floor(A*i/B) - A * floor(i/B) > ans) {
            ans = floor(A*i/B) - A * floor(i/B);
            }
    }
    }
    else {
        if (min(B-1, N) == N) ans = floor(A*N/B) - N * floor(N/B);
        else ans = floor(A*(B-1)/B) - N * floor((B-1)/B);
    }
    cout << ans;
    return 0;
}


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

using namespace std;

int main(){
        int n;
        cin >> n;
        for(int i = 0; i < n; i++){
                int num[10];
                for(int j = 0; j < 10; j++){
                        cin >> num[j];
                }

                // 深さ優先探索?
                int a, b;
                int j;
                a = b = 0;
                for(j = 0; j < 10; j++){
                        if(a < num[j]){
                                a = num[j];
                                continue;
                        }
                        if(b < num[j]){
                                b = num[j];
                                continue;
                        }
                        break;
                }

                if(j != 10){
                        cout << "NO" << endl;
                } else {
                        cout << "YES" << endl;
                }
        }

        return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		Integer full = sc.nextInt();
		Integer piece = sc.nextInt();

		System.out.println(calc(full,piece));
	}

	private static Integer calc(Integer full, Integer piece) {
		Integer pieces = full * 3 + piece;
		return pieces / 2;
	}


}


Measured memory_bytes: 21076
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")

N = I()
S = input()

R = [0] * N
G = [0] * N
B = [0] * N

r = 0
g = 0
b= 0
for i in range(N):
    if S[N-i-1] == "R":
        r += 1
        R[N-i-1] = r
    else:
        R[N-i-1] = r
    
    if S[N-i-1] == "G":
        g += 1
        G[N-i-1] = g
    else:
        G[N-i-1] = g

    if S[N-i-1] == "B":
        b += 1
        B[N-i-1] = b
    else:
        B[N-i-1] = b

ans = 0
for i, s in enumerate(S):
    if i > N-3:
        break

    if s == "R":
        ans += G[i+1] * B[i+1]
    if s == "G":
        ans += R[i+1] * B[i+1]
    if s == "B":
        ans += R[i+1] * G[i+1]
    
    j = 1
    while i + j*2 < N:
        if s == "R":
            if (S[i+j] == "G" and S[i+j+j] == "B") or (S[i+j] == "B" and S[i+j+j] == "G"):
                ans -= 1
        if s == "G":
            if (S[i+j] == "R" and S[i+j+j] == "B") or (S[i+j] == "B" and S[i+j+j] == "R"):
                ans -= 1
        if s == "B":
            if (S[i+j] == "G" and S[i+j+j] == "R") or (S[i+j] == "R" and S[i+j+j] == "G"):
                ans -= 1
        
        j += 1

print(ans)


Measured memory_bytes: 69060
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll d;
    while(cin>>d){
        ll n = 600/d;
        ll ans = 0;
        for(ll i=0,x=0;i<n;i++,x+=d){
            ll v = x*x; 
            ans += v*d;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2988
n,m = map(int,input().split())
h_list = list(map(int,input().split()))
result = [0 for i in range(n)]
for i in range(m):
    temp1, temp2 = map(int, input().split())
    if h_list[temp1-1] <= h_list[temp2-1]:
        result[temp1-1] = -1
    if h_list[temp1-1] >= h_list[temp2-1]:
        result[temp2-1] = -1
print(result.count(0))

Measured memory_bytes: 20112
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int main()
{

    int a, b;
    cin >> a >> b;
    if (a * b == 15)
    {
        cout << "*";
    }
    else if (a + b == 15)
    {
        cout << "+";
    }
    else
    {
        cout << "x";
    }
}


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

int main() {
  int N, M;
  vector<string> S, T;
  cin >> N;
  for (int i = 0; i < N; i++) { string tmp; cin >> tmp; S.push_back(tmp); }
  cin >> M;
  for (int i = 0; i < M; i++) { string tmp; cin >> tmp; T.push_back(tmp); }

  int score = 0;
  for (string t : S) {
    int inscore = 0;
    for (string tt : S) {
      if (t == tt)
        inscore++;
    }
    for (string tt : T) {
      if (t == tt)
        inscore--;
    }
    score = max(score, inscore);
  }
  cout << score << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n);
    int cnt=0;
    REP(i,n) cin>>a[i];
    for(int i=0;i<n;i++){
        int mi = i;
        for(int j=i+1;j<n;j++){
            if(a[j]<a[mi]) mi=j;
        }
        if(mi!=i){
            swap(a[i],a[mi]);
            cnt++;
        }
    }
    REP(i,n) cout<<a[i]<<(i<n-1?" ":"");
    cout<<endl;
    cout<<cnt<<endl;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, mx = -INF;
    int a[111111];
    cin>>n;
    rep(i, n) {
        cin>>a[i];
        chmax(mx, a[i]);
    }
    int half = (mx + 1) / 2;
    int itr = 0, best = INF;
    rep(i, n) {
        if( chmin(best, abs(half - a[i])) ) {
            itr = i;
        }
    }
    cout<<mx<<' '<<a[itr]<<endl;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL N = 1000000007;

LL dp[3005][3005] = {0};
LL pre[3005] = {0};
LL n;
char c[3005] = {0};

int main(){
	cin >> n;
	for(LL i = 2;i <= n;i ++) cin >> c[i];
	dp[1][1] = 1;
	for(LL i = 2;i <= n;i ++){
		for(LL j = 1;j <= i;j ++) pre[j] = (pre[j - 1] + dp[i - 1][j]) % N;
		for(LL j = 1;j <= i;j ++){
			if(c[i] == '>') dp[i][j] = pre[i - 1] - pre[j - 1];
			if(c[i] == '<') dp[i][j] = pre[j - 1];
			dp[i][j] = (dp[i][j] + N) % N;
		}
	}
	LL ans = 0;
	for(LL i = 1;i <= n;i ++) ans = (ans + dp[n][i]) % N;
	printf("%lld\n",ans);
	return 0;
}
//

Measured memory_bytes: 69120
/*
tarun360
IIT Indore
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define forn_s(i,start,lim) for(ll_s i=start;i<lim;i++)
#define forn_d_s(i,start,lim) for(ll_s i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define debug1(a) cout<<a<<endl
#define debug2(a,b) cout<<a<<" "<<b<<endl
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define debug4(a) cout<<"chu "<<a<<endl

ll h[100005],dp[100005];

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n;
  cin>>n;
  forn(i,0,n) cin>>h[i];
  dp[0]=0;dp[1]=abs(h[1]-h[0]);
  forn(i,2,n){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[n-1]<<endl;
  return 0;
}


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

using namespace std;
#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 rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int n, T;
	cin >> n >> T;
	vector<int>t(n);
	rep(i, n) {
		cin >> t[i];
	}
	int ret = T;
	rep(i, n - 1) {
		ret += min(T, t[i + 1] - t[i]);
	}
	print(ret);
}

Measured memory_bytes: 4764
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <sstream>

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
const int mod = 2019;

int main() {
    ll l, r; cin >> l >> r;
    r = min(r, l+4038);
    int ans = 2018;
    for (ll i = l; i <= r; i++) {
        for (ll j = i + 1; j <= r; j++) {
            int x = i*j % 2019;
            ans = min(ans, x);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    a, b = nm()
    c = max(a, b)
    d = max(c - 1, min(a, b))
    print(c + d)


if __name__ == '__main__':
    main()


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


int main()
{
	int n, m;
	int vegetable[1005];
	int ans;

	while (true)
	{
		ans = 0;

		cin >> n >> m;
		if (n == 0 && m == 0) break;

		for (int i = 0; i < n; ++i)
		{
			cin >> vegetable[i];
		}
		//???????????§?????????????????????
		for (int i = 0; i < n - 1; ++i)
		{
			for (int j = i + 1; j < n; ++j)
			{
				if (vegetable[i] < vegetable[j])
					swap(vegetable[i], vegetable[j]);
			}
		}
		//????¨????????¨????
		for (int i = 0; i < n; ++i)
		{
			if ((i + 1) % m != 0)
				ans += vegetable[i];
		}

		cout << ans << endl;
	}

	return 0;
}

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

using namespace std;


int main()
{
	int n; cin >> n;
	int ans = 0;
	if(n%1000 == 0) ans = 0;
	else{
		int x = n/1000+1;
		ans = x*1000-n;
	}
	cout << ans;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int x,y,ans=2000000003;
  scanf("%d %d",&x,&y);
  if(x<=y)
    ans=y-x;
  if(-1*x<=y)
    ans=min(ans,y+x+1);
  if(x<=-1*y)
    ans=min(ans,-1*y-x+1);
  if(-1*x<=-1*y)
    ans=min(ans,-1*y+x+2);
  printf("%d\n",ans);
}
  


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

int main(){
  string s;
  cin>>s;
  string ans="";
  for(int i=0;i<s.size();i++){
    if(s[i]=='B'){
      if(ans.size() != 0){
         ans.pop_back();
      }
    }else{
      ans += s[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

import (
    "fmt"
)

func main() {
	var b, ans string
	fmt.Scan(&b)
	if b == "A" {
		ans = "T"
	} else if b == "T" {
		ans = "A"
	} else if b == "C" {
		ans = "G"
	} else {
		ans = "C"
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
n=int(input())
s=input()
ans=0
alist=[0]*10
for i in range(n):
  alist[int(s[i])]=i
for i in range(10):
  flag1=False
  for a in range(n-2):
    if s[a]==str(i):
      flag1=True
      break
  if flag1:
    for j in range(10):
      flag2=False
      for b in range(a+1,n-1):
        if s[b]==str(j):
          flag2=True
          break
      if flag2:
        for k in range(10):
          if b<alist[k]:
            ans+=1
print(ans)

Measured memory_bytes: 9056
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N, K, Q; cin >> N >> K >> Q;
    vector<int> V(N);
    for(int i=0; i<Q; i++){
        int a; cin >> a;
        a--;
        V[a]++;
    }
    

    for(int i=0; i<N; i++){
        if(K - Q + V[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
/******************************************
* AUTHOR : Lokesh goel*
* NICK : InsaneNerd *
* INSTITUTION : NIT Kurukshetra *
******************************************/
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 1000000000
#define N 100005
#define pii pair<int,int>
#define vp vector<pair<int,int > >
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define gsz(x) ((int)(x).size())
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
#define endl "\n"
#define ms(x,v) memset(x,v,sizeof(x))
#define pi 3.14159265358979323846264338327950288419716939937510
int main()
{
	fastio;
	ll r;
	cin>>r;
	cout<<setprecision(18)<<2*pi*r<<endl;


	return 0;
}

Measured memory_bytes: 3800
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;
using Matrix = vector<vector<ll>>;
ll mod = 1e9 + 7;

Matrix product(const Matrix& a, const Matrix& b) {
  Matrix c(a.size(), vector<ll>(a[0].size(), 0));

  for (int i = 0; i < a.size(); i++) {
    for (int j = 0; j < b[0].size(); j++) {
      for (int k = 0; k < a[0].size(); k++) {
        c[i][j] += a[i][k] * b[k][j];
        c[i][j] %= mod;
      }
    }
  }
  return c;
}

Matrix exp(const Matrix& a, ll b) {
  if (b == 1) return a;

  Matrix tmp = exp(a, b / 2);
  tmp = product(tmp, tmp);
  if (b & 1) tmp = product(tmp, a);
  return tmp;
}

int main() {
  int n;
  ll b;
  cin >> n >> b;

  Matrix a(n, vector<ll>(n));
  for (auto& row : a) for (ll& e : row) cin >> e;

  a = exp(a, b);
  ll ans = 0;
  for (const auto& row : a) for (ll e : row) ans = (ans + e) % mod;
  cout << ans << endl;

  return 0;
}


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


//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
//#define mod             1000000007
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asorted(s)      sort(s.begin(), s.end())
#define dsorted(s)      sort(s.begin(), s.end(), cmp)
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
//#define SIZE            100005
//#define INF             1000000005
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)

const ll INF = 1e18;
const ll SIZE = 1e5+5;
const ll mod = 1e9+7;

ll gcd(ll x, ll y) {
    if(y == 0) return x;
    return gcd(y, x%y);
}

ll a[SIZE];
ll gp[SIZE]; ///PREFIX GCD
ll gs[SIZE]; ///SUFFIX GCD

int main() {
    ll t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
    scl1(n);

    for1(i, n) scl1(a[i]);

    if(n == 2) {
        cout << max(a[1], a[2]) << "\n";
        return 0;
    }

    for1(i, n) gp[i] = gcd(a[i], gp[i-1]);

    for(i = n; i >= 1; i--) gs[i] = gcd(a[i], gs[i+1]);

    for1(i, n) ans = max(ans, gcd(gp[i-1], gs[i+1]));

    printl(ans);


    return 0;
}



Measured memory_bytes: 2560
#include <cstdio>

using namespace std;

int n,dp[34];

int main(){
  while(1){
    scanf("%d",&n);
    if(n==0) break;
    for(int i=0;i<34;i++) dp[i]=0;
    dp[0]=1;

    for(int i=0;i<n;i++){
      dp[i+1]+=dp[i];
      dp[i+2]+=dp[i];
      dp[i+3]+=dp[i];
    }

    //for(int i=0;i<n;i++) printf("%d_%d\n",i,dp[i]);

    int ans=(dp[n]/3650)+1;

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

  }
  return 0;

}

Measured memory_bytes: 2596
/*
author : seryu
title : ABC171D_"Replacing"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

void solve()
{
	int n;
	cin >> n;
	map<ll, ll> mp;
	ll sum = 0;
	rep(i, n)
	{
		ll a;
		cin >> a;
		mp[a]++;
		sum += a;
	}
	int q;
	cin >> q;
	vector<ll> ans;
	rep(i, q)
	{
		ll b, c;
		cin >> b >> c;
		sum += (c-b)*mp[b];
		ans.push_back(sum);
		mp[c] += mp[b];
		mp[b] = 0;
	}
	rep(i, q)cout << ans[i] << endl;
	return;	
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 9940
import sys
import queue

#+++++
		
def main():
	n = int(input())
	nnn = list(map(int, input().split()))
	
	ppp=nnn[:n]
	ccc=nnn[n:2*n]
	bbb=nnn[2*n:]
	
	pp_v=[0]*(n+1)
	ppq=queue.PriorityQueue()
	for v in ppp:
		ppq.put(v)
	
	pre=sum(ppp)
	pp_v[0]=pre
	for i,v in enumerate(ccc):
		ppq.put(v)
		t=ppq.get()
		pre=pre+v-t
		pp_v[i+1]=pre
		
		
	bb_v=[0]*(n+1)
	bbq=queue.PriorityQueue()
	for v in bbb:
		bbq.put(-v)
	
	pre=-1*sum(bbb)
	bb_v[0]=pre
	for i,v in enumerate(ccc[::-1]):
		bbq.put(-v)
		t=bbq.get()
		pre=pre+(-v)-(t)
		bb_v[i+1]=pre
		
	dd=[p+q for p,q in zip(pp_v,bb_v[::-1])]
	ans=max(dd)
	
	print(ans)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int main() {
  char c;
  cin >> c;

  vector<char> vec = {'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'};
  auto itr = find(vec.begin(), vec.end(), c);
  size_t index = std::distance( vec.begin(), itr );
  
  cout << vec.at(index + 1) << endl;    
}

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

int main(){
  string s,t;
  cin >> s >> t;
  int a,b;
  cin >> a >> b;
  string u;
  cin >> u;
  if( u == s ){
    cout << a-1 << " " << b << endl;
  }else if( u == t ){
    cout << a << " " << b-1 << endl;
  }else{
    cout << a << " " << b << endl;
  }
  return 0;
}


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

int x;

int main() {
    cin >> x;

    if (x < 1200) {
        cout << "ABC" << endl;
    } else {
        cout << "ARC" << endl;
    }
}

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



int main() {
  int n, d, x; cin >> n >> d >> x;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  int tabeta = 0;
  rep(i,n){
    tabeta++;
    for(int j = 1; j * a[i] + 1 <= d; j++){
      tabeta++;
    }
  }

  int ans = tabeta + x;
  cout << ans << endl;

	return 0;
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define inf 1e18
#define pi acos(-1.0)
#define mod 998244353

int main(void)
{
    fastio;

    string s;
    cin >> s;
    int o=0,e=0,l=s.size(),i,m;
    for(i=0;i<l;i++)
    {
        if(i%2)
        {
            if(s[i]=='0')e++;
        }
        else
        {
            if(s[i]=='0')o++;
        }
    }
    //cout << o << " " << e << " ";
    if(l%2){m=l/2;l=l/2+1;}
    else {m=l/2;l=l/2;}

    cout << min(l-o+e,o+m-e);

    return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int main() {
	int N, K;
	cin >> N >> K;
	int a=0, b=0, c=0;
	string S;
	cin >> S;
	rep(i, S.size()-1) {
		if (S.at(i) == S.at(i + 1)) {
			a++;
		}
		else if (S.at(i) == 'L') {
			b++;
		}
		else {
			c++;
		}
	}
	int sa = min(b, c);
	int ka = 2*min(b, min(c, K));
	if (sa<K&&S.at(S.size() - 1) !=S.at(0)) {
		ka++;
	}
	
	
	cout << a +  ka << endl;
}


Measured memory_bytes: 512
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))

lg = [A[0]]
for a in A[1:]:
    lg.append(gcd(lg[-1], a))

rg = [A[-1]]
for a in reversed(A[:-1]):
    rg.append(gcd(rg[-1], a))
rg.reverse()

ans = max(lg[-2], rg[1])
for l,r in zip(lg,rg[2:]):
    g = gcd(l,r)
    ans = max(ans, g)
print(ans)

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

int main(){

  int N;
  cin >> N;
  vector<string> list = {};
  for (int i = 0; i < N; i++)
  {
    string tmp;
    cin >> tmp;
    list.push_back(tmp);
  }

  sort(list.begin(), list.end());
  list.erase(unique(list.begin(), list.end()),list.end());
  cout << list.size();
  return 0;
}

Measured memory_bytes: 11660
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
int l[10];
#include <fstream>
#include <iostream>
#include <string>
int main() {
    string a,b;
    cin >> a >> b;
    int i = stoi(a+b);
    double sq = sqrt(i);
    if(ceil(sq) == floor(sq)) cout << "Yes";
    else cout << "No";


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    n--;
    ll c[n],s[n],f[n];
    for(int i=0;i<n;i++){
        cin>>c[i]>>s[i]>>f[i];
    }
    for(int i=0;i<n;i++){
        ll ans=0;
        for(int j=i;j<n;j++){
            if(ans>s[j]){
                for(int k=0;k<f[j];k++){
                    if((ans+k)%f[j]==0){
                        ans+=c[j]+k;
                        k=f[j];
                    }
                }
            }
            else{
                ans+=s[j]-ans;
                ans+=c[j];
            }
        }
        cout << ans<<endl;
    }
    cout <<0<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] as = new long[n];
		long sum = 0;
		for(int i=0; i<n; i++){
			as[i] = sc.nextInt();
			sum += as[i];
		}
		Map<Long, Long> map = new HashMap<>();
		for (Long key : as) {
    		Long i = map.get(key);
    		map.put(key, i == null ? 1 : i + 1);
		}
		int q = sc.nextInt();
		long ans[] = new long[q];
		for(int i=0; i<q; i++){
			long from = sc.nextInt();
			long to = sc.nextInt();
			Long value = map.get(from);
			if(value == null) value = 0L;
			sum -= value*(from-to);
			ans[i] = sum;
			map.remove(from);
			Long j = map.get(to);
			map.put(to, j == null ? value : j + value);
		}
		for(long i: ans){
			System.out.println(i);
		}
	}
}


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

using namespace std;

#define ll long long int

int memo[(int)1e5 + 1];
vector<int> adj[(int)1e5 + 1];

bool vis[(int)1e5 + 1];

int dfs(int x) {
	
	if(vis[x])return memo[x];

	vis[x] = true;
	
	int temp = 1;

	for(int i = 0; i < adj[x].size(); i++) {
		memo[x] = max(memo[x], temp + dfs(adj[x][i]));
	}

	return memo[x];
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n,m; cin >> n >> m;
	int s,t;
	
	while(m--) {
		cin >> s >> t;
		adj[s].push_back(t);
	}

	for(int i = 1; i <= n; i++) {
		dfs(i);
	}

	int ans = 0;
	
	for(int i = 1; i <= n; i++) {
		ans = max(ans,memo[i]);
	}

	cout << ans << '\n';

	return 0;
}

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

int main(){
	int n, m;
	int s[400], l[400], p[400];
	int w[400];
	int dp[400];

	cin >> n;
	for(int i=0; i < n; i++) cin >> s[i] >> l[i] >> p[i];

	cin >> m;
	for(int i=0; i < m; i++) cin >> w[i];

	fill(dp, dp+400, -1);
	dp[0] = 0;

	for(int i=0; i < 400; i++){
		for(int j=0; j < n; j++){
			for(int k=s[j]; k <= l[j]; k++){
				if(i-k >= 0) dp[i] = max(dp[i], dp[i-k] + p[j]);
			}
		}
	}

	for(int i=0; i < m; i++){
		if(dp[w[i]] == -1){
			cout << -1 << endl;
			return 0;
		}
	}

	for(int i=0; i < m; i++){
		cout << dp[w[i]] << endl;
	}
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    vi score(n);
    rep(i,n)cin>>score[i];
    sort(score.begin(),score.end());
    ll sum=0;
    rep(i,n)sum+=score[i];
    int i=0;
    bool undiv=false;
    if(sum%10==0){
        while(i<n&&score[i]%10==0){
            i++;
        }
        if(score[i]%10!=0){
            sum-=score[i];
            undiv=true;
        }
    }
    else {
        undiv=true;
    }
    if(undiv)cout<<sum<<endl;
    else cout<<0<<endl;
    return 0;
}




Measured memory_bytes: 256
class Dice
    def initialize(line)
        @figures = line.chomp.split(" ").map(&:to_i)
    end
    
    def roll(direction)
        array = Array.new(6)
        
        case direction
        when "N"
            array[0] = @figures[1]
            array[1] = @figures[5]
            array[2] = @figures[2]
            array[3] = @figures[3]
            array[4] = @figures[0]
            array[5] = @figures[4]
        when "S"
            array[0] = @figures[4]
            array[1] = @figures[0]
            array[2] = @figures[2]
            array[3] = @figures[3]
            array[4] = @figures[5]
            array[5] = @figures[1]
        when "W"
            array[0] = @figures[2]
            array[1] = @figures[1]
            array[2] = @figures[5]
            array[3] = @figures[0]
            array[4] = @figures[4]
            array[5] = @figures[3]
        when "E"
            array[0] = @figures[3]
            array[1] = @figures[1]
            array[2] = @figures[0]
            array[3] = @figures[5]
            array[4] = @figures[4]
            array[5] = @figures[2]
        end
        @figures = Marshal.load(Marshal.dump(array))
    end
    
    def show()
        return @figures[0]
    end
end

dice = Dice.new(gets.chomp)
gets.chomp.split("").each {|d| dice.roll(d)}
puts dice.show()


Measured memory_bytes: 8928
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(){
	ll N,M;
	cin>>N>>M;
	if(M/2<=N){
		cout<<M/2<<endl;
	}
	else{
		ll ans=N;
		M=M-2*N;
		ans=ans+M/4;
		cout<<ans<<endl;
	}
	//cout<<(N/2<M?N/2:M)<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std; 
#define int long long
#define float double
#define MAX 100005
const int  mod = 99824435300;
#define LMT 100000000000
#define int long long 
#define pb push_back 
#define lp(i,n) for( i=0;i<n;i++) 
#define lop(j,n)for( j=0;j<n;j++)
typedef pair<int,int> pii;
typedef pair<pii,pii> ppi;
#define m_p make_pair
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define minheap priority_queue<int,vector<int>,greater<int>>
#define maxheap priority_queue<int>
#define kickstart  cout<<"Case #"<<cc<<": "
#define pair_pq priority_queue<pii,vector<pii>,greater<pii>>
#define ff first
#define ss second
#define pff pair<float,float>
#define piii pair<int,pii>
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = a * a;
        b >>= 1;
    }
    return res;
}


int fact(int a){int ans=1;
  while(a>1){ans=(ans*a)%mod;a--;}return ans;
}

void solve(){
int i,j,k,l=0,r=mod,m,diff=0,n,q;
cin>>n;int a[n],dp[n][3];lp(i,n)cin>>dp[i][0]>>dp[i][1]>>dp[i][2];
for(i=1;i<n;i++){
  dp[i][0]+=max(dp[i-1][1],dp[i-1][2]);
  dp[i][1]+=max(dp[i-1][0],dp[i-1][2]);
  dp[i][2]+=max(dp[i-1][0],dp[i-1][1]);

}
cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}
 int32_t main(){
  fastio
 #ifndef ONLINE_JUDGE 
  freopen("input.txt", "r", stdin); 
  freopen("output.txt", "w", stdout); 
 #endif
int t=1;
//cin>>t;
while(t--)solve();
return 0;
 }


Measured memory_bytes: 5904
import Control.Monad
import Data.List
import Data.Function

main = do
 n <- readLn
 ab_s <- foo n
 cd_s <- foo n
 print $ analyze (sortOn fst ab_s) (sortOn fst cd_s)

foo n = forM [1..n] $ \_ -> do
 [a,b] <- map read . words <$> getLine
 return (a,b)
type Point = (Int, Int)

analyze :: [Point] -> [Point] -> Int
analyze reds [] = 0
analyze reds ((c,d):bls) = case reverse $ sortOn snd [(a,b) | (a,b) <- reds, a<=c, b<=d] of
 [] -> analyze reds bls
 (r:_) -> 1 + analyze (filter (/=r) reds) bls



Measured memory_bytes: 1020
#include <iostream>
using namespace std;
int main(){
    int j;
    long long i,n,k;
    i=0;
    cin >> n >> k;
    if(k==0){
       cout << n*n << endl;
    }else{
    for(j=0;j<=n-k-1;j++){
        if(n%(k+j+1)<k-1){
        i += (n+1-k)/(k+j+1)*(j+1)+ (j+1);
    }else{
        i += (n+1-k)/(k+j+1)*(j+1) + (n-k+1)%(k+j+1);
    }
    }
cout << i << endl;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char workd[200004];
int l[200004],r[200004];
int main(){
	int n,k,c;
	scanf("%d%d%d",&n,&k,&c);
	scanf("%s",workd+1);
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(workd[i]=='o'){
			l[++cnt]=i;
			i+=c;
		}
		if(cnt>=k)break;
	}
	cnt=k;
	for(int i=n;i>=1;i--){
		if(workd[i]=='o'){
			r[cnt--]=i;
			i-=c;
		}
		if(cnt<1)break;
	}
	for(int i=1;i<=k;i++){
		if(l[i]==r[i])printf("%d\n",l[i]);
	}
}

Measured memory_bytes: 3200
#include<iostream>
#include<cstdio>
#define PI 3.141592653589
using namespace std;
 
int main(){
    double x;
    cin >> x;
     
    double z = x*PI;
    printf("%.6f %.6f\n",z*x,z*2.0);
     
    return 0;
}

Measured memory_bytes: 3204
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
class Point {
public:
	long double px, py;
	Point() : px(0), py(0) {};
	Point(long double px_, long double py_) : px(px_), py(py_) {};
	bool operator==(const Point& p) const { return px == p.px && py == p.py; }
	bool operator!=(const Point& p) const { return px != p.px || py != p.py; }
	bool operator<(const Point& p) const { return px < p.px ? true : (px == p.px && py < p.py); }
	bool operator>(const Point& p) const { return px > p.px ? true : (px == p.px && py > p.py); }
	bool operator<=(const Point& p) const { return !(Point(px, py) > p); }
	bool operator>=(const Point& p) const { return !(Point(px, py) < p); }
	Point operator+(const Point& p) const { return Point(px + p.px, py + p.py); }
	Point operator-(const Point& p) const { return Point(px - p.px, py - p.py); }
	Point operator/(long double d) const { return Point(px / d, py / d); }
	friend Point operator*(const Point p, long double d) { return Point(p.px * d, p.py * d); }
	friend Point operator*(long double d, const Point& p) { return p * d; }
	Point& operator+=(const Point& p1) { px += p1.px, py += p1.py; return *this; }
	Point& operator-=(const Point& p1) { px -= p1.px, py -= p1.py; return *this; }
	Point& operator*=(long double d) { px *= d, py *= d; return *this; }
	Point& operator/=(long double d) { px /= d, py /= d; return *this; }
};
class Circle {
public:
	Point p; long double r;
	Circle() : p(Point()), r(0.0L) {};
	Circle(Point p_) : p(p_), r(0.0L) {};
	Circle(Point p_, long double r_) : p(p_), r(r_) {};
	Circle(long double x_, long double y_) : p(Point(x_, y_)), r(0.0L) {};
	Circle(long double x_, long double y_, long double r_) : p(Point(x_, y_)), r(r_) {};
	bool operator==(const Circle& c) const { return p == c.p && r == c.r; }
	bool operator!=(const Circle& c) const { return !(Circle(p, r) == c); }
};

// ------ Functions ------ //
long double norm(const Point& a) { return a.px * a.px + a.py * a.py; }
long double abs(const Point& a) { return sqrtl(norm(a)); }
long double arg(const Point& a) { return atan2l(a.py, a.px); }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
Point pol(long double r, long double d) { return Point(cosl(d) * r, sinl(d) * r); }
long double dst(const Point& a, const Point& b) { return abs(b - a); }
vector<Point> crp(Circle c1, Circle c2) {
	long double d = abs(c1.p - c2.p);
	long double a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d));
	long double t = arg(c2.p - c1.p);
	return{ c1.p + pol(c1.r, t + a), c1.p + pol(c1.r, t - a) };
}

// ------ Main ------ //
Point p, q; Circle c;
int main() {
	cin >> p.px >> p.py >> c.p.px >> c.p.py >> c.r;
	vector<Point> v = crp(c, Circle((p + c.p) / 2, dst(p, c.p) / 2));
	sort(v.begin(), v.end());
	for(int i = 0; i < 2; i++) printf("%.9Lf %.9Lf\n", v[i].px, v[i].py);
	return 0;
}

Measured memory_bytes: 3600