akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>



using namespace std;


int main() {
//	freopen("1.out", "r", stdin);
//	freopen("l.out", "w", stdout);
	long long n;
	long long i;
	cin >> n;
	/*if (n >= 10) {
		printf("1\n2\n3\n4\n5\n6\n7\n8\n9\n");
		if (n >= 100) {
			printf("19\n29\n39\n49\n59\n69\n79\n89\n99\n");
			if (n >= 1000) {
				printf("199\n299\n399\n499\n599\n699\n799\n899\n999\n");
				if (n >= 2000) {
					printf("1099\n1199\n1299\n1399\n1499\n1599\n1699\n1799\n1899\n1999\n");
				}
			}
		}
	}*/
	for (i = 1; i <= n and i <= 9; i++) {
			printf("%lld\n", i);
	}
	
	
	int j = 1;
	for (; i <= n and j <= 9; i++) {
		printf("%d9\n", j++);
	}
	
	j = 1;
	for (; i <= n and j <= 19; i++) {
		printf("%d99\n", j++);
	}
	
	j = 2;
	for (; i <= n and j <= 29; i++) {
		printf("%d999\n", j++);
	}
	
	j = 3;
	for (; i <= n and j <= 39; i++) {
		printf("%d9999\n", j++);
	}
	
	j = 4;
	for (; i <= n and j <= 49; i++) {
		printf("%d99999\n", j++);
	}
	
	j = 5;
	for (; i <= n and j <= 59; i++) {
		printf("%d999999\n", j++);
	}
	
	j = 6;
	for (; i <= n and j <= 69; i++) {
		printf("%d9999999\n", j++);
	}
	
	j = 7;
	for (; i <= n and j <= 79; i++) {
		printf("%d99999999\n", j++);
	}
	
	
	j = 8;
	for (; i <= n and j <= 89; i++) {
		printf("%d999999999\n", j++);
	}
	
	
	j = 9;
	for (; i <= n and j <= 99; i++) {
		printf("%d9999999999\n", j++);
	}
	
	////////////////////////
	j = 10;
	for (; i <= n and j <= 99; i++) {
		printf("%d99999999999\n", j++);
	}
	
	j = 10;
	for (; i <= n and j <= 109; i++) {
		printf("%d999999999999\n", j++);//12 g 9
	}
	
	j = 11;
	for (; i <= n and j <= 109; i++) {
		printf("%d9999999999999\n", j++);
	}
	
	j = 11;
	for (; i <= n and j <= 99; i++) {
		printf("%d99999999999999a\n", j++);
	}
	/////////////
	
	j = 10;
	for (; i <= n and j <= 109; i++) {
		printf("%d99999999999\n", j++);
	}
	
	j = 11;
	for (; i <= n and j <= 119; i++) {
		printf("%d999999999999\n", j++);
	}
	
	
	
	j = 12;
	for (; i <= n and j <= 129; i++) {
		printf("%d9999999999999\n", j++);
	}
	
	
	j = 13;
	for (; i <= n and j <= 139; i++) {
		printf("%d99999999999999\n", j++);
	}
	
	
	/*while (n--) {
		
		printf("%d\n");
	}*/
}

