akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false


signed main(void){
    int N,M,R;
    int a;
    vector<int> r,A,B,C;
    
    cin >> N >> M >> R;
    REP(i,R){cin >> a;a--;r.push_back(a);}
    REP(i,M){
        cin >> a;a--;
        A.push_back(a);
        cin >> a;a--;
        B.push_back(a);
        cin >> a;
        C.push_back(a);
    }
    sort(r.begin(),r.end());
    
    int dp[205][205];
    REP(i,205){
        REP(j,205){
            dp[i][j]=INF;
        }
        dp[i][i]=0;
    }
    
    REP(i,M){
        dp[A[i]][B[i]]=C[i];
        dp[B[i]][A[i]]=C[i];
    }
    
    REP(k,N){
        REP(i,N){
            REP(j,N){
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }
    
    int Ans=INF;
    do{
        int num =0;
        REP(i,R-1){
            num+=dp[r[i]][r[i+1]];
        }
        Ans=min(Ans,num);
        /*REP(i,R){
            cout << r[i] << " "; 
        }cout << "  ";
        cout << num << endl;*/
    }while(next_permutation(r.begin(),r.end()));
    
    cout << Ans << endl;
    return 0;
}



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

ll ans=0;
string s;

void dfs(vector<bool> &div,ll num,bool divide){
    if(num==s.size()-1){
        ll a=0,b=0;
        while(a!=num+1){
            if(div[a]){//+で分割するときの最後の桁
                ans+=(10*b+(ll)(s[a]-'0'));
                b=0;
            }else{//+で分割されていない部分
                b=10*b+(ll)(s[a]-'0');
            }
            a++;
        }
        return;
    }

    div[num]=divide;

    dfs(div,num+1,true);
    dfs(div,num+1,false);

    return;
}

int main(){
    cin>>s;

    vector<bool> div(s.size());
    div[s.size()-1]=true;//sentinel
    
    dfs(div,0,true);
    dfs(div,0,false);
    cout<<ans/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

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

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! test {
    ($($input:expr => $expected_output:expr),*) => {
        #[test]
        fn solve_test() {
            let mut i = 0;
            println!("");
            $(
                i += 1;
                println!("Case {}:", i);
                println!("[in]\n{}", $input);
                println!("[out]\n{}", solve($input));
                println!("[expected out]\n{}", $expected_output);
                println!("");
                assert_eq!(solve($input), $expected_output);
             )*
        }
    }
}

test! {
    "2019/04/30" => "Heisei",
    "2019/11/01" => "TBD"
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        S: String
    }

    let mut ans = "Heisei";
    if S.as_str() > "2019/04/30" {
        ans = "TBD"
    }

    return ans.to_string();
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void)
{
  int num;
  int x[10000];
  int min, max;
  int i;
  long sum=0;

  scanf("%d", &num);
  for(i=0;i<num;i++)
    {
      scanf("%d", &x[i]);
    }

  min = x[0];
  max = x[0];

  for(i=0;i<num;i++)
    {
      if(min > x[i])
	{
	  min = x[i];
	}
      if(max < x[i])
	{
	  max = x[i];
	}
      sum += (long)x[i];
    }

  printf("%d %d %ld\n", min, max, sum);

  return 0;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int i=0;i<(n);i++)        //repeat n times
#define REP2(i,s,n) for(int i=(s);i<(n);i++)   //repeat from s to n 
#define REPD(i,n) for(int i=(n);i>=0;i--)      //repeat from n to 0
#define REPD2(i,s,e) for(int i=(s);i>=(e);i--) //repeat from s to e
#define RANGE(i,v) for(auto &i:v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T1,typename T2> using P = pair< T1, T2 >;
using Pii = P<int,int>;
using Pll = P<LL,LL>;
using Pdd = P<double,double>;
using Psi = P<string,double>;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    int N;
    cin>>N;
    LL ans = 0;
    REP(i,N){
        LL Y = N/(i+1);
        ans += Y*(Y+1)*(i+1)/2;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include <string>
using namespace std;
int main()
{
	int bResult = 0;
	string strInput;
	cin >> strInput;

	int strLength = strInput.length();
	int halfLength = strLength / 2;

	for (int i = 0; i < halfLength - 1; i++) {
		if (strInput[i] == strInput[strLength - i - 1]) {
			//何もしない
		}
		else {
			//回文じゃない
			bResult = 1;
			break;
		}
	}
	//普通の回文だったら前半をサーチする
	if (bResult == 0) {
		for (int i = 0; i < halfLength - 1; i++) {
			if (strInput[i] == strInput[halfLength - i - 1]) {
				//何もしない
			}
			else {
				//回文じゃない
				bResult = 1;
				break;
			}
		}
	}
	//普通の回文だったら後半もサーチする
	if (bResult == 0) {
		for (int i = 0; i < halfLength - 1; i++) {
			if (strInput[halfLength + 1 + i] == strInput[strLength - i - 1]) {
				//何もしない
			}
			else {
				bResult = 1;
				break;
			}
		}
	}

	if (bResult == 1) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 3492
#include <stdio.h>

int n, m;
int a, b, c;
int i;
int sum, max;

int main(){

  scanf( "%d %d" , &n , &m );

  for( i = 0; i < m; i++ ){
    scanf( "%d %d" , &a , &b );
    c = n - a;
    if( c > 0 ){
      sum += c;
    }
    if( c > max ){
      max = c;
    }
  }

  printf( "%d\n" , sum - max );

  return 0;
}

Measured memory_bytes: 1752
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
typedef long long ll;

int a[110][110];

int main(){
  int n; cin >> n;
  rep(x, n){
    int i, m; cin >> i >> m;
    rep(y, m){
      int j; cin >> j;
      a[i][j] = 1;
    }
  }

  REP(i, 1, n){
    REP(j, 1, n){
      if(j != 1) cout << " ";
      cout << a[i][j];
    }
    cout << endl;
  }

  return 0;
}






Measured memory_bytes: 3132
#include<iostream>

int main(){
  int A,B,C,D;
  std::cin >> A >> B >> C >> D;
  if(B<=C) std::cout << 0 << std::endl;
  else if(A>=D) std::cout << 0 << std::endl;
  else if(B<=D && A<=C) std::cout << B-C << std::endl;
  else if(A<=C && B>=D) std::cout << D-C << std::endl;
  else if(C<=A && D>=B) std::cout << B-A << std::endl;
  else if(A>=C && B>=D) std::cout << D-A << std::endl;
  else std::cout << 0 << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{	
	int a, b,c;
	
	scanf("%d %d %d",&a, &b, &c);
	int t;
	if(a > b){
		t = a; a = b; b = t;
	}
	if(a > c){
		t = a; a = c; c = t; 
	}
	if(b > c){
		t = b; b = c; c = t; 
	}
	printf("%d %d %d\n",a, b, c);
	
} 
//時分秒(a<b<c 3 2 1      1 2 2


Measured memory_bytes: 2072
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

// lld fac[500005]; 

// void getfac(lld p)
// {
//     fac[0] = 1; 
//     for (lld i=1 ; i<=500005; i++) 
//         fac[i] = fac[i-1]*i%p; 
// }    

// long long int nCrmodp(lld n, lld r,lld p) 
// { 
//    // Base case 
//    if (r==0) 
//       return 1; 
     
//     return (fac[n]* modInverse(fac[r], p) % p * 
//             modInverse(fac[n-r], p) % p) % p; 
// }

// bool sorter(lld a, lld b)
// {
//     vector<lld> v2;
//     vector<lld> w;
//     // cout<<"A == " <<a<<"  B== "<<b;
//     while(a>=1)
//     {
//         v2.pb(a%10);
//         a/=10;
//     }
//     while(b>=1)
//     {
//         w.pb(b%10);
//         b/=10;
//     }   
       
//     reverse(all(v2));
//     reverse(all(w));
//     lld l1 = v2.size();
//     lld l2 = w.size();
//     lld  l = (l1*l2)/__gcd(l1,l2);
//     // cout<<l1<< " "<<l2<< " "<<l<< " ";
//     for(int i=0;i<l;i++)
//     {
//         if(v2[i%l1]!=w[i%l2])
//         {
//             // cout<< "   "<< (v2[i%l1] > w[i%l2])<<"\n";
//             return v2[i%l1] > w[i%l2];
//         }
//     }
//     // printf("false\n");
//     return false;
// }


lld p1=1e8 + 7,p2=998244353;
lld l,r,mid,ans;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;
lld ss=1;


void solve()
{
    cin>>x>>y>>z>>k;
    ans=0;
    while(y<=x)
    {
        ans+=1;
        y*=2;
    }
    while(z<=y)
    {
        ans+=1;
        z*=2;
    }
    // cout<<ans;
    if(ans>k) cout<<"No";
    else cout<<"Yes";
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    // cin>>t;
    // cout<<t;
     // getfac(p1);
    //check the value by which modulo is to be taken
    // lld ans=0;
    // precompute();
    for(int i=0;i<t;i++)
    {
        // cout<<"Case #"<<i+1<<": ";
        solve();
        cout<<"\n";
    }
    return 0;
}

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

int N , M ;
cin >> N >> M ;
  int K ;
  int J ;
  int count = 0 ;
  int ans = 0 ;
  map<int,int> score ;
  rep(i,M) score[1+i] = 0 ;
  //rep(i,M) cout << i+1 << " " << score[i+1] << endl;
  rep(i,N){
    while(count < N ){
      count++ ;
      cin >> K ;
      rep(i,K) {
        cin >> J ;
        //cout << J << endl ;
        score[J]++ ;
        //cout  << score[J] << endl;
				}
		}
  }
  //rep(i,M) cout << i+1 << " " << score[i+1] << endl;
rep(i,M){
  if( score[i+1] == N )ans++;
}
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>
using namespace std;
using ll = long long int;

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		if (x % 2 == 1) {
			cout << "first";
			return 0;
		}
	}
	cout << "second";
	return 0;
}

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

int main(){
    int a, b, c, d, e;
    cin >> a >> b;
    c = a + b;
    d = a - b;
    e = a * b;

    int max = c;
    if (max < d) max = d;
    if (max < e) max = e;

    cout << max << endl;

}

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

const int nMatch[10] = {0,2,5,5,4,5,6,3,7,6};

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

    vector<string> dp(N+1,"");
    for(int i=0; i<M; i++){
        int ii = nMatch[A[i]];
        if(ii > N) continue;
        if(dp[ii] == "" || dp[ii] < to_string(A[i])) 
            dp[ii] = to_string(A[i]);
    }

    for(int i=1; i<=N; i++){
        if(dp[i]=="") continue;
        for(int j=0; j<M; j++){
            int nxt = i + nMatch[A[j]];
            if(nxt > N) continue;
            if(dp[nxt] == "" || dp[nxt].length() < dp[i].length() + 1){
                dp[nxt] = dp[i] + to_string(A[j]);
                sort(dp[nxt].begin(), dp[nxt].end(), greater<char>());
            }else if(dp[nxt].length() == dp[i].length() + 1){
                string tmp = dp[i] + to_string(A[j]);
                sort(tmp.begin(), tmp.end(), greater<char>());
                if(dp[nxt] < tmp) dp[nxt] = tmp;
            }
        }
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 33024
#include <iostream>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)


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

  if (K > (N-1) * (N-2) / 2) {
    cout << "-1\n";
    return 0;
  }

  int k = (N-1) * (N-2) / 2 - K;

  cout << k + N-1 << endl;
  rep(i, N-1)
    cout << 1 << " " << i+2 << endl;

  if (k > 0)
    rep(i, N-1) {
      rep(j, i+1, N-1) {
        cout << i+2 << " " << j+2 << endl;
        --k;
        if (k == 0)
          return 0;
      }
    }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	int k,m,n;
	scanf("%lld",&n);
	int ans=1e18;
	for(register int i=1;i*i<=n;i++){
		if(n%i==0){
			ans=min(ans,i+n/i-2);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<cmath>
using namespace std;
char s[1007];
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n; cin >> n;
	int nn=sqrt(n+0.5);
	int ans=0;
	for(int i=1; i<=nn; i++) {
		if(i*i<n) ans++;
		for(int j=i+1; j*i<n; j++) {
			ans+=2;
		}
	}
	cout << ans << '\n';
}


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

int main(void){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    int mx = *max_element(all(a));
    int mid = *min_element(all(a));
    int diff = mx/2-mid;
    rep(i,n){
        if( diff > abs(mx/2-a[i])){
            diff = abs(mx/2-a[i]);
            mid = a[i];
        }
    }
    printf("%d %d\n",mx, mid);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#define ll long long
using namespace std;
const int N=200100;
string a,temp,last;
int ans;
int main()
{
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		temp+=a[i];
		if(last!=temp)
		{
			last=temp;
			temp.clear();
			++ans;
		}
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> d(n+1);
  for(int i=1; i<=n; i++) {
    for(int j=i; j<=n; j+=i) {
      d[j]++;
    }
  }
  ll ans = 0;
  for(int i=1; i<=n; i++) {
    ans += (ll)i*d[i];
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define pb push_back
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define fast_cin() ios_base::sync_with_stdio(0)


typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
typedef pair <int,int> pii;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

bool bit(int n, int i) { return (n >> i) & 1; }
int faltu;

const int mod    = 1e9+7;
const ll MAX     = 4e18;
const ll MIN     = -MAX;
const int imax   = 2e9 + 100;
const int offset = 8001;

bool flag;
bool dp[offset][offset * 2];
bool seen[offset][offset * 2];

bool solve(int i, int x, vector <int> &vec, int final_x)
{
	if(seen[i][x + offset]) {
		return dp[i][x + offset];
	}
	seen[i][x + offset] = true;
	if(i == vec.size()) {
		return dp[i][x + offset] = (x == final_x);
	} else {
		if(i == 0 and !flag) {
			return dp[i][x + offset] = solve(i + 1, x + vec[i], vec, final_x);
		} else {
			return dp[i][x + offset] = solve(i + 1, x + vec[i], vec, final_x)
							 or solve(i + 1, x - vec[i], vec, final_x);
		}
	}
}

int main()
{
	time_t t1, t2;
	t1 = clock();

	string s;
	int x, y;
	cin >> s >> x >> y;
	int ct = 0;
	int last = -1;
	vector <int> vec[2];
	int n = s.size();

	for(int i = 0; i < n; i++) {
		if(s[i] == 'T') {
			vec[ct % 2].pb(i - last - 1);
			last = i;
			ct ++;
		}
	}

	vec[ct % 2].pb(n - last - 1);
	map <pii, bool> mp;
	bool X = true;
	
	X = solve(0, 0, vec[0], x);
	memset(seen, false, sizeof(seen));
	mp.clear();
	flag = true;
	X = X and solve(0, 0, vec[1], y);

	if(X) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	t2 = clock();
	cerr << "time taken: " << t2 - t1 << endl;
	return 0;
}

Measured memory_bytes: 188928
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+100;
const int MAX = 1E6;

int n;
int a[N];
int G;
bool vis[N],flag;

int prime[N] = {0},num_prime = 0;      
bool isNotPrime[N] = {1, 1};
int sieve(int n)
{
	for(int i = 2 ; i < n ; i ++)         
    {              
    if(! isNotPrime[i])            
        prime[num_prime ++]=i;
	for(int j = 0 ; j < num_prime && i * prime[j]<  N ; j ++)  
        {                 
        	isNotPrime[i * prime[j]] = 1;
            if( !(i % prime[j] ) )  
	            break;             
        }          
    }    
    
    return num_prime;
}
//vector<pair<int,int> > res;
void prime_divide(int x)
{
	if(!flag)	return ;
	for(int i=0;i<num_prime;i++)
	{
		int nowprime = prime[i];
		if(nowprime*nowprime > x)	break;
		if(x%nowprime)	continue;
		//res.emplace_back(nowprime,0);
	//	do
		//{
		//	res.back().second++;
		//}while((x /= nowprime)%nowprime == 0);
		if(vis[nowprime] == true)
		{
			flag = false;
			break;
		}
		vis[nowprime] = true;
		while((x /= nowprime)%nowprime == 0);
	}
	if(!flag)	return ;
	if(x!=1)	
	{
		if(vis[x] == true)
			flag = false;
		else vis[x] = true;
	}
	return ;
	//if(x!=1)	res.emplace_back(x,1);
	
 } 


int main()
{
	scanf("%d",&n);
	sieve(MAX);
	memset(vis,false,sizeof(vis));
	flag = true;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(i==1)	G = a[i];
		else	G = __gcd(G,a[i]);
		prime_divide(a[i]);
	}	
	if(G!=1)
	{
		printf("not coprime\n");
		return 0;
	}
	if(flag)	printf("pairwise coprime\n");
	else printf("setwise coprime\n");
	
	
	return 0;
}

Measured memory_bytes: 9820
//
//AtCoder Beginner Contest 129
//B - Balance
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<int> w(n);
    vector<int> ws(n+1, 0);
    int sum = 0;
    REP(i, n) {
        cin >> w[i];
        sum+=w[i];
        ws[i+1]=sum;
    }

    int ans = 999999;
    REP(i, n){
        int s1 = ws[i+1] - ws[0];
        int s2 = ws[n] - ws[i+1];
        //cout << s1 << " " << s2 << endl;
        ans = min(ans, abs(s1-s2));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main() {
    int n;
    cin >> n;
    ll dic[n][3];
    for (int i = 0; i < n; i++) {
        cin >> dic[i][0] >> dic[i][1] >> dic[i][2];
    }
    ll dp[n][3];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            dp[i][j] = 0;
        }
    }
    dp[0][0] = dic[0][0];
    dp[0][1] = dic[0][1];
    dp[0][2] = dic[0][2];
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j != k) {
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + dic[i][j]);
                }
            }
        }
    }
    OUT(max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}));
}


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

