akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 100000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
struct seg_mul{
	ll seg[(1<<19)],lazy[(1<<19)];
	void init(){
		rep(i,(1<<19)){
			seg[i] = 0;
			lazy[i] = 1;
		}
	}
	void ev(int k){
		lazy[2*k+1] = lazy[2*k+1]*lazy[k]%mod;
		lazy[2*k+2] = lazy[2*k+2]*lazy[k]%mod;
		seg[2*k+1] = seg[2*k+1]*lazy[k]%mod;
		seg[2*k+2] = seg[2*k+2]*lazy[k]%mod;
		lazy[k] = 1;
	}
	ll query(int a,int b,int k,int l,int r){
		if(r<a || b<l) return 0;
		if(a<=l && r<=b){
			return seg[k];
		}
		if(lazy[k] != 1) ev(k);
		return (query(a,b,k*2+1,l,(l+r)/2)+query(a,b,k*2+2,(l+r)/2+1,r))%mod;
	}
	ll update(int a,int k,int l,int r){
		if(l == a && a == r){
			seg[k] = 1;
			return seg[k];
		}
		if(lazy[k] != 1) ev(k);
		if(l<=a && a<=(l+r)/2){
			return seg[k] = (update(a,k*2+1,l,(l+r)/2)+seg[k*2+2])%mod;
		}
		else{
			return seg[k] = (update(a,k*2+2,(l+r)/2+1,r)+seg[k*2+1])%mod;
		}
	}
	ll mul(ll x){
		seg[0] = seg[0]*x%mod;
		lazy[0] = lazy[0]*x%mod;
	}
}p;
struct BIT
{
	int bit[(1<<18)+5];
	int f(int x)
	{
		return x&-x;
	}
	void add(int i,int x)
	{
		for(int s=i;s<=(1<<18);s+=f(s)) bit[s]+=x;
	}
	int sum(int i)
	{
		int res=0;
		for(int s=i;s>0;s-=f(s)) res+=bit[s];
		return res;
	}
}kaede;
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int n,a[200005],cnt[200005];
vector<int>pos[200005];
int main(){
	scanf("%d",&n);
	repn(i,n){
		scanf("%d",&a[i]);
		pos[a[i]].pb(i);
		cnt[a[i]]++;
	}
	int D = 0;
	ll way = 1;
	for(int i=n;i>=1;i--){
		D += (cnt[i]-1);
		way = way*(D+1)%mod;
		if(D < 0){
			puts("0");
			return 0;
		}
	}
	p.init();
	int zan = 0;
	ll X = 0,Y = 0,ans = 0;
	for(int i=n;i>=1;i--){
		rep(jj,pos[i].size()){
			int j = pos[i][jj];
			int pre = kaede.sum(j-1);
			X = (X+1LL*pre)%mod;
			kaede.add(j,1);
			X += p.query(j+1,n,0,0,(1<<18)-1);
			X %= mod;
			Y += p.query(1,j-1,0,0,(1<<18)-1);
			Y += p.query(j+1,n,0,0,(1<<18)-1);
			Y %= mod;
			p.update(j,0,0,(1<<18)-1);
		}
		zan += pos[i].size();
		ans += (X-Y)%mod*modpow(zan,mod-2)%mod;
		ll pp,qq;
		pp = modpow(zan,mod-2)*(zan-1)%mod;
		qq = modpow(zan-1,mod-2)*(zan-2)%mod;
		X = X*pp%mod;
		Y = Y*pp%mod*qq%mod;
		zan--;
		p.mul(pp);
	}
	printf("%lld\n",(ans%mod+mod)%mod*way%mod);
}

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

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

    // gratest common divisor
    long long GCD = __gcd( A, B );

    // prime factorization
    int num_loop = 1000001;
    if( GCD < num_loop ){
        num_loop = GCD;
    }
    int count = 1;
    for( int i=2; i<1+num_loop; i++ ){
        if( GCD % i == 0 ){
            count++;
        }
        while( GCD % i == 0 ){
            GCD /= i;
        }
    }
    if( GCD > 1 ){
        count++;
    }

    // output
    cout << count << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define maxn 100005
#define Mod 1000000007
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef set<int> si; 
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
#define __builtin_popcountll bitCountLL
#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
const int INF = 2e9;
const ll ML = 4e18;

void solve() {
    int n, k;
    cin >> n >> k;
    vll a,b;
    fori(i,0,n) {
        ll x;
        cin >> x;
        if(x >= 0) a.push_back(x);
        else b.push_back(x);
    }
    sort(all(a));
    sort(all(b));
    reverse(all(a));
    ll ans = 1;
    if(a.size() == 0 && k % 2) {
        rep(i,b.size() -1,(int)(b.size() - k)) 
            ans = (ans * b[i]) % Mod;
        ans = (ans + Mod) % Mod;
        cout << ans << endl;
        return;
    }
    if((int)(a.size() + b.size()) == k) {
        for(ll i : a) ans = (ans * i) % Mod;
        for(ll i : b) ans = (ans * i) % Mod;
        ans = (ans + Mod) % Mod;
        cout << ans << endl;
        return;
    }
    bool ok = false;
    int pos = a.size() - 1;
    for(int i = 0; i * 2 <= (int)b.size(); i++) {
        if(i * 2 + (int)a.size() < k) continue;
        if(!ok) {
            pos = k - (2 * i) - 1;
            ok = true;
            continue;
        }
        if(pos < 1) break;
        if(a[pos] * a[pos - 1] > b[2*i -2] * b[2*i -1]) 
            break;
        pos -= 2;
    }
    fori(i,0,pos + 1) ans = (ans * a[i]) % Mod;
    int len = k - pos - 1;
    fori(i,0,len/2) {
        ll x = b[i * 2] * b[i * 2 + 1] % Mod;
        ans = (ans * x) % Mod;
    }
    cout << ans << endl;

}

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

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


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

