akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
vector<int> E[2020];

int EE[2020][2],TE[2020][2];
set<int> VE[2020];
vector<int> EL[2020];
int dir[2020];
int cnt[2020][2020];

void shrink(int cur) {
	FORR(c,EL[cur]) dir[c%M] = c/M;
}

int dfs(int cur,int pre,int tar) {
	if(cur==tar) {
		cnt[pre][cur]++;
		return 1;
	}
	else {
		int ok=0;
		FORR(e,E[cur]) if(e!=pre) ok+=dfs(e,cur,tar);
		if(ok&&pre) cnt[pre][cur]++;
		return ok>=1;
	}
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N-1) {
		cin>>x>>y;
		E[x].push_back(y);
		E[y].push_back(x);
	}
	
	dfs(1,1,0);
	FOR(i,M) {
		cin>>EE[i][0]>>EE[i][1];
		dfs(EE[i][0],0,EE[i][1]);
		TE[i][0]=EE[i][0];
		TE[i][1]=EE[i][1];
		VE[EE[i][0]].insert(i);
		VE[EE[i][1]].insert(i+M);
		EL[i].push_back(i);
	}
	
	
	int ret=0;
	for(y=1;y<=N;y++) for(x=1;x<y;x++) ret+=min(2,cnt[x][y]+cnt[y][x]);
	cout<<ret<<endl;
	
	while(true) {
		for(i=1;i<=N;i++) if(E[i].size()==1) break;
		if(i>N) break;
		int cur=i;
		vector<int> delcand;
		FORR(v,VE[cur]) if(v<M && VE[cur].count(v+M)) {
			delcand.push_back(v);
			shrink(v);
		}
		FORR(d,delcand) VE[cur].erase(d),VE[cur].erase(d+M);
		
		
		int p=E[cur][0];
		if(VE[cur].size()>=2) {
			int a=*VE[cur].begin()%M;
			
			VE[TE[a][0]].erase(a);
			VE[TE[a][1]].erase(a+M);
			int b=*VE[cur].begin()%M;
			VE[TE[b][0]].erase(b);
			VE[TE[b][1]].erase(b+M);
			
			if(TE[a][0]==cur) {
				FORR(e,EL[a]) {
					if(e>=M) e-=M;
					else e+=M;
				}
				swap(TE[a][0],TE[a][1]);
			}
			if(TE[b][1]==cur) {
				FORR(e,EL[b]) {
					if(e>=M) e-=M;
					else e+=M;
				}
				swap(TE[b][0],TE[b][1]);
			}
			TE[a][1]=TE[b][1];
			FORR(e,EL[b]) EL[a].push_back(e);
			EL[b].clear();
			VE[TE[a][0]].insert(a);
			VE[TE[a][1]].insert(a+M);
		}
		FORR(v,VE[cur]) {
			TE[v%M][v/M]=p;
			VE[p].insert(v);
		}
		VE[cur].clear();
		E[p].erase(remove(ALL(E[p]),cur),E[p].end());
		E[cur].clear();
	}
	
	for(i=1;i<=N;i++) FORR(v,VE[i]) shrink(v);
	FOR(i,M) cout<<EE[i][dir[i]]<<" "<<EE[i][dir[i]^1]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 15616
n = int(input())
l = []
a = list(input())
l.append(a)
last = a[-1]
for i in range(n-1):
  a = list(input())
  if last != a[0]:
    print("No")
    exit()
  if a in l:
    print("No")
    exit()
  l.append(a)
  last = a[-1]
print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,i,j,k,a[10000];
    cin>>n;
    long long h[n];
    for(i=0;i<n;i++)
    {
        cin>>h[i];
    }
    long long b[n];
    b[0]=0;
    b[1]=abs(h[1]-h[0]);
    for(i=1;i+1 <=n-1;i++)
    {
        b[i+1]=min(b[i-1]+abs(h[i+1]-h[i-1]),b[i]+abs(h[i+1]-h[i]));
    }
    cout<<b[n-1]<<endl;

}


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

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

using namespace std;
typedef long long int ll;

int N, M;
int price[1001];
int keys[1001];

int dp[1001][(1<<12)+1];
int main(void){
    cin >> N >> M;
    int b, c;
    for(int i=1;i<=M;i++){
        scanf("%d %d", &price[i], &b);
        for(int j=1;j<=b;j++){
            scanf("%d", &c);
            keys[i] |= (1 << (c-1));
        }
    }
    for(int i=0;i<=M;i++) for(int j=1;j<(1<<N);j++) dp[i][j] = INF;
    for(int i=1;i<=M;i++){
        for(int j=0;j<(1<<N);j++) dp[i][j] = dp[i-1][j];
        for(int j=0;j<(1<<N);j++) dp[i][(j | keys[i])] = min(dp[i][(j | keys[i])], dp[i-1][j] + price[i]);
    }
    if(dp[M][(1<<N)-1] == INF) cout << -1 << endl;
    else cout << dp[M][(1<<N)-1] << endl;
    return 0;
}



