akhauriyash/Code-Regression huggingface dataset:
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
vector<ll> divisor(ll M){
    vector<ll> dd;
    for(ll i = 1; i * i <= M; i++){
        if(M % i == 0){
            dd.push_back(i);
            if(i * i != M) dd.push_back(M / i);
        }
    }
    sort(dd.begin(), dd.end());
    return dd;
}

int num[1000010] = {};

void solve(){
    ll N;
    cin >> N;
    ll A[200010];
    rep(i,0,N) cin >> A[i];
    ll ans = 0;
    rep(i,0,N) num[A[i]]++;
    rep(i,0,N){
        vector<ll> div = divisor(A[i]);
        bool ok = true;
        for(auto &e: div){
            if(e == A[i]){
                if(num[e] > 1) ok = false;

            }else{
                if(num[e] > 0) ok = false;
            }
        }
        if(ok) ans++;
    }
    print(ans);
}

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

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

int main() {

    int n;
    char s[101];
    char t[101];
    scanf("%d %s %s", &n, s, t);

    for (int i = 0; i < n; i++) {
        printf("%c", s[i]);
        printf("%c", t[i]);
    }

    return 0;

}


Measured memory_bytes: 128
#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()
{
  string s;
  cin >> s;
  
  int counter = 0;
  rep(i, 3)
  {
    if ('1' == s[i])
    {
      counter++;
    }
  }
  
  cout << counter << endl;
}


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

int main() {
  int k, n; 
  int max = 0;
  int len = 0;
  cin >> k >> n;

  int a[n];

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

    if((a[i] - a[i - 1]) > max && i != 0){
      max = a[i] - a[i - 1];
      len = (k - a[i]) + a[i - 1]; 
    }
  }

  if(a[n - 1] - a[0] < len){
    len = a[n - 1] - a[0];
  }

  cout << len << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;
using ll= long long;

long long mypow(long long k, long long n) {
    long long temp = 1;

    k = k % DIV;
    while (n) {
        if (n % 2) temp = temp * k % DIV;
        k = k * k % DIV;
        n = n / 2;
    }
    return temp % DIV;
}

