akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;

const ll INF = numeric_limits<ll>::max(),
         MOD = 1e9 + 7;

const int INF_i = numeric_limits<int>::max(),
          MAX = 1e6;

vii dp, v;
int n;
int f(int i = 0) {
    if (i == n - 1) return 0;
    if (dp[i] == -1) {
        dp[i] = abs(v[i] - v[i + 1]) + f(i + 1);
        if (i + 2 < n) {
            dp[i] = min(abs(v[i] - v[i + 2]) + f(i + 2), dp[i]);
        }
    }
    return dp[i];
}

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);
    cin >> n;
    v.resize(n);
    dp.assign(n, -1);
    for (int i = 0; i < v.size(); i++) {
        cin >> v[i];
    }
    cout << f() << '\n';
}

Measured memory_bytes: 5760
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<set>
#include<stack>
#include<queue>

#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)
#define fs first
#define sc second
#define pb push_back
#define mk make_pair

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

template<class S,class T>
ostream &operator<<(ostream &out, const pair<S,T> p){
	return out << "(" << p.fs << ", " << p.sc << ")";
}

template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()) out << v[i] << ", ";
	return out << "}" << endl;
}

#define N 15
#define NN (1 << N)
#define INF (((ll)1) << 40)
ll dp[NN];
int p[NN], pos[NN];


