akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
#define abs(a) (a>0?a:(-(a)))
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
using namespace std;
ll a[100050],b[100];
int main(){
	int n;
	ll s=0;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		s^=a[i];
	}
	for (int i=1;i<=n;i++){
		int f=0;
		ll t=a[i];
		for (int j=60;j>=0;j--)
		if (!(s&(1ll<<j))) {
			if (a[i]&(1ll<<j)) {
				if (!b[j]) {
					b[j]=a[i];
					f=1;
					break;
				}else a[i]^=b[j];
			}
		}
		if (f) continue;
		a[i]=t;
		for (int j=60;j>=0;j--)
		if (a[i]&(1ll<<j)) {
			if (!b[j]) {
				b[j]=a[i];
				break;
			}else a[i]^=b[j];
		}
	}
	ll ans=0;
	for (int i=60;i>=0;i--)
	if (!(ans&(1ll<<i))) ans=ans^b[i];
	printf("%lld\n",ans+(s^ans));
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}

	vector<int> x_ = vector<int>(x);

	sort(x.begin(), x.end());

	for (int i = 0; i < n; i++) {
		cout << ((x_[i] < x[n/2]) ? x[n / 2] : x[n / 2 - 1]) << endl;
	}

}

Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PGC
{
	class Program
	{
		static void Main(string[] args)
		{
			var N = int.Parse(Console.ReadLine());
			var A = Console.ReadLine().Split().Select(int.Parse).ToArray();

			System.Console.WriteLine(string.Join(" ", A));
			for (int i = 1; i < N; i++)
			{
				var val = A[i];
				var j = i - 1;

				while (0 <= j && val < A[j])
				{
					A[j + 1] = A[j];
					j--;
				}
				A[j + 1] = val;

				System.Console.WriteLine(string.Join(" ", A));
			}
		}
	}
}



Measured memory_bytes: 18312
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> K;
	vector<int>v(10,1);
	for (int i = 0; i < K; i++) {
		cin >> M;
		v[M] = 0;
	}
	while (1) {
		int bag = N;
		int flag = 1;
		while (bag) {
			flag &= v[bag % 10];
			bag /= 10;
		}
		if (flag) {
			cout << N << endl;
			return 0;
		}
		N++;
	}
	return 0;
}

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

typedef long long ll;

using namespace std;

bool check(const vector<ll>& v, const ll& k, const ll& t)
{
    vector<ll> tmp = v;
    
    for (int i = 0; i < v.size(); ++i)
    {
        tmp[i] %= t;
    }
    sort(tmp.begin(), tmp.end());
    
    vector<ll> c1(tmp.size());
    vector<ll> c2(tmp.size() + 1);
    
    for (int i = 0; i < v.size(); ++i)
    {
        if (i > 0)
        {
            c1[i] += c1[i - 1];
        }
        c1[i] += tmp[i];
    }
    for (int i = 0; i < v.size(); ++i)
    {
        if (i > 0)
        {
            c2[c2.size() - 2 - i] += c2[c2.size() - 1 - i];
        }
        c2[c2.size() - 2 - i] +=  (t - tmp[c2.size() - 2 - i]);
    }
    
    for (int i = 0; i < tmp.size(); ++i)
    {
        if (c1[i] == c2[i + 1])
        {
            if (c1[i] <= k)
            {
                return 1;
            }
        }
    }
    
    return 0;
}

int main() {

    
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    ll sum = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        sum += a[i];
    }
    
    vector<ll> can;
    
    for (int i = 1; i <= sqrt(sum); ++i)
    {
        if (sum % i == 0)
        {
            can.push_back(i);
            can.push_back(sum / i);
        }
    }
    
    ll ret = 1;
    for (int i = 0; i < can.size(); ++i)
    {
        if (check(a, k, can[i]))
        {
            ret = max(ret, can[i]);
        }
    }

    
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import itertools

N = int(input())
num1 = list(map(int,input().split()))
num2 = list(map(int,input().split()))
x, y = 0, 0
l = [_ + 1 for _ in range(N)]
A = []

for v in itertools.permutations(l, N):
    A.append(list(v))

x = A.index(num1)
y = A.index(num2)

print(abs(x - y))

Measured memory_bytes: 10228
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
 
 
int main () {
    int N,X;

    cin >> N >> X;

    int min = 1000;
    rep(i,N){
        int m;
        cin >> m;
        X -= m;
        if(min > m){
            min =m;
        }
    }

    int ans = N;
    ans += X/min;

    cout << ans << endl;


}


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

int n;
int dp[100005][3];

int main(){

    cin>>n;
    for(int i=1;i<=n;i++){

        cin>>dp[0][i]>>dp[1][i]>>dp[2][i];

        dp[0][i]+=max(dp[1][i-1],dp[2][i-1]);
        dp[1][i]+=max(dp[0][i-1],dp[2][i-1]);
        dp[2][i]+=max(dp[0][i-1],dp[1][i-1]);

    }

    cout<<max(dp[0][n],max(dp[1][n],dp[2][n]));

}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <list>
#include <iomanip>
#include <cmath>
using namespace std;