int main() {
    int N;
    cin >> N;

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

    map<int,int> L;
   
    for (int i = 0; i < N; i++) {
        int temp = A[i];
        for (int j = 2; j <= sqrt(temp); j++) {
            int cnt = 0;
            while (temp % j == 0) {
                cnt++;
                temp /= j;
            }
            if(cnt)
            L[j] = max(L[j], cnt);
        }
        if (temp != 1)
            L[temp] = max(L[temp], 1);
    }

    ll lcm = 1;
    for (auto x : L) {
        lcm *= mypow((ll)x.first, (ll)x.second);
        lcm %= DIV;
    }
   // cout << "lcm=" << lcm << endl;
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += lcm*mypow((ll)A[i],DIV-2);
        ans %= DIV;
        
    }
    cout << ans << endl;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,q;
	cin >>n >>q;
	string s;
	cin >>s;
	vector<int > cc(n), sm(n+1);
	rep2(i, 1, n){
		if(s[i-1]=='A' && s[i]=='C') cc[i]=1;
	}
	rep(i, n) sm[i+1] = sm[i]+cc[i];
	//for(auto x :sm) printf("%d, ",x);puts("");
	rep(i, q){
		int r,l;
		cin >>l >>r;
		int ans = sm[r] - sm[l-1] - (sm[l-1]!=sm[l]);
		cout << ans <<"\n";
		
	}
	
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
map<long,long>mp;
int main()
{
    long i,j,t,a,b,n,c,y,m,prev,sum,ans=1,count;
    t=1;
    // cin>>t;
    while(t--)
    {
           cin>>n>>m;
           char arr[n][m];
           for(i=0;i<n;i++)
           for(j=0;j<m;j++)
            cin>>arr[i][j];
           for(i=0;i<n;i++)
           {
               for(j=0;j<m;j++)
               {
                   if(arr[i][j]=='#')continue;
                   int dx[]={0,0,1,1,1,-1,-1,-1};
                   int dy[]={1,-1,0,-1,1,0,-1,1};
                   count=0;
                   for(c=0;c<8;c++)
                   {
                       int ii=dx[c];
                       int jj=dy[c];
                       if(i+ii<0 || i+ii>=n)continue;
                       if(j+jj<0 || j+jj>=m)continue;
                       if(arr[i+ii][j+jj]=='#')count++;
                   }
                   arr[i][j]=char(count+'0');
               }
           }
           for(i=0;i<n;i++)
           {
               for(j=0;j<m;j++)
               {
                    cout<<arr[i][j];
               }
               cout<<endl;
           }
       
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int A, B;

int main()
{
	scanf("%d%d", &A, &B);
	if (A <= 0 && 0 <= B) {
		puts("Zero");
		return 0;
	}

	if (1 <= A || (B - A) % 2 == 1) {
		puts("Positive");
		return 0;
	}
	puts("Negative");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int n;
	scanf("%d",&n);
	int i;
	int min = n;
	for(i=0;i<=n;i++){
		int cc = 0;
		int t=i;
		while( t>0){
			cc += t%6;
			t /=6;
		}
		t = n-i;
		while(t>0){
			cc += t%9;
			t/=9;
		}
		if( cc < min){
			min = cc;
		}	
	}
	printf("%d",min);
	return 0;
}

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

class Dice{
	int _num[6];
	public:
		void set(int num[6]){
			for(int i = 0; i < 6; i++) _num[i] = num[i];
		}
		void N(){
			swap(_num[0],_num[4]);
			swap(_num[0],_num[5]);
			swap(_num[0],_num[1]);
		}
		void S(){
			swap(_num[0],_num[1]);
			swap(_num[0],_num[5]);
			swap(_num[0],_num[4]);
		}
		void W(){
			swap(_num[0],_num[3]);
			swap(_num[0],_num[5]);
			swap(_num[0],_num[2]);
		}
		void E(){
			swap(_num[0],_num[2]);
			swap(_num[0],_num[5]);
			swap(_num[0],_num[3]);
		}
		void printTop(){
			cout << _num[0] << endl;
		}
};

int main(){
	int num[6];
	for(int i = 0; i < 6; i++) cin >> num[i];
	
	Dice d;
	d.set(num);
	
	string cmd;
	cin >> cmd;
	
	while(cmd.size() > 0){
		char c = cmd[0];
		cmd = cmd.substr(1);
		switch(c){
			case('N'): 
				d.N(); break;
			case('S'): 
				d.S(); break;
			case('W'):
				d.W(); break;
			case('E'):
				d.E(); break;
		}
	}
	d.printTop();
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
ii ar[1005];

int fact(int n){
	int ans = 1;
	for(int i = 1; i <= n; i++){
		ans *= i;
	}
	return ans;
}

int main(){
	cout << fixed << setprecision(6);
	int n; cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> ar[i].first >> ar[i].second;
	}
	int x = 2*fact(n-1);
	double ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = i; j <= n; j++){
			ans += sqrt(abs(ar[i].first - ar[j].first)*abs(ar[i].first - ar[j].first) + abs(ar[i].second - ar[j].second)*abs(ar[i].second - ar[j].second));
		}
	}
	ans *= x;
	ans /= fact(n);
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		sc.close();
		int a = 0;
		if(n % (2*d + 1)==0) {
			a = n / (2*d + 1);
		}else {
			a = n / (2*d + 1) +1;
		}

		System.out.println(a);
	}

}

Measured memory_bytes: 23892
n = gets.to_i
w_1 = gets.chomp
w = [w_1]
last = w_1[-1]

rule = true
(n-1).times do
    input = gets.chomp
    if last == input[0] && !w.include?(input)
        last = input[-1]
        w << input
    else
        rule = false
        break
    end
end

puts rule ? "Yes" : "No"

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

int main() {
  string s; cin >> s;
  int count = 0;
  string t = "abcdefghijklmnopqrstuvwxyz";
  vector<int>b(27);
  
  for(int i = 0; i < 26; i++){
    for(int j = 0; j < s.size(); j++){
      if(t.at(i) == s.at(j))b.at(i) = 1;
    }
  }
  int k = 0;
  while(b.at(k) == 1){
    if(k == 26)break;
    k++;
  }
  if(k ==26)cout << "None" << endl;
  else cout << t.at(k) << endl;
}

Measured memory_bytes: 512
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
A=get_i.sort!
if A[0].zero?
    puts 0
    exit
end
ans=1
A.each do|a|
    ans*=a
    if ans>10**18
        puts "-1"
        exit
    end
end
puts ans

Measured memory_bytes: 24104
x = int(input())
li = [False] * (x + 1)
li[1] = True

for i in range(x):
    for j in range(2, x):
        if i ** j > x:
            break
        li[i ** j] = True

