akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
using namespace std ;
#define ld long double
#define int long long
#define _ ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL);
#define dbg(x) cerr << #x << " is " << x << endl;
#define F(i,b) for(int i = 0 ; i < (int)(b) ; i++)
#define RF(j,b) for(int j = (int)(b)-1 ; j >= 0 ; j--)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 2e5+7 ;
const int INF = 1e9 ;
const int MOD = INF + 7 ;
string s ;

void solve(){
	int n , l ;
	cin >> n >> l ;
	vi a(n+1) ;
	for(int i = 1 ; i <= n ; i++){
		a[i] = l + i - 1 ;
	}
	int sm = accumulate(all(a), 0) ;
	int dif = INF ;
	int ans ;
	for(int i = 1 ; i <= n ; i++){
		int cur = sm - a[i] ;
		if(dif > abs(sm - cur)){
			ans = a[i] ;
			dif = abs(sm- cur) ;
		}			
	}
	cout << sm - ans << endl ;
}

int32_t main(){_
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll H,W,M;
    string S;
    cin >> H >> W >> M;
    vector<ll> R(H), C(W);
    ll h,w;
    map<Pll,ll> mp;
    rep(i,M){
        cin >> h >> w;
        h--;w--;
        R[h]++;
        C[w]++;
        mp[Pll(h,w)]++;
    }
    ll a = -1;
    rep(i,H){
        if(a < R[i]){
            a = R[i];
        }
    }
    ll b = -1;
    rep(i,W){
        if(b < C[i]){
            b = C[i];
        }
    }
    vector<ll> v,u;
    rep(i,H){
        if(R[i] == a){
            v.push_back(i);
        }
    }
    rep(i,W){
        if(C[i] == b){
            u.push_back(i);
        }
    }
    ll aid = -1;
    ll bid = -1;
    for(auto&e:v){
        for(auto& ee:u){
            if(mp[Pll(e,ee)]==0){
                aid = e;
                bid = ee;
                goto gt;
            }
        }
    }
    gt:
    //cout << aid <<" " << bid << endl;
    ll t = 0;
    if(aid == -1 && bid == -1){
        t = 1;
    }
    cout << a + b - t << endl;
}

