akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
     
int a[1000];
     
int main()
{
    for(int i=1;i<1000;++i){
        a[i]=a[i-1]+i;
    }
    int x,y;
    cin>>x>>y;
    for(int i=1;i<=998;++i){
        if((a[i]-x) == (a[i+1]-y)){
            if(a[i]>=x){
                cout<<a[i]-x;
            }
        }
    }
    return 0;
}



/*#include<bits/stdc++.h>
#define fastread ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
#define pb push_back

vector<std::vector<int> > v;

int count;

bool vis[100005];

int dfs(int current,int parent){

	vis[current]=1;

	int ret=0;

	for(int i=0;i<v[current].size();++i){

		if(vis[v[current][i]])continue;

		int x=dfs(v[current][i],current);
		
		if(!x&1)count++;

		else{
			ret+=x;
		}		
	}
	ret++;
	return ret;
}

int main()
{
	fastread;
	int n;
	cin>>n;
	
	v.resize(n+1);

	for(int i=0;i<n-1;++i){
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}

	if(n&1)cout<<-1;
	else cout<<count;
	return 0;
}*/


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

double calc(long[] xs, long[] ys, int p) {
    int n = cast(int)xs.length;

    double s = iota(n).map!(e => abs(xs[e] - ys[e]) ^^ p).sum;
    return s ^^ (1.0 / p);
}

void main() {
    int n = readint;
    auto xs = reads!long;
    auto ys = reads!long;

    foreach (p; 1..4) {
        writefln("%.6f", calc(xs, ys, p));
    }

    auto c = iota(n).map!(e => abs(xs[e] - ys[e])).reduce!max;
    writeln(c);
}


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

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
vector<ll> p;
vector<ll> h;

ll f(int level, ll x)
{
    if(level==0) return 1;
    if(x==1) return 0;
    if(x>=2 && x <= h[level-1]+1) return f(level-1, x-1);
    if(x==h[level-1]+2) return p[level-1]+1;
    if(x>=h[level-1]+3 && x <= 2*h[level-1]+2) return f(level-1, x-h[level-1]-2)+p[level-1]+1;
    if(x>=2*h[level-1]+3) return 2*p[level-1]+1;
}

int main()
{
    int n;ll x;
    cin >> n >> x;
    p.resize(n+1);
    h.resize(n+1);
    h[0] = 1;
    p[0] = 1;
    for (int i = 1; i < n+1; i++)
    {
        p[i] = p[i-1]*2+1;
        h[i] = h[i-1]*2+3;
    }
    cout << f(n,x) << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.util.stream.*;

public class Main{
	private static BufferedReader in;
	private static BufferedWriter out;
	
	public static void main(String[] args) throws IOException {
		open();

		StringTokenizer st;
		StringBuilder sb;
		
		int L=readInt();
		System.out.format("%.12f", (double)L*L*L/27);
		
		close();
	}
	
	private static int[] readInts() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
	}

	private static int readInt() throws IOException {
		return Integer.parseInt(in.readLine());
	}

	private static long[] readLongs() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
	}

	private static long readLong() throws IOException {
		return Long.parseLong(in.readLine());
	}

	private static double[] readDoubles() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToDouble(Double::parseDouble).toArray();
	}

	private static double readDouble() throws IOException {
		return Double.parseDouble(in.readLine());
	}

	private static String readString() throws IOException {
		return in.readLine();
	}

	private static int setBit(int S, int j) {
		return S | (1 << j);
	}

	private static int isOn(int S, int j) {
		return S & (1 << j);
	}

	private static int clearBit(int S, int j) {
		return S & ~(1 << j);
	}

	private static int toggleBit(int S, int j) {
		return S ^ (1 << j);
	}

	private static int lowBit(int S) {
		return S & (-S);
	}

	private static int setAll(int n) {
		return (1 << n) - 1;
	}

	private static int modulo(int S, int N) {
		return ((S) & (N - 1));
	} // returns S % N, where N is a power of 2

	private static boolean isPowerOfTwo(int S) {
		return (S & (S - 1)) == 0 ? true : false;
	}

	private static int nearestPowerOfTwo(int S) {
		return ((int) Math.pow(2.0, (int) ((Math.log((double) S) / Math.log(2.0)) + 0.5)));
	}

	private static int turnOffLastBit(int S) {
		return ((S) & (S - 1));
	}

	private static int turnOnLastZero(int S) {
		return ((S) | (S + 1));
	}

	private static int turnOffLastConsecutiveBits(int S) {
		return ((S) & (S + 1));
	}

	private static int turnOnLastConsecutiveZeroes(int S) {
		return ((S) | (S - 1));
	}

	private static void open() {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new BufferedWriter(new OutputStreamWriter((System.out)));
	}

	private static void close() throws IOException {
		out.flush();
		out.close();
		in.close();
	}
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

