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

double calcDistance(double x1, double y1, double x2, double y2){
	double d;
	d = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
	return d;
}

int main(){
	double xa, ya, ra;
	double xb, yb, rb;
	int num;
	std::cin >> num;
	
	while(num){
		std::cin >> xa >> ya >> ra >> xb >> yb >> rb;
		double d = calcDistance(xa, ya, xb, yb);
		int answer = 1;
		
		if(ra + rb < d) 
			answer = 0;
		else if(ra - rb > d)
			answer = 2;
		else if(rb - ra > d)
			answer = -2;
			
		std::cout << answer << std::endl;
		--num;
	}


}

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

int main(){
	string s;
	cin >> s;
	
	int len=0;
	bool flag=false;
	int ans=0;
	for(int i=0; i<s.size(); i++){
		if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
			len++;
			flag=true;
		}else{
			len=0;
			flag=false;
		}
		if(flag==true && ans<len) ans=len;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int a,b,sum_a=0,sum_b=0,i;
  for(i=0;i<4;i++){
    scanf("%d",&a);
    sum_a+=a;
  }
  for(i=0;i<4;i++){
    scanf("%d",&b);
    sum_b+=b;
  }
  printf("%d\n",sum_a>sum_b?sum_a:sum_b);
  return(0);
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_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;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll N;
vector<int> v;
int Zero, One;
vector<int> Back;
int main() {
    cin >> N;
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if(a == 0) Zero++;
        else if(a == 1) One++;
        else v.push_back(a);
    }
    sort(v.begin(), v.end());
    if(Zero % 2 == 0) {
        for(int i = 0; i < Zero; i++) {
            Back.push_back(0);
        }
        for(int i = 0; i < One; i++) {
            Back.push_back(1);
        }
    } else {
        if(One) {
            for(int i = 0; i < Zero - 1; i++) {
                Back.push_back(0);
            }
            Back.push_back(1);
            Back.push_back(0);
            for(int i = 0; i < One - 1; i++) {
                Back.push_back(1);
            }
        } else if(v.size()) {
            for(int i = 0; i < Zero - 1; i++) {
                Back.push_back(0);
            }
            Back.push_back(v[0]);
            Back.push_back(0);
            v.erase(v.begin());
        } else {
            for(int i = 0; i < Zero; i++) cout << 0 << endl;
            return 0;
        }
    }
    if(v.size() >= 2) {
        int k = v.size();
        if(v[k-1] == 3 and v[k-2] == 2) {
            swap(v[k-1], v[k-2]);
        }
    }
    for(auto val : v) cout << val << endl;
    for(auto val : Back) {
        cout << val << endl;
    }
    return 0;
}


Measured memory_bytes: 3172
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var K = parseInt(input[0].split(" ")[1]);
  var ans=N-K+1;

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n, a, b;
  scan(n, a, b);
  print(min(a * n, b));
  return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

ll gcd(ll a,ll b){
	if(a<b){
		swap(a,b);
	}

	while(ll r=(a%b)){
		a = b;
		b = r;
	}
	return b;
}

ll lcm(ll a,ll b){
	return a*b/gcd(a,b);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a;
	while(cin>>a){
		auto b=in();

		out(gcd(a,b),lcm(a,b));
	}
	return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define fr(i,n)  for(int i = 0;i<n;++i)
#define fri(i,a,b) for(int i= a;i<=b;++i)
#define fro(i,a,b) for(int i= a;i>=b;--i)
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define fi first
#define se second
#define pb(x) push_back(x)
#define  mp(x,y) make_pair(x,y)
#define endl  "\n"
#define  ii  pair<int,int>
#define  LL  long long
#define  maxm(a,b,c)  max(a,max(b,c))

int main(){
  int n;
  cin>>n;
  int a[n];
  fr(i,n){
  	cin>>a[i];
  }
  int dp[n];
  dp[0] = 0;
  dp[1] =  abs(a[1]-a[0]);
  fri(i,2,n-1){
  	dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
  }
  cout<<dp[n-1];
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner Input = new Scanner(System.in);
        long X = Input.nextLong();
        long Y = Input.nextLong();
        long Z = Input.nextLong();
        int Count = 0;

        if (X - Z > 0) {
            X = X - Z;
        } else {
            System.out.println("0");
        }

        while (X >= Z + Y) {
            Count++;
            X = X - (Z + Y);
            //System.out.println("C");
        }
        System.out.println(Count);

    }
}


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

#define ll long long
#define pb push_back
#define F first
#define S second

using namespace std;