Measured memory_bytes: 35064
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b) * h / 2;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, n) for (ll i = (a); i < (n); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _per(i, n) peri(i, 0, n)
#define peri(i, a, n) for (ll i = (n) - 1; i >= (a); --i)
#define per(...) _overload3(__VA_ARGS__, peri, _per)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void chmax(T& a, const T& b) {if (a < b) a = b;}
template<typename T> inline void chmin(T& a, const T& b) {if (a > b) a = b;}
template<typename T> inline void print(const T& x) {cout << x << "\n";}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) {is >> p.fi >> p.se; return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {os << p.fi << " " << p.se; return os;}
template<typename T> istream& operator>>(istream& is, vector<T>& v) {each(in, v) is >> in; return is;}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {rep(i, sz(v)) {os << v[i] << (i + 1 != sz(v) ? " " : "");} return os;}
struct Init {Init() {ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(10);}} init;

map<ll, ll> primeFactorize(ll n) {
    map<ll, ll> prime_factors;
    ll m = n;
    rep(i, 2, sqrt(n) + 1) {
        if (m < 1) break;
        while (m % i == 0) {
            ++prime_factors[i];
            m /= i;
        }
    }
    if (m != 1) ++prime_factors[m];
    return prime_factors;
}

int main() {
    ll n; cin >> n;
    map<ll, ll> d = primeFactorize(n);
    ll ans = 0;
    each(p, d) {
        int i = 1;
        while (p.se >= i) {
            p.se -= i;
            i++;
            ans++; 
        }
    }
    print(ans);
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define M   1000000007 // 1e9 + 7
#define MAXN 200100
using namespace std;
typedef pair<int,int> pii;
const int inf = 1e18;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int fat[MAXN];
int inv[MAXN];

int C(int n,int k){
	return mod(fat[n]*mod(inv[k]*inv[n-k],M),M);
}

int32_t main(){
	fastio;
	fat[0] = inv[0] = 1;
	for(int i=1;i<MAXN;i++){
		fat[i] = (fat[i-1]*i)%M;
	}
	inv[MAXN-1] = exp(fat[MAXN-1],M-2,M);
	for(int i=MAXN-2;i>=1;i--){
		inv[i] = (inv[i+1]*(i+1))%M;
	}
	int n,k;
	cin>>n>>k;
	int res=1;
	for(int zer=1;zer<=min(n-1,k);zer++){
		res = mod(res + mod(C(n - zer - 1 + zer,n-zer - 1)*C(n,zer),M),M);
		// x1 + x2 + x3 ... + x(n-zer) = zer;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;

void dfs(vi e[], int c[], int x, int p[], int sz[], int csz[], int lc2[]) {
    sz[x] = csz[x] = 1;

    int cp = lc2[c[x]];

    for (int y : e[x]) {
        if (y != p[x]) {
            lc2[c[x]] = y;
            p[y] = x;
            dfs(e, c, y, p, sz, csz, lc2);
            sz[x] += sz[y];
            csz[x] += sz[y];
        }
    }

    csz[cp] -= sz[x];
    lc2[c[x]] = cp;
}

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

    int n;
    cin >> n;
    int c[2*n];
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        c[i]--;
    }
    vi e[n];
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        e[u].push_back(v);
        e[v].push_back(u);
    }

    int p[n];
    int lc2[n];
    int sz[n], csz[2*n];
    for (int i = 0; i < n; i++) {
        c[i+n] = i;
        csz[i+n] = n;
        lc2[i] = i + n;
    }
    p[0] = -1;
    dfs(e, c, 0, p, sz, csz, lc2);

    ll ans[n];
    fill(ans, ans+n, 1ll * n * (n + 1) / 2);
    for (int i = 1; i < n; i++) {
        ans[c[p[i]]] -= 1ll * csz[i] * (csz[i] + 1) / 2;
    }
    for (int i = n; i < 2 * n; i++) {
        ans[c[i]] -= 1ll * csz[i] * (csz[i] + 1) / 2;
    }

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

    return 0;
}


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


int main() {
    int N;
    cin >> N;

    int ai;
    int S[N];
    rep(i, N) S[i] = 0;

    rep(i, N-1) {
        cin >> ai;
        ai--;
        S[ai]++;
    }

    rep(i, N) cout << S[i] << endl;

    return 0;
}



Measured memory_bytes: 4404
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

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<typename T>
vector<T> enum_div(T n){
    vector<T> ret;
    for(T i=1;i*i<=n;i++){
        if(n%i==0){
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n/i);
        }
    }
    //sort(ret.begin(), ret.end());
    return ret;
}
template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}
template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int N;
int v[50];
int main(void){
    cin >> N;
    rep(i,N) cin >> v[i];
    sort(v,v+N);

    double s = 0.0;
    /*
    s = (v[0]+v[1])/2.0;
    for(int i=2;i<N;i++){
        s = (s + v[2])/2.0;
    }
    */
    rep(i,N){
        if(i==0 or i==1) s += v[i]/pow(2.0,N-1);
        else s += v[i]/pow(2.0,N-i);
    }
    printf("%.9f",s);

    return 0;
}



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

typedef double ld;