int main() {
  
  int N;
  cin >> N;
/*
  vector<int> val(N);
  vector<int> whi(N);
*/
  float res;
  for(int i=0; i<N; i++){
    float val;
    string whi;
    cin >> val >> whi;
    if(whi=="JPY"){res += val;}
    else{res += val*380000;}
  }

  cout << res << endl;
}


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

int main(){
    char ch;
    int cnt[26]={};
    
    while(cin>>ch){
        ch = tolower(ch);
        if (isalpha(ch)){
            cnt[ch-'a']++;
        }
    }
    
    for(int i=0;i<26;i++){
        printf("%c : %d\n",i+'a',cnt[i]);
    }
    return 0;
}


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

using namespace std;
#define DEBUG
#ifdef DEBUG
#define dump(x) cout << "[*] " #x ": " << x << endl
#define debug(x) x
#else
#define dump(x)
#define debug(x)
#endif

#define int long long
typedef long long ll;
//constexpr int INF = 1e9;
//constexpr int MOD = 1000000007;

decltype(1) main() {
    //cin.tie(nullptr);
    //ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    ans += 1000 * (n / 500);
    n %= 500;
    ans += 5 * (n / 5);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
h,w=map(x->parse(Int,x),split(readline()))
s=[];
for i=1:h
	push!(s,readline())
end
dx=[0,1,0,-1,1,1,-1,-1]
dy=[1,0,-1,0,1,-1,1,-1]
for i=1:h
	for j=1:w
		if s[i][j]=='#'
			print('#')
		else
			c=0
			for r=1:8
				x=i+dx[r]
				y=j+dy[r]
				if 0<x<=h&&0<y<=w&&s[x][y]=='#'
					c+=1
				end
			end
			print(c)
		end
	end
	println()
end

Measured memory_bytes: 144192
import java.util.Scanner;

public class Main {
	static long mod=1000000007;
	static long[] fact;
	static long[] rfact;
	
	public static void factTable(int n){
		fact=new long[n+1];
		fact[0]=fact[1]=1;
		for(int i=2;i<=n;i++) fact[i]=(fact[i-1]*i)%mod;
		
		//逆元計算
		rfact=new long[n+1];
		for(int i=0;i<=n;i++) rfact[i]=inverse(fact[i]);
	}
	
	public static long comb(int n,int r){
		return (((fact[n]*rfact[r])%mod)*rfact[n-r])%mod;
	}

	public static long inverse(long a){
		return fastpow(a,mod-2);
	}
	
	public static long fastpow(long a, long b){
		long x=1;
		while(b>0){
			if((b&1)==1) x=(x*a)%mod;
			a=(a*a)%mod;
			b>>=1;
		}
		return x;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		factTable(n+1);

		int[] a=new int[n+1];
		boolean[] ext=new boolean[n];
		int x=-1;
		for(int i=0;i<n+1;i++){
			a[i]=sc.nextInt();
			if(ext[a[i]-1])x=a[i];
			ext[a[i]-1]=true;
		}
		
		int l=0,r=0;
		while(a[l]!=x) l++;
		while(a[n-r]!=x) r++;
		int c=l+r;
		
		long[] sol=new long[n+2];
		for(int i=1;i<=n+1;i++) {
			sol[i]=comb(n+1,i);
		}
		for(int i=1;i<=c+1;i++) {
			sol[i]-=comb(c,i-1);
			if(sol[i]<0)sol[i]+=mod;
		}
		
		for(int i=1;i<=n+1;i++){
			System.out.println(sol[i]);
		}
	
		
		
	}
}


Measured memory_bytes: 72204
#include<stdio.h>
#include<bitset>
#include<vector>
int main()
{
	const int N=30001;
	std::bitset<N>p;
	std::vector<int>v;
	int i,j,x[3][N]={0};
	for(i=2;i<N;++i)if(!p[i])for(v.push_back(i),j=i*i;j<N;j+=i)p[j]=1;
	for(i=0;i<v.size();++i)for(x[0][v[i]]=1,j=2;j<N-v[i];++j)
	{
		x[1][j+v[i]]+=x[0][j];
		if(v[i]<j)x[2][j+v[i]]+=x[1][j];
	}
	while(scanf("%d",&i),i)printf("%d\n",x[2][i]);
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int kind = sc.nextInt();
        int[] di = new int[kind];

        int[] count = new int[n];
        for(int i = 0; i<n; i++){
            count[i] = 0;
        }

        for(int i = 0; i<kind; i++){
            di[i] = sc.nextInt();
            for(int j = 0; j<di[i]; j++){
                count[sc.nextInt() - 1]++;
            }
        }

        int trickCount = 0;
        for(int i = 0; i<n; i++){
            if(count[i] == 0){
                trickCount++;
            }
        }

        System.out.println(trickCount);
    }
}

