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

using namespace std;
#define BUF (100005)
#define ll long long 

int n,h;
int a[BUF];
int b[BUF];

int main(void){
	int amx=0;
	int bmx=0;	
	cin >> n >> h;
	for(int i=1;i<=n;i++){
		cin >> a[i] >> b[i];
		if(amx<a[i])amx = a[i];
	}

	sort(b+1,b+n+1);

	int ans = 0;
	int cnt = n;

	while(b[cnt]>amx){
//		cout << cnt << b[cnt];
		h-=b[cnt];
		ans++;

		if(h<=0){
			cout << ans << endl;
			return 0;
		}
		cnt--;
		if(cnt==0)break;
	}

	ans+=h/amx+1;
	if(h%amx==0)ans--;
	cout << ans << endl;

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<int> cnt(9);
  for (auto a : A) (a < 400) ? cnt.at(0) = 1 : (a < 800) ? cnt.at(1) = 1 :  (a < 1200) ? cnt.at(2) = 1 :  (a < 1600) ? cnt.at(3) = 1 :  (a < 2000) ? cnt.at(4) = 1 :  (a < 2400) ? cnt.at(5) = 1 :  (a < 2800) ? cnt.at(6) = 1 :  (a < 3200) ? cnt.at(7) = 1 : cnt.at(8)++;
  int sum = accumulate(cnt.begin(), cnt.end(), 0);
  if (cnt.at(8) == 0) return cout << sum << " " << sum << "\n", 0;
  sum = accumulate(cnt.begin(), cnt.begin() + 8, 0);
  if (sum) cout << sum << " " << sum + cnt.at(8) << "\n", 0;
  else cout << 1 << " " << cnt.at(8) << "\n";
}

Measured memory_bytes: 3632
import java.util.*;
class Main {
	static boolean[][] map;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if(n == 0) break;
			map = new boolean[5011][5];
			for(int i = 0; i < n; i++) {
				int d = sc.nextInt();
				int p = sc.nextInt();
				int q = sc.nextInt();
				
				if(d == 1) {
					for(int j = 0; j < p; j++) {
						map[5010][j + q -1] = true;
					}
					IN:for(int j = 5009; j >= 0; j--) {
						for(int k = 0; k < p; k++) {
							if(map[j][k + q -1])break IN;
						}
						for(int k = 0; k < p; k++) {
							map[j  ][k + q - 1] = true;
							map[j+1][k + q - 1] = false;
						}
					}
				}
				else {
					for(int j = 0; j < p; j++) {
						map[5010 - j][q-1] = true;
					}
					for(int j = 5010 - p; j >= 0; j--) {
						if(map[j][q-1]) break;
						map[j][q-1] = true;
						map[j + p][q-1] = false;
						
					}
					
				}
				while(erase());
			}
			int count = 0;
			
			for(int i = 0; i < 5011; i++) {
				for(int j = 0; j < 5; j++) {
					if(map[i][j]) count++;
				}
			}
			System.out.println(count);
		}
	}

	static boolean erase() {
		boolean ret = false;
		for(int i = 0; i < 5010; i++) {
			for(int j = 0; j < 5; j++) {
				if(!map[i][j]) break;
				if(j == 4) {
					ret = true;
					for(int k = 0; k < 5; k++) {
						map[i][k] = false;
					}
					if(i != 5010) {
						for(int l = i; l < 5009; l++)
						for(int k = 0; k < 5; k++) {
							map[l][k] = map[l+1][k];
						}
					}
				}
			}
		}
		return ret;
	}
	
	static void show() {
		for(int i = 5; i >= 0; i--) {
			for(int j = 0; j < 5; j++) {
				System.out.print(" " + map[i][j]);
			}
			System.out.println();
		}
		System.out.println();
	}
}

Measured memory_bytes: 32532
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

struct Input
{
    int n;
};

static Input read_input()
{
    Input input{};
    cin >> input.n;
    return input;
}

struct Attendance
{
    int order;
    int student_no;
};

static void solve(const Input& input)
{
    vector<Attendance> attendances;
    attendances.reserve(input.n);

    // read
    for (auto i = 0; i < input.n; ++i) {
        int order;
        cin >> order;

        Attendance attendance{};
        attendance.order = order + 1;
        attendance.student_no = i + 1;

        attendances.push_back(attendance);
    }

    // sort
    sort(begin(attendances), end(attendances), [](const Attendance& lhs, const Attendance& rhs) {
        return lhs.order < rhs.order;
    });

    // output
    for (auto it = begin(attendances); it != end(attendances); ++it) {
        if (it != begin(attendances)) {
            cout << " ";
        }

        cout << it->student_no;
    }
    cout << endl;
}

static void setup()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
}

int main(int argc, char** argv)
{
    setup();

    const auto input = read_input();
    solve(input);

    return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c = 0;
        for (int i = 1 ; i < n ; i++) {
            c += (n - 1) / i;
        }
        System.out.println(c);

    }

}


Measured memory_bytes: 35700
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
 
