akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll n;
    cin >>n;
    ll x;
    cin >>x;
    vll a(n);
    ll r = 0;
    rep(i, n) {
        cin >>a[i];
    }
    Sort(a);
    
    rep(i, n) {
        x -= a[i];
        if (x < 0) break;
        r++;
    }
    if (x > 0) r--;
    if (r < 0) r = 0;
    
    mes(r);

    
    
    
    
    
    

}


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

int main() {
	string s;
	cin >> s;
	if (((int)s[5] - 48) * 10 + (int)s[6] - 48 > 4)
		cout << "TBD" << endl;
	else
		cout << "Heisei" << endl;
	return 0;
}


Measured memory_bytes: 256
N,K = list(map(int, input().split()))
D = sorted(input().split())
W = []
for i in range(10):
    if str(i) not in D:
        W.append(i)

while True:
    cnt = 0
    for i in range(len(W)):
        cnt += str(N).count(str(W[i]))
    if cnt == len(str(N)):
        break
    N += 1

print(N)

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

using namespace std;

int main(void)
{
	int t;
	while (cin >> t, t){
		int n, s, f;
		int stime = 0;
		cin >> n;
		while (n--){
			cin >> s >> f;
			stime += (f - s);
		}
		if (t <= stime){
			cout << "OK" << endl;
		}
		else {
			cout << t - stime << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1<<17;
const ll mod=1e9+7;
ll n,x,y,z;
ll dp[45][N];
int main()
{
	while(cin>>n>>x>>y>>z)
	{
		ll ans=1;
		for(int i=1;i<=n;i++)
			ans=(ans*10ll)%mod;
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		int forbid=(1<<z-1)|(1<<y+z-1)|(1<<x+y+z-1);
		int state=(1<<x+y+z)-1;
		for(int i=1;i<=n;i++)
		{
			for(int s=0;s<=state;s++)
			{
				if(dp[i-1][s]==0)//
					continue;
				for(int k=1;k<=10;k++)
				{
					int now=(s<<k)|(1<<k-1);
					now&=state;
					if((now&forbid)!=forbid)
						dp[i][now]=(dp[i][now]+dp[i-1][s])%mod;
				}
			}
		}
		for(int i=0;i<=state;i++)
			ans=(ans-dp[n][i]+mod)%mod;
		cout<<ans<<endl;
	}
	return 0;
}

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

int D, len;
vector<int> V;

int cc[22][22][2][2][2];
int dp(int p, int q, int a, int b, int f) {
    int &ret = cc[p][q][a][b][f];
    if(ret != -1) return ret;

    if(p < q) return ret = a == b;
    if(p == q) {
        ret = 0;
        for(int i = f; i <= 9; i++) {
            int x = 10*a;
            int y = -b;
            if(x - V[p] != 0 && x - V[p] != 1) continue;
            if(y != V[q] && 10 + y != V[q]) continue;
            ret++;
        }
        return ret;
    }

    ret = 0;
    for(int i = 0; i <= 9; i++) {
        for(int j = f; j <= 9; j++) {
            int x = i - j + 10*a;
            int y = j - i - b;
            if(x - V[p] != 0 && x - V[p] != 1) continue;
            if(y != V[q] && 10 + y != V[q]) continue;
            ret += dp(p - 1, q + 1, x - V[p], (V[q] - y) / 10, 0);
        }
    }
    return ret;
}

int main() {
    cin>>D;
    while(D) {
        V.push_back(D % 10);
        D /= 10;
    }
    len = V.size();
    for(int i = 0; i < 22; i++) V.push_back(0);

    int ans = 0;
    memset(cc, -1, sizeof(cc));

    for(int i = len - 1; i < 22; i++) {
        ans += dp(i, 0, 0, 0, 1);
    }

    printf("%d", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=605;
int n,m,x,y,a[N][N],d[N];
double f[N],g[N];
signed main(){
	scanf("%d%d",&n,&m);
	while (m--){
		scanf("%d%d",&x,&y);
		a[x][++a[x][0]]=y;
	}
	f[0]=0;
	for (int i=n-1;i;i--){
		for (int j=1;j<=a[i][0];j++)f[i]+=f[a[i][j]]/a[i][0];
		f[i]++;
	}
	double ans=f[1];
	for (int i=1;i<n;i++)
		if (a[i][0]>1){
			int flag=a[i][1];
			for (int j=2;j<=a[i][0];j++)
				if (f[a[i][j]]>f[flag])flag=a[i][j];
			for (int j=1;j<=n;j++)d[j]=a[j][0];
			d[i]--;
			memset(g,0,sizeof g);
			for (int j=n-1;j;j--){
				for (int k=1;k<=a[j][0];k++)
					if (j!=i||a[j][k]!=flag)g[j]+=g[a[j][k]]/d[j];
				g[j]++;
			}
			ans=min(ans,g[1]);
		}
	printf("%.10lf\n",ans);	
}

Measured memory_bytes: 1664
import math

(a, b, c, x, y) = map(int, input().split())

a1 = max(x, y) * c * 2

a2 = min(x, y) * c * 2 + a * (x - min(x, y))+ b * (y - min(x, y))

a3 = a * x + b * y

answer = min(a1, a2, a3)
print(str(answer))

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
using namespace std;
#define sL(i) i << 1
#define sR(i) i << 1 | 1
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<int, pair<int,int>> ppi;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 5;

int x, n, seen[101];
int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> x >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        seen[a] = true;
    }
    int best = 0;
    for (int i = 1; i <= 101; i++) {
        if (!seen[i] && abs(x - i) < abs(x - best)) {
            best = i;
        }
    }
    cout << best;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin>>n;
  int c=0,ans=0;
  int* arr=new int[n];
  for(int i=0;i<n;i++){
  	cin>>arr[i];
  } 
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=j+1;k<n;k++){
        if(arr[i]==arr[j]||arr[k]==arr[j]||arr[i]==arr[k])
          continue;
        if(arr[i]+arr[j]<=arr[k])
          continue;
        if(arr[k]+arr[j]<=arr[i])
          continue;
        if(arr[i]+arr[k]<=arr[j])
          continue;
        c++;
      }
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 3672
# -*- coding: utf-8 -*-
"""
Created on Mon Sep  7 15:49:02 2020

@author: liang
"""

N, X, Y = map(int, input().split())
ans = [0]*(N-1)
for i in range(1,N+1):
    for j in range(i+1, N+1):
        #print(i,j)
        res = min(abs(i-j), abs(X-i) + 1 + abs(Y-j))
        #print(i, j, res)
        ans[res-1] += 1

for i in ans:
    print(i)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[200010],b[200010];
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i],b[i]=a[i];
	sort(b,b+n+1);
	for(int i=1;i<=n;i++)
	{
		if(a[i]==b[n])
			cout<<b[n-1]<<endl;
		else
			cout<<b[n]<<endl;}
	return 0;
}

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

int main() {
  int n, x, y;
  cin >> n;
  x = 800 * n;
  y = 200 * (n / 15);
  cout << x - y << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define se second
#define mp make_pair
#define fi first
#define del(a,vec) vec.erase(std::remove(vec.begin(), vec.end(), a), vec.end());
#define search(f,l,v) binary_search(f,l,v)
#define iter(a,b) vector<int>::iterator a,b
#define lower(v,num) lower_bound (v.begin(), v.end(), num);
#define upper(v,num) upper_bound (v.begin(), v.end(), num); 
#define removecopy(a) unique(a.begin(), a.end()); 
#define ll long long int
namespace Rahul{
    bool isPrime(int n) 
    {if (n <= 1)  return false; if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; }
    ll pow (ll x, ll n,ll mod) {//calculate x^n
    if (n == 0) return 1;

    ll res = pow (x, n / 2,mod);

    res = (res * res) % mod;
    if (n % 2) res = (res * x ) % mod;

    return res;
    }
    ll _gcd(ll a,ll b)
    {
        if(a==0)
            return b;
        else    
            return _gcd(b%a,a);
    }
    //s.erase(s.find(2)) where s={1,2,3,3,2}; 
};

using namespace Rahul;
int main()
{
     ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
     ll n;
     cin>>n;
     ll a[n+1];
     ll sum=0;
     for(int i=0;i<n;i++){cin>>a[i];
     sum+=a[i];}
     
     
     ll ans=1e18;
     ll k=0;
     for(int i=0;i<n;i++)
        {
            ans=min(ans,abs(sum-k));
            sum=sum-a[i];
            k=k+a[i];
        }
     cout<<ans<<endl;
     
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
#define MAX 100100
//#define NIL -1

int main() {
    LL n;
    LL ans;
    cin >> n;
    vector<LL> a(n);
    vector<LL> keta(30, 0);
    vector<LL> ans_keta(30, 0);

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

    LL tmp;
    for(LL i=0; i<n; i++){
        tmp=a[i];
        for(LL j=0; j<30; j++){
            if(tmp&1==1){
                keta[j]++;
            }
            tmp/=2;
        }
    }

    for(LL i=0; i<n; i++){
        ans=0;
        tmp=a[i];
        for(LL j=0; j<30; j++){
            LL tmp2=tmp&1;
            if((tmp2+keta[j])%2!=0){
                ans_keta[j]=1;
            }else{
                ans_keta[j]=0;
            }
            tmp/=2;
        }
        for(LL j=29; j>=0; j--){
            ans*=2;
            ans+=ans_keta[j];
        }
        cout << ans << endl;
    }

    return 0;
}

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

int main()
{
	string s;
	cin>>s;
	
	for(int i=0;i<s.length();i++){
		for(int j=i+1;j<s.length();j++){
			if(s[i]==s[j]){
				cout<<"no"<<endl;
				return 0;
			}
		}
	}
	
	cout<<"yes"<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

int main() {
  ll S; cin >> S;
  vi num;
  ll len=0;
  while (S>0){
    num.push_back(S%10);
    S /=10;
  }
  len = num.size();
  ll ans =0;
  for (ll bit=0; bit<(1<<len-1); bit++){
    ll ssum = num[0];
    ll dig = 0;
    for (int i=0; i<len-1; i++){  //flg 1 = *, 0= +
      if(bit & (1<<i)) {
        dig++;
        ssum += num[i+1]*pow(10,dig);
      }
      else{
        ssum += num[i+1];
        dig = 0;
      }
    }
    ans += ssum;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4000
#include<stdio.h>
#include<stdlib.h>

int main(){
  int num,i,a;
  a=scanf("%d",&num);

  if(90<=num && num<100){
    printf("Yes\n");
    return 0;
  }
  
  for(i=90;i>=0;i=i-10){
    if((num-i)==9){
      printf("Yes\n");
    return 0;
    }
  }

  printf("No\n");

}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){

    int a, b,c;
    
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    
    if(0>a || 100<a){
        return 0;
    }
    
    if(0>b || 100<b){
        return 0;
    }
    
    if(0>c || 100<c){
        return 0;
    }
    
    
    
    if(a<b && b<c){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	string w;
	cin >> w;
	vector<string> t;
	while (true) {
		string tmp;
		cin >> tmp;
		t.push_back(tmp);
		if (tmp == "END_OF_TEXT") break;
	}

	int ans = 0;
	for (int i = 0; i < t.size(); i++) {
		int count = 0;
		if (t[i].size() == w.size()) {
			for (int j = 0; j < t[i].size(); j++) {
				if (t[i][j] == w[j]) count++;
				else if (t[i][j] + ('a' - 'A') == w[j]) count++;
			}
			if (count == t[i].size()) ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3172
//Vanjape Rajas Mangesh
#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))

#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define TRACE

#ifdef TRACE
#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

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);

const int N=200005;
string A;
int pref[N][26];

int main()
{
  cin>>A;
  int n=SZ(A);
  A="*"+A;
  for(int i=1;i<=n;i++){
    for(int j=0;j<26;j++)
      pref[i][j]=pref[i-1][j];
    pref[i][A[i]-'a']++;
  }
  LL ans=1;
  for(int i=1;i<=n;i++){
    ans=ans+(i-1-pref[i-1][A[i]-'a']);
  }
  cout<<ans<<"\n";
	return 0;
}


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

using namespace std;

#define int long long

bool codejam = 0;

typedef long long li;
typedef long double ld;

void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}

void solve() {
	string s;
	cin >> s;
	int n = (int) s.size();
	int win = 0;
	for (auto i: s) {
		if (i == 'o') win += 1;
	}
	win += (15 - n);
	if (win >= 8) 
		cout << "YES";
	else cout << "NO";
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int n;cin>>n;
  int _100=n/100;
  int kouho=_100*100+_100*10+_100;
  int ans=0;
  REP(i,10){
    if(n<=kouho){
      ans=kouho;
      break;
    }
    _100++;
    kouho=_100*100+_100*10+_100;
  }
  cout << ans<< endl;
}

Measured memory_bytes: 256
n = int(input())
s = {}
for i in range(n) :
  name = input()
  if name in s :
    s[name] += 1
  else :
    s[name] = 1

s = sorted(s.items(), key=lambda x:x[1], reverse=True)

ans = [s[0][0]]
v = s[0][1]
for i in range(1,len(s)) :
  if s[i][1] != v :
    break
  ans.append(s[i][0])
ans.sort()

for i in range(len(ans)) :
  print(ans[i])

Measured memory_bytes: 43228
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b & b!=c) || (a==c && b!=c) || (c==b && a!=c))
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

last = [0] * 26
manzoku = [0] * 26
for i in range(D):
    for j in range(26):
        if last[j] != 0:
            manzoku[j] -= c[j] * (i - last[j])
        last[s[i].index(max(s[i]))] = i
        manzoku[s[i].index(max(s[i]))] += max(s[i])
    print(manzoku.index(max(manzoku)) + 1)

Measured memory_bytes: 9400
def main():
    line_input = input()
    head = int(line_input[:2])
    tail = int(line_input[2:])

    YYMM = True
    MMYY = True
    if 1 > head or head > 12:
        MMYY = False

    if 1 > tail or tail > 12:
        YYMM = False

    if not (MMYY or YYMM):
        print("NA")
    elif MMYY and YYMM:
        print("AMBIGUOUS")
    elif MMYY:
        print("MMYY")
    elif YYMM:
        print("YYMM")


if __name__ == "__main__":
    main()

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

struct MillerRabin {
    using lint = unsigned long long int;
private : 
    const lint v1[3] = {2, 7, 61};
    const lint v2[7] = {2, 3, 5, 7, 11, 13, 17};
    const lint v3[7] = {2, 325, 9375, 28178, 450775, 9780504, 1795265022};
public : 
    inline lint modpow(lint x, lint k, lint m){
        lint a = 1, p = x;
        while(k > 0) {
            if (k % 2 == 0) { p = p * p % m; k /= 2; }
            else { a = a * p % m; k--; }
        }
        return a;
    }

    inline bool sub (lint a, lint n, lint d, lint s) {
        bool flag = true;
        for (lint r = 0; r < s; r++) {
            if (modpow(a, d, n) == n - 1) {
                flag = false; break;
            }
            d <<= 1LL;
        }
        return flag;
    }

    bool isprime (lint n) {
        if (n < 2) return false;
        lint d = n - 1, s = 0;
        while (d % 2 == 0) { d /= 2; s++; }
        if (n < 4759123141LL) {
            for (const lint &a : v1) {
                if (a == n) return true;
                if (n < a) break;
                if (modpow(a, d, n) == 1) continue;
                if (sub(a, n, d, s)) return false;
            }
        } else if (n < 341550071728321LL) {
            for (const lint &a : v2) {
                if (a == n) return true;
                if (n < a) break;
                if (modpow(a, d, n) == 1) continue;
                if (sub(a, n, d, s)) return false;
            }
        } else {
            for (const lint &a : v3) {
                if (a == n) return true;
                if (n < a) break;
                if (modpow(a, d, n) == 1) continue;
                if (sub(a, n, d, s)) return false;
            }
        }
        return true;
    }

};


int main() {
    MillerRabin miller;
    
    long long x;
    cin >> x;
    while (not miller.isprime(x)) x++;
    cout << x << endl;
    return 0;
}

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

int n, m, a, b, c, dp[4096];
int main() {
    cin >> n >> m;
    int s = (1 << n);
    dp[0] = 0;
    for(int i = 1; i < s; i++) dp[i] = 1e9;
    while(m--) {
        cin >> a >> b;
        int t = 0;
        while(b--) {
            cin >> c;
            t |= (1 << --c);
        }
        for(int i = 0; i < s; i++) {
            if(dp[i] != 1e9) dp[i | t] = min(dp[i | t], dp[i] + a);
        }
    }
    cout << (dp[s-1] == 1e9 ? -1 : dp[s-1]);
}

Measured memory_bytes: 256
import math
import itertools

n = int(input())
e = [[int(i) for i in input().split()] for i in range(n)] 
len_sum = 0
count = 0

for x in itertools.permutations(e):
  for i in range(n):
    for j in range(n):
      if j - i != 1:
        continue
      else:
        len_sum += math.sqrt(math.pow(x[i][0] - x[j][0], 2) + math.pow(x[i][1] - x[j][1], 2))
  count += 1
  
print(len_sum/count)

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

int main(void)
{
	int N,i;
	
	double ans=0,tmp;
	cin >> N;

	int V[N];

	for(i=0;i<N;i++)
	{
		cin >> V[i];

	}

	sort(V,V+N);
	
	ans=((double)V[0]+(double)V[1])/2;

	for(i=2;i<N;i++)
	{
		ans=(ans+(double)V[i])/2;

	}

	cout << fixed << setprecision(7) << ans << endl;
}



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

int main(){
    int n,m;
    cin >> n >> m;
    map<int,bool> mp[m];
    for(int i=0; i<m; i++){
        int k;
        cin >> k ;
        for(int j=0; j<k; j++){
            int s;
            cin >> s;
            s--;
            mp[i][s]=true;
        }
    }
    int p[m];
    bool zero=true;
    for(int i=0; i<m; i++){
        cin >> p[i];
        if(p[i]==1)zero=false;
    }
    queue<int> ess,tmp;
    bool flag=true;
    int ans=0;
    if(zero)ans++;
    for(int bit=0; bit<(1ll<<n); bit++){
        for(int i=0; i<n; i++){
            if(bit&(1<<i))ess.push(i);
        }
        tmp=ess;
        flag=true;
        
        if(!tmp.empty()){
            for(int i=0; i<m; i++){
                int cnt=0;
                tmp=ess;
                while(!tmp.empty()){
                    int on=tmp.front();
                    tmp.pop();
                    if(mp[i][on])cnt++;
                }
                if(cnt%2!=p[i])flag=false;
            }
            if(flag)ans++;
            while(!ess.empty())ess.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			List<long> a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
			a.Sort();
			long max = a.Last();
			var divisors = GetDivisors(max);
			divisors.Reverse();

			long ans = 1;
			foreach (long div in divisors) {
				int cnt = 0;
				for (int i = 0; i < n; i++) {
					if (a[i] % div != 0) {
						++cnt;
					}

					if (cnt >= 2) {
						break;
					}
				}

				if (cnt < 2) {
					ans = div;
					break;
				}
			}

			a.RemoveAt(a.Count - 1);
			ans = Math.Max(ans, GCD(a.ToArray()));

			Console.WriteLine(ans);
		}

		static List<long> GetDivisors(long value)
		{
			long max = (long)Math.Ceiling(Math.Sqrt(value));
			var divisors = new List<long>();
			for (int i = 1; i <= max; i++) {
				if (value % i == 0) {
					divisors.Add(i);
					divisors.Add(value / i);
				}
			}

			divisors.Sort();
			return divisors;
		}

		static long GCD(long a, long b)
		{
			if (a > b) {
				if (b == 0) {
					return a;
				}

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

				return GCD(a, b % a);
			}
		}

		static long GCD(long[] values)
		{
			if (values.Length == 1) {
				return values[0];
			}

			long gcd = values[0];
			for (int i = 1; i < values.Length; ++i) {
				if (gcd == 1) {
					return gcd;
				}
				gcd = GCD(values[i], gcd);
			}

			return gcd;
		}
	}
}


Measured memory_bytes: 31580
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;
int main(void) {
  lld x, s = 0, n = 100;
  cin >> x;
  while (1) {
    n = n + n / 100;
    s++;
    if (n >= x) {
      break;
    }
  }
  cout << s << "\n";
}


Measured memory_bytes: 3596
a, b, c = map(int, input().split())
k = int(input())
c = c * 2 ** k

i = 1
if a < b:
  if b < c:
    print("Yes")
  else:
    print("No")
else:
  while i <= k:
    if a < b and b < c:
      print("Yes")
      break
    else:
      b = b * 2
      c = int(c / 2)
      i += 1
  if i > k:
    print("No")

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    int n,t,a;
    cin >> n >> t >> a;
    int ans = 0;
    double zantei = INF;
    rep1(i,n+1){
        double x;
        cin >> x;
        double tmp = abs(a-(t-x*0.006));
        if(zantei>tmp){
            zantei = tmp; ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}
    

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MAX = 100010;
int cnt[MAX];
pii cntM[MAX];

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> X(N);
	int mm = 0;
	for (int i = 0; i < N; i++) {
		cin >> X[i];
		if (X[i]%M == 0) mm++;
		else cnt[X[i]]++;
	}
	for (int i = 0; i < MAX; i++) {
		cntM[i%M].first += cnt[i];
		if (cnt[i]%2 == 1) cntM[i%M].second++;
	}
	int ans = mm/2;
	for (int i = 1; i <= M/2; i++) {
		if (i == M/2 && M%2 == 0) ans += cntM[i].first/2;
		else {
			int tmp = min(cntM[i].first, cntM[M-i].first);
			ans += tmp;
			int index = i;
			if (cntM[i].first <= tmp) index = M-i;
			if (cntM[index].second >= tmp) {
				ans += (cntM[index].first - (cntM[index].second))/2;
			} else {
				ans += (cntM[index].first-tmp)/2;
			}
		} 
	}
	cout << ans << endl;
	return 0;
}


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

#define PI 3.14159265359
#define MODULO 1000000007

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
//large array has to be declared outside main, allocated statically
// if stored inside main, this variable lives in stack, caused overflow
int cnt[1010000];


int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int ans = 0;
  int n;
  cin >> n; 
  vi v(n);
  // cout << cnt[0];

  for(int i =0; i<n;i++){
    cin >> v[i];
    cnt[v[i]]++;
  }
  for(int i =0; i<n;i++){
    bool ok = true;
    for(int j =1; j*j <= v[i]; j++){
      if(v[i] % j != 0){
        continue;
      }
      if(cnt[j] >= 2) {
        ok = false;
      }
      if(j != v[i] and cnt[j] >= 1) {
        ok = false;
      }
      int x = v[i] / j;
      if(cnt[x] >= 2) {
        ok = false;
      }
      if(x != v[i] and cnt[x] >= 1) {
        ok = false;
      }
    }
    if(ok){
      ans++;
    }
  }
  cout << ans;
}
// Method from editorial

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

string solve(string &s){
  int same = 1;
  string res;
  char prev = s[0];
  for (int i = 1; i < s.length(); i++) {
    if(s[i] != prev){
      stringstream ss;
      ss << same;
      string tmp;
      ss >> tmp;
      res += tmp;
      res += prev;
      same = 1;
      prev = s[i];
    }else{
      same++;
    }
  }
  if(same != 0){
    res += to_string(same);
    res += prev;
  }
  return res;
}

int main(){
  int n;
  while (std::cin >> n, n) {
    string s;
    std::cin >> s;
    for (int i = 0; i < n; i++) {
      s = solve(s);
    }
    std::cout << s << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3260
//代码跟cqz抄的不知名代码一样 
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;
 
long long ans=0;
int tot=0,h[100005];
int n,m,x,y,S,T,k[100005],siz[100005];
int s[100005],top;
bool odd;
struct Edge{
    int x,next;
}e[200005];
 
inline void add_edge(int x,int y){
    e[++tot].x=y;
    e[tot].next=h[x],h[x]=tot;
}
 
void dfs1(int x,int fa){
    for(int i=h[x];i;i=e[i].next){
        if(e[i].x==fa)continue;
        if(siz[e[i].x]){
            if(siz[x]==siz[e[i].x])odd=true;
            S=x,T=e[i].x;
        }else{
            siz[e[i].x]=-siz[x];
            dfs1(e[i].x,x);
        }
    }
}
 
void dfs2(int x,int fa){
    for(int i=h[x];i;i=e[i].next){
        if(e[i].x==fa||(x==S&&e[i].x==T)||(x==T&&e[i].x==S))continue;
        dfs2(e[i].x,x);
        siz[x]+=siz[e[i].x];
        k[x]+=k[e[i].x];
    }
}
 
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d",&x,&y);
        add_edge(x,y);
        add_edge(y,x);
    }
    siz[1]=1,dfs1(1,0);
    int sum=0;
    for(int i=1;i<=n;i++)sum+=siz[i];
    if(m==n-1){
        if(sum)return printf("-1"),0;
    }else{
        if(odd){
            if(sum&1)return printf("-1"),0;
            ans+=abs(sum>>1);
            siz[S]-=sum>>1,siz[T]-=sum>>1;
        }else{
            if(sum)return printf("-1"),0;
            else k[S]=1,k[T]=-1;
        }
    }
    dfs2(1,0);
    for(int i=1;i<=n;i++){
        if(k[i])s[++top]=k[i]*siz[i];
        else ans+=abs(siz[i]);
    }
    s[++top]=0;
    sort(s+1,s+top+1);
    int mid=s[top+1>>1];
    for(int i=1;i<=top;i++)ans+=abs(s[i]-mid);
    printf("%lld",ans);
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

// <------------- Declare Variables Here ------------> //

ll t=1;
ll n,x;
string s;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n>>x;
	if(n > x) {
		cout<<"safe";
	}
	else cout<<"unsafe";
}

int main() {
	fastio;randomINT;
	//cin>>t;
	while(t--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 238028
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
 
int main()
{
    int a, b;
  
 // 整数の入力
    scanf("%d", &a);
    scanf("%d", &b);
 // printf("%d\n",N);

    if((a + b) % 2)
    printf("%d\n", (((a + b) /2) + 1));
    else
    printf("%d\n", ((a + b) /2));
    return 0;
}

Measured memory_bytes: 128
# -*- coding:utf-8 -*-
import sys

def solve():
    A, B, C = map(int, sys.stdin.readline().split())
    if ((A==B and A!=C and B!=C) or
        (B==C and B!=A and C!=A) or
        (C==A and C!=B and A!=B)):
        print("Yes")
        return
    print("No")

if __name__ == "__main__":
    solve()


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() {
    ll n; cin >> n;
    __int128 ans = 1;
    rep(i,n) {
        ll a; cin >> a;
        if (a == 0) ans = 0;
        if (ans != -1) ans *= __int128(a);
        if (ans > __int128(1e18)) ans = -1;
        // cerr << ll(ans) << endl;
    }
    cout << ll(ans) << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// 解説写経
int main(){
  int N,M; cin >> N >> M;
  vector<ll> X(N); ll cnt[100010] = {};
  for(int i = 0; i < N; i++){ cin >> X[i]; cnt[X[i]]++;}
  
  vector<ll> Mod(M,0);
  vector<ll> Pr(M,0);
  
  for(int i = 0; i < 100010; i++){
    Mod[i%M] += cnt[i]; 
    Pr[i%M] += (cnt[i]/2)*2;
  }
  
  ll ans = 0;
  
  ans += Mod[0]/2;
  
  for(ll i = 1; i < (M+1)/2; i++){
    ll c = min(Mod[i],Mod[M-i]);
    ans += c;
    Mod[i] -= c;
    Mod[M-i] -= c;
  }
  
  if( M%2 == 0 ){ 
    ans += Mod[M/2]/2;
    Mod[M/2] = 0;
    
  }

  for(ll i = 1; i < M; i++){
    ans += min(Mod[i],Pr[i])/2;
  }
  
  cout << ans << endl;
  
  return 0;
}
  

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
 typedef pair<int,int> ii;
 typedef vector<ii> vii;
 typedef vector <int > vi;
//vector <vi> adj(MAX); 
priority_queue<ll> v1,v2,v3,v4,v5,v6;
//multimap<ll,ll> m1,m2;

int main()
{
 //freopen("input.txt","r",stdin);
 //freopen("output.txt","w",stdout);
 ios::sync_with_stdio(false);
cin.tie(0);
 ll a,b;
 string arr[105];
 cin>>a>>b;
 for(ll i=0;i<a;i++)
    cin>>arr[i];
 for(ll i=0;i<=b+1;i++)
  cout<<"#";
cout<<endl;
for(ll i=0;i<a;i++)
 {
  cout<<"#";
    cout<<arr[i];
  cout<<"#"<<endl;
 }
 for(ll i=0;i<=b+1;i++)
  cout<<"#";
return 0;


}

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

using namespace std;

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

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n);
	rep(i,n) cin >>a[i];
	sort(all(a));
	a.push_back(-1);
	int ans =0, ct =1;
	rep(i,n){
		if(a[i] != a[i+1]){
			if(ct %2) ans ++;
			ct = 1;
		}else ct++;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 1024
d = int(input())
c = list(map(int, input().split()))
s = [[0]*26 for _ in range(d)]

for i in range(d):
    s[i] = list(map(int, input().split()))

v = [0]*d
for i in range(d):
    v[i] = int(input())

lday = [0]*26
sat = 0
for i in range(d):
    lday[v[i]-1] = i+1
    sat = sat + s[i][v[i]-1]
    for j in range(26):
        sat = sat - c[j]*(i+1 - lday[j])
    print(sat)

Measured memory_bytes: 9368
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

signed main()
{	
	int h, w, k;
	cin >> h >> w >> k;
	V<string> m(h);
	RBF(mi, m) {
		cin >> mi;
	}

	V<string> m2(m);
	const string red(w, 'r');

	int ans = 0;
	for (unsigned i = 0; i < (1u << h); i++) {
		m2 = m;
		bitset<6> hbit(i);
		REP(x, h) {
			if (hbit[x]) m2[x] = red;
		}
		V<string> m3(m2);

		for (unsigned j = 0; j < (1u << w); j++) {
			m2 = m3;
			bitset<6> wbit(j);
			REP(x, w) {
				if (wbit[x]) {
					REP(y, h) {
						m2[y][x] = 'r';
					}
				}
			}

			int tmp = 0;
			RBF(mi, m2) {
				RBF(c, mi) {
					if (c == '#') tmp++;
				}
			}

			if (tmp == k) ans++;
		}
	}

	col(ans);
	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
using namespace std;
long long const MAX_N = 1000000;
bool prim[MAX_N+1];
long long num_prim(long long n){
	long long count = 0;
	for (int i = 2; i <= n; i++)
		prim[i] = true;
	if (n > 2){
		for (int i = 2; i <= n; i++){
			if (prim[i]){
				for (int j = i * 2;j <= n; j += i){
					prim[j] = false;
				}
			}
		}
		for (int i = 2; i <= n; i++)
			if (prim[i])
				count++;
	}
	else{
		count = n - 1;
	}
	
	return count;
}
int main(){
	long long n;
	while (cin >> n){
		cout << num_prim(n)<<endl;
	}
}

Measured memory_bytes: 4036
from sys import stdin
from collections import deque

num = int(input())

q = deque()

for i in range(num):
	cmd = stdin.readline().strip().split()
	if cmd[0] == "0":
		if cmd[1] == "0":
			q.appendleft(cmd[2])
		else:
			q.append(cmd[2])
	elif cmd[0] == "1":
		print(q[int(cmd[1])],sep='\n')
	else:
		if cmd[1] == "0":
			q.popleft()
		else:
			q.pop()




Measured memory_bytes: 34660
#include <iostream>
#include <stdio.h>
#include <set>
#define MAXSIZE 100010
using namespace std;
long long a[MAXSIZE];
set<long long> st;

int main()
{
    int n;
    int num = 0;
    set<long long>::iterator it;
    cin>>n;
    for(int i = 0;i < n;i++)
    {
        cin>>a[i];
        it = st.find(a[i]);
        if(it == st.end())
        {
            st.insert(a[i]);
            num++;
        }
        else
        {
            st.erase(a[i]);
            num--;
        }
    }
    cout<<num<<endl;
    return 0;
}


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

void solve() {
    int X;
    cin >> X;

    for(auto i = 0; i <= X / 100; ++i) {
        int min_val = 100 * i;
        int max_val = 105 * i;

        if(X >= min_val && X <= max_val) {
            cout << 1 << endl;
            return;
        }
    }

    cout << 0 << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t;
    //cin >> t;
    //for(auto i = 0; i < t; ++i)
        solve();
}


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

using namespace std;

const int N = 1e5 + 10;

int x[N];

int main() {
	int n, k, pos, ans = INT_MAX;
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; ++ i)
		scanf("%d", &x[i]);
	pos = lower_bound(x + 1, x + n + 1, 0) - x;
	if(pos > n) return printf("%d\n", -x[n - k + 1]), 0;
	for(int i = pos; i <= min(n, pos + k - 1); ++ i)
		if(i - k + 1 >= 1) 
			ans = min(ans, abs(x[i]) * 2 + abs(x[i - k + 1]));
	for(int i = max(pos - k + 1, 1); i <= pos; ++ i)
		if(i + k - 1 <= n) 
			ans = min(ans, abs(x[i]) * 2 + abs(x[i + k - 1]));
	if(pos + k - 1 <= n) ans = min(ans, abs(x[pos + k - 1]));
	if(pos - k >= 1) ans = min(ans, abs(x[pos - k]));
	cout << ans << endl;
	return 0;
}


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

int main()
{
	LL a,b,n;
	cin>>a>>b>>n;
    LL f1,f2,c;
    c=min(b-1,n);
    f1=a*c/b;
	cout<<f1<<endl; 
	return 0;
}

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

long rec(int a[], int n, long **mem, int i, int j, long sum[])
{
  if(i==j)
    return 0;          
  if(mem[i][j]!=1e18)
    return mem[i][j];
  for(int k=i;k<=j;k++)
    mem[i][j]=min(mem[i][j],rec(a,n,mem,i,k,sum)+rec(a,n,mem,k+1,j,sum)+sum[j+1]-sum[i]);
  return mem[i][j];
}

int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  long **mem=new long*[n+1];
  for(int i=0;i<=n;i++)
  {
    mem[i]=new long[n+1];
    for(int j=0;j<=n;j++)
      mem[i][j]=1e18;
  }
  long sum[n+1];
  for(int i=1;i<=n;i++)
    sum[i]=a[i-1];
  sum[0]=0;
  for(int i=1;i<=n;i++)
    sum[i]+=sum[i-1];
  cout<<rec(a,n,mem,0,n-1,sum);

}

Measured memory_bytes: 1536
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.concurrent.CountDownLatch;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();

        final List<Integer> list = IntStream.range(0, n)
                .mapToObj(i -> scanner.nextInt())
                .collect(Collectors.toList());

        final Map<Integer, Integer> countMap = new HashMap<>();
        for (int i = 0; i < n; i++) {
            final int a = list.get(i);
            countMap.compute(a, (k, v) -> v == null ? 1 : v + 1);
        }

        long all = 0;
        for (final long value : countMap.values()) {
            all += value * (value - 1) / 2;
        }

        for (final int a : list) {
            final int count = countMap.get(a);
            if (count == 1) {
                System.out.println(all);
            } else {
                System.out.println(all - count * (count - 1) / 2 + (count - 2) * (count - 1) / 2);
            }
        }
    }
}


Measured memory_bytes: 129428
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int x = sc.nextInt();
                if(x > 2 && x < 8 && x % 2 != 0){
                        System.out.println("YES");
                }else{
                        System.out.println("NO");
                }
        }
}
//条件カッコよくした

Measured memory_bytes: 36064
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60
ll mod = 1e9+7;

void dfs(int s, map<int, vector<int>>& graph, vector<vector<ll>>& dp, vector<bool>& visited) {
    if(visited[s]) return;
    visited[s] = true;
    auto children = graph[s];
    bool is_leaf = true;

    for(auto v: children) {
        if(visited[v]==false) {
            is_leaf = false;
            dfs(v, graph, dp, visited);
            (dp[s][0] *= dp[v][0] + dp[v][1]) %= mod;
            (dp[s][1] *= dp[v][0]) %= mod;
        }
    }

    if(is_leaf) {
        dp[s][0] = ll(1);
        dp[s][1] = ll(1);
    }
}

int main() {
    int N;
    cin >> N;
    map<int, vector<int>> graph;
    for(int i=0; i<N-1; i++) {
        int a, b;
        cin >> a >> b;
        graph[a-1].push_back(b-1);
        graph[b-1].push_back(a-1);
    }

    vector<bool> visited(N, false);
    // dp[i]: iをrootする木に関して, dp[i][0]: color(i) = White, dp[i][1]: color(i) = Blackの時のそれぞれの塗り方
    vector<vector<ll>> dp(N, vector<ll>(2, 1));
    dfs(0, graph, dp, visited);
    
    cout << (dp[0][0] + dp[0][1]) % mod << endl;

    return 0;
}

Measured memory_bytes: 27776
/*

Author : AllKilled
Date   : 201911096

Contest: NIKKEI Programming Contest 2019-2.
Problem: Task B.
Result :

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

typedef long long LL;

const LL MOD = 998244353LL;
const LL MAXN = 1e6+7;

///--------------------------------------------///

LL n, ans, f[MAXN], g[MAXN];

LL qp(LL a, LL b){
    LL res = 1;
    for(; b; b >>= 1){
        if(b&1) res = res * a % MOD;
        a = a * a % MOD;
    }
    return res;
}

int main()
{
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> f[i];
        g[f[i]]++;
    }

    for(int i = 0; g[i]; ++i){
        ans += g[i];
    }

    if(g[0] != 1 || f[1] || ans != n) {
        cout << 0;
        return 0;
    }

    ans = 1;
    for(int i = 1; g[i]; ++i){
        ans = ans * qp(g[i-1], g[i]) % MOD;
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 5120