#define gc( ) std::getchar( )
#define pc( i ) std::putchar( i )
#define space ' '
#define enter '\n'
#define RE cout << "Passing [" << __FUNCTION__ << "] on " << __LINE__ << enter
#define DEBUG(...) for( auto &i: __VA_ARGS__ ) cout << i << " "; cout << enter
using std::make_pair;

template < typename T >
inline T read( )
{
 T x = 0;
 char ch = gc( );
 bool f = 0;
 while( !std::isdigit( ch ) )
 {
  f = ( ch == '-' );
  ch = gc( );
 }
 while( std::isdigit( ch ) )
 {
  x = x * 10 + ( ch - '0' );
  ch = gc( );
 }
 return f ? -x : x;
}

template < typename T >
void print( T x )
{
 if( x < 0 )
 {
  x = -x;
  pc( '-' );
 }
 if( x < 10 )
 {
  pc( x + 48 );
  return;
 }
 print < T > ( x / 10 );
 pc( x % 10 + 48 );
 return ;
}

namespace Solution
{
#define IOS std::ios::sync_with_stdio( false ), std::cin.tie( 0 ), std::cout.tie( 0 )
#define Rep( i, j, k ) for( int i = j; i >= k; --i )
#define rdi( ) read < int > ( )
#define rdl( ) read < long long > ( )
#define pti( i ) print < int > ( i ), putchar( space )
#define ptl( i ) print < long long > ( i ), putchar( space )
#define For( i, j, k ) for( int i = j; i <= k; ++i )
 using std::cin;
 using std::cout;
 using std::endl;
 using std::vector;
 using std::map;
 using std::queue;
 using std::deque;
 using std::set;
 using std::pair;
 const int N = 1000001, mod = 1e9 + 7;
 long long n, ans[ N ], ans1, fac[ N ], inv[ N ];
 long long ksm( long long x, long long I )
 {
  long long res = 1;
  for( ; I; I >>= 1, x = x * x % mod ) if( I & 1 )
   res = res * x % mod; 
  return res;
 }
 long long C( long long x, long long y )
 {
  return fac[ x ] * inv[ y ] % mod * inv[ x - y ] % mod;
 }
 void Fakemain( )
 {
  cin >> n;
  if( n == 1 )
  {
   cout << 0;
   return;
  }
  else
  {
   ans[ 0 ] = 1, ans1 = 1;
   for( int i = 1; i <= n; ++i )
    ans[ i ] = ans[ i - 1 ] * 8 % mod,
    ans1 = ans1 * 10 % mod;
   fac[ 0 ] = 1;
   for( int i = 1; i <= n; ++i )
    fac[ i ] = i * fac[ i - 1 ] % mod;
   inv[ n ] = ksm( fac[ n ], mod - 2 );
   for( int i = n - 1; ~i; --i )
    inv[ i ] = inv[ i + 1 ] * ( i + 1 ) % mod;
   ans1 = ( ans1 - ans[ n ] + mod ) % mod;
   for( int i = 1; i <= n; ++i )
   {
    ans1 = ( ans1 - 2 * C( n, i ) % mod * ans[ n - i ] % mod + mod ) % mod; 
   }
   cout << ans1;
  }
  return;
 }

} // namespace Solution