for i in reversed(range(x + 1)):
    if li[i]:
        print(i)
        break


Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
bool isodd8(int n){
	if(n%2==0)return 0;
	int sum=0;
	for(int i=1;i*i<=n;i++)
	if(n%i==0){
		if(i*i==n)sum++;
		else sum+=2;
	}
	return sum==8;
}
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int n;
	cin>>n;
	if(n<105)cout<<0;
	else{
		int ans=1;
		for(int i=106;i<=n;i++)if(isodd8(i))ans++;
		cout<<ans<<endl;
	}
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,sum=0,k=0;
    cin>>n;
    int p=n;
    while(p!=0)
    {
        k=p%10;
        p/=10;
        sum+=k;
    }
   if(n%sum==0)
   {
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

    vector<vector<int> > dp(s.size()+1, vector<int>(t.size()+1, 0));
    vector<vector<int> > path(s.size()+1, vector<int>(t.size()+1, 0));

    for(int si = 0; si < s.size(); si++){
        for(int ti = 0; ti < t.size(); ti++){
            if(s[si] == t[ti]){
                dp[si+1][ti+1] = dp[si][ti] + 1;
                path[si+1][ti+1] = 0;
            }else{
                if(dp[si+1][ti] > dp[si][ti+1]){
                    dp[si+1][ti+1] = dp[si+1][ti];
                    path[si+1][ti+1] = 2;
                }else{
                    dp[si+1][ti+1] = dp[si][ti+1];
                    path[si+1][ti+1] = 1;
                }
            }
        }
    }
    /*
    for(int si = 0; si <= s.size(); si++){
        for(int ti = 0; ti <= t.size(); ti++){
            printf(" %3d", dp[si][ti]);
        }
        printf("\n");
    }
    printf("\n");
    for(int si = 0; si <= s.size(); si++){
        for(int ti = 0; ti <= t.size(); ti++){
            printf(" %3d", path[si][ti]);
        }
        printf("\n");
    }
    */
    //printf("%d\n", dp[s.size()][t.size()]);
    int si = s.size();
    int ti = t.size();
    string lcs = "";
    while(si > 0 && ti > 0){
        if(path[si][ti] == 0){
            lcs += t[ti-1];
            si--; ti--;
        }else if(path[si][ti] == 1){
            si--;
        }else{
            ti--;
        }
    }
    reverse(lcs.begin(), lcs.end());
    printf("%s\n", lcs.c_str());
    return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	int n;
	cin >> n;
	cout << (1000 - (n % 1000)) % 1000 << endl;
	return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
bool e[8][8]={false};

int dfs(int v,int N,bool vv[8]){
    bool all = true;
    for(int i=0;i<N;i++){
        if(!vv[i]) all=false;
    }
    if(all) return 1;
    int ret=0;
    for(int i=0;i<N;i++){
        //今見ている頂点とつながっていれば探索
        if(e[v][i]==false) continue;
        //すでに訪れていたら探索しない
        if(vv[i]) continue;
        //探す
        vv[i]=true;
        ret+=dfs(i,N,vv);
        vv[i]=false;
    }
    return ret;
}

int main(){
    int  N,M;
    cin >> N >> M;
    for(int i=0;i<M;i++){
        int a,b; cin >> a >> b;
        e[a-1][b-1]=true;
        e[b-1][a-1]=true;
    }
    bool vv[8];
    for(int i=0;i<N;i++) vv[i] = false;
    vv[0]=true;
    cout << dfs(0,N,vv) << endl;
    
    return 0;
}


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

int main() {
 int  a;
 int  b;
 //AとBの平均 double x = (a + b)/2 余りがあると繰り上げ
  
  cin>> a;
  cin>> b;
    cout << (a + b + 1) /2 << endl;
    
}


Measured memory_bytes: 3628
s = list(input().rstrip())
n = len(s)
m = 10 ** 9 + 7
dp = [[0] * 13 for _ in range(n + 1)]
dp[0][0] = 1

for i in range(n):
    c = -1 if s[i] == '?' else int(s[i])
    for j in range(10):
        if c != -1 and c != j:
            continue
        for ki in range(13):
            dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki]
        for j in range(13):
            dp[i + 1][j] %= m
print(dp[n][5])


