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

using namespace std;

int main(){

	int n;
	cin >> n;
	int d[n];
	int num[101] = {0};
	int count = 0;

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

	for(int i=0; i<n; i++) num[d[i]]++;

	for(int i=1; i<=100; i++){
		if(num[i]) count++;
	}

	cout << count << endl;
}

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

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

struct Edge
{
  int to;     // 辺の行先
  int weight; // 辺の重み
  Edge(int t, int w) : to(t), weight(w) {}
};

using Graph = vector<vector<Edge>>;

vector<int> color;

void dfs(const Graph &G, int v, int cur = 0)
{
  color[v] = cur;
  for (auto next_v : G[v])
  {
    if (color[next_v.to] != -1)
      continue;
    if (next_v.weight % 2 == 0)
    {
      dfs(G, next_v.to, cur);
    }
    else
    {
      dfs(G, next_v.to, 1 - cur);
    }
  }
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  Graph G(N);
  for (int i = 0; i < N - 1; i++)
  {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    G[u].push_back(Edge(v, w));
    G[v].push_back(Edge(u, w));
  }

  // 探索
  color.assign(N, -1);
  for (int v = 0; v < N; v++)
  {
    if (color[v] != -1)
      continue;
    dfs(G, v);
  }
  for (auto &it : color)
    cout << it << endl;
  return 0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <math.h>
using namespace std;

int main(){
	int a[100001] = {};
	int n,x;
	long long ans;
	bool flag = true;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> x;
		a[x]++;
	}
	if(n%2 == 0){
		for(int i = 0;i < n;i++){
			if(i%2 == 0 && a[i] != 0){
				flag = false;
				break;
			}
			if(i%2 == 1 && a[i] != 2){
				flag = false;
				break;
			}
		}
	}
	else{
		for(int i = 0;i < n;i++){
			if(i == 0 && a[0] != 1){
				flag = false;
				break;
			}
			else if(i%2 == 0 && a[i] != 2 && i != 0){
				flag = false;
				break;
			}
			else if(i%2 == 1 && a[i] != 0){
				flag = false;
				break;
			}
		}
	}
	if(flag){
		n /= 2;
		ans = 1;
		for(int i = 0;i < n;i++){
			ans *= 2;
			if(ans > 100000007){
				ans %= 1000000007;
			}
		}
		cout << ans << endl;
	}
	else{
		cout << 0 <<endl;
	}
	return 0;
}

Measured memory_bytes: 640
while True:
    H, W = map(int, input().split())

    if H == 0 and W == 0:
        break

    for h in range(H):
        for w in range(W):
            if h == 0 or h == H - 1:
                print('#', end="")
            elif w == 0 or w == W - 1:
                print('#', end="")
            else:
                print('.', end="")
        print()
    print()



Measured memory_bytes: 7008
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll v[205];
ll x[20000005];
ll a[10005], b[10005];
ll dp[10005][10005];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
typedef pair<ll, ll> P;
int h, w;
char s[25][25];

int bfs(int sx,int sy) {
	queue<P>v;
	int dist[25][25];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			dist[i][j] = inf;
		}
	}
	dist[sx][sy] = 0;
	v.push(P{ sx,sy });
	while (v.size()) {
		P now = v.front();
		v.pop();
		for (int i = 0; i < 4; i++) {
			int nextx = now.first + dy[i];
			int nexty = now.second + dx[i];
			if ((0 <= nextx && nextx < h )&& (0 <= nexty && nexty < w)) {
				if (dist[nextx][nexty] == inf && s[nextx][nexty] != '#') {
					dist[nextx][nexty] = dist[now.first][now.second] + 1;
					v.push(P{ nextx,nexty });
				}
			}
		}

	}
	int res = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (dist[i][j] != inf) {
				res = max(res, dist[i][j]);
			}
		}
	}

	return res;

}

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> s[i][j];
		}
	}
	int ans=0;
	
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '.') {
				int res = bfs(i, j);
				if (res != inf) {
					ans = max(res, ans);
				}
			}
		}
	}
	cout << ans<< endl;
	return 0;
}


