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

int main() {
  int N;
  cin >> N;
  
  if (N >= 1 && N <= 200) {

  	int check = 0;
  	int count = 0;

  	int A[N] = {};

  	while (check == 0) {
  		for (int i = 0; i < N; i++) {
			cin >> A[i];

			if (A[i] >= 1 && A[i] <= std::pow(10,9)) {
				if (A[i] % 2 != 0) {
					check = 1;
				}
			} else {
				check = 1;
			}
			
  		}

  		if (check == 0) {
			count++;
			for (int j = 0; j < N; j++) {
				A[j] = A[j] / 2;
			}
  		}
  	}
  	cout << count << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		boolean jud[] = new boolean[1000000];
		jud[0] = false;
		jud[1] = false;
		int cnt = 0;
		int prim[] = new int[1000000];
		
		for(int i= 2;i<1000000;i++){
			jud[i] = true;
		}
		
		for(int i = 2;i<1000000;i++){
			for(int j = i*2;j<1000000;j+=i){
				jud[j] = false;
			}
			if(jud[i]) cnt++;
			prim[i] = cnt;
		}
		
		String s = "";
		while((s = br.readLine()) != null){
			int input = Integer.parseInt(s);
			System.out.println(prim[input]);
		}
	}
}

Measured memory_bytes: 29684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll n;
    cin >> n;
    // 離散集合における\sum f(L,R)
    ll ret = 0;
    for(ll i=0;i<n;++i){
        ret += (i+1)*(n-i);
    }
    for(int i=0;i<(n-1);++i){
        int u, v;
        cin >> u >> v;
        if (u>v){
            int tmp=v;
            v=u;
            u=tmp;
        }
        ret -= u*(n-v+1);
    }
    cout << ret;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct edge{
    int l,r;
    ll c;
    bool operator<(const edge&x){
        return l==x.l?r<x.r:l<x.l;
    }
};

template<class T, class E=T> struct LST{
    int n;T et; E ee;
    T f(T x,T y){return min(x,y);}
    T g(T x,T y){return min(x,y);}
    T h(T x,T y){return min(x,y);}
    T p(T x,int){return x;}
    int cur;
    vector<T> data;
    vector<E> lazy;
    vector<int> idx,len;

    LST(int n_,T et,E ee):n(1),et(et),ee(ee){
        while(n<n_) n<<=1;
        data.resize(n<<1, et);
        lazy.resize(n<<1, ee);
        idx.resize(128, -1);
        len.resize(n<<1, 1);
        for(int i=n-1;i;--i) len[i]=len[i<<1]<<1;
    }

    void build(vector<T>&v){
        for(int i=0;i<v.size();++i) data[i^n]=v[i];
        for(int i=n-1;i;--i) data[i]=f(data[i<<1],data[(i<<1)^1]);
    }

    inline void getidx(int a,int b){
        cur=0;
        if(a==n&&b==(n<<1)) return;
        while(1^a&1) a>>=1;
        while(1^b&1) b>>=1;
        a>>=1;
        b>>=1;
        while(a>1||b>1){
            if(a>=b){
                idx[cur++]=a;
                a>>=1;
            }
            else{
                idx[cur++]=b;
                b>>=1;
            }
        }
        idx[cur++]=1;
    }

    inline void eval(){
        int i;
        for(int k=cur-1;k>=0;--k){
            i=idx[k];
            if(lazy[i]==ee) continue;
            lazy[i<<1] = h(lazy[i<<1], lazy[i]);
            data[i<<1] = g(data[i<<1], p(lazy[i<<1], len[i<<1]));
            lazy[(i<<1)^1] = h(lazy[(i<<1)^1], lazy[i]);
            data[(i<<1)^1] = g(data[(i<<1)^1], p(lazy[(i<<1)^1], len[(i<<1)^1]));
            lazy[i] = ee;
        }
    }

    void ud(int a,int b,const E x){
        a+=n;b+=n;
        getidx(a, b);
        eval();
        for(;a<b;a>>=1,b>>=1){
            if(a&1){
                lazy[a]=h(lazy[a],x);
                data[a]=g(data[a],p(lazy[a],len[a]));
                ++a;
            }
            if(b&1){
                --b;
                lazy[b]=h(lazy[b],x);
                data[b]=g(data[b],p(lazy[b],len[b]));
            }
        }
        int i;
        for(int k=0;k<cur;++k){
            i=idx[k];
            data[i]=f(data[i<<1],data[(i<<1)^1]);
        }
    }

    T gt(int a, int b){
        a+=n;b+=n;
        getidx(a,b);
        eval();
        T vl=et,vr=et;
        for(;a<b;a>>=1,b>>=1){
            if(a&1) vl=f(vl,data[a++]);
            if(b&1) vr=f(data[--b],vr);
        }
        return f(vl,vr);
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,m;
    in>>n>>m;
    vector<edge> e(m);
    for(auto&E:e) in>>E.l>>E.r>>E.c,--E.l;
    sort(e.begin(),e.end());
    LST<ll> lst(n,1ll<<60,1ll<<60);
    lst.ud(0,1,0);
    ll d;
    for(auto&E:e){
        d=lst.gt(E.l,E.l+1);
        lst.ud(E.l,E.r,d+E.c);
    }
    d=lst.gt(n-1,n);
    cout<<(d==(1ll<<60)?-1:d)<<endl;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 N;
  cin >> N;

  auto factorize = [&](i64 n) -> i64 {
    i64 num_factors = 1;
    for (i64 k = 2; k * k <= n; ++k) {
      if (n % k == 0) {
        int cnt = 0;
        do {
          n /= k;
          ++cnt;
        } while (n % k == 0);
        num_factors *= (cnt + 1);
      }
    }
    if (n > 1) {
      num_factors *= 2;
    }
    return num_factors;
  };

  auto reach = [&](i64 k) -> bool {
    i64 n = N;
    while (n % k == 0) {
      n /= k;
    }
    return n % k == 1;
  };

  i64 ans = factorize(N - 1) - 1;
  i64 n = N;
  for (i64 k = 2; k * k <= n; ++k) {
    if (n % k == 0) {
      if (reach(k)) {
        // cerr << ">> " << k << " reaches 1" << endl;
        ++ans;
      }
    }
  }
  cout << (ans + 1) << endl;
}

Measured memory_bytes: 3656
#include<stdio.h>

int search(int A[], int n, int key) {
    int i = 0;
    A[n] = key;
    while( A[i] != key) i++;
    return i != n;
}

int main() {
    int i, n, A[10000+1], q, key, sum = 0;
    
    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &A[i]);
    
    scanf("%d", &q);
    for (i = 0;i < q; i++) {
        scanf("%d", &key);
        if( search(A, n, key)) sum++;
    }
    printf("%d\n", sum);
    
    return 0;
}