// -- spaghetti source!! -- //
// -- http://www.prefield.com/algorithm/geometry3D/min_ball.html -- //

#define dim 3

typedef vector<double> P;

P operator+(P a, P b){
  for(int i = 0; i < dim; i++){
    a[i] += b[i];
  }
  return a;
}

P operator-(P a, P b){
  for(int i = 0; i < dim; i++){
    a[i] -= b[i];
  }
  return a;
}

P operator*(P a, double x){
  for(int i = 0; i < dim; i++){
    a[i] *= x;
  }
  return a;
}

P operator/(P a, double x){
  for(int i = 0; i < dim; i++){
    a[i] /= x;
  }
  return a;
}

double dist2(const P &a, const P &b){
  double res = 0;
  for(int i = 0; i < dim; i++){
    res += (a[i] - b[i]) * (a[i] - b[i]);
  }
  return res;
}

double dot(const P &a, const P &b){
  double res = 0;
  for(int i = 0; i < dim; i++){
    res += a[i] * b[i];
  }
  return res;
}

P makeP(double x, double y, double z){
  P res;
  res.push_back(x);
  res.push_back(y);
  res.push_back(z);
  return res;
}

struct min_ball{
  P center;
  double radius2;

  void add(const P &p){
    ps.push_back(p);
  }

  void compile(){
    m = 0;
    center = makeP(0, 0, 0);
    radius2 = -1;
    make_ball(ps.end());
  }
 
  template <class OUT>
 
  void support(OUT out){
    copy(ps.begin(), supp_end, out);
  }
 
  min_ball(){
    for(int i = 0; i <= dim; i++){
      c[i] = makeP(0, 0, 0);
      v[i] = makeP(0, 0, 0);
    }
  }
 
private:
  list<P> ps;
  list<P>::iterator supp_end;
  int m;
  P v[dim + 1], c[dim + 1];
  double z[dim + 1], r[dim + 1];
 
  void pop() { m--; };
 
  void push(const P &p){
    if(m == 0){
      c[0] = p;
      r[0] = 0;
    }
    else{
      double e = dist2(p, c[m - 1]) - r[m - 1];
      P delta = p - c[0];
      v[m] = p - c[0];
 
      for(int i = 1; i < m; i++){
	v[m] = v[m] - v[i] * dot(v[i], delta) / z[i];
      }

      z[m] = dot(v[m], v[m]);
      c[m] = c[m - 1] + v[m] * e / z[m] / 2.0;
      r[m] = r[m - 1] + e * e / z[m] / 4.0;
    }

    center = c[m];
    radius2 = r[m];
    m++;
  }

  void make_ball(list<P>::iterator i){
    supp_end = ps.begin();
    if(m == dim + 1) return;
    for(list<P>::iterator k = ps.begin(); k != i; ){
      list<P>::iterator j = k++;
      if(dist2(*j, center) > radius2){
	push(*j);
	make_ball(j);
	pop();
	move_to_front(j);
      }
    }
  }

  void move_to_front(list<P>::iterator j){
    if(supp_end == j) supp_end++;
    ps.splice(ps.begin(), ps, j);
  }
};

// -- http://www.prefield.com/algorithm/geometry3D/min_ball.html -- //
// -- spaghetti source!! -- //

int main(){
  int n;

  while(cin >> n, n){
    struct min_ball ball;

    for(int i = 0; i < n; i++){
      double x, y, z;
      cin >> x >> y >> z;
      P p = makeP(x, y, z);
      ball.add(p);
    }

    ball.compile();
    cout << fixed << setprecision(5) << sqrt(ball.radius2) << endl;
  }
}

Measured memory_bytes: 1316
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;

#define rep(i,n) for (int i = 0; i < (n); ++i)

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
int n;
cin>>n;
deque<ll> dq;
  rep(i,n){
    ll a;cin>>a;
    if(i%2!=n%2){
      dq.push_front(a);
    }
    else dq.push_back(a);
  }

  rep(i,n){
    printf("%d ",dq[i]);
  }


  return 0;
}

Measured memory_bytes: 3840
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

A = [a, b, c, d, e]

ind = 0
for i in A:
    for j in A:
        if(abs(i - j) >k):
            ind = 1

if(ind == 0):
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	ll x,c=100,a,co=0;
	cin>>x;
	while (c<x){
		a=c/100;
		c+=a;
		co++;
	}
	cout<<co;
	return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int N; cin >> N;
  REP(i,10000) {
    if (N <= i*1000) {
      cout << i*1000 - N << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);++i)
#define rep1(i, n) for(int i=1;i<=(int)(n);++i)
#define irep(i, a, n) for(int i=a;i<(int)(n);++i)
#define rrep(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for(int i=(int)(n);i>=1;--i)
#define allrep(V, v) for(auto&& V:v)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const int INF=1<<29;
const double EPS=1e-9;
using namespace std;


