akhauriyash/Code-Regression huggingface dataset:
# すべて1のところ
# 毎回calc(x)を計算しているから遅い
MOD = 10 ** 9 + 7
L = list(input())
N = len(L)

lst = [-1] * N
def calc(x): #1が続いている桁数
    if x == 0:
        return 1
    tmp_ans = 1
    tmp = 1
    for i in range(1, x):
        tmp = (tmp * (x + 1 - i))//i
        tmp_ans += pow(2, i, MOD) * tmp
        tmp_ans %= MOD

    tmp_ans += pow(2, x, MOD)
    tmp_ans %= MOD
    return tmp_ans

def calc1(x):
    return pow(3, x, MOD)

#ここまでで一番上の桁が0の場合を処理済み（N - 1桁で書ける場合）
ans = calc1(N - 1) + 2
# print (ans)

# 1xxxxxxのxxxxxxの部分を足す必要がある

count = 1
for i in range(1, N):
    if L[i] == '1':
        ans += pow(2, count, MOD) * (calc1(N - 1 - i) + 1)
        count += 1
        ans %= MOD
    
print (ans % MOD)


Measured memory_bytes: 4776
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>
#include <utility>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
#define REPS(a,i,n) for(int i = a ; i < n ; ++i)
using namespace std;

int main(){
	double a, b;
	cin >> a >> b;

	printf("%.6lf\n", a*b / 3.305785);
	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
    using namespace std;
     
    int main()
    {
      int N;
      cin >> N;
      
      int ha = 0;
      
      ha += (N / 500) * 1000;
      N = N % 500;
      
      ha += (N / 5) * 5;
      cout << ha << endl;
      
      return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;

long long int DP[2000][2000];
long long int A[2000];

long long int INF = 100000000000000LL;

int main() {
	
	int N;
	cin >> N;
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			DP[i][j] = -INF;
		}
	}
	
	for(int i = 0; i < N; i++){
		cin >> A[i];
		DP[i][i] = A[i];
	}
	
	for(int i = 1; i < N; i++){
		for(int j = 0; j < N; j++){
			if(i % 2 == 0){
				DP[j][(j + i) % N] = max(DP[(j + 1) % N][(j + i) % N] + A[j], 
										DP[j][(j + i - 1) % N] + A[(j + i) % N]);
			}else{
				if(A[j] >= A[(j + i + 1) % N]){
					DP[j][(j + i) % N] = max(DP[j][(j + i) % N], DP[(j + 1) % N][(j + i) % N]);
				}
				if(A[(j - 1 + N) % N] <= A[(j + i) % N]){
					DP[j][(j + i) % N] = max(DP[j][(j + i) % N], DP[j][(j + i - 1) % N]);
				}
			}
			//cout << DP[j][(j + i) % N] << " ";
		}
		//cout << endl;
	}
	
	long long int ans = 0;
	
	for(int i = 0; i < N; i++){
		ans = max(ans, DP[i][(i - 1 + N) % N]);
	}
	
	cout << ans << endl;
	
	return 0;
}




Measured memory_bytes: 34344
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int main() {
	ll N;
	cin >> N;
	
	vector<ll> divisor;
	for(ll i = 1; i * i <= N; i++) if (N % i == 0) {
		divisor.push_back(i);
		if (i * i != N) divisor.push_back(N / i);
	}
	
	ll ans = 0;
	for (ll x : divisor) {
		if (x == 1) continue;
		x--;
		if (N % x == N / x) ans += x;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 384
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

//↑template↑

int main() {
	int a, b, c, d;
	cin >> a >> b >> c;
	d = 7 * a + b;
	cout << 7 * (c / d) + min(((c % d) + a - 1) / a, 7) << endl;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int x = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      x++;
    }
  }
  
  cout << (x) / float(n);
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    LL a,b,c;
    cin>>a>>b>>c;
    LL sa = c-a-b;
    //double a,b,c;
    //cin>>a>>b>>c;

    if(sa<=2){
        cout<<"No"<<endl;
        return;
    }

    
    if(sa*sa > 4*a*b){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if (a + b == 3) System.out.println(3);
    else if (a + b == 4) System.out.println(2);
    else System.out.println(1);
  }
}

Measured memory_bytes: 20692
#include <bits/stdc++.h>
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;


int main(){
    __int128 a, b, c, l, r;
    scan(a, b, c);
    l = 4*a*b, r = c-a-b;
    r *= r;
    puts((l<r and (c-a-b > 0))? "Yes" : "No");
    
    
    return 0;
}

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

