akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.lang.String;

public class Main{

	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
		int a,b;
		String op;
		int d;
		
		while(true){
		    a = sc.nextInt();
		    op = sc.next();
		    b = sc.nextInt();
		    
		    if(op.equals("+")){
		        d = a+b;
		    }
		    else if(op.equals("-")){
		        d = a-b;
		    }
		    else if(op.equals("*")){
		        d = a*b;
		    }
		    else if(op.equals("/")){
		        d = a/b;
		    }
		    else{
		        sc.close();
		        return;
		    }
		    System.out.println(d);
		    
		}
	}

}


Measured memory_bytes: 26160
#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;
  }
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

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

using ll = long long;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define pb push_back
#define mp make_pair
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

// these functions return the position of result of Binary Search.
#define LB(s, t, x) (int) (lower_bound(s, t, x) - s)
#define UB(s, t, x) (int) (upper_bound(s, t, x) - s)

ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx8[] = { 1, -1, 0, 0, 1, 1, -1, -1 }, dy8[] = { 0, 0, -1, 1, -1, 1, -1, 1 };

template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

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

inline tuple<ll, ll> rotate45(tuple<ll, ll> point) { ll x = get<0>(point), y = get<1>(point); return tuple<ll, ll>(x + y, x - y); }
inline bool rangeCheck2D(int nx, int ny, int Width, int Height) { return nx >= 0 and nx < Width and ny >= 0 and ny < Height; }
void out_sequence(vector<ll> &out) { REP(i, out.size()) { cout << out[i]; if (i == out.size() - 1) cout << endl; else cout << " "; } }



int main(void)
{
	cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);

	ll A, B; cin >> A >> B;
	if (A + B == 15) cout << "+" << endl;
	else if (A * B == 15) cout << "*" << endl;
	else cout << "x" << endl;	

	return 0;
}



Measured memory_bytes: 256
import numpy as np

n = int(input())
a = np.array(list(map(int,input().split())))

amax=max(a)+1
ah=[0]*amax

for i in a:
    for j in range(i,amax,i):
        ah[j]+=1

an=0
for i in a:
    if ah[i]==1:
        an+=1
print(an)

Measured memory_bytes: 50744
#include <stdio.h>

int main()
{
  int a,b,c;

  scanf("%d %d %d", &a , &b , &c);

  if( a < b && b < c )
    {
      printf("Yes\n");
    }
  else
    {
      printf("No\n");
    }
  return 0;
}


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

int a[510][510];
int main()
{
    int h, w; cin>>h>>w;
    for(int i=0; i<h; ++i) for(int j=0; j<w; ++j) {
        int t; cin>>t;
        a[i][j]=t%2;
    }
    int N=0;
    vector<vector<pair<int, int>>> res;
    vector<pair<int, int>> v;
    for(int i=0, j=0, d=1, n=0; n<h*w; ++n) {
        if (v.size()) {
            v.emplace_back(i, j);
            if (a[i][j]) { N+=v.size()-1; res.push_back(v); v.clear(); }
        }
        else if (a[i][j]) {
            v.emplace_back(i, j);
        }
        j+=d;
        if (j==w) { j=w-1; d=-1; ++i; }
        else if (j==-1) { j=0; d=1; ++i; }
    }
    cout<<N<<endl;
    for(auto& e: res) {
        for(int i=0; i+1<e.size(); ++i)
            cout<<e[i].first+1<<' '<<e[i].second+1<<' '<<e[i+1].first+1<<' '<<e[i+1].second+1<<endl;
    }
}


Measured memory_bytes: 9904
/*
    Author : Pranav_Raut.
*/