int main (void)
{
  string n; cin>>n;
  cout << count(all(n),'2') << endl;
  return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
h = list(map(int,input().split()))
#print(h)

dp = [0]*N
dp[0] = 0
for n in range(1,N):
	best = 99999999999999
	for k in range(1,K+1):
		if n-k<0: continue
		step = abs(h[n]-h[n-k])+dp[n-k]
		best = min(best,step)
	dp[n] = best

ans = dp[N-1]
print(ans)


Measured memory_bytes: 52704
#include <stdio.h>
#include <string.h>

// dp[weight] -> best_value

#define INIT(var_name, init_value)	memset(var_name, init_value, sizeof(var_name))
#define UNUSED (-1)

int main(void)
{
	int best_value[2048];
	int next_value[2048];
	int limit_weight;
	int n;
	int i, j;
	int test_case;

	test_case = 1;
	while (scanf("%d", &limit_weight), limit_weight){
		int best_weight;
		
		INIT(best_value, UNUSED);
		best_value[0] = 0;

		scanf("%d", &n);
		for (i = 0; i < n; i++){
			int value, weight;
			scanf("%d,%d", &value, &weight);
			
			memcpy(next_value, best_value, sizeof(next_value));
			for (j = 0; j <= limit_weight; j++){
				if (best_value[j] != UNUSED){
					if (next_value[j + weight] == UNUSED){
						next_value[j + weight] = best_value[j] + value;
					}
					else {
						next_value[j + weight] = fmax(next_value[j + weight], best_value[j] + value);
					}
				}
			}
			memcpy(best_value, next_value, sizeof(best_value));
		}

		best_weight = 0;
		for (i = 1; i <= limit_weight; i++){
			if (best_value[best_weight] < best_value[i]){
				best_weight = i;
			}
		}
		printf("Case %d:\n", test_case++);
		printf("%d\n%d\n", best_value[best_weight], best_weight);
	}

	return (0);
}

Measured memory_bytes: 620
function PriorityQueue(){
    this.heap = [];
}

PriorityQueue.prototype = {
    push : function(x){
        var h = this.heap, i = h.length++, j;
        while(i){
            j = i-1 >> 1;
            if(h[j] <= x)break;
            h[i] = h[j];
            i = j;
        }
        h[i] = x;
    },
    pop : function(){
        var h = this.heap, r = h[0], x = h.pop();
        var i = 0, k = h.length >> 1, j;
        while (i < k) {
            j = (i << 1) + 1;
            if(h[j+1] < h[j])++j;
            if(x <= h[j])break;
            h[i] = h[j];
            i = j;
        }
        if(h.length)h[i] = x;
        return r;
    },
    size : function(){return this.heap.length;},
    top : function(){return this.heap[0];},
};

function compareNumbers2(a, b) { //for sort
    return a-b;
}
function Main(arg)
{
  var N = arg.split("\n")[0] - 0;
  var K = arg.split("\n")[1].split(" ").map(Number);
  K.sort(compareNumbers2);

  var ans = new PriorityQueue();

  for (var i = K[0]; i <= K[N - 1]; i++){
    var tmp = 0;
    for (var j = 0; j < N; j++){
      tmp += (K[j] - i) * (K[j] - i);
    }
    ans.push(tmp);
  }


  console.log(ans.top());
  return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9548
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
int main()
{
  ld N;
  cin>>N;
  cout<<6.2831853*N<<endl;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n;cin>>n;
  ll m[n][n];
  for(i=0;i<n;i++)for(j=0;j<n;j++)m[i][j]=INF;
  vector<pair<ll,pair<ll,ll>>> a;
  for(i=0;i<n;i++)for(j=0;j<n;j++){
    cin>>buf;
    if(j>i)a.push_back({buf,{i,j}});
  }
  sort(ALL(a));
  for(i=0;i<a.size();i++){
    //cout<<i<<endl;
    ll l=a[i].first;
    ll p=a[i].second.first;
    ll q=a[i].second.second;
    if(m[p][q]==INF){
      //cout<<i<<endl;
      m[p][q]=l;
      m[q][p]=l;
      result+=l;
      for(j=0;j<n;j++){
        for(o=0;o<n;o++){
        if(m[j][p]!=INF&&j!=p){
          chmin(m[j][q],l+m[j][p]);
          chmin(m[q][j],l+m[j][p]);
        }
        if(m[j][q]!=INF&&j!=q){
          chmin(m[j][p],l+m[j][q]);
          chmin(m[p][j],l+m[j][q]);
        }
        if(m[j][q]!=INF&&j!=q&&
        m[o][p]!=INF&&p!=o&&o!=j){
          chmin(m[o][j],l+m[j][q]+m[o][p]);
          chmin(m[j][o],l+m[j][q]+m[o][p]);
        }
      }
      }
    }
    else if(m[p][q]!=l){
      //cout<<i+100<<endl;
      if(m[p][q]>l){
        m[p][q]=l;
      m[q][p]=l;
      result+=l;
      for(j=0;j<n;j++){
        for(o=0;o<n;o++){
        if(m[j][p]!=INF&&j!=p){
          chmin(m[j][q],l+m[j][p]);
          chmin(m[q][j],l+m[j][p]);
        }
        if(m[j][q]!=INF&&j!=q){
          chmin(m[j][p],l+m[j][q]);
          chmin(m[p][j],l+m[j][q]);
        }
        if(m[j][q]!=INF&&j!=q&&
        m[o][p]!=INF&&p!=o&&o!=j){
          chmin(m[o][j],l+m[j][q]+m[o][p]);
          chmin(m[j][o],l+m[j][q]+m[o][p]);
        }
      }
      }
      }
      else{
        result=-1;
        break;
      }

      

    }
    
  }
  /*for(i=0;i<n;i++){
  for(j=0;j<n;j++){
    cout<<m[i][j]<<" ";
  }
  cout<<endl;
  }
  for(i=0;i<a.size();i++){
    cout<<a[i].first spa a[i].second.first 
    spa a[i].second.second<<endl;
  }*/
  cout<<result<<endl;
  //n=1はコーナー？
  return 0;
}

Measured memory_bytes: 2552
#include <stdio.h>
#include<math.h>
int main(void){
    int a,b,deg;
    double x,y,z;
double rad;
double PI = acos(-1);
 scanf("%d", &a);
 scanf("%d", &b);
scanf("%d", &deg);
rad = deg * PI / 180;
double t=a*a+b*b-2*a*b*cos(rad);;
double s=0;
s=sqrt(t);
 x=a*b*sin(rad)/2;
 y=a+b+s;
 z=b*sin(rad);
printf("%f\n%f\n%f\n", x, y,z);
}



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

#define rep(i,N)  for(int i=0; i<N; i++)
#define ol(a) cout << a << endl
#define PI 3.14159265359
using namespace std;

int main(){
  int n; cin >> n;
  int a=0;
  int b = 0;
  int c= 0;
  int d=0;
  rep(i,n){
    string s; cin >> s;
    if(s == "AC"){
      a++;
    }
    else if(s == "WA"){
      b++;
    }
    else if(s == "TLE"){
      c++;
    }
    else{
      d++;
    }
  }
  /*
  ol("AC x "+a);
  ol("WA x "+b);
  ol("TLE x "+c);
  ol("RE x "+d);
  */
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
  
  
}

Measured memory_bytes: 3624
#include <iostream>
#include <queue>

int main()
{
    int n = 0;
    std::cin >> n;
    int m = 0;
    std::cin >> m;
    
    std::priority_queue<int> prices;
    
    int a = 0;
    for(int i = 0; i < n; ++i)
    {
        std::cin >> a;
        prices.emplace(a);
    }
    
    for(int i = 0; i < m; ++i)
    {
        a = prices.top();
        a /= 2;
        prices.pop();
        prices.emplace(a);
    }
    unsigned long sum = 0;
    for(int i = 0; i < n; ++i)
    {
        sum += prices.top();
        prices.pop();
    }
    std::cout << sum << std::endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
   ll x;
   mint(ll x = 0) { (this->x = (x + MOD)) %= MOD; }
   mint operator-() const { return mint(-x); }
   mint& operator+=(const mint a) {
      if ((this->x += a.x) >= MOD) x -= MOD;
      return *this;
   }
   mint& operator-=(const mint a) {
      if ((this->x += MOD - a.x) >= MOD) this->x -= MOD;
      return *this;
   }
   mint& operator*=(const mint a) {
      (this->x *= a.x) %= MOD;
      return *this;
   }
   mint operator+(const mint a) const {
      mint res(*this);
      return res += a;
   }
   mint operator-(const mint a) const {
      mint res(*this);
      return res -= a;
   }
   mint operator*(const mint a) const {
      mint res(*this);
      return res *= a;
   }
   mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t >> 1);
      a *= a;
      if (t & 1) a *= *this;
      return a;
   }
   mint inv() const { return pow(MOD - 2); }
   mint& operator/=(const mint a) { return *this *= a.inv(); }
   mint operator/(const mint a) const {
      mint res(*this);
      return res /= a;
   }
};
istream& operator>>(istream& is, mint& a) {
   return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a) {
   return os << a.x;
}
struct combination {
   vector<mint> fact, ifact;
   combination(int n) : fact(n + 1), ifact(n + 1) {
      assert(n < MOD);
      fact[0] = 1;
      for (int i = 1; i <= n; ++i)
         fact[i] = fact[i - 1] * i;
      ifact[n] = fact[n].inv();
      for (int i = n; i >= 1; --i)
         ifact[i - 1] = ifact[i] * i;
   }
   mint operator()(int n, int k) {
      if (k < 0 || k > n) return 0;
      return fact[n] * ifact[k] * ifact[n - k];
   }
   mint p(int n, int k) { return fact[n] * ifact[n - k]; }
} comb(1000005);
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n, m;
   cin >> n >> m;
   mint ans = 0;
   rep(i, 0, n + 1) {
      mint now = comb(n, i);
      now *= comb.p(m - i, n - i);
      if (i & 1) now = -now;
      ans += now;
   }
   ans *= comb.p(m, n);
   cout << ans << endl;
   return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    lint N;
    cin >> N;
    if (N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    N /= 2;
    lint x   = 5;
    lint ans = 0;
    while (x <= N) {
        ans += (lint)N / (x);
        x *= 5;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		long seconds = sc.nextLong();
		
		for(int i = 2; i<=N; i++) {
			long n = sc.nextLong();
			seconds = n/gcd(seconds, n)*seconds;
		}
		
		System.out.println(seconds);
	}
	
	public static long gcd(long x, long y) {
		if(y == 0) return x;
		return gcd(y, x%y);
	}

}


