akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n,m;
  cin>>n>>m;
  vector< vector<ll>> key(m,vector<ll>(2,0));
  rep(i,m){
    ll a,b;
    cin>>a>>b;
    key[i][0]=a;
    ll op=0;
    rep(j,b){
      ll c;
      cin>>c;
      op |= 1<<(c-1);
    }
    key[i][1]=op;
  }
  /*
  rep(i,m){
    cout << key[i][0] << "," << std::bitset<12>(key[i][1]) << endl;
  }
  */
  vector<ll> dp(4096,INF);
  dp[0]=0;
  rep(i,m){
    rep(j,4096){
      ll next_sta=(key[i][1] | j);
      dp[next_sta]=min( dp[next_sta],dp[j]+key[i][0] );
    }
  }
  if( dp[ (1<<n) - 1 ] == INF) cout << -1 << endl;
  else cout << dp[ (1<<n) - 1 ] << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <complex>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << "\n"
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[300][300];
char field[200][200];
bool prime[55560];

int mov[2] = {-1,1};

int dfs(int x,int y){
  int res = 0;
  if(field[x][y] == '#'){
    res++;
    field[x][y] = '.';
  }
  rep(i,0,2){
    if(field[x+mov[i]][y] == '#')res += dfs(x+mov[i],y);
    if(field[x][y+mov[i]] == '#')res += dfs(x,y+mov[i]);
  }
  // cout << x << " , " << y << " : " << res << endl;
  return res;
}

int main(){
  cin >> n >> m;
  bool f = true;
  lep(i,1,n)lep(j,1,m)cin >> field[i][j];
  lep(i,1,n){
    lep(j,1,m){
      if(field[i][j] == '#'){
        if(dfs(i,j) <= 1)f = false;
      }
    }
  }
  if(f)puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int N=1000;
long long X;
long long f(long long n){
    return n*n*n*n*n;
}
int main(){
    cin>>X;
    long long A[N+1],B[N+1];

    for(int i=0;i<=N;i++){
        A[i]=B[i]=f(i);
    }
    // for(int i=0;i<=N;i++){
    //     cout<<A[i]<<" "<<B[i]<<endl;;
    // }
    //++
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            if(A[i]+B[j]==X){cout<<i<<" "<<-j<<endl;return 0;}
        }
    }
    //+-
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            if(A[i]-B[j]==X){cout<<i<<" "<<j<<endl;return 0;}
        }
    }
    //-+
    // for(int i=0;i<=N;i++){
    //     for(int j=0;j<=N;j++){
    //         if(-A[i]+B[j]==X){cout<<-i<<" "<<-j<<endl;return 0;}
    //     }
    // }

    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  string S;
  cin >> S;

  int s_size = S.length();
  vector<int> ans(s_size, 0);

  int lastLR = -1;
  int lastRL = -1;
  bool flag = false;
  for(int i = 0; i < s_size; i++){
    if(i == s_size-1){
      int num = i - lastLR;
      if(num%2 == 0){
        ans[lastRL] = num/2;
        ans[lastRL+1] = num/2;
      } else {
        int l = lastRL - lastLR;
        if(l%2 == 0){
          ans[lastRL] = num/2;
          ans[lastRL+1] = num/2+1;
        } else {
          ans[lastRL] = num/2+1;
          ans[lastRL+1] = num/2;
        }
      }
      continue;
    }
    if(S[i] == 'R' && S[i+1] =='L'){
      lastRL = i;
      continue;
    }
    if((S[i] == 'L' && S[i+1] =='R')){
      int num = i - lastLR;
      if(num%2 == 0){
        ans[lastRL] = num/2;
        ans[lastRL+1] = num/2;
      } else {
        int l = lastRL - lastLR;
        if(l%2 == 0){
          ans[lastRL] = num/2;
          ans[lastRL+1] = num/2+1;
        } else {
          ans[lastRL] = num/2+1;
          ans[lastRL+1] = num/2;
        }
      }
      lastLR = i;
    }
  }

  cout << ans[0];
  for(int i = 1; i < s_size; i++){
    cout << " " << ans[i];
  }
  cout << endl;
  return 0;
}



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

