akhauriyash/Code-Regression huggingface dataset:
#include <iterator>
#include <unordered_map>
#include<iostream>
using namespace std;

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

    unordered_map<long long, int> map;
    long long a;
    for(int i = 0; i < n; i++){
        cin >> a;
        unordered_map<long long, int>::iterator itr = map.find(a);
        if( itr != map.end() ) {
            map[a]++;
        } else {
            map[a] = 1;
        }
    }

    long long ans = 0;
    for(unordered_map<long long, int>::iterator itr = map.begin(); itr != map.end(); ++itr) {
        if(itr -> first != itr -> second){
            if(itr -> first > itr -> second){
                ans += itr -> second;
            }else{
                ans += itr -> second - itr -> first;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4260
from collections import deque
N = int(input())
C = input()
r = deque()
lr = 0
for i in range(N):
  if C[i] == 'R':
    lr += 1
    r.append(i)
ans = 0
for i in range(N):
  if lr == 0:
    break
  if C[i] == 'W':
    if i < r[-1]:
      ans += 1
      r.pop()
      lr -= 1
    else:
      break
print(ans)

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

int main(){
    int N, L;
    cin >> N >> L;

    int tt = L;
    vector<int> app(N);
    for(int i = 0; i < N; i++){
        app[i] = tt;
        tt++;
    }
    int num, in = 101;
    for(int i = 0; i < N; i++){
        if(abs(in) > abs(app[i])){
            in = app[i];
            num = i;
        }
    }
    app[num] = 0;
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans += app[i];
    }

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


Measured memory_bytes: 256
import math
import sys
input=sys.stdin.readline
from collections import deque
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())
 
def ss_raw():
    return input().split()
 
def ints_raw():
    return tuple(map(int, ss_raw()))


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


DIV = 10**9+7

def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret
    
def mod_modify(a,mod):
    return (a+mod)%mod

def cal_ABC(A,B,C):
    AC = A//C + (1 if A%C>0 else 0)
    BC = (B//C)
    return max(BC-AC+1,0)


def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)

def main():
    N,K = ints_raw()
    MAX2 = (N-1)*(N-2)//2
    if K > MAX2:
        print(-1)
        return
    print(N-1+MAX2-K)
    for idx in range(2,N+1):
        print (1,idx)
    b = 0
    for idx in range(2,N+1):
        for jdx in range(idx+1,N+1):
            if b >= MAX2-K:
                return 
            print (idx,jdx)
            b+=1
            
main()


Measured memory_bytes: 42736
#include <bits/stdc++.h>
 
#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct Edge{int from, to; ll cost;};
 
const ll MOD = 1000000007;
const long double EPS = 10e-10;
 
int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int N,NC;
    cin >> N >> NC;
    vector< vector<int> > d(NC, vector<int>(NC));
    vector< vector<int> > c(N, vector<int>(N));
    rep(NC) repp(j, NC) cin >> d[i][j];
    rep(N) repp(j, N){
        cin >> c[i][j];
        c[i][j]--;
    }
 
    vector< vector<int> > cost(3, vector<int>(NC, 0));
    rep(N){
        repp(j, N){
            repp(color, NC){
                cost[(i+j)%3][color] += d[c[i][j]][color];
            }
        }
    }
 
    int ans = INT_MAX;
    rep(NC){
        repp(j, NC){
            if(i == j) continue;
            repp(k, NC){
                if(i == k || j == k) continue;
                ans = min(ans, cost[0][i]+cost[1][j]+cost[2][k]);
            }
        }
    }
 
    cout << ans << endl;
}

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


const int mod = (int)1e+9 + 7;

int solve(vector<int>&a, int n, long long k){
    
    long long res1 = 0;
    vector<long long>original(n, 0);
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            if(a[i] > a[j]){
                res1 += 1;
            }
        }
    }
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(a[i] > a[j]){
                original[i] += 1;
            }
        }
    }
    
    long long final_result = ((k%mod)*(res1%mod))%mod;;
    for(int i = 0; i < n; i++){
        long long mul;
        if(k&1){
            mul = (long long)(k%mod)*(((k-1)/2)%mod);
        }else{
            mul = (long long)((k/2)%mod)*((k-1)%mod);
        }
        final_result += ((mul%mod)*original[i]%mod)%mod;
        //final_result %= mod;
    }
    
    
    return final_result%mod;
    
    
}





int main(){
    
    int n, k;
    cin >> n >> k;
    vector<int>a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    cout << solve(a, n, (long long)k) << endl;
    
    
    
}