const int N = 100005;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int r, d, x;
    cin >> r >> d >> x;
    for (int i = 1; i <= 10; i++) {
        cout << (x = (r * x - d)) << endl;
    }
    return 0;
}


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

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

    for(int i = 0; i < T; i++){
        int N;
        cin >> N;

        vector<long long> K(N),L(N),R(N);
        for(int j = 0; j < N; j++) cin >> K[j] >> L[j] >> R[j];

        vector<pair<long long, long long>> l,r;
        long long ans = 0LL;
        for(int j = 0; j < N; j++){
            if(L[j] > R[j]){
                ans += R[j];//最低限R[j]はもらえる
                l.emplace_back(K[j]-1, L[j]-R[j]);
            }
            else{
                ans += L[j];//最低限L[j]はもらえる
                r.emplace_back(N-K[j]-1, R[j]-L[j]);
            }
        }
        sort(l.begin(), l.end());
        sort(r.begin(), r.end());
        priority_queue<long long, vector<long long>, greater<long long>> que;
        for(int j = 0; j < l.size(); j++){
            if((int)que.size() <= l[j].first){
                ans += l[j].second;
                que.push(l[j].second);
            }
            else{
                if(que.size() == 0) continue;
                if(que.top() < l[j].second){
                    ans -= que.top();
                    que.pop();
                    ans += l[j].second;
                    que.push(l[j].second);
                }
            }
        }

        while(que.size() != 0) que.pop();

        for(int j = 0; j < r.size(); j++){
            if((int)que.size() <= r[j].first){
                ans += r[j].second;
                que.push(r[j].second);
            }
            else{
                if(que.size() == 0) continue;
                else{
                    if(que.top() < r[j].second){
                        ans -= que.top();
                        que.pop();
                        ans += r[j].second;
                        que.push(r[j].second);
                    }
                }
            }
        }

        cout << ans << endl;
    }
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


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

	int n;
	cin >> n;
	
	vi v(n);
	
	repi(i , n){
		cin >> v[i - 1];
	}

	int ans = 0;
	
	rep(i , n){
		if(v[i] == i + 1){
			if(i + 1 < n && v[i + 1] == i + 2){
				swap(v[i + 1] , v[i]);
				++ans;
				continue;
			}
			if(i > 0){
				swap(v[i - 1] , v[i]);
				++ans;
			}else{
				swap(v[0] , v[1]);
				++ans;
			}
		}	
		
	}
	
	
	
	cout << ans;
	
	
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		//データ読み込み
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
		}
		
		int s = 1;
		int counter = 0;
		
		while (true){
			if (s == n){
				System.out.print(a[0]);
				
				for(int i = 1; i < n; i++){
					System.out.print(" " + a[i]);
				}
				System.out.print("\n");
				System.out.println(counter);
				break;
			}
			
			for(int i = n - 1; i >= s; i--){
				//左の要素の方が大きかった時には、swap
				if(a[i - 1] > a[i]){
					int temp = a[i - 1];
					a[i - 1] = a[i];
					a[i] = temp;
					counter++;
				}	
			}
			s++;
		}
	}
}


Measured memory_bytes: 26364
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <sstream>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using iii = pair<int, ii>;

using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvvi = vector<vi>;

bool res() {
	string s;
	cin >> s;
	if (!cin) return false;

	vi r, l;
	
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'R') r.push_back(i);
		else l.push_back(i);
	}

	int pr = 0, pl = 0;
	vi sol(s.size(), 0);
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'R') {
			int pprin = l[pl];
			if ((pprin - i) % 2 == 0) {
				++sol[l[pl] ];
			}
			else {
				++sol[l[pl]- 1];
			}


			if(i != 0) ++pr;
		}

		else {
			int pprin = r[pr];
			if ((i - pprin) % 2 == 0) {
				++sol[r[pr]];
			}
			else {
				++sol[r[pr]+ 1];
			}

			++pl;
		}
	}


	for (int i = 0; i < sol.size(); ++i) {
		cout << sol[i];
		if (i == sol.size() - 1) cout << '\n';
		else cout << ' ';
	}

	return true;
}

int main() {
	while (res()) {}
	return 0;
}

Measured memory_bytes: 1532
def solve(N):
    d = 10 ** 7
    index = d // 2
    while True:
        k1 = index * (index - 1) // 2
        k2 = index * (index + 1) // 2
        if k1 < N <= k2:
            break
        elif k1 <= N:
            index = (index + d) // 2
        else:
            d = index
            index = index // 2

    d = k2 - N
    return "\n".join([str(i) for i in range(1, index + 1) if i != d])


