akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iostream>

using namespace std;

int main(){
	int n,m,x,y;
	cin >> n >> m >> x >> y;
	int max_x = -200,min_y = 200;
	for(int i = 0;i < n;i++){
		int tx;
		cin >> tx;
		max_x = max(max_x,tx);
	}
	for(int i = 0;i < m;i++){
		int ty;
		cin >> ty;
		min_y = min(min_y,ty);
	}
	
	bool flag = true;
	for(int i = x+1;i <= y;i++){
		if(max_x < i && i <= min_y){
			flag = false;
		}
	}
	
	if(flag){
		cout << "War" << endl;
	}else{
		cout << "No War" << endl;
	}
	return 0;
}

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

const int MXN=3005;

char s[MXN];
char t[MXN];
char sol[MXN];
int dp[MXN][MXN];

int main(){
  scanf("%s%s",s+1,t+1); 
  for(int i=1;s[i];++i){
    for(int j=1;t[j];++j){
      if(s[i]==t[j]){
        dp[i][j]=dp[i-1][j-1]+1;
      }else{
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      }
    }
  }
  int n=strlen(s+1);
  int m=strlen(t+1);
  while(dp[n][m]){
    if(dp[n-1][m]==dp[n][m]||dp[n][m-1]==dp[n][m]){
      if(dp[n-1][m]>dp[n][m-1]){
        n--;
      }else{
        m--;
      }
    }else{
      sol[dp[n][m]-1]=s[n];
      n--;
      m--;
    }
  }
  printf("%s\n",sol);
}


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

#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()

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

    rep(i,max(a,b)) cout << min(a,b);
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

namespace NewSkill
{
	typedef long long ll;
	const int N=2010000,MOD=1000000007;
	ll inv(int x){return x==1?1:(-(MOD/x)*inv(MOD%x)%MOD);}
	int fact[N],ifact[N];
	inline int D(int n,int m){return (ll)fact[n+m]*ifact[n]%MOD*ifact[m]%MOD;}
	inline ll sum(int n,int m){if(n<0 || m<0)return 0;return D(n+1,m+1)-1;}

	int X1,X2,X3,X4,X5,X6;
	int Y1,Y2,Y3,Y4,Y5,Y6;
	int n,m;

	int from(int x,int y)
	{
		int x0=X5-x,x1=X6-x,y0=Y5-y,y1=Y6-y;
		return (sum(x1,y1)-sum(x1,y0-1)-sum(x0-1,y1)+sum(x0-1,y0-1))%MOD;
	}
	int to(int x,int y)
	{
		int x1=x-X1,x0=x-X2,y1=y-Y1,y0=y-Y2;
		return (sum(x1,y1)-sum(x1,y0-1)-sum(x0-1,y1)+sum(x0-1,y0-1))%MOD;
	}

	void initialize()
	{
		scanf("%d%d%d%d%d%d",&X1,&X2,&X3,&X4,&X5,&X6);
		scanf("%d%d%d%d%d%d",&Y1,&Y2,&Y3,&Y4,&Y5,&Y6);
		n=X4-X3+1,m=Y4-Y3+1;

		fact[0]=1;
		for(int i=1;i<N;i++)fact[i]=(ll)fact[i-1]*i%MOD;
		ifact[N-1]=inv(fact[N-1]);
		for(int i=N-1;i;i--)ifact[i-1]=(ll)ifact[i]*i%MOD;
	}

	void solve()
	{
		initialize();
		int ans=0;
		for(int i=0,w;i<m;i++)
		{
			w=(ll)to(X3-1,Y3+i)*from(X3,Y3+i)%MOD;
			ans=(ans+(ll)w*(-i))%MOD;

			w=(ll)to(X4,Y3+i)*from(X4+1,Y3+i)%MOD;
			ans=(ans+(ll)w*(n+i))%MOD;
		}
		for(int i=0,w;i<n;i++)
		{
			w=(ll)to(X3+i,Y3-1)*from(X3+i,Y3)%MOD;
			ans=(ans+(ll)w*(-i))%MOD;

			w=(ll)to(X3+i,Y4)*from(X3+i,Y4+1)%MOD;
			ans=(ans+(ll)w*(m+i))%MOD;
		}

		ans=(ans+MOD)%MOD;

		printf("%d\n",ans);
	}
}

int main()
{
	NewSkill::solve();
	return 0;
}


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

int main(){
  int n,s1,s2,s3;
  cin >> n;
  s3 = n % 10;
  s2 = (n % 100 - s3) / 10;
  s1 = (n - s2 * 10 - s3) / 100;
  cout << s1 + s2 + s3;
}

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

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

    int change = 0;
    for(int i = 0; i < s.length() / 2; i++) {
        if(s[i] != s[s.length() - i - 1]) {
            change++;
        }
    }

    std::cout << change << std::endl;
}


