akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<vector>
#include<map>
#include<queue>

#define N 1005
#define M 5005

#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)

#define mk make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

const int inf=(int)1e9;

int i,j,m,n,p,k,F[N],G[N],T[N][M],R[M],P[N][M],fa[N],a[N];

int main()
{
	scanf("%d",&n);
	for (i=2;i<=n;++i)
	{
			scanf("%d",&fa[i]); 
	}
	for (i=1;i<=n;++i) scanf("%d",&a[i]);
	for (i=n;i>=1;--i)
	{
			int f=inf;
			for (j=0;j<=a[i];++j) f=min(f,T[i][j]);
			F[i]=f;
			f=inf;
			for (j=0;j<=a[i];++j) f=min(f,P[i][j]);
			G[i]=f;
			if (F[i]==inf&&G[i]==inf) break;
			memset(R,60,sizeof(R));
			int p=fa[i];
			for (j=a[p];j-a[i]>=0;--j)
				R[j]=min(R[j],T[p][j-a[i]]+F[i]);
			for (j=a[p];j-G[i]>=0;--j)
				R[j]=min(R[j],T[p][j-G[i]]+a[i]);
			for (j=0;j<=a[p];++j)
				T[p][j]=R[j];
			memset(R,60,sizeof(R));
			for (j=a[p];j-F[i]>=0;--j)
				R[j]=min(R[j],P[p][j-F[i]]+a[i]);
			for (j=a[p];j-a[i]>=0;--j)
				R[j]=min(R[j],P[p][j-a[i]]+G[i]);
			for (j=0;j<=a[p];++j)
				P[p][j]=R[j];
	}
	if (i>=1) puts("IMPOSSIBLE");
	else puts("POSSIBLE"); 
}


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

int main(){
    int n, l;
    cin>>n>>l;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin>>s.at(i);
    }
    sort(s.begin(),s.end());
    for(int i=0;i<n;i++) cout<<s.at(i);
}


Measured memory_bytes: 256
// tzl ak IOI! 

#include<bits/stdc++.h>

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define MCPY(a, b) memcpy((a), (b), sizeof((b)))

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T>
inline void scf(T &x)
{
	bool f = 0; x = 0; char c = getchar();
	while((c < '0' || c > '9') && c != '-') c = getchar();
	if(c == '-') { f = 1; c = getchar(); }
	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	if(f) x = -x; return;
}

template <typename T1, typename T2>
void scf(T1 &x, T2 &y) { scf(x); return scf(y); }

template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) { scf(x); scf(y); return scf(z); }

template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) { scf(x); scf(y); scf(z); return scf(w); }

inline char mygetchar(){ char c = getchar(); while(c == ' ' || c == '\n') c = getchar(); return c; }

template <typename T>
void chkmax(T &x, const T &y){ if(y > x) x = y; return; }

template <typename T>
void chkmin(T &x, const T &y){ if(y < x) x = y; return; }

#ifdef ONLINE_JUDGE
#define debug(x,c) ;
#else
#define DEBUG
#define debug(x,c) cerr<<#x<<"="<<x<<c;
#endif

void TZL();

void RANK1();

#define tzl int
#define ak main
#define IOI ()
tzl ak IOI
{
#undef tzl
#undef ak
#undef IOI

	TZL();
	RANK1();

#define tzl return
#define caisi 0
#define myy ;
	tzl caisi myy
#undef tzl
#undef caisi
#undef myy
}

//---------------------------head----------------------------

const int N = 1e5 + 100;

int n;
vi b;

void TZL()
{
	scf(n);
	forn(i, 1, n)
	{
		int x; scf(x);
		if(!SZ(b) || x != b.back()) b.pb(x);
	}
	return;
}

void RANK1()
{
	int ans = 0;
	for(int i = 0; i < SZ(b);)
	{
		++ans;
		int j = i + 1;
		if(j == SZ(b)){ printf("%d\n", ans); return; }
		if(b[j] > b[i])
		{
			while(j < SZ(b) && b[j] > b[j - 1]) ++j;
			i = j;
		}
		else
		{
			while(j < SZ(b) && b[j] < b[j - 1]) ++j;
			i = j;
		}
	}
	printf("%d\n", ans);
	return;
}

Measured memory_bytes: 892
#!/usr/bin python3
# -*- coding: utf-8 -*-

def stds(n):
    if n == 1:
        return set(['a'])
    else:
        std = stds(n-1)
        ret = set([])
        for stdi in std:
            for x in range(ord('a'),max(map(ord,list(stdi))) + 2):
                ret.add(stdi + chr(x))
        return ret

def main():
    N = int(input())
    ret = list(stds(N))
    ret.sort()
    print('\n'.join(ret))


if __name__ == '__main__':
    main()

Measured memory_bytes: 24384
#include <cstdio>

int check(int n){
    int cnt = 0;
    for (int x = 1; x*x < n; x++){
        for (int y = 1; x*x+y*y+x*y < n; y++){
            for (int z = 1; x*x+y*y+z*z+x*y+y*z+x*z <= n; z++){
                if (x*x+y*y+z*z+x*y+y*z+x*z == n) cnt++;
            }
        }
    }
    return cnt;
}

int main(){
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++){
        int ans = check(i);
        printf("%d\n", ans);
    }
    return 0;
}


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

int main() {
  int N;
  cin>>N;
  vector<double> vec1(N);
  vector<string> vec2(N);
  for(int i=0;i<N;i++){
  	cin>>vec1.at(i)>>vec2.at(i);}
  	double ans=0;
  	for(int i=0;i<N;i++){
  		if(vec2.at(i)=="JPY"){ans+=vec1.at(i);}
  		else{ans+=vec1.at(i)*380000.0;}
  	}
  	cout<<ans<<endl;

}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

