akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX_N = 100005;

int n,m,easy[MAX_N],res[MAX_N];
vector<int> adjl[MAX_N];
vector<int> pre[MAX_N],suf[MAX_N];

int f(int i, int par)
{
	int p=1;
	for (int x : adjl[i])
		if (x!=par)
			p=(p*1LL*f(x,i))%m;
	pre[i].push_back(1);
	for (int x : adjl[i])
		if (x!=par)
			pre[i].push_back((pre[i].back()*1LL*easy[x])%m);
		else
			pre[i].push_back(pre[i].back());
	suf[i].push_back(1);
	for (int z=adjl[i].size()-1; z>=0; z--)
	{
		int x=adjl[i][z];
		if (x!=par)
			suf[i].push_back((suf[i].back()*1LL*easy[x])%m);
		else
			suf[i].push_back(suf[i].back());
	}
	reverse(suf[i].begin(),suf[i].end());
	return easy[i]=(1+p)%m;
}

void g(int i, int fp, int par)
{
	res[i]=((easy[i]-1+m)*1LL*fp+1)%m;
	for (int z=0; z<adjl[i].size(); z++)
	{
		int x=adjl[i][z];
		if (x!=par)
		{
			int nfp=(fp*1LL*pre[i][z])%m;
			nfp=(nfp*1LL*suf[i][z+1])%m;
			g(x,(1+nfp)%m,i);
		}
	}
}

int main()
{
	scanf("%d %d",&n,&m);
	for (int i=1; i<n; i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		adjl[a].push_back(b);
		adjl[b].push_back(a);
	}
	f(1,0);
	g(1,1,0);
	for (int i=1; i<=n; i++)
		printf("%d\n",(res[i]-1+m)%m);
	return 0;
}


Measured memory_bytes: 26240
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P = pair<int, int>;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    else {
        return false;
    }
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    else {
        return false;
    }
}
struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;


signed main() {
    set<int> st;
    rep(i, 0, 3) {
        int a; cin >> a;
        st.insert(a);
    }
    cout << st.size() << endl;
}

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

int main() {
	long long N, L, Q;
	cin >> N;
	vector<long long> X(N);
	for (int i = 0; i < N; i++) cin >> X[i];
	cin >> L >> Q;
	long long K = log2(N);
	vector<vector<long long> > D(N, vector<long long>(K + 1));
	for (int i = 0; i < N; i++) {
		D[i][0] = upper_bound(X.begin(), X.end(), X[i] + L) - X.begin() - 1;
	}
	for (int j = 1; j <= K; j++) {
		for (int i = 0; i < N; i++) {
			D[i][j] = D[D[i][j - 1]][j - 1];
		}
	}
	for (int i = 0; i < Q; i++) {
		long long S, T;
		cin >> S >> T;
		S--, T--;
		if (S > T) swap(S, T);
		long long ANS = 0;
		for (int j = K; j >= 0; j--) {
			if (D[S][j] < T) {
				S = D[S][j];
				ANS += 1LL << j;
			}
		}
		cout << ANS + 1 << endl;
	}
}

Measured memory_bytes: 18048
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>



#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define unko signed
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;

int dp[10010][2][100];
//dp[i][isless][r]
unko main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string K;
	int D;
	cin >> K >> D;
	int N = K.size();
	//dp[0][1][0] = 1;
	dp[0][0][0] = 1;
	REP(i, N) {//i+1桁目について
		int pos = K[i] - '0';
			REP(j, 10) {//i+1桁目の数字
				REP(r, D) {
					if (j == pos) {
						dp[i + 1][0][(r + j) % D] += dp[i][0][r];
						dp[i + 1][1][(r + j) % D] += dp[i][1][r];
					}
					else if (j < pos) {
						dp[i + 1][1][(r + j) % D] += dp[i][0][r] + dp[i][1][r];
					}
					else {
						dp[i + 1][1][(r + j) % D] += dp[i][1][r];
					}
					dp[i + 1][0][(r + j) % D] %= MOD;
					dp[i + 1][1][(r + j) % D] %= MOD;
				}
			}
	}
	int ans = (dp[N][0][0] + dp[N][1][0]-1+MOD) % MOD;
	print(ans);
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  vector<ll>vec(a);
  vector<ll>veco(a-1);
  ll b=0;
  for(ll i=0;i<a;i++){
    cin>>vec.at(i);
  }
  for(ll i=0;i<a;i++){
    ll c;
    cin>>c;
    b+=c;
  }
  for(ll i=0;i<a-1;i++){
    cin>>veco.at(i);
  }
  for(ll i=0;i<a-1;i++){
    if(vec.at(i)+1==vec.at(i+1)){
      b+=veco.at(vec.at(i)-1);
    }
  }
  cout<<b<<endl;
}
    

Measured memory_bytes: 3604
N = int(input())
S = input()
max_w = S.count(".")
if max_w == 0 or max_w == N:
  print(0)
  exit()

ans = float("inf")
b, w = 0, max_w
for s in S:
  if s == "#":
    b += 1
  else:
    w -= 1
  ans = min(ans, b+w)
print(min(ans, max_w, N-max_w))


Measured memory_bytes: 9472
W, H, x, y = map(int, input().split())