if __name__ == "__main__":
    N = int(input())
    print(solve(N))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    string s; cin >> s;
    if(s[s.size() - 1] == 's')
        cout << s  << "es";
    else
        cout << s << 's';
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
using namespace std;
int main() {
  int A, B, C; cin >> A >> B >> C;
  cout << max(C - (A - B), 0) << endl;
}


Measured memory_bytes: 256
n, m, q = [int(e) for e in input().split()]

abcd=list()
for i in range(q):
    abcd.append([int(e) for e in input().split()])

a=[]
b=[]
def combi(n,m,r=1): #nはN数、mは最大数,rは際少数
    if len(a) == n:
        b.append([0 for _ in range(n)])
        for i,v in enumerate(a):
            b[-1][i] += v
    else:
        for i in range(r,m+1):
            a.append(i)
            combi(n,m,i)
            a.pop()
    return(b)



all = combi(n,m)

count=list()
num=0
for i in all:
    for j in abcd:
        if i[j[1]-1]-i[j[0]-1] == j[2]:
            num += j[3]
        else:
            pass
    count.append(num)
    num=0

print(max(count))

Measured memory_bytes: 31016
/**
 * C - Snuke Festival
 * https://atcoder.jp/contests/abc077/tasks/arc084_a
 **/
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long

int n;

int main() {
    cin >> n;
    vector<ll> a(n, 0), b(n, 0), c(n, 0);
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) cin >> b[i];
    for(int i=0; i<n; i++) cin >> c[i];
    // ソートする
    sort(a.begin(), a.end());
    // sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll ans = 0;
    for (int j=0; j<n; j++) {
        ll bj = b[j];
        // Ai < Bj 満たす最大の i を求める
        decltype(a)::iterator it = lower_bound(a.begin(), a.end(), bj);
        ll i = distance(a.begin(), it);
        // Bj < Ck を満たす最小のkを求める
        decltype(c)::iterator it2 = upper_bound(c.begin(), c.end(), bj);
        ll k = distance(it2, c.end());
        ans += i*k;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>

int main() {
    int a, b, c;
    
    scanf("%d%d%d", &a, &b, &c);
    
    int iguais = (a == b && a == c);
    
    int diferentes = (a != b);
    diferentes = diferentes && (a != c);
    diferentes = diferentes && (b != c);
    
    if (!(iguais || diferentes)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    
    return 0;
}









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

int gcd(long long x, long long y){
    while(x*y > 0){
        if(x >= y){
            x %= y;
        }
        else{
            y %= x;
        }
    }
    return x + y;
}

int main(){
    int N;
    long long A[100010];
    cin >> N;

    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    long long L[100010];
    L[0] = 0;
    for(int i = 0; i <= N-2; i++){
        L[i+1] = gcd(L[i], A[i]);
    }

    long long R[100010];
    R[0] = 0;
    for(int i = 0; i <= N-2; i++){
        R[i+1] = gcd(R[i], A[N-i-1]);
    }

    long long GCD[100010];
    for(int i = 0; i < N; i++){
        GCD[i] = gcd(L[i], R[N-i-1]);
    }

    sort(GCD, GCD+N, greater<int>());

    cout << GCD[0] << endl;
    
}

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


using namespace std;

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

	char c = s.at(K - 1);

	for (int i = 0; i < n; i++) {
		if (c == s.at(i)) {
			continue;
		}
		else {
			s.at(i) = '*';
		}
	}

	cout << s << endl;
}

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

bool check(int A,int B,int x){
  bool ch=false;
  for(int a=0;A*a<=x;++a){
    if((x-A*a)%B==0) ch=true;
  }
  return ch;
}


int main(){
  int A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;
  double m=0.0000000;
  int sw=100*A;
  int s=0;

  for(int x=1;x<=F/100;++x){
    for(int y=0;y<=F;++y){
      if(100*x+y<=F && y<=E*x){
        //Aa+Bb=xかつCc+Dd=yなる(a,b,c,d)があるか判定する、けっこうかかりそう
        if(check(A,B,x) && check(C,D,y)){
          double r=(double)100*y/(100*x+y);
          if(r>m){
            m=r;
            sw=100*x+y;
            s=y;
          }
        }
      }
    }
  }

  cout<<sw<<" "<<s<<endl;

}

Measured memory_bytes: 256
k = gets.to_i

q = (1..9).to_a.reverse

x = 0

1.upto(k) do
  x = q.pop

  if x % 10 != 0
    q.unshift(10 * x + (x % 10) - 1)
  end
  
  q.unshift(10 * x + (x % 10))
  
  if x % 10 != 9
    q.unshift(10 * x + (x % 10) + 1)
  end
end
  
p x

Measured memory_bytes: 3452
#include<cstdio>
#include<cstring>
using namespace std;
long long l,ans,sum[200001]['z'+1];
char s[200001];
int main()
{
	scanf("%s",s);
	l=strlen(s);
	for (int i=l-1;i;i--)
		for (char j='a';j<='z';j++)sum[i][j]=sum[i+1][j]+(s[i]==j);
	for (int i=0;i<l;i++)ans+=l-1-i-sum[i+1][s[i]];
	printf("%lld\n",++ans);
}

Measured memory_bytes: 192512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    ll N, D, A;
    cin >> N >> D >> A;
    map<ll, ll> mp;
    rep(i, N){
        ll X, H;
        cin >> X >> H;
        if(H%A == 0) H /= A;
        else H = H/A + 1;
        mp[X] = H;
    }
    ll ans = 0;
    ll S = 0;
    vector<ll> sum;
    sum.pb(S);
    priority_queue<pll, vector<pll>, greater<pll> > que;
    ll now = 0;
    ll num, pos = 0;
        for(auto &e: mp){
            while(!que.empty() && e.first > que.top().first){
                que.pop();
            }
            if(que.empty()){
                S += e.second;
                sum.pb(S);
                now++;
                que.push(pll(e.first+2*D, now));
            }
            else{
                e.second -= (sum[now]-sum[que.top().second-1]);
                if(e.second > 0){
                    S += e.second;
                    sum.pb(S);
                    now++;
                    que.push(pll(e.first+2*D, now));
                }
            }
        }
    cout << S << endl;
}

