akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define maxn 200005
#define ll long long
using namespace std;
int pre[maxn];

int main()
{
  int n;
  cin>>n;
  vector<int> v;
  for(int i=0;i<n;i++){
    cin>>pre[i];
  }
  int i;
  for(i=n-1;i>=0;i-=2){
    v.push_back(pre[i]);
  }
  i ++;
  if(n % 2 == 1) i += 2;
  for(;i<=n-2;i+=2){
    v.push_back(pre[i]);
  }
  for(int i=0;i<v.size();i++){
    cout<<v[i]<<" ";
  }
  return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int check(int t, vector<int> &v) {
    int ans = 0;
    for (int i : v) ans += (i - t) * (i - t);
    return ans;
}

int main() {
    int w, h, n;
    cin >> w >> h >> n;

    int l = 0, r = w, u = h, d = 0;

    rep(_, n) {
        int x, y, a;
        cin >> x >> y >> a;


        if (a == 1) {
            // 左
            cmax(l, x);
        } else if (a == 2) {
            // 右
            cmin(r, x);
        } else if (a == 3) {
            // 下
            cmax(d, y);
        } else {
            cmin(u, y);
        }
    }

    if (r <= l || u <= d) {
        cout << 0 << endl;
    } else {
        int width = r - l;
        int height = u - d;
        cout << width * height << endl;
    }

}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int N; cin >>N;
  vector<ll> A(N); rep(i, N) cin >>A[i];
  sort(allR(A));
  map<ll,int> S; rep(i, N) S[A[i]]++;;
  int res = 0;
  rep(i, N){
    if (S[A[i]] == 0) continue;
    S[A[i]]--;
    ll buf = A[i];
    ll tmp = 1;
    while (buf > 0){ buf /= 2; tmp *= 2; }
    if (tmp < A[i]) tmp *= 2;
    if (S[tmp - A[i]] > 0){
      S[tmp - A[i]]--;
      res++;
    }
  }
  cout <<res <<endl;
}


Measured memory_bytes: 26752
import itertools

n=int(input())
p=''.join(list(map(str,input().split())))
q=''.join(list(map(str,input().split())))
arr=[]
for pairs in itertools.permutations([str(i) for i in range(1,n+1)]):
  arr.append(''.join(list(pairs)))
arr=sorted(arr)
print(abs(arr.index(q)-arr.index(p)))

Measured memory_bytes: 6296
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) {
 
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
  
        String inputStr = null;
        String inputBallNum = null;
        String inputSelectStr = null;
      
        try {
            inputStr = br.readLine();
            inputBallNum = br.readLine();
            inputSelectStr = br.readLine();
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
 
 		String[] str = inputStr.split(" ");
 		String[] ball = inputBallNum.split(" ");
      	
		int a = Integer.parseInt(ball[0]);
		int b = Integer.parseInt(ball[1]);
      
      	if(str[0].equals(inputSelectStr)){
          a--; 
        }else if(str[1].equals(inputSelectStr)){
          b--;
        }
      System.out.println(a + " " + b);
      
    }
 
}