int main(){
	
	ll n,a,b,c,d,e;
	cin>>n>>a>>b>>c>>d>>e;
	ll now{},start{};
	b = min(a,b);
	c = min(b,c);
	d = min(d,c);
	e = min(e,d);
	now += (n+a-1)/a;
	
	cout << 4+(n+e-1)/e<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 1000000007
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl '\n'


signed main() {

	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	string s,t;
	cin >> s >> t;
	int n=s.size();
	int m=t.size();

	int dp[n+1][m+1];

	memset(dp,0,sizeof(dp));

	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(i==0||j==0){
				dp[i][j]=0;
			}else if(s[i-1]==t[j-1]){
				dp[i][j]=1+dp[i-1][j-1];
			}else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}

	int i=n,j=m;
	string ans;
	while(i>0 && j>0){
		if(s[i-1]==t[j-1]){
			ans.push_back(s[i-1]);
			i--;
			j--;
		}else{
			if(dp[i-1][j] > dp[i][j-1]){
				i--;
			}else{
				j--;
			}
		}
	}

	reverse(ans.begin(), ans.end());
	cout << ans;
	return 0;
}

Measured memory_bytes: 73980
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll A , B , C , D ; cin >> A >> B >> C >> D ;
  ll L = (A+B) , R = (C+D);
  if(L==R) cout << "Balanced" << endl;
  else if(L > R) cout << "Left" << endl;
  else cout << "Right" << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

#define ll long long int

using namespace std;


