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

using namespace std;
typedef long long ll;
const int N = 5050;

int n, k;
ll p[N], pp[N][35], val[N][35], Max[N][35], c[N];
ll ans = -0x7fffffff;

int main() 
{
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; ++i) scanf("%lld", &p[i]);
	for(int i = 1; i <= n; ++i) scanf("%lld", &c[i]);
	for(int i = 1; i <= n; ++i) Max[i][0] = val[i][0] = c[p[i]], pp[i][0] = p[i];

	for(int j = 1; j < 32; ++j)
		for(int i = 1;i <= n; ++i)
			pp[i][j] = pp[pp[i][j - 1]][j - 1],
			val[i][j] = val[i][j - 1] + val[pp[i][j - 1]][j - 1],
			Max[i][j] = max(Max[i][j - 1], val[i][j - 1] + Max[pp[i][j - 1]][j - 1]);

	for(int i = 1;i <= n; ++i) 
	{
		ll K = k, P = i, V = 0, A = -0x7fffffff;
		for(int j = 30; j >= 0; --j) 
		{
			if(K & (1 << j)) 
			{
				A = max(A, V + Max[P][j]);
				V += val[P][j];
				P = pp[P][j];
			}
		}

		ans = max(ans, A);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7956
using System;

namespace AIZUJudge {
    class Factorial {
        static void Main(string[] args) {
            string data = Console.ReadLine();
            long n = int.Parse(data);

            for (long i = n-1; i > 0; i--) {
                 n *= i;
            }
            Console.WriteLine(n);
       }
    }
}

Measured memory_bytes: 9132
#include<iostream>
#include<cmath>

using namespace std;














int main(){

     int X = 0;
     int a=0;
     int b = 0;
     int i=0;

     int y=0;

     cin >> X;
     cin >> a;
     cin >> b;

     y=X-a;



     while(1){
         if(y<0){
          cout  << y+b;
          break;
        }
      y=y-b;
      //cout << i << " " << y << endl;
      //i++;
     }

     
 
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
using namespace std;
int main()
{
	int a, b, t, ans=0;
	cin >> a >> b >> t;
	int i = 1;
	while (i<=t)
	{
		if (i%a == 0)
		{
			ans += b;
		}
		i++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define M 1000000007
 
signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	
	int a,b;
	cin >> a >> b;
	cout << 3+2+1-a-b << endl;
}

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

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

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            for (int k = 1; k <= n; ++k) {
                ans += gcd(gcd(i, j), k);
            }
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 100000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
#define endl '\n'
#define mo 998244353
 
using namespace std ;
 
#define MAXN 100000 + 5 

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

vll v[MAXN] ;
bool vis[MAXN];
lli dp[MAXN][2];

void dfs(lli q)
{
    vis[q] = 1;

    lli ans1=1,ans2=1;

    for(auto x:v[q])
    {
        if(!vis[x])
        {
            dfs(x);
            ans1  = (ans1*((dp[x][0] + dp[x][1])%mod))%mod;
            ans2  = (ans2*dp[x][0])%mod ;
        }
    }

    if(v[q].size() == 0 && q!=1)
    dp[q][0] = dp[q][1] = 1;

    else
    {
        dp[q][0] = ans1;
        dp[q][1] = ans2; 
    }


}


int main()
{
///////////////////////////////////////////
    fastio;
///////////////////////////////////////////

    lli n;
    cin>>n;

    memset(dp,1,sizeof(dp));
    loopl(i,0,n-1) 
    {
        lli x,y;
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }    

    dfs(1);

    cout<<(dp[1][0] + dp[1][1])%mod<<endl;

}

Measured memory_bytes: 14336
#include <stdio.h>

int main(void)
{
    int input, hour, min, sec;

    scanf("%d", &input);
    sec = input % 60;
    min = ((input - sec) % 3600) / 60;
    hour = (input - sec - min * 60) / 3600;
    printf("%d:%d:%d\n", hour, min, sec);

    return 0;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vl = vector<ll>;
using vs = vector<string>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

vector<vector<pii>> bit(40);
map<pii, ll> sum;

vector<pii> calc(int b, vector<pii> a){
	vector<pii> ans;
	for(auto && i : a){
		if(sum[i] & ((ll)1 << b)) ans.push_back(i);
	}
	return ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	vector<ll> b(n + 1);
	for(int i = 0; i < n; ++i){
		b[i + 1] = b[i] + a[i];
	}
	for(int i = 0; i < n; ++i){
		for(int j = i; j < n; ++j){
			sum[{i, j}] = b[j + 1] - b[i];
			// cout << "sum[" << i << "][" << j << "]: " << sum[{i, j}] << "\n";
		}
	}
	for(auto && p : sum){
		for(int i = 0; i < 40; ++i){
			if(p.second & ((ll)1 << i)) bit[i].push_back(p.first);
		}
	}
	for(int i = 0; i < 40; ++i){
		sort(begin(bit[i]), end(bit[i]));
	}
	
	for(int i = 40 - 1; i >= 0; --i){
		if(bit[i].size() > k){
			vector<pii> c{bit[i]};
			ll ans = (ll)1 << i;
			for(int j = i - 1; j >= 0; --j){
				vector<pii> d = calc(j, c);
				if(d.size() >= k){
					ans += (ll)1 << j;
					c = d;
				}
			}
			cout << ans << "\n";
			return 0;
		}
		else if(bit[i].size() == k){
			ll ans = ((ll)1 << 40) - 1;
			for(auto && i : bit[k]){
				ans &= sum[i];
			}
			cout << ans << "\n";
			return 0;
		}
	}
	cout << "0\n";
	return 0;
}


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

using namespace std;

int main() {
    int w, h, n, x, y, a, f[100][100] = { 0 }, ans = 0;

    cin >> w >> h >> n;
    while (n--) {
        cin >> x >> y >> a;
        if (a == 1) {
            for (int j = 0; j < x; ++j) {
                for (int i = 0; i < h; ++i) {
                    f[i][j] = 1;
                }
            }
        }
        else if (a == 2) {
            for (int j = x; j < w; ++j) {
                for (int i = 0; i < h; ++i) {
                    f[i][j] = 1;
                }
            }
        }
        else if (a == 3) {
            for (int i = 0; i < y; ++i) {
                for (int j = 0; j < w; ++j) {
                    f[i][j] = 1;
                }
            }
        }
        else {
            for (int i = y; i < h; ++i) {
                for (int j = 0; j < w; ++j) {
                    f[i][j] = 1;
                }
            }
        }
    }
    
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            ans += !f[i][j];
        }
    }
    cout << ans << endl;
     
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int counter = 0;
        int n = sc.nextInt();
        int x = sc.nextInt();
        while (!(n == 0 && x == 0)) {
            for (int a = 1; a <= n - 2; a++) {
                for (int b = a + 1; b <= n - 1; b++) {
                    for (int c = b + 1; c <= n; c++){
                        if((a + b + c) == x) {
                            counter++;
                            break;
                        }
                    }
                }
            }
            System.out.println(counter);
            counter = 0;
            n = sc.nextInt();
            x = sc.nextInt();
        }
    }
}



Measured memory_bytes: 26668
#include <iostream>
#include <vector>

using namespace std;

const int z = 1e9+7;

int fp(int a, int x) {
    if (x == 0) {
        return 1;
    }
    if (x % 2 == 1) {
        return 1ll * a * fp(a, x-1) % z;
    }
    int t = fp(a, x/2);
    return 1ll * t * t % z;
}

int rev(int a) {
    return fp(a, z - 2);
}

int c(int n, int m) {
    int ret = 1;
    for (int i = 1; i <= m; i++) {
        ret = 1ll * ret * (n - i + 1) % z;
        ret = 1ll * ret * rev(i) % z;
    }
    
    return ret;
}

int main() {
    int n, m;
    cin >> n >> m;
    
    vector<int> pc;
    for (int i = 2; i * i <= m; i++) {
        if (m % i == 0) {
            pc.push_back(0);
            while (m % i == 0) {
                pc[pc.size()-1]++;
                m /= i;
            }
        }
    }
    if (m != 1) {
        pc.push_back(1);
    } 
    
    int ans = 1;
    for (int i : pc) {
        ans = 1ll * ans * c(n+i-1, i) % z;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<deque>
#define fo(i,j,k) for(int i=j;i<=k;++i)
#define fd(i,j,k) for(int i=j;i>=k;--i)
#define ll long long
using namespace std;
const int N=50;
int a[N],tot=0;
deque<int> q;
void dfs(ll x){
	if(x==1) return;
	if(x&1) dfs(x-1),q.push_front(++tot);
	else dfs(x>>1),q.push_back(++tot);
}
int main()
{
	ll n;
	scanf("%lld",&n);
	dfs(n+1),printf("%d\n",tot<<1);
	fo(i,0,tot-1) printf("%d ",q[i]);
	fo(i,1,tot) printf("%d ",i);
}


Measured memory_bytes: 256
import fractions
N = int(input())
x = []
for i in range(N):
    a1,b1,c1,d1=[int(i) for i in input().split()]
    x.append([a1,b1,c1,d1])
for i in range(N):
  y = x[i]
  if y[0] < y[1]:
    print("No")
  elif y[1] > y[3]:
    print("No")
  elif y[1] > y[2]:
    ama = y[0] % y[1]
    mo = y[3] %  y[1]
    if mo == 0:
      if ama<= y[2]:
        print("Yes")
      else:
          print("No")
    elif mo <= y[1]-y[2]-1:
      print("No")
    else:
        to = y[1] % mo
        if to == 0:
          if ama<= y[2]:
            print("Yes")
          else:
              print("No")
        else:
          are = fractions.gcd(to, y[1])
          if are <= y[1]-y[2]-1:
            print("No")
          else:
            print("Yes")
          
  else:
    print("Yes")

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

#define fast ios::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
#define ll unsigned long long

int main(){
	fast
	
	string s,out="";
	
	cin>>s;
	
	int len=s.length();
	
	out+=s;
	
	if(s[len-1] != 's')
	{
		out+="s";
	}
	else if(s[len-1] == 's'){
		out+="es";
	}
	
	cout << out << endl;
	
	return 0;
}


Measured memory_bytes: 3664
#include  <iostream>

using namespace std;

int main()
{

	int S;
	int h;
	int m;
	int s;

	cin >> S;

	h = S / 3600;
	m = (S % 3600) / 60;
	s = (S % 3600) % 60;

	cout << h << ":" << m << ":" << s << endl;



	return 0;
}

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

int main(void) {
	int K, X;
	cin >> K >> X;

	for (int i = X - (K - 1); i <= X + (K - 1); i++) {
		if (i < -1000000)i = -1000000;
		cout << i << " ";
		if (i > 1000000) break;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
a, b, c, x = 4.times.map { gets.to_i }
cnt = 0
(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
      cnt += 1 if i * 500 + j * 100 + k * 50 == x
    end
  end
end

puts cnt

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define print(i) std::cout << (i) << '\n'
inline long long ceildiv(long long a, long long  b) { return (a+b-1)/b; }
typedef pair<long long,long long> P;
const long long inf = 10e7;
//int |x|<=2*10**9     long |x|<= 9*10**18
#define ll long long
int n;int cnt[4];
const long long mod = 1000000007;
double dp[330][330][330];
/*dp[i][j][k]:= 3*i,2*j,1*kの寿司*/
int main(){
   cin>>n;rep(i,n){int a;cin>>a;cnt[a]++;}
rep(i,n+1){rep(j,n+1){rep(k,n+1){int sum=i+j+k;
if (sum){dp[i][j][k]=(double)n/sum;
if (j>=1){dp[i][j][k]+=dp[i][j-1][k+1]*j/sum;}
if (i>=1) {dp[i][j][k]+=dp[i-1][j+1][k]*i/sum;}
if (k>=1){dp[i][j][k]+=dp[i][j][k-1]*k/sum;}
}else{dp[0][0][0]=0;} }}}
printf("%.15lf\n",dp[cnt[3]][cnt[2]][cnt[1]]);
}

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


int main() {
  int x;
  cin >> x;
  if(x==0)cout << 1 << endl;
  else cout << 0<< endl;
}


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

int main() {
  int res[1000] = {0}, cnt = 0;
  while (true) {
    int n, x;
    cin >> n >> x;
    if (n == 0 && x == 0)
      break;
    else {
      for (int i=1;i<=n;i++)
        for (int j=i+1;j<=n;j++)
          for (int k=j+1;k<=n;k++)
            if (i + j + k == x)
              res[cnt]++;
    }
    cnt++;
  }

  for (int i=0;i<cnt;i++)
    cout << res[i] << endl;
}



Measured memory_bytes: 3068
#include "bits/stdc++.h"
using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define RREPS(i,n) RFOR(i,1,n+1)
#define ALL(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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; }
using ll = long long;
#define int ll

bool Fcomp(const pair<int,int>& firstElof, const pair<int,int>& secondElof)
{return firstElof.F < secondElof.F;}
bool Scomp(const pair<int,int>& firstElof, const pair<int,int>& secondElof)
{return firstElof.S < secondElof.S;}

//**********

signed main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n=0;
    vector<int> sousa;
    int sum[2] = {0,0};
    int num = 0;
    bool minus = 1;
    int oe = 0;
    
    scanf("%lld",&n);
    int a[n];
    REP(i,n){
        scanf("%lld",&a[i]);
        if(minus && a[i]>0) minus=0;
        if(a[i]>=0) sum[i%2] += a[i];
    }
    
    if(minus){
        int maxi = -1;
        int max = -INF;
        REP(i,n){
            if(chmax(max,a[i])) maxi = i;
        }
        printf("%lld\n%lld\n",a[maxi],n-1);
        REP(i,n){
            if(i<maxi) printf("1\n");
            if(i>maxi) printf("%lld\n",n-i+1);
        }
        return 0;
    }
    
    int del = 0;
    if(sum[0]>sum[1]){
        RFOR(i,1,n-1){
            if(i%2==0 && a[i]<=0){sousa.pb(i); del += 2;}
        }
        if(a[0]<=0) {sousa.pb(0); sousa.pb(0); del+=2;}
        if(a[n-1]<=0 && n%2==1) {sousa.pb(n-1-del); del++; sousa.pb(n-1-del); del++;}
        else if(n%2==0){sousa.pb(n-1-del); del++;}
        REP(i,(n-del-1)/2){sousa.pb(1);}
    } else {
        oe = 1;
        RFOR(i,1,n-1){
            if(i%2==1 && a[i]<=0){sousa.pb(i); del += 2;}
        }
        if(a[n-1]<=0 && n%2==0) {sousa.pb(n-1-del); del++; sousa.pb(n-1-del); del++;}
        else if(n%2==1){sousa.pb(n-1-del); del++;}
        sousa.pb(0); del++;
        REP(i,(n-del-1)/2){sousa.pb(1);}
    }
    num = sousa.size();
    printf("%lld\n%lld\n",sum[oe],num);
    REP(i,num){printf("%lld\n",sousa[i]+1);}
    

    return 0;
    
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int num;
    scanf("%d",&num);
    int s[5005] = {};
    for(int i = 0; i < num; i++)
    {
        scanf("%d", &s[i]);
    }
    sort(s,s+num);
    int ans = 0;
    for(int i = 0; i < num; i++)
    {
        for(int j = i + 1; j < num; j++)
        {
            int dif = s[j] - s[i];
            int k = 2;
            while(*(lower_bound(s, s+num, s[i] + dif *k)) == s[i] + dif * k)
            {
                k++;
            }
            ans = max(ans, k);
        }
    }
    printf("%d\n",ans);
}



Measured memory_bytes: 3316
S = input()
flag = 0
if S == "keyence":
    flag = 1
for i in range(len(S)-3):
    if str(S[:i]) + str(S[(-1)*(7-i):]) == "keyence":
        flag = 1
if flag == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100005;
int n;
long long ans;
inline int read(){
	int ret=0;bool f=0;char ch=getchar();
	while(ch>'9'||ch<'0') f^=ch=='-',ch=getchar();
	while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=getchar();
	return f?-ret:ret;
}
int main(){
	n=read();
	for (int i=1,lst=0;i<=n;i++){
		int x=read();
		if(lst&&x) x--,ans++;
		ans+=x>>1,lst=x&1;
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    string t; cin>>t;
    if (t.size()>s.size()){
        cout<<"UNRESTORABLE\n";
        return 0;
    }
    vector<string> cand;
    rep(i,s.size()-t.size()+1){
        bool ok = true;
        rep(j,t.size()){
            if (!(s[i+j]=='?' || s[i+j]==t[j])){
                ok = false;
                break;
            }
        }
        if (ok){
            string tmp;
            rep(j,i){
                if (s[j]=='?') tmp.pb('a');
                else tmp.pb(s[j]);
            }
            tmp += t;
            FOR(j,i+t.size(),s.size()-1){
                if (s[j]=='?') tmp.pb('a');
                else tmp.pb(s[j]);
            }
            cand.pb(tmp);
        }
    }
    if (cand.empty()){
        cout<<"UNRESTORABLE\n";
        return 0;
    }
    sort(all(cand));
    cout<<cand[0]<<endl;
    return 0;
}


Measured memory_bytes: 256
L,R = list(map(int, input().split()))
if R-L >= 2019:
    print(0)
    exit()
    
s=set()
for i in range(L,R+1):
    if i%2019 in s:
        break
    s.add(i%2019)
l = list(s)

if 3 in l and 673 in l:
    print(0)
    exit()
    
print(min([(i*j)%2019 for i in l for j in l if i != j]))

Measured memory_bytes: 10696
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define N 100010
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 n,m,rt[N],owo=0;
struct node{
	int lc,rc,x;
}tree[N*3*20];
struct point{
	int x,y;
}a[N*3];
inline bool cmp(point x,point y){return x.x<y.x;}
inline void add(int &p,int l,int r,int x){
	tree[++owo]=tree[p];p=owo;tree[p].x++;
	if(l==r) return;int mid=l+r>>1;
	if(x<=mid) add(tree[p].lc,l,mid,x);
	else add(tree[p].rc,mid+1,r,x);
}
inline int ask(int p1,int p2,int l,int r,int x,int y){
	if(x<=l&&r<=y) return tree[p2].x-tree[p1].x;
	int mid=l+r>>1,res=0;
	if(x<=mid) res+=ask(tree[p1].lc,tree[p2].lc,l,mid,x,y);
	if(y>mid) res+=ask(tree[p1].rc,tree[p2].rc,mid+1,r,x,y);
	return res;
}
int main(){
//	freopen("a.in","r",stdin);
	n=read();m=read();
	for(int i=1;i<=n;++i) a[i].x=read(),a[i].y=read();
	sort(a+1,a+n+1,cmp);int now=1;
	for(int i=1;i<=m;++i){
		rt[i]=rt[i-1];
		while(now<=n&&a[now].x==i){
			add(rt[i],1,m,a[now].y);++now;
		}
	}printf("%d\n",n);
	for(int i=2;i<=m;++i){
		int ans=n,x=i;
		for(x=i;x<=m;x+=i) ans-=ask(rt[x-i],rt[x-1],1,m,x-i+1,x-1);
		if(x-i+1<=m) ans-=ask(rt[x-i],rt[m],1,m,x-i+1,m);printf("%d\n",ans);
	}return 0;
}

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

int main(){

  int A,B,C,D;

  cin >> A >> B >> C >> D;

  while(1){
    C = C - B;
    if(C < 1){
      cout << "Yes" << endl;
      break;
    }else{
      A = A - D;
      if(A < 1){
        cout << "No" << endl;
        break;
      }
    }
  }

}


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

using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP(x)	make_pair(x)
 
#define debug(_x)		cerr << #_x << '=' << _x << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << _x << ' ' << #_y << '=' << _y << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << _x << ' '; cerr << endl;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN/2;

const double PI = 3.14159265358979311;
int32_t main() {
	FAST_IO;
	
	int r;
	cin >> r;
	
	cout << PI*2*r << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


Measured memory_bytes: 3760
#include <iostream>
using namespace std;
int main(){
  char c;
  cin >> c;
  if(c == 'A') cout << 'T' << endl;
  else if(c == 'T') cout << 'A' << endl;
  else if(c == 'C') cout << 'G' << endl;
  else cout << 'C' << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int H = scan.nextInt();
        int W = scan.nextInt();
        int K = scan.nextInt();
        char[][] map = new char[H][W];
        for (int i = 0; i < H; i++) {
            map[i] = scan.next().toCharArray();
        }
        long max = pow(2, H - 1);
        int ans = Integer.MAX_VALUE;
        for (int bit = 0; bit < max; bit++) {
            ans = Math.min(ans, child(H, W, K, map, bit));
        }
        System.out.println(ans);
    }

    int child(int H, int W, int K, char[][] map, int bit) {
        List<Range> ranges = ranges(H, bit);
        int[] whites = new int[ranges.size()];
        int ranges_len = ranges.size();
        int cut = ranges_len-1;
        int previous_block_total = 0;
        int block_total = 0;
        for (int j = 0; j < W; j++) {
            for (int i = 0; i < H; i++) {
                if (map[i][j] == '0') {
                    continue;
                }
                for (int k = 0; k < ranges_len; k++) {
                    Range x = ranges.get(k);
                    if (x.from <= i && i <= x.to) {
                        whites[k] += 1;
                        block_total += 1;
                    }
                }
            }
            boolean overK = false;
            for (int k = 0; k < ranges_len; k++) {
                if (K < whites[k]) {
                    overK = true;
                    continue;
                }
            }
            if (overK) {
                j -= 1;
                Arrays.fill(whites, 0);
                cut += 1;
                block_total = 0;
                if (previous_block_total == 0) {
                    return Integer.MAX_VALUE;
                }
            }
            previous_block_total = block_total;
        }
        return cut;
    }
    List<Range> ranges(int H, int x) {
        int previous = 0;
        List<Range> range = new ArrayList<>();
        int base = 1;
        for (int i = 0; i < H-1; i++) {
            if (0 < (base & x)) {
                Range r = new Range(previous, i);
                range.add(r);
                previous = i + 1;
            }
            base *= 2;
        }
        Range r = new Range(previous, H-1);
        range.add(r);
        return range;

    }

    long pow(int base, int x) {
        if (x == 0) {
            return 1L;
        }
        if (x % 2 == 1) {
            return (long) base * pow(base, x - 1);
        }
        long t = pow(base, x / 2);
        return t * t;
    }

    class Range {
        int from;
        int to;
        Range(int from, int to) {
            this.from = from;
            this.to = to;
        }
    }
}


Measured memory_bytes: 23252
n = int(input())
s = input()
x = 0
for i in range(1,n):
    count=0
    for j in "abcdefghijklmnopqrstuvwxyz":
        if j in s[0:i] and j in s[i:n]:
            count += 1
        if count > x:
            x = count
print(x)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#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(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

template<typename T>
vector<pair<T,long long>> RunLengthEncoder(vector<T> &v){
    vector<pair<T,long long>> RLE;
    long long cnt = 1;
    for(int i = 0; i < (int)v.size(); ++i){
        if(i == (int)v.size()-1){
            RLE.push_back(make_pair(v[i], cnt));
            continue;
        }
        if(v[i] == v[i+1])cnt++;
        else{
            RLE.push_back(make_pair(v[i],cnt));
            cnt = 1;
        }
    }
    return RLE;
}

vector<pair<char,long long>> RunLengthEncoder_ForString(string v){
    vector<pair<char,long long>> RLE;
    long long cnt = 1;
    for(int i = 0; i < (int)v.size(); ++i){
        if(i == (int)v.size()-1){
            RLE.push_back(make_pair(v[i], cnt));
            continue;
        }
        if(v[i] == v[i+1])cnt++;
        else{
            RLE.push_back(make_pair(v[i],cnt));
            cnt = 1;
        }
    }
    return RLE;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    string S;
    cin >> S;
    ll cntr = 0;
    rep(i,N)cntr += S[i] == 'R';
    auto v = RunLengthEncoder_ForString(S);
    ll ans = 0;
    rep(i,cntr){
        ans += S[i] == 'W';
    }
    cout << ans << endl;
}


Measured memory_bytes: 5720
#include <stdio.h>
int main()
{
	int a,b,sum=1;
	scanf("%d %d",&a,&b);
	for(int i=0;i<a;i++)
	{
		if(sum<b)
			sum = 2*sum;
		else
			sum +=b;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<set>
#include<string.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  string str[N];
  for(int i=0;i<N;i++) cin >> str[i];

  set<string> result;

  for(int i=0;i<N;i++) result.insert(str[i]);

  cout << result.size() << endl;



}

Measured memory_bytes: 25520
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N;
    cin >> N;
    cout << N / 2 + N % 2 << endl;
    return 0;
}

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

int main(void) {
	int i;
	int candy;
	int N;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);

	candy = 0;
	for(i = 0; i < N; i+= 1) {
		candy += i + 1;
	}

	printf("%d\n", candy);

	return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
int n,sum,pre,ans;
int main()
{
	scanf("%d",&n);
	for(register int i=1,x;i<=n;i++)
	{
		scanf("%d",&x);
		if(x>pre)
			sum=0;
		else
			sum++;
		if(sum>ans)
			ans=sum;
		pre=x;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>

using ll = long long;

struct City {
    int cityNum;
    int prefNum;
    int y;
    ll id;
};

int main() {
    int N, M;
    std::cin >> N >> M;

    std::vector<City> C(M);
    std::vector<int> pref(N + 1);

    for (int i = 0; i < M; i++) {
        int p, y;
        std::cin >> p >> y;
        C[i].cityNum = i;
        C[i].prefNum = p;
        C[i].y = y;
    }

    std::sort(C.begin(), C.end(), [](auto c1, auto c2)->bool {return c1.y < c2.y; });

    for (int i = 0; i < M; i++) {
        pref[C[i].prefNum]++;
        C[i].id = (ll)C[i].prefNum * 1000000 + pref[C[i].prefNum];
    }

    std::sort(C.begin(), C.end(), [](auto c1, auto c2)->bool {return c1.cityNum < c2.cityNum; });
    for (int i = 0; i < M; i++) {
        std::cout << std::setfill('0') << std::right << std::setw(12) << C[i].id << std::endl;
    }

    return 0;
}


Measured memory_bytes: 4224
#include <iostream>

using namespace std;

typedef long long ll;

#define MAXQ 50

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

    int n,m,q;

    cin >> n >> m >> q;

    int a[MAXQ];
    int b[MAXQ];
    int c[MAXQ];
    int d[MAXQ];
    int A[92378][10];
    int score = 0;
    int i;

    for (int p = 0; p < q; ++p)
        cin >> a[p] >> b[p] >> c[p] >> d[p];

    for (int k = 0; k < n; ++k)
        A[0][k] = 1;

    for (i = 1; ; ++i) {
        if (A[i-1][n-1] == m) {
            int j;
            for (j = n-2; j >= 0 && A[i-1][j] == m; --j) {
            }
            if (j == -1) {
                break;
            } else {
                for (int k = 0; k < n; ++k) {
                    if (k == j)
                        A[i][k] = A[i-1][k] + 1;
                    else if (k >= j+1 && k <= n-1)
                        A[i][k] = A[i][j];
                    else
                        A[i][k] = A[i-1][k];
                }
            }
        } else {
            for (int k = 0; k <= n-2; ++k)
                A[i][k] = A[i-1][k];
            A[i][n-1] = A[i-1][n-1] + 1;
        }
    }

    for (int j = 0; j < i; ++j) {
        int tmp = 0;
        for (int p = 0; p < q; ++p) {
            if (A[j][b[p]-1] - A[j][a[p]-1] == c[p])
                tmp += d[p];
        }
        if (tmp > score)
            score = tmp;
    }

    cout << score;

    return 0;
}


Measured memory_bytes: 7256
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n,q;
	cin >> n >> q;
	vector<stack<int> > v(n);

	for (int i = 0; i < q; i++) {
		int c; cin >> c;
		if (c == 0) {
			int x,t;
			cin >> t >> x;
			v[t].push(x);
		}
		else if (c == 1) {
			int t;
			cin >> t;
			if(!v[t].empty()) cout << v[t].top() << endl;
		}
		else {
			int t; cin >> t;
			if (!v[t].empty()) v[t].pop();
		}
	}
}
	



Measured memory_bytes: 4368
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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

//想定解答との絶対誤差または相対誤差が 10−6以下の場合+1以上だしておく。適当に15とかでもおｋ．
//cout << fixed << setprecision(15);

int main() {
    string s;
    ll a, b, c;
    cin >> a >> b >> c;
    ll right = (c-a-b)*(c-a-b);
    ll left = 4*a*b;
    if (left<right) {
        if (c-a-b<=0) {
         cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i

edges = []
g = Array.new(n+1){ [] }
(n-1).times do |i|
  a, b = gets.split.map(&:to_i)
  a, b = b, a if a > b # 辺は頂点 i < j の形で入れる。
  g[a] << b # 隣接リストに
  g[b] << a # 反対向きにも隣接リストに.無向グラフなので
  edges << [a,b] # 辺リストにいれる。辺が識別されてて、最後に辺リストから辺を回して色をとりだす。
end

colors = Hash.new() # Esge => color # 辺についてO(1)で使った色を見れる。O(1)はホントに?
colors_used = Array.new(n+1){Hash.new} # 頂点と色についてO(1)で使ったか確かめられる。
used = Array.new(n){false} # 頂点について探索済みかどうかO(1)でわかる。
que = [1] # 頂点0から見ていくので0が入っている # 探索待ちの未探索の頂点リスト

k = 0 # 答えとなる色の数
while !que.empty? do
  v = que.shift # queにある頂点を取り出す. 破壊的メソッドなので先頭は削除される。
  cur = 1 # 使ってない色がわからないので、とりあず色1から見ていく。
  g[v].each do |w| # vの隣接頂点wを見ていく。
    next if used[w] == true # 探索済みの頂点なら見ない。
    k = g[v].size if k < g[v].size  # 隣接する頂点数より色数が小さければ色数を更新
    v<w ? (i,j = v,w) : (i,j = w,v) # i < jの並びで頂点を捉える。
    # next if colors[[i,j]] != nil # nilでなければi-jの辺に色がついてて頂点jは探索済みで,次に。
    cur += 1 while colors_used[v][cur] == true # v周りの頂点で色をつかっていれば次の色に更新していく。塗る前に使ってない色にする。
    colors_used[v][cur] = true # vに色を使ったので記録する。
    colors_used[w][cur] = true # wに色を使ったので記録する。
    colors[[i,j]] = cur # 辺に使った色をいれる。
    que.push(w) #探索待ちの未探索頂点リストに頂点wを入れる。
  end
  used[v] = true # 頂点vを探索済みにする。
end

puts k
edges.each{ |e| puts colors[e] }

Measured memory_bytes: 58620
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n;
    cin>>n;
    long long int sum=0;
    std::deque<long long int> deq;
    long long int tmp=0;
    for (int i=1;i<=n;i++) {
        sum+=i;
        deq.emplace_back(i);
        if (sum>n) {
            tmp=sum-n;
            break;
        }
    }
    for (int i=0;i<deq.size();i++) {
        if (deq[i]!=tmp) {
            cout<<deq[i]<<endl;
        }
    }
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

char s[200010];
int szS;

int main()
{
	scanf("%s\n", s);
	szS = strlen(s);
	for (int i = 0 ; i < szS ; i++) {
		if (s[i] == '?')
			s[i] = 'D';
	}
	printf("%s\n", s);
	
	return 0;
}


Measured memory_bytes: 1856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int sum2 = 0;
  int sum4 = 0;
  for(int i=0; i<n; i++){
    if(a[i]%2==0 && a[i]%4!=0){
      sum2++;
    }
    if(a[i]%4==0) sum4++;
  }
  if(sum2>0){
    if((n-sum2+1)/2<=sum4) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else{
    if(n/2<=sum4) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 640
from collections import Counter

s = list(input())
chain = {}
abcs = []
kugiri = 0
countA = 0
ans = 0

for i in range(1,len(s)):
    if not((s[i] == "B" and s[i-1] == "C") or (s[i] == "B" and s[i-1] == "A") or (s[i] == "C" and s[i-1] == "B") or (s[i] == "A" and s[i-1] == "C") or (s[i] == "A" and s[i-1] == "A")):
        kugiri = i
        countA = 0
    elif s[i-1] == "A":
        countA += 1
    if s[i] == "C" and s[i-1] == "B":
        ans += countA

print(ans)


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

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vector<int> dist(n);
  function<void(int, int, int)> dfs = [&](int v, int pv, int d) {
    dist[v] = d;
    for (int to : g[v]) {
      if (to == pv) {
        continue;
      }
      dfs(to, v, d + 1);
    }
  };
  int ans = n;
  if (k % 2 == 0) {
    for (int v = 0; v < n; ++v) {
      dfs(v, -1, 0);
      int cnt = 0;
      for (int i = 0; i < n; ++i) {
        cnt += (dist[i] > k / 2);
      }
      ans = min(ans, cnt);
    }
  } else {
    for (int v = 0; v < n; ++v) {
      for (int u : g[v]) {
        dfs(v, u, 0);
        dfs(u, v, 0);
        int cnt = 0;
        for (int i = 0; i < n; ++i) {
          cnt += (dist[i] > (k - 1) / 2);
        }
        ans = min(ans, cnt);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>

using namespace std;

int n, a[200005], b[200005];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i], &b[i]);
  }
  sort(a, a + n);
  sort(b, b + n);
  if (n % 2 == 1) {
    int m = (n - 1) / 2;
    printf("%d\n", b[m] - a[m] + 1);
  } else {
    int m1 = n / 2 - 1;
    int m2 = n / 2;
    printf("%d\n", b[m1] + b[m2] - a[m1] - a[m2] + 1);
  }
}


Measured memory_bytes: 3288
#include <iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<vector>
using namespace std;

void debugout ( long long value ){
    cout << value  << endl;
}

int main(){

    int BallsAmount;
    cin >> BallsAmount;
    vector<int> BallsNum(BallsAmount);
    vector<long long> EqualNum(BallsAmount+1,0); // Amount+1防止在表示从1-BallAmount时vector越界

    for( int i = 0 ; i < BallsAmount ; i++){
        cin >> BallsNum[i];
        EqualNum[BallsNum[i]]++;
    }

    long long sum = 0;

    // 计算相同数字的排列组合，此时的BallAmount表示自然数
    for( int i = 1 ; i <= BallsAmount ; i++){
        if( EqualNum[i] >= 2 ){
            sum += ( EqualNum[i] * (EqualNum[i]-1) ) / 2 ;
        }
    }

    // 计算排除i-th球上的数字时的排列组合，此时从sum中减去即可，C(n,2)-C(n-1,2)=n-1
    for( int i = 0 ; i < BallsAmount ; i++){
        long long output = sum - EqualNum[BallsNum[i]] + 1 ;
        cout << output <<endl;
    }
    return 0;
}



Measured memory_bytes: 4992
import sys
n = int(input())
a = list(map(int, input().split()))

for ele in a:
  if ele == 0:
    print(0)
    sys.exit()

num = 1
for ele in a:
  num *= ele
  if num > 1000000000000000000:
    print(-1)
    sys.exit()

print(num)


Measured memory_bytes: 21476
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int count(vector<int> a, vector<int> b, int bit) {
	int mn = (1 << bit), mx = (1 << bit + 1) - 1, cnt = 0;
	for (auto &it : a)
		it &= mx;
	for (auto &it : b)
		it &= mx;
	sort(all(b));
	for (int i = 0; i < sz(a); i++) {
		cnt += upper_bound(all(b), mx - a[i]) - lower_bound(all(b), mn - a[i]);
		cnt += upper_bound(all(b), mx + 1 + mx - a[i])
				- lower_bound(all(b), mx + 1 + mn - a[i]);
		cnt &= 1;
	}

	return cnt;
}

int main() {
	//run();
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (auto &it : a)
		cin >> it;
	for (auto &it : b)
		cin >> it;
	int res = 0;
	for (int bit = 0; bit < 30; bit++)
		if (count(a, b, bit))
			res |= (1 << bit);
	cout << res << endl;
}


Measured memory_bytes: 3432
def examA():
    N = I()
    ans = ((N+1)//2)/N
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 4464
#include<iostream>
int main(){
	int a[10];
	int b;
	for (int i = 0; i < 10; i++){
		std::cin >> a[i];
	}

	for (int i = 0; i < 9; i++){
		for (int j = i + 1; j < 10; j++){
			if (a[i] < a[j]){
				b = a[i];
				a[i] = a[j];
				a[j] = b;
			}
		}
	}

	for (int i = 0; i < 3; i++){
		std::cout << a[i]<<std::endl;
	}

	return 0;
}

Measured memory_bytes: 1160
from sys import stdin
b = "357"
def valid(m):
 m = str(m)
 for i in b:
  if i not in m:
   return 0
 return 1
a = [3,5,7]
n = int(stdin.readline())
ans = 0
i = 0
while True:
 if i >= len(a):
  break
 cur = a[i]
 if cur > n:
  break
 if valid(cur):
  ans+=1
 a.append(cur*10 + 3); a.append(cur*10 + 5); a.append(cur*10 + 7)
 i+=1
print ans

Measured memory_bytes: 5380
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 100100
#define ll long long
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,a[MAX];
ll v[MAX],S,s,tot;
int main()
{
	n=read();s=1ll*n*(n+1)/2;
	for(int i=1;i<=n;++i)S+=(a[i]=read());a[n+1]=a[1];
	if(n==1){puts("YES");return 0;}
	if(S%s){puts("NO");return 0;}
	S/=s;
	for(int i=1;i<=n;++i)
	{
		v[i]=a[i]-a[i+1]+S;
		if(v[i]%n||v[i]<0){puts("NO");return 0;}
		tot+=v[i]/n;
	}
	if(tot!=S)puts("NO");else puts("YES");
	return 0;
}


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

int main(){
    int d;
    while(scanf("%d",&d)!=EOF){
        int ans=0;
        for(int i=d;i<600;i+=d)ans+=i*i*d;
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>

int main(void)
{
    int H = 0, N = 0;
    int A;
    int i;
    scanf("%d %d", &H, &N);
    for (i = 0; i < N; i++)
    {
        scanf("%d", &A);
        H = H - A;
    }
    if (H <= 0)
        printf("Yes");
    else
        printf("No");
    return (0);
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		char trump;
		cin >> trump;
		if (trump == '#')break;
		vector<vector<string>> c(4, vector<string>(13));
		int ns = 0, ew = 0;
		int start = 0;
		REP(i, 4) {
			REP(j, 13) {
				cin >> c[i][j];
				if (c[i][j][0] == 'T')c[i][j][0] = '9' + 1;
				if (c[i][j][0] == 'J')c[i][j][0] = '9' + 2;
				if (c[i][j][0] == 'Q')c[i][j][0] = '9' + 3;
				if (c[i][j][0] == 'K')c[i][j][0] = '9' + 4;
				if (c[i][j][0] == 'A')c[i][j][0] = '9' + 5;
			}
		}
		REP(i, 13) {
			char led = c[start][i][1];
			int flag = 0;
			REP(j, 4) {
				if (c[j][i][1] == trump)flag = 1;
			}
			int win = 0, cmax = -1;
			if (flag) {
				REP(j, 4) {
					if (c[j][i][1] == trump) {
						if (cmax < c[j][i][0] - '0') {
							win = j;
							cmax = c[j][i][0] - '0';
						}
					}
				}
			}
			else {
				REP(j, 4) {
					if (c[j][i][1] == led) {
						if (cmax < c[j][i][0] - '0') {
							win = j;
							cmax = c[j][i][0] - '0';
						}
					}
				}
			}
			start = win;
			if (win == 0 || win == 2)ns++;
			else ew++;
		}

		if (ns > ew) {
			cout << "NS " << ns - 6 << endl;
		}
		else {
			cout << "EW " << ew - 6 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;
const ll inf = 1LL<<60;

int main() {
    ll N;cin >> N;
    priority_queue<ll> L;
    priority_queue<ll,vector<ll>,greater<ll>>F;
    vector<ll> M(N);
    ll fval=0,lval=0;
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        F.push(a);
        fval+=a;
    }
    for(int i=0;i<N;i++){
        cin >> M[i];
    }
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        L.push(a);
        lval+=a;
    }
    vector<ll> resf(N+1),resl(N+1);
    resf[0]=fval;
    resl[N]=lval;
    for(int i=0;i<N;i++){
            fval+=M[i];
            F.push(M[i]);
            ll tf=F.top();
            fval-=tf;
            F.pop();
            resf[i+1]=fval;

            lval+=M[N-1-i];
            L.push(M[N-1-i]);
            ll tl = L.top();
            lval-=tl;
            L.pop();
            resl[N-i-1]=lval;
    }
    ll ans=-inf;
    for(int i=0;i<=N;i++){
        ans=max(ans,resf[i]-resl[i]);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4340