if W == H:
    if x == y and x == (W/2):
        print('{} 1'.format(0.5*W*H))
    else:
        print('{} 0'.format(0.5*W*H))
else:
    if x == (W/2) and y == (H/2):
        print('{} 1'.format(0.5*W*H))
    else:
        print('{} 0'.format(0.5*W*H))     

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
struct objects{
    int weight,value;
};
ll solve(){
   int n,w;
   cin>>n>>w;
   objects object[n];
   int totalvalue=0;
   for(int i=0;i<n;i++){
       cin>>object[i].weight>>object[i].value;
       totalvalue+=object[i].value;
   }
   ll dp[n+1][totalvalue+1];
    //dp[i][j] denotes the least weight to get a value of
   // j from the first i objects
   dp[0][0]=0;//It takes 0 weight here
   int ans=0;
   for(int i=1;i<=totalvalue;i++){
       dp[0][i]=1e18;
      // Just set it arbitrarily large
       //because it's not possible 
   }
   for(int i=0;i<n;i++){
       for(int j=0;j<=totalvalue;j++){
           if(j>=object[i].value){
                dp[i+1][j]=min(dp[i][j],dp[i][j-object[i].value]+object[i].weight);
                //Either don't choose this object(dp[i][j]) or choose this object
                //The value without it would be j-object[i].value
                //the minimum weight would be the minimum weight needed to
                //get a value of j- object[i].value and add the weight of this object.
           }
           else{
               //If I choose this object the value will go over j
               dp[i+1][j]=dp[i][j];
           }
           if(dp[i+1][j]<=w){//Is it possible to get value of j in less than w weight
               ans=max(ans,j);//Find maximum such j
           }
       }
   }
   return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<solve();
}


Measured memory_bytes: 79232
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int out=0,co=0;
vi in,tmp,q;
void f(int a){
	if(a==in.size()){
		int sum=out;
		rep(i,in.size()){
			int t=q[q.size()-1-i]*in[i];
			if(t>9)t=t/10+t%10;
			sum+=t;
		}
		if(sum%10==0)co++;
		return;
	}
	rep(i,tmp.size()){
		in[a]=tmp[i];
		f(a+1);
	}
}
int main(){
	int n,m;
	cin>>n;
	string s;
	cin>>s;
	cin>>m;
	tmp=vi(m);
	rep(i,m)cin>>tmp[i];
	
	reverse(all(s));
	rep(i,n)if(isdigit(s[i])){
		int t=s[i]-'0';
		if(i%2)t*=2;
		if(t>9)t=t/10+t%10;
		out+=t;
	}else{
		in.pb(0);
		q.pb(i%2?2:1);
	}
	f(0);
	cout<<co<<endl;
}

Measured memory_bytes: 1364
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000
using namespace std;
typedef long long ll;

int n, m;
int ans = 0;
vector<bool> visited(8, false);
vector<vector<bool>> vec(8, vector<bool>(8, false));
void dfs(int p){
  bool all_visited = true;
  rep(i, 0, n){
    if(!visited[i]){
      all_visited = false;
    }
  }
  if(all_visited){
    ans++;
    return;
  }

  rep(i, 0, n){
    if(!vec[p][i] || visited[i])  continue;
    visited[i]=true;
    dfs(i);
    visited[i]=false;
  }
  return ;
}