Measured memory_bytes: 2108
s=input()
x=int(s[0:2])
y=int(s[2:])
a=0
b=0
if(x>=1 and x<=12):
  a=1
if(y>=1 and y<=12):
  b=1
if(a==0 and b==1):
  print("YYMM")
elif(a==1 and b==0):
  print("MMYY")
elif(a==1 and b==1):
  print("AMBIGUOUS")
elif(a==0 and b==0):
  print("NA")

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

typedef long long ll;
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0);
//#define cerr if(false)cerr
#define PRINT(x) cerr<<"\n" << (#x) << " is " << (x) << endl;
//Erase duplicates in vector
#define REMOVE_DUP(x) x.erase(unique(x.begin(), x.end()), x.end());
#define UP toupper // lowercase to uppercase;
#define DOWN tolower
#define SZ(a) (int)a.size()
#define EB emplace_back
#define PB push_back
#define REP(i, a, b) for(int i=a; i<b; i++)
#define PER(i, a, b) for(int i=a; i>=b; i--)
ostream_iterator<int> output(cout, " ");
#define MOD 1e9+7
#define INF INT_MAX;
#define lim_size 200007

void solve(){
	int x; cin >> x;
	ll ans = (x / 500) * 1000;
	x%=500;
	ans += (x/5)*5;
	cout << ans << endl;
}

int main(){
	FAST_IO;
	int t=1; //cin >> t;
	while(t--){
		solve();
		//solve1();
	}
}			


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;

int main()
{
    fastio;
    ll a=0,b=0;
    cin>>a>>b;
    if(a>10)
        cout<<b;
    else 
        cout<<b+100*(10-a);
    
}

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

int main() {
    int N; cin >> N;
    long long A[N];
    rep(i,N) cin >> A[i];
    long long sum = 0;
    rep(i,N) sum += A[i];
    for (long long i = sum-N*(N-1); ; i++) {
        sum = 0;
        rep(j,N) sum += (A[j]+i+1)/(N+1);
        if (sum <= i) {cout << i << endl; return 0;}
    }
}

Measured memory_bytes: 3592
#!/usr/bin/env python3
import itertools

N = int(input().split()[0])
l_list = list(map(int, input().split()))

p_gen = itertools.combinations(range(len(l_list)), 3)
tri_list = []
for pattern in p_gen:
    i, j, k = sorted(list(pattern))
    w_list = sorted([l_list[i], l_list[j], l_list[k]])
    if len(set(w_list)) == 3:
        if w_list[2] < w_list[0] + w_list[1]:
            tri_list.append((i, j, k))
ans = len(tri_list)
print(ans)


Measured memory_bytes: 20396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int n;
Graph G;
vector<int> ans;

void dfs(int v,int p,int c){
    ans[v] = c;
    for(auto e:G[v]){
        if(e.first == p) continue;
        if(e.second & 1) dfs(e.first,v,1-c);  // 重み奇数なら違う色で塗る
        else dfs(e.first,v,c);
    }
}