#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");

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

  if (s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    int c=stoi(a+b);
    for(int i=1;i<=1000;i++){
        if(i*i==c){cout<<"Yes"<<endl;return 0;}
        
    }
    cout<<"No"<<endl;
    return 0; 
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

/*
  素因数分解
    nを素因数分解した結果をllpに格納する。結果はllp[i].first = (素因数)、llp[i].second = （個数）
    n <= 1 の時は何もしないので注意。
    n が素数ならばllpには (n, 1) のpairのみが入っている
*/
void factorization(vector<LLP>& llp, long long n) {
    if (n <= 1) return;
    long long n2 = n;
    for (long long i = 2; i * i <= n ; i++) {
        int count = 0;
        while (n2 % i == 0) {
            n2 = n2 / i;
            count ++;
        }
        if (count > 0) {
            LLP temp;
            temp.first = i;
            temp.second = count;
            llp.push_back(temp);
        }
    }
    if (n2 > 1) {
        LLP temp;
        temp.first = n2;
        temp.second = 1;
        llp.push_back(temp);
    }
}

/*
    ユークリッドの互除法（正の整数x, yの最大公約数を返す）
*/

long long gcd(long long x, long long y) {
    if (x < y) swap(x, y);
    while (x % y != 0) {
        long long divisor = x % y;
        x = y;
        y = divisor;
    }
    return y;
}

int main() {

    long long A, B;
    cin >> A >> B;

    long long g = gcd(A, B);
    vector<LLP> p;
    factorization(p, g);

    cout << p.size() + 1 << endl;
    
    return 0;
}

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

long long gcd(long long a_in, long long b_in){
    long long a = a_in;
    long long b = b_in;
    if(a < b){
        std::swap(a, b);
    }
    while(b != 0){
        long long c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main(){
    int N, M;
    std::cin >> N >> M;
    std::vector< int > A_in(N);
    for(int i=0; i<N; i++){
        std::cin >> A_in[i];
    }
    std::sort(A_in.begin(), A_in.end());
    std::vector< int > A;
    int remove_num = 0;
    int pre = 0;
    int n2 = -1;
    for(int i=0; i<N; i++){
        int n2_cnt = 0;
        int a_test = A_in[i];
        while(a_test % 2 == 0){
            a_test /= 2;
            n2_cnt++;
        }
        if(i == 0){
            n2 = n2_cnt;
        }else{
            if(n2 != n2_cnt){
                std::cout << 0 << std::endl;
                return 0;
            }
        }
        if(A_in[i] != pre){
            A.push_back(A_in[i] / 2);
        }else{
            remove_num++;
        }
        pre = A_in[i];
    }
    N -= remove_num;
    
    long long gcd_num = A[0];
    for(int i=1; i<N; i++){
        gcd_num = gcd_num * (long long)A[i] / gcd(gcd_num, (long long)A[i]);
        if(gcd_num > 2 * (long long)M){
            std::cout << 0 << std::endl;
            return 0;
        }
    }
    
    
    int ans = ((long long)M + gcd_num) / (gcd_num * 2);
    
    std::cout << ans << std::endl;
    
    return 0;
}
    



Measured memory_bytes: 640
from itertools import product
N, M = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(N)]

ans = []

for lst in product([-1, 1], repeat = 3):
    temp = []
    for x, y, z in xyz:
        temp.append(x * lst[0] + y * lst[1] + z * lst[2])
    temp.sort(reverse=True)
    ans.append(sum(temp[:M]))

print(max(ans))

Measured memory_bytes: 9140
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

class MyComparator implements Comparator<Long> {

	public int compare(Long obj1, Long obj2) {

		long num1 = (long) obj1;
		long num2 = (long) obj2;

		if (num1 < num2) {
			return 1;
		} else if (num1 > num2) {
			return -1;
		} else {
			return 0;
		}
	}
}

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long left[] = new long[N];
		long center[] = new long[N];
		long right[] = new long[N];
		long suml[] = new long[N + 1];
		long sumr[] = new long[N + 1];
		Queue<Long> lqueue = new PriorityQueue<Long>(N + 1);
		Queue<Long> rqueue = new PriorityQueue<Long>(N + 1, new MyComparator());
		for (int i = 0; i < N; i++) {
			left[i] = sc.nextLong();
			lqueue.add(left[i]);
			suml[0] += left[i];
		}
		for (int i = 0; i < N; i++) {
			center[i] = sc.nextLong();
		}
		for (int i = 0; i < N; i++) {
			right[i] = sc.nextLong();
			rqueue.add(right[i]);
			sumr[N] += right[i];
		}

		long s = Long.MIN_VALUE;
		for (int i = 0; i < N; i++) {
			lqueue.add(center[i]);
			suml[i + 1] = suml[i] + center[i] - lqueue.poll();
		}
		for (int i = N-1; i >=0; i--) {
			rqueue.add(center[i]);
			sumr[i] = sumr[i+1] + center[i] - rqueue.poll();
		}
		for (int i = 0; i <= N; i++) {
			s = Math.max(s, suml[i] - sumr[i]);
		}
		System.out.println(s);
	}
}