int main(){
	int n,m;
	while(cin >> n >> m, n){
		vi s(n), d(m);
		rep(i,n) cin >> s[i];
		rep(i,m) cin >> d[i];
		sort(d.begin(), d.end());
		fill( dp, dp+NN, INF);
		fill( pos, pos+NN, 0);
		dp[0] = 0;
		p[0] = 0;
		rep(b, 1 << n){
			rep(i, n){
				if ((b>>i)&1) continue;
				int t=0,bi = 1 << i, j = pos[b];
			   	int sum = p[b] + s[i];
				p[b | bi] = sum;
				while(d[j] <= sum && j < m){
					t += min(sum - d[j], d[j] - p[b]);
					j++;
				}
				if(dp[b | bi] > dp[b] + t){
					dp[b | bi] = dp[b] + t;
					pos[b | bi] = j;
				}
			}
		}
		int nnn = (1<<n) -1;
		ll ans = dp[nnn];
		reps(i, pos[nnn], m){
			ans += abs(d[i] - p[nnn]);
		}
		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 3604
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define INF 10000000

int n,m;


void refl(int *array){
	int pa[]={0,n};
	int ch=0;
	int card[201];
	
	REP(i,2*n){
		card[i]=array[pa[i%2]++];
	}
	REP(i,201)array[i]=card[i];
	return;
}

void cutk(int *array,int k){
	int card[201];int cnt=0;
	REP(i,2*n){
		if(i<2*n-k){
			card[i]=array[i+k];
		}else{
			card[i]=array[cnt++];
		}
	}
	REP(i,201)array[i]=card[i];
	return;
}

int main(){
	int card[201];
	cin>>n>>m;
	REP(i,2*n)card[i]=i+1;
	REP(i,m){
		int k;
		cin>>k;
		if(k==0){
			refl(card);
		}else{
			cutk(card,k);
		}
	}
	REP(i,2*n)cout<<card[i]<<endl;
	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    byte i1 = sc.nextByte();
    byte i2 = sc.nextByte();
    byte i3 = sc.nextByte();
    if(i1 + i2 + i3 > 21){
      System.out.println("bust");
    }else{
      System.out.println("win");
    }
  }
}

Measured memory_bytes: 21716
#include<stdio.h>

int main(){
	long long N,K,ans=0;
	scanf("%lld%lld",&N,&K);
	
	for(long long b=K+1;b<=N;b++){
		long long p=N/b;
		long long q=N%b-K+1;
		if(q<0)q=0;
		ans+=(b-K)*p+q;
		if(K==0)ans--;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#ifdef __STRICT_ANSI__
#undef __STRICT_ANSI__
#endif
#include<iostream>
//#include<bits/stdc++.h>
#include<cstdio>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<ctime>
#include<algorithm>
#include<cmath>
#include<vector>
#define showtime fprintf(stderr,"time = %.15f\n",clock() / (double)CLOCKS_PER_SEC)
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
#define MP make_pair
#define PII pair<int,int>
#define PFI pair<double,int>
#define PLL pair<ll,ll>
#define F first
#define S second
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
//freopen("1005.in","r",stdin);
//freopen("data.out","w",stdout);
typedef vector<ll> Vec;
typedef vector<Vec> Mat;
const double eps = 1e-8;
const double PI = acos(-1.);
const double E = 2.71828182845904523536;
const int MOD = (int)1e9+7;
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x7f7f7f7f;
const int N = 1e5 + 7;
const int M = 2000000 + 5;

inline int popcnt(int x){return __builtin_popcount(x); }
inline int clz(int x){return __builtin_clz(x);} //末尾的 0，即对 lowbit 取log
inline int clz(LL x){return __builtin_clzll(x);}
inline int lg2(int x){ return !x ? -1 : 31-clz(x);}
inline int lg2(LL x){ return !x ? -1 : 63-clz(x);}

int n,a[111111];
ll sum,all,cnt,no[111111],aaa,bbb;
int t[55];
int main(){
	scanf("%d",&n);
	for(int i = 0; i < n; i ++){
	 	scanf("%d",&a[i]);
		sum += a[i];
	}
	all = 1ll*(1+n)*n/2;
	if(sum % all) return 0*puts("NO");
	cnt = sum / all;
	// x+y=cnt=3
	// -x+4y=a[0]-a[1]=-3
	// y = 0 , x = 3;
	aaa = 0, bbb = 0;
	for(int i = 0; i < n; i ++){
		if(a[i]-a[(i+1)%n]+cnt < 0 || (a[i]-a[(i+1)%n]+cnt)%n) return 0*puts("NO");
		int y = (a[i]-a[(i+1)%n]+cnt) / n;
		int x = cnt-y;
		if(x < 0 || y < 0) return 0*puts("NO");
		no[(i+1)%n] = y;
		aaa += (x+y);
	}
  if(aaa == cnt*n) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <string>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for(char c:s)pcu(c);}
_vo(string s){for(char c:s)pcu(c);}
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
//_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	unordered_map<string, int> m;
	string k;
	for (int i = in(); i; i--) {
		int o = in();
		scan(k);
		switch(o) {
		case 0:
			m[k] = in();
			break;
		case 1:
			outl(m[k]);
			break;
		default:
			m.erase(k);
			break;
		}
	}
}


Measured memory_bytes: 25904
#include<bits/stdc++.h>
#define int long long
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)

signed main(){
    ll k;
    cin >> k;
    ll a = 7;
    for(int i = 1; i <= k; i++){
        a %= k;
        if(a % k == 0){
            cout << i << endl;
            return 0;
        }
        a = 10*a + 7;
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3632
import bisect

n = int(input())
l = list(int(i) for i in input().split())
list.sort(l)
count = 0

for i in range(n):
    a = l[i]
    for j in range(i+1, n):
        b = l[j]
        ab = a + b
        index_c = bisect.bisect_left(l, ab)
        count += index_c - j -1

print(count)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {

fast();

{
  ll n;
  cin>>n;
  set<ll>s;
  for(int i=1;i<=n;i++)
  {
    ll x;
    cin>>x;
    s.insert(x);
  }
if(s.size()<n)
{
  NO
}
else
{
  YES
}

}
return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>
#include <string.h>


int main(void)
{
    char W[11];
    char T[1001];
    int count = 0;
    int x;

    scanf("%s", W);

    while(1){

        scanf("%s", T);
        x = strlen(T);

        if(strcmp(T, "END_OF_TEXT") == 0){
            break;
        }

        for(int i = 0; i < x; i++){
            if(65 <= T[i] && T[i] <= 96){
                T[i] = T[i] + 32;
            }
        }

        if(strcmp(W, T) == 0){
            count++;
        }
    }

    printf("%d\n", count);
    return (0);
}



Measured memory_bytes: 2044
#include <iostream>

using namespace std;

const int MAX_N = 1e5 + 5;

int cnt [MAX_N];

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

  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    cnt[a]++;
  }

  int ans = 0;
  for (int i = 1; i < MAX_N - 1; i++) {
    ans = max(ans, cnt[i - 1] + cnt[i] + cnt[i + 1]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
//Be Name Khorgraph, Besmellah Rahmane Rahim, In The Name Of God;
//#include<bits/stweight++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include <iostream>
#include <fstream>


using namespace std;

int r;
double c = 3.14159265359;

int main()
{
	cin >> r;
	r = 2 * r;
	cout << setprecision(7) <<  r * c << endl;


}




Measured memory_bytes: 3776
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<double> x(n);
    vector<string> u(n);
    rep(i,n){
        cin >> x[i] >> u[i];
    }
    double res=0.0;
    rep(i,n){
        if(u[i]=="JPY"){
            res+=x[i];
        }else{
            res+=x[i]*380000.0;
        }
    }
    cout << res << endl;
    return 0;
}

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

int main() {
  int n, k;
  bool c = true;
  cin >> n >> k;
  if(n % 2 == 0) {
    if(n/2 >= k) {
      cout << "YES";
      c = false;
    }
  }else{
    if(n/2+1 >= k) {
      cout << "YES";
      c = false;
    }
  }
  if(c) cout << "NO";
} 

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

int main(){
    int N,M;
    cin >> N >> M;
    int ans=0;
    if(N>=1){
        ans += N*(N-1)/2;
    }
    if(M>=1){
        ans += M*(M-1)/2;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int A,B,K ;
    int i,cnt,small;
    int a[101]={};
    int ans=0;
    cnt=0;
    
    scanf("%d %d %d",&A,&B,&K);
    if(A>B) small=B;
    else small=A;
    for(i=1;i<=small;i++){
        if(A%i==0 && B%i==0){
            cnt++;
            a[cnt]=i;
            // if(cnt==K) ans = i;
        }
    }
    //printf("%d\n",cnt);
    //for(i=0;i<=small;i++){
    //    printf("%d\n",a[i]);
    //}
    printf("%d\n",a[cnt-K+1]);

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
vector<char> vec(6);
  rep(i,6) {
    cin >>vec.at(i);
  }
  if((vec.at(1)==vec.at(4)) &&(vec.at(0)==vec.at(5)) && (vec.at(2)==vec.at(3)))  {
    cout << "YES" << endl;
  }
else {
cout << "NO" << endl;
}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
static const int N=1000;


int lcs(string X,string Y){
    int c[N+1][N+1];
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    X = ' ' + X;//在X[0]中插入空格
    Y = ' ' + Y;//在Y[0]中插入空格
    for(int i=0;i<=m;i++) c[i][0]=0;
    for(int j=1;j<=n;j++) c[0][j]=0;
    
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(X[i]==Y[j]) c[i][j]=c[i-1][j-1]+1;
            else c[i][j]=max(c[i-1][j],c[i][j-1]);
            maxl=max(maxl,c[i][j]);
        }
    }
    return maxl;
}
int main(){
    string s1,s2;
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>s1>>s2;
        cout<<lcs(s1,s2)<<endl;
    }
    return 0;
}


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

using namespace std;

vector<int> six = {6,36,216,1296,7776,46656};
vector<int> nine = {9,81,729,6561,59049};

int dfs(int n);

int main(){
    int n;
    cin >> n;
    int sum = 0;
    /*
    while(n >= 10000){
        int nine_max = 1, six_max = 1;
        for(vector<int>::iterator i = nine.begin(); i < nine.end(); i++){
            if(n < *i) break;
            nine_max = *i;
        }
        for(vector<int>::iterator i = six.begin(); i < six.end(); i++){
            if(n < *i) break;
            six_max = *i;
        }
        n -= max(nine_max, six_max);
        sum++;
    }
    /*
    if(n < 6)
        cout << sum + n << endl;
    else if(n < 9)
        cout << sum + n - 6 + 1 << endl;
    else if(n < 12)
        cout << sum + n - 9 + 1 << endl;
    else
        cout << sum + n - 12 + 2 << endl;
    */
    cout << dfs(n) + sum << endl;
    return 0;
}

int dfs(int n){
    if(n < 6)
        return n;
    int nine_max = 1, six_max = 1;
    for(vector<int>::iterator i = nine.begin(); i < nine.end(); i++){
        if(n < *i) break;
        nine_max = *i;
    }
    for(vector<int>::iterator i = six.begin(); i < six.end(); i++){
        if(n < *i) break;
        six_max = *i;
    }

    return min(dfs(n - nine_max), dfs(n - six_max)) + 1;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int A, B, C, D, E;
	cin >> A >> B >> C >> D >> E;

	A += 9;
	B += 9;
	C += 9;
	D += 9;
	E += 9;
	int min_extra = min({A % 10, B % 10, C % 10, D % 10, E % 10});
	if (min_extra == 9)
		min_extra = 0;
	else
		min_extra -= 9;
	A /= 10;
	B /= 10;
	C /= 10;
	D /= 10;
	E /= 10;

	cout << (A + B + C + D + E) * 10 + min_extra << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
};

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

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

	int n,m,a;
	long long int res = 0;
	priority_queue <int> pque;

	cin >> n >> m;

	for(int i=0;i<n;i++)
	{
		cin >> a;
		pque.push(a);
	} 

	for(int i=0;i<m;i++)
	{
		int x = pque.top();
		pque.pop();
		pque.push(x/2);
	}

	while(!pque.empty())
	{
		res += pque.top();
		pque.pop();
	}

	cout << res << '\n';
	
	return 0;	
}

Measured memory_bytes: 1020
#include <algorithm>
#include <array>
#include <iostream>
#include <utility>

int main()
{
    int n;
    std::cin >> n;

    constexpr int size                                      = 2001;
    std::array<std::pair<long long, long long>, size> score = {std::make_pair(0, 0)};
    for (int i = 0; i < n; ++i)
    {
        std::cin >> score[i].first;
        score[i].second = i;
    }
    std::sort(score.begin(), score.end(), [](auto const& lhs, auto const& rhs) { return lhs.first > rhs.first; });

    std::array<std::array<long long, size>, size> dp = {{0}};
    for (int i = 0; i < n; ++i)
    {
        for (int x = 0; x <= i; ++x)
        {
            int y        = i - x;
            dp[x + 1][y] = std::max(dp[x + 1][y], dp[x][y] + score[i].first * std::abs(x - score[i].second));
            dp[x][y + 1] = std::max(dp[x][y + 1], dp[x][y] + score[i].first * std::abs(n - 1 - y - score[i].second));
        }
    }

    long long result = 0;
    for (int i = 0; i <= n; ++i)
    {
        result = std::max(dp[i][n - i], result);
    }
    std::cout << result << std::endl;

    return 0;
}


Measured memory_bytes: 34504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

struct dice{
    int s[6];
    void roll(char c) {
        int tmp;
        if (c == 'E') {
            tmp = s[0];
            s[0] = s[3];
            s[3] = s[5];
            s[5] = s[2];
            s[2] = tmp;
        } else if (c == 'W') {
            tmp = s[0];
            s[0] = s[2];
            s[2] = s[5];
            s[5] = s[3];
            s[3] = tmp;
        } else if (c == 'N') {
            tmp = s[0];
            s[0] = s[1];
            s[1] = s[5];
            s[5] = s[4];
            s[4] = tmp;
        } else {
            tmp = s[0];
            s[0] = s[4];
            s[4] = s[5];
            s[5] = s[1];
            s[1] = tmp;
        }
    }
    int top() {
        return s[0];
    }
};

int main()
{
    dice d;
    rep(i, 0, 6) cin >> d.s[i];
    string order;
    cin >> order;
    int len = order.size();
    rep(i, 0, len) {
        d.roll(order[i]);
    }
    cout << d.top() << endl;
    return 0;
}



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

const int N=2e5+20;

int n,k,a[N];
priority_queue <int> pq;
long long ans;

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]),pq.push(a[i]);

	while(not pq.empty() and k>0)
	{
		pq.pop();
		k--;
	}

	while(not pq.empty()) ans+=pq.top(),pq.pop();
	cout<<ans;
}