int main(){
    string n,a,b;
    cin >> n;
    a="FESTIVAL";
    cout << n.substr(0,n.length()-8) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second

typedef long long int lli;
typedef pair<int,int> P;

const int INF=1<<30;
const long long int INF_=1<<60;

int main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int N;
    while(cin >> N&&N){
		REP(i,0,N){
			int X[2],Y[2],Z[2],W[2];
			REP(j,0,2) cin >> X[j] >> Y[j] >> Z[j] >> W[j];
			vector<int> ans(4);
			ans[0]=X[0]*X[1]-Y[0]*Y[1]-Z[0]*Z[1]-W[0]*W[1];
			ans[1]=X[0]*Y[1]+Y[0]*X[1]+Z[0]*W[1]-W[0]*Z[1];
			ans[2]=X[0]*Z[1]-Y[0]*W[1]+Z[0]*X[1]+W[0]*Y[1];
			ans[3]=X[0]*W[1]+Y[0]*Z[1]-Z[0]*Y[1]+W[0]*X[1];
			REP(j,0,4) cout << ans[j] << (j==3?'\n':' ');
		}
	}
	return 0;
}

Measured memory_bytes: 1208
import sys
readline = sys.stdin.readline

N, K, Q = map(int, readline().split())
A = [int(readline()) for _ in range(Q)]
ans = [K-Q]*N
for a in A:
    ans[a-1] += 1
ans = ['Yes' if a > 0 else 'No' for a in ans]
print(*ans, sep = '\n')

Measured memory_bytes: 56412
#include<iostream>
#include<cstdio>
#include<cstring>
#define MAXN 200005
using namespace std;

char s[MAXN];
int len;
int dp[MAXN];
int pos[MAXN][30];

void solve(){
    len = strlen(s);
    for (int i = 0;i < 26;++i){
        pos[len][i] = len;
    }
    dp[len] = 1;
    dp[len+1] = 0;

    for (int i = len-1;i >= 0;--i){
        for (int j = 0;j < 26;++j){
            pos[i][j] = pos[i+1][j];
        }
        pos[i][s[i]-'a'] = i;
        dp[i] = len+1;
        for (int j = 0;j < 26;++j){
            dp[i] = min(dp[i], dp[pos[i][j]+1]+1);
        }
    }

    int T = dp[0];
    int p = 0;
    while (T--){
        for (int i = 0;i < 26;++i){
            if (dp[p] == dp[pos[p][i]+1]+1) {
                printf("%c", 'a'+i);
                p = pos[p][i]+1;
                break;
            }
        }
    }
    printf("\n");
}

int main(){
    scanf("%s", s);
    solve();
    return 0;
}

Measured memory_bytes: 24704
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int n,m; cin >> n >> m;
	int big_l = 0, small_r = inf;
	FOR(m){
		int l,r; cin >> l >> r;
		big_l = max(l,big_l);
		small_r = min(small_r, r);
	}
	cout << max(small_r - big_l + 1,0);
}

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


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, x;  cin >> k >> x;
    for(int i = k - 1; i >= 0; --i) {
      cout << x - i << " ";
    }
    FOR(i, 1, k) {
      cout << x + i;
      if (i != k - 1) {
        cout << " ";
      }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define lol long long
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c;
int ans[1000010];
int i[100010];
int o[100010];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol d=1,e=0,f=0;
  string s;
  cin >>a;
  for(int n=0;n<a;n++) cin >>o[n];
  i[0]=3;
  for(int n=0;n<a;n++){
    d*=i[o[n]],i[o[n]]--,i[o[n]+1]++;
    d=d%inf;
  }
  cout <<d<<'\n';
  return 0;
}


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

