akhauriyash/Code-Regression huggingface dataset:
from bisect import bisect_left as bl
INF = 10 ** 10
n = int(input())
alst = [int(input()) for _ in range(n)]
dp = [INF] * (n + 1)
dp[0] = -1
ans = 0
for a in alst:
  ind = bl(dp, a)
  dp[ind] = a
  ans = max(ans, ind)
print(ans)


Measured memory_bytes: 10468
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }

int modpow(int x, int n, int m){
    int a = 1;
    IREP(i, 64){
        a = (a * a) % m;
        if(((n >> i) & 1) == 1) a = (a * x) % m;
    }
    return a;
}

signed main(){

    int N, K; cin >> N >> K;
    int mod = 1000000007;

    if(K == 1){
        if(N == 1) cout << 1 << endl;
        else cout << modpow(2, N - 2, mod) << endl;
        return 0;
    }

    mat dp(K - 1, vec(N, 0));
    FOR(j, 1, N) dp[0][j] = 1;
    REP(i, K - 2){
        //上から取る
        FOR(j, 1, N){
            if(j >= N - 1 - i) continue;
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= mod;
        }
        //下から取る
        IFOR(j, 2, N){
            dp[i][j - 1] += dp[i][j];
            dp[i][j - 1] %= mod;
        }
        FOR(j, 1, N){
            if(j >= N - 1 - i) continue;
            dp[i + 1][j] += dp[i][j + 1];
            dp[i + 1][j] %= mod;
        }
    }
    int ans = 0;
    FOR(j, 1, N){
        ans += dp[K - 2][j];
        ans %= mod;
    }
    if(K < N){
        ans *= modpow(2, N - K - 1, mod);
        ans %= mod;
    }
    //debug(dp);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 31616
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <fstream>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};
typedef vector<vector<Edge>> Graph;

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

ll factorial(ll n) {//階乗
	ll ret = 1;
	rep(i, 1, n + 1)
		ret = (ret *i) % MODU;

	return ret;
}

ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x %mod;
		x = x * x%mod;
		n >>= 1;
	}
	return res;
}
ll divmod(ll a, ll b, ll m) { // a/b(mod m)
								  // a/b (mod m)
								  // a*b^-1
								  // b^-1 * b = 1
								  // b^(m-1) = 1 
								  // b^(m-2) * b = 1
								  // b^-1 = b^(m-2)

								  // a/b = a * b^(m-2)

	return (a * 1LL * mod_pow(b, m - 2, m)) % m;
}
ll ncr(ll n, ll r) {
	return divmod(factorial(n), (factorial(r) * (factorial(n - r))) % MODU, MODU);
}

int n;
string base;
bool quest(int from) { //True:base
	printf("?");
	REP(i, n) {
		printf(" %d", (from+ i) % (2*n) + 1);
	}
	cout << endl;
	string str;
	cin >> str;
	return str == base;
}

bool quest(int from, int ad) { //True:base
	printf("?");
	REP(i, n - 1) {
		printf(" %d", (from + i) % (2 * n) + 1);
	}
	printf(" %d", ad + 1);
	
	cout << endl;
	string str;
	cin >> str;
	return str == base;
}

signed main() {
	int m;
	cin >> m;
	ll ans = 0;
	ll keta = 0;
	REP(i, m) {
		ll d, c;
		cin >> d >> c;
		ans += c;
		keta += d * c;
	}
	cout << ans -1+ (keta - 1) / 9 << endl;
	return 0;
}


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

