akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	constexpr Int INF = 1e18 + 10;
	Int N, K;
	cin >> N >> K;
	vector<Int> P(N), C(N);
	for (int i = 0; i < N; ++i) { cin >> P[i]; --P[i]; }
	for (int i = 0; i < N; ++i) { cin >> C[i]; }

	vector<vector<Int>> tapu;
	vector<bool> used(N, false);
	for (int i = 0; i < N; ++i) {
		if (used[i]) { continue; }
		vector<Int> tmp;
		int now = i;
		while (!used[now]) {
			tmp.emplace_back(C[now]);
			used[now] = true;
			now = P[now];
		}
		tapu.emplace_back(tmp);
	}

	Int ans = -INF;
	for (auto vec : tapu) {
		Int n = vec.size();
		vector<Int> d(n * 2, 0);
		Int sum = 0;
		for (int i = 0; i < n * 2; ++i) {
			d[i] = vec[i % n];
			if (i < n) { sum += vec[i]; }
			if (i > 0) { d[i] += d[i - 1]; }
		}

		vector<Int> ma(n + 1, -INF);
		ma[0] = 0;
		for (int i = 0; i < 2 * n; ++i) {
			for (int j = i + 1; j < 2 * n; ++j) {
				if (j - i > n) { break; }
				ma[j-i] = max(ma[j-i], d[j] - d[i]);
			}
		}

		for (int i = 1; i <= min(K, n); ++i) {
			ans = max(ans, ma[i]);
		}
		
		if (sum > 0 && K >= n) {
			if (K % n == 0) {
				for (int i = 0; i <= n; ++i) {
					ans = max(ans, sum * (K / n - 1) + ma[i]);
				}
			}
			for (int i = 0; i <= K % n; ++i) {
				ans = max(ans, sum * (K / n) + ma[i]);
			}
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3828
// AOJ 1156
// Twirling Robot
//

#include<iostream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#define MAX_W_H 30
#define INF 1000000
using namespace std;

// ??????:[0] = E, [1] = S, [2] = W, [3] = N
// ??????:[0] = Straight, [1] = Right, [2] = Back, [3] = Left
int f[4][4] = {{0, 1, 2, 3}, {3, 0, 1, 2}, {2, 3, 0, 1}, {1, 2, 3, 0}}; // [?¬???????????????????][???????????????????????????] = ???????????????

// ??????(i, j, k) == ???????????????(j, i)??????????????????????????????k????????????????????¶???

int w, h;
int map[MAX_W_H][MAX_W_H];
int d[MAX_W_H][MAX_W_H][4];	// ??????(0, 0, 0)?????????????°??????????
int instr_cost[4];		// ?????????????????????
bool used[MAX_W_H][MAX_W_H][4];	// ?????§?????????????????????????????°

bool in_map(int x, int y)
{
  return (0 <= x && x < w && 0 <= y && y < h);
}

void dijkstra(void)		// ??????(0, 0)?????????????????????????°???????????±???????
{
  int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; // [0]=E, [1]=S, [2]=W, [3]=N
  while(true)
    {
      int x = -1, y = -1, di = -1;
      for(int i = 0; i < h; i++)
	for(int j = 0; j < w; j++) // ???????????????????????? and ?§?????????????????????????????°??????? == ???????????¢????¢????????????????
	  for(int k = 0; k < 4; k++)
	    if(!used[i][j][k] && ((x == -1 && y == -1 && di == -1) || (d[i][j][k] < d[y][x][di])))
	      x = j, y = i, di = k;

      if(x == -1 && y == -1 && di == -1)
	break;

      used[y][x][di] = true;

      // ??????(x, y, d)??¨??£??\???????????????"?§??????????????????¢"?????´??°
      for(int i = 0; i < 4; i++)
	{
	  int xx = x + dir[i][0];
	  int yy = y + dir[i][1];
	  int c;
	  if(!in_map(xx, yy))
	    continue;

	  int inst = f[di][i]; // d = ??????(x, y)????????????????????????, i = ??????(x, y)??????????????????(xx, yy)?????????, inst = ?§??????????????????????
	  if(inst == map[y][x])
	    c = 0;
	  else
	    c = instr_cost[inst];

	  if(d[yy][xx][i] > d[y][x][di] + c)
	    d[yy][xx][i] = d[y][x][di] + c;
	}
    }
}

int main(void)
{
  int ans = INF;
  while(cin >> w >> h, (w && h))
    {
      for(int i = 0; i < MAX_W_H; i++)
	for(int j = 0; j < MAX_W_H; j++)
	  for(int k = 0; k < 4; k++)
	    {
	      d[i][j][k] = INF;
	      used[i][j][k] = false;
	    }


      d[0][0][0] = 0;

      for(int i = 0; i < h; i++)
	for(int j = 0; j < w; j++)
	  cin >> map[i][j];

      for(int i = 0; i < 4; i++)
	cin >> instr_cost[i];

      dijkstra();


      for(int i = 0; i < 4; i++)
	ans = min(ans, d[h - 1][w - 1][i]);

      cout << ans << endl;

      ans = INF;
    }
  return 0;
}

Measured memory_bytes: 1180
#include <stdio.h>

// 配列の要素を順番に出力
void trace(int A[], int N)
{
  int i;
  for (i = 0; i < N; i++)
  {
    if (i > 0)
    {
      printf(" ");  // 隣接する要素の間に1つの空白を出力
    }
    printf("%d", A[i]);
  }
  printf("\n");
}

// 挿入ソート
void insertionSort(int A[], int N)
{
  int j, i, v;
  for (i = 1; i < N; i++)
  {
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v)
    {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    trace(A, N);
  }
}

int main()
{
  int N, i, j;
  int A[100];

  scanf("%d", &N);
  for (i = 0; i < N; i++)
  {
    scanf("%d", &A[i]);
  }
  trace(A, N);
  insertionSort(A, N);

  return 0;
}


Measured memory_bytes: 2692
/*
    DP Contest Atcoder
    Problem Name:- D Knapsack 1
*/

#include<bits/stdc++.h>
#define ll long long int
using namespace std;


// ll dp[1000][1000];

// ll knapsack(ll wt[], ll val[], ll w, ll n){
//     if(n==0 || w == 0){
//         return 0;
//     }
//     if(dp[n][w] != -1)
//         return dp[n][w];

//     if(wt[n-1] > w){
//         dp[n][w] = knapsack(wt, val, w, n-1);
//     }
//     else{
//         dp[n][w] =  max(val[n-1] + knapsack(wt, val, w-wt[n-1], n-1),
//                     knapsack(wt, val, w, n-1));
//     }
//     return dp[n][w];
// }
ll knapSack(ll W, ll wt[], ll val[], ll n) 
{ 
    ll i, w; 
    ll K[n + 1][W + 1]; 
  
    // Build table K[][] in bottom up manner 
    for (i = 0; i <= n; i++) { 
        for (w = 0; w <= W; w++) { 
            if (i == 0 || w == 0) 
                K[i][w] = 0; 
            else if (wt[i - 1] <= w) 
                K[i][w] = max( 
                    val[i - 1] + K[i - 1][w - wt[i - 1]], 
                    K[i - 1][w]); 
            else
                K[i][w] = K[i - 1][w]; 
        } 
    } 
  
    return K[n][W]; 
} 

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,w;
    cin>>n>>w;
    // memset(dp, -1, sizeof(dp));
    ll wt[n], val[n];
    for(ll i=0; i<n; i++){
        cin>>wt[i]>>val[i];
    }   
    cout<<knapSack(w, wt, val, n)<<endl;

    return 0;
}

Measured memory_bytes: 82484
d, n = map(int, input().split())
x = 100 ** d
y = 0
cnt = 0
while cnt < n:
    y += x
    #if d == 0 and y % 100 == 0:
    if y % (100 ** (d + 1)) == 0:
        continue
    cnt += 1
    #print("x={}, y={}, cnt={}".format(x, y, cnt))
print(y)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int n,d,ans,r;

int main(){
    cin>>n>>d;
    int pt=0,ans=1;
    r=2*d+1;
    while(r<n){
        r+=(2*d+1);
        ans++;
    }
    cout<<ans<<'\n';

}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 256
n,k = map(int,input().split())
*l, = map(int,input().split())
seenl = [1]
seen = {1}
temp=1
for i in range(k):
  temp=l[temp-1]
  if temp in seen:
    lenloop = len(seenl)-seenl.index(temp)
    r = (k-i-1)%lenloop
    temp = seenl[seenl.index(temp):][r]
    break
  seenl.append(temp)
  seen.add(temp)
print(temp)

Measured memory_bytes: 32372
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a)  (a).begin(),(a).end()
#define elif else if


