akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    string s;
    cin >> n;
    cout << 0 << endl;
    cin >> s;
    
    string check;
    int max = n - 1;
    int start = max / 2;
    int num = max / 2;
    
    if (s == "Vacant")
    {
        cout << 0 << endl;
    }
    
    check = s;
    
    for (int i = 0; i < 19; ++i)
    {
        cout << start << endl;
        cin >> s;
        
        if (s == "Vacant")
        {
            cout << start << endl;
            return 0;
        }
        
        if (num % 2 == 0)
        {
            num /= 2;
        }
        else
        {
            num = (num + 1) / 2;
        }
        
        if (start % 2 == 0)
        {
            if (check == s)
            {
                start += num;
            }
            else
            {
                start -= num;
            }
        }
        else
        {
            if (check != s)
            {
                start += num;
            }
            else
            {
                start -= num;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
const int INF = 1e9;

vector<vector<int> > G;

int main(){
   int n,m; cin >> n >> m;
   int from, to;
   G.assign(n,vector<int>());
   REP(i,m){
       cin >> from >> to;
       --from; --to;
       G[from].push_back(to);
   }
   
   for(int v : G[0]){
       for(int nv : G[v]){
           if(nv == n - 1){
               cout << "POSSIBLE" << endl;
               return 0;
           }
       }
   }
   cout << "IMPOSSIBLE" << endl;

}

Measured memory_bytes: 8576
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>
#include <bitset>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

double EPS = 1e-10;

double add(double a, double b){
	if(abs(a + b) < EPS * (abs(a) + abs(b))){
		return 0;
	}
	return a + b;
}

struct Pd{
	double x, y;
	Pd(){}
	Pd(double x, double y) : x(x), y(y){}
	Pd operator + (Pd p){
		return Pd(add(x, p.x), add(y, p.y));
	}
	Pd operator - (Pd p){
		return Pd(add(x, -p.x), add(y, -p.y));
	}
	Pd operator * (double d){
		return Pd(x * d, y * d);
	}
	double dot(Pd p){
		return add(x * p.x, y * p.y);
	}
	double det(Pd p){
		return add(x * p.y, -y * p.x);
	}
};

pair<Pd, double> min_ball(vector<Pd> ps) {
    const int n = ps.size();
 
    //assert(n >= 1); // n < 1 の場合、エラーメッセージを出力して異常終了
    if (n == 1) {
        return {ps[0], 0.0};
    }

    using circle = pair<Pd, double>;
 
    auto make_circle_3 = [](Pd a, Pd b, Pd c) -> circle {
        double A = (b - c).dot(b - c), B = (c - a).dot(c - a), C = (a - b).dot(a - b), S = Pd(b - a).det(c - a);
        Pd p = (a * A * (B + C - A) + b * B * (C + A - B) + c * C * (A + B - C)) * (1.0 / (4 * S * S));
        double r2 = (p - a).dot(p - a);
        return {p, r2};
    };
 
    auto make_circle_2 = [](Pd a, Pd b) -> circle {
        Pd c = (a + b) * 0.5;
        double r2 = (a - c).dot(a - c);
        return {c, r2};
    };
 
    auto in_circle = [](Pd a, circle c) -> bool {
        return (a - c.first).dot(a - c.first) <= c.second + EPS;
    };

    circle c = make_circle_2(ps[0], ps[1]);

    for (int i = 2; i < n; ++i) {
        if (!in_circle(ps[i], c)) {
            c = make_circle_2(ps[0], ps[i]);
            for (int j = 1; j < i; ++j) {
                if (!in_circle(ps[j], c)) {
                    c = make_circle_2(ps[i], ps[j]);
                    for (int k = 0; k < j; ++k) {
                        if (!in_circle(ps[k], c)) {
                            c = make_circle_3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

int main(){
	int N;
	cin >> N;
	vector<Pd> v;
	for(int i = 0; i < N; i++){
		Pd p = Pd();
		cin >> p.x >> p.y;
		v.push_back(p);
	}
	printf("%.15f\n", sqrt(min_ball(v).second));
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int n1, n2, n4, n5, t, cnt = 0;
		for (int i = a; i <= b; i++) {
			t = i;
			n1 = t % 10;
			t = t / 10;
			n2 = t % 10;
			t = t / 100;
			n4 = t % 10;
			t = t / 10;
			n5 = t % 10;
			if (n1 == n5 && n2 == n4) {
				cnt++;
			}
		}
		System.out.println(cnt);

	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
 using namespace std;
 #define ll long long
 #define maxn 10000005
  int main()
  {
       int a,b;
      cin>>a;
    b=a%1000;
    if(b==0)cout<<0<<endl;
    else cout<<1000-b<<endl;

  }


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

int main(){

	int N, M;
	cin >> N >> M;
	int answer = 0;
	int buf, buff;
	int MAX;

	for(int i = 0; i < M; i++){
		cin >> buf >> buff;
		answer += max(0, buff - N);
		MAX = max(MAX, buff - N);
	}

	if(MAX > 0) answer -= MAX;

	cout << answer << endl;

	return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c; cin >> a >> b >> c;
    cout << (0<c-a-b&&0<a*a+b*b+c*c-2*a*b-2*b*c-2*c*a?"Yes":"No") << '\n';
}

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

//Reverse Roads
public class Main{

	int[][] cap;
	boolean[] used;
	
	int augumentPath(int v, int t, int f){
		if(v==t)return f;
		used[v] = true;
		for(int i=0;i<cap[v].length;i++){
			if(cap[v][i]>0 && !used[i]){
				int d = augumentPath(i, t, Math.min(f, cap[v][i]));
				if(d>0){
					cap[v][i] -= d;
					cap[i][v] += d;
					return d;
				}
			}
		}
		return 0;
	}

	int maxFlow(int s, int t){
		int flow = 0;
		int n = cap.length;
		used = new boolean[n];
		while(true){
			Arrays.fill(used, false);
			int f = augumentPath(s, t, Integer.MAX_VALUE);
			if(f==0)return flow;
			flow += f;
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] e = new int[m][2];
		cap = new int[n][n];
		for(int i=0;i<m;i++){
			int from = sc.nextInt()-1;
			int to = sc.nextInt()-1;
			e[i][0] = from;
			e[i][1] = to;
			cap[from][to] = 1;
			cap[to][from] = 1;
		}
		int s = sc.nextInt()-1;
		int t = sc.nextInt()-1;
		System.out.println(maxFlow(s, t));
		int r = 0;
		List<Integer> l = new ArrayList<Integer>();
		for(int i=0;i<m;i++){
			if(cap[e[i][1]][e[i][0]]==0){
				r++;
				l.add(i+1);
			}
		}
		System.out.println(r);
		for(int i:l)System.out.println(i);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;

int main()
{
	int n, t[100], m, p[100], x[100], sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
		sum += t[i];
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> p[i] >> x[i];
		cout << sum - t[p[i] - 1] + x[i] << endl;;
	}
    return 0;
}



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

#define int long long

#define M 1046527 /* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return (key%(M-1)); }

int find(char str[]){
  long long key = getKey(str);
  int j=h1(key);
  int j2=h2(key);
  int i=1;
  while(H[j][0]!='\0' && M >= i){
    if(!strcmp(H[j],str)) return 1;
    else {
      j=1+i*j2;
      j%=M;
      i++;
    }
  }
  return 0;
  /* your task */
  
}
int insert(char str[]){
  long long key = getKey(str);
  int j=h1(key);
  int j2=h2(key);
  int i=1;
  while(1){
    if(H[j][0]=='\0'){
      strcpy(H[j],str);
      return j;
    }
    else{
      j=1+i*j2;
      i++;
      j%=M;
    }
  }
  /* your task */
  
}

signed main(){
  int i, n;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
  
  scanf("%lld", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
    
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }
  
  return 0;
}





Measured memory_bytes: 16040
#include<cstdio>
int main(){
  char s[1001];
  scanf("%s",s);
  for(int i=0;s[i]!='\0';i++){
    s[i]-=3;
    if(s[i]<65) s[i]+=26;
  }
  printf("%s\n",s);
  return 0;
}

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

int main(){
	int n, x;
	for(int i=0; i>=0; i++){
		cin >> n >> x;
		int cnt = 0;
		if(n==0 && x==0) break;
		for(int j=1; j<=n; j++){
			for(int k=j+1; k<=n; k++){
				for(int l=k+1; l<=n; l++){
					if(j+k+l==x) cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
# -*- coding:utf-8 -*-
import sys
W, H, N = map(int,input().split())
xya = []
W1 = 0
W2 = W
H3 = 0
H4 = H
for tmp in range(0, N):
    xya.append(list(map(int,input().split())))

for y in range(0, N):
    if xya[y][2] == 1:
        W1 = max(W1, xya[y][0])
    elif xya[y][2] == 2:
        W2 = min(W2, xya[y][0])
    elif xya[y][2] == 3:
        H3 = max(H3, xya[y][1])
    else:
        H4 = min(H4, xya[y][1])

    if W1 >= W2 or H3 >= H4:
        print(0)
        sys.exit()

    W_ans = W2 - W1
    H_ans = H4 - H3

print(W_ans*H_ans)

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

int main() {
  int N;
  cin>>N;
  vector<int> p(60000,1);
  vector<int> q;
  for(int i=2;i<55556;i++){
    if(p[i]){
      for(int j=i*2;j<=55555;j+=i){
        p[j]=0;
      }
      if(i%5==1){
        q.push_back(i);
      }
    }
  }
  for(int i=0;i<N;i++){
    cout<<q[i];
    if(i-1==N){
      cout<<endl;
    }
    else{
      cout<<" ";
    }
  }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	int sum[2]={0};
  	for(int i=0; i<2; i++){
      int a,b,c,d;
      cin>>a>>b>>c>>d;
      sum[i]+=(a+b+c+d);
    }
  cout<<max(sum[0],sum[1])<<endl;
}
		




Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];

    int cost1=0,S=0;
    REP(i,N){
        S+=a[i];
        if(i%2==0 and S<=0) cost1+=1-S,S=1;
        if(i%2==1 and S>=0) cost1+=S+1,S=-1;
    }

    int cost2=0; S=0;
    REP(i,N){
        S+=a[i];
        if(i%2==0 and S>=0) cost2+=S+1,S=-1;
        if(i%2==1 and S<=0) cost2+=1-S,S=1;
    }
    
    cout<<min(cost1,cost2)<<endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	long a, b, c, d;
	cin >> a >> b >> c >> d;
	while (a > 0 && c > 0)
	{
		a -= d;
		c -= b;
	}
	if (c <= 0)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

const int MAX = 2007;
const int MOD = 1000000007;

void solve() {
    int sum = 0, temp;
    for (int i = 0; i < 5; i++) {
        cin >> temp;
        sum += temp;
    }
    cout << 15 - sum;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //int tt; cin >> tt; for (int i = 1; i <= tt; i++) {solve(); cout << endl;}
    solve();
}


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

using namespace std;

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

constexpr int MOD = 1e9 + 7;
int sum(int a, int b, int mod=MOD) {
    int c = a + b;
    if (c >= mod) {
        c -= mod;
    }

    return c;
}

inline int prod(int a, int b, int mod=MOD) {
    return (1LL * a * b) % mod;
}

ll l, r;
int dp[62][2][2][2];
int solve(int k, bool xl, bool yr, bool x0) {
    if (k < 0) {
        return 1;
    }

    int& res = dp[k][xl][yr][x0];
    if (res != -1)
        return res;

    int lb = (l >> k) & 1;
    int rb = (r >> k) & 1;

    res = 0;
    // 00, 01, 11
    for (int a = 0; a <= 1; ++a) {
        for (int b = a; b <= 1; ++b) {
            bool a_valid = xl or lb <= a;
            bool b_valid = yr or rb >= b;

            // cout << k << ' ' << a << ' ' << b << ' ' << xl << ' ' << yr << ' ' << lb << ' ' << rb << '\n';

            if (a_valid and b_valid and (x0 or a == b)) {
                res = sum(res, solve(k - 1, xl or lb < a, yr or rb > b, x0 or a));
            }
        }
    }

    // cout << "dp[" << k << "][" << xl << "][" << yr << "] = " << res << '\n';
    return res;
}

int brute() {
    int ans = 0;
    for (ll x = l; x <= r; ++x) {
        for (ll y = x; y <= r; ++y) {
            if ((y ^ x) == (y % x)) {
                // cout << x << ' ' << y << '\n';
                ans++;
                assert((y & x) == x);
                assert(2 * x > y and (y & x) == x);
            }

            if (2 * x > y and ((y & x) == x)) {
                assert((y & x) == x);
                // --ans;
            }
        }
    }

    return ans;
}

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

    cin >> l >> r;
    // seems to happen if bits in x are a subset of the bits in y
    // and y is no more than double x
    // state is:
    // index of bit we're filling
    // whether x is > L yet
    // whether y is < R yet
    //
    // 1100100
    // 0001010
    //
    // alternately: pretty easy to compute for under a power of 2
    // 1 1 = 1
    // 1 3 = 5
    // 1 7 = 19
    // for b bits, this is 3^n - 2^n
    
    memset(dp, -1, sizeof(dp));
    int ans = solve(61, false, false, false);

    cout << ans << '\n';
    // cout << brute() << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+7;
#define ll long long

map<ll,int>mp;
vector<int>q;
int n;
ll m;
ll a[N];

int main(){
	scanf("%d%lld",&n,&m);
	for(int i = 1;i<=n;i++) {
		scanf("%lld",&a[i]);
		a[i]=a[i]+a[i-1];
	}
	for(int i = 1;i<=n;i++) a[i]%=m;
	ll ans=0;
	for(int i = 1;i<=n;i++) {
		if(!mp[a[i]]) q.push_back(a[i]);
		mp[a[i]]++;
		//ans+=mp[a[i]];
	}
	mp[0]++;
	//ll ans=0;
	for(int i = 0;i<q.size();i++){
		int num=q[i];
		ll tmp=mp[num];
		ans+=(tmp*(tmp-1))/2;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 5244
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
using namespace std;
const long long MAXN=200001;
long long arr[MAXN];
int main(){
    multiset<long long> st;
    long long n,c,k;
    cin>>n>>c>>k;
    for(long long i=1;i<=n;i++)cin>>arr[i];
    sort(arr+1,arr+n+1);
    long long ret=0;
    for(long long i=1;i<=n;i++){
        if(st.size()==0){
            st.insert(arr[i]);
            ret++;
        }
        else{
            if(*st.begin()+k>=arr[i] && st.size()<c){
                st.insert(arr[i]);
            }else{
                st.clear();
                st.insert(arr[i]);
                ret++;
            }
        }
    }
    cout<<ret;
    return 0;
}

/*
 5 2 0
 1
 2
 3
 6
 12
*/

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

int main() {
    int n,k;
    cin>>n>>k;
    int m=1;
    for(int i=1;i<=n;i++){
        if((m*2-m)<=k) m*=2;
        else m+=k;
    }

    cout<<m<<endl;
}

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

constexpr int mod = 1e9+7, N = 100001;
//vector<vector<int>> dp(N, vector<int>(2, 0));
long long ans;

long long modpow(long long x, long long y){
	long long res = 1;
	while(y > 0){
		if(y & 1){
			res *= x;
			res %= mod;
		}
		x *= x;
		x %= mod;
		y >>= 1;
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	int n = s.size();
	bitset<N> l(s);
	vector<int> v(n, 0);
	for(int i=0; i<n; ++i) v[i] = l[i];
	for(int i=n-2; i>=0; --i) v[i] += v[i+1];
	for(int i=0; i<n; ++i)
		if(l[n-i-1] == 1)
			ans += modpow(3, n-i-1) * modpow(2, v[n-i-1]-1) % mod;
	ans += modpow(2, v[0]);
	ans %= mod;
	cout << ans << "\n";
/*	for(int i=0; i<1000; ++i)
		for(int j=0; j<1000; ++j)
			if((i+j) == (i^j)){
				if((i & j) != 0){
					cout << i << " " << j << "\n";
				}
			}*/
}

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

using namespace std;

bool judge(string T){ int t = T.size();
  if(t % 2 != 0){return false;}
  else{ 
    string u = T.substr(0, t/2);
    string v = T.substr(t/2,t/2);
    if( u == v){return true;}
    else{return false;}
  } }

int main(){
  string S; cin >> S;
   int j ;
   for(int i = 1; i < S.size(); i++){ 
     j = i; 
     string T = S.substr(0,S.size() - i ); 
     if(judge(T)){break;}
     else{continue;} }
  
  cout << S.size() - j << endl; return 0;}
  
  

Measured memory_bytes: 256
#include <stdio.h>
int r[50];
int t[50];
int main(void){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d",&r[i],&t[i]);
    }
    for(int i=0;i<n;i++){
        if(t[i]%30==0){
            if(r[i]%100==0){
                printf("%d\n",t[i]/30*5+r[i]/100);
            }
            else{
                printf("%d %d\n",t[i]/30*5+r[i]/100,t[i]/30*5+r[i]/100+1);
            }
        }
        else{
            if(r[i]%100==0){
                printf("%d ",t[i]/30*5+r[i]/100);
                printf("%d\n",(t[i]/30+1)*5+r[i]/100);
            }
            else{
                printf("%d ",t[i]/30*5+r[i]/100);
                printf("%d ",t[i]/30*5+r[i]/100+1);
                printf("%d ",(t[i]/30+1)*5+r[i]/100);
                printf("%d\n",(t[i]/30+1)*5+r[i]/100+1);
            }
        }
    }
}


Measured memory_bytes: 2624
n = int(input())
dp = [10**6] * (n+1)
dp[0] = 0
for i in range(1,n+1):
  c = 1
  d = 1
  dp[i] = min(dp[i],dp[i-1]+1)
  while True:
    if i - 6**c >= 0:
      dp[i] = min(dp[i],dp[i-6**c]+1)
    else:
      break
    c += 1
  while True:
    if i - 9**d >= 0:
      dp[i] = min(dp[i],dp[i-9**d]+1)
    else:
      break
    d += 1
print(dp[n])

Measured memory_bytes: 42860
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	int a,b,c,n;
	cin>>a>>b>>c>>n;
	int w=0;
	rep(i,n+1)rep(j,n+1){
		int k=n-a*i-b*j;
		if(k>=0&&k%c==0)w++;
	}
	cout<<w<<endl;
}


Measured memory_bytes: 256
from itertools import combinations as comb

N = int(input())
xy = []
xy_ap = xy.append

for i in range(N):
    xy_ap(list(map(int, input().split())))

ls = [i for i in range(N)]

result = []

xy.sort()

for i, j in comb(ls, 2):
    result.append([xy[i][0] - xy[j][0], xy[i][1] - xy[j][1]])

cnt = 0
for i in range(len(result)):
    if result.count(result[i]) >= cnt:
        cnt = result.count(result[i])

print(N - cnt)



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

using namespace std;

const long long INF = 1e12;

int main() {
	int T;
	ignore = scanf("%d", &T);
	while (T--) {
		long long n, a, b, c, d;
		ignore = scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &c, &d);
		
		const int q[3] = {2, 3, 5};
		const long long p[3] = {a, b, c};
		
		long long k = min({a / d, b / (2 * d), c / (4 * d)}) + 1;
		
		map<long long, long long> dp;
		function<long long(long long)> calc = [&](long long x) {
			if (x <= k) return x * d;
			if (dp.count(x) == 1) return dp[x];
			
			long long res = INF;
			if (x <= INF / d) res = x * d;
			
			for (int i = 0; i < 3; i++) {
				long long cur = (x % q[i]) * d + p[i] + calc(x / q[i]);
				res = min(res, cur);
				
				cur = (q[i] - x % q[i]) % q[i] * d + p[i] + calc((x + q[i] - 1) / q[i]);
				res = min(res, cur);
			}
			
			return dp[x] = res;
		};
		
		printf("%lld\n", calc(n));
	}
	
	return 0;
}


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

int main(){

    int N, K;
    cin >> N >> K;
    vector<long long> x(N);
    for(int i = 0; i < N; i++) cin >> x[i];

    long long min = 1e12;
    for(int i = 0; i < N - K + 1; i++){
        long long dist = abs(x[i]) + abs(x[i + K - 1] - x[i]);
        if(min > dist) min = dist;
    }
    for(int i = 0; i < N - K + 1; i++){
        long long dist = abs(x[i + K - 1]) + abs(x[i + K - 1] - x[i]);
        if(min > dist) min = dist;
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
const int MaxN = 1e5+5;
int n;
char a[MaxN];
int main(){
	while(~scanf("%s",a)){
		int n = strlen(a);
		for(int i = 0;i<n;i++){
			if(i%2==0)
				printf("%c",a[i]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
#N,M=10**5, 10**5

works = Hash.new{|k,v| k[v]=[]}
works[M] << 0
N.times do |i|
  a, b = gets.split.map(&:to_i)
  #a, b = rand(1..10**5), rand(1..10**4)
  next if a > M
  works[a] << b
end

days = works.keys.sort
now = 1
tingins = works[days[0]]
ans = 0
(1..(days.size-1)).each do |i|
  day = days[i]
  while now < day
    if tingins.empty?
      now = day
      break
    else
      ans += tingins.pop
    end
    now += 1
  end
  
  works[day].each do |yen|
    index = tingins.bsearch_index {|x| x >= yen} || -1
    tingins.insert(index, yen)
  end
end
ans += tingins.pop

p ans


Measured memory_bytes: 17284
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;


namespace atPra
{
    class Class1
    {
        static void Main()
        {
            string[] str = Console.ReadLine().Split(null);
            int D = int.Parse(str[0]);
            int N = int.Parse(str[1]);
            int cnt = 0, val = 0;
            while(cnt<N){
                val++;
                if (calc(val) == D) cnt++;
            }
            Console.WriteLine(val);
        }

        static public int calc(int x){
            int ret = 0;
            while(x%100==0){
                x /= 100;
                ret++;
            }
            return ret;
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long
string s;
int W, H, x, y, r, a, b, c, num[5];

int main() {
	for (int i = 0; i < 3000; i++) {
		cin >> x >> y;
		if (x + y == 0) break;
		cout << min(x, y) << " " << max(x, y) << endl;

	}

	return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string s;
    cin >> s;

    ll ans = 0;
    rep(i, 3) {
        if(s[i] == '1') {
            ans++;
        }
    }

    out(ans);
    re0;
}

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

int main(){
  int n,a,q;
  set<int> s;
  cin >> n;
  while(n--){
    cin >> a;
    s.insert(a);
  }
  cin >> q;
  r(i,q){
    cin >> a;
    cout << s.count(a)<<endl;
  }
}


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

int main(int argc, char *argv[]) {
  string a;
  cin >> a;

  map<char, int> m;
  for (int i = 0; i < a.size(); ++i) {
    m[a[i]]++;
    if (m[a[i]] > 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  if (m.size() == 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static int N;
	static int sum;

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

		for (int i = 0; i < 100; i++) {
			N = sc.nextInt();

			if (N == 0) {
				break;
			}

			sum = 0;

			// 完全数判定
			for (int j = 1; j * j <= N; j++) {
				if (N % j == 0) {
					if (j == 1)
						sum += 1;
					else if (N / j == j) {
						sum += j;
					} else {
						int s = N / j;
						sum += j;
						sum += s;
					}
				}
			}

			if (N == sum && N != 1) {
				System.out.println("perfect number");
				// System.out.println("N " + N + " sum " + sum);
			} else if (N > sum || N == 1 || N == 2 || N == 3) {
				System.out.println("deficient number");
				// System.out.println("N " + N + " sum " + sum);
			} else {
				System.out.println("abundant number");
				// System.out.println("N " + N + " sum " + sum);
			}
		}
	}
}

Measured memory_bytes: 18152
using System;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		long[] a=new long[n];
		a[0]=int.Parse(Console.ReadLine());
		long ans=a[0]/2;
		a[0]%=2;
		for(int i=1;i<n;i++){
			a[i]=int.Parse(Console.ReadLine());
			ans+=(a[i-1]+a[i])/2;
			a[i]=a[i]>0?((a[i-1]+a[i])%2):0;
		}
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 17884
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int a, b;
    cin>>a>>b;
    int nexta=a-1;
    int nextb=b-1;
    int ans = max(a+nexta, max(b+nextb, a+b));
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

void solve(){
	int n;
	cin >> n;
	cout << (1000 - n % 1000) % 1000 << newl;

	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define mem(a, b) memset(a, (b), sizeof(a))
#define fore(i,a) for(int i=0;i<a;i++)
#define fore1(i,j,a) for(int i=j;i<a;i++)
#define print(ar) for(int i=0;i<ar.size();i++)cout<<ar[i]<<" ";
#define END cout<<'\n'
const double pi=acos(-1.0);
 
typedef pair<int, int> PII;
 
typedef vector<long long> VI;
 
typedef vector<string> VS;
 
typedef vector<PII> VII;
 
typedef vector<VI> VVI;
 
typedef map<int,int> MPII;
 
typedef set<int> SETI;
 
typedef multiset<int> MSETI;
 
typedef long int li;
 
typedef unsigned long int uli;
 
typedef long long int ll;
 
typedef unsigned long long int  ull;
ll fastexp (ll a, ll b, ll n) {
  ll res = 1;
  while (b) {
      if (b & 1) res = res*a%n;
      a = a*a%n;
      b >>= 1;
  }
  return res;
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
 {  fast();
  ll n,k;
  cin>>n>>k;
  vector<long long> vect(n+1);
  fore1(i,1,n+1)cin>>vect[i];
  vector<ll> arr;
  map<ll,ll> mp;
  ll j=1;
  //print(vect);
  arr.push_back(1);
  mp.insert({1,1});
  j++;
  int l;
  for(int i=vect[1];;i=vect[i]){
      if(mp.find(i)!=mp.end()){
        l= mp.find(i)->second;
          break;
      }
      else{
         // cout<<i<<" "<<j<<endl;
          mp.insert({i,j});
          arr.push_back(i);
          j++;
      }
  }
 // print(arr);
 // cout<<arr.size();
 
  int interval = arr.size()-(l-1);
  if(k<l-1)cout<<arr[k];
  else{
    //  cout<<l<<" "<<interval;
      cout<<arr[(k-(l-1))%interval+l-1];
  }
  //ull o=727202214173249351;
  //cout<<o%3<<endl;
  }

	  
	

Measured memory_bytes: 18596
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;



int main(){
    string A,B;
    cin >> A >> B;
    string S = A + B;
    int N = stoi(S);
    int root = sqrt(N);
    if(root*root == N){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
# coding: utf-8
n,m=map(int,input().split())
edge=[]
for i in range(m):
    a,b,c=map(int,input().split())
    edge.append((a-1,b-1,-c))
inf=99999999999999999999
d=[inf for i in range(n)]
d[0]=0
count=0
while count<n+1:
    count+=1
    if count==n:
        tmp=d[n-1]
    update=False
    for i in range(m):
        f,t,cost=edge[i]
        if(d[t]>d[f]+cost):
            d[t]=d[f]+cost
            update=True
    if count==n and tmp!=d[n-1]:
        print('inf')
        break
    if not update:
        print(-d[n-1])
        break
else:
    print(-d[n-1])

Measured memory_bytes: 3316
N = int(input())
A = list(map(int, input().split()))

dic = {}
dup = set()
for a in A:
    if a in dic:
        dic[a] += 1
        dup.add(a)
    else:
        dic[a] = 1

A_max = max(A)
A_set = set(dic.keys())

cnt = 0
for a in A:
    if a not in A_set:
        continue

    cnt1 = 2
    x = a * cnt1
    while x <= A_max:
        if x in A_set:
            A_set.remove(x)

        cnt1 += 1
        x = a * cnt1

A_set = A_set - dup

print(len(A_set))


Measured memory_bytes: 50384
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let r: i64 = input();
    let d: i64 = input();
    let x0: i64 = input();

    let mut x = x0;
    for _ in 1..11 {
        x = r * x - d;
        println!("{}", x);
    }
}


Measured memory_bytes: 4352
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import java.util.regex.*;

public class Main {
    
    private static PrintWriter out;
    
    private static <T> void mprintln(T ... ar){
        for(T i: ar) out.print(i + " ");
        out.println();
    }
    
    public static void main(String[] args) throws FileNotFoundException{

        // Input from file
        // File inputFile = new File("JavaFile.txt");
        // File outputFile = new File("JavaOutputFile.txt");
        // FileReader fileReader = new FileReader(inputFile);
        // Here it ends

        MyScanner sc = new MyScanner();
        // MyScanner sc = new MyScanner(fileReader);

        out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
        // out = new PrintWriter(new PrintStream(outputFile)); // Output to file

        getAns(sc);

        out.close(); 
    }
    
//  Global Variables  
    
    private static void getAns(MyScanner sc){
        int n = sc.ni(), l = sc.ni();
        int[] ar = new int[n + 1];
        int total = 0, minus = Integer.MAX_VALUE;
        for(int i = 1; i <= n; i++){
            ar[i] = l + i - 1;
            total += ar[i];
            if(Math.abs(ar[i]) < Math.abs(minus)) minus = ar[i];
        }
        
        out.println(total - minus);
    }
    
    static class MyScanner{
        BufferedReader br;
	StringTokenizer st;

	MyScanner(FileReader fileReader){
            br = new BufferedReader(fileReader);
	}

	MyScanner(){
            br = new BufferedReader(new InputStreamReader(System.in));
	}

	String nn(){
            while(st == null || !st.hasMoreElements()){
		try{
                    st = new StringTokenizer(br.readLine());
		}catch(IOException e){
                    e.printStackTrace();
		}
            }
            return st.nextToken();
	}
        
        String nextLine(){
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }

	char nc(){
            return nn().charAt(0);
	}

	int ni(){
            return Integer.parseInt(nn());
	}

	long nl(){
            return Long.parseLong(nn());
	}

	double nd(){
            return Double.parseDouble(nn());
	}

	int[] niArr0(int n){
            int[] ar = new int[n];
            for(int i = 0; i < n; i++) ar[i] = ni();
            return ar;
	}

        int[] niArr1(int n){
            int[] ar = new int[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = ni();
            return ar;
	}

        long[] nlArr0(int n){
            long[] ar = new long[n];
            for(int i = 0; i < n; i++) ar[i] = nl();
            return ar;
        }

        long[] nlArr1(int n){
            long[] ar = new long[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = nl();
            return ar;
        }
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {

int r; cin>>r;
  int rr;
  rr=2*r;
  
  double ans;
  ans=rr*3.1415926535;
  cout<<ans<<endl;
  

}

Measured memory_bytes: 3744
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long int ll;

int main()
{
	int n;
	ll s[100];
	cin >> n;
	for(int i=0;i<n;i++)cin >> s[i];
	ll dp[100][21];
	for(int i=0;i<21;i++){
		if(i==s[0])dp[0][i]=1;
		else dp[0][i]=0;
	}
	for(int i=1;i<n-1;i++){
		for(int j=0;j<=20;j++){
			if(j+s[i]>20)dp[i][j]=dp[i-1][j-s[i]];
			else if(j-s[i]<0)dp[i][j]=dp[i-1][j+s[i]];
			else dp[i][j]=dp[i-1][j-s[i]]+dp[i-1][j+s[i]];
		}
	}
	cout << dp[n-2][s[n-1]] << "\n";
	return 0;
}

Measured memory_bytes: 1184
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static String I = "IMPOSSIBLE";
	public static String B = "Bad";
	public static String G = "Good";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int n = ni();

		int counter = 0;

		HashMap<Long, Integer> hs = new HashMap<>();
		// int[] clist = new int[1000000000];

		for (int i = 0; i < n; i++) {
			long num = nl();
			if (hs.get(num) == null) {
				hs.put(num, 1);
			} else {

				int now = hs.get(num);
				if (now == (int) num) {
					counter++;

				} else {

					hs.put(num, hs.get(num) + 1);
				}
			}
			//			if (clist[num - 1] <= num) {
			//				clist[num - 1]++;
			//			} else {
			//				count++;
			//			}
		}

		for (Long key : hs.keySet()) {
			if (key != (int) hs.get(key)) {
				counter += (int) hs.get(key);
			}
		}

		out(counter);

	}

	public static int count(String search, String text) {
		int nsearch = search.length();
		int ntext = text.length();
		int count = 0;

		for (int i = 0; i <= ntext - nsearch + 1; i++) {
			for (int j = i + nsearch - 1; j < ntext; j++) {
				if (search.equals(text.substring(i, j + 1))) {
					count++;
				}
			}
		}

		return count;
	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static int max(int a, int b) {
		return Math.max(a, b);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


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

using namespace std;

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

  int x;
  cin >> x;

  string ans = "No";
  if (x >= 30) {
    ans = "Yes";
  }

  cout << ans << '\n';

  return 0;
}

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

namespace AtCoder20200328_2
{
    class Program
    {
        static void Main(string[] args)
        {
            // Coffee();
            GoldCoin();
        }

        public static void Coffee()
        {
            char[] inputs = new char[6];
            inputs = Console.ReadLine().Select(c => c).ToArray();
            if(inputs[2] == inputs[3] && inputs[4] == inputs[5])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }

        public static void GoldCoin()
        {
            long X = long.Parse(Console.ReadLine());
            long num_500 = X / 500;
            long num_5 = (X - num_500 * 500) / 5;

            Console.Write(num_500*1000 + num_5*5);
        }
    }
}


Measured memory_bytes: 11220
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	int sum = 1;
	vector<char> s(n);
	rep(i, n) cin >> s.at(i);
	char c_old = s.at(0);
	rep2(i, 1, n) {
		if (c_old != s.at(i)) {
			sum++;
			c_old = s.at(i);
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
int a,b;
scanf("%d",&a);
if(a<60){
printf("0:0:%d\n",a);
}
else if(a<3600){
printf("0:%d:%d\n",a/60,a-(a/60*60));
}
else{
b=(a-(a/3600*3600))/60;
printf("%d:%d:%d\n",a/3600,b,(a-(a/3600*3600))-b*60);
}
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, x, a[30]; bool dp[1000001], prime[1000001];
int main() {
	prime[0] = true, prime[2] = true;
	for(int i = 3; i <= 1000000; i += 2) prime[i] = true;
	for(int i = 3; i <= 1000; i += 2) {
		if(!prime[i]) continue;
		for(int j = i * i; j <= 1000000; j += i * 2) prime[j] = false;
	}
	while(scanf("%d%d", &n, &x), n) {
		for(int i = 0; i < n; i++) scanf("%d", &a[i]); sort(a, a + n);
		for(int i = 0; i < x; i++) dp[i + 1] = false; dp[0] = true;
		for(int i = 1; i <= x; i++) {
			for(int j = 0; j < n && i >= a[j]; j++) {
				if(dp[i - a[j]]) {
					dp[i] = true; break;
				}
			}
		}
		for(int i = x; i >= 0; i--) {
			if(dp[i] && prime[i]) {
				printf(i ? "%d\n" : "NA\n", i); break;
			}
		}
	}
}

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

int main() {
  string N;
  string tmp;
  cin >> N;
  
  size_t size = N.length();
  
  int sum = 0;
  
  for (int i=0; i < size; i++) {
    tmp = N[i];
    sum += stoi(tmp);
  }
  
  
  if (stoi(N) % sum == 0) {
      cout << "Yes" << endl;
  }
  else {
      cout << "No" << endl;
  }

}


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

int main(){
	long X,t,res;
	cin>>X>>t;
	if(1>X>1000000000)return -1;
	if(1>t>1000000000)return -1;
	res=X-t;
	if(res<0)res=0;
	cout<<res<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		if(n % k == 0) {
			System.out.println(0);
		} else {
			System.out.println(1);
		}
	}
}


Measured memory_bytes: 22100
import java.util.Scanner;

public class Main {

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

		while (true) {
			final int n = sc.nextInt();

			if (n == 0) {
				break;
			}

			for (int t = 0; t < n; t++) {

				int[] one = new int[4];
				int[] two = new int[4];

				for (int i = 0; i < 4; i++) {
					one[i] = sc.nextInt();
				}

				for (int i = 0; i < 4; i++) {
					two[i] = sc.nextInt();
				}

				int[] three = new int[4];

				for (int i = 0; i < 4; i++) {
					
					for (int j = 0; j < 4; j++) {
						//System.out.println(one[i] * two[j]);
						switch (i) {
						case 0:
							three[j] += one[i] * two[j];
							break;
						case 1:
							three[j % 2 == 0 ? j + 1 : j - 1] += j % 2 != 0 ? -(one[i] * two[j])
									: one[i] * two[j];
							break;
						case 2:
							three[j + 2 < 4 ? j + 2 : j - 2] += j == 1
									|| j == 2 ? -(one[i] * two[j]) : one[i]
									* two[j];
							break;
						case 3:
							three[3 - j] += j >= 2 ? -(one[i] * two[j])
									: one[i] * two[j];
							break;
						}
					}
				}

				for (int i = 0; i < 4; i++) {
					if (i == 0) {
						System.out.print(three[i]);
					} else {
						System.out.print(" " + three[i]);
					}
				}

				System.out.println();
			}

		}
	}

}

Measured memory_bytes: 12000
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderBeginnerContest
{
    public class Program
    {
        public static void Main(string[] args)
        {
            // D
            var line = Console.ReadLine().Split(' ');

            var N = int.Parse(line[0]);
            var A = int.Parse(line[1]);
            var B = int.Parse(line[2]);

            var h = new long[N];
            for (int i = 0; i < N; i++)
            {
                h[i] = long.Parse(Console.ReadLine());
            }

            long max = h.Max()/B + 1;
            long min = 1;
            long mid = 0;

            while (true)
            {
                mid = min + (max - min)/2;

                var hantei = Judge(mid, A, B, h);

                if(hantei && max == min)
                {
                    break;
                }
                else if(hantei && max != min)
                {
                    max = mid;
                }
                else
                {
                    min = mid + 1;
                }
            }
            Console.WriteLine(mid);
        }

        public static bool Judge(long kaisu,long A,long B,long[] h)
        {
            long k = 0;
            foreach(var x in h.OrderByDescending(x=>x))
            {
                var w = (x - B * kaisu);
                if(w > 0)
                {
                    k += (long)Math.Ceiling((1.0 * w) / (A - B));
                }
                else
                {
                    break;
                }
            }
            if(k> kaisu)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }
}


Measured memory_bytes: 36780
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 300010;
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n;
	cin >> n;
	vector<ll> a(n);
	for (auto &i : a)
		cin >> i;
	sort(a.begin(), a.end(), greater<>());
	ll res = a[0];
	int cnt = 1;
	vector<ll> b;
	for (int i = 1;i < n;++i)
		b.pb(a[i]), b.pb(a[i]);
	for (int i = 2, j = 0;i < n;++i) {
		res += b[j++];
	}

	cout << res << '\n';
}


Measured memory_bytes: 8952
#include <stdio.h>
#include <string.h>
#define MAX 1001
int main(void)
{
	char str[MAX], work[MAX]={'\0'}, p[MAX], ope[8];
	int a, b, q, len, i, j, x;
	scanf("%s", str);
	scanf("%d", &q);
	for(i=0; i<q; i++){
		scanf("%s", ope);
		switch(ope[2]){
			case 'i':
				scanf("%d%d", &a, &b);
				for(j=a; j<=b; j++){
					printf("%c", str[j]);
				}
				puts("");
				break;
			case 'v':
				scanf("%d%d", &a, &b);
				len = (int)strlen(str);
				strncpy(work, str, len);
				for(j=0; j<(b-a+1); j++){
					str[a+j] = work[b-j];
				}
				break;
			case 'p':
				scanf("%d%d%s", &a, &b, p);
				for(j=0; j<(b-a+1); j++){
					str[a+j] = p[j];
				}
				break;
			default:
				break;
		}
	}
	return 0;
}

Measured memory_bytes: 604