struct Edge { int to, en; };

struct State {
	int v, day, dst, event;
	bool operator > (const State& a) const { return dst > a.dst; }
};

int N, M, E, S, T, R, eve[111];
vector< Edge > edges[111];

const int iINF = 1L << 30;

int dst[111][111][16];

void solve() {
	for_(i,0,111) for_(j,0,111) for_(k,0,16) dst[i][j][k] = iINF;
	
	priority_queue< State, vector< State >, greater< State > > que;
	int ini_eve = (eve[S] >= 0 ? 1 << eve[S] : 0);
	que.push(State{S, 0, 0, ini_eve});
	dst[S][0][ini_eve] = 0;
	
	while (!que.empty()) {
		State s = que.top(); que.pop();
		if (s.day > R || dst[s.v][s.day][s.event] < s.dst) continue;
		
		if (dst[S][0][s.event] > s.dst + 1) {
			dst[S][0][s.event] = s.dst + 1;
			que.push(State{S, 0, s.dst + 1, s.event});
		}
		
		for (Edge e : edges[s.v]) {
			if (!(e.en == -1 || (e.en >= 0 && (s.event >> e.en & 1)))) continue;
			
			int nx_eve = s.event;
			if (eve[e.to] >= 0) nx_eve |= 1 << eve[e.to];
			
			if (dst[e.to][s.day + 1][nx_eve] > s.dst + 1) {
				dst[e.to][s.day + 1][nx_eve] = s.dst + 1;
				que.push(State{e.to, s.day + 1, s.dst + 1, nx_eve});
			}
		}
	}
	
	int ans = iINF;
	
	for_(r,0,R+1) for_(ev,0,1<<E) {
		ans = min(ans, dst[T][r][ev]);
	}
	
	cout << (ans == iINF ? -1 : ans) << endl;
}

int main() {
	cin >> N >> M >> E >> S >> T >> R;
	
	for_(i,0,M) {
		int a, b;
		cin >> a >> b;
		edges[a].push_back(Edge{b, -1});
		edges[b].push_back(Edge{a, -1});
	}
	
	memset(eve, -1, sizeof(eve));
	
	for_(i,0,E) {
		int a, b, c;
		cin >> a >> b >> c;
		edges[a].push_back(Edge{b, i});
		edges[b].push_back(Edge{a, i});
		eve[c] = i;
	}
	
	solve();
}

Measured memory_bytes: 2196
#include <stdio.h>
//#include <string.h>

int main() {
    int midterm, final, makeup;


    while (1) {
        scanf("%d %d %d\n", &midterm, &final, &makeup);

        if (midterm == -1 && final == -1 && makeup == -1)
            break;

        if (midterm == -1 || final == -1)
            printf("F\n");
        else if (midterm + final >= 80)
            printf("A\n");
        else if (midterm + final >= 65)
            printf("B\n");
        else if (midterm + final >= 50)
            printf("C\n");
        else if (midterm + final >= 30) {
            if (makeup >= 50)
                printf("C\n");
            else
                printf("D\n");
        } else
            printf("F\n");
    }
    return 0;
}


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

int main(){
	int data_set;
	std::cin >> data_set;
	std::cin.get();
	std::string document[data_set];
	for(int i = 0; i < data_set; ++i){
		std::getline(std::cin, document[i]);
	}
	for(int i = 0; i < data_set; ++i){
		auto pos = document[i].find("Hoshino");
		while(pos != std::string::npos){
			document[i].replace(pos, 7, "Hoshina");
			pos = document[i].find("Hoshino", pos + 7);
		}
		std::cout << document[i] << std::endl;
	}
	return 0;
}

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


long long int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){
  int A,N;
  cin >> N;
  A = 0;
  while(N>A){
    A = A+1000;
  }
  
  cout << A-N <<endl;
  
  return 0;
}


long long int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


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

typedef long long ll;
static const ll INF = 1ll<<60;
static const int MOD = 1e9+7;