Measured memory_bytes: 1912
s = gets.chomp
if s.size < 26
  code=[*97..122].each_with_object({}){|c,h|h[c.chr]=s.include?(c.chr)}
  x = code.select{_2==false}.keys.sort
  puts "#{s}#{x.first}"
  exit
end
x = s[-1]
(s.size-1).times.reverse_each do |i|
  if x < s[i]
    x = s[i]
    next
  end
  puts s[0...i] + s[i..-1].chars.select{|c| s[i] < c}.sort[0]
  exit
end
puts "-1"


Measured memory_bytes: 14276
H, W = map(int, input().split())
list = []
for i in range(H):
  s = input()
  list.append(s)
ans = [[0] * W for i in range(H)]  

for i in range(H):
  for j in range(W):
    if list[i][j] == '#':
      try:
        ans[i][j] = ''
        ans[i][j] = '#'
      except:
        pass
      try:
        if i-1 == -1 or j-1 == -1:
          pass
        else:
          ans[i-1][j-1] += 1
      except:
        pass
      try:
        if i-1 == -1:
          pass
        else:
          ans[i-1][j] += 1
      except:
        pass
      try:
        if i-1 == -1:
          pass
        else:
          ans[i-1][j+1] += 1
      except:
        pass
      try:
        if j-1 == -1:
          pass
        else:
          ans[i][j-1] += 1
      except:
        pass
      try:
        ans[i][j+1] += 1
      except:
        pass
      try:
        if j-1 == -1:
          pass
        else:
          ans[i+1][j-1] += 1
      except:
        pass
      try:
        ans[i+1][j] += 1
      except:
        pass
      try:
        ans[i+1][j+1] += 1
      except:
        pass  
      