Measured memory_bytes: 21332
#include <iostream>
using namespace std;
int main()
{
	long int n,min,max,sum=0,i;
	cin>>n;
	long int a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	min=a[0];
	max=a[0];
	for(i=0;i<n;i++)
	{
		if(a[i]<min)
			min=a[i];
		if(a[i]>max)
			max=a[i];
		sum+=a[i];
	}
	cout<<min<<" "<<max<<" "<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3180
#include <stdio.h>

#define BUF_SIZE 256

class stack10 {
private:
	int stack[10];
	int index;
public:
	stack10() {
		for (int i=0; i<10; i++)  stack[i]=0;
		index=0;
	}
	void PutTrain(int n) {
		if (index<10)  stack[index++] = n;
		else  printf("error: put\n");
	}
	int PopTrain() {
		if (index>0)  return stack[--index];
		else {
			printf("error: pop\n");
			return -1;
		}
	}
};

int main(void) {
	stack10 s;
	int i, j;
	int num;
	char buf[BUF_SIZE];
	
	while (fgets(buf, sizeof(buf), stdin) != NULL) {
		sscanf(buf, "%d", &num);
		
		if (num == 0)  printf("%d\n", s.PopTrain());
		else s.PutTrain(num);
	}
	
	return 0;
}

Measured memory_bytes: 1040
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    m = 10 ** 9 + 7
    tmp_sum = 0
    for i in range(n - 1):
        tmp_sum += a[i]
        # tmp_sum %= m
        ans += tmp_sum * a[i+1]
        ans %= m
    
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 94348
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Apr 26 16:07:41 JST 2020
 **/

signed main() {
    Int n;
    std::cin >> n;
    Int ans = 0, cur = 0;
    REP(i, n) {
        Int x;
        std::cin >> x;
        if (x == i + 1) {
            cur++;
        } else {
            ans += (cur + 1) / 2;
            cur = 0;
        }
    }
    ans += (cur + 1) / 2;
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

int prime[10001];

int main(){
	prime[0]=prime[1]=1;
	
	for(int i=2;i*i<10001;i++){
		if(prime[i]==1)continue;
		for(int j=2*i;j<10001;j+=i){
			prime[j]=1;
		}
	}
	
	int n;
	while(cin>>n){
		if(n==0)break;
		while(n>0){
			if(prime[n]==0 && prime[n-2]==0)break;
			else n--;
		}
		cout<<n-2<<" "<<n<<endl;
	}
}

Measured memory_bytes: 0
def arrow(cur, arr)
  case arr[cur[0]][cur[1]]
  when ">"
    return vec_sum(cur, [0, 1])
  when "<"
    return vec_sum(cur, [0, -1])
  when "^"
    return vec_sum(cur, [-1, 0])
  when "v"
    return vec_sum(cur, [1, 0])
  end
end

def vec_sum(v1, v2)
  return [v1[0] + v2[0], v1[1] + v2[1]]
end

while true
  arr, path, cur = [], [], [0, 0]
  h, w = gets.split.map(&:to_i)
  
  break if h == 0 && w == 0
  
  h.times do |i|    
    arr[i] = gets.chomp.split("")
  end

  while true
    if arr[cur[0]][cur[1]] == "."
      puts cur.reverse.join(" ")
      break
    elsif path.include?(cur)
      puts "LOOP"
      break
    end
  
    path << cur
    cur = arrow(cur, arr)
  end
end

Measured memory_bytes: 6736
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <iomanip>
#include<queue>
#include<set>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007


int main()
{

   int N;
   cin>>N;

   int A[N][61];

   REP(i,0,N){
       ll a;
       cin>>a;
       REP(j,0,61){
           A[i][j]=(a>>j)&1;
       }
   }
    ll ans=0;
    ll mx=1;
    REP(i,0,61){
        ll count=0;
        ll zero=0;
        ll one=0;
        REP(j,0,N){
            if(A[j][i]==0){
                zero++;
            }else{
                one++;
            }
        }
        count=zero*one%MOD;
        ans+=mx*count%MOD;
        mx=mx*2%MOD;
    }
    ans%=MOD;
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 71808
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll N, Q;
    cin >> N >> Q;
    Graph G(N);
    rep(i, N - 1) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<ll> score(N);
    rep(i, Q) {
        ll p, x;
        cin >> p >> x;
        p--;
        score[p] += x;
    }

    queue<ll> que;
    que.push(0);
    vector<bool> visit(N, false);
    visit[0] = true;
    while (que.size()) {
        ll now = que.front();
        que.pop();
        for (auto next : G[now]) {
            if (visit[next] == true) continue;
            visit[next] = true;
            score[next] += score[now];
            que.push(next);
        }
    }

    rep(i, N) {
        cout << score[i];
        if (i == N - 1)
            cout << "\n";
        else
            cout << " ";
    }
    return 0;
}

Measured memory_bytes: 19044
from bisect import bisect_right

import sys
input = sys.stdin.readline

N = int(input())
S = input()

dic = {}
for i in range(N):
    n = int(S[i])
    if not n in dic.keys():
        dic[n] = [i]
    else:
        dic[n].append(i)

c = 0
for k1 in range(10):
    if not k1 in dic.keys():
        continue
    i1 = dic[k1][0]
    for k2 in range(10):
        if not k2 in dic.keys():
            continue
        j2 = bisect_right(dic[k2], i1)
        if j2 == len(dic[k2]):
            continue
        i2 = dic[k2][j2]
        for k3 in range(10):
            if not k3 in dic.keys():
                continue
            j3 = bisect_right(dic[k3], i2)
            if j3 == len(dic[k3]): continue
            c += 1

print(c)

Measured memory_bytes: 4328
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
#define re register
using namespace std;
int a[100002],b[100002],n,m,x,y,z,ans,q;
signed main(){
	scanf("%d%d%d",&n,&m,&q);
	int mn=1e9;
	for(re int i=1;i<=n;++i){scanf("%d",&a[i]);mn=min(mn,a[i]);
	}
	ans+=mn;
	mn=1e9;
	for(re int i=1;i<=m;++i){scanf("%d",&b[i]);
	mn=min(mn,b[i]);}
	ans+=mn;
	while(q--){
		scanf("%d%d%d",&x,&y,&z);
		ans=min(ans,a[x]+b[y]-z);
	}
	printf("%d",ans);
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstdlib>

using namespace std;

const int MAXN=15;
int a[MAXN],tmp[MAXN];
int n,ans;
bool check()
{
	for (int i=1;i<=n;i++)
	{
		if (!(tmp[i]&1))
		{
			return true;
		}
	}
	return false;
}
void dfs(int size)
{
	if (size==n+1)
	{
		if (check())
		{
			ans++;
		}
		return ;
	}
	for (int i=-1;i<=1;i++)
	{
		tmp[size]+=i;
		dfs(size+1);
		tmp[size]-=i;
	}
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		tmp[i]=a[i];
	}
	for (int i=-1;i<=1;i++)
	{
		tmp[1]+=i;
		dfs(2);
		tmp[1]-=i;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
typedef long long ll;

std::map<ll, ll> mp;

int main()
{
	ll n;
	std::vector<ll> arr(200005);

	ll ans = 0;

	std::cin >> n;
	for (ll i = 1; i <= n; i++) {
		std::cin >> arr[i];
	}

	mp[0] = 1;
	for (ll i = 1; i <= n; i++) {
		arr[i] = arr[i] + arr[i - 1];

		ans = ans + mp[arr[i]];
		mp[arr[i]]++;
	}

	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 14336
/*siddharth goyal*/
#include<bits/stdc++.h>
using namespace std;
#define   pb              push_back
#define   REP(i,n)        for(int i=1;i<=n;i++)
#define   FOR(i,a,b)      for(int i=a;i<=b;i++)
#define   all(v)          v.begin(),v.end()
#define   F               first
#define   S               second
#define   vl              vector<LL>
#define   itr             ::iterator it
#define   lb              lower_bound
#define   ub              upper_bound
#define   LL              long long
#define   ULL             unsigned long long
#define   ret             return 
LL n,i,j,ans = 0,m;
vector <pair<LL,LL> > v ;  
int main()
{   // Read the constraints,highlights,Time Limit,Test Cases
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m ; 
    LL x,y ; 
    REP(i,n)  cin>>x>>y,v.pb({x,y}) ; 
    sort(all(v)) ; 
    for(auto i:v)
    {  if(m>0)
       {  LL M = min(m,i.S) ; 
          ans += M * ( i.F  ) ; 
          m -= M ; 

       }

    }    
    cout<<ans ; 
}
//Check for 0,1 and other corner cases.

Measured memory_bytes: 2420
import java.util.Scanner;
import java.util.Arrays;
public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        int n = nextInt();
        int k = nextInt();
        int[] arr = new int[n];

        for(int i=0;i<n;i++){
            arr[i] = nextInt();
        }
        Arrays.sort(arr);
        int sum = 0;
        for(int i=0;i<k;i++){
            sum += arr[i];
        }
        print(sum);
    }

    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }

    //print
    public static void print(Object a){
        System.out.println(a);
    }


    //gcd
    public static int gcd (int a, int b){
        int tmp;
        while((tmp = a%b) != 0){
            a = b;
            b = tmp;
        }
        return b;
    }


    //lcm
    public static int lcm(int a,int b){
        int tmp;
        long c = a;
        c *= b;
        while((tmp = a%b) != 0){
            a = b;
            b = tmp;
        }
        return (int)(c/b);
    }
}

Measured memory_bytes: 38812
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
  int N,D;
  cin >> N >> D;
  int x,y;
  int counter = 0;
  for(int i=0; i<N; i++){
    cin >> x >> y;
    if(sqrt(pow(x,2)+pow(y,2)) <= D) counter++;
  }
  cout << counter << endl;
  
  return 0;
}

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

int main() {
  ll w,h,x,y;
  ll s1,s2;
  double ans1;
  int ans2;

  cin >> w >> h >> x >> y;

  ans1 = (double)w*h/2;

  ans2 = (2*x == w) && (2*y == h) ? 1 : 0;
  cout << ans1 << " " << ans2;

  return 0;
}

Measured memory_bytes: 256
H,W = map(int, input().split())
A = [input() for _ in range(H)]

mod = 10**9+7

dp = [[0]*W for _ in range(H)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            continue
        if i > 0:
            dp[i][j] += dp[i-1][j]
        if j > 0:
            dp[i][j] += dp[i][j-1]
        dp[i][j] %= mod

print(dp[H-1][W-1])

Measured memory_bytes: 51952
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
vector<int> to[MAXN];

vector<int> dp(MAXN, -1);
int dfs(int u)
{
  if (dp[u] != -1)
  {
    return dp[u] + 1;
  }
  int ret = 0;
  for (auto v : to[u])
  {
    ret = max(ret, dfs(v));
  }
  dp[u] = ret;
  return ret + 1;
}

int main()
{
  int N, M, x, y;
  cin >> N >> M;
  for (int i = 0; i < M; i++)
  {
    cin >> x >> y;
    to[x - 1].push_back(y - 1);
  }
  for (int i = 0; i < N; i++)
  {
    dfs(i);
  }
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    ans = max(ans, dp[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 11148
#include <iostream>
#include <string>

using namespace std;

int fromMCXI( string s )
{
	int n = 1;
	int r = 0;
	for ( int i=0; i<(int)s.length(); i++ )
	{
		if (s[i]=='m')  r += n*1000,  n = 1;
		if (s[i]=='c')  r += n* 100,  n = 1;
		if (s[i]=='x')  r += n*  10,  n = 1;
		if (s[i]=='i')  r += n*   1,  n = 1;
		if ('2'<=s[i]&&s[i]<='9')  n = s[i]-'0';
	}

	return r;
}

string toMCXI(int num)
{
	int m = num/1000%10;
	int c = num/ 100%10;
	int x = num/  10%10;
	int i = num/   1%10;

	string r;
	if(m>=2) r+='0'+m;  if(m>=1) r+='m';
	if(c>=2) r+='0'+c;  if(c>=1) r+='c';
	if(x>=2) r+='0'+x;  if(x>=1) r+='x';
	if(i>=2) r+='0'+i;  if(i>=1) r+='i';
	
	return r;
}

int main()
{
	int n;
	cin>>n;
	for ( int i=0; i<n; i++ )
	{
		string mcxi1, mcxi2;
		cin >> mcxi1 >> mcxi2;
		cout << toMCXI(fromMCXI(mcxi1)+fromMCXI(mcxi2)) << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <bitset>

using namespace std;

#define rep(i,n,m) for(ll (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(ll (i)=(n);(i)>(m);(i)--)
using ll = long long;
const ll mod = 998244353;

void dfs(ll i,ll j,vector<vector<ll>>& lis, vector<vector<ll>>& exi , ll N){

    if ((i != 0) && (lis[i-1][j] > lis[i][j] + exi[i][j])){
        lis[i-1][j] = lis[i][j] + exi[i][j];
        dfs(i-1,j,lis,exi,N);
    }

    if ((i != N-1) && (lis[i+1][j] > lis[i][j] + exi[i][j])){
        lis[i+1][j] = lis[i][j] + exi[i][j];
        dfs(i+1,j,lis,exi,N);
    }

    if ((j != 0) && (lis[i][j-1] > lis[i][j] + exi[i][j])){
        lis[i][j-1] = lis[i][j] + exi[i][j];
        dfs(i,j-1,lis,exi,N);
    }

    if ((j != N-1) && (lis[i][j+1] > lis[i][j] + exi[i][j])){
        lis[i][j+1] = lis[i][j] + exi[i][j];
        dfs(i,j+1,lis,exi,N);
    }


}

int main(){

    ll N;
    cin >> N;
    vector<ll> P(N*N);
    rep(i,0,N*N) cin >> P[i];

    vector<vector<ll>> lis(N,vector<ll> (N,0));
    vector<vector<ll>> exi(N,vector<ll> (N,1));
    rep(i,0,N){
        rep(j,0,N){
            lis[i][j] = min(i,min(j,min(N-1-i,N-1-j)));
        }
    }

    ll ans = 0;

    rep(loop,0,N*N){

        ll ni = (P[loop]-1)/N;
        ll nj = (P[loop]-1)%N;

        ans += lis[ni][nj];
        exi[ni][nj] = 0;

        dfs(ni,nj,lis,exi,N);
    }

    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);

  for (auto &i : a) cin >> i;

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (abs(a[i] - a[j]) % (n - 1) == 0) {
        cout << a[i] << " " << a[j] << endl;
        return 0;
      }
    }
  }
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define Y(i) cout<<(i?"Yes":"No")<<endl
using namespace std;string S,T;int s[26],t[26];main(){cin>>S>>T;for(int i=0;i<S.size();i++){s[S[i]-'a']++;t[T[i]-'a']++;}sort(s,s+26);sort(t,t+26);for(int i=0;i<26;i++){if(s[i]!=t[i]){Y(0);return 0;}}Y(1);}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int A[4];
    string S;
    cin >> S;
    A[0] = S[0] - '0', A[1] = S[1] - '0', A[2] = S[2] - '0', A[3] = S[3] - '0';
    string s = "BCD";
    int now = A[0];
    string Ans = to_string(S[0] - '0'), tmp = Ans;
    for (int bit = 0; bit < (1 << 3); bit++)
    {
        now = A[0];
        tmp = Ans;
        for (int i = 0; i < 3; i++)
        {
            if (bit & (1 << i))
            {
                tmp += "+";
                tmp += A[i + 1] + '0';
                now += A[i + 1];
            }
            else
            {
                tmp += "-";
                tmp += A[i + 1] + '0';
                now -= A[i + 1];
            }
        }
        if (now == 7)
        {
            cout << tmp << "=7" << endl;
            return 0;
        }
    }
    cout << "-1";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
long long n, k, s, x, z, y, m, b, l;
long long p[5000];
long long c[5000];
int main() {
	scanf("%lld%lld", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%lld", p + i);
		p[i]--;
	}
	for (int i = 0; i < n; i++) {
		scanf("%lld", c + i);
	}
	m = -1000000000;
	for (int i = 0; i < n; i++) {
		s = i;
		x = 0;
		b = 0;
		while (p[s] != i) {
			s = p[s];
			x += c[s];
			b++;
		}
		x += c[i];
		b++;
		if (k > b) {
			l = b + k % b;
			y = 0;
			if (k > l) {
				if (x > 0)y += (k - l) / b * x;
			}
			s = i;
			for (int j = 0; j < l; j++) {
				s = p[s];
				y += c[s];
				if (y > m)m = y;
			}
		}
		else {
			s = i;
			y = 0;
			for (int j = 0; j < k; j++) {
				s = p[s];
				y += c[s];
				if (y > m)m = y;
			}
		}
	}
	printf("%lld\n", m);
}


Measured memory_bytes: 1800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, k;
  cin >> n >> k;
  vi h(n);
  rep(i, n) cin >> h[i];
  sort(all(h));
  rep(i, k) h.pop_back();
  ll ans = 0;
  rep(i, h.size()) ans += h[i];
  cout << ans << endl;
}

Measured memory_bytes: 1024
N = int(input())
S = list(input())

ans = 0
for i in range(1000):
    if i <= 9:
        if S.count("0") >= 2:
            first = S.index("0")
            SS = S[first+1:]
            second = SS.index("0")
            SSS = SS[second+1:]
            tmp = str(i)
            if SSS.count(tmp) == 0:
                continue
            ans += 1
            ##print(i)
        else:
            continue
    elif i <= 99:
        if S.count("0") >= 1:
            first = S.index("0")
            SS = S[first+1:]
            tmp = str(i)
            if SS.count(tmp[0]) == 0:
                continue
            second = SS.index(tmp[0])
            SSS = SS[second+1:]
            if SSS.count(tmp[1]) == 0:
                continue
            ans += 1
            ##print(i)
        else:
    
            continue
    else:
        tmp = str(i)
        ##print(tmp)
        if S.count(tmp[0]) == 0:
            continue
        first = S.index(tmp[0])
        SS = S[first+1:]
        if SS.count(tmp[1]) == 0:
            continue
        second = SS.index(tmp[1])
        SSS = SS[second+1:]
        if SSS.count(tmp[2]) == 0:
            continue
        ##print(i)
        ans += 1

print(ans)

Measured memory_bytes: 4524
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
int dp[100001];
int power(int x,int y)
{ int temp;
    if(y==0)
        return 1;
    temp=power(x,y/2)%mod;
    if(y%2==0)
        return (temp%mod*temp%mod)%mod;
    else
        return ((x%mod)*((temp%mod*temp%mod)%mod))%mod;
}
int check(vector<int>&v,int i,int n)
{ if(i>=n)
   {
    return 0;
   }
   if(dp[i]!=-1)
   {
    return dp[i];
   }

  int left=abs(v[i]-v[i+1])+check(v,i+1,n);
  int right=INT_MAX;
  if((i+2)<=n)
  {
    right=abs(v[i]-v[i+2])+check(v,i+2,n);
  }
  return dp[i]=min(left,right);

}

void solve()
{ int n;
  cin>>n;
  vector<int>v(n+1);
  for(int i=0;i<100001;i++)
    dp[i]=-1;
  for(int i=1;i<=n;i++)
    cin>>v[i];
  int ans=check(v,1,n);
  cout<<ans<<endl;

}
signed main()
{   ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
        //     #ifndef ONLINE_JUDGE
        // freopen("input1.txt","r",stdin);
        // freopen("output1.txt","w",stdout);
        //  #endif

    int t;
    //cin>>t;
    t=1;
    for(int i=1;i<=t;i++)
        {solve();
        }



        return 0;     

    }

Measured memory_bytes: 11096
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
    long long a,b,c = 0; //1-10^9
    long long tmp_4ab = 0;
    long long d = 0;
    
    string result = "No";
 
    cin >> a >> b >> c;

    tmp_4ab = 4*a*b;
    d = c-a-b; 

    if(tmp_4ab < d*d && d > 0)
    {
        result = "Yes";
    }
 
    cout << result << endl;
 
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
  var a, b int
  fmt.Scan(&a, &b)
  var count int
  for i := 0; i < 2; i++ {
    if a > b {
      count += a
      a--
    } else {
      count += b
      b--
    }
  }
  fmt.Println(count)
}

Measured memory_bytes: 512
S=list(input())
count = 0
for i in range(len(S)-1):
    if len(set(S[i:i+2])) == 1:
        if S[i+1] == '1':
            S[i+1] = '0'
        else:
            S[i+1] = '1'
        count += 1
print(count)

Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define endl '\n'

using namespace std;

main()
{
  fast;
  int k,i;
  ll x;
  cin>>k;
  queue<ll> q;
  for (i=1;i<10;i++)
    q.push(i);
  for (i=1;i<k;i++)
  {
    x=q.front();
    q.pop();
    if (x%10!=0)
      q.push(10*x+x%10-1);
    q.push(10*x+x%10);
    if (x%10!=9)
      q.push(10*x+x%10+1);
  }
  cout<<q.front()<<endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;

int main() {
  int n;
  cin >> n;
  int a[n];
  int b[n];

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

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

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (auto &e: a) cin >> e;

    int sum = accumulate(a.begin(), a.end(), 0);

    int cnt = 0;
    for (auto e: a) {
        if (e * 4 * m >= sum) cnt++;
    }

    if (cnt >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

ll sum(ll a) {

    if (a < 10) {
        ll x = 0;
        for (ll l = 1; l <= a; l++) {
            x ^= l;
        }
        return x;
    }

    ll amk = a % 2 == 0 ? a - 1 : a;

    ll x = (amk - 2 + 1) / 2 % 2;

    if (a % 2 == 0) {
        return 1ll ^ x ^ a;
    } else {
        return 1ll ^ x;
    }

}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << (sum(a - 1) ^ sum(b)) << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define for1(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define endl '\n'
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll int a, b, c;
    cin >> a >> b >> c;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll int ab, bc, ca;
    ab = a * b;
    bc = b * c;
    ca = c * a;
    ll int ans = ab;
    if (bc < ans) {
        ans = bc;
    }
    if (ca < ans) {
        ans = ca;
    }
    cout << ans << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  vi32 cnt(101);
  int n;
  while (cin >> n) {
    cnt[n]++;
  }
  int ma = 0;
  reps(i, 100) amax(ma, cnt[i]);
  reps(i, 100) {
    if (cnt[i] == ma) cout << i << '\n';
  }
}



Measured memory_bytes: 3056
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main(void){
  int n;
  cin >> n;
  int d[n];
  for(int i = 0; i < n; ++i){
    cin >> d[i];
  }
  int ans = 1;
  sort(d, d + n, greater<int>());

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define fi first
#define se second
const int LEN = 2e5+5;
const int LEN5 = 1e5+5;
const int MOD = 1e9+7;
typedef long long ll;
ll dp[1 << 22];
int n; int ar[22][22];
int main() {

   // freopen ("myfile.txt","r",stdin);
   // freopen ("myfile.txt","w",stdout);

   // ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(0);
   ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(0);
   cin>>n;
   int lim = (1 << n) -1;
   for(int i = 0;i<n;i++) {
      for(int k = 0;k<n;k++)
         cin>>ar[i][k];
   }

   dp[0] = 1;

   for(int i = 1;i< (1 << n);i++) {
      for(int k =0;k<n;k++) {
         int one = __builtin_popcount(i);
         int cur = i ^ (1 << k);
         if(ar[one-1][k] && ((1 << k) & i)) {
            dp[i] = dp[i] + dp[cur];
            dp[i] %= MOD;
         }
      }
   }
   

   cout<<dp[lim]<<endl;

}   

Measured memory_bytes: 18816
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
dp = [0] * (500000)
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            pe = x**2 + y**2 + z**2 + x*y + y*z + z*x
            dp[pe] += 1
print(*dp[1:n+1],sep='\n')


Measured memory_bytes: 14632
#include <iostream>
using namespace std;
typedef long long ll;
const ll INF = (1LL << 58);
int n;
int S[110];
ll C[110][110];

int main(void) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int r, c;
        cin >> r >> c;
        S[i] = r; S[i + 1] = c;
    }

    n++;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++) C[i][j] = INF;

    for (int i = 1; i <= n; i++) C[i][i] = 0;

    for (int j = 1; j <= n - 1; j++) {
        for (int i = 1; i <= n - j; i++) {
            for (int k = 1; k <= i + j; k++) {
                C[i][i + j]  = min(C[i][i + j], C[i][k - 1] + C[k][i + j] + S[i] * S[k] * S[i + j + 1]);
            }
        }
    }

    cout << C[1][n - 1] << endl;
    return 0;
}

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

using namespace std;

int main() {
	unsigned long long Q,i,A,B,temp,N,M,L;
	cin >> Q;
	for (i=0;i<Q;++i) {
		cin >> A >> B;
		if (A==B) {
			cout << (A-1) *2 << endl;
			continue;
		}
		if (A>B) {
			temp=A;
			A=B;
			B=temp;
		}
		N=sqrt(A*B);
		if (N*N==A*B) {
			M=N-1;
		} else {
			M=N;
		}
		L=N;
		while ((L+1)*N<A*B){
			L+=1;
		}
		M+=L-2;
		if (A>L) {
			M+=1;
		}
		cout << M << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N, W = map(int, input().split())

DP = {0: 0}
for i in range(N):
    wi, vi = map(int, input().split())
    p = {}
    for j in DP:
        if j+wi <= W and DP.get(j+wi, 0) < DP[j]+vi:
            p[j+wi] = DP[j]+vi
    for pi in p:
        DP[pi] = p[pi]
print(max((DP[x] for x in DP)))


Measured memory_bytes: 122544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c;cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

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

    int N = S.size(), M = T.size();
    vector<vector<int>> idx(26);
    rep(i, N) idx[S[i] - 'a'].push_back(i);
    rep(i, N) idx[S[i] - 'a'].push_back(i + N);

    ll ans = 0;
    int p = 0;
    rep(i, M) {
        int c = T[i] - 'a';
        if (idx[c].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        p = *lower_bound(idx[c].begin(), idx[c].end(), p) + 1;
        if (p >= N) {
            p -= N;
            ans += N;
        }
    }
    ans += p;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1724
n,  m = map(int, input().split())
a=[int(x) for x in input().split()]
a=sorted(a, reverse=True)
c=0
anch=sum(a)/(4*m)
for i in a:
  if i>=anch:
    c+=1
  else:
    break
if c>=m:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}
template <class T> T permutation(ll n, ll k) { T f(1); for (ll i=0; i<k; ++i, --n) f *= n; return f; }
template <class T> T factorial(ll n) { return permutation<T>(n,n); }
template <class T> T binomial(ll n, ll k) { return permutation<T>(n,k) /= factorial<T>(k); }

int main() {
    fastio;
    ll ans=0;
    ll N;
    cin >> N;
    vector<int> p(N), q(N);
    rep(i,N) cin >> p[i];
    rep(i,N) cin >> q[i];
    auto f = [&](vector<int>& v) {
        bool ap[10];
        fill(begin(ap), end(ap), false);
        int x=0;
        rep(i,N) {
            int d = v[i]-1;
            auto u = count(begin(ap), begin(ap)+d, true);
            ap[d] = true;
            int n = d-u ;
            x += n * factorial<int>(N-i-1);
        }
        return x + 1;
    };
    int a = f(p);
    int b = f(q);
    ans = abs(a-b);
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
template<class T,class C> T max(T a,C b){ return ((a)>(T)(b) ? (a) : (T)(b)); }
template<class T,class C> T min(T a,C b){ return ((a)<(T)(b) ? (a) : (T)(b)); }
typedef long long ll;
typedef long double ld;
#define LLINF (1LL<<60)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
  ll n,m,k,i,j,result=0,sum=0;
  int a[200010]={0};
  string s;
  
  cin >> n;
  rep(i,n){
    cin >> a[i];
    sum += (ll)a[i];
  }
  result = LLINF;
  j=0;
  rep(i,n){
    j += (ll)a[i];
    sum -= (ll)a[i];
    result = min(result,llabs(j-sum));
  }
  
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n,m;
  cin >>n>>m;
  vector<ll> a,c;
  ll k,l,fl=0;
  for(ll i=0;i<m;i++){
    cin >>k>>l;
    if(k==1) {
      fl=1;
      c.push_back(l);
    }
    if(l==n){
      fl=1;
      a.push_back(k);
    }
  }
  if(fl==0) {
    cout <<"IMPOSSIBLE"<<endl;
    return 0;
  }
  ll cs=c.size();
  ll as=a.size();
  if(cs==0||as==0){
    cout <<"IMPOSSIBLE"<<endl;
    return 0;
  }
  sort(a.begin(),a.end());
  for(ll i=0;i<cs;i++){
       if(binary_search(a.begin(),a.end(),c[i])){
         cout <<"POSSIBLE"<<endl;
         return 0;
       }
  }
  cout <<"IMPOSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 2004
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
int w2(int N ){
    ll ans = 0 ;
    while(N != 0){
    if(N %2 == 0){
        ans++ ;
        N = N / 2 ;
    }else{
        break ;
    }
    }
    return ans ;
}
int main()
{   
    ll N ;
    cin >>N ;
    int a ;
    int ans = 0 ;
    for(ll i = 0 ; i < N ; i++){
         cin >> a ;
         ans += w2(a) ;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3564
#include <iostream>
using namespace std;
int sumOfEachDigit (int n) {
    int ret = 0;
    while (n >= 1) {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

int main (void) {
    int n;
    int a;
    int b;
    int ans = 0;

    cin >> n >> a >> b;

    for (int i = 1; i <= n; i++) {
        int sum = sumOfEachDigit(i);
        if (a <= sum && sum <= b) ans += i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
ans=0
n,m=map(int,input().split())
a=[]
k=[]
for i in range(m):
    a.append([int(j) for j in input().split()])
    a[i]=a[i][::-1]
    k.append(a[i].pop())
p=[int(j) for j in input().split()]

for i in range(2**n):
    s=[]
    for j in range(n):
        s.append((i>>j)%2)
    
    if all([sum([s[y-1] for y in a[j]])%2==p[j] for j in range(m)]):
        ans+=1

print(ans)

Measured memory_bytes: 44396
#include <stdio.h>

int main(void)
{
	int i;
	int j;
	long sum;

	scanf("%d", &i);
	sum = 0;
	j = 1;
	while (j <= i)
	{
		if ((j % 3 != 0) && (j % 5 != 0))
			sum += j;
		j++;
	}
	printf("%ld\n", sum);
	return (0);
} 


Measured memory_bytes: 1732
import java.util.*;

public class Main {

	public static void main(String[] args) {

		/* System.out.println("数字を入力してください"); */
		Scanner scanner = new Scanner(System.in);

		long K = scanner.nextLong();
		long X = scanner.nextLong();
		if (X <= K * 500) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21204
//----------ACCIDENTAL COMPETITIVE PROGRAMMER---------------------

#include<bits/stdc++.h>

/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
using namespace std;

#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair


const LL MOD = (1e9) + 7 ;
const LD EPS = 0.0000001 ;

const int N = 100000 + 50;
LL A[N], B[N], C[N];
int n;

LL cache[N][4];

LL solve(int idx, int last)
{
	if (idx == n + 1)
		return 0;
	LL &ans = cache[idx][last];
	if (ans != -1){
		return ans;
	}

	if (last == 1){
		ans = max(solve(idx + 1, 2) + B[idx], solve(idx + 1, 3) + C[idx]);
	} else if (last == 2){
		ans = max(solve(idx + 1, 1) + A[idx], solve(idx + 1, 3) + C[idx]);
	} else {
		ans = max(solve(idx + 1, 1) + A[idx], solve(idx + 1, 2) + B[idx]);
	}
	return ans;
}

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(cache, -1, sizeof(cache));
    cin >> n;
    for (int i = 1; i <= n; i++){
    	cin >> A[i] >> B[i] >> C[i];
    }

    LL ans = max(solve(2,1) + A[1], solve(2,2) + B[1]);
    ans = max(ans, solve(2, 3) + C[1]);
    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<long long>a(n);
  long long sum1=0;
  for (int i=0;i<n;i++) {
    cin >> a.at(i); 
    sum1+=a.at(i);
  }
  sum1%=1000000007;
  long long ans=0;
  for (int i=0;i<n-1;i++) {
    sum1-=a.at(i);
    if(sum1<0){
    sum1+=1000000007;
    }
    ans+=(a.at(i)*sum1)%1000000007;
    ans%=1000000007;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4776