int main(){
    ll A,B,V,W,T;
    cin>>A>>V>>B>>W>>T;

    if(A >= B){
        if(B-W*T >= A-V*T) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }else{
        if(A+V*T >= B +W*T) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3676
#include<iostream>
#include<cstdio>
#include<queue>
#define INF 100000000
using namespace std;

typedef pair<int,int> P;
typedef pair<P,P> P2;

int main(){
  int w,h;
  char grid[100][50];
  vector<P2> G[2][100][50];
  int d[2][100][50];
  int dy[] = {-2,-1,0,1,2,-1,0,1,0} , dx[] = {1,1,1,1,1,2,2,2,3};

  while(cin >> w >> h , w||h){
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	scanf(" %c ",&grid[i][j]);

    priority_queue<P2,vector<P2>,greater<P2> > q;

    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	G[0][i][j].clear();
	G[1][i][j].clear();
	if(grid[i][j] == 'S'){
	  d[0][i][j] = d[1][i][j] = 0;
	  q.push(P2(P(0,0),P(i,j)));
	  q.push(P2(P(0,1),P(i,j)));
	}else d[0][i][j] = d[1][i][j] = INF;
      }
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	for(int k=0;k<9;k++){
	  int sy = i+dy[k], sx = j+dx[k];
	  if(sy<0 || sx<0 || h<=sy || w<=sx)continue;
	  if('1'<=grid[sy][sx] && grid[sy][sx]<='9')
	    G[0][i][j].push_back(P2(P(grid[sy][sx]-'0',1),P(sy,sx)));
	  if(grid[sy][sx] == 'T')
	    G[0][i][j].push_back(P2(P(0,1),P(sy,sx)));
	}
	for(int k=0;k<9;k++){
	  int sy = i+dy[k], sx = j-dx[k];
	  if(sy<0 || sx<0 || h<=sy || w<=sx)continue;
	  if('1'<=grid[sy][sx] && grid[sy][sx]<='9')
	    G[1][i][j].push_back(P2(P(grid[sy][sx]-'0',0),P(sy,sx)));
	  if(grid[sy][sx] == 'T')
	    G[1][i][j].push_back(P2(P(0,0),P(sy,sx)));
	}
      }
    }

    while(q.size()){
      P2 p = q.top();q.pop();
      
      int t = p.first.first, f = p.first.second;
      int y = p.second.first, x = p.second.second;

      if(grid[y][x] == 'T'){
	q.push(p);
	cout << t << endl;
	break;
      }

      for(int i=0;i<(int)G[f][y][x].size();i++){
	int tt = G[f][y][x][i].first.first, tf = G[f][y][x][i].first.second;
	int ty = G[f][y][x][i].second.first, tx = G[f][y][x][i].second.second;

	if(d[tf][ty][tx] > t + tt){
	  d[tf][ty][tx] = t+tt;
	  q.push(P2(P(t+tt,tf),P(ty,tx)));
	}
      }
    }
    if(q.empty())cout << -1 << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
inline void rd(long long &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S divup_L(S a, T b){
  return (a+b-1)/b;
}
long long N;
long long A[5];
int main(){
  long long b, res;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<5;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY;
    long long Q5VJL1cS;
    if(5==0){
      Q5VJL1cS = 0;
    }
    else{
      Q5VJL1cS = A[0];
      for(KL2GvlyY=1;KL2GvlyY<5;KL2GvlyY++){
        Q5VJL1cS = min_L(Q5VJL1cS, A[KL2GvlyY]);
      }
    }
    b =Q5VJL1cS;
  }
  res = (divup_L(N,b)) + 4;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190706-1

// --- original code ---
// ll N, A[5];
// {
//   ll res, b;
//   rd(N,A(5));
//   b = min(A(5));
//   res = (N /+ b) + 4;
//   wt(res);
// }


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}


ll i,j,k,ii,jj;
ll n,m;
ll a,b,c,d,e,g,h;
ll ans,num;
ll x[500005],y[500005],z[500005];
ll l[500005],r[500005];
bool dame,flag;
bool check[500005];
char s[500005],t[500005];

int main(){
    cin >> n >> m;
	for(i=0;i<n;i++){
		cin >> l[i] >> r[i];
	}
	for(i=0;i<n;i++){
		//pe("i");pe("=");p(i);
		num = 1;
		ll ba=INF,bb=INF;
		if(l[i] == r[i]){
			for(j=1;j*j<=l[i];j++){
				if(l[i] % j == 0){
					x[j] += 1;
					x[j+1] -= 1;
					if(j*j != l[i]){
						x[l[i]/j] += 1;
						x[l[i]/j + 1] -= 1;
					}
				}
			}
		}else{
			while(1){
				if(num >= 2){
					ba = a;
					bb = b;
				}
				a = (l[i]+num-1)/num;
				b = (r[i])/num;
				b = min(b,ba-1);
				a = min(a,b);
				if(b == 0)break;
				if(a != b){
					x[a] += 1;
					x[b + 1] -= 1;
				}else{
					if(r[i]/a != (l[i]-1)/a){
						x[a] += 1;
						x[a + 1] -= 1;
					}
				}
				//pe(a);p(b);
				if(b <= r[i]-l[i])break;
				num++;
			}
			if(a >= 2){
				x[1] += 1;
				x[a] -= 1;
			}
		}
		//pe("x[1]=");p(x[1]);
	}
	for(i=1;i<=m;i++){
		x[i] += x[i-1];
		p(x[i]);
	}


	return 0;

}


Measured memory_bytes: 33664
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	int N; cin >> N;
	vector<int> p(N);
	for (int i = 0; i < N; i++)cin >> p[i];
	int a = 0;
	for (int i = 0; i < N; i++) {
		if (p[i] != i+1)a++;
	}
	if (a == 2||a==0)cout << "YES" << endl;
	else cout << "NO" << endl;
}





Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

c1 = 0
s = 0

# 累積和の奇数番目を正とするパターン
for i in range(n):
    s += a[i]
    if i % 2 == 1:
        if s <= 0:
            c1 += 1 - s
            s = 1

    else:  # iが偶数
        if s >= 0:
            c1 += 1 + s
            s = -1

c2 = 0
s = 0

# 累積和の偶数番目を正とするパターン
for i in range(n):
    s += a[i]
    if i % 2 == 1:
        if s >= 0:
            c2 += 1 + s
            s = -1
    else:
        if s <= 0:
            c2 += 1 - s
            s = 1

print(min(c1, c2))


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


struct Tree{
	Tree *l,*r;
	Tree():l(0),r(0){}
	~Tree(){delete l;delete r;}
};