for i in range(H):
  line = ''
  for j in range(W):
    line += str(ans[i][j])
  print(line)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	
	if(a<b && b<c){
		printf("Yes");
		printf("\n");	
	}
	else{
		printf("No");
		printf("\n");
	}
return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;
// Welcome to my source code!

int search(int s[], int n, int key) {
    int i = 0;
    s[n] = key;
    while (s[i] != key) i++;
    return i != n;
}

int main() {
    int n, q, key, sum = 0; cin >> n;
    int s[n+1];
    rep(i,n) cin >> s[i];
    cin >> q;
    rep(i,q) {
        cin >> key;
        if (search(s, n, key)) sum++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3104
/*
概率DP，背包模型 
dp[i][j]表示前i枚硬币中，有j枚头朝上的概率 
*/
#include<cstdio>
#include<vector>
#include<algorithm>
#define MAXN 3005
double dp[MAXN][MAXN];
double p[MAXN];
int n; 
double ans;
int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
        scanf("%lf", &p[i]);
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        dp[i][0] = dp[i-1][0] * (1-p[i]);
        for(int j = 1; j <= n; j++)
            dp[i][j] = dp[i-1][j] * (1-p[i]) + dp[i-1][j-1] * p[i];
    }
    for(int i = n / 2 + 1; i <= n; i++)
        ans += dp[n][i];
    printf("%.10f\n", ans);
        
}


