akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<chrono>
#include<climits>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
 
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {for(auto x : v) cout << x << ' '; cout << endl;}
#define printn(v, n) {for(int _i = 0; _i < n; _i++) cout << *(v + _i) << ' '; cout << endl;}
 
typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
 
const int MAXN = 1e3 + 20;

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

    long long n;
    cin >> n;
    cout << n * n * n << endl;


    return 0;
}











Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define SORT(x) (sort(x.begin(),x.end()))
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    int N;cin>>N;
    double X[20];
    char U[20][7];
    double y=0;
    rep(i,N){
        cin >> X[i] >> U[i];
        y+=(strcmp(U[i],"BTC")==0 ? X[i]*380000 : X[i] );
    }
    cout << y << endl;
}

Measured memory_bytes: 384
s = input()[::-1]

dp = [0]*2019
dp[0]=1
total = 0
a = 1

for i in list(s):
  total += int(i)*a
  total %= 2019
  dp[total] += 1
  a *= 10
  a %= 2019
count=0
  
for i in range(2019):
    count += dp[i]*(dp[i]-1)//2
 
print(count)

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

char S[10010], T[10010];

int calcDist(char* S, char* T){
    int dist = 0;
    while(*T != 0){
        dist += (*T == *S ? 0 : 1);
        T++, S++;
    }
    return dist;
}

int main(){
    scanf("%s%s", S, T);
    int lenS= strlen(S), lenT = strlen(T);

    int mindist = lenS;
    for(int i=0; i<lenS-lenT+1; i++){
        int dist = calcDist(S+i, T);
        mindist = dist < mindist ? dist : mindist;
    }

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

    return 0;
}

Measured memory_bytes: 3740
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] sList = new String[n];
        for (int i = 1; i <= n; i++) sList[i-1] = Integer.toString(i);
        String s = String.join("", sList);

        String[] pList = new String[n];
        for (int i = 0; i < n; i++) pList[i] = sc.next();
        String p = String.join("", pList);

        String[] qList = new String[n];
        for (int i = 0; i < n; i++) qList[i] = sc.next();
        String q = String.join("", qList);

        List<String> list = new ArrayList<>();
        List<String> dict = permutation(list, s, "");

        int a = dict.indexOf(p) - 1;
        int b = dict.indexOf(q) - 1;

        System.out.println(Math.abs(a-b));
    }

    private static List<String> permutation(List<String> list, String q, String ans){
        if(q.length() <= 1) {
            list.add(ans+q);
        } else {
            for (int i = 0; i < q.length(); i++) {
                permutation(
                        list,
                        q.substring(0, i) + q.substring(i + 1),
                        ans + q.charAt(i));
            }
        }
        return list;
    }
}

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

