akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define N 200000

typedef struct a{
    int cost;
    int deadline;
} Work;

typedef Work key;

void marge(key data[], key work[], int start, int mid, int end){
    int i = start;
    int j = mid + 1;
    int k = start;
    while(i <= mid && j <= end){
        if(data[i].deadline <= data[j].deadline){
            work[k++] = data[i++];
        }else{
            work[k++] = data[j++];
        }
    }
    
    if(i <= mid){
        while(i <= mid){
            work[k++] = data[i++];
        }
    }else{
        while(j <= end){
            work[k++] = data[j++];
        }
    }
    
    for(k = start; k <= end; k++){
        data[k] = work[k];
    }
}

void margesort(key data[], key work[], int start, int end){
    int mid;
    if(start < end){
        mid = start + (end - start)/2;
        margesort(data, work, start, mid);
        margesort(data, work, mid + 1, end);

        marge(data, work, start, mid, end);
    }
}

int main(void){
    int n;
    long long int costsum = 0;
    Work data[N];
    Work tmp[N];
    int i;
    
    scanf("%d", &n);
    
    for(i = 0; i < n; i++){
        scanf("%d %d", &(data[i].cost), &(data[i].deadline));
    }
    
    margesort(data, tmp, 0, n-1);
    
    for(i = 0; i < n; i++){
        costsum += data[i].cost;
        if(costsum > data[i].deadline){
            break;
        }
    }
    
    if(i == n){
        puts("Yes");
    }else{
        puts("No");
    }
    
    return 0;
}

Measured memory_bytes: 3328
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; i<n; ++i)
#define rep1(i, n) for(int i = 1; i<n; ++i)
#define debug(x) cout << #x << ":" << x << "\n";
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T>
std::istream& operator >> (std::istream& is, std::vector<T>& vec){
  T tmp;
  is >> tmp;
  vec.push_back(tmp);
  return is;
}
template <class T>
auto mkVec(unsigned int x){
  return std::vector<int>(x);
}

template <class T>
auto mkVec2(unsigned int x, unsigned int y){
  return std::vector<std::vector<T>>(x, std::vector<T>(y));
}

template <class T>
auto mkVec3(unsigned int x, unsigned int y, unsigned int z){
  return std::vector<std::vector<std::vector<T>>>(x, std::vector<std::vector<T>>(y, std::vector<T>(z)));
}

// 113C
// #ifndef BOOST_TEST_MAIN
// int main(int const argc, char const** argv){
//   int N, M;
//   cin >> N >> M;
//   vector<ll> P;
//   vector<ll> Y;
//   auto X = mkVec2<ll>(N + 1, 0);
//   rep(i, M){
//     ll p, y;
//     cin >> p >> y;
//     P.push_back(p);
//     Y.push_back(y);
//     X[p].push_back(y);
//   }
//   rep(i, N + 1){
//     sort(X[i].begin(), X[i].end());
//   }
//   rep(i, M) {
//     ll y;
//     rep(j, N + 1){
//       auto x = find(X[j].begin(), X[j].end(), Y[i]);
//       if(x != X[j].end()){
//         y = x - X[j].begin();
//         break;
//       }
//     }
//     printf("%06lld%06lld\n", P[i], y + 1);
//   }
// }
// #endif

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  string s;
  cin >> s;
  ll K;
  cin >> K;

  for(auto &&c:s){

    if(c == '1'){
      --K;
      if(K == 0){
        cout << 1;
        return 0;
      }
    continue;
    }
    cout << c;
    return 0;
  }
}
#endif


Measured memory_bytes: 256
def main():
    n,m=map(int,input().split())
    ab=[list(map(int,input().split())) for _ in [0]*m]
    if n==1:
        for a,b in ab:
            print(min(a,b))
        return
    for a,b in ab:
        while a!=b:
            if a<b:
                b=(b+n-2)//n
            else:
                a=(a+n-2)//n
        print(a)
    
main()

