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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//切り上げ除算
long long cutup(long long a,long long b){return (a+b-1)/b;}

//累乗
template<typename t>
constexpr t my_pow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}
#define pow my_pow

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

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin>>s;
    Yes(s[0]=='9'||s[1]=='9');
}

Measured memory_bytes: 3620
x,n=map(int,input().split())
if n==0:
    print(x)
    exit()
p=list(map(int,input().split()))
l=list(range(0,102))
for i in p:
    l.remove(i)
ans=100
min_num=1000
for i in range(len(l)):
    if abs(l[i]-x)<min_num:
        min_num=abs(l[i]-x)
        ans=l[i]
print(ans)

Measured memory_bytes: 9020
I=lambda:map(int,input().split())
N,Q=I()
S=input()
m=[0]
for i in range(N-1):
    m+=[m[-1]+(1 if S[i:i+2]=='AC' else 0)]
#print(m)
for i in range(Q):
    l,r=I()
    print(m[r-1]-m[l-1])

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

struct kata{
    long atk;
    int styl;
    kata(long a,int b){
        atk=a;
        styl=b;
    }
    bool operator<(const kata& b)const{
        if(atk<b.atk)return false;
        else if(atk>b.atk)return true;
        else return styl < b.styl;
    }
};

int main() {
    long n,h;
    std::cin>>n>>h;
    std::vector<kata> katana;
    for (int i = 0; i < n; ++i) {
        long a,b;
        std::cin>>a>>b;
        katana.emplace_back(a,1);
        katana.emplace_back(b,2);
    }
    std::sort(katana.begin(),katana.end());
    long ans=0;
    for(auto i:katana){
        if(i.styl==2){
            h-=i.atk;
            ++ans;
        }
        else {
            ans+=h%i.atk==0?h/i.atk:h/i.atk+1;
            h=0;
        }
        if(h<=0)break;
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 6384
import math
while True:
    x = input()
    a, op, b = x.split(' ')
    a, b = int(a), int(b)
    if op == '?':
        break
    if op == '+':
        ans = a + b
    elif op == '-':
        ans = a - b
    elif op == '*':
        ans = a * b
    elif op == '/':
        ans = a / b
    print(math.floor(ans))



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

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

    int X;
    cin >> X;
    vector<int> f(X + 1, 0);
    for (int w : {100, 101, 102, 103, 104, 105}) {
        for (int v = w; v <= X; v++)
            f[v] = max(f[v], f[v - w] + w);
    }
    cout << (f[X] == X) << '\n';

    return 0;
}

Measured memory_bytes: 640
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <sstream>
#include <regex>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int a, b, k; cin >> a >> b >> k;
	rep(i, k)
	{
		if (i % 2 == 0)
		{
			a /= 2;
			b += a;
		}
		else
		{
			b /= 2;
			a += b;
		}
	}
	cout << a << " " << b << endl;
}

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