Measured memory_bytes: 16256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 201001;
static const ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline T int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif


ll dp[MAX];
ll dp_minus[MAX];

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	memr(dp, 0);

	dp[0] = 1;
	dp_minus[1] = 1;
	int N, K; cin >> N >> K;
	vector<pair<int, int> > lr(K);
	rep(i, K){
		int l, r; cin >> l >> r;
		lr[i] = {l, r};
	}

	rep(i, N){
		// rep(i, N){
		// 	if(i) cout << " ";
		// 	cout << dp[i];
		// }
		// cout << endl;
		rep(j, K){
			if(i + lr[j].first >= MAX) continue;
			dp[i + lr[j].first] = (dp[i + lr[j].first] + dp[i]) % MOD;
			dp_minus[i + lr[j].second + 1] = (dp_minus[i + lr[j].second + 1] + dp[i]) % MOD;
		}
		dp[i + 1] = (dp[i] + dp[i+1]) % MOD;
		dp[i + 1] = (dp[i+1] - dp_minus[i + 1]) % MOD;
		while(dp[i+1] < 0) dp[i+1] += MOD;
	}
	// rep(i, N){
	// 	if(i) cout << " ";
	// 	cout << dp[i];
	// }
	// cout << endl;


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

	return 0;
}


Measured memory_bytes: 6732
//************************
//** author  :  Alex Hu **
//************************

//  _______        __________         ________        __
//  \      \   ____\______   \ ____  /  _____/  _____/  |_
//  /   |   \ /  _ \|       _// __ \/   \  ____/ __ \   __\
// /    |    (  <_> )    |   \  ___/\    \_\  \  ___/|  |
// \____|__  /\____/|____|_  /\___  >\______  /\___  >__|
//         \/              \/     \/        \/     \/

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define fi first
#define se second
#define sqr(a) ((a)*(a))

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const ll mod=1e9+7;
const int INF=0x3f3f3f3f;
const int MAX=1e5+5;

ll a[MAX],b[MAX],x[MAX],v[MAX];
ll n,c,ans;

