akhauriyash/Code-Regression huggingface dataset:
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    int N,M;cin >> N >> M;
    map<int,int> retu;
    for(int i = 0;i<M;i++){
        int a,b;cin >> a >> b;
        retu[a]++;
        retu[b]++;
    }
    for(auto A : retu){
        int B = A.second;
        if(B % 2 == 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200005 ;
int main()
{
   fast ;
   ll tests=1 ;
   ///cin>>tests ;
   for(ll testcase=1;testcase<=tests;testcase++)
   {
      ///cout<<"Case #"<<testcase<<": " ;
      ///Read,Think ans Test Properly,then code
      ///Try to avoid using print statements debug on your own
      ll x,y,a,b,c ;
      cin>>x>>y>>a>>b>>c ;
      vector<ll>v1,v2,v3 ;
      ll ans=0 ;
      multiset<ll>st ;
      for(ll i=0;i<a;i++)
      {
          ll o ;
          cin>>o ;
          v1.pb(o) ;
      }
      for(ll i=0;i<b;i++)
      {
          ll o ;
          cin>>o ;
          v2.pb(o) ;
      }
      for(ll i=0;i<c;i++)
      {
          ll o ;
          cin>>o ;
          v3.pb(o) ;
      }
      sort(all(v1)) ;
      sort(all(v2)) ;
      sort(all(v3)) ;
      reverse(all(v1)) ;
      reverse(all(v2)) ;
      reverse(all(v3)) ;

      for(ll i=0;i<x;i++)
      {
          ans+=v1[i] ;
          st.insert(v1[i]) ;
      }
      for(ll i=0;i<y;i++)
      {
          ans+=v2[i] ;
          st.insert(v2[i]) ;
      }
      for(ll i=0;i<c;i++)
      {
          auto it=st.begin() ;
          ll ops=*it ;
          if(ops<v3[i])
          {
              st.erase(it) ;
              ans-=ops ;
              ans+=v3[i] ;
              st.insert(v3[i]) ;
          }
      }
      cout<<ans ;


    }
}
/// ans ->for answer
/// cur ->for local answer
/// level ->for depth in tree
/// v -> adjacency matrix
/// r -> array
/// s ->string



Measured memory_bytes: 10996
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<algorithm>
using namespace std;
int n[200005];
int main()
{
    
    int a,b,c,i,o,ans,l;
    while(~scanf("%d%d",&a,&b))
    {
        ans=0;
        for(i=0;i<b;i++)
        {
            scanf("%d",&n[i]);
        }
        o=n[b-1]-n[0];
        for(i=0;i<b-1;i++)
        {
            l=n[i+1]-n[i];
            ans=max(ans,l);
        }
        ans=a-ans;
        ans=min(ans,o);
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

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

    vector<Int> A(N);
    rep(i,N){
        cin >> A[i]; A[i]--;
    }

    vector<Int> first_visited(N, -1);

    Int now = 0, cnt = 0;
    while(first_visited[now] == -1){
        first_visited[now] = cnt;
        now = A[now];
        cnt++;
    }

    Int times, ans;
    if(K <= first_visited[now]){
        times = K;
        ans = 0;
    } else {
        times = (K - first_visited[now]) % (cnt - first_visited[now]);
        ans = now;
    }

    rep(i,times) ans = A[ans];
    cout << ans+1 << endl;
}


Measured memory_bytes: 6428
#include<bits/stdc++.h>
using namespace std;
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
#define int long long int 
#define F first
#define S second
#define boost ios_base::sync_with_stdio(false),cin.tie(NULL);
const int MOD = 998244353;
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp>  
//using namespace __gnu_pbds; 
//stringstream ss; string temp; ss<<str(original string) ss>>temp;


int32_t main()
{	
	
  	
  	int n,a,b; cin>>n>>a>>b;
  	cout<<min(n*a,b)<<endl;
	return 0;
} 


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;

    cout << (a1 + a2 + a3 >= 22 ? "bust" : "win") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
bool cmp(pint a, pint b) {return a.second < b.second;}
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 = 1LL<<60;

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

    vi a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    vector<vector<ll>> dp(n + 1, vector<ll>(h + 1, INF));
    dp[0][0] = 0;

    rep(i, n) {
        rep(j, h + 1) {
            chmin(dp[i + 1][j], dp[i][j]);
            chmin(dp[i + 1][min(j + a[i], h)], dp[i + 1][j] + b[i]);
        }
    }

    cout << dp[n][h] << endl;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll n;
  cin>>n;

  auto divisor = [](ll x){
    vector<ll> res;
    for(ll p=1;p*p<=x;++p){
      if(x%p==0){
        res.emplace_back(p);
        if(p*p!=x)res.emplace_back(x/p);
      }
    }
    sort(begin(res),end(res));
    return res;
  };
  auto check = [](ll n,ll k){
    if(k==1)return false;
    while(n>=k){
      if(n%k==0)n/=k;
      else n%=k;
      dump(n,k);
    }
    return n==1;
  };

  ll ans = 0;
  for(auto k:divisor(n))if(check(n,k))ans++;
  for(auto k:divisor(n-1))if(check(n,k))ans++;
  cout<<(ans)<<endl;

}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
     long long int x;
    scanf("%lld",&x);
     int i;
     long long int m=100;
     long long int j;
    for(i=0;m<x;i++){
    j=0;
    j=m*0.01;
    m=m+j;
    }
    printf("%d\n",i);
    return 0;
}

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

#define endl "\n"

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	int n;	cin>>n;
	vector< pair<int,int> > V(n+1);
	V[0]={0,1};

	for(int i=1;i<=n;i++){
		cin>>V[i].first>>V[i].second;
		V[i].second=10-V[i].second;
	}
	// T1 < T2 < T3 < ...
	//for(int i=1;i<=n;i++){
	//	V[i].second*=V[i-1].second;
	//	//大きくなるだろ
	//}


	int q;	cin>>q;
	for(int i=0;i<q;i++){
		int l,r;	cin>>l>>r;
		int lPos,rPos,NG;

		rPos=0,NG=n+1;
		while(NG-rPos>1){
			int mid=(rPos+NG)/2;
			if(r<=V[mid].first)NG=mid;
			else rPos=mid;
		}
		//rPos: R以前で起きた最後の地震
		//cout<<rPos<<endl;

		lPos=0;	NG=n+1;
		while(NG-lPos>1){
			int mid=(lPos+NG)/2;
			if(V[mid].first<=l)lPos=mid;
			else NG=mid;
		}
		//cout<<lPos<<endl;
		//lPos: L以前に起きた最後の地震
		double ans=1000000000.0;
		for(int j=lPos+1;j<=rPos;j++){
			ans*=V[j].second/10.0;
		}

		//printf("%.8lf\n",ans);
		cout<<ans<<endl;

	}


	return 0;
}