#include<bits/stdc++.h>
using namespace std;
#define input(arr,n) for(ll i=0;i<n;i++){cin>>arr[i];}
typedef long long int ll;
const ll MOD = 1000000007;
const ll MAXN = 100005;
ll H,W;
ll dp[1001][1001];
char ar[1001][1001];
ll recur(ll i, ll j)
{
  	if(i>=H || j>=W)
    {
      	return 0;
    }
  	if(ar[i][j]=='#')
    {
      	dp[i][j] = 0;
      	return 0;
    }
  	if(dp[i][j]!=-1)
    {
      	return dp[i][j];
    }
  	dp[i][j] = ( recur(i+1,j) % MOD + recur(i,j+1) % MOD ) % MOD;
  	return dp[i][j];
}
        

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    cin >> H >> W;
  	for(ll i=0;i<H;i++)
    {
        for(ll j=0;j<W;j++)
        {
            cin>>ar[i][j];
            dp[i][j] = -1;
        }
    }
    dp[H-1][W-1] = 1;
  	cout << recur(0,0) % MOD << endl;
    return 0;
}


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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
const int N=2e3+3;
int n,x,y;
int dis[N];
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            int far=min(j-i,min(abs(x-i) +1+ abs(y-j),abs(x-j)+ 1+abs(y-i)));
            dis[far]++;
        }
    }
    for(int k=1;k<=(n-1);k++) cout<<dis[k]<<'\n';
    return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

class UnionFind{
private:
  vector<ll> Parent; 
 public:
  UnionFind(ll N){
    Parent = vector<ll>(N, -1);
  }
  
  ll root(ll A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  ll size(ll A){
    return -Parent[root(A)]; 
  }
  
  bool connect(ll A, ll B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(ll A, ll B){
    return root(A) == root(B);
  }
};

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  vll ans(m);
  ans[0]=n*(n-1)/2;
  vpll ab(m);
  rep(i,m){
    ll a,b; cin>>a>>b; a--,b--;
    ab[i]={a,b};
  }
  reverse(all(ab));
  UnionFind uf(n);
  rep(i,m-1){
    ll a=ab[i].first, b=ab[i].second;
    if(!uf.isSame(a,b)){
      ans[i+1]=ans[i]-uf.size(a)*uf.size(b);
      uf.connect(a,b);
    }else{
      ans[i+1]=ans[i];
    }
  }
  reverse(all(ans));
  rep(i,m) cout<<ans[i]<<endl;
}

Measured memory_bytes: 4608
// https://leetcode.com/problems/count-complete-tree-nodes/
#include <bits/stdc++.h>
using namespace std;


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

	
	int r; cin >> r;

	
	int p = pow(r,2);

	cout << (3 * p);

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
//using ll = long long;
//using P = pair<int,int>;

struct Node {
    int key;
    Node *prev, *next; // *prevはNode型、prevはNodeを示すアドレス
};

Node *nil; // *nilは構造体、nilはその先頭アドレス

void init(){
    nil = (Node *)malloc(sizeof(Node)); // malloc(sizeof(Node)) : Node分のメモリ確保した先頭アドレス (Node *)：Node型へのアドレスにキャスト ※右辺はアドレス
    nil->next = nil; // 構造体のメンバを出すとき：(構造体の出したい要素のアドレス)->(メンバ) ※nilは構造体*nilの先頭アドレス
    nil->prev = nil;
}

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node)); // 構造体型*x, 構造体の先頭アドレスx
    x -> key = key;
    x -> next = nil -> next;
    x -> next -> prev = x; // (構造体のアドレス)->(メンバ)でメンバを見れるので、このように繋げられる
    nil -> next = x;
    x -> prev = nil;
}

Node* listSearch(int key){
    Node *cur = nil->next;
    while ((cur != nil) && (cur->key!=key)) cur = cur -> next;
    return cur;
}

void deleteNode(Node *t){
    if (t == nil) return;
    t -> prev -> next = t -> next;
    t -> next -> prev = t -> prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil -> next);
}

void deleteLast(){
    deleteNode(nil -> prev);
}

void deletekey(int key){
    deleteNode(listSearch(key));
}

void printList(){
    Node *cur = nil->next;
    int j = 0;
    while (cur != nil) {
        if (j != 0) cout << ' '; 
        cout << ((Node *)cur)->key;
        cur = cur->next;
        j++;
    }
    cout << endl;
}

int main(){
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd=0;
    init();
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        scanf("%s", com);
        if (com[0]=='i'){
            scanf("%d", &key);
            insert(key);
        }
        else if(com[0]=='d'){
            if (com[6]=='F') deleteFirst();
            else if (com[6]=='L') deleteLast();
            else {
                scanf("%d", &key);
                deletekey(key);
            }
        }
    }
    printList();
    return 0;
}


Measured memory_bytes: 34408
from collections import deque
area = input()
S1 = deque()
S2 = deque()
total = 0