int main( int argc, char* argv[] )
{
 Solution::Fakemain( );
 return 0;
}

Measured memory_bytes: 26956
import re


def ok(last4):
    pattern = '.?AGC.?|.?GAC.?|.?ACG.?|A.GC|AG.C'
    res = re.match(pattern, last4)
    return res is None


def dfs(cur, last3, n, m, mod):
    if last3 in m[cur]:
        return m[cur][last3]
    if cur == n:
        return 1
    ret = 0
    for c in 'ACGT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c, n, m, mod)) % mod

    m[cur][last3] = ret
    return ret


def main():
    n = int(input())
    mod = 10 ** 9 + 7

    m = [{} for _ in range(n + 1)]
    ans = dfs(0, 'TTT', n, m, mod)

    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
  int N;
  cin >> N;
  bool flag = false;
  for(int i=1;i<10;i++){
    if(N%i==0 && N/i < 10){
      flag = true;
      break;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] h = new int[N + K + 1];
        for (int i = 0; i < N; i++) {
            h[i] = sc.nextInt();
        }

        int[] dp = new int[N + K + 1];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for (int i = 0; i < N; i++) {
            for (int j = 1; j <= K; j++) {
                dp[i + j] = Math.min(dp[i + j],  dp[i] + Math.abs(h[i + j] - h[i]));
            }
        }

        System.out.println(dp[N - 1]);
    }
}


