akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;


int main(){
	ll n;
	cin>>n;
	ll a=0,b=0;
	ll ans=0;
	for(ll i=2;i<=sqrt(n);i++){
		if(n%i==0 ){
			a=max(a,i);
			b=n/i;
		}
	}
	if(a!=0 && b!=0){
	    ans=(a+b)-2;
	}
	else if(a==0 && b==0){
	    ans=n-1;
	}
	cout<<ans;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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;
}
ll m;
vvl g,dpw,dpb;
vl ans;
pl dfs(ll v,ll par=-1){
    ll rb=1,rw=1;
    dpw[v].resize(g[v].size());
    dpb[v].resize(g[v].size());
    rep(i,g[v].size()){
        if(par==g[v][i])continue;
        pl p=dfs(g[v][i],v);
        dpb[v][i]=p.fi;dpw[v][i]=p.se;
        rb*=p.fi+p.se;rb%=m;
        rw*=p.se;rw%=m;
    }
    return {rb,rw};
}
void bfs(ll v,pl val,ll par=-1){
    ll deg=g[v].size();
    rep(i,deg){
        if(par==g[v][i]){
            dpb[v][i]=val.fi;
            dpw[v][i]=val.se;
        }
    }

    vl dplw(deg+1,1),dprw(deg+1,1),dplb(deg+1,1),dprb(deg+1,1);
    rep(i,deg)dplw[i+1]=dplw[i]*dpw[v][i]%m;
    rep(i,deg)dplb[i+1]=dplb[i]*(dpw[v][i]+dpb[v][i])%m;
    per(i,deg)dprw[i]=dprw[i+1]*dpw[v][i]%m;
    per(i,deg)dprb[i]=dprb[i+1]*(dpw[v][i]+dpb[v][i])%m;
    //rep(i,deg)cout << dpb[v][i] <<" ";cout << endl;
    //rep(i,deg)cout << dpw[v][i] <<" ";cout << endl;
    //rep(i,deg+1)cout << dplb[i] <<" ";cout << endl;
    ans[v]=dplb[deg];
    rep(i,deg){
        ll nv=g[v][i];
        if(nv==par)continue;
        ll z=(dplb[i]/*+dplw[i]*/)*(dprb[i+1]/*+dprw[i+1]*/)%m;
        ll zz=dplw[i]*dprw[i+1]%m;
        bfs(nv,{z,zz},v);
    }
}

int main(){
    ll n;cin >> n>> m;
    g.resize(n);dpw.resize(n),dpb.resize(n),ans.resize(n);
    rep(i,n-1){
        ll a,b;cin >> a >> b;a--;b--;
        g[a].pb(b);g[b].pb(a);
    }
    dfs(0);
    bfs(0,{1,1});
    rep(i,n)cout << ans[i] <<endl;
}

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

#define ___ ios::sync_with_stdio(0),  cin.tie(0);
#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;