for i, v in enumerate(area):
    if v == '\\':
        S1.append(i)
    elif v == '/' and S1:
        j = S1.pop()
        subtotal = i - j
        total += i - j
        while S2 and S2[-1][0] > j:
            subtotal += S2.pop()[1]
        S2.append([j, subtotal])

print(total)
print(len(S2), *(subtotal for j, subtotal in S2))

Measured memory_bytes: 8516
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a=1,N,K,a2,i;
  cin >> N >> K;
  for(i=0;i<N;i++){
    if(a*2>=a+K){
      a+=K;
    } else {
      a*=2;
    }
    if(i+1==N){
      cout << a << endl;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{


    int x,a,b,s=0;
    cin>>x>>a>>b;

    x=x-a;
   /* for(int i=0; ; i++)
    {
        if(b>=x)
            x=x-b;
        else
            break;
    }*/

    while(x>=b)
        x=x-b;

    cout<<x<<endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,sj;
	sj=0;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]%2!=0)
		{
			sj=sj+a[i];
		}
	}
	if(sj%2==0)
	{
		printf("%s","YES");
	}
	else
	{
		printf("%s","NO");
	}
}

Measured memory_bytes: 640
class Combination:
  def __init__(self, n_max, mod=10**9+7):
    self.mod = mod
    self.modinv = self.make_modinv_list(n_max)
    self.fac, self.facinv = self.make_factorial_list(n_max)

  def __call__(self, n, r):
    return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

  def make_factorial_list(self, n):
    # 階乗のリストと階乗のmod逆元のリストを返す O(n)
    # self.make_modinv_list()が先に実行されている必要がある
    fac = [1]
    facinv = [1]
    for i in range(1, n+1):
      fac.append(fac[i-1] * i % self.mod)
      facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
    return fac, facinv

  def make_modinv_list(self, n):
    # 0からnまでのmod逆元のリストを返す O(n)
    modinv = [0] * (n+1)
    modinv[1] = 1
    for i in range(2, n+1):
      modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
    return modinv

n,k = map(int,input().split())
ans = 1
MOD = 10**9+7
comb = Combination(2*10**5+1)
for i in range(1, min(n, k+1)):
  ans += (comb(n,i)*comb(n-1, i))%MOD
  ans %= MOD

print(ans)