int main()
{
    string s; cin>>s;
    int g=0,p=0;
    int n=s.length();
    for(int i=0;i<n;i++)
    {
        if(s[i]=='g') g++;
        else p++;
    }
    int pp=n/2;
    cout<<pp-p;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll ;

ll max(ll a , ll b)
{
  return (a > b) ? a: b;
}
ll min(ll a , ll b)
{
  return (a < b) ? a : b;
}
void memset(int *arr , int n , int value)
{
    for(int i= 0; i<n ; i++)
    {
        arr[i] = value;
    }
}
 int vacation(int **arr , int i , int n , int last , int **dp)
 {
     if(i == n)
     {
         return 0;
     }
    if(dp[i][last] != -1)
     {
         return dp[i][last] ;
     }

     int opsn1 = -1e9+7 ;
     int opsn2 = -1e9+7 ;
     int opsn3 = -1e9+7 ;

     if(last !=0)
     {
         opsn1 = arr[i][0] + vacation(arr , i+1 , n , 0 , dp);
     }
     if(last !=1)
     {
         opsn2 = arr[i][1] + vacation(arr , i+1  , n , 1 ,dp);
     }
     if(last !=2)
     {
         opsn3 = arr[i][2] + vacation(arr , i+1  , n , 2 ,dp);
     }
     return  dp[i][last] = max(opsn1 , max(opsn2 , opsn3)) ;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int **arr = new int*[n];
    for(int i= 0; i<n ; i++)
    {
        arr[i] = new int[3] ;
    }
    for(int i= 0; i<n ; i++)
    {
        for(int j= 0; j<3 ; j++)
        {
            cin>>arr[i][j];
        }
    }
    int **dp = new int*[n+1];
    for(int i=0 ; i<=n ; i++)
    {
        dp[i]= new int[3];
        for(int k = 0 ; k<3 ; k++)
        {
            dp[i][k] = -1 ;
        }
    }

    int opsn1 = vacation(arr , 0 , n , 0 , dp);
    int opsn2 = vacation(arr , 0 , n , 1 , dp);
    int opsn3 = vacation(arr , 0 , n  , 2 , dp);
    cout<<max(opsn1 , max(opsn2 , opsn3)) ;
    return 0;
}


Measured memory_bytes: 15872
#include <cstdio>
#include <algorithm>
using std::min;

int m_abs(int z)
{
    if (z<0)
        return -z;
    else
        return z;
}

int main(void)
{
    int *a,*dp,N,i,j;
    scanf("%d",&N);
    a=new int [N];
    dp=new int [N];
    for (i=0;i<N;i++)
    {
        scanf("%d",a+i);
    }
    dp[N-1]=0;
    dp[N-2]=abs(a[N-2]-a[N-1]);
    for(i=N-3;i>=0;i--)
    {
        dp[i]=min(dp[i+1]+abs(a[i]-a[i+1]),dp[i+2]+abs(a[i]-a[i+2]));
    }
    printf("%d\n",dp[0]);

    delete [] a;

}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n)cin>>a[i];
	vector<ll> sum((n*(n+1))/2);
	ll count = 0;
	rep(i,n){
		ll now = a[i];
		sum[count++] = now;
		For(j,i+1,n){
			now+=a[j];
			sum[count++]=now;
		}
	}
	sort(sum.rbegin(),sum.rend());
	// 2^50を超えるものから順に見ていく。最大でも10^12 
	ll ans = 0;
	for(ll i = 60; i >= 0; i--){
		vector<ll> now(0);
		int cnt = 0;
		rep(j,sum.size()){
			if((sum[j]&(1ll << i))){
				cnt ++;
				now.push_back(sum[j]);
			}
		}
		if(cnt >= k) {
			ans += (1ll << i);
			sum = now;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 5372
import Data.List
main = interact $ unlines . map (unwords . map show . hit_and_blow) . fin [] . lines
fin acc xs = reverse $ case xs of {[] -> acc; (a:b:ns) -> fin ([words a, words b]:acc) ns} 
hit_and_blow [as,bs] = [hit, blow]
 where
  hit = length $ filter (== True) $ zipWith (== )as bs
  blow = length (intersect as bs) - hit

Measured memory_bytes: 3552
//To debug :  g++ -g file.cpp -o code
//cout<<setprecision(p)<<fixed<<var
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807;
#define big1 LONG_MAX
#define big2 INT_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 INT_MIN
#define sma3 -1000000000;
#define mp make_pair
#define dub double
#define ivec vector<int>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);


int a[100],n;

int dp[100001][2];

int fun(int k,int p)
{
	if(k<=0)
		return (1-p);
	else if(dp[k][p]!=-1)
		return dp[k][p];
	
	int res=(!p);

	int i;


	rep(i,0,n)
	{
		if((k-a[i])>=0)
		{
			res = fun(k-a[i],1-p); 


			if(res==p)
			{
				break;
			}
		}
	}

	dp[k][p]=res;

	return dp[k][p];
	

}

int main()
{
	int  k,i;

	cin>>n>>k;

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

	memset(dp,-1,sizeof(dp));

	if(fun(k,1)==1)
		cout<<"First\n";
	else
		cout<<"Second\n";


	return 0;
}

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

#define INT int
#define REP(i,a,b) for(INT i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
int A,B;
cin >> A >> B;
int ans = 0;
REP(i,A,B+1){
	//数値分解
	int I = i;
	int a = i/10000;
	I -= 10000*a;
	int b = I/1000;
	I -= 1000*b;
	int c = I/100;
	I -= 100*c;
	int d = I /10;
	I -= 10*d;
	int e = I;

	if(a==e && b==d) ans++;
}
cout << ans<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <bitset>
#include <utility>
#include <sstream>
#include <fstream>
#include <stack>
#include <cstdlib>
#include <complex>
#include <set>

using namespace std;

#define INF 1070000000LL
#define pb push_back
#define irep(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) irep(i,0,n)

typedef long long lint;
typedef pair<int, int> pint;
struct Edge{
    int to,weight;
};
typedef vector<vector<Edge> > Graph;


int main(){
    lint n;
    cin >> n;
    cout << n*(n+1)/2 - n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#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 pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int data[300];
int main(){
	data['a'] = 0;
	data['b'] = 0;
	data['c'] = 0;
	data['d'] = 0;
	data['e'] = 0;
	data['f'] = 0;
	data['g'] = 0;
	data['h'] = 1;
	data['i'] = 1;
	data['j'] = 1;
	data['k'] = 1;
	data['l'] = 1;
	data['m'] = 1;
	data['n'] = 1;
	data['o'] = 1;
	data['p'] = 1;
	data['q'] = 0;
	data['r'] = 0;
	data['s'] = 0;
	data['t'] = 0;
	data['u'] = 1;
	data['v'] = 0;
	data['w'] = 0;
	data['x'] = 0;
	data['y'] = 1;
	data['z'] = 0;
	while(1){
		string tmp;
		cin >> tmp;
		if(tmp=="#") break;
		int old;
		old = data[tmp[0]];
		int cnt = 0;
		FOR(i,1,tmp.size()){
			if(old!=data[tmp[i]]){
				cnt++;
				old = data[tmp[i]];
			}
		}
		cout << cnt << endl;
	}

}

Measured memory_bytes: 1188
HW = input().split()
HW = [int(n) for n in HW]

if HW[0] == 1 or HW[1] == 1:
    print(1)
else:
    m = HW[0]*HW[1]
    if HW[0]%2==1 and HW[1]%2==1:
        print(int(m/2)+1)
    else:
        print(int(m/2))


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n) for(i64 i=(s); i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

signed main()
{
  int h , w, a, b;
  cin >> h >> w >> a >> b;

  cout << (h - a) * (w - b) << endl;
  return 0;
}



Measured memory_bytes: 256
//
//  main.cpp
//  ABC119
//
//  Created by hiroaki on 2019/02/25.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <string>
using namespace std;

int main() {
   /* string s="hello";
    string sa ={s.begin(),s.begin()+3};
    cout<<sa<<endl;*/
    string S;
    cin >> S;
    string ad={S[0],S[1],S[2],S[3]};
    string month ={S[5],S[6]};
    string day={S[8],S[9]};
    /*cout<<S[0]<<S[1]<<S[2]<<S[3]<<S[4]<<S[5]<<S[6]<<S[7]<<S[8]<<S[9]<<endl;
    cout<<atoi(ad.c_str())<<atoi(month.c_str()) <<endl;*/
    /*if (atoi(ad.c_str())> 2108) {
        cout<<"true"<<endl;
        cout<<atoi(ad.c_str())*10<<endl;
    }*/
    if (atoi(ad.c_str())> 2018 && atoi(month.c_str()) > 4) {
        cout<<"TBD"<<endl;
    }else{
        cout<<"Heisei"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////



int n,l,q,x[110000];P qr[110000];
int d[22][110000];
signed main(){
  cin>>n;rep(i,n)cin>>x[i];
  cin>>l>>q;
  rep(i,q)cin>>qr[i].first>>qr[i].second;
  rep(i,22)rep(j,110000)d[i][j] = INF;
  rep(i,n){
    auto itr = upper_bound(x+i, x+n, x[i]+l)-1;
    d[0][i] = itr - x;
    if(i == n-1)d[0][i] = INF;
  }
  rep(k,21){
    rep(i,n){
      if(d[k][i] == INF)continue;
      d[k+1][i] = d[k][d[k][i]];
    }
  }

  rep(i,q){
    int a = qr[i].first, b = qr[i].second;a--;b--;
    if(a > b)swap(a, b);
    int ans = 0, now = a;
    while(now < b){
      int ok = 0, ng = 22;
      while(abs(ok - ng) > 1){
        int mid = (ok+ng)/2;
        if(d[mid][now] <= b)ok = mid;
        else ng = mid;
      }
      now = d[ok][now];
      int plus = 1;
      rep(i,ok)plus *= 2;
      ans += plus;
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 22144
n, k = map(int, input().split())
s = input()
s = list(s)

seqCnt = 0
seqTotal = 0
for i in range(n-1) :
    #print(i, seqCnt)
    if s[i] == s[i+1] :
        seqCnt += 1
    if s[i] != s[i+1] or i == n - 2 :
        #print(ans, seqCnt, i)
        seqTotal += seqCnt
        seqCnt = 0

print(min(seqTotal + 2*k, n-1))

Measured memory_bytes: 4024
#!/usr/bin/env python3
#AGC31 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = input()
t = list(Counter(s).items())
ans = 1
for i,j in t:
    ans *= j+1
    ans %= mod
ans -= 1
print(ans)


Measured memory_bytes: 39920
#include<cstdio>
#include<cstring>
#include<iostream>
#define in inline
#define re register
using namespace std;
in int read() {
	re int t=0;
	re char v=getchar();	
	while(v<'0'||v>'9'){
	v=getchar();
	}	
	while(v>='0'&&v<='9'){		
	t=(t<<3)+(t<<1)+(v^48);		
	v=getchar();	}
	return t;
}
int a,b,c,d;
int main(){
a=read();
if(a>9899){
	puts("1");
	return 0;
}
b=a/100;
if(b*105>=a)puts("1");
else puts("0");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
using P = pair<int,int>;

void visit(vector<vector<int>>& Graph, vector<bool>& visited, vector<int>& topo, int v){
    if(visited[v]) return;
    visited[v] = true;
    for(auto next : Graph[v]) visit(Graph, visited, topo, next);
    topo.push_back(v);
}

vector<int> topological_sort(vector<vector<int>>& Graph, int V){
    vector<int> topo;
    vector<bool> visited(V,false);
    for(int i=0;i<V;i++) visit(Graph, visited, topo, i);
    reverse(topo.begin(),topo.end());

    return topo;
}

int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> Graph(N);

    for(int i=0;i<M;i++){
        int x,y;
        cin >> x >> y;
        x--, y--;
        Graph[x].push_back(y);
    }

    vector<int> topo = topological_sort(Graph,N);

    vector<int> dp(N,0);
    int ans = -1;

    for(int i=0;i<N;i++){
        int v = topo[i];
        for(auto next : Graph[v]) {
            dp[next] = max(dp[next],dp[v] + 1);
            ans = max(ans,dp[next]);
        }
    }

    cout << ans << endl;


    
}

Measured memory_bytes: 9336
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;

const int INF = 100000000;
typedef pair<int, int> P;

char maze[55][55];
int h, w;
int sx, sy;
int gx, gy;

int d[55][55];

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

int bfs(){
  queue<P> que;
  for(int i=0; i<h; ++i)
    for(int j=0; j<w; ++j) d[i][j] = INF;

  que.push(P(sx-1, sy-1));
  d[sy-1][sx-1] = 0;

  while(que.size()){
    P p = que.front(); que.pop();
    if(p.first == gx-1 && p.second == gy-1) break;

    for(int i=0; i<4; ++i){
      int nx = p.first + dx[i], ny = p.second + dy[i];

      if(0 <= nx && nx < w && 0 <= ny && ny < h && maze[ny][nx] != '#' && d[ny][nx] == INF){
        que.push(P(nx, ny));
        d[ny][nx] = d[p.second][p.first] + 1;
      }
    }
  }
  return d[gy-1][gx-1];
}

int main(){
  cin >> h >> w;
  sx = 1; sy =1;
  gx = w; gy = h;
  int cnt = 0;
  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j){
      cin >> maze[i][j];
      if(maze[i][j] == '.') cnt++;
    }
  }
  int res = bfs();
  if(res == INF) cout << -1 << "\n";
  else cout << cnt - res - 1 << "\n";
}

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

bool revp2(const pair<ll,ll>&a,const pair<ll,ll>&b){return a.first>b.first;}
bool revp3(const pair<ll,ll>&a,const pair<ll,ll>&b){if(a.first==b.first)return a.second<b.second;
return a.first>b.first;}

int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    ll n,s=0;
    cin>>n;
    ll d,x;
    cin>>d>>x;
    ll a;
    for(int i=1;i<=n;i++){
        cin>>a;ll j=1;
        while(a*j+1<=d)s++,j++;
    }
    cout<<x+n+s;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define Pi 3.1415926535
#define MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << endl;}
void no(){cout << "No" << endl;}

int solve(){
    int n; cin >> n;
    ll ans = 0;
    repp(i,n){
        if(i % 5 == 0 or i % 3 == 0) continue;
        else ans += i;
    }
    cout << ans << endl;

    return 0;
}

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


Measured memory_bytes: 3656
H,W = map(int,input().split())

m = 100000000000000

if (H%3)==0:
  m = min(m,0)
else:
  m = min(m,W)
  
if (W%3)==0:
  m = min(m,0)
else:
  m = min(m,H)

 
R = 100
for dh in range(-R,R):
  for dw in range(-R,R):
    S1 = H*(W//3+dw)
    S2 = (H//2+dh)*(W-W//3-dw)
    S3 = (H-H//2-dh)*(W-W//3-dw)
    if ( (W//3+dw)<0 or (H//2+dh)<0 or (H//2-dh)<0 or (W-W//3-dw)<0 or (H-H//2-dh)<0 ):
      continue
    m = min(m,max([S1,S2,S3])-min([S1,S2,S3]))
 
for dh in range(-R,R):
  for dw in range(-R,R):
    S1 = W*(H//3+dw)
    S2 = (W//2+dh)*(H-H//3-dw)
    S3 = (W-W//2-dh)*(H-H//3-dw)
    if ( (H//3+dw)<0 or (W//2+dh)<0 or (W//2-dh)<0 or (H-H//3-dw)<0 or (W-W//2-dh)<0  ):
      continue
    m = min(m,max([S1,S2,S3])-min([S1,S2,S3]))

print ( m )

Measured memory_bytes: 42204
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] x = new int[n];
        for(int i = 0; i < n; i++){
            x[i] = sc.nextInt();
        }
        int dist = 0;
        for(int i = 0; i < n; i++){
            dist = dist + Math.min(x[i],Math.abs(k-x[i]));
        }
        System.out.print(dist*2);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main()
{
    int n,p;
    cin >> n >> p;
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    vector<ll> d(n+1);
    d[0] = 0;
    ll ans = 0;
    rep(i,n){
        ll x = s[i] - '0';//今の桁
        d[i+1] = (d[i] + x*modpow(10,i+1,p))%p;
        
    }
    if(p == 2|| p == 5){
        rep(i,n){
            if((s[i] - '0')%p == 0)ans += n-i;
        }
        cout << ans << endl;
    }
    else{
        map<int,ll>m;
        rep(i,n+1){
            m[d[i]]++;
        }
        
        rep(pi,p){
            ans += m[pi] * (m[pi]-1) /2;

        }
        cout << ans << endl;

    }
        
    return 0;
}


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

int main(void)
{
    int r,c;
    cin >> r >> c;
    int data[101][101] = {0};
    for(int i = 0 ; i < r ; i++)
    {
        for(int j = 0 ; j < c ; j++)
        {
            cin >> data[i][j];
            data[i][c] += data[i][j];
        }
        data[r][c] += data[i][c];
    }
    
    for(int i = 0 ; i < c ; i++)
    {
        for(int j = 0 ; j < r ; j++)
        {
            data[r][i] += data[j][i];
        }
    }
    
    for(int i = 0 ; i <= r ; i++)
    {
        for(int j = 0 ; j <= c ; j++)
        {
            cout << data[i][j];
            if(!(j == c))cout << " ";
        }
        cout << endl;
    }
    return 0;
}



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

struct Node {
  int key;
struct Node *prev,*next;
};

struct Node *nil;

void init();//双方向リストの初期化
void insert(int);
struct Node* listSearch(int );
void deleteNode(struct Node *);
void deleteFirst();
void deleteLast();
void deleteKey(int );

int main(){
  int key,n,i,size=0,p=0,d=0;
  char com[25];
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%s%d",com,&key);
    if(com[0]=='i'){
      insert(key);
      p++;
      d++;
    }
    else if(com[6]=='F')
      deleteFirst();
    else if(com[6]=='L')
      deleteLast();
    else{ deleteKey(key);
      d++;
    }
  size--;
  }
  struct Node *cur=nil->next;
  int f=0;
  while(1){
    if(cur==nil)break;
    if(f++>0)printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
  }
  printf("\n");


  return 0;
}
void init(){
  nil=(struct Node*)malloc(sizeof(struct Node));
  nil->next=nil;
  nil->prev=nil;
}
void insert(int key){
  struct Node *x=(struct Node*)malloc(sizeof(struct Node));
  x->key =key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}
struct Node* listSearch(int key){
  struct Node *cur=nil->next;
  while(cur!=nil&&cur->key!=key)
    cur=cur->next;
  return cur;
}
void deleteNode(struct Node *t){
  if(t==nil)return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}
void deleteFirst(){
  deleteNode(nil->next);
}
void deleteLast(){
  deleteNode(nil->prev);
}
void deleteKey(int key){
  deleteNode(listSearch(key));
}



Measured memory_bytes: 33824
#include<bits/stdc++.h>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int main(){
    cs;
    int n,r,t=0;
    cin>>n>>r;
    while(n){
        n/=r;
        t++;
    }
    cout<<t;
}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE(x) ((ll)(x).size()) 
#define MAX(x) *max_element(ALL(x)) 
#define MIN(x) *min_element(ALL(x)) 
#define ALL(x) (x).begin(),(x).end() 

#define INF 1000000000000 
#define MOD 1000000007 
#define MAXR 100000 

#define PB push_back 
#define MP make_pair 
#define F first 
#define S second 



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    //vector<int> a(100005);
    vector<int> a(200005);
    REP(i, n) cin >> a[i];
    //vector<int> b(100005, 0);
    vector<int> b(200005, 0);
    REP(_, min(k, 42)){
        //vector<int> b(100005, 0);
        vector<int> b(200005, 0);
        REP(i, n){
            int l = max(0, (int)i-a[i]);
            int r = min(n-1, (int)i+a[i]);
            b[l] += 1;
            b[r+1] -= 1;
        }
        REP(i, n-1) b[i+1] += b[i];
        REP(i, n) a[i] = b[i];
    }
    REP(i, n) cout << a[i] << " ";
}


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

#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ms(a, b) memset((a), (b), sizeof(a))
#define len(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define lb lower_bound
#define ub upper_bound
#define fore(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <class T> void __f(const char* name, T&& a) {
    cerr << name << ": " << a << '\n';
}
template <class T, class... Ts> void __f(const char* names, T&& a, Ts&&... b) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << a << " /";
    __f(comma + 1, b...);
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <class T> bool mini(T& a, const T& b) { return a > b ? (a = b, 1) : 0; }
template <class T> bool maxi(T& a, const T& b) { return a < b ? (a = b, 1) : 0; }

typedef long long ll;
typedef double db;
typedef pair<int, int> pi;
typedef pair<int, pi> ti;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ti> vti;
typedef vector<vpi> vvpi;

const int inf = (int)0x3f3f3f3f3f3f3f3f;
const int ninf = (int)0xc0c0c0c0c0c0c0c0;
const int M = (int)1e9 + 7;
const int N = 2e5 + 3;

int n;
vi a[N];

main() {
//    freopen("CP.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    fort(u, 2, n) {
        int v; cin >> v;
        a[v].pb(u);
    }
    fort(i, 1, n) cout << len(a[i]) << '\n';
}


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

using namespace std;

int s[5001];

int main()
{
	int n;

	while (scanf("%d", &n), n) {
        memset(s, 0, sizeof(s));

		for (int i = 1; i <= n; ++i) {
			int a; scanf("%d", &a);
			s[i] = a + s[i - 1];
		}

        int ma = -100000;

		for (int i = 1; i <= n; ++i) for (int j = 1; j <= i; ++j) {
			ma = max(ma, s[i] - s[j - 1]);
		}

		printf("%d\n", ma);
	}
}

Measured memory_bytes: 1216
#include<string>
#include <vector>
#include <algorithm>
#include<cstdlib>
#include <queue>
#include <cmath>
#include <iomanip>
#include<list>
#include<cstring>
#include<cctype>
#include <iostream>
 
 
int main(void){
	std::string str;
	std::cin>>str;
	for(int i=0;i<3;i++){
		if(str[i]=='7'){
			std::cout<<"Yes"<<std::endl;
			return 0;
		}
	}
	std::cout << "No" << std::endl;
}

Measured memory_bytes: 3600
import heapq

X, Y, Z, K = map(int, input().split())
A = [int(x) for x in input().split()] + [float('-inf')]
B = [int(x) for x in input().split()] + [float('-inf')]
C = [int(x) for x in input().split()] + [float('-inf')]

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)


def f(i, j, k):
    x = A[i] + B[j] + C[k]
    return (-x, (i, j, k))


hq = []
heapq.heappush(hq, f(0, 0, 0))

ans = []
memo = set()
while len(ans) < K:
    v, (i, j, k) = heapq.heappop(hq)
    ans.append(-v)

    for x in range(3):
        a, b, c = i, j, k
        if x == 0:
            a += 1
        elif x == 1:
            b += 1
        else:
            c += 1
        v = (a << 20) + (b << 10) + c
        if v not in memo:
            heapq.heappush(hq, f(a, b, c))
            memo.add(v)

for x in ans:
    print(x)


Measured memory_bytes: 4976
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        div = 4*h*n - N*(h+n)
        if div!=0 and N*h*n%div==0:
            w = N*h*n // div
            if w > 0:
                print(h,n,w)
                exit()

Measured memory_bytes: 41388
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>


using namespace std;

void solve3() {
	int N;
	cin >> N;
	map<string, int> map;
	for (int i = 0; i < N; i++)
	{
		string A;
		cin >> A;
		if (map[A] == 1) {
			map[A] = 0;
		} else {
			map[A] = 1;
		}
		
	}
	int ans = 0;
	for (auto it = map.begin(); it != map.end(); it++)
	{
		if (it->second == 1)
			ans++;
	}
	cout << ans << endl;
}

void solve2() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
}

void solve1() {
	int N;
	cin >> N;
	if (N / 10 == 9 || N % 10 == 9) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

int main() {
	//solve1();
	//solve2();
	solve3();
	return 0;
}

Measured memory_bytes: 12544
n, m = [int(i) for i in input().split()]
def get_dp(x):
    return sum([2**i for i in x])
a = []
c = []
d=set()
for j in range(m):
    a2, _ = [int(i) for i in input().split()]
    a.append(a2)
    temp=[int(i)-1 for i in input().split()]
    c.append(get_dp(temp))
    d |= set(temp)

if len(d) != n:
    print(-1)
    exit()


dp = [10**10] * (2 ** n)
dp[0] = 0
for i,m in zip(c,a):
    for j, k in enumerate(dp):
        if k != 10**10:
            l=j|i
            dp[l] = min(dp[l], k + m)
print(dp[-1])

Measured memory_bytes: 45544
h, w, n = map(int, input().split())
sr, sc = map(int, input().split())
s = list(input())
t = list(input())
sl_move, sr_move, su_move, sd_move = [], [], [], []
tl_move, tr_move, tu_move, td_move = [], [], [], []
for i in s:
    if i == 'L':
        sl_move += [-1]
        sr_move += [0]
        su_move += [0]
        sd_move += [0]
    elif i == 'R':
        sl_move += [0]
        sr_move += [1]
        su_move += [0]
        sd_move += [0]
    elif i == 'U':
        sl_move += [0]
        sr_move += [0]
        su_move += [-1]
        sd_move += [0]
    elif i == 'D':
        sl_move += [0]
        sr_move += [0]
        su_move += [0]
        sd_move += [1]
for i in t:
    if i == 'L':
        tl_move += [-1]
        tr_move += [0]
        tu_move += [0]
        td_move += [0]
    elif i == 'R':
        tl_move += [0]
        tr_move += [1]
        tu_move += [0]
        td_move += [0]
    elif i == 'U':
        tl_move += [0]
        tr_move += [0]
        tu_move += [-1]
        td_move += [0]
    elif i == 'D':
        tl_move += [0]
        tr_move += [0]
        tu_move += [0]
        td_move += [1]
ru, rd, cr, cl = sr, sr, sc, sc
for i in range(n):
    ru += su_move[i]
    if ru < 1:
        ans = 'NO'
        break
    ru += td_move[i]
    if ru > h:
        ru = h
    rd += sd_move[i]
    if rd > h:
        ans = 'NO'
        break
    rd += tu_move[i]
    if rd < 1:
        rd = 1
    cr += sr_move[i]
    if cr > w:
        ans = 'NO'
        break
    cr += tl_move[i]
    if cr < 1:
        cr = 1
    cl += sl_move[i]
    if cl < 1:
        ans = 'NO'
        break
    cl += tr_move[i]
    if cl > w:
        cl = w
    ans = 'YES'
print(ans)

Measured memory_bytes: 110792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		//static int[] parent;
		//static long MAX_LONG = 100000000000;
		//static int MAX_NUM = 1000000000;
		static void Main(string[] args)
		{
			int[] input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			int N = input[0];
			input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();

			// 数列の最大公約数を取るだけなので
			int gcd = input[0];
			for(int i=1; i<N; i++)
			{
				gcd = getGCD(gcd, input[i]);
			}
			Console.WriteLine(gcd + "");
		}

		static int getGCD(int a, int b)
		{
			if(a%b==0)
				return b;

			return getGCD(b, a%b);
		}


	}
}


Measured memory_bytes: 21728
n,m,k = map(int,input().split())
A = [[] for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    A[a].append(b)
    A[b].append(a)
C = [[] for i in range(n+1)]
for i in range(k):
    c,d = map(int,input().split())
    C[c].append(d)
    C[d].append(c)
from collections import deque
reach = [0]*(n+1)
for i in range(1,n+1):
    if reach[i] != 0:
        pass
    else:
        reach[i] = i
        q = deque([])
        q.append(i)
        while q:
            x = q.popleft()
            for s in A[x]:
                if reach[s] == 0:
                    q.append(s)
                    reach[s] = i
dis_count = [0]*(n+1)
for i,C0 in enumerate(C):
    for CC in C0:
        if reach[CC] == reach[i]:
            dis_count[i] += 1
import collections
D = collections.Counter(reach)
for i in range(1,n+1):
    print(D[reach[i]]-len(A[i])-dis_count[i]-1,end="")
    print(" ",end="")
print("")

Measured memory_bytes: 52988
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;

ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
int exp(int x,int y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%big;
    int t=exp(x,y/2);
    return (t*t)%big;
}

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


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
    
    string s;cin >> s;
    int k;cin >> k;
    rep(i,s.size()){
        if('z'+1-s[i]<=k&&s[i]!='a'){
            k-=('z'+1-s[i]);
            s[i]='a';
        }
    }
    k%=26;
    s[(int)s.size()-1]+=k;
    cout << s << endl;
}

Measured memory_bytes: 592
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()

ans = 0
for b in range(K+1, N+1):
    cnt = 0
    while b*(cnt+1)<=N:
        ans += b*(cnt+1)-(b*cnt+K)
        cnt += 1
    if K!=0:
        ans += max(0, N-b*cnt-K+1)
    else:
        ans += max(0, N-b*cnt-K)
print(ans)

Measured memory_bytes: 69436
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d.begin(), d.end(), greater<int>());
	int ans =1;
	int temp = d[0];
	for (int i = 0; i < n; i++) {
		if (temp > d[i]) {
			temp = d[i];
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def search4(y, x):
    dy = [1, 0, -1, 0]
    dx = [0, 1, 0, -1]
    cnt = 0
    for k in range(4):
        ny = y + dy[k]
        nx = x + dx[k]
        if ny < 0 or H <= ny or nx < 0 or W <= nx:
            continue
        if field[ny][nx] == '#':
            cnt += 1
    return cnt

H, W = map(int, readline().split())
field = [readline().decode().rstrip() for _ in range(H)]

for y in range(H):
    for x in range(W):
        if field[y][x] == '#':
            if search4(y, x) == 0:
                print('No')
                exit()
print('Yes')

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

typedef long long ll;

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

    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for(char a='0';a<='9';a++){
        for(char b='0';b<='9';b++){
            for(char c='0';c<='9';c++){
                int cnt = 0;
                for(int i=0;i<n;i++){
                    if(cnt==0 && s[i]==a) cnt++;
                    else if(cnt==1 && s[i]==b) cnt++;
                    else if(cnt==2 && s[i]==c) cnt++;
                    if(cnt==3) break;
                } 
                if(cnt==3) ans++;   
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<functional>
using namespace std;

int n,m,h,k;
typedef pair<int,int> P;
vector<P> ber;
long long int x[1001],ax[1001];
long long int sc[1001],scn[1001];
long long int yk[100001][2],ys[100001][2];
int resn;
long long int res;
long long int ans;

int main(void){
	while(1){
		cin >> n >> m >> h >> k;
		if(n==0 && m==0 && h==0 && k==0)break;
		memset(x,0,sizeof(x));
		memset(ax,0,sizeof(ax));
		memset(sc,0,sizeof(sc));
		memset(scn,0,sizeof(scn));
		memset(yk,0,sizeof(yk));
		memset(ys,0,sizeof(ys));
		ber.clear();
		res=0;
		resn=0;
		ans=0;
		for(int i=1;i<=n;i++){
			cin >> sc[i];
			scn[i]=sc[i];
			x[i]=i;
			ax[i]=i;
		}
		for(int i=0;i<m;i++){
			int a,b;
			scanf("%d%d",&a,&b);
			ber.push_back(P(b,a));
		}
		sort(ber.begin(),ber.end());
		for(int i=0;i<m;i++){
			swap(x[ber[i].second],x[ber[i].second+1]);
		}
		resn=-1;
		for(int i=m-1;i>=0;i--){
			ys[i][0]=scn[ber[i].second],ys[i][1]=scn[ber[i].second+1];
			swap(x[ber[i].second],x[ber[i].second+1]);
			swap(scn[ber[i].second],scn[ber[i].second+1]);
			yk[i][0]=x[ber[i].second],yk[i][1]=x[ber[i].second+1];
			if(yk[i][0]<=k && yk[i][1]>k){
				long long int sa=ys[i][1]-ys[i][0];
				if(sa>=res)resn=i,res=sa;
			}
			if(yk[i][1]<=k && yk[i][0]>k){
				long long int sa=ys[i][0]-ys[i][1];
				if(sa>=res)resn=i,res=sa;
			}
		}
		for(int i=0;i<m;i++){
			if(i!=resn)swap(ax[ber[i].second],ax[ber[i].second+1]);
		}
		for(int i=1;i<=n;i++){
			if(ax[i]<=k)ans+=sc[i];
		}
		cout << ans << endl;
	}
    return 0;
}

Measured memory_bytes: 5320
#include<bits/stdc++.h>
#define mp make_pair
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define sci(x) scanf("%d",&x)
#define scs(s) scanf("%s",s)
#define scc(c) scanf("%c",c)
#define scd(d) scanf("%lf",&d)
#define scld(ld) scanf("%Lf",&ld)
#define int long long
using namespace std;

//********************************************
//Error tracking
#define show(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
    vector<string> v;
    stringstream ss(s);
    string x;
    while (getline(ss, x, c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
    err(++it, args...);
}
//********************************************

int x,y;
int sol;

int Go(int a, int b)
{
    int aux = a + b;
    int xa = x, ya = y;

    if (a) xa = -xa;
    if (b) ya = -ya;

    if (xa > ya) return (1LL << 31) - 5;
    else 
    {
        aux += abs(xa - ya);
        return aux;
    }
}

int32_t main()
{
   // freopen("input","r",stdin);
 //   freopen("output","w",stdout);
    cin.sync_with_stdio(false);

    cin >> x >> y;

    int aux = min(Go(0,0), Go(1, 0));
    aux = min(aux, Go(0, 1));
    aux = min(aux, Go(1, 1));

    cout << aux << "\n";
    return 0;   
}

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

using namespace std;

void test_case(vector <long> v, int n){
	sort(v.begin(),v.end());
	long ans = 0;	
	for (int i = 0; i < n - 2; i++){
		for (int j = i + 1; j < n - 1; j++){
			for (int k = j + 1; k < n; k++){
				if (v[i] != v[j] && v[j] != v[k] && v[i] != v[k] && (v[k] < v[j] + v[i])){
					++ans;
				}
			}                                     
		}
	}
	cout << ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector <long> v(n);
	for (auto &x : v){
		cin >> x;
	}
	test_case(v,n);	
    return 0;
}





Measured memory_bytes: 3652
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(n: usize,abc: [(usize,usize,usize);n]);

    let mut dp = vec![(0, 0, 0); n];
    let mut index = 1;
    let (a, b, c) = abc[0];
    dp[0] = (a, b, c);

    loop {
        if index == n {
            let (a, b, c) = dp[index - 1];
            let a_b_max = if a > b { a } else { b };
            let max = if a_b_max > c { a_b_max } else { c };
            println!("{:?}",max);
            return
        }
        let (a, b, c) = abc[index];
        let (ha, hb, hc) = dp[index - 1];
        let new_ha = a + if hb > hc { hb } else { hc };
        let new_hb = b + if ha > hc { ha } else { hc };
        let new_hc = c + if ha > hb { ha } else { hb };

        dp[index] = (new_ha, new_hb, new_hc);

        index = index + 1;
    }
}


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

using namespace std;

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

    string s = "";
    do
    {
        if(n % 2)
        {
            s = '1' + s;
            n--;
        }
        else s = '0' + s;

        n = (n / (-2));
    } while(n != 0);
    cout << s << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
#include<vector>
#include<numeric>
#include <cfenv>
#include <cmath>
#include <algorithm>
typedef long long ll;

using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> as(n);
	vector<int> bs(n);
	for (int i = 0; i < n; i++) {
		cin >> as[i];
	}
	for (int i = 0; i < n; i++) {
		bs[i]=as[i]-i-1;
	}
	sort(bs.begin(), bs.end());
	int b = bs[n / 2];
	
	ll kotae=0;

	for (int i = 0; i < n; i++) {
		kotae += abs(bs[i] - b);
	}
	cout << kotae << endl;
	return 0;
}

Measured memory_bytes: 1792