int main(){___
  int x, y; cin >>  x >> y;
  if(4*x-y >=0 and 4*x-y <= 2*x and (4*x-y)%2==0 )  printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 3660
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = [str(i) for i in input().split()]
    count = 0

    for i in range(4):
        if a[0][i] == "+":
            count +=1
        else:
            count -=1
    print(count)

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

int main(){
    int N; cin >> N;
    map<string, long> m;
    for (int i = 0; i < N; i++)
    {
        string s; cin >> s;
        sort(s.begin(), s.end());
        m[s]++;
    }
    long ans=0;
    for(auto i : m){
        long j = i.second -1;
        ans += j *(j+1)/2;
    } 
    cout << ans << endl;
}

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

const long long int MOD = 1000000007;
const int MAX_K = 4040404;

long long int fac[MAX_K], finv[MAX_K], inv[MAX_K];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX_K; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
      finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long int COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int x, y;

int main(){
  cin >> x >> y;
  
  if((x + y) % 3 != 0){
    cout << 0 << endl;
    return 0;
  }
  
  int n = (2 * x - y) / 3, m = (2 * y - x) / 3;
  
  COMinit();
  cout << COM(n + m, m) << endl;
  
  return 0;
}

Measured memory_bytes: 94976
#include <cstdio>
using namespace std;

const int N = 200000;
char s[N + 1];
char t[N + 1];

int main() 
{
	scanf("%s%s", &s, &t);
	int c = 0;
	for (int i = 0; s[i]; ++i) if (s[i] != t[i]) ++c;
	printf("%d\n", c);
	return 0;
}


Measured memory_bytes: 2100
def main():
    n = int(input())
    c = input()
    i, j = 0, n-1
    ans = 0
    while i < j:
        if c[i] == "W" and c[j] == "R":
            ans += 1
            i += 1
            j -= 1
        if c[i] == "R":
            i += 1
        if c[j] == "W":
            j -= 1
    print(ans)

if __name__ == "__main__":
    main()

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

mt c;

void error(){
  cout << "No" << endl;
  exit(0);
}

int main(){
  c = mt(3,vl(3));
  for(ll i = 0;i < 3;i++){
    for(ll j = 0;j < 3;j++){
      cin >> c[i][j];
    }
  }
  for(ll i = 0;i < 2;i++){
    ll a1 = 0;
    ll a2 = 0;
    for(ll j = 0;j < 3;j++){
      a1 += c[i][j];
      a2 += c[(i+1)%3][j];

    }
    ll x = a2-a1;
    if(x%3 != 0) error();
    x /= 3;
    for(ll j = 0;j < 3;j++){
      c[(i+1)%3][j] -= x;
    }
  }
  for(ll j = 0;j < 3;j++){
    for(ll i = 0;i < 3;i++){
      if(c[i][j] != c[0][j]) error();
    }
  }
  cout << "Yes" << endl;

}


Measured memory_bytes: 256
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

const int N=2e5+10;
char s[N],t[N];
int n,m;
int main() {
    R(s);
    n=strlen(s);
    REP(i,n) {
        if ( s[i]=='S' ) t[m++]=s[i];
        else {
            if ( m>0 && t[m-1]=='S' ) m--;
            else t[m++]=s[i];
        }
    }
    t[m]=0;
    W(m);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 500009 /// Still trying to be one thing
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b;
    cout<<fixed<<setprecision(0);
    cin>>a>>b;
    if(a==1 || b==1){
        cout<<1<<endl;
        return 0;
    }
    cout<<(a*b+1LL)/2LL<<endl;
    return 0;   
}           



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int A[100],N,i,j,minj,temp,count=0;
  scanf("%d",&N);
  for(i=0;i<N;i++){scanf("%d",&A[i]);}
  
  for(i=0;i<N;i++)
    {
      minj=i;
      for(j=i;j<N;j++){
	if(A[minj]>A[j]){minj=j;}
	}
      if(i!=minj){
      temp=A[i];
      A[i]=A[minj];
      A[minj]=temp;
      count++;
      }
    }
  for(i=0;i<N;i++){printf("%d",A[i]);
      if(i!=(N-1)){printf(" ");}
      }
  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 604
#include <stdio.h>
#include <string.h>

int main(){
    char c[1005];
    int len,cnt,i;
    fgets(c,1005,stdin);
    while(strcmp(c,"0\n")){
        len = strlen(c)-1;
        cnt = 0;
        for(i=0;i<len;i++)cnt += c[i]-'0';
        printf("%d\n",cnt);
        fgets(c,1005,stdin);
    }
}

Measured memory_bytes: 944
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		// 計算
		int result = 0;
		if(a >= b && a >= c){
		    result = 10 * a + b + c;
		}else if(b >= a && b >= c){
		    result = 10 * b + a + c;
		}else{
		    result = 10 * c + a + b;
		}
		
		// 出力
		System.out.println(result);
		
	}
}


