akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(decltype(N+k) i=k; i<N;i++)
#define rep(i,N) for(decltype(N) i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数unordered_set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

// check prime (and n>=2) or not
auto isPrime = [](auto n){
  if(n <= 1) return false;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return true;
};



int main() {
    ll n;
    cin>>n;
    ll a = (double)n / 1.08;
    bool b= false;
    ll m;
    fr(i, a, n+1){
        if((ll)(i * 1.08) == n) {
            b = true;
            m = i;
            break;
            }
    }
    if(b){
        pr(m);
    }else{
        pr(":(");
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int,int> P;

const int N=1005;
const ll INF=1e18;
int n,m;
vector<P> adj;
vector<int> nxt[N],rev[N];
ll c[N][N],d[N],dp[N];
vector<int> topo;
bool neg[N];

void neg_cycle(){
	for(int i=1;i<=n;++i)
		d[i]=INF;
	d[1]=0;
	for(int i=0;i<n-1;++i){
		for(auto it:adj){
			int u=it.first;
			int v=it.second;
//			if(d[u]==INF) continue;
			if(d[u]+c[u][v]<d[v]) 
				d[v]=d[u]+c[u][v];
		}
	}
	for(int i=0;i<n-1;++i){
		for(auto it:adj){
			int u=it.first;
			int v=it.second;
//			if(d[u]==INF) continue;
			if(d[u]+c[u][v]<d[v]){
				d[v]=d[u]+c[u][v];
				neg[v]=true;
			}
			neg[v]|=neg[u];
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<m;++i){
		int u,v;
		ll w;
		cin>>u>>v>>w;
		c[u][v]=-w;
		adj.emplace_back(u,v);
	}
	neg_cycle();
	if(neg[n]) cout<<"inf\n";
	else cout<<-d[n]<<'\n';
}




Measured memory_bytes: 8780
k = int(input())
dp = [[0] * 10 for _ in range(11)]
for i in range(10):
    dp[0][i] = 1
for i in range(1,11):
    dp[i][0] = dp[i-1][0] + dp[i-1][1]
    dp[i][9] = dp[i-1][8] + dp[i-1][9]
    for j in range(1,9):
        dp[i][j] = dp[i-1][j] + dp[i-1][j-1] + dp[i-1][j+1]

#print(dp)

ans = ""
cumsum = 0
brflag = False
for i in range(11):
    for j in range(1,10):
        cumsum += dp[i][j]
        if cumsum >= k:
            ans += str(j)
            k -= cumsum - dp[i][j]
            brflag = True
            break
    if brflag == True:
        brflag = False
        break
        
while i > 0:
    #print(i,j,k)
    i -= 1
    cumsum = 0
    psfl = False
    if j > 0:
        cumsum += dp[i][j-1]
        if cumsum >= k:
            ans += str(j-1)
            k -= cumsum - dp[i][j-1]
            j = j - 1
            #print("pass1")
            psfl = True
    if not psfl:
        cumsum += dp[i][j]
        if cumsum >= k:
            ans += str(j)
            k -= cumsum - dp[i][j]
            psfl = True
            #print("pass2")
    if (not psfl) and j < 9:
        cumsum += dp[i][j+1]
        if cumsum >= k:
            ans += str(j+1)
            k -= cumsum - dp[i][j+1]
            j = j + 1
            psfl = True    
            #print("pass3")
print(ans)

Measured memory_bytes: 3188
A, B, C, D = input()

A = int(A)
B = int(B)
C = int(C)
D = int(D)

def calc(a, b, c, d, s):
  for _b in [b, -b]:
    for _c in [c, -c]:
      for _d in [d, -d]:
        if a + _b + _c + _d == s:
          return a, _b, _c, _d
  return False


print('{}{:=+}{:=+}{:=+}=7'.format(*calc(A, B, C, D, 7)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using mat = vector<vector<LL>>;
const LL mod=1e9+7;

mat matmul(mat &A, mat &B){
	mat C(A.size(),vector<LL>(B[0].size()));
	rep(i,A.size()){
		rep(k,B.size()){
			rep(j, B[0].size()){
				(C[i][j]+=A[i][k]*B[k][j])%=mod;
			}
		}
	}
	return C;
}

mat matpow(mat A, LL n){
	mat C(A.size(),vector<LL>(A.size()));
	rep(i,A.size()) C[i][i]=1;
	while(n>0){
		if(n&1) C=matmul(C,A);
		A=matmul(A,A);
		n>>=1;
	}
	return C;
}

int main(){
	int N;
	cin >> N;
	LL K;
	cin >> K;
	mat a(N,vector<LL>(N));
	rep(i,N){
		rep(j,N) cin >> a[i][j];
	}
	mat b=matpow(a,K);
	LL ans=0;
	rep(i,N){
		rep(j,N) (ans+=b[i][j])%=mod;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DEBUG_OUTPUT_ENABLED 1
	#define DBG(X) dout << #X << "=" << (X) << '\n';
	#define SAY(X) dout << (X) << '\n';
#else
	#define DEBUG_OUTPUT_ENABLED 0
	#define DBG(X) 42;
	#define SAY(X) 42;
#endif

#define dout   ___debug::instance

using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const multiset<T>& v) { for(auto el: v) cout << el << " "; return os; }
namespace ___debug {
	struct DebugStream {
		private:
			bool is_first;
		public:
			DebugStream(bool _is_first): is_first(_is_first) {}
			template<typename T> DebugStream operator<<(const T& value) const {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				cout << value;
				return DebugStream(false);
			};

			template<typename T> DebugStream printArray(T* l, T* r) {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				while(l != r) {
					cout << (*l);
					++l;
					if(l == r) {
						cout << '\n';
					} else {
						cout << ' ';
					}
				}
				return DebugStream(false);
			}
	};
	DebugStream instance(true);
};

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	ll A = fetch<ll>();	
	int n = fetch<int>();
	for(int i = 0; i < n; ++i) A -= fetch<ll>();
	if(A < 0) A = NIL;
	cout << A << '\n';	
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 3660
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
ll arr[200101];
ll rec[200101];
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    for(ll i=1;i<=n;i++)cin>>arr[i];
    map<ll,ll> vis;
    if(arr[1]==1)
    {
        cout<<1<<endl;
        return 0;
    }
    ll p=1;
    ll cnt=1,f_in,l_in;
    while(true)
    {
        p=arr[p];
        if(vis.count(p))
        {
            f_in=vis[p];
            l_in=cnt-1;
            break;
        }
        else
        {
            rec[cnt]=p;
            vis[p]=cnt;
            cnt++;
        }
    }
//    cout<<"first index= "<<f_in<<" last index= "<<l_in<<endl;
    if(k<=f_in)
        cout<<rec[k]<<endl;
    else
    {
        ll len=l_in-f_in+1;
        map<ll,ll> ans;
        for(ll i=f_in;i<=l_in;i++)
            ans[i%len]=rec[i];
        cout<<ans[k%len]<<endl;
    }
    return 0;
}


Measured memory_bytes: 26484
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

vector<pint> vp[500001];
int d[100001];
int INF=1000100010;
int n;
int dijkstra(int st){
    priority_queue<pint,vector<pint>,greater<pint> > pq;
    rep(i,n) d[i]=INF;
    d[st]=0;
    pq.push(make_pair(0,st));
    while(!pq.empty()){
        pint pi=pq.top();pq.pop();
        int t=pi.second;
        if(d[t]<pi.first) continue;
        for(auto it:vp[t]){
            if(d[it.second]>d[t]+it.first){
                d[it.second]=d[t]+it.first;
                pq.push(make_pair(d[it.second],it.second));
            }
        }
    }
}
int main(){
    cin>>n;
    int u,k,v,c;
    rep(i,n){
        cin>>u>>k;
        rep(j,k){
            cin>>v>>c;
            vp[u].pb(c,v);
        }
    }
    dijkstra(0);
    rep(i,n){
        cout<<i<<" "<<d[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 14884
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

typedef ll Id;
typedef ll Distance; // doubleに変更する可能性もある為必要
#define INF_DIST TEN(15)
struct Edge { Id to; Distance cost; };
typedef vector<vector<Edge>> Graph;
vector<Distance> dijkstra(Id s, const Graph & g) {
	vector<Distance> d(g.size(), INF_DIST);
	d[s] = 0;

	typedef pair<Distance, Id> P;
	priority_queue<P, vector<P>, greater<P>> que;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		Id v = p.second;
		if (d[v] < p.first) continue;
		for (Edge e : g[v]) if (d[e.to] > d[v] + e.cost) {
			d[e.to] = d[v] + e.cost;
			que.push(P(d[e.to], e.to));
		}
	}

	return d;
}

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n, m, s, t; cin >> n >> m >> s >> t;
	s--, t--;

	vector<vector<Edge>> g(n);
	vector<vector<Edge>> g2(n);
	REP(i, m) {
		ll u, v, a, b; cin >> u >> v >> a >> b; u--, v--;
		g[u].push_back({ v, a });
		g[v].push_back({ u, a });
		g2[v].push_back({ u, b });
		g2[u].push_back({ v, b });
	}
	auto dist1 = dijkstra(s, g);
	auto dist2 = dijkstra(t, g2);

	ll mi = TEN(15);
	vl ans(n);
	for (ll i = n - 1; i >= 0; --i) {
		ans[i] = (mi = min(mi, dist1[i] + dist2[i]));
	}
	REP(i, n) {
		cout << TEN(15) - ans[i] << "\n";
	}

	return 0;
}


Measured memory_bytes: 19200
/*
２つの整数 a と b を読み込んで、以下の値を計算するプログラムを作成して下さい：

a ÷ b ： d (整数)
a ÷ b の余り ： r (整数)
a ÷ b ： f (浮動小数点数)
 */

#include <stdio.h>

int main(void)
{
    int a, b;
    int devision, remainder;
    double double_point;

    devision = remainder = 0;
    double_point = 0.0;

    scanf("%d %d", &a, &b);

    devision = a / b;
    remainder = a % b;
    double_point = (double)a / (double)b;

    // Floatの箇所で問題あり？
    printf("%d %d %f\n", devision, remainder, double_point);
    return (0);
}


Measured memory_bytes: 2116
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    string s;
    cin >> s;
    unordered_map<char, ll> cnt;
    ll ans = 0;
    for(char c: s) {
        cnt[c] += 1;
    }
    ll n = s.size();
    ans = n*(n+1) / 2;
    for(auto p: cnt) {
        ll freq = p.second;
        ans -= freq*(freq+1) / 2;
    }
    cout << ans+1 << endl; // original
    return 0;
}




Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
int a[100010],b[100010],father[100010];
long long n,m,ans[100010],sum[100010];
int find_father(int x)
{
	while(father[x]!=x)
		x=father[x];
	return x;
}
int main()
{
	int i,x,y;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		father[i]=i;
		sum[i]=1;
	}
	for(i=1;i<=m;i++)
		cin>>a[i]>>b[i];
	ans[m]=n*(n-1)/2;
	for(i=m;i>=2;i--)
	{
		x=find_father(a[i]);
		y=find_father(b[i]);
		father[a[i]]=x;
		father[b[i]]=x;
		if(x!=y)
		{
			ans[i-1]=ans[i]-sum[x]*sum[y];
			sum[x]+=sum[y];
			father[y]=x;
		}
		else
			ans[i-1]=ans[i];
	}	
	for(i=1;i<=m;i++)
		cout<<ans[i]<<endl;	
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>


int a, b, c;

int main()
{
    std::cin >> a >> b >> c;
    bool can = false;

    for (int i=0; i <= b; i++)
    {
      int m = (a * i) % b;
      if(m == c) can = true;
    }
    std::string s = (can) ? "YES" : "NO";
    std::cout << s << '\n';

}


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

inline int read(){
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	x=c-48;
	while((c=getchar())>='0'&&c<='9')x=x*10+c-48;
	return x;
}

char s[1000000];

int main(){
	scanf("%s",s);
	s[strlen(s)-8]=0;
	puts(s);
	return 0;
}

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

int main(){
  //迷路を表す配列
  string maze[1005];
  int sx=0, sy=0;//スタート座標
  int gx=0, gy=0;//ゴール座標
  int d[1005][1005];//各位置への最短ワープ回数

  int dx[4]={1,0,0,-1};
  int dy[4]={0,1,-1,0};
  int ex[20]={1,1,-1,-1,2,2,2,2,2,1,1,0,0,-1,-1,-2,-2,-2,-2,-2};
  int ey[20]={1,-1,1,-1,-2,-1,0,1,2,-2,2,-2,2,-2,2,-2,-1,0,1,2};

  int x, y;
  cin >> x >> y;
  cin >> sx >> sy;sx--;sy--;
  cin >> gx >> gy;gx--;gy--;
  
  rep(i, x){
    cin >> maze[i];
  }

  rep(i, x){
    rep(j, y){
      d[i][j]=INF;
    }
  }

  queue<P> q;
  q.push(P(sx,sy));//スタート位置
  d[sx][sy]=0;
  int warp = 0;
  while(1){
    int count = 0;
    set<P> r;//ワープ可能な位置
    while(q.size()>0){
      P p=q.front();q.pop();
      // ゴールなら探索をやめる
      // if(p.first==gx&&p.second==gy){
      //   cout << d[gx][gy];
      //   return 0;
      // }

      bool flag = false;
      rep(i, 4){
        int nx = p.first+dx[i], ny = p.second+dy[i];
        //訪れたことがないところにワープせずに移動可能
        // cout << "(" << nx << "," << ny << ")";
        if(0<=nx&&nx<=x&&0<=ny&&ny<=y&&maze[nx][ny]=='.'&&d[nx][ny]==INF){
          d[nx][ny]=warp;
          q.push(P(nx,ny));
        }
      }
      rep(i, 20){
        int nx = p.first+ex[i], ny = p.second+ey[i];
        //ワープ可能な位置として追加しておく
        if(0<=nx&&nx<=x&&0<=ny&&ny<=y&&maze[nx][ny]=='.'&&d[nx][ny]==INF){
          r.insert(P(nx,ny));
        }
      }
    }
    //ワープ可能な位置の計算
    warp++;
    for(auto pp:r){
      if(d[pp.first][pp.second]==INF){
        q.push(pp);
        d[pp.first][pp.second]=warp;
        // cout << "warp(" << pp.first << "," << pp.second << ")";
        count++;
      }
    }
    // cout << count;
    //ワープもできないしどこにも移動できない
    if(count == 0)break;
  }  

  // rep(i, x){
  //   rep(j, y){
  //     if(d[i][j]==INF)cout << '#';
  //     else cout << d[i][j];
  //   }
  //   cout << endl;
  // }
  if(d[gx][gy]==INF)cout << "-1";
  else cout << d[gx][gy];

  return 0;
}


Measured memory_bytes: 9912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int MAXN=1e5+10;
int n,a[MAXN];
set<int> s;
map<int,int> p;
set<int>::iterator it;
bool judge()
{
	for(int i=1;i<=n;++i)
	{
		s.insert(a[i]);
		++p[a[i]];
	}
	if(n%3==0)
	{
		if(s.size()>3)
			return false;
		int sz=s.size();
		int x[3];
		it=s.begin();
		for(int i=0;i<3;++i)
		{
			x[i]=*it;
			if(s.size()>1)
				s.erase(it);
			it=s.begin();
		}
		if(sz==3)
			return ((x[0]^x[1])==x[2]) && p[x[0]]==n/3 && p[x[1]]==n/3;
		if(sz==2)
			return (x[0]==0) && p[x[0]]==n/3;
		if(sz==1)
			return (x[0]==0);
	}
	return s.size()==1 && a[1]==0;
}
int main()
{
	n=read();
	for(int i=1;i<=n;++i)
	{
		a[i]=read();
		p[a[i]]=0;
	}	
	if(judge())
		puts("Yes");
	else
		puts("No");
	return 0;
}


Measured memory_bytes: 7808
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	int n; cin >> n;
	vvl d(n,vl(2));
	rep(i,n) rep(j,2) cin >> d[i][j];
	rep(i,n-2){
		if(d[i][0] == d[i][1] && d[i+1][0] == d[i+1][1] && d[i+2][0] == d[i+2][1]){
			cout << "Yes" << "\n";
			return 0;
		}
	}
	cout << "No" << "\n";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int A, B;
  cin >> A >> B;
  if (A == 1)
    A = 14;
  if (B == 1)
    B = 14;

  string ans = "Draw";
  if (A > B)
    ans = "Alice";
  else if (A < B)
    ans = "Bob";

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, m; cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
}

Measured memory_bytes: 256
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
//import static java.lang.System.*; はしばらく使わなそう(使うとしてもexit(0)のためだけ)←return;でよさそう
最後にout.flush()またはout.close()をするのを忘れずに！
*/
//入力終了→Ctrl+D
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        int n = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        ArrayDeque<Integer> ans = new ArrayDeque<>();
        int c=1;
        while (c==1&&!list.isEmpty()) {
            for (int i = list.size() - 1; i > -1; i--) {
                if (list.get(i) == i + 1) {
                    ans.push(list.get(i));
                    list.remove(i);
                    c=1;
                    break;
                }else c=0;
            }
        }
        if(list.size()>0){
            out.println(-1);
        }else {
            while (!ans.isEmpty()){
                out.println(ans.pop());
            }
        }
        out.close();
    }

    static PrintWriter out = new PrintWriter(System.out);

    static class sc {
        static Scanner s = new Scanner(System.in);

        static String next() {
            return s.next();
        }

        static int nextInt() {
            return Integer.parseInt(s.next());
        }

        static long nextLong() {
            return Long.parseLong(s.next());
        }

        static double nextDouble() {
            return Double.parseDouble(s.next());
        }
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define pii pair<int, int>
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
using namespace std;



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

	string s, t;
	cin >> s >> t;
	int ans = INT_MAX;
	for (int i = 0; i < s.size() - t.size() + 1; i++) {
		string temp = s.substr(i, t.size());
		int cnt = 0;
		for (int j = 0; j < temp.size(); j++) {
			if (temp[j] != t[j]) {
				cnt++;
			}
		}

		ans = min(ans, cnt);
	}

	cout << ans << '\n';
	

}

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

int main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if (s < t){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int main(){
	int a,b;
	cin >> a >> b;
	
	int cnt = 1;
	int plug = a;
	while(plug < b){
		cnt++;
		plug += a-1;
	}

    if(b==1) cout << 0 << endl;
	else cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())

a = [int(input()) for i in range(N)]

a = sorted(a)

t = 0
b = False
ans = 0
for i in range(N):
    if not a[i] == t:
        if b:
            ans += 1
        t = a[i]
        b = True
    else:
        if b:
            b = False
        else:
            b = True
if b:
    ans += 1


print(ans)

Measured memory_bytes: 8284
use std::io;
use std::collections::HashMap;


/// https://beta.atcoder.jp/contests/abc061/tasks/abc061_b
fn main() {
    let (n, m) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let mut hm = HashMap::new();
    for _ in 0..m {
        let i = read::<usize>();
        *hm.entry(i[0] - 1).or_insert(0) += 1;
        *hm.entry(i[1] - 1).or_insert(0) += 1;
    }

    for i in 0..n {
        println!("{}", hm.get(&i).unwrap_or(&0));
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll A,B,N;
	cin>>A>>B>>N;

	ll m = A - 1,x;

	//max value oocurs at B-1;

	if(N >= B - 1)
	{
		x = B-1;
	}

	else
	{
		x = N;
	}

	ll res = floor(A*(x)/B) - A * floor((x)/B);

	cout<<res<<endl; 

	return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c;
int main()
{
    cin>>a>>b>>c;
    if(a>=b) swap(a,b);
    if((c>=a)&&(c<=b)) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
class Main
{
	public static void main(String[] args)throws Exception
	{
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		int x;
		int sum=0;
		x=Integer.parseInt(br.readLine());
		sum=x*x*x;
		System.out.println(sum);
	}
}

Measured memory_bytes: 24352
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s =new Scanner(System.in);
        String input=s.nextLine();
        List<Character> cl=new ArrayList<>();
        for(int i=0;i<input.length();i++){
            cl.add(input.charAt(i));
        }
        boolean flag=false;

        if(Collections.frequency(cl,'S')==3){
            System.out.println("0");
        }
        else if(Collections.frequency(cl,'R')==3){
           System.out.println("3");
        }
        else {
            for(int i=0;i<input.length()-1;i++){
                if(cl.get(i)=='R' && cl.get(i+1)=='R'){
                    flag=true;
                }
            }
            if(flag==true){
                System.out.println("2");
            }
            else
            {
                System.out.println("1");
            }

        }

    }
}


Measured memory_bytes: 35676
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
  ans += B[A[i]-1]
  if i != 0:
    if A[i - 1] + 1 == A[i]:
      ans += C[A[i - 1]-1]
  
print(ans)

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

string S;
int idx;
int N, M;
string alphas;
int curr;

bool consume(char c) {
  if(idx >= N) return false;
  if(S[idx] != c) return false;
  idx ++;
  return true;
}

int E();

int convert(string const& b) {
  int n = b.size();
  int ret = 0;
  for(int i=0; i<n; i++) {
    ret *= 2;
    assert(isdigit(b[i]));
    ret += b[i] - '0';
  }
  return ret;
}

string B() {
  string ret;
  while(1) {
    if(S[idx] == '0') ret += '0';
    else if(S[idx] == '1') ret += '1';
    else break;
    idx++;
  }
  return ret;
}

int Nu() {
  if(consume('0')) {
    return 0;
  }
  else if(consume('1')) {
    return convert("1" + B());
  }
  else {
    return -inf;
  }
}

int F() {
  if(consume('-')) {
    int r = F();
    if(r == -inf) return -inf;
    return -r;
  }
  else if(consume('(')) {
    int r = E();
    if(r == -inf) return -inf;
    if(!consume(')')) return -inf;
    return r;
  }
  else {
    return Nu();
  }
}

int T() {
  int num1 = F();
  if(num1 == -inf) return -inf;
  while(consume('*')) {
    int num2 = F();
    if(num2 == -inf) return -inf;
    num1 *= num2;
  }
  return num1;
}

int E() {
  int term1 = T();
  if(term1 == -inf) return -inf;
  while(1) {
    bool cont = 0;
    while(consume('+')) {
      cont = 1;
      int term2 = T();
      if(term2 == -inf) return -inf;
      term1 += term2;
    }
    while(consume('-')) {
      cont = 1;
      int term2 = T();
      if(term2 == -inf) return -inf;
      term1 -= term2;
    }
    if(!cont) break;
  }
  return term1;
}

bool Q() {
  if(idx == N) return curr == 0;

  int expr1 = E();
  if(expr1 == -inf) return false;

  if(!consume('=')) return false;

  int expr2 = E();
  if(expr2 == -inf) return false;
  if(expr1 != expr2) return false;

  return idx == N;
}

int main() {

  string T = "01+-*()=";
  sort(T.begin(), T.end());
  int Tsize = T.size();

  string RS; cin >> RS;
  N = RS.size();
  for(auto c: RS) if(isalpha(c)) alphas.push_back(c);
  sort(alphas.begin(), alphas.end());
  alphas.erase(unique(alphas.begin(), alphas.end()), alphas.end());
  M = alphas.size();

  if(M > T.size()) {
    cout << 0 << endl;
    exit(0);
  }

  int ans = 0;
  set<string> st;
  do {
    S = RS;
    rep(i, N)
      if(isalpha(S[i])) S[i] = T[alphas.find(S[i])];
    if(!st.count(S)) {
      st.insert(S);
      idx = curr = 0;
      ans += Q();
    }
  } while(next_permutation(T.begin(), T.end()));
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 7488
#include <stdio.h>

int main(void)
{
    int a[100];
    int i, n;
    
    scanf("%d", &n);
    for(i=0; i<n; i++){
    scanf("%d", &a[i]);
    }
    for(i=n-1; i>0; i--)
        printf("%d ", a[i]);
    printf("%d\n", a[0]);
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<int>ans(N, 0);
	rep(i, 0, N - 1) {
		int a; cin >> a;
		--a;
		ans[a]++;
	}
	rep(i, 0, N)cout << ans[i] << "\n";

	return 0;
}

Measured memory_bytes: 3932
import Control.Monad
import Data.List
import GHC.Exts

main = do
  [n,l,t] <- map read . words <$> getLine
  xws <- map (map read . words) <$> replicateM n getLine :: IO [[Int]]
  mapM_ print $ solve n l t xws

solve n l t xws = drop d ps ++ take d ps
  where
  d = sum (map (`div`l) ps') `mod` n
  moved x w = x + t * (3-w*2)
  ps = sort $ map (`mod`l) ps'
  ps' = [ moved x w | [x,w] <- xws ]


Measured memory_bytes: 68988
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9
#define EPS 1e-10
struct point{
	double x,y;
	void make(){
		cin>>x>>y;
	}
	point(){};
	point(double x,double y):x(x),y(y){};
	point operator + (point &p) { return point(x+p.x,y+p.y)  ; }
	point operator - (point &p) { return point(x-p.x,y-p.y)  ; }
	double norm() { return x*x+y*y;}
	double abs() { return sqrt(norm()) ;}
};
struct line{
	point s,e;
};

double cross(point a,point b){
	return a.x*b.y-a.y*b.x;
}
double dot(point a,point b){
	return a.x*b.x+a.y*b.y;
}

struct circle{
	point p;
	double r;
	void make(){
		p.make();
		cin>>r;
	}
};

double abs(point a){
	return a.abs();
}
double distance(line l,point p){
	point tmp = l.e-l.s;
	if(dot(tmp,p-l.s) < EPS) return abs(p-l.s);
	if(dot(l.s-l.e,p-l.e) < EPS ) return abs(p-l.e);
	return abs(cross(l.e-l.s,p-l.s ) / abs(l.e-l.s) );
}


int main(){
	while(1){
		point p[3];
		p[0].make();
		if(p[0].x==0 && p[0].y==0 )break;
		p[1].make();
		p[2].make();
		circle c;
		c.make();
		double d[3];
		double l[3];
		double r = c.r;
		for(int i=0;i<3;i++){
			point dis = p[i]-c.p;
			d[i] = dis.abs();
			line lt;
			lt.s = p[(i+1)%3];
			lt.e = p[(i+2)%3];
			l[i] = distance(lt,c.p);
		}
		double area = abs(cross(p[2]-p[0],p[1]-p[0]) );
		double area2 = 0.0;
		for(int i=0;i<3;i++){
			area2+= abs( cross(p[i]-c.p, p[(i+1)%3]-c.p ) );
		}
		
		if( r <= l[0]+EPS && r <= l[1]+EPS && r <= l[2]+EPS && area2 <= area + EPS ){
		//    cout<<l[0]<<' '<<l[1]<<' '<<l[2]<<endl;
			cout<<'a'<<endl;
		}else if(d[0] <= r+EPS && d[1] <= r+EPS && d[2] <= r+EPS){
			cout<<'b'<<endl;
		}else if(d[0] > r && d[1] > r&& d[2] >r && l[0]>r&&l[1]>r&&l[2]>r){
			cout<<'d'<<endl;
		}else {
			cout<<'c'<<endl;
		}



	}
	return 0;
}



Measured memory_bytes: 3220
#include<cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<vector>
#include<cmath>
#include<cstdlib>
using namespace std;

map<int,int>vis;

int main(){
	int a,b,c;scanf("%d %d %d",&a,&b,&c);
	vis[a]++,vis[b]++,vis[c]++;
	if(vis[a] == 1) cout << a;
	else if(vis[b] == 1) cout << b;
	else if(vis[c] == 1) cout << c;
}

Measured memory_bytes: 256
# ABC111 C - \/\/\/\
import collections
N=int(input())
V=list(map(int,input().split()))
a=[V[i] for i in range(N) if i%2==0]
b=[V[i] for i in range(N) if i%2==1]

a=collections.Counter(a)
b=collections.Counter(b)
a=a.most_common()
b=b.most_common()
if len(a)==len(b)==1:
    if a[0][0]==b[0][0]:
        print(int(N/2))
    else:
        print(0)
elif len(a)==1 and len(b)>=2:
    print(N-(b[0][1] if a[0][0]!=b[0][0] else b[1][1])-a[0][1])
elif len(a)>=2 and len(b)==1:
    print(N-(a[0][1] if a[0][0]!=b[0][0] else a[1][1])-b[0][1])
elif len(a)>=2 and len(a)>=2:
    print(min(N-(b[0][1] if a[0][0]!=b[0][0] else b[1][1])-a[0][1],N-(a[0][1] if a[0][0]!=b[0][0] else a[1][1])-b[0][1]))


Measured memory_bytes: 18784
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};


int main(){
  int n,x; cin >> n >> x;
  vi ans(2*n-1,-1);
  if(x == 1 || x == 2*n-1){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  if(n == 2){
    printf("%d %d %d\n", 1,2,3);
    return 0;
  }

  bool seen[2*n];
  memset(seen, false, sizeof(seen));

  ans[n-1] = x;
  seen[x] = true;
  if(x != 2){
    ans[n-2] = 1;
    seen[1] = true;
    ans[n] = 2*n-1;
    seen[2*n-1] = true;
    ans[n+1] = 2;
    seen[2] = true;
  }
  else{
    ans[n-2] = 2*n-1;
    seen[2*n-1] = true;
    ans[n] = 1;
    seen[1] = true;
    ans[n+1] = 2*n-2;
    seen[2*n-2] = true;
  }

  int num = 1;
  rep(i,2*n-1) {
    if(ans[i] != -1) continue;
    while(seen[num]) num++;
    ans[i] = num;
    num++;
  }

  rep(i,2*n-1) cout << ans[i] << endl;
}

Measured memory_bytes: 2432
//https://atcoder.jp/contests/abc155/tasks/abc155_a
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
    set<ll> tmp;
    REP(i,3){
        ll v; cin>>v;
        tmp.insert(v);
    }
    if(tmp.size()==2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  AtCoder
//
//  Created by Shivam on 19/09/20.
//  Copyright © 2020 Shivam. All rights reserved.
//

#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<climits>
#include<cmath>
#include<cstring>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<list>
using namespace std;
#define x first
#define y second
#define mp make_pair
#define endl "\n"
typedef long long ll;
int mod=(int)1e9+7;
void sieve(vector<int> &lpn) {
    ll n=(int)lpn.size()-1;
    for(int i=1;i<=n;++i)
        lpn[i]=i;
    for(int i=4;i<=n;i+=2)
        lpn[i]=2;
    for(ll i=3;i<=n;++i) {
        if(lpn[i]==i)
            for(ll j=i;j*i<=n;++j)
                if(lpn[j*i]==j*i)
                    lpn[j*i]=i;
    }
}
vector<int> getPrimeFactors(vector<int> &lpn,int x) {
    vector<int> res;
    while(x!=1) {
        res.push_back(lpn[x]);
        x=x/lpn[x];
    }
    return res;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int> lpn(n);
    sieve(lpn);
    ll ans=1;
    vector<int> prime;
    n-=1;
    while(n!=1) {
        //cout<<n+1<<" "<<ans<<endl;
        prime=getPrimeFactors(lpn,n);
        ll temp=1,count;
        int prev;
        if(prime.size()==1){
            ans+=2;
            n--;
            continue;
        }
        for(int i=0;i<prime.size();++i) {
            count=0;
            prev=prime[i];
            while(i<prime.size() && prime[i]==prev){
                count++;
                i++;
            }
            i--;
            temp*=(count+1);
        }
        //cout<<temp<<endl;
        ans+=temp;
        n--;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 7124
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <list>


constexpr int INF = 1050000000;
constexpr int MOD = 1000000007;
constexpr long long LONGINF = 1005000000000000000;
using namespace std;

using ll = long long;
/*    UnionFind


class UnionFind {
private:
	std::vector<int> parent;
	std::vector<int> height;
	std::vector<int> m_size;

public:
	UnionFind(int size_) : parent(size_), height(size_, 0), m_size(size_, 1) {
		for (int i = 0; i < size_; ++i) parent[i] = i;
	}
	void init(int size_) {
		parent.resize(size_);
		height.resize(size_, 0);
		m_size.resize(size_, 1);
		for (int i = 0; i < size_; ++i) parent[i] = i;
	}
	int find(int x) {
		if (parent[x] == x) return x;
		return parent[x] = find(parent[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		int t = size(x) + size(y);
		m_size[x] = m_size[y] = t;
		if (height[x] < height[y]) parent[x] = y;
		else parent[y] = x;
		if (height[x] == height[y]) ++height[x];
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		if (parent[x] == x) return m_size[x];
		return size(parent[x] = find(parent[x]));
	}
};


*/

int main() {
	

	while (1) {
		string s; cin >> s;
		if (s == "#") { return 0; }

		int a, b, c; cin >> a >> b >> c;

		bool x = false;

		if (a < 31) {
			x = true;
		}
		else {
			if (a == 31 && b < 5) {
				x = true;
			}
		}

		if (x) {
			cout << s << " " << a << " " << b << " " << c << endl;
		}
		else {
			cout <<"? "<< a - 30 << " " << b << " " << c << endl;
		}

	}

}


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

using ll = uint_fast64_t;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;

constexpr int inf = ~(1 << 31);
constexpr ll llinf = ~(1LL << 63);
constexpr int mod = 1e9 + 7;
constexpr ld pi = 3.14159265358979323846L;

constexpr int dy[4] = {0, 1, 0, -1};
constexpr int dx[4] = {1, 0, -1, 0};
struct Pos { int x, y; };

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()
#define DEBUG cerr << "DEBUG: DONE" << endl;

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    rep (i, n) cin >> a[i];
    rep (i, m) cin >> b[i];

    // loop a //
    for (int ah = 0; ah <= n-m; ah++) {
        for (int aw = 0; aw <= n-m; aw++) {
            // loop b //
            bool match = true;
            for (int bh = 0; bh < m; bh++) {
                for (int bw = 0; bw < m; bw++) {
                    if (a[ah+bh][aw+bw] != b[bh][bw]) {
                        match = false;
                        bh = bw = m;
                    }
                }
            }
            if (match) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


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

int main() {
 int n;
 cin >> n;
 vector<int> a(n);
 for(int i = 0; i < n;i++){
  cin >> a.at(i);
  }
  
  int count = 0;
  rep(i,n) {
   if(i % 2 == 0 && a.at(i) % 2 != 0) {
    count++;
    }
    }
    cout << count;

}

Measured memory_bytes: 3600
import java.util.Scanner;

class Main{
	static int N;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int res=N;	//最短記録を記録する

		for(int i=0; i<=N; i++) {
			int cc=0;
			int t=i;
			while(t>0) {
				cc+=t%6;
				t/=6;
			}
			t=N-i;
			while(t>0) {
				cc+=t%9;
				t/=9;
			}
			if(res> cc) {
				res=cc;
			}
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 23636
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int n;
	int[] pow;
	String[] names;
	HashSet<String>[] sets;

	@SuppressWarnings("unchecked")
	void run(){
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			names=new String[n];
			pow=new int[n];
			sets=new HashSet[n];
			for(int j=0; j<n; j++){
				names[j]=sc.next();
				pow[j]=sc.nextInt();
				sets[j]=new HashSet<String>();
				int m=sc.nextInt();
				for(int i=0; i<m; i++){
					sets[j].add(sc.next());
				}
			}
			solve();
		}
	}

	long[] g;
	int[] _;
	int ans;

	void solve(){
		HashMap<String, Integer> map=new HashMap<String, Integer>();
		for(int i=0; i<n; i++){
			map.put(names[i], i);
		}
		g=new long[n];
		for(int i=0; i<n; i++){
			for(String s : sets[i]){
				int j=map.get(s);
				g[i]|=1L<<j;
			}
		}
		// _:順番->ID
		_=new int[n];
		for(int i=0; i<n; i++){
			_[i]=i;
		}
		for(int j=0; j<n; j++){
			for(int i=j+1; i<n; i++){
				if(Long.bitCount(g[_[i]])<Long.bitCount(g[_[j]])){
					int t=_[i];
					_[i]=_[j];
					_[j]=t;
				}
			}
		}

		ans=0;
		mis(1, 1, pow[0]);
		println(ans+"");
	}

	void mis(int k, long choosed, int sum){
		if(k==n){
			// String c=Long.toBinaryString(choosed);
			// for(; c.length()<n; c="0"+c);
			// debug(c, sum);
			ans=max(ans, sum);
			return;
		}

		// debug(k, Long.toBinaryString(choosed));
		/*
		if((choosed&(g[k]|(1L<<k)))!=0){
			mis(k+1, choosed, sum);
			return;
		}

		long rem=0;
		for(int i=k+1; i<n; i++){
			if((choosed&g[i])==0)
				rem|=g[i];
		}

		if((rem>>k&1)==0){
			mis(k+1, choosed|(1L<<k), sum+pow[k]);
			return;
		}
		mis(k+1, choosed, sum);
		mis(k+1, choosed|(1L<<k), sum+pow[k]);
		*/
		if((choosed&(g[k]|(1L<<k)))==0){
			mis(k+1, choosed|(1L<<k), sum+pow[k]);
			long rem=0;
			for(int i=k+1; i<n; i++){
				if((choosed&g[i])==0)
					rem|=g[i];
			}
			if((rem>>>k&1)==0){
				return;
			}
		}
		mis(k+1, choosed, sum);

	}

	void mis_(int k, long choosed, int sum){
		if(k==n){
			// String c=Long.toBinaryString(choosed);
			// for(; c.length()<n; c="0"+c);
			// debug(c, sum);
			ans=max(ans, sum);
			return;
		}

		// debug(k, Long.toBinaryString(choosed));

		if((choosed&(g[_[k]]|(1L<<_[k])))==0){
			mis(k+1, choosed|(1L<<_[k]), sum+pow[_[k]]);
			long rem=0;
			for(int i=k+1; i<n; i++){
				if((choosed&g[_[i]])==0)
					rem|=g[_[i]];
			}
			if((rem>>_[k]&1)==0){
				mis(k+1, choosed|(1L<<_[k]), sum+pow[k]);
				return;
			}

		}
		mis(k+1, choosed, sum);
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 13000