Measured memory_bytes: 46040
N = gets.to_i
A = gets.split.map &:to_i
L = Array.new(N)
R = Array.new(N)

N.times do |i|
  L[i] = if i.zero? then A[i] else A[i].gcd L[i-1] end
end

(N-1).downto(0) do |i|
  R[i] = if i == N - 1 then A[i] else A[i].gcd R[i+1] end
end

ans = 0
N.times do |i|
  l = if i.zero? then 0 else L[i-1] end
  r = if i == N - 1 then 0 else R[i+1] end
  x = l.gcd(r)
  ans = x if ans < x
end

puts ans

Measured memory_bytes: 10124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  string s;
  cin >> s;
  vector<ll> a(3);
  rep(i,s.size()){
    if(s.at(i)=='R'){
      a.at(0)++;
    }
    if(s.at(i)=='G'){
      a.at(1)++;
    }
    if(s.at(i)=='B'){
      a.at(2)++;
    }
  }
  ll ans=a.at(0)*a.at(1)*a.at(2);
  for(ll i=0;i<n;i++){
    for(ll j=i+1;j<n;j++){
      if(2*j-i<n && s.at(i)!=s.at(j) && s.at(i)!=s.at(2*j-i) && s.at(j)!=s.at(2*j-i)){
        ans--;
      }
    }
  }  
  cout << ans;
}


Measured memory_bytes: 3580
n,p=map(int,input().split())
a=list(map(int,input().split()))
even=len([a[i] for i in range(len(a)) if a[i]%2==0])
odd=len([a[i] for i in range(len(a)) if a[i]%2!=0])

def make_c(n):
	nck=[1]
	child=n
	mother=1
	for i in range(1,n+1):
		nck.append(nck[i-1]*child//mother)
		child-=1
		mother+=1
	return nck
	


if(p==0):
	comb=make_c(odd)
	comb=comb[0::2]
	odd_comb=sum(comb)	
	ans=(2**even)*odd_comb
else:
	comb=make_c(odd)
	comb=comb[1::2]
	odd_comb=sum(comb)
	ans=(2**even)*odd_comb	
print(ans)

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


def main():
    n = int(input())
    h_list = list(map(int, input().split()))

    dp = [0] + [9999999999] * (n - 1)

    for i in range(n):
        if i > 0:
            dp[i] = min(dp[i], dp[i - 1] + abs(h_list[i] - h_list[i - 1]))
        if i > 1:
            dp[i] = min(dp[i], dp[i - 2] + abs(h_list[i] - h_list[i - 2]))

    print(dp[-1])


if __name__ == '__main__':
    main()


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

int n,m,x[100000],y[100000];
int cnt[100000],flg[100000];

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

	cin>>n>>m;
	REP(i,m) {
		cin>>x[i]>>y[i];
		x[i]--,y[i]--;
	}
	REP(i,n) cnt[i]=1;
	flg[0]=1;
	REP(i,m) {
		if(flg[x[i]]) flg[y[i]]=1;
		cnt[y[i]]++;
		cnt[x[i]]--;
		if(cnt[x[i]]==0) flg[x[i]]=0;
	}
	int ans=0;
	REP(i,n) if(flg[i]) ans++;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <map>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>

using namespace std;
#define set_precision cout << fixed << setprecision(10)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define repit(arr) for (auto it = arr.begin(); it != arr.end(); it++)
#define vi vector<int>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define vpi vector<pair<int,int>>
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define dsortA(arr) sort(arr.begin(), arr.end(), greater<int>())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define nth(v,n) nth_element(v.begin,v.begin+n-1,v.end())
#define dnth(v,n) nth_element(v.begin,v.begin+n-1,v.end(), greater<int>())
#define init(a)  memset((a),0,sizeof(a))
#define pi pair<int,int>
#define pb push_back
#define pl pair<ll,ll>
#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
long double EPS = 1e-9;

/*struct comp {
  bool operator() (const int& lhs, const int& rhs) const
  {return lhs<rhs;}
};*/

ll cel(ll a,ll b){return((a-1)/b+1);} 
ll gcd(ll a, ll b){
    if (a < b)swap(a, b);
    return (b == 0)? a: gcd(b, a % b);
}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

int main()
{
    FIO;
    ll n,k,d,x,y;
    cin>>x>>k>>d;
    y=cel(abs(x),d);
    if(y>=k){cout<<abs(x+(x>=0?-1:1)*k*d);}
    else{
        x=x+(x>=0?-1:1)*y*d;
        if((k-y)%2==0)cout<<abs(x);
        else cout<<abs(x+(x>=0?-1:1)*d);
    }
    return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <deque>
#include <iostream>
#include <list>
#include <string>

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

    std::string command;
    int key;
    std::deque<int> l;
    for (int i = 0; i < n; i++) {
        std::cin >> command;
        if (command[0] == 'i') {
            std::cin >> key;
            l.push_front(key);
        } else if (command.length() == 6) {
            std::cin >> key;
            std::deque<int>::iterator itr = find(l.begin(), l.end(), key);
            if (itr != l.end()) l.erase(itr);
        } else if (command[6] == 'F') {
            l.pop_front();
        } else if (command[6] == 'L') {
            l.pop_back();
        }
    }

    for (int i = 0; i < l.size() - 1; i++) {
        std::cout << l[i] << " ";
    }
    std::cout << l.back() << std::endl;

    return 0;
}

Measured memory_bytes: 5280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
 
 
int main(){
    int n,k;
    cin>>n>>k;
    vector<ll> dp(n,0),l(k),r(k);
    vector<vector<ll>> xxx(k,vector<ll>(n,0));
    rep(i,k){
        cin>>l[i]>>r[i];
    }
    dp[0]=1;
    for(int i=1;i<n;i++){
        rep(j,k){
            if(i-l[j]>=0&&i-r[j]<=0)xxx[j][i]=dp[i-l[j]]+xxx[j][i-1];
            else if(i-l[j]>=0&&i-r[j]>=0) xxx[j][i]=xxx[j][i-1]+(-dp[i-r[j]-1]+dp[i-l[j]]);
            xxx[j][i]%=998244353;
            dp[i]+=xxx[j][i];
            dp[i]%=998244353;
        }
    }
    while(dp[n-1]<0){
        dp[n-1]+=998244353;
    }
    cout<<(dp[n-1]+998244353)%998244353<<endl;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
const ll INF = 1LL << 60;

int N, M;
vector<ll> a, b;
vector<ll> c;
vector<vector<ll>> dp;
int main(){
  cin >> N >> M;
  a.resize(M), b.resize(M), c.resize(M, 0);
  REP(i, M){
    cin >> a[i] >> b[i];
    REP(j, b[i]){
      int key;
      cin >> key;
      key--;
      c[i] += (1 << key);
    }
  }
  dp.resize(M+10, vector<ll>(5000, INF));
  dp[0][0] = 0;
  REP(i, M){
    for(int j = 0; j < (1<<N); j++){
      if(dp[i+1][j] > dp[i][j]){
        dp[i+1][j] = dp[i][j];
      }
      dp[i+1][j | c[i]] = min(dp[i+1][j | c[i]], dp[i][j] + a[i]);
    }
  }
  
  cout << (dp[M][(1<<N)-1] < INF ? dp[M][(1<<N)-1] : -1) << endl;
  return 0;
}


Measured memory_bytes: 39808
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = null;
		try {
			input = br.readLine();
			br.close();
		} catch (IOException e) {
		}

		String [] abc = input.split(" ");

		int a = Integer.parseInt(abc[0]);
		int b = Integer.parseInt(abc[1]);
		int c = Integer.parseInt(abc[2]);
		
		if (a < b){
		    if(b < c){
                System.out.println("Yes");
		    }else{
		        System.out.println("No");
		    }
		}else{
            System.out.println("No");
		}
	}
}