Tree* to_t(string s){
	Tree *t=new Tree();
	if(s=="")return 0;
	if(s=="(,)")return t;
	int lev=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='(')lev++;
		else if(s[i]==')')lev--;
		else if(lev==1&&s[i]==','){
			t->l=to_t(s.substr(1,i-1));
			t->r=to_t(s.substr(i+1,s.size()-(i+1)-1));
			break;
		}
	}
	return t;
}
string intersection(Tree *s,Tree *t){
	string res;
	if(!s||!t)return res;
	res+='(';
	res+=intersection(s->l,t->l);
	res+=',';
	res+=intersection(s->r,t->r);
	res+=')';
	return res;
}
string _union(Tree *s,Tree *t){
	string res;
	if(!s&&!t)return res;
	res+='(';
	res+=_union(s?s->l:0,t?t->l:0);
	res+=',';
	res+=_union(s?s->r:0,t?t->r:0);
	res+=')';
	return res;
}


int main(){
	char op;
	string a,b;
	Tree * s,*t;
	while(cin>>op>>a>>b){
		s=to_t(a);
		t=to_t(b);
		if(op=='i')cout<<intersection(s,t)<<endl;
		else cout<<_union(s,t)<<endl;
		delete s;
		delete t;
	}
	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265359
int main(){
    int a,b,c,d,e,k;
    cin>>a;
    cin>>b;
    cin>>c;
    cin>>d;
    cin>>e;
    cin>>k;
    vector <int> S(5);
    S[0]=a,S[1]=b;S[2]=c;S[3]=d;S[4]=e;
    sort(S.begin(),S.end());
    if(S[4]-S[0]>k){
        cout<<":(";
    }
    else{
        cout<<"Yay!";
    }
    return 0;
}

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

using namespace std;
typedef vector<int> vi;
typedef long long ll;
vi primes;
int f[104];

void fact(int N){
  int pos = 0;
  int p = primes[pos];
  while(p <= N){
    while(N%p==0){
      f[pos]++; N/=p;
    }
    pos++;
    p = primes[pos];
  }
}

ll fun(int pos, ll total){
  if(pos>=primes.size()) return 0;
  if(total>=75){
    if(total==75) return 1;
    return 0;
  }
  ll ans = 0;
  for(ll i=0;i<=f[pos];++i){
    ans += fun(pos+1,total*(i+1));
  }
  return ans;
}

main(){
  fill(f,f+104,0);
  primes.push_back(2);
  for(int i=3;i<=102;i+=2){
    int c = 0;
    for(int j=1;j<=i;j++) if(i%j==0) c++;
    if(c==2) primes.push_back(i);
  }
  int n; cin >> n;
  for(int i=2;i<=n;++i) fact(i);
  cout << fun(0,1) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext())
		{
			int y = sc.nextInt();
			int m = sc.nextInt();
			int d = sc.nextInt();
			if (y < 1868)
			{
				System.out.println("pre-meiji");
			}
			else if (y == 1868)
			{
				if (m == 9)
				{
					if (d < 8)
					{
						System.out.println("pre-meiji");
					}
					else
					{
						System.out.printf("meiji %d %d %d\n", y - 1868 + 1, m, d);
					}
				}
				else if (m < 9)
				{
					System.out.println("pre-meiji");
				}
				else if (9 < m)
				{
					System.out.printf("meiji %d %d %d\n", y - 1868 + 1, m, d);
				}
			}
			else if (1868 < y && y < 1912)
			{
				System.out.printf("meiji %d %d %d\n", y - 1868 + 1, m, d);
			}
			else if (y == 1912)
			{
				if (m == 7)
				{
					if (d < 30)
					{
						System.out.printf("meiji %d %d %d\n", y - 1868 + 1, m, d);
					}
					else
					{
						System.out.printf("taisho %d %d %d\n", y - 1912 + 1, m, d);
					}
				}
				else if (m < 7)
				{
					System.out.printf("meiji %d %d %d\n", y - 1868 + 1, m, d);
				}
				else if (7 < m)
				{
					System.out.printf("taisho %d %d %d\n", y - 1912 + 1, m, d);
				}
			}
			else if (1912 < y && y < 1926)
			{
				System.out.printf("taisho %d %d %d\n", y - 1912 + 1, m, d);
			}
			else if (y == 1926)
			{
				if (m == 12)
				{
					if (d < 25)
					{
						System.out.printf("taisho %d %d %d\n", y - 1912 + 1, m, d);
					}
					else
					{
						System.out.printf("showa %d %d %d\n", y - 1926 + 1, m, d);
					}
				}
				else if (m < 12)
				{
					System.out.printf("taisho %d %d %d\n", y - 1912 + 1, m, d);
				}
				else if (12 < m)
				{
					System.out.printf("showa %d %d %d\n", y - 1926 + 1, m, d);
				}
			}
			else if (1926 < y && y < 1989)
			{
				System.out.printf("showa %d %d %d\n", y - 1926 + 1, m, d);
			}
			else if (y == 1989)				
			{
				if (m == 1)
				{
					if (d < 8)
					{
						System.out.printf("showa %d %d %d\n", y - 1926 + 1, m, d);
					}
					else
					{
						System.out.printf("heisei %d %d %d\n", y - 1989 + 1, m, d);
					}
				}
				else
				{
					System.out.printf("heisei %d %d %d\n", y - 1989 + 1, m, d);
				}
			}
			else
			{
				System.out.printf("heisei %d %d %d\n", y - 1989 + 1, m, d);
			}
		}
	}
}

Measured memory_bytes: 11000
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
6 1
LRLRRL
---+/
/+---test
13 3
LRRLRLRRLRLLR
---+/
/+---test
10 1
LLLLLRRRRR
---+/
/+---test
9 2
RRRLRLRLL
---+/

void main(string[] args) {
  long N, K;
  readf(" %d %d ", &N, &K);
  auto S = readln.chomp.to!(char[]);

  const same = zip(S, S[1..$]~' ').count!(x => x[0] == x[1]);
  (same + K*2).min(S.length-1).writeln;
}


