akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define modn 1000000007

#define SZ 100005
using namespace std;
ll n;
ll fn(ll arr[], ll x)
{
    ll ret = 0;
    for(int i=1; i<=n; i++) ret += abs(arr[i]-x);
    return ret;
}
int main()
{
    cin>>n;
    ll arr[n+1];
    for(ll i=1; i<=n; i++)
    {
        cin>>arr[i];
        arr[i] -= i;
    }
    sort(arr+1, arr+1+n);
    ll ans = LLONG_MAX;
    ll aage[n+3], piche[n+3];
    aage[1] = arr[1];
    piche[n] = arr[n];
    for(int i=2; i<=n; i++) aage[i] = arr[i] + aage[i-1];
    for(int i=n-1; i>=1; i--) piche[i] = arr[i] + piche[i+1];
    
    for(ll i=1; i<=n; i++)
    {
        ll a = i*arr[i] - aage[i];
        ll b;
        if(i == n) b = 0;
        else b = piche[i+1] - (n-i)*arr[i];
        ans = min(ans, abs(a)+abs(b));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define vi vector<int>
#define lvi vector<long long>
#define pi pair<int,int>
#define lpi pair<long long ,long long>
#define mp make_pair
#define pb push_back
#define ll long long 
#define faltu ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define mod1 1000000000000000007
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>multiordered_set;
ll int pw(ll int a, ll int b,ll md) {
    if (b == 0) return 1;
    ll int t = pw(a, b / 2,md);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
vector<int> pm;
void prm(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
              prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p]) pm.push_back(p);
}
bool cmp(const pair<ll int,ll int> &a,const pair<ll int,ll int> &b)
{
    if(a.first==b.first)return a.second<b.second;
    return a.first>b.first;
}
ll int gcd(ll int a,ll int b)
{
    if(!a)return b;
    return gcd(b%a,a);
}
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
    return true; 
} 
map<int,int>pa;
int find(int i){
    if(pa[i]==i)return i;
    return pa[i]=find(pa[i]);
}     
void join(int i,int j){
    int a=find(i);
    int b=find(j);
    if(b>=a)pa[b]=a;
    else pa[a]=b;
}               
int ddx[]={-1,-1,-1,0,1,1,1,0};
int ddy[]={-1,0,1,1,1,0,-1,-1};
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int main()
{
    faltu;
    int t=1;
   // cin>>t;
    while(t--)
    {
       ll x;
       cin>>x;
       if(x%2)x*=2;
       cout<<x<<endl;
    }
}

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

int n;
int x[100], y[100];
int dx[]{ 2,2,2,-2,-2,-2,1,0,-1,1,0,-1 }, dy[]{ 1,0,-1,1,0,-1,2,2,2,-2,-2,-2 };
bool dfs(int cnt, int px, int py) {
	if (~cnt && (abs(x[cnt] - px) > 1 || abs(y[cnt] - py) > 1))return false;
	if (cnt == n - 1)return true;
	rep(i, 12) {
		int nx = px + dx[i], ny = py + dy[i];
		if (0 <= nx&&nx < 10 && 0 <= ny&&ny < 10 && dfs(cnt + 1, nx, ny) == true)
			return true;
	}
	return false;
}
int main() {
	int px, py;
	while (scanf("%d%d", &px, &py), px) {
		scanf("%d", &n);
		rep(i, n) {
			scanf("%d%d", &x[i], &y[i]);
		}
		puts(dfs(-1, px, py) ? "OK" : "NA");
	}
}

Measured memory_bytes: 3000
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
int INF = 1e9+7;
int dp[41][500][500];

int main(){
    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    vector<int> a(N), b(N), c(N);
    for(int i = 0;i < N;i++)    cin >> a[i] >> b[i] >> c[i];
    for(int i = 0;i < 41;i++)for(int j = 0;j < 410;j++)for(int k = 0;k < 410;k++)  dp[i][j][k] = INF;
    dp[0][0][0] = 0;
    for(int i = 0;i < N;i++){
        for(int j = 0;j < 401;j++){
            for(int k = 0;k < 401;k++){
                dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i]);
                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
            }
        }
    }
    int ans = INF;
    for(int i = 1;i < 401;i++){
        for(int j = 1;j < 401;j++){
            if(Ma*j == Mb*i)ans = min(ans, dp[N][i][j]);
        }
    }
    if(ans == INF)  ans = -1;
    cout << ans << endl;
}

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