void solve() {
    int n;
    cin >> n;
    vector<vector<int>> f(n, vector<int>(3));
    for (int i = 0; i < n; i++) {
        cin >> f[i][0];
        cin >> f[i][1];
        cin >> f[i][2];
    }

    vector<vector<int> > dp(n, vector<int>(3));

    dp[0][0] = f[0][0];
    dp[0][1] = f[0][1];
    dp[0][2] = f[0][2];
    for (int i = 1; i < n; i++) {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + f[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + f[i][1];
        dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + f[i][2];
    }

    cout << max(dp[n - 1][0], max(dp[n-1][1], dp[n-1][2]));
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

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

int main() {
    int n , rcnt = 0, bcnt = 0;
    string s;
    cin >> n >> s;

    for(int i = 0;i < s.size();i++){
        if(s[i] == 'R'){
            rcnt++;
        }
        if(s[i] == 'B'){
            bcnt++;
        }
    }

    if(bcnt >= rcnt){
        cout << "No";
    }
    else{
        cout << "Yes";
    }
    
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 200010
#define ll long long
const ll mod=1e9+7;

int n,k;
int a[55];
int main()
{
   scanf("%d%d",&n,&k);
   for(int i=1;i<=n;i++)
   {
       scanf("%d",&a[i]);
   }
   ll ans=0;
   for(int i=0;i<=min(k,n);i++)
   {
       for(int j=0;i+j<=min(k,n);j++)
       {
           priority_queue<int,vector<int>,greater<int> >q;
           ll sum=0;
           for(int x=1;x<=i;x++)q.push(a[x]),sum+=a[x];
           for(int y=1;y<=j;y++)q.push(a[n-y+1]),sum+=a[n-y+1];
            int c=k-i-j;
            while(c--)
            {
                if(q.empty())break;
                if(q.top()<0)sum-=q.top(),q.pop();
                else
                    break;
            }
            ans=max(ans,sum);
       }
   }
   cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast            ios_base::sync_with_stdio(false)
#define mems(x, y)      memset(x, y, sizeof x)
#define pii             pair < int, int >
#define prec(x)         << fixed << setprecision(x)
#define itf             it->first
#define its             it->second
#define it(x)           it = x.begin(); it != x.end(); it++
#define pq_max(x)       priority_queue < x >
#define pq_min(x)       priority_queue < x, vector < x >, greater < x > >
#define ll              long long
#define nl              << "\n"
#define spc             << " "
#define pb              push_back
#define inf             0x3f3f3f3f
#define PI              3.14159265358979323846
#define E               2.71828182845904523536
#define gamma           0.5772156649
#define EPS             1e-9
#define toint(st, x)    stringstream ss(st); ss >> x
// =======Debug========//
#define watch(x)        cout << (#x) spc << x nl
//int fx[] = {1, -1, 0, 0};
//int fy[] = {0, 0, 1, -1};
const int mod=1e9+7;
const int mxn=1e5+4;
ll arr[mxn][4];
ll dp[mxn][4];
bool vis[mxn][4];
int n;
ll func(int i, int type)
{
    if(i >= n)      return 0;
    if(vis[i][type])    return dp[i][type];
    vis[i][type] = 1;
    ll t = 0;
    for(int j = 0; j < 3; j++) {
        if(type != j)  t = max(t, arr[i][type] + func(i + 1, j));
    }
    return dp[i][type] = t;
}
int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < 3; j++)
            cin >> arr[i][j];

    ll ans = 0;
    for(int i = 0; i < 3; i++)  {
        ans = max(ans, func(0, i));
    }

    cout << ans nl;
    return 0;
}



Measured memory_bytes: 14720
#include <iostream>
#include <algorithm>

int main() {
    using namespace std;

    int N, X;
    cin >> N >> X;

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

    int sum = 0;
    for (size_t i = 0; i < N; i++) {
        sum += m[i];
    }

    int *mx = std::min_element(m, m + N);
    
    int n = N;
    int r = X - sum;
    r -= *mx;
    while (0 <= r) {
        n++;
        r -= *mx;
    }

    cout << n << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;

bool check(P a, P b) {
    return a.fi < b.fi;
}

signed main() {
    int N;
    cin >> N;
    V(P) red(N), blue(N);
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        red[i] = P(a, b);
    }
    rep(i, N) {
        int c, d;
        cin >> c >> d;
        blue[i] = P(c, d);
    }
    sort(ALL(red), check); sort(ALL(blue), check);
    vi done(N, 0);
  
    int res = 0;    
    rep(i, N) {
        int mi = 0;
        rep(j, N) {
            if(blue[i].fi>red[j].fi && blue[i].se>red[j].se && !done[j]) {
                if(blue[i].fi>red[mi].fi && blue[i].se>red[mi].se && !done[mi]){
                    if(red[j].se > red[mi].se) mi = j;
                } else mi = j;
            }
        }
        if(blue[i].fi>red[mi].fi && blue[i].se>red[mi].se && !done[mi]) {
            res++;
            done[mi] = 1;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  int n;cin>>n;
  cout<<8-int((n-400)/200)<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a, k;
    cin >> n >> k;
    vector<lli> v;
    for (lli i = 0; i < n; i++) {
        cin >> a;
        v.pb(a);
    }

    lli ptr = 0;
    for (lli i = k; i < n; i++) {
        if (v[i] <= v[ptr]) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
        ptr++;
    }
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 5328
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
ll C[100005]={};
int n,m;
vector<int> v[100005];
int a[100001],b[100001];
int main() {
	int n;
	priority_queue<ll,vector<ll> > que;
	cin>>n;
	rep(i,0,n)cin>>a[i];
	ll t=0;
	ll ans=0;
	rep(i,0,n){
		cin>>b[i];
		if(b[i]>a[i]){
			t+=b[i]-a[i];
			ans++;
		}
		if(b[i]<a[i])que.push(a[i]-b[i]);
	}
	while(1){
		if(t<=0||que.empty())break;
		ll f=que.top();que.pop();
		t-=f;
		ans++;
	}
	if(t>0)ans=-1;
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  int N,A[210],i,count=0,bin;

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

  while(1){
    for(i=0; i < N; i++) {
      if (A[i] % 2 != 0) bin++;
    }

    if(bin > 0) break;

    for (i=0; i < N; i++) A[i]/=2;

    count++;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;

void solve() {
	int n; cin >> n;
	vector<long long int> a(n);
	vector<long long int> b(n);
	vector<long long int> 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];
	int j = 0;
	vector<long long int> s(n + 2, 0);
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	for (int i = 0; i < n; ++i) {
		while (j < n && b[i] >= c[j]) j++;
		s[i] = n - j;
	}
	long long int ans = 0;
	for (int i = n; i > -1; --i) {
		s[i] += s[i + 1];
	}
	for (int i = 0; i < n; ++i) {
		ans += s[upper_bound(b.begin(), b.end(), a[i]) - b.begin()];
	}
	cout << ans << endl;
	return;
}

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

Measured memory_bytes: 3328
let s = read_line ()
let f g s = let n = ref 0 in String.iter (fun c -> if g c then incr n) s; !n
let _ = print_endline @@ if s.[0] = 'A' && String.(f ((=) 'C') @@ sub s 2 (length s - 3)) = 1 && f (fun c -> Char.uppercase c = c) s = 2 then "AC" else "WA"

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 2e18;

signed main() {
    string S;
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#!/usr/bin/env python3

N = int(input())
K = int(input())

x = list(map(int,input().split(" ")))

ans = 0
for i in range(N):
    if x[i]  <  K - x[i]:
        ans += x[i]*2
    else:
        ans += (K-x[i])*2
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int maxn=(1<<21);
const int mod=1e9+7;
long long int dp[22][maxn];
bool pd[21][21];
int n;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
     cin>>n;
     for(int i=0;i<n;i++){
     	for(int j=0;j<n;j++){
     		cin>>pd[i][j];
		 }
	 }
	 dp[0][0]=1;
	 for(int mask=1;mask<(1<<n);mask++){
	 	for(int j=0;j<n;j++){
	 		if(((1<<j)&mask)!=0&&pd[__builtin_popcount(mask)-1][j]==1){
	 			dp[__builtin_popcount(mask)][mask]+=dp[__builtin_popcount(mask)-1][(1<<j)^mask];
	 			dp[__builtin_popcount(mask)][mask]%=mod;
			 }
		 }
	 }
	 cout<<dp[n][(1<<n)-1];
}

Measured memory_bytes: 309504
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_PRM_MAX		100										// 最大素数数

// 内部構造体 - 素数情報
typedef struct Prm {
	long long mlVal;											// 値
	int miCnt;													// 個数
} Prm;

// 内部変数
static FILE *szpFpI;											// 入力
static Prm sz1Prm[D_PRM_MAX];									// 素数
static int siPCnt;												// 素数数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 素因数分解
int
fDivPrm(
	long long plVal				// <I> 対象値
)
{
	int i;

	// 初期化
	memset(sz1Prm, 0, sizeof(sz1Prm));
	siPCnt = 0;

	// 上限
	int liLimit = (int)sqrt((double)plVal);

	// 素因数分解
	for (i = 2; i <= liLimit; i++) {

		// 分解終了
		if (plVal == 1) {
			break;
		}

		// 分解
		while (plVal % (long long)i == 0) {
			plVal /= i;
			sz1Prm[siPCnt].miCnt++;
		}

		// 分解あり
		if (sz1Prm[siPCnt].miCnt > 0) {
			sz1Prm[siPCnt].mlVal = i;
			siPCnt++;
		}
	}

	// 上限を超える素数
	if (plVal != 1) {
		sz1Prm[siPCnt].miCnt = 1;
		sz1Prm[siPCnt].mlVal = plVal;
		siPCnt++;
	}

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i, j;
	char lc1Buf[1024];

	// データ - 初期化

	// 値 - 取得
	long long llVal;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%lld", &llVal);

	// 素因数分解
	fDivPrm(llVal);

	// 回数 - 取得
	int liCnt = 0;
	for (i = 0; i < siPCnt; i++) {
		for (j = 1; ; j++) {
			if (sz1Prm[i].miCnt < j) {
				break;
			}
			else {
				sz1Prm[i].miCnt -= j;
				liCnt++;
			}
		}
	}

	return liCnt;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 2005
typedef long double ldouble;

double eps=1e-10;
bool eq(double a,double b){
  return (-eps<a-b&&a-b<eps);
}

int divi(int a,int b){ return (a+b-1)/b; }
 
int n,m;
int a[MAX_N],b[MAX_N],c[MAX_N];
map<int,ldouble> ma,mb,mc;
 
ldouble z[MAX_N];
 
 
ldouble dp[MAX_N][4];
 
ldouble func(int a[MAX_N],map<int,ldouble> &ma,int cnt,ldouble val){
  if(ma.count(cnt))return ma[cnt];
   
  fill( dp[0], dp[MAX_N] , 0.0 );
  dp[1][0]=1;
 
  ldouble w=1.0;
  for(int i=1;i<n;i++){
    int x=divi(a[0]*cnt,a[i]);
     
    ldouble p=(x<=m?z[x]:0.0);
    ldouble q=1.0-p;
    w*=p;
    for(int j=0;j<3;j++){
      if( eq(dp[i][j],0) )continue;
      
      if(!eq(p,0))dp[i+1][j+1]+=dp[i][j]*p;
      if(!eq(q,0))dp[i+1][j]+=dp[i][j]*q;
    }
  }
  ldouble res=(dp[n][0]+dp[n][1]+dp[n][2])*val-w;
  return ma[cnt]=res;  
}
 
ldouble nCr(int n,int r){
  ldouble res=1.0;
  for(int i=0;i<r;i++){
    res/=(ldouble)(i+1);
    res*=(ldouble)(n-i);
  }
  return res;
}
 
int main(){
  scanf("%d %d",&n,&m);
  for(int i=0;i<n;i++){
    scanf("%d %d %d",&a[i],&b[i],&c[i]);
  }
 
  for(int i=0;i<=m;i++){
    z[i]=nCr(m,i);
    for(int j=0;j<i;j++)
      z[i]/=3.0;

    for(int j=0;j<m-i;j++)
      z[i]/=3.0;

    for(int j=0;j<m-i;j++)
      z[i]*=2.0;

  }
  for(int i=m-1;i>=0;i--)z[i]+=z[i+1];
 
  ldouble ans=-1e30;
  for(int i=0;i<=m;i++){
    for(int j=0;j<=m-i;j++){
      int k=m-i-j;
 
      ldouble va=func(a,ma,i,5);
      ldouble vb=func(b,mb,j,3);
      ldouble vc=func(c,mc,k,2);
      ldouble v=va+vb+vc;
 
      ans=max(ans, v);
    }
  }
 
  printf("%.16f\n",(double)ans);
  return 0;
}

Measured memory_bytes: 1872
#3.3

N = int(input())
a = list(map(int, input().split()))

flag = 1
swapcount = 0
while flag == 1:
    flag = 0
    for i in range(0, N-1):
        if a[i] > a[i + 1]:
            tmp = a[i];
            a[i] = a[i + 1]
            a[i + 1] = tmp
            flag = 1
            swapcount += 1

print(' '.join(map(str, a)))
print(swapcount)


            

Measured memory_bytes: 7640
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> H >> W;
	vector<string>r(H);
	vector<string>c(W);
	for (int i = 0; i < H; i++) {
		cin >> r[i];
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			c[j].push_back(r[i][j]);
		}
	}
	for (int i = 0; i < H; i++) {
		sort(r[i].begin(), r[i].end());
	}
	for (int i = 0; i < W; i++) {
		sort(c[i].begin(), c[i].end());
	}

	int rood = 0;
	vector<int>ro(13);
	for (int i = 0; i < H; i++) {
		int cnt = 0;
		for (int j = 0; j < H; j++) {
			if (r[i] == r[j]) {
				cnt++;
			}
		}
		ro[cnt]++;
	}
	int cood = 0;
	vector<int>co(13);
	for (int i = 0; i < W; i++) {
		int cnt = 0;
		for (int j = 0; j < W; j++) {
			if (c[i] == c[j]) {
				cnt++;
			}
		}
		co[cnt]++;
	}
	for (int i = 1; i <= 11; i += 2) {
		rood += ro[i] / i;
	}
	for (int i = 1; i <= 11; i += 2) {
		cood += co[i] / i;
	}
	if ((H & 1) < rood || (W & 1) < cood) {
		cout << "NO\n";
		return 0;
	}
	if ((!(H & 1) && rood) || (!(W & 1) && cood)) {
		cout << "NO\n";
		return 0;
	}
	if (H >= 7 && H < 9 && W >= 7 && W < 9 && ro[H] && co[W]) {
		cout << "NO\n";
		return 0;
	}
	cout << "YES\n";
	return 0;
}


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

int main()
{

        int N;
        cin >> N;
        int x[N];
        for (int i = 0; i < N; ++i) {
                cin >> x[i];
        }
        long long cost = 0;
        long long min = -1;
        for (int i = -100; i <= 100; ++i) {

                cost = 0;
                int y = i;
                for (int j = 0; j < N; ++j) {

                        if (x[j] == y) continue;

                        cost += (x[j] - y) * (x[j] - y);
                }

                if (min == -1) {
                        min = cost;
                }
                else {
                        if (min > cost) {
                                min = cost;
                        }
                }
        }
        cout << min << endl;

}


Measured memory_bytes: 256
import numpy as np

n = int(input())
list_a = list(map(int, input().split()))

counts = np.zeros(100000, dtype=int)

ans = 0

for i in range(len(list_a)):
    counts[list_a[i]-1] += 1
    ans += list_a[i]

q = int(input())

for i in range(q):
    b, c = map(int, input().split())

    ans += counts[b-1] * (c - b)

    counts[c-1] += counts[b-1]
    counts[b-1] = 0

    print(ans)


Measured memory_bytes: 38580
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<MOD>;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<int> A(N),B(M);
    rep(i,N) cin >> A[i];
    rep(i,M) cin >> B[i];

    sort(all(A)); reverse(all(A));
    sort(all(B)); reverse(all(B));

    int r = 0, c = 0;
    mint ans = 1;
    for (int i = N*M; i > 0; i--) {
        if (r < N && c < M && A[r] == i && B[c] == i) {
            r++;
            c++;
        } else if (r < N && A[r] == i) {
            ans *= c;
            r++;
        } else if (c < M && B[c] == i) {
            ans *= r;
            c++;
        } else ans *= (r*c - (N*M-i));
    }

    cout << ans.a << endl;
}

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

struct process
{
    char name[10];
    int time;
};

struct queue
{
    const int max_index = 100005;
    int front, end, quantum;
    process* P;
    
    queue(int n) : front(0), end(n)
    {
        P = new process[max_index];
        for(int i=0;i<n;++i)
        {
            cin >> P[i].name >> P[i].time;
        }
    }

    void push(process p)
    {
        // if(end >= max_index) end = 0;
        end %= max_index;
        P[end++] = p;
    }

    process pop()
    {
        if(front == end) return process();
        process p = P[front++];
        // if(front == max_index) front = 0;
        front %= max_index;
        return p;
    }

    bool empty()
    {
        return front == end;
    }
};

int main()
{
    int n, quantum;
    cin >> n >> quantum;
    queue Q(n);
    int time = 0;
    while(!Q.empty())
    {
        process p = Q.pop();
        p.time -= quantum;
        if(p.time > 0)
        {
            Q.push(p);
            time += quantum;
        }
        else{
            time += (quantum + p.time);
            cout << p.name << " " << time << endl;
        }
    }
}



Measured memory_bytes: 4608
$d = [[[-1, -1], [0, -1], [1, -1], [1, 0], [0, 1], [-1, 0]],
      [ [-1, 0], [0, -1],  [1, 0], [1, 1], [0, 1], [-1, 1]]]
     
def bfs(fld, w, h)
  ok = Array.new(h+2){Array.new(w+2,false)}
  (1..h).each do |i|
    (1..w).each do |j|
      if !fld[i][j] && !ok[i][j]
        flag = true
        v = Array.new(h+2){Array.new(w+2,false)}
        arr = []
        arr << [i, j]
        until arr.empty?
          y, x = arr.shift
          v[y][x] = true
          if y <= 0 || y > h || x <= 0 || x > w
            flag = false
            break
          end
          $d[y%2].each do |dy, dx|
            if !fld[dy+y][dx+x] && !v[dy+y][dx+x] && !arr.include?([dy+y, dx+x]) then arr << [dy+y, dx+x]
            end
          end
        end
        if flag
          h.times do |k|
            w.times do |m|
              fld[k][m] = true if v[k][m]
            end
          end
        else
          h.times do |k|
            w.times do |m|
              ok[k][m] = true if v[k][m]
            end
          end          
        end
      end
    end
  end
  fld
end

w, h = gets.split.map(&:to_i)
fld = Array.new(h+2)
(1..h).each{ |i| fld[i] = gets.split(" ") }
(1..h).map{ |i| (0...w).map{ |j| fld[i][j] = fld[i][j] == "1" ? true : false } }
fld[1,h].each{ |arr| arr.unshift(false); arr << false }
fld[0] = [false]*(w+2); fld[h+1] = [false]*(w+2)
fld = bfs(fld, w, h)
sum = 0
(1..h).each do |i|
  (1..w).each do |j|
    if fld[i][j]
      $d[i%2].each do |y, x|
        sum += 1 if !fld[i+y][j+x]
      end
    end
  end
end
p sum

Measured memory_bytes: 21280
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long S, long long W){
  if(S <= W)
    std::cout << "unsafe" << std::endl;
  else
    std::cout << "safe" << std::endl;
}

int main(){
  long long S;
  scanf("%lld",&S);
  long long W;
  scanf("%lld",&W);
  solve(S, W);
  return 0;
}



Measured memory_bytes: 3200
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    int N;
    map<int, int> M;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int x;
        cin >> x;
        ++M[x];
    }

    int ans = 0;
    for (auto p : M) {
        int x = p.first;
        int c = p.second;

        int d = c;
        if (c >= x)
            d = min(d, c - x);
        ans += d;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4736
#include<stdio.h>

typedef struct{
	int a;
	int b;
} DrawingLots;

int main(){
	int w,n,i,j;
	int now;
	int answer[31];
	DrawingLots q[31];
	scanf("%d%d",&w,&n);
	for(i=0;i<n;i++){
		scanf("%d,%d",&q[i].a,&q[i].b);
	}
	for(i=1;i<=w;i++){
		now=i;
		for(j=1;j<=n;j++){
			if(q[j-1].a==now){
				now=q[j-1].b;
			}else if(q[j-1].b==now){
				now=q[j-1].a;
			}
		}
		answer[now]=i;
	}
	for(i=1;i<=w;i++) printf("%d\n",answer[i]);
	return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n;
  cin>>n;
  vector<string> s(n);
  rep(i,n) cin>>s[i];

  rep(i,n) sort( begin(s[i]),end(s[i]) );

  sort( begin(s),end(s) );

  //rep(i,n) cout << s[i] << endl;

  map<string,ll> m;

  rep(i,n) m[ s[i] ]++;

  ll ans=0;

  for(auto x:m) ans+= x.second*(x.second-1LL)/2;

  cout << ans << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

Measured memory_bytes: 13568
import java.util.Scanner

fun main(args: Array<String>) {
  val cin = Scanner(System.`in`)
  val d = cin.nextDouble()
  val n = cin.nextInt()

  var res = 0
  for (i in 0 until n) {
    res += Math.pow(100.0, d).toInt()
    if (res % (Math.pow(100.0, d + 1.0).toInt()) == 0) {
      res += Math.pow(100.0, d).toInt()
    }
  }

  println(res)

  cin.close()
}

Measured memory_bytes: 31268
A, B = list(map(int, input().split()))

# (a-k)2 = (b-k)2
# a2 -2ak +k2 = b2 -2bk +k2
# a2 -2ak = b2 -2bk
# a2-b2 = 2ak-2bk
# (a+b)(a-b)=2(a-b)k
# (a+b)=2k

if ((A + B) % 2) == 1:
	print("IMPOSSIBLE")
	exit(0)

K = (A + B)//2

print(K)

Measured memory_bytes: 2940
n,k=map(int,input().split())

ans=[0]*n

for i in range(k):
  d=int(input())
  a=[int(k) - 1 for k in input().split()]
  for j in a:
    ans[j]+=1

ansint=0


for i in range(n):
  if ans[i]==0:
    ansint+=1


print(ansint)


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

int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  if (a1 + a2 + a3 > 21){
    cout << "bust" << endl;
  }
  else {
    cout << "win" << endl;
  }
}


Measured memory_bytes: 256
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<numeric>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int p,q;
  cin>>p>>q;
  printf("%.5f\n",p*q/3.305785);
  return 0;
}

Measured memory_bytes: 1192
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
for line in stdin:
    n = int(line)
    cnt = 0
    for a in xrange(10):
        if n < a:
            break
        for ab in xrange(a, a + 10):
            if n < ab:
                break
            for abc in xrange(ab, ab + 10):
                if n < abc:
                    break
                for abcd in xrange(abc, abc + 10):
                    if n == abcd:
                        cnt += 1
                        break
                    if n < abcd:
                        break
    print(cnt)

Measured memory_bytes: 4232
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
#define N 203
 
main(){
  int i,j,k,l,q,n,huyou;
  int A[N],m[N][N];
 
  scanf("%d",&n);
 
  for(i=1;i<n;i++){
	scanf("%d%d",&A[i],&huyou);
  }
  scanf("%d%d",&A[i],&A[i+1]);

  for(i=1;i<=n;i++){
	m[i][i]=0;
  }

  for(l=2;l<=n+1;l++){
    for(i=1;i<=n-l+2;i++){
      j=i+l-1;
      m[i][j]=INT_MAX;
      for(k=i;k<=j-1;k++){
    q=m[i][k]+m[k+1][j]+A[i-1]*A[k]*A[j];
    m[i][j]=(m[i][j]<q ? m[i][j]:q);
      }
    }
  }
  printf("%d\n",m[i][j]);
 
  return 0;
}

Measured memory_bytes: 680
#include<iostream>
using namespace std;
int main(){
  int n;
  while(cin >> n){
    int math[100000]={0};
    math[1]=1;
    for(int i=2;i<100000;i++){
      int bell=i;
      while(bell+i<=100000){
	bell+=i;
	if(math[bell]==0){
	  math[bell]=1;
	}
      }
    }
    
    int hess=n;
    while(1){
      hess--;
      if(math[hess]==0){
	cout << hess << " ";
	break;
      }
    }
    
    hess=n;
    while(1){
      hess++;
      if(math[hess]==0){
	cout << hess << endl;
	break;
      }
    }
  }
    
  return (0);
}

Measured memory_bytes: 1556
import java.util.Scanner;


public class Main {

    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String  s = sc.next();
        String  t = sc.next();
        String ans = t.substring(0, s.length());
        sc.close();
        if(s.equals(ans)){
            System.out.println("Yes"); 
        }else{
            System.out.println("No"); 
        }
    }
}

Measured memory_bytes: 35808
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        long a[] = new long[n];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }

        long ans = 0;
        while (true) {
            long adivn[] = new long[n];
            for (int i = 0; i < n; i++) {
                adivn[i] = a[i] / n;
            }
            long sum = Arrays.stream(adivn).sum();
            ans += sum;
            if (sum == 0) {
                break;
            }

            for (int i = 0; i < n; i++) {
                a[i] = a[i] % n + sum - adivn[i];
            }
        }

        System.out.println(ans);
    }

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