int low(V<int> a,int b){
  decltype(a)::iterator c=lower_bound(a.begin(),a.end(),b);
  int d=c-a.bgn;
  return d;
}
int upp(V<int> a,int b){
  decltype(a)::iterator c=upper_bound(a.begin(),a.end(),b);
  int d=c-a.bgn;
  return d;
}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int INF=1000000007;
int kaijou(int a){
  int b=1;
  fo(i,a)
    b*=i+1;
  return b;
}

V<P<int,int>> factorize(int n){
  V<P<int,int>> res;
  for(int i=2; i*i<=n; i++){
    if(n%i)
      continue;
    res.emplace_back(i,0);
    while(n%i==0){
      n/=i;
      res.back().second++;
    }
  }
  if(n!=1)
    res.emplace_back(n,1);
  return res;
}

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



  int dp[55][2];
  signed main(){
  int n,p,a[55];
  cin>>n>>p;
  dp[0][0]=1;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  for(int i=1;i<=n;i++){
    for(int j=0;j<2;j++){
      if(a[i]%2){
        dp[i][j]=dp[i-1][0]+dp[i-1][1];
      }
      else dp[i][j]=dp[i-1][j]+dp[i-1][j];
    }
  }
  cout<<dp[n][p]<<endl;
  return 0;
}

Measured memory_bytes: 256
def main():
	#N, D = [int(x) for x in input().split()]
	N = int(input())
	S = input()
	
	if N % 2 == 1:
		print("No")
		return
	
	n = int(N/2)
	s1 = S[0:n]
	s2 = S[n:N]

	if s1 == s2:
		print("Yes")
	else:
		print("No")

if __name__ == "__main__":
	main()