Measured memory_bytes: 3636
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long MODPOW(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	ll n,ans=0;
    cin >> n;
    for(ll i=0;i<n;i++){
        ll tmp;
        cin >> tmp;
        if(i%2==0 && tmp%2==1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){

    int A;
    string B;

    cin>>A>>B;

    int Bint;
    Bint=(B[0]-'0')*100+(B[2]-'0')*10+(B[3]-'0')*1;
    int sum=A*Bint;
    cout<<(int)(sum/100)<<endl;


}


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

map<pair<string,string>,ll>M;
int main(){
  int n;cin>>n;
  string s;cin>>s;
  for(int i=0;i<(1<<n);++i){
    string red="",blue="";
    for(int j=0;j<n;++j){
      if(i&(1<<j))red+=s[j];
      else blue+=s[j];
    }
    ++M[make_pair(red,blue)];
  }
  ll ans=0;
  for(int i=0;i<(1<<n);++i){
    string red="",blue="";
    for(int j=0;j<n;++j){
      if(i&(1<<j))red+=s[j+n];
      else blue+=s[j+n];
    }
    reverse(red.begin(),red.end());
    reverse(blue.begin(),blue.end());
    ans+=M[make_pair(blue,red)];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 87040
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,a,b;
	cin>>k>>a>>b;
	int x=a/k;
	int y=b/k;
	if((y!=x)||(a%k==0 || b%k==0))
	cout<<"OK"<<endl;
	else
	cout<<"NG"<<endl;
	
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>

int main() {
    int n=0;
    std::cin >> n;

    std::string s;

    std::cin >> s;
  
    std::string r;
    if (s.substr(0, n/2) == s.substr(n/2, n-1)) r = "Yes";
    else r = "No";
      
    if (n%2 == 1) r = "No";
  
    std::cout << r;

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x,0))
#define vec1(a,n) vector<int> a(n);rep(i,n)cin>>a[i]
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n,r;
  cin>>n>>r;
  int ans=r+100*(10-n);
  if(n>=10) cout<<r<<endl;
  else cout<<ans<<endl;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int N, ans=0;
	string S[605];

	cin >> N;
	rep(i,N) cin >> S[i];

	rep(i,N) S[i] = S[i] + S[i];
	rep(i,N) S[i+N] = S[i];

	int cnt[605][605] = {};
	rep(i,N) reps(j,i+1,2*N) reps(k,1,N){
		int x = i+k;
		int y = j-k;
		if( x < 2*N && y >= 0 ){
			int a = (S[i][j] == S[x][y]);
			int px = i;
			int py = y;
			px -= min(i,y);
			py -= min(i,y);
			while( px >= 0 && py >= 0 && x < px + N && j < py + N ){
				cnt[px][py] += a;
				px--;
				py--;
			}
		}
	}

	// rep(i,2*N){
	// 	rep(j,2*N) cout << cnt[i][j] << " ";
	// 	cout << endl;
	// }

	rep(i,1) rep(j,N){
		if( cnt[i][j] == N*(N-1)/2 ) ans++;
	}
	ans *= N;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll four,two,other;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n){
        if(a[i]%4==0)four++;
        else if(a[i]%2==0)two++;
        else other++;
    }
    if(two==n)Cout("Yes");
    else{
    if(two>=1)other++;
    if(four==0&&other>=1)Cout("No");
    else{
        four--;
        other-=2;
        other-=four;
        if(other>=1)Cout("No");
        else Cout("Yes");
    }
    }
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<string>

int main(){
    int N;
    scanf("%d",&N);

    std::string W[N];
    for(int i=0;i<N;i++){
     std::cin>>W[i];
    }

    int flag=0;

    for(int i=0;i<N-1;i++){
        int end_i=W[i].size();
        char c_end_i=W[i][end_i-1];
        char c_begin_i_plus1=W[i+1][0];
        if(c_end_i!=c_begin_i_plus1){
            flag=1;
            break;
        }
    }

    for(int i=0;i<N;i++){
        if(flag==1)break;
        for(int j=i+1;j<N;j++){
            if(W[i]==W[j]){
                flag=1;
                break;
            }
        }
    }

    if(flag==0)std::cout<<"Yes"<<"\n";
    else std::cout<<"No"<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
int M = 1e9+7;

int f(int n, int x, vector<vector<int> > &happiness, vector<vector<int> > &dp) {
	if(n < 0) return 0;
	if(dp[n][x] != -1) return dp[n][x];

	if(x == 0) dp[n][x] = happiness[n][x] + max(f(n - 1, 1, happiness, dp), f(n - 1, 2, happiness, dp));
	else if(x == 1) dp[n][x] = happiness[n][x] + max(f(n - 1, 0, happiness, dp), f(n - 1, 2, happiness, dp));
	else dp[n][x] = happiness[n][x] + max(f(n - 1, 0, happiness, dp), f(n - 1, 1, happiness, dp));
	return dp[n][x];
}
 
int main() {
   
    //Fast IO crap
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    vector<vector<int> > happiness(n, vector<int>(3));
    for(int i = 0; i < n; i++) for(int j = 0; j < 3; j++) cin >> happiness[i][j];

	vector<vector<int> > dp(n, vector<int>(3, -1));
	cout << max(f(n - 1, 0, happiness, dp), max(f(n - 1, 1, happiness, dp), f(n - 1, 2, happiness, dp)));
   
    return 0;
}


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

int main()
{
	long long N, T;
	cin >> N >> T;
	long long t[N];
	for(long long i = 0; i < N; i++){
		long long tmp;
		cin >> tmp;
		t[i] = tmp;
	}

	long long total_emit = 0;
	long long last_push_time = t[0];
	for(long long i = 1; i < N; i++){
		total_emit += min(T + last_push_time, t[i]) - last_push_time;
		last_push_time = t[i];
	}
	total_emit += T;
	cout << total_emit << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    int cnt = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(i % 2 == 0 && a[i] % 2 != 0)cnt++;
    }

    cout << cnt << endl;

}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>d(N);
  for(int &i:d)cin>>i;
  vector<int>num(110,0);
  int ans=0;
  for(int i=0;i<N;i++){
    num.at(d.at(i))++;
  }
  for(int i=0;i<=100;i++){
    if(num.at(i))ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    int n;
    cin >> n;
    vector<int> a(n);
    int t4 = 0;
    int t2 = 0;
    int t = 0;
    rep(i, n)
    {
        cin >> a[i];
        if (a[i] % 4 == 0)
        {
            t4++;
        }
        else if (a[i] % 2 == 0)
        {
            t2++;
        }
        else
        {
            t++;
        }
    }
    n -= (t4 * 2);

    if (n == 1)
    {
        cout << "Yes" << endl;
    }
    else
    {
    

    n -= t2;
    if (n <= 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    }

}


Measured memory_bytes: 640
#include <cstdio>

long long N,A;
int overN(long long x,long long y) {
	if(N/x+1<y) return 1;
	if(x*y<1) printf("err");
	if(N<x*y) return 1;
	return 0;
}
long long eval(int k,long long wsum) {
	long long prod=1;
	for(int i=0;i<k;i++) {
		if(i<wsum%k) {
			if(overN(prod,wsum/k+1)) return wsum+A*k+1;
			prod*=wsum/k+1;
		} else {
			if(overN(prod,wsum/k)) return wsum+A*k+1;
			prod*=wsum/k;
		}
		if(prod<1) printf("err");
		if(prod>=N) return wsum+A*k+1;
	}
	if(N%prod) {
		return wsum+A*k+N/prod+1;
	} else {
		return wsum+A*k+N/prod;
	}
}
int main() {
	scanf("%lld%lld",&N,&A);
	long long sol=N;
	int k=1;
	long long minv=2;
	while(1) {
		if(minv>=N) {
			long long temp=(A+2)*k+1;
			if(sol>temp) sol=temp;
			break;
		}
		long long search_minv=k*2;
		long long search_maxv=N;
		while(search_minv+100000<search_maxv) {
			long long search_hav=(search_minv*2+search_maxv)/3;
			long long search_hbv=(search_minv+search_maxv*2)/3;
			long long eval_ha=eval(k,search_hav);
			long long eval_hb=eval(k,search_hbv);
			if(eval_ha>eval_hb) {
				search_minv=search_hav;
			} else {
				search_maxv=search_hbv;
			}
		}
		for(long long i=search_minv;i<=search_maxv;i++) {
			long long temp=eval(k,i);
			if(sol>temp) sol=temp;
		}
		k++;
		minv*=2;
	}
	printf("%lld\n",sol);
	return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.length();
    int m = t.length();

    int ans = n;
    for(int i = 0; i <= n-m; i++) {
        string ss = s.substr(i, m);
        int diff = 0;
        for(int j = 0; j < m; j++) if(ss[j] != t[j]) diff++;
        ans = min(ans, diff);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3616
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

int n,m,cev,b,a[li],k;
string s;
vector<int> v;

int main(void){
	cin>>n>>k>>s;
	s[k-1]+=32;
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n, x;
  cin >> n >> x;
  int sum = 0, m = 10000000;
  REP(i, n) {
    int a;
    cin >> a;
    sum += a;
    m = min(m, a);
  }

  cout << n + (x - sum) / m << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>

//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)


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

  int N;
  cin >> N;

  int N2, N0;
  N2 = N/2;
  N0 = N%2;

  int A[N];

  int c[N]={0};
  int temp;
  REP(i, N){
  cin >> temp;
  c[temp]++;
}

  int ans = 0;
  if(N0==0){
    for(int i=1; i<N; i += 2){
      if(c[i] != 2){
        cout << 0 << endl;
        return 0;
      }
    }
  }

  if(N0==1){
      if(c[0] != 1){
        cout << 0 << endl;
        return 0;
      }
    for(int i=2; i<N; i += 2){
      if(c[i] != 2){
        ans = 0;
        cout << 0 << endl;
        return 0;
      }
    }
  }


  long long int tot = 1;
  REP(i, N2) (tot *= 2) %= 1000000000+7;
  cout << tot << endl;

  return 0;
}


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

typedef pair<int, int> P;

#define MAX_H 50
#define MAX_W 50

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

int h, w;
char maze[MAX_H][MAX_W];
int d[MAX_H][MAX_W];
P s, g;

int bfs(P c, P t) {
    queue<P> q;
    
    q.push(P(c.first, c.second));
    rep(i, h) rep(ii, w) d[i][ii] = INT_MAX;
    d[c.first][c.second] = 0;
    
    while (q.size()) {
        P p = q.front();
        q.pop();
        
        rep(i, 4) {
            int nx = p.second + dx[i];
            int ny = p.first + dy[i];
            
            if (
                (nx < 0) || (nx >= w) ||
                (ny < 0) || (ny >= h) ||
                (maze[ny][nx] == '#') ||
                (d[ny][nx] != INT_MAX)
            ) {
                continue;
            }
            
            q.push(P(ny, nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
    
    return d[t.first][t.second];
}

int main() {
    int blacks = 0;
    int ans;
    
    cin >> h >> w;
    
    rep(i, h) {
        rep(ii, w) {
            cin >> maze[i][ii];
            
            if (maze[i][ii] == '#') {
                blacks++;
            }
        }
    }
    
    s = P(0, 0);
    g = P(h - 1, w - 1);
    ans = bfs(s, g);
    
    if (ans == INT_MAX) {
        cout << -1 << endl;
        return 0;
    }
    
    ans = h * w - ans - blacks - 1;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * @author torith
 * @date 2018-10-12
 */

#include <bits/stdc++.h>

using namespace std;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    char S;
    bool n = false;
    bool s = false;
    bool w = false;
    bool e = false;
    while(cin >> S){
        if (S == 'N'){
            n = true;
        }else if (S == 'S'){
            s = true;
        }else if (S == 'W'){
            w = true;
        }else{
            e = true;
        }
    }

    if (((n && s) || (!n && !s)) && ((w && e) || (!w && !e))) cout << "Yes" << "\n";
    else cout << "No" << "\n";

    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

vector<int> shuffle(const vector<int> &v, const int c){
  int n = v.size();
  vector<int> ret(n);
  int pos = 0;
  int Atop  = n / 2;
  int Alast = n;
  int Btop  = 0;
  int Blast = Atop;
  
  while(Atop != Alast || Btop != Blast){
    if(Atop != Alast) 
      for(int i=0; Atop != Alast && i < c; i++) ret[pos++] = v[Atop++];
    if(Btop != Blast) 
      for(int i=0; Btop != Blast && i < c; i++) ret[pos++] = v[Btop++];
  } 
   
  return ret;
}

int main(){
  int n,r;
  while(~scanf("%d%d",&n,&r)){
    vector<int> v(n);
    REP(i,n) v[i] = i;

    REP(i,r){
      int c;
      scanf("%d",&c);

      v = shuffle(v, c);

      //printf("%d: ",c);REP(i,n) printf("%d ",v[i]); puts("");
    }

    print(v.back());
  }
  return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  cout << "#";
  
  for ( int i = 0; i < W; i++) {
    cout << "#";
  }
  
  cout << "#" << endl;
  
  for ( int i = 0; i < H; i++) {
    string a;
    cin >> a;
    cout << "#" << a << "#" << endl;
  }
  cout << "#";
  
  for ( int i = 0; i < W; i++) {
    cout << "#";
  }
  
  cout << "#" << endl;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rg register
using namespace std;
const int MAXN=2e5+10;
const int Mod=1e9+7;
int n,Ans,A[MAXN];
int L1[MAXN]={1},Il1[MAXN]={1},L2[MAXN]={1},Il2[MAXN]={1};
int Prez[MAXN],Inv2=500000004;
int Tr[MAXN],Back;
inline int Read()
{   rg int a=0,c=1;   rg char b=getchar();
	while(b!='-'&&(b<'0'||b>'9'))b=getchar();
	if(b=='-')c=-1,b=getchar();
	while(b>='0'&&b<='9')a=a*10+b-48,b=getchar();
	return a*c;
}
inline int Fast(rg int Di,rg int Mi)
{   rg int Back=1;
	while(Mi>=1)
	{   if(Mi&1) Back=1ll*Back*Di%Mod;
		Di=1ll*Di*Di%Mod;   Mi>>=1;
	}
	return Back;
}
inline int Calc(rg int Le,rg int Ri)
{   if(Prez[Ri]>=Le) return 0;
	else return 1ll*L1[n]*Il1[Ri]%Mod*L2[Ri]%Mod*Il2[Le-1]%Mod*L1[Le-1]%Mod*Inv2%Mod;
}
inline int Lowbit(rg int K){   return K&(-K);   }
inline void Insert(rg int A,rg int Sum)
{   while(A<=n) Tr[A]=(Tr[A]+Sum)%Mod,A+=Lowbit(A);   }
inline int Q(rg int A)
{   Back=0;   while(A>=1) Back=(Back+Tr[A])%Mod,A-=Lowbit(A);   return Back;   }
inline void Init(){   for(rg int i=1;i<=n;i++) Tr[i]=0;   }
int main()
{   n=Read();
	for(rg int i=1;i<=n;i++) A[i]=Read(),L1[A[i]]++;
	for(rg int i=n;i>=1;i--) L1[i]+=L1[i+1];
	for(rg int i=1;i<=n;i++) L1[i]-=n-i,L2[i]=L1[i]-1;
	for(rg int i=1;i<=n;i++)
	{   Prez[i]=L2[i]?Prez[i-1]:i;
		L1[i]=1ll*L1[i-1]*L1[i]%Mod;
		L2[i]=(L2[i]?1ll*L2[i-1]*L2[i]%Mod:L2[i-1]);
		Il1[i]=Fast(L1[i],Mod-2),Il2[i]=Fast(L2[i],Mod-2);
	}
	for(rg int i=1;i<=n;i++)
		Ans=(1ll*Ans+Q(A[i])-Q(A[i]-1)+Mod)%Mod,Insert(A[i],1ll*L1[n]*Inv2%Mod);
	Init();
	for(rg int i=1;i<=n;i++)
	{	Ans=(Ans+1ll*L1[n]*Il1[A[i]]%Mod*L2[A[i]]%Mod*Inv2%Mod*(Q(A[i]-1)-Q(Prez[A[i]]))%Mod)%Mod;
		Insert(A[i],1ll*Il2[A[i]]*L1[A[i]]%Mod);
	}
	Init();
	for(rg int i=n;i>=1;i--)
	{   Ans=(Ans-1ll*L1[n]*Il1[A[i]]%Mod*L2[A[i]]%Mod*Inv2%Mod*(Q(A[i]-1)-Q(Prez[A[i]]))%Mod)%Mod;
		Insert(A[i],1ll*Il2[A[i]]*L1[A[i]]%Mod);
	}
	Init();
	for(rg int i=n;i>=1;i--)
	{   Ans=(Ans+1ll*L1[n]*Q(A[i]-1)%Mod)%Mod;
		Insert(A[i],1);
	}
	printf("%d\n",Ans);
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
signed main(){
    int n;
    double ans=0.0;
    cin>>n;
    rep(i,n){
        double d;
        string s;
        cin>>d>>s;
        if(s=="BTC")ans+=380000.0*d;
        else ans+=d;
    }
    printf("%.6f\n",ans);
    return 0;
}

Measured memory_bytes: 256
n, c, k = map(int,input().split())
t = sorted([int(input()) for _ in range(n)])

ans = 0
bus = []

for i in range(n):
	if len(bus) == c:
		ans += 1
		bus = [t[i]]
	elif bus != [] and bus[0] + k < t[i]:
		ans += 1
		bus = [t[i]]
	else:
		bus.append(t[i])

print(ans+1)

Measured memory_bytes: 51544
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<math.h>

#define long long ll

using namespace std;

main()
{
	int n,k;
	cin>>n;
	int a[n],b[n],c[n];
	
	int i,j;
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	
	int dp[n][3];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	
	for(i=1;i<n;i++)
	{
		dp[i][0] = a[i] + max(dp[i-1][1] , dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0] , dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][0] , dp[i-1][1]);
	}
	
	cout<<max(dp[n-1][0] , max(dp[n-1][1] , dp[n-1][2]));
	
	
	
}



Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  int N, Q;
  while (cin >> N >> Q) {
    string S;
    cin >> S;
    vector<char> T(Q), D(Q);
    for (int q = 0; q < Q; q++) cin >> T[q] >> D[q];
    auto simulate = [&](int i, int edge) {
      for (int q = 0; q < Q; q++) {
        if (S[i] == T[q]) {
          i += D[q] == 'L' ? -1 : +1;
        }
        if (i < 0 || i >= N) return i == edge;
      }
      return false;
    };
    auto bsearch = [&](int edge, int pass, int fail) {
      while (abs(pass - fail) > 1) {
        int i = (pass + fail) / 2;
        if (simulate(i, edge)) {
          pass = i;
        } else {
          fail = i;
        }
      }
      return pass;
    };
    int res = N;
    if (simulate(0, -1)) {
      res -= bsearch(-1, 0, N) + 1;
    }
    if (simulate(N - 1, N)) {
      res -= N - bsearch(N, N - 1, -1);
    }
    cout << res << endl;
  }
  return 0;
}


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

int main()
{
    /*
    int n;
    cin>>n;
    while(n)
    {
        if(n%10==7)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        n=n/10;
    }
    cout<<"No"<<endl;
    */
    int n;
    cin>>n;
    ll total = 0;

    for(int i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
        {
            total+=i;
        }
    }
    cout<<total<<endl;

    return 0;
}

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

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

    if(a>b){
        cout << "a > b" << endl;
    }
    else if(a<b){
        cout << "a < b" << endl;
    }
    else{
        cout << "a == b" << endl;
    }
}



Measured memory_bytes: 3120
#include <stdio.h>
 
int main(void)
{
    int a, b;
     
    scanf("%d %d",&a, &b);
    if (a < b)
            printf("a < b\n");
    else if (a > b)
            printf("a > b\n");
    else
            printf("a == b\n");
     
    return 0;
}

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

int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    if(abs(c - a) <= d || (abs(b - a) <= d && abs(c - b) <= d)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

prev_h = 0
answer = 'Yes'
for h in H:
    if h - 1 >= prev_h:
        prev_h = h - 1
    elif h >= prev_h:
        prev_h = h
    else:
        answer = 'No'
        break
print(answer)

Measured memory_bytes: 14252
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

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

        int[][] arr = new int[n][3];
        for(int i = 0 ; i < n; i++) {
            arr[i][0] = sc.nextInt();
            arr[i][1] = sc.nextInt();
            arr[i][2] = sc.nextInt();
        }

        if (n > 1) {
            for (int i = 1; i < n; i++) {
                arr[i][0] = Math.max(arr[i - 1][1], arr[i - 1][2]) + arr[i][0];
                arr[i][1] = Math.max(arr[i - 1][0], arr[i - 1][2]) + arr[i][1];
                arr[i][2] = Math.max(arr[i - 1][0], arr[i - 1][1]) + arr[i][2];
               
            }
        }

        System.out.println(Math.max(Math.max(arr[n-1][0], arr[n-1][1]) , arr[n-1][2]));
    }
}


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

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

    static class BCountBalls {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            long n = in.nextLong();
            long a = in.nextLong();
            long b = in.nextLong();
            // a + b 個ごとにa
            out.println(n / (a + b) * a + Math.min(a, n % (a + b)));

        }

    }
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll ans=0;
    unordered_multiset<ll> canuse;
    Vec v(n);
    ll in;
    rep(i,n){
        cin>>in;
        v[i]=in;
        canuse.insert(in);
    }
    ll t=0;
    sort(ALL(v),greater<>());
    while(!(v[0]>=pow(2,t)&&v[0]<pow(2,t+1))){
        t++;
    }
    rep(i,n){
        while(!(v[i]>=pow(2,t)&&v[i]<pow(2,t+1))){
            t--;
        }
        if(canuse.find(v[i])!=canuse.end()){
            canuse.erase(canuse.find(v[i]));
            auto itr = canuse.find(pow(2,t+1)-v[i]);
            if(itr!=canuse.end()){
                canuse.erase(itr);
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 10184
# import copy
# In general, DP problems can often be thought of as a decision making process, where you make some "local" decision and your state after that 
# local decision becomes some state you have previously calculated the answer for. So, when you are on a given state, you try all the local 
# decisions you can, and take the one that results in the best answer (or in this case, sum up the number for each local decision to get the 
# total count for the current state).

# Your dp state characterization is correct: dp[i][j] represents the number of ways of distributing j candies among the first i people. 
# Now, say you are trying to calculate dp[i][j]. What is the "local decision" that you must make at this state? It will just be how many 
# candies you want to give to the i'th person (in fact, deciding what to do with the i'th person is often the decision that must be made 
# when your dp state deals with "something among the first i people"). So, say you want to give the i'th person k candies, where k is 
# somewhere between 0 and min(ai, j) (we can't give them more than ai candies because of the problem constraint, and can't give them more 
# than j candies because we only have j candies). Then, we see that if we give k candies to person i, then the number of ways to do 
# that is dp[i - 1][j - k] (because we precisely want to find the number of ways to distribute j - k candies to the first i - 1 people). 
# If we sum up these numbers over all the k from 0 to min(ai, j), then we should get the count for dp[i][j].

# You'll notice, though, that this results in O(NK) states and O(K) operations per state, or O(NK2) runtime, which is too slow. 
# There is something about the state transitions that allows you to calculate the sum over all the different local decisions much faster, 
# in fact in O(1). Can you think of what to do? Hint: all of the local decisions for a given dp[i][j] recurse into a contiguous block 
# in the dp[i - 1] row.

N, K = map(int,  input().split())
A = list(map(int,  input().split()))
dp = [[0 for k in range(K+1)] for n in range(N)]
# pref = [0 for k in range(K+1)]
# sSum = [0 for n in range(N)]
# sSum[N-1] = A[N-1]
# for n in range(N-2, -1, -1):
# 	sSum[n] = sSum[n+1] + A[n]
mod = int(1e9+7)
dp[N-1][0] = 1
# pref[0] = 1
for k in range(1, K+1):
	if k > A[N-1]:
		dp[N-1][k] = 0
		# pref[k] = 0
	else:
		dp[N-1][k] = 1
		# pref[k] = 1
# print(pref)
for n in range(N-2, -1, -1):
	ans = 0
	for k in range(A[n]+1):
		ans += dp[n+1][k]%mod
		ans = ans
		dp[n][k] = ans%mod
	# print(dp)
	for k in range(A[n]+1,K+1):
		# print(n, k ,ans, dp[n+1][k], dp[n+1][k-A[n]-1])
		ans = (ans%mod + dp[n+1][k]%mod - dp[n+1][k-A[n]-1]%mod + mod)%mod
		dp[n][k] = ans%mod
	# pref = copy.deepcopy(dp[n])
# print(dp)
print(dp[0][K])

Measured memory_bytes: 171656
#pragma region Macros
/***
 * @author uesugi
 * @file AtCoder用テンプレート
 */

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

/**
 * 最大値更新
 * @param T &a 更新対象
 * @param const T &b 判定対象
 * @return 更新有無
 */
template <class T>
inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

/**
 * 最小値更新
 * @param T &a 更新対象
 * @param const T &b 判定対象
 * @return 更新有無
 */
template <class T>
inline bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

/**
 * overload
 * 入力を配列に格納
 * 配列の長さ分入力を格納
 * @param std::istream &is 入力ストリーム
 * @param std::vector<T> &vec 格納先配列
 * @return std::istream 
 */
template <typename T>
inline std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element : vec) {
        is >> element;
    }
    return is;
}

/**
 * overload
 * コンテナの要素を出力する
 * @param std::basic_ostream<Ch, Tr> &os 出力ストリーム
 * @param Container const &x 出力対象コンテナ
 * @return std::basic_ostream<Ch, Tr> 
 */
template <class Ch, class Tr, class Container>
inline std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
/**
 * デバッグ用出力メソッド
 * 変数名及び値を出力
 * -D_DEBUG オプション付きビルド時のみ有効
 * @param 可変長引数
 */
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

/**
 * 処理
 * @return void
 */
void Main() {
    int N;
    cin >> N;
    set<string> s;
    string buff;
    REP(i, N) {
        cin >> buff;
        s.insert(buff);
    }

    cout << s.size();
}

#pragma region main
/**
 * main
 * 共通処理
 * @return signed
 */
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << std::fixed;
    cout.precision(20);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 19200
# -*- coding: utf-8 -*-
c1x,c1y,c1r = map(int,input().split())
c2x,c2y,c2r = map(int,input().split())

L = (c1x - c2x) ** 2 + (c1y - c2y) **2
if L > (c1r + c2r) ** 2:
    print(4)
elif L == (c1r + c2r) ** 2:
    print(3)
elif L < (c1r + c2r) ** 2 and (c1r - c2r) ** 2 < L:
    print(2)
elif L == (c1r - c2r) ** 2:
    print(1)
elif L < (c1r - c2r) ** 2:
    print(0)



Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#define wid 1
#define hgt 0

using namespace std;

typedef long long int lli;

lli a[101][101][2];

lli func(bool vis[101][101][2], int w, int h, int s, int t, int d, bool f, int wd, int hd)
{
  if(s > h || t > w){
    return 0;
  }

  if(f){
    if(s == h && t == w){
      return 1;
    }
    return func(vis, w, h, s+hd, t+wd, d, false, wd, hd);
  }

  if(d != 2 && !vis[s][t][d]){
    return a[s][t][d];
  }

  lli u = 0;
  if(d != wid){
    u += func(vis, w, h, s+1, t, hgt, false, 0, 1);
  } else {
    u += func(vis, w, h, s+1, t, hgt, true, 0, 1);
  }
  if(d != hgt){
    u += func(vis, w, h, s, t+1, wid, false, 1, 0);
  } else {
    u += func(vis, w, h, s, t+1, wid, true, 1, 0);
  }
  vis[s][t][d] = false;
  a[s][t][d] = u%100000;

  return a[s][t][d];
}

int main()
{
  int w, h;
  bool vis[101][101][2];

  while(cin>>w>>h && (w+h)){
    fill(&a[0][0][0], &a[100][100][1], 0);
    a[h][w][1] = a[h][w][0] = 1;
    fill(&vis[0][0][0], &vis[100][100][1], true);
    vis[h][w][0] = vis[h][w][1] = false;

    cout << func(vis, w, h, 1, 1, 2, false, 1, 1) << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


int main(){
  int N;
  ll dp[16] = {};
  ll pow = 3;
  dp[1] = 1;
  for(int i = 2; i <= 15; i++){
    dp[i] = dp[i - 1] + pow;
    pow *= 3;
  }
  ll dp2[31] = {};
  dp2[1] = 1;
  dp2[2] = 2;
  for(int i = 3; i <= 30; i++){
    dp2[i] = dp2[i - 1] + (dp[(i - 1) / 2] * 2 + 1);
  }
  while(cin >> N) cout << dp2[N] << endl;
  return 0;
}

Measured memory_bytes: 1156
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
from collections import deque


def main():
    mod=10**9+7
    S=deque(input())
    Q=I()
    dir=0#0で手前につける
    
    for _ in range(Q):
        q=list(input().split())
        if q[0]=="1":
            dir+=1
            dir%=2
        else:
            dir2=dir
            if q[1]=="2":
                dir2+=1
                dir2%=2
            if dir2==0:
                S.appendleft(q[2])
            else:
                S.append(q[2])
            
    ans=list(S)
    
    if dir==1:
        ans=ans[::-1]
        
    print(''.join(map(str, ans)))
        

main()


Measured memory_bytes: 97948
/*
 * yaswanth phani kommineni
 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n';

const ll mod = 1e9+7,M = 1e6+1;

ll modpow(ll x,ll n){
	if(n == 0) return 1%mod;
	ll u = modpow(x,n/2);
	u = (u*u)%mod;
	if(n&1) u = (u*x)%mod;
	return u;
}

void solve(){
	ll n;
	cin >> n;
	cout << (modpow(10,n)-2*modpow(9,n)+modpow(8,n)+10*mod)%mod << endl;
}

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int z;
	z = 1;
	//cin >> z;
	for(int z1=1;z1<=z;z1++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main() {
// input
int N; 
  cin >> N;
vector <int> V(N);
for (int i = 0; i < N; ++i) {
cin >> V[i];
}
vector <int> C(N);
for (int i = 0; i < N; ++i) {
cin >> C[i];
}
// compute
int ans = 0;
for (int i = 0; i < N; ++i) {
if (V[i] > C[i]) {
ans += V[i] - C[i];
}
}
// output
cout << ans << endl;
}

Measured memory_bytes: 256