Measured memory_bytes: 15384
#include<iostream>
#include<cmath>
using namespace std;
int main(void)
{
  int n, b, r, t;
  double y;

  while(cin >> n, n){
    cin >> y;
    int ans;
    double max = -99.0;
    for(int i = 0;i < n; i++){
      cin >> b >> r >> t;
      double m = 100.0;
      double a;
      if(t == 1)
	a = m * (1.0 + (y * (r / 100.0)));
      else
	a = m * pow(1.0 + (r / 100.0), y);
      if(max < a){
	max = a; ans = b;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 1320
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

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

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	h, a := r.nextInt(), r.nextInt()

	fmt.Fprintln(stdout, h/a+b2i(h%a > 0))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 string S;
  cin>>S;
  for(ll i=0;i<3;i++) {
    if(S[i]==S[i+1]) {
      cout<<"Bad"<<endl;
      return 0;
    }
  }
  
  cout<<"Good"<<endl;
}
  



Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <ctype.h>
#include <stdlib.h>
#include <vector>
#include <math.h>
using namespace std;
int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 int a,b,c,n7=0,n5=0;
 cin>>a>>b>>c;
 if(a==5){
    n5++;
 }
 else{
    n7++;
 }
if(b==5){
    n5++;
 }
 else{
    n7++;
 }

 if(c==5){
    n5++;
 }
 else{
    n7++;
 }
if(n5==2&&n7==1){
    cout<<"YES";
}
else{
    cout<<"NO";
}
}




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

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}

int main(void){
	int a=in(),b=in(),c=in();
	puts(a<=c&&c<=b?"Yes":"No");
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

ll sq(ll x){
	return x*x;
}

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

bool isvowel(char c){
	int i;
	string v="aeiou";
	for(i = (v.size()-1); i>=0; --i){
		if(c == v[i]){
			return true;
		}
	}
	return false;
}

int main(void){
	int n,a[123456],v,i;
	ll ans=1ll;
	cin >> n;
	for(i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	if(n%2){
		if(a[0] != 0){
			ans = 0ll;
		}
		i = 1;
		v = 2;
	}else{
		i = 0;
		v = 1;
	}
	for(i=i; i<n; i+=2){
		if(a[i] != v || a[i+1] != v){
			ans = 0ll;
			break;
		}else{
			mul_mod(ans,2ll);
		}
		v += 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))


def binary_search(A, key):
    left = 0
    right = n
    while left < right:
        mid = int((left + right)/2)
        if A[mid] == key:
            return True
        elif key < A[mid]:
            right = mid
        else:
            left = mid + 1
    return False

cnt = 0
for i in T:
    if binary_search(S, i):
        cnt += 1

print(cnt)

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

using namespace std;
typedef long long ll;

int N, K;
ll A[200000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = K; i < N; i++){
        if(A[i-K] < A[i]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 5212
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include <math.h>

int sosu(int x){
	if(x==2)return 1;
	else if(x<2 || x%2==0)return 0;
	int i=3;
	while(i<=sqrt(x)){
		if(x%i==0)return 0;
		i+=2;
	}
	return 1;
}

int main(void){
	int a,b,n,i,j,k,x,y,r;
	scanf("%d%*c",&n );
	for(i=0,x=0;i<n;i++){
		scanf("%d",&a );
		x+=sosu(a);
	}

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

Measured memory_bytes: 596
#include<bits/stdc++.h>
#include<atcoder/dsu>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;

int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, m, u, v;
    cin >> n >> m;
    atcoder::dsu dsu(n);
    for(int i = 0; i < m; i++) {
        cin >> u >> v;
        dsu.merge(u-1, v-1);
    }
    
    cout << dsu.groups().size()-1 << endl;
    return 0;
}


Measured memory_bytes: 8912
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>
#include <iostream>

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

using namespace std;

int main() {
    string s;
    cin >> s;
    s = "ABC" + s;
    printf("%s\n", s.c_str());
    return 0;
}

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

int main()
{
    int n,i,x=1,c=0,ans=0;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
     for(i=0;i<n;i++)
    {
        if(a[i]==x)
        {
            x++;
        }
        else
            c++;
    }
    if(c==n)
        c=-1;
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 1024
from fractions import Fraction

n, m = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)

total = sum(A)
flg = total * Fraction(1, (4 * m))
ans = 'No'

for i in range(m):
    if A[i] < flg:
        ans = 'No'
        break
    else:
        ans = 'Yes'

print(ans)


Measured memory_bytes: 64364
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	var x = make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&x[i])
	}

	if n >= m {
		fmt.Println(0)
		return
	}

	sort.Ints(x)
	var y = make([]int, m)
	for i, v := range x[1:] {
		if a := v - x[i]; a >= 0 {
			y[i] = a
		} else {
			y[i] = -a
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(y)))
	var sum int
	for _, i := range y[0 : n-1] {
		sum += i
	}
	fmt.Println(x[m-1] - x[0] - sum)
}


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

int main()
{
    long long a,b,c,d,e,temp;
    cin>>a>>b>>c>>d>>e;
    temp=min(a*8,min(b*4,min(c*2,d)));
    if(e%2==0)
    {
        cout<<temp*(e/2);
    }
    else
    {
        //cout<<temp<<" ";
        e/=2;
        temp=temp*e;
        temp=temp+min(a*4,min(b*2,c));
        cout<<temp;
    }

    return 0;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
const ll INF = 1LL<<55;

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n;
	cin >>n;

	ll ans = 1LL<<50;
	for(ll i=1; i*i <=n; i++){
		if(n%i==0){
			ans = min(ans, i-1 + n/i -1);
		}
	}
	cout <<ans <<"\n";
	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);
		// 整数の入力
		String S = sc.nextLine();
		char s1 = S.charAt(0);
		S = S.replaceAll(s1+"","");
		if(S.length()!=2) {
			System.out.println("No");
			return;
		}
		if(S.charAt(0)==S.charAt(1)) {
			System.out.println("Yes");

		}else {

			System.out.println("No");
		}


	}
}