int main() {
    cin >> n;
    G.assign(n,vector<Edge>());
    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));
    }
    ans.resize(n);
    dfs(0,-1,1);
    for(auto v:ans) cout << v << endl;
    return 0;
}

Measured memory_bytes: 8960
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

int cnt[100010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int A[100010];
    rep(i, n) cin >> A[i];
    int ans = 1;
    rep(i, n) {
        if(A[i] == 0)
            ans *= 3 - cnt[A[i]];
        else 
            ans *= cnt[A[i] - 1] - cnt[A[i]];
        ans %= mod;
        cnt[A[i]]++;
        //cout << ans << endl;
    }
    cout << ans << endl;

    return 0;
}
// 0 1 0
// a a b
//

Measured memory_bytes: 1792
program sample
  implicit none
  integer :: n,i,j,count8
  integer,allocatable :: count(:)

  read(*,*) n
  allocate(count(n))

  count=0
  count8=0
  count(1)=1
  do i=2,n
     do j=1,i
        if(mod(i,j)==0)then
           count(i)=count(i)+1
        endif
     enddo
     if(count(i)==8.and.mod(i,2)==1)then
        count8=count8+1
     endif     
  enddo

  write(*,*) count8

  stop
  
end program sample

Measured memory_bytes: 2792
import sys
def line():return sys.stdin.readline().strip()

e=""
ans=0
while True:
    try:
        temp = line()
        if temp=="/":
            e+="//"
        elif temp=="*":
            e+="*"
        elif temp=="+":
            e+="+"
        elif temp=="-":
            e+="-"
        elif temp=="=":
            print(eval(e))
            break
        else:
            e+=temp
            ans=eval(e)
            e=str(ans)            
    except:
        break

Measured memory_bytes: 7420
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <numeric>
#include <utility>
#include <climits>
#include <float.h>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
constexpr ll INF = LLONG_MAX;
constexpr double DINF = DBL_MAX;
constexpr ll mod = 1e9+7;
constexpr double PI = M_PI;