int main()
{
	ld N;
	cin >> N;
	for(ld i=1;i<=3500;i+=1)
	{
		for(ld j=1;j<=3500;j+=1)
		{
			if(4*i*j-N*j-N*i==0)
				continue;
			ld w=(N*i*j)/(4*i*j-N*j-N*i);
			if(w==(long long)w&&w>0)
			{
				printf("%.0lf %.0lf %.0lf\n",i,j,w);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
struct edge {int from, to, cost;};
const int INF = 1000000;

void warshall_floyd(std::vector< std::vector<int> > & array, int V) {
  for(int k=0;k<V;k++)
   for(int i=0;i<V;i++)
    for(int j=0;j<V;j++)
     array[i][j] = std::min(array[i][j], array[i][k]+array[k][j]);
}
int main() {
  while(true) {
    int n, m;
    cin >> n >> m;
    if(n==0 && m==0) break;
    vector< vector<int> > cost(m, vector<int>(m, INF));
    vector< vector<int> > time(m, vector<int>(m, INF));
    for(int i=0;i<m;i++) {
      cost[i][i] = 0;
      time[i][i] = 0;
    }

    for(int i=0;i<n;i++) {
      int ai, bi, ci, ti;
      cin >> ai >> bi >> ci >> ti;
      ai--; bi--;
      cost[ai][bi] = ci;
      cost[bi][ai] = ci;
      time[ai][bi] = ti;
      time[bi][ai] = ti;
    }
    warshall_floyd(cost, m);
    warshall_floyd(time, m);


    int k;
    cin >> k;
    for(int i=0;i<k;i++) {
      int pi, qi, ri;
      cin >> pi >> qi >> ri;
      pi--;qi--;
      if(ri)
        cout << time[pi][qi] << endl;
      else
        cout << cost[pi][qi] << endl;
    }
  }
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll H,W;
    cin >>H>>W;
    vector<string>C(H);
    rep(i,H){
        cin>>C[i];
    }

    rep(i,H){
        cout<<C[i]<<endl;
        cout<<C[i]<<endl;
    }



    return 0;
    

}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

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

  int A, B;
  cin >> A >> B;
  cout << (A+B)%24 << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if (A % 3 == 0 || B % 3 == 0
				|| (A + B) % 3 == 0) {
			System.out.println("Possible");
		} else {
			System.out.println("Impossible");
		}
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  set<int> r, g, b;
  long long ans = 0;
  for(int i=0;i<n;i++) {
    if(s[i] == 'R') r.emplace(i);
    else if(s[i] == 'G') g.emplace(i);
    else b.emplace(i);
  }
  for(auto it_1 = r.begin(); it_1 != r.end(); it_1++) {
    for(auto it_2 = g.begin(); it_2 != g.end(); it_2++) {
      int dist = abs(*it_1 - *it_2);
      int a = min(*it_1, *it_2)-dist;
      int aa = max(*it_1, *it_2)+dist;
      int aaa = (*it_1+*it_2)/2;
      int add = b.size();
      if(b.find(a) != b.end()) add--;
      if(b.find(aa) != b.end()) add--;
      if(dist % 2 == 0 && b.find(aaa) != b.end()) add--;
      ans += add;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3760
import math, itertools
K = int(input())
#K = 2

a = [i for i in range(1,K+1)]

x = itertools.combinations(a,2)
y = itertools.combinations(a,3)

c = 0
for i,j in x:
  c += math.gcd(i,j)

d = 0
for i,j,k in y:
  d += math.gcd( math.gcd(i,j) , k)

ans = sum(a) + c*6 + d*6

if K == 1:
  ans = 1
elif K == 2:
  ans = 9

print(ans)

Measured memory_bytes: 9236
#include <stdio.h>
int max(int a, int b){
	if(a>b){
		return a;
	}
	return b;
}
int min(int a, int b){
	return -max(-a,-b);
}
int main(){
	int W,H,N,x,y,a;
	int i;
	scanf("%d %d %d",&W,&H,&N);
	int xmin,xmax,ymin,ymax;
	xmin=0;
	xmax=W;
	ymin=0;
	ymax=H;
	for(i=1;i<=N;i++){
		scanf("%d %d %d",&x,&y,&a);
		if(a==1){
			xmin=max(xmin,x);
		}else if(a==2){
			xmax=min(xmax,x);
		}else if(a==3){
			ymin=max(ymin,y);
		}else{
			ymax=min(ymax,y);
		}
	}
	int ans;
	ans=max(0,xmax-xmin)*max(0,ymax-ymin);
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k)
{
	if (n < k)
		return 0;
	if (n < 0 || k < 0)
		return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod)
{
	long long res = 1;
	while (n > 0)
	{
		if (n & 1)
			res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
void solve()
{
	COMinit();
	int n,k;
	cin>>n>>k;
	int ma=min(k,n-1);
	//cout<<ma<<endl;
	ll ans=1;
	for(int i=ma; i>0; i--){
		ans+=COM(n,i)*COM(n-i-1+i,i)%M;
		ans%=M;
	}
	
	ans%=M;
	cout<<ans<<endl;


}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}


Measured memory_bytes: 12160
#include <iostream>

using namespace std;

int main()
{
    int n , k;
    string s;
    cin >> n >> k >> s;
    char a = s[k - 1];
    switch ((int)a){
        case 65:
            a = 'a';
            break;
        case 66:
            a = 'b';
            break;
        case 67:
            a = 'c';
            break;
    }
    for (int i = 0 ; i < n ; i++){
        if (i == k - 1){
            cout << a;
        }else{
            cout << s[i];
        }
    }
    return 0;
}


Measured memory_bytes: 3524
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

using namespace std;
int N;
vector<int> f(100001);
vector<int> s(100001);
set<int> graph[100001];

void bfsf(int i) {
  queue<int> que;
  f.at(i) = 0;
  que.push(i);
  while (!que.empty()) {
    int u = que.front(); que.pop();
    for (int v : graph[u]) {
      if (f.at(v) == -1) {
        f.at(v) = f.at(u) + 1;
        que.push(v);
        // cout << "f.at(" << v << "): " << f.at(v) << endl;
      }
    }
  }
}

void bfss(int i) {
  queue<int> que;
  s.at(i) = 0;
  que.push(i);
  while (!que.empty()) {
    int u = que.front(); que.pop();
    for (int v : graph[u]) {
      if (s.at(v) == -1) {
        s.at(v) = s.at(u) + 1;
        que.push(v);
        // cout << "s.at(" << v << "): " << s.at(v) << endl;
      }
    }
  }
}

int main() {
  cin >> N;
  if (N==2) {
    cout << "Snuke" << endl;
    return 0;
  }
  for (int i=0; i<N-1; i++) {
    int a, b;
    cin >> a >> b;
    graph[a].insert(b);
    graph[b].insert(a);
  }
  for (int i=1; i<=N; i++) {
    f.at(i) = -1;
    s.at(i) = -1;
  }
  bfsf(1);
  bfss(N);
  int dist = f.at(N);
  // cout << "dist: " << dist << endl;
  int u, v;
  u = dist/2;
  v = dist/2 + 1;
  int ui, vi;
  for (int i=1; i<=N; i++) {
    if (f.at(i) == u && s.at(i) == dist-u) {
      ui = i;
      // cout << "ui: " << ui << endl;
    }
    if (f.at(i) == v && s.at(i) == dist-v) {
      vi = i;
      // cout << "vi: " << vi << endl;
    }
  }
  // cout << "ui: " << ui << " vi: " << vi << endl;
  graph[ui].erase(vi);
  graph[vi].erase(ui);
  for (int i=1; i<=N; i++) {
    f.at(i) = -1;
  }
  bfsf(1);
  int sumf = 0;
  for (int i=1; i<=N; i++) {
    if (f.at(i) >= 0) {
      sumf++;
    }
  }
  cout << ((sumf > N-sumf) ? "Fennec" : "Snuke") << endl;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    cout << A.back()-A.front() << endl;
}

Measured memory_bytes: 256
l = list(input())

for i in range(1<<(len(l)-1)):
  s = l[0]
  for j in range(len(l)-1):
    if (i>>j) & 1:
      s += "+"
    else:
      s += "-"
    s += l[j+1]
  if eval(s) == 7:
    print(s+"=7")
    quit()

print("wrong input.")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
    long long x;
public:
    mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator^(const ll& t)const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream& operator<<(ostream& os, const mint& m) {
        os << m.x;
        return os;
    }
};

//////////////////////////
ll N;
vector<ll> A;
vector<vector<ll>> g;

ll dfs(ll u, ll v) {
    if (g[v].size() == 1&&v!=1) { return A[v]; }

    ll s = 0;
    vector<ll> vc;
    for (ll w : g[v]) {
        if (u == w) { continue; }
        ll x = dfs(v, w);
        if (x == -1) { return -1; }
        vc.push_back(x);
        s += x;
    }

    ll d = (s + 1) / 2;
    for (ll x : vc) {
        d = max(d, x);
    }

    if (A[v]<d || A[v]>s) { return -1;}

    ll ret=A[v] * 2 - s;
    return ret;
}

int main() {
    cin >> N;
    A.assign(N + 1, 0);
    repn(i, N) cin >> A[i];

    g.resize(N + 1);
    repn(i, N - 1) {
        ll a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    ll X = dfs(0, 1);
    if (g[1].size()!=1&&X==0) { cout << "YES"; }
    else if (g[1].size() == 1 && X == A[1]) { cout << "YES"; }
    else { cout << "NO"; }
    
	system("PAUSE");
}

Measured memory_bytes: 16116
#include<iostream>
#include<string>
using namespace std;
int main(){
  string S;
  cin >> S;
  if(S[0] == S[1] && S[1] == S[2]){
    cout << "Yes" << endl;
  }else if(S[1] == S[2] && S[2] == S[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = 0
r = 0
xum = 0
for l in range(n):
    while (r < n and (xum^a[r])==(xum+a[r])):
        xum += a[r]
        r +=1
    ans += r-l
    if l==r:
        r +=1
    else:
        xum -= a[l]
print(ans)

Measured memory_bytes: 77772
A, B, H, M = list(map(float, input().split()))

import math

v_h = (2*math.pi) / (12*60)
v_m = (2*math.pi) / 60

length = math.sqrt(A**2 + B**2 -2*A*B*math.cos(v_h*(H*60+M)-v_m*M))
print(length)

Measured memory_bytes: 9440
N = gets.to_i
i = 1
min_move = N - 1

loop do
  j = N / i
  if i * j == N
    move = (i - 1) + (j - 1)
    min_move = move if move < min_move
  end
  i += 1
  break if i * i > N
end

puts min_move


Measured memory_bytes: 1788
#include <iostream>

using namespace std;

int main()
{   int x,y;
    while (true){
        cin >> x >> y;
        if(x==0&&y==0)
        {
            break;
        }else if(y<x){
        cout << y <<" " << x << endl;
        }
        else{
            cout << x << " " << y << endl;
        }
            }
            return 0;
}



Measured memory_bytes: 3076
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
using namespace std;

#define PI 3.14159265358979323846264338327950L

void comb(int n, int k, int p, int q, vector<int> v, vector<vector<int>> &w, int *cnt) {
	if (n == p && k == q) *cnt = 0;
	if (w.size() == *cnt) w.resize(w.size() + 10000);
	if (q == 0) {
		w.at(*cnt) = v;
		*cnt += 1;
		return;
	}
	if (p == q) {
		w.at(*cnt) = v;
		for (int jj = n - p + 1; jj <= n; jj++) {
			w.at(*cnt).push_back(jj);
		}
		*cnt += 1;
		return;
	}
	comb(n, k, p - 1, q, v, w, cnt);
	v.push_back(n - p + 1);
	comb(n, k, p - 1, q - 1, v, w, cnt);
	return;
}

int main() {
	int N, M, Q;
	int l[50][4];

	cin >> N >> M >> Q;
	for (int ii = 0; ii < Q; ii++) {
		for (int jj = 0; jj < 4; jj++) {
			cin >> l[ii][jj];
		}
	}
	vector<int> v;
	vector<vector<int>> w(100, vector<int>());
	int cnt, sum = 0;
	comb(N + M - 1, N, N + M - 1, N, v, w, &cnt);
	for (int ii = 0; ii < cnt; ii++) {
		int tmp = 0;
		for (int jj = 0; jj < N; jj++) {
			w.at(ii).at(jj) -= jj;
		}
		for (int jj = 0; jj < Q; jj++) {
			if (w.at(ii).at(l[jj][1] - 1) - w.at(ii).at(l[jj][0] - 1) == l[jj][2]) {
				tmp += l[jj][3];
			}
		}
		if (tmp > sum) {
			sum = tmp;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 12004
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
int main(){
    int n,c1=0,c2=0,c3=0,c4=0,c5=0,c6=0,c7=0,c8=0,c9=0,mi=0,ma=0;
    cin>>n;
    int a;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a<400) c1++;
        else if(a<800) c2++;
        else if(a<1200) c3++;
        else if(a<1600) c4++;
        else if(a<2000) c5++;
        else if(a<2400) c6++;
        else if(a<2800) c7++;
        else if(a<3200) c8++;
        else c9++;
    }
    if(c1!=0)c1=1;
    if(c2!=0)c2=1;
    if(c3!=0)c3=1;
    if(c4!=0)c4=1;
    if(c5!=0)c5=1;
    if(c6!=0)c6=1;
    if(c7!=0)c7=1;
    if(c8!=0)c8=1;
    
    mi=c1+c2+c3+c4+c5+c6+c7+c8;
    ma=mi+c9;
    if(mi==0) mi=1;
    cout<<mi<<" "<<ma<<endl;
    return 0;
}

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

int main(){
  long long n,x,cnt=0;
  cin >> n >> x;
  long long a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n-1;i++){
  	if(a[i]+a[i+1]>x){
    	long long b = a[i]+a[i+1]-x;
    	cnt += b;
      if(a[i+1]-b>0) a[i+1] -= b; 
      else a[i+1] = 0;
  	}
  }
  cout << cnt << endl;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s;
    cin >> s;
    LL res = 0;
    for(int i = 0; i < s.size(); ++i) {
        res += s[i] - '0';
    }
    if(res % 9 == 0) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}



Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int N=S.size();
  int ans=1000;
  for(int i=0;i<N-2;i++){
    int xxx=(S.at(i)-'0')*100+(S.at(i+1)-'0')*10+(S.at(i+2)-'0');
    ans=min(ans,abs(753-xxx));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int x,n,a[101],i,j,k;
	scanf("%d %d",&n,&x);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	/*sort*/
	for(i=0;i<n;i++){
		for(j=i;j<n;j++){
			if(a[i]>a[j]){
				k=a[j];
				a[j]=a[i];
				a[i]=k;
			}
		}
	}
	
	for(i=0;i<n;i++){
		x-=a[i];
		if(x<0){
			printf("%d",i);
			return 0;
		}else if(x==0){
			printf("%d",++i);
			return 0;
		}
	}
	printf("%d",i-1);
	return 0;
}

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

using namespace std;

vector<int> dp;
vector<vector<int>> x;

int parent(int a)
{
    if(!x[a].size())
        return 0;
    if(dp[a])
        return dp[a];
    int ret=0;
    for(auto &i:x[a])
        ret=max(ret,parent(i));
    return dp[a]=ret+1;
}

int main()
{
    int m,n;
    scanf("%d%d",&m,&n);
    x.assign(m+1,vector<int>());
    dp.assign(m+1,0);
    while(n--)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        x[a].push_back(b);
    }
    int ans=0;
    for(int i=0;i<=m;++i)
        ans=max(ans,parent(i));
    printf("%d\n",ans);
}


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

void quicksort(int x[10],int first,int last){
    int pivot,j,temp,i;

     if(first<last){
         pivot=first;
         i=first;
         j=last;

         while(i<j){
             while(x[i]>=x[pivot]&&i<last)
                 i++;
             while(x[j]<x[pivot])
                 j--;
             if(i<j){
                 temp=x[i];
                  x[i]=x[j];
                  x[j]=temp;
             }
         }

         temp=x[pivot];
         x[pivot]=x[j];
         x[j]=temp;
         quicksort(x,first,j-1);
         quicksort(x,j+1,last);

    }
}
int main()
{
    int i;
    int a[15];
    for(i=0;i<10;i++)
        scanf("%d",&a[i]);
    quicksort(a,0,9);

    for(i=0;i<3;i++)
        printf("%d\n",a[i]);

    return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#include<array>
using namespace std;
using UL = unsigned;
using LL = long long;
using ULL = unsigned long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)
void Solve() {
	UL n; cin >> n;
	rep(i, n + 1) {
		if (n == i * 108 / 100) {
			cout << i << endl;
			return;
		}
	}
	cout << ":(" << endl;
}
int main() { Solve(); return 0; }


Measured memory_bytes: 256
using System;
using System.Text;

namespace Kznner
{
	class Program
	{
		static void Main()
		{
			int K = int.Parse(Console.ReadLine());
			string S = Console.ReadLine();
			
			if(S.Length <= K)
			{
				Console.WriteLine(S);
			}
			else
			{
				Console.WriteLine(S.Substring(0, K) + "...");
			}
		}
	}
}

Measured memory_bytes: 27540
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = a + b;
        if (c >= 24) c -= 24;
        System.out.println(c);
    }
}


Measured memory_bytes: 21844
function main(input) {
    var S = input.trim();
    var move = 1000000;
    var squares = new Array(S.length);
    squares.fill(0);
    var rightIndex = undefined;
    var leftIndex = undefined;
    for (var i = 0; S.length > i; i++) {
        var j = i;
        var count = 0;

        if (S[j] === "R") {
            if (typeof rightIndex !== "undefined" && j < rightIndex) {
                j = rightIndex;
                count = j - i;
            }
        } else {
            if (typeof leftIndex !== "undefined" && j > leftIndex) {
                j = leftIndex;
                count = i - j;
            }
        }

        while (S[j] + S[j+1] !== "RL") {
            if (S[j] === "R") {
                j++;
            } else {
                j--;
            }

            count++;
        }

        if (j >= i) rightIndex = j;
        if (i >= j) leftIndex = j;

        var point = (move - count) % 2 === 0 ? j : j + 1;
        squares[point] += 1;
    }

    console.log(squares.join(" "));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 15308
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process()throws IOException
    {
        int n=ni();
        double p[]=new double[n+1];
        for(int i=1;i<=n;i++)
            p[i]=nd();

        double dp[][]=new double[n+1][n+1];

        dp[1][0]=1.0d-p[1];        
        dp[1][1]=p[1];

        //states(i,j)--> at position i you've j heads

        for(int i=2;i<=n;i++){

            dp[i][0]=dp[i-1][0]*(1.0d-p[i]);
            
            for(int j=1;j<=i;j++){
                dp[i][j]=dp[i-1][j]*(1.0d-p[i]);
                dp[i][j]+=dp[i-1][j-1]*p[i]; 
            }
        }

        double res=0.0d;
        for(int i=n/2+1;i<=n;i++){
            res+=dp[n][i];
        }
        pn(res);
    }
 
 
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new FastReader();
 
        long s = System.currentTimeMillis();
        int t=1;
        //t=ni();
        while(t-->0)
            process();
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }
    
    
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static int ni()throws IOException{return Integer.parseInt(sc.next());}
    static long nl()throws IOException{return Long.parseLong(sc.next());}
    static double nd()throws IOException{return Double.parseDouble(sc.next());}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    
    static long mod=(long)1e9+7l;
 
    static<T> void r_sort(T arr[],int n){
        Random r = new Random(); 
        for (int i = n-1; i > 0; i--){ 
            int j = r.nextInt(i+1); 
                  
            T temp = arr[i]; 
            arr[i] = arr[j]; 
            arr[j] = temp; 
        } 
        Arrays.sort(arr); 
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 108676
#include <stdio.h>

int main(void)
{
	int c1, c5, c10, c50, c100, c500, a;
	
	scanf("%d" "%d" "%d" "%d" "%d" "%d",&c1, &c5, &c10, &c50, &c100, &c500);
	
	a = c1 + 5 * c5 + 10 * c10 + 50 * c50 + 100 * c100 + 500 * c500;
	
	if(a >= 1000){
		printf("1\n");
	}
	else{
		printf("0\n");
	}
	
	return 0;
}


Measured memory_bytes: 2120
num = int(input())
Seq = list(map(int, input().split()));
revSeq = reversed(Seq)
answer = []

able = True;

for i in range(num):
    if i+1<Seq[i]:
        able = False;
        break;

if able==False:
    print(-1);
else:
    while len(Seq)>0:
        for i in reversed(range(num)):
            if i+1==Seq[i]:
                answer.append(Seq[i]);
                del Seq[i];
                num-=1;
                break;

for i in reversed(answer):
    print(i)


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#define N 100

int main(void)
{
  int i, j, k = 0, m = 0, h, len[N] = {0}, cnt = 0, sum[N] = {0};
  char str[201], STR[100][201];

  while(cnt != -1) {
    scanf("%s", str);
    if(str[0] == '-') break;
    len[cnt] = strlen(str);
    scanf("%d", &m);
    for(i = 0; i < m; i++) {
      scanf("%d", &h);
      sum[cnt] += h;
    }
    strcpy(STR[cnt], str);
    strcat(STR[cnt], str);
    cnt++;
  }

  for(i = 0; i < cnt; i++) {
    k = sum[i]%len[i];
    for(j = k; j < k+len[i]; j++) {
      printf("%c", STR[i][j]);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const int MOD = 1000000007;

        static void Solve()
        {
            int n = ReadAndParseInt();
            var ab = ReadAndParseIntArr();
            int a = ab[0];
            int b = ab[1];
            var p = ReadAndParseIntArr();
            int[] problemTotals = new int[3];
            foreach(int pp in p)
            {
                if( pp <= a)
                {
                    problemTotals[0]++;
                }else if( pp <= b)
                {
                    problemTotals[1]++;
                }
                else
                {
                    problemTotals[2]++;
                }
            }
            int ans = problemTotals.Min();
            Console.WriteLine(ans);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
#define rep(i,n) for(int i=0;i<n;i++)
 

 int main(void)
 {
     int n;
     cin>>n;
    string s,t;
    cin>>s>>t;

    string ans="";

    rep(i,n){
        ans +=s[i];
        ans +=t[i];
    }

    cout<<ans<<endl;





 }

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

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  vector<string> devide = {"dream","dreamer","erase","eraser"};

  string S;
  cin >> S;

  reverse(S.begin(),S.end());
  for(int i=0;i<4;i++) reverse(devide.at(i).begin(),devide.at(i).end());
  //for(int i=0;i<4;i++) cout<<devide.at(i)<<endl;

  bool can=true;
  for(int i=0;i<S.size();i++){
    //cout<<i<<endl;
    bool can2=false;
    for(int j=0;j<4;j++){
      if(S.substr(i,devide.at(j).size())==devide.at(j)){
        can2 = true;
        i = i+devide.at(j).size()-1;
        //cout<<devide.at(j)<<' '<<i<<endl;
      }
    }
    if(!can2){
      can =false;
      break;
    }
  }
  if(can) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;
int main(){
  char ch[100],s[100],str[200];
  int n=0,i=0,j=0;
  cin>>n;
  cin.ignore();
  cin>>ch;
  cin>>s;
  while(i<n){
    str[j]=ch[i];
    j++;
    str[j]=s[i];
    j++;
    i++;
  }
  for(i=0;i<(2*n);i++)
    cout<<str[i];
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define INF 1e9 + 5


using namespace std;

int main(void) {
	int H, n;
	cin >> H >> n;
	vector<int> dp(H+1, INF);
	dp[0] = 0;
	while(n--) {
		int value, cost;
		cin >> value >> cost;
		for (int i = 0; i <= H; i++) {
			int nextval = min(H, i+value);
			dp[nextval] = min(dp[nextval], dp[i] + cost);
		}
	}

	cout << dp[H]<< endl;
	
}
	


Measured memory_bytes: 256
# coding: UTF-8

def h(z,C):
  if 50*C >= z:
    return 1
  else:
    return 0

def g(y,B,C):
  ans = 0
  i = 0
  while 100*i <= y and i <= B:
    ans += h(y-100*i,C)
    i += 1
  return ans

def f(x,A,B,C):
  ans = 0
  i = 0
  while 500*i <= x and i <= A:
    ans += g(x-500*i,B,C)
    i += 1
  return ans

def solve():
  A = int(input())
  B = int(input())
  C = int(input())
  X = int(input())
  return str(f(X,A,B,C))
 
if __name__ == '__main__':
  ans = solve()
  print(ans, flush=True)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(){
  int num,n,c,i,k;
  char s[5];
  int data[4][14]={0};
  char mark[]="SHCD";
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%s",s);
    scanf("%d",&n);
    if(strcmp(s,"S")==0)c=0;
    else if(strcmp(s,"H")==0)c=1;
    else if(strcmp(s,"C")==0)c=2;
    else c=3;
    data[c][n]++;
  }
  for(i=0;i<4;i++){
    for(k=1;k<14;k++){
      if(!data[i][k])printf("%c %d\n",mark[i],k);
    }
  }
  return 0;
}

Measured memory_bytes: 2712
import math
def merge(a, left, mid, right):
    global c
    n1 = mid - left
    n2 = right - mid
    l = a[left:left + n1]
    r = a[mid:mid + n2]
    l.append(10e10)
    r.append(10e10)
    i = 0
    j = 0
    for k in range(left, right):
        c += 1
        if l[i] < r[j]:
            a[k] = l[i]
            i += 1
        else:
            a[k] = r[j]
            j += 1

def mergeSort(a, left, right):
    if left + 1 < right:
        mid = math.ceil((left + right) / 2)
        mergeSort(a, left, mid)
        mergeSort(a, mid, right)
        merge(a, left, mid, right)

n = int(input())
a = list(map(int,input().split()))
c = 0
mergeSort(a, 0, n)
print(" ".join(map(str, a)))
print(c)


Measured memory_bytes: 70508
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;

int main(){
    long long L,R; cin>>L>>R;
    if((R-L) >=2018)cout << 0 << endl;
    else if(R%2019 < L%2019)cout<< 0 << endl;
    else{
        long long a = L%2019;
        long long b = R%2019;
        long long ans=2020;
        for(int i=a; i<=b; i++){
            for(int j=i+1; j<=b; j++){
                if(i*j%2019<ans) ans=i*j%2019;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    var s = readLine()!!

    if (isYymm(s) && isMmyy(s)) {
        print("AMBIGUOUS")
        return
    }

    if (isYymm(s)) {
        print("YYMM")
        return
    }

    if (isMmyy(s)) {
        print("MMYY")
        return
    }

    print("NA")
    return
}

fun isYymm(s: String): Boolean {
    if (s.substring(2, 4).toInt() in 1..12) {
        return true
    }

    return false
}

fun isMmyy(s: String): Boolean {
    if (s.substring(0, 2).toInt() in 1..12) {
        return true
    }

    return false
}

Measured memory_bytes: 33756