int main()
{
	cin>>n>>c;
	rept(i,1,n+1) cin>>x[i]>>v[i];
	for (ll i=1;i<=n;i++) a[i]=a[i-1]+v[i]-(x[i]-x[i-1]);
	x[n+1]=c;
	for (ll i=n;i>=1;i--) b[i]=b[i+1]+v[i]-(x[i+1]-x[i]);
	for (ll i=2;i<=n;i++) a[i]=max(a[i-1],a[i]);
	for (ll i=n-1;i>=1;i--) b[i]=max(b[i],b[i+1]);
	for (ll i=1;i<=n;i++)
	{
		ans=max(ans,a[i]-x[i]+b[i+1]);
		ans=max(ans,b[i]-(c-x[i])+a[i-1]);
		ans=max(ans,a[i]);
		ans=max(ans,b[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
using namespace std;
#define NIL -1

struct Node{int p=NIL,l=NIL,r=NIL,s=NIL,d=0,h=0;};

int printTree(int n,Node T[]){
	for(int i=0;i<n;i++){
		Node nd=T[i];
		cout<<"node "<<i<<": ";
		cout<<"parent = "<<nd.p<<", ";
		cout<<"sibling = "<<nd.s<<", ";
		int deg=0;
		if(nd.l!=NIL)deg++;
		if(nd.r!=NIL)deg++;
		cout<<"degree = "<<deg<<", ";
		cout<<"depth = "<<nd.d<<", ";
		cout<<"height = "<<nd.h<<", ";
		if(nd.p==NIL)cout<<"root";
		else if(deg==0)cout<<"leaf";
		else cout<<"internal node";
		cout<<endl;
	}
}

void setDepth(Node T[],int id,int d){
	T[id].d=d;
	if(T[id].l!=NIL)setDepth(T,T[id].l,d+1);
	if(T[id].r!=NIL)setDepth(T,T[id].r,d+1);
}

int setHeight(Node T[],int id){
	int h1=0,h2=0;
	if(T[id].l!=NIL)h1=setHeight(T,T[id].l)+1;
	if(T[id].r!=NIL)h2=setHeight(T,T[id].r)+1;
	T[id].h = (h1 > h2 ? h1:h2);
	return T[id].h;
}

int main(){
	int n;
	cin >> n;
	Node T[n];
	for(int i=0;i<n;i++){
		int id,l,r;
		cin >> id >> l >> r;
		T[id].l=l;
		T[id].r=r;
		if(l!=NIL){
			T[l].p=id;
			T[l].s=r;
		}
		if(r!=NIL){
			T[r].p=id;
			T[r].s=l;
		}
	}
	int r;
	for(int i=0;i<n;i++){
		if(T[i].p==NIL){
			r=i;
			break;
		}
	}
	setDepth(T,r,0);
	setHeight(T,r);
	printTree(n,T);
	return 0;
}



Measured memory_bytes: 3100
/*
* Welcome to my code!
*---------------------------------------------*
* author : lynmisakura(twitter : @andoreiji11)
*/
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size()) 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using pl = pair<ll,ll>;
using vpl = vector<pl>;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a)
{ int sz = a.size(); for(int i=0;i<a.size();i++)cout << a[i] << (i < sz-1 ? ' ' : '\n'); }
void ioboost(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}
///////////////////////////////////////////////////////////

int main(int argc, char const *argv[])
{
  ioboost();
  
  string s,t;cin >> s >> t;
  if(t.size() == s.size() + 1 && t.substr(0,s.size()) == s){
    cout << "Yes" << '\n';
  }else cout << "No" << '\n'; 

  return 0;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

ll solve1(ll n) {
	ll ret = 1;
	Rep(i, n) {
		ret *= 10;
		ret %= Mod;
	}
	return ret;
}

ll solve2(ll n) {
	ll ret = 1;
	Rep(i, n) {
		ret *= 8;
		ret %= Mod;
	}
	return ret;
}

ll solve3(ll n) {
	ll ret = 1;
	Rep(i, n) {
		ret *= 9;
		ret %= Mod;
	}
	return ret;
}

int main() {
	ll N;
	cin >> N;
	if (N == 1)cout << 0 << endl;
	else {
		ll ans = (solve1(N) - 2 * solve3(N) + solve2(N)) % Mod;
		if (ans < 0) cout << Mod + ans << endl;
		else cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
	ll a,b,c,cnt=0;
	cin>>a>>b>>c;
	while(a%2==0 && b%2==0 && c%2==0)
	{
		if(a==b && b==c)
		{
			cout<<-1;
			return 0;
		}
		ll a1=a,b1=b,c1=c;
		a=(b1+c1)/2;
		b=(a1+c1)/2;
		c=(a1+b1)/2;
		cnt++;
	}
	cout<<cnt;	
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vll a(n), k(n);
  REP(i, n) {
    cin >> a[i] >> k[i];
  }

  int ans = 0;
  REP(i, n) {
    while(a[i] % k[i] && a[i] >= k[i]) {
      int diff = a[i] / k[i] + 1;
      a[i] -= (a[i] - a[i] / k[i] * k[i] - 1) / diff * diff;
      a[i] -= diff;
    }
    if(a[i] >= k[i]) ans ^= a[i] / k[i];
  }

  cout << (ans ? "Takahashi" : "Aoki") << endl;

}
























Measured memory_bytes: 256
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
    int N;
    cin >> N ;
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
  

    int sa;
    sa = 0;
    for (int i = 1; i < N; i++) {
        if (vec.at(i) != vec.at(i - 1)) {
            sa++;
        }
    }
    cout << sa+1 << endl;
}


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

int main(){
    int N;
    char S[100];
    cin >> N;
    for(int i=0;i<N;i++) cin >> S[i];

    bool four=false;
    for(int i=0;i<N;i++) if(S[i]=='Y') four=true;

    cout << (four?"Four":"Three") << endl;
    
    return 0;
}

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

using namespace std;
using i64 = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())

template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int K = 1000;
const int NMAX = 1000;
#define FILENAME ""   
int n, m;
vector <vector <int> > e;

int bfs (int v)
{
	vector <int> d(n, -1); 	
	queue <int> q;
	d[v] = 0;
	q.push(0);
	while (!q.empty())
	{
	 	int x = q.front();
	 	q.pop();
	 	for (int i = 0; i < e[x].size(); i++)
	 	{
	 	 	int to = e[x][i];
	 	 	if (d[to] == -1)
	 	 	{
	 	 	 	d[to] = d[v] + 1;
	 	 	 	q.push(to);
	 	 	}
	 	}
	}
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
	 	if (d[i] != -1) ans += d[i];	
	}
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
//	freopen("symposium.in", "r", stdin);
//	freopen("symposium.out", "w", stdout);
    int a, b, c;
    cin >> a >> b >> c;
    vector <int> d;
    d.pb(a);
    d.pb(b);
    d.pb(c);
    sort(d.rbegin(), d.rend());
    cout << (d[0]*10 + d[1]) + d[2];
    re 0;
}

Measured memory_bytes: 256
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (((a + d - 1) / d) >= ((b + c - 1) / b) ? "Yes" : "No");
}

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


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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
} 
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}
inline void W(int x) {
	static int buf[50];
	if(!x) {putchar('0'); return;}
	if(x<0) {putchar('-'); x=-x;}
	while(x) {buf[++buf[0]]=x%10; x/=10;}
	while(buf[0]) {putchar(buf[buf[0]--]+'0');}
}