Measured memory_bytes: 256
$#q=$N=<>;
/ /,push@{$`},$' for<>;
map$q[$_]+=$q[$i]/@$i,@{$i=$_}for++$q[1]..$N;
print+(sort{$a<=>$b}map{$s=$m=!$N--;$m=($~=$e[$_])>$m?$~:$m,$s+=$~for@$N;$e[$N]=1+$s/@$N;
$q[$N]*=$#$N&&($s-$m)/$#$N-$s/@$N}2..$N)[0]+"@e"

Measured memory_bytes: 42368
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>

using namespace std;

int main()
{
	int a, b;

	while(cin >> a >> b){
		a = a+b; b=0;
		while(true){
			if(a==0){cout << b << endl; break;}
			a=a/10; b++;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
#define mod 1000000007
ll int a[22][22];
ll int n,mask;
ll int dp[21][6000000];
ll int ans(ll int in,ll int mask1,ll int mask2)
{if(in==n)
  {
    return mask1==mask ;
  }
  if(dp[in][mask2]!=-1)
  return dp[in][mask2];
  
  dp[in][mask2]=0;
for(ll int i=0;i<n;i++)
{
if(a[in][i]==1  && ( (mask2&(1<<i)) ==0 )  ) 
dp[in][mask2]=( dp[in][mask2]%mod +ans(in+1,(mask1|(1<<in)),(mask2|(1<<i)))%mod )%mod;

    
}
return dp[in][mask2];
 
 
}
int main()
{
memset(dp,-1,sizeof dp);
cin>>n;
for(ll int i=0;i<n;i++)
{for(ll int j=0;j<n;j++)
  cin>>a[i][j];
}
mask=(1<<(n))-1;
ll int d=ans(0,0,0);
cout<<d<<endl;
}

Measured memory_bytes: 984576
// Problem : E - This Message Will Self-Destruct in 5s
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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


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

    long n;
    cin >> n;
    vector<long> a(n+1);
    for (long i = 1; i <= n; i++) {
        cin >> a[i];
    }
    map<long, long> hashMap;
    long long count = 0;
    for (long i = 1; i <= n; i++) {
        long rightKey = i - a[i];
        if (hashMap.find(rightKey) != hashMap.end()) count += hashMap[rightKey]; 
        long leftKey = i + a[i];
        if (hashMap.find(leftKey) == hashMap.end()) hashMap[leftKey] = 1;
        else hashMap[leftKey]++;
    }
    cout << count << "\n";
    
    return 0;
}


Measured memory_bytes: 17016
#include<stdio.h>
#define MAX 101


int main(){

  int i,j,n,u,k,l,v;
  int G[MAX][MAX];
  
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      G[i][j]=0;
    }
  }
  
  for(i=1;i<=n;i++){

    scanf("%d%d",&u,&k);

    for(l=1;l<=k;l++){
      scanf("%d",&v);


      G[u][v] = 1;
 
    }
  }

  

  for(i=1;i<=n;i++){
    for(j=1;j<n;j++){
      
      printf("%d ",G[i][j]);
    }
    printf("%d",G[i][j]);
    printf("\n");
  }


  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <stdio.h>
using namespace std;
 
int main(){
	int a,b,c,r;
	double n;
	cin >> a >> b;
	c=a/b;
	r=a%b;
	n=1.0*a/b;
	printf("%d %d %.8lf\n",c,r,n);
    return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<algorithm>
using namespace std;
main(){
	int n,l[200];cin>>n;
	for(int i=0;i<2*n;i++)cin>>l[i];
	sort(l,l+2*n);
	int sum=0;
	for(int i=0;i<2*n;i+=2)sum+=l[i];
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
using namespace std;
const int maxd=1000000007,N=100000;
const double pi=acos(-1.0);
typedef long long ll;
struct node{
	int to,nxt;
}sq[200200];
int n,m,all=0,head[100100],d[100100];
vector<int> four;

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

void add(int u,int v)
{
	all++;sq[all].to=v;sq[all].nxt=head[u];head[u]=all;
}

bool dfs(int u,int fa,int from,int to)
{
	if (u==from) return 0;
	if (u==to) return 1;
	int i;
	for (i=head[u];i;i=sq[i].nxt)
	{
		int v=sq[i].to;
		if (fa==v) continue;
		return dfs(v,u,from,to);
	}
	return 0;
}

int main()
{
	n=read();m=read();
	int i;
	for (i=1;i<=m;i++)
	{
		int u=read(),v=read();
		add(u,v);add(v,u);
		d[u]++;d[v]++;
	}
	bool six=0;
	for (i=1;i<=n;i++)
	{
		if (d[i]&1) {printf("No");return 0;}
		else if (d[i]>=6) six=1;
		else if (d[i]==4) four.push_back(i);
	}
	if ((six) || (four.size()>=3)) {printf("Yes");return 0;}
	if (four.size()<2) {printf("No");return 0;}
	int from=four[0],to=four[1],cnt=0;
	for (i=head[from];i;i=sq[i].nxt)
		if (dfs(sq[i].to,from,from,to)) cnt++;
	if (cnt==2) printf("Yes");else printf("No");
	return 0;
}
	

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define    ll   long long int
#define    sz   200010
#define    md   1000000007
#define    py   printf("Yes\n")
#define    pn   printf("No\n")

using namespace std;


ll tani(ll n)
{
    ll i,c=0;
    while(n>0)
    {
        c++;
        n/=10;
    }

    return c;
}


int main()
{


   ll n,c=0,i,j,k;

   cin>>n;

   for(i=1;i<=n;i++)
   {
       k=tani(i);

       if(k%2==1)c++;
   }

   cout<<c<<endl;




    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    char a;
    cin >> a;
    if(isupper(a)){
        cout << 'A';
    }else{
        cout << 'a';
    }
}

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

int j,n,m;
string str;
int a[200000];
//int x[200000],y[200000];
int plot[200001];
int to[200000];

struct RMQ{
	int n;
	vector<int> dat;

	RMQ(int n_){
		n = 1;
		while(n < n_) n *= 2;
		dat.resize(2*n-1);
		for(int i = 0;i < dat.size();i++) dat[i] = INT_MAX;
	}

	void update(int k,int a){
		k += n-1;
		dat[k] = a;
		while(k > 0){
			k = (k-1)/2;
			dat[k] = min(dat[k*2+1],dat[k*2+2]);
		}
	}

	int query(int a,int b,int k,int l,int r){
		if(r <= a || b <= l) return INT_MAX;
		if(a <= l && r <= b) return dat[k];
		else{
			int vl = query(a,b,k*2+1,l,(l+r)/2);
			int vr = query(a,b,k*2+2,(l+r)/2,r);
			return min(vl,vr);
		}
	}
};

int cul(){
  int count = 0;
  for(int i = n;i > 0;i--){
    if(plot[i]){
      for(j = 1;j <= plot[i];j++){
        if(i-j < 0) break;
        if(plot[i-j] >= plot[i]-j){
          i = i-j+1;
          break;
        }
        if(j == plot[i]){
          i = i-j+1;
        }
      }
    }
    else{
      count++;
      to[i] = -1;
    }
  }
  return count;
}

int main(){
  cin >> n >> m;
  RMQ rmq(n+1);
  for(int i = 0;i < n;i++){
    cin >> a[i];
    //a[i]--;
    plot[a[i]]++;
  }
  for(int i = 0;i <= n;i++){
    rmq.update(i,i-plot[i]);
  }
  int ans = cul();
  for(int i = 0;i < m;i++){
    int x,y;
    cin >> x >> y;
    x--;
    plot[a[x]]--;
    rmq.update(a[x],a[x]-plot[a[x]]);
    if(a[x]-plot[a[x]] > 0 && rmq.query(a[x]-plot[a[x]],n+1,0,0,rmq.n) >= a[x]-plot[a[x]]){
      ans++;
      to[a[x]-plot[a[x]]] = -1;
    }
    if(y-plot[y] > 0 && to[y-plot[y]] == -1){
      ans--;
      to[y-plot[y]] = 0;
    }
    plot[y]++;
    rmq.update(y,y-plot[y]);
    a[x] = y;
    cout << ans << endl;
  }
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
const int MOD = 998244353;
string s;
lint ans = 1;
int r, g, b, e;
int rg, rb, gb;
inline void trans(int & x, int & y, int & z, int & i, int & j, int & k) {
	if (x) {
		ans = ans * x % MOD, --x;
	} else if (y) {
		ans = ans * y % MOD, --y, ++i;
	} else if (z) {
		ans = ans * z % MOD, --z, ++j;
	} else {
		ans = ans * e % MOD, --e, ++k;
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	cin >> e >> s;
	for (auto ch : s) {
		if (ch == 'R') trans(gb, g, b, rg, rb, r);
		else if (ch == 'G') trans(rb, r, b, rg, gb, g);
		else if (ch == 'B') trans(rg, r, g, rb, gb, b);
	}
	cout << ans << endl;
	return 0;
}

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

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec() -> Vec<i32> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect()
}

fn read_int_tuple() -> (i32, i32) {
    let v = read_vec();
    (v[0], v[1])
}

fn main() {
    let (N, X) = read_int_tuple();
    let L = read_vec();
    let mut D = 0;
    let mut ans = 1;
    for i in 2..(N+2) as usize {
        D += L[i-2];
        if D <= X {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
all = [1,
 2,
 3,
 4,
 5,
 6,
 7,
 8,
 9,
 10,
 12,
 14,
 15,
 16,
 18,
 20,
 21,
 24,
 25,
 27,
 28,
 30,
 32,
 35,
 36,
 40,
 42,
 45,
 48,
 49,
 54,
 56,
 63,
 64,
 72,
 81]
n=int(input())  
if n in all:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
//“Do. Or do not. There is no try.” – Yoda
#include<iostream>
#include<limits.h>
#include<algorithm>
#include<cstring>
#include<math.h>
#include<stdlib.h>
#include<cstdlib>
#include<vector>
#include<stdio.h>
#include<string>
#include<utility>
#include<iomanip>
#include<queue>
#include<map>
#include<set>
#include<fstream>
#include<stack>
#include<unordered_map>
using namespace std;
#define PI 3.14159265
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define pid pair<int,double>
#define vi vector<int>
#define vl vector<ll>
#define ss second
#define ff first
#define ll long long
#define ld long double
#define ull unsigned long long
#define SIZE 100100
#define MOD 1000000007
#define BIG 999999937
#define pq priority_queue
#define maxpq priority_queue<int>
#define minpq priority_queue<int,vector<int>,greater<int> >
#define endl '\n'
#define FOI(i, a, n) for(int i = int(a); i <= int(n); i++)
#define FOD(i, a, n) for(int i = int(a); i >= int(n); i--)
#define ALL(t) t.begin(),t.end()
#define DBG(c) cout << #c << " = " << c << endl;
#define MSET(tabl,i) memset(tabl, i, sizeof(tabl))


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


    ll n,m;
    cin>>n>>m;
    ll l[SIZE],r[SIZE];
    ll arr[SIZE];
    MSET(arr,0);
    for(int i=0;i<m;i++) {
        cin>>l[i]>>r[i];
        arr[l[i]]+=1;
        arr[r[i]+1]-=1;
    }
    ll ctr=0;
    ll ans = 0;
    for(int i=1;i<=n;i++) {
        ctr += arr[i];
        if(ctr==m) {
            ans++;
        }
    }
    cout<<ans;


    
}

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

const int moder = 1e9 + 7;
const int N = 110;

int powermod(int a, int exp){
    int ret = 1;
    for ( ; exp > 0; exp >>= 1){
        if (exp & 1){
            ret = 1ll * a * ret % moder;
        }
        a = 1ll * a * a % moder;
    }
    return ret;
}

int h[N], c[N];
int dp[N][N];

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i){
        scanf("%d", &h[i]);
        c[i + 1] = h[i];
    }
    std::sort(c, c + n + 1);
    int cnt = std::unique(c, c + n) - c;
    for (int i = cnt - 1; i >= 0; -- i){
        if (c[i] > h[0]){
            continue;
        }
        dp[0][i] = powermod(2, std::min(h[0] - c[i] + 1, h[0]));
    }
    for (int i = 0; i < cnt; ++ i){
        dp[0][i] -= dp[0][i + 1];
        dp[0][i] += dp[0][i] < 0 ? moder : 0;
    }
    for (int i = 1; i < n; ++ i){
        dp[i][0] = 1ll * powermod(2, h[i] - h[i - 1]) * dp[i - 1][0] % moder;
        int sit = std::lower_bound(c, c + cnt, h[i]) - c;
        for (int j = 1; j < N; ++ j){
            if (c[j] > h[i - 1]) break;
            if (c[j] == h[i - 1] && h[i - 1] < h[i]){
                for (int k = cnt - 1; k >= j; -- k){
                    if (c[k] > h[i]) continue;
                    dp[i][k] = (dp[i][k] + 1ll * powermod(2, h[i] - c[k] + 1) * dp[i - 1][j]) % moder;
                    dp[i][k] += dp[i][k] < 0 ? moder : 0;
                }
                for (int k = j; k < cnt; ++ k){
                    dp[i][k] -= dp[i][k + 1];
                    dp[i][k] += dp[i][k] < 0 ? moder : 0;
                }
                continue;
            }
            if (c[j] < h[i]){
                dp[i][j] = (dp[i][j] + 1ll * powermod(2, h[i] - h[i - 1]) * dp[i - 1][j]) % moder;
            }
            else{
                auto &u = dp[i][std::min(j, sit)];
                u = (u + 2ll * powermod(2, h[i] - h[i - 1]) * dp[i - 1][j]) % moder;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < N; ++ i){
        ans += dp[n - 1][i];
        ans -= ans >= moder ? moder : 0;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
// CODE © by 𝕌𝕥𝕜𝕒𝕣𝕤𝕙 𝔾𝕒𝕣𝕘
// Copying or sharing of this code without permission of the Author is strictly prohibited!!!
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Speed ios::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define endl "\n"
int power(int x, int n, int mod) {int res = 1; x %= mod; while (n) {if (n & 1)res = (res * x) % mod; x = (x * x) % mod; n >>= 1;} return res;}
signed main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
#endif
	int a = 0, b = 0, c = 0, d = 0, i = 0, j = 0, k = 0, t = 0, n = 0, q = 0;
	cin >> n >> k;
	unordered_set<int> arr;
	int dp[k + 1] = { -1};
	memset(dp, -1, sizeof(dp));
	// for (auto i : dp)cout << i << " "; cout << endl;

	for (int i = 0; i < n; i++) {cin >> a; arr.insert(a);}
	dp[0] = 2;
	int chance = 0;
	for (int i = 1; i <= k; i++) {
		if (arr.find(i) != arr.end())
			dp[i] = 0;
		else for (auto j : arr) {
				if (j < i && dp[i - j] == 1)dp[i] = 0;
			}
		if (dp[i] == -1) {
			dp[i] = 1;
			// cout << "not " << i << endl;
			// if (chance == 1)dp[i] = 0;
			// else dp[i] = 1;
		}
		// if (chance == 1)chance = 0;
		// else chance = 1;
	}
	// for (auto i : dp)cout << i << " "; cout << endl;
	if (dp[k])cout << "Second";
	else cout << "First";
	// cout << dp[k];
}

Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
typedef long long ll;
const int N = 1e2+5;
const int INF = 1e9;
const int MOD = 1e9+7;
const int K = 1e5+5;

int n, k;
int a[N];
int f[K]; //0: lose position, 1: win position
int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> k;
	for (int i=0; i<n; i++){
		cin >> a[i];
		f[a[i]] = 1; //win 
	}
	// chi can no co the dua ve 1 vi tri lose nao do la no win
	for(int i=1; i<=k; i++){
		f[i] = 0; //init lose
		for(int j=0; j<n; j++){
			if (i-a[j] < 0) continue;
			if (f[i-a[j]] == 0) {
				f[i] = 1;
				break;
			}
		}
	}
	if (f[k] == 1) cout << "First\n"; 
	else cout << "Second\n";

	return 0;
}


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

using namespace std;

const int MOD = 1000000007;
const int MAX = 110000;

long long fac[MAX], finv[MAX], inv[MAX];

void comInit() {
	fac[0] = fac[1] = inv[1] = finv[0] = finv[1] = 1;
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

long long nCr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

int main() {
	comInit();
	int n, k; cin >> n >> k;
	vector<int> a(n);
	for (auto& e : a) cin >> e;
	sort(a.begin(), a.end());
	long long smax = 0, smin = 0;
	for (int i = 0; i < n; ++i) {
		(smax += nCr(i, k - 1) * a[i]) %= MOD;
		(smin += nCr(n - i - 1, k - 1) * a[i]) %= MOD;
	}
	cout << (MOD + smax - smin) % MOD << endl;

	return 0;
}

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


using namespace std;

#define fastio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()


void go(){
   int n;cin>>n;
   int a=0;
   for(int i=0;i<n;i++) {
	   int x;cin>>x;
	   if(x&1&&(i+1)&1) a++;
   }
   cout << a;
}
int main(){
   
   fastio();
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}




Measured memory_bytes: 3612
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 1e+5+5;

int n,m;
struct segment{
	int x,y;
	segment(const int x_=0,const int y_=0){x=x_;y=y_;}
	friend bool operator < (segment a,segment b){
		if (a.x!=b.x)return a.x<b.x;
		return a.y<b.y;
	}
}a[N*2];
int k;

int main(){
	n=get();m=get();
	int lst=get();
	LL sum=0;
	LL rs=0,ans,cnt=0;
	fo(i,2,n){
		int x=get();
		if (lst<=x)a[++k]=segment(x,lst),a[++k]=segment(lst,x),sum+=x-lst;
		else{
			a[++k]=segment(x,lst-m),a[++k]=segment(lst,x+m);
			rs=rs+x;cnt++;
		}
		lst=x;
	}
	sort(a+1,a+1+k);
	int w=1;
	fo(i,1,m){
		LL tmp=rs-cnt*i+cnt+sum;
		if (i==1||tmp<ans)ans=tmp;
		while(w<=k&&a[w].x==i){
			if (a[w].y>a[w].x){
				sum-=a[w].y-a[w].x;
				cnt++,rs+=a[w].y;
			}
			else{
				sum+=a[w].x-a[w].y;
				cnt--,rs-=a[w].x;
			}
			w++;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
ll S[20007];
int main()
{
    ll N;
    cin >> N;
    if(N<=2) cout << 0 << endl;
    else {
        ll ans  = 0;
        S[0] = 1;S[1] = 1;S[2] = 1;
        for(ll i=3;i<=N;i++)
        {
            S[i] = S[i-1]+S[i-3];
            S[i] %= MOD;
        } cout << S[N-3] << endl;
    }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, m, ans=0;
    vector<int> v;
    cin >> n >> m;
    REP(i,m){
        int a, b;
        cin >> a >> b;
        v.push_back(max(0,n-a));
    }
    SORT(v);
    REP(i,m-1){
        ans += v[i];
    }
    cout << ans << endl;
    return 0;
}



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

int main(){
    int N,M,X;
    int A[101] = {};
    int res;

    cin>>N>>M>>X;

    for(int i=0;i<M;i++){
        int a;
        cin>>a;
        for(int j=0;j<N;j++){
            if(j == a) A[j]++;
        }
    }

    int count_p=0;
    int count_m=0;

    for(int i=X;i<N;i++){
        if(A[i]) count_p++;
    }

    for(int i=X;i>0;i--){
        if(A[i]) count_m++;
    }
    
    res = min(count_p,count_m);

    cout<<res<<"\n";
     
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

int main(){	
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt_R=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='R'){
			cnt_R++;
		}
	}
	string t="";
	for(int i=0;i<cnt_R;i++){
		t+='R';
	}
	for(int i=0;i<s.size()-cnt_R;i++){
		t+='W';
	}
	//cout << t << endl;
	int ans=0;
	for(int i=0;i<cnt_R;i++){
		if(s[i]!=t[i])ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3924
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

int dfs(int p, int q, int a, int n, int i=1){
  if (p == 0) return 1;
  if (n == 0) return 0;
  if (a < i) return 0;
  if (p * i < q) return dfs(p, q, a, n, (q+p-1)/p);
  return dfs(p, q, a, n, i+1) + dfs(p*i - q, q*i, a/i, n-1, i);
}

int main() {
  while(1){
    int p,q,a,n;
    cin>>p>>q>>a>>n;
    if(!p)break;
    cout << dfs(p,q,a,n) << endl;
  }
  return 0;
}

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

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

  int A[100010];
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  sort(A, A+N);

  int ans = 1 << 30;
  for (int i = K-1; i < N; ++i) {
    ans = min(ans, A[i] - A[i-K+1]);
  }

  cout << ans << endl;

  return 0;
}


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

typedef long long ll;
typedef long double ld;
#define int ll
#define pb push_back
const int INF = 1e18;

signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n; cin>>n;
	ld arr[n+1];
	for(int i=1;i<=n;i++)
		cin>>arr[i];

	vector<ld> dp(n+1,(ld) 0), next(n+1,(ld)0);
	dp[0] = 1;
	for(int i=1;i<=n;i++){
		next[0] = dp[0]*(1 - arr[i]);
		for(int j=0;j<n;j++)
			next[j+1] = dp[j]*arr[i] + dp[j+1]*(1-arr[i]);

		for(int i=0;i<=n;i++)
			dp[i] = next[i];
	}

	ld ans = 0;
	for(int i = n/2 + 1; i<=n;i++)
		ans += dp[i];

	cout<<fixed<<setprecision(12);
	cout<<ans;
	

	return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    int A,B;
    cin >> A >> B;

    cout << max(max( A+B, A-B), A*B) << endl;
}


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

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)

//repetition
//------------------------------------------
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T> ostream & operator<<(ostream& os, vector<T> const& v){
        for(auto it=v.begin(); it!=v.end(); ++it){
            os << *it << (it+1==v.end() ? "" : ",");
        }
        return os;
    }
}

//clear memory
#define clr(a) memset((a), 0 ,sizeof(a))

int lcm(int a,int b){
   return a*b/__gcd(a,b);
}
 
vb pn((int)1e4+10); 
void prime_number(int n){
   fill(all(pn),true);
   pn[0]=false;pn[1]=false;
   loop(i,2,n/2+1){
      if(!pn[i]) continue;
      for(int j=2;i*j<=n;j++){
         pn[i*j]=false;
      }
   }
}

char m[21][21];
int ans;

void tansaku(int a, int b, int x, int y){
   if(a-1>=0)if(m[a-1][b]=='.'){
      m[a-1][b]='*';
      ans++;
      tansaku(a-1,b,x,y);
   }
   if(b-1>=0)if(m[a][b-1]=='.'){
      m[a][b-1]='*';
      ans++;
      tansaku(a,b-1,x,y);
   }
   if(a+1<x)if(m[a+1][b]=='.'){
      m[a+1][b]='*';
      ans++;
      tansaku(a+1,b,x,y);
   }
   if(b+1<y)if(m[a][b+1]=='.'){
      m[a][b+1]='*';
      ans++;
      tansaku(a,b+1,x,y);
   }
}

int main(){
   int x,y,a,b;
   string tmp;
   while(cin >> x >> y){
      if(x+y==0) break;
      ans=1;
      rep(j,y){
         rep(i,x){
            cin>>m[i][j];
            if(m[i][j]=='@'){
               a=i;b=j;
            }
         }
      }
      tansaku(a,b,x,y);
      cout <<  ans << endl;

   }
}

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

using namespace std;

int main() {
	int flag = 2;
	string output[3] = { "GREATER","LESS","EQUAL" };

	string A, B;
	cin >> A >> B;
	
	int na = (int)A.size();
	int nb = (int)B.size();
	int a_temp = 0, b_temp = 0;

	if (na > nb) flag = 0;
	else if (na < nb) flag = 1;
	else if (na == nb){
		for (int i = 0; i < na; i++) {
			a_temp = stoi(A.substr(i, 1));
			b_temp = stoi(B.substr(i, 1));
			if (a_temp > b_temp) {
				flag = 0;
				break;
			}
			if (a_temp < b_temp) {
				flag = 1;
				break;
			}
		}
	}

	cout << output[flag] << endl;
}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

#ifdef BOI
#include "debug.h"
#else
#define debug(args...)
#endif

#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define eps 1e-7
#define inf 0x3f3f3f3f
#define endl '\n'

int main() {
    cin.tie(0)->sync_with_stdio(0), cin.exceptions(cin.failbit);
    string s; cin >> s;
    char x = s.back();
    if (x == 's') {
        s += "es";
    } else {
        s += "s";
    }
    cout << s;
}


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

#define ALL(a)  (a).begin(),(a).end()

int main(){
  int64_t N;
  cin>>N;
  vector<int64_t> A(N),B(N),C(N);
  for(int i=0;i<N;++i){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());

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

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


  int64_t sum=0;
  for(int i=0;i<N;++i){
    int64_t ue=lower_bound(ALL(A),B.at(i))-A.begin();
    int64_t sita=C.end()-upper_bound(ALL(C),B.at(i));
    sum=sum+ue*sita;
  }

  cout<<sum<<endl;
}

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

// 座標圧縮
void compress(vector<ll>& A){
    
    // 変換表
    auto B = A;
    sort(ALL(B));
    auto it = unique(ALL(B));
    B.erase(it, B.end());

    ll N = A.size();
    FOR(i, 0, N){
        ll a = lower_bound(ALL(B), A[i]) - B.begin();
        A[i] = a;
    }}

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    compress(A);

    auto bit = BinaryIndexedTree<ll>(N);

    ll count = 0;
    FOR(i, 0, N){
        ll a = A[i];
        ll num = i - bit.sum(a);
        count += num;
        bit.add(a, 1);
    }

    p(count);
    
    return 0;
}


Measured memory_bytes: 6020
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>

#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#include <utility>
#include <list>

#include <cmath>
#include <algorithm>
#include <cassert>
#include <bitset>
#include <complex>
#include <climits>
#include <functional>
#include <unordered_set>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
typedef pair<double, double> dd;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back

#define debug(x) cerr << #x << " = " << x << " "
int main()
{
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for (int i = 0; i * r <= n; ++i)
        for (int j = 0; j * g <= n; ++j)
        {
            int left = n - i * r - j * g;
            ans += left >= 0 && left % b == 0;
        }
    cout << ans << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define in insert
#define sz(v) v.size()
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 5;
void solve(){
    int n, x;  cin>>n>>x;
    vi v(n+1,0);
    for(int i = 1; i <= n+1; i++){
        int t; cin>>t;
        v[i]=v[i-1]+t;
        if(v[i]>x){
            cout<<i;
            return;
        }
    }
    cout<<n+1;
}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K,Q;
  cin >> N >> K >> Q;
  vector<int> score(N,0);
  int A;
  
  for(int i=0;i<Q;i++){
    cin >> A;
    score.at(A-1)++;
  }
  for(int i=0;i<N;i++){
    if(K-Q+score.at(i) > 0)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
}
  

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

using namespace std;

int main()
{
	vector<int> vec;
  	for (int i = 0; i < 3; i++){
    	int a; cin >> a;
      	vec.push_back(a);
    }
  	sort(vec.begin(), vec.end(), greater<int>());
  
  	int ans = vec[0] * 10 + vec[1] + vec[2];
  	cout << ans;
  	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second

const int INF = 19191919;

using Point = pair<int,int>;

bool solve(int n, int m){
    vector<Point> b(n),w(m);
    rep(i,n) cin >>b[i].x >>b[i].y;
    rep(i,m) cin >>w[i].x >>w[i].y;

    rep(i,n)rep(j,m){
        int A = w[j].y - b[i].y;
        int B = b[i].x - w[j].x;
        int C = b[i].y*w[j].x - b[i].x*w[j].y;

        bool ok = true;
        vector<pair<Point,int>> on_line;

        int bp = 0, bm = 0;
        rep(k,n){
            int v = A*b[k].x + B*b[k].y + C;

            if(v>0) ++bp;
            else if(v<0) ++bm;
            else on_line.pb({b[k],0});
        }

        int wp = 0 , wm = 0;
        rep(k,m){
            int v = A*w[k].x + B*w[k].y + C;

            if(v>0) ++wp;
            else if(v<0) ++wm;
            else on_line.pb({w[k],1});
        }

        if(bp>0 && bm>0) ok = false;
        if(wp>0 && wm>0) ok = false;
        if(bp>0 && wp>0) ok = false;
        if(bm>0 && wm>0) ok = false;

        sort(all(on_line));
        int sz = on_line.size();
        int ch = 0;
        rep(k,sz-1) ch += (on_line[k].second != on_line[k+1].second);

        if(ch>1) ok = false;
        if(ok) return true;
    }

    return false;
}

int main(){
    int n,m;
    while(cin >>n >>m,n) cout << (solve(n,m)?"YES":"NO") << endl;
    return 0;
}



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

int main(){
  int k;
  string s;
  cin >> k >> s;
  if(s.size() <= k) cout << s << endl;
  else{
    for(int i = 0; i < k; i++){
      cout << s[i];
    }
    cout << "..." << endl;
  }
}

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

const int N = 700 + 10;
bool adj[N][N], r[N], mark[N];
bool dp[N][N];
int n;

void dfs(int root, int color) {
    mark[root] = true;
    r[root] = color;
    for (int i = 0; i < n; i++)
        if(!mark[i] && !adj[root][i] && root != i)
            dfs(i, 1 - color);
}

pair<int, int> dfs2(int root) {
    pair<int, int> res;
    res.first = 1;
    res.second = 0;
    mark[root] = true;
    for (int i = 0; i < n; i++)
        if(!mark[i] && !adj[root][i] && root != i) {
            pair<int, int> x = dfs2(i);
            res.first += x.second;
            res.second += x.first;
        }
    return res;
}

int main() {
    int m, u, v;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> u >> v;
        u--;
        v--;
        adj[u][v]++;
        adj[v][u]++;
    }
    for (int i = 0; i < n; i++)
        if(!mark[i])
            dfs(i, 0);
    bool ans = true;
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            if(!adj[i][j] && r[i] == r[j])
                ans = false;
    int ans2 = n + 1;
    if(ans) {
        for (int i = 0; i < n; i++)
            mark[i] = false;
        vector<int> x, y;
        for (int i = 0; i < n; i++)
            if(!mark[i]) {
                pair<int, int> z = dfs2(i);
                x.push_back(z.first);
                y.push_back(z.second);
            }
        dp[0][abs(x[0] - y[0])] = true;
        for (int i = 1; i < x.size(); i++) {
            for (int j = 0; j <= n; j++)
                dp[i][j] = dp[i - 1][abs(j - abs(x[i] - y[i]))] || dp[i - 1][abs(j + abs(x[i] - y[i]))];
        }
        for (int i = n; i >= 0; i--)
            if(dp[x.size() - 1][i]) {
                int t1 = (n - i) / 2, t2 = (n - i) / 2 + i;
                ans2 = (t1 * (t1 - 1)) / 2 + (t2 * (t2 - 1)) / 2;
            }
    }
    cout << (ans? ans2: -1) << endl;
    return 0;
}


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

int main(){
    long long int x,y;
    cin>>x>>y;
    long long int res;
    if(y>=x){
        res=y-x;
        if(x<0 && y>0){
            if(y-abs(x)>=0) res=min(res,1+y-abs(x));
            else res=min(res,abs(x)-y+1);

        }
    }
    else{
        if(x>=0 && y>=0){
            res=1+y+abs(x);
            res=min(res,2+x-y);
        }
        else if(x>0 && y<0){
            if(abs(x)>abs(y)){
                res=1+y+abs(x);
            }
            else if(abs(x)<abs(y)){
                res=1+abs(y)-x;
            }
            else{
                res=1;
            }
        }
        else{
            res=2+abs(y)-abs(x);
            res=min(res,abs(y)-x+1);
        }
    }
    cout<<res<<endl;
    return 0;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

class Main {

	public static void main(String[] args) throws IOException {

		StringBuilder buider = new StringBuilder();

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String n = br.readLine();

		String nums;

		int count=0;
		for(int i=0; i<Integer.parseInt(n); i++){
			 nums = br.readLine();
			if(new BigInteger(nums).isProbablePrime(3)){
				count++;
			}
		}

		System.out.println(count);

	}

}

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

int ctoi(char c){
    if(c>='0' && c<='9'){
        return c-'0';
    }
    return 0;
}

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    int num, ans;
    ans = 0;
    string str;
    for(int i=1; i<=N; i++){
        num = 0;
        str = to_string(i);
        for(int j=0; j<str.size(); j++){
            num += ctoi(str[j]);
        }
        if(A<=num && num<=B){
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
function Main(input) {
    "use strict";
    const els = input.split('\n');
    const number = els[0];
    const values = els[1].split(' ');
    const costs = els[2].split(' ');
    let sum = 0;

    for (let i = 0; i < number; i++) {
        if(parseInt(values[i],10) >= parseInt(costs[i],10)){
            sum += parseInt(values[i],10) - parseInt(costs[i],10);
        }
    }

    console.log(sum);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf-8'));

Measured memory_bytes: 21064
import heapq

N = int(input())
C = input()

W, R = [], []
heapq.heapify(W)
heapq.heapify(R)

ans = 0
for i in range(N):
    if C[i] == "W": heapq.heappush(W,i+1)
    if C[i] == "R": heapq.heappush(R,-(i+1))

if len(W) == 0 or len(R) == 0:
    print(0)
    exit()

ans = 0
while W[0] < -R[0]:
    w, r = heapq.heappop(W), -heapq.heappop(R)
    heapq.heappush(W,r)
    heapq.heappush(R,-w)
    ans += 1

print(ans)

Measured memory_bytes: 17392
from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
from bisect import *
input=lambda :sys.stdin.readline().rstrip()


X=int(input())

value=X//500 * 1000
X%=500
value+=X//5 * 5
print(value)


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

int main() {
	int a;
	string x, y;
	vector<string> buff;

	cin >> a;
	cin >> x;
	buff.push_back(x);
	
	for (int i = 1; i < a; i++) {
		cin >> x;
		if (x[0] == buff[i - 1].back()) {
			for (int j = 0; j < i; j++) {
				if (x == buff[j]) {
					cout << "No" << endl;
					return 0;
				}
			}
			buff.push_back(x);
		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e6+69, INF=2e9+6969;

int qq;
map <string,int> m;
int main()
{
	int n;
	scanf("%d", &n);
	for(int i=0;i<n;++i)
	{
		string s;
		cin >> s;
		m[s]++;
	}
	printf("AC x %d\n", m["AC"]);
	printf("WA x %d\n", m["WA"]);
	printf("TLE x %d\n", m["TLE"]);
	printf("RE x %d\n", m["RE"]);
	return 0;
}


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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define vi vector< int > 
#define pii pair< int, int >
#define mii map< int , int > 
#define F(start,stop) for(int i=start; i<stop; i++)
#define FRev(start,stop) for(int i=start; i>=stop; i--)
#define MOD1 1000000007
#define MOD2 998244353

int main()
{

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	IOS

	int n;
	cin >> n;
	int arr[n];
	int hash[1000005] = {0};
	F(0,n) {
		cin >> arr[i];
		hash[arr[i]]++;
	}

	int cnt = 0;

	F(0,n){
		
		if(arr[i] == 1 && hash[1] == 1){
			cnt++;
			continue;
		}

		if(hash[arr[i]] > 1)
			continue;

		if(hash[1] >= 1)
			continue;

		bool isPoss = true;

		for(int j=2; j <= sqrt(arr[i]); j++){

			if(arr[i] % j == 0){
				if(hash[j] != 0 || hash[arr[i]/j] != 0){
					isPoss = false;
					break;
				}
			}
		}
		if(isPoss)
			cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 8308
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long H, W;
    scan(H, W);
    auto cnt = new long[]('z' - 'a' + 1);
    foreach (_; 0 .. H)
        foreach (c; sread())
            cnt[c - 'a']++;
    long[] task;
    foreach (y; 0 .. (H + 1) / 2)
        foreach (x; 0 .. (W + 1) / 2)
        {
            long iy = H - y - 1;
            long ix = W - x - 1;
            task ~= () {
                if (y == iy && x == ix)
                    return 1;
                if (y == iy || x == ix)
                    return 2;
                return 4;
            }();
        }
    task.sort!"b<a"();
    outer: foreach (t; task)
    {
        foreach (i; 0 .. cnt.length)
            if (t <= cnt[i])
            {
                cnt[i] -= t;
                continue outer;
            }
        writeln("No");
        return;
    }
    writeln("Yes");
}


Measured memory_bytes: 380
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define eps 0.00000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define f(n) for(int i=0;i<n;++i)
#define REP(i,n) for(long long i = 0;i < n;++i)
int main(){
	string s;
	cin >> s;
	string hoge;
	REP(i,s.length()){
		if(i % 2 == 0)hoge.push_back(s[i]);
	}
	cout << hoge << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
main(){
  int a,b,c;
  char op;
  scanf("%d %c %d",&a,&op,&b);
  while(op-'?'){
    switch(op){
      case '+':c=a+b;
        break;
      case '-':c=a-b;
        break;
      case '*':c=a*b;
        break;
      case '/':c=a/b;
        break;
    }
    printf("%d\n",c);
    scanf("%d %c %d",&a,&op,&b);
  }
}

Measured memory_bytes: 1028
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<algorithm>
#define P pair<string,int>
using namespace std;

int main() {
	priority_queue<int>a;
	string b;
	while (cin >> b, b[2]!= 'd') {
		if (b[0] == 'i') {
			int c;
			scanf("%d", &c);
			a.push(c);
		}
		else {
			int d = a.top();
			a.pop();
			printf("%d\n", d);
		}
	}
}

Measured memory_bytes: 7020
#include<iostream>
#include<vector>
#include<algorithm>
#define ll long long int;

using namespace std;


int main(){

    int n;
    cin >> n;

    int a, b;
    vector<pair<int,int> > task(n);

    for(int i=0;i<n;i++){
        cin >> a >> b;
        task[i] = make_pair(b,a);
    }

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

    int sum=0;

    for(int i=0;i<task.size();i++){
        sum += task[i].second;

        if(sum > task[i].first){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <list>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>

#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    int N;
    cin >> N;
    map<int, int> cardMap;
    int ans = 0;
    for (int i = 0; i < N; i++) {
    	int A;
    	cin >> A;
    	auto itr = cardMap.find(A);
    	if (itr != cardMap.end()) {
    		cardMap[A]++;
    	}
    	else {
    		cardMap[A] = 1;
    		ans++;
    	}
    }

    int count_even = 0;

    // 同じ数字が奇数枚ある場合は、何回かの操作で1枚にすることができる
    // また同じ数字が偶数枚ある場合は、何回かの操作で2枚にすることができる
    for (auto itr = cardMap.begin(); itr != cardMap.end(); itr++) {
    	if (itr -> second % 2 == 0) {
    		count_even++;
    	}
    }

    // 同じカードが2枚ある組が偶数の場合は、そのなかでペアをつくり操作すればカードに書かれた数字の種類は減らない
    // 同じカードが2枚ある組が奇数の場合は、1枚だけの数字のどれかと操作を行う必要があるため解答が1種類減る
    if (count_even % 2 == 1) {
    	ans--;
    }

    cout << ans << endl;
}


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

int main() {
  int N, W;
  string all = "";
  
  cin >> N >> W;
  
  string k;
  for (int i=0; i<N; i++) {
    cin >> k;
    all += k;
  }
  
  for (int i=0; i<N*W; i++) {
    // 改行処理
    if (i != 0 && i%W == 0)
      cout << endl;
    // 自身が爆弾の時
    if (all.at(i) == '#') 
      cout << '#';
    // 爆弾でない時
    else {
      int count = 0;
      bool checker_1 = false;
      bool checker_2 = false;
      // 上がある
      if (W <= i) {
        if (all.at(i-W) == '#')
          count++;
        checker_1 = true;
      }
      // 下がある
      if (i < W*(N-1)) {
        if (all.at(i+W) == '#')
          count++;
        checker_2 = true;
      }
      // 左がある
      if (i%W != 0) {
        if (all.at(i-1) == '#')
          count++;
        // 左上がある
        if (checker_1) {
          if (all.at(i-W-1) == '#')
            count++;
        }
        // 左下がある
        if (checker_2) {
          if (all.at(i+W-1) == '#')
            count++;
        }
      }
      // 右がある
      if (i%W != W-1) {
        if (all.at(i+1) == '#')
          count++;
        // 右上がある
        if (checker_1) {
          if (all.at(i-W+1) == '#')
            count++;
        }
        // 右下がある
        if (checker_2) {
          if (all.at(i+W+1) == '#')
            count++;
        }
      }
      cout << count;
    }
  }
  cout << endl;
}  
      
      
    


Measured memory_bytes: 256