Measured memory_bytes: 108580
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ d, n ] <- readInts
	let
		n' = if n == 100 then 101 else n
	print $ n' * ( 100 ^ d )

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

int main() {
    int n;
    cin >> n;
    string s;
    while (n != 0) {
        if (n % 2 == 0) {
            s = '0' + s;
        }    
        else {
            s = '1' + s;
            n--;
        }
        n /= -2;
    }
    if (s == "") s = '0';
    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<vector<int>> data(26, vector<int> (N));
  string S;
  for(int i = 0; i < N; i++) {
    cin >> S;
    for(char a: S) {
      data.at(a - 'a').at(i)++;
    }
  }
  int minnum;
  char c;
  for(int i = 0; i < 26; i++) {
    minnum = 100;
    for(int j = 0; j < N; j++) {
      minnum = min(minnum, data.at(i).at(j));
    }
    for(int j = 0; j < minnum; j++) {
      c = i + 'a';
      cout << c;
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	
	int n, l;
	cin>>n>>l;
	string s[n];
	
	for(int i=0 ; i<n ;i++){
		cin>>s[i];
	}
	sort(s, s+n);
	for(int i=0 ; i<n ;i++){
		cout<<s[i];
	}
	
	return 0;
	}

Measured memory_bytes: 3612
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin, (v).end);

typedef unsigned long long int ull;
typedef long long lint;

using namespace std;


int main(void){
    int A, B;

    //入力
    cin >> A >> B;

    if(A>9||A<1)    cout << -1 << endl;
    else if(B>9||B<1)   cout << -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<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;
const ll INF=1e18;

int N;
ll a[3010];
void input(){
    cin>>N;
    rep(i,N)cin>>a[i];
}

ll dp[3010][3010];
ll dfs(int l, int r, int f){
    if(dp[l][r]!=INF)return dp[l][r];
    if(l==r){
        dp[l][r]=0;
        return 0;
    }
    if(f==1){
        dp[l][r]=max(dfs(l,r-1,-f)+a[r-1], dfs(l+1, r, -f)+a[l]);
        return dp[l][r];
    }
    else{
        dp[l][r]=min(dfs(l,r-1,-f)-a[r-1], dfs(l+1, r, -f)-a[l]);
        return dp[l][r];
    }
}

ll ans;
void solve(){
  	rep(l,N+1)rep(r,N+1)if(l<=r)dp[l][r]=INF;
    ans=dfs(0,N,1);
}

void output(){
    cout<<ans<<endl;
}

int main(){
    input();
    solve();
    output();
}

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

int BinaryResearch(string s,int key,int n){
  int left = 0,right = n;
  int mid;
  while(left < right){
  	mid = (left+right)/2;
    if((int)s.at(mid) == key) return mid;
    else if(key < (int)s.at(mid)) right = mid+1;
    else if(key > (int)s.at(mid)) left = mid;
  }
  return -1;
}
int main()
{
  string s1,s2,s3; cin >> s1 >> s2 >> s3;
  int atoA = (int)('A')-(int)'a';
  cout << (char)(atoA+(int)s1.at(0)) << (char)(atoA+(int)s2.at(0)) << (char)(atoA+(int)s3.at(0)) << endl;
}

Measured memory_bytes: 256
#include<cstdio>

int n;
char s[4];
int main(){
	scanf("%s",s);

	for(int i = 0; s[i] != '\0'; i++){
        n++;
    }

	for(int i = 0; i < n; i++){
        s[i] -= '0';
    }

	long ans = 0;
	for(int S = 0;S < (1 << n);S++){
		long sum = s[0];
		long a = s[1];
		for(int i = 1;i < n;i++){
			if(S & (1 << i)){
				sum += a;
				a = s[i + 1];
			}else{
				sum -= a;
				a = s[i + 1];
			}
		}

        ans = sum;
        if(ans == 7){
            printf("%d",s[0]);
            for(int i = 1;i < n;i++){
                if(S & (1 << i)){
                    printf("+%d",s[i]);
                }else{
                    printf("-%d",s[i]);
                }
            }
            printf("=%ld\n",ans);
            break;
        }
	}

	return 0;
}

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

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define MAX 1000000
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)

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


int32_t main(){
	int a, b;
	cin>>a>>b;
	if(a==b) cout<<"Draw"<<endl;
	else{
		if(a==1) cout<<"Alice"<<endl;
		else if(b==1) cout<<"Bob"<<endl;
		else {
			if(a>b) cout<<"Alice"<<endl;
			else cout<<"Bob"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)
char s[1010];
int main() {
	cin >> s;
	if (s[strlen(s)-1] == 's') {
		s[strlen(s)] = 'e';
		s[strlen(s)] = 's';
	} else {
		s[strlen(s)] = 's';
	}
	cout << s << endl;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <string>

using namespace std;

int fromMCXI(const string &s) {
  int res = 0, t = 1;
  for (int i=0;i<s.size();i++) {
    switch (s[i]) {
    case 'm': res += t*1000; t = 1;break;
    case 'c': res += t*100; t = 1; break;
    case 'x': res += t*10; t = 1; break;
    case 'i': res += t; t = 1; break;
    default: t = s[i]-'0'; break;
    }
  }
  return res;
}

string toMCXI(int x) {
  string res = "";
  if (2000 <= x) res += (char)('0'+x/1000);
  if (1000 <= x) res += 'm';
  x %= 1000;
  if (200 <= x) res += (char)('0'+x/100);
  if (100 <= x) res += 'c';
  x %= 100;
  if (20 <= x) res += (char)('0'+x/10);
  if (10 <= x) res += 'x';
  x %= 10;
  if (2 <= x) res += (char)('0'+x);
  if (1 <= x) res += 'i';
  return res;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i=0;i<n;i++) {
    char buf[1001];
    string s1, s2;
    scanf("%s", buf); s1 = buf;
    scanf("%s", buf); s2 = buf;
    printf("%s\n", toMCXI(fromMCXI(s1)+fromMCXI(s2)).c_str());
  }
  return 0;
}

Measured memory_bytes: 2572
N, A, B = (int(x) for x in input().split())

x = input()
y = list(x)
count_a = 0
count_b = 0

for i in range(0, N):
    if (y[i] == "a"):
        if(count_a + count_b < (A + B)):
            print("Yes")
            count_a += 1
        else:
            print("No")
    
    elif(y[i] == "b"):
        if(count_a + count_b < (A + B) and count_b < B):
            print("Yes")
            count_b += 1
        else:
            print("No")
    
    elif(y[i] == "c"):
        print("No")

    

Measured memory_bytes: 4784
K = int(input())
num_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(num_list[K-1])

Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int cnt;
string s;
int main()
{
	cin >> s;
	REP(i, 0, s.size()) {
		if (s[i] == 'o')cnt++;
	}
	cout << 700 + 100 * cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;
 
signed main(){

    int n;
    cin >> n;
    int h[100010] = {0};
    rep(i,n)cin >> h[i];

    int dp[100010] = {0};

    dp[1] = abs(h[1] - h[0]);
    for(int i = 2;i <= n-1;i++){
        dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
    }

    cout << dp[n-1] << endl;
    

    return 0;   
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://dp.contest.atcoder.jp/tasks/dp_a
// rm -r -f test;oj dl http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m;
int ma[510][510],mb[510][510],mc[510][510];
char ch[510][510];
//1 1 1 1 1
//1 0 1 0 1
//1 0 1 0 1
//1 0 1 0 1
//0 0 0 0 0
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		cin>>ch[i];
		for(int j=0;j<m;j++){
			if(ch[i][j]=='#')mc[i][j+1]=1;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(i==1)mb[i][j]=1;
			else if(i==n)ma[i][j]=1;
			else if(j%2==1)mb[i][j]=1;
			else if(j%2==0)ma[i][j]=1;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(mc[i][j])ma[i][j]=mb[i][j]=1;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(mb[i][j])printf("#");
			else printf(".");
		}
		printf("\n");
	}
	printf("\n");
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(ma[i][j])printf("#");
			else printf(".");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 3968
#include<stdio.h>                                                 
#include<string.h>                                                
                                                                  
int main(void){                                                   
   char S[6];                                                     
   scanf("%s",S);                                                 
                                                                  
   if(S[2] == S[3] && S[4] == S[5]){                              
      printf("Yes");                                              
   }else{                                                         
      printf("No");                                               
   }                                                              
   return 0;                                                      
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n],cnt=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}

	for(int i=0;i<n-2;i++)
	{
		if(a[i+1]>a[i]&&a[i+1]>a[i+2])
		{
			
		}
		else if(a[i+1]<a[i]&&a[i+1]<a[i+2])
		{
		
		}
		else
		{
			cnt++;
		}
	}
	cout<<cnt;
	
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int cnt[550][550];
int main() {
	int n, m, q;
	cin >> n >> m >> q;

	rep(i, m) {
		int l, r;
		cin >> l >> r;
		cnt[l][r]++;
	}
	rep(i, n + 1) {
		rep(j, n + 1) {
			cnt[i][j + 1] += cnt[i][j];
		}
	}
	rep(i, q) {
		int p, q;
		cin >> p >> q;
		int ans = 0;
		for (int j = p; j <= q; j++) {
			ans += cnt[j][q] - cnt[j][j - 1];
		}
		cout << ans << endl;			   
	}
	return 0;
}

Measured memory_bytes: 2048
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N;
  ll x;
  cin >> N >> x;
  vector<ll> a(N);
  ll a_all=0;
  for(int i=0;i<N;i++){
    cin >> a.at(i);
    a_all+=a.at(i);
  }
  if(a_all==x){
    cout << N << endl;
    return 0;
  }
  sort(a.begin(),a.end());
  
  int ans=0;
  ll a_sum=0;
  for(int i=0;i<N;i++){
    a_sum+=a.at(i);
    if(x<a_sum) break;
    ++ans;
  }

  if(ans==N) --ans;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
V = list(map(int, input().split()))
Vi = [i+1 for i in range(len(V))]
V.extend(V)
Vi.extend(Vi)
ans = 0
for k in range(1, min(K+1, N+1)):
    for s in range(len(V)):
        part_Vi = Vi[s:s+k]
        if 1 not in part_Vi and N not in part_Vi:
            continue
        can_remove = K - k
        part_V = V[s:s+k]
        part_V = sorted(part_V)
        plus_i = 0
        for v in part_V:
            if can_remove <= 0:
                break
            if v < 0:
                plus_i += 1
                can_remove -= 1
            else:
                break
        ans = max(ans, sum(part_V[plus_i:]))
print(ans)


Measured memory_bytes: 3064
A, B = map(int, input().split())
S = list(input())

flag = True
for i in range(len(S)):
    if i == A:
        if S[i] != '-':
            flag=False
    else:
        if S[i] not in '0123456789':
            flag=False

if flag:
    print('Yes')
else:
    print('No')
    



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

int main(){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    int X,Y;
    X = x2-x1;
    Y = y2-y1;

    cout << x2-Y << " " << y2+X <<" " <<  x1-Y << " " << y1+X  << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
	int a,b;
	char op;
	int ans;
	scanf("%d %c %d",&a,&op,&b);
	if(op=='+') ans = a + b;
	else if(op=='-') ans = a - b;
	printf("%d\n",ans);
}


Measured memory_bytes: 128
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()

score=0
kekka=[]

def Tensu(Aite):
  if Aite=="r":
    return P
  elif Aite=="s":
    return R
  else:
    return S


for i in range(N):
  if i<K:
    score+=Tensu(T[i])
    kekka.append(1)
  else:
    if T[i]!=T[i-K] or kekka[i-K]==0:
      score+=Tensu(T[i])
      kekka.append(1)
    else:
      score+=0
      kekka.append(0)
      
print(score)
    
  
  

Measured memory_bytes: 79900
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,cnt[27];
string s;
int32_t main(){
CODE_START;
cin >> s;
n=s.size();
for(ll i=0;i<n;i++)
    cnt[s[i]-'a']++;
for(ll i=0;i<=26;i++)
if(cnt[i]%2==1){
    rc("No");
}
rc("Yes");
return 0;}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		int[] w = new int[1 << n];
		
		
		
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		w[0] = 0;
		for(int i = 0; i < w.length; i++) {
			for(int j = 0; j < n; j++) {
				if((i & (1 << j)) == 0) 
					w[i | (1 << j)] = w[i] + c[j]*20;
			}
		}
		
		double[][] dp = new double[1 << n][n+1];
		int[][] prev = new int[1 << n][n+1];
		for(int i = 1; i < dp.length; i++) {
			Arrays.fill(prev[i], -1);
		}
		for(int i = 0; i < dp.length; i++) {
			Arrays.fill(dp[i], 2 << 27);
		}
		dp[0][0] = 0;
		
		for(int i = 0; i < dp.length; i++) {
			for(int j = 0; j < n+1; j++) {
				for(int k = 0; k < n; k++) {
					if(j-1 == k) continue;
					if((i & (1 << k)) == 0) {
						if( dp[i | (1 << k)][k+1] >  dp[i][j] + Math.abs((j == 0)?0:(b[j-1] - b[k]) / (2000.0 / (70.0 + w[i])))) {
							dp[i | (1 << k)][k+1] =  dp[i][j] + Math.abs((j == 0)?0:(b[j-1] - b[k]) / (2000.0 / (70.0 + w[i])));
							prev[i | (1 << k)][k+1] = j;
						}
					}
				}
			}
		}
		double min = 2 << 27;
		int id = 0;
		
		for(int i = 0; i < n+1; i++) {
			if(dp[dp.length-1][i] < min) {
				
				min = dp[dp.length-1][i];
				id = i;
			}
		}
		ArrayList<Integer> list = new ArrayList<Integer>();
		int now = dp.length-1;
		list.add(id-1);
		while(true) {
			if(prev[now][id] == 0) break;
			list.add(prev[now][id]-1);
			int ck = now;
			now ^= (1 << (id-1));
			id = prev[ck][id];
		}
		System.out.print(a[list.get(list.size()-1)]);
		for(int i = list.size()-2; i >= 0; i--) {
			System.out.print(" " + a[list.get(i)]);
		}
		System.out.println();
		
	}
	

}

Measured memory_bytes: 30040
use proconio::*;

fn run() {
    input! {
        n: usize,
        k: usize,
        mut a: [usize; n],
    }
    for _ in 0..k {
        let mut imos = vec![0; n + 1];
        for (i, &a) in a.iter().enumerate() {
            let l = if a > i {
                0
            } else {
                i - a
            };
            let r = if i + a + 1 > n {
                n
            } else {
                i + a + 1
            };
            imos[l] += 1;
            imos[r] -= 1;
        }
        for i in 1..=n {
            imos[i] += imos[i - 1];
        }
        let mut fill = true;
        for (a, &imos) in a.iter_mut().zip(imos.iter()) {
            *a = imos;
            fill &= imos == n;
        }
        if fill {
            break;
        }
    }
    let mut s = String::new();
    for a in a {
        s.push_str(&format!("{} ", a));
    }
    s.pop();
    println!("{}", s);
}

fn main() {
    run();
}


Measured memory_bytes: 7696
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    int h[n+1] = {};
    // rep(i,n+1) h[i] = 0;
    rep(i,n) cin >> h[i];
    int ans = 0;
    while (accumulate(h, h+n, 0) > 0) {
        int lef = 0; bool lef_dicided = false;
        int rig = 0; bool rig_dicided = false;
        int minh = 101;
        for (int i = 0; i < n+1; i++) {
            if (h[i] != 0 && !lef_dicided) {
                lef = i;
                lef_dicided = true;
            }
            if (h[i] == 0 && lef_dicided && !rig_dicided) {
                rig = i-1;
                rig_dicided = true;
            }
            if (lef_dicided && !rig_dicided) {
                minh = min(h[i], minh);
            }
        }
        for (int i = lef; i <= rig; i++) {
            h[i] -= minh;
        }
        ans += minh;
    }
    cout << ans << endl;
}

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

