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

using namespace std;

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

    bool flag1 = false, flag2 = false;
    int s1 = s/100, s2 = s%100;

    if(1<=s1 && s1<=12){
        flag1 = true;
    }

    if(1<=s2 && s2<=12){
        flag2 = true;
    }

    if(flag1==true && flag2==true){
        cout << "AMBIGUOUS" << endl;
    }else if(flag2){
        cout << "YYMM" << endl;
    }else if(flag1){
        cout << "MMYY" << endl;
    }else{
        cout << "NA" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 50;
int n;
ll k, DP[N][N], tmp[N][N], ans[N][N];
void merge(ll (&a)[N][N], ll (&b)[N][N], ll (&c)[N][N]){
  FOR(i, 0, n)FOR(j, 0, n){
    tmp[i][j] = 0;
    FOR(k, 0, n) tmp[i][j] = (tmp[i][j] + a[i][k] * b[k][j]) % MOD;
  }
  FOR(i, 0, n)FOR(j, 0, n) c[i][j] = tmp[i][j];
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  FOR(i, 0, n){
    ans[i][i] = 1;
    FOR(j, 0, n) cin >> DP[i][j];
  }
  while(k > 0){
    if(k%2) merge(ans, DP, ans);
    merge(DP, DP, DP);
    k >>= 1;
  }
  ll s = 0;
  FOR(i, 0, n)FOR(j, 0, n) s += ans[i][j];
  cout << s % MOD << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    ll a, b, c;
    cin >> a >> b >> c;

    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        cout << 0 << '\n';
    } else {
        cout << min({a*b, b*c, c*a}) << '\n';
    }

    return 0;
}

Measured memory_bytes: 504
import re
s = input().replace('?', '.')[::-1]
t = input()[::-1]
for i in range(len(s)-len(t)+1):
  if re.match(s[i:i+len(t)], t):
    print((s[:i].replace('.','a')+t+s[i+len(t):].replace('.','a'))[::-1])
    break
else:
  print('UNRESTORABLE')

Measured memory_bytes: 3188
a = gets.chomp
b = gets.chomp
if a.size > b.size
  b = b.rjust(a.size, '0')
else
  a = a.rjust(b.size, '0')
end

if a > b
  puts 'GREATER'
elsif a == b
  puts 'EQUAL'
else
  puts 'LESS'
end

Measured memory_bytes: 1788
#include <iostream>
#include <math.h>

using namespace std;

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

	int array[8];
	int size = sizeof(array) / sizeof(array[0]);
	for(int i = 0; i < size; i++){
		array[i] = pow(2, i);
	}

	for(int i = size - 1; i >= 0; i--){
		if(array[i] > N){
			continue;
		}else{
			cout << array[i] << endl;
			break;
		}
	}

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define ll long long int
using namespace std;
void solveC(){
    ll x,k,d;
    cin>>x>>k>>d;
    if(x>=0) x-=d;
    else x+=d;
    k--;
    ll ans=abs(x);
    ll y=abs(x);
    ll mov=y/d;
    if(x<0){
        if(mov>=k){
            x+=k*d;
            k=0;
        }
        else{
            x+=mov*d;
            k-=mov;
        }
        if(k&1) x+=d;
    }
    else{
        if(mov>=k){
            x-=k*d;
            k=0;
        }
        else{
            x-=mov*d;
            k-=mov;
        }
        if(k&1) x-=d;
    }
    cout<<abs(x);
}
int main()
{
    solveC();
    return 0;
}


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

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

  vector<int> a(N);
  rep(i, N) {
    cin >> a.at(i);
    a.at(i)--;
  }

  int count = 0;
  int nowIndex = 0;
  while (1) {
    if (count > N) {
      cout << "-1" << endl;
      break;
    }
    if (nowIndex == 1) {
      cout << count << endl;
      break;
    }

    count++;
    nowIndex = a.at(nowIndex);
  }
}


Measured memory_bytes: 640
#include <stdio.h>
int main(){
	int i,a = 0;
	char ram[4];
	scanf("%3s",ram);
	//printf("%s\n",ram);
	for(i=0;i<3;i++){
		if(ram[i] == 'o') a =a+1;
		//printf("%d\n",a );
	}

	printf("%d",700 +a*100);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define fi first
#define se second
#define pb push_back
#define read(type, ...)type __VA_ARGS__; macro_scan(__VA_ARGS__);

using namespace std;

template<typename T> void macro_scan(T& t){cin>>t;};
template<typename F, typename ...R>void macro_scan(F& f , R& ...r){
  cin>>f;macro_scan(r...);
}

void deb(){
    cerr<<endl;
}
template<typename T , typename... t>
void deb(T a , t...b){
    cerr<<a<<" ";
    deb(b...);
}
template<typename T>
void dev(vector<T>v){
    int c = 0;
    for(auto i : v){
        cerr<<i<<" ";
        c++;
    }
    cerr<<endl;
}
const int N = 1e5 + 2;
const int M = 1e9 + 7;
string s;
int dp[N][13];


void add_self(int &a , int b , int Mod){
    a += b;
    if(a >= Mod){
        a -= Mod;
    }
}
int rec(int pos , int rem ){
    if(pos >= s.size())return rem%13 == 5;
    if(dp[pos][rem] != -1)return dp[pos][rem];
    int ans  = 0;
    if(s[pos] == '?'){
        for(int i = 0 ; i < 10; ++i){
            add_self(ans , rec(pos + 1 , (rem * 10 + i)%13) , M);
        }
    }else{
        add_self(ans , rec(pos + 1 , (rem * 10 + s[pos] - '0') % 13),M);
    }
    return dp[pos][rem] = ans;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //int t; cin>>t;for(;t--;)done();
    cin>>s;
    memset(dp , -1 , sizeof(dp));
    cout<<rec(0 , 0)<<"\n";


}




Measured memory_bytes: 13392
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        try (Scanner scan = new Scanner(System.in)) {
            StringBuffer str = new StringBuffer(scan.nextLine());
            System.out.println(str.reverse());
        } catch (Exception e) {
            System.exit(0);
        }
    }
}