template<typename T>
vector<T> make_v(size_t a){
	return vector<T>(a);
}
 
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts){
  	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

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

	string s, t;
	cin >> s >> t;
	s += t[s.size()];
	if(s == t){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <map>
#include <cmath>
#include <array>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <iostream>
#include <ctype.h>
#include <string>

typedef long long ll;
using namespace std;



int main(){
  string st;
  int a,b, h, m;
  cin>>a>>b;
  
  
  cout<<a*b<<endl;
}

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

int main(){
  int k, a, b;
  cin >> k >> a >> b;
  bool f = false;
  for(int i = a; i <= b; i++) {
    if(i % k == 0) f = true;
  }
  cout << (f ? "OK" : "NG") << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
      string a,b="";
      cin>>a;
      for(int i=0;i<a.size();i++)
      {
            if(i%2==0)
                  b=b+a[i];

      }
      cout<<b;
      return 0;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))

a_i = max(A)
a_j = a_i + 1

A.remove(a_i)
for a in A:
    if abs(a_j - a_i / 2) > abs(a - a_i / 2):
        a_j = a

print(a_i, a_j)


Measured memory_bytes: 14428
#include <cstdio>
#include <iostream>
using namespace std;
int a, b, c;

int main() {
    ios::sync_with_stdio(false);
    
    cin >> a >> b >> c;
    
    if (a == b && b== c)
        cout << 1 << endl;
    else if (a == b || b == c || a == c)
        cout << 2 << endl;
    else
        cout << 3 << endl;
    
    
    return 0;
}


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

int main() {
  int n, m, l;
  cin >> n >> m >> l;
  int a[n][m];
  std::memset(a, 0, sizeof a);
  int b[m][l];
  std::memset(b, 0, sizeof b);
  long long c[n][l];
  std::memset(c, 0, sizeof c);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }

  for (int i = 0; i < m; i++) {
    for (int j = 0; j < l; j++) {
      cin >> b[i][j];
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < l; j++) {
      for (int k = 0; k < m; k++) {
        c[i][j] += a[i][k] * b[k][j];
      }
      cout << c[i][j];
      if (j != l - 1) {
        cout << " ";
      }
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3252
#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

ll mod = 1e9+7;
  
// 検索タグ
int main() {
	// 入力
	ll N,X,Y;cin>>N>>X>>Y;
	X--;Y--;

	// 解法
	ll k[N-1];
	REP(i,N) k[i] = 0;
	REP(i,N){
		REP(j,N){
			if (i>=j) continue;
			ll i_X = abs(i - X);
			ll j_Y = abs(j - Y);
			ll dist = min(j - i, i_X + j_Y + 1);
			// printf("%lld-%lld, %lld\n", i, j, dist);
			k[dist-1]++;
		}
	}

	//出力
	REP(i,N-1){
		printf("%lld\n", k[i]);
	}
}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

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

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




Measured memory_bytes: 256
public class Main {
	public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int N = sc.nextInt();
		String S[] = sc.next().split("");
		String T[] = sc.next().split("");

		for (int i = 0; i < N; i++) {
			System.out.print(S[i] + T[i]);
		}


	}
}

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

/*
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <ctype.h>
*/


using namespace std;

typedef pair<int , int > pii;
typedef pair<long , long> pll;
typedef pair<pii , int > piii;
typedef pair<pll , long > plll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector <pii> vii;
typedef vector<pll> vll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef unsigned long long int ulli;
typedef long long int lli;
typedef double d;
typedef float f;
typedef string s;
typedef char ch;
typedef pair<int,ll> pill;

#define loop(n) for(int i = 0; i < (n); i++)
#define lp(x , s , e) for(int x = (s); x < (e); x++)
#define lpe(x , s , e) for(int x = (s); x <= (e); x++)
#define readline(s) getline(cin,s)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;
#define MP make_pair
#define PB push_back
#define all(a) a.begin(),a.end()
#define clr(x , val) memset((x) , (val) , sizeof(x))
#define endl '\n'

ll power(ll a, ll b)
{
    ll res = 1;
    for(int i = 0; i<b; i++)
       res *= a;

    return res;
}



int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	int a, b ,c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	char c;
	cin>>c;
	switch(c){
		case'A':cout<<'T';break;
		case'T':cout<<'A';break;
		case'G':cout<<'C';break;
		case'C':cout<<'G';break;
	}
    return 0;
}


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

int N;
int main()
{
  scanf("%d", &N);
  if (N < 105) printf("0");
  else if (N < 135) printf("1");
  else if (N < 165) printf("2");
  else if (N < 189) printf("3");
  else if (N < 195) printf("4");
  else printf("5");
  printf("\n");
  return 0;
}


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

struct node { int p, le, ri;};

node T[max];
int n, D[max];

void print(int u)
{
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";

	if (T[u].p == NIL)cout << "root, ";
	else if (T[u].le == NIL)cout << "leaf, ";
	else cout << "internal node, ";

	cout << "[";

	for (i = 0, c = T[u].le; c != NIL; i++, c = T[c].ri)
	{
		if (i)cout << ", ";
		cout << c;
	}
	
	cout << "]" << endl;
}

int rec(int u,int  p)
{
	D[u] = p;
	if (T[u].ri != NIL)rec(T[u].ri, p);
	if (T[u].le != NIL)rec(T[u].le, p + 1);
}

int main()
{
	int i, j, d, v, c, l, r;
	cin >> n;
	for (i = 0; i < n; i++)  T[i].p = T[i].le = T[i].ri = NIL;

	for(i=0;i<n;i++)
	{
		cin >> v >> d;
		for (j = 0; j < d; j++)
		{
			cin >> c;
			if (j == 0)T[v].le = c;
			else T[l].ri = c;
			l = c;
			T[c].p = v;
		}
	}

	for (i = 0; i < n; i++) if (T[i].p == NIL) r = i;

	rec(r, 0);

	for (i = 0; i < n; i++)  print(i);

	return 0;
}




Measured memory_bytes: 7772
#include <vector>
#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main(){
    int n,ans = 0; cin >> n;
    vector<int> vec(n);
    for(int i = 0;i < n;i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    for(int i = 0;i < n-1;i++){
        if(vec.at(i) == vec.at(i+1)){
            break;
        }
        ans++;
    }
    if(ans == n-1){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <db,db> pdd;
typedef vector<int> vi;
//typedef vector<vector<int> > matrix;
 
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
 
#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
 
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD=998244353;
const ll hell=1000000007;
const int INF = 1e16;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);
 
double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };
 
const int N=200005;


const int k=51;
struct matrix
{
    int m[k][k];
    matrix()
    {
        memset(m,0,sizeof(m));
    }
} M,I;
matrix matmul(matrix a,matrix b)
{
    matrix x;
    for(int i=0;i<k;i++)
    {
        for(int j=0;j<k;j++)
        {
            for(int l=0;l<k;l++)
            {
                x.m[i][j]=(x.m[i][j]%hell+(a.m[i][l]%hell*b.m[l][j]%hell)%hell)%hell;
            }
        }
    }
    return x;
}
matrix matexpo(int n)
{
    if(n==0)
    {
        return I;
    }
    matrix F;
    F=matexpo(n/2);
    F=matmul(F,F);
    if(n%2)
        F=matmul(F,M);
    return F;
}




void solve()
{
int n,K;
cin>>n>>K;
for(int i=0;i<n;i++)
{
    for(int j=0;j<n;j++)
    {
        cin>>M.m[i][j];
        
    }
}
for(int i=0;i<k;i++)
I.m[i][i]=1;
matrix re=matexpo(K);
int ans=0;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
ans=(ans+re.m[i][j])%hell;
cout<<ans<<endl;



    
}

int32_t main()
{
    //IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        
        solve();
    }
    return 0;
}

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