int n,a[100010];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	int cnt=1,maxv=1;
	for(int i=2;i<=n;i++){
		if(a[i]<=a[i-1]){
			cnt++;
		}
		else{
			maxv=max(maxv,cnt);
			cnt=1;
		}
	}
	cout<<max(maxv,cnt)-1<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define INIT() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define Rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define rFor(i,t,s) for (int i = (t); i >= (s); --i)
#define ForLL(i, s, t) for (LL i = LL(s); i <= LL(t); ++i)
#define rForLL(i, t, s) for (LL i = LL(t); i >= LL(s); --i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define rforeach(i,c) for (__typeof(c.rbegin()) i = c.rbegin(); i != c.rend(); ++i)
 
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
 
#define LOWBIT(x) ((x)&(-x))
 
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
 
#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,inf,sizeof(a))
#define msM(a) memset(a,-1,sizeof(a))

#define MP make_pair
#define PB push_back
#define ft first
#define sd second
 
template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
    in >> p.first >> p.second;
    return in;
}
 
template<typename T>
istream &operator>>(istream &in, vector<T> &v) {
    for (auto &x: v)
        in >> x;
    return in;
}
 
template<typename T1, typename T2>
ostream &operator<<(ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]" << "\n";
    return out;
}

inline int gc(){
	static const int BUF = 1e7;
	static char buf[BUF], *bg = buf + BUF, *ed = bg;
	
	if(bg == ed) fread(bg = buf, 1, BUF, stdin);
	return *bg++;
} 