Measured memory_bytes: 2684
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	int mxm=0;
	int sco;
	REP(i,n){
		int a,b;
		scanf("%d%d",&a,&b);
		if(a>mxm){
			mxm=a;
			sco=b;
		}
	}
	
	cout<<mxm+(sco-0)<<endl;
	return 0;
}

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

int main(void){
    string s;
    string yes = "Yes", no = "No";
    cin >> s;
    if(s[0]==s[1] && s[1]!=s[2] && s[2]==s[3]) cout << yes;
    else if(s[0]!=s[1] && s[1]==s[2] && s[2]!=s[3]) cout << yes;
    else if(s[0]!=s[1] && s[1]!=s[2] && s[2]!=s[3] && s[0]==s[2] && s[1]==s[3]) cout << yes;
    else cout << no;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <algorithm>
#include <math.h>
#include<string>
#include<vector>
using namespace std;
int main(){
    long long n,k;
    cin >> n >> k;
    long long temp = min(n,n%k);
    cout << min(temp,abs(temp-k)) << endl;
}

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

int main(){
  int n;cin>>n;
  set<int> st;
  int temp;
  for(int i=1;i<=n;i++){
    cin>>temp;
    if(st.find(temp)!=st.end()){
      cout<<"NO\n";
      return 0;
    }
    st.insert(temp);
  }
  cout<<"YES\n";
  return 0;
}

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

void solve() {
  string s;
  int N;
  cin >> s;
  cin >> N;

  for (int i = 0; i < s.size(); i += N) {
    cout << s[i];
  }
  cout << endl;
}

int main() {
  solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 2020
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int a[maxn][maxn][4];
int b[maxn][maxn];
char s[maxn];
int sum[maxn][maxn][4];
int bb[maxn][maxn];
int get_bb(int x,int y,int xx,int yy)
{
    return bb[xx][yy]-bb[xx][y-1]-bb[x-1][yy]+bb[x-1][y-1];
}
int get_sum(int x,int y,int xx,int yy,int typ)
{
    return sum[xx][yy][typ]-sum[xx][y-1][typ]-sum[x-1][yy][typ]+sum[x-1][y-1][typ];
}
int main()
{
    int n,m,q;
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=n;++i)
    {
        scanf("%s",s+1);
        for(int j=1;j<=m;++j)
            b[i][j]=s[j]-'0';
    }
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=m;++j)
        {
            if(b[i][j]==0) continue;
            for(int k=0;k<4;++k)
            {
                int nx=i+dx[k],ny=j+dy[k];
                a[i][j][k]=b[nx][ny];
            }
        }
    }
    for(int k=0;k<4;++k)
    {
        for(int i=1;i<=n;++i)
            for(int j=1;j<=m;++j)
        {
            sum[i][j][k]=sum[i][j-1][k]+sum[i-1][j][k]-sum[i-1][j-1][k]+a[i][j][k];
            //if(b[i][j]==1) sum[i][j][k]+=a[i][j][k];
        }
    }
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
            bb[i][j]=bb[i-1][j]+bb[i][j-1]-bb[i-1][j-1]+b[i][j];
    int x,y,xx,yy;
    while(q--)
    {
        scanf("%d%d%d%d",&x,&y,&xx,&yy);
        int ans=get_bb(x,y,xx,yy);
        int tmp=0;
        for(int i=0;i<4;++i)
        {
            tmp+=get_sum(x,y,xx,yy,i);
        }
        tmp-=get_sum(x,y,x,yy,3);
        tmp-=get_sum(x,y,xx,y,1);
        tmp-=get_sum(xx,y,xx,yy,2);
        tmp-=get_sum(x,yy,xx,yy,0);
        ans-=tmp/2;
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 160640
#include <iostream>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;

vector<pair<ll, ll> > prime_factorize(ll n) {
  vector<pair<ll, ll> > res;

  for (ll p = 2; p * p <= n; p++) {
    if (n % p != 0) { continue; }
    int num = 0;
    while (n % p == 0) { ++num; n /= p; }
    res.push_back(make_pair(p, num));
  }

  if (n != 1) { res.push_back(make_pair(n, 1)); }
  return res;
}

// n! の約数の数を mod で割った余りを返す
ll mod_div_fact(ll n, ll mod) {
  map<ll, ll> mp;
  for (ll i = 2; i <= n; i++) {
    vector<pair<ll, ll> > v = prime_factorize(i);
    for (int i = 0; i < v.size(); i++) {
      ll prime = v[i].first;
      ll exp = v[i].second;

      mp[prime] += exp;
    }
  }
  ll res = 1;
  for (std::map<ll, ll>::iterator it = mp.begin(); it != mp.end(); it++) {
    res *= ((it->second) + 1);
    res %= mod;
  }
  return res;
}

const ll mod = int(1e9)+7;

int main() {
  ll n;

  cin >> n;
  cout << mod_div_fact(n, mod) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int G() {
	int o=0;bool f=0;char t=getchar();
	while(t<48||t>57) f|=t=='-',t=getchar();
	while(t>47&&t<58) o=(o<<1)+(o<<3)+t-48,t=getchar();
	return f?-o:o;
}
int n,i,k[2];ll ans=1,mod=1000000007;
char s1[55],s2[55];
int main() {
	cin>>n;
	scanf("%s%s",s1,s2);
	if(s1[0]==s2[0]) i=1,ans=3,k[0]=2,k[1]=2;
	else i=2,ans=6,k[0]=3,k[1]=1;
	for(;i<n;i++) {
		if(s1[i]==s2[i]) {
			ans=ans*k[1]%mod;
			k[0]=2,k[1]=2;
		} else {
			i++;
			ans=ans*k[0]%mod;
			k[0]=3,k[1]=1;
		}
	}
	cout<<ans;
}


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

using namespace std;

typedef long long int64;

int main()
{
  int N, A[100001] = {};

  cin >> N;
  for(int i = 0; i < N; i++) {
    int P;
    cin >> P;
    A[P]++;
  }

  queue< int > que;
  for(int i = 0; i < 100001; i++) {
    if(A[i] % 2 == 1) {
      A[i] = 1;
    } else if(A[i] > 0 && A[i] % 2 == 0) {
      A[i] = 2;
      que.push(i);
    }
  }

  while(que.size() >= 2) {
    int p = que.front();
    que.pop();
    int q = que.front();
    que.pop();
    --A[p];
    --A[q];
  }

  if(que.size()) {
    --A[que.front()];
    --A[que.front()];
  }


  cout << accumulate(A, A + 100001, 0) << endl;
}


Measured memory_bytes: 640
package main

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

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

func main() {
	sc := NewScanner()
	S := sc.NextLine()
	N := sc.NextInt()

	s := []byte(S)
	for i := 0; i < len(S); i++ {
		s[i] = S[i] - 'a'
	}
	for i := 0; i < len(s); i++ {
		if s[i] == 0 {
			continue
		}
		if int(26 - s[i]) <= N {
			N -= int(26 - s[i])
			s[i] = 0
		}
	}
	p := len(s) - 1

	N %= 26
	s[p] += byte(N)
	for i := 0; i < len(s); i++ {
		fmt.Print(string(s[i] + 'a'))
	}
	fmt.Println()

}

Measured memory_bytes: 3456
/* ****GT_18**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		int n;
		cin>>n;
		vi a(n);
		rep(i,0,n) cin>>a[i];
		map<ll,ll> m;
		rep(i,0,n) m[a[i]]++;
		vi t;
		for(auto i:m)
		{
			if(i.S>=2)
				t.pb(i.F);
		}
		sort(all(t));
		if(sz(t)==0)
		{
			cout<<0;
			return 0;
		}
		if(m[t[sz(t)-1]]>=4)
		{
			cout<<t.back()*t.back();
			return 0;
		}
		else if(sz(t)<2) cout<<0<<endl;
		else cout<<t[sz(t)-1]*t[sz(t)-2];
	}
	return 0;
}


Measured memory_bytes: 7296
import java.util.Scanner;

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

        if (scanner.hasNextLine()) {
            String[] array = scanner.nextLine().split(" ");
            int a = Integer.parseInt(array[0]);
            int b = Integer.parseInt(array[1]);

            if (a <= 5) {
                System.out.println(0);
            } else if (a <= 12) {
                System.out.println(b / 2);
            } else {
                System.out.println(b);
            }
        }
    }
}

Measured memory_bytes: 21716
#include<iostream>
using namespace std;
int main()
{
  int a,b,c=0;
  cin >> a >> b;
  int arr[a];
  for(int i = 0;i < a;i++){
    cin >> arr[i];
    if(arr[i] >= b){
      c++;
    }
  }
  cout << c << endl;
}

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

int main() 
{

    int n;
    cin >> n;

    vector<pair<int, int>> G[n];

    int cnt[n];
    rep(i,n) cnt[i] = 0;
    int maxNode = -1;
    int maxEdgeCount = 0;

    rep(i,n-1) {
        int a,b;
        cin >> a >> b;
        a--;b--;

        G[a].push_back(make_pair(b,i));
        G[b].push_back(make_pair(a,i));
        cnt[a]++;
        cnt[b]++;

        if (maxEdgeCount < cnt[a]) {maxNode = a; maxEdgeCount = cnt[a];}
        if (maxEdgeCount < cnt[b]) {maxNode = b; maxEdgeCount = cnt[b];}
    }

    queue<int> que;
    
    int CN[n]; // 使える色の記録用
    rep(i,n) CN[i] = -1;

    int C[n-1]; // 辺の色
    rep(i,n-1) C[i] = -1;

    que.push(maxNode);
    while (!que.empty()) {
        int node = que.front(); que.pop();
        for(auto p : G[node]) {
            int v = p.first;
            int e = p.second;
            
            // 既に色を塗ってる辺は無視
            if (C[e] > -1) continue;
            
            // まだ通過してない辺の場合。色を塗って頂点をQueueに積む。
            CN[node]++;
            int color = CN[node] % maxEdgeCount;
            C[e] = color;
            CN[v] = color;
            que.push(v);
        }
    }

    cout << maxEdgeCount << endl;
    rep(i,n-1) {
        cout << C[i] + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 7808
// Author :mastermindevil/mdragneell
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define pi  pair< int,int >
#define pl  pair< ll,ll >
#define f first
#define s second
#define endl '\n'
 
 
ll const mod=1e9+7;
ll const N=1e5+5;
ll fact[N];
ll min(ll x,ll y) { if(x < y) return x; else return y; }
ll max(ll x,ll y) { if(x > y) return x; else return y; }
ll gcd(ll x,ll y) { if(x == 0) return (y>0?y:1); else return gcd(y%x,x);}
ll powmod(ll x,ll y){ll res=1;while(y>0){if(y%2==1)res=(res*x)%mod;y>>=1;if(y<=0)break;x=(x*x)%mod;}return res;}
ll factorial () { fact[0]=1; fact[1]=1; for(int i=2;i<N;i++) fact[i]=(fact[i-1]*i)%mod;}ll
 
 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);}
};
struct compare {
    bool operator()(const pair<ll, ll>& value,  const ll& key){ return (value.first < key); }
    bool operator()(const ll& key, const pair<ll, ll>& value) { return (key < value.first); }
};
 
bool compare1(const pair<ll,ll> &a,const pair<ll,ll> &b)
{   
    if(a.f==b.f)
    {
        if(a.s<=0 && b.s<=0) return (a.s>b.s);
        return (a.s<b.s);
    }
    else if(a.f<=0 && b.f<=0 ) return (a.f > b.f);
    else return (a.f<b.f);
}


int main()
{

        ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        

        string s;
        cin>>s;

        if(count(s.begin(),s.end(),'A')==3)
            cout<<"No"<<endl;
        else if(count(s.begin(),s.end(),'C')==3)
            cout<<"No"<<endl;
        else if(count(s.begin(),s.end(),'B')==3)
            cout<<"No"<<endl;
        
        else
            cout<<"Yes"<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
char S[110];
int a[100010],b[100010];
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int A=gi(),B=gi(),M=gi();
	int ans=1e9,aa=1e9,bb=1e9;
	for(int i=1;i<=A;++i)a[i]=gi(),cnk(aa,a[i]);
	for(int i=1;i<=B;++i)b[i]=gi(),cnk(bb,b[i]);
	ans=aa+bb;
	int x,y,c;
	while(M--){
		x=gi(),y=gi(),c=gi();
		cnk(ans,a[x]+b[y]-c);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;

public class Hello {
  public static void Main() {
    //使わないのはコメントアウトしないとエラー
    var loop = NumInput().First();
    var num = NumInput().OrderByDescending(x => x).ToArray();
    int alice=0, bob=0;
//    var text = StringInput();        
    int res = 0;
    for(int i = 0; i < loop; i++){
      if(i%2==0) alice += num[i];
      else bob += num[i];
    }
    Result(alice-bob);
  }
  
  
  static int[] NumInput(){
    var input_line = Console.ReadLine().Split(' ');
    return input_line.Select(int.Parse).ToArray();
  }
  static string[] StringInput(){
    return Console.ReadLine().Split(' ');
  }

  static void Result(string text){
    Console.WriteLine( text );
  }   
  static void Result(int num){
    Console.WriteLine( num );
  }
  static void Result(float num){
    Console.WriteLine( num );
  }
}

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

int main() {
    string str1, str2;
    cin >> str1 >> str2;
    string str3 = str1;
    bool flag = false;
    int i = str1.size();
    if (str1 == str2)
    {cout << "Yes";flag = true;}
    else while (i) {
        str3 = str3.substr(str1.size() - 1) + str3.substr(0, str1.size() - 1);
        if(str3 == str2)
        {cout << "Yes";flag = true;break;}
        i--;
    }
    if (!flag) cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = -100100100;
const ll M = 1000000007;
typedef pair<int,int> P;

int main(){
    int n,m;
    cin >> n >> m;
    vector<ll>cnt(m+2),a(n+10), b(n+10);
    rep(i,m)cin>>cnt[i];
    int l = 0;
    rep(i,m){
        a[cnt[i]-1] = 1;
    }
    rep(i,n){
        if(i==0)b[i]=1;
        else if(i==1){
            if(a[i-1])b[i]=1;
            else b[i]=2;
        }
        else{
            if(a[i-1] && a[i-2]){
                cout << 0 << endl;
                return 0;
            }else if(a[i-1] && a[i-2]==0){
                b[i] = b[i-2]%M;
            }else if(a[i-2]){
                b[i] = b[i-1]%M;
            }else{
                b[i] = (b[i-1]+b[i-2]) %M;
            }
        }
    }
    cout << b[n-1]<< endl;
    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    int max = 0;
    for (int i = 1; i < Math.sqrt(n) + 1; i++)
      if (n % i == 0)
        max = i;
    System.out.println(max + n / max - 2);
  }
}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		//????????£????????????
		Scanner sc = new Scanner(System.in);

		//??\??????????????? ??????r
		double r =sc.nextDouble();
		//?????¨????????£?¨?
		double P = Math.PI;
		//????????¢??? ??¬??? ?????????????????????¨???
		double AreaCircle = r * r * P;
		//?????¨????????? ??¬??? ?????¨????????? = ??´??????????¨???
		double Arch =(r + r) * P;
		//?°???°???????????´
		String fAreaCircle = String.format("%.6f", AreaCircle);
		//?°???°???????????´
		String  fArch = String.format("%.6f", Arch);
		//???????????¨???
		System.out.printf(fAreaCircle + " " + fArch);
	}
}

Measured memory_bytes: 28268
/*
    Problem 82
    https://onlinejudge.u-aizu.ac.jp/problems/2013
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 24*3600+2;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
vector<int> T(MAX);
/* function */
int stringToSecond(string S) {
    int t = stoi(S.substr(0, 2)) * 3600 + stoi(S.substr(3, 2)) * 60 + stoi(S.substr(6, 2));
    return t;
}
void solve(int N) {
    for (int i = 0; i <= MAX; i++) T[i] = 0;
    for (int i = 0; i < N; i++) {
        string st; cin >> st;
        string gl; cin >> gl;
        T[stringToSecond(st)]++;
        T[stringToSecond(gl)]--;
    }
    int ans = 0;
    for (int i = 0; i <= MAX; i++) {
        T[i+1] += T[i];
        ans = max(ans, T[i]);
    }
    cout << ans << '\n';
}
/* main */
int main(){
    while (1) {
        int N;
        cin >> N;
        if (N == 0) return 0;
        solve(N);
    }
}


Measured memory_bytes: 2980
#include <stdio.h>
int k(int);
int main(void)
{
    int N,A,B,i,c=0,wa;
    scanf("%d%d%d",&N,&A,&B);
    for(i = 1;i <= N;i++){
        wa = k(i);
        if(wa <= B&&wa >= A) c += i;
    }
    printf("%d",c);
	return 0;
}
int k(int n)
{
    int i,wa = 0;
    for (i = 1;;i++){
        wa += n % 10;
        if(n / 10 == 0) break;
        n /= 10;
    }
    return wa;
}

Measured memory_bytes: 1688
#define _USE_MATH_DEFINES
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>


using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const long long int INF=1001001001001001001;
int N,K;
char S[15];
vector<int> D;

int main(){
	scanf("%s",&S);
	char ans[15];
	int po=0;
	rep(i,strlen(S)){
		if(S[i]=='0'){ans[po]='0';po++;}
		if(S[i]=='1'){ans[po]='1';po++;}
		if(S[i]=='B'&&po>0){po--;}
	}
	ans[po]='\0';
	
	printf("%s\n",ans);
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=sorted(map(int,input().split()))
l=list()
for i in range(m):
    l.append(list(map(int,input().split())))
l.sort(key=lambda x:-x[1])
i=0
for b,c in l:
    for j in range(b):
        if i+j<n and a[i+j]<c:
            a[i+j]=c
        else:
            print(sum(a))
            exit()
    i+=b
print(sum(a))

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

int main() {
  string S, T;

  cin >> S >> T;
  
  int count = 0;

  for(int i = 0; i < 3; i++){
    if(S[i]==T[i]){
      count++;
    }
  }
  cout << count << endl;

  return 0;
  }




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, m, a[100010], b[100010];
vector<int> vec[100010], vec2[100010];
int cnt[100010];
stack<int> st;
int p[100010];

signed main() {
	cin >> n >> m;
	for (int i = 0; i < n + m - 1; i++) {
		cin >> a[i] >> b[i];
		vec[a[i]].push_back(b[i]);
		vec2[b[i]].push_back(a[i]);
		cnt[b[i]]++;
	}
	for (int i = 1; i <= n; i++) {
		if (!cnt[i]) {
			st.push(i);
			break;
		}
	}
	int k = 0;
	while ((int)st.size()) {
		int s = st.top(); st.pop();
		k++;
		p[s] = k;
		for (int i = 0; i < (int)vec[s].size(); i++) {
			cnt[vec[s][i]]--;
			if (!cnt[vec[s][i]])st.push(vec[s][i]);
		}
	}
	for (int i = 1; i <= n; i++) {
		int ans = 0, ma = 0;
		for (int j = 0; j < (int)vec2[i].size(); j++) {
			if (ma < p[vec2[i][j]]) {
				ma = p[vec2[i][j]];
				ans = vec2[i][j];
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 14848
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * n
    a[0] = 0
    for i in range(1, n):
        hi = h[i]
        s = max(0, i - k)
        a[i] = min(aj + abs(hi - hj) for hj, aj in zip(h[s:i], a[s:i]))
    print(a[-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 13980
#include <stdio.h>

int main( void ) {
	int i;

	for ( i = 0; i < 81; i++ )
		printf( "%dx%d=%d\n", i / 9 + 1, i % 9 + 1, ( i / 9 + 1 ) * ( i % 9 + 1 ) );

	return 0;
}

Measured memory_bytes: 524
from collections import Counter
march = "MARCH"
n = int(input())
initial = Counter([input()[0] for _ in range(n)])
ans = []
for i, num in initial.items():
    if i in march:
        ans.append(num)

x = len(ans)
if x < 3:
    print(0)
elif x >= 3:
    y = 0
    for i in range(0, x-2):
        for j in range(i+1, x-1):
            for k in range(j+1, x):
                y += ans[i] * ans[j] * ans[k]
    print(y)


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

int main(){
    int n;
    cin >> n;
    int ans = 0, keta1 = 0, keta2 = 0, keta3 = 0;
    vector<int> keta(3);
    for(int i = 0; i < 3; i++)
    {
        if ((n%10) == 1) {
            keta.at(i) = 9;
        }
        else if ((n%10) == 9) {
            keta.at(i) = 1;
        }
        else
        {
            keta.at(i) = n % 10;
        }
        n = n / 10;
    }
    cout << keta.at(0) + 10*keta.at(1) + 100*keta.at(2) << endl;
}

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

int main() {
  long X, K, D;
  cin >> X >> K >> D;
  
  long abs_min;
  abs_min = abs(X);
  
  if (abs(X) / D > K) {		//原点を跨がない
    abs_min -= D * K;
  }
  else {					//原点を跨ぐ
    for (int i = 0; i <= K; i ++) {
      if (((K - i) % 2 == 0) && (abs(X) <= D)) {
        abs_min = abs(X);
        break;
      }
      
      if (X > 0) X -= D;
      else X += D;
    }
  }
  cout << abs_min << endl;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool flg=false;
    if (s[0] != 'A') {
        out("WA");
        return 0;
    }
    int cnt=0;
    for (int i=1; i<n; i++){
        if(isupper(s[i])){
            if(i == 1 || i == n-1 || s[i] != 'C'){
                out("WA");
                return 0;
            }
            if(s[i] == 'C') cnt++;
        }
    }
    if(cnt > 1 || cnt == 0) {
        out("WA");
        return 0;
    }

    out("AC");
    return 0;


}

Measured memory_bytes: 256