double dp[303][303][303] = {0.0}; 

double f(int i,int j,int k,int n){
    double tmp = 0.0;
    if (i==0 && j==0 && k==0) return 0.0;
    if (dp[i][j][k]!=0.0) return dp[i][j][k];
    if (i>0) tmp += f(i-1,j,k,n)*i/(i+j+k);
    if (j>0) tmp += f(i+1,j-1,k,n)*j/(i+j+k);
    if (k>0) tmp += f(i,j+1,k-1,n)*k/(i+j+k);
    tmp += (double)n/(i+j+k);
    dp[i][j][k] = tmp;
    return tmp;
}   

int main(void) {
	int n,a[304];
	double res;
	int cnt[3] = {0}; //1個の個数,二個の個数,三個の個数
	scanf("%d",&n);
	for (int i=0;i<n;i++) scanf("%d",&a[i]);
	for (int i=0;i<n;i++) cnt[a[i]-1]++;
	
	res = f(cnt[0],cnt[1],cnt[2],n);
	printf("%.9f\n",res);
	return 0;
}


/*
import numpy as np
n=int(input())
a = list(map(int,input().split()))
cnt = [0,0,0] #1個の個数、二個の個数、三個の個数
for i in range(n):
    cnt[a[i]-1] += 1
    
def f(i,j,k):
    if [i,j,k] == [0,0,0]:
        return 0.0
    if dp[i][j][k] != 0.0:
        return dp[i][j][k]
    tmp = 0.0
    if i>0:
        tmp += f(i-1,j,k)*float(i)/float(i+j+k)
    if j>0:
        tmp += f(i+1,j-1,k)*float(j)/float(i+j+k)
    if k>0:
        tmp += f(i,j+1,k-1)*float(k)/float(i+j+k)
    tmp += float(n)/float(i+j+k)
    
 
    dp[i][j][k] = tmp
    return tmp
dp = np.zeros((n+1,n+1,n+1))
#dp = [[[0.0 for i in range(n+1)] for j in range(n+1)] for k in range(n+1)]
 
print(f(cnt[0],cnt[1],cnt[2]))
*/

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