Measured memory_bytes: 28752
N = gets.chomp.to_i

X_cand = (N / 1.08).floor
X_array = [X_cand-2, X_cand-1, X_cand, X_cand+1, X_cand+2]

answer = ":("
X_array.each do |x|
  if (x * 1.08).floor == N
    answer = x
    break
  end
end

puts answer

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
ll MOD = 1000000007;
const long long INF = 1LL << 60;
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

signed main()
{   
    gearup;
    int a,b; cin >> a >> b;
    cout << 6 -a -b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int64 MOD = 1000000007;

int main() {
    int N, K;
    cin >> N >> K;
    vector<vector<int>> G(N);
    rep(i, 0, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    function<int64(int, int)> dfs = [&](int cur, int pre) {
        int col = K - 1;
        if(pre != -1) col--;
        int64 res = 1;
        for(auto &to : G[cur]) {
            if(to == pre) continue;
            res = res * col % MOD;
            res = res * dfs(to, cur) % MOD;
            col--;
            if(col < 0) return 0LL;
        }
        return res;
    };
    cout << K * dfs(0, -1) % MOD << endl;
    return 0;
}


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

int main(){
	ll K, A, B;
	cin >> K >> A >> B;
	if(B - A <= 2){
		cout << 1+K << endl;
	}else{
		if(K <= A){
			cout << 1+K << endl;
		}else{
			if((K-A)%2 == 0){
				cout << ((K-A)/2)*(B-A) + A + 1 << endl;
			}else{
				cout << ((K-A+1)/2)*(B-A) + A << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define rep2(i,start,end) for(ll i = start; i < end; i++)
#define dwn(i,n) for(int i = n; i >= 0; i--)
#define dwn2(i,start,end) for(ll i = start; i >= end; i--)
#define pll pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define pdl pair<double, ll>
const ll N = 4e5 + 200;
const ll INF = 0x3f3f3f;
const ll mod = 1e9 + 7;
const double eps = 1e-7;


ll a[N],f[N];
ll n,k;
bool ok(ll x){
	ll cnt = 0;
	rep(i,n){
		ll tmp = x/f[i];
		cnt += max(0LL,a[i] - tmp);
		if(cnt > k) return 0;
	}
	return 1;
}

int main(){
	cin>>n>>k;
	rep(i,n){
		cin>>a[i];
	}
	rep(i,n){
		cin>>f[i];
	}
	sort(a,a+n,greater<ll>());
	sort(f,f+n);
	ll l = 0, r = 1e12+100;
	while(l < r){
		ll mid = (l+r) >> 1;
		if(ok(mid)){
			r = mid;
		}else{
			l = mid+1;
		}
//		cout<<mid<<endl;
	}
	cout<<l;
	return 0;
}






Measured memory_bytes: 5888
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

void insert(int);
void preorder(Node);
void inorder(Node);

#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

     while (x != NIL){
         y = x;
         if (z->key < x->key)
             x = x->left;
         else 
             x = x->right;
             z->parent = y;
}
    if (y == NIL)
        root = z;
    else if (z->key < y->key)
        y->left = z;
    else 
        y->right = z;

}

void inorder(Node u){
if (u == NIL) return;
inorder(u->left);
printf(" %d", u->key);
inorder(u->right);
}

void preorder(Node u){
    if(u == NIL) return;
    printf(" %d", u->key);
preorder(u->left);
preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
      scanf("%s", com);
      if(com[0] == 'i'){
          scanf("%d", &x);
      insert(x);
      }
      else if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
}
}
  return 0;
}



Measured memory_bytes: 25172
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
if len(c) == 3:
    l = list(c.keys())
    v = list(c.values())
    if l[0]^l[1]^l[2] == 0 and v[0]==v[1]==v[2]:
        print("Yes")
    else:
        print("No")
elif len(c) == 1:
    if list(c.keys())[0] == 0:
        print("Yes")
    else:
        print("No")
elif len(c) == 2:
    if (0 not in a):
        print("No")
    else:
        v = c[0]
        if len(a) == c[0]*3:
            print("Yes")
        else:
            print("No")
else:
    print("No")

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int main(){
    char t[] = {'a','e','i','u','o'};
    char c; cin >> c;

    rep(i,5){
        if(c==t[i]){
            puts("vowel");
            return 0;
        }
    }

    puts("consonant");
    return 0;
}

Measured memory_bytes: 3620
import java.io.*;

class Main {
	public static void main(String[] args) {
		try {
			
			BufferedReader br = new BufferedReader(new InputStreamReader(
					System.in));// ??\????????????????????????
			String line;

			// ????????????????????´?????????
			// String line; // ??\???????????????????????\???
			// while ((line = br.readLine()) != null) {
			// processLine(line);
			// }

			while ((line = br.readLine()) != null) {
				String[] fruit = line.split(" ");
				
				int first = Integer.valueOf(fruit[0]);
				int second = Integer.valueOf(fruit[1]);
				String printed = "";
				
				if(first == 0 && second == 0)
				{
					break;
				}
				
				if (first < second) {
					printed = first + " " + second;
				} else {
					printed = second + " " + first;
				}
				System.out.println(printed);
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	// private static void processLine(String line) {
	// System.out.println(line);
	// }
}

Measured memory_bytes: 27324
#include "bits/stdc++.h"
using namespace std;

#define rep(i,beg,end)   for (auto i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
#define rall(cont)           rbegin(cont), rend(cont)
using ll = long long;
using vi = vector<ll>;
const ll INFMAX = LLONG_MAX;
const ll INFMIN = LLONG_MIN;
const ll MOD = 1000000007;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	vector<string> r = { "Sunny", "Cloudy", "Rainy" };
	auto ite = find(all(r), s);
	if (++ite == end(r))
		ite = begin(r);
	cout << *ite << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n; cin >> n;
  VVll a(n, Vll(2));
  cin >> a;
  sort(all(a), [](auto const &x, auto const &y) {
    return x[0] + x[1] < y[0] + y[1];
  });

  Vll dp(n+1, INFll);
  dp[0] = 0;

  rep(i, n) drep(j, i+1)
    if (dp[j] <= a[i][0])
      chmin(dp[j+1], dp[j] + a[i][1]);

  ll ans = 0;
  rep(i, n+1) if (dp[i] < INFll) chmax(ans, i);

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


Measured memory_bytes: 512