akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define INF (int)1e9
#define fora(i,a,b) for(ll i=a;i<b;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp(x,y) make_pair(x,y)
#define mii map<int,int>
using namespace std;

int main()
{   ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n,b,cnt=0;
    cin>>n>>b;
    while(n>0)
    {
        cnt++;
        n/=b;
    }
    //cout<<n<<"&";
    if(n!=0)
    cout<<cnt+1;
    else
    cout<<cnt;
    return 0;
}




Measured memory_bytes: 256
#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 SIZE(string s){ return (int)s.size(); }

int main(){
    cout << setprecision(16);
    string s; cin >> s;
    map<char,int> m;
    for(auto c: s) m[c]++;
    rep(i, 26){
        if(m['a'+i] == 0){
            char ans = 'a'+i;
            cout << ans << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <unordered_set>

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

    std::unordered_set<std::string> dict;

    for (int i = 0; i < n; i ++) {
        char command[6], str[12];
        scanf("%s %s", command, str);
        if ((std::string)command == "insert") {
            dict.insert((std::string)str);
        } else if ((std::string)command == "find") {
            if (dict.count((std::string) str) > 0) {
                std::cout << "yes" << std::endl;
            } else {
                std::cout << "no" << std::endl;
            }
        }
    }
}



Measured memory_bytes: 28988
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define print(n) cout << n << endl
#define in(v) int v; cin >> v
#define vint vector<int>
#define pb push_back
typedef long long int ll;

int main(){
  int k,a,b;
  cin>>k>>a>>b;
  for(int i = a; i<=b; i++){
    if(i%k==0){
      print("OK");
      return 0;
    }
  }
  print("NG");
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define all(x) x.begin(), x.end()
#define x first
#define y second
#define mp make_pair
#define mt make_tuple

const int N = 1e6;
int n;
int a[N];
int d[N];

signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int i = 0;
	do {
		int j = (i + 2) % n;
		d[j] = d[i] + a[(i + 1) % n] - a[i];
		i = j;
	} while (i);
	int sa = accumulate(a, a + n, 0LL);
	int sd = accumulate(d, d + n, 0LL);
	int av = (sa / 2 - sd);
	assert(av % n == 0);
	av /= n;
	for (i = 0; i < n; ++i) {
		cout << (d[i] + av) * 2 << " ";
	}
	cout << "\n";
	return 0;
}


Measured memory_bytes: 6272
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>//辞書順はnext_permutation
#include<set>
#include<string>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<utility>//swap(数値交換)
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define cncn int cnt=0
#define please return
#define AC 0

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


int main(void) {
int n;
cin>>n;
asas;
rop(i,n){
ans+=i;
}
cout<<ans<<rt;
	please AC;
}

// abc : 141 , aoj : ITP1_6_D
//sort, abs, swap, reverse, max, min
//__gcd, sbstring, erase, push_back,stoll、stoi

Measured memory_bytes: 256
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	static class State implements Comparable<State>{
		Long A, B;
		State(Long A, Long B){
			this.A = A;
			this.B = B;
		}
		public int compareTo(State s){
			if(this.A + this.B < s.A + s.B ){
				return 1;
			}
			else if(this.A + this.B == s.A + s.B ) {
				return  0;
			}
			return -1;
		}

	}
    public static void main(String[] args) throws Exception {
    	Scanner sc = new Scanner(System.in);

    	int N = sc.nextInt();
    	PriorityQueue<State> pq = new PriorityQueue<State>();
    	for(int i = 0; i < N; i++){
    		Long a = sc.nextLong();
    		Long b = sc.nextLong();
    		pq.add(new State(a, b));
    	}
    	long Acount = 0, Bcount = 0;
    	for(int i = 0; i < N; i++){
    		State s = pq.remove();
    		if(i%2 == 0){
    			Acount += s.A;
    		}
    		else{
    			Bcount += s.B;
    		}
    	}
    	System.out.println(Acount - Bcount);
    }
}

Measured memory_bytes: 98360
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
 
#pragma comment(linker, "/STACK:336777216")  
 
using namespace std;

const int MAXN = 1000000 + 10;

int N;
map <int, int> M;

void Work()
{
	scanf("%d", &N);
	for (int i = 0; i < N; i ++)
	{
		int x;
		scanf("%d", &x);
		M[x] ++;
	}
	int ans = 0;
	for (auto it: M)
	{
		int x = it.first;
		int rep = it.second;
		if (rep >= x) ans += rep - x; else ans += rep;
	}
	printf("%d\n", ans);
}
 
int main()
{
	Work();
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int n,m;cin>>n>>m;
    int p[m],y[m];
    vi py[100001];
    rep(i,m){
        cin>>p[i]>>y[i];
        py[p[i]].PB(y[i]);
    }
    rep(i,100001){
        sort(py[i].begin(),py[i].end());
    }
    rep(i,m){
        int b=y[i];
        int c=p[i];
        int a=lower_bound(py[c].begin(),py[c].end(),b)-py[c].begin()+1;
        string s=to_string(p[i]);
        int x=s.size();
        while(x<6){
            s='0'+s;
            x++;
        }
        string t=to_string(a);
        int z=t.size();
        while(z<6){
            t='0'+t;
            z++;
        }
        cout<<s+t<<endl;    
    }
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)


const ll mod = 1000000007;

int main(void)
{
	ll h,w;
	cin >> h >> w;
	vector<vector<int>> vs(h, vector<int>(w, 0));
	int black = 0;
	vector<vector<P>> q(2);
	rep(i, h) {
		string s;
		cin >> s;
		rep(j, w) {
			vs[i][j] = s[j] == '#';
			if (vs[i][j]) {
				black++;
				q[0].emplace_back(j, i);
			}
		}
	}
	P offset[4] = { {-1,0},{1,0},{0,-1},{0,1} };
	int count = 0;
	while (black < h * w) {
		q[1].clear();
		count++;
		for (auto e : q[0]) {
			rep(i, 4) {
				auto nx = e.first + offset[i].first;
				auto ny = e.second + offset[i].second;
				if (nx >= 0 && nx < w) if (ny >= 0 && ny < h) {
					if (!vs[ny][nx]) {
						black++;
						vs[ny][nx] = 1;
						q[1].emplace_back(nx, ny);
					}
				}
			}
		}
		swap(q[0], q[1]);
	}
	cout << count << endl;


	return 0;

}


Measured memory_bytes: 28388
#include <iostream>
#include <cstdint>

int main()
{
	uint64_t H;
	uint64_t W;

	std::cin >> H >> W;

	uint64_t answer;
	if (H == 1 || W == 1)
	{
		answer = 1;
	}
	else if ((H % 2 == 1) && (W % 2 == 1))
	{
		answer = H * W / 2 + 1;
	}
	else
	{
		answer = H * W / 2;
	}
	std::cout << answer;

	return 0;
}


Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int N, one=0, two=0, three=0, four=0;
string veredict;

int main()
{
    cin>>N;
    for(int i=0; i<N; i++){
        cin>>veredict;
        if(veredict=="AC"){
            one++;
        }
        if(veredict=="WA"){
            two++;
        }
        if(veredict=="TLE"){
            three++;
        }
        if(veredict=="RE"){
            four++;
        }
    }
    cout<<"AC x "<<one<<endl;
    cout<<"WA x "<<two<<endl;
    cout<<"TLE x "<<three<<endl;
    cout<<"RE x "<<four;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define N 105
#define ll long long
#define db double
#define dbg1(x) cout<<#x<<"="<<x<<" "
#define dbg2(x) cout<<#x<<"="<<x<<"\n"
int n,a,b,cnt1,cnt2,A[N][N];
void Print()
{
	printf("%d %d\n",n,n);
	for(int i=1;i<=n;puts(""),i++)
		for(int j=1;j<=n;j++) putchar(A[i][j]?'#':'.');
}
int main()
{
	scanf("%d%d",&a,&b),n=100,cnt1=a-1,cnt2=b-1;
	for(int i=1;i<=n;i++) A[i][1]=1;
	for(int i=1;i<=n;i+=2)
		for(int j=1;j<n;j++) A[i][j]=1;
	//Print();
	for(int i=2;i<=n&&cnt1;i+=2)
		for(int j=3;j<n&&cnt1;j+=2) A[i][j]=1,cnt1--;
	//Print();
	for(int i=n-1;i&&cnt2;i-=2)
		for(int j=n-2;j>1&&cnt2;j-=2) A[i][j]=0,cnt2--;
	Print();
	return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s:String = read();
    let c:Vec<char> = s.chars().collect();
    let mut cnt = 0u128;
    for bit in 0..1<<(s.len()-1) {
        let mut tmp = 0u128;
        for i in 0..s.len()-1 {
            tmp *= 10;
            tmp +=  c[i].to_digit(10).unwrap() as u128;
            if bit & 1<<i == 1 <<i {
                cnt += tmp;
                tmp = 0;
            }
        }
        tmp *= 10;
        tmp += c[s.len()-1].to_digit(10).unwrap() as u128;
        cnt += tmp;
    }
    println!("{}", cnt);
}


Measured memory_bytes: 2112
n=int(input())
A=list(map(int,input().split()))
m=-10**15
#dp[i][j]=i番目までで、j回選ばない連続を使ったときの最大値
dp1=[[m,m,m] for i in range(n)] #最後を使うとき
dp0=[[m,m,m] for i in range(n)] #最後を使わないとき
dp1[0][0]=A[0]
dp0[0][1]=0 #最初選ばないときはj=1にする
for i in range(1,n):
    for j in range(3):
        dp1[i][j]=max(dp1[i][j],dp0[i-1][j]+A[i])
        dp0[i][j]=max(dp0[i][j],dp1[i-1][j])
        if j!=2:
            dp0[i][j+1]=max(dp0[i][j+1],dp0[i-1][j])
if n%2==0:
    print(max(dp1[n-1][1],dp0[n-1][0]))
else:
    print(max(dp1[n-1][2],dp0[n-1][1]))

Measured memory_bytes: 131044
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,c,count=0,num;
    cin >> n >> m >> c;
    int a[256][256], b[256];
    
    for(int i=0;i<m;i++){
        cin >> num;
        b[i] = num;
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> num;
            a[i][j] = num;
        }
    }
    
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            ans += a[i][j]*b[j];
        }
        if(ans+c>0) count++;
        ans=0;
    }
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;scanf("%d",&n); int t=n;
	int tmp=0;
	while (n){
		tmp+=n%10;
		n/=10;
	}
	if (t%tmp!=0) puts("No"); else puts("Yes");
	return 0;
}

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