Measured memory_bytes: 70656
def main():
    # import sys
    # readline = sys.stdin.readline
    # readlines = sys.stdin.readlines
    
    A = input()
    N = len(A)
    a = ord('a')

    INF = N
    na = [[INF] * 26 for _ in range(N + 1)]
    for i in range(N - 1, -1, -1):
        c = ord(A[i]) - a
        for j in range(26):
            na[i][j] = na[i + 1][j]
        na[i][c] = i

    dp = [INF] * (N + 1)
    dp[N] = 1
    recon = [None] * (N + 1)
    for i in range(N - 1, -1, -1):
        for j in range(26):
            ni = na[i][j]
            if ni == N:
                if dp[i] > 1:
                    dp[i] = 1
                    recon[i] = (chr(a + j), N)
            elif dp[i] > dp[ni + 1] + 1:
                dp[i] = dp[ni + 1] + 1
                recon[i] = (chr(a + j), ni + 1)

    # k =
    # for j in range(26):
    #     ni = na[0][j]
    #     if dp[i] > dp[ni] + 1:

    i = 0
    ans = []
    while i < N:
        c, ni = recon[i]
        ans.append(c)
        i = ni

    print(''.join(ans))


if __name__ == "__main__":
    main()


Measured memory_bytes: 127776
#include<bits/stdc++.h>
using namespace std;
string s;
int b=0,ans=0;
int main()
{
	cin>>s;
	for(int i=0;i<s.length();++i)
	{
		if(s[i]=='C') b=1;
		if(b==1&&s[i]=='F') 
		{cout<<"Yes";
		ans=1;
		break;
		}
	}
	if(ans==0) cout<<"No";
	return 0;
}