Measured memory_bytes: 23124
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 130000;
char cn[CM + 10], * ci = cn + 10, ct, c, * owa = cn + CM;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	swap(c, ci[8]);
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	swap(c, ci[8]);
	ci += (64 - dig >> 3) + 1;

	if (ci - owa > 0) {
		memcpy(cn, owa, 10);
		ci -= CM;
		fread(cn + 10, 1, CM, stdin);
	}
	return tmp;
}
//inline int getint() {
//	int A = 0;
//	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
//	
//	if (ci - owa > 0) {
//		memcpy(cn, owa, 20);
//		ci -= 119980;
//		fread(cn + 20, 1, 119980, stdin);
//	}
//
//	return A;
//}

char* di = cn;
const int MAX = 200000;
class shuturyoku_unko {
public:
	char C[MAX * 6 + 10];
	int K[MAX + 10];
	constexpr shuturyoku_unko() : C(), K() {
		auto di = C + 1;
		C[0] = '0';
		K[1] = 1;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
			K[i + 1] = K[i] + keta;
		}
	}
} f;
inline void putint(ll X) {
	int ue = X / 100000;
	if (ue) {
		for (int i = f.K[ue]; i < f.K[ue + 1]; i++)* di++ = f.C[i];
		int sita = X - ue * 100000ll;
		rep(i, 5 - f.K[sita + 1] + f.K[sita])* di++ = '0';
		for (int i = f.K[sita]; i < f.K[sita + 1]; i++)* di++ = f.C[i];
	}
	else for (int i = f.K[X]; i < f.K[X + 1]; i++)* di++ = f.C[i];
	*di++ = '\n';
}