Measured memory_bytes: 66552
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
long long n,d,a,tot,rpos;
pair<long long,long long> arr[200001];
struct node{
    node *l,*r;
    long long s,m,e,val,lazy;
    node (int ss,int ee){
        s=ss;
        e=ee;
        m=(s+e)/2;
        val=0;
        lazy=0;
        if (s!=e){
            l=new node(s,m);
            r=new node(m+1,e);
        }
    }
    long long value(){
        if (s==e){
            val+=lazy;
            lazy=0;
            return val;
        }
        val+=lazy;
        r->lazy+=lazy;
        l->lazy+=lazy;
        lazy=0;
        return val;
    }
    void upd(int x,int y,long long v){
        if (s==x && e==y) lazy+=v;
        else if (x>m) r->upd(x,y,v);
        else if (y<=m) l->upd(x,y,v);
        else l->upd(x,m,v),r->upd(m+1,y,v);
    }
    long long qry(int x){
        value();
        if (s==e) return value();
        if (x>m) return r->qry(x);
        return l->qry(x);
    }
}*root;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>d>>a;
    d*=2;
    for (int i=1;i<=n;i++){
        cin>>arr[i].first>>arr[i].second;
    }
    sort(arr+1,arr+n+1);
    root=new node(1,n);
    for (int i=1;i<=n;i++){
        root->upd(i,i,arr[i].second);
    }
    for (int i=1;i<=n;i++){
        long long h=root->qry(i);
        if (h<=0) continue;
        while (rpos<n && arr[rpos+1].first<=arr[i].first+d){
            rpos++;
        }
        long long cur=(h+a-1)/a;
        root->upd(i,rpos,-cur*a);
        tot+=cur;
    }
    cout<<tot;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
/****** define constant end ********/
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
	if (n & 1)
	  res = res * a % mod;
	a = a * a % mod;
	n >>= 1;
  }
  return res;
}
/****** define variable start ******/
ll n;
/******* define variable end *******/
int solve() {
	cin >> n;
	vector<vector<ll>> f(n, vector<ll>(10));
	vector<vector<ll>> p(n, vector<ll>(11));
	REP(i, n){
		REP(j, 10){
			cin >> f[i][j];
		}
	}
	REP(i, n){
		REP(j, 11){
			cin >> p[i][j];
		}
	}
	ll ans = INF * (-1);
	for(ll i = 1; i < 1 << 10; ++i){
		vl open(10);
		ll tmp = i;
		ll count = 0;
		while(tmp > 0){
			open[count] = tmp % 2;
			tmp /= 2;
			count++;
		}
		vl count_v(n);
		REP(j, n){
			count_v[j] = 0;
		}
		ll ans_tmp = 0;
		REP(j, n){
			REP(k, 10){
				if(f[j][k] == open[k] && f[j][k] == 1){
					count_v[j]++;
				}
			}
			ans_tmp += p[j][count_v[j]];
		}
		if(ans < ans_tmp){
			ans = ans_tmp;
		}
	}
	cout << ans << endl;
	return 0;
}

int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
nakami=[]
for i in range(n):
  ilist= list(map(int,input().split()))
  for j in range(1,ilist[0]+1):
    nakami.append(ilist[j])

import collections
c=collections.Counter(nakami)

a=0
for i in range(m+1):
  if c[i] == n:
    a += 1
  else:
    pass
  
print(a)  

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010
#define MAX_C 40

ll table[MAX_C][MAX_N];
ll ch[MAX_N];
ll N, C;

int main()
{

    ZERO(table);
    ZERO(ch);

    cin >> N >> C;

    for (int i = 0; i < N; i++) {
        ll s, t, c;
        cin >> s >> t >> c;
        if(s > 0) { s--; }
        table[c][s] += 1;
        table[c][t] -= 1;
    }

    // 完全に包含する 1, -1 区間ができてしまうので、
    // それは除去する
    for(int c = 1; c <= C; ++c) {
        bool open = false;
        ll elim = 0;
        for(int i = 0; i < MAX_N; ++i) {
            if(!open && table[c][i] > 0) {
                open = true;
            }
            else if(open) {
                if(table[c][i] > 0) {
                    elim++;
                    table[c][i] = 0;
                }
                else if(table[c][i] < 0) {
                    if(elim > 0) {
                        elim--;
                        table[c][i] = 0;
                    } else {
                        open = false;
                    }
                }
            }
        }
    }

    // シミュレート
    for (int i = 0; i < MAX_N; ++i) {
        int sub = 0;
        for(int j = 1; j <= C; ++j) { sub += table[j][i]; }
        if(i > 0) { ch[i] += (ch[i - 1] + sub); }
        else { ch[i] += sub; }
    }
    // 最大値を調べる
    ll ans = 0;
    for (int i = 0; i < MAX_N; ++i) { ans = max(ans, ch[i]); }

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


Measured memory_bytes: 32256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  double l,r;
  int res[4][2] = {0};
  while(cin>>l>>r){
    if(l >= 1.1){
      res[0][0] ++;
    }else if(l >= 0.6){
      res[1][0] ++;
    }else if(l >= 0.2){
      res[2][0] ++;
    }else{
      res[3][0] ++;
    }
    if(r >= 1.1){
      res[0][1] ++;
    }else if(r >= 0.6){
      res[1][1] ++;
    }else if(r >= 0.2){
      res[2][1] ++;
    }else{
      res[3][1] ++;
    }
  }
  for(int i = 0 ; i < 4 ; i ++){
    cout<<res[i][0]<<" "<<res[i][1];
    cout<<endl;
  }

}