Measured memory_bytes: 26264
#include<bits/stdc++.h>
using namespace std;
const int maxx=1e5+10;
typedef long long ll;
int a[maxx];
int main(){
    int n; cin>>n;
    int cnt=0,ans=0;;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(a[i]>a[i-1]){
            cnt=0;
        }else{
            cnt++;
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

// int MOD = 998244353;
int MOD = 1000000007;
int dp[3010][3010][2] = {0};

//----------------------------------------------------------------
signed main(){
   
    int n,t;
	cin >> n >> t;

	vll a(n),b(n);
	rep(i,n)cin >> a[i] >> b[i];

	for(int i = 1;i <= n;i++){
		rep(j,t){
			if(j-a[i-1] >= 0){
				dp[i][j][0] = max(dp[i-1][j-a[i-1]][0]+b[i-1],dp[i-1][j][0]);
			}else{
				dp[i][j][0] = dp[i-1][j][0];
			}
			if(j-a[i-1] >= 0){
				dp[i][j][1] = max(dp[i-1][j-a[i-1]][1]+b[i-1],dp[i-1][j][1]);
			}else{
				dp[i][j][1] = dp[i-1][j][1];
			}
			dp[i][j][1] = max(dp[i][j][1],dp[i-1][j][0]+b[i-1]);
		}
	}

	cout << dp[n][t-1][1] << endl;

	return 0;
}

//----------------------------------------------------------------

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://nikkei2019-2-qual.contest.atcoder.jp/tasks/nikkei2019_2_qual_b
// rm -r -f test;oj dl https://abc145.contest.atcoder.jp/tasks/abc145_b

Measured memory_bytes: 141568
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 200005
#define INF 10000000000000000LL
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
typedef pair <ll,P> PP;
 
struct edge
{
	int to;
	ll cost;
	edge(int to=0,ll cost=0):to(to),cost(cost){}
};
struct UF
{
	int par[SIZE],rank[SIZE];
	
	void init(int n)
	{
		for(int i=0;i<n;i++)
		{
			par[i]=i;
			rank[i]=0;
		}
	}
	int find(int x)
	{
		if(par[x]==x) return x;
		return par[x]=find(par[x]);
	}
	void unite(int x,int y)
	{
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]) par[x]=y;
		else
		{
			par[y]=x;
			if(rank[x]==rank[y]) rank[x]++;
		}
	}
	bool same(int x,int y)
	{
		return find(x)==find(y);
	}
};
UF uf;
vector <edge> vec[SIZE];
ll X[SIZE];
int v1[SIZE],v2[SIZE];
ll d1[SIZE],d2[SIZE];
int id[SIZE],ch[SIZE];
int now_id;
 
void dfs(int v=0,int p=-1)
{
	id[v]=now_id++;
	d1[v]=d2[v]=INF;
	v1[v]=v2[v]=-1;
	for(int i=0;i<vec[v].size();i++)
	{
		edge e=vec[v][i];
		if(e.to!=p)
		{
			dfs(e.to,v);
			ll vl=d1[e.to]+e.cost;
			int vv=v1[e.to];
			if(vl>e.cost+X[e.to])
			{
				vl=e.cost+X[e.to];
				vv=e.to;
			}
			if(vl<d1[v])
			{
				swap(vl,d1[v]);
				swap(vv,v1[v]);
			}
			if(vl<d2[v])
			{
				swap(vl,d2[v]);
				swap(vv,v2[v]);
			}
		}
	}
	ch[v]=now_id;
}
void make(int v=0,int p=-1)
{
	for(int i=0;i<vec[v].size();i++)
	{
		edge e=vec[v][i];
		if(e.to!=p)
		{
			ll vl=d1[v]+e.cost;
			int vv=v1[v];
			if(id[e.to]<=id[vv]&&id[vv]<ch[e.to])
			{
				vl=d2[v]+e.cost;
				vv=v2[v];
			}
			if(vl>e.cost+X[v])
			{
				vl=e.cost+X[v];
				vv=v;
			}
			if(vl<d1[e.to])
			{
				swap(vl,d1[e.to]);
				swap(vv,v1[e.to]);
			}
			if(vl<d2[e.to])
			{
				swap(vl,d2[e.to]);
				swap(vv,v2[e.to]);
			}
			make(e.to,v);
		}
	}
}
int A[SIZE],B[SIZE];
ll C[SIZE];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%lld",&X[i]);
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		ll c;
		scanf("%d %d %lld",&a,&b,&c);a--,b--;
		vec[a].push_back(edge(b,c));
		vec[b].push_back(edge(a,c));
		A[i]=a,B[i]=b,C[i]=c;
	}
	dfs();
	make();
	uf.init(n+2);
	ll ret=0;
	for(int i=0;i<n;i++)
	{
		if(v1[v1[i]]==i&&i<v1[i]) continue;
		ret+=d1[i]+X[i];
		uf.unite(i,v1[i]);
	}
	for(int i=0;i<n-1;i++)
	{
		if(!uf.same(A[i],B[i]))
		{
			ret+=min(X[A[i]],d1[A[i]]);
			ret+=min(X[B[i]],d1[B[i]]);
			ret+=C[i];
		}
	}
	printf("%lld\n",ret);
	return 0;
}