int main() {
  int k;
  string s;
  cin >> k >> s;
  if(s.size()<=k) cout << s;
  else{
    for(int i=0; i<k; i++){
      cout << s[i];
    }
    cout << "...";
  }
  return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	string s;
	ll f=0,i,g=0;
	cin>>s;
	ll len=s.length();
	ll prev=-3;
	for(i=0;i<=len-3;i++)
	{
		if(s[i]=='A'&&(i-prev)>2)
			g++;
		else if(s[i]!='A')
			g=0;
		if(s.substr(i,3)=="ABC")
		{
			f+=g;
			prev=i;
			s[i]='B';s[i+1]='C';s[i+2]='A';
			i++;
		}	
	}
	cout<<f<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if(a == b){
    cout << "Yes\n";
  }
  else{
    cout << "No\n";
  }
}


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

class P
{
    static void Main()
    {
        //int[] NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
        string s = Console.ReadLine();
        string t = Console.ReadLine();
        string u = Console.ReadLine();
        char turn = 'a';
        while (true)
        {
            switch (turn)
            {
                case 'a':
                if (s.Length == 0)
                {
                    Console.WriteLine("A"); return;
                }
                turn = s[0];
                s = s.Substring(1);
                break;
                case 'b':
                if (t.Length == 0)
                {
                    Console.WriteLine("B"); return;
                }
                turn = t[0];
                t = t.Substring(1);
                break;
                case 'c':
                if (u.Length == 0)
                {
                    Console.WriteLine("C"); return;
                }
                turn = u[0];
                u = u.Substring(1);
                break;
            }
        }
    }
}