Measured memory_bytes: 3060
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,popcnt,sse4.1,sse4.2,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<int, int>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 1<<17, mod = 119<<23|1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, m;
const int q = 1<<10;
ll res[3][2], p[maxn], a[3][q], b[q], c[q];
#define mul(x, y) ((x)*1ll*(y)%mod)
int main() {
	cin.tie(0)->sync_with_stdio(0);
	p[0] = 1;
	for(int i = 1; i < maxn; i++) p[i] = p[i-1]*716070898ll%mod;
	cin >> n;
	
	bitset<q> t;
	for(int i = 0; i < q; i++) t.set(i);
	
	for(int i = 0; i < 3; i++) {
		cin >> m;
		vvi g(n+1);
		for(int f, t, j = 0; j < m; j++) {
			cin >> f >> t;
			g[f].pb(t);
			g[t].pb(f);
		}
		vi rem(n+1, 0);
		for(int v = n; v; v--) {
			for(auto u : g[v]) if(u>v) t.set(rem[u], 0);
			rem[v] = t._Find_first();
			for(auto u : g[v]) if(u>v) t.set(rem[u]);
			(a[i][rem[v]]+=p[v])%=mod;
		}
	}
	for(int i = 0; i < q; i++) {
		for(int j = 0; j < q; j++) {
			(b[i^j] += a[0][i]*a[1][j])%=mod;
		}
	}
	for(int i = 0; i < q; i++) {
		for(int j = 0; j < q; j++) {
			(c[i^j] += b[i]*a[2][j])%=mod;
		}
	}
	cout << c[0];
}


Measured memory_bytes: 7936
#include<iostream>

int main(){

    std::string s;
    std::cin >> s;

    int len;
    len = s.length();
    
    // end
    if (s[len-1] == s[len-2])
    {   
        if (len == 2)
            std::cout << len-1 << " " << len << std::endl;
        else 
            std::cout << len-2 << " " << len << std::endl;
        return 0;
    }   
        
    for (int i = 0; i < len-2; ++i)
    {   
        if (s[i] == s[i+1])
        {   
            std::cout << i+1 << " " << i+3 << std::endl;
            return 0;
        }   
        if (s[i] == s[i+2])
        {   
            std::cout << i+1 << " " << i+3 << std::endl;
            return 0;
        }   
    }   
    std::cout << "-1 -1" << std::endl;
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n,s;cin>>n>>s,n|s;){
		vvvl dp(n+1,vvl(101,vl(s+1))); // [count][last][sum]
		dp[0][0][0]=dp[1][0][0]=1;
		rep(i,n) rep(j,101) rep(k,j) rep(l,s+1-j)
			dp[i+1][j][l+j]+=dp[i][k][l];
		ll res=0;
		rep(i,101) res+=dp[n][i][s];
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 8988
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};




int main(){
    ll h,w;
    cin >> h >>w;
    ll x,y;
    if (h ==1 || w ==1){
        cout << 1 << endl;
        return  0;
    }
    if(w%2 == 0){
         x = w/2;
         cout << x *h <<endl;
         return 0;
    }else{
         x = (w/2)  + 1;
         if(h %2 == 0){
             x += x-1;
             cout << x * (h/2) <<endl;
             return 0;
         }else{
             ll o = x;
             x += x-1;
             y = x * (h/2);
             cout << y + o <<endl;
         }
    }

    
}



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


const ll INF = 1e18;
const int MAX_N = 2e3 + 10;

int N;
vector<vector<int> > G, rG;
int used[MAX_N], dist[MAX_N];

int bfs(int s){
    for(int i = 0; i < N; i++) dist[i] = 1e9;

    queue<int> Q;
    Q.push(s);
    dist[s] = 0;

    while(!Q.empty()){
        int v = Q.front(); Q.pop();
        used[v] = 1;
        for(auto nv:G[v]){
            if(used[nv] == 0){
                dist[nv] = dist[v] + 1;
                used[nv] = true;
                Q.push(nv);
            }/* else{
                cout << v << endl;
                return (dist[v] + 1);
            } */
        }
    }
    int ans = 1e9;
    for(auto e: rG[s]){
        if(dist[e] != 1e9){
            ans = min(ans, dist[e] + 1);
        }
    }
    return ans;
}

/* int bfs2(int s){
    for(int i = 0; i < N; i++) dist[i] = 1e9;

    queue<int> Q;
    Q.push(s);
    dist[s] = 0;

    while(!Q.empty()){
        int v = Q.front(); Q.pop();
        used[v] = 1;
        for(auto nv:rG[v]){
            if(used[nv] == 0){
                dist[nv] = dist[v] + 1;
                Q.push(nv);
            }else{
                return dist[v];
            }
        }
    }
    return 1e9;
} */

int main(){
    int M;cin >> N >> M;
    G.resize(N);
    rG.resize(N);
    rep(i, 0, M){
        int a, b; cin >> a >> b;a--,b--;
        G[a].emplace_back(b);
        rG[b].emplace_back(a);
    }
    int ans_index = 0, K = 1e5;
    rep(i, 0, N){
        rep(j, 0, N) {used[j] = 0;}
        int t = bfs(i);
        if(t < K){
            ans_index = i;
            K = t;
        }
    }
    rep(j, 0, N) used[j] = 0;
    vector<int> ans;
    if(K == 1e5) cout << -1 << endl;
    else{
        cout << K << endl;
        bfs(ans_index);
        ans.push_back(ans_index);
        int t = ans_index;
        K--;
        while(K > 0){
            for(auto e: rG[t]){
                if(dist[e] == K){
                    t = e;
                    K--;
                    ans.push_back(t);
                    break;
                }
            }
        }
        //sort(ans.begin(), ans.end());
        for(auto e: ans){
            cout << e + 1 << endl;
        }
        return 0;
    }
    

}

