akhauriyash/Code-Regression huggingface dataset:
<?php
function p2($p){
	if($p==2)
	{
		return true;
	}
	if($p<2||$p%2==0)
	{
		return false;
	}	
	$i=3;
	while($i<=sqrt($p))
	{
		if($p%$i==0){
			return false;
		}
		$i+=2;
	}
	return true;
}
$sum=0;
$n=trim(fgets(STDIN));
for($i=0;$i<$n;$i++){
	$a=trim(fgets(STDIN));
	if(p2($a)==true)$sum++;
}	
print $sum."\n";

Measured memory_bytes: 6604
#include <stdio.h>

int main(int argc , char *argv[]){
    int n,q;
    int i,j;
    int N[100000];
    int Q[500000];
    int count=0;
    int right,left,mid;
    int key;
    
    /* scan N[] */
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d",&N[i]);
    }
    /* -------- */
    
    /* scan Q[] */
    scanf("%d",&q);
    
    for(i=0;i<q;i++){
        scanf("%d",&Q[i]);
    }
    /* --------- */

   
    for(i=0;i<q;i++) {
        key=Q[i];
        left=0;
        right=n;
    
            while(left < right){
                mid = (right+left)/2;
                if(key == N[mid]){count++;break;}
                if(key > N[mid])left=mid+1;
                else if(key<N[mid])right=mid;
                    }
        
        }
        printf("%d\n",count);
        return 0;
}

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

int main() {
    int H, W;
    cin >>H >> W;
    char map[H][W];
    for (int i=0; i<H; i++)
        for (int j=0; j<W;j++) cin >> map[i][j];
    char d[H][W];
    int s=0;
    for (int i=0; i<H; i++){
        bool t=true;
        for (int j=0; j<W;j++){
            if (map[i][j]=='#') t=false;
        }
        if (!t){
            for (int j=0; j<W;j++){
                d[s][j]=map[i][j];
            }
            s++;
        }
    }
    char e[H][W];
    int u=0;
    for (int i=0; i<W; i++){
        bool t=true;
        for (int j=0; j<s;j++){
            if (d[j][i]=='#') t=false;
        }
        if (!t){
            for (int j=0; j<s;j++){
                e[j][u]=d[j][i];
            }
            u++;
        }
    }
    for (int i=0; i<s; i++){
        for (int j=0; j<u; j++){
            printf("%c", e[i][j]);
            if (j==u-1) printf("\n");
        }
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;

struct CHT{
	using D = ll;
	typedef pair<D,D> P;
	vector<P> deq;
	int s,sd,t;
	void init(int N){
		deq.resize(N);
		s=0,sd=0,t=0;
	}
	void add(D a,D b){		//add ax+b     a:(広義)単調減少!!!
		b=-b;
		P p(a,b);
		while(s+1<t&&check(deq[t-2],deq[t-1],p)) t--;
		deq[t++]=p;
	}
	D incr_query(D x){		//x:単調増加の時,これを繰り返し呼ぶ(間にaddが挟まるのはOK)
		x=-x;
		while(s+1<t&&f(deq[s],x)>=f(deq[s+1],x)) s++;
		return -f(deq[s],x);
	}
	D decr_query(D x){		//x:単調減少の時,これを繰り返し呼ぶ(間にaddが挟まるのはOK)
		x=-x;
		if(sd>=t) sd=t-1;
		while(sd+1<t&&f(deq[sd],x)>=f(deq[sd+1],x)) sd++;
		while(sd>0&&f(deq[sd],x)>f(deq[sd-1],x)) sd--;
		return -f(deq[sd],x);
	}
	D query(D x){
		x=-x;
		int lb=s-1,ub=t-1;
		while(ub-lb>1){
			int m=(lb+ub)/2;
			if(isright(deq[m],deq[m+1],x)) lb=m;
			else ub=m;
		}
		return -f(deq[ub],x);
	}

	bool isright(P& a,P& b,D x){
		return f(a,x)>=f(b,x);
	}
	bool check(P& a,P& b,P& c){
		return (b.fs-a.fs)*(c.sc-b.sc)>=(b.sc-a.sc)*(c.fs-b.fs);
	}
	D f(P &p,int x){
		return p.fs*x+p.sc;
	}
}cht;

ll inf=1e18;
const int MN=300000;
int N;
ll T[MN];

ll le[MN+1],ri[MN+1];

ll notuse[MN];
ll use[MN];

void calc(int L,int R){
	if(L==R) return;
	int m=(L+R)/2;
	
	//L<=j<=m<=p<i<=R
	cht.init(m-L+1);
	for(ll j=L;j<=m;j++) cht.add(-j,le[j]+(j*j-j)/2);
	ll mx=-inf;
	for(ll i=R;i>=m+1;i--){
		ll val=cht.incr_query(i)+(i*i+i)/2+ri[N-i];
		chmax(mx,val);
		chmax(use[i-1],mx);
	}

	//L<=j<=p<m<i<=R
	cht.init(R-m);
	for(ll i=m+1;i<=R;i++) cht.add(-i,ri[N-i]+(i*i+i)/2);
	mx=-inf;
	for(ll j=L;j<m;j++){
		ll val=cht.decr_query(j)+(j*j-j)/2+le[j];
		chmax(mx,val);
		chmax(use[j],mx);
	}

	calc(L,m);
	calc(m+1,R);
}
int main(){
	cin>>N;
	rep(i,N) cin>>T[i];

	cht.init(N);
	le[0]=0;
	for(ll i=0;i<N;i++){
		cht.add(-i,le[i]+(i*i-i)/2);
		le[i+1]=max(le[i]+T[i],cht.decr_query(i+1)+(i+1)*(i+2)/2);
	}
	cht.init(N);
	ri[0]=0;
	for(ll i=0;i<N;i++){
		cht.add(-i,ri[i]+(i*i-i)/2);
		ri[i+1]=max(ri[i]+T[N-1-i],cht.decr_query(i+1)+(i+1)*(i+2)/2);
	}
	
	rep(i,N) notuse[i]=le[i]+T[i]+ri[N-1-i];

	ll sum=0;
	rep(i,N) sum+=T[i];

	calc(0,N);

//	rep(i,N) printf("use[%d]=%lld\n",i,use[i]);
//	rep(i,N) printf("notuse[%d]=%lld\n",i,notuse[i]);
	

	int M;
	cin>>M;
	rep(i,M){
		int p;
		ll x;
		cin>>p>>x;
		p--;
		ll ans=max(use[p],notuse[p]-T[p]+x);
		cout<<ans-(sum-T[p]+x)<<endl;
	}
}


Measured memory_bytes: 19072
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.size();i+=2){
        cout << s[i];
    }
    cout<<endl;
}