int aaa(int a,int n){
    int b=1;
    while(n!=0){
        b*=a;
        n--;
    }
    return b;
}
int main(void){
    int n;
    cin>>n;
    int a[20][20]={};
    int k=0;
    long long ans=0;
    for(int i=1;i<=n;i++){
        if(i>=aaa(10,k+1)){
            k++;
        }
        a[i/aaa(10,k)][i%10]++;
    }
    int b[20][20]={};
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(b[i][j]==0){
                ans+=a[i][j]*a[j][i];
                b[i][j]=1;
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    string s;
    ll k;
    cin >> s >> k;
    for (ll i = 0; i < k; i++)
    {
        if(s[i] != '1'){
        cout << s[i] << endl;
        return 0;
        }
    }
    cout << 1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
#define inRange(x,a,b) (a <= x && x < b)

int main(){
    int n, q;
    string s;
    cin >> n >> q >> s;
    vector<char> t(q), d(q);
    for(int i = 0; i < q; i++)  cin >> t[i] >> d[i];
    int l = -1, r = n;
    while(r-l > 1){
        int mid = (l+r)/2;
        int cp = mid;
        bool ok = false;
        for(int i = 0; i < q; i++){
            if(t[i] == s[cp]){
                if(d[i] == 'L') cp--;
                else            cp++;
                if(cp < 0){
                    ok = true;
                    break;
                }
                if(cp >= n){
                    break;
                }
            }
        }
        if(ok)  l = mid;
        else    r = mid;
    }
    int ll = l;    
    l = -1, r = n;
    while(r-l > 1){
        int mid = (l+r)/2;
        int cp = mid;
        bool ok = false;
        for(int i = 0; i < q; i++){
            if(t[i] == s[cp]){
                if(d[i] == 'L') cp--;
                else            cp++;
                if(cp < 0){
                    break;
                }
                if(cp >= n){
                    ok = true;
                    break;
                }
            }
        }
        if(ok)  r = mid;
        else    l = mid;
    }
    int rr = r;
    vector<bool> v(n);
    for(int i = 0; i <= ll; i++)    v[i] = true;
    for(int i = n-1; i >= rr; i--)  v[i] = true;
    int ans = n;
    for(int i = 0; i < n; i++)  if(v[i])    ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 900
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Queue;

public class Main {
	static ContestScanner in;
	static Writer out;
	public static void main(String[] args) {
		Main main = new Main();
		try {
			in = new ContestScanner();
			out = new Writer();
			main.solve();
			out.close();
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	void solve() throws IOException {
		int n = in.nextInt();
		boolean[] dp = new boolean[10001];
		dp[0] = true;
		for(int i = 0; i < n; i++) {
			int s = in.nextInt();
			for(int j = 10000 - s; j >= 0; j--) {
				if(dp[j] == false) continue;
				dp[j + s] = true;
			}
		}
		for(int i = 10000; i >= 0; i--) {
			if(dp[i] && i % 10 != 0) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(0);
	}
}

class Writer extends PrintWriter{
	public Writer(String filename)throws IOException
	{super(new BufferedWriter(new FileWriter(filename)));}
	public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
	private BufferedReader in;private int c=-2;
	public ContestScanner()throws IOException 
	{in=new BufferedReader(new InputStreamReader(System.in));}
	public ContestScanner(String filename)throws IOException
	{in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
	public String nextToken()throws IOException {
		StringBuilder sb=new StringBuilder();
		while((c=in.read())!=-1&&Character.isWhitespace(c));
		while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public String readLine()throws IOException{
		StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
		while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public long nextLong()throws IOException,NumberFormatException
	{return Long.parseLong(nextToken());}
	public int nextInt()throws NumberFormatException,IOException
	{return(int)nextLong();}
	public double nextDouble()throws NumberFormatException,IOException 
	{return Double.parseDouble(nextToken());}
	public void close() throws IOException {in.close();}
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===


vector<Vi> node;
vector<Pii> ans;
Vi cnt;
Vi color;
int i_ans = 0;
map<Pii, bool> chk;

void dfs(int u, int par) {
	color[u] = 1;
	for (const auto& v : node[u]) {
		if (v == par) continue;
		Pii p1 = make_pair(u, v);
		Pii p2 = make_pair(v, u);
		if (color[v] == 1 && !chk[p1] && !chk[p2]) {
			ans.emplace_back(u, v);
			++cnt[u];
			chk[p1] = true;
			continue;
		}
		if (color[v] == 0) {
			dfs(v, u);
		}
	}
	if (par == -1) {
		return;
	}
	if (cnt[u] % 2 == 0) {
		ans.emplace_back(par, u);
		++cnt[par];
	}
	else {
		ans.emplace_back(u, par);
		++cnt[u];
	}
}

int main() {
	int N, M;
	cin >> N >> M;
	if (M % 2 == 1) {
		cout << -1 << endl;
		return 0;
	}

	node.resize(N);
	cnt.resize(N);
	color.resize(N);

	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		node[a].push_back(b);
		node[b].push_back(a);
	}

	dfs(0, -1);

	for (const auto& a : ans) {
		cout << a.first + 1 << " " << a.second + 1 << endl;
	}
}

Measured memory_bytes: 19444
#include<stdio.h>
#include<stdlib.h>

int main(){
	int a[3],b[2],Ans=0,amin=0,bmin=0;
	
	scanf("%d",&a[0]);
	amin=a[0];
	scanf("%d",&a[1]);
	if(amin>a[1])amin=a[1];
	scanf("%d",&a[2]);
	if(amin>a[2])amin=a[2];
	scanf("%d",&b[0]);
	scanf("%d",&b[1]);
	if(b[0]>b[1])bmin=b[1];else bmin=b[0];
	Ans=amin+bmin-50;
	printf("%d\n",Ans);
	return 0;
} 

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>

using namespace std;

class Tree {
public:
	explicit Tree(long long L) {
		nodes.emplace_back(L);
	}
	void add(const string& s){
		int cur = 0;
		for(int i=0;i<s.size();i++){
			int& nextNode = nodes[cur].next[s[i]-'0'];
			if(nextNode == -1){
				nodes.emplace_back(nodes[cur].depth - 1);
				nextNode = nodes.size() - 1;
			}
			cur = nextNode;
		}
	}
	bool solve() const {
		long long grundy = 0LL;
		for(const auto& node : nodes){
			if(!node.valid()) continue;
			long long d = node.depth;
			grundy ^= d^(d&(d-1));
		}
		return grundy != 0LL;
	}
private:
	class Node {
	public:
		explicit Node(long long d) : depth(d), next(2, -1) {}
		bool valid() const{
			if(depth <= 0) return false;
			int cnt = 0;
			for(int t : next) if(t == -1) ++cnt;
			return cnt == 1;
		}
		long long depth;
		vector<int> next;
	};
private:
	vector<Node> nodes;
};

int main(){
	int N; long long L;
	while(cin >> N >> L){
		Tree tree(L);
		for(int i=0;i<N;i++){
			string s; cin >> s;
			tree.add(s);
		}
		cout << (tree.solve() ? "Alice" : "Bob") << endl;
	}
}


Measured memory_bytes: 7920
// D - Five, Five Everywhere
// https://abc096.contest.atcoder.jp/tasks/abc096_d
//
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;


vector<bool> create_prime_list(unsigned int limit);



vector<bool> create_prime_list(unsigned int limit) {
    // エラトステネスの篩
    vector<bool> isprime(limit+1, true);
    isprime[0] = false;
    isprime[1] = false;

    for (auto i = 2; i <= sqrt(limit); ++i) {
        if (isprime[i]) {
            int j = i + i;
            while (j <= limit) {
                isprime[j] = false;
                j += i;
            }
        }
    }
    return isprime;
}


vector<int> solve(unsigned int n) {
    // 素数リストの作成
    vector<bool> res = create_prime_list(55555);
    vector<int> primes;
    for (auto i = 2; i < res.size(); ++i) {
        if (res[i])
            primes.push_back(i);
    }

    vector<int> ans;
    for (auto p: primes) {
        if (p % 5 == 1) {
            ans.emplace_back(p);
            if (ans.size() == n)
                break;
        }
    }
    return ans;
}


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

    unsigned int n;
    cin >> n;
    vector<int> ans = solve(n);

    for (int i = 0; i < ans.size(); ++i) {
        string s = (i+1 >= ans.size()) ? "\n": " ";
        cout << ans[i] << s;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c, d;
  in2(a, b);
  in2(c, d);
  out(max(a * b, c * d));
  memi;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> g(h);
  rep(i,h) cin >> g[i];


  vector<vector<int>> r(h,vector<int>(w,0)),
                      l(h,vector<int>(w,0)),
                      u(h,vector<int>(w,0)),
                      d(h,vector<int>(w,0));
  rep(i,h){
    int cnt = 0;
    for(int j = 0; j < w; j++){
      if(g[i][j]=='#') cnt = 0;
      else cnt++;
      l[i][j] = cnt;
    }
  }
  rep(i,h){
    int cnt = 0;
    for(int j = w-1; j >=0; j--){
      if(g[i][j]=='#') cnt = 0;
      else cnt++;
      r[i][j] = cnt;
    }
  }
  rep(j,w){
    int cnt = 0;
    for(int i = 0; i < h; i++){
      if(g[i][j]=='#') cnt = 0;
      else cnt++;
      u[i][j] = cnt;
    }
  }
  rep(j,w){
    int cnt = 0;
    for(int i = h-1; i >=0 ; i--){
      if(g[i][j]=='#') cnt = 0;
      else cnt++;
      d[i][j] = cnt;
    }
  }

  int ans = 0;
  rep(i,h)rep(j,w){
    ans = max(ans, r[i][j]+l[i][j]+u[i][j]+d[i][j]-3);
  }
  cout << ans << endl;

}


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

int main() {
  ll x,k,d;
  cin >> x >> k >> d;

  x = abs(x);
  ll ans;
  if (x/d > k) {
    //原点を往復しない場合
    ans = x -d*k;
    //原点を往復する場合
  } else {
    ll e = x/d;
    k -= e;
    x -= e*d;
    //原点を往復する場合、偶数か奇数かで値が変わる
    if (k%2 == 1) x = abs(x-d);
    ans = x;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){

	int n;
	cin>>n;
	int k[n],p[n];
	for(int i=0;i<n;i++){
		cin>>k[i]>>p[i];
	}

	for(int i=0;i<n;i++){
		if(k[i]%p[i]!=0){
			cout<<k[i]%p[i]<<endl;
		}
		else{
			cout<<p[i]<<endl;
		}
	}

return 0;
}

Measured memory_bytes: 1160
function main(input) {
    var n = input[0]-0;
    var cnt = 1;
    var ans = 0;
    for(cnt=1;ans<n;cnt++){
        ans += cnt;
    }
    console.log(cnt-1);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


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


int main() {
	int n, m;
	cin >> n >> m;
	vector<int> s(m);
	vector<int> c(m);
	rep(i, m)	cin >> s[i] >> c[i];
	int ans = -1;
	int checker = 1;

	//入力から値作る．
	vector<int> val(n,-1);
	rep(i, m) {
		if (val[s[i] - 1] != -1 && val[s[i] - 1] != c[i]) {
			checker = 0;
			break;	
		}
		val[s[i]-1] = c[i];
	}

	if ((n == 1 && val[0] == -1) || (n == 1 && val[0] == 0)) {
		ans = 0;
		checker = 0;
	}
	
	//判定，最小値
	if (checker) {
		if (val[0] != 0) {
			if (val[0] == -1)	val[0] = 1;
			for (int i = 1; i < n; i++) {
				if (val[i] == -1)
					val[i] = 0;
			}
			ans = 0;
			rep(i, n)	ans += pow(10, n - i - 1)*val[i];
		}	
	}

	cout << ans << endl;



}

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

int main() {
  int N;
  cin >> N ;
  string ans = "No";
  
  for(int i = 0; 7 * i <= N; ++i) {
    if((N - 7 * i) % 4 == 0) {
      ans = "Yes";
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e12)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
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; }
 
int main()
{
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    rep(ki, k){
        vector<int> b(n+1, 0);
        rep(i, n){
            int l = max(i - a[i], 0);
            int r = min(i + a[i]+1, n);
            b[l]++; b[r]--;
        }
        rep(i, n) b[i+1] += b[i];
        b.pop_back();
        if(a==b) break;
        a = b;
    }
    prvec(a);

    return 0;}

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

int main()
{
    int n;
    cin >> n;
    vector<int> ans(n+1, INT_MAX), h(n+1);
    ans[1] = 0; 
    for (int i = 1 ; i <= n ; i++) cin>>h[i];
    for (int i = 1 ; i <= n ; i++) {
        for (int j = 1 ; j <= 2 ; j++) {
            if ((i + j) > n) continue;
            ans[i+j] = min(ans[i+j], ans[i] + abs(h[i] - h[i+j]));
        }
    }
    cout << ans[n];
    return 0;
}


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

int main() {
	long long A, B, C;
	cin >> A >> B >> C;

	if (((A >= C) && (B <= C)) || ((A <= C) && (B >= C))) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,n,i,ans1,ans2;
	cin>>x>>n;
	int a[n],b[100000]={0};
	for(i=0;i<n;i++){
		cin>>a[i];
		b[a[i]]=1;
	}
	for(i=x;i<100000;i++){
		if(b[i]==0){
			ans1=i;
			break;
		}
	}
	for(i=x-1;i>=0;i--){
		if(b[i]==0){
			ans2=i;
			break;
		}
	}
	if((x-ans2)<=(ans1-x))
	cout<<ans2<<"\n";
	else
	cout<<ans1<<"\n";
	return 0;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,int> pll;

int n,m,x;
int valor[13];
int libros[13][13];
int valorMinimo=10000000;
int habilidadesActuales[13];

void habilidades(int i,int dineroGastado){
    if(i==n){
        for(int j=0;j<m;j++){
            if(habilidadesActuales[j]<x) return;
        }
        if(dineroGastado<valorMinimo) valorMinimo=dineroGastado;
        return;
    }
    for(int j=0;j<m;j++){
        habilidadesActuales[j]+=libros[i][j];
    }
    habilidades(i+1,dineroGastado+valor[i]);
    for(int j=0;j<m;j++){
        habilidadesActuales[j]-=libros[i][j];
    }
    habilidades(i+1,dineroGastado);
    return;
}

int main() {
    #ifndef LOCAL
        fastIO;
    #endif
    memset(habilidadesActuales,0,sizeof(habilidadesActuales));
    cin >> n >> m >> x;
    for(int i=0;i<n;i++){
        cin >> valor[i];
        for(int j=0;j<m;j++){
            cin >> libros[i][j];
        }
    }
    habilidades(0,0);
    if(valorMinimo==10000000) cout << -1 << endl;
    else cout << valorMinimo << endl;
    return 0;
}


Measured memory_bytes: 3668
#include <stdio.h>

max (a, b) {
	if (a < b) return b; else return a;
}

main() {
	char chars[] = {'A', 'C', 'G', 'T'};
	int c, maximumCnt, cnt, i, found;

	cnt = 0;
	maximumCnt = 0;

	while ( (c = getchar()) != -1 ) {
		found = 0;
		for ( i = 0; i < sizeof(chars) / sizeof(char); ++i ) {
			if ( chars[i] == c ) {
				found ++;
				break;
			}
		}
		if (!found) {
			maximumCnt = max(maximumCnt, cnt);
			cnt = 0;
		} else {
			cnt ++;
		}
	}

	printf("%d\n", maximumCnt);
}




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

const int inf = 1e9;

int main()
{
    int n; cin >> n;
    vector<int> b(n+1); b[0] = inf; b[n] = inf;
    for (int i = 1; i < n; i++) cin >> b[i];
    
    int ans = 0;
    for (int i = 0; i < n; i++) ans += min(b[i], b[i+1]);

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define PI          acos(-1)
#define INF         100000000
#define sc(n)       scanf("%d",&n);
#define ssc(n)      scanf("%s",n);
#define lsc(n)      scanf("%lld",&n);
#define dsc(n)      scanf("%lf",&n);
#define csc(n)       scanf("%c",&n);
#define LL          long long int
#define UI          unsigned int
#define ULL         unsigned long long int
#define DB          double
#define pii         pair<int,int>
#define VI          vector<int>
#define MII         map<int,int>
#define PB          push_back
#define MP          make_pair
#define M(mx,a)     mx=max(mx,a)
#define IT          ::iterator
#define all(a)      a.begin(),a.end()
#define mems(a,b)   memset(a,b,sizeof(a))
#define F(i,a,b)    for(i=a;i<b;i++)
#define IN(n,aa)    for(i=0;i<n;i++)scanf("%d",&aa[i]);
#define PNT(n,aa)   for(i=0;i<n;i++)printf("%lld ",aa[i]);
#define mod         1000000007
#define NUM         10000009
#define NUM2        1000000000


int main()
{
    int T=1,QQ=0;
    //cin >> T ;
    while(T--)
    {
        int n;
        cin >> n;
        n++;
        int i,j,k;
        LL sm=0,smm=0;
        int aa[n],bb[n],aaa[n],bbb[n];
        for(i=0;i<n;i++)
        {
            sc(aa[i]);
            aaa[n-i-1]=aa[i];
        }
        for(i=0;i<n-1;i++)
        {
            sc(bb[i]);
            bbb[n-i-2]=bb[i];
        }
        for(i=0;i<n-1;i++)
        {
            if(bb[i]<aa[i])sm+=bb[i];
            else
            {
                sm+=aa[i];
                bb[i]-=aa[i];
                if(bb[i]>aa[i+1])sm+=aa[i+1],aa[i+1]=0;
                else sm+=bb[i],aa[i+1]-=bb[i];
            }
        }
        for(i=0;i<n-1;i++)
        {
            if(bbb[i]<aaa[i])smm+=bbb[i];
            else
            {
                smm+=aaa[i];
                bbb[i]-=aaa[i];
                if(bbb[i]>aaa[i+1])smm+=aaa[i+1],aaa[i+1]=0;
                else smm+=bbb[i],aaa[i+1]-=bbb[i];
            }
        }
        cout << max(sm,smm) ;
    }
}

//printf("Case %d: ",++QQ);


Measured memory_bytes: 5192
# coding: utf-8
len = int(input())
a = list(map(int, input().split()))
#print(a)
 
def main():
    flag = "TRUE"
    count = 0
    while flag == "TRUE":
        for i in range(0,len):
            if a[i] % 2 == 0:
                a[i] = a[i]/2
                #print(flag)
            else:
                flag = "FALSE"
 
        if flag == "TRUE":
            count = count + 1
        else:
            #print(a)
            print(count)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<P> A(n);
  ll aoki_sum = 0;
  ll takahashi_sum = 0;
  rep(i, n){
    int a, b;
    cin >> a >> b;
    aoki_sum += b;
    A[i] = {a, b};
  }
  sort(A.begin(), A.end(), [](P x, P y) {
    return (x.first + x.second) >  (y.first+ y.second);
  });
  rep(i, n){
    if(i % 2 == 0)takahashi_sum += A[i].first + A[i].second;
  }
  cout << takahashi_sum - aoki_sum << endl;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            bool flag = true;
            int cnt = 0;

            while (flag)
            {
                flag = false;

                for(int i = n - 1; i > 0; i--)
                {
                    if(A[i] < A[i - 1])
                    {
                        int temp = A[i];
                        A[i] = A[i - 1];
                        A[i - 1] = temp;

                        flag = true;
                        cnt++;
                    }
                }
            }

            Console.WriteLine(string.Join(" ", Array.ConvertAll(A, a => a.ToString())));
            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define mod        1000000007
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define inf        1e18
#define ps(x,y)    fixed<<setprecision(y)<<x

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

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

	ll x1 = n % b;
	ll x2 = n - x1 - 1;

	ll ans = (a * n) / b - (a * (n / b));
	ll ans2 = INT_MIN;
	if (x2 > 0)
		ans2 = (a * x2) / b - (a * (x2 / b));

	ans = max(ans, ans2);
	cout << ans;






}

Measured memory_bytes: 3600
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
long long dp[N];

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

	int n, W;
	cin >> n >> W;
	memset(dp, 63, sizeof dp);
	for (int i = dp[0] = 0; i < n; i++) {
		int w, v;
		cin >> w >> v;
		for (int j = N - 1; j >= v; j--)
			dp[j] = min(dp[j], dp[j - v] + w);
	}

	int ans = 0;
	for (int i = 0; i < N; i++)
		if (dp[i] <= W)
			ans = i;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
n,m,x = map(int,input().split())
c = [[int(i) for i in input().split()] for _ in range(n)]
ans = float("inf")
for i in range(1<<n):
    cnt = [0]*m
    cost = 0
    for j in range(n):
        if i >> j & 1:
            cost += c[j][0]
            for k in range(1,m+1):
                cnt[k-1] += c[j][k]
    for j in range(m):
        if cnt[j] < x: break
    else:
        ans = min(cost,ans)
print(ans if ans != float("inf") else -1)
            


Measured memory_bytes: 9236
F =-> {gets.split.map &:to_i}
N,M = F[]
A = (0..N).map {[]}
A[0] = 1
M.times {
  a,b = F[]
  A[a] << b
  A[b] << a
}
1.upto(N) {|i|
  next  if (a=A[i]).frozen?
  A[i] = i
  while j = a.pop
    next  if (b=A[j]).frozen?
    a.concat b
    A[j] = i
  end
}
p A.tally.size-1

Measured memory_bytes: 25732
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
"""
すべてのjで割れない場合、カウントする。
逆に言えば、一つでもiをjで割れるようなjが存在するならば、それはカウントしない。
一番小さい数が2つあればそれはカウントしないが、基本的に一番小さい数はほかのどの数字でも割れない
Aiの制約が10**6であることから、小さい数から数えていって、10**6までの倍数の場所にマークを付ける。
初めて出てくるような数字に関して、カウントを1足してやる。
一番小さい数のコーナーケースに注意
"""
n = int(readline())
lst1 = list(map(int,readline().split()))

lst1.sort()

memo = [0]*(10**6+1)
if n == 1:
    print(1)
    exit()

ans = 0
for i in range(n):
    if memo[lst1[i]] == 0:
        if i < n-1:
            if lst1[i] != lst1[i+1]:
                ans += 1
        elif i == n-1:
            ans += 1
        j = 1
        while lst1[i]*j <= 10**6:
            memo[lst1[i]*j] = 1
            j += 1

print(ans)


Measured memory_bytes: 95164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = pow(10, 9) + 7; //10e9 + 7

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {//https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll gcd(ll a, ll b){//greatest common divider 最大公約数を求める
  if(b==0) return a;
  return gcd(b, a%b);
}

ll Fact(ll n){//Factorial 階乗を求める関数
  ll ans = 1;
  for(ll i=1; i<=n; i++){
    ans *= i;
    ans %= mod;
  }
  return ans; 
}


int main() {
  ll X, Y;
  cin >> X >> Y;
  ll ans = 0;
   if((2*X-Y)%3 != 0 || (2*Y-X)%3 != 0 || (2*X-Y)<0 || (2*Y-X)<0){
        cout << 0 << endl;
        return 0;
    }
  
  ll a, b;
  a = (2*Y-X)/3;
  b = (2*X-Y)/3;
  //cout <<" a: " << a << " b: " << b << endl;
  
  ll ab_kaijo = Fact(a+b) % mod;
  ll a_kaijo = Fact(a) % mod;
  ll b_kaijo = Fact(b) % mod;
  ll a_multi_b_kaijo = (a_kaijo * b_kaijo) % mod;
  //cout << " ab_kaijo: " << ab_kaijo << endl;
  //cout << " a_kaijo: " << a_kaijo << endl;
  //cout << " b_ kaijo: " << b_kaijo << endl;
  //cout << " a_multi_b_kaijo: " << a_multi_b_kaijo <<endl;
  
  //ans = ab_kaijo / a_multi_b_kaijo;//mod使う割り算は逆元を利用しなかん↓↓
  ans = ab_kaijo * modinv(a_multi_b_kaijo, mod);
  
  cout << ans % mod << endl;
}


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

using namespace std;

int X, t;

int main() {
  scanf("%d%d", &X, &t);
  if(X > t) {
    X = X - t;
    printf("%d\n", X);
  } else 
      printf("%d\n", 0);
  return 0;
}

Measured memory_bytes: 256
/*
 * ex 4_3
 * kamecha
 */
#include<stdio.h>

int stone(int x){
    int len = 0;
    for(int i = 1; i <= x; i++)  len += i;
    return len;
}

int main(void){
    int west, east;
    scanf("%d %d", &west, &east);
    int ans = stone(east-west) - east;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System.Text;
 
class DandA {
    static void Main(string[] args) {
        int[] nk = ReadLineIntArray();
        Console.WriteLine(IntToNString(nk[0], nk[1]).Length);
    }
 
    static string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
    static string[] strAry = new string[] {"L", "R", "U", "D"}; 
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private long ReadLineLong() {return long.Parse(Console.ReadLine());}
    static private double ReadLineDouble() {return double.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private double[] ReadLineDoubleArray() {return Console.ReadLine().Trim().Split().Select(a => double.Parse(a)).ToArray();}
    static private decimal[] ReadLineDecimalArray() {return Console.ReadLine().Trim().Split().Select(a => decimal.Parse(a)).ToArray();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}
 
    static private bool IsPrime(int num) {
        if (num < 2) return false;
        if (num == 2) return true;
        else if (num % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) return false;
        }
        return true;
    }
public static string IntToNString(int x, int n)
{
    var nstring = "";
    var numbers = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
    int r = 1;  // 余り
    int q = x;  // 商

    // 商が0になるまでループ
    while (q > 0)
    {
        r = q % n;
        nstring += numbers[r];
        q = q / n;
    }
    return string.Join("",nstring.Reverse());
}
}

Measured memory_bytes: 13396
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;

fn main() {
    let ss: Vec<u8> = read_line().bytes().collect();
    let mut res = 0;
    for &c in &ss {
        match c {
            b'+' => {
                res += 1;
            }
            b'-' => {
                res -= 1;
            }
            _ => {}
        }
    }
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec_i64<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 4352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            String s = in.next();
            int ans = 0;
            for (int i = 0; i < s.length() / 2; i++) {
                if (s.charAt(i) != s.charAt(s.length() - 1 - i)) ans++;
            }
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 23124
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
using namespace std;

void solve(){

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

    int n,k;
    cin >> n >> k;
    map<int,int> q;

    for(int i=0; i<k;i++){
        int d;
        cin >>d;
        for (int j=0;j<d;j++){
            int a;
            cin >> a;

            q[a]=q[a]+1;
        }
    } 
    int cnt;
    cnt=0;
    for (int i=1;i<n+1;i++){
        if(q[i]==0){
            cnt+=1;
        }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3656
using System;

namespace NTL1_B
{

    class Program
    {
        const int mod = 1000000007;

        static void Main(string[] args)
        {
            var t = scan;
            Console.WriteLine(powmod(t[0], t[1], mod));
        }

        static int[] scan { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } }
        static long powmod(long a, long b, long p)
        {
            if (b == 0) return 1;
            if (b % 2 == 0)
            {
                long d = powmod(a, b / 2, p);
                return (d * d) % p;
            }
            else
            {
                return (a * powmod(a, b - 1, p)) % p;
            }
        }
    }
   
}

Measured memory_bytes: 9216
var x = require('fs').readFileSync('/dev/stdin', 'utf8');
input = x.split(/ /);
a = parseInt(input[0]);
b = parseInt(input[1]);
if (a < b) {
  console.log("a < b");
} else if (a > b) {
  console.log("a > b");
} else {
  console.log("a == b");
}



Measured memory_bytes: 15116