Measured memory_bytes: 50236
N=int(input())
A=[]
B=[]
for i in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
A=sorted(A)
B=sorted(B)
if N%2==0:
  m=A[N//2]+A[N//2-1]
  M=B[N//2]+B[N//2-1]
  print(M-m+1)
else:
  m=A[N//2]
  M=B[N//2]
  print(M-m+1)

Measured memory_bytes: 26952
from collections import defaultdict
def solve():
	Base = 2000
	MAX = Base*2
	p = 10**9+7
	F = [1]; Finv = [0]*(MAX*2+1)
	for i in xrange(MAX*2): F.append(F[i]*(i+1)%p)
	Finv[MAX] = pow(F[MAX],p-2,p)
	for i in xrange(MAX,0,-1): Finv[i-1] = Finv[i]*i%p
	N = int(raw_input())
	dup = A_MAX = B_MAX = 0
	dp = [[0]*(MAX+2) for i in xrange(MAX+2)]
	goals = defaultdict(int)
	for i in xrange(N):
		A,B = map(int,raw_input().split())
		dup = (dup + F[A*2+B*2]*Finv[A*2]*Finv[B*2])%p
		if A > A_MAX: A_MAX = A
		if B > B_MAX: B_MAX = B
		goals[(Base+A,Base+B)] += 1
		dp[Base-B][Base-A] += 1
	for j in xrange(Base-B_MAX,Base+B_MAX+1):
		for i in xrange(Base-A_MAX,Base+A_MAX+1):
			dp[j+1][i] = (dp[j+1][i] + dp[j][i]) % p
			dp[j][i+1] = (dp[j][i+1] + dp[j][i]) % p
	ans = 0
	for (i,j),v in goals.iteritems():
		ans = (ans + dp[j][i]*v) % p
	print ((ans - dup)*pow(2,p-2,p)+p) % p
solve()

Measured memory_bytes: 189084
l = []
for i in range(5):
  l.append(input())

ans = 0
min_val = 99
flag = False

for i in range(5):
  if l[i][-1] == "0":
    ans += int(l[i])
  else:
    if int(l[i][-1]) <= int(str(min_val)[-1]):
      if flag:
        ans += (-(-int(min_val)//10))*10
      flag = True
      min_val = l[i]
    else:
      ans += (-(-int(l[i])//10))*10
if flag:
  ans += int(min_val)
print(ans)



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

using namespace std;

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

    unsigned long long n, a, b;

    cin >> n >> a >> b;

    if(a > b)
        swap(a,b);

    if((b - a) % 2 == 0)
    cout << (b - a) / 2;
    else
    {
        unsigned long long st = a - 1;
        unsigned long long dr = n - b;

        unsigned long long a1 = a + dr;
        unsigned long long b1 = b - st;


        long long rez = 0;
        rez++;
        rez += min((n - 1 - a1) / 2 + dr,(b1 - 2) / 2 + st);

        cout << rez;

    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	char a;
	cin>>a;
	if('a' <= a && a <= 'z'){cout<<'a'<<endl;}
	else {cout<<'A'<<endl;}
	return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>

int main()

{
   int i,j,tc,a[100000],cnt=0,z;

   scanf("%d",&tc);

   for(i=0;i<tc;i++)
   {
      scanf("%d",&a[i]);
   }

   for(j=1,z=0;j<=tc;j++,z++)
   {
      if(j!=a[z])
      {
         cnt++;
      }
   }

   if(cnt<=2)
   {
      printf("YES\n");
   }

   else
   {
      printf("NO\n");
   }
}


Measured memory_bytes: 3140
/* ex9_2
   key_tree */

#include <stdio.h>
#include <stdlib.h>
#define SIZE 100001

//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}

int main(void){
    int count = 0, i;
    char input_str[SIZE];
    scanf("%s", input_str);
    //最初のノードはNULLを指す
    node *first = NULL;
    
    for(i = 0; input_str[i] != '\0'; i++){
        //nullのとき、または一個前の要素と一致するときはスタックに追加
        if(first == NULL || input_str[i] == first -> elem){
            push(&first, input_str[i]);
        }
        //それ以外（一個前と要素が違う）のとき、取り出してカウントを2進める
        else{
            pop(&first);
            count += 2;
        }
    }

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

}


Measured memory_bytes: 4844
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    i64 n, x;
    cin >> n >> x;
    vector<i64> a(n);
    for(auto& x : a) cin >> x;
    i64 ans = 0LL;
    i64 before = a[0];
    for(int i : in(1, n)) {
        i64& cur = a[i];
        if(before + cur >= x) {
            i64 diff = (before + cur) - x;
            ans += diff;
            cur = max(0LL, cur - diff);
        }
        before = cur;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T>
class UnionFind {
public:

	vector<T> Parent;
 
	UnionFind(T N) {
		Parent = vector<T>(N, -1);
	}
 
	T root(T A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	T size(T A) {
		return -Parent[root(A)];
	}
 
	bool connect(T A, T B) {
		A = root(A);
		B = root(B);
		if (A == B) {
			return false;
		}
		if (size(A) < size(B)) swap(A, B);
		Parent[A] += Parent[B];
		Parent[B] = A;
 
		return true;
	}

    bool same(T A,T B){
        return root(A)==root(B);
    }
};

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int n,m,k;cin>>n>>m>>k;
  V<int> fri(n),blo(n,0);
  
  UnionFind<int> u(n);
  rep(i,0,m){
    int a,b;cin>>a>>b;
    a--;b--;
    u.connect(a,b);
    fri[a]++;
    fri[b]++;
  }
  rep(i,0,k){
    int c,d;cin>>c>>d;
    c--;d--;
    if(u.same(c,d)){
      blo[c]++;
      blo[d]++;
    }
  }

  rep(i,0,n){
    cout<<u.size(i)-1-fri[i]-blo[i]<<" ";
  }cout<<ENDL;

}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define END << endl;
#define SP << " " << 
using namespace std;

int main(){
	int N,M;
	int a[1000];
	int b[1000];
	int c[1000];
	cin >> N >> M;
	REP(i,1000)c[i] = 0;
	REP(i, N)cin >> a[i];
	REP(i,M)cin >> b[i];
	REP(i,M){
		int t = -1;
		for(int j = 0; a[j] >  b[i]; j++)t = j;
		t++;
		c[t]++;
	}
	int m = 0;
	REP(i,M)m = max(m,c[i]);
	REP(i,M)if(m == c[i]){
		cout<< i+1 END
		break;
	}
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}

int main(){
	int n;
	cin>>n;
	vi a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;;i++){
		auto s=to_string(i);
		bool B=1;
		int m=s.size();
		for(int j=0;j<n;j++){
			string t;
			for(int k=0;k<m;k++) if(j+k<n) t+=(char)('0'+a[j+k]);
			if(s==t) B=0;
		}
		if(B){
			cout<<i<<endl;
			break;
		}
	}
}


Measured memory_bytes: 3292
n = int(input())
cards = input().split()
cards_s, cards_b = cards[:], cards[:]
flag_s, flag_b = False, False
for i in range(n):
    # for Selection Sort
    mini = i
    for j in range(i, n):
        if cards_s[j][1] < cards_s[mini][1]:
            mini = j
    if mini != i:
        cards_s[i], cards_s[mini] = cards_s[mini], cards_s[i]
    # for Bubble Sort    
    for j in range(n-1, i, -1):
        if cards_b[j][1] < cards_b[j-1][1]:
            cards_b[j], cards_b[j-1] = cards_b[j-1], cards_b[j]
for i in range(n-1):
    for j in range(i+1,n):
        # for Selection Sort
        if cards_s[i][1] == cards_s[j][1]:
            flag_s = flag_s or (cards.index(cards_s[i]) > cards.index(cards_s[j]))
        # for Bubble Sort     
        if cards_b[i][1] == cards_b[j][1]:
            flag_b = flag_b or (cards.index(cards_b[i]) > cards.index(cards_b[j]))
# for Bubble Sort 
for i in range(n-1):
    print(cards_b[i], end = ' ')
print(cards_b[n-1])
if flag_b:
    print('Not stable')
else:
    print('Stable')
# for Selection Sort
for i in range(n-1):
    print(cards_s[i], end = ' ')
print(cards_s[n-1])
if flag_s:
    print('Not stable')
else:
    print('Stable')


Measured memory_bytes: 5612
#include <stdio.h>
int min(int x,int y)
{
    if (x<y) return(x); else return(y);
}
int max(int x,int y)
{
    if (x<y) return(y); else return(x);
}
int main()
{
 int a,b,k,i;
    scanf("%d%d%d",&a,&b,&k);
    for (i=a;i<=min(b,a+k-1);i++)
    printf("%d\n",i);
    for (i=max(a+k,b-k+1);i<=b;i++)
        printf("%d\n",i);
    return(0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define MAX_V 2001
int d[MAX_V][MAX_V];
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n,x,y;
cin>>n>>x>>y;
vector<vector<ll>> g(n);
int dist[n];
rep(i,n-1){
    g[i].pb(i+1);
    g[i+1].pb(i);
}

g[x-1].pb(y-1);
g[y-1].pb(x-1);

map<ll,ll> cnt;

queue<ll> q;
rep(i,n-1){
    memset(dist,-1,sizeof(dist));
    dist[i]=0;
    q.push(i);
    while(!q.empty()){
        auto v =q.front();
        q.pop();
        rep(j,g[v].size()){
            int nv=g[v][j];
            if(dist[nv]>=0)continue;
            dist[nv]=dist[v]+1;
            q.push(nv); 
        }
    }
    reps(k,n,i+1){
        cnt[dist[k]]++;
    }
}

// rep(i,MAX_V){
//     rep(j,MAX_V)d[i][j]=1000000;
// }

// rep(i,n-1){
//     d[i][i+1]=1;
//     d[i+1][i]=1;
//     d[i][i]=0;
// }
// d[n-1][n-1]=0;
// d[x-1][y-1]=1;
// d[y-1][x-1]=1;

// rep(k,n){
//     rep(i,n){
//         rep(j,n){
//             d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//         }
//     }
// }

ll ans=0;
reps(k,n,1){
    if(cnt.count(k)){
        cout<<cnt[k]<<endl;
    }
    else{
        cout<<0<<endl;
    }
}
//system("pause");
return 0;
}

Measured memory_bytes: 512
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

bool isPrime(int n) {
  if (n < 2) return false;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) return false;
  }
  return true;
}

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

  int n; cin >> n;
  set<int> s;
  for (int i = 0; i < n; ++i) {
    int x; cin >> x; s.insert(x);
  }

  int cnt = 0;

  for (auto element : s) {
    cnt += isPrime(element);
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

#define B       (cout << "Sehen Sie mich!" << endl)
#define VB(val) (cout << val << endl)

int main()
{
        int s, count = 0;
        char str[4];
        cin >> s;
        sprintf(str, "%d", s);
        for (int i = 0; i < 3; i++)
                if (str[i] == '1')
                        count++;
        VB(count);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+100;
vector<int> g[N];
int d[N],mx[N],fa[N],n,a,t;

void dfs1(int u,int f){
    fa[u]=f; mx[u]=d[u]=d[f]+1;
    for(auto v:g[u]){
        if(v==f) continue;
        dfs1(v,u); mx[u]=max(mx[u],mx[v]);
    }
}

int ans=0;
int main(){
    scanf("%d %d %d",&n,&t,&a);
    for(int i=1,u,v;i<n;++i){
        scanf("%d %d",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs1(a,a);
    int k=d[t]/2-1;
    if(d[t]%2==1) ans=1;
    while(k--){
        ans++; t=fa[t];
    }
    //printf("%d %d %d\n",t,mx[t],d[t]);
    ans+=mx[t]-d[t];
    printf("%d\n",ans);
}

Measured memory_bytes: 12032
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,c,n) for(int i=c;i<n;i++)

int main() {
  long long int n;
  cin>>n;

  vector<long long int> a(200001,0);
  
  rep(i,1,n){
    long long int tmp;
    cin>>tmp;
    a[tmp-1]++;;
  }

  rep(i,0,n){cout<<a[i]<<endl;}
  
  return 0;
}


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

using namespace std;

const int maxn = (int)3e5 + 7;

pair <int, int> apple[maxn];
int cnt[3];

int main()
{
//    freopen("TEST.INP", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    int n = a + b + c;
    for (int i = 1; i <= a; ++i)
        cin >> apple[i].first, apple[i].second = 1;
    for (int i = a + 1; i <= a + b; ++i)
        cin >> apple[i].first, apple[i].second = 2;
    for (int i = a + b + 1; i <= n; ++i)
        cin >> apple[i].first, apple[i].second = 0;
    sort(apple + 1, apple + n + 1, greater <pair <int, int> > ());
    for (int i = 1; i <= x + y; ++i) ++cnt[apple[i].second];
    if (cnt[1] <= x && cnt[2] <= y)
    {
        long long ans = 0LL;
        for (int i = 1; i <= x + y; ++i)
            ans += 1LL * apple[i].first;
        cout << ans;
        return 0;
    }
    else
    {
        long long ans = 0LL;
        if (cnt[1] > x)
        {
            for (int i = 1; i <= n && x; ++i)
                if (apple[i].second == 1)
                    ans += 1LL * apple[i].first, --x;
            for (int i = 1; i <= n && y; ++i)
                if (apple[i].second != 1)
                    ans += 1LL * apple[i].first, --y;
            cout << ans;
            return 0;
        }
        else
        {
            for (int i = 1; i <= n && y; ++i)
                if (apple[i].second == 2)
                    ans += 1LL * apple[i].first, --y;
            for (int i = 1; i <= n && x; ++i)
                if (apple[i].second != 2)
                    ans += 1LL * apple[i].first, --x;
            cout << ans;
            return 0;
        }
    }
    return 0;
}


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

using ll = long long;
using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int lb = 0;
    int ub = n;
    while (ub - lb > 1) {
        int mid = (lb + ub) / 2;
        bool possible = false;
        for (int i = 0; i < n - mid; i++) {
            string t = s.substr(i, mid);
            string rest = s.substr(i + mid, n - mid - i);
            if (rest.find(t) != string::npos) {
                possible = true;
                break;
            }
        }
        if (possible)
            lb = mid;
        else
            ub = mid;
    }
    cout << lb << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector< vector<int> > VVI;
typedef vector< vector<int> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair

int main(){
  int N;
  string S,T;
  cin>>N>>S>>T;
  int M=3;
  ll ans=6;
  ll mod=1e9+7;
  if(S[0]==T[0]){
    M=1;
    ans=3;
  }
  rep(i,N){
    if(i){
      if(M==1){
        ans=ans*2%mod;
        if(S[i]!=T[i]) M=3;
      }else if(M==2){
        if(S[i]!=T[i]){
          ans=ans*3%mod;
          M=3;
        }else M=1;
      }else M=2;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = true;
}  // namespace mydef
using namespace mydef;
#define pb push_back
//#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N, P, cnt[5];

void solve() {
}

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

    cin >> N >> P;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        cnt[a % 2]++;
    }

    cout << (1ll << cnt[0]) * ((P == 0 && cnt[1] == 0) ? 1 : (1ll << cnt[1]) / 2) << endl;

    solve();
    return 0;
}


Measured memory_bytes: 3564