Measured memory_bytes: 512
using System;

class B
{
	static void Main()
	{
		var s = Console.ReadLine().Replace("BC", "X");

		var r = 0L;
		for (int t = -1, i = 0; i < s.Length; i++)
		{
			if (t != -1)
			{
				if (s[i] == 'X') r += i - t++;
				else if (s[i] != 'A') t = -1;
			}
			else if (s[i] == 'A') t = i;
		}
		Console.WriteLine(r);
	}
}


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

typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < n; i++)

int main()
{
    int n;
    int v[n+100];
    int c[n+100];
    cin >> n;
    REP(i,n){
        cin >> v[i];
    }
    REP(i,n){
        cin >> c[i];
    }
    int ans = 0;
    REP(i, n)
    {
        if (v[i] - c[i] > 0)
        {
            ans += v[i] - c[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  rep(i,n-1){
    if (a[i] == a[i + 1]) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}

Measured memory_bytes: 4748
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
   	int n=read(),m=read();
   	pr2(n*(n-1)/2+m*(m-1)/2);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N,x;
    cin>>N>>x;
    vector<int> a(N);
    REP(i,N) cin>>a[i];
    Sort(a);
    int ans = 0;
    int stock = x;
    for(int i=0; i<N-1; i++){
        if(stock>=a[i]){
            stock -= a[i];
            ans++;
        }
    }
  if(stock==a[N-1]) ans++;
    cout<<ans<<endl;
}

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

using ll = long long;

int main() {
	int n;
	cin >> n;
	ll ans = 0;
	while(n--) {
		ll x;
		cin >> x;
		while(!(x & 1)) {
			x /= 2;
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=1e5+5;
#define ll long long
#define inf 0x3f3f3f3f
#define mem(x) memset(x,0,sizeof(x))
#define sca(x) scanf("%d",&x)
#define scall(x) scanf("%lld",&x)
#define eps 1e-6
int vis[1000005];
int a[200005];
int num[1000005];
int main()
{
	int n;sca(n);
	mem(num);
	for(int i=1;i<=n;i++)
	{
		sca(a[i]);
		num[a[i]]++;
	}
	sort(a+1,a+n+1);
	mem(vis);
	for(int i=1;i<=n;i++)
	{
		if(vis[a[i]])
		continue;
		if(num[a[i]]>1)
		vis[a[i]]=1;
		for(int j=a[i]*2;j<=a[n];j+=a[i])
		vis[j]=1;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(vis[a[i]]==0)
		ans++;
	}
	
	printf("%d\n",ans);
}

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

 
int main()
{
 int n;
 cin>>n;
  string a="AC";int a1=0;
  string b="WA";int b1=0;
  string c="TLE";int c1=0;
  string d="RE";int d1=0;
  for(int i=0;i<n;i++)
  {
       string s;cin>>s;
       if(s==a)a1++;
       if(s==b)b1++;
       if(s==c)c1++;
       if(s==d)d1++;
  }
  cout<<a<<" x "<<a1<<endl;
  cout<<b<<" x "<<b1<<endl;
  cout<<c<<" x "<<c1<<endl;
  cout<<d<<" x "<<d1<<endl;
 return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, X, Y, A[2000];
ll dp[2][2000];

ll dfs(ll p, ll x, ll y, ll t) {
  if(p == N) return abs(x - y);
  if(dp[t][p] >= 0) return dp[t][p];

  vector<ll> vec;
  REP(i, p, N) {
    ll nx = t == 0 ? A[i] : x;
    ll ny = t == 1 ? A[i] : y;
    vec.push_back(dfs(i + 1, nx, ny, 1 - t));
  }

  return dp[t][p] = (t == 0 ? *max_element(vec.begin(), vec.end()) : *min_element(vec.begin(), vec.end()));
}

int main(void) {
  cin >> N >> X >> Y;
  REP(i, 0, N) cin >> A[i];

  REP(i, 0, N) dp[0][i] = dp[1][i] = -1;
  cout << dfs(0, X, Y, 0) << endl;
}


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

int main(){
	using namespace std;
// 	ios_base::sync_with_stdio(false); 
//     cin.tie(NULL); 

// #ifndef ONLINE_JUDGE 
//     freopen("inputf.in", "r", stdin); 
//     freopen("outputf.in", "w", stdout); 
// #endif

	int n, k;
	cin >> n;
	cin >> k;

	int a[n], d[n];


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

	for(int i = 1; i < n; i++) {
		int s  = (i - k < 0 ? 0 : i - k);
		d[i] = abs(a[i] - a[s]) + d[s];
		for(int j = s; j < i; j++) {
			d[i] = min(d[i], abs(a[i] - a[j]) + d[j]);
		}
	}

	cout << d[n - 1];
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから

void solve(){
  string s;
  cin>>s;
  bool flag=false;
  string y=s.substr(0,4);
  if(y>"2019")flag=true;
  string m=s.substr(5,2);
  string d=s.substr(8,2);
  if(m>"04")flag=true;
  else if(m=="04"){
    if(d>"30")flag=true;
  }
  if(flag)cout<<"TBD";
  else cout<<"Heisei";
}

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


Measured memory_bytes: 256
def get_num():
    n = int(input())
    w = int(input())
    return n,w

def check_range(n,w):
    return n in range(1,101) and w in range(n**2+1)

def black_tiles(n,w):
    if (check_range(n,w)):
        return n**2 - w
    else:
        raise Exception('Value out of range')

if (__name__=='__main__'):
    print(black_tiles(*get_num()))

Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
        
      	if(a <= 999){
          System.out.println("ABC");          
        }else{
          System.out.println("ABD");         
        }
        


 
      	
 
    }
}

Measured memory_bytes: 35860
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# 


s = str(input())
ans = "Good"
for i in range(3):
    if s[i] == s[i+1]:
        ans = "Bad"
print(ans)


Measured memory_bytes: 3064
s = input()
if s[0] != 'A':
    print('WA')
    exit()

is_find = False
idx = 0
for i in range(2, len(s)-1):
    if s[i] == 'C':
        if is_find:
            print('WA')
            exit()
        else:
            is_find = True
            idx = i

if is_find == False:
    print('WA')
    exit()

rm_s = s[1:idx] + s[idx+1:]

if rm_s.lower() == rm_s:
    print('AC')
else:
    print('WA')



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli mod = 1e9 +7;

int main(){
    int x,a;
    cin >> x >> a;
    if(x < a){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var a = new bool[10000000];
        generatePrime(a);
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            Console.WriteLine(getAns(a, n));
        }
    }
    public static void generatePrime(bool[] f)
    {
        var pL = f.Length;                                           // prime :  false
        f[0] = true; f[1] = true;
        for (int i = 2; i < pL; i++)
            if (!f[i])
                for (int j = i + i; j < pL; j += i) f[j] = true;
    }
    public static int getAns(bool[] a, int n)
    {
        if (n % 2 == 0) n--;
        for (int i = n - 8; i >= 1; i-= 2)
            if (!a[i] && !a[i + 2] && !a[i + 6] && !a[i + 8]) return i + 8;
        return 0;
    }
}




Measured memory_bytes: 19076
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, m = map(int, input().split())
  counts = [0] * (n)
  for _ in range(m):
    a, b = map(int, input().split())
    counts[a-1] += 1
    counts[b-1] += 1
  if all([c%2==0 for c in counts]):
    print('YES')
  else:
    print('NO')

if __name__=='__main__':
  main()



Measured memory_bytes: 4656
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

bool is_prime(ll n) {
    if (n < 2) {
        return false;
    } else if (n == 2) {
        return true;
    } else if (n % 2 == 0) {
        return false;
    }
 
    for (ll i = 3; i <= sqrt(n); i += 2) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

void solve() {
    int n;
    cin >> n;
    int ans = 0;
    int a;
    REP(i, n) {
        cin >> a;
        if (is_prime(a)) ans++;
    }
    cout << ans << endl;
}




Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
	int n;
	vector<int> N;

	for(int i=0;i<3;i++){
		cin >> n;
		N.push_back(n);
	}
	sort(N.begin(),N.end());

	for(int i=0;i<3;i++){
		cout << N.at(i);
		if(i!=2) cout << " ";
		else cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
n = gets.to_i
t,a = gets.split(" ")
a = a.to_i
t = t.to_i
h = gets.split(" ").map(&:to_i)

temp = []
h.each do |h|
    ondo = t-(h*0.006)
    temp.push((ondo-a).abs)
end

puts temp.index(temp.min)+1

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

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

  int fiveh;
  fiveh = x / 500;

  int result = x % 500;

  int five = result / 5;

  cout << fiveh * 1000 + five * 5 << endl;

}


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

#define ll             long long
#define LL             long long
#define pii            pair<int, int>
#define pll            pair<ll, ll>
#define pil            pair<int, ll>
#define pli            pair<ll, int>
#define vi             vector<int>
#define vl             vector<ll>
#define vii            vector<pii>
#define vll            vector<pll>
#define vil            vector<pil>
#define vli            vector<pli>
#define pb             push_back
#define ppb            pop_back
#define mp             make_pair
#define ff             first
#define ss             second
#define sz(x)          (int)x.size()
#define TN             typename
#define all(v)         v.begin(), v.end()
#define fill(a, b)     memset(a, b, sizeof(a))
#define endl           '\n'

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> T lcm(T a, T b) {return a * (b / gcd(a, b));}
template <TN T> T sqr(T a) {return a * a;}
template <TN T> T cube(T a) {return a * a * a;}
template <TN T> inline void smin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void smax(T &a, T b) {a = a > b ? a : b;}

template <TN T> inline void Int(T &n) {
	n = 0; int f = 1; register int ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
	for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
	n = n * f;
}

#define error(args...) {vector <string> _v = split(#args, ','); err(_v.begin(), args); cout << endl;}
vector <string> split(const string &s, char c) {
	vector <string> v;
	stringstream ss(s); string x;
	while (getline(ss, x, c)) v.emplace_back(x);
	return move(v);
}
void err(vector <string> :: iterator it) {}
template <typename T, typename... Args>
void err(vector <string> :: iterator it, T a, Args... args) {
	cout << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", ";
	err(++it, args...);
}

inline int in() {int n; scanf("%d", &n); return n;}
inline ll Lin() {ll n; scanf("%lld", &n); return n;}
inline double Din() {double n; scanf("%lf", &n); return n;}

inline int add(int a, int b, int mod) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b, int mod) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b, int mod) {return (ll)a * b % mod;}

const int N          = 2e5 + 5;
const ll  Mod        = (ll)1e9 + 7;
const int inf        = (int)2e9;
const ll  Inf        = (ll)1e18;
const int mod        = (int)1e9 + 7;

int dp[N];

int solve() {
	int n = in(), k = in();
	vi a(n);
	for (int i = 0; i < n; i++) {
		a[i] = in();
	}
	for (int i = 0; i <= k; i++) {
		if (dp[i] == 0) {
			for (int x : a) {
				if (i + x <= k) {
					dp[i + x] = 1;
				}
			}
		}
	}
	dp[k] == 1 ? printf("First\n") : printf("Second\n");
	return 0;
}

int main() {
	int test = 1, tc = 0;
	//scanf("%d", &test);
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
	return 0;
}





Measured memory_bytes: 640
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

h, w = MAP()
a = [STR() for _ in range(h)]
nextstrtj = 0
for i in range(h):
    flag1 = False #.のあとに#が出たか
    flag2 = False ##が出たか
    for j in range(nextstrtj):
        if a[i][j] == '#':
            print('Impossible')
            exit()
    for j in range(nextstrtj, w):
        if flag1 and a[i][j] == '#':
            print('Impossible')
            exit()
        elif a[i][j] == '#':
            flag2 = True
            nextstrtj = j
        elif flag2 and a[i][j] == '.':
            flag1 = True
    if not flag2:
        print('Impossible')
        exit()

print('Possible')

Measured memory_bytes: 5148
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  cout << accumulate(a.begin(), a.end(), 0) - a[n-1]/2 << endl;

  return 0;
}



///


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

using namespace std;
typedef unsigned long long llong;

#define MAX 200001

int main()
{
  llong N, P;
  char S[MAX];
  llong mod = 0, ans = 0;
  llong T[MAX], M[MAX];
  M[0] = 1;
  T[0] = 1;

  scanf("%llu%llu", &N, &P);

  for (llong i = 1; i < P; i++)
  {
    M[i] = 0;
  }

  scanf("%s", S);
  if (P == 2 || P == 5)
  {
    for (int i = 1; i <= N; i++)
    {
      if ((S[i - 1] - '0') % P == 0)
      {
        ans += i;
      }
    }
  }
  else
  {

    for (llong i = 1; i < N; i++)
    {
      T[i] = (T[i - 1] * 10) % P;
    }

    for (llong i = 0; i < N; i++)
    {
      mod = (mod + (S[N - 1 - i] - '0') * T[i]) % P;
      ans += M[mod];
      M[mod]++;
    }
  }
  printf("%llu", ans);

  return 0;
}

Measured memory_bytes: 3516
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	COMMAND_UNITE = iota
	COMMAND_SAME
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	nItems := scanInt(sc)
	nQueries := scanInt(sc)

	roots := make([]int, nItems)
	for i := 0; i < nItems; i++ {
		roots[i] = i
	}

	// 各木構造の高さを保持する。
	ranks := make([]int, nItems)

	findRoot := func(x int) int {
		for roots[x] != x {
			x = roots[x]
		}
		return x
	}

	w := bufio.NewWriter(os.Stdout)
	for i := 0; i < nQueries; i++ {
		command := scanInt(sc)
		x, y := scanInt(sc), scanInt(sc)
		rx := findRoot(x)
		ry := findRoot(y)

		switch command {
		case COMMAND_UNITE:
			// なるべく木の高さを抑えるため、より高い木を unite 後のルートに選ぶ。
			if ranks[rx] > ranks[ry] {
				roots[ry] = rx
			} else if ranks[rx] < ranks[ry] {
				roots[rx] = ry
			} else {
				roots[rx] = ry
				ranks[ry] += 1
			}
		case COMMAND_SAME:
			if findRoot(x) == findRoot(y) {
				fmt.Fprintln(w, 1)
			} else {
				fmt.Fprintln(w, 0)
			}
		}
	}
	w.Flush()
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}



Measured memory_bytes: 2392
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n, k;
  cin >> n >>k;
  string s;
  cin >> s;
  vector<int> index;
  rep(i, n){
    if(i==0){
      index.push_back(0);
    } else if(s[i]!=s[i-1]){
      index.push_back(i);
    }
  }
  int isz=index.size();
  int ans=0;
  rep(i, isz){
    int ik;
    if(s[index[i]]=='0'){
      ik=i+2*k;
    } else {
      ik=i+2*k+1;
    }
    if(ik>=isz){
      ans=max(ans, n-index[i]);
    } else {
      ans=max(ans,index[ik]-index[i]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4092
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

N = int(input())
L1 = []
L2 = []

for _ in range(N):
    a,b = map(int,input().split())
    L1.append(a)
    L2.append(b)

L1.sort()
L2.sort()

def median(L):
    if N&1:
        return L[(N)//2]
    else:
        ret = L[N//2-1] + L[N//2]
        return ret

ans = median(L2) - median(L1)
print(ans+1)

Measured memory_bytes: 25368
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <deque>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    //input
    int n,m; cin >> n >> m;
    vector<int> x(m + 1,0);
    vector<int> y(m + 1,0);
    for(int i = 1; i < m + 1; i++) cin >> x[i] >> y[i];

    //compute
    vector<int> p(n + 1,0);
    vector<int> b(n + 1,1);
    p[1] = 1;
    b[0] = 0;

    for(int i = 1; i < m + 1; ++i){
        if(p[x[i]] == 1){
            p[y[i]] = 1;
        }
        if(b[x[i]]== 1){
            p[x[i]] = 0;
        }
        b[x[i]] = b[x[i]] - 1;
        b[y[i]] = b[y[i]] + 1;     
    }

    //output
    cout << count(p.begin() + 1,p.begin() + n + 1,1) << endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define PI 3.141592653589793
#define mod 1000000007
# define N 200005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

set<int>s;
int cnt[N];
int a[N];
vector<int>v;
int main()
{
	IOS;
	ll n,k;
	cin >> n >> k;
	ll ans=0;
	for(int i=0;i<n;i++)
		{
			cin >> a[i];
			cnt[a[i]]++;
			s.insert(a[i]);
		}
		for(int i=0;i<N;i++)
			if(cnt[i])
				v.pb(cnt[i]);
	sort(v.begin(),v.end());

	int dif=((int)s.size()-k);
	for(int i=0;i<dif;i++)
		ans+=v[i];
	cout << ans;

}

Measured memory_bytes: 12408
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

string S;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> S;
  int cnt = 0;
  REP(i,S.size()) cnt += S[i] == 'o';
  cout << (cnt+(15-S.size()) >= 8 ? "YES" : "NO") << endl;

  return 0;
}

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

int main(void) {
  string S;
  cin >> S;
  
  sort(S.begin(), S.end());
  
  if(S[0] == S[1] && S[1] != S[2] && S[2] == S[3])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a < 10 && b < 10)
        cout << a * b << endl;
    else
        cout << -1 << endl;

    return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	for(auto &i:a) cin >> i;
	sort(a.begin(), a.end());
	for(int i=1; i<n; ++i)
		if(a[i] == a[i-1]){
			cout << "NO\n";
			return 0;
		}
	cout << "YES\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  int M; cin>>M;
  ll sum=0,sumC=0;
  rep(i,M){
    ll d,c; cin>>d>>c;
    sum+=d*c;
    sumC+=c;
  }
  cout<<sumC-1+(sum-1)/9<<endl;
  return 0;
}

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

using namespace std;

int main(){
	int n;
	string s;
	cin>>n;
	cin>>s;
	for(int i=0;i<s.length();i++){
		int temp=(int)s[i] + n;
		if(temp>90){
			temp=temp%90 + 64;
		}
		cout<<(char)temp;
	}
	return 0;
}

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

int main() {
    int x, n;
    cin >> x >> n;
    int p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int ans = x;
    for (int i = 0; i <= n; i++) {
        bool a = true;
        for (int j = 0; j < n; j++) {
            if (p[j] == ans - i) a = false;
        }
        if (a) {
            ans -= i;
            cout << ans << endl;
            return 0;
        }
        a = true;       
        for (int j = 0; j < n; j++) {
            if (p[j] == ans + i) a = false;
        }
        if (a) {
            ans += i;
            cout << ans << endl;
            return 0;
        }
        

    }


return 0;
}

Measured memory_bytes: 3628
#include <cstdio>

const int MAXN = 400;
const int MOD = 998244353;

int pow_mod(int b, int p) {
	int ret = 1;
	for(int i=p;i;i>>=1,b=1LL*b*b%MOD)
		if( i & 1 ) ret = 1LL*ret*b%MOD;
	return ret;
}

int fct[MAXN + 5], ifct[MAXN + 5];
void init() {
	fct[0] = 1;
	for(int i=1;i<=MAXN;i++)
		fct[i] = 1LL*fct[i-1]*i%MOD;
	ifct[MAXN] = pow_mod(fct[MAXN], MOD-2);
	for(int i=MAXN-1;i>=0;i--)
		ifct[i] = 1LL*ifct[i+1]*(i+1)%MOD;
}

int A[MAXN + 5], B[MAXN + 5], SA, SB;

int f[2][2][MAXN + 5][MAXN + 5];

int main() {
	init();
	int N; scanf("%d", &N);
	for(int i=1;i<=N;i++)
		scanf("%d%d", &A[i], &B[i]), B[i];
	f[0][0][0][0] = 1;
	for(int i=1;i<=N;i++) {
		for(int j=0;j<=SA;j++)
			for(int k=0;k<=SB;k++)
				f[1][0][j][k] = f[0][0][j][k], f[1][1][j][k] = f[0][1][j][k];
		for(int j=0;j<=SA;j++)
			for(int k=0;k<=SB;k++) {
				int t = 1;
				for(int p=0;p<=B[i];p++,t=1LL*t*A[i]%MOD) {
					if( p == B[i] ) {
						int d = (MOD - 1LL*t*ifct[p-1]%MOD*f[1][0][j][k]%MOD)%MOD;
						f[0][1][j+A[i]][k+p] = (f[0][1][j+A[i]][k+p] + d)%MOD;
					}
					else {
						int d = (MOD - 1LL*t*ifct[p]%MOD*f[1][0][j][k]%MOD)%MOD;
						f[0][0][j+A[i]][k+p] = (f[0][0][j+A[i]][k+p] + d)%MOD;
						d = (MOD - 1LL*t*ifct[p]%MOD*f[1][1][j][k]%MOD)%MOD;
						f[0][1][j+A[i]][k+p] = (f[0][1][j+A[i]][k+p] + d)%MOD;
					}
				}
			}
		SA += A[i], SB += B[i];
	}
	int ans = 0;
	for(int i=1;i<=SA;i++)
		for(int j=1;j<=SB;j++) {
			int d = 1LL*f[0][1][i][j]*fct[j-1]%MOD*j%MOD*pow_mod(i,MOD-1-j-1)%MOD;
			ans = (ans + d)%MOD;
		}
	printf("%lld\n", 1LL*SA*(MOD - ans)%MOD);
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int counter = 0;
  if (s[0] == '1'){
    counter++;
  }
  if(s[1] == '1') {
    counter++;
  }
  if(s[2] == '1') {
    counter++;
  }
  cout << counter << endl;
}

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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 1e9
using namespace std;
template <class T = int>
T in()
{
  T x;
  cin >> x;
  return (x);
}

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

bool contains(vector<int> v, int n)
{
  auto itr = find(all(v), n);
  size_t index = std::distance(v.begin(), itr);
  if (index != v.size())
  {
    return true;
  }
  else
  {
    return false;
  }
}
#pragma endregion

int main()
{
  int n = in(), m = in();
  vector<vector<int>> load(n + 1);
  vector<int> ans(n, 0);
  rep(i, m)
  {
    int a = in(), b = in();
    load[a].pb(b);
    load[b].pb(a);
  }

  queue<int> que;
  que.push(1);
  int index = 0;
  ans[0] = 1;
  while (!que.empty())
  {
    rep(i, load[que.front()].size())
    {
      int target = load[que.front()][i];
      if (ans[target - 1] == 0)
      {
        ans[target - 1] = que.front();
        que.push(target);
      }
    }
    que.pop();
  }

  auto result = find(all(ans), 0);
  if (result == ans.end())
  {
    cout << "Yes" << endl;
    for (int i = 1; i < n; i++)
    {
      cout << ans[i] << endl;
    }
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 10260
from math import gcd
n=int(input())
a=list(map(int,input().split()))
l=[0 for i in range(n)]
r=[0 for i in range(n)]
l[0]=a[0]
r[0]=a[-1]
for i in range(n-1):
    l[i+1]=gcd(l[i],a[i+1])
for i in range(n-1):
    r[i+1]=gcd(r[i],a[-2-i])

ans=[0 for i in range(n)]

for i in range(1,n-1):
    ans[i]=gcd(l[i-1],r[-i+n-2])
ans[0]=r[n-2]
ans[n-1]=l[n-2]

print(max(ans))

    



Measured memory_bytes: 24516
n,k=map(int,input().split())
a=list(map(int,input().split()))
town=[0]*n
town[0]+=1
next=a[0]
for i in range(n):
  if town[next-1]==0:
    town[next-1]+=1
    next=a[next-1]
  else:
    break
re=next
next=a[re-1]
t2=0
for i in range(n):
  t2+=1
  if a[next-1]==re:
    t2+=1
    break
  else:
    next=a[next-1]
t1=0
next=a[0]
for i in range(n):
  t1+=1
  if a[next-1]==re:
    t1+=1
    break
  else:
    next=a[next-1]
if k<=t1:
  next=a[0]
  for i in range(k-1):
    next=a[next-1]
  print(next)
else:
  k-=t1
  k%=t2
  next=re
  for i in range(k):
    next=a[next-1]
  print(next)

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#2019/10/24
# S = list(map(int, list(open(0).read())))
S = list(map(int, input()))
# print(S)
print(S[::2].count(0) + S[1::2].count(1) if S[0]==1 else S[::2].count(1) + S[1::2].count(0)) 

Measured memory_bytes: 4256
#include <iostream>
#include <string>
using namespace std;
int main(){
	string word , str;
	int counter = 0;
	cin >> word;
	for( int i=0 ; i<word.size() ; i++ )
		if( islower( word[i] ))
			word[i] = toupper( word[i] );
	while( cin >> str ){
		if( str != "end_of_text" ){
			for( int i=0 ; i<str.size() ; i++)
				if( islower(str[i]))
					str[i] = toupper(str[i]);
			}
		if( word == str )
			counter ++;
		if( str == "END_OF_TEXT" ) break;
	}
	cout << counter << endl;
}

Measured memory_bytes: 3156
package main

import (
	"fmt"
)

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)
	for k > 0 {
		a, b, k = a/2, b+a/2, k-1
		if k <= 0 {
			break
		}
		a, b, k = a+b/2, b/2, k-1
	}
	fmt.Println(a, b)
}


Measured memory_bytes: 512
/*  -*- coding: utf-8 -*-
 *
 * 2906.cc: Santa's Gift
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 10000;
const int MAX_M = 10000;
const int MAX_C = 10000;

/* typedef */

typedef long long ll;

/* global variables */

int ss[MAX_N], ps[MAX_N];
int dp[MAX_C + 1];

/* subroutines */

inline void setmax(int &a, int b) { if (a < b) a = b; }

/* main */

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

  for (int i = 0; i < n; i++) scanf("%d%d", ss + i, ps + i);

  memset(dp, -1, sizeof(dp));
  dp[0] = 0;

  for (int i = 0; i < n; i++)
    for (int j = c - ss[i]; j >= 0; j--)
      if (dp[j] >= 0)
	setmax(dp[j + ss[i]], dp[j] + ps[i]);
  for (int j = 0; j < c; j++) setmax(dp[j + 1], dp[j]);

  for (int k = 1; k <= m; k++) printf("%lld\n", (ll)dp[c / k] * k);
  return 0;
}



Measured memory_bytes: 3344
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define inf 1e18
int main()
{
      ll n,temp=n;
      cin>>n;
      ll ans=360;
      while (n % 2 == 0)  
	    {  
	        if(ans%2==0)
	        {
	        	ans=ans/2;
			}
	        n = n/2;  
	    }  
	    for (ll i = 3; i <= n+1; i = i + 2)  
	    {  
	         if(n<2) break;
	        while (n % i == 0)  
	        {  
	            if(ans%i==0)
				{
					ans=ans/i;
				 } 
	            n = n/i;  
	            if(n<2) break;
	        }  
	    }  
	  cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int mas=-1;
int ans;
int main()
{
 int t;
 cin>>t;
 int all[t+1];
 for(int i=0;i<t;i++)
 {
 	cin>>all[i];
 }
 for(int i=0;i<t;i++)
 {
 	mas=max(mas,all[i]);
 	if(all[i]>=mas)
 	{
 		ans++;
	 }
 }
 cout<<ans<<endl; 
}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = [0] + list(map(int, input().split()))
for i in range(1, n+1):
    p[i] = ((p[i] + 1)/2)
    p[i] += p[i-1]
ans = 0
for i in range(1, n-k+2):
    ans = max(ans, p[i+k-1]-p[i-1])
print(ans)


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

struct UnionFind {
  vector<int> par, s; 
  UnionFind(int N) : par(N), s(N) { rep(i,N) { par[i] = i; s[i] = 1; } }
  int root(int x) { return par[x]==x ? x : par[x] = root(par[x]); }
  int size(int x) { return par[x]==x ? s[x] : s[x] = size(root(x)); }
  void unite(int x, int y) { int rx=root(x), ry=root(y); if (rx!=ry) { s[rx] += s[ry]; par[ry] = rx; } }
  bool same(int x, int y) {  int rx=root(x), ry=root(y); return rx==ry; }
};

vector<vector<int>> spadj;
vector<int> numin;

void dfs(int n=0, int p=-1) {
  for (auto x: spadj[n]) {
    if (x==p) continue;
    dfs(x,n);
  }
  if (p!=-1) {
    if (numin[n]%2==0) {
      cout << p+1 << " " << n+1 << endl;
      numin[p]++;
    }
    else {
      cout << n+1 << " " << p+1 << endl;
      numin[n]++;
    }
  }
}

int main() {
  int N, M; cin >> N >> M;
  if (M%2==1) { cout << -1 << endl; return 0; }

  spadj.resize(N); numin.resize(N);
  UnionFind uf(N);
  rep(i,M) {
    int A, B; cin >> A >> B; A--; B--;
    if (!uf.same(A,B)) {
      spadj[A].push_back(B);
      spadj[B].push_back(A);
      uf.unite(A,B);
    }
    else {
      cout << A+1 << " " << B+1 << endl;
      numin[A]++;
    }
  }

  dfs();
  return 0;
}

Measured memory_bytes: 12032
from math import ceil
from bisect import bisect
from operator import itemgetter
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort(key=itemgetter(0))
X = [XH[i][0] for i in range(N)]
H = [XH[i][1] for i in range(N)]

bit = BIT(N)
ans = 0
for i in range(N):
    bit.add(i+1,H[i])
    bit.add(i+2,-H[i])
    h = bit.sum(i+1)
    if h>0:
        ans += ceil(h/A)
        x = -ceil(h/A)*A
        j = bisect(X,X[i]+2*D)
        bit.add(i+1,x)
        bit.add(j+1,-x)

print(ans)


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

int n, a[100010],L[100010],R[100010],ans;

int gcd(int x, int y)
{
	if(y==0) return x;
	while (x % y != 0){
		int r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 2; i <= n; i++) L[i] = gcd(L[i-1],a[i-1]);
	reverse(a+1,a+n+1);
	for(int i = 2; i <= n; i++) R[i] = gcd(R[i-1],a[i-1]);
	for(int i = 1; i <= n; i++){
		ans=max(ans,gcd(L[i],R[n-i+1]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408