const int N=2e5+50,mod=924844033,G=5;
inline int add(int x,int y) {return (x+y>=mod) ? (x+y-mod) : (x+y);}
inline int dec(int x,int y) {return (x-y<0) ? (x-y+mod) : (x-y);}
inline int mul(int x,int y) {return (long long)x*y%mod;}
inline int power(int a,int b,int rs=1) {for(;b;b>>=1,a=mul(a,a)) if(b&1) rs=mul(rs,a); return rs;}

int n,k,sze[N],fac[N],ifac[N];
int f[N*8],g[N*8],pos[N*8],w[N*8];
vector <int> edge[N];
inline int C(int a,int b) {return (a<b) ? 0 : (mul(fac[a],mul(ifac[b],ifac[a-b])));}
inline void dfs(int x,int fa) {
	sze[x]=1;
	for(auto v:edge[x]) if(v!=fa)
		dfs(v,x), sze[x]+=sze[v];
	if(x!=1)++f[sze[x]]; ++f[n-sze[x]];
}
inline void init(int nn) {
	for(k=1;k<=nn;k<<=1);
	for(int i=1;i<k;i++) pos[i]=(i&1) ? ((pos[i>>1]>>1)^(k>>1)) : (pos[i>>1]>>1);
}
inline void dft(int *a) {
	for(int i=1;i<k;i++) if(pos[i]>i) swap(a[pos[i]],a[i]);
	for(int bl=1;bl<k;bl<<=1) {
		int tl=bl<<1,wn=power(G,(mod-1)/tl);
		w[0]=1; for(int i=1;i<bl;i++) w[i]=mul(w[i-1],wn);
		for(int bg=0;bg<k;bg+=tl)
			for(int j=0;j<bl;++j) {
				int &t1=a[bg+j],&t2=a[bg+j+bl],t=mul(t2,w[j]);
				t2=dec(t1,t); t1=add(t1,t);
			}
	}
}
inline void mul(int *a,int *b,int nn) {
	init(nn); dft(a); dft(b); 
	for(int i=0;i<k;i++) a[i]=mul(a[i],b[i]);
	dft(a); reverse(a+1,a+k); const int inv=power(k,mod-2);
	for(int i=0;i<k;i++) a[i]=mul(a[i],inv);
}
int main() {
	n=rd();
	fac[0]=1; for(int i=1;i<=n;i++) fac[i]=mul(fac[i-1],i);
	ifac[n]=power(fac[n],mod-2); for(int i=n-1;~i;i--) ifac[i]=mul(ifac[i+1],i+1);
	for(int i=1;i<n;i++) {
		int x=rd(), y=rd();
		edge[x].push_back(y);
		edge[y].push_back(x);
	} dfs(1,0);
	for(int i=0;i<=n;i++) f[i]=mul(f[i],fac[i]);
	for(int i=0;i<=n;i++) g[i]=ifac[i];
	reverse(f,f+n+1); mul(f,g,2*n);
	for(int i=1;i<=n;i++) {
		int tot=mul(n,C(n,i));
		W(dec(tot,mul(f[n-i],ifac[i])));
		putchar('\n');
	}
}

Measured memory_bytes: 35712
a,b,c,d=input()
ab=int(a)*10+int(b)
cd=int(c)*10+int(d)
if 1<=ab<=12:
  if 1<=cd<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1<=cd<=12:
    print("YYMM")
  else:
    print("NA")

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    vector<vi> c(3, vi(3));
    REP(i, 3) REP(j, 3) cin >> c[i][j];

    bool f = true;

    f &= c[0][0] - c[0][1] == c[1][0] - c[1][1];
    f &= c[1][0] - c[1][1] == c[2][0] - c[2][1];
    f &= c[0][0] - c[0][1] == c[2][0] - c[2][1];

    f &= c[0][1] - c[0][2] == c[1][1] - c[1][2];
    f &= c[1][1] - c[1][2] == c[2][1] - c[2][2];
    f &= c[0][1] - c[0][2] == c[2][1] - c[2][2];

    f &= c[0][0] - c[0][2] == c[1][0] - c[1][2];
    f &= c[1][0] - c[1][2] == c[2][0] - c[2][2];
    f &= c[0][0] - c[0][2] == c[2][0] - c[2][2];

    print(f ? "Yes" : "No");
}

Measured memory_bytes: 3672
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <numeric>
using namespace std;
#define MAX_N 50

// input
int N;
int p[MAX_N];

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

  int temp = 0;
  for (int i = 0; i < N; i++) {
    if (p[i] != i+1) {
      if (temp == 0) {
        temp = i+1;
      } else {
        if (temp == p[i]) {
          temp = 0;
        } else {
          temp = -1;
        }
      }
    }
  }

  if (temp == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){
	fast;
	string s;
	vector<int> v;
	map<int,int> mp;
	int n,m,c=0,t=1;
	//cin>>t;
	while(t--){
		cin>>m>>n;
		int a[n],dmax=0,am=0;
		for(int i=0;i<n;i++) {
			cin>>a[i];
		}
		sort(a,a+n);
		for(int i=1;i<n;i++){
			dmax=max(dmax,a[i]-a[i-1]);
		}
		dmax=max(dmax,m-a[n-1]+a[0]);
		cout<<m-dmax;

	}
	return 0;
}



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