Measured memory_bytes: 23124
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
using namespace std;


typedef long long ll;
ll rngl,rngr;
ll N,A,B,C,D,tar,dt;
ll Fabs(ll x){
    return x>0?x:-x;
}

int main(){
    scanf("%lld %lld %lld %lld %lld",&N,&A,&B,&C,&D);
    N--;
    ll tar=Fabs(A-B);dt=Fabs(C-D);
    if(N%2==0){
        if(dt*(N/2)>=tar){printf("YES\n");return 0;}
    }

    if(C>D)swap(C,D);
    ll cnt=0;
    while(cnt<N){
        cnt++;
        rngl+=C,rngr+=D;
        if((N-cnt)%2==0){
            if(rngl<=tar&&rngr>=tar){
                printf("YES\n");
                return 0;
            }ll best=min(Fabs(rngl-tar),Fabs(rngr-tar));
            if((N-cnt)/2*dt>=best){
                printf("YES\n");
                return 0;
            }
        }
    }printf("NO\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 long long int N,K,sum=0,x;
	vector<long long int> v;
	cin>>N>>K;
	if(N<=K)
	{
		cout<<0;
		return 0;
	}
	for(int j=0;j<N;j++)
	{
		cin>>x;
		v.push_back(x);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<N-K;i++)
	{
		sum+=v[i];
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 2420
a, b, c, x, y = map(int, input().split())
if (a+b) <= 2*c:
    print(x*a+y*b)
else:
    price = min(x, y) * 2 * c
    n = abs(x - y)
    if x - min(x, y) > 0:
        if a*n <  2*c*n:
            price += a*n
        else:
            price += 2*c*n
    if y - min(x, y) > 0:
        if b*n <  2*c*n:
            price += b*n
        else:
            price += 2*c*n
    print(price)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;

multiset<ll> ms;
ll N, Q;
ll d[200005];
ll s[200005];
ll t[200005];
ll x[200005];
vector<ll> insert[200005];
vector<ll> del[200005];

int main()
{
    cin >> N >> Q;
    for (int i = 0; i < N; i++) {
        cin >> s[i] >> t[i] >> x[i];
    }
    for (int i = 0; i < Q; i++) {
        cin >> d[i];
    }

    for (int i = 0; i < N; i++) {
        int l = lower_bound(d, d + Q, s[i] - x[i]) - d;
        int r = lower_bound(d, d + Q, t[i] - x[i]) - d;

        insert[l].push_back(x[i]);
        del[r].push_back(x[i]);
    }

    for (int i = 0; i < Q; i++) {
        for (int j = 0; j < insert[i].size(); j++) {
            ms.insert(insert[i][j]);
        }
        for (int j = 0; j < del[i].size(); j++) {
            ms.erase(ms.find(del[i][j]));
        }
        
        if (!ms.empty()) {
            cout << *(ms.begin()) << endl;
        }
        else {
            cout << -1 << endl;
        }
    }

    return 0;
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A + B > C + D ){
  cout << "Left" << endl;
  }
  if(A + B == C + D){
  cout << "Balanced" << endl;
  }
  if(A + B < C + D){
  cout << "Right" << endl;
  }
}

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

int N,Q;
char t[200010],d[200010];
string S;

bool ok(int id){
    int now = id;
    for(int i=1;i<=Q;i++){
        if(S[now]==t[i]){
            if(d[i]=='L') now--;
            else now++;
        }
        if(now==-1 || now==N) return true;
    }
    return false;
}

int main(){
    cin >> N >> Q >> S;
    for(int i=1;i<=Q;i++){
        cin >> t[i] >> d[i];
    }
    int l1 = -1,r1 = N;
    while(l1+1<r1){
        int m = (l1+r1)/2;
        if(ok(m)) l1 = m;
        else r1 = m;
    }
    int l2 = -1,r2 = N;
    while(l2+1<r2){
        int m = (l2+r2)/2;
        if(ok(m)) r2 = m;
        else l2 = m;
    }
    if(l1>=r2) cout << 0 << endl;
    else cout << N-(l1+1)-(N-r2) << endl;
}

Measured memory_bytes: 1028
#include<iostream>
using namespace std;
int main()
{
    int n,a,b;
    cin>>n;
    a=n/10;
    b=n%10;
    if (a==9 || b==9)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
    system("pause");
    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}


int main() {
    string s; cin >> s;
    int ans = 0;
    rep(i, s.size()) {
        if(s[i] - '0' == 1) ans++;
    }
    cout << ans << endl;

    return 0;

}


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

bool check_sum(string s){
    int pre=0;
    int ans=0;
    for(int i=0;s[i]!='\0';i++){
        ans=(pre+(s[i]-'0'))%9;
        pre=ans;
    }
    return ans ? false: true;
}

int main(){
    string s; cin>>s;
     check_sum(s) ? cout<< "Yes" : cout<<"No";
}

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

int main ()
{
    ll n;
    int a[20],m=0;
    cin>>n;
    memset(a,0,sizeof(a));
    while(n)
    {
        if(n%26)    a[m++]+=n%26;
        else        {a[m++]+=26;n--;}
        n/=26;
    }
    for(int i=m-1;i>=0;i--)
        if(a[i])
            cout<<char(a[i]+'a'-1);
    cout<<endl;
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main() {
	int a, b, s = 1;
	cin >> a >> b;
	while (a--) {
		if (s > b) s += b;
		else s *= 2;
	}
	cout << s;
	return 0;
}



Measured memory_bytes: 256
INF = 10**30
import sys
sys.setrecursionlimit(10**6)
def bellman_ford(s, t, g):
    d = [INF for _ in range(n)] # 各頂点への最小コスト
    d[s] = 0 # 自身への距離は0
    val_at_t = INF # 下記参照
    for i in range(n):
        #update = False # 更新が行われたか
        for x, y, z in g:
            if d[y] > d[x] + z:
                d[y] = d[x] + z
                #update = True
        # 負閉路が存在して、点tの値が更新され続けている場合
        if i == n-1 and val_at_t > d[t]:
            return []
        val_at_t = d[t] #点tの現在の値
    return d

n, m = map(int, input().split()) # n:頂点数, m:辺の数
g = []
for _ in range(m):
    x, y, z = map(int, input().split()) # 始点,終点,コスト
    x -= 1
    y -= 1
    z *= -1
    g.append([x, y, z])
    
ans = bellman_ford(0, n-1, g)
#print(ans)
print(-ans[n-1] if ans else "inf")


Measured memory_bytes: 9296
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
const int N = (int)1e5+10 ;
const int M = (int)1000000007; 

vector<ll>topo ;
bool mark[N] ;
void topology(vector<ll>g[] , ll idx){
    mark[idx]=1 ;
    for(auto e:g[idx]){
      if(mark[e]==0) topology(g , e) ;
       // cout << e << endl ;
    }
   // cout << idx << endl ;
   topo.pb(idx) ;
}
int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    ll n , m , i , x , y  ;
    cin >> n >> m ;
    vector<ll> g[n+1] ;
    for(i=0 ; i<m ; i++){
         cin >> x >> y ;
         g[x].pb( y ) ;
    }
    for(i=1 ; i<=n ; i++){
        if(mark[i])continue ;
         topology(g , i) ;
    }
    reverse(all(topo)) ;
    ll dp[n+1] = {0} ;
    for(i=0 ; i<n ;i++){
        ll p = topo[i] ;
        for(auto e:g[p]){
            dp[e] = max(dp[e] , dp[p]+1) ;
        }
    }
    ll ans=0 ;
    for(i=1 ; i<=n ; i++){
        ans = max(ans , dp[i]) ;
    }

    cout << ans ;
    
    
    return 0 ;
}

Measured memory_bytes: 9080
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf = 1e9+123;
void yes()
{cout << "Yes" << endl;}
void no()
{cout <<  "No" << endl;}
void q()
{cout << -1 << endl;}

void solve()
{	
	ll a, b, c, k, sum=0;
	cin >> a >> b >> c >> k;
	if(k<=a)
		cout << k << endl;
	else if ( a<k && k<=a+b)
		cout << a << endl;
	else
		cout << a-(k-a-b) << endl;
}
int main()
{	
//	int t;
//	cin >> t;
//	while(t--)
		solve();
}

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

int n, a[110], i, j, t, mini;

void selectionsort() {
	for (i=0; i<n; i++) {
		int mini = i; //mini is the minimum value
		for (j=i; j<n; j++) //j is unsorted
			if (a[j]<a[mini])
				mini=j;
			if ( i != mini) {
				swap (a[i], a[mini]);
				t++;
	}
		
			}
}

int main() {
	cin>>n; //input a value of n where n = number of values eg. 5
		for (i=0; i<n; i++) cin>>a[i]; //input the values eg. 1 3 6 2 5
			selectionsort();
		for (i=0; i<n-1; i++) cout<<a[i]<< " "; //output sorted values with space in between eg. 1 2 3 5
	cout<<a[n-1]<<endl; //output value a[n-1] and then end of line(\n)
	cout<<t<<endl;
	return 0;
}

// I not sure where is the problem since I'm not fimilar to C++ but you can try to to print out some word on each command that you think might make your program not working.

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprv(i, n) for (int i = n - 1; i >= 0; i--)
#define ll long long
using namespace std;

int main() {
    int a,b;

    cin >> a >> b;

    if ( a > b) {
        cout << "safe" << endl;
    } else {
        cout << "unsafe" << endl;
    }

    return 0;
}


Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#define rep(i,j,k) for(register int i=j;i<=k;i++) 
#define dow(i,j,k) for(register int i=j;i>=k;i--) 
#define ll long long
using namespace std;
const int N=6e5+200;
const int mod = 998244353;
long long f[N],inv[N];
long long qpow(int x,int y){
	ll res=1;
	while(y) {
		if(y&1) res=res*x%mod;
		x=1ll*x*x%mod;
		y>>=1;
	}
	return res;
}
void init(){
	f[0]=1;
	rep(i,1,N-100) f[i]=f[i-1]*i%mod;
	inv[N-100]=qpow(f[N-100],mod-2) ;
	dow(i,N-101,0) inv[i]=inv[i+1]*(i+1)%mod;
}

long long C(int n,int m) {
	return f[m]*inv[n]%mod*inv[m-n]%mod;
}

long long n,a,b,k,ans;
int main( ){
	init();
	//rep(i,1,5) cout<<f[i]*inv[i]%mod<<endl;
	cin>>n>>a>>b>>k;
	rep(i,0,n) {
		ll res=k-1ll*a*i;
		if(res%b) continue;
		ll num=res/b;
		if(num>n||num<0) continue;
		//cout<<i<<" "<<num<<" "<<C(i,n)<<" "<<C(num,n)<<endl;
		ans+=C(i,n)*C(num,n)%mod;
		ans%=mod;
	}
	cout<<ans<<endl;
}





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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string N;
	cin >> N;

	if (N[0] == '9' || N[1] == '9')
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> x(M),y(M);
  for(int i=0;i<M;i++){
    cin >> x.at(i) >> y.at(i);
    x.at(i)--;
    y.at(i)--;
  }

  vector<bool> red(N,false);
  red.at(0)=true;
  vector<int> cnt(N,1);
  for(int i=0;i<M;i++){
    if(red.at(x.at(i))) red.at(y.at(i))=true;
    cnt.at(x.at(i))--;
    cnt.at(y.at(i))++;
    if(cnt.at(x.at(i))==0)  red.at(x.at(i))=false;
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(red.at(i)) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N,M,K = map(int,input().split())

    MAXN = N*M
    fact = [1]
    for i in range(1,MAXN + 1):
        fact.append(fact[-1]*i%MOD)
    inv_fact = [-1] * (MAXN + 1)
    inv_fact[-1] = pow(fact[-1],MOD - 2,MOD)
    for i in range(MAXN - 1,-1,-1):
        inv_fact[i] = inv_fact[i + 1]*(i + 1)%MOD
    
    nck = lambda N,K: 0 if K > N or K < 0 else fact[N]*inv_fact[N - K]*inv_fact[K]%MOD

    ans = 0
    const = nck(N*M - 2,K - 2)
    for i in range(1,N):
        ans += (N - i) * M*M * const * i % MOD
        ans %= MOD
    
    for i in range(1,M):
        ans += (M - i) * N*N * const * i % MOD
        ans %= MOD
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 18964
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  LL n; read(n);
  LL sq = sqrt(n);
  LL ans = 0x7f7f7f7f7f7f7f7f;
  for (RI i = 1; i <= sq; ++i)
    if (n % i == 0)
      ans = min(ans, n / i + i - 2);
  printf("%lld\n", ans);

  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 256
#include <bitset>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, a, b) for(int i = (a); i >= (b); i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

//nが素数かをO(√n)で判断
bool is_prime(int n){
    bool res = true;

    if(n == 1) return false;
    else if(n == 2) return true;

    else{
        for(int i = 2; i*i <= n;i++){
            if(n%i == 0){
                res = false;
                break;
            }
        }
    }

    return res;
}

int main(){
    int MAX_N = 100010;
    //Aは2017に似た数をtrueで保存
    vector<bool> a(MAX_N, false);
    rep(i, MAX_N){
        if(i % 2 == 1){
            if(is_prime(i) && is_prime((i+1)/2)) a[i] = true;
        }
    }

    //iまでの2017に似た数をカウントして保存
    vector<int> s(MAX_N, 0);
    rep(i, MAX_N){
        s[i+1] = s[i] + a[i];
    }

    //クエリを処理
    int q; cin >> q;
    rep(i, q){
        int l, r; cin >> l >> r;
        cout << s[r+1] - s[l] << endl;
    }
}

Measured memory_bytes: 1024
k = int(input().strip())
a, b = input().strip().split()
a = int(a)
b = int(b)
c = 0
for i in range(1,1001):
    if i*k <= b and i*k >= a:
        print("OK")
        c = 1
        break
if c == 0:
    print("NG")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
const string YES = "YES";
const string NO = "NO";
  
void solve(long long N, std::vector<long long> p){
  int a=0;
  for (int i = 0; i < N; i++) {
    if(i+1 != p[i]){
      a++;
    }
  }
  cout << (a <= 2 ? YES : NO) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, std::move(p));
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    char S[5];
    char x,y;
    int a=0,b=0,i;
    cin>>S;
    x=S[0];
    if(S[0]!=S[1])
    {
        y=S[1];
    }
    else if(S[0]!=S[2])
    {
        y=S[2];
    }
    else if(S[0]!=S[3])
    {
        y=S[3];
    }
    for(i=0;i<4;i++)
    {
        if(S[i]==x)
        {
            a=a+1;
        }
        else if(S[i]==y)
        {
            b=b+1;
        }
    }
    if(a==2 && b==2)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
rate=int(input())
a=400
if rate>=a and rate<=a+199:
  print(8)

elif rate>=a+200 and a+399>=rate:
  print(7)
elif rate>=a+400 and a+599>=rate:
  print(6)
  
elif rate>=a+600 and a+799>=rate:
  print(5)
  
elif rate>=a+800 and a+999>=rate:
  print(4)
  
elif rate>=a+1000 and a+1199>=rate:
  print(3)
  
elif rate>=a+1200 and a+1399>=rate:
  print(2)
  
  
else:
  print(1)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int n, x, y; cin >> n >> x >> y;
	int ans[n+1] = {0};
	for (int i = 1; i <= n; ++i)
	{
		for (int j = i+1; j <= n; ++j)
		{
			int dist = j-i;
			dist = min(dist, abs(x-i) + 1 + abs(y-j));
			dist = min(dist, abs(x-j) + 1 + abs(y-i));
			++ans[dist];
		}
	}
	for (int i = 1; i < n; ++i)
		cout << ans[i] << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
using namespace std;
typedef vector<int> vec;
int main(){
	int n,x,s;
	while(cin>>n,n){
		vec tab[31];
		set<int> have[60];
		set<int>::iterator ite;
		int now=0;
		while(n!=now++){
			cin>>x;
			for(int i=0;i<x;i++){
				cin>>s;
				tab[s].push_back(now);
			}
		}
		for(int i=1;i<=n;i++)
		have[i].insert(i);
		for(int i=1;i<=30;i++){
			vec box;
			for(int j=0;j<(int)tab[i].size();j++){
				box.push_back(tab[i][j]);
				ite=have[tab[i][j]].begin();
				while(ite!=have[tab[i][j]].end()){
					box.push_back(*ite);
					ite++;
				}
			}
			for(int j=0;j<(int)tab[i].size();j++){
				for(int k=0;k<box.size();k++)
					have[tab[i][j]].insert(box[k]);
				if((int)have[tab[i][j]].size()==n){
					cout<<i<<endl;
					goto end;
				}
			}
		}
			cout<<"-1"<<endl;
		end:;
	}
	return 0;
}

Measured memory_bytes: 1008
n = int(input())
l = sorted(map(int, input().split()))[::-1]

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[k] < l[j] < l[i] and l[k] + l[j] > l[i]:
                ans += 1
print(ans)


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int A[220000];
signed main() {
    cin >> N;
    rep(i, N) { cin >> A[i]; }
    if (A[0] != 0) {
        cout << "-1" << endl;
        return 0;
    }
    int ans = 0;
    for (int i = 1; i < N; i++) {
        if (A[i] == A[i - 1] + 1) { ans++; }
        if (A[i] <= A[i - 1]) { ans += A[i]; }
        if (A[i] > A[i - 1] + 1) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int64_t n,k;
  cin >> n >> k;
  vector<int64_t> a(n);
  rep(i,n){
    cin >> a[i];
  }
  vector<int64_t> ruiseki(1);
  rep(i,n){
    ruiseki.push_back(ruiseki.back()+a[i]);
  }
  vector<int64_t> cand;
  for(int64_t i=0;i < n+1;i++){
    for(int64_t j=i+1;j < n+1;j++){
      cand.push_back(ruiseki[j]-ruiseki[i]);
    }
  }
  /*rep(i,cand.size()){
    cout << cand[i] << ",";
  }*/
  int64_t sieve = 1;
  sieve = sieve << 60;
  vector<int64_t> goods = cand;
  while(sieve > 0){
    vector<int64_t> sieved;
    rep(i,goods.size()){
      if(goods[i] & sieve){
        sieved.push_back(goods[i]);
      }
    }
    if(sieved.size() >= k){
      goods.clear();
      goods = sieved;
    }
    sieve = sieve >> 1;
  }
  int64_t res = 0;
  rep(i,k){
    if(i == 0){
      res = goods[0];
    }else{
      res = res & goods[i];
    }
  }
  cout << res << endl; 
      
}
  
  

Measured memory_bytes: 9976