Measured memory_bytes: 256
/*Lucky_Glass*/
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e5;
struct EDGE{int u,v,col,len;}edg[N+5];
struct QUERY{int col,id,mdy,tag;};
vector<int> lnk[N+5];
vector<QUERY> qry[N+5];
int fa[N+5][20],dep[N+5],ans[N+5];
int n,m;
void Process(int u,int pre){
	fa[u][0]=pre;dep[u]=dep[pre]+1;
	for(int i=1;i<20;i++) fa[u][i]=fa[fa[u][i-1]][i-1];
	for(int i=0;i<lnk[u].size();i++){
		int v=edg[lnk[u][i]].u==u? edg[lnk[u][i]].v:edg[lnk[u][i]].u;
		if(v==pre) continue;
		Process(v,u);
	}
}
int totfar,colcnt[N+5],collen[N+5];
void DFS(int u,int pre){
	for(auto it : qry[u])
		ans[it.id]+=it.tag*(totfar-collen[it.col]+colcnt[it.col]*it.mdy);
	for(int i=0;i<lnk[u].size();i++){
		int v=edg[lnk[u][i]].u==u? edg[lnk[u][i]].v:edg[lnk[u][i]].u;
		if(v==pre) continue;
		totfar+=edg[lnk[u][i]].len;
		colcnt[edg[lnk[u][i]].col]++;
		collen[edg[lnk[u][i]].col]+=edg[lnk[u][i]].len;
		DFS(v,u);
		totfar-=edg[lnk[u][i]].len;
		colcnt[edg[lnk[u][i]].col]--;
		collen[edg[lnk[u][i]].col]-=edg[lnk[u][i]].len;
	}
}
int LCA(int u,int v){
	if(dep[u]<dep[v]) swap(u,v);
	for(int i=19;i>=0;i--)
		if(dep[fa[u][i]]>=dep[v])
			u=fa[u][i];
	if(u==v) return u;
	for(int i=19;i>=0;i--)
		if(fa[u][i]!=fa[v][i])
			u=fa[u][i],v=fa[v][i];
	return fa[u][0];
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++){
		int u,v,col,len;scanf("%d%d%d%d",&u,&v,&col,&len);
		edg[i]=(EDGE){u,v,col,len};
		lnk[u].push_back(i);lnk[v].push_back(i);
	}
	Process(1,0);
	for(int i=1;i<=m;i++){
		int u,v,col,len;
		scanf("%d%d%d%d",&col,&len,&u,&v);
		int lca=LCA(u,v);
		qry[u].push_back((QUERY){col,i,len,1});
		qry[v].push_back((QUERY){col,i,len,1});
		qry[lca].push_back((QUERY){col,i,len,-2});
	}
	DFS(1,0);
	for(int i=1;i<=m;i++)
		printf("%d\n",ans[i]);
	return 0;
}

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

int main()
{
    long int N, K, a, n, m;
    cin >> N >> K;
    a = N / K;
    if (N - a * K > (a + 1) * K - N)
    {
        cout << (a + 1) * K - N << endl;
    }
    else
    {
        cout << N - a * K << endl;
    }
}

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

int main() {
  
  int n;
  string s;
  cin >> n >> s;
  
  int count = 0;
  
  for ( int i = 0; i < 1000; i++){
    int c[3] = { i / 100, ( i / 10 ) % 10, i % 10 };
    int f = 0;
    for ( int j = 0; j < n; j++){
      if ( s[j] == '0' + c[f] )f++;
      if ( f == 3 )break;
    }
    if ( f == 3 )count++;
  }
  
  cout << count << endl;
  
}

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