Measured memory_bytes: 21716
#include<stdio.h>
#define NUMBER 300
int main(void){
    int H[NUMBER],W[NUMBER],i,j,k,c=0;
    for(i=0;i<NUMBER;i++){
       scanf("%d %d",&H[i],&W[i]);
       if(H[i]==0&&W[i]==0)
         break;
      c++;
    }
    for(i=0;i<c;i++){
       for(j=0;j<H[i];j++){
          for(k=0;k<W[i];k++){
             putchar('#');
          }
       putchar('\n');
       }
    putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2064
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

vec P(100010),Left(100010),Right(100010);
ll func_left(ll s){
    ll res=1;
    ll x=s-2-Left[s];
    while(P[x]<P[s]){
        res++;
        x--;
    }
    return res;
}
ll func_right(ll t){
    ll res=1;
    ll y=t+2+Right[t];
    while(P[y]<P[t]){
        res++;
        y++;
    }
    return res;
}

int main(){
    int N;cin>>N;
    P[0]=pow(10,18);P[N+1]=pow(10,18);
    for(int i=1;i<=N;i++){
        cin>>P[i];
    }
    for(int i=1;i<=N;i++){
        Left[i]=0;
        int j=i-1;
        while(P[j]<P[i]){
            Left[i]+=1+Left[j];
            j=j-Left[j]-1;
        }
    }
    for(int i=N;i>=1;i--){
        Right[i]=0;
        int k=i+1;
        while(P[k]<P[i]){
            Right[i]+=1+Right[k];
            k=k+Right[k]+1;
        }
    }

    ll ans=0;
    for(int i=1;i<=N;i++){
        ll sum=0;
        //左側に大きい数がある場合
        if(Left[i]!=i-1){
            sum+=func_left(i)*((ll)1+Right[i]);
        }
        //右側
        if(Right[i]!=N-i){
            sum+=((ll)1+Left[i])*func_right(i);
        }
        ans+=sum*P[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

string solve(){
    ll N; cin >> N;
    vector<ll> A(N);
    ll sum = 0;
    for(auto &in:A){ cin >> in; sum += in; }
    if(sum%(N*(N+1)/2) != 0) return "NO";
    ll k = sum / (N*(N+1)/2);
    for(int i = 0; i < N;i++){
        ll d = A[(i+1)%N] - A[i];
        if(d - k > 0 || abs(d-k)%N != 0) return "NO";
    }
    return "YES";
}
int main(void) {
    ll N; cin >> N;
    vector<ll> A(N);
    ll sum = 0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        sum += A[i];
    }
    if(sum%(N*(N+1)/2) != 0){
        cout << "NO" << endl;
        return 0;
    }
    ll k = sum / (N*(N+1)/2);
    for(int i = 0; i < N;i++){
        ll d = A[(i+1)%N] - A[i];
        if(d - k > 0 || abs(d-k)%N != 0){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <unordered_map>

using namespace std;
char s[10];
int  st[26];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s);
        st[s[0]-'A']++;
    }
    printf("AC x %d\n",st[0]);
    printf("WA x %d\n",st[22]);
    printf("TLE x %d\n",st[19]);
    printf("RE x %d\n",st[17]);
    return 0;
}

Measured memory_bytes: 3820
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
#define rep(i,N) for(int i=0;i<(int)N;++i)
//cout << fixed << setprecision(20) << *** << endl;
typedef long long ll;
using namespace std;
//ユークリッド
ll gcd(ll a,ll b){
	ll t;
	if(a<b){
		t=a;
		a=b;
		b=t;
	}
	if(a%b==0)return b;
	return gcd(b,a%b);
}
//階乗
ll Factorial(ll a){
	ll b=1;
	for(ll i=a;i>=1;i--){
		b=b*i;
	}
	return b;
}
//素数判定
bool prime(ll n){
	for(ll i=2;i*i<=n;i++){
		if(n%i==0) return false;
	}
	return true;
}
int main()
{
	ll N;
	cin>>N;
	vector<ll>V;
	for(ll i=2;i<=1000000;i++){
		bool F=prime(i);
		if(F==true&&i>=N){
			cout<<i<<endl;
			break;
		}
	}
}

Measured memory_bytes: 256
c={
    'S':[1]*13,
    'H':[1]*13,
    'C':[1]*13,
    'D':[1]*13
}
n=int(input())
for i in range(n):
    a,b=input().split()
    c[a][int(b)-1]=0
for i in ['S','H','C','D']:
    for j in range(13):
        if c[i][j]==1:
            print(i,j+1)



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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int TC;
    cin >> TC;
    while (TC--) {
        int N;
        cin >> N;
        V<ll> A(N);
        string S;
        rep(i, N) cin >> A[i];
        cin >> S;

        V<ll> base;
        bool flg = 0;

        per(i, N) {
            if (S[i] == '0') {
                ll x = A[i];
                for (ll v : base) chmin(x, x ^ v);
                if (x) {
                    base.pb(x);
                }
                sort(ALL(base));
                reverse(ALL(base));
            } else {
                ll x = A[i];
                for (ll v : base) {
                    chmin(x, x ^ v);
                }

                if (x) {
                    flg = 1;
                }
            }
        }
        puts(flg ? "1" : "0");
    }
    return 0;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int _i=(first);_i<(last);++_i){cout<<#a<<"["<<_i<<"] = "<<(a)[_i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

    int L, R, d;
    cin >> L >> R >> d;
    int result = 0;
    FOR(i, L, R + 1) {
        if (i % d == 0) {
            ++result;
        }
    }
    cout << result << endl;
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int a[100010];

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

	rep(i,n) cin >> a[i];
	sort(a,a+n);

	int an = a[n-1];
	
	int ar = a[0], cmax = min(a[0],an - a[0]); 
	rep(i,n-1) if(chmax(cmax,min(a[i],an - a[i]))) ar = a[i];

	cout << an << " " << ar << endl;

	return 0;
}

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

using namespace std;

const int maxn = 1e5 + 10;
int n, a[maxn];

int main() {
    scanf("%d", &n);
    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        ans ^= a[i];
    }
    sort(a+1, a+1+n);
    n = unique(a+1, a+1+n)-a-1;
    if(ans) puts("No");
    else puts("Yes");
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

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++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
    int to;
    T cost;
    Edge() {};
    Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
    int n;
    bool directed;
    vector<vector<Edge<T>>> edges;
public:

    Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)){};
    Graph() {};

    void add(int from,int to, T cost) {
        edges[from].emplace_back(to, cost);
        if(!directed){
            edges[to].emplace_back(from,cost);
        }
    }

    int size() {
        return n;
    }
};