inline int ri(){
	int x = 0, f = 1, c = gc();
	for(; c<48||c>57; f = c=='-'?-1:f, c=gc());
	for(; c>47&&c<58; x = x*10 + c - 48, c=gc());
	return x*f;
}
 
typedef long long LL;
typedef unsigned long long uLL;
typedef pair< double, double > PDD;
typedef pair< int, int > PII;
typedef pair< string, int > PSI;
typedef set< int > SI;
typedef vector< int > VI;
typedef map< int, int > MII;
typedef pair< LL, LL > PLL;
typedef vector< LL > VL;
typedef vector< VL > VVL;
const double EPS = 1e-10;
const LL inf = 0x7fffffff;
const LL infLL = 0x7fffffffffffffffLL;
const LL mod = 1e9 + 7;
const int maxN = 1e5 + 7;
const LL ONE = 1;
const LL evenBits = 0xaaaaaaaaaaaaaaaa;
const LL oddBits = 0x5555555555555555;

int N, M, ans;

int f[maxN], sz[maxN];
void Find(int &x){
	while (x != f[x]) x = f[x] = f[f[x]];
} 

void Union(int x, int y){
	if (sz[x] > sz[y]) swap(x, y);
	f[x] = y;
	sz[y] += sz[x];
}

int main(){
	INIT(); 
	cin >> N >> M;
	ans = N;
	For(i, 1, N) f[i] = i;
	For(i, 1, M) {
		int x, y, z;
		cin >> x >> y >> z;
		Find(x);
		Find(y);
		if(x != y) {
			Union(x, y);
			--ans;
		}
	}
	
	cout << ans << endl;
    return 0;
}

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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
  if(A.size() == n + 1) {
    int now = 0;
    rep(i, q) {
      if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
    return;
  }
  
  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i, q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  dfs(vector<int>(1, 1));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n;cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> sum(n+1);
  sum[0] = 0;
  int res = 1e+9;
  rep(i,n) sum[i+1] = sum[i]+a[i];
  rep1(i,n-1) res = min(res,abs(sum[n]-sum[i]-sum[i]));
  cout << res << "\n";
  return 0;
}


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