Measured memory_bytes: 256
def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor: GCD)を求める
    計算量: O(log(min(a, b)))
    """
    while b:
        a, b = b, a % b
    return a


def lcm(a: int, b: int) -> int:
    """a, bの最小公倍数(least common multiple: LCM)を求める
    計算量: O(log(min(a, b)))
    """
    return (a * b) // gcd(a, b)


def multi_gcd(array: list) -> int:
    """arrayのGCDを求める"""
    n = len(array)
    ans = array[0]
    for i in range(1, n):
        ans = gcd(ans, array[i])
    return ans


n = int(input())
a = list(map(int, input().split()))

print(multi_gcd(a))

Measured memory_bytes: 62704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

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

	if (A >= 13) co(B);
	else if (A >= 6) co(B / 2);
	else co(0);
	
	Would you please return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N,0);
  for (int i = 0; i < N-1; i++ ) {
    int x;
    cin >> x;
    A[x-1] += 1;
  }
  
  for (int e : A) cout << e << endl;
}

Measured memory_bytes: 3996
/*		     ___
			(._.)
			<|>         HELLO IT'S ME! KINGSLEY ZHONG!
			_/\_
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          ___   ____
        /' --;^/ ,-_\     \ | /
       / / --o\ o-\ \\   --(_)--
      /-/-/|o|-|\-\\|\\   / | \
       '`  ` |-|   `` '
             |-|
             |-|O                    2020 @ CodeForces, CodeChef, CCC & More!
             |-(\,__
          ...|-|\--,\_....
      ,;;;;;;;;;;;;;;;;;;;;;;;;,.
~~,;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,  ______   ---------   _____     ------
 */


//Optimisation
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)\
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")\
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


//Imports
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <queue>
#include <vector>

using namespace std;

//Macros
#define el '\n'
#define elc << el;
#define debug(x) cout << ">>" << x << el;
#define rep(i, c) for(int i = 0; i <(c); ++i)
#define fora(i, s, c) for(int i = (s); i < (c); ++i)
#define forr(i, s, c) for(int i = (s); i > (c); --i)
#define pb push_back
#define eb emplace_back
#define ff first;
#define ss second;
#define mp make_pair;
#define all(p) p.begin(),p.end()
#define max(x,y) (x>y)?x:y
#define min(x,y) (x<y)?x:y
#define mid(s,e) (s+(e-s)/2)
#define absv(a) (a<0)?(-1*a):a
#define negv(a) (a>0)?(-1*a):a
#define arrset(a,b,v) rep(i, b) a[i]=v //Sets array to a value, where a is the array, b is the count, and v is the value

//Typedefs
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;

//Random Stuff
#define Pi 3.141592653589793
#define space << ' ' <<
const ll mod = 1000000007;

//Functions
inline int twop(int n) { return 1 << n; }
template<class T> T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<class T> T lcm(T a, T b ){return (a*b)/gcd(a,b);}

//Testcase start
#define tcs() int testcases; cin >> testcases; while(testcases--)

int main() {
	//Fast io for cin / cout
	ios_base::sync_with_stdio(false);
	cin.tie(0); //Comment out if there is large exchange of cin / cout
	cout.tie(0);

	string s;
	cin >> s;

	int sz = s.size();

	int p2 = sz-1;
	rep(a, (sz-1)/2){
		if(s[a] != s[p2]){
			cout << "No" elc;
			return 0;
		}
		p2--;
	}

	int t2 = (sz-1)/2;
	int t3 = (sz+3)/2;

	int p3 = t2-1;
	rep(a, (t2)/2){
		if(s[a] != s[p3]){
			cout << "No" elc;
			return 0;
		}
		p3--;
	}

	int p4 = sz-1;
	fora(a, t3-1, (sz-t3-1)/2){
		if(s[a] != s[p4]){
			cout << "No" elc;
			return 0;
		}
		p4--;
	}

	cout << "Yes" elc;



	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////


int main() {
	int N, x; cin >> N >> x;
	if (x == 1 || x == 2 * N - 1) {
		cout << "No" << endl;
		return 0;
	}
	int ans[200000];
	if (x != 2) {
		ans[N - 2] = x - 1;
		ans[N - 1] = x;
		ans[N] = x + 1;
		queue<int>que;
		for (int i = 1; i < 2 * N; ++i) {
			if (i != x-1 && i != x && i != x+1) {
				que.push(i);
			}
		}
		REP(i, 2 * N - 1) {
			if (i == N - 2 ||i== N - 1 || i==N)continue;
			ans[i] = que.front();
			que.pop();
		}
	}
	else {
		ans[N - 2] = 3;
		ans[N - 1] = 2;
		ans[N] = 1;
		queue<int>que;
		for (int i = 1; i < 2 * N; ++i) {
			if (i != 3 && i != 2 && i != 1) {
				que.push(i);
			}
		}
		REP(i, 2 * N - 1) {
			if (i == N - 2 || i==N - 1 || i==N)continue;
			int x = que.front();
			ans[i] = x;
			que.pop();
		}
	}
	cout << "Yes" << endl;
	REP(i, 2 * N-1) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 2396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			String str[] = br.readLine().split("");
			StringBuilder sb = new StringBuilder();

			int count = 0;
			for (int j = 0; j < str.length; j++) {
				String s = str[j];
				if (s.equals("0")) {
					if (j - 1 < 0) {
						if (!str[j].equals("0"))
							sb.append(getStr(str[j], count));
					} else {
						if (!str[j - 1].equals("0"))
							sb.append(getStr(str[j - 1], count));
					}
					count = 0;
				} else {
					count++;
				}
			}
			System.out.println(sb);
		}
	}

	static char getStr(String s, int count) {
		switch (Integer.parseInt(s)) {
		case 1:
			switch (count % 5) {
			case 1:
				return '.';
			case 2:
				return ',';
			case 3:
				return '!';
			case 4:
				return '?';
			case 0:
				return ' ';
			}
			break;
		case 2:
			switch (count % 3) {
			case 1:
				return 'a';
			case 2:
				return 'b';
			case 0:
				return 'c';
			}
			break;
		case 3:
			switch (count % 3) {
			case 1:
				return 'd';
			case 2:
				return 'e';
			case 0:
				return 'f';
			}
			break;
		case 4:
			switch (count % 3) {
			case 1:
				return 'g';
			case 2:
				return 'h';
			case 0:
				return 'i';
			}
			break;
		case 5:
			switch (count % 3) {
			case 1:
				return 'j';
			case 2:
				return 'k';
			case 0:
				return 'l';
			}
			break;
		case 6:
			switch (count % 3) {
			case 1:
				return 'm';
			case 2:
				return 'n';
			case 0:
				return 'o';
			}
			break;
		case 7:
			switch (count % 4) {
			case 1:
				return 'p';
			case 2:
				return 'q';
			case 3:
				return 'r';
			case 0:
				return 's';
			}
			break;
		case 8:
			switch (count % 3) {
			case 1:
				return 't';
			case 2:
				return 'u';
			case 0:
				return 'v';
			}
			break;
		case 9:
			switch (count % 4) {
			case 1:
				return 'w';
			case 2:
				return 'x';
			case 3:
				return 'y';
			case 0:
				return 'z';
			}
			break;
		}
		return '0';
	}
}


Measured memory_bytes: 30660
from collections import deque

n = int(input())
g = [[] for _ in range(n)]
ans = [-1] * n
for i in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    g[v].append([u, w])
    g[u].append([v, w])

queue = deque([0])
while queue:
    now = queue.popleft()
    for u, w in g[now]:
        if ans[u] != -1:
            continue
        ans[u] = ans[now] + w
        queue.append(u)
for a in ans:
    if a % 2 == 0:
        print(1)
    else:
        print(0)


Measured memory_bytes: 49320
#include<iostream>
#include <climits>
#include<vector>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<ll> R(n);
	int max = INT_MIN;
	int min = INT_MAX;
	REP(i, n) {
		cin >> R[i];
		if (max < R[i] - min) max = R[i] - min;
		if (min > R[i]) min = R[i];
	}
	cout << max << "\n";

	return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li n,r;
    cin>>n>>r;
    if(n>=10){
        cout<<r<<endl;
    }else {
        cout<<r+100*(10-n)<<endl;
    }


    return 0;
}

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

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

  ll R; cin >> R;
  ll C; cin >> C;
  ll K; cin >> K;
  vector<vector<ll>> cells(R, vector<ll>(C, 0));
  for (ll i = 0; i < K; i++) {
    ll r; cin >> r;
    ll c; cin >> c;
    ll v; cin >> v;
    r--; c--;
    cells[r][c] = v;
  }
  vector<vector<vector<ll>>> dp(R + 1, vector<vector<ll>>(C + 1, vector<ll>(4, 0)));
  for (ll r = 0; r < R; r++) {
    for (ll c = 0; c < C; c++) {
      ll v = cells[r][c];
      if (v == 0) {
        for (ll i = 0; i < 4; i++) {
          dp[r + 1][c + 0][0] = max(dp[r + 1][c + 0][0], dp[r + 0][c + 0][i]);
          dp[r + 0][c + 1][i] = max(dp[r + 0][c + 1][i], dp[r + 0][c + 0][i]);
        }
      } else {
        for (ll i = 0; i < 4; i++) {
          dp[r + 1][c + 0][0] = max(dp[r + 1][c + 0][0], dp[r + 0][c + 0][i]);
          dp[r + 0][c + 1][i] = max(dp[r + 0][c + 1][i], dp[r + 0][c + 0][i]);
        }
        for (ll i = 0; i < 3; i++) {
          dp[r + 1][c + 0][0] = max(dp[r + 1][c + 0][0], dp[r + 0][c + 0][i] + v);
        }
        for (ll i = 0; i < 3; i++) {
          dp[r + 0][c + 1][i + 1] = max(dp[r + 0][c + 1][i + 1], dp[r + 0][c + 0][i] + v);
        }
      }
    }
  }

  ll ans = 0;
  for (ll i = 0; i < 4; i++) {
    ans = max(ans, dp[R - 1][C - 1][i]);
    ans = max(ans, dp[R - 1][C - 0][i]);
    ans = max(ans, dp[R - 0][C - 0][i]);
  }
  cout << ans << '\n';
  return 0;
}

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

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

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define Ms(s, n) memset(s, n, sizeof(s))
#define Rp(i,l,m) for(int i=l; i<m; ++i)
#define Rpd(i,l,m) for(int i=l; i>=m; --i)
#define Rpp(i,l,m) for(int i=l; i<=m; i++)
#define RpAll(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define All(a) (a).begin(), (a).end()
#define Fi first
#define Se second
#define Pb push_back
#define Pf push_front
#define Is insert
#define Sz(a) int((a).size())
#define ooi INT_MAX
#define ool LLONG_MAX
#define endl "\n"
#define maxx(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
const int MOD = (int) 1e9 + 7;
const ld PI = acos((ld) -1);
inline ll gcd(ll a,ll b) {ll r;while(b){r=a%b;a=b;b=r;}return a;}
inline ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
inline ll fpow(ll n,ll k){ll r=1; for(;k;k>>=1){if(k&1)r=r*n%MOD;n=n*n%MOD;}return r;}
const int base = 311;
const int N = 5000 + 5;

ll m, n, k, ans, a[N], F[N][N];
// 10 5 2 3 2 3 2 2 3 2 3 2
void Solve(){
    cin >> m >> n;
    cout << maxx(m + n, m - n, m * n);
}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<map>
#include<cstring>
#include<cmath>
#include<iostream>
using namespace std;
typedef long long LL;

map<pair <string,string>,LL> cnt;
const int maxn = 50;
char s[maxn];

int main(){
	int n; scanf("%d",&n);
	scanf("%s",s);
	for(int i = 0;i < (1 << n);i++){
		string s1 = "",s2 = "";
		for(int j = 0;j < n;j++){
			if(i & (1 << j)) s1 += s[j];
			else s2 += s[j];
		}
		cnt[make_pair(s1,s2)]++;
	}
	LL sum = 0;
	for(int i = 0;i < (1 << n);i++){
		string s1 = "",s2 = "";
		for(int j = n - 1;j >= 0;j--){
			if(i & (1 << j)) s2 += s[j + n];
			else s1 += s[j + n];
		}
		sum += cnt[make_pair(s2,s1)];
	}
	printf("%lld\n",sum);
}

Measured memory_bytes: 91904
#include<bits/stdc++.h>
int main(int argc, char *argv[])
{
  int A,B,C;
  int res=0;
  scanf("%d %d %d",&A,&B,&C);
  if(A%2!=0||B%2!=0||C%2!=0){
    printf("0\n" );
    return 0;
  }
  if(A==B&&B==C){
    printf("-1\n");
    return 0;
  }
  
  while(A%2==0&&B%2==0&&C%2==0){
    int tmpA = B/2+C/2;
    int tmpB = A/2+C/2;
    int tmpC = B/2+A/2;
    A=tmpA;
    B=tmpB;
    C=tmpC;
    res++;
  }
  printf("%d\n",res);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){  
    int m, f, r; 
    while(1){        
        scanf("%d %d %d ", &m, &f, &r);      
        if(m==-1&&f==-1&&r==-1)break;      
        if(m==-1||f==-1){           
            printf("F\n");       
            }else if(m+f>=80){    
                printf("A\n");       
                }else if(m+f>=65){       
                    printf("B\n");       
                }else if(m+f>=50){       
              printf("C\n");      
              }else if(m+f>=30){      
                  if(r>=50){     
                      printf("C\n");       
                      }else{             
                          printf("D\n");     
                          }   
                          }else{     
                              printf("F\n");    
                              }  
                              }  
                              return 0;
}
                  
                  
                  


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;


int main(){
  int N, T;
  while(cin >> N >> T){
    vector<int> A(N), B(N);
    REP(i,N) cin >> A[i] >> B[i];

    vector<int> ord(N);
    iota(ALL(ord), 0);
    sort(ALL(ord), [&](int i, int j){return A[i] < A[j];});
    

    vector<vector<int>> dp(N+1, vector<int>(T));

    REP(i,N){
      REP(j,T){
        chmax(dp[i+1][j], dp[i][j]);

        if(j+A[ord[i]] < T){
          chmax(dp[i+1][j+A[ord[i]]], dp[i][j] + B[ord[i]]);
        }
      }
    }

    int ans = 0;

    REP(i,N){
      chmax(ans, dp[i][T-1] + B[ord[i]]);
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 35584
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <complex>

using namespace std;
using pii = pair<int, int>;
using ll = long long;

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

	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	vector<pii> v(m);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < m; i++) cin >> v[i].second >> v[i].first;
	sort(a.begin(), a.end());
	sort(v.rbegin(), v.rend());
	int p = 0;
	for (int i = 0, j = 0; i < m; i++) {
		for (int j = 0; j < v[i].second && p < n; j++, p++) {
			if (a[p] < v[i].first) a[p] = v[i].first;
			else break;
		}
	}
	ll answer = 0;
	for (int aa : a) answer += (ll)aa;
	cout << answer;

	return 0;
}


Measured memory_bytes: 1408
//Author: Rahul Purohit

#include<bits/stdc++.h>
#define vi vector<int>
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll  long long int
#define pi pair<ll,ll>
#define f first
#define mp make_pair
#define mod 1000000007
#define s second
#define pb push_back
#define mp make_pair
#define N 100001
using namespace std;
int gcd(int a, int b)
{
	if(b==0)
		return a;
	else
		return (b,a%b);
}
/*ll isp[N]={1};
void sieve(int n)
{
	isp[0]=isp[1]=0;
	for(int i=2;i<=n;i++)
	{
		if(isp[i]==1)
		{
			for(int j=i*i;j<=n;j+=i)
			{
				isp[j]==0;
			}
		}
	}
}*/
ll pow(int x,int  y,int m)
{
	ll ans=1;
	while(y!=0)
	{
		if(y%2==1)
		{
			ans=(ans*x)%m;
		}
		x=(x*x)%m;
		y/=2;
	}
	return ans;
}
template <class x>
void swap(x &a,x &b)
{
	x tp;
	tp=a;
	a=b;
	b=tp;
}
template <class x>
void max(x &a,x &b)
{
	return (a>=b?a:b);
}
template <class x>
void min(x &a,x &b)
{
	return (a>=b?b:a);
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll n;
	cin >> n;
	if(n>999)
	{
		cout<<"ABD\n";
	}
	else
	{
		cout<<"ABC\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
    ll n,k;
    cin>>n>>k;
    if (n%k<=abs(n%k-k))
    {
        /* code */
        cout<<abs(n%k)<<endl;
    }
    else
    {
        cout<<abs(n%k-k)<<endl;
    }
    
    
    
    
}


Measured memory_bytes: 256
n,m=map(int,input().split())
A=[]
for _ in range(m):
    A.append([i-1 for i in list(map(int,input().split()))[1:]])
P=list(map(int,input().split()))
ans=0
for bit in range(1<<n):
    for j in range(m):
        now=0
        for i in A[j]:
            if bit & 1<<i: now+=1
        if now%2!=P[j] : break
        if j==m-1: 
            
            ans+=1


print(ans)
                

Measured memory_bytes: 39920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+20;
int main()
{
	 int a,b,c,d;
	 while(cin>>a>>b>>c>>d)
	 {
	 	cout<<max(a*b,c*d)<<endl;
	 }
 
	return 0;
}


Measured memory_bytes: 256