int main() {

    int N;

    cin >> N;

    string S;

    cin >> S;

    int ans = 0;

    REP(i,N-2){
        if(S[i] == 'A'){
            if(S[i+1] == 'B'){
                if(S[i+2] == 'C'){
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
a = [0, 0, 0]
b = [0, 0, 0]

3.times do |i|
  (p, q) = gets.chomp.split(' ').map(&:to_i)
  a[i] = p - 1
  b[i] = q - 1
end

c = [0, 0, 0, 0]
3.times do |i|
  c[ a[i] ] += 1
  c[ b[i] ] += 1
end

f = true
4.times do |i|
  if c[i] == 3 then
    f = false
    break
  end
end
  
puts (f ? 'YES' : 'NO')

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REP1(i,n) for(int i=1;i<=(int)(n);i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)


int main(){
  int N,temp=0,ans=0;
  cin >> N;
  vector<int> vec(N);
  REP(i,N)cin >> vec.at(i);

  REP(i,N){
    REP(i,N){
      if(vec.at(i)>vec.at(temp))temp=i;
    }
    FOR(i,temp+1,N){
      if(vec.at(i)==vec.at(temp))vec.at(i)=0;
    }

    if(vec.at(temp)==0)break;
    ans++;
    vec.at(temp)=0;
  }

  cout << ans << endl;
}

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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n, k; cin >> n >> k;
	vector<int> data(n);
	rep(i, n){
		int a; cin >> a;
		rep(j, a){
			int b; cin >> b;
			data.at(b-1)++;
		}
	}
	int sum = 0; 
	rep(i, n){
		if(data.at(i) == 0) sum++;
	}
	cout << sum;
} 

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#define ll long long
#define space putchar(' ')
#define endl putchar('\n')
#define debug puts("------------------------")
#define F(i,x,n) for(int i=x;i<=n;++i)
#define F_(i,x,n) for(int i=x;i>=n;--i)
using namespace std;
inline void read(int &a) {a=0;int c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b; }
inline int  Rem() {int a=0,c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*=b; }
inline void write(int x) {if(x>9)write(x/10);putchar('0'+x%10);}
inline void W(int x) {if(x<0){putchar('-'),x=-x;}write(x);}
/**/
const int N = 1e5+5;
int n,k,ans;
string s;
/**/
int main()
{
	// freopen("test.in","r",stdin);
	// freopen("test.out","w",stdout);
	read(n);read(k);
	cin>>s;
	for(int i=0;i<s.length()-1;i++) if(s[i]==s[i+1]) ans++;
	cout<<min(n-1,ans+2*k)<<'\n';
	return 0;
}

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




struct UnionFind {
  vector<int> par;

  UnionFind(int N) : par(N, -1){}

  // Aのrootを調べる
  int root(int A){
    if (par[A] < 0) return A;  // マイナスならそれはroot
    return par[A] = root(par[A]);
  }

  // rootの値をプラスに戻して返す(サイズ)
  int size(int A){
    return -par[root(A)];
  }

  bool same(int A, int B){
    return root(A) == root(B);
  }

  void connect(int A, int B){
    A = root(A);  
    B = root(B);
    if (size(A) < size(B))
      swap(A, B);        
    par[A] += par[B];  
    par[B] = A;
  }
};

int main(){
    ll n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    rep(i, m){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }

    UnionFind tree(n);
    vector<ll> ans(m);
    ans[m - 1] = n * (n - 1) / 2;
    for (int i = m - 1; i >= 1; i--){
        if (!tree.same(a[i], b[i])){
            ll res = tree.size(a[i]) * tree.size(b[i]);
            ans[i - 1] = ans[i] - res;
            tree.connect(a[i], b[i]);
        }
        else ans[i - 1] = ans[i];
    }
    rep(i, m) cout << ans[i] << endl;
}

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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

void solve(long long N, std::vector<long long> x, std::vector<long long> y) {
  auto dsu = atcoder::dsu(N + 1);
  vector<pair<ll, pair<ll, ll>>> v(N);
  REP(i, N) {
    v[i] = make_pair(x[i], make_pair(y[i], i));
  }
  sort(ALL(v));
  reverse(ALL(v));
  map<ll, ll> m;
  REP(i, N) {
    ll yy = v[i].second.first;
    ll ii = v[i].second.second;
    auto it = m.lower_bound(yy);
    while (it != m.end()) {
      dsu.merge(ii, it->second);
      if (dsu.size(ii) - 1 == i) {
        break;
      }
      it++;
    }
    m[yy] = ii;
  }
  REP(i, N) {
    cout << dsu.size(i) << endl;
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> x(N);
  std::vector<long long> y(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &x[i]);
    scanf("%lld", &y[i]);
  }
  solve(N, std::move(x), std::move(y));
  return 0;
}


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

int op(int a,int b,int i){
  if(i==0) return a + b;
  else return a - b;
}

char opSign(int i){
  if(i) return '-';
  else return '+';
}

int main(){
  char s[5];
  scanf("%s",&s);
  int A = s[0] - '0'; int B = s[1] - '0'; int C = s[2] - '0'; int D = s[3] - '0';
  for(int i=0;i<=1;i++){
    for(int j=0;j<=1;j++){
      for(int k=0;k<=1;k++){
        int ans = 0;
        ans += op(op(op(A,B,k),C,j),D,i);
        if(ans == 7){
          cout << A << opSign(k) << B << opSign(j) << C << opSign(i) << D << "=7" << endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
const int maxn = 200005;

int n,a[maxn];

int main() {
#ifdef suiyuan2009
  freopen("in.cpp","r",stdin);
#endif
  ll sum=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  ll ret=abs(sum-a[0]-a[0]);
  ll s=a[0];
  sum-=a[0];
  for(int i=1;i+1<n;i++){
    s+=a[i];
    sum-=a[i];
    ret=min(ret,abs(s-sum));
  }
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
    /*int x; cin >> x;
    if (x == 0)cout << 1 << endl;
    else cout << 0 << endl;
    */

    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll ans = a * c;
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int n,m,sum=0,f[40010][20],b[40010],dis[20][20];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		int xx,yy,zz;
		scanf("%d%d%d",&xx,&yy,&zz);
		dis[xx][yy]=zz;
		dis[yy][xx]=zz;
		sum+=zz;
    }
    for (int i=1;i<(1<<n);i++)
	  for (int j=1;j<=n;j++)
	    if (i>>(j-1)&1)
	      for (int k=j+1;k<=n;k++)
	        if ((i>>(k-1))&1) b[i]+=dis[j][k];
	memset(f,-10,sizeof(f));
	f[1][1]=0;
	int N=(1<<n)-1;
	for (int i=1;i<=N;i++)
	  for (int j=1;j<=n;j++)
	    if ((i>>(j-1))&1)
	    {
	    	for (int k=1;k<=n;k++)
	    	  if (!((i>>(k-1))&1)&&dis[j][k]) f[i|(1<<(k-1))][k]=max(f[i|(1<<(k-1))][k],f[i][j]+dis[j][k]);
	    	for (int k=N^i;k;k=(k-1)&(N^i))
	    	  f[i|k][j]=max(f[i|k][j],f[i][j]+b[k|(1<<(j-1))]);
	    }
	cout<<sum-f[N][n];
}

Measured memory_bytes: 3456
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

import itertools
import collections
seq = [i+1 for i in range(n)]
li = itertools.permutations(seq)
dic = collections.defaultdict()
for i,  each in enumerate(li):
    dic[each] = i

print(abs(dic[p] - dic[q]))


Measured memory_bytes: 10740
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b, c := intScanner(), intScanner(), intScanner()
	if a+b >= c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1772
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
using namespace std;

int C[500];
int S[500];
int F[500];

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N - 1; i++){
        cin >> C[i] >> S[i] >> F[i];
    }

    for(int i = 0; i < N - 1; i++){
        int cur_time = S[i];
        for(int j = i; j < N - 1; j++){
            if(cur_time < S[j]){
                cur_time = S[j];
            } else {
                if(cur_time % F[j] != 0){
                    cur_time = cur_time / F[j] * F[j] + F[j];
                }
            }
            cur_time += C[j];
        }
        cout << cur_time << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int c1,c2,c3;
	int card[11];
	while(scanf("%d %d %d",&c1,&c2,&c3)!=EOF){
		int i;
		int cnt=0;
		for(i=0;i<11;i++) card[i]=i;
		card[c1]=0;
		card[c2]=0;
		card[c3]=0;
		for(i=1;i<11;i++){
			if(card[i]>0&&c1+c2+card[i]<=20) cnt++;
		}
		if(cnt>=4){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

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

#define vi vector<int>
#define ll long long int

int main() {

    int N, K, Q;
    cin >> N >> K >> Q;

    vi P(100010, K-Q);

    int A;
    for (int i = 0; i < Q; i++) {
        cin >> A;
        P[A-1]++;
    }

    for (int i = 0; i < N; i++) {
        if (P[i] > 0) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }

    return 0;
}


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

#define ll long long int
#define str string
#define sec .second

ll MOD = 1000000007,INFL = 1ll << 60,INF = 1 << 30;
ll A[10000000] = {};
ll X[1000000] = {};
ll aiti[10000];
int dy[]={0, 0, 1, -1},dx[]={1, -1, 0, 0};
vector <ll> v;
ll a = 0,b = 0,c = 0,n = 0,sum = 0, max = INF;
str S;
bool an = false,bn = false;

int findDigits(int n) {
        int i = 0;
        while (n > 0) {

                X[i] = n%10;
                n /= 10;
                i++;
        }
        return i;
}


int main(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        //Code Line
cin >> a >> b;
if(a >= 13)cout << b << endl;
else if(a >= 6)cout << b / 2 << endl;
else cout << 0 << endl;
  //Code Line
        return 0;
}


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

int diagonal( int a, int b, int c ){
	if( a > c ) swap( a, c );
	if( b > c ) swap( b, c );
	return a*a + b*b;
}

int main()
{
	int a, b, c;
	while( cin >> a >> b >> c && !( a == 0 && b == 0 && c == 0 ) ){
		int dia_square = diagonal( a, b, c );

		int num;
		cin >> num;
		for( int i = 0; i < num; ++i ){
			int radius;
			cin >> radius;
			if( dia_square < radius * radius * 4 ){
				cout << "OK" << endl;
			}else{
				cout << "NA" << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
def solve(Mi,i):
	if Mi == 0: return True
	if i < n and 0 <= Mi <= sum(A[i:]):
		r1 = solve(Mi-A[i],i+1)
		if r1: return r1
		r2 = solve(Mi,i+1)
		if r2: return r2
n = input()
A = sorted(map(int,raw_input().split()))
q = input()
M = map(int,raw_input().split())
for Mi in M:
	print "yes" if solve(Mi,0) else "no"

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

int main(){
	int n;
	if(scanf("%d", &n)==EOF){return 0;}
	int count = 0;
	int count_sub;
	
	if(n<105){printf("0\n"); return 0;}
	for(int i = 105; i <= n; i++){
		count_sub = 0;
		if(i % 2 == 0){continue;}
		for(int j = 3; j < i; j++){
			if(i % j == 0){count_sub++;}
		}
		//その他j=1, i で割り切れる
		if(count_sub == 6){count++;}
	}

	printf("%d\n", count);
	return 0;

}

Measured memory_bytes: 1700
while True:
    a,op,b = [x for x in input().split()]
    if op == "+": print(int(a)+int(b))
    if op == "-": print(int(a)-int(b))
    if op == "*": print(int(a)*int(b))
    if op == "/": print(int(a)//int(b))
    if op == "?": break


Measured memory_bytes: 5604
#include <iostream>
#include<stdio.h>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<math.h>
#include<cmath>
#include<stack>
using namespace std;
int a[100010];
int main()
{
  long long int r,m=0,n,i,j,k,l,rmid,lmid;
  cin>>n>>k>>m;
  for(i=0;i<k;i++)
  {
      cout<<m<<" ";
  }
  for(i=k;i<n;i++)
    {
        if(m==1000000000)
            cout<<1<<" ";
        else
            cout<<1+m<<" ";
    }
  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };


ll x;
bool j = true;

int main() {

	cin >> x;

	ll i = 0;
	while (j) {
		ll a = pow(i, 5);

		for (ll k = 1; ((a - (k * k * k * k * k) >= x) || ((a + (k * k * k * k * k)) <= x)); k++) {
			if (a - (k * k * k * k * k) == x) {
				cout << i << " " << k << endl;
				j = false;
				break;
			}
			else if (a + (k * k * k * k * k) == x) {
				cout << i << " " << -1 * k << endl;
				j = false;
				break;
			}
		}
		i++;
	}

	return 0;
}


Measured memory_bytes: 4096
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(std::vector<long long> x);

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

void Main(){
    std::vector<long long> x(5);
    for(int i = 0 ; i < 5 ; i++){
        scanf("%lld",&x[i]);
    }
    solve(std::move(x));
}

void solve(std::vector<long long> x){
    REP(i, 5){
        if(x[i] == 0){
            cout << i+1 << el;return;
        }
    }
}



Measured memory_bytes: 3700
N = int(input())
a = list(map(int, input().split()))
color = [0] * 9

for i in a:
    color[min(i, 3200) // 400] += 1

x = 8 - color[:-1].count(0)
ans = [max(1, x), x + color[8]]
print(' '.join(map(str, ans)))

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

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "Yes" : "No")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

const int siz = 2e5 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "3";



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

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    int d, t, s;
    cin >> d >> t >> s;

    cout << yn(t * s >= d) << "\n";

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 3520
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>
#include <iomanip>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	ll q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	
	ll bottom = min( {4LL * q, 2LL * h, s} );
	ll ans = min(d * (n / 2LL) + (n % 2LL) * bottom, n * bottom);
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3520
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  cin >> A;
  sort(A.begin(), A.end());
  vector<int> v(202020, 0);
  for (int i = 0; i < N; i++) {
    v[A[i]]++;
  }
  int unq = 0;
  for (int i = 0; i < 202020; i++) {
    if (v[i] != 0) unq++;
  }
  debug(unq);
  if ((N - unq) % 2 == 1) {
    unq--;
  }
  cout << unq << endl;
  return 0;
}

Measured memory_bytes: 4572
#include<stdio.h>
int main(){
    int i,k,x;
    const int n=999999;
    int prime[n+1];
    for(i=2;i<=n;i++){
        prime[i]=1;
    }
    for(i=2;i*i<=n;i++){
        if(prime[i]){
            for(k=2*i;k<=n;k+=i){
                prime[k]=0;
            }
        }
    }
    prime[0]=0;
    prime[1]=0;
    int count=0;
    while(scanf("%d",&x)!=EOF){
        count++;
        int cnt=0;
        for(i=x;i>0;i--){
            if(prime[i]==1){
                cnt++;
            }
        }
        printf("%d\n",cnt);
        if(count==31)  
            break;  
    }
    return 0;
}

Measured memory_bytes: 4500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
  int N;
  cin >> N;
  ll A[N];
  ll sum = 0;
  ll ans1 = 0;
  int pre = 0; // i-1番目までの和の符号。1:正, -1:負, 0:初期値
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<N; i++){
    int next;
    sum += A[i];
        
//    cout << sum << endl;
    if(pre > 0){
      if(sum < 0) ;
      else if(sum >= 0){
        ans1 += (sum+1);
        sum = -1;
      }
    }else if(pre < 0){
      if(sum > 0) ;
      else if(sum <= 0){
        ans1 += (-sum+1);
        sum = 1;
      }
    }
    
    if(pre == 0) {
      next = 1;
      if(sum>0) ;
      else {
        ans1 = (-sum+1);
        sum = 1;
      }
    }else{
      next = 0-pre;
    }    
    pre = next;
//    cout << pre << endl;
  }
  
  sum = 0;
  ll ans2 = 0;
  pre = 0; // i-1番目までの和の符号。1:正, -1:負, 0:初期値
  for(int i=0; i<N; i++){
    int next;
    sum += A[i];
        
//    cout << sum << endl;
    if(pre > 0){
      if(sum < 0) ;
      else if(sum >= 0){
        ans2 += (sum+1);
        sum = -1;
      }
    }else if(pre < 0){
      if(sum > 0) ;
      else if(sum <= 0){
        ans2 += (-sum+1);
        sum = 1;
      }
    }
    if(pre == 0) {
      next = -1;      
      if(sum<0) ;
      else {
        ans2 = (sum+1);
        sum = -1;
      }
    }else{
      next = 0-pre;
    }    
    pre = next;
//    cout << pre << endl;
  }
  
  cout << min(ans1, ans2) << endl;
  return 0;
}

Measured memory_bytes: 1024