int main()
{
	int n, c;
    string ans;
    cin >> n;
    if(n<10){
      if(n == 2||n==4||n==5||n==7||n==9){
        ans = "hon";
      }else if(n==3){
        ans = "bon";
      }else{
        ans = "pon";
      }
    }else if(n<100){
      c = n%10;
      if(c == 2||c==4||c==5||c==7||c==9){
        ans = "hon";
      }else if(c==3){
        ans = "bon";
      }else{
        ans = "pon";
      }
    }else{
      c = n%10;
      if(c == 2||c==4||c==5||c==7||c==9){
        ans = "hon";
      }else if(c==3){
        ans = "bon";
      }else{
        ans = "pon";
      }
    }
  	
	cout<< ans <<endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
  char a,b;
  while(scanf("%c %c",&a,&b)!=EOF)
  {
   if(a=='H')
   {
      if(b=='H')
          printf("H");
          if(b=='D')
              printf("D");
   }
   if(a=='D')
   {
           if(b=='H')
              printf("D");
              if(b=='D')
                printf("H");
   }
  }
return 0;
}

Measured memory_bytes: 128
while True:
    a = input()
    if a == '0':
        break
    b, c = a[1:].count('A'), a[1:].count('B')
    if b < c:
        d, e = 0, 1
    else:
        d, e = 1, 0
    Ap = b+d
    Bp = c+e
    print(Ap,Bp)


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

int a, b;
char ch;

int main()
{
	for (int i = 1; i <= 3; i++) {
		ch = getchar();
		if (ch == 'A') a++;
		else b++;
	}
	if (a > 0 && b > 0) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int main(){
  	int N;
  	int max = 101;
  	cin >> N;
  	vector<int> d(N),flag(max);
  	for(int i=0;i<N;i++){
      	cin >> d[i];
      	flag[d[i]] = 1;
    }
  	int res=0;
  	for(int i=0;i<max;i++){
      	if(flag[i]) res++;
   	}
  	cout << res << endl;  	
}

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

int main() {
	int N,i;
	cin >> N >> i;
  cout << (N-i)+1 << endl;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))
X_sort = X.copy()
X_sort.sort()
s = N // 2
median = (X_sort[s - 1] + X_sort[s]) / 2

for x in X:
    if x < median:
        print(X_sort[s])
    else:
        print(X_sort[s-1])


Measured memory_bytes: 26180
#include <stdio.h>

int main(void)
{
	int i,m[10],count = 0,st = 10000;
	for(i = 0;i < 10;i++){
	scanf("%d",&m[i]);
	}
	while(count<3)
	{
		for(i = 0;i < 10;i++)
		{
			if(m[i] == st){
				printf("%d\n",m[i]);
				count++;

                                if(count==3)break;
			}
		}
		st--;
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
 
using namespace std;
 
const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;
 
double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}
 
std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}
 
std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}
 
bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }
 
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;
 
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;
const int mod = 1000000007;
 
 
int main() {
    double r;
    cin >> r;
 
    printf("%.20f\n", r * 2 * PI);
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	int N;
	vector<pll> v;
	map<pll, int> mp;

	cin >> N;
	rep(i,N){
		int x, y;
		cin >> x >> y;
		v.emplace_back(x, y);
		mp[pii(x,y)] = i;
	}
	sort(all(v));

	vector<int> cv[2];
	auto check = [&](int i, int k){
		pll a = v[ cv[k][cv[k].size()-2] ];
		pll b = v[ cv[k][cv[k].size()-1] ];
		pll c = v[i];
		if(k == 0) return (b.Y-a.Y) * (c.X-a.X) < (c.Y-a.Y) * (b.X-a.X);
		if(k == 1) return (b.Y-a.Y) * (c.X-a.X) > (c.Y-a.Y) * (b.X-a.X);
	};
	// rep(k,2) rep(i,N){
	// 	while( cv[k].size() >= 2 && check(i, k) ) cv[k].pop_back();
	// 	cv[k].push_back(i);
	// }
	rep(i,N){
		int k = 0;
		while( cv[k].size() >= 2 && check(i, k) ) cv[k].pop_back();
		cv[k].push_back(i);
	}
	rrep(i,N-1){
		int k = 0;
		while( cv[k].size() >= 2 && check(i, k) ) cv[k].pop_back();
		cv[k].push_back(i);
	}

	vector<int> convex;
	for(auto t: cv[0]) convex.push_back(t);
	rrep(i, cv[1].size()-1) convex.push_back(cv[1][i]);
	convex.push_back( cv[0][1] );

	//for(auto i: convex) cout << v[i].X << "," << v[i].Y << endl;

	vector<double> ans(N);
	reps(i, 1, convex.size()-1){
		pll a = v[ convex[i-1] ];
		pll b = v[ convex[i] ];
		pll c = v[ convex[i+1] ];
		double vx1 = - (b.Y - a.Y);
		double vy1 = b.X - a.X;
		double vx2 = - (c.Y - b.Y);
		double vy2 = c.X - b.X;
		double cdot = (vx1*vx2 + vy1*vy2);
		double l1 = sqrt(vx1*vx1 + vy1*vy1);
		double l2 = sqrt(vx2*vx2 + vy2*vy2);
		double ang = acos( cdot / l1 / l2 );
		int n = mp[ v[convex[i]] ];
		ans[n] = ang / 2.0 / M_PI;
	}

	for(auto t: ans) printf("%.20f\n", t);

	return 0;
}