Measured memory_bytes: 43520
#include<iostream>
using namespace std;
int N, i, p, q, j, flg;
int Pn[201][3], Psum[201];
int main(){
    cin >> N;
    for (i=1; i<=N; i++) { Psum[i] = 0;}
    for (i=1; i<=N; i++) {
        for (j=1; j<=3; j++) {
            cin >> Pn[i][j];
        }
    }
    for (j=1; j<=3; j++) {
        for (p=1; p<=N; p++) {
            flg = 0;
            for (q=1; q<=N; q++) {
                if(p == q) { continue;}
                if(Pn[p][j] == Pn[q][j]) { flg = 1; break;}
            }
            if(flg == 0){ Psum[p] += Pn[p][j];}
        }
    }
    for (i=1; i<=N; i++) {
        cout << Psum[i] << endl;
    }
    return 0; 
}

Measured memory_bytes: 3036
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;

/* const */
const int INF = 999999999;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) { std::cout << x << '\n'; }
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

bool intersect(P a, P b, P c, P d) {
  return ((a.X - b.X) * (c.Y - a.Y) + (a.Y - b.Y) * (a.X - c.X)) * 
    ((a.X - b.X) * (d.Y - a.Y) + (a.Y - b.Y) * (a.X - d.X)) > 0.0 && 
    ((c.X - d.X) * (a.Y - c.Y) + (c.Y - d.Y) * (c.X - a.X)) * 
    ((c.X - d.X) * (b.Y - c.Y) + (c.Y - d.Y) * (c.X - b.X)) > 0.0;
}

signed main()
{
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  D a1, a2, b1, b2, c1, c2, d1, d2;

  while (~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &a1, &a2, &b1, &b2, &c1, &c2, &d1, &d2)) {
    P a = P(a1, a2), b = P(b1, b2), c = P(c1, c2), d = P(d1, d2);
    puts(intersect(a, b, c, d) ? "YES" : "NO");
  }

  return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<stdlib.h>
#include<string.h>
using namespace std;
int main(){
	int a,b,k,turn=0;
	cin>>a>>b>>k;
	for(int i=0;i<k;i++){
		if(turn==0){
			if ((a&1)==0){
				a=a/2;
				b+=a;
			}else{
				a--;
				a=a/2;
				b+=a;
			}
			turn++;
		}else{
			if ((b&1)==0){
				b=b/2;
				a+=b;
			}else{
				b--;
				b=b/2;
				a+=b;
			}
				turn--;
			}
		}
		cout<<a<<" "<<b;
		return 0;
		}

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

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  vector<int> V{A, A - 1, B, B - 1};
  sort(V.rbegin(), V.rend());
  cout << V[0] + V[1] << endl;
  return 0;
}


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

int main () {
	int N, T, c[110], t[110], mn = 1001;
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		cin >> c[i] >> t[i];
		if (t[i] <= T) {
			mn = min(mn, c[i]);
		}
	}
	if (mn == 1001) cout << "TLE" << endl;
	else cout << mn << endl;
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];
#define ALL(v)  (v).begin(),(v).end()

    /*  ペア関連
    //vector<pair<long long, long long> > pairs(N);
    for(long long i=0; i<N; i++){
        long long a, b;
        cin >> a >> b;
        pairs[i] = make_pair(a, b);
    }
    
    //sort(pairs.begin(), pairs.end(),greater<pair<int,int> >());
	sort(pairs.begin(), pairs.end());
    */

 	//stack<int> sta;   
    //queue<int> que;