Measured memory_bytes: 103180
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int n, m;
int main() {
	cin >> n >> m;
	vector<int>ya;
	for (int i = 1; i <= sqrt(m); i++) {
		if (m%i == 0) {
			ya.emplace_back(i);
			ya.emplace_back(m / i);
		}
	}
	int ans = 0;
	REP(i, ya.size()) {
		if (m / ya[i] >= n)ans = max(ans, ya[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var mod = 1e9 + 7;
function abmod(){for(var a=arguments,r=a[0],i=1;i<a.length;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i++])%mod;return r;}
function powmod(a,n){for(var r=1;n;a=abmod(a,a),n>>=1)if(n&1)r=abmod(a,r);return r;}

console.log(main());
function main(){
  var n = o.a();
  var a = o.l();
  var mx = 0;
  for(var i = 0; i < n; i++)if(mx < a[i])mx = a[i];
  mx = f(mx);
  var dp = xArray(0,mx);
  var dp0 = xArray(1,mx);
  var c = new Map();
  var x = 0, z = 0;
  for(var i = 0; i < n; i++){
    x ^= a[i];
    if(x === 0)dp0[0]++,z++;
    else{
      solve(x);
    }
  }
  if(x !== 0)return dp0[x];
  var ans = powmod(2,dp0[0]-2);
  for(var i = 1; i < mx; i++)ans += dp[i];
  return ans % mod;
  
  function solve(x){
    if(c.has(x) && c.get(x) < z){
      dp0[x] += abmod(z-c.get(x),dp[x]);
      dp0[x] %= mod;
    }
    c.set(x,z);
    dp[x] += dp0[x];
    dp[x] %= mod;
  }
}
function f(a){
  var r=1;
  while(a)r<<=1,a>>=1;
  return r;
}

Measured memory_bytes: 130780
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
X = [list(map(int, input().split())) for _ in range(Q)]

ctr = Counter(A)
ans = sum(A)
for b, c in X:
    n = ctr[b]
    ans += -b * n + c * n
    ctr[b] = 0
    ctr[c] += n
    print(ans)


Measured memory_bytes: 107664
//let's do it
 #include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 1000000000000000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define boost1 ios::sync_with_stdio(false);
#define boost2 cin.tie(0);
#define mem(a,val) memset(a,val,sizeof a)
#define endl "\n"
#define maxn 200005

ll a[maxn];
int main()
{
	boost1;boost2;
	ll i,j,n,ans;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]+=a[i-1];
	}
	ans=inf;
	for(i=1;i<n;i++)
	ans=min(ans,abs(a[i]-(a[n]-a[i])));
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
	int n,i,sum,o;
	int map[246913];
	for(i=0;i<=246912;i++)
		map[i]=1;map[1]=0;map[0]=0;
	for(i=2;i*i<246912;i++){
		o=2;
		while(i*o <= 246912){
			map[i*o]=0;
			o++;
		}
	}
	while(1){
		sum=0;
		scanf("%d",&n);
		if(n == 0)
			break;
		for(i=n+1;i<=2*n;i++)
			sum+=map[i];
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 1564
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    in1(N);

    vi x(N), y(N), h(N);
    rep(i, N) in3(x[i], y[i], h[i]);

    int nonzero = 0;
    rep(i, N)
    {
        if (h[i] != 0)
        {
            nonzero = i;
            break;
        }
    }

    repse(cx, 0, 100)
    {
        repse(cy, 0, 100)
        {
            int H = h[nonzero] + abs(cx - x[nonzero]) + abs(cy - y[nonzero]);

            bool flg = true;
            rep(i, N)
            {
                int tmp = max(H - abs(cx - x[i]) - abs(cy - y[i]), 0);

                if (tmp != h[i])
                {
                    flg = false;
                    break;
                }
            }

            if (flg)
            {
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define le 100005
using namespace std;
int n[le][4];
int dp[le][4];
int len;
int fnc(int i, int j){
    if(i == len) return 0;
    if(dp[i][j] != 0) return dp[i][j];
    int ans = 0;
    if(j == 0) ans = max(fnc(i + 1, 1), fnc(i + 1, 2));
    else if(j == 1) ans = max(fnc(i + 1, 0), fnc(i + 1, 2));
    else ans = max(fnc(i + 1, 0), fnc(i + 1, 1));
    return dp[i][j] = n[i][j] + ans;
}
int main(){
    //freopen("input.txt", "r", stdin);
    scanf("%d", &len);
    for(int i = 0; i < len; i++){
        scanf("%d %d %d", &n[i][0], &n[i][1], &n[i][2]);
    }
    cout << max(fnc(0, 0), max(fnc(0, 1), fnc(0, 2))) << endl;
    return 0;
}


Measured memory_bytes: 11444
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int N;
ll D, A;
vector<ll> X, H;

ll solve()
{
    vector<int> ids(N);
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(), [&](int i, int j) {
        return X[i] < X[j];
    });
    ll res = 0;
    queue<pair<ll, ll>> que;
    ll num = 0;
    for (auto i : ids)
    {
        while (!que.empty() && que.front().first < X[i])
        {
            num -= que.front().second;
            que.pop();
        }
        H[i] -= num;
        if (H[i] <= 0)
            continue;
        res += H[i];
        que.push({X[i] + D * 2, H[i]});
        num += H[i];
    }
    return res;
}

int main()
{
    cin >> N >> D >> A;
    X.resize(N);
    H.resize(N);
    rep(i, 0, N)
    {
        cin >> X[i] >> H[i];
        H[i] = (H[i] + A - 1) / A;
    }
    cout << solve() << endl;
}


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

template <typename T>
T Pow(T a, ll b) {
	T res = 1;
	while (b) {
		if (b & 1) res *= a;
		a *= a;
		b >>= 1;
	}
	return res;
}

class mint {
	ll val;
public:
	static const ll mod = 1e9 + 7;
public:
	mint() : val(0) {}
	mint(ll v) : val(v % mod) {}
	operator int() { return (int)val; }
	operator ll() { return val; }
	mint operator+(mint v) { return val + v.val >= mod ? val + v.val - mod : val + v.val; }
	mint operator-(mint v) { return val < v.val ? val + mod - v.val : val - v.val; }
	mint operator*(mint v) { return val * v.val % mod; }
	mint operator/(mint v) { return val * v.inv().val % mod; }
	mint inv() { return Pow(*this, mod - 2); }
	mint& operator+=(mint v) { *this = *this - v; return *this; }
	mint& operator-=(mint v) { *this = *this - v; return *this; }
	mint& operator*=(mint v) { *this = *this * v; return *this; }
	mint& operator/=(mint v) { *this = *this / v; return *this; }
};
istream& operator >> (istream& is, mint m) { is >> (ll)m; return is; }
ostream& operator << (ostream& os, mint m) { os << (ll)m; return os; }

const int MAX = 1e5 + 1;

mint fac[MAX + 1];
mint rfac[MAX + 1];

void init() {
	fac[0] = 1;
	rfac[0] = 1;
	for (int i = 1; i <= MAX; i++) {
		fac[i] = fac[i - 1] * mint(i);
		rfac[i] = fac[i].inv();
	}
}

mint combi(int n, int k) {
	if (k < 0 || k > n) return 0;
	return fac[n] * rfac[k] * rfac[n - k];
}

int main()
{
	init();
	int n;
	cin >> n;
	vector<int> a(n + 1);
	vector<int> used(n, -1);
	int f, b;
	for (int i = 0; i < n + 1; i++) {
		cin >> a[i]; a[i]--;
		if (used[a[i]] != -1) {
			f = used[a[i]];
			b = i;
		}
		used[a[i]] = i;
	}
	for (int i = 1; i <= n + 1; i++) {
		cout << (combi(n + 1, i) - combi(n - b + f, i - 1)) << endl;
	}
	return 0;
}


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

using namespace std;

int CountDivisors(int min, int max, int numerator){
//    vector<int> denominators;
    int count = 0;
    for (int i = min; i <= max; i++){
        if (numerator % i == 0)
            count++;
    }
    return count;
}

int main(){
    // ---------------------------
    // ITP_1_3_A: Many Hello World
//    HelloWorldloop(1000);
    // ---------------------------

    // ---------------------------
    // ITP_1_3_B: Print Test Case
//    std::vector<int> data;
//    int in;
//    for (int i = 0; i >= 0; i++){
//        std::cin >> in;
//        data.push_back(in);
//        if (data[i] == 0) {
//            PrintTestCase(data);
//            break;
//        }
//    }
    // ---------------------------

    // ---------------------------
    // ITP_1_3_C: Swapping Two Data
//    std::vector<vector<int>> data;
//    int x, y;
//    for (int i = 0; i >= 0; i++){
//        std::cin >> x >> y;
//        data.push_back({x, y});
//        if (x == 0 && y == 0) {
//            SwapingTwoData(data);
//            break;
//        }
//    }
    // ---------------------------

    // ---------------------------
    // ITP_1_3_D: How Many Divisors?
    int a, b, c;
    std::cin >> a >> b >> c;
    std::cout << CountDivisors(a,b,c) << std::endl;
    // ---------------------------

    return 0;
}


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

int main(){
	int n;
	while(cin >> n and n){
		vector<int> v;
		for(int i = 0 ; i < n ; i++){
			string s;
			cin >> s;
			v.push_back(s.size());
		}
		for(int i = 0 ; i < n ; i++){
			int j = i;
			int s = 0;
			int f = 1;
			while( j < n and s < 5 ) s += v[j++];
			
			if( s != 5 ) f = 0;
			s = 0;
			while( j < n and s <7 ) s += v[j++];
			if( s != 7 ) f = 0;
			s = 0;
			while( j < n and s < 5 ) s += v[j++];
			if( s != 5 ) f = 0;
			s = 0;
			while( j < n and s < 7 ) s += v[j++];
			if( s != 7 ) f = 0;
			s = 0;
			
			while( j < n and s < 7) s += v[j++];
			if( s != 7 ) f = 0;
			
			if( f ){
				cout << i+1 << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 3132
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

long long binpow(long long x, long long y, long long m)
{
	long long res = 1;
	x %= m;
	while (y)
	{
		if (y & 1)
			res = mul(res, x, m);
		y = (y >> 1);
		x = mul(x, x, m);
	}
	return res;
}

void solve(int tc)
{
	ll n;
	cin >> n;
	ll ans = binpow(10, n, MOD);
	ll tmp = mul(2, binpow(9, n, MOD), MOD);
	tmp = add(tmp, MOD - binpow(8, n, MOD), MOD);
	ans = add(ans, MOD - tmp, MOD);
	cout << ans << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve(tc);
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 3688
class Bitset
    attr_reader :int

    def initialize(int=0)
        @int = int
    end

    def &(other); Bitset.new(@int & other.int); end
    def |(other); Bitset.new(@int | other.int); end
    def ^(other); Bitset.new(@int ^ other.int); end
    def <<(n); Bitset.new(@int << n); end
    def >>(n); Bitset.new(@int >> n); end
    
    def length; @int.bit_length; end
    def to_s; @int.to_s(2).reverse; end
    def to_i; @int; end

    def [](n); (@int >> n) & 1; end
    def []=(n, bit)
        if bit == 1
            @int |= 1 << n
        elsif bit == 0
            @int &= (1 << n) ^ -1
        else
            raise 'invalid argument of Bitset'
        end
        self
    end
end

N = gets.to_i
as = gets.split.map(&:to_i)
#N = 5000
#as = (1..5000).to_a

sum = as.inject(:+)

bs = Bitset.new(1)
as.each do |a|
    bs |= bs << a
end

i = (sum+1)/2
loop do
    if bs[i] == 1
        puts i
        exit
    end
    i += 1
end

Measured memory_bytes: 87984
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;



int main(void) {
	int a, b, k,cnt=0;
	vector<int> n;
	cin >> a >> b >> k;
	for (int i = min(a, b);i>0; i--) {
		if (a%i == 0 && b%i == 0) {
			n.push_back(i);
		}
	}
	REP(i, n.size()) {
		if (i == k-1) { cout << n[i] << endl; break; }
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int H,W;
    cin >> H >> W;
    
    vi dh = {-1,1,0,0};
    vi dw = {0,0,-1,1};
    
    int Ch,Cw,Dh,Dw;
    cin >> Ch >> Cw >> Dh >> Dw;
    Ch--,Cw--,Dh--,Dw--;
    
    ve<ve<char>> S(H,ve<char>(W));
    rep(i,H) rep(j,W) cin >> S[i][j];
    
    vvi B(H,vi(W,infi));
    B[Ch][Cw] = 0;
    
    deque<pii> A;
    
    A.push_front({Ch,Cw});
    
    while (!A.empty()) {
        pii p = A.front();
        A.pop_front();
        
        rep(i,4){
            int nh = p.fi + dh[i];
            int nw = p.se + dw[i];
            
            if(nh >= 0 && nh < H && nw >= 0 && nw < W){
                if(S[nh][nw] == '#') continue;
                
                if(B[nh][nw] > B[p.fi][p.se]){
                    B[nh][nw] = B[p.fi][p.se];
                    A.push_front({nh,nw});
                }
            }
        }
        
        reps(i,-2,3) reps(j,-2,3){
            if(i == 0 && j == 0) continue;
            
            int nh = p.fi + i;
            int nw = p.se + j;
            
            if(nh >= 0 && nh < H && nw >= 0 && nw < W){
                if(S[nh][nw] == '#') continue;
                
                if(B[nh][nw] > B[p.fi][p.se]+1){
                    B[nh][nw] = B[p.fi][p.se]+1;
                    A.push_back({nh,nw});
                }
            }
        }
        
        
    }
    
    if(B[Dh][Dw] == infi) cout << -1 << endl;
    else cout << B[Dh][Dw] << endl;

    return 0;
}


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

typedef long long LL;
const LL MOD = 1e9+7;

struct Matrix{
	LL a[50][50];
	
	Matrix operator * (Matrix &b){
		Matrix ret;
		memset(ret.a,0,sizeof(ret));
		for(int i=0;i<50;i++){
			for(int j=0;j<50;j++){
				for(int k=0;k<50;k++){
					ret.a[i][j] += a[i][k] * b.a[k][j];
					ret.a[i][j] %= MOD;
				}
			}
		}
		return ret;
	}
};

Matrix fe(Matrix &x, LL p){
	if(p==1) return x;
	Matrix ret = fe(x,p/2);
	ret = ret*ret;
	if(p&1) ret = ret*x;
	return ret;
}

int n;
LL k;

Matrix mult;

int main(){
	scanf("%d%lld",&n,&k);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			scanf("%lld",&mult.a[i][j]);
		}
	}
	mult = fe(mult,k);
	LL ans = 0LL;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			ans+=mult.a[i][j];
			ans%=MOD;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main()
{
      ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
      long double n, ans=1, flag1=0, flag2=0;
      cin >> n;
      while(n--)
      {
            long double temp;
            cin >>temp;
            ans*=temp;
            if (temp==0) flag2=1;
            if (ans>1000000000000000000)flag1=1;
      }
      if (flag2==1)cout << 0 << endl;
      else if (flag1==1)cout <<-1 << endl;
      else cout <<fixed <<setprecision(0) <<ans << endl;
      return 0;
}


Measured memory_bytes: 3812
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let v: Vec<usize> = s.trim().split(" ").map(|x| x.parse().unwrap()).collect();
    let mut u: Vec<Vec<char>> = vec![Vec::new(); v[0]];
    for i in 0..v[0] {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        u[i] = s.trim().chars().collect::<Vec<char>>();
    }
    for x in 0..v[0] {
        for y in 0..v[1] {
            if u[x][y] == '#' {print!("#");}
            else {print!("{}", cnt(x, y, v[0]-1, v[1]-1, &u));}
        }
        println!("");
    }
}

fn cnt(x: usize, y: usize, h: usize, w: usize, u: &Vec<Vec<char>>) -> usize {
    let mut a = 0;
    if x > 0 && y > 0 && u[x-1][y-1] == '#' {a += 1;}
    if x > 0 &&          u[x-1][y]   == '#' {a += 1;}
    if x > 0 && y < w && u[x-1][y+1] == '#' {a += 1;}
    if          y > 0 && u[x][y-1]   == '#' {a += 1;}
    if          y < w && u[x][y+1]   == '#' {a += 1;}
    if x < h && y > 0 && u[x+1][y-1] == '#' {a += 1;}
    if x < h &&          u[x+1][y]   == '#' {a += 1;}
    if x < h && y < w && u[x+1][y+1] == '#' {a += 1;}
    a
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<vector<int>> da(n, vector<int>(12, 1));
	for (int i = 0;i < n;i++) {
		string s;
		int p;
		cin >> s >> p;
		for (int j = 0;j < s.size();j++) {
			da[i][j] = 'a' - s[j];
		}
		da[i][10] = p;
		da[i][11] = i + 1;
	}
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n - i - 1;j++) {
			int k = 0;
			while (da[j][k] == da[j + 1][k])
				k++;
			if (da[j][k] < da[j + 1][k])
				swap(da[j], da[j + 1]);
		}
	}
	for (int i = 0;i < n;i++)
		cout << da[i][11] << endl;
}

Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-27 23:04:31
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; cin >> n;
  vector<int> a(n), b(n), c(n); cin >> a >> b >> c;

  sort(all(a));
  sort(all(b));
  sort(all(c));

  int64 ans = 0;

  for (int x : b) {
    ans += (int64) distance(a.begin(), lower_bound(all(a), x)) * (int64) (n - distance(c.begin(), upper_bound(all(c), x)));
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408
n=int(input())
l_x=[]
l_y=[]

for i in range(n):
	x,y=map(int,input().split())

	l_x.append(x+y)
	l_y.append(x-y)

tmpx=max(l_x)-min(l_x)
tmpy=max(l_y)-min(l_y)

if tmpx>tmpy:
	print(tmpx)
else:
	print(tmpy)


Measured memory_bytes: 24984
#include <iostream>

using namespace std;

int main ()
{
	long a,b,c;

	cin >> a >> b >> c;

	if (a + b < c)
	{
		cout << "NA" << endl;
	}
	else if (a >= c)
	{
		cout << '0' << endl;
	}
	else
	{
		cout << c - a << endl;
	}
}


Measured memory_bytes: 3120
#include<stdio.h>
int main()
{
    int n, a[100000], i;
    long long int h, sum=0;
    scanf("%lld%d", &h, &n);
    for(i=1; i<=n; i++)
    {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    if(sum >=h)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 1984
function Main(input) {
    var num = input.split("\n")[0];

    var formula = '';
    var ans = 0;

    for (var i = 0; i < 8; i++) {
        var tmp = '000' + i.toString(2);
        var bin = tmp.substring(tmp.length - 3);
        formula += num.charAt(0);
        ans += Number(num.charAt(0))
        for (var j = 1; j < 4; j++) {
            formula += bin.charAt(j - 1) === '0' ? '+' : '-'
            formula += num.charAt(j);
            ans += bin.charAt(j - 1) === '0' ? Number(num.charAt(j)) : -Number(num.charAt(j));
        }

        if (ans === 7) {
            formula += '=7';
            break;
        }
        formula = '';
        ans = 0;
    }
    console.log(formula)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require("fs").readFileSync("./input", "utf8"));

Measured memory_bytes: 7372
N,M = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(M)]

ans = [0 for _ in range(N)]

for m in range(M):
  ans[ab[m][0]-1] += 1
  ans[ab[m][1]-1] += 1

for a in ans:
  print(a)

Measured memory_bytes: 9188
/* Search III */
#include<stdio.h>
#include<string.h>

#define M 1000003
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+key%(M-1); }

int find(char str[]){
  int key,i,h_1,h_2;
  key=getKey(str);
  h_1=h1(key);
  if(strcmp(H[h_1],str)==0){
    return 1;  /*true*/
  }else{
    h_2=h2(key);
    for(i=h_1;;){
      if(strcmp(H[i],str)==0)return 1; /*true*/
      else if(H[i][0]=='\0')return 0; /*false*/
      else if((M-i)<=h_2){
	i=h_2-(M-i);
      }else{
	i+=h_2;
      }
    }
  }
}

int insert(char str[]){
  int key, h_1, h_2, h, i;
  key=getKey(str);
  h_1=h1(key);
  if(H[h_1][0]=='\0'){
    strcpy(H[h_1],str);
  }else{
    h_2=h2(key);
    for(i=0;;i++){
      h=(h_1+i*h_2)%M;
      if(H[h][0]=='\0')break;
      }
    strcpy(H[h],str);
  }
  return 0;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
  scanf("%d", &n);
    
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
    
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 13000
import sys
from io import StringIO
import unittest

def resolve():
    h, w = map(int, input().split())
    s = [list(input()) for _ in range(h)]

    ans = [[0]*w for i in range(h)]

    def put(s, i, j):
        if 0 <= i-1:
            s[i-1][j] += 1
        if 0 <= i-1 and 0 <= j-1:
            s[i-1][j-1] += 1
        if 0 <= j-1:
            s[i][j-1] += 1
        if i+1 < h:
            s[i+1][j] += 1
        if i+1 < h and j+1 < w:
            s[i+1][j+1] += 1
        if j+1 < w:
            s[i][j+1] += 1
        if 0 <= i-1 and j+1 < w:
            s[i-1][j+1] += 1
        if 0 <= j-1 and i+1 < h:
            s[i+1][j-1] += 1
        return s
    
    for i in range(h):
        for j in range(w):
            if s[i][j] == '#':
                ans = put(ans, i, j)
    for i in range(h):
        for j in range(w):
            if s[i][j] == '#':
                ans[i][j] = '#'
    
    ans_str = ''
    for i in range(h):
        for j in range(w):
            ans_str += str(ans[i][j])
        ans_str += '\n'
    ans_str = ans_str[:-1]
    print(ans_str)
    



class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 5
.....
.#.#.
....."""
        output = """11211
1#2#1
11211"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 5
#####
#####
#####"""
        output = """#####
#####
#####"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """6 6
#####.
#.#.##
####.#
.#..#.
#.##..
#.#..."""
        output = """#####3
#8#7##
####5#
4#65#2
#5##21
#4#310"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

using namespace std;
typedef long long ll;

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

int main(){
// ここに処理を記述
    int N, K, Q;
    cin >> N >> K >> Q;

    int player[N+1];
    REP(i,N+2){
        player[i] = 0;
    }

    int A;

    REP(i,Q){
        cin >> A;
        player[A]++;
    }

    FOR(i,1,N+1){
        if(player[i] > Q-K) cout << "Yes" << "\n";
        else cout << "No" << "\n";
    }

return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <vector>

using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int N, M;
    scanf("%d %d", &N, &M);

    UnionFind tree(N);

    for(int i = 0; i < M; i++) {
        int  x, y, z;
        scanf("%d %d %d", &x, &y, &z);
        tree.unite(x-1, y-1); // xの木とyの木を併合する
    }

    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(tree.par[i] == i){
            cnt++;
        }
    }

    printf("%d", cnt);
    return 0;
}

Measured memory_bytes: 640