Measured memory_bytes: 13140
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N;
int A[100010];

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

	cin >> N;
	rep(i, 0, N)
	{
		cin >> A[i];
	}

	int ans = 0;
	rep(i, 0, N)
	{
		if (i + 1 == A[i])
		{
			if (i < N - 1)
			{
				if (i + 2 == A[i + 1])
				{
					i++;
				}
			}
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"sort"
)

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(in io.Reader, out io.Writer) {
	var bs = NewBufScanner(in)
	var bw = NewBufWriter(out)
	defer bw.w.Flush()

	n, k := bs.IntScan(), bs.IntScan()

	if n == k {
		bw.Printf("0\n")
		return
	}

	m := make(map[string]int)
	for i := 0; i < n; i++ {
		m[bs.Scan()]++
	}

	if len(m) <= k {
		bw.Printf("0\n")
		return
	}

	arr := []int{}
	for _, c := range m {
		arr = append(arr, c)
	}
	sort.Ints(arr)

	var cnt int
	for i:=0; i < len(arr) - k;i++{
		cnt += arr[i]
	}
	bw.Printf("%d\n", cnt)
}

// BufScanner original scanner
type BufScanner struct {
	s *bufio.Scanner
}

// NewBufScanner constructer
func NewBufScanner(in io.Reader) *BufScanner {
	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 1024), 1e+9)
	s.Split(bufio.ScanWords)
	return &BufScanner{
		s: s,
	}
}

// Scan Scan Data
func (b *BufScanner) Scan() string {
	b.s.Scan()
	return b.s.Text()
}

// IntScan Scan Data
func (b *BufScanner) IntScan() int {
	v, err := strconv.Atoi(b.Scan())
	if err != nil {
		panic(err)
	}
	return v
}

// BufWriter original writer
type BufWriter struct {
	w *bufio.Writer
}