Measured memory_bytes: 384
using System;

class Program
{
 static void Main(string[] args) 
 {
   int cnt = 0;
   int operationNum = 0;
   int step = 0;
   int x = 0;
   int y = 0;
   int stamina = 0;
   int needStep = 0;
   int buff = 0;
   bool result = true;
   String[] operationStr = new String[3];
   
   operationNum = int.Parse(Console.ReadLine());

   int[,] operation = new int[operationNum,3];
   
   for( cnt = 0; cnt < operationNum; cnt++ )
   {
     operationStr = Console.ReadLine().Split(' ');
     operation[cnt,0] = int.Parse(operationStr[0]);
     operation[cnt,1] = int.Parse(operationStr[1]);
     operation[cnt,2] = int.Parse(operationStr[2]);
   }
   
   for( cnt = 0; cnt < operationNum; cnt++ )
   {
     stamina = operation[cnt,0] - step;
     needStep = Math.Abs( (operation[cnt,1] - x) ) + Math.Abs( (operation[cnt,2] - y) );
     
     if( needStep <= stamina )
     {
       buff = stamina - needStep;
       
       if( buff > 0 )
       {
         if( ( buff % 2 ) != 0 ) 
         {
           result = false;
           break;
         }
       }
       
       step = operation[cnt,0];
       x = operation[cnt,1];
       y = operation[cnt,2];
     }
     else
     {
       result = false;
       break;
     }
   }
   
   Console.WriteLine("{0}",(result?"Yes":"No"));
 }
}


Measured memory_bytes: 17316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    long long n,w;
    cin >> n >> w;
    
    vector<vector<long long>> dp(n+1,vector<long long>(w+1,0));
    vector<long long> weight(n),value(n);

    for(int i = 0; i < n; i++) cin >> weight[i] >> value[i]; 

    for(int i = 0; i < n; i++){
        for(int j = 0; j <= w; j++){
            if(weight[i] <= j)
                dp[i+1][j] = max(dp[i+1][j],dp[i][j-weight[i]]+value[i]);
            dp[i+1][j] = max(dp[i][j],dp[i+1][j]);
        }
    }

    long long ans = dp[n][w];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 83168
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String words;
        words = scan.next();
        int n, cuting;
        
        while(!words.equals("-")){
            n=scan.nextInt();
            
            for(int i=0; i<n; i++){
                cuting=scan.nextInt();
                words=words.substring(cuting)+words.substring(0, cuting);
            }
                System.out.println(words);
            words=scan.next();
        }
        
    }
}