Measured memory_bytes: 256
import math
q=int(input())
A=[]
for i in range(q):
    a,b=map(int,input().split())
    p=max(a,b)
    q=min(a,b)
    ans=q-1
    if p-q==1:
        now=q-1
    else:
        now=p-1
    if q>now:
        ans+=now
    else:
        s=int(math.sqrt(a*b))
        if s*(s+1)<a*b:
            ans+=(s-q+1)+s-1
        elif s*s<a*b:
            ans+=(s-q+1)+s-2
        else:
            ans+=(s-1-q+1)+s-2
    A.append(ans)
print(*A,sep="\n")

Measured memory_bytes: 3064
import numpy as np
n,l = map(int,input().split())
sc = []
for i in range(n):
  sc.append(l+i)
sc2 = sc
sc = np.array(sc)
out = sum(sc2)
for i in range(len(sc)):
  sc[i] = abs(sc[i])
out = out - sc2[np.argmin(sc)]
print(out)

Measured memory_bytes: 12504
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;

int N, X;
int mod = 1e9 + 7;

int power(int a, int n){
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        int b = power(a, n / 2);
        return 1ll * b * b % mod;
    } else {
        return 1ll * a * power(a, n - 1) % mod;
    }
}

int inverse(int a) {
    if (a == 1) {
        return 1;
    }
    return power(a, mod - 2);
}

int factorial(int N) {
    if (N == 0) {
        return 1;
    } else {
        return 1ll * N * factorial(N - 1) % mod;
    }
}

int main() {
    cin >> N >> X;
    vector<int> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    sort(S.begin(),S.end(), greater<int>());
    vector<vector<long long>> E(N + 1, vector<long long>(X + 1));
    E[0][X] = 1;
    for (int i = 0; i < N; i++) {
        int d = inverse(N - i);
        for (int x = 1; x <= X; x++) {
            int r = x % S[i];
            E[i + 1][r] = (E[i + 1][r] +  E[i][x] * d) % mod;
            E[i + 1][x] = (E[i + 1][x] +  E[i][x] * (N - i - 1) % mod * d ) % mod;
        }
    }
    long long ans = 0;
    for (int x = 1; x <= X; x++) {
        ans = (ans + E[N][x] * x) % mod;
    }
    cout << ans * factorial(N) % mod << endl;
}




Measured memory_bytes: 158592
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] r = new int[m][2];
        Set<Integer> can1 = new HashSet<>();
        Set<Integer> can2 = new HashSet<>();
        for (int i = 0; i < m; i++) {
            int from = sc.nextInt();
            int to = sc.nextInt();
            if (from == 1) can1.add(to);
            if (to == n) can2.add(from);
        }

        for (int i : can1) {
            if (can2.contains(i)) {
                System.out.println("POSSIBLE");
                return;
            }
        }
        System.out.println("IMPOSSIBLE");
    }
}

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

int main(){
    int N,M,X,A[110]={},a;
    cin>>N>>M>>X;
    for(int i=1;i<=M;i++){
        cin>>a;
        A[a]=1;
    }
    int f=0,l=0;
    for(int i=1;i<X;i++){
        f+=A[i];
    }
    for(int i=X+1;i<=N;i++){
        l+=A[i];
    }
    cout<<min(f,l);
}

Measured memory_bytes: 256
n,m = map(int,input().split())
AB = []
CD = []
for i in range(n):
    a,b = map(int,input().split())
    AB.append([a,b])
for i in range(m):
    c,d = map(int,input().split())
    CD.append([c,d])

for st in range(n):
    ans = float("inf")
    for po in range(m):
        dist = abs(AB[st][0]-CD[po][0])+abs(AB[st][1]-CD[po][1])
        if ans > dist:
            ans = dist
            memo = po + 1
    print(memo)


Measured memory_bytes: 9076
#include<iostream>

#define ll long long

using namespace std;

int main(){

   ll x;
   ll it;
   ll a=100;
   cin >> x;
   ll count =0;
   for (ll i=0;i<=x;i++){
      it = a/100;
      a+=it;
      count ++;
      if (a>=x)
        {cout << count;
        return 0;}
   }


}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1132>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