Measured memory_bytes: 384
#include <bits/stdc++.h> //H - Grid 1
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int maxn = 1100;
const int mod = 1e9 + 7;
typedef long long int ll;


int dp[maxn][maxn];
bool mm[maxn][maxn];
int n,m,ans;



int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
		{
			char c;
			cin>>c;
			if(c == '.') mm[i][j] = true;
			else mm[i][j] = false;
		}

	dp[1][1] = 1;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
		{
			dp[i][j] = (dp[i][j] + (mm[i-1][j] == true ? dp[i-1][j] : 0))%mod;
			dp[i][j] = (dp[i][j] + (mm[i][j-1] == true ? dp[i][j-1] : 0))%mod;
		}

	cout<<dp[n][m]<<'\n';
}

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

int main()
{
	int n;
	cin >> n;
	double sum = 0;
	auto a = vector<int>(n);
	for(auto&& aa : a){
		cin >> aa;
		sum += aa;
	}
	int d = (int)(sum / n + (sum > 0.0 ? 0.5: -0.5));
	int ans = 0;
	for(auto aa : a){
		ans += ((aa - d) * (aa - d));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <stack>
using namespace std;


double rad(int degree){
	return (M_PI*degree) / 180;
}


int main(){
	double x = 0, y = 0;
	int d, dir = 90, a;
	char comma;

	while (cin >> d >> comma >> a, d || a){
		x += d * cos(rad(dir));
		y += d * sin(rad(dir));
		dir -= a;
	}

	cout << (int)x << endl;
	cout << (int)y << endl;

	return 0;
}

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

int main()
{
	for (int i = 1; i <= 9; ++i)
	{
		for (int j = 1; j <= 9; ++j)
		{
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1116
def ts(E):
    L = []
    n = len(E)
    done = [0] * n
    checking = [0] * n
    Q = []
    for i in range(n)[::-1]:
        Q.append(-1)
        Q.append(i)
        Q.append(3)
        Q.append(i)
        Q.append(2)
        Q.append(i)
        Q.append(1)
    while Q:
        tp = Q.pop()
        if tp == 2:
            j = Q.pop()
            if done[j]: continue
            done[j] = 1
            L.append(j)
            checking[j] = 0
            continue
        elif tp == 3:
            j = Q.pop()
            k = Q.pop()
            D[j] = max(D[j], (D[k] + 1 if k >= 0 else 0))
        elif tp == 1:
            j = Q.pop()
            if done[j]: continue
            checking[j] = 1
            for k in E[j]:
                if checking[k]:
                    return []
                Q.append(k)
                Q.append(j)
                Q.append(3)
                Q.append(k)
                Q.append(2)
                Q.append(k)
                Q.append(1)
    return L[::-1]
def ca(i, j):
    return max(i, j) * (max(i, j)-1) // 2 + min(i, j)

N = int(input())
M = N * (N-1) // 2
X = [[] for i in range(M)]
for i in range(N):
    A = [int(a)-1 for a in input().split()]
    for j in range(N-2):
        X[ca(i, A[j])].append(ca(i, A[j+1]))
D = [0] * M
L = ts(X)
print(max(D) + 1 if L else -1)


Measured memory_bytes: 219380
#abc133d

n=int(raw_input())
a=map(int,raw_input().split())
s=sum(a)
s2=0
for i in xrange(1,n,2):
 s2+=a[i]
x=[0]*n
x[0]=s-2*s2
print x[0],
for i in xrange(1,n):
 x[i]=2*a[i-1]-x[i-1]
 print x[i],
print


Measured memory_bytes: 11340
// 1_6_B
#include <iostream>
using namespace std;

int main(){
  int n, i, value;
  char suit;
  int cards[4][13] = {};

  cin >> n;
  for(i = 0; i < n; i++){
    cin >> suit >> value;
    switch(suit){
    	case 'S':
    	  cards[0][value-1] = 1;
        break;
    	case 'H':
    	  cards[1][value-1] = 1;
        break;
    	case 'C':
    	  cards[2][value-1] = 1;
        break;
    	case 'D':
    	  cards[3][value-1] = 1;
        break;
    }
  }

  for(int s = 0; s < 4; s++){
    for(int v = 0; v < 13; v++){
      if(!cards[s][v]){
        switch(s){
        	case 0:
        	  cout << "S " << v+1 << endl;
            break;
        	case 1:
        	  cout << "H " << v+1 << endl;
            break;
        	case 2:
        	  cout << "C " << v+1 << endl;
            break;
        	case 3:
        	  cout << "D " << v+1 << endl;
            break;
        }
      }
    }
  }
  return 0;
}

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

vector<int> primes;
vector<int> factor;
map<int,int> ma;
int z[1010101];
int main(){
	ll n;
	cin >> n;

	for(int i = 2; i <= 1010101; i++){
		if(z[i]) continue;
		z[i] = i;
		primes.push_back(i);
		for(int u = i; u <= 1010101; u += i){
			z[u] = i;
		}
	}
	while(n){
		bool bo = false;
		for(auto u : primes){
			if(u > sqrt(n)) break;
			if(n % u == 0){
				bo = true;
				ma[u]++;
				n /= u;
			}
		}
		if(!bo){ma[n]++;break;}
	}
	ll su = 0;
	ma[1] = 0;
	for(auto u : ma){
		ll s = 0;
		for(int i = 1; i <= 100; i++){
			s += i;
			if(s > u.second) break;
			su++;
		}
	}
	cout << su << "\n";
}


Measured memory_bytes: 7828
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath> 
typedef long long ll;
using namespace std;
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
inline int rd(){
	int res=0,sign=1;char ch;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')sign=-1;res=res*10+ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;
	return res*sign;
}
int n,base;
int sum;
void solve(int n,int base){
    if(n==0)
      return;
    solve(n/base,base);
    sum++;
}
int main(){
	cin>>n>>base;
	solve(n,base);
	cout<<sum;
	return 0;
}


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

template <int Mod, bool IsPrime = false>
class mod_int {
    using ll = long long;

public:
    constexpr mod_int() : n(0) {}
    constexpr mod_int(int n_) : n(n_) {
        if(n >= Mod)     n %= Mod;
        else if(n < 0) n = (n % Mod + Mod) % Mod;
    }
    constexpr mod_int(ll n_) : n(n_) { n = (n + Mod) % Mod; }

    constexpr operator int() const { return n; }
    constexpr operator ll() const  { return n; }

    constexpr bool operator==(mod_int const& other) const { return n == other.n; }
    constexpr mod_int& operator+=(mod_int const& other) {
        if((n += other.n) >= Mod) n -= Mod;
        return *this;
    }
    constexpr mod_int& operator-=(mod_int const& other) {
        if((n += Mod - other.n) >= Mod) n -= Mod;
        return *this;
    }
    constexpr mod_int& operator*=(mod_int const& other) {
        n = (unsigned long long)n * other.n % Mod;
        return *this;
    }
    constexpr typename std::enable_if<IsPrime, mod_int>::type& operator/=(mod_int const& other) {
        return *this *= other.inverse();
    }
    constexpr mod_int operator+(mod_int other) const { return mod_int(*this) += other; }
    constexpr mod_int operator-(mod_int other) const { return mod_int(*this) -= other; }
    constexpr mod_int operator*(mod_int other) const { return mod_int(*this) *= other; }
    constexpr mod_int operator/(mod_int other) const { return mod_int(*this) /= other; }

    constexpr typename std::enable_if<IsPrime, mod_int>::type inverse() const {
        ll a = n, b = Mod, u = 1, v = 0;
        while(b) {
            ll t = a / b;
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        return mod_int(u);
    }

private:
    ll n;
};

template <int Mod, bool IsPrime>
std::ostream& operator<<(std::ostream& os, mod_int<Mod, IsPrime> const& n) {
    os << (int)n;
    return os;
}

constexpr int default_mod = 998244353;

template <int Mod = default_mod>
mod_int<Mod, true> fact(int n) {
    static std::vector<mod_int<Mod, true>> v = {1};
    if(n >= static_cast<int>(v.size())) {
        const int from = v.size(), to = n + 1024;
        v.reserve(to);
        for(int i = from; i < to; ++i) {
            v.push_back(v.back() * mod_int<Mod, true>(i));
        }
    }
    return v[n];
}

template <int Mod = default_mod>
mod_int<Mod, true> comb(int n, int r) { // nCr
    if(r < 0 || r > n) return 0;
    return fact<Mod>(n) / fact<Mod>(r) / fact<Mod>(n - r);
}

using ll = long long;
using mint = mod_int<default_mod, true>; // default

int main() {
    ll n, a, b, k; cin >> n >> a >> b >> k;
    mint ans;
    for(int i = 0; i <= n; ++i) {
        const ll bcnt = (k - i * a) / b;
        if(bcnt < 0 || n < bcnt || i * a + bcnt * b != k) continue;
        ans += comb(n, i) * comb(n, bcnt);
    }

    cout << ans << endl;
}


Measured memory_bytes: 4864
n, m = map(int, input().split())
bits = '0b' + '1' * n
s = []

for _ in range(m):
    i = [int(i) for i in input().split()]
    s.append(i[1:])

p = [int(i) for i in input().split()]
c = 0
for i in range(2**n):
    l = bin(i)[2:]
    b = (n - len(l)) * '0' + l
    addable = True
    for h, j in enumerate(s):
        d = 0
        for k in j:
            d += int(b[k - 1])
        if addable:
            addable = d % 2 == p[h]
    if addable:
        c += 1
print(c)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include<iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;
ll calc(ll num)
{
  ll bit=1;
  ll res=0;
  ll cnt=0;
  while(num>=bit)
  {
    cnt=0;
    ll loop=bit*2;
    cnt+=(num/loop)*(loop/2);
    cnt+=max(0LL,num%loop-loop/2+1);
    if(cnt&1)res+=bit;
    bit=loop;
  }
  return res;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  ll a,b;
  cin>>a>>b;
  cout<<(calc(a-1)^calc(b))<<endl;
  return 0;

}


Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]

dp = [0, abs(h[1] - h[0])] + [-1 for i in range(n - 2)]

for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[-1])


Measured memory_bytes: 90412
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 100000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;
const ll MAXN = 1e18;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	char a,b;
	cin >> a >> b;
	int suma = a;
	int ama = b;
	if(suma > ama){
		cout << ">" << endl;
	}else if(suma < ama){
		cout << "<" << endl;
	}else{
		cout << "=" << endl;
	}
	return 0;
}



Measured memory_bytes: 3628
#include <iostream>

using namespace std;
typedef long long ll;
const ll MOD = 1000000007;


int main(void) {
  ll n,k;
  ll ans=0;
  cin>>n;
  cin>>k;
  
  for(ll i=k;i<=n+1;i++){
    ans += (((2*i*(n-i+1))/2)+1) % MOD;
  }

  ans%=MOD;
  cout<<ans;
  
  return 0;
}


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

int main() {
   int D, N;
   cin >> D >> N;
   if( D == 0 ){
     if( N == 100 ) cout << 101 << endl;
     else cout << N << endl;
   }else if( D == 1 ){
     if( N == 100 ) cout << 10100 << endl;
     else cout << N*100 << endl;
   }else{
     if( N == 100 ) cout << 1010000 << endl;
     else cout << N*10000 << endl;
   }
   
}

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

#define all(v)   v.begin(), v.end()
#define endl "\n";
#define pb push_back
#define F first
#define S second
#define JULEE_DO_THE_THING fast()
#define to_str to_string
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMIN INT_MIN
#define IMAX INT_MAX
#define pow POW

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double dd;
typedef string str;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef pair<int, int> pii;

void fast() {
	cin.tie(0);
	cout.tie(0);
	cin.sync_with_stdio(0);
}

bool compare(int &a, int &b) {
	return a > b;
}

ll numOfDigits(ll n) {
	if (!n)
		return 1;
	return (ll) (log10(n)) + 1;
}

ull POW(ll a, ll b);

/*

 */

ll BN();
int main() {
	JULEE_DO_THE_THING;
	//freopen("test cases\\Strings of Impurity.txt", "r", stdin) ;
	str s, t; cin>>s>>t;
    int n = s.size(), m = t.size();
    map<char, bool> vis;
    for(int i=0; i<n; i++)vis[s[i]] = 1;
    for(int i=0; i<m; i++){
        if(vis.find(t[i])==vis.end())
            return cout<<-1, 0;
    }
    map<char, set<int>> mp;
    t = " " + t; m++;
    for(int i=0; i<n; i++) mp[s[i]].insert(i);
    int index[m+1]={IMAX}; index[m] = IMAX;
    for(int i=1; i<m; i++){
        int up;
        auto it = mp[t[i]].upper_bound(index[i-1]);
        if(it==mp[t[i]].end()) up = *mp[t[i]].begin();
        else up = *it;
        index[i] = up;
    }
    ull subSequnce = 0;
    for(int i=1; i<m; i++){
       if(index[i]<=index[i-1])subSequnce++;
    }
    //cout<<subSequnce<<endl;
    int j = m-1, x;
    while(j>=1 && index[j]<index[j+1]) j--;
    str lastSequence = t.substr(j+1);
    t = t.substr(1); m--;
    ull lastSubLenght  = 0 ;
    for( j=0, x = 0; j<n && x<lastSequence.size(); j++){
       if(s[j]==lastSequence[x])x++;
    }
    lastSubLenght = j;
    //cout<<lastSubLenght<<endl;
    cout<<(subSequnce-1)*s.size() + lastSubLenght;
	return 0;
}

ll BN() {
	ll low = 0;
	ll up = 0;
	ll ans = 0;
	while (low <= up) {
		ll mid = ((low + up) / 2);
		if (mid) {
			ans = mid;
			low = mid + 1;
		} else
			up = mid - 1;
	}
	return ans;
}

ull POW(ll a, ll b) {
	ull res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}


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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 200500;

int n, a[N];

inline ll calc(int x) {
	ll res = 0;
	for (int i = 1; i <= n; i++)
		res += abs(a[i] - (x + i));
	return res;
}

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

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

	//cout << setprecision(10) << fixed;
	
	cin >> n;
	
	for (int i = 1; i <= n; i++)
		cin >> a[i];

	int l = -(int)1e9, r = (int)1e9;

	while (r - l > 3) {
		int m1 = l + (r - l) / 3;
		int m2 = r - (r - l) / 3;
		if (calc(m1) > calc(m2))
			l = m1;
		else
			r = m2;
	}

	ll ans = inf;

	for (int i = l; i <= r; i++)
		ans = min(ans, calc(i));

	cout << ans;
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int a,b,c;
	cin>>a>>b>>c;
	a=b/a;
	if(a>=c){
		cout<<c<<endl;	
	}
	else{
		cout<<a<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
'use strict';
(function(stdin) {
  var inputs  = stdin.toString();
  var r = parseFloat(inputs);
  var circlearea = Math.pow(r,2) * Math.PI ;
  var circumference = 2 * Math.PI * r;

  console.log(
    Number(circlearea.toFixed(5))
    ,Number(circumference.toFixed(5))
  );

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15868
#include <bits/stdc++.h>
#define MAXP 40000
#define MAXN 200010
using namespace std;

const long long M=1e9+7;

int n,m,k,cnt[MAXP];
long long ans=1,fac[MAXN],inv[MAXN],invfac[MAXN];

inline void read(int &x)
{
	x=0;char ch=getchar();bool f=false;
	while (ch<'0'||ch>'9'){if (ch=='-') f=true;ch=getchar();}
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	if (f) x=-x;return ;
}

int main()
{
	read(n);read(m);int q=m,p=sqrt(m);
	if (n==1)
	{
		puts("1");
		return 0;
	}
	fac[0]=invfac[0]=1;inv[1]=1;
	for (int i=1;i<=(n<<1);i++) fac[i]=fac[i-1]*i%M;
	for (int i=2;i<=(n<<1);i++) inv[i]=(M-M/i)*inv[M%i]%M;
	for (int i=1;i<=(n<<1);i++) invfac[i]=invfac[i-1]*inv[i]%M;
	for (int i=2;i<=p;i++)
		while (!(q%i)){++cnt[i];q/=i;++k;}
	if (q!=1) ++k;
	for (int i=1;i<=p;i++)
		if (cnt[i])
		{
			long long p=fac[cnt[i]+n-1]*invfac[cnt[i]]%M*invfac[n-1]%M;
			ans=ans*p%M;
		}
	if (q!=1) ans=(ans*n)%M;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4992
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int p = sc.nextInt();
    int q = sc.nextInt();
    int r = sc.nextInt();

    int sum = p + q + r - Math.max(p,Math.max(q,r));
    System.out.println(sum);
  }
}

Measured memory_bytes: 21972
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define sum(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class CForbiddenList {
public:
  static void solve(istream &cin, ostream &cout) {
    int X, N;
    cin >> X >> N;
    map<int, int> check;
    rep(i, N) {
      int p;
      cin >> p;
      check[p]++;
    }
    int ans = 0;
    REP(i, -200, 500) {
      if (check[i]) continue;
      if (abs(X - i) == abs(ans - X) and i < ans) {
        ans = i;
      } else if (abs(X - i) < abs(ans - X)) {
        ans = i;
      }
    }
    cout << ans << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  CForbiddenList solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3652
import sys
A, B, K = map(int, input().split())

for i in range(A , A + K):
    if i > B:
        break
    elif i == B - K + 1:
        break
    print(i)

if i > B:
    sys.exit()

else:
    for j in range(B - K + 1, B + 1):
        print(j)


Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstdio>
using namespace std;
const int maxn=705;
vector<int> adj[maxn];
int n,m,c[maxn],vis[maxn];
bool dp[maxn][maxn];
int g[maxn][maxn];
int cnt0,cnt1;
inline int getv(int x){
	return x*(x-1)/2;
}
bool flg;
inline void dfs(int u,int id){
	vis[u]=1;
	c[u]=id;
	if (id==0) cnt0++;
	else cnt1++;
	for (int i=0;i<adj[u].size();i++){
		int v=adj[u][i];
		int ot=id^1;
		if (vis[v]){
			if (c[v]==c[u]){
				flg=1;
				return;
			}
			continue;
		}
		dfs(v,ot);
	}
}
int main(){
	cin>>n>>m;
	for (int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		g[u][v]=g[v][u]=1;
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<i;j++){
			if (g[i][j]) continue;
			adj[i].push_back(j);
			adj[j].push_back(i);
		}
	}
	dp[0][0]=1;
	int m=0;
	for (int i=1;i<=n;i++){
		if (vis[i]) continue;
		cnt0=cnt1=0;
		dfs(i,0);
		if (flg) break;
		m++;
		//cout<<"print cnt 0 cnt 1 "<<cnt0<<' '<<cnt1<<endl;
		for (int j=cnt0;j<=n;j++){
			dp[m][j]|=dp[m-1][j-cnt0];
		}
		for (int j=cnt1;j<=n;j++){
			dp[m][j]|=dp[m-1][j-cnt1];
		}
	}
	if (flg){
		cout<<"-1"<<endl;
		return 0;
	}
	int ans=2e9;
	for (int i=0;i<=n;i++){
		if (dp[m][i]){
			ans=min(ans,getv(i)+getv(n-i));
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6340
char s[65536],t[65536];
int n,i,r,w,c;
int main(n,i,r,w,c)
{
	for(;scanf("%d",&n),n;puts(s))
		for(i=!scanf("%s",s);i++<n;t[w]=0,strcpy(s,t))
			for(r=w=0;r<strlen(s);t[w++]=s[r],r+=c){
				for(c=0;s[++c+r]==s[r];);
				for(sprintf(t+w,"%d\0",c);t[++w];);
			}
	exit(0);
}

Measured memory_bytes: 492
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    string S;
    cin >> S;
    for (int i = 0; i < 3; i++) {
        if (S[i] == S[i + 1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

ll solve (ll h) {
    if (h == 1) {
        return 1;
    }
    return 1 + 2*solve(h/2);
}

int main(){
    ll h;
    cin >> h;
    cout << solve(h) << endl;
    return 0;
}




Measured memory_bytes: 256
n = int(input())
nums = list(map(int,input().split()))
ans = 0
i = 0

while i < n:
    j, k = i, i
    while j < n - 1 and nums[j] <= nums[j+1]:
        j += 1
    while k < n - 1 and nums[k] >= nums[k+1]:
        k += 1
    i = max(j , k) + 1
    ans += 1
print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char n[3];
	for(int p=0;p<3;p++)
	{
		cin>>n[p];
	}
	if(n[0]==n[2]){
		printf("Yes");
	}
	else{
		printf("No");	
	}
	return 0;
}

Measured memory_bytes: 256
d,n = map(int,input().split())
res=0
if(d == 0):
    if n ==100:
        n=101
        for i in range(0,n+1):
            res = i
        print(res)
    else:
        for i in range(0,n+1):
            res = i
        print(res)
elif(d == 1):
    if n == 100:
        n=101
        for i in range(0,n+1):
            res = i*100
        print(res)
    else:
        for i in range(0,n+1):
            res = i*100
        print(res)
elif(d == 2):
    if n==100:
        n=101
        for i in range(0,n+1):
            res = i*10000
        print(res)
    else:
        for i in range(0,n+1):
            res = i*10000
        print(res)
    


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

int main() {
int a;
cin >> a;
if(a<1200){
  cout << "ABC" << endl;
}
else{
  cout << "ARC" << endl;
}

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long ans=1;
for(int i=1;i<=n;i++){
ans*=i;
ans-=(long)(ans/1000000007l)*1000000007l;
}
System.out.println(ans);
}
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
#include <fstream>
#pragma GCC optimize("O2")
using namespace std;

#define F first
#define S second
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ld long double
#define pii pair <int ,int >
#define bug(x)  cout<<"passed "<<x<<endl;
#define ashar(x , y , z) cout<<setprecision(x)<<fixed<<y ; if (z==1) cout<<"\n" ;
long long const inf = 1e18, linf = 2e9, mod = 1e9+7 , inf2 = 1e12;
int const mxn = 3e5 + 10 ;


ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

long long  l[mxn] ; 
long long ans ; 

vector <long long > vec ; 



int main(){
	int n ; 
	cin>>n ; 
	for (int i = 1 ; i <= n ; i++){
		int a ; 
		cin>>a ; 
		l[i] = i + a ; 
		vec.push_back(i - a) ; 
	}
	vec.push_back(inf) ; 
	sort(vec.begin() , vec.end()) ; 
	for (int i = 1 ; i <= n ; i++){
		long long a = l[i] ; 
		long long A = lower_bound(vec.begin() , vec.end() , a) - vec.begin() ; 
		long long B = upper_bound(vec.begin() , vec.end() , a) - vec.begin() ; 
		ans+= B - A ; 
	}
	cout<<ans ; 
}	

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

using namespace std;

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

  int n;cin>>n;
  ll cnt=0;
  for(int i=0;i<n;i++){
      ll gomi,num;
      string s;
      cin>>gomi>>s>>num;
      if(s=="(")  cnt+=num;
      else cnt-=num;

      if(cnt) cout<<"No"<<endl;
      else cout<<"Yes"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
int main(){
    char a;
    cin >> a;
    if(a=='a' || a=='i' || a=='u' || a=='e' || a=='o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	String k = sc.next();
      	int s = sc.nextInt();
      	String ans = "";
      	char c = k.charAt(s-1);
      	for(int i=0;i<n;i++){
          if( k.charAt(i) == c ){
          	ans += ""+k.charAt(i);
          }else{
            ans += "*";
          }
        }
      System.out.println(ans);
	}
}

Measured memory_bytes: 39492
#include <iostream>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {//最大フロー求める Ford-fulkerson
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
	//最大フロー・最小カットの場合逆辺は0にする
}

void Dijkstra(Graph& G, ll s, Array& d) {//O(|E|log|V|)
	d.resize(G.size());
	REP(i, d.size())d[i] = INF;
	d[s] = 0;
	priority_queue<P, vector<P>, greater<P>> q;
	q.push(make_pair(0, s));
	while (!q.empty()) {
		P a = q.top();
		q.pop();
		if (d[a.second] < a.first)continue;
		REP(i, G[a.second].size()) {
			Edge e = G[a.second][i];
			if (d[e.to] > d[a.second] + e.cap) {
				d[e.to] = d[a.second] + e.cap;
				q.push(make_pair(d[e.to], e.to));
			}
		}
	}
}

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

	ll n;
	cin >> n;
	vector<string> s(n);
	REP(i, n) cin >> s[i];

	Graph g(n);
	vector<P> in(n);

	REP(i, n) {
		in[i].second = i;
	}

	REP(i, n) {
		REP(j, n) {
			if (s[i][j] == '1') {
				add_edge(g, i, j, 1, false, 1);
				in[j].first++;
			}
		}
	}
	sort(all(in));

	queue<ll> que;
	Array used(n, 0);
	que.push(in[0].second);
	used[in[0].second] = 1;

	while (que.size() > 0) {
		ll v = que.front();
		que.pop();
		for (auto e : g[v]) {
			if (!used[e.to]) {
				used[e.to] = used[v] + 1;
				que.push(e.to);
			}
			else {
				if (used[e.to] != used[v] + 1 && used[e.to] != used[v] - 1) {
					cout << -1 << endl;
					return 0;
				}
			}
		}
	}

	
	ll max = 0;
	REP(i, n){
		Array d;

		Dijkstra(g, i, d);
		REP(j, n) {
			chmax(max, d[j]);
			//cout << i << " " << j << " " << d[j] << endl;
		}
	}
	cout << max+1 << endl;
	return 0;
}


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

int main() {
  
  int N, M;
  cin >> N >> M ;
  
  vector<int> vec(2*M);
  
  for(int i = 0;i < 2 * M ;i++) {
    cin >> vec.at(i);
  }//配列完成
  
  for(int j = 0; j < N; j++) {
  
  	int x = 0 ;//整数xを定義
  
  	for (int i = 0 ; i < 2 * M ; i++) {
		if(vec.at(i) == j+1) /*配列の各項がj+1(1~N)と一致するかチェック*/ x++;
  	}
  
  	cout << x << endl;
  }
}
  

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void use_io_optimizations()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main()
{
    use_io_optimizations();

    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        int maxA = 0;
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            maxA = Math.max(maxA, A[i]);
        }

        int ng = 0;
        int ok = maxA;
        while (ng + 1 < ok) {
            int m = (ok+ng)/2;
            int c = 0;
            for (int i = 0; i < N; i++) {
                c += (A[i]+m-1)/m - 1;
            }
            if (c <= K) {
                ok = m;
            } else {
                ng = m;
            }
        }
        System.out.println(ok);
    }
}


Measured memory_bytes: 59492