int main(){
  int n, t, ans, f;
  string s;
  while (cin >> n, n){
    ans = 0;
    t = 0;
    f = 2;
    for (int i = 0; i < n; ++i){
      cin >> s;
      if (s == "lu" || s == "ru") ++t;
      else --t;
      if (t == f){
	++ans;
	f = (f+2)%4;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>
#include <string.h>

typedef long long ll;

int main() {
  int i, j;
  // s を文字列として読み込む
  char s[20];
  scanf("%s", s);

  int s_len = strlen(s);
 // printf("%d\n", s_len);

  int a[20];
  for (i = 0; i < s_len; i++) {
    a[i] = s[i]-'0';
  }

  for (i = 0; i < s_len; i++) {
   // printf("%d\n", a[i]);
  }

  ll ans = 0; // 答えは int に収まらないので long long int を使う
  // s_len 個の数字の間は s_len-1 個ある
  // それぞれの間に, + を入れるか入れないかを考える.
  for (i = 0; i < (1<<(s_len-1)); i++) {
    // i: 000..00 ~ 111..11
    // i 番目の bit が立っている => i番目の間に + を入れると考える
    ll cur = a[0], sum = 0;
    for (j = 0; j < s_len-1; j++) {
      // j 番目の bit が立っていたら
      // j 番目の間に入るのは +
      if ( (i>>j) & 1 ) {
        sum += cur;
        cur = a[j+1];
      } else {
        cur *= 10;
        cur += a[j+1];
      }
    }
    sum += cur;
    ans += sum;
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
 *
 * @author Y
 */

class saikoro{
    String a[];
    String tmp;
    saikoro(String a){
        this.a = new String[6];
        this.a = a.split(" ");
    }
    
    void N(){
        tmp = this.a[0];
        this.a[0] = this.a[1]; this.a[1] = this.a[5]; 
        this.a[5] = this.a[4]; this.a[4] = tmp; 
    }
    void S(){
        tmp = this.a[0];
        this.a[0] = this.a[4]; this.a[4] = this.a[5]; 
        this.a[5] = this.a[1]; this.a[1] = tmp; 
    }
    void W(){
        tmp = this.a[0];
        this.a[0] = this.a[2]; this.a[2] = this.a[5];
        this.a[5] = this.a[3];  this.a[3] = tmp;
    }
    void E(){
        tmp = this.a[0];
        this.a[0] = this.a[3];  this.a[3] = this.a[5];
        this.a[5] = a[2];  this.a[2] = tmp;
    }
    public String getS(int n){
        return this.a[n];
    }
}

class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        saikoro d = new saikoro(str);
        str = br.readLine();
        
        for(int i = 0;i<str.length();i++){
            char c = str.charAt(i);
            switch(c){
                case 'N':
                    d.N();
                    break;
                case'S':
                    d.S();
                    break;
                case 'W':
                    d.W();
                    break;
                case 'E':
                    d.E();
                    break;
                default:
                    break;
            }
        }
        
        System.out.println(d.getS(0));
    }
}

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

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    int d = a*b;
    if(d>c){
        cout << c << endl;
    }else{
        cout << d << endl;
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

template<int MOD>
class ModInt {
public:
    ModInt() :value(0) {}
    ModInt(long long val) :value((int)(val<0 ? MOD + val%MOD : val%MOD)) { }

    ModInt& operator+=(ModInt that) {
        value = value + that.value;
        if (value >= MOD)value -= MOD;
        return *this;
    }
    ModInt& operator-=(ModInt that) {
        value -= that.value;
        if (value<0)value += MOD;
        return *this;
    }
    ModInt& operator*=(ModInt that) {
        value = (int)((long long)value * that.value % MOD);
        return *this;
    }
    ModInt &operator/=(ModInt that) {
        return *this *= that.inverse();
    }
    ModInt operator+(ModInt that) const {
        return ModInt(*this) += that;
    }
    ModInt operator-(ModInt that) const {
        return ModInt(*this) -= that;
    }
    ModInt operator*(ModInt that) const {
        return ModInt(*this) *= that;
    }
    ModInt operator/(ModInt that) const {
        return ModInt(*this) /= that;
    }
    ModInt pow(long long k) const {
        ModInt n = *this, res = 1;
        while (k) {
            if (k & 1)res *= n;
            n *= n;
            k >>= 1;
        }
        return res;
    }
    ModInt inverse() const {
        long long a = value, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }
    int toi() const { return value; }

private:
    int value;
};
typedef ModInt<1000000007> mint;
ostream& operator<<(ostream& os, const mint& x) {
    os << x.toi();
    return os;
}

void solve() {
    int H, W;
    cin >> H >> W;
    vector<vector<mint>> dp(H, vector<mint>(W));
    vector<string> S(H);

    dp[0][0] = 1;

    rep(y, H) {
        cin >> S[y];
    }
    rep(y, H) {
        rep(x, W) {
            if (y < H - 1 && S[y + 1][x] == '.')dp[y + 1][x] += dp[y][x];
            if (x < W - 1 && S[y][x + 1] == '.')dp[y][x + 1] += dp[y][x];
        }
    }
    cout << dp[H - 1][W - 1] << endl;
}

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


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

int main(void){
 
  int N;
  
  cin >> N;
  
  int array[N];
  
  for(int i = 0; i < N; i++){
    cin >> array[i];
  }
  
  int temp = 0;
  
  for(int i = 0; i < N - 1; i++){
    for(int j = i; j < N; j++){
      if(array[i] < array[j]){
        temp = array[i];
        array[i] = array[j];
        array[j] = temp;
      }
    }
  }
  
  int count = 0;
  int num = 0;
  
  for(int i = 0; i < N; i++){
     if(i == 0){
       num = array[i];
       count++;
     }
  	 if(num > array[i]){
       num = array[i];
       count++;
     }
  }
  
  cout << count << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m, X, Y;
    cin >> n >> m >> X >> Y;

    const int INF = 1 << 28;
    vector<int> mins(2, INF);
    vector<int> maxs(2, -INF);

    for (int i = 0; i < n; ++i) {
        auto& mn = mins[0];
        auto& mx = maxs[0];
        int x;
        cin >> x;
        mn = min(mn, x);
        mx = max(mx, x);
    }

    for (int i = 0; i < m; ++i) {
        auto& mn = mins[1];
        auto& mx = maxs[1];
        int x;
        cin >> x;
        mn = min(mn, x);
        mx = max(mx, x);
    }

    bool res = false;
    if (maxs[0] < mins[1]) {
        // cout << mins[1]  << " " << maxs[0] << endl;
        if (mins[1] > X && maxs[0] < Y) {
            res = true;
        }
    }
    if (res) {
        cout << "No War\n";
    } else {
        cout << "War\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  int n; string s;
  cin >> n >> s;
  for(int i = 0; i < s.length(); i++){
    cout << char('A'+(s[i]+n-'A')%(26));
  }
  cout << endl;
}


Measured memory_bytes: 384
import math

def isprime(x):
    if x==2:
        return True
    
    if x<2 or x%2==0:
        return False
    i = 3

    while i<=math.sqrt(x):
        if x%i==0:
            return False
        i = i+2

    return True

n = int(input())
count = 0

for i in range(0, n):
    b = int(input())

    if isprime(b):
        count += 1

print(count)



Measured memory_bytes: 5672
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
 
int main(){
  int n; cin >> n;
  vector<int> a(n),b(n),c(n);
  for(auto&&e : a)cin >> e;
  for(auto&&e : b)cin >> e;
  for(auto&&e : c)cin >> e;
 
  sort(a.begin(),a.end());
  sort(c.begin(),c.end());
 
  long long sum = 0;
 
  for(auto&&e : b){
    long long sum_a = 0, sum_b = 0;
    sum_a = lower_bound(a.begin(), a.end(), e) - a.begin();
    sum_b = c.end() - upper_bound(c.begin(), c.end(), e);
    sum += sum_a * sum_b;
  }
 
  cout << sum << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;

#define out(v) cout<<v<<"\n"
#define _overload3(_1,_2,_3,name,...) name
#define _all1(a) (a).begin(),(a).end()
#define _all2(a,n) (a),(a)+n
#define all(...) _overload3(__VA_ARGS__,42,_all2,_all1,)(__VA_ARGS__)
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
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; }
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

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

  vector<int> v(N);
  ll sum = 0;
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    sum += b;
    v[i] = a + b;
  }
  sort(all(v));
  reverse(all(v));
  ll ans = 0;
  rep(i, N) {
    if (i % 2 == 0)
      ans += v[i];
  }
  out(ans - sum);

  return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int ans=n;
	for(int i=90,j=100;j<=n;i*=100,j*=100)ans-=i;
	int size=to_string(n).size();
	if(size%2==0){
		int p=1;
		while(size>1)p*=10,--size;
		ans-=n-p+1;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 3672
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<"IMPOSSIBLE"<<endl;return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
//12:15~
const int mod=1e9+7;
const int big=1e9+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
bool solve(int n){
	int i;
	if(n==0){return false;}
	vector<bitset<50>> a(n);
	vector<vector<int>> can(30);
	bitset<50> las;//??£??§???
	for(i=0;i<n;i++){
		int f;cin>>f;
		while(f--){int q;cin>>q;q--;can[q].pub(i);}
	}
	for(i=0;i<n;i++){a[i][i]=true;las[i]=true;}
	for(int d=0;d<30;d++){
		bitset<50> now;
		for(auto it:can[d]){now|=a[it];}
		if(now==las){cout<<d+1<<endl;return true;}
		for(auto it:can[d]){a[it]=now;}
	}
	cout<<-1<<endl;return true;
}
int main(void){
	int n;
	while(cin>>n,solve(n)){}
	return 0;
}

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

#define INF 0x3f3f3f3f

using namespace std;

typedef long long ll;
// typedef priority_queue<int, vector<int>, greater<int>> min_pq;

std::random_device rd_device;
std::mt19937 rng(rd_device());

template<typename T>
void printVec(vector<T> &vec) {
    for (auto &v : vec) cout<<v<<" ";
    cout<<endl;
}

void sleep(int ms) {
    std::this_thread::sleep_for(std::chrono::milliseconds(ms));
}

vector<vector<int>> dir = {{-1,0},{1,0},{0,-1},{0,1}};

int main() {
    std::srand(std::time(0));
    ios::sync_with_stdio(false);
//    cin.exceptions(ios_base::failbit);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(10);
    cout<<fixed;
    
    int h, w;
    cin>>h>>w;
    vector<string> grid(h);
    queue<vector<int>> q;
    for (int i=0;i<h;i++) { 
        cin>>grid[i];
        for (int j=0;j<w;j++) {
            if (grid[i][j] == '#') q.push({i, j, 0});
        }
    }

    int m = 0;
    while (!q.empty()) {
        vector<int> curr = q.front();
        q.pop();
        for (auto &d : dir) {
            int x = curr[0]+d[0];
            int y = curr[1]+d[1];
            if (x>=0 && x<h && y>=0 && y<w) {
                if (grid[x][y] != '.') continue;
                int s = curr[2]+1;
                m = max(m, s);
                grid[x][y] = '#';
                q.push({x,y,s});
            } 
        }
    }
    cout<<m<<endl;

    return 0;
}


Measured memory_bytes: 56756
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll X,Y,Z,K;
	cin >>X>>Y>>Z>>K;
	ll A[X],B[Y],C[Z];
	for (ll i = 0; i < X; ++i) cin >> A[i];
	for (ll i = 0; i < Y; ++i) cin >> B[i];
	for (ll i = 0; i < Z; ++i) cin >> C[i];
	
	// 解法
	sort(A,A+X, greater<ll>());
	sort(B,B+Y, greater<ll>());
	sort(C,C+Z, greater<ll>());
	
	ll step = 0;
	ll AB[X*Y];
	REP(i,X){
		REP(j,Y){
			AB[step] = A[i]+B[j];
			step++;
		}
	}
	sort(AB,AB+X*Y, greater<ll>());

	step = 0;
	ll upper = min(K,X*Y);
	ll ans[upper*Z];
	REP(i,upper){
		REP(l,Z){
			ans[step] = AB[i]+C[l];
			step++;
		}
	}
	sort(ans,ans+upper*Z, greater<ll>());
	//出力
	
	REP(i,K) printf("%lld\n", ans[i]);
}


Measured memory_bytes: 31616
n, m = map(int, input().split())
A = [[int(e) for e in input().split()] for i in range(n)]
b = []
for i in range(m):
    e = int(input())
    b.append(e)
for i in range(n):
    p = 0
    for j in range(m):
        p += A[i][j] * b[j]
    print(p)

Measured memory_bytes: 8000
#include <stdio.h>

int main(){
  int W, H, x, y, r;
  int up, down, left, right;

  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  up = y + r;
  down = y - r;
  left = x - r;
  right = x + r;

  if(left < 0){
    printf("No\n");
  } else if(down < 0){
    printf("No\n");
  } else if(right > W){
    printf("No\n");
  } else if(up > H){
    printf("No\n");
  } else {
    printf("Yes\n");
  }

  return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
#define inf 101010
typedef pair<int,int> pii;
typedef pair<double,pii> pp;

int main(void){
    int n,m,p,a,b;
    while (cin>>n>>m>>p>>a>>b && n) {
        a--, b--;
        vector<int> t(n);
        for (int i = 0; i < n; i++) cin >> t[i];
        vector<vector<pii> > g(m, vector<pii>());
        for (int i = 0; i < p; i++) {
            int x,y,z;
            cin>>x>>y>>z;
            x--, y--;
            g[x].push_back(make_pair(y,z));
            g[y].push_back(make_pair(x,z));
        }
        
        vector<vector<double> > d(m, vector<double>(1<<n, inf));
        priority_queue<pp, vector<pp>, greater<pp> > que;
        que.push(make_pair(0.0, make_pair(a, (1<<n)-1)));
        
        double ans = inf;
        while (!que.empty()) {
            pp p = que.top(); que.pop();
            double cost = p.first;
            int cur = p.second.first, bit = p.second.second;
            if (cur == b) {
                ans = cost;
                break;
            }
            if (cost > d[cur][bit]) continue;
            
            for (int i = 0; i < g[cur].size(); i++) {
                int to = g[cur][i].first, len = g[cur][i].second;
                for (int j = 0; j < n; j++) {
                    if (bit & 1<<j) {
                        double x = len / (double)t[j];
                        int nbit = bit & ~(1<<j);
                        if (cost+x >= d[to][nbit]) continue;
                        d[to][nbit] = cost+x;
                        que.push(make_pair(cost+x, make_pair(to, nbit)));
                    }
                }
            }
        }
        if (ans == inf) cout << "Impossible" << endl;
        else printf("%.8lf\n",ans);
    }
}

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

int main(){
  string s = "aeiou";
  char c;
  cin >> c;
  for(int i = 0; i < 5; ++i){
	if(c == s[i]){
      cout << "vowel" << endl;
      return 0;
    }
  }
  cout << "consonant" << endl;
  return 0;
}


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

A = A-1
B = B-1
C = C-1
D = D-1

for i in range(B,D):
    if S[i] == "#" and S[i+1] == "#":
        print("No")
        exit()

for i in range(A,C):
    if S[i] == "#" and S[i+1] == "#":
        print("No")
        exit()

if C < D:
    print("Yes")
    exit()

if C > D:
    for i in range(B-1, D - 1):
        if S[i] == "." and S[i + 1] == "." and S[i + 2] == ".":
            print("Yes")
            exit()
    if S[D-1] == "#" or S[D+1] == "#":
        print("No")
    else:
        print("Yes")

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

int main()
{
    string s, t; cin >> s >> t;

    map<char, char> st, ts;
    for (int i = 0; i < s.length(); i++) {
        if (st.count(s[i])) {
            if (st[s[i]] != t[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
        if (ts.count(t[i])) {
            if (ts[t[i]] != s[i]) {
                cout << "No" << endl;
                return 0;
            }
        }

        st[s[i]] = t[i], ts[t[i]] = s[i];
    }
    cout << "Yes" << endl;
    return 0;
}

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

long long M, A[1 << 18], B[1 << 18];
long long V1, V2;

int main() {
	cin >> M;
	for (int i = 1; i <= M; i++) {
		cin >> A[i] >> B[i];
		V1 += B[i];
		V2 += 1LL * A[i] * B[i];
	}
	cout << ((V2 - 1LL) / 9LL) + (V1 - 1LL) << endl;
	return 0;
}

Measured memory_bytes: 6780
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main(int argc, char *argv[])
{
    int h, w;
    int rows, cols;
    int ans;

    scanf("%d %d", &h, &w);
    scanf("%d %d", &rows, &cols);

    ans = h * w - (w * rows + h * cols - rows * cols);

    printf("%d\n", ans);

    return 0;
}


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

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ','){cerr << *sdbg++;}cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

const int N = 2E5 + 10;

int a[N];

inline bool cmp(const pll &l, const pll &r){
	return abs(l.st - l.nd) < abs(r.st - r.nd);
}

vector<pll> gen(int a[], int n){
	vector<pll> ret;
	ll A = a[0], B = 0;
	for (int j = 1, i = 1; i < n; ++i){
		B += a[i];
		for (; j < i && A + a[j] <= B - a[j]; ++j)
			A += a[j], B -= a[j];
		pll t(A, B);
		if (j < i && cmp(pll(A + a[j], B - a[j]), t))
			t = pll(A + a[j], B - a[j]);
		if (t.st > t.nd)
			swap(t.st, t.nd);
		ret.push_back(t);
	}
	return ret;
}

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", a + i);
	vector<pll> f = gen(a, n);
	reverse(a, a + n);
	vector<pll> g = gen(a, n);
	reverse(all(g));
	eput(f);
	eput(g);
	ll ans = 1ll << 60;
	for (int i = 0; i < f.size() - 2; ++i)
		ans = min(ans, max(f[i].nd, g[i + 2].nd) - min(f[i].st, g[i + 2].st));
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 13164
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
    string s; cin>>s;
    int n=s.size();
    reverse(s.begin(), s.end());
    ll dp[13][100010]={};
    dp[0][0]=1;
    int p=1;
    for(int i=0; i<n; i++){
        if(s[i]!='?'){
            int x=(s[i]-'0')*p%13;
            for(int j=0; j<13; j++){
                (dp[(j+x)%13][i+1]+=dp[j][i])%=MOD;
            }
        }else{
            for(int k=0; k<10; k++){
                int x=k*p%13;
                for(int j=0; j<13; j++){
                    (dp[(j+x)%13][i+1]+=dp[j][i])%=MOD;
                }
            }
        }
        p=p*10%13;
    }
    cout<<dp[5][n]<<endl;
    return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

int main(int argc, char **argv)
{
	ll n, x;
	while (cin >> n >> x, (n != 0) || (x != 0) )
	{

		ll res{0};
		for (ll a = 1; a <= n; ++a)
		{
			for (ll b = a+1; b <= n; ++b)
			{
				ll c = x - a - b;
				if (c <= a || c <= b || c > n || c <= 0) continue;
				// std::cout << "a : " << a << std::endl;
				// std::cout << "b : " << b << std::endl;
				// std::cout << "c : " << c << std::endl;
				++res;
			}
		}
		std::cout << res << std::endl;
	}
}



Measured memory_bytes: 3100
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var A = sc.ArrayDouble(N);

        double sum = 0;
        for (int i = 0; i < N; i++) {
            sum += 1 / A[i];
        }
        WriteLine(1 / sum);
    }
    
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13268
#include<iostream>
using namespace std;
// comment
typedef long long ll;
const int mod=1e9+7;
const int N=50000005;
int s,len[N],p[N];
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    p[0]=1;
    scanf("%d",&s);
    ll ans=0;
    int sum=0;
    for(int l=1,r=0;l<10000000;l++)
    {
        while(sum<s)
        {
            r++;
            p[r]=p[r-1];
            len[r]=len[r-1];
            if(r/p[r]!=0) p[r]*=10,len[r]++;
            sum+=len[r];
        }
        if(sum==s) ans++;
        sum-=len[l];
    }
    for(int t=1;t<=s/8;t++)
    {
        if(s%t) ans=(ans+1)%mod;
        else ans=(ans+(qpow(10,s/t)-qpow(10,s/t-1)-t+1))%mod;
    }
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}

Measured memory_bytes: 178432
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int N;
	string S, T;
	cin >> N >> S >> T;
	for(int i=0; i<N; ++i) cout << S[i] << T[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


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

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n,k,m; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

int main() {
	cin >> s >> t;
	int res = 100; string str; vector<string> v;
	if (s.size() < t.size()) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	for (int i = 0; i <= s.size()-t.size(); i++) {
		int flag = 0;
		for (int j = 0; j < t.size(); j++) {
			if (s[i + j] != '?' && s[i + j] != t[j]) {
				flag = 1;
			}
		}
		if (flag)
			continue;

		string tt = s;
		tt.replace(i, t.size(), t);
		for (int j = 0; j < tt.size(); j++) {
			if (tt[j] == '?') {
				tt[j] = 'a';
			}
		}
		v.push_back(tt);
	}
	if (v.empty()) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	sort(v.begin(), v.end());

	cout << v[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define for_tests(t, tt) int t; scanf("%d", &t); for(int tt = 1; tt <= t; tt++)
#ifndef ONLINE_JUDGE
#define debug(args...) fprintf(stderr,args)
#else
#define debug(args...)
#endif //ONLINE_JUDGE
template<typename T> inline T abs(T t) { return t < 0? -t : t; }
const ll modn = 1000000007;
inline ll mod(ll x) { return x % modn; }
#define IOS() ios::sync_with_stdio(0),cin.tie(0)

const int MAXN = 212345;

ll n, m, k;
int main (){
	scanf("%lld%lld%lld", &n, &m, &k);
    if(n > m*k)
        puts("No");
    else
        puts("Yes");
}



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

int main() {
	string s;
	cin>>s;
	if(s == "SUN")cout<<7<<'\n';
	else if(s == "MON")cout<<6<<'\n';
	else if(s == "TUE")cout<<5<<'\n';
	else if(s == "WED")cout<<4<<'\n';
	else if(s == "THU")cout<<3<<'\n';
	else if(s == "FRI")cout<<2<<'\n';
	else if(s == "SAT")cout<<1<<'\n';
}

Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<String> s = nextCharArray();
		int N = nextInt();
		String output = "";
		for(int i = 0; i < s.size(); i += N){
			output += s.get(i);
		}
		myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


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

int main() {
 int h,n;
 cin >> h >> n;
 int ans =0;
 for(int i=0;i<n;i++){
    int a;
    cin >> a;
    ans += a;
 }
 if(ans>=h) cout << "Yes" << endl;
 else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    
    string s,t;
    cin >> s >> t;
    int n=s.size();
    bool ok=true;
    int m=t.size();
    if(n+1!=m){
        print("No");
        return 0;
    }
    rp(i,n){
        if(s.at(i)!=t.at(i)){
            ok=false;
            break;
        }
    }
    Yes(ok);
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
using namespace std;
int main(){
  int X,A,B;
  cin >> X >> A >> B;
  if(A >= B){
    cout << "delicious" << endl;
  }else{
    if(X + A >= B){
      cout << "safe" << endl;
    }else{
      cout << "dangerous" << endl;
    }
  }
}

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

#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()

const int mod = 1e9+7;
const int inf = 2e18;

int32_t main()
{	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin>>n;

	int a[n+5];

	int sum[n+5];
	int diff[n+5];
	
	unordered_map<int,int> mpsum;
	unordered_map<int,int> mpdiff;

	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum[i] = (a[i]+i);
		diff[i] = (a[i]-i);		
		mpsum[sum[i]]++;
		mpdiff[diff[i]]++;
	}

	int cnt = 0;

	for(int i=1;i<=n;i++)
	{
		int tsum = sum[i];
		tsum = (-1)*tsum;
		cnt+=(mpdiff[tsum]);
	}

	cout<<cnt<<'\n';
	return 0;
}	

Measured memory_bytes: 31068
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF (1LL << 60)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll SX, SY, GX, GY, N;
vector<pll> P;

int main(void) {
  ll m = 1;
  cin >> SX >> SY >> GX >> GY;
  if(SX > GX) swap(SX, GX), swap(SY, GY);
  if(SY > GY) swap(SY, GY), m = -1;

  cin >> N;
  REP(i, 0, N) {
    ll x, y;
    cin >> x >> y;
    if(SX <= x && x <= GX && SY <= y && y <= GY) {
      P.push_back(pll(x, m * y));
    }
  }
  N = P.size();
  sort(P.begin(), P.end());

  ll dp[200000];
  REP(i, 0, N) dp[i] = INF;
  REP(i, 0, N) {
    *lower_bound(dp, dp + N, P[i].second) = P[i].second;
  }
  ll t = lower_bound(dp, dp + N, INF) - dp;

  double pi = atan(1.0) * 4.0;
  double ans = ((GX - SX) + (GY - SY)) * 100 + t * (5 *  pi - 20);
  if(min(GX - SX, GY - SY) + 1 == t) ans += 5 * pi;
  printf("%.15lf\n", ans);
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vi l(n);
  rep(i,n)cin >> l[i];
  sort(rng(l));
  int ans = 0;
  rep(i,n-1){
    srep(j,i+1,n){
      int x = l[i]+l[j];
      int num = lower_bound(rng(l),x)-l.begin();

      ans+=max(0,num-j-1);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

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

int main() {
	ll n, t, q;
	cin >> n >> t >> q;
	vector<pll> data(n);
	
	REP(i, n) scanf("%lld%lld", &data[i].first, &data[i].second);
	sort(data.begin(), data.end());
	
	vector<ll> sto;
	REP(i, n - 1) {
		if (data[i].second == 1 && data[i + 1].second == 2) {
			sto.push_back((data[i].first + data[i + 1].first) / 2);
		}
	}
	sort(sto.begin(), sto.end());
	
	REP(i, q) {
		int now;
		scanf("%d", &now);
		now--;
		
		ll ans;
		if (data[now].second == 1) {
			ans = data[now].first + t;
			REP(j, sto.size()) {
				if (data[now].first < sto[j])
					ans = min(ans, sto[j]);
			}
		}
		else {
			ans = data[now].first - t;
			REP(j, sto.size()) {
				if (sto[j] < data[now].first)
					ans = max(ans, sto[j]);
			}
		}
		
		printf("%lld\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 4856
#include"bits/stdc++.h"
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
using namespace std;

void Main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b << endl;
}
int main() {
	cout << fixed;
	cout << setprecision(6);
	Main();
}

Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

for i in range(1, N+1):
    A[i-1] -= i

# print(A)

ans = 0
if all(a != 0 for a in A):
    ans = 0
else:
    seq = 0
    for i in range(N):
        if A[i] == 0:
            seq += 1
        else:
            ans += (seq+1)//2
            seq = 0
    ans += (seq+1)//2
print(ans)


Measured memory_bytes: 14068