typedef complex<double> Point;
int n;
int solve(){
    int res = 1;
    vector<Point> ps(n);
    for(int i = 0; i < n;i++){
        double x,y; cin >> x >> y;
        ps[i] = Point(x,y);
    }
    for(int i = 0; i < n;i++){
        for(int j = i+1; j < n;j++){
            double dist = abs(ps[i]-ps[j]);
            if(dist > 2) continue;
            Point mp = (ps[i]+ps[j])/2.;
            Point dp = ps[i]-ps[j];
            double x = sqrt(1-dist*dist/4);
            Point cp = Point(-dp.imag()*x/dist+mp.real(),dp.real()*x/dist+mp.imag());
            int cnt = 0;
            for(int k = 0; k < n;k++){
                if(abs(cp-ps[k]) < 1.0 + 1e-9) cnt++;
            }
            res = max(res,cnt);
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> n,n){
        cout << solve() << endl;
    }
    return 0;
}



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

int main() {
  
  int n; 
  cin >> n;
  
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    int s;
    cin >> s;
    
    vec.at(i) = s;
  }
  
  sort(vec.begin(), vec.end());
  
  int ans = 1;
  for(int i=1; i<n; i++){
    if (vec.at(i) > vec.at(i-1)) ans++;
  }  
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <bitset>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <deque>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
const LL INF = 2e6;
const LL MOD = 1e9 + 7;
const LL _ = 1e10;

void solve() {
    LL a, b, c, d;
    cin >> a >> b >> c >> d;
    vector <LL> v;
    LL x;
    x = a * c;
    v.pb(x);
    x = a * d;
    v.pb(x);
    x = b * d;
    v.pb(x);
    x = b * c;
    v.pb(x);
    LL ans = *max_element(v.begin(), v.end());
    cout << ans << endl;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(20), cout.setf(ios::fixed);
    /*int t;
    cin >> t;
    while (t--) {
        solve();
    }*/
    solve();
}

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




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

        int l = a;
        int r = a + n -1;

        int eat;
        if (r <= 0) eat = r;
        else if(l >= 0) eat =l;
        else eat = 0;

        int ans = (r + l)*(r-l+1)/2-eat;
        std::cout <<  ans << "\n";
        return 0;
        
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  string S, T;
  cin >> S >> T;
  i64 ans = 0;
  for (i64 i = 0; i < S.size(); i++)
    if (S[i] != T[i])
      ans++;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n, k;
	string s;
	cin >> n >> k >> s;
	for(int i=0; i<n; i++){
		if(i==k-1) cout << (char)(s[i]+'a'-'A');
		else cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

const LL INF = 0x3f3f3f3f3f3f3f3fLL;
const int MAXN = 5011;
int N;
LL A[MAXN];
VI G[MAXN];
LL dp[MAXN][MAXN][2];
LL nxt[MAXN][2];
int par[MAXN];
int sz[MAXN];

VI ord;

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%lld", A+i);
    REP (i, N-1) {
	int x, y;
	scanf("%d%d", &x, &y);
	x--; y--;
	G[x].push_back(y);
	G[y].push_back(x);
    }

    ord.reserve(N);
    ord.push_back(0);
    REP (i_, N) {
	int v = ord[i_];
	EACH (e, G[v]) if (*e != par[v]) {
	    par[*e] = v;
	    ord.push_back(*e);
	}
    }

//    REP (i_, N) {
//	int v = ord[N-1-i_];
//	sz[v] = 1;
//	EACH (e, G[v]) if (*e != par[v]) {
//	    sz[v] += sz[*e];
//	}
//    }

    memset(dp, 0x3f, sizeof dp);

    REP (i_, N) {
	int v = ord[N-1-i_];
	if (A[v] < 0) {
	    dp[v][0][1] = A[v];
	} else {
	    dp[v][0][0] = A[v];
	}

	sz[v] = 1;
	EACH (e, G[v]) if (*e != par[v]) {
	    memset(nxt, 0x3f, sizeof nxt);

	    REP (i, sz[v]) REP (a, 2) if (dp[v][i][a] < INF) {
		REP (j, sz[*e]) {
		    REP (b, 2) if (dp[*e][j][b] < INF) {
			amin(nxt[i+j][a|b], dp[v][i][a] + dp[*e][j][b]);
		    }

		    if (dp[*e][j][0] < INF || dp[*e][j][1] < 0) {
			amin(nxt[i+j+1][a], dp[v][i][a]);
		    }
		}
	    }

	    sz[v] += sz[*e];
	    REP (i, sz[v]) REP (a, 2) dp[v][i][a] = nxt[i][a];
	}
    }

    int ans = N;
    REP (i, N) {
	if (dp[0][i][0] < INF || dp[0][i][1] < 0) {
	    ans = i;
	    break;
	}
    }
    printf("%d\n", ans);

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 393088
#include <iostream>

int main()
{
    std::int64_t n, dist;
    std::cin >> n >> dist;

    std::int64_t sqDist = dist * dist;

    size_t count = 0;
    for (auto index = 0; index < n; ++index)
    {
        std::int64_t x, y;
        std::cin >> x >> y;
        if (x * x + y * y <= sqDist)
        {
            ++count;
        }
    }

    std::cout << count;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main()
{
	string s;
	bool foo = true;
	cin>>s;
	int size = s.size();
	for(int i=0;i<size;i++)
	{
		if(i%2==0&&s[i]=='L')
		{
			foo = false;
			//cout<<i<<"dhfhis";
		}
		if(i%2!=0&&s[i]=='R')
		{
			foo = false;
			//cout<<i<<"jdnff";
		}
	}
	if(foo)
	{
		cout<<"Yes\n";
	}
	else 
	{
		cout<<"No\n";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

int main(){
 string S;
 cin >> S;
 int len = S.size();
 ll sum = 0;
 for(int i=0;i<len;i++){
   int tmp = S[i] - '0';
   sum += tmp;
 }

 if(sum%9==0){
   cout << "Yes" << endl;
 }else{
   cout << "No" << endl;
 }
}


Measured memory_bytes: 3724
import java.util.*;

public class Main {
    Scanner sc = new Scanner(System.in);
    
	int n = 100001 ; int total = 0 ;
	int[] time = new int[n];
	String[] name = new String[n];
	int topInt = 0 ,topString=0;  //キューの先頭
	int bottomInt = 0 ,bottomString=0;//キューの末尾 +1
	
	void enQueueInt(int m){
		time[bottomInt] = m ;
		if(bottomInt == n-1) bottomInt = 0;
		else bottomInt++ ;
	}
	void enQueueString(String m){
		name[bottomString] = m ;
		if(bottomString == n-1) bottomString = 0;
		else bottomString++ ;
	}
	
	
	int deQueueInt(){
		int x = time[topInt];
		if(topInt == n-1) topInt = 0;
		else topInt++;
		return x ;
	}
	String deQueueString(){
		String x = name[topString];
		if(topString == n-1) topString = 0;
		else topString++;
		return x ;
	}
	
	void run(){
	    int m = sc.nextInt();
	    int q = sc.nextInt();
	    
	    for(int i=0;i<m;i++){
	        enQueueString(sc.next());
	        enQueueInt(sc.nextInt());
	    }

	    int x ; String y ;
	    while(topInt != bottomInt){
	        x = deQueueInt();
	        y = deQueueString();
	        
	        if(x <= q){
	            total += x;
	            System.out.printf("%s %d\n",y,total);
	            continue;
	        }
	        
	        x -= q; enQueueInt(x); enQueueString(y); total+=q;
	    }
	}
	
    public static void main(String[] args) throws Exception {
        new Main().run();
    }
}


Measured memory_bytes: 107364
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int n;
vstr ans;
string alpha = "abcdefghijklmn";
void dfs(string s, int d) {
    if (d >= n) {
        set<char> st;
        int mx = 0;
        for (char c : s) {
            st.insert(c);
            mx = max(mx, c-'a'+1);
            if (st.size() < mx) return;
        }
        ans.push_back(s);
        return;
    }
    rep(i, d+1) {
        dfs(s + alpha[i], d+1);
    }
}

int main() {
    cin >> n;
    dfs("a", 1);

    for (string s : ans) {
        cout << s << endl;
    }
    return 0;
}

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

int main(){
  int N,i,j;
  int ct;
  string S;
  cin >> N >> S;
  ct = 0;
  i=0;
  j = S.size()-1;
  while(i<j){
    while(S[i] == 'R')
      i++;
    while(S[j] == 'W')
      j--;
    if (i < j){
      ct++;
      S[i] = 'R';
      S[j] = 'W';
    }
  }
  cout << ct << endl;
  return 0;
}
      

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;
int main()
{
    int N, Ma, Mb;
    int dp[425][425];
    int a[44], b[44], c[44];
    fill_n(*dp, 425 * 425, INF);
    int minv = INF;
    cin >> N >> Ma >> Mb;

    for(int i = 0; i < N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[0][0] = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 404; j >= 0; j--) {
            for(int k = 404; k >= 0; k--) {
                dp[j + a[i]][k + b[i]] = min(dp[j + a[i]][k + b[i]], dp[j][k] + c[i]);
            }
        }
        for(int j = 1; j < 405; j++) {
            if(j * Ma < 405 && j * Mb < 405) {
                minv = min(minv, dp[j * Ma][j * Mb]);
            }
        }
    }
    cout << (minv == INF ? -1 : minv) << endl;
    return (0);
}


Measured memory_bytes: 896
#include <iostream>
#define int long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define FOR(i,a,b)  for(int i = (a); i < (b); ++i)

using namespace std;
//const int MOD = 10e9+7;
const int INF = 1LL << 60;
template <class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}  
template <class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}  

signed main (){
    int N ;
    cin >> N;
    int h[N];
    int dp[100100];

    REP(i,N) cin >>h[i];
    fill(dp,dp+N,INF);
    dp[0] = 0;
    REP(i,N){
        //dp[i]はi+1番目のところに行きつくまでの最短コスト
        if(i+1 <= N) dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
        if(i+2 <= N) dp[i+2] = min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));



    }
    
   cout << dp[N-1]<<endl;
}