using namespace std;

int sum_less(int *v,int t){
    int sum=0;
    for(int i=t;i>=0;i--){
        sum+=v[i];
    }
    return sum;
}

int sum_great(int *v,int t,int n){
    int sum=0;
    for(int i=t+1;i<n;i++)
        sum+=v[i];
    return sum;
}

int main(){

    ios::sync_with_stdio(false);

    int n,*w,less,dif;

    cin>>n;

    w = (int*) malloc(n*sizeof(int));

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

    for(int t=0;t<n;t++){
        if(t==0){
            less = sum_great(w,t,n)-sum_less(w,t);
            if(less<0)
                less*=-1;
        }
        else{
            dif = sum_great(w,t,n) - sum_less(w,t);
            if(dif<0)
                dif*=-1;
            if(dif<less)
                less = dif;
        }
    }

    cout<<less<<endl;

    return 0;
}

Measured memory_bytes: 256
package main

import(
    "fmt"
)



func main() {
    var a,b string
    fmt.Scan(&a,&b)
    ans := "NO"
    if a[0]==b[2] && a[1]==b[1] && a[2]==b[0]{
        ans = "YES"
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, col[300000], cnt;
vector<int> x[300000];
void dfs(int pos) {
    if (col[pos] != 0) {
        return;
    }
    col[pos] = cnt;
    for (int i = 0; i < x[pos].size(); i++) {
        dfs(x[pos][i]);
    }
}
int main() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        x[a].push_back(b);
        x[b].push_back(a);
    }
    for (int i = 1; i <= n; i++) {
        if (col[i] != 0) {
            continue;
        }
        cnt++;
        dfs(i);
    }
    cout << cnt - 1 << endl;
    return 0;
}