int main() {
  int N; cin >> N;
  int ans[100000];
  
  for(int i = 1; i*i< N; i++){
    for(int j = 1; j*j < N;j++){
      for(int k = 1; k*k < N;k++){
        int total = i*i+j*j+k*k+j*k+j*i+i*k;
        ans[total]++;
      }
    }    
  }
  for(int i = 1; i <= N; i++){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

ll power(ll x, ll y)
{
	ll ans = 1;
	while (y>0) {
		if (y&1) {
			ans *= x;
		}
		y /= 2;
		x *= x;
	}
	return ans;
}

void solve()
{
	ll n,m,x;
	cin>>n>>m>>x;
	vector<vector<ll>> a(n, vector<ll>(m+1));
	for (int i=0; i<n; i++) {
		for (int j=0; j<=m; j++) {
			cin>>a[i][j];
		}
	}
	ll stop = power(2,n);
	ll ans = INT_MAX;
	bool found = false;
	for (ll i=0; i<stop; i++) {
		ll sum = 0;
		ll temp = i;
		vector<ll> level(m+1);
		for (int j=0; j<n; j++) {
			if (temp&1) {
				sum += a[j][0];
				for (int k=1; k<=m; k++) {
					level[k] += a[j][k];
				}
			}
			temp >>= 1;
		}
		bool ok = true;
		for (int j=1; j<=m; j++) {
			if (level[j] < x) {
				ok = false;
				break;
			}
		}
		if (ok) {
			found = true;
			ans = min(ans, sum);
		}
	}
	if (found) {
		cout << ans << "\n";
	}
	else {
		cout << "-1\n";
	}
}

int main()
{
	fastIO;
	int t=1;
	// cin>>t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3572
#include<stdio.h>
int main()
{
   char ch;
   scanf("%c",&ch);
   if(ch=='a' || ch=='e' ||ch=='o' || ch=='i' || ch=='u')
   {
       printf("vowel\n");
   }
   else
   {
       printf("consonant\n");
   }
   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    stack<int> m_stack;
    int ans1, ans2;
    getline(cin, str);
    for (int i = 0; i < str.size(); ++i)
    {
        if (str[i] >= '0' && str[i] <= '9')
        {
            int j, tmp(0);
            for (j = 0; str[i + j] >= '0' && str[i + j] <= '9'; ++j)
                ;
            for (int k = 0; k < j; ++k)
                tmp += (str[i + k] - '0') * pow(10, j - k - 1);
            m_stack.push(tmp);
            i += (j - 1);
        }
        if (str[i] == '+' || str[i] == '-' || str[i] == '*')
        {
            ans1 = m_stack.top();
            m_stack.pop();
            ans2 = m_stack.top();
            m_stack.pop();
            if (str[i] == '+')
                m_stack.push(ans1 + ans2);
            if (str[i] == '-')
                m_stack.push(ans2 - ans1);
            if (str[i] == '*')
                m_stack.push(ans1 * ans2);
        }
    }
    cout << m_stack.top() << endl;
}


Measured memory_bytes: 3368
#include <stdio.h>
#define sz 300000
int main()
{
    long long int n,i,x;
    int a[sz];

    scanf("%lld",&n);

    for( i=1 ; i<n ; i++ )
    {
        scanf("%lld",&x);
        a[x-1]++;
    }
    for( i=0 ; i<n ; i++ )
        printf("%d\n",a[i]);
    return 0;
}



Measured memory_bytes: 2516
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    int N;
    ll Y;
    cin >> N >> Y;
    for(int x = 0; x <= N; x++){
        for(int y = 0; y <= N; y++){
            int z = N-x-y;
            if (z < 0) continue;
            if(10000*x+5000*y+1000*z == Y){
                cout << x << " " << y << " " << z;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace My_Math{
	#define N 100000

	int fac[N+100],invfac[N+100];

	int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
	int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
	int mul(int x,int y) {return 1ll*x*y%maxd;}
	ll qpow(ll x,int y)
	{
		ll ans=1;
		while (y)
		{
			if (y&1) ans=mul(ans,x);
			x=mul(x,x);y>>=1;
		}
		return ans;
	}
	int inv(int x) {return qpow(x,maxd-2);}

	int C(int n,int m)
	{
		if ((n<m) || (n<0) || (m<0)) return 0;
		return mul(mul(fac[n],invfac[m]),invfac[n-m]);
	}

	int math_init()
	{
		fac[0]=invfac[0]=1;
		rep(i,1,N) fac[i]=mul(fac[i-1],i);
		invfac[N]=inv(fac[N]);
		per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
	}
	#undef N
}
using namespace My_Math;

int n1,n2,m,a[100100],b[100100];

int main()
{
	n1=read();n2=read();m=read();
	int mn1,mn2;mn1=mn2=maxd;
	rep(i,1,n1) {a[i]=read();mn1=min(mn1,a[i]);}
	rep(i,1,n2) {b[i]=read();mn2=min(mn2,b[i]);}
	int ans=mn1+mn2;
	rep(i,1,m)
	{
		int x=read(),y=read(),c=read();
		ans=min(ans,a[x]+b[y]-c);
	}
	printf("%d",ans);
	return 0;
}



Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))

waru=10**9+7

kakunin=[0]*n
kigu=n%2
for i in range(n):
    if kigu==a[i]%2:
        print(0)
        quit()
    kakunin[a[i]]+=1

for i in range(n):
    # if i==0 and kakunin[0]==1 and kigu==1:
    #     continue
    # if kigu!=i%2 and kakunin[i]!=2:
    #     print(0)
    #     quit()
    if kigu==0 and i%2==1:
        if kakunin[i]!=2:
            print(0)
            quit()
    if kigu==1 and i%2==0:
        if i==0 and kakunin[i]!=1:
            print(0)
            quit()
        elif i!=0 and kakunin[i]!=2:
            print(0)
            quit()

print((2**(n//2))%waru)


Measured memory_bytes: 52844
import numpy as np
from sys import stdin
N,M=[int(x) for x in stdin.readline().rstrip().split()]
a=[]
for i in range(N):
    a.append([int(x) for x in stdin.readline().rstrip().split()])

res=set(list(range(1,M+1)))
for data in a:
  
  res=res&set(data[1:])
print(len(res))

Measured memory_bytes: 21288
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	foreach (line; stdin.byLine) {
		auto p = line.map!(a=>a.to!int-'0').array;
		foreach (i; 0..10) {
			foreach (j; 0..9-i) {
				p[j] = p[j] + p[j+1];
			}
		}
		writeln(p[0]%10);
	}
}

Measured memory_bytes: 1040
#define __GLIBCXX_DEBUG

#include <iostream>
#include <iomanip>
#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 <random>
#include <queue>
#include <bitset>

#define pb push_back
#define int long long
#define dbl long double
#define str string
using namespace std;
const int M = 998244353;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    int ans = 0;
    for (int x = 1; x <= n; x++) {
        if (x % 3 && x % 5) ans += x;
    }
    cout << ans;
}

Measured memory_bytes: 3636
def resolve():
    n = int(input())
    x = [int(i) for i in input().split()]
    y = [int(i) for i in input().split()]
    D1 = 0
    D2 = 0
    D3 = 0
    D4 = 0
    for i in range(n):
        D1 += abs(x[i] - y[i])
        D2 += (x[i] - y[i])**2
        D3 += abs(x[i] - y[i])**3
        D4 = max(D4, abs(x[i] - y[i]))
    D2 = D2**(1 / 2)
    D3 = D3**(1 / 3)
    print(D1 / 1)
    print(D2 / 1)
    print(D3 / 1)
    print(D4 / 1)


resolve()



Measured memory_bytes: 5648
import math

op = ""
while True:
    s = input().split()

    a = int(s[0])
    op = s[1]
    b = int(s[2])

    ans = ""
    if op == "?":
        break
    elif op == "+":
        ans = a + b
    elif op == "-":
        ans = a - b
    elif op == "*":
        ans = a * b
    elif op == "/":
        ans = math.floor(a / b)

    print(ans)



Measured memory_bytes: 5660
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"
#define MOD 1000000007

typedef long long int  ll;


int main()
{
	FAST;
	int n;
	cin >> n;

	ll ans = 1;
	for(int i=2 ; i<=n ; i++)
	{
		ans = ( (ans)%MOD * (i)%MOD)%MOD;
	}
	cout << ans;
	return 0;
}

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

using namespace std;

int main()
{ ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0) ;
   long long a, b ;
   cin >> a >> b;
   cout<<(a*b) /__gcd(a,b);
    return 0;
}


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

using namespace std;

class Mo {
public:

    const int mod = (int) 1e9 + 7;
    
    inline int add(int a, int b) const {
        a += b;
        return a < mod ? a : a - mod; 
    }
    
    inline int sub(int a, int b) const {
        a -= b;
        return a < 0 ? a + mod : a;
    }
    
    inline int mul(long long a, long long b) const {
        a *= b;
        return a < mod ? a : a - a / mod * mod;
    }
    
    inline int pow_mod(long long a, long long b) const {
        long long res = 1;
        res %= mod;
        while (b) {
            if (b & 1) {
                res = mul(res, a);
            }
            a = mul(a, a);
            b >>= 1;
        }
        return res;
    }
    
    inline int inv(int a) const {
        return pow_mod(a, mod - 2);
    }
    
    vector<int> fact, finv;
    void init_comb_1(int n = 1000000) {
        fact.resize(n + 5);
        finv.resize(n + 5);
        fact[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = mul(fact[i - 1], i);
        }
        finv[n] = inv(fact[n]);
        for (int i = n - 1; i >= 0; i--) {
            finv[i] = mul(finv[i + 1], i + 1);
        }
    }
    
    ////  M
    //
    ////  N
    inline int C1(int n, int m) {
        if (n < m) return 0;
        return mul(mul(fact[n], finv[m]), finv[n - m]);
    }
    
    inline int C2(int n, int m) {
        if (n < m) return 0;
        if (m > n - m) {
            m = n - m;
        }
        int a = 1, b = 1;
        for (int i = 1; i <= m; i++) {
            a = mul(a, n - i + 1);
            b = mul(b, i);
        }
        return mul(a, inv(b));
    }
} mo;

int main() {
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);// don't forget &
    int ans = mo.pow_mod(2, n);
    ans = mo.sub(ans, mo.C2(n, a));
    ans = mo.sub(ans, mo.C2(n, b));
    ans = mo.sub(ans, 1);
    printf("%d", ans);
    
    return 0;
}


Measured memory_bytes: 256
#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 fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
int i,j,d[50],p,n,q,a[5]={5,7,5,7,7};
char s[15];
main(){
	for(n=1;n;){
		scanf("%d\n",&n);
		for(i=0;i<n;i++)d[i]=strlen(gets(s));
		for(i=0;n;i++){
			p=i;
			for(j=0;j<5;j++){
				q=a[j];
				while(q>0){
					q-=d[p];p++;
				}
				if(q<0)break;
			}
			if(j>4){
				printf("%d\n",i+1);
				break;
			}
		}
	}
}

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

using namespace std;
#define ll long long

ll INF = 1e9 + 7;
const int N = 30;


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

    ll n,x,k;
    cin>>n>>x>>k;

    cout<<(( n + x - 1)/x) * k<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int n, ans=0, p=0;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h.at(i);
  rep(i,n) {
    if(p < h.at(i)) {
      ans += h.at(i) - p;
      p = h.at(i);
    } 
    else 
      p = h.at(i);
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>

bool eligible(int n, int a, int b) {
  int sum = 0;
  while (n) {
    sum += n % 10;
    n /= 10;
  }
  return a <= sum && sum <= b;
}

int main() {
  int n, a, b;
  std::cin >> n >> a >> b;
  int sum = 0;
  for (int i = 1; i <= n; ++i) {
    if (eligible(i, a, b)) {
      sum += i;
    }
  }
  std::cout << sum << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;



int main(){
    vector<string> S(3);
    cin >> S[0] >> S[1] >> S[2];
    string ans = "ABC";
    int turn = 0;
    while (1){
        if (S[turn].empty()){
            cout << ans[turn] << endl;
            return 0;
        }
        int next = S[turn][0]-'a';
        S[turn].erase(S[turn].begin());
        turn = next;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	ll a, b, c, d; cin >> a >> b >> c >> d; a--;
	ll ans = b - a, g = c * d / __gcd(c, d);
	ans -= b / c - a / c;
	ans -= b / d - a / d;
	ans += b / g - a / g;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
// #define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define repp(i,n,s) for (int i= (int)(n); i >= (int)(s); i--)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;

template <typename T>
struct RMQ {
    const T INF = numeric_limits<T>::max();
    int n;         // 葉の数
    vector<T> dat; // 完全二分木の配列
    RMQ(int n_) : n(), dat(n_ * 4, INF) { // 葉の数は 2^x の形
        int x = 1;
        while (n_ > x) {
            x *= 2;
        }
        n = x;
    }
 
    void update(int i, T x) {
        i += n - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;  // parent
            dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }
 
    // the minimum element of [a,b)
    T query(int a, int b) { return query_sub(a, b, 0, 0, n); }
    T query_sub(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return INF;
        } else if (a <= l && r <= b) {
            return dat[k];
        } else {
            T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
};


int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,q;cin>>n>>q;
    RMQ<ll> x(n);
    rep(i,0,n){
        x.update(i,pow(2,31)-1);
    }
    rep(i,0,q){
        ll a,b,c;cin>>a>>b>>c;
        if (a==0){
            x.update(b,c);
        }else{
            cout<<x.query(b,c+1)<<endl;
        }

    }
}


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

using namespace std;

#define rep(i, a) for (int (i) = 0; (i) < (a); (i)++)
#define reps(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define MP(a, b) make_pair((a), (b))
#define pb(a) push_back((a))

int main()
{
	int r;
	cin >> r;
	string s;
	if (r < 1200) s = "ABC";
	else if (r < 2800) s = "ARC";
	else s = "AGC";
	cout << s << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int N;
    int d[100] = {0},tmp;
    int i,j,cnt;

    scanf("%d",&N);

    for(i = 0;i < N;i++){
       scanf("%d",&d[i]);
    }

    for(i = 0;i < N;i++){
        for(j = i+1;j < N;j++){
            if(d[i] > d[j]){
                tmp = d[i];
                d[i] = d[j];
                d[j] = tmp;
            }
        }
    }

    cnt = 0;
    for (i = 0; i < N - 1; i++) {
        if (d[i] != d[i + 1]) {
          cnt++;
        }
    }

    printf("%d",cnt+1);

    return 0;
}

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

h,w=map(int,input().split())
G=[]
for i in range(h):
    S=input()
    g=[]
    cnt=0
    for s in S:
        if s==".":
            cnt+=1
        else:
            if cnt==0:
                g.append(0)
            else:
                for j in range(cnt):
                    g.append(cnt)
                g.append(0)
                cnt=0
    if cnt>0:
        for j in range(cnt):
            g.append(cnt)
    G.append(g)

ans=0
for i in range(w):
    cnt=0 #壁じゃないマスの個数
    m=0 #最大値
    for j in range(h):
        g=G[j][i] #現在のマス(縦に見る)
        if g==0:
            if cnt!=0:
                ans=max(m+cnt-1,ans)
                cnt=0
                m=0
        else:
            cnt+=1
            m=max(g,m)
    if cnt>0:
        ans=max(m+cnt-1,ans)

print(ans)

Measured memory_bytes: 79068
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define method(name,res,...) function<res (__VA_ARGS__) > name = [&](__VA_ARGS__) -> res
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){

  int N = 1e6+10;
  vector<int> prime(N,true);
  prime[0]=prime[1]=false;
  rep(i,2,N){
    if(prime[i]){
      for(int j=i*2;j<N;j+=i){
        prime[j] = false;
      }
    }
  }

  int a,b,c;
  while(cin>>a>>b>>c&&a){
    while(true){
      if(prime[a]){
        if(--c==0)break;
      }
      a += b;
    }
    cout << a << endl;
  }

  return 0;
}



Measured memory_bytes: 6528
#define  _CRT_SECURE_NO_WARNiINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <cassert>
#include <set>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define cycle_per_sec 2806192512
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int geko = 0;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] == 'E') geko++;
	}
	int ans = 1000000;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] == 'E') geko--;
		ans = min(ans, geko);
		if (s[i] == 'W') geko++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >> S;
    if(S == "Sunny")
        cout << "Cloudy" << endl;
    else if (S == "Cloudy")
        cout << "Rainy" << endl;
    else if (S == "Rainy")
        cout << "Sunny" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

int main()
{
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int n; cin >> n;
    int ans = 3 * n * n;
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int a = Integer.parseInt(s.substring(0, 4));
        int b = Integer.parseInt(s.substring(5, 7));
        int c = Integer.parseInt(s.substring(8, 10));

        String ans = "";
        if (a*10000 + b*100 + c <= 20190430) ans = "Heisei";
        else ans = "TBD";

        System.out.println(ans);

        in.close();
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
using namespace std;
int main(){

  int r;
  cin>>r;
  cout<<3*r*r;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int *p = (int *)malloc(sizeof(int)*n+1);
  p[n] = 0;
  int *q = (int *)malloc(sizeof(int)*n+1);
  q[n] = 0;
  for(int i=0; i<n; i++){
    cin >> p[i];
    q[i] = 0;
  }
  for(int i=1; i<n-1; i++){
    int p1 = p[i-1];
    int p2 = p[i];
    int p3 = p[i+1];
    if(p1 > p2 && p2 > p3) q[i] = 1;
    if(p3 > p2 && p2 > p1) q[i] = 1;
  }
  int flag = 1;
  char spc = ' ';
  int count = 0;
  for(int i=0; i<n; i++){
    if(q[i] == 1) count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
XL=[list(map(int,input().split())) for i in range(N)]

R=[]
for i in range(N):
    a=max(0,XL[i][0]-XL[i][1])
    b=XL[i][1]+XL[i][0]
    R.append([b,a])
R.sort()

ans=0
con_l=0
for i in range(N):
    if con_l <= R[i][1]:
        ans += 1
        con_l = R[i][0]
print(ans)

Measured memory_bytes: 42488
#include <iostream>
#include <math.h>
#include <vector>
#include <cstdlib>
 
using namespace std;
 
int main(int argc, const char * argv[]) {
  int N;
  int sum = 0;
 
  cin >> N;
  int A[N];
  int B[N];
  int C[N];
 
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  for (int i = 0; i < N-1; i++) {
    cin >> C[i];
  }
 
  for (int i = 0; i < N; i++) {
    sum += B[A[i]-1];
    if (i > 0 && ((A[i] - 1) == A[i - 1])) {
      sum += C[A[i-1]-1];
    }
  }
 
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << (X - Z) / (Y + Z) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef unsigned long long u64;
const u32 P=998244353;
u32 f[3001][3001], g[3001][3001];
int main() {
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	f[a][b]=g[a][b]=1;
	for(int i=b+1; i<=d; ++i) f[a][i]=1llu*f[a][i-1]*a%P;
	for(int i=a+1; i<=c; ++i) g[i][b]=1llu*g[i-1][b]*b%P;
	g[a][b]=0;
	for(int i=a+1; i<=c; ++i) {
		for(int j=b+1; j<=d; ++j) {
			f[i][j]=(1llu*i*(f[i][j-1]+g[i][j-1]))%P;
			g[i][j]=(1llu*j*g[i-1][j]+f[i-1][j])%P;
		}
	}
	printf("%u\n", (f[c][d]+g[c][d])%P);
	return 0;
}

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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  int A,B;
  cin >> A >> B;
  if(A+B >= 10) cout << "error" <<endl;
  else cout << A+B << endl;
 }

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

int main(){
    int n,x;
    while(1){
    cin >>n>>x;
    if (n==0&&x==0)break;
    int ans =0;
    for (int a=1;a<=n;a++)
       for (int b =a+1;b<= n;b++)
          for (int  c = b+1;c<=n;c++){
             if (a+b+c !=x) continue;
             ans++;
           }
        cout <<ans<<endl;
      }
           return 0;
      }


Measured memory_bytes: 3020
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

ll dp[305][305];

int main()
{
    while(true){
        ll n;
        cin >> n;
        if(n==0) break;
        vector<ll> w(n);
        rep(i,n) cin >> w[i];
        rep(i,305){
            rep(j,305){
                dp[i][j]=0;
            }
        }
        for(ll W=2;W<=n;W++){
            rep(l,n){
                ll r=l+W;
                if(r>n) continue;
                if(dp[l+1][r-1]==W-2 && abs(w[l]-w[r-1])<=1){
                    dp[l][r]=W;
                }
                for(ll mid=l;mid<=r;mid++){
                    dp[l][r]=max(dp[l][mid]+dp[mid][r],dp[l][r]);
                }
            }
        }
        cout << dp[0][n] << endl;
    }
    return 0;
} 


Measured memory_bytes: 3820
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;


void sub_main(istream &is) {
    ll N;
    is >> N;
    if(!is) return;
    map<string, int> count;
    for (int i = 0; i < N; ++i) {
        string s;
        is >> s;
        sort(ALL(s));
        count[s]++;
    } // end i
    ll ans = 0;
    for (auto &&x : count) {
        ll t = x.second;
        ans += t * (t-1)/2;
    } // end x
    cout << ans << endl;

}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_C.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n; cin >> n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin >> a[i];
    sort(ALL(a));
    vector<bool> f(a[n-1]+1,true);

    ll ans = 0;
    for(ll i=0;i<n;i++){
        if(!f[a[i]]) continue;
        if(f[a[i]]  and  a[i] != a[i+1]) ans++;
        for(ll j=1;a[i]*j<=a[n-1];j++) f[a[i]*j] = false;
    }

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



Measured memory_bytes: 5104
#include<iostream>
using namespace std;
const int N = 2000;
int main(){
    int n,m,c;
    int B[N];
    while(cin>>n>>m>>c){
        for(int i = 0;i<m;i++){
            cin>>B[i];
        }
        int ans = 0;
        while(n--){
            int tmp = c;
            for(int i = 0;i<m;i++){
                int a; cin>>a;
                tmp += a*B[i];
            }
            if(tmp > 0)ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
x = 0
m = [0,]

for i in range(len(s)):
    if s[i] == 'I':
        x += 1
        m.append(x)
    elif s[i] == 'D':
        x -= 1
        m.append(x)
else:
    print(max(m))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
const int inf =1e9;
char s[maxn];
int cnt[3000];
int p[maxn];

int main(){
    cin>>s+1;
    int n=strlen(s+1);

    p[0]=1;
    for(int i=1;i<=n;i++)p[i]=p[i-1]*10%2019;


    int tmp=0;

    cnt[0]=1;
    for(int i=1;i<=n;i++){
        tmp*=10;
        tmp+=s[i]-'0';
        tmp%=2019;
        cnt[tmp*p[n-i]%2019]++;
    }

    ll ans=0;
    for(int i=0;i<2019;i++){
        if(cnt[i]){
        ans+=1ll*cnt[i]*(cnt[i]-1)/2;
        }
    }

    cout<<ans<<endl;

    return 0;
}



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

int64_t mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N, M, ans = 0;
    cin >> N >> M;
    vector<vector<bool>> list(N, vector<bool>(M));
    for (int i = 0; i < N; i++)
    {
        int x, y;
        cin >> x;
        for (int j = 0; j < x; j++)
        {
            cin >> y;
            y--;
            list[i][y] = true;
        }
    }
    for (int i = 0; i < M; i++)
    {
        bool z = true;
        for (int j = 0; j < N; j++)
        {
            if (list[j][i] == false)
                z = false;
        }
        if(z)
            ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
int main(){
    int a,b,sum=0,ans,area[10000];
    string s;
    char str[100000];
    stack<int> S1;
    stack<int> S2;
    stack<int> S3;
    cin>>s;
    int n=s.size();
    s.copy(str,n);
    for(int i=0;i<n;i++){
        if(str[i]== '/'){
            if(S1.size()!=0){
                a=S1.top();
                S1.pop();
                ans=i-a;
                sum=sum+ans;
                if(S2.size()==0){
                    S2.push(a);
                    S3.push(ans);
                }
                else{
                    if(S2.top()>a){
                        while(1){
                            if(S2.size()==0 || S2.top()<a){
                                break;
                            }
                            S2.pop();
                            b=S3.top();
                            ans=ans+b;
                            S3.pop();
                        }
                        S2.push(a);
                        S3.push(ans);
                        
                    }
                    else{
                    S2.push(a);
                    S3.push(ans);
                    }
                }
            }
        }
        else if(str[i]=='_'){
        }
        else{
            S1.push(i);
        }
    }

    int c=S2.size();
    cout<<sum<<endl<<c;
    for(int i=0;i<c;i++){
            area[i]=S3.top();
            S3.pop();
    }
    for(int i=c-1;i>=0;i--){
        cout<<" "<<area[i];
    }
    cout<<endl;
    return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  ll x;
  cin >> x;

  ll tot = 100;
  int y = 0;
  while (tot < x) {
    tot = (tot*ld(1.01));
    ++y;
  }

  cout << y << '\n';
}

Measured memory_bytes: 3652
H,W = map(int,input().split())
S = list()
for i in range(H):
	S.append(list(input()))
ans = list()

for i in range(len(S)):
	row = list()
	for j in range(len(S[i])):
		if S[i][j] == '#': # 爆弾だったら#を出力
			row.append('#')
			continue # この後のfor文内の処理をスキップ
		count = 0
		check_list =[[i-1,j-1],[i-1,j],[i-1,j+1],[i,j-1],[i,j+1],[i+1,j-1],[i+1,j],[i+1,j+1]]
		for c in range(len(check_list)):
			if check_list[c][0] >= 0 and check_list[c][0] < len(S) and check_list[c][1] >= 0 and check_list[c][1] < len(S[i]):
				if S[check_list[c][0]][check_list[c][1]] == '#':
					count += 1
		row.append(str(count))
	print(''.join(row))

Measured memory_bytes: 3064
N,K = map(int, input().split())
LRs = []
P = 998244353
for _ in range(K):
  l,r = map(int, input().split())
  LRs.append((l,r))
  
memo = [0]*(N+2)
memo[1] = 1
memo[2] = -1
rlt = [0]*(N+2)
rlt[1] = 1


for i in range(1,N+1):
  for t in LRs:
    l = min(t[0]+i,N+1)
    r = min(t[1]+i+1,N+1)
    memo[l] = memo[l]+rlt[i]
    memo[r] = memo[r]-rlt[i]
  rlt[i+1] = (rlt[i]+memo[i+1])%P
  
print(rlt[N])

Measured memory_bytes: 85944
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	int n, p, odd = 0, even = 0;
	cin >> n >> p;
	rep(i, n) {
		int a;
		cin >> a;
		if (a % 2 == 0) {
			even++;
		}
		else {
			odd++;
		}
	}
	if (odd == 0) {
		if (p == 0) {
			cout << (ll)pow(2, n) << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	else {
		cout << (ll)pow(2, n - 1) << endl;
	}
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000009
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	K := nextInt()
	N := nextInt()
	An := make([]int, N)
	for i, _ := range An {
		An[i] = nextInt()
	}
	ans := K - (An[0] + (K - An[N-1]))
	for i := 1; i < N-1; i++ {
		// fmt.Println(ans, K-(An[i]-An[i-1]), K-(An[i+1]-An[i]))
		ans = MinOf(ans, K-(An[i]-An[i-1]), K-(An[i+1]-An[i]))
	}
	fmt.Println(ans)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}


Measured memory_bytes: 36608