Measured memory_bytes: 28516
#include <iostream>
#include <bitset>
#include <string>
using namespace std;
int main()
{
    long long sum = 0;
    int n;
    long long num;
    cin >> n;
    for(int i = 1;i <=n;i++)
    {
        cin >> num;
        sum+=num;
    }

    cout << sum - n << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main() {
  long double a, b;
  cin >> a >> b;
  b *= 1000;
  cout << ll(a * b / 1000) << endl;
  return 0;
} 

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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    int n,m;
	cin >> n>>m;
    int l[100000],r[100000];
    fori(m){cin>>l[i]>>r[i];}
    sort(l,l+m,greater<int>());
    sort(r,r+m);
    if(l[0]>r[0]){
        cout<<0;
    }else{
        cout<<r[0]-l[0]+1;
    }
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<string>
#include<stack>

using namespace std;

int main(){

	int N;
	int pi;
	int gi;
	int cnt[101];
	char in;
	string s[100];
	int gl[100];
	string tmp;
	stack<int> p;
	

	cin>>N;

	getchar();
	/*1...label 2...goto*/
	for(int i=0;i<N;i++){
		tmp="";
		while(1){
			in=getchar();
			if(in=='\n') break;
			tmp+=in;
		}
		s[i]="";
		if(tmp[tmp.size()-1]==';'){
			gl[i]=2;
			for(int j=5;j<tmp.size()-1;j++){
				s[i]+=tmp[j];
			}
		}
		else{
			gl[i]=1;
			for(int j=0;j<tmp.size()-1;j++){
				s[i]+=tmp[j];
			}
		}
	}

	for(int i=0;i<=N;i++){
		cnt[i]=100000;
	}

	p.push(0);
	cnt[0]=0;
	while(!p.empty()){
		pi=p.top();
		p.pop();
		if(gl[pi]==1){
			if(cnt[pi]<cnt[pi+1]){
				cnt[pi+1]=cnt[pi];
				if(pi!=N) p.push(pi+1);
			}
		}
		else if(gl[pi]==2){
			for(int i=0;i<N;i++){
				if(gl[i]==1&&s[i]==s[pi]){
					gi=i;
					break;
				}
			}
			if(cnt[pi]+1<cnt[pi+1]){
				cnt[pi+1]=cnt[pi]+1;
				if(pi!=N) p.push(pi+1);
			}
			if(cnt[pi]<cnt[gi]){
				cnt[gi]=cnt[pi];
				p.push(gi);
			}
		}
	}

	cout<<cnt[N]<<endl;

	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

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

	int count = 0;

	rep(i, 100) {
		if (b<=a) {
			count++;
			b *= 2;
		}
		else {
			break;
		}
	}

	rep(i,100){
		if (c <= b) {
			count++;
			c *= 2;
		}
		else {
			break;
		}
	}
	
	if (count > k) {
		cout << "No" << endl;
	}else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 3516
import java.util.Scanner;

// C - Dice and Coin
// https://atcoder.jp/contests/abc126/tasks/abc126_c
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int K = Integer.parseInt(scanner.next());

        scanner.close();

        // 各値ごとに勝つ確率を出して確率をsumする
        double sum = 0;
        for (int dice = 1; dice <= N; dice++) {
            double tmp = 1.0d / N; // サイコロの各値が出る確率
            int point = dice;

            // K点を超えるまで
            while (point < K) {
                point *= 2;
                tmp /= 2;
            }
            sum += tmp;
        }

        System.out.println(sum);


    }
}


Measured memory_bytes: 22100
N, A = map(int, input().split())
X = list(map(int, input().split()))
L = max(X)
L = max(L, A)