Measured memory_bytes: 1792
from fractions import gcd

N = int(input())
AB = [list(map(int, input().split(" "))) for _ in range(N)]

round_up = lambda a, b: -(-a//b)

c = 0
for a, b in AB[::-1]:
    # print(a, b)
    # lcm_ab = a*b//gcd(a, b)
    # print(round_up(a+c, lcm_ab), lcm_ab, a+c)
    r = round_up(a+c, b)*b - (a+c)
    # print(r)
    c += r

print(c)

Measured memory_bytes: 30080
import java.util.Scanner;

public class Main {

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

		int num = sc.nextInt();
		double ans;

		if (num == 1) {
			ans = 1.0;
		} else if (num % 2 == 0) {
			ans = ((num / 2.0)) / num;
		} else {
			ans = ((num / 2.0) + 0.5) / num;
		}

		System.out.println(ans);

	}

}

Measured memory_bytes: 21844
#include<stdio.h>
int main(void)
{
	int n,flg,i,a;
	char s[101];
	scanf("%d %s",&n,s);
	flg=0;
	if(n%2==0){
		a=n/2;
		for(i=0;i<a;i++){
			if(s[i]!=s[i+a]){
				break;
			}
			if(i==a-1){
				flg=1;
			}
		}
	}
	if(flg==0){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}


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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}
const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