int main(){
	int flg,flg1,cnt,cnt1;
	flg=0;
	flg1=0;
	cnt=0;
	cnt1=0;
	
	int A,B,T;
	string s;
    
	//std::cin >> N;
    //std::cin >> N >> M;
    std::cin >> A >> B >> T;
    
	//std::vector<long long> v(N);
	
    //std::cin >> s;
    
    //ソート
    //std::sort(v.begin(),v.end());//昇順ソート
    //std::sort(v.begin(),v.end(),std::greater<long long>());//降順ソート
    
    // 配列入力
    /*
    for(long long i=0; i<N; i++){
		std::cin >> v[i];
	}
	/*
	for(long long i=0; i<N; i++){
		
	}
	*/
	int i;
	i=1;
	int sum;
	sum=0;
	int A_dummy;
	A_dummy=A;
	while(A_dummy<=T){
		sum+=B;
		i++;
		A_dummy=i*A;
	}
	//文字列入力
	/*
	for(long long i=0; i<s.length(); i++){
		
		if(s[i]!='1'){
	}
	*/
    if(1){
    	printf("%d",sum);
    	//puts("Yes");
    	//文字列の出力
    	//std::cout << s << std::endl;
	}
	else{
		//puts("No");
	}
	return 0;
}

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

int main(void) {
    int N;
    cin >> N;
    vector< string > S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    int AC, WA, TLE, RE;
    AC = WA = TLE = RE = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == "AC") {
            ++AC;
        } else if (S[i] == "WA") {
            ++WA;
        } else if (S[i] == "TLE") {
            ++TLE;
        } else if (S[i] == "RE") {
            ++RE;
        }
    }
    printf("AC x %d\n", AC);
    printf("WA x %d\n", WA);
    printf("TLE x %d\n", TLE);
    printf("RE x %d\n", RE);
    return 0;
}


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

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

enum Mode { Begin, AfterB };
string s;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> s;
  ll cnt = 0;
  ll acca = 0;
  Mode mode = Begin;
  for (size_t i = 0; i < s.size(); i++) {
    if (s.at(i) == 'A') {
      if (mode == AfterB) {
	acca = 1;
      }else {
	acca++;
      }
      mode = Begin;
    }else if (s.at(i) == 'B') {
      if (mode == AfterB) {
	acca = 0;
      }
      mode = AfterB;
    }else if (s.at(i) == 'C') {
      if (mode == AfterB) {
	cnt += acca;
      }else {
	acca = 0;
      }
      mode = Begin;
    }
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 720
import numpy as np

h, w = map(int, input().strip().split())
table = [input().strip() for _ in range(h)]

numbers = np.zeros((h, w), dtype=np.int)

for i in range(h):
    for j in range(w):
        # 上
        up    = 1 if i > 0 and table[i - 1][j] == '#' else 0
        # 下
        down  = 1 if i < h - 1 and table[i + 1][j] == '#' else 0
        # 左
        left  = 1 if j > 0 and table[i][j - 1] == '#' else 0
        # 右
        right = 1 if j < w - 1 and table[i][j + 1] == '#' else 0
        # 左上
        left_up = 1 if j > 0 and i > 0 and table[i - 1][j - 1] == '#' else 0
        # 左下
        left_down = 1 if j > 0 and i < h - 1 and table[i + 1][j - 1] == '#' else 0
        # 右下
        right_down = 1 if j < w - 1 and i < h - 1 and table[i + 1][j + 1] == '#' else 0
        # 右上
        right_up = 1 if j < w - 1 and i > 0 and table[i - 1][j + 1] == '#' else 0

        numbers[i][j] = up + down + left + right \
                      + left_up + left_down + right_down + right_up


for i in range(h):
    for j in range(w):
        if table[i][j] == '#':
            print('#', end='')
        else:
            print(numbers[i][j], end='')
    print('')


Measured memory_bytes: 12796
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 
string s;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
	
	int a,b;
	cin >> a >> b;
	int ans = max(0LL, a-b-b );
	cout << ans << endl;
 

return 0;
}
///....


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

#define ll long long
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define forn(i,n) for(ll i=0; i<(n); i++)
#define fori(i,k,n) for(ll i=k; i<(n); i++) 
#define all(x) (x).begin(),(x).end()
#define en '\n'
#define FILL(x,v) memset(x,v,sizeof(x))
#define pb push_back

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
 
template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
 
template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}


void solve(){
	int n;
	cin >> n;
	// vi a(n), b(n), c(n), dp(n);
	// dp[i] - total cost do activity i on last day
	vi dp(3);
	forn(i,n){
		// cin >> a[i] >> b[i] >> c[i];
		vi a(3), new_dp(3, 0);
		cin >> a[0] >> a[1] >> a[2];
		forn(i,3){
			forn(j,3){
				if(i!=j){
					new_dp[j] = max(new_dp[j], dp[i]+a[j]);
				}
			}
		}
		dp = new_dp;
	}
	cout << max({dp[0],dp[1],dp[2]}) << en;
}

int main(){
    ios::sync_with_stdio(0);
	cin.tie(0);
    cout.tie(0);
 
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#pragma region Macros
// ===========
// include
// ===========
#include <iostream>
#include <vector>
#include <cstdint>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

// ===========
// conversion
// ===========
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

// ===========
// math
// ===========
template<class T> inline T sqr( T x ){ return x * x; }

// ===========
// typedef
// ===========
typedef int64_t int64;
typedef vector<int64> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;

// ===========
// repetition
// ===========
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a), __length = int(b); i < __length; ++i)