dp = [[[0 for _ in range((N+1)*(L+1))] for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1

for j in range(1, N+1):
    for k in range(N+1):
        for s in range((N+1)*(L+1)):
            if s < X[j-1]:
                dp[j][k][s] = dp[j-1][k][s]
            if k >= 1 and s >= X[j-1]:
                dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-X[j-1]]
ans = 0
for k in range(1, N+1):
    ans += dp[N][k][k*A]
print(ans)

Measured memory_bytes: 96732
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

//std::cout << std::fixed << std::setprecision(10)
constexpr long long MOD = 1000000007;

int main()
{
  int n;
  std::cin >> n;
  std::vector<int> p(n);
  for(auto& val: p)
    std::cin >> val;
  int ans = 0;
  for (int i = 1; i < n - 1; ++i)
  {
    if ((p[i-1] < p[i] && p[i] < p[i+1]) ||
        (p[i+1] < p[i] && p[i] < p[i-1]))
      ++ans;
  }
  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 256
s = int(input())
a = [0]*10**5
a[0] = s
for i in range(1, 10**5):
    a[i] = a[i-1] // 2 if a[i-1]%2 == 0 else 3*a[i-1] + 1
    tmp = a[i]
    if tmp in a[:i]:
        break
print(i+1)

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

public class Main {
	
	public int space(Point a, Point b, Point c){
		return (a.x-c.x)*(b.y-c.y) - (a.y-c.y)*(b.x-c.x);
	}
	public double dist(Point a, Point b){
		return Math.sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
	}
	public double dist(Point a, Point b, Point c){
		return Math.abs(space(a, b, c) / dist(a, b));
	}
	public boolean inOrOut(Triangle tr, Point p){
		double key = Math.signum(space(tr.a, tr.b, p)) + Math.signum(space(tr.b, tr.c, p)) + Math.signum(space(tr.c, tr.a, p));
		return (Math.abs(key) == 3);
	}
	public boolean crossOrNot(Point a, Point b, Circle c){
		if( dist(a, b, c.p) > c.r ){
			return true;
		}
		if( Math.min(dist(a, c.p), dist(b, c.p)) <= c.r ){
			return false;
		}
		double l = Math.max(dist(a, c.p), dist(b, c.p));
		double d = dist(a, b, c.p);
		if( Math.sqrt(l*l - d*d) > dist(a, b) ){
			return true;
		}
		return false;
	}		
	public void relation(Triangle tr, Circle c){
		if( dist(tr.a, c.p) <= c.r && dist(tr.b, c.p) <= c.r && dist(tr.c, c.p) <= c.r ){
			writer.println("b");
		} else if( inOrOut(tr, c.p) && (dist(tr.a, tr.b, c.p) >= c.r && dist(tr.b, tr.c, c.p) >= c.r && dist(tr.c, tr.a, c.p) >= c.r) ){
			writer.println("a");
		} else if( crossOrNot(tr.a, tr.b, c) && crossOrNot(tr.b, tr.c, c) && crossOrNot(tr.c, tr.a, c) ){
			writer.println("d");
		} else {
			writer.println("c");
		}
		return;
	}
			
	public void solve() throws IOException{
		int n, m;
		while( (n = nextInt()) != 0 | (m = nextInt()) != 0 ){
			int p = nextInt(), q = nextInt(), r = nextInt(), s = nextInt();
			Triangle tr = new Triangle(n, m, p, q, r, s);
			int x = nextInt(), y = nextInt(), z = nextInt();
			Circle c = new Circle(x, y, z);
			relation(tr, c);
		}
	}			
	public static void main (String args[]) throws IOException{
		new Main().run();
	}
	
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	
	public void run() throws IOException{
		try{
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e){
			e.printStackTrace();
			System.exit(1);
		}
	}
	public int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}		
	public String nextToken() throws IOException{
		while( tokenizer == null || !tokenizer.hasMoreTokens() ){
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}

class Triangle{
	Point a;
	Point b;
	Point c;
	Triangle(int p, int q, int r, int s, int t, int u){
		a = new Point(p, q);
		b = new Point(r, s);
		c = new Point(t, u);
	}
}
class Point{
	int x;
	int y;
	Point(int x, int y){
		this.x = x;
		this.y = y;
	}
}
class Circle{
	Point p;
	int r;
	Circle(int x, int y, int r){
		p = new Point(x, y);
		this.r = r;
	}
}

Measured memory_bytes: 9592
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
int exp(int x,int y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%big;
    int t=exp(x,y/2);
    return (t*t)%big;
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}
priority_queue<ll> div(ll m){
    priority_queue<ll> ans;
    for(int i=1;i*i<=m;i++){
        if(m%i==0){
            ans.push(i);ans.push(m/i);
        }
    }
    return ans;
}


int main(){
    //Mの約数であるのは明らか
    //d*N<=Mなる最大のdを取れば良い。
    ll n,m;cin >> n >> m;
    priority_queue<ll> ans=div(m);
    int s=ans.size();
    rep(i,s){
        ll k=ans.top();ans.pop();
        if(k*n<=m){printf("%lld\n",k);return 0;}
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
#define ll long long int
using namespace std;

int main()
{
    ll x;
    cin >> x;

    ll ans;
    ans = (x / 11) * 2;

    if(x % 11 == 0)
    {
    	cout << ans << endl;
    } 
    else
    {
    	x = x % 11;
    	if(x > 6)
    		cout << ans + 2 << endl;
    	else
    		cout << ans + 1 << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main 
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		
		int t = b;
		b = a;
		a = t;
		
		t = c;
		c = a;
		a = t;
		
		System.out.println(a + " " + b + " " + c);
		
	}
}


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

 int main() {
	 int N;
	 cin >> N;
	 vector<int>v(N);
	 for (int i = 0;i < N;++i) {
		 cin >> v[i];

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

	 int answer = v[v.size() / 2] - v[v.size() / 2 - 1];

	 cout << answer << endl;

	 return 0;
 }

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
    int a,b,c,d,e,f,g,h;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    e=a+b+c+d;f=e/60;g=60*f;h=e-g;
    printf("%d\n%d\n",f,h);
    return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<bitset>
#include<functional>
#include<climits>
using namespace std;
typedef pair<int,int>pii;
const int INF=1e9;
const int dx[]={0,-1,0,1},dy[]={-1,0,1,0};


int main(){
    int n;
    int w[6]={2,3,5,10,12,15};
    int v[6]={380,550,850,380*5*80/100,550*4*85/100,850*3*88/100};
    while(scanf("%d",&n),n){
        n/=100;
        int dp[51];fill_n(dp,51,1<<25);
        dp[0]=0;
        for(int i=1;i<=n;i++){
            for(int j=0;j<6;j++){
                if(i-w[j]<0)continue;
                dp[i]=min(dp[i],dp[i-w[j]]+v[j]);
            }
        }
        printf("%d\n",dp[n]);
    }
    return 0;
}

Measured memory_bytes: 1188
#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(){
  ll n;
  cin>>n;
  vector<P> v(n);
  rep(i,n){
    cin>>v.at(i).first;
  }
  rep(i,n){
    v.at(i).second = i+1;
  }
  sort(v.begin(),v.end());
  rep(i,n-1){
    cout << v.at(i).second << ' ';
  }
  cout <<v.at(n-1).second << endl;
}

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

#define rep(i, x, n) for(int i=x;i<=n;i++)
#define pr make_pair
#define fi first
#define se second

const int MOD = int(1E9) + 7;
const int MAX = 420000;

inline int add(int x, int y) {x += y; return x >= MOD ? x - MOD : x;}
inline int sub(int x, int y) {x -= y; return x < 0 ? x + MOD : x;}
inline int mul(int x, int y) {return (int) (1LL * x * y % MOD);}
int mpow(int b, int p) {
	int r; for(r=1;p;p>>=1,b=mul(b,b))
		if( p & 1 ) r = mul(r, b);
	return r;
}

struct node{int x[40], cnt;}st[MAX + 5];

int l[75], tot, N, K;
void dfs(int s, node a, int x) {
	st[++tot] = a;
	for(int i=x;i<=N&&l[i]<=s;i++)
		a.x[a.cnt++] = i, dfs(s - l[i], a, i), a.x[--a.cnt] = i;
}

int f[MAX + 5], fct[505], ifct[505], c[505][505];
void init() {
	rep(i, 0, 500) rep(j, 0, i)
		c[i][j] = (j == 0 ? 1 : add(c[i - 1][j], c[i - 1][j - 1]));
	fct[0] = 1; rep(i, 1, 500) fct[i] = mul(fct[i - 1], i);
	ifct[500] = mpow(fct[500], MOD - 2);
	for(int i=499;i>=0;i--) ifct[i] = mul(ifct[i + 1], i + 1);
	
	l[1] = 2; rep(i, 2, N) l[i] = (i - 1) << 1; dfs(N, (node){}, 1);
	rep(i, 1, tot) {
		int a = 1, b = 0, t = 1, p = 1;
		rep(j, 1, st[i].cnt - 1) {
			if( st[i].x[j] != st[i].x[j-1] )
				t = mul(t, ifct[p]), p = 1;
			else p++;
		}
		t = mul(t, ifct[p]);
		rep(j, 0, st[i].cnt - 1) {
			b += l[st[i].x[j]];
			if( st[i].x[j] != 1 ) a += 2;
		}
		f[i] = mul(mul(fct[st[i].cnt], t), c[N + a - 1][a + b - 1]);
	}
//	printf("%d\n", tot);
}

int tg[75], q[75]; char s[75];
int main() {
	scanf("%d%d%s", &N, &K, s + 1), N++, init();
	
	int ans = 0;
	rep(i, 1, tot) {
		int cnt1 = 0, pos = -1;
		rep(j, 0, st[i].cnt - 1) {
			if( st[i].x[j] != 1 ) {
				pos = j;
				break;
			} else cnt1++;
		}
		
		int hd = 1, tl = 0, p = st[i].cnt - cnt1;
		rep(j, 1, K) tg[j] = -1;
		for(int j=1;p&&j<=K;j++) {
			if( s[j] == 'r' ) q[++tl] = j;
			else if( hd <= tl ) tg[q[hd++]] = 0, tg[j] = 1, p--;
		}
		
		int cnt[2] = {}; bool flag = true;
		for(int j=K;j>=1;j--) {
			if( tg[j] == -1 ) cnt[s[j] == 'r' ? 0 : 1]++;
			else if( tg[j] == 1 ) {
				int tmp = st[i].x[pos] - 2;
				while( cnt[1] && tmp ) cnt[1]--, tmp--;
				while( cnt[0] && tmp ) cnt[0]--, tmp--;
				if( tmp ) {
					flag = false;
					break;
				}
				pos++;
			}
		}
		
		if( flag && cnt[0] >= cnt1 && p == 0 ) ans = add(ans, f[i]);
	}
	printf("%d\n", ans);
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 1e9 + 7;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  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*(const mint a) const {mint res(*this);return res*=a;}
  mint pow(ll b) const {
    mint res(1), a(*this);
    while (b) {
      if (b & 1) res *= a;
      a *= a;
      b >>= 1;
    }
    return res;
  }
  // 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;}
};
ostream& operator<<(ostream& os, const mint& a) {os << a.x; return os;}



const int SZ = 2123456;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
ll choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}

mint H(int box, int ball) {
  ll res = choose(box - 1 + ball, box - 1);
  return mint(res);
}

int main2() {
  int K = nextLong();
  string S; cin >> S;
  const int N = S.size();
  mint ans = 0;
  for (int k = 0; k <= K; k++) {
    mint val = mint(25).pow(K - k) * H(N, K - k);
    val *= mint(26).pow(k);
    ans += val;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  inv[1] = 1;
  for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
  fact[0] = 1;
  for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
  fact_inv[0] = 1;
  for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;


#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 55168
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  string a="MARCH";
  vector<string> s(n);
  for(Int i=0;i<n;i++) cin>>s[i];

  map<char,Int> r;
  for(Int i=0;i<5;i++) r[a[i]]=i;

  vector<Int> cnt(5,0);
  for(Int i=0;i<n;i++)
    if(r.count(s[i][0])) cnt[r[s[i][0]]]++;

  Int ans=0;
  for(Int i=0;i<5;i++)
    for(Int j=0;j<i;j++)
      for(Int k=0;k<j;k++)
	ans+=cnt[i]*cnt[j]*cnt[k];

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


Measured memory_bytes: 6144
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

int main() {
  ll N, K;
  cin >> N >> K;

  vector<P> lst(N);
  for (int i = 0; i < N; i++) {
    P tmp;
    cin >> tmp.first >> tmp.second;
    lst[i] = tmp;
  }

  sort(lst.begin(), lst.end());

  ll acc = 0;
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    acc += lst[i].second;
    if(acc >= K){
      ans = lst[i].first;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    while(1){
    int n,m,k;
    cin>>n>>m>>k;
    if(n==0)break;
    vector<int> dp(n*m+1,0);
    dp[0] = 1;
    for(int i=0;i<n;i++){
	vector<int> tmp(n*m+1,0);
	for(int j=0;j<=n*m;j++){
	    for(int k=1;j+k<=n*m&&k<=m;k++){
		tmp[j+k] += dp[j];
	    }
	}
	dp = tmp;
    }
    double res = 0;
    double p = pow(m,n);
    for(int i=0;i<=n*m;i++){
	res += (double)(dp[i]*max(1,i-k) )/p;
    }
    printf("%0.10lf\n",res);
    }
    return 0;
}



Measured memory_bytes: 3456
def solve():
  import sys
  import math

  sys.setrecursionlimit(10**7)
  readline=sys.stdin.readline

  n,k = map(int,input().split())
  s = input()
  
  from itertools import groupby
  
  ans = 0
  for _,g in groupby(list(s)):
    l = len(list(g))
    if l > 1:
      ans += l-1

  print(min(ans+k*2,n-1))

if __name__ == '__main__':
  solve()

Measured memory_bytes: 4748
#include <bits/stdc++.h>
using namespace std;
const int M = 1e6 + 10;
int a[M], vis[M], book[M];
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        book[a[i]]++;
        if(book[a[i]] <= 2) {
            for(int j = a[i]; j <= 1e6; j += a[i]) {
                vis[j]++;
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if(vis[a[i]] == 1) ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 12308
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

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

    if(n % 2 == 0){
        vector<ll> dp1(n, 0), dp2(n, 0);
        dp1[0] = a[0];
        dp2[n-1] = a[n-1];
        for(int i = 1; i < n; i++){
            if(i % 2 == 0)dp1[i] = dp1[i-1] + a[i];
            else dp1[i] = dp1[i-1];
        }
        for(int i = n-2; i >= 0; i--){
            if(i % 2 == 1)dp2[i] = dp2[i+1] + a[i];
            else dp2[i] = dp2[i+1];
        }
        ll ans = max(dp2[0], dp1[n-1]);
        for(int i = 1; i < n-1; i++){
            ans = max(ans, dp1[i-1]+dp2[i+1]);
        }
        cout << ans << endl;
    }else{
        vector<vector<ll>> dp1(n, vector<ll>(2, 0));
        dp1[0][0] = a[0];
        for(int i = 1; i < n; i++){
            if(i % 2 == 1){
                dp1[i][0] = dp1[i-1][0];
                dp1[i][1] = dp1[i-1][1] + a[i];
                if(i >= 2)dp1[i][1] = max(dp1[i][1], dp1[i-2][0] + a[i]);
            }else{
                dp1[i][0] = dp1[i-1][0] + a[i];
                dp1[i][1] = dp1[i-1][1];
            }
        }
        vector<vector<ll>> dp2(n, vector<ll>(2, 0));
        dp2[n-1][0] = a[n-1];
        for(int i = n-2; i >= 0; i--){
            if(i % 2 == 1){
                dp2[i][0] = dp2[i+1][0];
                dp2[i][1] = dp2[i+1][1] + a[i];
                if(i <= n-3)dp2[i][1] = max(dp2[i][1], dp2[i+2][0]+a[i]);
            }else{
                dp2[i][0] = dp2[i+1][0] + a[i];
                dp2[i][1] = dp2[i+1][1];
            }
        }

        ll ans = -1001001001001001001;
        rep(i, n){
            if(i == 0){
                ans = max(ans, dp2[2][0]);
                ans = max(ans, dp2[1][1]);
            }else if(i == n-1){
                ans = max(ans, dp1[n-3][0]);
                ans = max(ans, dp1[n-2][1]);
            }else if(i % 2 == 0){
                ans = max({ans, dp1[i-1][0]+dp2[i+1][0], dp1[i-1][0]+dp2[i+1][1]});
                ans = max({ans, dp1[i-1][1]+dp2[i+1][0], dp1[i-1][1]+dp2[i+1][1]});
            }else{
                ans = max({ans, dp1[i-1][0]+dp2[i+1][1], dp1[i-1][1]+dp2[i+1][0]});
                ans = max(ans, dp1[i-1][1]+dp2[i+1][1]+a[i]);
            }
        }
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 26764
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int s,a,ans=1;
  vector<bool> u(1e6+1,false);
  cin >> s;
  a=s;
  while (!u.at(a)){
    u.at(a)=true;
    if (a%2) a=a*3+1;
    else a/=2;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, n) for (int i = 1; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 3000000000000000000;

int main() {
    int N, M;
    ll K;
    cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];
    
    vector<ll> Asum(N + 1, 0), Bsum(M + 1, 0);
    rep(i, N) Asum[i + 1] = Asum[i] + A[i];
    rep(i, M) Bsum[i + 1] = Bsum[i] + B[i];
    
    int ans = 0;
    rep(i, N + 1) {
        if (Asum[i] > K) continue;
        auto iter = upper_bound(ALL(Bsum), K - Asum[i]);
        if (iter == Bsum.begin()) {
            ans = max(ans, i);
            continue;
        }
        ans = max(ans, i + (int)(iter - 1 - Bsum.begin()));
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 9528
# -*- coding:utf-8 -*-

def main():
    List=[]

    for i in range(10):
        a=int(input())
        List.append(a)

    List.sort(reverse=True)
    print(List[0])
    print(List[1])
    print(List[2])
        
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 7712
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef vector<int> vi;	//26
typedef map<vi,int> mvi;
string s;
vi operator+(const vi& x,const vi& y){
	vi z;
	rep(i,26) z.pb(x[i]+y[i]);
	return z;
}
mvi pro(mvi a,mvi b){
	mvi c;
	for(auto p:a) for(auto q:b){
		c[p.fs+q.fs]+=p.sc*q.sc;
	}
	return c;
}
mvi expr(int& it);
int dig(int &it){
	int x=0;
	while(isdigit(s[it])){
		x*=10;
		x+=s[it]-'0';
		it++;
	}
	return x;
}
mvi fac(int &it){
	if(s[it]==' ') it++;
	if(s[it]=='('){
		it++;
		mvi ret=expr(it);
		assert(s[it]==')');
		it++;
		return ret;
	}else if(islower(s[it])){
		int c=s[it]-'a';
		int o=1;
		if(s[it+1]=='^'){
			o=s[it+2]-'0';
			it+=2;
		}
		it++;
		mvi ret;
		vi a(26,0);
		a[c]=o;
		ret[a]=1;
		return ret;
	}else{
		assert(isdigit(s[it]));
		int x=dig(it);
		mvi ret;
		vi a(26,0);
		ret[a]=x;
		return ret;
	}
}
mvi term(int &it){
	mvi ret=fac(it);
	while(it<s.size()&&s[it]!='+'&&s[it]!='-'&&s[it]!=')'){
		mvi a=fac(it);
		ret=pro(ret,a);
	}
	return ret;
}
mvi expr(int& it){
	mvi ret=term(it);
	while(s[it]=='+'||s[it]=='-'){
		if(s[it]=='+'){
			it++;
			mvi a=term(it);
			for(auto p:a) ret[p.fs]+=p.sc;
		}else{
			it++;
			mvi a=term(it);
			for(auto p:a) ret[p.fs]-=p.sc;
		}
	}
	return ret;
}
string igs(string s){
	int i=0;
	while(i<s.size()){
		if(s[i]==' ' && (i==0||!isdigit(s[i-1])||i+1==s.size()||!isdigit(s[i+1])) ) s.erase(i,1);
		else i++;
	}
	return s;
}
bool isame(mvi a,mvi b){
	mvi x,y;
	for(auto p:a) if(p.sc!=0) x[p.fs]=p.sc;
	for(auto p:b) if(p.sc!=0) y[p.fs]=p.sc;
	return x==y;
}
int main(){
	while(true){
		getline(cin,s);
		if(s[0]=='.') break;
		s=igs(s);
		int it=0;
		map<vi,int> ms=expr(it);
		while(true){
			getline(cin,s);
			if(s[0]=='.'){
				puts(".");
				break;
			}
			s=igs(s);
			it=0;
			if(isame(expr(it),ms)) puts("yes");
			else puts("no");
		}
	}
}

Measured memory_bytes: 1664
n = int(input())
s = []

for i in range(n):
    s.append(str(input()))

a = 0
b = 0
c = 0
d = 0

for _ in s:
    if _ == 'AC':
        a += 1
    if _ == 'WA':
        b += 1
    if _ == 'TLE':
        c += 1
    if _ == 'RE':
        d += 1

print('AC x {}'.format(a))
print('WA x {}'.format(b))
print('TLE x {}'.format(c))
print('RE x {}'.format(d))

Measured memory_bytes: 16148
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
i64 A[202020];
map<i64, int> Cnt;

bool is_pow2(i64 V)
{
	return (V & -V) == V;
}
i64 companion(i64 V)
{
	for (i64 i = 1;; ++i) {
		i64 p = 1LL << i;
		if (p > V) return p - V;
	}
}

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%lld", A + i);
	for (int i = 0; i < N; ++i) {
		if (Cnt.count(A[i]) == 0) Cnt[A[i]] = 1;
		else Cnt[A[i]] += 1;
	}
	int ret = 0;
	while (!Cnt.empty()) {
		auto pp = (--Cnt.end());
		if (pp->second == 0) {
			Cnt.erase(pp);
			continue;
		}
		i64 x = pp->first;
		i64 y = companion(x);
		Cnt[x] -= 1;
		if (Cnt.count(y) && Cnt[y] > 0) {
			++ret;
			Cnt[y] -= 1;
		}
	}
	printf("%d\n", ret);

	return 0;
}


Measured memory_bytes: 14464
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	string s;
	string t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    bool a[2][1001]={};
    for(int i=0,t;i<n;i++)
      cin>>t,a[0][t]=1;
    for(int i=1;i<=2*n;i++)if(!a[0][i])a[1][i]=1;

    int as=n,bs=n,ba=0;
    bool t=0;
    while(as&&bs){
      bool r=1;
      for(int i=ba+1;i<=2*n;i++)
	if(a[t][i]){a[t][i]=0,ba=i,r=0;break;}
      if(r)ba=0;
      else if(!t)as--;
      else bs--;
      t=!t;
    }

    cout<<bs<<endl<<as<<endl;
  }
  return 0;
}

Measured memory_bytes: 3052
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
 
 
int main(){
	int N,cn=1,temp;

	cin >> N;
	while(N != 0)
	{
		temp = N%10;
		if(temp == 7){
			Yes();
			cn = 0;
			break;
		}
		N = N/10;
	}
	if(cn)No();
    

    biday;
}
 
//...............BYE BYE................

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}
 
int main(){
 
	set<int> S;
	int n = nxt();
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		a[i] = nxt();
	}

	S.insert(0);
	S.insert(n + 1);

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

	long long ans = 0;

	for (int i = 0; i < n; i++) {
		int p = pos[i] + 1;
		auto it = S.lower_bound(p);
		auto it2 = it;
		--it2;
		int x = p - *it2;
		int y = *it - p;
		ans += 1ll * x * y * (i + 1);
		S.insert(p);
	}

	cout << ans << "\n";
 
	return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <list>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

typedef long long ll;

using namespace std;
int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> X;
    ll x;
    ll ans = 0;
    for (int i = 0; i < N; i++) {
    	cin >> x;
    	X.push_back(x);
    }
    for (int i = 0; i < N - 1; i++) {
    	ans += min(A * (X[i+1] - X[i]), B);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1400
#include<stdio.h>


int main(void){
	int a[3][3];
	int n;
	int count[8] = {};
	int i,j,k;
	int b;
	int f;
	int ret=0;

	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			scanf("%d",&a[i][j]);
		}
	}

	scanf("%d",&n);

	for(k=0;k<n;k++){
		scanf("%d",&b);

		for(i=0;i<3;i++){
			for(j=0;j<3;j++){
				if( a[i][j] == b){
					count[i]++;
					count[j+3]++;
					if(i==j)  {	count[6]++; }
					if(2==i+j){	count[7]++; }
					break;
				}
			}
		}


	}


	for(i=0;i<8;i++){
		if(count[i] == 3){
			ret++;
		}
	}

	if(ret > 0){
		printf("Yes\n");
	}else{
		printf("No\n");

	}



}



Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    int x;
    cin >> x;
    int a = x / 500;
    x -= a * 500;
    int b = x/5;
    cout << 1000 * a + 5*b << endl;
}

          

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

int main(){
  int n;
  cin>>n;
  int p[n];
  int j = 0;
  for(int i=1; i<=n; i++){
    cin>>p[i-1];
    if(p[i-1]!=i)j++; 
  }
  if(j>2)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  
  return 0;
}

  



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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    string s, t; cin >> s >> t;
    cout << t << s << endl;
}

Measured memory_bytes: 256
import sys
from collections import Counter
from operator import itemgetter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    n, *V = map(int, read().split())

    counter1 = Counter(V[::2])
    counter2 = Counter(V[1::2])

    vec1 = sorted(counter1.items(), reverse=True, key=itemgetter(1))
    vec2 = sorted(counter2.items(), reverse=True, key=itemgetter(1))

    if vec1[0][0] != vec2[0][0]:
        ans = n - vec1[0][1] - vec2[0][1]
    elif len(vec1) == len(vec2) == 1:
        ans = n // 2
    else:
        tmp = []
        if len(vec1) > 1:
            tmp.append(vec1[1][1] + vec2[0][1])
        if len(vec2) > 1:
            tmp.append(vec1[0][1] + vec2[1][1])
        ans = n - max(tmp)

    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 27564
F=lambda x:x if P[x]<0else F(P[x]);N,M,*X=map(int,open(0).read().split());P=[-1]*-~N;S=N*~-N//2;r=[]
while X:
	r+=S,;b,a=sorted(map(F,(X.pop(),X.pop())))
	if a!=b:S-=P[a]*P[b];P[a]+=P[b];P[b]=a
print(*r[::-1])

Measured memory_bytes: 25076
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)

using namespace std;

llint a[4];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	for(int i = 0; i < 4; i++) cin >> a[i];
	sort(a, a+4);
	cout << abs(a[0]+a[3] - (a[1]+a[2])) << endl;
	
	return 0;
}


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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9
vector<ll> memo;
ll fib(int a){
  if(a == 0 || a== 1){
    return 1;
  }
  if(memo[a] != -1){
    return memo[a];
  }
  return memo[a] = (fib(a-1) + fib(a-2));
}

int main(){
  int n;
  cin >> n;
  memo.resize(50, -1);
  cout << fib(n) << endl;
  return 0;
}



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

int main() {
	string s;
	cin >> s;

	int start = 0;
	int end = 0;
	int count = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s.at(i) == 'A') {
			if (count == 0) {
			start = i;
			count++;
			}
		} else if (s.at(i) == 'Z') {
			end = i;
		}
	}
	int ans = end - start + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <set>
#include <cmath>
#include <math.h>
 
using namespace std;
        
int main(){
    int n;
    cin>>n;
    vector<long int> a(n),b(n),c(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
     sort(a.begin(),a.end());
     sort(b.begin(),b.end());
     sort(c.begin(),c.end());
    
    long long int ans=0,disa=0,disc=0;
    for(int i=0;i<n;i++){
        auto j=lower_bound(a.begin(),a.end(),b[i]);
        disa=distance(a.begin(),j);
        auto k=upper_bound(c.begin(),c.end(),b[i]);
        disc=(n-distance(c.begin(),k));
        ans+=(disa*disc);
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
num=int(input())
if num>81:
    print('No')
else:
    num_list=[]
    
    for a in range(1,10):
        for b in range(1,10):
            num_list.append(a*b)
    num_list=set(num_list)
    if num in num_list:
        print('Yes')
    else:
        print('No')


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

//大文字と小文字の文字コードが32異なることを利用する

int main(){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  s[k-1]+=32;
  cout<<s<<endl;
  
  
  return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int N;
    cin >> N;

    vi d(N);
    REP(i,N) cin >> d[i];

    int ans = 0;
    REP(x,N) REP(y,N) {
        if (x == y or x > y) continue;
        ans += d[x] * d[y];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char line[10000];
  int num;
  fgets(line, sizeof(line), stdin);
  sscanf(line, "%d", &num);
  int list[num];
  int i;
  for(i=0; i<num; ++i){
	scanf("%d", &list[i]);	
}
  for(i=(num-1); i>=0; --i){
	printf("%d", list[i]);
	if(i==0);
	else 
	  printf(" ");
}
  printf("\n");
  return 0;
}



Measured memory_bytes: 2044
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

char a[2010][2010];
int s1[2010][2010],s2[2010][2010],s3[2010][2010];

int main()
{
    //freopen("input.txt","r",stdin);
    int n,m,q;scanf("%d%d%d",&n,&m,&q);
    for (int i=1;i<=n;i++) scanf("%s",a[i]+1);
    for (int i=1;i<=n;i++)
    {
        int s=0;
        for (int j=1;j<=m;j++) {s+=a[i][j]-'0';s1[i][j]=s1[i-1][j]+s;}
    }
    for (int i=1;i<=n;i++)
    {
        int s=0;
        for (int j=1;j<m;j++) {s+=(a[i][j]=='1'&&a[i][j+1]=='1');s2[i][j]=s2[i-1][j]+s;}
    }
    for (int i=1;i<n;i++)
    {
        int s=0;
        for (int j=1;j<=m;j++) {s+=(a[i][j]=='1'&&a[i+1][j]=='1');s3[i][j]=s3[i-1][j]+s;}
    }
    while (q--)
    {
        int x1,y1,x2,y2;scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        int ans=s1[x2][y2]-s1[x1-1][y2]-s1[x2][y1-1]+s1[x1-1][y1-1];
        ans-=(s2[x2][y2-1]-s2[x1-1][y2-1]-s2[x2][y1-1]+s2[x1-1][y1-1]);
        ans-=(s3[x2-1][y2]-s3[x1-1][y2]-s3[x2-1][y1-1]+s3[x1-1][y1-1]);
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 52992
#!/usr/bin/env python3
import numpy as np
import math
import re

n = input()
n = re.split(" ",n)
n = list(map(int,n))
m = max(n)
a = int(n[0])
b = int(n[1])
c = int(n[2])
k = int(input())
if(m == a):
    print(b + c + m*2**k)
elif(m == b):
    print(a + c + m*2**k)
elif(m == c):
    print(a + b + m*2**k)


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

int main(){
 int N,M;
 cin>>N>>M;
  int ans=0;
  vector<int>a(N);
  for(int i=0;i<M;i++){
  int K;
    cin>>K;
   for(int j=0;j<K;j++){
   		int s;
        cin>>s;
      	s--;
      a.at(s) |= 1<<i;
	  }
  }
  int P=0;
  for(int i=0;i<M;i++){
    int x;
    cin>>x;
    P |=x<<i;
  }
  for(int s=0;s< (1<<N);s++){
  int t=0;
    for(int i=0;i<N;i++){
    if(s>>i &  1){
    	t ^=a.at(i);
      }
    }
    if(t==P){
    ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <memory.h>
#include <queue>
#include <string.h>
using namespace std;

#define N 502
#define M 1000000
int A[N],tmp[N];
int dv[M];
void solve() {
  int n,k;scanf("%d %d ",&n,&k);
  int sum = 0,pos=0;
  for(int i=1;i<=n;++i) scanf("%d ", &A[i]),sum += A[i];

  for(int i=1;i*i<=sum;++i) {
    if(sum%i==0) {
      dv[pos++] = i;
      if(i*i!=sum) {
        dv[pos++] = sum/i;
      }
    }
  }
  sort(dv,dv+pos);
  for(int i=pos-1;i;--i) {
    int val = dv[i], len = 0,u;
    int tmpSum = 0,testing = 0;
    for(int j = n;j;--j) {
      if(A[j]%val==0) continue;
      u= val - (A[j]%val);
      tmpSum += u;
      tmp[len++] = val - u;
      testing += val-u;
    }
    assert(testing%val==0);
    int minValue = 0;
    if(len>0) {
      sort(tmp,tmp+len);
      int need = testing/val;
      minValue = testing;
      for(int j=len-1;j>=len-need;--j) {
        minValue -= tmp[j];
      }
    }
    if(minValue<=k) {
      printf("%d\n", val);
      return;
    }
  }
  printf("1\n");
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    string s;
    cin >> s;
    string ans;
    ans = s[0] + to_string(s.length()-2) + s.back();
    cout << ans << "\n";
}

Measured memory_bytes: 256