Measured memory_bytes: 1224
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cctype>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

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

#define ALL(c) (c).begin(), (c).end()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define RANGE(lb, x, ub) ((lb) <= (x) && (x) < (ub))

#define dump(x) cerr << #x << ": " << (x) << endl;

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INF = 1000000000;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main(void) {
  int n; cin >> n;
  VI ws(n); REP(i, n) cin >> ws[i];

  int ret = INF;
  FOR(t, 0, n) {
    int s1=0, s2=0;
    FORE(i, 0, t) s1 += ws[i];
    FOR(i, t+1, n) s2 += ws[i];
    ret = min(ret, abs(s1-s2));
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 888
from collections import defaultdict

N, M = map(int, input().split())
YPID = [[0, 0, 0, ''] for _ in range(M)]
import sys
input = sys.stdin.readline
for i in range(M):
    pp, mm = map(int, input().split())
    YPID[i][0] = mm
    YPID[i][1] = pp
    YPID[i][2] = i
YPID.sort()
ID = defaultdict(int)

for ypid in YPID:
    ID[ypid[1]] += 1
    ypid[3] = str(ypid[1]).zfill(6) + str(ID[ypid[1]]).zfill(6)

YPID.sort(key=lambda x: x[2])
for ypid in YPID:
    print(ypid[3])


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

const long long INF = 1LL<<60;

int main(){
    int n,W;
    cin >> n >> W;
    int w[n],v[n];
    for(int i=0;i<n;i++)
        cin >> w[i] >> v[i];

    const long long V = pow(10,5); //N*vの最大値
    static long long dp[100+1][V+1]; //大きい配列はstaticにする必要がある
    for(int i=0;i<V+1;i++)
        dp[0][i] = INF;
    dp[0][0] = 0;
    for(int i=1;i<n+1;i++){
        for(int j=0;j<V+1;j++){
            if(j-v[i-1]>=0)
                dp[i][j] = min(dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }

    for(int i=V;i>=0;i--){
        if(dp[n][i]<=W){
            cout << i;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 79104
#include<iostream>
#include<algorithm>

int const MAXN = 1e3;
int const MAXB = 1e4;
int const MAXH = 1e4;

int A[MAXN], B[MAXN], H, N;
int dp[MAXH+1];

int calc(int h) {
  if(h <= 0) return 0;
  if(dp[h] >= 0) return dp[h];
  int res = h*1e4;
  for(int i = 0; i < N; ++i) {
    res = std::min(res, calc(h-A[i])+B[i]);
  }
  return dp[h] = res;
}

int main() {
  std::cin >> H >> N;
  for(int i = 0; i < N; ++i) std::cin >> A[i] >> B[i];
  std::fill_n(dp, H+1, -1);
  std::cout << calc(H) << std::endl;
  return 0;
}


Measured memory_bytes: 896
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int a = scanner.nextInt(); //次に開催されるabcの回数
        int hoge;

        while(!isRepDigit(a)){
            a++;
        }
        hoge =a;

        out.println(hoge);
        out.flush();
    }

    private static boolean isRepDigit(int num){
        String str = String.valueOf(num);
        int len = str.length();
        boolean ret = true;
        for(int n = 0; n < len-1; n++) {
            if(str.charAt(n)!=str.charAt(n+1)){
                ret =false;
            }
        }
        return ret;
    }

}


Measured memory_bytes: 23636
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 1000000009
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()

//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    const int limbin = 500001;
    int fact[limbin], factinv[limbin] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,limbin)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();
        if(n<r) return 0;             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    rep(i,t)
    {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}

void solve()
{
    int n;
    cin >> n;
    int a[n];
    rep(i,n)
        cin >> a[i];
    sort(a,a+n);
    int cnt = n , res = a[n-1] , i = 2;
    cnt -= 2;
    while(cnt>0)
    {
        res += min(cnt,2ll)*a[n-i];
        cnt-=2;
        i++;
    }
    cout << res;
}

// 5 4 4 3

Measured memory_bytes: 5172
#include <iostream>
using namespace std;
int main(){
	int t=0;
	string s, a;
	cin >> s;
	a=s[0];
 	for (int i=1; i<s.size(); i++) {
	 if (s[i]==s[i-1]){
	 	t++;
	 	if (s[i-1]=='1'){
	 		s[i]= '0';
		 }else if (s[i-1]=='0'){
	 		s[i]= '1';
		 }
	 }	
	}cout << t << endl;
	return 0;
}

Measured memory_bytes: 512
import math
x = int(input())
xmax = int(math.sqrt(1000))
ans = 0
for i in range(1, xmax + 1): #b
    for j in range(2, 11): #p
        tmp = pow(i, j)
        #print(tmp, i, j)
        if tmp <= x:
            ans = max(ans, tmp)
            #print('a')
        else:
            break
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    string b;

    cin >> b;

    if (b == "A")
        cout << "T" << endl;

    else if (b == "T")
        cout << "A" << endl;

    else if (b == "C")
        cout << "G" << endl;

    else if (b == "G")
        cout << "C" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
int64_t INF = 1000000007;
// int64_t INF = 9223372036854775807;
// int64_t INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s.at(i);
    vvi a(26,vector<ll>(s.size()));
    rep(i,n) sort(s.begin(), s.end());
    rep(i,26){
        char c = 'a'+i;
        rep(j,s.size()){
            rep(k,s.at(j).size()){
                if(s.at(j).at(k)==c) a.at(i).at(j)++;
            }
        }
    }
    // rep(i,a.size()){
    //     rep(j,a.at(i).size()){
    //         cout << "i:" << i << " j:" << j << " a:" << a.at(i).at(j) << endl;;
    //     }
    // }
    string res = "";
    rep(i,26){
        vi b = a.at(i);
        sort(a.at(i).begin(), a.at(i).end());
        rep(j,a.at(i).at(0)){
            res += 'a' + i;
        }
    }
    cout << res << endl;
}

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

int cmp(const int *a,const void *b){
  return *(int*)a - *(int*)b;
}

int main(void){
  int n,i,j;
  long long min=1e16,tmp;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  qsort(a,n,sizeof(int),cmp);
  for(i=a[0];i<=a[n-1];i++){
    tmp=0;
    for(j=0;j<n;j++){
      tmp += abs(i-a[j])*abs(i-a[j]);
    }
    if(min>tmp) min = tmp;
  }
  printf("%d\n",min);
  return 0;
}

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

using namespace std;

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

int main() {
	int n, mx;
	cin >> n;
	vector<int> a(n), l(n + 1, 0), r(n + 1, 0);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i) {
		l[i + 1] = gcd(l[i], a[i]);
		r[n - i - 1] = gcd(r[n - i], a[n - i - 1]);
	}
	mx = gcd(l[0], r[1]);
	for (int i = 1; i < n; ++i) {
		mx = max(mx, gcd(l[i], r[i + 1]));
	}
	cout << mx << endl;
}


Measured memory_bytes: 1408
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Program{
  public static void Main(){
      int x = int.Parse(Console.ReadLine());
      int a = x / 500;
      int b = (x - 500*a) / 5;
      int result = a*1000 + b*5;
      Console.Write(result);
  }
}

Measured memory_bytes: 13140
k, n=map(int,input().split())
a = list(map(int, input().split()))
s = sorted(a)
d = []
for x in range(n-1):
    d.append(s[x+1]-s[x])
d.append(k+s[0]-s[n-1])
print(sum(sorted(d)[:n-1]))

Measured memory_bytes: 26444
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

int get_int3(int *a1, int *a2, int *a3) {
  scanf("%d %d %d", a1, a2, a3);
  return 0;
}

int get_int4(int *a1, int *a2, int *a3, int *a4) {
  scanf("%d %d %d %d", a1, a2, a3, a4);
  return 0;
}

int get_int5(int *a1, int *a2, int *a3, int *a4, int *a5) {
  scanf("%d %d %d %d %d", a1, a2, a3, a4, a5);
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

char get_char(void) {
    char buf[3];
    scanf("%s", buf);
    return buf[0];
}

int get_str(char *str, int size)
{
    char format[100];
    if (size == 0)
        return 0;
    snprintf(format, sizeof(format), "%%%ds", size);
    scanf(format, str);
    return 0;
}

// sort
int asc(const void *a1, const void *a2) {
    int64_t aa1 = *(int64_t*)a1;
    int64_t aa2 = *(int64_t*)a2;
    if(aa1 > aa2) return 1;
    if(aa1 == aa2) return 0;
    return -1;
}

int main(void) {
  int n, m;
  get_int2(&n, &m);
  printf("%d\n", (n-1)*(m-1));
  return 0;
}


Measured memory_bytes: 128
d, n = map(int, input().split())

if d == 0:
    if n == 100:
        print(101)
    else:
        print(n)
elif d == 1:
    if n == 100:
        print(10100)
    else:
        print(n*100)
else:
    if n == 100:
        print(1010000)
    else:
        print(n*10000)


Measured memory_bytes: 61788
i = list(map(int, input().split()))
if 1 <= i[0] and i[0] <= 100:
    N = i[0]
else:
    print('N is invalid value.')
if 0 <= i[1] and i[1] <= 4111:
    R = i[1]
else:
    print('R is invalid value.')

if N < 10:
    rate = R + (100 * (10 - N))
else:
    rate = R

print(rate)

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

int main()
{
	string string;
	int sum=0;
	int i=0;
	
	while(1){
		getline(cin, string);
		if(string[0]=='0')
			break;
		
		while(string[i]!='\0'){
			sum+=(string[i]-'0');
			i++;
		}
		
		cout << sum << endl;
		
		i=0;
		sum=0;
	}
	return 0;
}

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

const int N = 2e5 + 100;
vector<int> g[N];
int ans = -1;
int st;

void dfs(int u, int p, int d) {
    if(ans < d) ans = d, st = u;
    for(int v : g[u]) {
        if(v != p) dfs(v, u, d + 1);
    }
}

int dp[N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1, -1, 0);
    ans = -1;
    dfs(st, -1, 0);
    dp[1] = 1;
    dp[2] = 0;
    for(int i = 3; i <= n; i++) {
        if(dp[i-1] && dp[i-2]) dp[i] = 0;
        else dp[i] = 1;
    }
    ans++;
    if(dp[ans]) {
        cout << "First";
    } else {
        cout << "Second";
    }
}


Measured memory_bytes: 21376
#include<bits/stdc++.h>
using namespace std;
#define For(n) for(int i=0;i<n;i++)
#define Forj(n) for(int j=0;j<n;j++)
#define pi 3.141592654
#define hell 1000000007
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define in1(n,c) c n;cin>>n
#define in2(a,b,c) c a,b;cin>>a>>b
#define ina(a,n,c) c a[n];rep(i,0,n)cin>>a[i]
#define ins(s) string s;cin>>s
#define mset(a,n) memset(a,n,sizeof a)
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define lbd lower_bound
#define ubd upper_bound
#define ll  long long
#define ull unsigned long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define piii pair<pair<int,int>,int>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
#define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define line cout<<endl

int main ()
{
in1(n,int);
ll a[n+1];
For(n+1)
cin>>a[i];
ll b[n+1];
For(n)
cin>>b[i];
b[n]=0;
ll ans=0;
For(n+1)
{
  if (a[i]>b[i]){

        ans+=b[i];}
  else{

    ans+=a[i];
   ans+=min((b[i]-a[i]),a[i+1]);
    a[i+1]-=(b[i]-a[i]);
   if (a[i+1]<0)
    a[i+1]=0;

  }
}
outl(ans);
}


Measured memory_bytes: 1792
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/28 06:06:21 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1000000007;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	int	n;
	cin >> n;

	vector<int>	V(n);
	stack<int>	S;
	rep(i, n)
		cin >> V.at(i);
	int	current_size;
	current_size = n;
	while (current_size)
	{
		int check;
		check = current_size;
		bool	flag;
		flag = false;
		rrep(i, n - 1)
		{
			if (V.at(i) == 0)
				continue;
			else if (V.at(i) == check)
			{
				S.push(V.at(i));
				V.at(i) = 0;
				current_size--;
				flag = true;
				break;
			}
			else
				check--;
		}
		if (flag == false)
		{
			cout << -1 << endl;
			return ;
		}
	}
	rep(i, n)
	{
		cout << S.top() << endl;
		S.pop();
	}
}
// END

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


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

ll n;

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

    printf("%lld\n", n * (n - 1) / 2);
    return 0;
}