Measured memory_bytes: 24476
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	ll X,Y; 
	cin >> X >> Y;
	if(X%Y ==0) cout << -1 << endl;
	else cout << X << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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

constexpr ll INF = 1ll<<60;

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 S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
std::map<ll, ll> mp;
std::vector<ll> vs;

const std::string march = "MARCH";

int main()
{
  std::cin >> N;

  rep( i, N ) {
    std::string S;
    std::cin >> S;
    ++mp[S[0]];
  }

  itr( it, mp ) if( march.find(it->first) != std::string::npos && it->second > 0 )
    vs.emplace_back( it->second );

  ll ans = 0;

  rep( i, vs.size() ) rep( j, i ) rep( k, j )
    ans += vs[i]*vs[j]*vs[k];

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
const double pi = 3.14159265359;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n;
int a, b, w;

int main()
{
	cin >> w >> a >> b;

	int v[4];
	v[0] = a;
	v[1] = b;
	v[2] = a + w;
	v[3] = b + w;

	sort(v, v + 4);
	
	int d = v[3] - v[0] - 2 * w;
	
	cout << max(d, 0) << endl;

	return 0;
}



Measured memory_bytes: 256
/*
Author: Babin Dutta
*/
 
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define inf 1e18
#define mm 998244353
 
ll power(ll x, ll y, ll p)
{
    ll res = 1;  
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modInverse(ll A,ll M)
{
    return power(A,M-2,M);
}

void solve(){
    ll n; cin>>n;
    ll x = n/1000;
    if(n%1000 != 0) x++;
    ll y = x*1000;
    ll ans = y-n;
    cout<<ans<<endl;
}
 
int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cctype>

using namespace std;

int PQR[3],NOT[3]={2,1,0},now;
string exp;

int fomula(){
  if(exp[now]=='('){
    now++;
    int res=fomula();
    if(exp[now]=='+'){
      now++;
      res=max(res,fomula());
    }
    if(exp[now]=='*'){
      now++;
      res=min(res,fomula());
    }
    now++;
    return res;
  }
  else if(isdigit(exp[now])){
    return exp[now++]-'0';
  }
  else if(isupper(exp[now])){
    return PQR[exp[now++]-'P'];
  }
  else if(exp[now]=='-'){
    now++;
    return NOT[fomula()];
  }
}

int main(void){

  while(cin >> exp){
    if(exp==".")break;
    int cnt=0;
    for(PQR[0]=0;PQR[0]<3;PQR[0]++){
      for(PQR[1]=0;PQR[1]<3;PQR[1]++){
	for(PQR[2]=0;PQR[2]<3;PQR[2]++){
	  now=0;
	  cnt+=(2==fomula());
	}
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define SIZE 100
#define rep(i, N) for (i = 0; i < N; i++) //制御変数iを用いてN回転
#define array(N, t) ((t)*)calloc(N, sizeof(t)) //t型N要素の配列を動的確保後0クリア(freeを忘れずに)
#define zero(a); {int iter; rep(iter, sizeof(a)/sizeof((a)[0])) (a)[iter]=0;} //1次元配列aのゼロ初期化?
typedef long long ll;
void printa_int(int *a, int size); //int型の1次元配列aを出力(for debug)

int N, M, X;
int A[12][13];
int Prog[12];

int money(int idx) {
    int i, min = -1, flag = 1;
    rep(i, M) {
        Prog[i] += A[idx][i + 1];
        if (Prog[i] < X) flag = 0;
    }
    if (flag) {
        rep(i, M) {
            Prog[i] -= A[idx][i + 1];
        }
        return A[idx][0];
    }
    for (i = idx + 1; i < N; i++) {
        int temp = money(i);
        if (temp == -1) continue;
        if (min == -1 || min > temp)
            min = temp;
    }
    rep(i, M) {
        Prog[i] -= A[idx][i + 1];
    }
    if (min != -1) min += A[idx][0];
    return min;
}

int main() {
    int i, j, min = -1;
    scanf("%d %d %d", &N, &M, &X);
    rep(i, N) {
        scanf("%d", &A[i][0]);
        rep(j, M) {
            scanf("%d", &A[i][j + 1]);
        }
    }
    rep(i, N) {
        int temp = money(i);
        if (temp == -1) continue;
        if (min == -1 || min > temp)
            min = temp;
    }
    printf("%d\n", min);
    return 0;
}

void printa_int(int *a, int size) {
    int i;
    for (i = 0; i < size; i++)
        printf("%d, ", a[i]);
    printf("\n");
}

Measured memory_bytes: 1724
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    for(int i=1; i<=(y2-y1); i++)
        printf("U");
    for(int i=1; i<=(x2-x1); i++)
        printf("R");
    for(int i=1; i<=(y2-y1); i++)
        printf("D");
    for(int i=1; i<=(x2-x1); i++)
        printf("L");

    printf("L");
    for(int i=1; i<=(y2-y1)+1; i++)
        printf("U");
    for(int i=1; i<=(x2-x1)+1; i++)
        printf("R");
    printf("D");

    printf("R");
    for(int i=1; i<=(y2-y1)+1; i++)
        printf("D");
    for(int i=1; i<=(x2-x1)+1; i++)
        printf("L");
    printf("U\n");

    return 0;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskD {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int ans = 0;
            int count = 0;

            for (int i = 1; i <= n; i++) {
                int cn = in.nextInt();
                if (i == cn) {
                    count++;
                } else {
                    ans += ++count / 2;
                    count = 0;
                }
            }
            ans += ++count / 2;
            count = 0;

            out.println(ans);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



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

using namespace std;

//aとbの最大公約数を算出（ユークリッドの互除法）
long long gcd(long long a, long long b)
{
	if(b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

int main()
{
	int n, x;
	cin >> n >> x;
	
	vector<long long> v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i];
	}
	
	vector<long long> tmp;
	for(int i = 0; i < n; i++) {
		tmp.push_back(abs(v[i] - x));
	}
	
	long long ans = tmp[0];
	for(long long i = 1; i < tmp.size(); i++) {
		ans = gcd(ans, tmp[i]);
	}
	
	cout << ans << endl;
    return 0;
}

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

int main() {
	char c;
	cin >> c;
	switch (c) {
	case 'a': case 'i': case 'u': case'e': case 'o':
		cout << "vowel" << endl;
		break;
	default:
		cout << "consonant" << endl;
		break;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

int main() {
    long n, d, ans = -1e9;
    cin >> n >> d;
    if (n % (2 * d + 1) == 0) {
        cout << n / (2 * d + 1) << endl;
    } else {
        cout << n / (2 * d + 1) + 1 << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace A___T_or_T
{
    class Program
    {
        static void Main(string[] args)
        {
            var N_A_B = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = N_A_B[0], A = N_A_B[1], B = N_A_B[2];

            Console.WriteLine(Math.Min(A * N, B));
        }
    }
}


Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	ll n;
	cin >> n;
	for (int h = 1; h <= 3500; h++) {
		for (int w = 1; w <= 3500; w++) {
			ll nume = (n * h * w);
			ll deno = (4 * h * w - n * (h + w));
			if (deno <= 0 || nume % deno != 0) continue;
			cout << h << " " << w << " " << nume / deno << endl;
			return;
	}
	}
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  ll n,m;
  cin>>n>>m;
  ll l[100000],r[100000];
  ll mx=BIG,mn=0;
  rep(i,m){
    cin>>l[i]>>r[i];
    mx=min(mx,r[i]);
    mn=max(mn,l[i]);
  }
  //cout<<mn<<" "<<mx<<endl;
  int ans=mx-mn+1;
  if(ans<=0) ans=0;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn= 5e5+5;
#define mod 1000000007
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    ll n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int ans=INT_MAX;
    for(int i=0;i<n;i++){
        int temp=0;
        while(arr[i]%2==0){
            arr[i]=arr[i]/2;
            temp++;
        }
        ans=min(temp,ans);
    }
    cout<<ans;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000010
using namespace std;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
vector<int> num(200);
vector<int> num_odd(200);
vector<int> dp(1000011,INF);
vector<int> dp_odd(1000011,INF);
int main()
{
	int i = 0;
	while(i <= 185)
	{
		long tmp = i*(i+1)*(i+2)/6;
		num[i] = tmp;
		if(num[i] % 2) num_odd.push_back(tmp);
		i++;
	}
	dp[0] = dp_odd[0] = 0;
	for(int i=0; i<num.size(); i++)
	{
		for(int j=num[i]; j<=1000000; j++)
		{
			dp[j] = min(dp[j], dp[j - num[i]] + 1);
		}
	}
	for(int i=0; i<num_odd.size(); i++)
	{
		for(int j=num_odd[i]; j<=1000000; j++)
		{
			dp_odd[j] = min(dp_odd[j], dp_odd[j - num_odd[i]] + 1);
		}
	}
	int N;
	while(cin >> N, N)
	{
		cout << dp[N] << " " << dp_odd[N] << endl;
	}
	return 0;
}



Measured memory_bytes: 10576
import java.io.*;
import java.util.*;
public class Main{
	static String s,t;
	public static String lcs(){
		int n=s.length();
		int m=t.length();
		//System.out.println(s+":"+t);
		int[][] dp=new int[n+1][m+1];
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				if(s.charAt(i-1)==t.charAt(j-1)){
					dp[i][j]=dp[i-1][j-1]+1;
				}
				else{
					dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1]);
				}
			}
		}
		
		char[] ans=new char[dp[n][m]];
		int x=dp[n][m],i1=n,j1=m,ind=ans.length-1;
		while(i1!=0&&j1!=0){
			if(s.charAt(i1-1)==t.charAt(j1-1)){
				ans[ind--]=s.charAt(i1-1);
				i1--;
				j1--;
			}
			else{
				if(dp[i1-1][j1]>dp[i1][j1-1]){
					i1--;
				}
				else{
					j1--;
				}
			}
		}
		return new String(ans);
	}
	public static void main(String[] args) throws IOException{
    	 BufferedReader br = new BufferedReader( 
                              new InputStreamReader(System.in)); 
     	s=br.readLine();
     	t=br.readLine();
     	System.out.println(lcs());

	}
 }


Measured memory_bytes: 82476
#include<iostream>
#include<unordered_map>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<unordered_set>
#include<map>
#include<iomanip>



using namespace std;


int main() 
{
    int n;
    cin >> n;
    vector<int> arr(n);
    int i;
    unordered_map<int, int> map;
    for (i = 0; i < n; ++i) {
        cin >> arr[i];
        map[arr[i]]++;
    }
    long long ans=0,val;
    unordered_map<int, int>::iterator itr;
    for (itr = map.begin(); itr != map.end(); ++itr) {
        val = itr->second;
        ans += ((val) * (val - 1)) / 2;

    }
    long long curr_ans = ans;
    long long curr_val;
    for (i = 0; i < n; ++i) {
        curr_val = map[arr[i]];
        curr_ans = ans - ((map[arr[i]]) * (map[arr[i]] - 1)) / 2 + ((map[arr[i]] - 1) * (map[arr[i]] - 2)) / 2;
        cout << curr_ans << "\n";

    }
   



}
    


Measured memory_bytes: 8392
package main

import (
	"fmt"
)

func main() {
	var n, m, d float64
	fmt.Scan(&n, &m, &d)
	mul := 2.0
	if int(d) == 0 {
		mul = 1.0
	}
	fmt.Println((n - d) * mul * (m - 1) / (n * n))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(in) in.begin(), in.end()

string to_s(int a) {
  string s = to_string(a);
  while (s.size() - 6) s = "0" + s;
  return s;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> in(n);
  rep(i, m) {
    int p, y;
    cin >> p >> y;
    p--;
    in[p].push_back({y, i});
  }
  vector<string> out(m);
  rep(i, n) {
    sort(all(in[i]));
    rep(j, in[i].size()) out[in[i][j].second] = to_s(i + 1) + to_s(j + 1);
  }
  rep(i, m) cout << out[i] << endl;
}


Measured memory_bytes: 12416
// inputに入力データ全体が入る
function Main(input) {
  	tmp = input.split(" ");
	var flag = 0;

  if(Number(tmp[0]) < Number(tmp[1])){
    flag = 0;
  }
  else {
    flag = 10;
  }
	
 	//出力
 	console.log(flag);
 }
 //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
 Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <limits>
#include <iterator>
#include <cmath>

int main() {
  int N;
  int T, A;
  // int H[N];
  std::cin >> N;
  std::cin >> T >> A;
  std::istream_iterator<int> it(std::cin);
  int p = -1;
  double t;
  double min = std::numeric_limits<double>::infinity();
  for (int i = 0; i < N; ++i) {
    int H = *it;
    if (i < N - 1) ++it;
    t = (double)T - 0.006 * H;
    double diff = std::fabs(t - A);
    if (diff < min) {
      p = i;
      min = diff;
    }
  }
  std::cout << p + 1;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var a = int.Parse(input[0]);
        var b = int.Parse(input[1]);

        if (a * b % 2 == 0)
        {
            Console.WriteLine("Even");
            return;
        }
        Console.WriteLine("Odd");
    }
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		int N, K;
		cin >> N >> K;
		cout << (K*2-1 <= N ? "YES" : "NO") << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 256
/*
Author: Fuadul Hasan(fuadul202@gmail.com)
BSMRSTU,Gopalganj
*/
#include<bits/stdc++.h>
using namespace std;

void    		print(int n)    {printf("%d ", n);}
void    		printl(long long n)     {printf("%I64d ", n);}
long long    	readline(){long long x;scanf("%I64d", &x);return x;}
/*
1.#define  gcd(a,b) __gcd(a,b) 2. #define  lcm(a,b) (a*b)/gcd(a,b) 3. #define  PI acos(-1.0) 4.#define  sqr(x) ((x)*(x))
5.#define  min3(a,b,c) min(a,min(b,c))6.#define  min4(a,b,c,d) min(d,min(a,min(b,c)))7.#define  max3(a,b,c) max(a,max(b,c))
8.#define  max4(a,b,c,d) max(d,max(a,max(b,c)))
*/
//.............ignore it................//
/*....... scanf.......*/
template <typename T> inline void readline(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';n = n * f;}
template <typename T, typename TT> inline void readline(T &n, TT &m) { readline(n); readline(m); }
template <typename T, typename TT, typename TTT> inline void readline(T &n, TT &m, TTT &l) { readline(n, m); readline(l);}
/*..........error........*/
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {
  vector<string>v; stringstream ss(s); string x;
  while (getline(ss, x, c))v.emplace_back(x); return move(v);
} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}
//............ignore it..................//

typedef  pair<int, int> ii;
typedef  std::vector<ii> vii;
#define  vi   std::vector<int>
#define  vll  std::vector<ll>
#define  all(n) n.begin(),n.end()
#define  mpsi std::map<string, int>
#define  pb    push_back
#define  ll    long long int
#define  nl    printf("\n");
#define  happy  cin.tie(0);
#define  coding ios::sync_with_stdio(false);

const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)2e18 + 5;
const int N             = 1e6 + 5;
const int N1            = 3e5 + 5;

int siv[N1];
int solve()
{
	//happy coding
	int n;
	cin>>n;
	cout<<(n+1)/2<<endl;
	//error()
	return 0;
}

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

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


int main() {
    int a, b, res = 0; ;
    cin >> a >> b;
    int maxi = max(a, b);
    int mini = min(a,b);
    res += maxi;
    maxi--;
    res += max(maxi,mini);
    cout << res;    
    cout << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

ans = [-1] * n
for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if ans[s] != -1 and ans[s] != c:
        print(-1)
        exit()
    ans[s] = c

if n > 1 and ans[0] == 0:
    print(-1)
    exit()

if ans[0] == -1:
    if n == 1:
        ans[0] = 0
    else:
        ans[0] = 1
for i in range(1, n):
    if ans[i] == -1:
        ans[i] = 0
print(''.join(map(str, ans)))


Measured memory_bytes: 9204
n=int(input())
l=list(map(int,input().split()))
a=[0]*(10**6+1)
for i in range(n):
    if(a[l[i]]==0):
       for j in range(2*l[i],10**6+1,l[i]):
           a[j]=2
    a[l[i]]+=1
print(a.count(1))       


Measured memory_bytes: 32216
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    int x;
    rep(i,n){
        cin >> a[i];
        if (a[i] == 1){
            x = i;
        }
    }
    cout << (n - 1 + k - 2) / (k - 1) << endl;
} 


Measured memory_bytes: 640
#include <cassert>// c
#include <ctime>
#include <iostream>// io
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>// container
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <algorithm>// other
#include <utility>
#include <complex>
#include <numeric>
#include <functional>
#include <random>
#include <regex>

using namespace std;
typedef long long ll;

#define ALL(c) (c).begin(),(c).end()
#define FOR(i,l,r) for(int i=(int)l;i<(int)r;++i)
#define REP(i,n) FOR(i,0,n)
#define FORr(i,l,r) for(int i=(int)r-1;i>=(int)l;--i)
#define REPr(i,n) FORr(i,0,n)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end())
//debug
#define DUMP(x)  cerr << #x << " = " << (x)
#define LINE()    cerr<< " (L" << __LINE__ << ")"

template<typename T,typename U> T pmod(T x,U M){return (x%M+M)%M;}

stringstream ss;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	ss   <<fixed <<setprecision(20);
	cout <<fixed <<setprecision(20);
	cerr <<fixed <<setprecision(20);

	while(true){
		vector<string> str(3);
		REP(i,3){
			cin >> str[i];
			if(str[i]=="0") return 0;
		}

		vector<vector<pair<int,int>>> check;
		REP(y,3){
			vector<pair<int,int>> ls;
			REP(x,3)ls.push_back(make_pair(y,x));
			check.push_back(ls);
		}
		REP(x,3){
			vector<pair<int,int>> ls;
			REP(y,3)ls.push_back(make_pair(y,x));
			check.push_back(ls);
		}
		{
			vector<pair<int,int>> ls;
			REP(i,3)ls.push_back(make_pair(i,i));
			check.push_back(ls);
		}
		{
			vector<pair<int,int>> ls;
			REP(i,3)ls.push_back(make_pair(i,2-i));
			check.push_back(ls);
		}

		bool bwin=false,wwin=false;
		for(auto ls:check){
			bool ok=true;for(auto p:ls)if(str[p.first][p.second]!='b')ok=false;
			if(ok)bwin=true;
		}
		for(auto ls:check){
			bool ok=true;for(auto p:ls)if(str[p.first][p.second]!='w')ok=false;
			if(ok)wwin=true;
		}
		if(bwin == wwin){
			cout <<"NA"<<endl;
		}else if(bwin){
			cout <<"b" <<endl;
		}else if(wwin){
			cout <<"w" <<endl;
		}
	}

 	return 0;
 }

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

int main() {
	int ans = 0;
	int K, S; cin >> K >> S;
	
	for (int i = 0; i <= K; i++)
	{
		for (int j = 0; j <= K; j++)
		{
			int k = S - i - j;
			if (k >= 0 && k <= K) ans++;
		}
	}

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

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

string YorN(bool P) { if (P)return "Yes"; else return "No"; }

int main() {

    char c;
    cin >> c;
    
    cout << ((c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') ? "vowel" : "consonant") << endl;

    return 0;

}

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

int N,W;
long long dp[110][100010];

struct Objeto{
    int peso;
    int valor;
};

Objeto objetos[120];

int main(){
    cin>>N>>W;
    for(int i=1;i<=N;i++) {
        cin>>objetos[i].peso>>objetos[i].valor;
    }

    for(int j=0;j<=W;j++){
        dp[0][j]=0;
    }

    for (int i=1;i<=N;i++){     //i percorre as linhas que são os pesos de cada objeto
        for (int j=0;j<=W;j++){ //j percorre as colunas que são o peso de 0 ate W , pois assim verificcamos se o peso do objeto sendo visto é menor maior ou igual ao o do j ..
            dp[i][j]=0;
            if(j<objetos[i].peso){
                dp[i][j]=max(dp[i][j],dp[i-1][j]); // se o peso da mochila nesse instante for menor do que o objeto avaliado, guardamos no o max entre o valor maximo anterior que a mochila conseguia guardar com os objetos anteriores avaliados e o dp[i][j]=0; 
            }else{
                dp[i][j]=max(objetos[i].valor+dp[i-1][j-objetos[i].peso],dp[i-1][j]);
            }
        }
    }
    
    /*for (int i=0;i<=N;i++){     //i percorre as linhas que são os pesos de cada objeto
        for (int j=0;j<=W;j++){ //j percorre as colunas que são o peso de 0 ate W , pois assim verificcamos se o peso do objeto sendo visto é menor maior ou igual ao o do j ..
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<dp[N][W];
    
}

Measured memory_bytes: 82408
#include <iostream>
#include <algorithm>
#define REP(i,n) for(int i = 0;i < n; i++)
using namespace std;
int main(void){
    // Your code here!
    int n,x;
    cin>>n>>x;
    int a[100];
    REP(i,n)cin>>a[i];
    sort(a,a+n);
    int sum = 0;
    int count = 0;
    REP(i,n){
        sum += a[i];
        if(sum > x){
            cout<<count;
            return 0;
        }
        count++;
    }
    if(sum == x){
        cout<<n;
    }else{
        cout<<n-1;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int[] a=new int[5];
    for(int i=0;i<5;i++){
      a[i]=sc.nextInt();
      if(a[i]!=i+1){
        System.out.println(i+1);
        break;
      }
    }
      
  }
}


Measured memory_bytes: 35756
#include <iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

int main()
{
    int  a=0,b=0,i=0,j=0,k=0;
    cin >> a;
    //int aa[1000]={};
    vector <int> aa(a,0);
    for(i=0;i<a;i++){
        cin >> aa[i];
    }

    for(i=0;i<a;i++){
        b=aa[i];
        j=i-1;
        while(j>=0 && aa[j]>b){//????????°???
            aa[j+1]=aa[j];//??§???????????????????????????
            j--;
            aa[j+1]=b;//?°???????????????\???????????\??????????????????
        }

        for(k=0;k<a;k++){

            cout << aa[k];
            if(k<a-1){
                cout << ' ';
            }
        }
        cout << endl;
    }

return 0;

}

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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  const int dx = tx - sx, dy = ty - sy;

  // Path1
  cout << string(dy, 'U') << string(dx, 'R');

  // Path2
  cout << string(dy, 'D') << string(dx, 'L');

  // Path3
  cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';

  // Path4
  cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U';
  cout << endl;

  return 0;
}


Measured memory_bytes: 3640
// Last Change: 03/22/2020 21:28:18.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> cnt(N + 1, 0);
  for (auto &&e : A) {
    cin >> e;
    ++cnt[e];
  }

  auto combi = [](ll a) { return a * (a - 1) / 2; };

  ll goukei = 0;
  for (auto &&e : cnt) {
    goukei += combi(e);
  }

  for (auto &&e : A) {
    ll res = goukei - combi(cnt[e]) + combi(cnt[e] - 1);
    cout << res << endl;
  }
}


Measured memory_bytes: 6392