ll d[200010];
ll MOD = 1e9+7;

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

	string s,t;
	cin>>s>>t;

	cout<<t+s<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF INT_MAX
#define ull unsigned long long
#define ll long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define sz size()
#define db double
#define pb push_back
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    int h[n+1];
    for(int i=1;i<=n;i++)
        cin >> h[i];
    vector<int> dp(n+1);
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        int ans=INF;
        for(int j=1;j<=k;j++)
        {
            if(j>=i)
                break;
            int cost=abs(h[i-j]-h[i]);
            ans=min(ans,dp[i-j]+cost);
        }
        dp[i]=ans;
    }
    cout << dp[n] << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }

typedef long long LL;

unordered_map<LL, LL> mp;
LL dp(LL x)
{
    if (x == 1) return 1;
    if (mp.find(x) != mp.end())
        return mp[x];
    else return mp[x] = 2LL * dp(x/2) + 1;
}

int main(int argc, char const *argv[])
{
    LL h; cin >> h;
    cout << dp(h) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int x = 1;
      while(true) {
          int A = (int)(x * 0.08 * 10) / 10;
          int B = (int)(x * 0.1 * 10) / 10;
        if(A == a && B == b) {
            System.out.println(x);
            return;
        }
        if(A > a && B > b)
            break;
        x++;
      }
      System.out.println(-1);
  }
}

Measured memory_bytes: 23380
s = input()
t = input()
lis = []
lit = []
anss = ""
anst = ""
n = len(s)
for i in range(n):
  if s[i] in lis:
    anss += str(lis.index(s[i]))
  else:
    lis.append(s[i])
    anss += str(lis.index(s[i]))
for i in range(n):
  if t[i] in lit:
    anst += str(lit.index(t[i]))
  else:
    lit.append(t[i])
    anst += str(lit.index(t[i]))
if anss == anst:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 4144
# -*- coding: utf-8 -*-
"""
Bitset I - Bit Mask
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_10_D&lang=jp

"""
class Bit:
    def __init__(self, masks = []):
        self.data = 0
        self.masks = masks

    def process(self, op, arg):
        funcs = (self.test, self.set, self.clear, self.flip, self.all, self.any, self.none, self.count, self.val)
        funcs[op](arg)

    def test(self, arg):
        print(int(bool(self.data & 1 << int(arg))))

    def set(self, arg):
        for m in self.masks[arg]:
            self.data |= 1 << int(m)

    def clear(self, arg):
        for m in self.masks[arg]:
            self.data &= ~(1 << int(m))

    def flip(self, arg):
        for m in self.masks[arg]:
            self.data ^= 1 << int(m)

    def all(self, arg):
        print(int(all([self.data & 1 << m for m in self.masks[arg]])))

    def any(self, arg):
        print(int(any([self.data & 1 << m for m in self.masks[arg]])))

    def none(self, arg):
        print(int(all([(self.data & 1 << m)==0 << m for m in self.masks[arg]])))

    def count(self, arg):
        print(len([True for m in self.masks[arg] if self.data & 1 << m]))

    def val(self, arg):
        print(sum(self.data & 1 << m for m in self.masks[arg]))


masks = []
for _ in range(int(input())):
    _, *m = input().split()
    m = [int(i) for i in m]
    masks.append(m)
b = Bit(masks)

for _ in range(int(input())):
    op, arg = map(int, input().split())
    b.process(op, arg)