// NewBufWriter constructer
func NewBufWriter(out io.Writer) *BufWriter {
	w := bufio.NewWriter(out)
	return &BufWriter{
		w: w,
	}
}

// Printf Output file
func (b *BufWriter) Printf(format string, a ...interface{}) {
	fmt.Fprintf(b.w, format, a...)
}

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

int main(){
    vector<int> fib(1002);
    fib[0] = 1; fib[1] = 2;
    for(int i = 2; i <= 1001; i++)  fib[i] = (fib[i-1]+fib[i-2])%1001;
    int v, d;
    while(cin >> v >> d){
        vector<int> x;
        for(int i = 1; i <= v; i++) x.push_back(fib[i]);
        sort(x.begin(), x.end());
        int now = x[0], cnt = 1;
        for(int i = 1; i < v; i++){
            if(x[i]-x[i-1] >= d)    cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3164
#include<iostream>
using namespace std;
int main(void)
{
	int m,f,r;

	while(1){
		cin >> m >> f >> r;
		if(m==-1 && f==-1 && r==-1)break;

		if(m==-1 || f==-1){
			cout << "F" << endl;
		}else if(m+f>=80){
			cout << "A" << endl;
		}else if(m+f>=65){
			cout << "B" << endl;
		}else if(m+f>=50){
			cout << "C" << endl;
		}else if(m+f>=30){
			if(r>=50){
				cout << "C" << endl;
			}else{
				cout << "D" << endl;
			}
		}else{
			cout << "F" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
    #include<string>
    #define ll long long
    #define lld long double
    #define llu unsigned long long int
    #define pb push_back
    #define mp make_pair
    #define fir first
    #define sec second
    #define gll(a,n) for(ll i=0;i<n;i++) cin>>a[i];
    #define mod 1000000007
    #define mod1 998244353
    #define pi 3.1415926535897
    using namespace std;
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        //freopen("B-small-attempt0.in", "r", stdin);freopen("output.txt", "w", stdout);
        //std::cout << std::setprecision(9);
        //std::cout << std::fixed;
        ll l,r,i,j;
        cin>>l>>r;
        if(r-l>2019)
        {
            cout<<0;
            return 0;
        }
        l=l%2019;
        r=r%2019;
        if(l==r)
        {
            cout<<l;
            return 0;
        }
        if(r<l)
            swap(l,r);
        ll ans=LONG_LONG_MAX;
        for(i=l;i<=r;i++)
        {
            for(j=i+1;j<=r;j++)
            {
                ans=min(ans,(i*j)%2019);
            }
        }
        cout<<ans;
    }


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define NUM 51

struct Info{
	Info(int arg_node_id,int arg_num){
		node_id = arg_node_id;
		num = arg_num;
	}
	bool operator<(const struct Info & arg) const{
		return num > arg.num;
	}

	int node_id,num;
};

int N;
int in_table[NUM],out_table[NUM],calc_out[NUM];
int edge_exist[NUM][NUM];
vector<int> G[NUM];


int main(){

	scanf("%d",&N);

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++)edge_exist[i][k] = 0;
	}

	int sum = 0,in_sum = 0;
	for(int i = 0; i <= N; i++){
		scanf("%d",&in_table[i]);
		sum += in_table[i];
		in_sum += i*in_table[i];
	}

	if(sum != N){
		printf("NO\n");
		return 0;
	}

	sum = 0;
	int out_sum = 0;
	for(int i = 0; i <= N; i++){
		scanf("%d",&out_table[i]);
		sum += out_table[i];
		out_sum += i*out_table[i];
	}

	if(sum != N){
		printf("NO\n");
		return 0;
	}

	if(in_sum != out_sum){
		printf("NO\n");
		return 0;
	}

	vector<Info> IN_NODE;
	int index = 0;

	for(int i = N; i >= 0; i--){
		for(int k = 0; k < in_table[i]; k++){
			IN_NODE.push_back(Info(index++,i));
		}
	}

	index = 0;

	for(int i = 0; i <= N; i++){
		for(int k = 0; k < out_table[i]; k++){
			calc_out[index++] = i;
		}
	}

	int count;

	for(int i = 0; i < N; i++){
		if(calc_out[i] == 0)continue;

		count = 0;
 		for(int k = 0; k < N; k++){
 			if(IN_NODE[k].num == 0)break;
 			count++;
 			IN_NODE[k].num--;
 			G[i].push_back(IN_NODE[k].node_id);
 			if(count == calc_out[i])break;
		}

 		if(count < calc_out[i]){
 			printf("NO\n");
 			return 0;
 		}

 		sort(IN_NODE.begin(),IN_NODE.end());
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k < G[i].size(); k++){
			edge_exist[i][G[i][k]] = 1;
		}
	}

	printf("YES\n");

	for(int i = 0; i < N; i++){
		printf("%d",edge_exist[i][0]);
		for(int k = 1; k < N; k++){
			printf(" %d",edge_exist[i][k]);
		}
		printf("\n");
	}

	return 0;
}



Measured memory_bytes: 3292
def find_sum_of_digits(num)
  sum = 0
  while (num > 0)
    sum += num % 10
    num /= 10
  end
  
  sum
end

n, a, b = gets.chomp.split(" ").map(&:to_i)

total_sum = 0

(1..n).each do |num|
  sum = find_sum_of_digits(num)
  total_sum += num if sum >= a && sum <= b
end

puts "#{total_sum}"


Measured memory_bytes: 1788
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	int64_t W, H, x, y;
	if (scanf("%" SCNd64 "%" SCNd64 "%" SCNd64 "%" SCNd64, &W, &H, &x, &y) != 4) return 1;
	printf("%" PRId64 ".%d %d\n", W * H / 2, (W * H) % 2 == 0 ? 0 : 5, x * 2 == W && y * 2 == H);
	return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> num(N);
  for (int i = 0; i < N; i++) {
    cin >> num.at(i);
  }
  
  sort(num.begin(), num.end());
  
  vector<int> a(N);
  
  int count = 0;
  int check = num.at(0);
  
  for(int i = 0; i < N; i++) {
    if (num.at(i) == check) {
      count++;
      if (i == N - 1) {
        a.at(i) = count;
      }
    }
    else {
      a.at(i) = count;
      count = 1;
      if (i == N - 1) {
        a.at(0) = count;
      }
      check = num.at(i);
    }
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int ans = 0;
  
  for (int i = K; i < N; i++) {
    ans += a.at(i);
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
import java.math.*;
import java.lang.*;
public class Main {
    static void dfs(int i, ArrayList<Integer>[] g, boolean[] vis, int[] dp) {
        vis[i]=true;
        for(int j:g[i]) {
            if(!vis[j])
                dfs(j,g,vis,dp);
            dp[i]=Math.max(dp[i],dp[j]+1);
        }
    }
    public static void main(String[] args) throws Exception {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String s=br.readLine();
        String[] c=s.split(" ");
        int n=Integer.valueOf(c[0]),
            m=Integer.valueOf(c[1]);
        ArrayList<Integer>[] g=new ArrayList[n];
        for(int i=0;i<n;i++)
            g[i]=new ArrayList<>();
        for(int i=0;i<m;i++) {
            s=br.readLine();
            c=s.split(" ");
            int x=Integer.valueOf(c[0])-1,
                y=Integer.valueOf(c[1])-1;
            g[x].add(y);
        }
        int[] dp=new int[n];
        boolean[] vis=new boolean[n];
        for(int i=0;i<n;i++) {
            if(!vis[i])
                dfs(i,g,vis,dp);
        }
        int ans=0;
        for(int i=0;i<n;i++)
            ans=Math.max(ans,dp[i]);
        pw.print(ans);
        br.close();
        pw.close();
    }
}

Measured memory_bytes: 62888
#include <stdio.h>

int main(void){
    int A, B;

    scanf("%d%d", &A, &B);

    if(B == 1){
        printf("0\n");
    }else if(A >= B){
        printf("1\n");
    }else{
        B -= A;

        printf("%d\n", (B + A - 2) / (A - 1) + 1);
    }
}

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

using namespace std;

int main(){
    int N; cin>>N;
    int r_cnt=0;
    int tmp;
    vector<int> a(N);
    vector<int> b(N);//1~N-2 左なら0

    for(int i=0;i<N;i++) cin>>a[i];

    sort(a.begin(),a.end());
    
    int min=a[0];
    int max=a[N-1];

    //<=0 1~minus   >0 minus+1~N-2

    for(int i=1;i<=N-2;i++){
        if(a[i]<=0 && r_cnt%2==0){
            b[i]=1;
        }
        else if(a[i]<=0 && r_cnt%2==1){
            b[i]=0;
         	r_cnt++;
        }
        else if(a[i]>0 && r_cnt%2==0){
            b[i]=0;
         	r_cnt++;
        }
       else if(a[i]>0 && r_cnt%2==1){
            b[i]=1;
        }
    }
    if(r_cnt%2==1){
        tmp=a[0]-a[N-1];
    }else{
        tmp=a[N-1]-a[0];
    }

    for(int i=N-2;i>=1;i--){
        if(b[i]==0){
            tmp=a[i]-tmp;
        }else if(b[i]==1){
            tmp=tmp-a[i];
        }
    }
    printf("%d\n",tmp);
  if(r_cnt%2==1){
        printf("%d %d\n",a[0],a[N-1]);
        tmp=a[0]-a[N-1];
    }else{
        printf("%d %d\n",a[N-1],a[0]);
        tmp=a[N-1]-a[0];
    }

    for(int i=N-2;i>=1;i--){
        if(b[i]==0){
            printf("%d %d\n",a[i],tmp);
            tmp=a[i]-tmp;
        }else if(b[i]==1){
            printf("%d %d\n",tmp,a[i]);
            tmp=tmp-a[i];
        }
    }
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
 
int main() {
    unsigned long long a, b;
    char s[6];
 
    scanf("%lld%s", &a, s);
    b = (s[0]-'0')*100 + (s[2]-'0')*10 + (s[3]-'0'); 
 
    printf("%llu\n", a*b/100);
 
    return 0;
}

Measured memory_bytes: 3824
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        long[] a=new long[n];
        for(int i=0;i<n;i++) a[i]=fsc.nextLong();
        fsc.close();
        Arrays.sort(a);
        long ai=a[n-1];
        long aj=-1;
        long del=Long.MAX_VALUE;
        for(int k=0;k<n-1;k++){
            long ak=Math.min(ai-a[k], a[k]);
            long newDel=Math.abs(ai/2-ak);
            if(newDel<del){
                del=newDel;
                aj=a[k];
            }
        }
        System.out.println(ai+" "+aj);
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 25932
#include<iostream>
#include <string>
using namespace std;
#define ll  long long
int main(){
string s;
cin>>s;
ll len = s.length();
for(ll i=0;i<len;i++){
	if(i % 2 == 0){
		if(s[i]=='L'){cout<<"No";return 0;}

	}
	if(i % 2 == 1 ){

		if(s[i]=='R'){cout<<"No";return 0;}

	}


}
cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>


using namespace std;
using ll = long long int;

struct entry {
  ll a;
  ll b;

  bool operator<(const entry &e) const {
    return this->b < e.b;
  }

  bool operator>(const entry &e) const {
    return this->b > e.b;
  }
};

int main(void) {
  ll N;
  cin >> N;

  priority_queue<entry, vector<entry>, greater<entry> > queue;

  for (ll i = 0; i < N; i++) {
    ll a, b;
    cin >> a >> b;
    queue.push(entry{ a, b });
  }

  ll time = 0;
  while (!queue.empty()) {
    entry e = queue.top();
    queue.pop();

//    cout << e.a << ',' << e.b << endl;

    time += e.a;

    if (time > e.b) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 6256
while True:
    a = list(map(int, input().split()))
    b = a[0]
    c = a[1]
    if b == c == 0:
        break
    for i in range(1, b+1):
        if i % 2 != 0:
            if c % 2 == 0:
                print('#.' * (c // 2))
            else:
                print('#.' * (c // 2) + '#')
        else:
            if c % 2 == 0:
                print('.#' * (c // 2))
            else:
                print('.#' * (c // 2) + '.')
    print()

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

int main(){
  int n,m,k;
  int ans = 0;
  cin >> n >> m;
  for(int i = 0;i<n;i++){
    cout << "lst " << i << endl;
    cin >> k;
    for(int j =0;j<k;j++) cin >> m;
    ans += k*(k-1);
  }
  cout << "ans " << ans << endl;
  return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<ctype.h>

int main(void){
    char ch;
    while(1){
        scanf("%c",&ch);
        if(ch=='\n'){
            printf("\n");
            break;
        }else if(islower(ch)){
            printf("%c",toupper(ch));
        }else if(isupper(ch)){
            printf("%c",tolower(ch));
        }else{
            printf("%c",ch);
        }
    }
    return 0;
}



Measured memory_bytes: 2136
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let _n = i.read::<usize>();
    let s = i.read_line().to_string();
    let q = i.read::<usize>();
    let k = i.read_vec::<usize>(q);
    for k in k {
        writeln!(o, "{}", solve(&s, k)).unwrap();
    }
}
pub fn solve(s: &str, k: usize) -> usize {
    let s = s.as_bytes();
    let mut d = 0;
    let mut m = 0;
    let mut dm = 0;

    let mut result = 0;
    let mut j = 0;

    for i in 0..s.len() {
        if i - j == k {
            match s[j] {
                b'D' => {
                    d -= 1;
                    dm -= m;
                }
                b'M' => {
                    m -= 1;
                }
                _ => {}
            }
            j += 1;
        }
        match s[i] {
            b'D' => {
                d += 1;
            }
            b'M' => {
                m += 1;
                dm += d;
            }
            b'C' => {
                result += dm;
            }
            _ => {}
        }
    }
    result
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];
    ll icnt,bcnt;
    icnt = bcnt = 0;
    //前から
    int num = 0;
    rep(i,N-1){
        int m;
        m = (a[i] - num)/2;
        icnt += m;
        num += m*2;
        icnt += min(a[i]-num,a[i+1]);
        num = min(a[i]-num,a[i+1]);
    }
    icnt += (a[N-1] - num) / 2;
    //後ろから
    num = 0;
    rep(i,N-1){
        int m;
        m = (a[N-1-i]- num)/2;
        bcnt += m;
        num += m * 2;
        bcnt += min(a[N-1-i] -num,a[N-2-i]);
        num = min(a[N-1-i] -num,a[N-2-i]);
    }
    bcnt += (a[0] - num) / 2;
    cout << max(bcnt,icnt) << endl;
}

Measured memory_bytes: 3732
#include <cstdio>
#include <cstring>
using namespace std;

char s[100001];

signed main()
{
	scanf("%s", s); int l=strlen(s), p=0;
	for(int i=0; i<l; ++i) if(s[i]=='p') ++p;
	printf("%d\n", l/2-p);
	return 0;
}

Measured memory_bytes: 256
module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.container.rbtree;
import std.conv;
import std.stdio;
import std.string;
import std.traits;

struct Input
{
    string s;
    int q;
    Query[] queries;
}

enum QueryType
{
    reverse,
    prepend,
    append,
}

struct Query
{
    QueryType type;
    char c;
}

void parseInput(T)(out Input input, T file)
{
	with (file) with (input)
	{
        s = readln().strip();
        q = readln().strip().to!int;
        queries.length = q;
        foreach (i; 0..q)
        {
            Query query;
		    auto ar = readln().strip().split().array();
            auto t = ar[0];
            if (t == "1")
            {
                query.type = QueryType.reverse;
            }
            else
            {
                auto f = ar[1];
                if (f == "1")
                {
                    query.type = QueryType.prepend;
                }
                else
                {
                    query.type = QueryType.append;
                }
                query.c = ar[2][0];
            }
            queries[i] = query;
        }
	}
}

auto main2(Input* input)
{
	with (input)
	{
        char[200000] pre;
        int preLength = 0;
        char[200000] post;
        int postLength = 0;
        bool reversed = false;

        foreach (query; queries)
        {
            final switch (query.type) with (QueryType)
            {
                case reverse:
                    reversed = !reversed;
                    break;
                case prepend:
                    if (!reversed)
                        pre[preLength++] = query.c;
                    else
                        post[postLength++] = query.c;
                    break;
                case append:
                    if (reversed)
                        pre[preLength++] = query.c;
                    else
                        post[postLength++] = query.c;
                    break;
            }
        }

        if (!reversed)
        {
            for (int i = preLength - 1; i >= 0; i--)
            {
                write(pre[i]);
            }
            write(s);
            for (int i = 0; i < postLength; i++)
            {
                write(post[i]);
            }
        }
        else
        {
            for (int i = postLength - 1; i >= 0; i--)
            {
                write(post[i]);
            }
            foreach_reverse (c; s)
                write(c);
            for (int i = 0; i < preLength; i++)
            {
                write(pre[i]);
            }
        }
	}
}

alias retType = ReturnType!main2;

void printResult(T)(T result)
{
	static if (isFloatingPoint!T) writefln("%f", result);
	else writeln(result);
}

void main()
{
	Input input = void;
	parseInput(input, stdin);
	static if (is(retType == void))
		main2(&input);
	else
	{
		auto result = main2(&input);
		printResult(result);
	}
}


Measured memory_bytes: 5400
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF  numeric_limits<int_fast64_t>::max();
#define intf int_fast64_t
int main(){
    intf a,b,c,k;
    cin >>a >>b >>c >>k;
    intf i=0;

    if(a>=k){
        cout << k<<endl;
    }else if(a+b>=k){
        cout << a <<endl;
    }else{
        cout << a- (k-a-b)<<endl;
    }

}


Measured memory_bytes: 3604
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

ll gcd(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

int main()
{
    int n;
    cin >> n;
    vi v(n), c(n);
    rep(i, 0, n) cin >> v[i];
    rep(i, 0, n) cin >> c[i];

    int ans = -INF;
    rep(i, 0, 1 << n)
    {
        int x = 0, y = 0;
        rep(j, 0, n)
        {
            if ((i & (1 << j)) != 0)
            {
                x += v[j];
                y += c[j];
            }
        }
        ans = max(ans, x - y);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define debug(x) cout << #x << " : " << (x) << " --------------" << endl;
using namespace std;
int getPreNum(char mcxi, const string& str) {
    int i = str.find(mcxi);
    if (i == -1) return 0;
    else if (i == 0 || !isdigit(str[i-1])) return 1;
    else return str[i-1] - '0';
}
int main(void){
    int n;
    cin >> n;
    string ixcm = "ixcm";
    string mcxi = "mcxi";
    REP(k, n) {
        string str1, str2;
        cin >> str1 >> str2;
        int sum = 0;
        REP(i, 4) {
            int num = getPreNum(ixcm[i], str1) + getPreNum(ixcm[i], str2);
            sum += num * pow(10, i);
        }
        ostringstream oss;
        oss << setfill('0') << setw(4) << sum;
        string digits = oss.str();
        string res = "";
        REP(i, 4) {
            char c = digits[i];
            if (c > '0') {
                if (c > '1') res += c;
                res += mcxi[i];
            }
        }
        cout << res << endl;
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3372
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <algorithm>
#include <cctype>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
typedef pair<double,double> pdd;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;

struct point{
	double x,y;
	point operator+(point Gep){
		return point{x+Gep.x,y+Gep.y};
	}
	point operator-(point Gep){
		return point{x-Gep.x,y-Gep.y};
	}
	point operator*(double Gex){
		return point{x*Gex,y*Gex};
	}
	point operator/(double Gex){
		if(!Gex) return point{0,0}; 
		return point{x/Gex,y/Gex};
	}
	bool operator==(point Gep){
		return fabs(x-Gep.x)<eps&&fabs(y-Gep.y)<eps;
	}
};
class Geom{
	public:
	vector<point> Ge;
	vector<pair<point,point> > Geseg,Geline;
	void line_push(point Gex,point Gey){
		Geline.push_back(make_pair(Gex,Gey));
	}
	pdd POI(pdd Gea,pdd Geb,pdd Gec,pdd Ged){
		return pdd(3,4);
	}
	double IP(point Gex,point Gey){
		return Gex.x*Gey.x+Gex.y*Gey.y;
	}
	double LEN(point Gex){
		return sqrt(Gex.x*Gex.x+Gex.y*Gex.y);
	}
	point PRO(point Gea,point Geb,point Gex){
		point Ge1=Gex-Geb,Ge2=Gea-Geb;
		return Ge2*(IP(Ge1,Ge2)/(LEN(Ge2)*LEN(Ge2)))+Geb;
	}
	point line_open(int Gex,bool Gej){
		if(Gej) return Geline[Gex].second;
		else return Geline[Gex].first;
	}
};

int q;
double x,xx,y,yy,xxx,yyy;

int main(){
	cout<<shosu(10);
	cin>>x>>y>>xx>>yy>>q;
	for(int i=0;i<q;i++){
		cin>>xxx>>yyy;
		Geom geo;
		geo.line_push(point{x,y},point{xx,yy});
		point ans=geo.PRO(geo.line_open(0,0),geo.line_open(0,1),point{xxx,yyy});
		cout<<ans.x<<' '<<ans.y<<endl;
	}
}

Measured memory_bytes: 1300
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

const int maxn = 2e3;
const int MOD = 1e9 + 7;

class Modint {
public:
	long long val;

	Modint (long long _val = 0)
		: val((_val + MOD) % MOD) {}

	Modint operator+ (Modint other) {
		return Modint(val + other.val);
	}

	void operator+= (Modint other) {
		val += other.val;
		val %= MOD;
	}

	Modint operator- () {
		return Modint(MOD - val);
	}

	Modint operator- (Modint other) {
		return Modint(val + MOD - other.val);
	}

	void operator-= (Modint other) {
		val += MOD - other.val;
		val %= MOD;
	}

	Modint operator* (Modint other) {
		return Modint(val * other.val);
	}

	void operator*= (Modint other) {
		val *= other.val;
		val %= MOD;
	}

	bool operator== (Modint other) {
		return val == other.val;
	}

	bool operator!= (Modint other) {
		return val != other.val;
	}
};

Modint exp (Modint a, int k) {
	if (k == 0) {
		return Modint(1);
	} else if (k % 2 == 0) {
		Modint half = exp(a, k / 2);
		return half * half;
	} else {
		return a * exp(a, k - 1);
	}
}

Modint inv (Modint a) {
	return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
	out << p.val;
	return out;
}

vector<Modint> fact(maxn + 1, 1);
vector<Modint> inv_fact(maxn + 1, 1);

void preC() {
	for (long long i = 1; i <= maxn; i++) {
		fact[i] = fact[i - 1] * i;
		inv_fact[i] = inv(i) * inv_fact[i - 1];
	}
}

Modint C(long long n, long long r) { // nCr % MOD
	if (n < r) return 0;
	return fact[n] * inv_fact[r] * inv_fact[n - r];
}


int main() {

	preC();

	int n, k; cin >> n >> k;

	for (int i = 1; i <= k; i++) {
		cout << C(n - k + 1, i) * C(k - 1, i - 1) << "\n";
	}


	return 0;
}

Measured memory_bytes: 3192