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

int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
   
  vector<int> AC(N+1);
  AC.at(0) = 0;
  for( int i = 1; i < N; i++ ){
    if( S.at(i) == 'C' && S.at(i-1) == 'A' ){
      AC.at(i+1) = AC.at(i) + 1;
    }else{
      AC.at(i+1) = AC.at(i);
    }
  }
  
  int ans;
  for( int i = 0; i < Q; i++ ){
    int l, r;
    cin >> l >> r;
    if( l > 1 && S.at(l-1) == 'C' && S.at(l-2) == 'A' ){
      ans = AC.at(r) - AC.at(l-1) - 1;
    }else{
      ans = AC.at(r) - AC.at(l-1);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int a[] = new int[n];
		int d = 0;
		int temp = 0;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			d += Math.abs(temp - a[i]);
			temp = a[i];
		}
		d += Math.abs(temp);

		int ans = d;
		ans -= Math.abs(0 - a[0]);
		ans -= Math.abs(a[0] - a[1]);
		ans += Math.abs(a[1] - 0);
		System.out.println(ans);

		for (int i = 1; i < n - 1; i++) {
			ans = d;
			ans -= Math.abs(a[i - 1] - a[i]);
			ans -= Math.abs(a[i] - a[i + 1]);
			ans += Math.abs(a[i - 1] - a[i + 1]);
			System.out.println(ans);
		}

		ans = d;
		ans -= Math.abs(0 - a[n - 1]);
		ans -= Math.abs(a[n - 1] - a[n - 2]);
		ans += Math.abs(a[n - 2] - 0);
		System.out.println(ans);

	}

}


Measured memory_bytes: 65792
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int N;
  std::cin >> N;
  std::vector<std::string> S(N);
  std::vector<int> sum(N), min(N);
  for (int i: range(0, N)) {
    std::cin >> S[i];
    for (auto c: S[i]) {
      if (c == '(') {
        ++sum[i];
      }
      else {
        --sum[i];
        chmin(min[i], sum[i]);
      }
    }
  }
  if (std::accumulate(sum.begin(), sum.end(), 0) != 0) {
    std::cout << "No\n";
    return 0;
  }
  std::vector<std::pair<int, int>> up, down;
  for (int i: range(0, N)) {
    if (sum[i] > 0) {
      up.emplace_back(min[i], sum[i]);
    }
    else {
      down.emplace_back(min[i] - sum[i], -sum[i]);
    }
  }
  auto solve = [&](std::vector<std::pair<int, int>> vec) {
    std::sort(vec.rbegin(), vec.rend());
    int cur = 0;
    for (auto p: vec) {
      if (cur + p.first < 0) {
        return false;
      }
      cur += p.second;
    }
    return true;
  };
  if (solve(up) && solve(down)) {
    std::cout << "Yes\n";
  }
  else {
    std::cout << "No\n";
  }
  return 0;
}


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