Measured memory_bytes: 256
def make_cands(num, cands=[[0],[1]]):
    if len(cands[0]) == num:
        return cands
    else:
        newcands = []
        for cand in cands:
            newcands.append(cand+[0])
            newcands.append(cand+[1])
        return make_cands(num, newcands)

N,M = map(int, input().split())
switches = []
for _ in range(M):
    ks = list(map(int, input().split()))
    switches.append(ks[1:])
p = list(map(int, input().split()))
ans = 0
ress = make_cands(N)
for res in ress:
    tentou = 0
    for sw_i, sw in enumerate(switches):
        cnt = 0
        for num in sw:
            cnt += res[num-1]
        tentou += 1 if cnt % 2 == p[sw_i] else 0
    if tentou == M:
        ans += 1

print(ans)


Measured memory_bytes: 41456
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

set<int> s;
bool chek(int n){
  while(n>0){
    int k=n%10;
    if(s.count(k)) return 0;
    else n/=10;
  }
  return 1;
}

int main(){
  int n,k; cin>>n>>k;
  rep(i,k){
    int d; cin>>d;
    s.insert(d);
  }

  while(1){
    if(chek(n)){
      cout<<n<<endl;
      return 0;
    }else n++;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	ld r;
	cin >> r;
	ld v = acos(-1);
	r = 2 * r * v;
	cout << fixed << setprecision(10) << r;
}


Measured memory_bytes: 3804
n,m = map(int,input().split()) #要復習
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
 
for i in range(n-m+1):
    for j in range(n-m+1):
        a1 = [a[k][j:j+m] for k in range(i,i+m)]
        if a1 == b:
            print('Yes')
            exit()

print('No')

Measured memory_bytes: 3060
N, K, Q = map(int, input().split())
A_i = [int(input()) for i in range(Q)]

Ans_i = [0  for i in range(N)]

for i in range(Q):
    Ans_i[A_i[i] - 1] += 1

for i in range(N):
    if Ans_i[i] > Q - K:
        print("Yes")

    else:
        print("No")


Measured memory_bytes: 8608
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;

vector<int> vec[100010];
int d1[100010], d2[100010];

void dfs1(int ver, int dep) {
    if (d1[ver] == -1) {
        d1[ver] = dep;
    }
    else {
        return;
    }
    for (auto x : vec[ver]) {
        dfs1(x, dep + 1);
    }
}

void dfs2(int ver, int dep) {
    if (d2[ver] == -1) {
        d2[ver] = dep;
    }
    else {
        return;
    }
    for (auto x : vec[ver]) {
        dfs2(x, dep + 1);
    }
}

int main() {
    int n;
    int a, b;
    cin >> n;
    imfor(i, n - 1) {
        cin >> a >> b;
        a--;
        b--;
        vec[a].push_back(b);
        vec[b].push_back(a);
    }
    fill(d1, d1 + n, -1);
    fill(d2, d2 + n, -1);
    dfs1(0, 0);
    dfs2(n - 1, 0);
    int counter1 = 0;
    int counter2 = 0;
    imfor(i, n) {
        if (d1[i] <= d2[i]) {
            counter1++;
        }
        else {
            counter2++;
        }
    }
    if (counter1 > counter2) {
        cout << "Fennec" << endl;
    }
    else {
        cout << "Snuke" <<endl;
    }
}

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

struct segtree{
    int size;
    vector<int> dat;
    int init = 0;

    segtree (int N) {
        size = 1;
        while (size < N) size *= 2;
        dat = vector<int>(2*size-1, init);
    }

    int op(int a, int b) {
        return a+b;
    }

    void update(int i, int x) { 
        i += size-1;
        dat[i] += x;
        while (i > 0) {
            i = (i-1)/2;
            dat[i] = op(dat[2*i+1], dat[2*i+2]);
        }
        return;
    }

    int query(int a, int b) {
        return query(a, b, 0, 0, size);
    }
    

    int query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return init;
        if (a <= l && r <= b) return dat[k];
        int lv, rv;
        lv = query(a, b, 2*k+1, l, (l+r)/2);
        rv = query(a, b, 2*k+2, (l+r)/2, r);
        return op(lv, rv);
    }
};


int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    ll l = 0, r = 1e9+1;
    
    while (r-l > 1) {
        ll c = (l+r)/2;
        segtree st(N*2+1);
        int t = N;
        st.update(t, 1);
        ll psec = 0;
        for (int i = 0; i < N; i++) {
            if (a[i] < c) t--;
            else t++;
            psec += st.query(0, t+1);
            st.update(t, 1);
        }
        if (psec*2 >= (ll)N*(N+1)/2) l = c;
        else r = c;
    }
    
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 2812
#include <iostream>
#include<bits/stdc++.h>
#define input ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define dl endl
#define ft first
#define sc second
using namespace std;
int n, a[105],cnt=0;
int main()
{
	//freopen("", "r", stdin);
	//freopen("", "w", stdout);
	input;
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
		if (a[i] & 1 && i & 1) ++cnt;
	}
	cout << cnt;
}

Measured memory_bytes: 3568