Measured memory_bytes: 14680
#include <iostream>

using namespace std;

int main(){
    int n, cnt = 0, ans = 0;
    cin >> n;
    for(int i = 1; i <= n; i+=2){
        for(int j = 1; j <= i; j++){
            if(i%j==0) cnt++;
        }
        if(cnt==8) ans++;
        cnt = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	char b;
	cin >> b;
	switch(b){
		case 'A':
			cout << 'T' << endl;
			break;
		case 'C':
			cout << 'G' << endl;
			break;
		case 'G':
			cout << 'C' << endl;
			break;
		case 'T':
			cout << 'A' << endl;
			break;
		default: break;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, m;	//??????A????????°???????????????b???????´???°
	scanf("%d %d", &n, &m);
	
	int matrixA[100][100];//??????A???????¬??????????
	int b[100];//????????????b???????´??????????
	
	for(int i = 0; i < n; i++){	//?????????
		for(int j = 0; j < m; j++){
			 matrixA[i][j] = 0;
		}
	}
	
	for(int i = 0; i < n; i++){	
		for(int j = 0; j < m; j++){
			scanf("%d", &matrixA[i][j]);
		}
	}
	
	for(int j = 0; j < m; j++){	
		scanf("%d", &b[j]);
	}
	
	for(int i = 0; i < n; i++){	
		int c;
		int sum = 0;
		for(int j = 0; j < m; j++){
			c = matrixA[i][j] * b[j];
			sum += c;
		}
		printf("%d\n", sum);
	}
}

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

// #define multitest 1
// #define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

void solve()
{
	int n, x, k;
	cin >> n >> k;
	vector<int> dp(n + 1, mod), h(n + 1);
	dp[1] = 0;
	for (int i = 1; i <= n; ++i)
	{
		cin >> h[i];
		for (int j = i - 1; j >= 1 && j >= i - k; --j)
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
	}
	cout << dp[n];
}

int main()
{
#ifndef Debug
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long n,a[3005],ans=0,m;
    string s[105],t[105];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>t[i];
    }
    for(int i=0;i<n;i++){
        int sum=0;
        for(int j=0;j<n;j++){
            if(s[i]==s[j]){
                sum++;
            }
        }
        for(int j=0;j<m;j++){
            if(s[i]==t[j]){
                sum--;
            }
        }
        if(sum>ans){
            ans=sum;
        }
    }
    cout<<ans<<endl;
    return(0); 
}


Measured memory_bytes: 3572
import java.io.*;
import java.util.*;
import java.util.regex.*;

import javax.lang.model.element.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		String S =nextString();
		String T =nextString();

		char[] ex = new char['z'-'a'+1];
		Arrays.fill(ex, '0');
		int[][] p1 = new int['z'-'a'+1]['z'-'a'+1];
		int[][] p2 = new int['z'-'a'+1]['z'-'a'+1];

		for(int i=0;i<T.length();i++){
			p1[S.charAt(i)-'a'][T.charAt(i)-'a']++;
			p2[T.charAt(i)-'a'][S.charAt(i)-'a']++;
		}
		for(int i=0;i<p1.length;i++){
			ArrayList<Integer> Scnt=new ArrayList<>();
			ArrayList<Integer> Tcnt=new ArrayList<>();

			for(int k=0;k<p1.length;k++){
				if(p1[i][k]!=0){
					Scnt.add(k);
				}
				if(p2[i][k]!=0){
					Tcnt.add(k);
				}
			}
			if(Scnt.size()>1||Tcnt.size()>1){
				pw.println("No");
				return;
			}

		}
		pw.println("Yes");
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N; cin >> N;
    int l = 1, r = N-1;
    int ans = 1000;
    while(l <= r){
        int val = 0;
        int work1 = l, work2 = r;
        while(work1 > 0){
            val += work1 % 10;
            work1 /= 10;
        }
        while(work2 > 0){
            val += work2 % 10;
            work2 /= 10;
        }
        if(val < ans) ans = val;
        l++; r--;
    }
    cout << ans << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 256
def chr_num(word):
    return ord(word) - 97


if __name__ == "__main__":
    s = input()
    t = input()

    start = [-1] * 26
    goal = [-1] * 26
    for i in range(len(s)):
        a = chr_num(s[i])
        b = chr_num(t[i])

        if start[a] != -1 or goal[b] != -1:
            if start[a] != b or goal[b] != a:
                print('No')
                exit()
        else:
            start[a] = b
            goal[b] = a

    print('Yes')


Measured memory_bytes: 3632
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-2):
    p1, p2, p3 = p[i], p[i+1], p[i+2]
    aaa = [p1,p2,p3]
    aaa.sort()
    if aaa[1] == p2:
        ans += 1
print(ans)


Measured memory_bytes: 3060