Measured memory_bytes: 3640
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,X,T = I()
print(((N-1)//X+1)*T)

Measured memory_bytes: 10076
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, t;
	cin >> n >> t;
	int ans = inf;
	rep(i, n) {
		int c, tmp;
		cin >> c >> tmp;
		if (tmp <= t) ans = min(ans, c);
	}
	if (ans == inf) cout << "TLE" << endl;
	else cout << ans << endl;
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    
    int A[N];
    rep(i,N){
        cin >> A[i];
    }
    
    vector<int> v;
    
    rep(i,N){
        v.push_back(A[i]);
    }
    
    sort(v.rbegin(),v.rend());
    
    rep(i,N){
        if(A[i] != v[0]){
            cout << v[0] << endl;
        }else{
            cout << v[1] << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3316
// The moment you think of giving up you have already lost the battle
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define Mod 1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}
const ll N=1e7+5;
ll  dp[N+1]={0};
int main()
{
   int ans=0;
   string S,T;
   cin>>S>>T;
   int i;
   for(i=0;i<S.length();i++)
   {
       if(S[i]!=T[i])
        ans++;
   }
   cout<<ans;




}


Measured memory_bytes: 3916
#include<iostream>
#include<vector>
#include<queue>
#include<iomanip>
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> pii;

int main(){
  lli n, k, t, u, v, l;
  std::cin >> n >> k >> t >> u >> v >> l;
  vector<lli> d(n);
  priority_queue<pii, vector<pii>, greater<pii> > que;
  for (int i = 0; i < n; i++) {
    std::cin >> d[i];
    que.push(pii(d[i], 0));
  }
  que.push(pii(l, 1));
  double ans = 0, prev, pos = 0, end = 0;
  bool fast = false;
  lli carrot = 0;
  while(not que.empty()){
    prev = pos;
    pos = que.top().first;
    ans += (pos - prev)/((fast)?v:u);
    int event = que.top().second;
    que.pop();
    if(event == 0){
      if(fast == false){
        fast = true;
        end = min((double)l, pos + v*t);
        que.push(pii(min((double)l, pos + v*t), 1));
      }else if(carrot == k){
        end = min((double)l, pos + v*t);
        que.push(pii(min((double)l, pos + v*t), 1));
      }else{
        carrot = min(k, carrot + 1);
      }
    }else if(end <= pos + 1e-9){
      if(carrot > 0){
        carrot--;
        end = min((double)l, pos + v*t);
        que.push(pii(min((double)l, pos + v*t), 1));
      }else{
        fast = false;
      } 
      
    }
  }
  printf("%.12lf\n", ans);
  return 0;
}

Measured memory_bytes: 3236
import sys

#read = sys.stdin.buffer.read
#input = sys.stdin.buffer.readline
#inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np
#from math import gcd
from fractions import gcd

def main():
	a,b=map(int,input().split())
	c=gcd(a,b)
	print(a*b//c)
	
	




	
if __name__ == "__main__":
	main()


Measured memory_bytes: 5560
#include<bits/stdc++.h>
using namespace std;
int  main (){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b){
    cout<<c<<"\n";
    return(0);
  }
  if(a==c){
    cout<<b<<"\n";
    return(0);
  }
  if(b==c){
    cout<<a<<"\n";
    return(0);
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;

int main(int argc, char *argv[])
{
    int A, B;
    std::cin >> A >> B;

    if (A % 2 != 0 && B % 2 != 0) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No"  << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
n, w = [ int(v) for v in input().split() ]

knapsack = [ [ int(v) for v in input().split() ] for i in range(n) ]
total_value = sum([ i[1] for i in knapsack ])

dp_list = [ w+1 for i in range(total_value+1) ]
dp_list[0] = 0

for wi, vi in knapsack:
    new_dp_list = [0] + [ w+1 for i in range(total_value) ]
    for j in range(total_value+1):
        if j >= vi:
            new_dp_list[j] = min(dp_list[j], dp_list[j-vi] + wi)
        else:
            new_dp_list[j] = dp_list[j]
    dp_list = new_dp_list

ans = 0
for i, v in enumerate(dp_list):
    if v != w+1:
        ans = i
print(ans)

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  int b = 380000;
  int n;
  cin >> n;
  double ans = 0;
  rep (i, n) {
    double x;
    string u;
    cin >> x >> u;
    if (u[0] == 'J') ans += x;
    else ans += x * b;
  }
  Sp(ans);

}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

int main()
{
    ll H;
    cin >> H;

    ll d = 0;
    while(H > 0) {
        ++d;
        H /= 2;
    }
    PR((1LL<<d)-1);

    return 0;
}

/*

*/

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

int main(int argc, char const *argv[])
{
    char c;
    cin >> c;

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    {
        cout << "vowel" << endl;
    }
    else
    {
        cout << "consonant" << endl;
    }

    return 0;
}


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

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int64 n,ww;
    cin >> n >> ww;
    vector<int64> w(n);
    vector<int64> v(n);
    for (int i=0; i<n; i++) cin >> w[i] >> v[i];

    int64 v_max = -1;
    for (int i=0; i<n; i++) v_max = max(v_max, v[i]);
    v_max *= n;

    vector<int64> dp(v_max+1, INT_MAX);
    dp[0] = 0;

    for (int i=0; i<n; i++) {
        for (int j=v_max; j-v[i]>=0; j--) {
            dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
        }
    }

    int ans = INT_MAX;
    for (int i=0; i<=v_max; i++) {
        if (dp[i] <= ww) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
/*
  Contest 111
  A - AtCoder Beginner Contest 999
  Rakesh Kumar --> 27/09/2020
 */

#include <bits/stdc++.h>

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

    std::string s;
    std::getline(std::cin, s);
    for (char c : s)
        if (c == '1') std::cout << '9';
        else if (c == '9') std::cout << '1';
        else std::cout << c;
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 3644
import java.util.*;


public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char c = sc.next().charAt(0);
        sc.close();
        if(Character.isUpperCase(c)){
            System.out.println("A");
        }else{
            System.out.println("a");
        }
    }
}

Measured memory_bytes: 26796
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>

using namespace std;
#define n_max 100000

#define rep(i,n) for(int i = 0; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;
typedef pair<ll, ll> PI;

int main() {

    ll n, m; cin >> n >> m;
   
    vector<ll> p(m), y(m);
    vector<vector<PI> > t(n+1);

    rep(i,m) {
        cin >> p[i] >> y[i];
        t[p[i]].push_back(make_pair(y[i],i));
    }
    
    vector<PI> ans(m);
    for(ll i = 1; i < n+1; i++) {
        sort(t[i].begin(), t[i].end());
        for(ll j = 0; j < t[i].size(); j++) {
            ans[t[i][j].second] = make_pair(i,j+1);    
        }
    }
    for(ll i = 0; i < m; i++) {
        printf("%06d%06d\n", ans[i].first, ans[i].second);
    }
    return 0;
}


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

int main()
{
  int N; cin >> N;
  string S; cin >> S;
  int m = N/2;
  string temp = "No";
  //substr(a,b) a:開始位置, b:取り出す長さ
  if(N % 2 == 0 && S.substr(0,m) == S.substr(m,m)) temp = "Yes";
  cout << temp << endl;
}

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

ll mod=1e9+7;

int main() {
  ll num;
  cin >> num;
  map<ll,ll> res;
  ll tn;
  for (int n=2;n<=num;n++) {
    tn=n;
    for(int i=2;i*i<=tn;i++) {
      while(tn%i==0) {
        res[i]++;
        tn/=i;
      }
    }
    if(tn!=1) {
      res[tn]++;
    }
  }
  ll ans=1;
  for(auto p: res) {
    ans=ans*(p.second+1)%mod;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cassert>
#include<map>
#include<vector>
#include<cmath>
#include<complex>
using namespace std;

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define N 100
#define DEAD false
#define ARRIVE true
#define eps 1e-10

typedef complex<double> P;

double dot(P a,P b){
  return a.real()*b.real()+a.imag()*b.imag();
}

double cross(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

double distance_ls_p(P a,P b,P c,double r){
  if ( dot(b-a,c-a)<0)return r*2;
  else if ( dot(a-b,c-b)<0)return r*2;
  return abs(cross(b-a,c-a))/abs(b-a);
}


bool is_intersect_cl(P a,P b,P circle,double radius){
  bool flag1 = abs(a-circle)<=radius?1:0;
  bool flag2 = abs(b-circle)<=radius?1:0;
  
  if ( flag1 == true)return true;
  else if ( flag2 == true)return true;
  if (  distance_ls_p(a,b,circle,radius)<radius+eps)return true;
  return false;
}

class UFO{

public:
  P now;
  double r,v,theta,time;
  double vx,vy;
  bool flag;
  UFO(){};
  UFO(double tx,double ty,double tr,double tv,double R){
    flag = ARRIVE;
    now.real()=tx;
    now.imag()=ty;
    v=tv;
    r=tr;
    theta = arg(now);
    time = sqrt(tx*tx+ty*ty)-R;
    if (time < 0)flag=DEAD;
    else time/=v;
    vx=-cos(theta)*v;
    vy=-sin(theta)*v;    
  }

  void move(double t){    
    if (flag == DEAD){return;}
    now.real()+=vx;
    now.imag()+=vy;
    if ( time < t+eps){flag = DEAD;return ;}
  }

  bool crash_check(P a,P b){
    if ( flag == DEAD)return false;
    if ( is_intersect_cl(a,b,now,r)==true){
      flag = DEAD;
      return true;
    }
    return false;
  }
};


int solve(int n,UFO *data,double R){
  const double INF = 20000;
  int cnt=0;
  double time=1;
  while(true){
    double dist = 1000*1000;
    int minindex = -1;
    rep(i,n){
      data[i].move(time);
      if (data[i].flag == ARRIVE&& abs(data[i].now)<dist){
	dist=abs(data[i].now);
	minindex=i;
      }
    }
    if ( minindex == -1)break;
    
    P a,b,e;
    e = data[minindex].now/abs(data[minindex].now);
    a=e*R;
    b=e*INF;
    rep(i,n){
      if ( data[i].crash_check(a,b) == true)cnt++;
    }


    time+=1;
  }

  return n-cnt;
}

main(){
  double R;
  int n;
  while(cin>>R >> n && n){
    UFO data[n];
    rep(i,n){
      double x,y,r,v;
      cin>>x>>y>>r>>v;
      data[i]=UFO(x,y,r,v,R);
    }
    cout << solve(n,data,R) << endl;
  }

}

Measured memory_bytes: 0
n,a,b=map(int,input().split())
A,B=0,0
for i in input():
  if i=="a":
    if A+B<a+b:
      print("Yes")
      A+=1
    else:
      print("No")
  elif i=="b":
    if A+B<a+b and B<b:
      print("Yes")
      B+=1
    else:
      print("No")
  else:
    print("No")

Measured memory_bytes: 4016
#include<iostream>
using namespace std;
int main(){
    int i,n;
    i=1;
    cin>>n;
    while(i<=n){
    if (i%3==0 || i%10==3|| i/10%10==3||i/100%10==3||i/1000%10==3){
        cout<<" "<<i;
    }
    i+=1;
    }
    cout<<endl;
}


Measured memory_bytes: 3088
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define F first
#define S
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,a;
  cin>>n;
  vi x(100005,0);
  rep(i,n){
    cin>>a;
    x[a]++;
  }
  i=0;
  j=100005;
  int ans=0;
  while(1){
    while(x[i]<2 && i<=j)i++;
    while(x[j]<2 && i<=j)j--;
    if(x[i]<2 && x[j]<2)break;
    x[i]--;
    x[j]--;
    ans+=2;
  }
  cout<<n-ans<<endl;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline

A = int(input()) #500
B = int(input()) #100
C = int(input()) #50
X = int(input()) #sum
count = 0

for a in range(A + 1):
    for b in range(B + 1):
        if 500 * a + 100 * b <= X <= 500 * a + 100 * b + 50 * C:
            count += 1

print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vl;
typedef vector<vector<ll>> vll;
typedef vector<bool> vb;
typedef set<int> si; 
typedef queue<int> qi;
typedef stack<int> sti;
typedef priority_queue<int> pqi;
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
//#define __builtin_popcountll bitCountLL
//#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
//std::uniform_int_distribution<long long> rg(1,1e18);
#define maxn 100005
#define Mod 1000000007
const int INF = 2e9;
const ll ML = 4e18;
    
void solve() {
    int n, k;
    cin >> n >> k;
    vl a(n), b(n);
    mii mp;
    fori(i,0,n) {
        cin >> a[i];
        a[i]--;
    }
    vb vis(n,false);
    ll ans = -ML;
    fori(i,0,n) cin >> b[i];
    fori(x,0,n) {
        int cur = x, j = 0;
        vl rs;
        ll cum = 0;
        while(!vis[cur]) {
            rs.push_back(b[cur]);
            cum += b[cur];
            vis[cur] = true;
            cur = a[cur];
            j++;
        }
        int r = rs.size();
        ll mx = -ML;
        int len = min(r, k);
        fori(i,1,len + 1) {
            ll sum = 0;
            fori(j,0,i) sum += rs[j];
            vl mx(r);
            mx[0] = sum;
            ll rt = sum;
            fori(j,1,r) {
                sum += rs[(j + i - 1) % r] - rs[j-1];
                mx[j] = sum;
                rt = max(rt, sum);
            }
            ans = max(ans, rt);
            if(k > r && cum > 0) {
                ans = max(ans, (k - i) / r * cum + rt);
            }
        }
    }
            
    cout << ans << endl;

}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
	//freopen("D:\\data_in.txt", "r", stdin);
   
    solve();
   
    /*
    clock_t start,finish;
    start = clock();
    
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


Measured memory_bytes: 3724
#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>;

int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int n = max(x, y);
    int ans = 1e9;
    rep(i, n+1) {
        int cost = 2 * c * i;
        if (x >= i) cost += a * (x - i);
        if (y >= i) cost += b * (y - i);
        ans = min(ans, cost);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String A = sc.nextLine();
    String B = sc.nextLine();
    String C = sc.nextLine();
    
    int ans = 0;
    for(int i = 0; i < N; i++){
      char a = A.charAt(i);
      char b = B.charAt(i);
      char c = C.charAt(i);
      if(a == b && a == c){
      }else if(a == b || b == c || a == c){
        ans++;
      }else{
        ans += 2;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
struct segtree{
    int n=1;
    vector<bitset<26>> t;
    segtree(int k, string s){
        while(n<k) n*=2;
        t.resize(2*n-1);
        rep(i,s.size()){
            int now=s[i]-'a';
            t[i+n-1].set(now);
        }
        for(int i=n-2;i>=0;i--){
            t[i] = t[i*2+1]|t[i*2+2];
        }
    }
    void query1(int i, char no){
        int now=no-'a';
        i+=n-1;
        t[i]=bitset<26>(0);
        t[i].set(now);
        while(i>0){
            i=(i-1)/2;
            t[i]=t[i*2+1]|t[i*2+2];
        }
    }
    auto preque(int a,int b, int k, int l, int r){
        if(r<=a||b<=l)return bitset<26>(0);
        else if(a<=l&&r<=b) return t[k];
        else{
            auto vl=preque(a,b,k*2+1,l,(r+l)/2);
            auto vr=preque(a,b,k*2+2,(r+l)/2,r);
            return vl|vr;
        }
    }
    int query2(int l, int r){
        auto a= preque(l,r+1,0,0,n);
        return a.count();
    }
};
int main(void){
    // Your code here!
    int n,q;string s;cin>>n>>s>>q;
    segtree seg(n,s);
    rep(i,q){
        int Q;cin>>Q;
        if(Q==1){
            int a;char b;cin>>a>>b;
            a--;
            seg.query1(a,b);
        }else{
            int a,b;cin>>a>>b;
            a--;b--;
            cout<<seg.query2(a,b)<<endl;
        }
    }
}

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

using namespace std;

#define min(a, b) ((a) < (b)? (a):(b))
#define max(a, b) ((a) > (b)? (a):(b))
#define rep(i, n) REP((i), 0, (n))
#define REP(i, a, n) for(int i=(a); i<(n); i++)

pair<int, int> p[210];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1) {
        int N; cin >> N;
        if(N == 0) break;
        
        p[0] = {0, 0};
        int xmin=0, xmax=0, ymin=0, ymax=0;
        REP(i, 1, N) {
            int n, d; cin >> n >> d;
            if(d == 0) p[i] = {p[n].first-1, p[n].second};
            else if(d == 1) p[i] = {p[n].first, p[n].second+1};
            else if(d == 2) p[i] = {p[n].first+1, p[n].second};
            else if(d == 3) p[i] = {p[n].first, p[n].second-1};
            xmin = min(xmin, p[i].first);
            xmax = max(xmax, p[i].first);
            ymin = min(ymin, p[i].second);
            ymax = max(ymax, p[i].second);
        }
        cout << xmax-xmin+1 << " " << ymax-ymin+1 << endl;
    }
}


Measured memory_bytes: 3012
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int n, k;
    cin >> n >> k;
    if(500 * n >= k)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
l, r = gets.split.map(&:to_i)

ans = 2018
zero_divided = false

l.upto(r - 1) do |i|
  if zero_divided
    ans = 0
    break
  end

  (i + 1).upto(r) do |j|
    p = i * j % 2019

    if p == 0
      zero_divided = true
      break
    end

    ans = p if p <= ans
  end
end

puts ans


Measured memory_bytes: 3836
# -*- coding: utf-8 -*-

from sys import stdin

def main():
    _ = stdin.readline().rstrip()
    s = stdin.readline().rstrip()
    k = int(stdin.readline())

    target = s[k-1]
    ans = ''

    for c in s:
        if c == target:
            ans += c
        else:
            ans += '*'
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long int ll;
using namespace std;

struct edge {
    int src, dst, cost; 
    edge(int s, int t, int c): src(s), dst(t), cost(c) {}
};
const int INF = 1e8;

void warshall_floyd(vector<vector<int> > &d, vector<edge> &edges) {
    for(size_t i=0; i<d.size(); ++i) {
        d[i].assign(d[i].size(), INF);
        d[i][i] = 0;
    }
    for(auto &e : edges) {
        d[e.src][e.dst] = e.cost;
    }
    const size_t n = d.size();
    for(size_t j=0; j<n; ++j) {
        for(size_t k=0; k<n; ++k) {
            for(size_t i=0; i<n; ++i) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    for(size_t j=0; j<n; ++j) {
        for(size_t k=0; k<n; ++k) {
            for(size_t i=0; i<n; ++i) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    for(size_t j=0; j<n; ++j) {
        for(size_t k=0; k<n; ++k) {
            for(size_t i=0; i<n; ++i) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main(void) {
    int n, m, s, g1, g2;
    while(cin >> n >> m >> s >> g1 >> g2 && n) {
        vector<edge> edges;
        vector<vector<int> > d(n, vector<int>(n, INF));
        --s; --g1; --g2;
        REP(i, m) {
            int b1, b2, c;
            cin >> b1 >> b2 >> c;
            edges.push_back(edge(b1-1, b2-1, c));
        }
        warshall_floyd(d, edges);
        int cost = numeric_limits<int>::max();
        REP(i, n) {
            cost = min(cost, d[s][i] + d[i][g1] + d[i][g2]);
        }
        cout << cost << endl;
    }
 }


Measured memory_bytes: 3180
#include <stdio.h>
#define SMAX 1000000

int S[SMAX];
int n;

int binaryserch(int bs)
{ 
    int left = 0; 
    int right = n; 
    int mid;

    while( left < right){
     mid = (left + right)/2;
     if( bs == S[mid] ) {
      return 1;
    }
     if( bs > S[mid] ) {
      left = mid + 1;
    }
     else if (bs < S[mid] ) {
      right = mid;
    }
   }
    return 0;
}

int main()
{ 
  int i=0,j=0,q,count=0,T;
  int c;

  scanf("%d",&n);
  while(i < n){
    scanf("%d",&S[i]);
    i++;
  }  
  scanf("%d",&q);
  while(j < q ){
    scanf("%d",&T);
    c = binaryserch(T);
    if(c == 1) count++;
    j++;
  }
    
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
#define ll long long
#define min(a,b) a<b?a:b

using namespace std;

ll llabs(ll a){
	if (a < 0) return -a;
	return a;
}

int main(){

	ll n, k;

	cin >> n >> k;

	vector < ll > adj(n+1);
	vector < ll > dp(n+1);

	for (ll i = 1; i <= n; i++){
		ll a;
		cin >> a;
		adj[i] = a;
	}

	dp[1] = 0;
	dp[2] = llabs(adj[1] - adj[2]);

	for (ll i = 3; i <= n; i++){
		ll aux = INT_MAX;
		for (ll j = 1; j <= k && (i - j) > 0; j++){
			aux = min(aux, dp[i-j] + llabs(adj[i-j] - adj[i]));
			//aux = min(dp[i-1] + llabs(adj[i-1] - adj[i]), dp[i-2] + llabs(adj[i-2] - adj[i]));
		}
		dp[i] = aux;
	}

	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 1792
//https://atcoder.jp/contests/abc118/tasks/abc118_b

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define max(a, b) (((a) > (b)) ? (a) : (b))

int main()
{
    int n, m, o, ans = 0, buf;
    scanf("%d%d", &n, &m);
    int count[m];

    // 初期化
    for (int i = 0; i < m; i++)
        count[i] = 0;

    // N人に対して聞く
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &o);
        for (int j = 0; j < o; j++)
        {
            scanf("%d", &buf);
            count[buf - 1]++;
        }
    }

    for (int i = 0; i < m; i++)
    {
        if (count[i] == n)
        {
            ans++;
        }
    }
    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 128
// https://atcoder.jp/contests/abc170/tasks/abc170_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  cin >> N;

  VL as(N);
  rep(i, N) cin >> as[i];

  ll MAX = *max_element(all(as));
  VL fact_cts(MAX + 1, 0);  // 2 以上は 2 にまとめる

  for (ll a : as) {
    unless(fact_cts[a] == 0) {
      fact_cts[a] = 2;
      continue;
    }

    for (ll m = a; m <= MAX; m += a) {
      ++fact_cts[m];
    }
  }

  ll res = 0;
  for (ll a : as) {
    if (fact_cts[a] == 1) res++;
  }

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


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

const int N = 200005;

int n;
char s[30];
long long a[N];

int cnt[50][50];

int solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", s);

    long long num = 0;
    int len = strlen(s);
    int after = 0;
    bool point = false;
    for (int i = 0; i < len; ++i) {
      if (s[i] == '.') {
        point = true;
        continue;
      }
      if (point) ++after;
      num = num * 10 + s[i] - '0';
    }

    for (int i = after; i < 9; ++i) {
      num = num * 10;
    }

    a[i] = num;
    // cerr << a[i] << endl;
  }

  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    int two = 0, five = 0;
    while (a[i] % 2 == 0) {
      ++two;
      a[i] /= 2;
    }

    while (a[i] % 5 == 0) {
      ++five;
      a[i] /= 5;
    }

    ans += cnt[max(0, 18 - two)][max(0, 18 - five)];
    // cerr << ans << endl;

    for (int i = 0; i <= two; ++i) {
      for (int j = 0; j <= five; ++j) {
        ++cnt[i][j];
      }
    }
  }

  printf("%lld\n", ans);
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 5328
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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 fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll,ll> P;
typedef long double ld;

ll code (ll h, ll w, ll y, ll x) {
    return y * (max(h, w) + 2) + x;
}

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w, m; cin >> h >> w >> m;
    vector<P> tate(h), yoko(w), b(m);
    map<ll, bool> ma;
    rep (i, tate.size()) tate[i].second = i;
    rep (i, yoko.size()) yoko[i].second = i;
    rep (i, m) {
        cin >> b[i].first >> b[i].second;
        b[i].first--; b[i].second--;
        tate[b[i].first].first++;
        yoko[b[i].second].first++;
        ma[code(h, w, b[i].first, b[i].second)] = true;
    }
    sort(all(tate), [](P a, P b){return a.first > b.first;});
    sort(all(yoko), [](P a, P b){return a.first > b.first;});

    // rep (i, tate.size()) eprintf("(%lld,%lld)", tate[i].first, tate[i].second);
    // eprintf("\n");
    // rep (i, yoko.size()) eprintf("(%lld,%lld)", yoko[i].first, yoko[i].second);
    // eprintf("\n");

    bool nobomb = false;
    ll count = 0;
    ll tatem = tate[0].first, yokom = yoko[0].first;
    rep (i, h) {
        if (tate[i].first != tatem) goto ret;
        rep (j, w) {
            if (count > m + 100) goto ret;
            if (yoko[j].first != yokom) break;

            if (!ma[code(h, w, tate[i].second, yoko[j].second)]) {
                eprintf("!(%lld,%lld)\n", tate[i].second, yoko[j].second);
                nobomb = true;
                goto ret;
            }

            count++;
        }
    }
    ret:
    cout << tatem + yokom - (nobomb ? 0 : 1) << "\n";
    return 0;
}

Measured memory_bytes: 35944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  string n;cin>>n;
  bool ans=false;
  if(n.substr(0,3)==string(3,n[0])||
     n.substr(1,3)==string(3,n[3])){
    ans=true;
  }
  cout <<btos(ans)<<endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        n: usize,
        d: [usize; n],
    );

    let mut ans = 0;

    for i in 0..n {
        for j in 0..i {
            ans += d[i] * d[j];
        }
    }

    println!("{}", ans);
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572