int main() {
    string S;
    cin >> S;
    // for (int i = 0; i < S.length(); i += 2) {
    //     if (S[i] == 'L'){
    //         cout << "No" << endl;
    //         exit(1);
    //     }
    // }
    // for (int i = 1; i < S.length(); i += 2) {
    //     if (S[i] == 'R') {
    //         cout << "No" << endl;
    //         exit(1);
    //     }
    // }
    for (int i = 0; i < S.length(); i++) {
        if (i % 2 == 0 && S[i] == 'L') {
            cout << "No" << endl;
            return 0;
        } else if (i % 2 == 1 && S[i] == 'R') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

ll N,M,K,A,B,C,ans=0,cnt=0;
string S,T;
vector<int> P,Q;
vector<pair<int,int>> PP;
bool CAN=true;


int main(){
  cin>>N;
  ll A[N+1];
  RREP(i,N) cin>>A[i];
  
  for(int i=1; i<=N; ++i){
    if(A[i]==0 || i==N){
      if(i==N) cnt+=A[i];
      ans+=cnt/2;
      cnt=0;
    }
    else cnt+=A[i];
  }
  
  cout<<ans<<endl;
}

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

const int mod = 1e9 + 7;

int n, k;
vector<int> d, f;

void add(int &x,int y) {
	x += y;
	if (x >= mod) x -= mod;
}

int pw(int x,int y) {
	int ret = 1;
	while (y) {
		if (y & 1) ret = 1ll * ret * x % mod;
		x = 1ll * x * x % mod;
		y >>= 1;
	}
	return ret;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> k;
	for (int i = 1; i * i <= n; ++i) if (n % i == 0) {
		d.push_back(i);
		if (i < (n / i)) d.push_back(n / i);	
	}
	sort(d.begin(), d.end());
	f.resize(d.size());
	int ans = 0;
	for (int i = 0; i < d.size(); ++i) {
		f[i] = pw(k, (d[i] + 1) >> 1);
		for (int j = 0; j < i; ++j) if (d[i] % d[j] == 0) {
			add(f[i], mod - f[j]);
		} 
		add(ans, 1ll * f[i] * (d[i] & 1 ? d[i] : d[i] >> 1) % mod);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 256
#include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<cstdlib>
    #include<algorithm>
    #include<map>
    #include<cstdlib>
    using namespace std;
    const int M=100010;
int a[M];
long long int n,m,c,d;
int main()
{
  scanf("%d %d",&n,&m);
  c=n*m%2;
  if(c==0)
    cout<<"Even"<<endl;
  else
    cout<<"Odd"<<endl;
}


Measured memory_bytes: 256
N,M = gets.split.map(&:to_i)
Mod = 1000000007
if (N-M).abs > 1
  p 0; exit
end

x = [N,M].min
y = [N,M].max
f = (1..x).reduce(1){ |a,b| (a * b) % Mod }
f = (f * f) % Mod
p (f * (y > x ? y : 2)) % Mod


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

int main () {
    int n;
    std::string s;
    std::cin >> n >> s;

    int dp[n];
    int kp[n];
    dp[0] = (s[0] == 'W') ? 1 : 0;
    kp[0] = (s[n-1] == 'E') ? 1 : 0;
    for (int i = 0; i < n - 1; i++)
    { 
        if(s[i + 1] == 'W') {
            dp[i + 1] = dp[i] + 1;
        } else {
            dp[i + 1] = dp[i];
        }

        if(s[n - 1 - (i+1)] ==  'E' ) {
            kp[i + 1] = kp[i] + 1;
        } else {
            kp[i + 1] = kp[i];
        }

        
    }

    int min = 400000;
    for (int i = 0; i < n; i++) {
        if(min > dp[i] + kp[n-1-i] - 1) {
            min = dp[i] + kp[n-1-i] - 1;
        }
    }

        std::cout << min << "\n";
}

Measured memory_bytes: 2948
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trii(x) cerr<<#x<<": ("<<x.F<<","<<x.S<<")\n";
#define trvii(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<"("<<a[zz].F<<","<<a[zz].S<<") ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define trsetii(s) cerr<<#s<<": ";for(auto &i:s) trii(i);
#define epsilon 0.000000001L
#define mod 1000000007ll
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define modulo 998244353ll


int main()
{
    fast();
    string s;
    cin>>s;
    for(ll i=0;i<sz(s);i++)
    {
        if(s[i]=='?')
            s[i]='D';
    }
    cout<<s<<nl;
}


Measured memory_bytes: 3744
#include "bits/stdc++.h"
 
using namespace std;
int main()
{
	vector<int> a(5);
	for (int i = 0; i < 5; i++)
	{
		cin >> a[i];
	}
	int min = 10;
	int index = -1;
	for (int i = 0; i < 5; i++)
	{
		if (a[i] % 10 < min && a[i] % 10 != 0) {
			min = a[i] % 10;
			index = i;
		}
	}
	int s = 0;
	for (int i = 0; i < 5; i++)
	{
		if (i != index && a[i] % 10 != 0)
			s += (a[i] / 10) * 10 + 10;
		else
			s += a[i];
	}
	cout << s << endl;
}
 

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  cout << (n-2)*180 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

bool flag[30];

int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    map<int,int> mp;
    int ans = 0;
    rep(i,30){
        mp[(1 << (i+1)) - 1] = i+1;
    }
    rep(i,n){
        cin >> vec[i];
        ans ^= vec[i];
        int res = mp[vec[i]^(vec[i]-1)];
        if(res){
            flag[res-1] = true;
        }
    }
    int a = 0;
    for(int i=29;i>=0;i--){
        if(ans & (1 << i)){
            if(flag[i]){
                ans ^= ((1 << (i+1)) - 1);
                a++;
            }else{
                cout << "-1\n";
                return 0;
            }
        }
    }
    cout << a << "\n";
    return 0;
}


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

int main() {
    long long N, Y;
    cin >> N >> Y;
    for (int x = 0; x <= Y / 10000; x++) {
        if ((5000 * (x + N) - Y) % 4000 == 0) {
            long long z = (5000 * (x + N) - Y) / 4000;
            long long y = N - (x + z);
            if (y >= 0 && z >= 0) {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n=int(input())
a = list(map(int, input().split()))
a.sort()
r=a.pop(0)
while len(a)>0:
  x = a.pop(0)
  if x%r!=0:
    a.append(r)
    a.append(x%r)
    a.sort()
    r=a.pop(0)
    
    

print(r)
  
  


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep( i, n ) for (long long i = 1; i < ( long long )(n); i++)

using namespace std;
typedef long long ll;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;


int main(){
  ll r;
  cin>>r;
  cout << fixed << setprecision(10);
  cout<<2*r*3.1415926;
} 

Measured memory_bytes: 3788
#include <stdio.h>
#include <vector>
#include <utility>
using namespace std;
typedef pair<int,int> pii;
vector<vector<pii> > v;
vector<pii> lst;
int N,M,S,E;
int visit[51];
vector<int> path[51][51];
int chk[21];
long long ans;
bool dfs(int x){
	if(x==E) return true;
	for(pii nx : v[x]){
		if(visit[nx.second]==0){
			visit[nx.second] = 1;
			if(dfs(nx.first)) return true;
			visit[nx.second] = 0;
		}
	}
	return false;
}
void bt(int x){
	if(x==M){
		int tmp[51]={0,}, edge=0,cnt=0;
		for(int i=0;i<M;i++){
			if(chk[i]){
				cnt++;
				for(int j : path[lst[i].first][lst[i].second]){
					tmp[j]=1;
				}
			}
		}
		for(int i=0;i<N-1;i++) edge+=tmp[i];
		ans += 1LL*(1-(cnt%2)*2)*(1LL<<(N-1-edge));
	}
	else{
		bt(x+1);
		chk[x]=1;
		bt(x+1);
		chk[x]=0;
	}
}
int main(){
	scanf("%d",&N);
	v.resize(N+1);
	for(int i=0;i<N-1;i++){
		int a,b;scanf("%d %d",&a,&b);
		v[a].push_back({b,i});
		v[b].push_back({a,i});
	}
	scanf("%d",&M);
	for(int i=0;i<M;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		lst.push_back({a,b});
	}
	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++){
			S=i;E=j;
			dfs(S);
			for(int k=0;k<N-1;k++){
				if(visit[k]) path[i][j].push_back(k);
				visit[k]=0;
			}
		}
	}
	bt(0);
	printf("%lld",ans);
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ2400().doIt();
	}
	
	class AOJ2400{
		int T,P,R;
		
		void solve(){
			Team[] team = new Team[T];
			for(int i=0;i<T;i++)team[i]=new Team(i+1);
			for(int i=0;i<R;i++){
				 int teamId = in.nextInt();
				 int problemId = in.nextInt();
				 int time = in.nextInt();
				 String message = in.next();
				 team[teamId-1].submit(problemId, time, message);
			}
			Arrays.sort(team);
			for(int i=T-1;i>=0;i--){
				System.out.println(team[i].id+" "+team[i].currect+" "+team[i].point);
			}
			
			
		}
		
		void doIt(){
			while(in.hasNext()){
				T = in.nextInt();
				P = in.nextInt();
				R = in.nextInt();
				if(P+R+T==0)break;
				solve();
			}
		}
		
		class Team implements Comparable<Team>{
			int id;
			boolean[] solved;
			int fail[];
			int point;
			int currect;//正解した数;
			public Team(int id){
				this.id = id;
				solved = new boolean[P+1];
				fail = new int[P+1];
				point = 0; 			
			}
			
			void submit(int problem,int time,String message){
				if(solved[problem])return;
				if(message.equals("CORRECT")){
					point+=(fail[problem]*1200+time);
					solved[problem]=true;
					currect++;
				}else{
					fail[problem]++;
				}
			}

			public int compareTo(Team o) {
				if(this.currect>o.currect)return 1;
				else if(this.currect<o.currect)return -1;
				else if(this.point<o.point)return 1;
				else if(this.point>o.point)return -1;
				else if(this.id<o.id)return 1;
				else if(this.id>o.id)return -1;
				return 0;
			}
			
		}
		
	}
	
}

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

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, s, e) for (ll i = s; i < e; i++)
#define pb push_back
#define ll long long
#define mp make_pair

bool comp(pair<ll, ll> a, pair<ll, ll> b)
{
    if (a.second < b.second)
        return true;
    else if (a.second == b.second)
        return a.first < b.first;
    return false;
}
int main()
{
    ll n;
    cin >> n;
    ll x = n / 1000;
    if (n % 1000 != 0)
        cout << ((x + 1) * 1000) - n << endl;
    else
    {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 3644
# coding: utf-8
# Your code here!
#from sys import stdin
#import math
#from functools import reduce
    
#A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
#N = int(input())
S = list(input())
 
is_difficult = 'Yes'

for i, s in enumerate(S):
    if (i+1)%2 == 0:
        if (s=='R'):
            is_difficult = 'No'
            break
    else:
        if (s=='L'):
            is_difficult = 'No'
            break
print(is_difficult)

Measured memory_bytes: 38256
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
 
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		boolean[] dp = new boolean[a[n-1]+1];
		for(int i = 0; i < dp.length; i++) {
			dp[i] = true;
		}
		
		for(int i = 0; i < a.length; i++) {
			if(dp[a[i]]) {
				if(i > 0 && a[i] == a[i-1])dp[a[i]] = false;
				for(int m = 2 * a[i]; m < dp.length; m += a[i]) {
					dp[m] = false;
				}
			}
		}
		
		int cnt = 0;
		for(int i = 0; i < n; i++) {
			if(dp[a[i]])cnt++;
		}
		System.out.println(cnt);
	}
}

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

constexpr long long MOD = 1'000'000'007;

class binomial_coefficients {
	long long MAX_VAL;
	vector<long long> fac, mmi;

public:

	binomial_coefficients(){
	}
	
	binomial_coefficients(long long num){
		init(num);
	}
	
	~binomial_coefficients(){
		
	}
	
	void init(long long num){
		MAX_VAL = num+1; 
		fac.resize(MAX_VAL);
		mmi.resize(MAX_VAL);
		
		factorial_mod();
		modular_multiplicatibe_inverse();
	}
	
	void factorial_mod(){
		 fac[0] = 1;
		for(long long i = 1; i < MAX_VAL; fac[i] %= MOD, i++)
			fac[i] = fac[i - 1] * (i % MOD);
	}
	
	long long power(long long x, long long n){
		long long ans = 1;
		for(;n;n >>= 1, x *= x, ans %= MOD, x %= MOD)
			if(n&1)ans*=x;
		return ans % MOD;
	}
	
	void exgcd(long long a, long long b, long long &x, long long &y){
		if(b == 0){
			x = 1;
			y = 0;
			return ;
		}
		exgcd(b, a % b, y, x);
		y -= a / b * x;
	}
	
	void modular_multiplicatibe_inverse(){
		long long x, y;  
		exgcd(fac[MAX_VAL - 1], MOD, x, y);
		mmi[MAX_VAL-1] = (x % MOD + MOD) % MOD;
		// mmi[MAX_VAL-1] = power(fac[MAX_VAL-1], MOD-2);
		for(long long i = MAX_VAL - 2; i >= 0; mmi[i]%=MOD, i--)
			mmi[i] = mmi[i + 1] * ((i + 1) % MOD);
	}
	
	long long combination(long long n, long long r){
		return r < 0 ? 0 :n < r ? 0 :fac[n] * (mmi[r] * mmi[n-r] % MOD) % MOD;
	}
};


int main(){
	
	long long n, k;
	long long ans = 0;
	binomial_coefficients bc;
	
	cin>>n>>k;
	
	bc.init(n+k);
	
	
	ans = bc.combination(k + n - 1 - k, n - k);
	
	cout<<ans<<endl;
}


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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

const int mod=1000000007;

int main(){
    int n,h;
    cin>>n>>h;
    int a[n],b[n];
    rep(i,n) cin>>a[i]>>b[i];
    sort(a,a+n);
    sort(b,b+n);
    int p=n;
    int ans=0;
    while(b[--p]>a[n-1]&&h>0){
        h-=b[p];
        ++ans;
    }
    if(h>0){
        ans+=(h+a[n-1]-1)/a[n-1];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10e+6
#define DEKA 1000000007

using namespace std;

//union-find

int par[100005]; //parents
int hukasa[100005]; //depth

// search root
int find (int x){
    if (par[x]<0) return x;
    else return par[x]=find(par[x]);
}
//xとyの集合を併合

int setsize(int n){
    return -par[n];
}

void unit(int x,int y){
    x=find(x);
    y=find(y);
    if (x==y) return;
    
    if (hukasa[x]<hukasa[y]){
        par[y]+=par[x];
        par[x]=y;
    }
    else {
        par[x]+=par[y];
        par[y]=x;
        if (hukasa[x]==hukasa[y]) hukasa[x]++;
    }
    
}

//xとyは同じ集合に入るか？

bool same(int x,int y){
    return find(x) == find(y);
}



int main(){
    int n,m;
    cin >> n >> m;
    
    for (int i=1;i<=n;i++){
        par[i]=-1;
        hukasa[i]=1;
    }
    
    int p[n+10];
    for (int i=1;i<=n;i++) cin >> p[i];
    vector<pair<int,int>> pairs(m+10);
    for (int i=1;i<=m;i++) {
        cin >> pairs[i].first >> pairs[i].second;
        unit(p[pairs[i].first],p[pairs[i].second]);
    }
    int ans=0;
    for (int i=1;i<=n;i++) if(same(i,p[i])==1) ans++;
    cout << ans << endl;
}




Measured memory_bytes: 2176
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define INF INT_MAX/3
#define EPS 1e-7

int main(){
  ll n;
  cin>>n;
  vector<ll> v;
  ll a[200001];
  ll t;
  rep(i,n){
    cin>>t;
    a[i]=t;
    v.push_back(t);
  }

  sort(v.begin(),v.end());

  rep(i,n){
    if(a[i]<=v[n/2-1]) cout<<v[n/2]<<endl;
    else cout<<v[n/2-1]<<endl;
  }

  return 0;
}



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

int main(){
int n, m, l;
cin >> n >> m >> l;

//行列Aの読み込み
vector< vector<int> > matrix_A(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> matrix_A.at(i).at(j);
    }
  }

//行列Bの読み込み
vector< vector<int> > matrix_B(m, vector<int>(l));
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < l; j++) {
      cin >> matrix_B.at(i).at(j);
    }
  }


//結果(積AB)の出力
 for( int i = 0; i < n; i++){
   long int a[l] = {};
   for(int k = 0; k < l; k++){

     for(int j = 0; j < m; j++){
         a[k] += matrix_A.at(i).at(j) * matrix_B.at(j).at(k);
       }
     cout << a[k];
     if(k < l-1) cout << " ";
  }
   cout << endl;
 }
return 0;
}




Measured memory_bytes: 3216
import java.util.*;

public class Main {

    static int MAX_N = 1 << 24;
    static int INT_MAX = 2147483647;
    static int INT_MIN = 0;

    static int n;
    static long[] dat = new long[2*MAX_N-1];

    public static void init(int n_) {
        n = 1;
        while (n < n_) {
            n*=2;
        }
        for (int i=0;i<2*n-1;i++) {
            dat[i] = INT_MIN;
        }
    }

    public static void update(int k, long a) {
        k+=n-1;
        dat[k]=a;
        while (k>0) {
            k = (k-1)/2;
            dat[k] = Math.max(dat[k*2+1], dat[k*2+2]);
        }
    }

    public static long query(int a, int b, int k, int l, int r) {
        if (r<=a || b<=l) {
            return INT_MIN;
        }
        if (a<=l && r<=b) {
            return dat[k];
        } else {
            long vl = query(a, b, k*2+1, l, (l+r)/2);
            long vr = query(a, b, k*2+2, (l+r)/2, r);
            return Math.max(vl, vr);
        }
    }


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] h = new int[N];
        int[] a = new int[N];
        init(N);
        for (int i=0;i<N;i++) {
            h[i] = Integer.parseInt(sc.next())-1;
        }
        for (int i=0;i<N;i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        long[] dp = new long[N];
        for (int i=0;i<N;i++) {
            dp[h[i]] = a[i]+query(0, h[i], 0, 0, n);
            update(h[i], dp[h[i]]);
        }

        long ans = 0;
        for (int i=0;i<N;i++) {
            ans = Math.max(ans, dp[i]);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 331972
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 10000
#define NIL -1

struct Node{int p, l, r;};
struct Node T[MAX];
int n;

//???????????????
void preParse(int u){
  if(u == NIL)
    return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

//???????????????
void inParse(int u){
  if(u == NIL)
    return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

//???????????????
void postParse(int u){
  if(u == NIL)
    return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main(){
  int i, v, l, r, root;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    T[i].p = NIL;
  }

  for(i = 0; i < n; i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }

  for(i = 0; i < n; i++){
    if(T[i].p == NIL)
      root = i;
  }

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
typedef  long long   ll;
ll inf=100000000000000000,mod=1000000007;
int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        ll n;cin>>n;string s;set<string >arr;
        for(ll i=0;i<n;i++)cin>>s,arr.insert(s);
        ll num=arr.size();
        cout<<num;
	return 0;
}


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

int main()
{
    int n,i;
    long long ans=0;
    queue<int>q;

    cin>>n;

    int a[n+5];

    for(i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);

    q.push(a[n-1]);

    for(i=n-2;i>=0;i--){
        ans=ans+q.front();
        q.pop();
        q.push(a[i]);
        q.push(a[i]);
    }
    cout<<ans<<endl;

    return 0;
}



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

int main() {
  int a, b, A, B, x;
  cin >> a >> b;
  A = a%2;
  B = b%2;
  x = A*B;
  if (x == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define ll long long int
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)

using namespace std;
using mii=map<int, int>;
using mll=map<ll, ll>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int mod = 1000000007;

ll desc(ll x, ll y)
{
    return x > y;
}

int main() {
    fastIO
    int n, i;
    cin >> n;

    vi a(n, 0);
    fo(i, n)
    cin >> a[i];

    ll s1 = a[0];
    ll s2 = a[n - 1];

    int j = 0;
    int k = n - 1;

    while(j < k)
    {
        while(s1 <= s2)
        {
            j++;
            if(j < k)
            s1 += a[j];
            else {
                j++;
                break;
            }
        }
        while(s2 < s1)
        {
            k--;
            if(k > j)
            s2+= a[k];
            else
            {
             k--;
                break;
            }
//            deb(s2)
        }
    }
    cout << abs(s1 - s2) << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
arr=list(map(int,input().split()))
s=0
d={}
for i in arr:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    s+=i
for i in range(int(input())):
    a,b=map(int,input().split())
    if a in d:
        s=s-a*d[a]+b*d[a]
    if b in d and a in d:
        d[b]+=d[a]
    else:
        if a in d:
            d[b]=d[a]
    d[a] = 0
    print(s)


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

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] num = new int[n];
		for (int i = 0; i < n; i++) {
			num[i] = scanner.nextInt();
		}
		int m = scanner.nextInt();
		int count = 0;
		while (m-- > 0) {
			int a = scanner.nextInt();
			if (Arrays.binarySearch(num, a) > -1)
				count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 63648
import sys

N, A, B = map(int, sys.stdin.readline().strip().split())

H = []
for _ in range(N):
    H.append(int(sys.stdin.readline().strip()))
H.sort()

# 二分探索でmid回の攻撃で魔物を消し去れるか
left = 1
right = 10**9

# うまくいかないのでansを保持しておく
ans = right
while left < right:
    mid = (left + right) // 2
    # print(mid)
    n = mid
    for h_i in H:
        if h_i <= B * mid:
            continue

        # Bの攻撃のみで消し去れない場合はAの攻撃を消費する
        h_i -= B * mid
        n -= (h_i - 1) // (A-B) + 1

    if n >= 0:
        ans = min(ans, mid)
    if n == 0:
        break
    elif n > 0:
        right = mid
    else:
        left = mid + 1

print(ans)

Measured memory_bytes: 44572
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main(){
	int a[30] = {0};
	string s;
	cin >> s;
	for (int i = 0; i < s.size();i++) {
		a[s[i]-'a'] ++ ;
	}
	for (int i = 0; i < 30;i++) {
		if (a[i]>1) {
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define double long double
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define msi map<string,int>
#define set set<int>
#define u_set unordered_set<int>
#define pb push_back
#define endl "\n"
#define ll long long int
#define vll vector<long long int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define umap unordered_map 
#define mod 1000000007
#define fori(a,n) for(int i=a;i<n;i++)
#define forj(a,n) for(int j=a;j<n;j++)
#define MAX 300303
using namespace std;
vi dp(100001,INT_MAX);
int n;
signed main()
{
    io
    cin >> n;
    vi h(n);
    fori(0,n)cin >> h[i];
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    fori(2,n){
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a,b;
	cin>>a>>b;
	for(int i=1;i<=2000;i++)
	{
		int x=i*0.08,y=i*0.1;
		if(x==a&&y==b)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int puzz[3][3];
int copy[3][3];
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
void empty(int *,int *);
int dfs(int,int,int,int,const int);
int cal();
void swap(int *,int *);

int main(){
  int i,j,ans,x,y,l;
  for(i = 0; i < 3; i++)
    for(j = 0; j < 3; j++)
      scanf("%d", &puzz[i][j]);


  empty(&x,&y);
    for(l=0; l<100; l++) {
        //copy
        for(i=0; i<3; i++) {
            for(j=0; j<3; j++) copy[i][j] = puzz[i][j];
        }
         
        //dfs
        ans = dfs(x,y,-1,0,l);
        if(ans!=-1) {
            printf("%d\n",ans);
            break;
        }
         
        //copy
        for(i=0; i<3; i++) {
            for(j=0; j<3; j++) puzz[i][j] = copy[i][j];
        }
         
        //error
        ans = -1;
        if(l==99) printf("%d\n",ans);
    }


  return 0;
} 
 
void empty(int *x,int *y) {
    int i,j;
    for(i=0; i<3; i++) {
        for(j=0; j<3; j++) {
            if(!puzz[i][j]) {
                *x = j;
                *y = i;
                return;
            }
        }
    }
}
 
 
void swap(int *a,int *b) {
    int tmp;
     
    tmp = *a;
    *a = *b;
    *b = tmp;
}
 
 
int cal() {
    int i,a,sum=0;
     
    for(i=0; i<9; i++) {
        a = puzz[i/3][i%3];
        if(a) {
            a--;
            sum += abs(i/3 - a/3) + abs(i%3 - a%3);
        }
    }
     
    return sum;
}
 
 
int dfs(int x,int y,int p,int dep,const int lim) {
    int i,h,nx,ny,res;
     
    h = cal();
    if(h==0) return dep;
    if(dep+h>lim) return -1;
     
    for(i=0; i<4; i++) {
        nx = x+dx[i];
        ny = y+dy[i];
         
        if(~p && i==(p+2)%4) continue;
        if(!(0<=nx && nx<3 && 0<=ny && ny<3)) continue;
         
        swap(&puzz[y][x],&puzz[ny][nx]);
        res = dfs(nx,ny,i,dep+1,lim);
        if(~res) return res;
         
        swap(&puzz[y][x],&puzz[ny][nx]);
    }
     
    return -1;
}

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

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

  int H, W, h, w, ans;
  cin >> H >> W;
  cin >> h >> w;

  ans = H * W - H * w - W * h + h * w;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
use std::cmp::max;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let k: usize = sc.read();
    let r: usize = sc.read();
    let s: usize = sc.read();
    let p: usize = sc.read();

    let t = sc.chars();

    let mut ts = vec![vec![]; k];
    for i in 0..n {
        ts[i % k].push(t[i]);
    }

    let mut ans = 0;
    for t in ts.into_iter() {
        let n = t.len();
        let mut dp = [0; 3];
        for i in 0..n {
            let mut next = [0; 3];
            for next_hand in 0..3 {
                // r, s, p
                for prev_hand in 0..3 {
                    if next_hand == prev_hand {
                        continue;
                    }

                    let get = match t[i] {
                        'r' if next_hand == 2 => p,
                        's' if next_hand == 0 => r,
                        'p' if next_hand == 1 => s,
                        _ => 0,
                    };

                    next[next_hand] = max(next[next_hand], dp[prev_hand] + get);
                }
            }
            dp = next;
        }

        ans += max(dp[0], max(dp[1], dp[2]));
    }

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

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int n;
  cin >> n;
  vector<int> a(26, 2e9);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    vector<int> b(26);
    for (auto &i : s) {
      b[i - 'a']++;
    }
    for (int i = 0; i < 26; i++) {
      a[i] = min(a[i], b[i]);
    }
  }
  for (int i = 0; i < 26; i++)
  for (int j = 0; j < a[i]; j++) {
    cout << (char)('a' + i);
  }
  cout << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e6 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n, k;
bool bad[11];

bool good(int val)
{
	while (val)
	{
		if (bad[val % 10])
			return false;
		val /= 10;
	}
	return true;
}

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

	scanf("%d %d", &n, &k);
	int now;
	for (int i = 0; i < k; i++)
	{
		scanf("%d", &now);
		bad[now] = true;
	}
	for (int i = n; i < maxn; i++)
		if (good(i))
		{
			printf("%d\n", i);
			break;
		}
}



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

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
using namespace std;
using ll = long long;
using lld = long long;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

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

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

  ll D, T, S;
  cin >> D >> T >> S;

  if (D > T * S) {
    print("No");
  } else {
    print("Yes");
  }
}

Measured memory_bytes: 3636
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	bool a[10] = { false };
	int A;
	for (int i = 0; i < k; i++) {
		cin >> A;
		a[A] = true;
	}
	for (int i = n; i <= 200000; i++) {
		if (i < 10) {
			if (a[i % 10] == false) {
				cout << i << endl;
				break;
			}
		}
		else if(i < 100) {
			if (a[i % 10] == false && a[i / 10 % 10] == false) {
				cout << i << endl;
				break;
			}
		}
		else if(i < 1000) {
			if (a[i % 10] == false && a[i / 10 % 10] == false && a[i / 100 % 10] == false) {
				cout << i << endl;
				break;
			}
		}
		else if(i < 10000) {
			if (a[i % 10] == false && a[i / 10 % 10] == false && a[i / 100 % 10] == false && a[i / 1000 % 10] == false) {
				cout << i << endl;
				break;
			}
		}
		else {
			if (a[i % 10] == false && a[i / 10 % 10] == false && a[i / 100 % 10] == false && a[i / 1000 % 10] == false && a[i / 10000 % 10] == false) {
				cout << i << endl;
				break;
			}
		}
	}
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

int p,q,a,n;

int gcd(int x,int y){
    if(y==0) return x;
    return gcd(y,x%y);
}

int dfs(int denom,int numer,int prev,int product,int num){
    int res=0,g=gcd(denom,numer);
    denom/=g;
    numer/=g;
    if(denom==q and numer==p) ++res;
    if(num==0) return res;

    {
        int tmp1=denom*prev,tmp2=numer*prev+denom*num;
        if((double)tmp2/tmp1<(double)p/q) return 0;
    }

    if((double)numer/denom>(double)p/q) return 0;

    int x=prev;
    while(true){
        if(product*x>a) break;
        res+=dfs(denom*x,numer*x+denom,x,product*x,num-1);
        ++x;
    }
    return res;
}

void solve(){
    while(cin >> p >> q >> a >> n){
        if(p==0 and q==0 and a==0 and n==0) break;
        int g=gcd(p,q);
        p/=g;
        q/=g;
        cout << dfs(1,0,1,1,n) << endl;
    }
}

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

Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct edge{ int u,v,cost; };
const int MAX_E = 2e5+10;
const int MAX_V = 1e5+10;
int par[MAX_V + 10];
int rankrank[MAX_V + 10];
vector<edge> es;
int V, E;

void init(int n){
    for (int i = 0; i < n; i++){
        par[i] = i;
        rankrank[i] = 0;
    }
}

int getRoot(int x){
    if (par[x] == x){
        return x;
    }else{
        return par[x] = getRoot(par[x]);
    }
}

void unite(int x, int y){
    x = getRoot(x);
    y = getRoot(y);
    if (x == y) return;
    if (rankrank[x] == rankrank[y]) {
        par[y] = x;
        rankrank[x]++;  
    }else if (rankrank[x] < rankrank[y]) {
        par[x] = y;
    }else if (rankrank[x] > rankrank[y]) {
        par[y] = x;
    }
}

bool isSame(int x, int y){
    return getRoot(x) == getRoot(y);
}

bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}

long long kruskal(){
    sort(es.begin(), es.end(), comp); 
    init(V);

    long long res = 0;
    for (auto i = es.begin(); i != es.end(); ++i){
        edge e = *i;
        if (!isSame(e.u, e.v)){
            unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}


int main(){

    vector<pair<int, int>> X;
    vector<pair<int, int>> Y;
    cin >> V;
    for (int i = 1; i <= V; ++i){
        int x, y;
        cin >> x >> y;
        X.push_back(make_pair(x,i));
        Y.push_back(make_pair(y,i));
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    for (int i = 0; i < V-1; ++i){
        es.push_back(edge{X[i].second, X[i+1].second, abs(X[i].first-X[i+1].first)});
        es.push_back(edge{Y[i].second, Y[i+1].second, abs(Y[i].first-Y[i+1].first)});
    }
    int ans = kruskal();
    cout << ans << endl;


    return 0;
}

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

using namespace std;
using llint = long long;

#define LOG(x) cout << "# " << #x <<" => "<< (x) <<endl

int n, ans;

int main() {
    cin >> n;

    ans = 180*(n-2);

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

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

int main()
{
  int a,b,c,d;
  int res=0;
  cin >> a>>b>>c>>d;

  bool aliceOn = false;
  bool bobOn = false;

  for(int i=0;i<=100;i++){
    if(aliceOn && bobOn) res++;
    if(i==a) aliceOn=true;
    if(i==b) aliceOn=false;
    if(i==c) bobOn=true;
    if(i==d) bobOn=false;
  }

  cout << res << endl;
}


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

class Main{

	public static void main(String[] args){

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] l = new int[n*2];
		
		for(int i = 0; i < n*2; i++){
			l[i] = in.nextInt();
		}
		Arrays.sort(l);
		int sum = 0;
		for(int i = 0; i < n; i++){
			sum += l[i*2];
		}

		System.out.println(sum);
		in.close();

	}

}

Measured memory_bytes: 9684
m = list(map(int,input().split()))
count = 0
for i in range(m[1]+1):
    for j in range(m[0]+1):
        k = str(i)
        k = k.rjust(2, '0')
        if int(k[0])*int(k[1]) == j and int(k[0]) >=2 and int(k[1]) >= 2 :
            count = count + 1
        else:
            count = count

print(count)

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

int N;

int main() {
    cin >> N;
    vector<int> w(N), b(N);
    for (int i = 0; i < N; i++) {
        cin >> w.at(i) >> b.at(i);
    }

    vector<vector<int>> grundy(210, vector<int>(110));
    // grundy数を前計算
    for (int b = 0; b < 101; b++) {
        for (int a = 0; a < 201; a++) {
            // mex と同様 のことを行う
            set<int> st;
            if (a - 1 >= 0) st.insert(grundy[a - 1][b]);  // (ア)白石を一つ取り除く
            for (int c = 1; c <= a && c <= b; c++) {      // (イ)白石を超えない数だけ黒石を取り除く
                st.insert(grundy[a][b - c]);
            }
            if (b - 1 >= 0) st.insert(grundy[a + 1][b - 1]);  //(ウ)黒石を一つの白石に交換する
            int g = 0;
            while (st.count(g)) {
                g++;
            }
            grundy[a][b] = g;
        }
    }

    int xor_sum = 0;
    for (int i = 0; i < N; i++) {
        xor_sum ^= grundy[w[i]][b[i]];
    }

    if (xor_sum == 0) {  // 後手必勝
        cout << 1 << endl;
    } else {  // 先手必勝
        cout << 0 << endl;
    }
}



Measured memory_bytes: 3300