int main() {
 
  int A, B;
  cin >> A >> B;
  
  if (A == 1) {
    A = 14;
  }

  if (B == 1) {
    B = 14;
  }

  if (A == B) {
    cout << "Draw" << endl;
  } else if (A < B){
    cout << "Bob" << endl;
  } else {
    cout << "Alice" << endl;
  }

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll gcd(ll p,ll q){while(q){ll t=p%q;p=q;q=t;}return p;}

int main(){
	ll a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	puts(c-a-b>0&&(c-a-b)*(c-a-b)>4*a*b?"Yes":"No");
}

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

using namespace std;

int main()
{
  int a, b, c, x, y, ans = 0;

  scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);

  if (a + b > c * 2)
  {
    if (x > y)
    {
      ans += y * c * 2;
      ans += a * (x - y);

      if (a > 2 * c)
      {
        ans = 0;

        ans += x * 2 * c;
      }
    }
    else
    {
      ans += x * c * 2;
      ans += b * (y - x);

      if (b > 2 * c)
      {
        ans = 0;

        ans += y * 2 * c;
      }
    }
  }
  else
  {
    ans += a * x;
    ans += b * y;
  }

  printf("%d", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

char winlose (vector <string> b )
{
	int size = b.size();
	int i,j;

	for (j = 0; j < size; ++j){
		for (i = 0; i < size; ++i){
			if (b[i][j] == b[i][(j+1) % size] 
			 && b[i][j] == b[i][(j+2) % size] ){
				if (b[i][j] != '+'){
					return b[i][j];
				} // end if
			} // end if
			if (b[j][i] == b[(j+1) % size][i] 
			 && b[j][i] == b[(j+2) % size][i] ){
				if (b[j][i] != '+'){
					return b[j][i];
				} // end if
			} // end if
		} // end for
		if (b[j][j] == b[(j+1)%size][(j+1)%size] 
		 && b[j][j] == b[(j+2)%size][(j+2)%size] ){
			if (b[j][j] != '+'){
				return b[j][j];
			} // end if
		} // end if

		if (b[j][size - 1 - j] == b[(j+1) % size][size - 1 - (j+1)%size]
		 && b[j][size - 1 - j] == b[(j+2) % size][size - 1 - (j+2)%size] ){
			if (b[j][size - 1 - j] != '+'){
				return b[j][size - 1 - j];
			} // end if
		} // end if
 	} // end for
		
	return 'd';
}

template<class T> void disp_t (vector <T> t )
{
//	static int count = 0;
	int size = t.size();
	int i,j;
//	++count;

//	cout << "No. " << count << endl;

	for (i = 0; i < size; ++i){
		for (j = 0; j < size; ++j){
			cout << t[i][j];
		} // end for
		cout << endl;
	} // end for
//	cout << endl;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.board", "r", stdin );
	string str = "";
	int i;

	while (1) {
		vector <string> board (3);
		for (i = 0; i < 3; ++i){
			getline (cin, str );
			if (str.empty() || str[0] == '0' ){
				goto end;
			} // end if
			board[i] = str;
		} // end for

		char res = winlose (board );


		switch (res ){
			case 'w': cout << 'w'  << endl; break;
			case 'b': cout << 'b'  << endl; break;
			case 'd':  cout << "NA" << endl; break;
		} // end switch

//		disp_t (board );

	} // end loop
end:		
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main()
{
  int len;
  string s;
  
  cin >> len;
  cin >> s;
  
  int cnt = 0;
  for(int i = 2; i < len; i++)
  {
    if(s[i - 2] == 'A' &&
       s[i - 1] == 'B' &&
       s[i] == 'C')
    {
      cnt++;
    }
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	
 static    class Card {
        char suit;
        int num;
        int idx;
 
        public Card(char suit, int num, int idx) {
            this.suit = suit;
            this.num = num;
            this.idx = idx;
        }
 
      /*  @Override
        public String toString() {
            return "[p=" + suit + ", n=" + num + ", id=" + idx + "]\n";
        }
        */
 
    }

	
	public  static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt(); // 要素の個数
		  Card[] A = new Card[n];
	        for (int i = 0; i < n; i++) {
	            A[i] = new  Card(scan.next().charAt(0), scan.nextInt(), i);
	        }
	        Quicksort(A,0,n-1);
	        check(A,n);
	        for(int i=0;i<n;i++){
	        	if(i != n-1){
	        		System.out.print(A[i].suit+" ");
	        		System.out.print(A[i].num);
	        		System.out.println();
	        	}else{
	        		System.out.print(A[i].suit+" ");
	        		System.out.print(A[i].num);
	        		System.out.println();
	        	}
	        }
	
	}
	

	public static  int Partition(Card[] num, int p, int r) {
		int x = num[r].num;
		int i = p - 1;
		for (int j = p; j < r; j++) {
			if (num[j].num <= x) {
				i = i + 1;
				Card tmp = num[i];
				num[i] = num[j];
				num[j] = tmp;
			}

		}
		Card tmp = num[i + 1];
		num[i + 1] = num[r];
		num[r] = tmp;
		return i + 1;
	}
	
	public  static  void Quicksort(Card[] A, int p, int r){
		if(p < r){
			int q = Partition(A,p,r);
			Quicksort(A,p,q-1);
			Quicksort(A,q+1,r);
		}
	//	return A;
	}

	 static  void swap(String[] a,int idx1,int idx2){
	        String temp = a[idx1];
	        a[idx1] = a[idx2];
	        a[idx2] = temp;
	    }
	 
	 static  void check(Card[] A,int n){
		  for(int i=0;i<n-1;i++){
		    if(A[i].num == A[i+1].num){
		    	if(A[i].idx > A[i+1].idx){
		    		System.out.println("Not stable");
		    		   return;
		    	}
		 
		    }
		  }
		    System.out.println("Stable");
		}
		 



}



Measured memory_bytes: 114104
#include <stdio.h>

int main(){
  long long int score, group, rest, operation;
  scanf("%lld", &score);
  group = score / 11;
  rest = score % 11;
  if(rest >= 1 && rest <= 6){
    operation =  2 * group + 1;
  }else if(rest == 0){
    operation = 2 * group;
  }else{
    operation = 2 * (group + 1);
  }
  printf("%lld\n", operation);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    int n, m;
    cin >> n >> m;
    if(n == m){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}


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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if (abs(a-c)<=d){
        cout<<"Yes"<<endl;
    }else if (abs(a-b)<=d && abs(b-c)<=d){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
Int n,k;
string calc(string s){
  reverse(s.begin(),s.end());
  Int cnt=0;
  while(cnt<n&&s[0]==s[cnt]) cnt++;
  Int len=cnt<<k;
  if(len>=n) return string(n,s[0]);
  string res;
  for(Int i=cnt;i<n;i++)
    if(len+(Int)res.size()<n) res+=s[i];
  return string(len,s[0])+res;
}

signed main(){
  string s;
  cin>>n>>k>>s;
  chmin(k,20);
  k--;
  string ans=s;

  string t(s);
  reverse(t.begin(),t.end());
  string b=s+t;
  for(Int i=0;i<=n;i++){
    string c=b.substr(i,n);
    chmin(ans,calc(c));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
//#define DEB1 //output check function
//#define DEB2 //same output, input from input.txt

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VVI = vector<VI>;


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


#ifdef DEB1
#define DPRINT(x) cout<< #x << "=" << (x) << endl; // print at debug mode
#else
#define DPRINT(x) ;
#endif
#ifdef DEB1
#define DCHECK(x) cout<< "debug check" << #x << endl;
#else
#define DCHECK(x) ;
#endif
 


/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9

// Main program
void solve(){
    int N;
    LL A[100100];
    LL B[100100];
    cin >> N;
    REP(i,N+1) cin >> A[i];
    REP(i,N) cin >> B[i];
    LL ans = 0;
    
    REP(i,N){
        LL b = B[N-1-i];
        LL a1 = A[N-i];
        if(A[N-i] > b ){
        ans+= b;
        }
        else{
            ans+= a1;
            b-=a1;
            if(A[N-1-i] > b){
                ans+= b;
                A[N-1-i] -= b;
            }
            else{
                ans+= A[N-1-i];
                A[N-1-i]=0;
            }
        }
    }
    cout << ans<< endl;

}



// ----------------------------------------------
int main() {

#ifdef DEB2
    cout << "DEBUG MODE"  << endl;
	ifstream in("input.txt"); //for debug
	cin.rdbuf(in.rdbuf()); //for debug
#endif

	int T=1; 

	for (int i = 0; i < T; ++i) {
		solve();
	}
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define mp make_pair
const int mod=1e9+7;

void solve()
{
  int n,m,x1,x,y,a,b,c;
  ll ans=0;
  cin>>x>>y>>a>>b>>c;
  vector<int> A,B,C;
  for(int i=0;i<a;i++)
  {
    cin>>x1;
    A.pb(x1);
  }
  for(int i=0;i<b;i++)
  {
    cin>>x1;
    B.pb(x1);
  }
  for(int i=0;i<c;i++)
  {
    cin>>x1;
    C.pb(x1);
  }
  sort(A.rbegin(),A.rend());
  sort(B.rbegin(),B.rend());
  for(int i=0;i<x;i++)
  {
    C.pb(A[i]);
  }
  for(int i=0;i<y;i++)
  {
    C.pb(B[i]);
  }
  sort(C.rbegin(),C.rend());
  for(int i=0;i<x+y;i++)
  {
    ans+=C[i];
  }
  cout<<ans<<endl;
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 3188
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)
INF = 10 ** 18

N, M = map(int, raw_input().split())
E = [[] for i in range(N)]
for i in range(M):
    L, R, D = map(int, raw_input().split())
    E[L - 1].append((R - 1, D))
    E[R - 1].append((L - 1, -D))

X = [INF] * N

def func(pos, x):
    if X[pos] != INF:
        return X[pos] == x
    X[pos] = x
    ret = True
    for to, D in E[pos]:
        ret = ret and func(to, x + D)
    return ret

flag = True
for i in range(N):
    if X[i] == INF:
        flag = flag and func(i, 0)

print "Yes" if flag else "No"

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

int main() {
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<int> l(n);
    rep(i,n) cin >> l[i];

    int ans = (n-3)*10+3*1*1000;
    rep(i,1<<(2*n)){
        int p = 0;
        int q = 0;
        int r = 0;
        int z = n-3;
        rep(j,n){
            int g = i>>(2*j)&0b11;
            int lj = l[j];
            if(g == 0) p += lj;
            else if(g == 1) q += lj;
            else if(g == 2) r += lj;
            else z--;
        }
        if(p == 0 || q == 0 || r == 0) continue;

        int mpi = 10*z+abs(p-a)+abs(q-b)+abs(r-c);
        ans = min(ans,mpi);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1e18;

int main() {
  ll k,n;
  cin >> k >> n;
  vec a(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  ll ans=a[0]+k-a[n-1];
  for(ll i=0;i<n-1;i++) {
    ans=max(ans,a[i+1]-a[i]);
  }
  cout << k-ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            for(int k = 0; k <= c; k++){
                int z = 500 * i + 100 * j + 50 * k;
                if(x == z)
                    ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())
 
def check(X):
  global A
  global B
  return (int)(X*0.08) == A and (int)(X*0.1) == B
 
for x in range(1, max(A, B)*20):
  if check(x):
    print(x)
    exit(0)
 
print(-1)

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
  int N,flag=0;
  scanf("%d",&N);

  if(N/100==7){
    flag = 1;
  }
  else if((N-N/100*100)/10==7){
      flag = 1;
  }
  else if((N-N/10*10)==7){
        flag = 1;
  }

  if(flag==1){
    printf("Yes");
  }
  else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 1708
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

long long int pow_mod(long long int p_a,long long int p_n,long long int p_p=1e9+7){
	//p_a^p_n mod p_p
	long long int p_b=1,p_t=1;
	for(;p_b<=p_n;p_b<<=1);
	for(p_b>>=1;p_b>0;p_b>>=1){
		p_t*=p_t;
		if(p_t>=p_p)p_t%=p_p;
		if(p_n&p_b)p_t*=p_a;
		if(p_t>=p_p)p_t%=p_p;
	}
	return p_t;
}

LL t[110000];

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c;
	cin>>n>>m;
	for(i=2;i<=m;i++){
		t[i]=pow_mod(m/i,n);
	}
	for(i=m;i>=2;i--){
		for(j=2;j<i && j<=400;j++){
			if(i%j)continue;
			k=i/j;
			if(j>k)break;
			t[j]-=t[i];
			if(t[j]<0)t[j]+=MAX;
			if(j!=k){
				t[k]-=t[i];
				if(t[k]<0)t[k]+=MAX;
			}
		}
	}
	a=pow_mod(m,n);
	LL s=0;
	for(i=2;i<=m;i++){
		a-=t[i];
		s+=t[i]*i;
		s%=MAX;
		if(a<0)a+=MAX;
	}
	s+=a;
	cout<<s%MAX<<endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main() {

    ll N, K, S;
    cin >> N >> K >> S;

    ll iku = 1919;
    if(S == 1000000000){
        iku *= -1;
    }

    for(ll i = 0; i < N; i++){
        if(i >= K){
            cout << ( i ? " " : "" ) << S + iku;
        }else{
            cout << ( i ? " " : "" ) << S;
        }
    }

}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll i;
    ll N;
    cin >> N;
    for(i = 1LL;i <= N;i <<= 1);
    cout << (i >> 1) << endl;
    return 0;
}


Measured memory_bytes: 256
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg1(){write2(-1);exit(0);}
	void gg2(){puts("NO");exit(0);}
	
	const double eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int N=1e6+10;
	
	int a[N],mx[N];
	int dec[N];
	void main()
	{
		dec[0]=1;fo(i,1,N-1) dec[i]=dec[i-1]*10;
		int n=qread();int L=log10(n)+1;deb(L);
		int F=n/dec[L-1],FF=dec[L-1]*F;deb(F);deb(FF);
		ll ans=0;
		fo(A,1,n)
		{
			int fir=A/dec[(int)log10(A)],lst=A%10;
			if(lst==0) continue;
			ans+=(lst==fir and lst<=n);
			fo(ln,2,L)
			{
				if(ln==L and lst>F) continue;
				if(ln==L and lst==F)
				{
					int mid=n-FF;mid/=10;
					if(n%10>=fir) mid++;ans+=mid;
				}
				else ans+=dec[ln-2];
			}
			//debug("A=%d ans=%d\n",A,ans);
		}write(ans);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	#endif
	srand(time(0));
	mine::main();
	if(DD) cerr<<"Time: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll n;
  cin>>n;
  ll a[n+1]={};
  ll b[n+1]={};

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

  ll ans=0;
  for(int i=29;i>0;i--){
    for(int j=0;j<n;j++){
      a[j]%=(1<<i);
      b[j]%=(1<<i);
    }
    sort(b,b+n);

    ll t=(1<<(i-1));
    ll z=0;
    for(int j=0;j<n;j++){
      z+=lower_bound(b,b+n,2*t-a[j])-lower_bound(b,b+n,t-a[j]);
      //cout<<z<<endl;
      z+=lower_bound(b,b+n,4*t-a[j])-lower_bound(b,b+n,3*t-a[j]);
      //cout<<i<<" "<<a[j]<<" "<<z<<endl;
    }
    if(z%2) ans=ans+(1<<(i-1));
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include<cstring>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
  int r,b,w,g;
  cin>>r>>b>>w>>g;
  cout<<r+b+w+g<<endl;


  
  return 0;
}




Measured memory_bytes: 3092
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

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

int main(){
    ll k; cin >> k;
    vector<vector<string>> vec(k+1);
    vec[0] = {"a"};
    
    rep(i,k){
        for(string s : vec[i]){
            char max = 'a';
            for(auto c : s)chmax(max, c);
            rep(j, max - 'a' + 2){
                char next = 'a' + j;
                vec[i+1].emplace_back(s + next);
            }
        }    
    }

    for(auto s : vec[k-1])cout << s << "\n";
}

Measured memory_bytes: 61160
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535;

int main()
{
    int n, k;
    cin >> n >> k;

    vector<int> count(n, 0);
    rep(i, k) {
        int d;
        cin >> d;
        rep(i, d) {
            int a;
            cin >> a;
            a--;
            count[a]++;
        }
    }

    int ans = 0;
    rep(i, n) {
        if (count[i] == 0) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(void)

{

 int a, b, d = 0,r = 0;

 double f = 0;

 scanf("%d %d",&a, &b);

 d = a/b;

 r = a%b;

 f = (double)a/(double)b;

 printf("%d %d %lf\n",d, r, f);

 return 0;

}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n,m;
    cin >> n >> m;
    int a[n][m];
    int c[m];
    vector<ll> ans(n,0);
    rep(i,n){
        rep(j,m) cin >> a[i][j];
    }
    rep(i,m) cin >> c[i];
    //rep(i,m) cout << c[i] << endl;
    rep(i,n){
        rep(j,m){
            ans[i] += a[i][j]*c[j];
        }
    }
    rep(i,n) cout << ans[i] << endl;
return 0;
}


Measured memory_bytes: 3092
/*  Don’t Quit
    
    When things go wrong as they sometimes will;
        When the road you’re trudging seems all uphill;
            When the funds are low, and the debts are high;
                And you want to smile, but you have to sigh;
                    When care is pressing you down a bit
                        Rest if you must, but don’t you quit.
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=2e5+10;

int gcd(int n,int m)
{
    if(n==0)
        return m;
    else
        return gcd(m%n,n);
}
int a[N];
int32_t main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    int mn=MOD;
    for(int i=k;i<=n;i++)
    {
        mn=min(mn,a[i]-a[i-k+1]);
    }
    cout<<mn<<endl;
    



    


}

Measured memory_bytes: 1024
s=input()
i=1
n=0
ans=[0]
sta=0

 
while i<=len(s):
  if s[i-1]=='A'or s[i-1]=='C' or s[i-1]=='G' or s[i-1]=='T':
    n=n+1
    sta=1
  elif sta==1:
    ans.append(n)
    n=0

  if i<=len(s)&n==len(s):
    ans.append(n)
  elif n!=0:
      ans.append(n)
    
  i=i+1
  
print(max(ans))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
vl ans;
int k;
void dfs(ll num,int d){
    ans.push_back(num);
    if(d==10) return;
    dfs(num*10+num%10,d+1);
    if(num%10!=0)dfs(num*10+((num%10)-1),d+1);
    if(num%10!=9)dfs(num*10+((num%10)+1),d+1);
}
int main(){
    cin>>k;
    rrep(i,9) dfs(i,1);
    sort(ans.begin(),ans.end());
    cout<<ans[k-1]<<endl;
    return 0;
}

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

int main(){
  ll h,w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  rep(i,h)rep(j,w){
    if(s[i][j]=='.') s[i][j]='0';
    if(s[i][j]=='#') continue;
    if(s[i][j+1]=='#') s[i][j]++;
    if(s[i][j-1]=='#') s[i][j]++;
    if(i+1<h){
      if(s[i+1][j+1]=='#') s[i][j]++;
      if(s[i+1][j]=='#') s[i][j]++;
      if(s[i+1][j-1]=='#') s[i][j]++;
    }
    if(i-1>-1){
      if(s[i-1][j-1]=='#') s[i][j]++;
      if(s[i-1][j]=='#') s[i][j]++;
      if(s[i-1][j+1]=='#') s[i][j]++;
    }
  }
  rep(i,h) cout << s[i] << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	double a, b, x;
	cin >> a >> b >> x;
	double s = x / a;
	double rad;
	if (s >= a * b / 2) {
		double h = (a*b - s) * 2 / a;
		rad = atan2(h, a);
	}
	else {
		double w = s * 2 / b;
		rad = atan2(b, w);
	}
	double pi = acos(-1);
	//cout << rad / (2 * pi) * 360 << endl;
	printf("%.10f\n", rad / (2 * pi) * 360);



	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
const int mod = 1e9+7;
const int nax = 1e5+5;
vector<int> adj[nax];
int dp[nax][2]; // 0 - white 1 - black
void dfs(int s,int p=-1)
{
  int p1 = 1,p2 = 1;
  for(auto it : adj[s])
  {
    if(it == p) continue;
    dfs(it,s);
    p1 *= (dp[it][0] + dp[it][1]);
    p1 %= mod;
    p2 *= dp[it][0];
    p2 %= mod;
  }
  dp[s][0] = p1;
  dp[s][1] = p2;
}
signed main()
{
    IOS
    int n; cin>>n;
    int a,b;
    for(int i=0;i<n-1;i++)
    {
      cin>>a>>b;
      adj[a].pb(b);
      adj[b].pb(a);
    }
    dfs(1);
    cout<<(dp[1][0]+dp[1][1])%mod<<endl;
    return 0;
}

Measured memory_bytes: 14208
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<cmath>
using namespace std;


int main(){
    int n,a,b;
    cin >> n >> a >> b;
    if(n==1){
        if(a==b)cout << 1 << endl;
        else cout << 0 <<endl;
    }else{
        if(a>b) cout << 0 << endl;
        else cout << (long long)(b-a)*(n-2)+1;
    }

    return 0;
}


Measured memory_bytes: 256
#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 SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int x, n; cin >> x >> n;
  set<int> p;
  rep(i, n) {
    int a; cin >> a;
    p.insert(a);
  }
  int r = x;
  while(p.find(r) != p.end()) ++r;
  int l = x;
  while(p.find(l) != p.end()) --l;

  if(abs(x-l) <= abs(x-r)) cout << l << endl;
  else cout << r << endl;
}

Measured memory_bytes: 3632
a = int(input())
b = list(map(int, input().split()))
sum = 0
for i in range(a):
    sum += b[i]
left = 0
for i in range(a):
    left += b[i]
    if left > sum / 2:
        if abs(sum / 2 - left) > abs(sum / 2 - left + b[i]):
            left -= b[i]
        print(abs(sum - left * 2))
        exit()



Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define DEC(i, s) for (int i = (s); i >= 0; i--)

#define SIZE(v) (int)((v).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define FIND(m, w) ((m).find(w) != (m).end())


int decode(char *str) {
  int num = 0;
  int prev = 1;
  for (int i = 0; str[i]; i++) {
    if (str[i] == 'm') { num += prev * 1000; }
    if (str[i] == 'c') { num += prev * 100; }
    if (str[i] == 'x') { num += prev * 10; }
    if (str[i] == 'i') { num += prev * 1; }
    prev = 1;
    if (isdigit(str[i])) { prev = str[i] - '0'; }
  }
  return num;
}

void decode(int num) {
  if (num >= 1000) {
    if (num >= 2000) {
      printf("%d", num / 1000);
    }
    printf("m");
  }
  num %= 1000;
  if (num >= 100) {
    if (num >= 200) {
      printf("%d", num / 100);
    }
    printf("c");
  }
  num %= 100;
  if (num >= 10) {
    if (num >= 20) {
      printf("%d", num / 10);
    }
    printf("x");
  }
  num %= 10;
  if (num >= 1) {
    if (num >= 2) {
      printf("%d", num / 1);
    }
    printf("i");
  }
  puts("");
}

int main() {
  char left[100];
  char right[100];
  int test;
  scanf("%d", &test);
  while (test--) {
    scanf("%s %s", left, right);
    int l = decode(left);
    int r = decode(right);
    decode(l + r);
  }
}

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

int main(void){
    int a,b;
    cin>>a>>b;
    double aa=a,bb=b;
    
    int d=a/b;
    double f=aa/bb;
    
    cout<<d<<" "<<a%b<<" ";
    printf("%.5lf\n",f);
    
    return 0;
}


Measured memory_bytes: 3232
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);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; }


int main() {
    ll n, a, b; cin >> n >> a >> b;
    ll res = a*(n/(a+b)) + min(n%(a+b), a);
    cout << res << ln;
}

Measured memory_bytes: 256
//＊最初に、入力のNを1/2倍しておく。以降では1≦N≦5*10^6として考える。
//AB, BA -> AA, BBと置き換えて良い. （偶数番目のAをBに, BをAにした文字列Tを考えると分かる）
//置き換え後、A,BだけならAB,BAを消せるので、AとBが同数が必要条件。
//逆にAとBが同数(1個以上)なら, AB, BAがどこかに存在するので、帰納的に十分性が成立。
//Cは(AまたはB)として使えるので、長さ2NのABC列であって「A,BがN個以下」を数えれば良い。
//否定を取ると「AがN+1個以上」または「BがN+1個以上」となりこれは排反かつ対称な条件なので嬉しい。
//「AがN+1個以上」はAの個数を全探索すれば容易に計算可能。
//1～Nのmod P (P=998244353)での逆元の計算にO(NlogP)かけると厳しいが、これはO(N)にできるので大丈夫。

#include <iostream>
#define int long long
using namespace std;

const int MAX = 10000010;
const int mod = 998244353;
int fact[MAX], finv[MAX], inv[MAX];
int pow2[MAX];

int comb(int n, int k) {
	if (k > n) return 0;
	return fact[n] * finv[k] % mod * finv[n - k] % mod;
}

int n;

signed main() {
	int i;
	
	cin >> n;
	n /= 2;
	
	//参考：http://drken1215.hatenablog.com/entry/2018/06/08/210000
	fact[0] = fact[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (i = 2; i < MAX; i++) {
		fact[i] = fact[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
	
	pow2[0] = 1;
	for (i = 1; i < MAX; i++) {
		pow2[i] = pow2[i - 1] * 2 % mod;
	}
	
	int ngCnt = 0;
	for (i = n + 1; i <= 2 * n; i++) {
		ngCnt += comb(2 * n, i) * pow2[2 * n - i] % mod;
		ngCnt %= mod;
	}
	
	int all = 1;
	for (i = 0; i < 2 * n; i++) (all *= 3) %= mod;
	
	int ans = (all - 2 * ngCnt + 2 * mod) % mod;
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int  MOD=1000000007;
const int  INF= int(1e9);

const int  MAX= int(1e6);

int main() {
    ios_base::sync_with_stdio(false);
    int n, s;
    cin >> n >> s;
    vector<ll> w(n+1),v(n+1);   
    for(int i = 1 ; i <= n ; i++) {
        cin >> w[i] >> v[i];
    }

    vector< vector<ll> > dp(n+1, vector<ll>(s+1,0)); 
    for(int i = 1 ; i <= n ; i++) {
        for (int j = 1 ; j <=s ; j++) {
            dp[i][j] = dp[i-1][j];
            if( w[i] <= j && dp[i-1][j-w[i]] + v[i] > dp[i][j]) {
                dp[i][j] = dp[i-1][j-w[i]] + v[i];
             }
        }
    }

    cout<<dp[n][s];

    return 0;
}



Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc085_d.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll N, H;
  cin >> N >> H;

  vector<ll> a(N, 0);
  vector<ll> b(N, 0);
  ll amax = 0;
  rep(i, N) {
    cin >> a[i] >> b[i];
    if (amax < a[i]) amax = a[i];
  }
  sort(a.rbegin(), a.rend());
  sort(b.rbegin(), b.rend());

  ll ans = 0;
  rep(i, N) {
    if (amax > b[i]) break;
    H -= b[i];
    ans++;
    if (H <= 0) {
      cout << ans << endl;
      return 0;
    }
  }

  ans += ceil((double)H / a[0]);
  cout << ans << endl;
}

Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int i,j;
	string n;
	while(1){
		cin>>n;
		if(n=="-")	break;
		int x,h;
		cin>>x;
		for(i=0;i<x;i++){
			cin>>h;
			string y;
			for(j=0;j<h;j++){
				y+=n[j];
			}
			n.erase(0,h);
			n+=y;
		}
		cout<<n<<endl;
	}
	return 0;
}


Measured memory_bytes: 3228
import java.util.*;

class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int[] ten = new int[s.length() + 1];
        ten[0] = 1;
        for (int i = 1; i < s.length() + 1; i++) {
            ten[i] = (ten[i - 1] * 10) % 2019;
        }

        long res = 0;

        int[] mod = new int[s.length()];
        int[] ans = new int[2019];
        ans[0]++;
        mod[0] = Integer.parseInt(s.substring(s.length() - 1, s.length()));
        ans[mod[0]]++;
        for (int i = 1; i < s.length(); i++) {
            mod[i] = (mod[i - 1] + (Integer.parseInt(s.substring(s.length() - i - 1, s.length() - i)) * ten[i] % 2019))
                    % 2019;
            ans[mod[i]]++;
            // System.out.println(mod[i]);
        }
        for (int i = 0; i < 2019; i++) {
            res += (ans[i] * (ans[i] - 1)) / 2;
        }
        System.out.println(res);

        sc.close();
    }
}


Measured memory_bytes: 51680
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  string data,result;
  getline(cin,data);
 
  for(int i=0;i<data.size();i++){
    if(data[i]=='0' or data[i]=='1'){
      result.push_back(data[i]);
    }
    else if(data[i]=='B' and result.size()!=0){
      result.pop_back();
    }
    else if(result.size()==0 and data[i]=='B'){
    }
  }
  cout<<result<<endl;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    q,h,s,d=parseMap(split(readline()))
    n=parseInt(readline())
    h=min(h,q*2)
    s=min(s,h*2)
    if n%2==0
        ans=min(n*s,n÷2*d)
    else
        ans=min(n*s,n÷2*d+s)
    end
    println(ans)

end
main()

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

string s, t, dp[3010][3010];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> s >> t;
	dp[s.size()][t.size()] = "";
	dp[s.size()-1][t.size()] = "";
	dp[s.size()][t.size()-1] = "";
	for(int i=s.size()-1; i>=0; --i)
		for(int j=t.size()-1; j>=0; --j){
			if(dp[i+1][j].size() < dp[i][j+1].size()) dp[i][j] = dp[i][j+1];
			else dp[i][j] = dp[i+1][j];
			if(s[i] == t[j] && dp[i][j].size() <= dp[i+1][j+1].size())
				dp[i][j] = s[i] + dp[i+1][j+1];
		}
	cout << dp[0][0] << "\n";
//	for(int i=0; i<s.size(); ++i)
//		for(int j=0; j<t.size(); ++j)
//			cout << i << " " << j << " " << dp[i][j] << "\n";
}

Measured memory_bytes: 841984
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    while(true){
        int a,b,c; cin >> a >> b >> c;
        if(a==0 && b==0 && c==0) break;
        int ans=0;
        rep(i,c){
            rep(j,c){
                if((i+1)*(100+a)/100+(j+1)*(100+a)/100!=c) continue;
                chmax(ans,(i+1)*(100+b)/100+(j+1)*(100+b)/100);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3220