void input(vector<int64> *vec, const int size){ vec->resize(size); rep(i, size) { cin >> vec->at(i); } }
void input(vector<string> *vec, const int size){ vec->resize(size); rep(i, size) { cin >> vec->at(i); } }

#pragma endregion //Macros

int main()
{
    int N;
    cin >> N;
    VS S;
    input( &S, N );

    map<string, int> jadges;

    jadges["AC"] = 0;
    jadges["WA"] = 0;
    jadges["TLE"] = 0;
    jadges["RE"] = 0;

    rep(i, N)
    {
        jadges[S.at(i)]++;
    }

    {
        cout << "AC" << " x " << jadges["AC"] << endl;
        cout << "WA" << " x " << jadges["WA"] << endl;
        cout << "TLE" << " x " << jadges["TLE"] << endl;
        cout << "RE" << " x " << jadges["RE"] << endl;
    }

    
    return 0;
}


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

int main(){
	string o,e;
	cin >> o >> e;
	int size = max((int)o.size(), (int)e.size());
	if((int)e.size() != (int)o.size()){
		size--;
		rep(i,size) cout << o[i] << e[i];
		cout << o[o.size()-1] << endl;
	}
	else{
		rep(i,size) cout << o[i] << e[i];
		cout << endl;
	}
}

Measured memory_bytes: 3608
N = int(input())
a = [int(x) for x in input().split()]
MOD = 10**9 + 7
ans = 1

lst = [0] * 3

for aa in a:
    cnt = 0
    j = -1
    for i, l in enumerate(lst):
        if l == aa:
            cnt += 1
            j = i
    if j == -1:
        ans = 0
        break
    ans *= cnt
    ans %= MOD
    lst[j] += 1

print(ans)