int main(){
	int n;
	int hasil=0;
	scanf("%d",&n);
	int temp = n;
	while(temp > 0){
		hasil+= temp%10;
		temp/=10;
	}
	if(n%hasil == 0)printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n;
    cin >> n;

    ll count = 0;
    ll i = 5;
    if(n % 2 == 1){
        cout << 0 << endl;
        return 0;
    }
    while(i * 2 <= n){
        count += n / (i * 2);
        i *= 5;
    }

    cout << count << endl;
    return 0;
}


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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  long long ans = 0;
  long long S = 0;
  int right = 0;
  for (int left = 0; left < N; left++) {
    while (right < N && (S ^ A.at(right)) == (S + A.at(right))) {
      S += A.at(right);
      right++;
    }
    ans += (right - left);
    if (left == right) right++;
    else S -= A.at(left);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N; cin>>N;
    vector <long long int> B(N-1);
    for(int i=0;i<N-1;i++){
        cin>>B[i];
    }
    int ans=0;
    int a=0;
    for(int i=0;i<N;i++){
        if(i==0){
            a=B[0];
        }
        else if(i==N-1){
            a=B[N-2];
        }
        else{
            a=min(B[i-1],B[i]);
        }
        ans=ans+a;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n,c;
int main()
{
    cin>>n;
    c=n%10;
    if(c==3)
        cout<<"bon";
    else if(c==0||c==1||c==6||c==8)
        cout<<"pon";
    else
        cout<<"hon";
    return 0;
}


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

ans = False
zoro_renzoku = 0

for _ in range(N):
    D_1, D_2 = map(int, input().split())
    if D_1==D_2:
        zoro_renzoku += 1
    else:
        zoro_renzoku = 0
    
    if zoro_renzoku ==3:
        ans = True
        
if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
#include<iostream>
#include<cstdlib>
#include<algorithm>

using namespace std;

typedef long long ll;

const int MAXN = 100010;
const ll INF = 1e9 + 10;
ll dp[MAXN];

int main() {
   int N;
   cin >> N;
   ll a[N];
   for (int i = 0; i < N; i++) cin >> a[i];
   
   fill(dp, dp + N, INF);
   for (int i = 0; i < N; i++) {
      *lower_bound(dp, dp + N, a[i]) = a[i];
   }
   int ans = lower_bound(dp, dp + N, INF) - dp;
   cout << ans << endl;
   return 0;
}



Measured memory_bytes: 4660
N, M = map(int, input().split())
k = []
for _ in range(M):
    k1 = list(map(int, input().split()))
    k.append(k1)    
p = list(map(int, input().split()))


ans = 0
a = [0] * N
for i in range(1 << N):
    for j in range(N):
        if i >> j & 1 == 1:
            a[j] = 1
        else:
            a[j] = 0
    for j in range(M):
        sc = 0
        for l in range(k[j][0]):
            if a[k[j][l+1]-1] == 1:
                sc += 1
        if sc % 2 != p[j]:
            break
        elif j == M-1:
            ans += 1
            
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int a,b,c,d; 
	cin>>a>>b>>c>>d;
	int p = a/d;int q = c/b;
	if(p*d<a){
		p++;
	}
	if(q*b<c){
		q++;
	}
	if(q<=p){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3668
#include<stdio.h>
int main(void) {
	int p, q, r;
	scanf("%d %d %d", &p, &q, &r);
	if (p > q) {
		if (p > r) printf("%d", q + r);
		else printf("%d", p + q);
	}
	else {
		if (q > r) printf("%d", p + r);
		else printf("%d", p + q);
	}
	return 0;
}

Measured memory_bytes: 128
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> as(q); cin >> as;
    vector<int> nums(n);
    for(auto& a : as){
        nums[a - 1]++;
    }
    for(int i = 0; i < n; i++){
        cout << (k - q + nums[i] <= 0 ? "No" : "Yes") << '\n';
    }
}


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

int main(void){
  int N;
  cin>>N;
  vector<int> X(N);
  for(int i=0;i<N;i++){
    cin>>X[i];
  }
  int minimum=10000000;
  for(int i=1;i<=100;i++){
    int sum=0;
    for(int j=0;j<N;j++){
      sum+=(X[j]-i)*(X[j]-i);
    }
    minimum=min(minimum,sum);
  }
  cout<<minimum<<endl;
  return 0;
}


Measured memory_bytes: 256
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
const int N = 1000010;
using namespace std;
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
ll lcm(ll a,ll b)
{
  return (a*b)/__gcd(a,b);
}
int main()
{
  // int x = -1, y = 10000;
  // double z = 0.2;
  // string s2 = "beginner1010";
  // long long b = 1LL << 60;
    
  // // debug(x, y, z, s, b);
    
  // double aux = 1010.0;
  // string code = "code";
    
  // debug(code + "forces",-aux / 10 * 2.3);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n,m,ac=0,wa=0;
  cin >> n >> m;
  for (int i = 0; i < m; ++i)
  {
    ac = ac*10+n; 
  }
  for (int i = 0; i < n; ++i)
  {
    wa = wa*10+m;
  }
  if (n >= m )
  {
    cout << wa;
  }
  else
  {
    cout << ac;
  }
  return 0;
}


Measured memory_bytes: 256
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        s: chars
    }
    let n = s.len();
    let f = |a: &[char]| -> bool {
        let mut b = Vec::from(a);
        b.reverse();
        a.iter().zip(b.iter()).all(|(a,b)| a == b)
    };
    if f(&s) && f(&s[0..(n/2)]) && f(&s[(n/2+1)..n]) {
        println!("Yes");
    } else {
        println!("No");
    }
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4352
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

int main(void){
    int H,W;
    cin >> H >> W;
    int A[H][W];
    rep(i,H) rep(j,W) cin >> A[i][j];
    int N=0;
    int cnt=0;
    vector<int> res[4];
    for(int i=0;i<H;i++){
        if(i%2==0){
            for(int j=0;j<W;j++){
                cnt++;
                if(cnt==H*W) break;
                int nh=i,nw=j+1;
                if(nw==W) nh++,nw--;
                if(A[i][j]%2){
                    N++;
                    res[0].push_back(i);
                    res[1].push_back(j);
                    res[2].push_back(nh);
                    res[3].push_back(nw);
                    A[nh][nw]++;
                }
            }
        }
        else{
            for(int j=W-1;j>=0;j--){
                cnt++;
                if(cnt==H*W) break;
                int nh=i,nw=j-1;
                if(nw==-1) nh++,nw++;
                if(A[i][j]%2){
                    N++;
                    res[0].push_back(i);
                    res[1].push_back(j);
                    res[2].push_back(nh);
                    res[3].push_back(nw);
                    A[nh][nw]++;
                }
            }
        }
    }
    cout << N << endl;
    rep(i,N){
        rep(j,4) cout << res[j][i]+1 << (j==3?"\n":" ");
    }
}

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

#define MAX_N 2000

// int N = 10;
int N;
int main() {
    cin >> N;
    rep(i, 9) {
        rep(j, 9) {
            if ((i + 1) * (j + 1) == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    
    cout << "No" << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <type_traits>
#include <limits>
#include <random>
#include <iomanip>

using namespace std;

using ll = long long;

typedef pair<ll, ll> P;

#define rep(i,N) for(long long i = 0;i < (long long)N; ++i)

static int mod = 1000000007;
static int large_int = 1000000000;
static ll large_ll = 100000000000000;

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


ll N, M;
ll a[100002];
P b[100000];

int main()
{
	
	cin >> N >> M;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < M; i++)
	{
		cin >> b[i].second >> b[i].first;
	}
	sort(b, b + M, greater<P>());
	sort(a, a + N);
	int na = 0;
	bool flag = false;
	for (int i = 0; i < M; i++)
	{
		int c = 0, d = 0;
		c = b[i].first;
		d = b[i].second;
		for (int j = 0; j < d; j++)
		{
			
			if (c >= a[na] && na < N)
			{
				a[na] = c;
			}
			else
			{
				flag = true;
				break;
			}
			na++;
		}
		if (flag) break;
	}
	ll ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 2560
#include "bits/stdc++.h"

using namespace std;

void solve()
{
	string S;
	cin >> S;
	int l = S.size();
	bool ok = S == "keyence";
	for (int i = 0; i < l-1; i++)
		for (int j = i; j < l; j++)
		{
			ok |= (S.substr(0, i) + S.substr(j, l - j + 1)) == "keyence";
			//cout << S.substr(0, i) + S.substr(j, l - j + 1) << endl;
		}

	cout << (ok ? "YES" : "NO") << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cctype>
#include <functional>
#include <map>
#include <cmath>

using namespace std;
typedef long long ll;

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

int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    int tmp;
    ll ans = 0;
    int b;
    rep(i,n){
        cin >> tmp;
        vec[i] = tmp - (i+1);
    }

    sort(vec.begin(),vec.end());

    if(n % 2==0){
        b = (vec[n/2] + vec[n/2-1])/2;
    }else{
        b = vec[n/2];
    }

    rep(i,n){
        ans += abs(vec[i] - b);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
ans = {
    '0': 'pon',
    '1': 'pon',
    '2': 'hon',
    '3': 'bon',
    '4': 'hon',
    '5': 'hon',
    '6': 'pon',
    '7': 'hon',
    '8': 'pon',
    '9': 'hon',
}
    

s = input()

print(ans[s[-1]])




Measured memory_bytes: 9028
#include "bits/stdc++.h"

using namespace std;

void solve(void)
{
	int k, x;
	cin >> k >> x;
	for (int i = x-k+1; i <= x+k-1; i++)
	{
		cout << i << ' ';
	}
	cout << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

int main(){
	int money=1000,m;
	for(int m;cin>>m;money=1000){
		if(m==0)break;
		money-=m;
		int count;
		for(count=0;money;){
			//cout<<"money:"<<money<<endl;
			if(money/500){
				money-=500;
			}
			else if(money/100){
				money-=100;
			}
			else if(money/50){
				money-=50;
			}
			else if(money/10){
				money-=10;
			}
			else if(money/5){
				money-=5;
			}
			else if(money/1){
				money-=1;
			}
			count++;
		}
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>


struct UFT {
    int i;
    UFT* parent = nullptr;
};


int getValue(int x, UFT *n) {
    UFT* parent = &n[x];
    while (parent->parent != nullptr) {
        parent = parent->parent;
    }
    return parent->i;
}


void unit(int x, int y, UFT *n) {
    int px = getValue(x, n);
    int py = getValue(y, n);
    if (px == py) {
        return;
    }
    if (px < py) {
        n[py].parent = &n[px];
    } else {
        n[px].parent = &n[py];
    }
}


void same(int x, int y, UFT *n) {
    int px = getValue(x, n);
    int py = getValue(y, n);
    if (px == py) {
        std::cout << 1 << std::endl;
    } else {
        std::cout << 0 << std::endl;
    }
}


int main() {
    int n, q;
    std::cin >> n >> q;

    UFT set[n];

    for (int i = 0; i < n; i++) {
        set[i].i = i;
    }
    
    for (int i = 0; i < q; i++) {
        int com, x, y;
        std::cin >> com >> x >> y;
        if (com == 0) {
            unit(x, y, set);
        } else {
            same(x, y, set);
        }
    }
}



Measured memory_bytes: 3244
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    d = collections.defaultdict(list)
    for i in range(m):
        a, b = list(map(int, input().rstrip('\n').split()))
        if a == 1 or a == n:
            d[a] += [b]
        if b == 1 or b == n:
            d[b] += [a]
    if 1 in d and n in d:
        dd = collections.defaultdict(list)
        for v in d[n]:
            dd[v]
        for i in d[1]:
            if i in dd:
                print("POSSIBLE")
                exit()
    print("IMPOSSIBLE ")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 68188
N=int(input())
A=[0]+[int(i) for i in input().split()]
S=[0]*(N+1)
MOD=10**9+7
for i in range(1,N+1):
    S[i]=(S[i-1]+A[i])%MOD

ans=0
for i in range(2,N+1):
    ans=(ans+A[i]*S[i-1])%MOD

print(ans)


Measured memory_bytes: 93972
package main
import(
  "fmt"
  "sort"
)
func main(){
  var i, n int
  count:=0
  fmt.Scan(&n)
  a:=make([]string, n)
  for i=0;i<n;i++{
    fmt.Scan(&a[i])
  }
  sort.Sort(sort.StringSlice(a))
  for i=0;i<n-1;i++{
    if a[i]==a[i+1]{
      count++
    }
  }
  fmt.Println(n-count)
}


Measured memory_bytes: 12076
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define PB push_back
int main(){
    string s,nxt;
    vector<string> front,back;
    int n,m,pos,ans;
    cin>>n>>m;
    while(n--){
        cin>>s;
        front.PB(s);
        reverse(s.begin(),s.end());
        back.PB(s);
    }
    s="z";
    s.back()++;
    front.PB(s);
    back.PB(s);
    sort(front.begin(),front.end());
    sort(back.begin(),back.end());
    while(m--){
        cin>>s;
        pos=-1;
        ans=0;
        if(s.front()=='*'){
            reverse(s.begin(),s.end());
            s.pop_back();
            nxt=s;
            for(int i=0;i<s.size();i++)if(s[i]=='?'){
                pos=i;
                break;
            }
            if(pos>=0)for(char i='a';i<='z';i++){
                s[pos]=i;
                nxt[pos]=i;
                nxt.back()=s.back()+1;
                ans+=lower_bound(back.begin(),back.end(),nxt)-lower_bound(back.begin(),back.end(),s);
            }
            else{
                nxt.back()++;
                ans+=lower_bound(back.begin(),back.end(),nxt)-lower_bound(back.begin(),back.end(),s);
            }
        }
        else if(s.back()=='*'){
            s.pop_back();
            nxt=s;
            for(int i=0;i<s.size();i++)if(s[i]=='?'){
                pos=i;
                break;
            }
            if(pos>=0)for(char i='a';i<='z';i++){
                s[pos]=i;
                nxt[pos]=i;
                nxt.back()=s.back()+1;
                ans+=lower_bound(front.begin(),front.end(),nxt)-lower_bound(front.begin(),front.end(),s);
            }
            else{
                nxt.back()++;
                ans+=lower_bound(front.begin(),front.end(),nxt)-lower_bound(front.begin(),front.end(),s);
            }
        }
        else{
            for(int i=0;i<s.size();i++)if(s[i]=='?'){
                pos=i;
                break;
            }
            if(pos>=0)for(char i='a';i<='z';i++){
                s[pos]=i;
                if(*lower_bound(front.begin(),front.end(),s)==s)ans++;
            }
            else if(*lower_bound(front.begin(),front.end(),s)==s)ans++;
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 11504
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.valueOf(sc.nextLine());
		String s = sc.nextLine();

		String a = s.substring(0, n / 2);
		String b = s.substring(n / 2, s.length());
		if (a.equals(b)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int main()
{
    int n;
    cin >>n;
    vector<int> a(n),b(n);
    rep(i,n) scanf(" %d %d", &a[i], &b[i]);

    //number of people to invite
    int ans=0;

    for(int num=n; num>0; --num)
    {
        int ct=0;
        rep(i,n)
        {
            if(a[i]<=num+1 && num+1<=b[i]) ++ct;
        }

        if(ct>=num)
        {
            ans=num;
            break;
        }
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3576
from collections import Counter


def main():
    n = int(input())
    v = list(map(int, input().split()))
    if Counter(v).most_common()[0][1] == n:
        print(n // 2)
        return
    o, e = v[::2], v[1::2]
    oc = Counter(o)
    ec = Counter(e)
    om = oc.most_common()
    em = ec.most_common()
    if om[0][0] == em[0][0]:
        a = om[0][1] + em[1][1]
        b = em[0][1] + om[1][1]
        print(n - max(a, b))
    else:
        print(n - (om[0][1] + em[0][1]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 23768
#include <stdio.h>

int main(void){
  int N,m,min = 1001;
  long X,ans = 0;
  scanf("%d%ld",&N,&X);

  for(int i = 0;i < N;i++){
    scanf("%d",&m);
    if(min > m) min = m;
    X -= m;
  }
  ans = N;
  ans += X/min;

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

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,m,x[500],y[500],X,Y,xm=-1145141919,ym=1145141919;
int main(){
    cin>>n>>m>>X>>Y;
    for(int i=0;i<n;i++){
        cin>>x[i];
        xm=max(xm,x[i]);
    }
    for(int i=0;i<m;i++){
        cin>>y[i];
        ym=min(ym,y[i]);
    }
    if(X<Y){
        if(xm<ym){
            if(ym>X&&xm<Y){
                cout<<"No War"<<endl;
            }else{
                cout<<"War"<<endl;
            }
        }else{
            cout<<"War"<<endl;
        }

    }else{
        cout<<"War"<<endl;
    }

}


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

using namespace std;

int main()
{

    int A,B,C,D;
    cin>>A>>B>>C>>D;

    int X= (A+D-1)/D;
    int Y=(C+B-1)/B;

    cout<<(X>=Y?"Yes":"No")<<"\n";

    return 0;
}


Measured memory_bytes: 3620