Measured memory_bytes: 5660
#include<iostream>
#include<cstring>
using namespace std;
const int p = 1e9 + 7;
inline int mod(int x, int y)
{return x < y ? x : x-y;}
int d[15], f[15];
int main()
{
	string n;
	int len;
	cin >> n;
	len = n.size();
	for(int i = 0; i < 10; i++)
		d[i] = (n[len-1] == '?' || n[len-1]-'0' == i);
	for(int base = 10, tmp, i = len-2; i >= 0; i--, base = base * 10 % 13)
	{
		for(int j = 0; j < 13; j++)
			f[j] = 0;
		if(n[i] == '?')
		{
			for(int k = 0; k <= 9; k++)
			{
				tmp = base * k % 13;
				for(int j = 0; j < 13; j++)
					f[j] = mod(f[j]+d[mod(j-tmp+13,13)],p);
			}
		}
		else
		{
			tmp = base * (n[i] - '0') % 13;
			for(int j = 0; j < 13; j++)
				f[j] = d[mod(j-tmp+13,13)];
		}
		for(int j = 0; j < 13; j++)
			d[j] = f[j];
	}
	cout << d[5] << '\n';
	return 0;
} 

Measured memory_bytes: 512
input()
l = list(map(int,input().split()))
tomato = sum(l)
s = 0
m = 1000000000000
for i in range(len(l)-1):
    s += l[i]
    if(m > abs(s-(tomato-s))):
        m = abs(s-(tomato-s))
print(m)

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