Measured memory_bytes: 20784
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DWaterBottle solver = new DWaterBottle();
        solver.solve(1, in, out);
        out.close();
    }

    static class DWaterBottle {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            double a = (double) in.nextInt();
            double b = (double) in.nextInt();
            double x = (double) in.nextInt();
            double res;
            if (x >= a * a * b / 2) {
                res = Math.toDegrees(Math.atan((a * a * b - x) * 2 / a / a / a));
            } else {
                res = Math.toDegrees(Math.atan((a * b * b) / 2 / x));
            }
            out.println(res);
        }

    }
}



Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	string s;
	int q;
	cin>>s>>q;
	vector<char> v;
	rep(i, s.size()){
		v.push_back(s[i]);
	}
	int a, b, d=0;
	char c;
	rep(i, q){
		cin>>a;
		if(a==1){
			if(d==0)
				d=1;
			else
				d=0;
		}
		else{
			cin>>b>>c;
			if((b+d-1)%2==1){
				v.push_back(c);
			}
			else{
				v.insert(v.begin(), c);
			}
		}
	}
	if(d==0){
		rep(i, v.size()){
			cout<<v[i];
		}
	}
	else{
		for(int i=v.size()-1;i>=0;i--){
			cout<<v[i];
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define clear(a, b) memset((a), (b), sizeof(a))
typedef long long LL;
#define Maxn 2009
int n, k;
int read() {
	int x = 0, flag = 1;
	char ch = getchar();
	while(!isdigit(ch)) {
		if(ch == '-') flag = -1;
		ch = getchar();
	}
	while(isdigit(ch)) {
		x = x * 10 + ch - 48;
		ch = getchar();
	}
	return x * flag;
}
int e, head[Maxn], nxt[Maxn << 1], to[Maxn << 1];
int dep[Maxn], size[Maxn], cnt_Dep[Maxn];
void add(int a, int b) {
	to[++e] = b;
	nxt[e] = head[a];
	head[a] = e;
}
void dfs(int a) {
	++cnt_Dep[dep[a]];
	for(int i = head[a]; i; i = nxt[i]) {
		int v = to[i];
		if(!dep[v]){	
			dep[v] = dep[a] + 1;
			dfs(v);
		}
	}
}
int main() {
#ifdef Qrsikno
	freopen("AGC001_3.in", "r", stdin);
	freopen("AGC001_3.out", "w", stdout);
#endif
	n = read(), k = read();
	rep(i, 1, n - 1) {
		int a = read(), b = read();
		add(a, b), add(b, a);
	}
	int ans = INT_MAX;
	if(k & 1) {
		rep(i, 1, n) 
			for(int j = head[i]; j; j = nxt[j]) {
				clear(dep, 0), clear(cnt_Dep, 0);
				dep[i] = dep[to[j]] = 1, dfs(i), dfs(to[j]);
				int cnt = 0;
				rep(l, k / 2 + 2, n)
					cnt += cnt_Dep[l];
				ans = min(ans, cnt);
			}
	}else{
		rep(i, 1, n) {
			clear(dep, 0), clear(cnt_Dep, 0);
			dep[i] = 1, dfs(i);
			int cnt = 0;
			rep(j, k / 2 + 2, n) 
				cnt += cnt_Dep[j];
			ans = min(ans, cnt);
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int N,M,K;
string U[500],V[500];
vector<int> g[500];
int dp[22][601][501][2];
const int L=22;

int main(){
  while(1){
    cin>>N>>M>>K;
    if(N==0)break;

    rep(i,500)g[i].clear();

    vector<string> S;
    rep(i,N){
      cin>>U[i]>>V[i];
      S.push_back(U[i]);
      S.push_back(V[i]);
    }
    sort(all(S));
    uni(S);
    rep(i,N){
      ll u=lower_bound(all(S),U[i])-S.begin();
      ll v=lower_bound(all(S),V[i])-S.begin();
      g[u].push_back(v);
    }
    N=S.size();

    vector<string> P(K),pfx;
    rep(i,K){
      cin>>P[i];
      rep(j,P[i].size()+1)pfx.push_back(P[i].substr(0,j));
    }
    sort(all(pfx));
    uni(pfx);
    int T=pfx.size();

    vector<int> ok(T,0);
    vector<vector<int> > nxt(T,vector<int>(26,-1));
    rep(i,T){
      rep(j,K){
        if(P[j].size()<=pfx[i].size()){
          if(pfx[i].substr(pfx[i].size()-P[j].size(),P[j].size())==P[j])ok[i]++;
        }
      }
      rep(j,26){
        string tmp=pfx[i];
        tmp+='a'+j;
        int k;
        while(1){
          k=lower_bound(all(pfx),tmp)-pfx.begin();
          if(k<T&&pfx[k]==tmp)break;
          tmp=tmp.substr(1);
        }
        nxt[i][j]=k;
      }
    }

    vector<vector<int> > mov(T,vector<int>(N,-1)),cnt(T,vector<int>(N,0));
    rep(i,T){
      rep(j,N){
        mov[i][j]=i;
        rep(k,S[j].size()){
          mov[i][j]=nxt[mov[i][j]][S[j][k]-'a'];
          cnt[i][j]+=ok[mov[i][j]];
        }
      }
    }

    memset(dp,0,sizeof(dp));
    rep(v,N){
      if(cnt[0][v]<=1)dp[S[v].size()][mov[0][v]][v][cnt[0][v]]=1;
    }
    int i=0;
    rep(ri,M){
      i++; i%=L;
      rep(j,T)rep(v,N)rep(f,2)dp[(i-1+L)%L][j][v][f]=0;
      rep(j,T)rep(v,N)rep(f,2){
        for(ll nv : g[v]){
          if(f+cnt[j][nv]<=1&&i+(int)S[nv].size()<=M){
            (dp[(i+S[nv].size())%L][mov[j][nv]][nv][f+cnt[j][nv]]+=dp[i][j][v][f])%=mod;
          }
        }
      }
    }
    ll res=0;
    rep(j,T)rep(v,N)(res+=dp[M%L][j][v][1])%=mod;
    cout<<res<<endl;
  }
  return 0;
}




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


int main() {
  int r, D, x;

  cin >> r >> D >> x;

  
  for (int i = 0; i < 10; i++) {
    x = r * x - D;
    cout << x << endl;
  }
}
/* 2 10 20 */


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int N, M;
typedef vector<int> vec;
typedef vector<vec> mat;

mat mul(mat &A, mat &B) {
    mat C(A.size(), vec(B[0].size()));
    for (int i = 0; i < A.size(); i++) {
        for (int k = 0; k < B.size(); k++) {
            for (int j = 0; j < C.size(); j++) {
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod;
            }
        }
    }
    return C;
}

mat pow(mat A, int n) {
    mat B(A.size(), vec(A.size()));
    for (int i = 0; i < A.size(); i++) {
        B[i][i] = 1;
    }
    while(n > 0) {
        if (n & 1) B = mul(B, A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}
void solve() {
    mat A(M, vec(M));
    rep(i, M) rep(j, M) A[i][j] = 0;
    A[0][0] = 1;
    A[0][M - 1] = 1;
    rep(i, M - 1) A[i + 1][i] = 1;
    A = pow(A, N + 1);
    cout << A[1][0] << endl;
}


signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    mat A(51, vec(51));
    rep(i, N) rep(j, N) cin >> A[i][j];
    A = pow(A, K);
    int ans = 0;
    rep(i, N) {
        rep(j, N) {
            ans = ans + A[i][j];
            ans %= mod;
        }
    }
    cout << ans << endl;




    return 0;
}


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

using namespace std;

int main()
{
    //system("chcp 65001");

    int A,B,X;
    cin >> A >> B >> X;

    if(X > A + B || X < A)
    {
        cout << "NO";
    }
    else
    {
        cout << "YES";
    }
    

    return 0;
}

Measured memory_bytes: 256
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	mx := int(1e6 + 5)
	eras := make([]int, mx)
	usa := make([][]int, mx)
	for i := 2; i < mx; i++ {
		if eras[i] == 0 {
			for j := i; j < mx; j += i {
				eras[j] = i
				usa[j] = append(usa[j], i)
			}
		}
	}
	m := map[int]int{}
	for i := 0; i < n; i++ {
		a := getNextInt(scanner)
		for _, b := range usa[a] {
			m[b]++
		}
	}
	if maxd(m) == 1 || len(m) == 0 {
		fmt.Fprintln(writer, "pairwise coprime")
		return
	}
	for _, c := range m {
		if c == n {
			fmt.Fprintln(writer, "not coprime")
			return
		}
	}
	fmt.Fprintln(writer, "setwise coprime")
}

func maxd(m map[int]int) int {
	var ans int
	for _, c := range m {
		if ans < c {
			ans = c
		}
	}
	return ans
}


Measured memory_bytes: 87408
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = numeric_limits<long long>::max();

int main(){
    int X, Y, Z;
    cin >> X >> Y >> Z;
    int tmp;
    tmp = X;
    X = Y;
    Y = tmp;
    
    tmp = X;
    X = Z;
    Z = tmp;

    cout << X << " " << Y << " " << Z;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef pair<int,int> pi;

const int N=500005,M=200005;

int n,m,k,dist[N];
bool vi[N];
int fr[M],to[M],cl[M];
vector<int> e0[N],e1[N];
map<pi,int> dat;
queue<int> q0,q1;

int makenode(int u,int c){
	pi a={u,c};
	if(!dat.count(a)){
		dat[a]=++k,e0[u].pb(k),e1[k].pb(u);
		return k;
	}
	return dat[a];	
}

void expand(int u){
	if(vi[u])return;
	vi[u]=true;
	for(int v:e0[u])if(dist[v]==-1)dist[v]=dist[u],q0.push(v);
	for(int v:e1[u])if(dist[v]==-1)dist[v]=dist[u]+1,q1.push(v);
}

int main(){
	scanf("%d%d",&n,&m);k=n;
	for(int i=1;i<=m;i++)scanf("%d%d%d",&fr[i],&to[i],&cl[i]);
	for(int i=1;i<=m;i++){
		int u=fr[i],v=to[i],c=cl[i];
		int s=makenode(u,c),t=makenode(v,c);
		e0[s].pb(t),e0[t].pb(s);
	}
	memset(dist,-1,sizeof(dist));
	q0.push(1);dist[1]=0;
	while((q0.size()||q1.size())&&dist[n]==-1){
		if(q0.size())expand(q0.front()),q0.pop();
		else expand(q1.front()),q1.pop();
	}
	printf("%d\n",dist[n]);
	return 0;
}

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

int main(){
  int num,choose,tree[100001],min,dif;
  cin >> num >> choose;
  for(int i = 0; i < num; i++)cin >> tree[i];

  sort(tree,tree + num);
  min = tree[choose - 1] - tree[0];
  for(int i = 1; i <= num - choose; i++){
    dif = tree[i + choose - 1] - tree[i];
    if(dif < min)min = dif;
  }

  cout << min << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>

int main()
{
  int N;
  std::cin >> N;
  int n_odd = 0;

  for ( int i = 0; i < N; i++ ) {
    long tmp;
    std::cin >> tmp;
    if ( tmp % 2 == 1 ) n_odd++;
  }

  if ( n_odd % 2 == 0 ) std::cout << "YES\n";
  else std::cout << "NO\n";
}


Measured memory_bytes: 256
import math
A,B = map(int,input().split())

# low =  math.floor(A / 0.08)
low =  math.ceil(A / 0.08)
high = math.floor((A+1) / 0.08)

# low_B = math.floor(B / 0.1)
low_B = math.ceil(B / 0.1)
high_B = math.floor((B+1) / 0.1)

is_found = False
for price in range(low,high) :
    # print(price)
    if (low_B <= price and price < high_B) :
        is_found = True
        print(price)
        break

if (not is_found) :
    print("-1")


Measured memory_bytes: 3060
import Control.Monad
main = do
  n <- readLn
  x <- replicateM n $ words <$> getLine
  print $ sum $ map f x

f y
  | last y == "JPY" = read $ head y :: Float
  | last y == "BTC" = 380000.0 * g (head y)
  | otherwise = 0.0
g z = read z :: Float

Measured memory_bytes: 636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから
ll f(ll x){
  return x*x*x;
}
void solve(){
  ll n,k;
  cin>>n>>k;
  if(k%2){
    cout<<f(n/k);
  }
  else cout<<f(n/k)+f(2*n/k-n/k);
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}

Measured memory_bytes: 256
/*input
2
1 1
1 1
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits>
#include <random>

using namespace std; 

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;

int const MOD = 1e9+7;

struct points {
	double x, y;
	double rot1x, rot2x;
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	double rot1x[] = {0.707106, -0.707106};
	double rot2x[] = {0.707106, 0.707106};
	ll n;
	cin >> n;
	vector<points> pts(n);
	rep(i, n) {
		cin >> pts[i].x >> pts[i].y;
		pts[i].rot1x = rot1x[0]*pts[i].x+rot1x[1]*pts[i].y;
		pts[i].rot2x = rot2x[0]*pts[i].x+rot2x[1]*pts[i].y;
	}
	points one, two;
	// 45 deg anti-clock
	sort(all(pts), [](points a, points b) {
		return a.rot1x < b.rot1x;
	});
	one=pts[0], two=pts.back();
	ll ans1=abs(one.x-two.x)+abs(one.y-two.y);
	// 45 deg clock
	sort(all(pts), [](points a, points b) {
		return a.rot2x < b.rot2x;
	});
	one=pts[0], two=pts.back();
	ll ans2=abs(one.x-two.x)+abs(one.y-two.y);
	cout << max(ans1, ans2);
	return 0;	
}

Measured memory_bytes: 9532
#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<limits>

using namespace std;

const unsigned long long INF = numeric_limits<unsigned long long>::max() / 100;

struct edge {
    unsigned long long to;
    unsigned long long cost;
};


int main(void){
    unsigned long long N;
    cin >> N;
    vector<vector<edge>> g(N);
    for(unsigned long long i=0; i<N-1; i++){
        unsigned long long a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        g[a].push_back(edge{b, c});
        g[b].push_back(edge{a, c});
    }

    unsigned long long Q, K;
    cin >> Q >> K;
    K--;


    // dijkstra
    using P = pair<unsigned long long, unsigned long long>; // first: distance, second:  vertex
    vector<unsigned long long> d(N, INF);
    priority_queue<P, vector<P>, greater<P>> q;
    d[K] = 0;
    q.push(P(0, K));

    while(!q.empty()){
        P p = q.top(); q.pop();
        unsigned long long v = p.second;
        if(d[v] < p.first) continue;
        for(unsigned long long i=0; i < g[v].size(); i++){
            edge e = g[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                q.push(P(d[e.to], e.to));
            }
        }
    }


    for(unsigned long long i=0; i<Q; i++){
        unsigned long long x, y;
        cin >> x >> y;
        x--; y--;
        cout << d[x] + d[y] <<endl;
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    vi x(3);
    rep(i,3)cin>>x[i];
    sort(ALL(x));
    cout<<x[0]+x[1]<<endl;

    return 0;
}

//a=97,z=122

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

int main(){
  int k,x;cin >>k>>x;
  if(x<-1000001+k){
    for(int i = -1000000; i < x+k;i++){
      cout << i << endl;
    }
  }
  else if(1000000-k+1<x){
    for(int i = x-k+1; i <1000001; i++){
      cout << i << endl;
    }
  }
  else{
    for(int i = x-k+1; i < x+k; i++){
      cout << i << endl;
    }
  }  
}


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

int main()  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(2 * n);
    for (int &it : a) cin >> it;
    sort(a.begin(), a.end());
    int sum = 0;
    for (int i = 0; i < 2 * n; i += 2) {
        sum += a[i];
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3600
/**
 * Created by hiramekun at 20:47 on 2019-11-24.
 */
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n), d(n + 1);

    rep(i, n) cin >> a[i];
    rep(i, n) {
        d[i + 1] = d[i] + a[i];
        d[i + 1] %= k;
    }
    map<ll, ll> mp;
    ll ans = 0;
    queue<ll> que;

    rep(r, n + 1) {
        ll t = (d[r] - r) % k;
        if (t < 0) t += k;

        ans += mp[t];
        mp[t]++;

        que.push(t);
        if (que.size() >= k) {
            mp[que.front()]--;
            que.pop();
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 17536
#include<stdio.h>
int main(){
  int N,A,B;
  scanf("%d",&N);
  scanf("%d",&A);
  scanf("%d",&B);
  
  
  if((N*A)<B){
    printf("%d",N*A);
  }
  else{
    printf("%d",B);
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, start, stop) for (ll i = start; i < stop; i++)
#define FORR(i, start, stop) for (ll i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<ll>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<ll>());
#define REMOVE(v,n) remove(vector<ll> v,v+v.size(),ll n)
#define ERASE(v,n) v.erase(v.begin()+n);
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );



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

    ll N;
    cin>>N;
    string S;
    cin>>S;
    vector<ll> cnt_black(N+1),cnt_white(N);
    cnt_black[N]=0;
    FOR(i,0,N){
        if(i==0) cnt_black[N-1] = S[N-1]=='#' ? 1:0; 
        else{
            if(S[N-1-i]=='#')cnt_black[N-1-i]=cnt_black[N-i]+1;
            else cnt_black[N-1-i]=cnt_black[N-i];
        }
    }

    FOR(i,0,N){
        if(i==0) cnt_white[0] = S[0]=='.' ? 1:0;
        else{
            if(S[i]=='.') cnt_white[i]=cnt_white[i-1]+1;
            else cnt_white[i]=cnt_white[i-1];
        }

    }

    ll ans=INF;
    FOR(i,0,N){
        ans=min(ans,N-cnt_white[i]-cnt_black[i+1]);
    }

    cout<<min(ans,cnt_white[N-1])<<endl;

    

    return 0;
}

Measured memory_bytes: 3732