Measured memory_bytes: 26416
#include"iostream"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"iomanip"
using namespace std;
typedef long long ll;
const int maxn=2100;
ll a[maxn],b[maxn],c[maxn],ans[2*maxn];
bool a1[2*maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;cin>>n>>m;
    for(int i=0;i<m;++i)
    {
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;b[i]--;
    }
    ll small =- (1LL<<55);
    for(int i=0;i<2*maxn;++i)
        ans[i]=small;
    ans[n-1]=0;
    for(int i=0;i<n-1;++i)
    {
        for(int j=0;j<m;++j)
        {
            ans[a[j]]=max(ans[a[j]],ans[b[j]]+c[j]);
        }
    }
    ll kkk=1000;
    while(kkk--)
    for(int i=0;i<m;++i)
    {
        if(ans[a[i]]<ans[b[i]]+c[i])
        {
            ans[a[i]]=ans[b[i]]+c[i];
            a1[a[i]]=1;
            if(a1[a[i]])
                a1[b[i]]=1;
        }
    }
    if(a1[0])
    {
        cout<<"inf\n";
    }
    else cout<<ans[0]<<'\n';
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;


int main()
{
   FAST/**/
   
   ll n,x,y;
   cin>>n>>x>>y;
   x--,y--;
   vector<ll> v[n];
   rep(n-1)
   {
       ll a,b;
       cin>>a>>b;
       a--,b--;
       
       v[a].pb(b);
       v[b].pb(a);
   }
   
   ll disx[n],disy[n];
   memset(disx,-1,sizeof(disx));
   memset(disy,-1,sizeof(disy));   
   
   disx[x] = 0;
   queue<ll> q;
   q.push(x);
   while(q.size()>0)
   {
       ll curr = q.front();
       q.pop();
       
       autoit(v[curr],it)
       {
           if(disx[*it] != -1)
                continue;
           disx[*it] = disx[curr] + 1;
           q.push(*it);
       }
   }
   
   disy[y] = 0;
   q.push(y);
   while(q.size()>0)
   {
       ll curr = q.front();
       q.pop();
       
       autoit(v[curr],it)
       {
           if(disy[*it] != -1)
                continue;
           disy[*it] = disy[curr] + 1;
           q.push(*it);
       }
   }
   
   ll ans = 0;
   
   rep(n)
   {
       if(disx[i]<=disy[i])
            ans = max(ans,disy[i]);// cout<<disx[i]<<" "<<disy[i]<<" at "<<i+1<<"\n";
   }
   
   cout<<ans-1;
   
   return 0;        
}  
   

Measured memory_bytes: 8064
import java.util.Scanner;

//Angel Stairs
public class Main{
	
	String[] f = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};
	int trans(String s){
		for(int k=0;k<12;k++)if(f[k].equals(s))return k;
		return 0;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		while(T--!=0){
			int n = sc.nextInt(), m = sc.nextInt();
			int[] t = new int[n+2];
			t[0] = t[n+1] = -1;
			for(int i=1;i<=n;i++)t[i]=trans(sc.next());
			int[] s = new int[m];
			for(int i=0;i<m;i++)s[i]=trans(sc.next());
			int p = n;
			boolean con = true;
			for(int k=m-1;k>=0&&con;k--){
				con = false;
				if(p==0||p==n+1)break;
				int np = p-2;
				if(0<=np&&s[k]==(t[p]+1)%12){
					con = true; p = np; continue;
				}
				np = p-1;
				if(0<=np&&s[k]==t[p]){
					con = true; p = np; continue;
				}
				np = p+1;
				if(np<=n&&s[k]==(t[p]+11)%12){
					con = true; p = np; continue;
				}
			}
			if(con&&p==0){
				System.out.println("Yes"); continue;
			}
			p = n-1;
			if(0<=p){
				con = true;
				for(int k=m-1;k>=0&&con;k--){
					con = false;
					if(p==0||p==n+1)break;
					int np = p-2;
					if(0<=np&&s[k]==(t[p]+1)%12){
						con = true; p = np; continue;
					}
					np = p-1;
					if(0<=np&&s[k]==t[p]){
						con = true; p = np; continue;
					}
					np = p+1;
					if(np<=n&&s[k]==(t[p]+11)%12){
						con = true; p = np; continue;
					}
				}
				if(con&&p==0){
					System.out.println("Yes"); continue;
				}
			}
			System.out.println("No");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 15000
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int num(long long n)
{
    ll t,p;
    t=((int)(log10(n)));
    p=(int)(n/(int)(pow(10,t)));
    return p;
}
int main()
{
    ll N,i,j,s,k=0;
    ll a[10][10]={0};
    cin>>N;
    for(i=1;i<=N;i++){
        if(i%10==0) continue;
        else{
            s=num(i);
            a[s][i%10]++;
        }
    }
    for(i=1;i<=9;i++){
        for(j=1;j<=9;j++){
            k+=a[i][j]*a[j][i];
        }
    }
    cout<<k<<endl;
}

Measured memory_bytes: 3944
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int,int> > vp;

struct square
{
  int x=0;
  int y=0;
};
int main()
{
  while(1)
    {
      int n;
      cin >> n;
      if(!n) break;
      else if(n==1) cout << 1 << ' ' << 1 << endl;
      else
	{
	  vector<square> s(n);
	  for(int i=1;i<n;i++)
	    {
	      pair<int,int> intro;
	      cin >> intro.first >> intro.second;
	      if(intro.second==1)
		{
		  s[i].y=s[intro.first].y-1;
		  s[i].x=s[intro.first].x;
		}
	      else if(intro.second==3)
		{
		  s[i].y=s[intro.first].y+1;
		  s[i].x=s[intro.first].x;
		}
	      else if(intro.second==0)
		{
		  s[i].x=s[intro.first].x-1;
		  s[i].y=s[intro.first].y;
		}
	      else if(intro.second==2)
		{
		  s[i].x=s[intro.first].x+1;
		  s[i].y=s[intro.first].y;
		}
	    }
	  int colmax=0;
	  int rowmax=0;
	  for(int i=0;i<n;i++)
	    {
	      for(int j=0;j<n;j++)
		{
		  if(i==j) continue;
		  if(colmax<(s[i].y-s[j].y+1)) colmax=(s[i].y-s[j].y+1);
		  if(rowmax<(s[i].x-s[j].x+1)) rowmax=(s[i].x-s[j].x+1);
		}
	    }
	  cout << rowmax << ' ' <<  colmax << endl;
	}
    }
  return 0;
}
      



Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

 
int main() {
    while(true){
    int n;
    cin >> n;
    if (n==0) break;
    vector<int> a(2*n,0);
    rep(i,n){
        int f;
        cin >> f;
        a[f-1]=1;
    }
    int t=n,tt=n,c=1;
    while(true){
        if (t==0 || tt==0) break;
        rep(i,2*n){
            if (a[i]==c){
                if (c==1) t--;
                else tt--;
                a[i]=2;
                c=1-c;
            }
            if (t==0 || tt==0) break;
        }
        c=1-c;
    }
    cout << tt << endl;
    cout << t << endl;
    }

}


Measured memory_bytes: 3024
k = gets.chomp.to_i
puts [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][k-1]


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
#define P pair<int,int>
typedef long long ll;
using namespace std;

int main(){
    ll n,k; cin >> n >> k;
    ll times=n/k;
    ll ans=n-k*times;
    cout << min(ans,abs(ans-k)) << endl;
return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RInt;
            var c = new int[n - 1];
            var s = new int[n - 1];
            var f = new int[n - 1];
            for (int i = 0; i < n - 1; i++)
            {
                var csf = IO.RSInt;
                c[i] = csf[0];
                s[i] = csf[1];
                f[i] = csf[2];
            }

            for (int i = 0; i < n; i++)
            {
                int t = 0;
                for (int j = i; j < n - 1; j++)
                {
                    if (t < s[j]) t = s[j];
                    else if (t % f[j] == 0) ;
                    else t = t + f[j] - t % f[j];
                    t += c[j];
                }
                WriteLine(t);
            }
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 28456
#include <stdio.h>
#include <stdio.h>
int main(void){
    // Your code here!

    int x,y,temp;
    while(1){
      scanf("%d %d",&x,&y);
      if(x>y){
        temp = x;
        x = y;
        y = temp;
      }
      if( (x+y)==0 )break;
      printf("%d %d\n",x,y);
    }
}



Measured memory_bytes: 1844
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int n=b-a;
    int total=0;
    for(int i=0;i<n;i++){
      total+=n-i;
    }
    System.out.println(total-b);

    sc.close();

  }
}

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

int main(){
  int n,m,X,Y;
  cin >> n >> m >> X >> Y;
  vector<int> x(n+1,X);
  vector<int> y(m+1,Y);
  for(int i=0;i<n;i++)cin >> x.at(i);
  for(int i=0;i<m;i++)cin >> y.at(i);
  
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  
  if(x.at(n)<y.at(0)) cout << "No ";
  
  cout << "War" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int number;
	public static void main(String[] args){
		while(read()){
			slove();
		}
	}
	static boolean read(){
		if(!sc.hasNextInt()){
			return false;
		}
		
		number = sc.nextInt();
		return true;
	}
	static void slove(){
		int a, b, c, d, count;
		count = 0;
		for(a = 0; a < 10; a++){
			for(b = 0; b < 10; b++){
				for(c = 0; c < 10; c++){
					for(d = 0; d < 10; d++){
						if(a+b+c+d == number){
							count++;
						}
					}
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 11;
#define LL long long
int n;
LL a[N], f[N][2];
int main(){
    cin>>n;
    for(int i = 1;i <= n; i++){
        scanf("%lld", &a[i]);
    }
    memset(f, -127, sizeof f);
    f[0][0] = 0;
    for(int i = 0;i < n / 2; i++){
        for(int j = 0;j <= 1; j++){
            LL F = f[i][j];
            f[i+1][1] = max(f[i+1][1], F + a[i*2+2]);
            if(j != 1)f[i+1][0] = max(f[i+1][0], F + a[i*2+1]);
        }
    }
    if(n & 1){
        LL sum = a[n];
        LL ans = max(f[n/2][1], f[n/2][0]);
        for(int i = n - 2;i >= 1; i -= 2){
            ans = max(ans, sum + max(f[(i-1)/2][0], f[(i-1)/2][1]));
            sum += a[i];
        }
        cout<<ans<<endl;

    }
    else {
        printf("%lld\n", max(f[n/2][0], f[n/2][1]));
    }
    return 0;
}


Measured memory_bytes: 8400
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cctype>
#include <cstdio>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  string number;
  while(1){
    cin >> number;
    if(number =="0")
      break;
    int sum=0;
    REP(i,number.size())
    sum +=(int)(number[i]-'0');
    cout << sum << endl;
    sum=0;//clear
  }
}

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

using namespace std;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(int i = 0;i < n;++i)
long long H,W,K,N,D;
long long A=0;
int main()
{
  string a;
  int l=0,c=0;
  vector<int>s;
  cin>>a;
  for(int i=0;i<a.size();i++){
    if(a[i]=='0')s.push_back(0);
    if(a[i]=='1')s.push_back(1);
    if(a[i]=='B')if(!s.empty())s.pop_back();
  }
  REP(i,s.size())cout<<s[i];
  
  return 0;
}

Measured memory_bytes: 3596