int main(){
  cin >> n >> m;
  vector<int> a(m), b(m);
  rep(i, 0, m){
    cin >> a[i] >> b[i];
    a[i]--;  b[i]--;
    vec[a[i]][b[i]] = true;
    vec[b[i]][a[i]] = true;
  }

  rep(i, 0, n)  visited[i] = false;
  visited[0]=true;
  dfs(0);

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int a,b,x,res,m,n;
    cin>>a>>b;
    x=__gcd(a,b);
    m=a/x;
    n=b/x;
     res=a*n;
     cout<<res<<endl;
     return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <map>
#include <vector>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <iostream>

#define ll long long

using namespace std;

int
main() {

  ll n;
  cin>>n;

  ll dp[60][2] = {0};
  ll index, v;
  for (int i=0; i<n; i++) {
    cin>>v;

    index = 0;
    while (index < 60) {
      dp[index][v%2]++;
      index++;
      v /= 2;
    }
  }

  ll ans = 0;
  ll mod = 1e9 + 7;
  for (int i=0; i<60; i++) {
    ll temp = 1ll<<i;
    temp %= mod;
    temp *= dp[i][0];
    temp %= mod;
    temp *= dp[i][1];
    temp %= mod;

    ans += temp;
    ans %= mod;
  }
 
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char a[110][20];
int main()
{

    int n;
    int flag=1;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf(" %s",a[i]);
        if(i>0&&a[i][0]!=a[i-1][strlen(a[i-1])-1])
            flag=0;
        for(int j=0;j<i;j++)
            if(strcmp(a[i],a[j])==0)
                flag=0;
    }
    puts(flag?"Yes":"No");
    return 0;
}


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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;


int main() {

    int a, b, c;

    cin >> a >> b >> c;

    if (a <= c && c <= b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


}



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

int main(){
  int i;
  int N ;
  cin >> N;
  vector<int> V(N),C(N);
  int ans = 0;
  for(i=0;i<N;i++){
    cin >> V[i];
  }
  for(i=0;i<N;i++){
    cin >> C[i];
    if(C[i] < V[i]) ans += V[i]-C[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol i[10000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d,e=0,f=0;
  vector<string> s;
  string w;
  vector<int> p;
  bool ans=true;
  cin >>a>>b;
  cin >>w;
  int now=w.size()-1;
  while(1){
      int u=-1;
      for(int m=now-1;m>=now-b;m--){
	  if(m==0){
	      u=now;
	      break;
	  }
	  if(w[m]=='0') u=now-m;
      }
      if(u==-1){
	  ans=false;
	  break;
      }
      p.push_back(u);
      now-=u;
      if(now==0) break;
      
  }
  if(ans){
      cout <<p[p.size()-1];
      for(int n=p.size()-2;n>=0;n--) cout <<' '<<p[n];
      cout <<'\n';
  }
  else cout <<"-1\n";
  return (0);
}


Measured memory_bytes: 1096
function Main(arg) {
    let n = BigInt(arg.trim());
    let result = '';
    while(n > 26) {

      let surplus = n % 26n;
      if (surplus == 0){
        result = 'z' + result;
        n = n-1n;
      } else {
        result = String.fromCharCode(Number(surplus) + 96)  + result;
      }
      n = n / 26n;
    }
    if(n != 0) {
      result = String.fromCharCode(Number(n) + 96)  + result;
    } else {
      result = 'z' + result;
    }
    console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define watch(x) cout << (#x) << " = " << x << endl;
#define mkp make_pair
#define mkt make_tuple
#define pb push_back
#define ll long long
#define ld long double

using namespace std;

ll BIT[200010], dp[200010], a[200010];
int n, h[200010];

ll bit(int x){
	if(x == 0) return 0;

	ll t = -1e18;
	for(int i = x; i > 0; i -= (i & (-i))) t = max(t, BIT[i]);

	return t;
}

void upd(int x, ll val){
	for(int i = x; i <= n; i += (i & (-i))) BIT[i] = max(BIT[i], val);
}

int main(){
	scanf("%d", &n);

	for(int i = 1; i <= n; i++) scanf("%d", &h[i]);
	for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);

	for(int i = 1; i <= n; i++){
		dp[i] = bit(h[i] - 1) + a[i];
		upd(h[i], dp[i]);
	}

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

	return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>
int main()
{
    int A,B,C,D,ans=0;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    if(A<=B)
        ans=ans+A;
    else
        ans=ans+B;
    if(C<=D)
        ans=ans+C;
    else
        ans=ans+D;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>

using namespace std;

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

const ll INF = 1e15;
const ll MOD = 1e9 + 7;


int main(){
	string S;
	cin >> S;
	ll L = S.length();
	for (int i = 0; i < L - 8; i++){
		cout << S[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	
	if(a==b&&b==c&&c==a){
		printf("1\n");
	}else if(a==b||b==c||c==a){
		printf("2\n");
	}else{
		printf("3\n");
	}
	return 0;
}
	

Measured memory_bytes: 128
N, M, X, Y = map(int, input().split())

x = [i for i in map(int, input().split())]
x.sort()

y = [i for i in map(int, input().split())]
y.sort()

if X in x:
    print("War")
elif Y in y:
    print("War")
else:
    x.append(X)
    y.append(Y)
    if len(x) != len(set(x)):
        print("War")
    elif len(y) != len(set(y)):
        print("War")
    elif max(x) >= min(y):
        print("War")
    elif X >= Y:
        print("War")
    else:
        print("No War")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    int p, q, r;
    cin >> p >> q >> r;
    int sm = p + q + r;
    sm = sm - max(p, max(q, r));
    cout << sm << endl;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
ll a[100500];
ll sum;
int main() {
    //cout.precision(10);
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> a[i];
        sum += a[i];
    }
    bool FIRST_WIN = true;
    while(true) {
        if(sum % 2 != N % 2) break;
        FIRST_WIN = !FIRST_WIN;
        int index = -1;
        for(int i = 1; i <= N; i++) {
            if(a[i] % 2 == 1) {
                if(index != -1) goto outer;
                index = i;
            }
        }
        a[index]--;
        if(a[index] == 0) break;
        ll GCD = a[1];
        for(int i = 2; i <= N; i++) {
            GCD = __gcd(GCD, a[i]);
        }
        for(int i = 1; i <= N; i++) {
            a[i] = a[i] / GCD;
        }
        sum = (sum - 1) / GCD;
    }
    outer:
    if(FIRST_WIN) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
 
int N, M;
int A[100005], B[100005];
vector<int> G[100005];
bool bi;
int color[1000005];

void solve(int v){
  if(!bi) return;
  rep(i,G[v].size()){
    if(color[G[v][i]] == 0){
      color[G[v][i]] = (color[v]==1)?2:1;
      solve(G[v][i]);
    }else{
      if(color[G[v][i]] == color[v]){
        bi = false;
        break;
      }
    }
  }
}

int main(){
  cin >> N >> M;
  rep(i,M){
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
    G[A[i]].push_back(B[i]);
    G[B[i]].push_back(A[i]);
  }

  bi = true;
  color[0] = 1;
  solve(0);

  if(bi){
    ll a = 0;
    ll b = 0;
    rep(i,N){
      if(color[i] == 1) a++;
      else b++;
    }

    cout << (a*b) - M << endl;
  }else{
    cout << (N*(ll)(N-1)/2) - M << endl;
  }
  
  return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c;
    std::deque<int> deq;
    cin>>a>>b>>c;
    deq.emplace_back(a);
    deq.emplace_back(b);
    deq.emplace_back(c);
    sort(deq.begin(),deq.end());
    int sum=0;
    sum+=abs(deq[1]-deq[0])+abs(deq[2]-deq[1]);
    cout<<sum<<endl;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
ary_num = gets.chomp.split.map(&:to_i)

class Array
  def uniq?
    uniq_check = {}
    each do |v|
      return false if uniq_check.key? v
      uniq_check[v] = true
    end
    return true
  end
end

if ary_num.uniq?
  puts 'YES'
else
  puts 'NO'
end

Measured memory_bytes: 30852
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); i++)
#define loops(i,f,n) for(int i = (f); i < (n); i++)
#define INF 9999999

int main()
{
	int n, a;
	cin >> n >> a;
	n %= 500;
	if (n <= a)cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

int main() {
    int n,k; cin >> n >> k;
    int x[n];
    for(int i = 0; i < n; i ++) cin >> x[i];
    int cost = 0;
    for(int i = 0; i < n; i++) {
        cost += min(abs(x[i]-k), abs(x[i]-0)) * 2;
    }
    cout << cost << endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def main():
    N = int(input())
    S = input()
    sub_sum = {key : [0]*N for key in "RGB"}
    
    for i, key in enumerate(S):
        sub_sum[key][i] = 1
    
    for i in range(1, N):
        for key in "RGB":
            sub_sum[key][i] += sub_sum[key][i-1]

    ans = 0
    for i in range(1, N):
        now = S[i]
        right_nums = {key:sub_sum[key][N-1]-sub_sum[key][i-1] for key in "RGB"}
        for j in range(i):
            left = S[j]
            right = [c for c in "RGB" if  c not in [now, left]][0]
            right_num = right_nums[right]
            if now != left:
                if 2*i - j < N and right_num:
                    if S[2*i - j] == right:
                        right_num -= 1
                ans += right_num
    print(ans)




if __name__ == "__main__":
    main()

Measured memory_bytes: 70032
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n,y;
  cin >> n >> y;
  int flag=0;
  for(int a=0;a<=2000;a++){
    for(int b=0;b<=2000;b++){
      int c = n - a - b;
      if(c >=0 ){
        if(flag ==0){
        if(10000*a + 5000*b+1000*c == y){
          cout << a <<" "<<b <<" " <<c <<endl;
          flag = 1;
        }
        }
      }
    }
  }
  if(flag==0)cout<<-1<<" "<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 3612
from math import factorial

n, m = map(int, input().split())

mod = 10**9+7
if abs(n - m) == 0:
    print((factorial(n) * factorial(m) * 2) % mod)
elif abs(n - m) == 1:
    print((factorial(n) * factorial(m)) % mod)
else:
    print(0)


Measured memory_bytes: 5180
#include <iostream>
#include <deque>
#include <vector>
#include <numeric>
#include <limits.h>
#include <algorithm>
using namespace std;

typedef vector<int> vi;
typedef vector<pair<int, int> > vii;

int main() {
	int n, m, num;
	cin >> n;
	m = n;
	num = 0;
	while (m) {
		num += (m%10);
		m /= 10;
	}
	if (n % num == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
;; 写経
(defun placing-marbles (s)
  (let ((counter 0))
    (loop :for c :across s
	  :do (if (string= c "1") (incf counter)))
    counter))

(defun placing-marbles2 (s)
  (loop :for c :across s
	:count (char= c #\1)))


(format t "~a~%" (placing-marbles2 (read-line)))


Measured memory_bytes: 13668
/*
 * atcoder/abc129/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
#define MOD 1000000007
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%MOD+MOD)%MOD){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%MOD+MOD)%MOD; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=MOD) x-=MOD; return *this;}
  mint& operator-=(const mint& a){ if((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=MOD; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
ostream & operator << (ostream & out, mint const & v) {
  out << v.x;
  return out;
}

int N, M;
vector<bool> A(100001, true);

mint dp[100100];

void solve() {
  cin >> N >> M;
  int a;
  loop(m,0,M) {
    cin >> a;
    A[a] = false;
  }


  dp[0] = 1;
  for (int n=0; n<N; n++) {
    if (A[n+1]) dp[n+1] += dp[n];
    if (A[n+2]) dp[n+2] += dp[n];
  }

  cout << dp[N] << endl;
}
int main() {
  // cout.precision(15);

  solve();

  return 0;
}


Measured memory_bytes: 1024
def main():
    d = int(input())
    c = [int(v) for v in input().split()]
    last = [-1] * 26
    s = []
    for _ in range(d):
        s.append([int(v) for v in input().split()])

    td = 0
    for i in range(d):
        td0 = td
        dmax = -99999999
        tmax = 0
        for test in range(26):
            diff = s[i][test]
            for j in range(26):
                if j != i:
                    diff -= c[j]*(i-last[j])
            if diff>dmax:
                dmax = diff
                tmax = test
        print(tmax+1)

main()

Measured memory_bytes: 9620
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int n,m;
V z;

main(){
	int i,j,a,b,c,t;
	for(;scanf("%d%d%d%d%d%d",&n,&m,&a,&b,&c,&t),n;){
		V x(n*n);
		V e(n*n);
		z.resize(n*n);

		x[0]=b;
		x[1]=c;
		e[0]=1;
		for(i=1;i<n-1;i++){
			x[i*n+i-1]=a;
			x[i*n+i]=b;
			x[i*n+i+1]=c;
			e[i*n+i]=1;
		}
		x[i*n+i-1]=a;
		x[i*n+i]=b;
		e[i*n+i]=1;
		for(;t;t>>=1){
			if(t&1){
				for(i=0;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=((const V&)e[slice(i*n,n,1)]*(const V&)x[slice(j,n,n)]).sum()%m;
				e=z;
			}
			for(i=0;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=((const V&)x[slice(i*n,n,1)]*(const V&)x[slice(j,n,n)]).sum()%m;
			x=z;
		}
		V s(n);
		for(i=0;i<n;i++)scanf("%d",&s[i]);
		for(i=0;i<n-1;i++)printf("%d ",((const V&)e[slice(i*n,n,1)]*s).sum()%m);
		printf("%d\n",((const V&)e[slice(i*n,n,1)]*s).sum()%m);
	}
}

Measured memory_bytes: 1088
#include "math.h"
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
const lli MOD = 1000000007;

string s, t;
int ss, ts;
/*
    O(S + T + q)
    AB -> BBB -> ""
    BA -> AAA -> ""
    BB -> AAAA -> A
    AA -> BBBB -> B
    ABB -> B or BBA
    BA -> BBB -> AB irekaehaok
    ABB -> BBA
    BBBAAAA -> BBB
 */
int cnt[2][100004] = {};
bool solve(int a, int b, int c, int d)
{
    // itiban migi ga issyodattabaai ha
    int SA = cnt[0][b] - cnt[0][a - 1];
    int SB = b - a + 1 - SA;

    int TA = cnt[1][d] - cnt[1][c - 1];
    int TB = d - c + 1 - TA;

    // can ? SA==TA ,SB==TB
    //ope1 : SA -=1 ,SB +=2  alpha
    //ope2 : SA +=2  SB -=1  alpha'
    //ope2 : SA -=3  beta
    //ope3 : SB -=3  gamma
    int alpha = (TA - SA + 600000) % 3;
    int beta = (TB - SB + 600000) % 3;

    //cout << alpha << " " << beta << endl;
    return alpha == beta;
}
int main()
{
    int q;
    cin >> s >> t >> q;
    int a, b, c, d;
    ss = s.size(), ts = t.size();
    rep(i, ss)
    {
        cnt[0][i + 1] = cnt[0][i] + (s[i] == 'A');
    }
    rep(i, ts)
    {
        cnt[1][i + 1] = cnt[1][i] + (t[i] == 'A');
    }
    rep(i, q)
    {
        cin >> a >> b >> c >> d;
        std::cout << (solve(a, b, c, d) ? "YES" : "NO") << endl;
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
    ios_base::sync_with_stdio(0); cin.tie(0); 
    freopen((s+".in").c_str(),"r",stdin);
    freopen((s+".out").c_str(),"w",stdout);
}
int main()
{
  //flash;
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String... args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        Map<String, Integer> NMap = new HashMap<>();
        for (int i = 0; i < N; i++) {
            String name = sc.next();
            if(NMap.containsKey(name)) {
                NMap.put(name, NMap.get(name) + 1);
            } else {
                NMap.put(name, 1);
            }
        }

        int M = sc.nextInt();
        Map<String, Integer> MMap = new HashMap<>();
        for (int i = 0; i < M; i++) {
            String name = sc.next();
            if(MMap.containsKey(name)) {
                MMap.put(name, MMap.get(name) - 1);
            } else {
                MMap.put(name, -1);
            }
        }

        Map<String, Integer> RMap = new HashMap<>();
        NMap.keySet().stream().forEach(key -> {
            RMap.put(key, NMap.get(key));
        });
        MMap.keySet().stream().forEach(key -> {
            if(RMap.containsKey(key)) {
                RMap.put(key, RMap.get(key) + MMap.get(key));
            } else {
                RMap.put(key, MMap.get(key));
            }
        });
        int max = 0;
        for (String key : RMap.keySet()) {
            max = Math.max(max, RMap.get(key));
        }
        System.out.println(max);




    }

}


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

const int sz=1e6+10;

void solve()
{
    ll n,x,t,rem,ans=0;
    cin>>n>>x>>t;
    if(n%x==0) ans=n/x;
    else ans=n/x +1;

    cout<<ans*t<<endl;
}

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

    int t=1;
    //cin>>t;

    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3652
n,m,x=[int(i) for i in input().split()]
c=[]
a=[]
for i in range(n):
    _=[int(j) for j in input().split()]
    c.append(_[0])
    a.append(_[1:])

def f(cost,rikai,index):
    if all([x<=i for i in rikai]):
        return cost
    elif n<=index:
        return -1
    v1=f(cost,rikai,index+1)
    v2=f(cost+c[index],[rikai[i] + a[index][i] for i in range(len(rikai))],index+1)
    if v1!=-1 and v2!=-1:
        cost=min(v1,v2)
    elif v1!=-1:
        cost=v1
    elif v2!=-1:
        cost=v2
    else:
        cost=-1
    return cost

print(f(0,[0 for i in range(m)],0))


Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
const int N = 100030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const int mod =    1e9+7;
ll n;
ll a[3010];
ll dp[3030][3030][2];
ll fn(ll s,ll l,ll x)
{
	ll y=0;
	if(dp[s][l][x])
	return dp[s][l][x];
	if(s==l)
	{
		
		if(s>=1&&s<=n){

	  if(!x){

	  dp[s][s][0]=a[s];
	return a[s];}
	else  {
	dp[s][s][1]=-a[s];return -a[s];}}
	else
	return 0;
}
 if(!x)
	 y=max(a[s]+fn(s+1,l,1^x),a[l]+fn(s,l-1,1^x));
 else
 y=min(fn(s+1,l,1^x)-a[s],fn(s,l-1,1^x)-a[l]);
	dp[s][l][x]=y;
//	cout<<s<<" "<<l<<" "<<x<<" "<<y<<endl;
	return y;
}
int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n;
rep(i,1,n+1)
cin>>a[i];
memset(dp,0,sizeof(dp));
fn(1,n,0);
cout<<dp[1][n][0];
}

Measured memory_bytes: 143872
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	long long a, b, c; cin >> a >> b >> c;
	long long num = a;
	for (int i = 0; i < a; i++){
		long long n; cin >> n;
		if (b <= n&&n < c)num--;
	}
	cout << num << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl;
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl;
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl;
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl;
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl;
#define pb push_back
#define pf push_front
#define oo (ll)1e18
#define inf (int)1e10
#define ll long long 
#define ld long double
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
typedef tuple<ll,ll,ll> tl3;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string lts(ll x) {stringstream s; s << x; return s.str(); }
ll stl(string x) {stringstream s(x); ll temp; s >> temp; return temp; }
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
const int MAXN = 100005;
template <typename T> void maxself(T& a, T b) {
    a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
    a = min(a, b);
}

//#define cerr if(0)cout

vector <int> adjlist[MAXN];
int dist[MAXN];
bool visited[MAXN];
vector <int> preorder;
void dfs(int x) {
	visited[x] = 1;
	for (auto i : adjlist[x]) {
		if (!visited[i]) dfs(i);
	}
	preorder.pb(x);
	
}

int main() {
    IAMSPEED
    int n,e; cin >> n >> e;
    FOR(i,1,e) {
		int a,b; cin >> a >> b;
		adjlist[a].pb(b);
	}
	FOR(i,1,n) {
		if (!visited[i]) dfs(i);
	}
	reverse(all(preorder));
	int ans = 0;
	for (auto x : preorder) {
		for (auto it : adjlist[x]) {
			maxself(dist[it], dist[x] + 1);
			maxself(ans, dist[it]);
		}
	}
	cout << ans;
}


Measured memory_bytes: 8824
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll K;
ll n;
ll N[101];
ll ans;
ll M;
ll dp[101][101];
ll cnt;
ll cntt;
ll A,B,C,D;
map<int, const char*>m;
map<int, const char*>::iterator ite;
vector<string> S;
 
 
 
int main(){
    cin >>n;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        S.push_back(s);
    }
    cnt = 1;
    sort(S.begin(),S.end());
    for(int i=1;i<n;i++){
        if(S[i]!=S[i-1]){
            cnt++;
        }
        
    }
    cout << cnt << endl;
    
}
 
 


Measured memory_bytes: 11600
#include<stdio.h>
#include<math.h>
#include<string.h>
int main ()
{
	int i,j,k;
	char a[4];
	k=0;
	for(i=0;i<3;i++)
		scanf("%c",&a[i]);
	for(i=0;i<3;i++)
		for(j=i+1;j<3;j++)
		{
			if(a[i]==a[j])
			{
				k++;	
			}	
		}
	if(k!=0)
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

ll P = 1000000007;
int main(int argc, char const *argv[]) {
  ll n, m;std::cin >> n >> m;
  vll a(n), A(n), b(m), B(m);
  re(i, n) std::cin >> a[i];
  re(i, m) std::cin >> b[i];
  ll XS = 0, YS = 0;
  re(i, n) A[i] = ((i==0?0:A[i-1]) + a[i])%P;
  re(i, m) B[i] = ((i==0?0:B[i-1]) + b[i])%P;

  ll z = P*10000000;

  re(i, n-1){
    ll tmp = (A[n-1] - A[i] + P)%P;
    ll nokori = n-1-i;
    tmp = (tmp - (nokori*a[i])%P + z)%P;
    XS = (XS + tmp)%P;
  }
  re(i, m-1){
    ll tmp = (B[m-1] - B[i] + P)%P;
    ll nokori = m-1-i;
    tmp = (tmp - (nokori*b[i])%P + z)%P;
    YS = (YS + tmp)%P;
  }
  std::cout << (XS*YS)%P << '\n';
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int cnt=0;
    cnt=h2*60+m2-(h1*60+m1);
    cout<<cnt-k<<endl;
}


Measured memory_bytes: 3624
def s(i, dp, st)
  w = st
  while w<=i
    dp[i] = [dp[i], dp[i-w]+1].min
    w *= st
  end
end

n=gets.to_i
dp = []
(n+1).times do |i|
  dp[i] = i
  s(i, dp, 6)
  s(i, dp, 9)
end
puts dp[n]


Measured memory_bytes: 2684
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(void)
{
    int N[2], K;
    cin >> N[0] >> N[1] >> K;
    for (int i = 0; i < K; i++)
    {
        auto S = i % 2;
        auto O = (i + 1) % 2;
        N[S] /= 2;
        N[O] += N[S];
    }
    cout << N[0] << " " << N[1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int n;
int main(int argc,char const* argv[])
{
  string s;
  int year,month,day;
  cin >> s;
  int slash=0;
  if(s=="2019/04/30")
    {
      cout << "Heisei" << endl;
      return 0;
    }
  string tmp="";
  for(int i=0;i<int(s.size());i++)
    {
      if(s[i]=='/')
	{
	  if(slash==0)
	    {
	      year=stoi(tmp);
	    }
	  else if(slash==1)
	    {
	      month=stoi(tmp);
	    }
	  slash++;
	  tmp="";
	  continue;
	}
      else
	{
	  tmp+=s[i];
	} 
    }
  day=stoi(tmp);
  if(year<2019 || (year==2019 && month<4) || (year==2019 && month==4 && day<30))
    {
      cout << "Heisei" << endl;
    }
  else
    {
      cout << "TBD" << endl;
    }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
bool used[100001];
int main(){
	int n,t=0;
	cin>>n;
	int a[n];
	r(i,n)cin>>a[i];
	used[a[0]-1]=1;t++;
	int p=a[0]-1;
	if(p==1){
		cout<<1<<endl;
		return 0;
	}
	while(1){
		if(used[a[p]-1])break;
		p=a[p]-1;
		used[p]=1;
		t++;
		if(p==1){
			cout<<t<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
}

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

int main() {
    int N;
    cin >> N;
    bool p = true, w = true, g = true, y = true;
    int ans = 0;

    for (int i = 0; i < N; i++) {
        string op;
        cin >> op;
        if ((op == "P" && p == true)) {
            ans++;
            p = false;
        }
        if ((op == "W" && w == true)) {
            ans++;
            w = false;
        }
        if ((op == "G" && g == true)) {
            ans++;
            g = false;
        }
        if ((op == "Y" && y == true)) {
            ans++;
            y = false;
        }
    }

    if (ans == 3)
        cout << "Three"<<endl;
    if (ans == 4)
        cout << "Four"<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = input().rstrip()
    if n == "#":
        return False
    lis = [LS() for i in range(4)]
    num = ["2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K", "A"]
    ans = [0] * 4
    master = 0
    for i in range(13):
        north, east, south, west = lis[0][i], lis[1][i], lis[2][i], lis[3][i]
        suit = [north[1], east[1], south[1], west[1]]
        tmp = [num.index(lis[master][i][0]), master]
        if n in suit:
            tmp = [-1, -1]
            for k in range(4):
                if suit[k] == n:
                    if tmp[0] < num.index(lis[k][i][0]):
                        tmp = [num.index(lis[k][i][0]), k]
        else:
            for k in range(4):
                if suit[tmp[1]] == suit[k] and tmp[0] < num.index(lis[k][i][0]):
                    tmp = [num.index(lis[k][i][0]), k]
        ans[tmp[1]] += 1
        master = tmp[1]
    a = ans[0] + ans[2] - 6
    b = ans[1] + ans[3] - 6
    if a > b:
        print("NS {}".format(a))
    else:
        print("EW {}".format(b))
    return True


#main
if __name__ == '__main__':
    while solve():
        pass



Measured memory_bytes: 8256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int MOD = 1e+7;

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

  int n;
  cin >> n;
  vector<int> board(n);
  rep(i,n) cin >> board[i];

  bool flag = true;
  int res = 0;
  while(true) {
    rep(i,n) {
      if(board[i] % 2 != 0) flag = false;
      board[i] /= 2;
    }
    if(!flag) {
      cout << res << endl;
      return 0;
    }
    res++;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define ALL(c) (c).begin(),(c).end()
typedef long long ll;
ll ans1[3000000],ans2[3000000],tmp[3000000],ans[1000];
int main(){
	ll x,y,z,a,b,c,n;
	cin >> x >> y >> z >> a >> b >> c >> n;
	tmp[0]=1;
	ans1[0]=1;
	ans2[0]=1;
	rep(i,a) tmp[i+1]++;
	rep(i,x-1-a) tmp[i+1]++;
//	for(int i=0;tmp[i]!=0;i++) cout << tmp[i] << " ";
//	cout << endl;
	for(int i=0;i+1<3000000;i++){
		ans1[i+1]=ans1[i]+tmp[i+1];
		if(0<b && b<=i && tmp[i-b]==0) break;
		if(b<=i) ans1[i+1]-=tmp[i-b];
	}
//	for(int i=0;ans1[i]!=0;i++) cout << ans1[i] << " ";
//	cout << endl;
	for(int i=0;i+1<3000000;i++){
		ans2[i+1]=ans2[i]+tmp[i+1];
		if(0<y-1-b && y-1-b<=i && tmp[i-(y-1-b)]==0) break;
		if(y-1-b<=i) ans2[i+1]-=tmp[i-(y-1-b)];
	}
//	for(int i=0;ans2[i]!=0;i++) cout << ans2[i] << " ";
//	cout << endl;
	rep(i,3000000) tmp[i]=ans1[i]+ans2[i]-tmp[i];
//	for(int i=0;tmp[i]>0;i++) cout << tmp[i] << " ";
	for(int i=0;i+1<3000000;i++){
		ans1[i+1]=ans1[i]+tmp[i+1];
		if(0<c && c<=i && tmp[i-c]==0) break;
		if(c<=i) ans1[i+1]-=tmp[i-c];
	}
//	for(int i=0;ans1[i]!=0;i++) cout << ans1[i] << " ";
//	cout << endl;
	for(int i=0;i+1<3000000;i++){
		ans2[i+1]=ans2[i]+tmp[i+1];
		if(0<z-1-c && z-1-c<=i && tmp[i-(z-1-c)]==0) break;
		if(z-1-c<=i) ans2[i+1]-=tmp[i-(z-1-c)];
	}
	rep(i,3000000) ans[i%n]+=(ans1[i]+ans2[i]-tmp[i]);
	rep(i,n-1) cout << ans[i] << " ";
	cout << ans[n-1] << endl;
	return 0;
}

Measured memory_bytes: 73428
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"sort"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	var N, M int
	fmt.Sscanf(scanner.Text(), "%d %d", &N, &M)

	ps := make([]int, M)
	ys := make([]int, M)
	for i := 0; i < M; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d %d", &ps[i], &ys[i])
	}

	var p2years = make(map[int][]int)
	for i := 0; i < M; i++ {
		p2years[ps[i]] = append(p2years[ps[i]], ys[i])
	}

	var orders = make(map[int]map[int]int)
	for p, years := range p2years {
		sort.Sort(sort.IntSlice(years))

		indexes := make(map[int]int)
		for i, year := range years {
			indexes[year] = i
		}
		orders[p] = indexes
	}

	var buffer bytes.Buffer
	for i := 0; i < M; i++ {
		buffer.WriteString(fmt.Sprintf("%06d", ps[i]))
		index := orders[ps[i]][ys[i]]
		buffer.WriteString(fmt.Sprintf("%06d\n", index+1))
	}
	fmt.Print(buffer.String())
}

func indexOf(slice []int, value int) int {
	for i := 0; i < len(slice); i++ {
		if slice[i] == value {
			return i
		}
	}
	return -1
}


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

int main(){
	int n;
	cin >> n;
	map<string, int> cnt;
	rep(i,n){
		string s;
		cin >> s;
		cnt[s]++;
	}
	for(string x : {"AC","WA","TLE","RE"}){
		cout << x << " x " << cnt[x] << endl;
	} 
}

Measured memory_bytes: 3640
//NAME-DEEPESH BHATT
//Institute-IIT Dhanbad
//MOTTO-THINK FIRST,CODE LATER

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007  ;
#define pb push_back
#define mp make_pair

//Check for signed int overflow

ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a ,ll b)
{
    return a/gcd(a,b)*b;
}
ll power(ll a,ll n)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2);
    p = (p * p);
    if (n % 2)
        return (p * a);
    else
        return p;
}
/*vector<bool>is_prime(1000001,true);
void sieve(){
    is_prime[0]=is_prime[1]=false;
    is_prime[2]=true;
    for(int i=2;i*i<=1000000;i++){
        if(is_prime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                is_prime[j]=false;
            }
        }
    }
}*/

/*bool is_sorted(int *arr,int n){
    for(int i=0;i<n-1;i++){
        if(arr[i+1]<arr[i]){
            return false;
        }
    }
    return true;
}*/

void solve(){
    ll n;
    cin>>n;
    vector<ll>v(n);
    ll mx=0;
    vector<ll>count(1000001,0);
    for(ll i=0;i<n;i++){
        cin>>v[i];
        count[v[i]]++;
        mx=max(mx,v[i]);
    }
    vector<ll>b(mx+1,0);
    for(ll i=0;i<n;i++){
        ll j;
        if(count[v[i]]==1)
            j=2*v[i];
        else
            j=v[i];
        for(j;j<=mx;j+=v[i]){
            b[j]=1;
        }
    }
    ll c=0;
    for(ll i=0;i<n;i++){
        if(!b[v[i]]){
            c++;
        }
    }
    cout<<c;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);    //for fast I/O operation
    cin.tie(NULL);
    ll test=1;
    /*cin>>test;*/
    while(test--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 20356