int main() {
	string s,t;cin>>s>>t;
	int ans=0;
	for(int i=0;i<3;i++){
		if(s[i]==t[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
#define MOD (ll)(1e9 +7)
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	ll t,n,i,j,k,l,c,f;
	cin>>n;
	vc a(n+1,1);
	ll sum=1;
	for(i=2;i<=n;i++)
	{
	    for(j=i;j<=n;j+=i)
	        a[j]++;
	    sum+=i*a[i];
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 81236
from itertools import accumulate

n, k = map(int, input().split())
p = list(map(int, input().split()))

xs = [0] + list(accumulate(map(lambda v: (1 + v) * v // 2 / v, p)))
ans = 0
for i in range(n - k + 1):
    ans = max(ans, xs[i + k] - xs[i])
print(ans)


Measured memory_bytes: 101540
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

map <ll,ll> mp;
ll n,a[maxn],ans;

int main()
{
	n=read(); rep(i,1,n) a[i]=read();
	for(ll i=1;i<=n;i++)
	{
		ans+=mp[i-a[i]];
		mp[a[i]+i]++;
	}
	cout<<ans<<endl;
	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main()
{
    int32 a,b,t;
    cin >> a >> b >> t;
    ANS((t/a) * b);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n;
double x[114514], y[114514];
double difx[114514], dify[114514];
double f(double ti) {
	double maxx = -inf, maxy = -inf, minx = inf, miny = inf;
	rep(i, n) {
		chmax(maxx, x[i] + difx[i] * ti);
		chmax(maxy, y[i] + dify[i] * ti);
		chmin(minx, x[i] + difx[i] * ti);
		chmin(miny, y[i] + dify[i] * ti);
	}
	return (maxx - minx) * (maxy - miny);
}
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> x[i] >> y[i];
		char c; cin >> c;
		if (c == 'R')difx[i] = 1;
		else if (c == 'L')difx[i] = -1;
		else if (c == 'U')dify[i] = 1;
		else dify[i] = -1;
	}
	double mi = 0., ma = 100000000.;
	rep(_, 1000) {
		double l = mi + (ma - mi) / 3.;
		double r = ma - (ma - mi) / 3.;
		double vl = f(l), vr = f(r);
		if (vl < vr) {
			ma = r;
		}
		else {
			mi = l;
		}
	}
	printf("%.12lf\n", f(mi));
}


Measured memory_bytes: 3328
using System;

class keisan
{
  static void Main()
  {
    
    string str = Console.ReadLine();

    long kaisuu = 0;
    long Bkazu = 0;
    for (int i = 0; i < str.Length; i++)
    {
      //左にある
      if (str[i] == 'B')
      {
        Bkazu++;
      }
      else if (str[i] == 'W')
      {
        kaisuu += Bkazu;
      }
    }
  	System.Console.WriteLine(kaisuu);
  }
}

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

int getMax(int a, int b, int c)
{
    //cout << a << " " << b << " " << c << endl;
    if(a >= b && a >= c)
    {
        return a;
    }
    else if(b >= a && b >= c)
    {
        return b;
    }
    else
    {
        return c;
    }
}

int main()
{
    int nums[100002] = {};
    int n;
    int t;
    int max = 0;

    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        cin >> t;
        t += 1;
        nums[t-1] += 1;
        nums[t] += 1;
        nums[t+1] += 1;
        //cout << t-1 << ":" << t << ":"<< t+1 << endl;
        int tMax = getMax(nums[t-1], nums[t], nums[t+1]);
        max = max >= tMax ? max : tMax;
    }
    cout << max << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){while(1){int n,s;scanf("%d %d",&n,&s);if(n==0)return 0;int ans=0;int i,j;int sum;int time;for(i=0;i<1<<10;i++){sum=0;time=0;for(j=0;j<10;j++)if(i>>j&1){sum+=j;time++;}if(sum==s&&time==n)ans++;}printf("%d\n",ans);}}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    ll ans = 0;
    int r = 0;
    int x=0,y=0;
    for(int i=0;i<n;i++){
        while(r<n && ((x+a[r])==(y^a[r]))){
            x=x+a[r];
            y=y^a[r];
            r++;
        }
        assert(i<r);
        ans += r - i;
        x -= a[i];
        y ^= a[i];
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll a, b; cin >> a >> b;

    cout << a / __gcd(a, b) * b << endl;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            bool[,] cards = new bool[4,13];
            char[] color = {'S', 'H', 'C', 'D' };

            int n = int.Parse(Console.ReadLine());

            while(n-->0)
            {
                string[] str= Console.ReadLine().Split(' ');
                int num = int.Parse(str[1]);

                switch(str[0])
                {
                    case "S":
                        cards[0, num - 1] = true;
                        break;
                    case "H":
                        cards[1, num - 1] = true;
                        break;
                    case "C":
                        cards[2, num - 1] = true;
                        break;
                    default:
                        cards[3, num - 1] = true;
                        break;
                }
            }

            for (int i = 0; i < 4; i++)
            {
                for(int j=0;j<13;j++)
                {
                    if (!cards[i, j]) Console.WriteLine("{0} {1}",color[i],j+1);
                }
            }
        }
    }
}

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

int main()
{
	int len;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			for (int j = s.size() - 1; j > i; j--) {
				if (s[j] == 'Z') {
					len = j - i + 1;
					break;
				}
			}
			break;
		}
	}
	cout << len << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string S, T;
	cin >> S >> T;
	int ss, tt, uu, c, d;
	ss = S.size();
	tt = T.size();
	uu = ss - tt + 1;
	
	c = tt;
	d = tt;
	
	
	for(int i = 0; i < uu; i++){
		for(int j = 0; j < tt; j++){
			char &e = T.at(j);
			char &f = S.at(i + j);
			
			if(e == f)
				d--;
		}
		
		if(d < c)
			c = d;
		
		d = tt;
		
		if(c == 0)
			break;
	}
	
	
	
	cout << c << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
    #define f(i,j,k) for(int i=j;i<k;i++)
    #define f2(i,j,k) for(int i=j;i>k;i--)
    using namespace std;
    int main(){
        long long a[3][3],ans=0;
        f(i,0,3){
            f(j,0,3){
                cin>>a[i][j];
                ans+=a[i][j];
            }
        }
        if(ans%3!=0){
            cout<<"No"<<endl;
            return 0;
        }
        long long d[6];
        d[0]=a[0][0]+a[1][1]+a[2][2];
        d[1]=a[0][0]+a[1][2]+a[2][1];
        d[2]=a[0][1]+a[1][0]+a[2][2];
        d[3]=a[0][1]+a[1][2]+a[2][0];
        d[4]=a[0][2]+a[1][0]+a[2][1];
        d[5]=a[0][2]+a[1][1]+a[2][0];
        f(i,0,6){
            if(d[i]!=ans/3){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
        return 0;
    }

Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
#define mprint(x) printf(FORMATCONVERSION(x),(x))
#define FORMATCONVERSION(x) _Generic((x),\
                                    int:"%d",unsigned int:"%u",\
                                    double:"%lf",long long int:"%lld",\
                                    unsigned long long int:"%llu",\
                                    char :"%c",char*:"%s")

#define mswap(x,y) _Generic((x),int:swap_int,unsigned int:swap_uint,\
                            long long:swap_ll,unsigned long long:swap_ull)(&(x),&(y))

void swap_int(int *a,int *b){int tmp = *a;*a = *b;*b= tmp;return;}
void swap_uint(unsigned int *a,unsigned int *b){unsigned int tmp = *a;*a = *b;*b= tmp;return;}
void swap_ll(long long *a,long long *b){long long tmp = *a;*a = *b;*b= tmp;return;}
void swap_ull(unsigned long long *a,unsigned long long *b){unsigned long long tmp = *a;*a = *b;*b= tmp;return;}

int main(void){
    unsigned long long n,k;
    unsigned long long int ans = 0;
    scanf("%llu %llu",&n,&k);
    if(n * 2 < k){
        mprint(ans);
        return 0;
    }
    if(k % 2 != 0){
        //ki
        ans += ((n / k) * (n / k) * (n / k));
    }else{
        ans += ((n / k)*(n / k) * (n / k));
        unsigned long long int tmp = n - (k / 2);
        unsigned long long int hoge  = (tmp / k) + 1;
        ans +=  (hoge * hoge * hoge);
    }
    mprint(ans);
    return 0;
}

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

int main()
{
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a<=k)
  {
    cout << "Yay!" << endl;
  }
  else
  {
    cout << ":(" << endl;
  }
}


Measured memory_bytes: 256
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 10;

int ans = INF;
int n, a, b, c;
int l[N];

void test_case();
void solve(int ind, int sa, int sb, int sc, int ta, int tb, int tc);

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void test_case() {
	cin >> n >> a >> b >> c;
	for (int i = 1; i <= n; ++i) {
		cin >> l[i];
	}
	solve(1, 0, 0, 0, 0, 0, 0);
	cout << ans << "\n";
}

void solve(int ind, int sa, int sb, int sc, int ta, int tb, int tc) {
	if (ind == n + 1) {
		if (ta > 0 && tb > 0 && tc > 0) {
			ans = min(ans, abs(sa - a) + (ta - 1) * 10 + abs(sb - b) + (tb - 1) * 10 + abs(sc - c) + (tc - 1) * 10);
		}
	} else  {
		solve(ind + 1, sa, sb, sc, ta, tb, tc);
		solve(ind + 1, sa + l[ind], sb, sc, ta + 1, tb, tc);
		solve(ind + 1, sa, sb + l[ind], sc, ta, tb + 1, tc);
		solve(ind + 1, sa, sb, sc + l[ind], ta, tb, tc + 1);
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN 200005
#define MAXVAL 1000005
int a[MAXN];
int f[MAXVAL];  //1:0->1×ÔÉí³öÏÖ1´Î£¬1->2»ò0->2 ±»±ðµÄÊýÕû³ý 
int n, ans;
int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    sort(a+1, a+n+1);
    if(a[1] == 1){
    	if(a[2] == 1)
    		printf("%d\n", 0);
        else
			printf("%d\n", 1);
        return 0;
    }
    for(int i = 1; i <= n; i++){
        int j = a[i];
        if(f[j] == 0)
            f[j] = 1;
        else if(f[j] == 1)
            f[j] = 2;
        for(int k = 2*j; k < MAXVAL; k+= j)
            f[k] = 2; 
    }
    for(int i = 1; i <= n; i++)
        if(f[a[i]] == 1)
            ans++;
    printf("%d\n", ans);
}

Measured memory_bytes: 8252
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {
    ll n;
    cin>>n;
    if(n%2!=0){
        cout<<0<<endl;
    }
    else{
        n/=2;
        ll ans=0;
        while(true){
          if(n==0)break;
          n/=5;
          ans+=n;
      }
      cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  string s;
  cin >> s;
  int i;
  sort(s.begin(),s.end());
  if(s[0]!='a'){
    cout << "a" << "\n";
    return 0;
  }
  for(i=0;i<s.size();i++){
    char c = s[i];
    char d = s[i+1];
    char e = s[i+1]-1;
    char f = s[i]+1;
    if(c==d || c==e) continue;
    else if(i==s.size()-1){
      if(s[i]=='z') break;
      else{
        cout << f << "\n";
        return 0;
      }
    }
    else{
      cout << f << "\n";
      return 0;
    }
  }
  cout << "None" << "\n";
  return 0;
}

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

template<class T>
struct BIT{
	vector<T> dat;

	BIT(int sz) : dat(sz,0){}

	void add(int i,T x){
		for(;i < dat.size();i += i & -i) dat[i] += x;
	}
	
	T sum(T i){
		T ret = 0;
		for(;i;i -= i & -i) ret += dat[i];
		return ret;
	}
};
 
signed main(){
    int n,q;
    cin >> n >> q;
    BIT<int> bit(n + 10);
    for(int i = 0;i < q;i++){
        int t,x,y;
        cin >> t >> x >> y;
        if(!t) bit.add(x,y);
        else cout << bit.sum(y) - bit.sum(x - 1) << endl;
    }
}


Measured memory_bytes: 3116
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[3];
		for (int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int ans = 0;
		ans += a[2] - a[1];
		a[0] += a[2] - a[1];
		ans += (a[2] - a[0]) / 2;
		ans += ((a[2] - a[0]) % 2) * 2;
		System.out.println(ans);
	}
}

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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
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 REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
ll max_val = 3234566667LL;
vector<ll> vals;
void dfs(ll val,int digit){
  if(val > max_val){
    return;
  }else{
    vals.push_back(val);
    for(int i=-1;i<=1;i++){
      if(digit+i>=0 && digit+i<=9){
        dfs(val*10+(digit+i),digit+i);
      }
    }
  }
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int k;
  cin >> k;
  FOR(i,1,10){
    dfs(i,i);
  }
  sort(ALL(vals));
  cout << vals[k-1] << endl;
  return 0;
}




Measured memory_bytes: 4240
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    h,w=map(int,input().split())
    C=[list(map(int,input().split())) for _ in range(10)]

    # Warshall-Floyd
    from itertools import product
    for k,i,j in product(range(10),repeat=3):
        C[i][j]=min(C[i][j],C[i][k]+C[k][j])

    # input
    A=[list(map(int,input().split())) for _ in range(h)]

    ans=0
    for i,j in product(range(h),range(w)):
        a=A[i][j]
        if(a==-1): continue
        ans+=C[a][1]
    print(ans)
resolve()

Measured memory_bytes: 40284
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long int li;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

ll gcd(ll a ,ll b){
    if(a==0){return b;}
    else if(b==0){return a;}
    else{
    ll tmp,r;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
    }
}

int main() {
    ll n,k;
    ll ans=0;
    cin >> n >> k;
    ans=n-k+1;
    cout << ans << endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/* output : ??\??? n ????????????1~n?????§????????¶??°????????§ n ??¨??????????´??????????????????° */

vector<ll> PrimeFact(ll n){
    vector<ll> res;
    while(n!=1){
        if(n == 2 || n == 3){
            res.emplace_back(n); n/=n;
            continue;
        }
        bool prime_flag = false;
        for(int i = 2;i*i <= n;i++){
            if(n%i==0){
                res.emplace_back(i); n/=i;
                prime_flag = true;
                break;
            }
        }
        if(!prime_flag){res.emplace_back(n); n/= n;}
    }
    return res;
}

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n; cin >> n;
    auto primes = PrimeFact(n);
    primes.erase(unique(primes.begin(),primes.end()),primes.end());
    ll res = n;
    for(auto p:primes){
        res = res - res/p;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3140
n = input()
def dfs(s):
    if int(s) > int(n):
        return 0
    ret = 1 if all(c in s for c in ['7', '5', '3']) else 0
    for c in ['7', '5', '3']:
        ret += dfs(s + c)
    return ret
print(dfs('0'))


Measured memory_bytes: 2940
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    ll x;
    cin >> x;
    if(x == 1){
        print(0);
    }else{
        print(1);
    }

}

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

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
string s;
vi f(){
	s+=".";
	vi a;
	int t=0;
	rep(i,s.size())if(s[i]=='.'){
		a.pb(atoi(&s.substr(t,i)[0]));
		t=i+1;
	}
	return a;
}
int uruu(int a){
	return a%400==0||(a%4==0&&a%100!=0);
}
int main(){
	int d[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	while(cin>>s,s!="#"){
		vi in=f();
		if(in.size()==3){
			int a=2012,b=12,c=21,t=0;
			while(a!=in[0]||b!=in[1]||c!=in[2]){
				t%=13*20*20*18*20;
				if(a!=in[0]&&b==1&&c==1){
					t+=365+uruu(a);
					a++;
				}else if((a!=in[0]||b!=in[1])&&c==1){
					t+=d[b]+(b==2?uruu(a):0);
					b++;
					if(b==13)b=1;
				}else{
					t++;
					c++;
					if(d[b]+1+(b==2?uruu(a):0)==c){
						b++;c=1;
					}
					if(b==13){
						b=1;
						a++;
					}
				}
			}
			t%=13*20*20*18*20;
			cout<<t/(20*20*18*20)<<".";
			t%=20*20*18*20;
			cout<<t/(20*18*20)<<".";
			t%=20*18*20;
			cout<<t/(18*20)<<".";
			t%=18*20;
			cout<<t/20<<"."<<t%20<<endl;
		}else{
			int t=in[0]*20*20*18*20+
					in[1]*20*18*20+
					in[2]*18*20+
					in[3]*20+in[4];
			int a=2012,b=12,c=21;
			while(t){
				if(t>365&&b==1&&c==1){
					t-=365+uruu(a);
					a++;
				}else if(t>d[b]+uruu(a)&&c==1){
					t-=d[b]+(b==2?uruu(a):0);
					b++;
					if(b==13)b=1;
				}else{
					t--;
					c++;
					if(d[b]+1+(b==2?uruu(a):0)==c){
						b++;c=1;
					}
					if(b==13){
						b=1;a++;
					}
				}
			}
			cout<<a<<"."<<b<<"."<<c<<endl;
		}
	}
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
  char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
  vector<char*> v({token});
  while(token = strtok(NULL,", ")) v.push_back(token);
  return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
  debug() << " [" << args.back() << ": " << H << "] ";
  args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;


const int maxn=1000001;
int isprime[maxn];
int main() {
    IOS;
    int n,i;
    REP(i,1,maxn-1) isprime[i]=i;
    for(i=2;i*i<maxn;i++)
        if(isprime[i])
            for(int j=i*i;j<maxn;j+=i)
                isprime[j]=min(i,isprime[j]);
            

    cin>>n;
    ll ans=0,num;
    REP(i,1,n-1){
    	num=i;
    	map<int,int> mp;
    	while(num>1){
    		mp[isprime[num]]++;
    		num/=isprime[num];
    	}
    	num=1;
    	for(auto u:mp) num*=(u.S+1);
    	ans+=num;
    	// dbg(i,num,ans);
    }
    cout<<ans;
    return 0;   
} 

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

int main(){
	long long int q,h,s,d,n;
	cin>>q>>h>>s>>d>>n;
	
	long long int a,b,c,e;
	a=4*q*n;
	b=2*h*n;
	c=s*n;
	e=d*(n/2);
	
	
	
	if(n%2==0){
		cout<<min(a,min(b,min(c,e)))<<endl;
	}else{
		e+=min(4*q,min(2*h,s));
		//cout<<a<<" "<<b<<" "<<c<<" "<<e<<endl;
		cout<<min(a,min(b,min(c,e)))<<endl;
	}
	
	
	return 0;
}

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

const int N = 22;
const int mod = 1e9 + 7;

int n, a[N][N];
int f[N][1 << N];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) scanf("%d", &a[i][j]);
	}
	f[0][0] = 1;
	for(int S = 1; S < (1 << n); ++S) {
		int i = 0;
		for(int j = 0; j < n; ++j) if((S >> j) & 1) ++i;
		for(int j = 0; j < n; ++j) {
			if(((S >> j) & 1) && a[i][j + 1]) (f[i][S] += f[i - 1][S ^ (1 << j)]) %= mod;
		}
	}
	printf("%d\n", f[n][(1 << n) - 1]);
}

Measured memory_bytes: 178432
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  char buff[3][4];

  while(cin >> buff[0], buff[0][0] != '0'){
    cin >> buff[1];
    cin >> buff[2];

    char ans = 0;

    REP(i,3){
      if(buff[i][0] != '+' && 
	 buff[i][0] == buff[i][1] &&
	 buff[i][0] == buff[i][2])
	ans = buff[i][0];
      if(buff[0][i] != '+' && 
	 buff[0][i] == buff[1][i] &&
	 buff[0][i] == buff[2][i])
	ans = buff[0][i];
      if(buff[0][0] != '+' && 
	 buff[0][0] == buff[1][1] &&
	 buff[0][0] == buff[2][2])
	ans = buff[0][0];
      if(buff[2][0] != '+' && 
	 buff[2][0] == buff[1][1] &&
	 buff[2][0] == buff[0][2])
	ans = buff[2][0];
    }

    if(ans != 0) cout << ans << endl;
    else cout << "NA" << endl;
  }
  return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N; //N円の商品
  int num = 0;
  int i = 1;
  
  while(true){
    if ( N > i * 1000)
      i++;
    else
      break;
  }
  
  cout << i*1000 - N << endl;
  
}

Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<vector>
#include<set>

using namespace std;

const int MAXN = 100005;

int n, m, cnt;
long long sol;
int l[MAXN], bio[MAXN], mn[MAXN];
vector <int> v[MAXN];
multiset <int> s;

void dfs (int x, int boja) {
	if (bio[x]) return;
	bio[x]=boja;
	if (mn[boja]==0 || l[x]<l[mn[boja]]) mn[boja]=x;
	for (int i=0; i<v[x].size(); i++) {
		dfs(v[x] [i], boja);
	}
}

int main () {
	cin >> n >> m;
	for (int i=1; i<=n; i++) {
		scanf("%d", &l[i]);
	}
	for (int i=0; i<m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		a++; b++;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for (int i=1; i<=n; i++) {
		if (!bio[i]) {
			cnt++;
			dfs(i, cnt);
		}
	}
	if (cnt==1) {
		cout << 0;
		return 0;
	}
	for (int i=1; i<=n; i++) {
		int boja=bio[i];
		if (i==mn[boja]) sol+=l[i]; else s.insert(l[i]);
	}
	if (s.size()<cnt-2) {
		cout << "Impossible";
		return 0;
	}
	int br=0;
	for (set <int> :: iterator it=s.begin(); it!=s.end(); it++) {
		if (br==cnt-2) break;
		sol+=*it;
		br++;
	}
	cout << sol;
	return 0;
}




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

using namespace std;

const int MAX_N = 3456;

long long N, M;
long long C[MAX_N][MAX_N], P2[MAX_N], P2P2[MAX_N], way[MAX_N][MAX_N];

long long add(long long a, long long b) { return (a + b) % M; }
long long mul(long long a, long long b) { return (a * b) % M; }

int main() {
  cin >> N >> M;
  
  for (int i = 0; i <= N; ++i) {
    C[i][0] = C[i][i] = 1; 
    for (int j = 1; j < i; ++j) {
      C[i][j] = add(C[i - 1][j], C[i - 1][j - 1]);
    }
  }

  for (int i = 0; i <= N * N; ++i) {
    P2[i] = (i == 0 ? 1 : mul(P2[i - 1], 2));
  }

  for (int i = 0; i <= N; ++i) {
    P2P2[i] = (i == 0 ? 2 : mul(P2P2[i - 1], P2P2[i - 1]));
  }

  // divide i to j groups, i-th can appear or not-appear
  memset(way, 0x00, sizeof(way));
  for (int i = 0; i <= N; ++i) {
    way[i][0] = 1;
    for (int j = 1; j <= i; ++j) {
      way[i][j] = 0;
      // i-th not-appear
      way[i][j] = add(way[i][j], way[i - 1][j]);
      // i-th appear, self group
      way[i][j] = add(way[i][j], way[i - 1][j - 1]);
      // i-th appear, with-other group
      way[i][j] = add(way[i][j], mul(j, way[i - 1][j]));
    }
  }

  long long res = 0;
  for (int i = 0; i <= N; ++i) {

    long long tmp = 0;
    for (int j = 0; j <= i; ++j) {
      // each j group could have 2^(N-i) types
      tmp = add(tmp, mul(way[i][j], P2[(N - i) * j]));
    }
    tmp = mul(tmp, mul(C[N][i], P2P2[N - i]));

    if (i & 1) res = add(res, M - tmp);
    else res = add(res, tmp);

  }

  cout << res << endl;

  return 0;
}

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

ll helper(ll* weights, ll* values,int start, int end, int maxWeight , ll **ans){
 if(start>end || maxWeight == 0){
   return 0;
 }
  
  if(ans[start][maxWeight]!=-1)
    return ans[start][maxWeight];
  
  ll x = INT_MIN;
  if(maxWeight >= weights[start]){
    x = values[start] + helper(weights , values , start+1 , end , maxWeight-weights[start] , ans);
  }
  
  ll y = helper(weights , values , start+1 , end , maxWeight , ans);
  
  ans[start][maxWeight] = max(x , y);
  return ans[start][maxWeight];
  
  
}

ll knapsack(ll* weights, ll* values, int n, int maxWeight){

  ll **ans  = new ll*[n];
  for(int i=0;i<n;i++){
    ans[i] = new ll[maxWeight+1];
    for(int j=0;j<maxWeight+1;j++)
      ans[i][j] = -1;
  }
  return helper(weights , values ,0 ,  n-1 , maxWeight , ans);
}

int main(){
	int n,W;
	cin>>n>>W;
	
	ll w[n],v[n];
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	cout<<knapsack(w,v,n,W);
}

Measured memory_bytes: 78592
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

template <typename T>
struct RollingHash
{
	int size;
	int n;
	ll factor = 1;
	ll b = 0;
	ll mod = 0;
	ll hash = 0;
	vector<T> list;
	int num = 0;
	int head = 0;

	void init(int _n, ll _b = (ll)1e8 + 7, ll _mod = (ll)1e9 + 7)
	{
		n = _n;
		b = _b;
		list.reserve(n);
		mod = _mod;
		auto temp = 1ll;
		for (auto i = 0; i < n; ++i)
		{
			factor = temp;
			temp = temp * b % mod;
		}
	}

	void add(ll val)
	{
		if ((int)list.size() >= n)
		{
			hash = (((hash - list[head] * factor) % mod) + mod) % mod;
			list[head] = val;
			head = (head + 1) % n;
		}
		else
		{
			list.push_back(val);
		}
		hash = hash * b % mod;
		hash = (hash + val) % mod;
	}

	ll getHash() { return hash; }
};

int main()
{
	int N;
	cin >> N;
	vector<ll> a(N);
	vector<ll> b(N);
	for (auto i = 0; i < N; ++i)
	{
		ll temp;
		cin >> temp;
		a[i] = temp;
		a.push_back(temp);
	}
	for (auto& temp : b)
	{
		cin >> temp;
	}

	vector<ll> x;
	for (auto i = 0; i < N; ++i)
	{
		x.push_back(b[0] ^ a[i]);
	}

	auto bitNum = 31;
	auto mod = (ll)1e9 + 7;
	vector<ll> rollingHashFactor = { (ll)1e8 + 7 };
	vector<vector<vector<RollingHash<ll>>>> hashA
		(bitNum, vector<vector<RollingHash<ll>>>(2, vector<RollingHash<ll>>((int)rollingHashFactor.size())));
	vector<vector<RollingHash<ll>>> hashB
		(bitNum, vector<RollingHash<ll>>((int)rollingHashFactor.size()));

	for (auto i = 0; i < bitNum; ++i)
	{
		for (auto k = 0; k < N; ++k)
		{
			auto val = (b[k] >> i) & 1;
			for (auto l = 0; l < (int)rollingHashFactor.size(); ++l)
			{
				if (k == 0)
				{
					hashB[i][l].init(N, rollingHashFactor[l], mod);
				}
				hashB[i][l].add(val);
			}
		}
	}

	for (auto i = 0; i < bitNum; ++i)
	{
		for (auto j = 0; j < 2; ++j)
		{
			for (auto k = 0; k < N; ++k)
			{
				auto val = ((a[k] >> i) ^ j) & 1;
				for (auto l = 0; l < (int)rollingHashFactor.size(); ++l)
				{
					if (k == 0)
					{
						hashA[i][j][l].init(N, rollingHashFactor[l]);
					}
					hashA[i][j][l].add(val);
				}
			}
		}
	}

	vector<pair<int, ll>> ans;
	for (auto k = 0; k < N; ++k)
	{
		auto match = true;
		for (auto i = 0; i < bitNum; ++i)
		{
			int j = (x[k] >> i) & 1;
			for (auto l = 0; l < (int)rollingHashFactor.size(); ++l)
			{
				if (hashB[i][l].getHash() != hashA[i][j][l].getHash())
				{
					match = false;
					break;
				}
			}

			if (match == false)
			{
				break;
			}
		}

		if (match != false)
		{
			ans.push_back({ k, x[k] });
		}

		for (auto i = 0; i < bitNum; ++i)
		{
			for (auto j = 0; j < 2; ++j)
			{
				auto val = ((a[k + N] >> i) ^ j) & 1;
				for (auto l = 0; l < (int)rollingHashFactor.size(); ++l)
				{
					hashA[i][j][l].add(val);
				}
			}
		}
	}

	for (auto& pair : ans)
	{
		cout << pair.first << " " << pair.second << endl;
	}

	return 0;
}

Measured memory_bytes: 160804
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define int ll

int c[4] = {1,9,7,4};
bool b[4];

signed main(){
  rep(i,4){
    int a;
    cin>>a;
    rep(j,4){
      if(a==c[j])
        b[j]=true;
    }
  }

  rep(i,4){
    if(!b[i]){
      cout<<"NO"<<endl;
      return 0;
    }
  }

  cout<<"YES"<<endl;
}

Measured memory_bytes: 256
void main() {
	auto N = ri;
	real res = 0;
	foreach(_; 0..N) {
		auto arr = rs.chomp.split;
		auto x = arr[0].to!real;
		if(arr[1] == "BTC") res += x * 380000;
		else res += x;
	}
	writefln("%.9f", res);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n=0, m, f, r;
	while (cin >> m >> f >> r)
	{
		n++;
		if ((m == -1 && f == -1 && r == -1) || (n >= 50))break;
		int z = m + f;

		if (z >= 80&&m!=-1&&f!=-1)cout << "A" << endl;
		else if (z < 80 && z >= 65 && m != -1 && f != -1)cout << "B" << endl;
		else if (m == -1 || f == -1)cout << "F" << endl;
		else if ((z < 65 && z >= 50 && m != -1 && f != -1)||(z<50&&z>=30 && m != -1 && f != -1&&r>=50)) cout << "C" << endl;
		else if ((z < 50 && z >= 30 && m != -1 && f != -1) && r < 50)cout << "D" << endl;
		else if (z < 30 && m != -1 && f != -1)cout << "F" << endl;
	}
	return 0;
}


Measured memory_bytes: 3124
#include <cstdio>
#include <queue>
#include <iostream>
#include <cmath>
using namespace std;
#define ll long long
const int inf = -1e9 + 5;

int main()
{
    int q;
    ll ans = 0;
    priority_queue<int> left;
    priority_queue<int, vector<int>, greater<int>> right;
    int mid = inf;
    scanf("%d", &q);
    while (q--)
    {
        int op;
        scanf("%d", &op);
        if (op == 1)
        {
            int x, y;
            scanf("%d%d", &x, &y);
            ans += y;
            if (mid == inf)
            {
                if (left.empty())
                    mid = x;
                else
                {
                    if (x >= left.top())
                    {
                        if (x < right.top())
                            mid = x;
                        else
                        {
                            right.push(x);
                            mid = right.top(), right.pop();
                            ans += x - mid;
                        }
                    }
                    else
                    {
                        left.push(x);
                        mid = left.top(), left.pop();
                        ans += mid - x;
                    }
                }
            }
            else
            {
                if (left.empty())
                {
                    left.push(min(mid, x)), right.push(max(mid, x));
                    ans += abs(mid - x), mid = inf;
                }
                else
                {
                    if (x >= mid)
                    {
                        right.push(x), left.push(mid);
                        ans += x - mid, mid = inf;
                    }
                    else
                    {
                        left.push(x), right.push(mid);
                        ans += mid - x, mid = inf;
                    }
                }
            }
        }
        else
        {
            int ansn = mid;
            if (ansn == inf)
                ansn = left.top();
            cout << ansn << " " << ans << "\n";
        }
    }
}

Measured memory_bytes: 3452
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;



public class Main {

	public static void main(String[] args) {
		 FastScanner scanner =new FastScanner();
		
			int n=scanner.nextInt();
			long d=scanner.nextLong();
		int c=0;
		for(int i=0;i<n;i++) {
			long x=scanner.nextLong(),y=scanner.nextLong();
			if(d*d>=(x*x+y*y))c++;
		}
		System.out.println(c);
		    	
		    }
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
}

		    
		}

Measured memory_bytes: 55480
#include<bits/stdc++.h>
     
    using namespace std;
    bool q[10];
    int main()
    {
        bool chk=true;
        string s;
        int len, i, mn=100, j, k, n, x;
        cin >> s >> k;
        for(i=0;i<k;i++)
        {
            len=scanf("%d",&n);
            q[n]=true;
        }
        len=s.size();
        for(i=1;i<=9;i++) if(!q[i]) mn=min(mn,i);
        for(i=0;i<len;i++)
        {
          //  cout<<s[i]-'0'<<endl;
            if(q[s[i]-'0'])
            {
                for(j=s[i]-'0';j<=9;j++)
                {
                    if(!q[j])
                    {
                        for(x=0;x<i;x++) printf("%c",s[x]);
                        printf("%d",j);
                        for(++i;i<len;i++) !q[0] ? printf("0") : printf("%d",mn);
                        printf("\n");
                        exit(0);
                    }
                }
                printf("%d",mn);
                for(i=0;i<len;i++) !q[0] ? printf("0") : printf("%d",mn);
                printf("\n");
                exit(0);
            }
        }
        cout<<s<<endl;
    }

Measured memory_bytes: 256