int B[200010];

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


	fread(ci, 1, CM, stdin);

	int N = getint();
	ll kotae = 0;
	int A[200000];
	rep(i, N) kotae += B[(A[i] = N - getint())]++;
	int i = 0;
	
	int amari = N % 10800;
	int shou = N / 10800;
	rep(j, shou) {
		rep(k, 10800) putint(kotae - B[A[i++]] + 1);
		fwrite(cn, 1, di - cn, stdout);
		di = cn;
	}
	rep(k, amari) putint(kotae - B[A[i++]] + 1);
	fwrite(cn, 1, di - cn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 3712
l=[int(x) for x in input().split()]
N=l[0]
K=l[1]
ans = []

while True:
  ans.append(int(N) % int(K))
  N = int(N) / int(K)
  if int(N) == 0:
    break
  elif N < K:
    ans.append(int(N))
    break
    
print(len(ans))

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <tuple>
#include <complex>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define previous fake_previous
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL MAXN = 41;
const LL MAXK = 20;

void bad()
{
	cout << "Impossible";
	exit(0);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	LL n, l;
	cin >> n >> l;
	VLL a(n);
	FOR(i, 0, n)
		cin >> a[i];

	LL ma = 0;
	FOR(i, 0, n - 1)
		ma = max(ma, a[i] + a[i + 1]);

	if (ma < l)
		bad();

	cout << "Possible" << endl;
	VI ans(n - 1);
	int ind = -1;
	FOR(i, 0, n - 1)
		if (ma == a[i] + a[i + 1])
			ind = i;

	FOR(i, 0, ind)
		cout << i + 1 << endl;

	RFOR(i, n - 1, ind + 1)
		cout << i + 1 << endl;

	cout << ind + 1 << endl;
//	cin >> n;
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int A, P; cin >> A >> P;
    cout << (A*3 + P)/2 << endl;
}

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

MOD = 10**9+7

fac = [1,1] + [0]*N
finv = [1,1] + [0]*N
inv = [0,1] + [0]*N
for i in range(2,N+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

cums = [fac[N]]
for n in range(2,N+1):
    a = (fac[N] * inv[n]) % MOD
    cums.append((cums[-1] + a) % MOD)

ans = 0
for i,a in enumerate(A):
    l,r = i,N-i-1
    tmp = cums[l] + cums[r] - cums[0]
    tmp *= a
    ans += tmp
    ans %= MOD
print(ans)

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

int main() {
  long long N, cnt = 0;
  cin >> N;
  vector<string> vec(N);

  for (int i = 0; i < N; i++) {
    string tmpstr;
    vector<string> tmpvec(10);
    cin >> tmpstr;
    for (int j = 0; j < 10; j++) {
      tmpvec.at(j)= tmpstr.at(j);
    }
    sort(tmpvec.begin(), tmpvec.end());
    vec.at(i) = tmpvec.at(0);
    for (int j = 1; j < 10; j++) {
      vec.at(i) += tmpvec.at(j);
    }    
  }
  
  sort(vec.begin(), vec.end());
  long long tmpcnt = 0;

  for (int i = 0; i < N - 1; i++) {
    if (vec.at(i) == vec.at(i+1)) {
      tmpcnt++;
      cnt++;
      if (tmpcnt == N - 1)
        cnt += tmpcnt * (tmpcnt - 1) / 2;
    }
    else {
      if (tmpcnt > 0)
        cnt += tmpcnt * (tmpcnt - 1) / 2;
      tmpcnt = 0;
    }
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 7296
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long llong;
int main(){
    int n;
    string s1;
    string s2;

    cin >> n;
    cin >> s1 >> s2;

    string ans;
    
    for (int i = 0; i < n; i++){
        ans += s1[i];
        ans += s2[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input()) #number of elements
seq = list(map(int,input().split()))
print(' '.join([str(i) for i in seq]))
for i in range(1,N):
    key = seq[i]
    j = i-1
    while j>=0 and seq[j]>key:
        seq[j+1] = seq[j]
        j -= 1
    seq[j+1] = key
    print(' '.join([str(k) for k in seq]))



Measured memory_bytes: 5612
N,K = map(int,input().split())

if(N == 0):
  print(N)
elif(K == 1):
  print(0)
else:
  mod = N % K
  if(N<=K):
    if(K-mod < mod):
      print(K-mod)
    else:
      print(mod)
  else:
    print(K-mod)

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

int main(){
    int N;
    cin >> N;
    vector<int>B(N-1);
    rep(i, N-1) cin >> B[i];
    ll ans = B[0];
    rep(i, N-2){
        if(B[i]>B[i+1]){
            ans+=B[i+1];
        }
        else ans+=B[i];
    }
    cout << ans+B[N-2] << endl;
    return 0;
}


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

typedef long long ll;
const int maxn = 200010;
int n;
ll X, a[maxn], s[maxn];

int main() {
    scanf("%d %lld", &n, &X);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]), s[i] = s[i - 1] + a[i];
    }
    ll ans = LLONG_MAX;
    for (int i = 1; i <= n; i++) {
        ll sum = 0;
        for (int j = n, cur = 1; j >= 1; cur++) {
            int k = max(j - i, 0);
            sum += (s[j] - s[k]) * max(5, cur * 2 + 1);
            if (sum > ans) break;
            j = k;
        }
        ans = min(ans, sum + i * X);
    }
    printf("%lld\n", ans + n * X);
    return 0;
}

Measured memory_bytes: 3328
n = int(input())
ss = []
t = ['AC', 'WA', 'TLE', 'RE']
ans = [0, 0, 0, 0]
for i in range(n):
    ss.append(input())

for s in ss:
    if s == t[0]:
        ans[0] += 1
    elif s == t[1]:
        ans[1] += 1
    elif s == t[2]:
        ans[2] += 1
    elif s == t[3]:
        ans[3] += 1


for j, c in zip(t, ans):
    print(j, " x ", c)


Measured memory_bytes: 16316
#include <bits/stdc++.h>
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 all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ":" << x << "\n"
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;

int cost(vi &h, int x, int y) { // 足場xから足場yに行く場合
	return abs(h[x] - h[y]);		
}

int main () {
	const int INF = pow(10, 9);
	int N, K; cin >> N >> K;
	vi h(N); rep(i, N) cin >> h[i];
	vi dp(N, INF); dp[0] = 0; // 足場i(0-ind)までたどり着くための最小コスト	
	rep2(i, 1, N) rep2(j, i - K, i) { // 足場 i-K ~ i-1 のそれぞれから 足場 i に行った時の合計コストのminを採用
			j = max(j, 0);
			dp[i] = min(dp[i], dp[j] + cost(h, j, i));
		}	
	cout << dp[N - 1] << endl;
}

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

int main()
{
  string str, tmp;
  int n, ct = 0;
  cin >> str >> n;
  int m = str.size();
  for (int i = 0; i < n; i++){
    int judge = 0;
    cin >> tmp;
    tmp += tmp;
    for (int j = 0; j < 20; j++){
      if (tmp[j] == str[0]){
        judge++;
        for (int k = 1; k < m; k++){
          if (k + j >= 20 || tmp[k + j] != str[k]){
            judge--;
            break;
          }
        }
      }
    }
    if (judge > 0){
      ct++;
    }
  }
  cout << ct << endl;
}

Measured memory_bytes: 3112
# input
N, A, B = map(int, input().split())

# process
ans = 0
if A%2 == B%2:
    ans = (B-A)//2
else:
    if A-1 < N-B:
        ans = A+(B-A-1)//2
    else:
        ans = N-B+1+(B-A-1)//2

# output
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <array>
int main() {

	int array_value;	
	std::cin >> array_value;
	
	std::array<int, 256> array;
	for(int i = 0; i < array_value; i++) {
		std::cin >> array[i];
	}

	int operation_count = 0;
	while(1) {
	
		for(int ai = 0; ai < array_value; ai++) {
			if((array[ai] % 2) == 0 ){
				array[ai] = array[ai] / 2;
			} else {
				std::cout <<  operation_count << std::endl;
				return 0;
			}
		}
		operation_count++;
	}

	return 0;

}

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

#define ll long long int
#define fir first
#define sec second
#define endl '\n'
ll const mod = 1e9 + 7;

ll power(ll x, ll y, ll p) { 
    ll res = 1;    x = x % p;  
    while(y > 0) {
        if(y & 1) res = (res*x) % p; 
        y = y>>1;    x = (x*x) % p; 
    } return res; 
}

ll MIN(ll a, ll b) {
    if(a<b) return a;   return b;
}

ll MAX(ll a, ll b) {
    if(a>b) return a;   return b;
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n;
    cin>>n;
    
    ll x=100;
    int ans=0;
    while(x<n)
    {
        x+=(x/100);
        ans++;
    }
    cout<<ans;
    
	// your code goes here
	return 0;
}


Measured memory_bytes: 3652
let g p =
  match p with
  | 1 -> 300000
  | 2 -> 200000
  | 3 -> 100000
  | _ -> 0
let money = Scanf.sscanf (read_line ()) "%d %d" (fun a b ->
  match (g a) + (g b) with
  | 600000 -> print_endline "1000000"
  | x -> Printf.printf "%d\n" x
)

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

             佛祖保佑       永无BUG

   本程序已经经过开光处理，绝无可能再产生bug
 **********************************************/
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define db1(x) cout<<#x<<"="<<(x)<<endl
#define db2(x,y) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<endl
#define db3(x,y,z) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<", "<<#z<<"="<<(z)<<endl

bool num[3000010]={1,1};
ll prime[3000100];

ll gcd(ll a,ll b)
{
    if(b==0)return a;
    else return gcd(b,a%b);
}

ll getprime()
{
    for(int i=2;i*i<=3000000;i++)
        if(!num[i])
            for(int j=i;j*i<=3000000;j++)
                num[i*j]=true;

    int k=0;
    for(int i=2;i<=3000000;i++)
    {
        if(!num[i])prime[k++]=i;
    }

    return k;
}

int main(void)
{
    #ifdef DanDan
    freopen("in.txt","r",stdin);
    //freopen("in.txt","w",stdout);
    clock_t start=clock();
    #endif //test

    ll a,b,g=0,k=getprime(),sum=1;
    scanf("%lld%lld",&a,&b);
    g=gcd(a,b);

    for(int i=0;i<k;i++)
    {
        if(g%prime[i]==0)
        {
            sum++;
            while(g%prime[i]==0)g/=prime[i];
        }
    }
    if(g!=1)sum++;
    printf("%lld\n",sum);


    #ifdef test
    clockid_t end=clock();
    double endtime=(double)(end-start)/CLOCKS_PER_SEC;
    printf("\n\n");
    cout<<"Total time:"<<endtime<<"s"<<endl;        //s为单位
    cout<<"Total time:"<<endtime*1000<<"ms"<<endl;    //ms为单位
    #endif //test
    return 0;
}


// ━━━━━━神兽出没━━━━━━
//      ┏┓       ┏┓
//     ┏┛┻━━━━━━━┛┻┓
//     ┃           ┃
//     ┃     ━     ┃
//     ????━????   ┃
//     ┃           ┃
//     ┃    ┻      ┃
//     ┃           ┃
//     ┗━┓       ┏━┛
//       ┃       ┃
//       ┃       ┃
//       ┃       ┗━━━┓
//       ┃           ┣┓
//       ┃           ┏┛
//       ┗┓┓┏━━━━━┳┓┏┛
//        ┃┫┫     ┃┫┫
//        ┗┻┛     ┗┻┛
//
// ━━━━━━感觉萌萌哒━━━━━━


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

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

  int n;
  cin >> n;

  vector<int> h(n);
  for (int i = 0; i < n; ++i) cin >> h[i];

  int now = h[0], ans = 0, stroke = 0;
  for (int i = 1; i < n; ++i) {
    if (now >= h[i]) ++stroke;
    else {
      ans = max(ans, stroke);
      stroke = 0;
    }

    now = h[i];
  }

  cout << max(ans, stroke) << endl;

  return (0);
}


Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    vector<double> A(N);
    for(int i = 0;i < N;i++){
        cin>>A[i];
    }
    vector<vector<double>> dp(N+1,vector<double>(N+1,0.0));
    dp[0][0] = 1.0;
    for(int i = 1;i <= N;i++){
        dp[i][0] = dp[i-1][0] * (1.0-A[i-1]);
        for(int j = 1;j <= N;j++){
            dp[i][j] = dp[i-1][j-1] * A[i-1] + dp[i-1][j] * (1.0-A[i-1]);
        }
    }
    double result = 0.0;
    for(int j = N/2+1;j <= N;j++){
        result += dp[N][j];
    }
    // for(int i = 0;i <= N;i++){
    //     for(int j = 0;j <= N;j++){
    //         cout<<dp[i][j]<<" ";
    //     }cout<<endl;
    // }
    cout<<fixed<<setprecision(12)<<result<<endl;
}

Measured memory_bytes: 70784