int main() {
	int N,ans = 0;
	cin >> N;
	vector<int>data_seiretu(N);
    vector<int>data(N);
	rep(i,N){
		cin >> data_seiretu.at(i);
        data.at(i) = data_seiretu.at(i);
	}
    sort(data_seiretu.begin(),data_seiretu.end());
    int data_max = data_seiretu.at(N-1);
    int data_second = data_seiretu.at(N-2);
    
    rep(i,N){
        if(data.at(i) == data_max){
            cout << data_second << endl;
        }else{
            cout << data_max << endl;
        }
    }
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  int sum = 0;
  rep(i, 0, s.size()) {
    if (s[i] == s[i + 1]) ++sum;
  }

  cout << min(n - 1, 2 * k + sum) << '\n';
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
string vowel = "aiueo";
int main() {
  char a;
  cin >> a;
  for(int i = 0; i < vowel.size(); i++) {
    if(a == vowel[i]) {
      cout << "vowel" << endl;
      return 0;
    }
  }
  cout << "consonant" << endl;
  
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[105]; 
int main()
{
   int n;cin>>n;double p=0.0;
   for(int i=1;i<=n;i++)
   {
   		cin>>a[i];
   		p=p+((double)1.0/a[i]);
   }
   p=(double)1.0/p;
   printf("%.8lf",p);
}

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

int main(){
  vector<vector<int>> a(3, vector<int>(3));
  vector<vector<int>> r(3, vector<int>(3, 0));
  rep(i, 3) rep(j, 3) cin>> a[i][j];
  
  int n;
  cin >> n;
  
  int b;
  rep(i, n){
    cin >> b;
    rep(j, 3) rep(k, 3) if(a[j][k]==b) r[j][k]=1;
  }
  
  rep(i, 3) {
    if((r[i][0] && r[i][1] && r[i][2]) ||
       (r[0][i] && r[1][i] && r[2][i]) ||
       (r[0][0] && r[1][1] && r[2][2]) ||
       (r[0][2] && r[1][1] && r[2][0])){
      cout << "Yes" << endl;
      return 0;
    }
  }

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


Measured memory_bytes: 3608
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()

	cnt := map[int]int{}

	factorize := func(n int) {
		for i := 2; i*i <= n; i++ {
			for n%i == 0 {
				cnt[i]++
				n /= i
			}
		}

		if n!= 1 {
			cnt[n]++
		}
	}

	for i := 2; i <= n; i++ {
		factorize(i)
	}

	dp := make([][76]int, len(cnt)+1)
	dp[0][1] = 1
	// debug(dp[0])

	c := 0
	for _, e := range cnt {
		for i := 1; i < 76; i++ {
			for j := 1; j < e+2; j++ {
				if i*j > 75 {
					continue
				}
				dp[c+1][i*j] += dp[c][i]
			}
		}
		// debug(e,dp[c+1])
		c++
	}

	fmt.Fprintln(wr, dp[len(cnt)][75])
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<utility>
#include <numeric>
 
using namespace std;
typedef long long ll;
 
int main(){
ll a,b,c;
cin>>a>>b>>c;
if(a==b&&b==c)
cout<<"Yes";
else
cout<<"No";
  return 0;
 
}
 

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
//#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

const int MAX=110000;
vector<int> V[MAX*2];
bool visited[MAX*2];
int cnt[2];

void dfs(int x){
    if(visited[x]) return;
    visited[x]=true;
    cnt[x/MAX]++;
    for(int next:V[x]){
        dfs(next);
    }
}

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

    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        int x,y;
        cin>>x>>y;
        y+=MAX;
        V[x].push_back(y);
        V[y].push_back(x);
    }
    ll ans=0;
    for(int i=0;i<MAX*2;i++){
        if(visited[i]) continue;
        cnt[1]=0;cnt[0]=0;
        dfs(i);
        ans+=(ll)cnt[0]*cnt[1];
    }
    cout<<ans-N<<endl;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % 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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;

  vector<int> X(N);
  rep(i, N) cin >> X[i];

  ll ans = 1e9;
  
  for(int i = 0; i <= 101; i++){

    ll tmp_ans = 0;
    for(int j = 0; j < N; j++){

      tmp_ans += (i - X[j]) * (i - X[j]);

    }
    chmin(ans, tmp_ans);

  }


  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
# include <iostream>
using namespace std;
int n;
char a;
void work (void)
{
	int i,f;
	f=0;
	for (i=1;i<=n;i++)
	{
		cin>>a;
		if (a=='Y')
		{
			f=1;
			break;
		}
	}
	if (f==1)
	cout<<"Four";
else cout<<"Three";
}
int main (void)
{
	cin>>n;
	work ();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <stdint.h>

typedef signed char        int8;
typedef short              int16;
typedef int                int32;
typedef long long          int64;
typedef unsigned char      uint8;
typedef unsigned short     uint16;
typedef unsigned int       uint32;
typedef unsigned long long uint64;

int main(void) {
  uint64 h;
  std::cin >> h;

  uint64 dpth = 0;
  uint64 cnt = 0;
  while (true) {
    h = h / 2;
    cnt += uint64(1) << dpth;
    dpth++;
    if (h == 0) break;
  }
  std::cout << cnt << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int combina(int a) {
    for(int i=a-1; i>a-2; --i)
        a *= i;
    return (a/2);
}


int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    printf("%d\n", combina(n)+combina(m));
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
    int a, b, c, p;
    scanf("%d %d %d",&a,&b,&c);
    if(a > b){
        p = a;
        a = b;
        b = p;
    }
    if(b > c){
        p = b;
        b = c;
        c = p;
    }
    if(a > b){
        p = a;
        a = b;
        b = p;
    }
    
    printf("%d %d %d\n", a, b, c);
    
    return 0;
}


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

using namespace std;

long long a, b, c, k;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> a >> b >> c >> k;
    int Ans = 0;
    if (k <= a)
    {
        cout << k;
        return 0;
    }
    else 
    {
        Ans = a;
        k -= a;
    }
    if (k <= b)
    {
        cout << Ans;
        return 0;
    }
    else
    {
        k -= b;
    }
    Ans = Ans - min(k, c);
    cout << Ans;
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
    int n,d,x,i,j;
    int a[100];
    cin>>n;
    cin>>d>>x;
    for(i=0;i<n;i++)
        cin>>a[i];
    int s=n;
    for(i=0;i<n;i++)
        for(j=1;j*a[i]+1<=d;j++)
            s++;
    cout<<s+x;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1e9

using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;

int main(void){
  int H,W; cin>>H>>W;
  vector<vector<char>> VVC(H,vector<char>(W,0));
  VB tatecheck(H,false);
  VB yokocheck(W,false);

  rep(i ,H){
    rep(t ,W){
      cin>>VVC[i][t];
      if(VVC[i][t] == '#'){
        tatecheck[i] = true;
        yokocheck[t] = true;
      }
    }
  }

  rep(p,H ){
    rep(q ,W){
      if(tatecheck[p] && yokocheck[q]){
        cout<<VVC[p][q];
      }
    }
    if(tatecheck[p])cout<<endl;
  }
}


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

using namespace std;
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main()
{
    long N,K;
    std::cin >> N >> K;
    std::vector<long> A;
    for(long i=0; i<N; i++){
        long temp;
        std::cin >> temp;
        A.push_back(temp);
    }
    std::sort(A.begin(),A.end());
    long calctable[100000];
    calctable[0]=1;
    const int amari=1000000000+7;
    for(long i=1; i<=N-K; i++){
        calctable[i]=(calctable[i-1]*(K+i-1));
        calctable[i]=calctable[i]%amari;
        calctable[i]=calctable[i]*modinv(i,amari)%amari;
    }   
    
    long max_sum=0;
    long min_sum=0;
    for(long i=K-1; i<N;i++){
        max_sum+=calctable[i-(K-1)]*A[i];
        max_sum=max_sum%amari;
    }
    for(long i=0; i<=N-K; i++){
        min_sum+=calctable[N-K-i]*A[i];
        min_sum=min_sum%amari;
    }
    long result=max_sum-min_sum;
    if(result<0){
        result+=amari;
    }
    result=result%amari;
    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 1524
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            while(true){
                int n = sc.nextInt();
                int r = sc.nextInt();
                if(n == 0 && r == 0){
                    break;
                }
                int[] src = new int[n];
                int[] dest = new int[n];
                for(int i= 0; i < src.length; i++){
                    src[i] = src.length - i;
                }
                for(int i = 0; i < r; i++){
                    int p = sc.nextInt();
                    int c = sc.nextInt();
                    int j = 0;
                    for(; j < c; j++){
                        dest[j] = src[p - 1 + j];
                    }
                    for(; j < c + p - 1; j++){
                        dest[j] = src[j - c];
                    }
                    for(; j < src.length; j++){
                        dest[j] = src[j];
                    }
                    int[] tmp = src;
                    src = dest;
                    dest = tmp;
                }
                System.out.println(src[0]);
            }
        }
    }  
}


Measured memory_bytes: 36740
#include<stdio.h>

int main(void){
    int n;
    int i;
    int ans = 0;
    scanf("%d",&n);
    int p[n];
    for(i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    for(i=1;i<n-1;i++){
        if((p[i]-p[i-1])*(p[i]-p[i+1]) < 0){
            ans =  ans + 1;
        }
    }
    printf("%d\n",ans);
    return 0;
    
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int a,b,c,len;
int main()
{
    scanf("%d%d",&a,&b);
    c=b;
    while(c>0)
    {
        c/=10;
        len++;
    }
    a=a*pow(10,len)+b;
    if(sqrt(a)==floor(sqrt(a)))printf("Yes");
    else printf("No");
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t; cin >> s >> t;
    int a,b; cin >> a >> b;
    string u; cin >> u;
    if(s == u) cout << a-1 << " " << b;
    else cout << a << " " << b-1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    string s;
    cin >> s;
    if (s.length() < 26) {
        map<char,bool> m;
        for (int i = 0 ; i < s.length() ;i++) 
            m[s[i]] = true;
          
        for (int i = 0 ;i < 26 ;i++) {
            if (m[(char)('a'+ i)] == 0) {
                s += (char)('a' + i);
                break;
            }
        }
        cout << s << endl;
    } else {
        s += '0';
        if (next_permutation(s.begin(), s.end())) {
            for (int i = 0; s[i] != '0'; i++)
                cout << s[i];

            cout << endl;
        } else {
            cout << -1 << endl;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int n,m[1010],i,j,k,d[510][510]={};
  while(scanf("%d",&n),n){
    for(i=0;i<n;i++)scanf("%d",&m[i]);
    for(i=0;i<=n;i++){
      for(j=0;i+j<=n;j++){
	if(i<2)d[j][j+i]=0;
	else if(d[j+1][j+i-1]+2==i&&abs(m[j]-m[j+i-1])<2)d[j][j+i]=i;
	else{
d[j][j+i]=0;
	  for(k=j+1;k<i+j;k++)d[j][j+i]=MAX(d[j][j+i],d[j][k]+d[k][j+i]);
	}
      }
    }
    printf("%d\n",d[0][n]);
  }
  return 0;
}



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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> ii;

const int len = 2e5+5;
char str[len];
int ans = 0, col[len], vis[len][4];
vector<int> adj[len];

void dfs(int u, int t){
    vis[u][t] = 1;

    for (int j = 0; j < adj[u].size(); j++){
        int v = adj[u][j];
        if (t == 0 && !(col[u] == 0 && col[v] == 0))
            continue;
        if (t == 1 && !(col[u] == 0 && col[v] == 1))
            continue;
        if (t == 2 && !(col[u] == 1 && col[v] == 1))
            continue;
        if (t == 3 && !(col[u] == 1 && col[v] == 0))
            continue;

        if (vis[v][(t+1)%4] == 0)
            dfs(v, (t+1)%4);
        else if (vis[v][(t+1)%4] == 1)
            ans = 1;
    }

    vis[u][t] = 2;
}

int main(){
    int n, m;
    scanf("%d %d %s", &n, &m, &str);
    for (int i = 0; i < n; i++)
        col[i+1] = str[i]-'A';

    for (int i = 0; i < m; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        adj[a].pb(b);
        adj[b].pb(a);
    }

    for (int i = 1; i <= n; i++)
        for (int t = 0; t < 4; t++)
            vis[i][t] = 0;

    for (int i = 1; i <= n; i++)
        for (int t = 0; t < 4; t++)
            if (vis[i][t] == 0)
                dfs(i, t);

    if (ans)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 24832
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)

using namespace std;
typedef long long ll;
ll x[105],y[105];
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(d==1) cout<<"1\n";
    else cout<<"0\n";



}


Measured memory_bytes: 256
import std;

void main() {
    string s = read!string;
    writeln(s == "ABC" ? "ARC" : "ABC");
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


Measured memory_bytes: 3664
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

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

	REP(i, 1000000) {
		if((b*i+c)%a == 0) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256