using namespace std;
int n;
const int maxn=2e5+5;
int a[maxn];
priority_queue<int> q;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        q.push(a[i]);
    }
    int k;
    for(int i=1;i<=n;i++)
    {
        int t=q.top();
        if(t==a[i])
        {
            q.pop();
            k=q.top();
            q.push(t);
            t=k;
        }
        printf("%d\n",t);
    }
    return 0;
}


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <stdio.h>
#include <string>


using namespace std;

long yakusuukosuu(long a) {
    long ans = 1;

    for (int i = 2; i <= sqrt(a); i++) {
        int cnt = 0;
        while (a % i == 0) {
            cnt++;
            a /= i;
        }
        ans *= (cnt + 1);
        if (a == 1) break;
    }
    if (a != 1) ans *= 2;


    return ans;
}

int main() {

    long intNum;
    long intCount = 0;

    cin >> intNum;

    for (long i = 1; i <= intNum - 1; i++)
    {
        intCount = intCount + yakusuukosuu(i);
    }

    cout << intCount << endl;

    return 0;
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, a, b; cin >> n >> a >> b;
    cout << min(a*n, b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define ii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
#define MOD 998244353
#define output(x) for (auto a:x) cout<<a<<" ";cout<<endl;
#define output2(x) for (auto a:x) cout<<a.fi<<" "<<a.se<<endl;
 
int power(int x,int y,int mod) 
{ 
 	int ret = 1;
 	x = x % mod;
 	while (y){
 		if(y&1) ret = (ret*x)%mod;
 		y = y>>1;
 		x = (x*x)%mod;
    } 
    return ret%mod; 
}

int isprime(int x)
{
	for (int i=2;i*i<=x;i++)
		if (x%i==0) return 0;
	return 1;
}
 
 bool cmp(ii a,ii b){
	return a.se<b.se;
}
void solve()
{	
	int n;
	cin>>n;
	int ans = 0;
	for (int i=1;i<=n;i++){
		if (i%3==0 || i%5==0) continue;
		else ans+=i;
	}
	cout<<ans<<endl;
}
 
 
signed main(){
	// int t;
	// cin>>t;
	// while (t--)	
	solve();	
 
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  vector<int> cost(3);
  cost[0] = a;
  cost[1] = b;
  cost[2] = c;
  sort(cost.begin(), cost.end());
  cout << cost[0]+cost[1];
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
 
using namespace std;

const int maxn = 1e5+5;
long long arr[maxn];

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

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

    int ans = 0; int c = 0;
    for (int i = 0; i < N-1; i++) {
        if (arr[i+1] <= arr[i]) { c++; }
        else { ans = max(ans, c); c = 0; }
    }
    ans = max(ans, c);
    cout << ans << endl;

}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <fstream>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cstring>
#include <cctype>
#include <numeric>
#include <cstdio>
#include <math.h>
#include <functional>
using namespace std;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define rep(i, n) for (i64 i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (i64 i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
#define na(a, n) rep(i, n) cin >> a[i];
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
vb d(10);
int ans(int x)
{
    while (x)
    {
        if (d[x % 10])
            return 0;
        x /= 10;
    }
    return 1;
}
//ここからメイン
int main()
{
    int r, g, b, a;
    cin >> r >> g >> b;
    a = 100 * r + 10 * g + b;
    if (a % 4 == 0)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    static FastScanner sc = new FastScanner();
    public void solve1(int testNumber, Scanner in, PrintWriter out) {
        int K = Integer.parseInt(in.next());
        int x = 7 % K;
        int i = 1;
        Set<Integer> s = new HashSet<>();
        while (!s.contains(x)) {
            if (x == 0) {
                out.println(i);
                return;
            } else {
                s.add(x);
                x = (x * 10 + 7) % K;
                ++i;
            }
        }
        out.println(-1);
    }
    static void solve(int k){
        int x=7%k;
        int i=1;
        Set<Integer> s= new HashSet<>();
        while (!s.contains(x)){
            if (x==0){
                System.out.println(i);
                return;
            }
            else{
                s.add(x);
                x=(x*10+7)%k;
                i++;
            }
        }
        System.out.println("-1");
    }

    public static void main(String[] args) {
        int t=sc.nextInt();
        solve(t);


    }

        static void sortint(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }
    static void sort(long[] a) {
        ArrayList<Integer> l = new ArrayList<>();
        for (long i : a) l.add((int) i);
        Collections.sort(l);
        for (int i = 0; i < a.length; i++) a[i] = l.get(i);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}





Measured memory_bytes: 99696
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
vector<ll>pos[21];
ll inp[100];
map<ll,ll>mp;
vector<ll>points;
vector<ll>::iterator upper1, upper2;
int main()
{
  ll i,j,k,l,t,n,x=0,y=0,p,q,z=0,a,b;
  cin>>a>>b;
  x=a-(b+b);
  cout<<max(y,x);
  
  
     
     
     	
  	
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int k, x;
	cin >> k >> x;
	
	if( 500 * k >= x ) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		bool infect[n+1];
		rep(i,n+1)infect[i]=false;
		infect[1]=true;
		long long ans=1;
		long long t[m];
		int s[m],d[m];
		rep(i,m)cin>>t[i]>>s[i]>>d[i];
		for(int i=m;i>=0;i--){
			for(int j=0;j<i-1;j++){
				if(t[j]>t[j+1]){
					long long alt=t[j];
					t[j]=t[j+1];
					t[j+1]=alt;
					alt=s[j];
					s[j]=s[j+1];
					s[j+1]=alt;
					alt=d[j];
					d[j]=d[j+1];
					d[j+1]=alt;
				}
			}
		}
		rep(i,m){
			if(infect[s[i]]){
				if(!infect[d[i]])ans++;
				infect[d[i]]=true;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1492
#include<iostream>
#include<cmath>
#include<algorithm>

typedef unsigned long long ULL;
typedef long long LL;
using namespace std;

int F(ULL a);
int main(){
    ULL N,min,temp,i;
    
    cin >> N;
    
    min = -1;
    for( i= 1;i<=sqrt(N);i++){
        if( N % i == 0){
            temp = F(N/i);
            if( min == -1 || min > temp){
                min = temp;
            }
        }
    }
    
    cout << min << endl;
    
    return 0;
}
int F(ULL a){
    int a_dighit;
    a_dighit = 0;
    
    while(a > 0 ){
        a_dighit++;
        a /= 10;
    }
    return a_dighit;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(void){
    int n,x; cin>>n>>x;
    vector <int> kids(n);
    for(int i=0;i<n;i++){
        cin>>kids[i];
    }
    int ans = 0;
    sort(kids.begin(),kids.end());
    for(int i=0;i<n;i++){
        if(i==n-1) {if(kids[i]==x) ans++; break;}
        if(x-kids[i]>=0){
            x-=kids[i];
            ans++;
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  int **A = new int*[n];
  for (int i = 0; i < n; i++)
  {
    A[i] = new int[m];
    for (int j = 0; j < m; j++)
    {
      cin >> A[i][j];
    }
  }
  int *a = new int[m];
  for (int i = 0; i < m; i++)
  {
    cin >> a[i];
  }

  int *ans = new int[n];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      ans[i] += A[i][j] * a[j];
    }
  }

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


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

void lcs(string X,string Y,ll m,ll n)
{
  ll L[m+1][n+1],i,j;
  for(i=0;i<=m;i++)
  {
   for(j=0;j<=n;j++)
   {
     if(i==0||j==0) L[i][j]=0;
     else if(X[i-1]==Y[j-1]) 
            L[i][j]=L[i-1][j-1]+1;
     else L[i][j]=max(L[i-1][j],L[i][j-1]);
   }
  }
  ll index=L[m][n];
  char lcs[index+1];

  lcs[index]='\0';
  i=m,j=n;
  while(i>0&&j>0)
  {
    if(X[i-1]==Y[j-1])
    {
    lcs[index-1]=X[i-1];
    i--,j--,index--;
    }
    else if(L[i][j-1]>L[i-1][j]) j--;
    else i--;        
  }
    cout<<lcs<<endl;
}
int main()
{
  ll m,n;
  string s,t;
  
  cin>>s>>t;
  m=s.size(),n=t.size();
  
    
  lcs(s,t,m,n);
}

Measured memory_bytes: 70656
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(void){
	int n,m;
	long res = 0;
	cin >> n >> m;
	priority_queue<int> a;
	for(int i=0;i<n;++i){
		int k;
		cin >> k;
		a.push(k);
	}
	for(int i=0;i<m;i++){
		int k = a.top() / 2;
		a.pop();
		a.push(k);
	}
	for(int i=0;i<n;++i){
		res += a.top();
		a.pop();
	}
	cout << res << endl;
}

Measured memory_bytes: 892
#include <string.h>

int main(){
    int A=0,B=0;
    char a[100];
    char b[100];
    int N;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%s %s",&a,&b);
        if(strcmp(a,b)==0){
            A+=1;
            B+=1;
        }else if(strcmp(a,b)>0){
            A+=3;
        }else if(strcmp(a,b)<0){
            B+=3;
        }
    }
    printf("%d %d\n",A,B);
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define pie 3.14159265358979323846
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
bool greater_pair(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first!=b.first){
        return a.first>b.first;
    }else{
        return a.second>b.second;
    }
}
int main() {
    ios::sync_with_stdio(false);
    int N=in();int T=in();
    int ans=INF;
    bool flg=false;
    REP(i,N){
        int c,t;
        cin>>c>>t;
        if(t<=T){
            ans=min(ans,c);
            flg=true;
        }
    }
    if(flg){
         cout<<ans<<endl;
    }else{
        cout<<"TLE"<<endl;
    }
   
    return 0;
}


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

#define MAXN 100*1000 + 5

int color[MAXN];
vector<pair<int, int>> g[MAXN];

void dfs(int u, int p = -1, int p_color = -1) {
	int c = 1;
	for(auto e : g[u]) {
		int v = e.first, i = e.second;
		if(v == p) continue;
		if(c == p_color) c++;
		color[i] = c;
		dfs(v, u, c);
		c++;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	for(int i = 0; i < n-1; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		g[u].emplace_back(v, i);
		g[v].emplace_back(u, i);
	}
	
	dfs(0);
	int mx = 0;
	for(int i = 0; i < n-1; i++) {
		mx = max(mx, color[i]);
	}
	cout << mx << '\n';
	for(int i = 0; i < n-1; i++) {
		cout << color[i] << '\n';
	}
}


Measured memory_bytes: 9344
n=int(input())
a=list(map(int,input().split()))
t1=0
t2=0
t4=0
for i in a:
    if i%4==0:
        t4+=1
    elif i%2==0:
        t2+=1
    else:
        t1+=1
if t2==0:
    print('Yes' if t1<=t4+1 else 'No')
else:
    print('Yes' if t1<=t4 else 'No')

Measured memory_bytes: 14252
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define INF 1e9+7
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
ll dp[101][100001];
int main(){
    int n,W;
    cin>>n>>W;
    vector<int>w(n+1),v(n+1);
    for(int i=1;i<n+1;i++)cin>>w[i]>>v[i];
    rep(i,100001)dp[0][i]=INF;
    dp[0][0]=0;
    for(int i=1;i<n+1;i++){
        for(int j=0;j<100001;j++){
            if(j-v[i]>=0)dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    int ans=100000;
    
    while(dp[n][ans]>W)ans--;
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
	int x,c,d,e,f,g,h;
	cin>>x;
	
	
	for(c=0; c<=x/100; c++)
		for(d=0; d<=x/101; d++)
			for(e=0; e<=x/102; e++)
				for(f=0; f<=x/103; f++)
					for(g=0; g<=x/104; g++)
						for(h=0; h<=x/105; h++)
						{
							if(c*100+d*101+e*102+f*103+g*104+h*105==x)
							{
								cout<<"1"<< endl;
								return 0;
							}
						}
	cout<<"0"<< endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c,x,t;
  t=0;
  cin >> a >> b >> c >> x;
  for(int i=0;i<a+1;i++){
      x-=500*i;
      for(int j=0;j<b+1;j++){
         x-=100*j;
         for(int k=0;k<c+1;k++){
            x-=50*k;
            if(x==0) t+=1;
            x+=50*k;
         }
         x+=100*j;
      }
      x+=500*i;
  }
  cout<< t <<endl;
}


Measured memory_bytes: 504
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main(){
string S;
cin>>S;
int N=S.size()+1;
int table[N];
table[0]=0;
rep(i,S.size()){
    if(S[i]=='<'){
        table[i+1]=table[i]+1;
        
    }
    else{
        table[i+1]=0;
    }
}
repr(i,S.size()){
    if(S[i]=='>'){
        table[i]=max(table[i],table[i+1]+1);

    }
    
}
ll ans=0;
rep(i,N){
    ans+=table[i];
}
cout<<ans<<endl;
}

Measured memory_bytes: 5872
#include "bits/stdc++.h"
#include "math.h"
#include "string.h"
#include "algorithm"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<int,int> P;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
vin dp(1000,0);
int main(){
  int n;
  cin>>n;
  int x=n/2;
  if(n%2==1){
    x++;
  }
  cout<<x<<endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
limit = 100000
mod = 10**9+7
lpow = [False] * (limit+1)
lpow[0] = 1
def pow(n,p):
    if p<0:return 0
    if lpow[p]:
        return lpow[p]
    else:
        if p % 2 == 0:
            ret = (pow(n,p//2)**2) % mod
        else:
            ret = ((pow(n,p//2)**2)*n) % mod
        lpow[p] = ret
        return ret

def main():
    s=input()
    res = 0
    ca = 0
    cc = s.count("C")
    cw = 0
    aw = s.count("?")
    for c in s:
        if c == "A":
            ca += 1
        elif c == "C":
            cc -= 1
        elif c == "B":
            res += ca*cc*pow(3,aw)+ca*(aw-cw)*pow(3,aw-1)+cw*cc*pow(3,aw-1)+cw*(aw-cw)*pow(3,aw-2)
            res %= mod
        elif c == "?":
            res += ca*cc*pow(3,aw-1)+ca*(aw-cw-1)*pow(3,aw-2)+cw*cc*pow(3,aw-2)+cw*(aw-cw-1)*pow(3,aw-3)
            res %= mod
            cw += 1

    print(res)

main()

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


int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    int ans = H*W - (H*w + h*W) + h*w;
    cout << ans << endl;
}



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

int main(){
  ll x, y;
  cin >> x >> y;
  int ans = 0;
  while (x <= y){
    x *= 2;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

string s, t;
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if(s[i] != t[i]) ans++;
    }
    cout << ans << '\n';
    return 0;
}

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

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i] - (i + 1);
  }
  sort(b.begin(), b.end());
  long long ans = 0;
  for (int i = 0; i < n; i++)
    ans += abs(b[i] - b[n / 2]);
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1792
from math import atan, degrees
a, b, x = map(int, input().split())

#ans = max(90 - degrees(atan(0.5 * a ** 3/(a ** 2 * b - x))), 90 - degrees(atan(2 * x / (a * b ** 2))))
if a ** 2 * b == x:
    ans = 0
else:
    if 0.5 * a ** 2 * b < x:
        ans = 90 - degrees(atan(0.5 * a ** 3/(a ** 2 * b - x)))
    else:
        ans = 90 - degrees(atan(2 * x / (a * b ** 2)))

print(ans)

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

int up(const void *a,const void *b){
 
  return *(int *)a - *(int *)b;
}

int main(void){
  int n , k;
  scanf("%d %d",&n,&k);
  
  int h[n];
  for(int i = 0;i < n;i ++){
    scanf("%d",&h[i]);
  }
  
  qsort(h,n,sizeof(int),up);
  
  
 int min = 1000000000;
 
 for(int i = 0;k - 1 + i < n;i ++){  
  if(h[k-1+i] - h[i] < min){
    min = h[k -1 + i] - h[i];
  }
 }
  
  printf("%d\n",min);
  return 0;
}

Measured memory_bytes: 892
#include <iostream>

using namespace std;

int main() {
	string s;
	cin >> s;
	int a[26];
	for (int i = 0; i < 26; i++) a[i] = 0;
	for (auto c : s) a[c - 'a']++;
	bool ok = true;
	for (int i = 0; i < 26; i++)
		if (a[i] % 2) ok = false;
	cout << (ok ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    int a;
    int b;
    int c;
    cin >> a >> b >> c;

    cout << c << " " << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

long gcd(int a, int b){
    if(a % b == 0){
        return b;
    }
    return gcd(b, a % b);
}

int main(){
    int k;
    int ans;
    scanf("%d", &k);
    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            for(int l = 1; l <= k; l++){
                ans += gcd(gcd(i, j), l);
            }
        }
    }
    std::cout << static_cast<long>(ans) << std::endl;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int maxn=1e6+100;
char st[maxn],qu[maxn];
int main()
{
    string s;
    cin>>s;
    int n,tot=0,cas1=0,cas2=0;
    scanf("%d",&n);
    while(n--){
        int x;
        scanf("%d",&x);
        if(x==1){
            tot++;
        }else{
            char ch;
            scanf("%d%c%c",&x,&ch,&ch);
            if(tot%2==0){
                if(x==1){
                    //s=ch+s;
                    st[cas1++]=ch;
                }else
                    //s=s+ch;
                    qu[cas2++]=ch;
            }else{
                if(x==1){
                    //s=s+ch;
                    qu[cas2++]=ch;
                }else
                    //s=ch+s;
                    st[cas1++]=ch;
            }
        }
    }
    if(tot%2)
        {
            for(int i=cas2-1;i>=0;i--)
                printf("%c",qu[i]);
            reverse(s.begin(),s.end());
            cout<<s;
            for(int i=0;i<cas1;i++)
                printf("%c",st[i]);
        }
    else{
        for(int i=cas1-1;i>=0;i--)
                printf("%c",st[i]);

            cout<<s;
    for(int i=0;i<cas2;i++)
                printf("%c",qu[i]);
    }

    //cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define maxn 100100
int gcd(int x,int y)
{
	if(x<y) swap(x,y);
	if(y==0) return x;
	else return gcd(y,x%y);
}
int a[maxn];
int n,k;
int main()
{
	while(~scanf("%d%d",&n,&k))
	{
		for(int i=1;i<=n;++i) scanf("%d",&a[i]);
		sort(a+1,a+1+n);
		if(a[n]<k) 
		{
			puts("IMPOSSIBLE");
			continue;
		}
		int ans=a[n];
		for(int i=n-1;i>=1;--i) ans=gcd(ans,a[i]);
		if(k%ans!=0) puts("IMPOSSIBLE");
		else puts("POSSIBLE");
	}
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

ll n;

void mul(vector<vector<ll>>&a, vector<vector<ll>>&b)
{
	vector<vector<ll>>ans(n, vector<ll>(n, 0));
	for (ll i = 0; i < n; i++)
	{
		for (ll j = 0; j < n; ++j)
		{
			for (ll k = 0; k < n; ++k)
				ans[i][j] = (ans[i][j] + (a[i][k] * b[k][j]) % MOD) % MOD;
		}
	}
	a = ans;
}

vector<vector<ll>>a;
ll power(ll k)
{
	vector<vector<ll>>id(n, vector<ll>(n, 0));
	for (ll i = 0; i < n; i++)
		id[i][i] = 1;
	while (k)
	{
		if (k & 1)
			mul(id, a);
		mul(a, a);
		k >>= 1;
	}
	ll ans = 0;
	for (auto it : id)
	{
		for (auto it2 : it)
			ans = (ans + it2) % MOD;
	}
	return ans;
}

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

	ll k; cin >> n >> k;
	a = vector<vector<ll>>(n, vector<ll>(n));
	for (auto &it : a)
	{
		for (auto &it2 : it)
			cin >> it2;
	}
	cout << power(k);


	return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    int a,b;
    int sum=0;
    scanf("%d %d",&a,&b);
    
    int A[a+1][b+1];
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
            scanf("%d",&A[i][j]);
            sum+=A[i][j];
        }
        A[i][b]=sum;
        sum=0;
    }
    
    for(int i=0;i<=b;i++){
        for(int j=0;j<a;j++){
            sum+=A[j][i];
        }
        A[a][i]=sum;
        sum=0;
    }
    
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            cout<<A[i][j];
            if(j!=b)cout<<' ';
        }
        cout<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3260
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    if (X < Y) {
        swap(A, B);
        swap(X, Y);
    }

    int ans = A * X + B * Y;
    int tmp = ans;
    FOR(i, 1, Y + 1) {
        tmp += C * 2;
        tmp -= A + B;
        chmin(ans, tmp);
    }
    FOR(i, Y + 1, X + 1) {
        tmp += C * 2;
        tmp -= A;
        chmin(ans, tmp);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;




int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    string s;
    cin >> s;
    int n = s.size();
    int pre[n], post[n];

    pre[0] = 0;
    for (int i = 1; i < n; i++) {
        if (s[i] == 'R') {
            pre[i] = i;
        }

        else {
            pre[i] = pre[i - 1];
        }
    }

    post[n - 1] = n - 1;
    for (int i = n - 2; i >= 0; i--) {
        post[i] = (s[i] == 'L' ? i : post[i + 1]);
    }

    int ans[n];
    memset(ans, 0, sizeof ans);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'L') {
            int dif = i - pre[i];
            if (dif % 2 == 0) {
                ans[pre[i]]++;
            }

            else {
                ans[pre[i] + 1]++;
            }
        }

        else {
            int dif = post[i] - i;
            if (dif % 2 == 0) {
                ans[post[i]]++;
            }

            else {
                ans[post[i] - 1]++;
            }
        }
    }

    for (int e : ans) {
        cout << e << ' ';
    }

}

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 998244353
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    string S,T; cin>>S>>T;
    int s = S.size(),t = T.size();
    vector<vector<int>> dp(s+1,vector<int>(t+1,0));//dp[i][j] = 初めi,j文字の最長部分列。
    rep(i,s){
        rep(j,t){
            if(S[i]==T[j])dp[i+1][j+1]=max({dp[i][j+1],dp[i+1][j],dp[i][j]+1});
            else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
        }
    }
    string res = "";
    int i = s, j = t;
    while(i>0&&j>0){
        if(S[i-1]==T[j-1]){
                res += S[i-1];
                i--; j--;
        }else if(dp[i-1][j]==dp[i][j]){
            i--;
        }else j--;
    }
    reverse(res.begin(),res.end());
    cout<<res<<endl;
}


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

signed main () {
	int n, m, a;
    cin >> n >> m;
    map < int, int > pref;
    int cur = 0;
    ++pref[cur];
    int64_t ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        (cur += a) %= m;
        ans += pref[cur];
        ++pref[cur];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


ll dp[10010]; // i本使って作れる最大桁数
int num[10] = {0,2,5,5,4,5,6,3,7,6};
int main(){
    int n, m;
    cin >> n >> m;
    rep(i, 10010) dp[i] = -INF;
    dp[0] = 0;
    int a[m];
    rep(i,m) cin >> a[i];
    sort(a,a+m);
    reverse(a,a+m);

    rep(i, n+1){
        rep(j, m){
            if (i >= num[a[j]]) dp[i] = max(dp[i], dp[i-num[a[j]]] + 1);
        }
    }

    vector<char> ans;

    // rep(i, m) cout << a[i] << " ";
    // cout << endl;
    
    int i = n;
    while(i > 0){
        bool flag = false;
        rep(j, m){
            if (i - num[a[j]] < 0) continue;
            if (dp[i - num[a[j]]] == dp[i]-1){
                ans.push_back(a[j] + '0');
                i -= num[a[j]];
                // cout << "j=" << j << endl;
                flag = true;
                break;
            }
        }
        if (!flag) break;
    }

    rep(i, ans.size()) cout << ans[i];
    cout << endl;


    return 0;
}


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


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

    vector<int> A(N);
    for(int i(0); i < N; ++i) cin >> A[i];

    long long ans = 0;
    for(int i = 1; i < N; ++i){
        int MaxNum = max(A[i - 1],A[i]);
        ans += MaxNum - A[i];
        A[i] = MaxNum;
    }

    cout << ans << endl;


    return 0;
}


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

map<char, int> _map = { { 'm', 1000 },{ 'c', 100 },{ 'x', 10 },{ 'i', 1 } };

int solve(string a)
{
	int aa = 0;

	rep(i, 0, a.length())
	{
		if ('1' <= a[i] && a[i] <= '9')
		{
			aa += (a[i] - '0') * _map[a[i + 1]];
			i++;
		}
		else
			aa += _map[a[i]];
	}

	return aa;
}

string solve2(int a)
{
	char c[4] = { 'm', 'c', 'x', 'i' };
	string ret = "";

	rep(i, 0, 4)
	{
		int d = a / _map[c[i]];
		if (d == 0) continue;
		if (d == 1)
			ret += c[i];
		else
			ret += to_string(d) + c[i];

		a %= _map[c[i]];
	}

	return ret;
}

int main()
{
	int n; cin >> n;
	rep(_n, 0, n)
	{
		string a, b; cin >> a >> b;

		int aa = solve(a);
		int bb = solve(b);

		cout << solve2(aa + bb) << endl;
	}
}

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

typedef long long ll;
 
int main(){
  int n, ans=0;
  cin >> n;
  vector<int> k(n+1, 0);
  for(int i=0; i<n; i++){
    int a;
    cin >> a;
    if(n<a){
      ans++;
      continue;
    }
    k[a]++;
  }
  for(int i=0; i<=n; i++){
    if(k[i]>i) ans+=k[i]-i;
    else if(k[i]<i) ans+=k[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
s = gets.chomp
n = s.length - 1
sum = 0
for i in 0...(2 ** n) do
  ss = s.dup
  for b in 0...n do
    f = (i >> b) & 1
    if f == 1
      ss.insert(n - b, "+")
    end
  end
  eval("sum +=" + ss)
end
puts sum


Measured memory_bytes: 3964
#include <iostream>

using namespace std;
int main(){
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for(int i = 0; i <= k; i++) {
    for(int j = 0; j <= k; j++) {
      int z = s - i - j;
      if(0 <= z && z <= k) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

int main(){
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<long long> ans(0);
  ans.push_back(a * c);
  ans.push_back(b * c);
  ans.push_back(d * a);
  ans.push_back(b * d);
  
  sort(ans.begin(), ans.end());
  cout << ans[3] << endl;
}


Measured memory_bytes: 3564
#include <iostream>
using namespace std;
int main()
{
    char a[4];
    cin>>a[0]>>a[1]>>a[2]>>a[3];
    if(a[0]==a[1]&&a[1]==a[2])cout<<"Yes";
    else if(a[1]==a[2]&&a[2]==a[3])cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define SZ(x) ((int)(x).size())
#define le length()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define fastIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define c(a) cout << a << "\n";
#define endl '\n'
const int MOD = 1e9 + 7;
const int N = 3e5 + 6;
#define pi 3.141592653589793
// int v[N];
// void add(int idx, int val)
// {
//     while (idx <= N)
//     {
//         v[idx] += val;
//         idx += idx & -idx;
//     }
// }

// int sum(int idx)
// {
//     int ans = 0;
//     while (idx > 0)
//     {
//         ans += v[idx];
//         idx -= idx & -idx;
//     }
//     return ans;
// }
bool check(ll n, ll i)
{
    if (i == 1)
        return false;
    while (n % i == 0)
        n /= i;
    n %= i;
    return n == 1;
}
int main()
{
    ll n;
    cin >> n;
    ll x = n - 1;
    set<ll> s;
    for (ll i = 2; i * i <= x; i++)
    {
        if (x % i == 0)
        {
            s.insert(i);
            s.insert(x / i);
        }
    }
    s.insert(x);
    for (ll i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            if (check(n, i))
                s.insert(i);
            if (check(n, n / i))
                s.insert(n / i);
        }
    }
    if(s.find(1)!=s.end()) s.erase(s.find(1));
    s.insert(n);
    c(s.size())

        return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>

using namespace std;
long long n,m,h=1;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		if(h<m)
		{
			h*=2;
		}
		else
		{
			h+=m;
		}
	}
	cout<<h;
	return 0;
}

Measured memory_bytes: 764
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define lld long long
#define pi pair<lld,lld>
#define mod 1000000007
#define N 2000005
#define pb push_back
lld fact[N],ifact[N];
lld expo(lld a,lld b)
{
    if(b==0) return 1; if(b==1) return a%mod;
    lld z=expo(a,b/2);
    z=(z%mod*z%mod)%mod;
    if(b%2) z=(z*a)%mod;
    return z;
}
lld ncr(lld n,lld r)
{
    if(r>n) return 0;
    if(r==n) return 1;
    lld mm=fact[n]*ifact[n-r]%mod;
    mm=mm*ifact[r]%mod;
    return mm;
}

void pre(){
    fact[0] = 1;
    ifact[0] = 1;
    rep(i,1,N){
        fact[i] = i;
        fact[i] *= fact[i-1];
        fact[i] %= mod;;
        ifact[i] = expo(fact[i],mod - 2);
    }
}
vector < int > z_function ( string s ) {
    int n = (int)s.length();
    vector<int> z(n);
    for (int i = 1,l=0,r=0;i<n;++i){
        if (i<=r)
            z[i] = min(r-i+1,z[i-l]);
        while(i+z[i]<n&&s[z[i]]==s[i+z[i]])
            ++z[i];
        if(i+z[i]-1>r)
            l=i,r=i+z[i]-1;
    }
    return z ;
}

lld max(lld a,lld b){return a>b?a:b;}
double dis(lld a,lld b,lld c,lld d)
{
    a=(a-c)*(a-c);
    b=(b-d)*(b-d);
    return sqrt(a+b);
}
lld n;
double d=0.0;
void find(int a[][2],int vis[],int i)
{
    for(int j=0;j<n;++j)
    {
        if(vis[j]) continue;
        else
        {
            vis[j]=1;
            d=d+(double)dis(a[i][0],a[i][1],a[j][0],a[j][1]);
            find(a,vis,j);
            vis[j]=0;
        }
    }
}
int main()
{
    //pre();
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // freopen("/home/ankit/input_10.txt","r",stdin);
    // freopen("/home/ankit/out10.txt","w",stdout);
        cin>>n;
    int a[n][2];
    rep(i,0,n)cin>>a[i][0]>>a[i][1];
    lld b[10];
    b[0]=1;
    for(int i=1;i<10;++i)b[i]=i*b[i-1];
    int f[n];
    for(int i=0;i<n;++i)f[i]=i;
    do
{
    for(int i=1;i<n;i++)
    {
        d=d+dis(a[f[i-1]][0],a[f[i-1]][1],a[f[i]][0],a[f[i]][1]);
    }
}while(next_permutation(f,f+n));
d=d*1.0/b[n];
printf("%.10lf\n",d);
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    int res, ans;
    res = min(a, b);
    ans = min(c, d);

    ans += res;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;

int main() {
	double D, T, S;
	cin >> D >> T >> S;
	if (D / S > T) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3680
#include<iostream>
#include<math.h>
#include<set>
using namespace std;

int main(){
  int N,K;
  int d[200], A[200][200];
  set<int> ans;
  //int ans[200] = {};
  cin >> N >> K;
  for(int i=0;i<K;i++){
    cin >> d[i];
    for(int j=0; j<d[i];j++){
      cin >> A[i][j];
      ans.insert(A[i][j]);
    }
  }

  int result=0;
  //for(int i=0;i<K;i++)if(ans[i]==0) result++;
  cout <<N-ans.size() << endl;

}

Measured memory_bytes: 3712