akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>
#include <limits>

template <typename T>
void vc(T t) {
    std::cout << t << " ";
}

template<typename T, typename... Args>
void vc(T t, Args... args) {
// recursive variadic function
    std::cout << t << " ";
    vc(args...) ;
}

const int N = 100000;
long long dp[100001];
long long dpf(const std::vector<int>& vw, const std::vector<long long>& vv, int w, int r, int n) {
  for (int i = 1; i <= n; ++i) {
    for (int wi = w; wi >= vw[i]; --wi) {
      dp[wi] = std::max(dp[wi], dp[wi - vw[i]] + vv[i]);
    }
  }
  return dp[w];
}

void once() {
  int n, w;
  std::cin >> n >> w;
  std::vector<int> vw(n + 1);
  std::vector<long long> vv(n + 1);
  for (int i = 1; i <= n; ++i) {
    std::cin >> vw[i] >> vv[i];
  }
  // vc("return , r, w, dp[r][w], \n");
  std::cout << dpf(vw, vv, w, 1, n) << std::endl;
}

int
main() {
  int n = 1;
  std::ios::sync_with_stdio(false);
  // std::cin >> n;
  while (n--) {
    once();
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

const int maxsize = 8000;

int main() {
    string S; cin >> S;
    int x, y; cin >> x >> y;

    int sx = 0;
    while (sx < (int)S.size() && S[sx] == 'F') sx++;

    vector<int> LR, UD; bool X = true; int cur = 0;
    REP(i, sx, S.size()) {
        if (S[i] == 'T') {
            if (cur) {
                if (X) LR.push_back(cur);
                else UD.push_back(cur);
            }
            X = not X;
            cur = 0;
        } else {
            cur++;
        }
    }
    if (X) LR.push_back(cur);
    else UD.push_back(cur);

    // cout << "### LR" << endl;
    // for (auto lr : LR) cout << lr << " ";
    // cout << endl;
    // cout << "### UD" << endl;
    // for (auto ud : UD) cout << ud << " ";
    // cout << endl;
    vector<int> dpx(maxsize * 2 + 1, 0);
    dpx[maxsize + sx] = 1;
    REP(i, 0, LR.size()) {
        vector<int> tmp(maxsize * 2 + 1, 0);
        REP(j, 0, maxsize * 2 + 1) {
            if (j + LR[i] < maxsize * 2 + 1) tmp[j + LR[i]] = tmp[j + LR[i]] || dpx[j];
            if (j - LR[i] >= 0) tmp[j - LR[i]] = tmp[j - LR[i]] || dpx[j];
        }
        dpx = tmp;
    }
    
    vector<int> dpy(maxsize * 2 + 1, 0);
    dpy[maxsize] = 1;
    REP(i, 0, UD.size()) {
        vector<int> tmp(maxsize * 2 + 1, 0);
        REP(j, 0, maxsize * 2 + 1) {
            if (j + UD[i] < maxsize * 2 + 1) tmp[j + UD[i]] = tmp[j + UD[i]] || dpy[j];
            if (j - UD[i] >= 0) tmp[j - UD[i]] = tmp[j - UD[i]] || dpy[j];
        }
        dpy = tmp;
    }

    if (dpx[maxsize + x] && dpy[maxsize + y]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

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

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

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll L,R;
    cin>>L>>R;
    int l = L%2019;
    int r = R%2019;
    int mi = 2018;
    if(R-L>2019){
        cout<<0<<endl;
        return 0;
    }
    for(int i=l;i<r;i++){
        for(int j=i+1;j<=r;j++){
            chmin(mi,(i*j)%2019);
        }
    }
    cout<<mi<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>
#include <set>
#include <queue>
#include <climits>
#include <limits>
#define inf 1000000000000000000

#define ll long long
#define max(A, B) ((A) > (B) ? (A) : (B))
#define min(A, B) ((A) < (B) ? (A) : (B))
#define pair(A, B) make_pair(A, B)

using namespace std;

typedef pair<int, int> pi;
typedef pair<pair<int, int>, int> pii;

void perform() {
  int n, m; cin >> n >> m;
  ll fact1 = n * (n - 1) / 2;
  ll fact2 = m * (m - 1) / 2;
  cout << fact1 + fact2 << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t = 1; //cin >> t;
  while (t--) {perform();}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;
	if (a < b)
		cout << "a < b" << endl;
	if (a > b)
		cout << "a > b" << endl;
	if (a == b)
		cout << "a == b" << endl;
	return 0;
}

Measured memory_bytes: 1156
class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self._root(self.table[x])
            return self.table[x]

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2


n, m = map(int, input().split())
uft = UnionFind(n)
ppp = list(map(int, input().split()))
rev = {x: i for i, x in enumerate(ppp)}

for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    uft.union(x, y)

ans = 0
for i, x in enumerate(ppp):
    if uft.find(i, x - 1):
        ans += 1

print(ans)


Measured memory_bytes: 21472
/*ex7_1 hightierra*/
#include <stdio.h>

// 頂点の定義
typedef struct point{
    int x_elem;
    int y_elem;
}point;

// 隣接２点からもう一方の隣接点を求める
point shift_point(point vertex1, point vertex2){
    // 移動後の点
    point after;
    /* 
    vertex1とvertex2の２点間の辺を斜辺とする4つの合同な三角形を利用
    */
    after.x_elem = vertex2.x_elem - (vertex2.y_elem - vertex1.y_elem);
    after.y_elem = vertex2.y_elem + (vertex2.x_elem - vertex1.x_elem);
    return after;
}

int main(void){
    point point1, point2, point3, point4;
    scanf("%d %d %d %d",&(point1.x_elem),&(point1.y_elem),&(point2.x_elem),&(point2.y_elem));

    // point1,2からpoint3を求める
    point3 = shift_point(point1, point2);
    // point2,3からpoint4を求める
    point4 = shift_point(point2, point3);
    printf("%d %d %d %d\n",point3.x_elem,point3.y_elem,point4.x_elem,point4.y_elem);
    return 0;
}

Measured memory_bytes: 1712
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    int A, B, C, X, ans = 0;
    cin >> A >> B >> C >> X;

    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k= 0; k <= C; k++) {
                if (500 * i + 100 * j + 50 * k == X)ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int C[100050], R[100050];

int main() {
  int N = in();
  int M = in();
  fill(C, C + N, 1);
  R[0] = 1;

  for (int i = 0; i < M; ++i) {
    int x = in() - 1;
    int y = in() - 1;
    --C[x];
    ++C[y];
    R[y] |= R[x];
    if (C[x] == 0) {
      R[x] = 0;
    }
  }

  int res = 0;
  for (int i = 0; i < N; ++i) {
    res += R[i];
  }

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

  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	int n, m;
	int[] p, parent, rank;

	void run() {
		try (Scanner sc = new Scanner(System.in)) {
			n = sc.nextInt();
			m = sc.nextInt();
			p = new int[n];
			for (int i = 0; i < n; i++) {
				p[i] = sc.nextInt() - 1;
			}

			init(n);
			for (int i = 0; i < m; i++) {
				unite(sc.nextInt() - 1, sc.nextInt() - 1);
			}
			System.out.println(fnc());
		}
	}

	String fnc() {
		int cnt = 0;

		for (int i = 0; i < n; i++) {
			if (find(p[i]) == find(i)) {
				cnt++;
			}
		}

		return "" + cnt;
	}

	void init(int n) {
		parent = new int[n];
		rank = new int[n];
		for (int i = 0; i < n; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) {
			return;
		}

		if (rank[x] < rank[y]) {
			parent[x] = y;
		} else {
			parent[y] = x;
			if (rank[x] == rank[y]) {
				rank[x]++;
			}
		}
	}

	int find(int x) {
		if (parent[x] == x) {
			return x;
		}

		return parent[x] = find(parent[x]);
	}

	public static void main(String[] args) {
		new Main().run();
	}

}


Measured memory_bytes: 87872
//
// Created by ss250251 on 2/16/2020.
//

#include<bits/stdc++.h>
using namespace std;
#define INF 1e18L + 7
#define MOD 1e9+7
template <typename T>
void max_self(T&a,T b){
    a = max(a,b);
}
template <typename T>
void min_self(T&a,T b){
    a = min(a,b);
}

int main(){
    int n;
    cin>>n;
    vector<double>dp(1+n);
    dp[0]=1;
    for(int coin =0;coin<n;coin++){
        double h;
        cin>>h;
        for(int i =coin+1;i>=0;--i){
            dp[i] = (i==0?0:dp[i-1]*h)+dp[i]*(1-h);
        }
    }
    double ans =0;
    for(int h = 0;h<=n;++h){
        int t= n-h;
        if(h>t){
            ans+=dp[h];
        }
    }
    printf("%.10lf\n", ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b, c, n;
    int ans = 0;
    cin >> n;
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(i*j == n){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
from fractions import gcd

N=int(input())
A=list(map(int,input().split()))
X=[A[0]]
Y=[A[-1]]
for i in range(N):
    X.append(gcd(X[-1],A[i]))
    Y.append(gcd(Y[-1],A[N-1-i]))
X=X[1:]
Y=Y[1:]
Y=Y[::-1]
ans=1
for i in range(N):
    if i==0:
        ans_=Y[i+1]
    elif i==N-1:
        ans_=X[i-1]
    else:
        ans_=gcd(X[i-1],Y[i+1])
    ans=max(ans,ans_)
print(ans)

Measured memory_bytes: 96992
#include <iostream>
//#include <algorithm>
//#include <vector>
//#include <stack>
//#include <queue>
//#include <map>
//#include <cmath>
//#include <string>
//#include <sstream>
//#include <iomanip>
//#include <complex>
using namespace std;
 
//#define ll long long
//#define vvi vector< vector<int> >
//#define All(X) X.begin(),X.end()
//#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
//#define pb push_back 
//ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  while(1){
    int n, p;
    cin >> n >> p;
    if(n==0&&p==0) break;
    int kago=p;
  	int pc[100]={0};
    int i=0;
    while(1){
      int nowc=i%n;
      if(pc[nowc]==p){
	cout << nowc << endl;
	break;
      }
      if(kago>0){
	kago--;
	pc[nowc]++;
      }
      else{
	kago=pc[nowc];
	pc[nowc]=0;}
      i++;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(){
  int N,i,j,minj,tmp,data,A[100],trade=0;
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&A[i]);
  for(i=0;i<N-1;i++){
    for(minj=j=i+1;j<N;j++){
      if (A[minj] > A[j]) minj = j;
    }
    if(A[i] > A[minj]){
      trade++;
      tmp = A[i];
      A[i] = A[minj];
      A[minj] = tmp;
    } 
  }
  for(i=0;i<N;i++){
    if(i==N-1)printf("%d\n",A[i]);
    else printf("%d ",A[i]);
  }
  printf("%d\n",trade);
  return 0;
}


Measured memory_bytes: 2104
p['   '];t['   '];n,x,k,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x)*n;memset(t,0,4e6)){for(*t=1;n--;)for(i=-scanf("%d",&k);++i<x;)t[i+k]|=t[i];for(;p[x]|!t[x];x--);printf(x<2?"NA\n":"%d\n",x);}}

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

#define Nmax 100010

int main(int argc, char const *argv[])
{
    /* code */
    int N, M;
    scanf("%d %d", &N, &M);
    
    int p[Nmax];
    char S[Nmax][3];

    int i = 0;
    for (i = 0; i < M; i++)
    {
        scanf("%d %s", &p[i], S[i]);
    }
    
    int flag_ac[Nmax], flag_ac_already[Nmax];
    for (i = 1; i <= N; i++)
    {
        flag_ac[i] = 0;
        flag_ac_already[i] = 0;
    }

    for (i = 0; i < M; i ++)
    {
        if(strcmp(S[i], "AC") == 0)
        {
            flag_ac[p[i]] = 1;
        }
    }

    int N_ac = 0, N_penalty = 0;
    for (i = 0; i < M; i++)
    {
        if(flag_ac_already[p[i]] == 0 && flag_ac[p[i]] == 1)
        {
            if (strcmp(S[i], "AC") == 0)
            {
                N_ac++;
                flag_ac_already[p[i]] = 1;
            }
            else if(strcmp(S[i], "WA") == 0)
            {
                N_penalty++;
            }   
        }
    }

    printf("%d %d", N_ac, N_penalty);
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }

int main(){
    ll n; cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        if(i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
/*
    [Gnana Deepak]
    [August 01, 2020 6:08 PM]
    [D - Knapsack 1]
    [https://atcoder.jp/contests/dp/tasks/dp_d]
    [2000 ms]
    [1024 MB]
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
using ld = long double;
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#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")
#define int long long
#define F first
#define S second
#define orderKey order_of_key
#define findOrder find_by_order
#define s(x) set<x>
#define um(x, y) unordered_map<x, y>
#define m(x, y) map<x, y>
#define p(x, y) pair<x, y>
#define v(x) vector<x>
#define min_heap(t) priority_queue<t, vector<t>, greater<t>>
#define max_heap(t) priority_queue<t>
#define ordered_set(x) tree<x, null_type, less<x>, rb_tree_tag, tree_order_statistics_node_update>
#define eb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define ss(v) stable_sort(all(v))
#define fori(i, a, b) for (int i = a; i <= b; i++)
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define stprs(x) cout << fixed << setprecision(x);
#define FILE_READ_IN freopen("input.txt", "r", stdin);
#define FILE_READ_OUT freopen("output.txt", "w", stdout);
#define bs binary_search
#define deb(x) cout << #x << "=" << x << '\n';
#define scn(v1)        \
    for (auto &x : v1) \
        cin >> x;
#define R(x) reverse(all(x));
#define lb lower_bound
#define ub upper_bound
const char nl = '\n';
const int mod1 = 1e9 + 7;
const int mod2 = 998244353;
const ld PI = acos(-1);
const int N = 100;
const int W = 1e5;
const int imx = LLONG_MAX;
int KS[N + 1][W + 1];
void accio_ac(void)
{
    int n, w;
    cin >> n >> w;
    v(int) weight(n + 1), value(n + 1);
    v(p(int, int)) pairs;
    fori(i, 1, n)
    {
        int a, b;
        cin >> a >> b;
        pairs.eb(mp(a, b));
    }
    ss(pairs);
    fori(i, 1, n)
    {
        weight[i] = pairs[i - 1].F;
        value[i] = pairs[i - 1].S;
    }
    fori(i, 0, n) fori(j, 0, w)
    {
        if (i == 0 or j == 0)
        {
            KS[i][j] = 0;
        }
        else
        {
            KS[i][j] = KS[i - 1][j];
            if (weight[i] <= j)
            {
                KS[i][j] = max(KS[i][j], KS[i - 1][j - weight[i]] + value[i]);
            }
        }
    }
    cout << KS[n][w] << endl;
}
int32_t main(void)
{
    fastio;
    int __ = 1;
    // cin >> __;
    while (__--)
    {
        accio_ac();
    }
    return 0;
}


Measured memory_bytes: 82476
#include <iostream>
#include <string>
using namespace std;
int main(){
  int n,i,j,len,s1cal,s2cal,cal,m,c,x,ii;
  string s1,s2;
  cin >> n;
  for(i=0;i<n;i++){
    s1cal=0;
    cin >> s1;
    len=s1.size();
    for(j=0;j<len;j++){
      if(s1[j]=='m'){
	if(j-1!=-1&&'2'<=s1[j-1]&&s1[j-1]<='9') s1cal=s1cal+1000*(s1[j-1]-'0');
	else s1cal=s1cal+1000;
      }
      else if(s1[j]=='c'){
	if(j-1!=-1&&'2'<=s1[j-1]&&s1[j-1]<='9') s1cal=s1cal+100*(s1[j-1]-'0');
	else s1cal=s1cal+100;
      }
      else if(s1[j]=='x'){
	if(j-1!=-1&&'2'<=s1[j-1]&&s1[j-1]<='9') s1cal=s1cal+10*(s1[j-1]-'0');
	else s1cal=s1cal+10;
      }
      else if(s1[j]=='i'){
	if(j-1!=-1&&'2'<=s1[j-1]&&s1[j-1]<='9'){
	  s1cal=s1cal+(s1[j-1]-'0');
	}
	else s1cal=s1cal+1;
      }
    }
    s2cal=0;
    cin >> s2;
    len=s2.size();
    for(j=0;j<len;j++){
      if(s2[j]=='m'){
	if(j-1!=-1&&'2'<=s2[j-1]&&s2[j-1]<='9') s2cal=s2cal+1000*(s2[j-1]-'0');
	else s2cal=s2cal+1000;
      }
      else if(s2[j]=='c'){
	if(j-1!=-1&&'2'<=s2[j-1]&&s2[j-1]<='9') s2cal=s2cal+100*(s2[j-1]-'0');
	else s2cal=s2cal+100;
      }
      else if(s2[j]=='x'){
	if(j-1!=-1&&'2'<=s2[j-1]&&s2[j-1]<='9') s2cal=s2cal+10*(s2[j-1]-'0');
	else s2cal=s2cal+10;
      }
      else if(s2[j]=='i'){
	if(j-1!=-1&&'2'<=s2[j-1]&&s2[j-1]<='9') s2cal=s2cal+(s2[j-1]-'0');
	else{
	  s2cal=s2cal+1;
	}
      }
    }
    cal=s1cal+s2cal;
    m=0;
    c=0;
    x=0;
    ii=0;
    if(cal/1000>0){
      ii=cal%10;
      cal=cal/10;
      x=cal%10;
      cal=cal/10;
      c=cal%10;
      cal=cal/10;
      m=cal%10;      
    }
    else if(cal/100>0){
      ii=cal%10;
      cal=cal/10;
      x=cal%10;
      cal=cal/10;
      c=cal%10;
    }
    else if(cal/10>0){
      ii=cal%10;
      cal=cal/10;
      x=cal%10;
    }
    else ii=cal;
    if(m!=0){
      if(m!=1) cout << m << 'm';
      else cout << 'm';
    }
    if(c!=0){
      if(c!=1) cout << c << 'c';
      else cout << 'c';
    }
    if(x!=0){
      if(x!=1) cout << x << 'x';
      else cout << 'x';      
    }
    if(ii!=0){
      if(ii!=1) cout << ii << 'i';
      else cout << 'i';
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();

		int ans = Integer.MAX_VALUE;

		for (int ab = 0; ab <= Math.max(X * 2, Y * 2); ab++) {
			int a = Math.max(0, X - (ab / 2));
			int b = Math.max(0, Y - (ab / 2));
			ans = Math.min(ans, a * A + b * B + ab * C);
		}

		out.println(ans);

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
#define double long double

template<typename T> void chmin(T &a,T b){if(a>b) a=b;}
template<typename T> void chmax(T &a,T b){if(a<b) a=b;}

Int x[3][2222];
double po[2222];
double su[2222];
Int sc[3]={5,3,2};

double dp[2][4][2222];
double dp2[3][2][4][2222];
signed main(){
  Int n,m;
  cin>>n>>m;
  for(Int i=0;i<n;i++)
    for(Int j=0;j<3;j++)
      cin>>x[j][i];
  {
    po[m]=1.0;
    for(Int i=0;i<m;i++) po[m]/=3.0;
    
    for(Int i=0;i<m;i++)
      po[m-(i+1)]=po[m-i]*2.0*(m-i)/(i+1);
    su[m]=po[m];
    for(Int i=m-1;i>=0;i--) su[i]=su[i+1]+po[i];
  }
  //for(Int i=0;i<=m;i++) cout<<i<<":"<<po[i]<<endl;
  //cout<<su[0]<<endl;
  memset(dp2,0,sizeof(dp2));
  for(Int s=0;s<3;s++){
    for(Int t=0;t<=m;t++){
      memset(dp,0,sizeof(dp));
      dp[0][0][1]=1;
      for(Int i=1;i<n;i++){
	double p=su[min((x[s][0]*t+x[s][i]-1)/x[s][i],m+1)];
	for(Int j=0;j<2;j++){
	  for(Int k=0;k<4;k++){
	    dp[j][min(k+1,(Int)3)][i+1]+=dp[j][k][i]*p;
	    dp[1][k][i+1]+=dp[j][k][i]*(1.0-p);
	  }
	}
      }
      for(Int j=0;j<2;j++)
	for(Int k=0;k<4;k++)
	  dp2[s][j][k][t]=dp[j][k][n];
    }
  }
  double ans=-3;
  for(Int i=0;i<=m;i++){
    for(Int j=0;i+j<=m;j++){
      Int k=m-(i+j);
      Int y[3]={i,j,k};
      double tmp=0;
      for(Int s=0;s<3;s++)
	for(Int t=0;t<2;t++)
	  for(Int u=0;u<4;u++)
	    tmp+=dp2[s][t][u][y[s]]*((t-1)+(u<3?sc[s]:Int(0)));
      chmax(ans,tmp);
    }
  }    
  cout<<fixed<<setprecision(12)<<ans<<endl;
  return 0;
}



Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
class Combination
{
    vector<long long> fact;
    vector<long long> factinv;
    long long MOD = 1e9 + 7;
    long long modpow(long long a, long long n)
    {
        if (n == 0)
            return 1;
        if (n % 2 == 0)
        {
            long long t = modpow(a, n / 2);
            return t * t % MOD;
        }
        return a * modpow(a, n - 1) % MOD;
    }

    long long modinv(long long a)
    {
        // mod is prime
        return modpow(a, MOD - 2);
    }

public:
    Combination(int n) : fact(n), factinv(n)
    {
        fact[0] = 1;
        for (int i = 1; i < n; i++)
        {
            fact[i] = fact[i - 1] * i % MOD;
        }
        factinv[n - 1] = modinv(fact[n - 1]);
        for (int i = n - 2; i >= 0; i--)
        {
            factinv[i] = factinv[i + 1] * (i + 1) % MOD;
        }
    }

    long long ncr(long long n, long long r)
    {
        if (r < 0 || r > n)
            return 0;
        return fact[n] * factinv[r] % MOD * factinv[n - r] % MOD;
    }

    long long npr(long long n, long long r)
    {
        if (r < 0 || r > n)
            return 0;
        return fact[n] * factinv[n - r] % MOD;
    }

    long long nhr(long long n, long long r)
    {
        if (n == 0 && r == 0)
            return 1;
        return ncr(n + r - 1, r);
    }
};

int main(){
    int n,k;
    cin >> n >> k;
    set<P> s;
    Combination comb(1001000);
    vector<ll> v(n);
    rep(i,n){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    ll ans =0;
    ll mod = 1e9+7;
    rep(i,n){
        if(n-i-1<k-1){
            break;
        }
        if(v[i]<0){
            ans+= mod+(abs(v[i])*comb.ncr(n-i-1,k-1))%mod;
        }
        else{
            ans+= mod-(v[i]*comb.ncr(n-i-1,k-1))%mod;
        }
        ans%=mod;
    }
    reverse(v.begin(),v.end());
    rep(i,n){
        if(n-i-1<k-1){
            break;
        }
        if(v[i]<0){
            ans+= mod-(abs(v[i])*comb.ncr(n-i-1,k-1))%mod;
        }
        else{
            ans+=(v[i]*comb.ncr(n-i-1,k-1))%mod;
        }
        ans%=mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16640
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const int N=3e5+10;
ll n,L,a[N],t[N],ans;
int main(){
	cin>>n>>L;
	for (int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for (int i=1;i<=n;i++)scanf("%lld",&t[i]),ans+=t[i]/(2*L)*2*L,t[i]%=2*L;
	ans+=2*L;
	int cnt1=0,cnt2=0,cnt3=0,tag1=0,x,y;
	for (int i=1;i<=n;i++){
		x=2*a[i]>=t[i],y=2*(L-a[i])>=t[i];
		if (t[i]==0){x=y=0;continue;}
		if (x==0&&y==0){ans+=2*L;continue;};
		if (x==1&&y==1){
			cnt2++;
			if (cnt3)
				cnt3--,cnt2--,ans+=2*L,tag1=1;
		}
		if (x==0&&y==1){
			cnt1++;
			if (cnt2)
				cnt1--,cnt2--,ans+=2*L;
		}
		if (x==1&&y==0)cnt3++;
	}
	ans+=2*L*(cnt2/2);
	ans+=2*L*(cnt1+cnt3+(cnt2%2)*(!y));
	cout<<ans<<endl;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vll l(n);
    rep(i, n) cin >> l[i];
    VSORT(l);
    ll ans = 0;
    rep(i, n) for (int j=i+1; j<n; ++j) for (int k=j+1; k<n; ++k) {
        if (l[i]==l[j] || l[j]==l[k] || l[k]==l[i]) continue;
        if (l[k] < l[i]+l[j]) ++ans;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i]; 

    for(int SortedNum = 0; SortedNum < N; ++SortedNum){ // Sorted is the # of sorted cards.
        int MovingVal = A[SortedNum];
        int CompNum = SortedNum - 1;
        while( (CompNum >= 0) && (A[CompNum] > MovingVal) ){
            A[CompNum + 1] = A[CompNum]; // 一つ上の箱に上書き
            --CompNum;
        }
        A[CompNum + 1] = MovingVal;
        
        rep(i,N-1) cout << A[i] << " ";
        cout << A[N-1] << endl;
    }
    
    return 0;
}


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

using namespace std;

using int64 = long long;

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

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

  int n;
  cin >> n;
  vector<vector<int64>> mat = Make2DVector<int64>(n, n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> mat[i][j];
    }
  }
  vector<int64> set_to_score(1 << n);
  for (int s = 0; s < 1 << n; s++) {
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if ((s & (1 << i)) > 0 && (s & (1 << j)) > 0) {
          set_to_score[s] += mat[i][j];
        }
      }
    }
  }

  vector<int64> dp(1 << n, INT64_MIN);
  int count = 0;
  function<int64(int)> solve = [&](int s) -> int64 {
    count++;
    if (dp[s] != INT64_MIN) return dp[s];

    if (s == 0) return 0;
    int bit_count = 0;
    for (int i = 0; i < n; i++) {
      if ((s & (1 << i)) > 0) {
        bit_count++;
      }
    }
    if (bit_count == 1) return 0;

    int64 value = set_to_score[s];
    int first_bit = 0;
    for (int i = 0; i < n; i++) {
      if ((s & (1 << i)) > 0) {
        first_bit = 1 << i;
        break;
      }
    }
    for(int t = (1 << n) - 1; t >= 0; t--) {
      t &= s - first_bit;
      if (t == s || t == 0) continue;
      // cout << "s: " << s << " t: " << t << " s - t: " << s - t << endl;
      value = max(value, solve(t) + solve(s - t));
    }
    dp[s] = value;
    return value;
  };
  int64 ans = solve((1 << n) - 1);
  // cerr << "count: " << count << endl;
  cout << ans << endl;
}


Measured memory_bytes: 1280
N = int(input())

coodinates = [list(map(int, input().split())) for _ in range(N)]

flag = True
if N == 1:
    print(1)
    flag = False

if flag:
    # p, qを求める
    d = {}  # [p, q]をkeyにもつ辞書
    for a in coodinates:
        for b in coodinates:
            if a == b:
                continue
            p, q = a[0]-b[0], a[1]-b[1]
            if (p, q) in d:
                d[(p, q)] += 1
            else:
                d[(p, q)] = 1

    good_distance_count = list(sorted(d.values(), reverse=True))[0]

    print(N - good_distance_count)


Measured memory_bytes: 3444
M,D = map(int, input().split())

ans = 0

for i in range(1,M+1):
    for j in range(1,D+1):
        j1 = j // 10
        j2 = j % 10
        if j1 >= 2 and j2 >= 2 and j1 * j2 == i:
            ans += 1


print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <utility>
#include <assert.h>
using namespace std;

inline void swap(vector< pair<int,int> >& vec, int a, int b){
    pair<int,int> tmp = vec.at(b);
    vec.at(b) = vec.at(a);
    vec.at(a) = tmp;
    return;
}

void qsort(vector< pair<int,int> >& vec, int start, int end){
    if(start < end){
        int pivot_idx = (start + end) / 2;
        int pivot = vec[pivot_idx].second;
        swap(vec, start, pivot_idx);
        pivot_idx = start;
        int i;
        for(i = start + 1; i < end; i++){
            if(vec.at(i).second < pivot){
                pivot_idx++;
                swap(vec, i, pivot_idx);
            }
        }
        swap(vec, pivot_idx,start);
        
        qsort(vec, start, pivot_idx);
        qsort(vec, pivot_idx + 1, end);
    
    }
    return; 
}

int main(){
    int N, i;
    cin >> N;
    assert(1 <= N);
    //vec: [student ID, attend #]
    vector< pair<int,int> > vec;
    for(i = 0; i < N; i++){
        int val;
        cin >> val;
        vec.push_back(pair<int,int>(i + 1,val));
    }

    qsort(vec, 0, N);
    for(i = 0; i < N; i++){
        cout << vec.at(i).first << " ";
    }

    return 0;
}



Measured memory_bytes: 1780
// (c) 2020, redotter

// Roses are red
// The Tardis is blue
// The Doctor once said
// Rose Tyler...

#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#pragma comment(linker, "/stack:500000000")
#endif

#define pb push_back
#define the(a) (a).begin(), (a).end()
#define ft first
#define sd second
#define endl "\n"
#define forn(i, n) for (int i = 0; i < (n); i++)
#define forr(i, s, n) for (int i = (s); i < (n); i++)

using i64 = long long;
using i32 = int;
using f64 = long double;

template <class T> using vec = vector<T>;
using str = string; using p64 = pair<i64, i64>;
using v64 = vec<i64>; using vv64 = vec<v64>;
using s64 = set<i64>; using m64 = map<i64, i64>;
template <size_t Size1> using a64 = array<i64, Size1>;
template <size_t Size1, size_t Size2> using aa64 = array<a64<Size2>, Size1>;
template <class T> using hash_set = unordered_set<T>;
template <class T, class U> using hash_map = unordered_map<T, U>;

mt19937 gen(998244353);
const i64 inf = numeric_limits<i64>::max() / 2;

template <class T> inline i64 len(const T& a) { return (i64)(a.size()); }
inline void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
template <class T, class S>
inline bool check_min(T& a, S b) { if (a > b) return a = b, 1; return 0; }
template <class T, class S>
inline bool check_max(T& a, S b) { if (a < b) return a = b, 1; return 0; }

void read() {}
template<class T, class ...U>
void read(T& a, U& ...b) { cin >> a; read(b...); }
void print() {}
template<class T, class ...U>
void print(const T& a, const U& ...b) { cout << a << " "; print(b...); }
void println() { cout << "\n"; }
template<class T, class ...U>
void println(const T& a, const U& ...b) { cout << a << " "; println(b...); }

struct Problem {
	void files(str in, str out) {
#ifdef ONLINE_JUDGE
		freopen(in.c_str(), "r", stdin), freopen(out.c_str(), "w", stdout);
#endif
	}
	void solve(), input();
	void many() { i32 t; cin >> t; while (t--) input(), solve(); }
	void make(bool mt = 0) { if (mt) many(); else input(), solve(); }
} problem;

signed main() {
	fast();
	problem.make();
#ifdef _DEBUG
	println(); println("[finished]"); system("pause > nul");
#endif
	return 0;
}

i64 n, m;
str s, t;

void Problem::solve() {
	s.insert(s.begin(), '-');
	t.insert(t.begin(), '-');
	vv64 dp(n + 1, v64(m + 1, 0));
	forr(i, 1, n + 1) {
		forr(j, 1, m + 1) {
			if (s[i] == t[j]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			} else {
				dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
			}
		}
	}
	i64 i = n, j = m;
	str ans;
	while (i && j) {
		if (s[i] == t[j]) {
			ans.pb(s[i]);
			--i, --j;
			continue;
		}
		if (dp[i][j] == dp[i][j - 1]) {
			--j;
			continue;
		}
		if (dp[i][j] == dp[i - 1][j]) {
			--i;
			continue;
		}
	}
	reverse(the(ans));
	println(ans);
}

void Problem::input() {
	read(s, t);
	n = len(s), m = len(t);
}


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

int main(){
    ios::sync_with_stdio(false); //125   00   0代表不切開, 1 代表切開
	string s;                    //1 25  01
	cin >> s;                    //12 5  10
	long long int a = 0;         //1 2 5 11
	int len=s.length();
	for (int i=0; i<(1<<len-1); i++){//2的len-1次方, 1<<3-->1,2,4,8
		long long int b = s[0]-'0';
		for (int j=1; j<len; j++){
			if (i & (1<<(j-1))){
				a += b;
				b = s[j]-'0';
			}else{
				b = b*10+s[j]-'0';
			}
		}
	a += b;	
	}
	cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
#pragma region chminmax
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion
using vvll = vector<vll>;
const ll INF = 1e12;
int main()
{
    string s;
    cin >> s;
    int n = s.size();

    vvll dp(n + 1, vll(2, INF));
    dp[0][0] = 0;
    dp[0][1] = 1;

    rep(i, n)
    {
        int x = s[i] - '0';
        chmin(dp[i + 1][0], dp[i][0] + x);
        chmin(dp[i + 1][1], dp[i][0] + x + 1);
        chmin(dp[i + 1][0], dp[i][1] + (10 - x));
        chmin(dp[i + 1][1], dp[i][1] + (10 - x) - 1);
    }

    cout << dp[n][0] << endl;
    return 0;
}

Measured memory_bytes: 58880
import java.util.Scanner

object Main extends App {
  def readALine(c:Int, ac:List[Int]):List[Int] =
    if (c > 0) readALine(c-1, sc.nextInt::ac) else ac.reverse
  def readLines(r:Int, c:Int, ac:List[List[Int]]):List[List[Int]] =
    if (r > 0) readLines(r-1, c, readALine(c, Nil)::ac) else ac.reverse
  val sc = new Scanner(System.in)
  val N = sc.nextInt
  val K = sc.nextLong
  val ls = readALine(N, Nil)
//  println(ls)

  def analyze():(Int, Int, Int) = {
    val usedTowns = Array.fill(N+1)(0)

    def iter(pos:Int, order:Int):(Int, Int, Int) = {
      if (usedTowns(pos) > 0) (pos, usedTowns(pos)-1, order - usedTowns(pos))
      else {
        usedTowns.update(pos, order)
        iter(ma(pos), order+1)
      }
    }

    iter(1, 1)
  }

  def move(s:Int, t:Int):Int = if (t == 0) s else move(ma(s), t-1)

  val ma = (0::ls).toArray
  val (pos, lead, loop) = analyze()

  // println(s"pos:$pos  lead:$lead  loop:$loop")
  println( if (K < lead) move(1, K.toInt) else move(pos, ((K-lead) % loop).toInt))
}


Measured memory_bytes: 70236
/************************************************
 # @Author:      miniLCT
 # @DateTime:    2019-12-22 20:05:09
 # @Description: You build it.You run it
 # @More: If lots of AC,try BF,dfs,DP
 ***********************************************/
#include <bits/stdc++.h>

using namespace std;
#define eps 1e-8
#define close ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long ll;
const int maxn = 1e6;
const int INF = 1e9;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
ll mod = 1e9+7;
int n , pos = 0,a[maxn];
int main()
{
	cin >> n;
	int ans = 0;
	for(int i = 0; i < n;i++)cin >> a[i];
	for(int i = 0; i < n;i++){
		//cin >> a[i];
		if(a[i] - pos == 1){
			pos++;
		}
		else ans++;
	}
	if(pos != 0)cout << ans << endl;
	else cout << -1 << endl;
}

/******************************************************
 stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?), set tle
  * do smth instead of nothing and stay organized
*******************************************************/

Measured memory_bytes: 1024
H, W = map(int, input().split())
fld = []
mp = [[0] * W for i in range(H)]
dd = ((-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1))

for i in range(H):
  fld.append(input())

for i in range(W):
  for j in range(H):
    if fld[j][i] == "#":
      mp[j][i] = "#"
      for d in dd:
        if 0 <= j+d[0] <= H-1 and 0 <= i+d[1] <= W-1:
          if fld[j+d[0]][i+d[1]] != "#":
            mp[j+d[0]][i+d[1]] += 1

for i in mp:
  print(''.join(map(str, i)))

Measured memory_bytes: 40432
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
   int a, b;
   cin >> a >> b;
   
   int ab = a - b;
   int ba = b - a;
   

    if ( ab >= 1 ){
        cout << "a > b" << endl;
    } else if ( ba >= 1 ) {
        cout << "a < b" << endl;
    } else {
        cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

typedef pair<long long, long long> pl;

long long gcd(long long a, long long b) {
    return a == 0 ? b : gcd(b % a, a);
}

long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b;
}

void reduce(pl &a) {
    long long t = gcd(a.first, a.second);
    a.first /= t;
    a.second /= t;
}

pl lcm(pl a, pl b) {
    long long k = a.second, l = b.second;
    a.first *= l; a.second *= l;
    b.first *= k; b.second *= k;
    pl ret(a.first / gcd(a.first, b.first) * b.first, a.second);
    reduce(ret);
    return ret;
}

int main() {
    int n;
    while (cin >> n, n) {
        vector<long long> d(n), v(n);
        pl t;
        for (int i=0; i<n; ++i) {
            cin >> d[i] >> v[i];
            if (i == 0) {
                t = pl(d[i], v[i]);
            } else {
                t = lcm(t, pl(d[i], v[i]));
            }
        }
        for (int i=0; i<n; ++i) {
            cout << (t.first * v[i]) / (d[i] * t.second) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1200
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;



int main() {
    string s;
    cin >> s;
    if(s[s.size()-1] == 's') s += "es";
    else s += 's';
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3624
N = int(input())
T = [int(input()) for i in range(N)]
T.sort()
if N == 1:
    ans = 0
else:
    y = T[-1]
    R = []
    for x in range(1, y+1):
        if y % x == 0:
            R.append(x)
    cur = ans = 0
    for t in T:
        while R[cur] < t:
            cur += 1
        ans += R[cur] - t
print(ans)



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

int dp[100005], v[100005], n;

int main(){
    cin >> n;

    for(int i = 1; i <= n; ++i)
        cin >> v[i];

    v[0] = v[1];

    for(int i = 2; i <= n; ++i)
        dp[i] = min( abs(v[i] - v[i - 1]) + dp[i-1], abs(v[i] - v[i - 2]) + dp[i - 2] );

    cout << dp[n];

    return 0;
}


Measured memory_bytes: 3936
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        int aLength = a.length();
        int bLength = b.length();
        int length = Math.max(aLength, bLength);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length; i++) {
            if (i < aLength) {
                sb.append(a.charAt(i));
            }
            if (i < bLength){
                sb.append(b.charAt(i)); 
            }
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 23764
#include <iostream>

using namespace std;

int main() {
  int noPoison, deliciousNoPoison, deliciousPoison;
  cin >> noPoison >> deliciousNoPoison >> deliciousPoison;

  int deliciousAll = deliciousNoPoison + deliciousPoison;
  int noPoisonAll = noPoison + deliciousNoPoison;
  if (noPoisonAll >= deliciousPoison) {
    cout << deliciousAll << endl;
  } else {
    int result = 0;
    int deliciousPoisonCount = deliciousPoison;
    for (int i = 0; i < deliciousNoPoison; i++) {
      if (deliciousPoisonCount == 0) break;
      deliciousPoisonCount--;
      result += 2;
    }
    for (int i = 0; i < noPoison; i++) {
      if (deliciousPoisonCount == 0) break;
      deliciousPoisonCount--;
      result++;
    }
    if (deliciousPoisonCount != 0) result++;
    cout << result << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
  ll i,j;
  ll r,g,b,n;
  cin>>r>>g>>b>>n;
  ll ans=0;
  for(i=0;i<3030;i++){
    for(j=0;j<3030;j++){
      ll x=n-i*r-j*g;
      if(x>=0&&x%b==0) ans++;
    }
  }
  cout<<ans<<endl;

  return 0;
}

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

class C
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(long.Parse).ToArray();
		long a = h[0], b = h[1], c = h[2], d = h[3];

		Func<long, long> count = x => x - x / c - x / d + x / Lcm(c, d);
		Console.WriteLine(count(b) - count(a - 1));
	}

	static long Gcd(long x, long y) { for (long r; (r = x % y) > 0; x = y, y = r) ; return y; }
	static long Lcm(long x, long y) => x / Gcd(x, y) * y;
}


Measured memory_bytes: 13396
#!/usr/bin/env python3
import sys
import itertools


class cPrimes:
    def __init__(self, N):
        self.N = N
        self.L = N // 96 + 1
        self.sieve()
    
    def sieve(self):
        self.bits = [ -1 ] * self.L
        for p in itertools.takewhile(lambda p: p * p < self.N,
                            itertools.islice(self.enumerate(), 2, None)):
            k0 = p // 3
            for k in range(k0 + p * 2, self.N // 3 + 1, p * 2):
                self.erase_bit(k)
            for k in range(-k0 - 1 + p * 2, self.N // 3 + 1, p * 2):
                self.erase_bit(k)
    
    def enumerate(self):
        yield 2
        yield 3
        k0 = 1
        for m, B in enumerate(self.bits):
            for k in range(k0, 32):
                if ((B >> k) & 1) == 1:
                    yield m * 96 + k * 3 + 1 + (k & 1)
            k0 = 0
    
    def is_prime(self, n):
        if n < 4:
            return n >= 2
        else:
            q, r = divmod(n, 6)
            if r == 1:
                k = q >> 4
                l = (q & 15) << 1
                return ((self.bits[k] >> l) & 1) == 1
            elif r == 5:
                k = q >> 4
                l = ((q & 15) << 1) + 1
                return ((self.bits[k] >> l) & 1) == 1
            else:
                return False
    
    def erase_bit(self, k):
        m = k >> 5
        l = k & 31
        if l != 31:
            self.bits[m] &= ~(1 << l)
        else:
            self.bits[m] &= ~(-1 << 31)

def solve(N: int):
    cp = cPrimes(55555)
    result = []
    for p in cp.enumerate():
        if p % 5 == 2:
            result.append(str(p))
        if len(result) == N:
            break
    print(' '.join(result))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

void Main() {
	int N;
	cin >> N;

	vector<int64_t> lucasNum = vector<int64_t>(N + 1);

	for (int i = 0; i < N + 1; i++) {
		if (i == 0) {
			lucasNum.at(i) = 2LL;
		}
		else if (i == 1) {
			lucasNum.at(i) = 1LL;
		}
		else {
			lucasNum.at(i) = lucasNum.at(i - 2) + lucasNum.at(i - 1);
		}
	}

	cout << lucasNum.at(N) << endl;
}

int main() {
	Main();
}

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

int main(){
  vector<vector<int>>c(3,vector<int>(3));
  vector<int>b(3);
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> c.at(i).at(j);
    }
  }
  b.at(0) = c.at(0).at(0);
  b.at(1) = c.at(0).at(1);
  b.at(2) = c.at(0).at(2);
  if(c.at(1).at(0) - b.at(0) == c.at(1).at(1) - b.at(1) && 
     c.at(1).at(1) - b.at(1) == c.at(1).at(2) - b.at(2) &&
     c.at(2).at(0) - b.at(0) == c.at(2).at(1) - b.at(1) && 
     c.at(2).at(1) - b.at(1) == c.at(2).at(2) - b.at(2)) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

int main(){
    //*
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    /*/
      /*/

    int N, A, B;
    string S;

    cin >> N >> A >> B;
    cin >> S;

    int ja = 0, ot = 0;
    for(int i=0;i<N;++i){
        bool f = false;
        if(S[i] == 'b' && (ja + ot) < A + B && ot < B){
            ++ot;
            f = true;
        }else if(S[i] == 'a' && (ja + ot) < A + B){
            ++ja;
            f = true;
        }

        if(f){
            std::cout << "Yes" << std::endl;
        }else{
            std::cout << "No" << std::endl;
        }
    }
}


Measured memory_bytes: 848
s = input()
length = len(s)

for i in range(length):
		ss = s[i]
		ii = i+1
		
		if ii%2 == 0:
			if ss != 'L' and ss != 'U' and ss != 'D':
					print("No")
					exit()
		else:
			if ss != 'R' and ss != 'U' and ss != 'D':	
					print("No")
					exit()
print("Yes")

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

using namespace std;

int main()
{

    int a[4],b[4] = {1 ,7 ,9 ,4};
    for(int i = 0;i < 4;i++)    scanf("%d",&a[i]);
    int flag = 0;
    sort(a,a+4);
    do{
        int flag1 = 1;
        for(int i = 0;i < 4;i++)
            if(a[i] != b[i])
                flag1 = 0;
        if(flag1)
        {
            flag = 1;
            break;
        }
    }while(next_permutation(a,a+4));

    if(flag)    puts("YES");
    else    puts("NO");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int[] array = new int[n];
        for(int i = 0; i < n; i++){
            array[i] = scanner.nextInt();
        }
        for(int i = n-1; i >=0; i--){
            if(i != 0)System.out.print(array[i]+" ");
            else System.out.println(array[i]);
        }
    }
}



Measured memory_bytes: 26372