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

using namespace std;

int main() {
  static std::bitset<1000000000> bits{};
  int n;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    std::cin >> a;
    a--;
    bits[a] = bits[a] ^ 1;
  }
  std::cout << bits.count() << std::endl;
  return 0;
}


Measured memory_bytes: 122112
# p = list(map(int, input().split()))
# a, b, c = map(int, input().split())
# n = int(input())
# s = input()
# print(i, end=" ")
s = input()
t = input()
ans = len(t)

for i in range(len(s) - len(t) + 1):
    dif = 0
    for j in range(len(t)):
        if t[j] != s[i + j]:
            dif = dif + 1

    ans = min(ans, dif)
print(ans)


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

int f(int n) {
  int cnt = 0;
  for (int i = 1; i < sqrt(n); i++) {
    if (n % i == 0) {
      cnt++;
    }
  }
  return cnt * 2;
}

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    if (f(i) == 8) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3688
package main

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

var sc = bufio.NewScanner(os.Stdin)

const initBufSize, maxBufSize = 10000, 1000000

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInts(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = nextInt()
	}
	return res
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func pow(r, n int) int {
	return int(math.Pow(float64(r), float64(n)))
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initBufSize), maxBufSize)
	k := nextInt()
	a := nextInt()
	b := nextInt()
	for i := a; i <= b; i++ {
		if i%k == 0 {
			fmt.Println("OK")
			return
		}
	}
	fmt.Println("NG")
}


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

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n, -1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        uf.unite(a,b);
    }

    int ans = 0;
    rep(i,n) ans = max(ans, uf.size(i));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3996
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=1;i<=(n);++i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

class EGolf {
public:
	void solve(std::istream& in, std::ostream& out) {
	    lint X, Y, K, D;
	    in>>K>>X>>Y;
	    if(K%2==0 and (X+Y)%2) {out<<-1<<endl; return;}

	    bool swapped = false, x_rev = false, y_rev = false;
	    if(abs(X)<abs(Y)) swap(X, Y), swapped = true;
	    if(X<0) X *= -1, x_rev = true;
	    if(Y<0) Y *= -1, y_rev = true;

	    D = X + Y;
	    lint n = (D+K-1) / K;
	    if(X+Y<K) ++n;
	    if((n*K-D)%2) ++n;

	    vector<pll> ans;
	    if((D+K-1)/ K==1 and n==3){
	        lint a = (3*K-D) / 4, b = (3*K-D+3) / 4;
	        ans.eb(pll(-b, K-b)), ans.eb(pll(X-K+a, Y+a));
	    } else if(n>1) {
	        lint a = (n*K-D) / 2, x = 0, y = 0;
	        while(y+K<=a+Y) y += K, ans.eb(pll(0, y));
	        if((a+Y)%K) x += K - (a+Y) % K, ans.eb(pll(x, a+Y));
	        while(x+K<X) x += K, ans.eb(pll(x, a+Y));
	    }
	    ans.eb(pll(X, Y));

	    out<<n<<'\n';
	    for(auto p : ans){
	        if(x_rev) p.first *= -1;
	        if(y_rev) p.second *= -1;
	        if(swapped) swap(p.first, p.second);
	        out<<p.first<<' '<<p.second<<'\n';
	    }
	}
};


int main() {
	EGolf solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 6384
N = input()
if int(N[-1]) == 2 or int(N[-1]) == 4 or \
        int(N[-1]) == 5 or int(N[-1]) == 7 or \
        int(N[-1]) == 9:
    print('hon')
elif int(N[-1]) == 0 or int(N[-1]) == 1 or \
        int(N[-1]) == 6 or int(N[-1]) == 8:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9152
n = int(input())

ans = float("inf")

for i in range(n+1):
    kari = 0

    a = i
    while a >= 6:
        kari += a % 6
        a //= 6
    kari += a

    b = n - i
    while b >= 9:
        kari += b % 9
        b //= 9
    kari += b

    ans = min(ans, kari)

print(ans)

Measured memory_bytes: 3060
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: 21716
#include <bits/stdc++.h>
using namespace std;

int main() {
  string S;
  cin >> S;
  
  int A;
  A = S.size() - 1;
  
  if (S[A] != 's') {
    S.push_back('s');
    cout << S << endl;
  }else{
    S.push_back('e');
    S.push_back('s');
    cout << S << endl;
  }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
  long h,w,ans(0);
  cin >> h >> w;
  if((h*w)%2 == 1)ans++;
  ans += (h*w)/2;
  if(h == 1 || w == 1)ans = 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
typedef long long ll;

unsigned gcd(int a, int b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

int main(){

	//int N, M, *A, *B, i, j, *W, *flag, sum=0, start, end, length, tmp;
	int i, j, k, l, m, n, len, a, b, c;
	int *A, *B, C, N, M, K,num_R,num_G,num_B;
	ll sum_A = 0, sum_B = 0, sum_C = 0;
	ll **dp;
	double ans;

	scanf("%d", &N);



	
	A= (int *)malloc((N+1) * sizeof(int));

	B = (int *)malloc((N+1) * sizeof(int));

	A[0] = B[0] = 0;
	A[1] = B[1] = 0;
	for (i = 2; i <= N; i++){
		scanf("%d", &A[i]);
		B[i] = 0;
	}
	
	for (i = 1; i <= N; i++){
		B[A[i]]++;
	}
	for (i = 1; i <= N; i++){
		printf("%d\n", B[i]);
	}

	return 0;

}
    


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int width = tx - sx, height = ty - sy;
    string ans = "";

    // Path 1
    ans += string(width, 'R') + string(height, 'U');

    // Path 2
    ans += string(width, 'L') + string(height, 'D');

    // Path 3
    ans += "D" + string(width+1, 'R') + string(height+1, 'U') + "L";

    // Path 4
    ans += "U" + string(width+1, 'L') + string(height+1, 'D') + 'R';

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<(int)(n);i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int solve(int n, int k){
    if(n==1) return 0;
    return (solve(n-1,k)+k)%n;
}

int main(){
    int n,m;
    while(cin>>n>>m){
        if(n==0) break;
        vi a(n),b;
        rep(i,n){
            cin>>a[i];            
        }
        b.resize((*max_element(all(a))+m)/m,0);
        rep(i,n){
            b[a[i]/m]++;
        }

        double ans=0.01;
        rep(i,b.size()){
            ans+=1.0*(b.size()-1-i)/(b.size()-1)*b[i]/(*max_element(all(b)));
        }
        cout<<fixed<<setprecision(7)<<ans<<endl;
    }
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
using namespace std;
 
int main(){
    int W,H,N;
    cin>>W>>H>>N;
    int x[N],y[N],a[N];
    for(int i=0;i<N;++i)cin>>x[i]>>y[i]>>a[i];

    int xMax=0,yMax=0,xMin=W,yMin=H;
    for(int i=0;i<N;++i){
        if(a[i]==1){
            if(xMax<x[i])xMax=x[i];
        }
        else if(a[i]==2){
            if(xMin>x[i])xMin=x[i];
        }
        else if(a[i]==3){
            if(yMax<y[i])yMax=y[i];
        }
        else if(a[i]==4){
            if(yMin>y[i])yMin=y[i];
        }
    }
	int ans=(xMin-xMax)*(yMin-yMax);
  	if(xMin<xMax||yMin<yMax)cout<<0<<endl;
  	else cout<<ans<<endl;

    
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	if a <= b {
		fmt.Println(strings.Repeat(strconv.Itoa(a), b))
	} else {
		fmt.Println(strings.Repeat(strconv.Itoa(b), a))
	}
}


Measured memory_bytes: 640
#include <algorithm>
#include<bits/stdc++.h>
#include <ios>
#include <iterator>
using namespace std;
#define ll      long long
#define f(n)    for(int i=0;i<n;i++) 
#define pb      push_back
#define mp      make_pair
#define vi      vector<ll int>
#define w(t)    while(t--)
#define all(v)  v.begin(),v.end() 
#define take(n) int n;cin>>n;
void speed (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int main(){
    speed();
  int n;
    cin>>n;
    int n1=n/100;
    int n2=n%100;
    if((n1==0||n1>12)&&n2<=12&&n2!=0){
        cout<<"YYMM";
    }
    else if(n1<=12&&n1!=0&&(n2>12||n2==0)){
        cout<<"MMYY";
    }
    else if((n1 == 0 || n1 > 12) && (n2 == 0 || n2 > 12)){
        cout<<"NA";
    }
    else{
        cout<<"AMBIGUOUS";
    }
    return 0;
}















Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000000
ll gcd(ll a,ll b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    ll s=1;
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==s)
        {
            ans++;
            s++;
        }
    }
    if(ans==0)
        cout<<-1;
    else cout<<n-ans;
return 0;
}


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

#define ll long long
#define f(i,start,end,inc) for(int i = start;i<end;i+=inc)
#define fl(i,start,end,inc) for(ll i = start;i<end;i+=inc)
#define vi vector<int>
#define vl vector<ll>
#define vs vector<string>
#define umap unordered_map
#define uset unordered_set
#define vpii vector<pair<int,int> >
#define vpll vector<pair<ll,ll> >
#define vpis vector<pair<int,string> >
#define vpls vector<pair<ll,string> >
#define w(t) int t;cin >> t;while(t--)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pis pair<int,string>
#define pls pair<ll,string>
#define F first
#define S second
#define inp(c) int c;cin >> c
#define inpl(c) ll c;cin >> c



using namespace std;

vector<int> g[100001];
int dp[100001];

int solve(int src){
	if(dp[src]!=-1){
		return dp[src];
	}
	bool leaf = 1;
	int bchild = 0;
	for(int c : g[src]){
		leaf = 0;
		bchild = max(bchild,solve(c));
	}

	return dp[src] = leaf ? 0 : 1 + bchild;
}

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

//   #ifndef ONLINE_JUDGE
//   freopen("input.txt","r",stdin);
//   freopen("output.txt","w",stdout);
//   #endif
  int n,m;
  cin >> n >> m;
  memset(dp,-1,sizeof(dp));
  f(i,0,m,1){
  	int u,v;
  	cin >> u >> v;
  	g[u].pb(v);
  }
  int ans = 0;
  f(i,1,n+1,1){
  	ans = max(ans,solve(i));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 8192
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int n, k;
        cin >> n >> k;

        if (k == 1) {
            cout << 0 << endl;
        } else {
            cout << n - k << endl;
        }
    }
};


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

    Solve().solve();


    return 0;
}


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

int main(int argc, const char * argv[]) {
    uint64_t N;
    cin >> N;
    
    uint64_t sum = 0;
    for (uint64_t i = 1; i <= N; i++) {
        if ((i % 15 != 0) &&
            (i % 5 != 0) &&
            (i % 3 != 0)) {
            sum += i;
        }
    }

    std::cout << sum;
    
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int maxn = 100100;
const long long oo = 1e18;
struct node
{
	long long b, l, u, v;
	bool operator<(const node &a) const
	{
		return v < a.v;
	}
}s[maxn];
int n, a;
long long mn = oo, ans = oo;
long long X, sum1 = 0;
void work(int x)
{
	if(s[x].u > mn)
	{
		long long sum2 = sum1 + s[a].v - s[x].v - s[a].l * s[a].b + s[a].u * s[a].b;
		long long c = (sum2 + s[a].u - 1) / s[a].u;
		if(c <= X)
			ans = min(ans, c);
	}
	else
	{
		long long sum2 = sum1 - s[x].l * s[x].b + s[x].u * s[x].b;
		long long c = (sum2 + s[x].u - 1) / s[x].u;
		if(c <= X)
			ans = min(ans, c);
	}
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> X;
	for(int i = 1; i <= n; i ++)
	{
		cin >> s[i].b >> s[i].l >> s[i].u;
		s[i].v = X * s[i].u - s[i].b * s[i].u + s[i].b * s[i].l;
		sum1 += s[i].b * s[i].l;
	}
	sort(s + 1, s + n + 1);
	int p;
	for(p = n; p >= 1; p --)
	{
		if(sum1 <= s[p].v)
			break;
		sum1 -= s[p].v;
		if(s[p].u <= mn)
		{
			a = p;
			mn = s[p].u;
		}
	}
	for(int i = 1; i <= p; i ++)
	{
		long long c = (sum1 + s[i].l - 1) / s[i].l;
		if(c <= X)
			ans = min(ans, c);
		work(i);
	}
	sum1 -= s[p].v;
	for(int i = p; i <= n; i ++)
	{
		long long sum2 = sum1 + s[i].v;
		long long c = (sum2 + s[i].l - 1) / s[i].l;
		if(c <= X)
			ans = min(ans, c);
	}
	cout << ans + (n - p) * X << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    const int ma = 100000;
    vector<bool> is_prime(ma+1,1);
    vector<int> a(ma+2,0);
    for(int i=2;i<=ma;i++) if(is_prime[i]){
        for(int j=2*i;j<=ma;j += i) is_prime[j] = 0;
    }
    for(int i=3;i<=ma;i+=2){
        if(is_prime[i] && is_prime[(i+1)/2]) a[i]++; 
    }
    for(int i=3;i<=ma;i++) a[i] += a[i-1];
    int q;cin >> q;
    while(q--){
        int l,r;
        cin >> l >> r;
        cout << a[r] - a[l-1] << endl;
    }
}

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

int main(){
  ll a, b, k;
  cin >> a >> b >> k;
  if(k <= a) cout << a-k << "  " <<  b<< endl;
  if(k > a && a+b>= k) cout << 0   <<  "  " << b-(k-a) << endl;
  if(k > a+b) cout << 0 << "  " << 0 <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

int Max(int x, int y) {
	for (int i = 1; i <= y; i++) {
		x = x * 2;
	}
	return x;
}

int main() {
	int A, B, C;
	int K;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> K;
	int M = max(A, max(B, C));
	cout << Max(M, K)+A+B+C-M;
}


Measured memory_bytes: 3220
/*---------------------------------------------------------------------*/
/*                   -------------------------------------             */
/*                   -----------MEHEDI HASAN--------------             */
/*                   -----CSE,JAHANGIRNAGAR UNIVERSITY----             */
/*                   -------------------------------------             */
/*---------------------------------------------------------------------*/
#include<bits/stdc++.h>
#include <cassert>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
/*---------------------------------------------------------------------*/
#define FAST        ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define cc(x)       cout<<#x<<"="<<x<<" ";
#define ccc(x)      cout<<#x<<"="<<"("<<x.ff<<" "<<x.ss<<") ";
#define CC(x)       cout<<"["<<#x<<"] = ";for(auto xx: x) cout<<xx<<" ";
#define CCC(x)      cout<<"["<<#x<<"] = ";for(auto xx: x) cout<<"("<<xx.ff<<" "<<xx.ss<<") ";
#define mark(x)     cout<<x<<" ";
#define ee          cout<<"\n";
#define OK          cout<<"Ok"<<"\n";
/*---------------------------------------------------------------------*/
#define ff          first
#define ss          second
#define ll          long long
#define ull         unsigned long long
#define pii         pair<int,int>
#define mp          make_pair
#define ps          push
#define psb         push_back
#define psf         push_front
#define pp          pop
#define ppb         pop_back
#define ppf         pop_front
#define all(x)      x.begin(),x.end()
#define TESTS       int t;cin>>t;for(int tcase=1;tcase<=t;tcase++)
#define ordered_set tree< int, null_type, less_equal< int >, rb_tree_tag, tree_order_statistics_node_update>
/*---------------------------------------------------------------------*/
#define MAX (ll)(2e5+9)
#define MOD (ll)(1e9+7)

int main()
{
    FAST
    ll n,k;
    cin>>n>>k;
    cout<<min(k-n%k,n%k)<<endl;
    return 0;
}

/*--------------------------------------------------------------------*/
/*
>Check Corner Cases (n==1 or T==1)
>Overflow issues?
>LB / UB !!not found!! check?
*/
/*--------------------------------------------------------------------*/
/* ---INPUT---
--------(1)------


-------(2)-------


-------(3)-------


-------(4)-------



--------------
*/
/*--------------------------------------------------------------------*/




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <climits>
#include <functional>
#include <map>
#include <stack>
#include <cstdlib>
#define endl '\n'
#define ll long long
#define NCONS 100001

using namespace std;

int A[100][2];
int dp[100][2];

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    for(int i = 0; i < N; i++)
        cin >> A[i][0];
    for(int i = 0; i < N; i++)
        cin >> A[i][1];
    
    dp[0][0] = A[0][0];
    dp[0][1] = A[0][0] + A[0][1];
    
    for(int i = 1; i < N; i++)
    {
        dp[i][0] = dp[i-1][0] + A[i][0];
        dp[i][1] = max(dp[i][0], dp[i-1][1]) + A[i][1];
    }
    
    
    cout << dp[N-1][1] << endl;
    return 0;
}


Measured memory_bytes: 504
import os

MAX = 10**6
MOD = 10**9 + 7

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % MOD

g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, MAX + 1 ):
    g1.append( ( g1[-1] * i ) % MOD )
    inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )
    g2.append( (g2[-1] * inverse[-1]) % MOD )



x, y = map(int, input().split())
m = x + y
if m % 3 != 0:
    print(0)
    os.sys.exit()

n = int(m / 3)
k = x - n + 1

print(cmb(n, k-1))




Measured memory_bytes: 124048
#include <bits/stdc++.h>
#define INF 100000000
using namespace std;

int main()
{
	int N, M, L, K, A, H, road[100][100], cold[100], res[100][100];
	while (cin >> N >> M >> L >> K >> A >> H, N || M || L || K || A) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				road[i][j] = res[i][j] = (i == j ? 0 : INF);
			}
		}
		for (int i = 0; i < L; i++) {
			cin >> cold[i];
		}
		cold[L] = A;
		cold[L + 1] = H;
		for (int i = 0, X, Y, T; i < K; i++) {
			cin >> X >> Y >> T;
			road[X][Y] = road[Y][X] = T;
		}
		for (int k = 0; k < N; k++) {
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++) {
					road[i][j] = min(road[i][j], road[i][k] + road[k][j]);
				}
			}
		}
		for (int i = 0; i < L + 2; i++) {
			for (int j = 0; j < L + 2; j++) {
				if(road[cold[i]][cold[j]] <= M) res[i][j] = road[cold[i]][cold[j]];
			}
		}
		for (int k = 0; k < L + 2; k++) {
			for (int i = 0; i < L + 2; i++) {
				for (int j = 0; j < L + 2; j++) {
					res[i][j] = min(res[i][j], res[i][k] + res[k][j]);
				}
			}
		}
		if (res[L][L + 1] != INF) {
			cout << (res[L][L + 1] <= M ? res[L][L + 1] : res[L][L + 1] * 2 - M) << endl;
		}
		else {
			cout << "Help!" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3152
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

ll mod_pow(ll n, ll k, ll mod) {
    ll res = 1;
    for(; k>0; k>>=1) {
        if(k & 1) (res *= n) %= mod;
        (n *= n) %= mod;
    }
    return res;
}

const int MAXP = 105;
ll dp[200010][MAXP + 10];

int main() {
    ll N, P; cin >> N >> P;
    string s; cin >> s;

    if(P < MAXP) {
        for(int i=0; i<N; i++) {            
            dp[i+1][(s[i] - '0') % P]++;
            for(int j=0; j<P; j++) {
                ll nj = (j * 10 + (s[i] - '0')) % P;
                dp[i+1][nj] += dp[i][j];
            }
        }

        ll ans = 0;
        for(int i=1; i<=N; i++) ans += dp[i][0];
        cout << ans << endl;
    }
    else {
        ll mod = 0, ans = 0, mul = 1;
        ll inv = mod_pow(10, P-2, P);
        vector<ll> cnt(P);
        cnt[0] = 1;
        fprintf(stderr, "inv = %lld\n", inv);
        for(int i=0; i<N; i++) {
            mod = (mod + (s[i] - '0') * mul) % P;
            (mul *= inv) %= P;
            fprintf(stderr, "mod = %lld, cnt = %lld\n", mod, cnt[mod]);
            ans += cnt[mod];
            cnt[mod]++;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 180228
import heapq
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = list(map(lambda x:x*(-1),a))
heapq.heapify(a)
while m>0:
    ma = heapq.heappop(a)*(-1)
    ma //=2
    heapq.heappush(a,ma*(-1))
    m-=1
print(sum(a)*(-1))

Measured memory_bytes: 20048
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;
  cout << min({P+Q, Q+R, P+R}) << endl;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n; cin >> n;
	vector<string> s(n);
	for(auto &i:s) cin >> i;
	bool bpg = true;
	vector<Int> c(n, -1);
	queue<Int> q;
	c[0] = 0;
	q.push(0);
	while(!q.empty()){
		Int p = q.front(); q.pop();
		for(Int i=0; i<n; ++i)
			if(s[p][i] == '1'){
				if(c[i] != -1 && c[i] != 1-c[p]) bpg = false;
				if(c[i] == -1) q.push(i);
				c[i] = 1-c[p];
			}
	}
	if(!bpg){
		cout << -1 << "\n";
		return 0;
	}
	vector<vector<Int>> d(n, vector<Int>(n, 201));
	for(Int i=0; i<n; ++i)
		for(Int j=0; j<n; ++j){
			if(i == j) d[i][j] = 0;
			else if(s[i][j] == '1') d[i][j] = 1;
		}
	for(Int k=0; k<n; ++k)
		for(Int i=0; i<n; ++i)
			for(Int j=0; j<n; ++j)
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	Int ans = 2;
	for(Int i=0; i<n; ++i){
		Int tmp = 0;
		for(Int j=0; j<n; ++j) tmp = max(tmp, d[i][j]);
		ans = max(ans, tmp+1);
	}
	cout << ans << "\n";
}

Measured memory_bytes: 640
N = int(input())
red = dict()
blue = dict()

for n in range(N):
  r = input()
  if r in red:
    red[r] += 1
  else:
    red[r] = 1

M = int(input())

for m in range(M):
  b = input()
  if b in blue:
    blue[b] += 1
  else:
    blue[b] = 1

ret = [0]
for k in red.keys():
  cnt = red[k] - (blue[k] if k in blue else 0)
  ret.append(cnt)

print(max(ret))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;


int main() {
  int n; cin >> n;
  vector<ll> a(n+1);
  vector<ll> b(n);
  rep(i,n+1) cin >> a[i];
  rep(i,n) cin >> b[i];
  ll ans = 0;
  rep(i,n){
    int left = min(a[i],b[i]);
    ans += left;
    a[i] -= left;
    b[i] -= left;

    int right = min(a[i+1],b[i]);
    ans += right;
    a[i+1] -= right;
    b[i] -= right;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4828
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int ll
typedef long long ll;
const int N=2e5+5;
ll ma[N*4];
int n,q;

void update(int l,int r,int id,int i,int v){
    if(l==r){
        ma[id]=v;
        return;
    }
    int mid=(l+r)>>1;
    ma[id]=0;
    if(i<=mid)update(l,mid,id*2,i,v);
    else update(mid+1,r,id*2+1,i,v);
    if(ma)
    ma[id]=max(ma[id*2],ma[id*2+1]);
}
/*
ll query_mi(int l,int r,int ql,int v,int id){
    if(r<ql)return -1;
    if(l==r){
        if(ma[id]>=v)return l;
        else return -1;
    }
    int mid=(l+r)>>1;
    int ans=-1;
    if(ql<mid)ans=query_mi(l,mid,ql,v,id*2);
    if(ans!=-1)return ans;
    ans=query_mi(mid+1,r,ql,v,id*2+1);
    return ans;
}
*/vector<int> a;
ll mi(int x,int v){
    for(int i=x;i<=n;i++){
        if(a[i]>=v)return i;
    }
    return n+1;
}

ll query_ma(int l,int r,int ql,int qr,int id){
    if(l>=ql&&r<=qr)return ma[id];
    int mid=(l+r)>>1;
    int a=0,b=0;
    if(ql<=mid)a=query_ma(l,mid,ql,qr,id*2);
    if(qr>mid)b=query_ma(mid+1,r,ql,qr,id*2+1);
    return max(a,b);
}

/*
ll query_ma(int l,int r,int ql,int qr,int id){
    if(l>=ql&&r<=qr)return ma[id];
    int mid=(l+r)>>1;

    if(qr<=mid){
        return query_ma(l,mid,ql,qr,id*2);
    }
    else if(ql>=mid+1){
        return query_ma(mid+1,r,ql,qr,id*2+1);
    }
    else{
        int a=query_ma(l,mid,ql,qr,id*2),b=query_ma(mid+1,r,ql,qr,id*2+1);
        return max(a,b);
    }
}
*/
signed main(){
    ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);

    cin>>n>>q;
    a.resize(n+1);
    for(int i=1;i<=n;i++){
        int x;cin>>x;
        a[i]=x;
        update(1,n,1,i,x);
    }
    while(q--){
        int mode,x,y;cin>>mode>>x>>y;
        if(mode==1){
            update(1,n,1,x,y);
            a[x]=y;
        }
        else if(mode==2){
            cout<<query_ma(1,n,x,y,1)<<endl;
        }
        else if(mode==3){
            /*
            ll ans=query_mi(1,n,x,y,1);
            if(ans==-1)cout<<n+1<<endl;
            else cout<<ans<<endl;
            */
            cout<<mi(x,y)<<endl;
        }
    }
}


Measured memory_bytes: 8988
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef long long            ll;
typedef unsigned long long   ull;
typedef vector<int>          vi;
typedef vector<ll>           vl;
typedef pair<int, int>       pi;
typedef pair<ll, ll>         pl;
typedef vector<pi>           vpi;
typedef vector<pl>           vpl;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;
 
#define read        freopen("in.c", "r", stdin)
#define write       freopen("out.c", "w", stdout)
#define all(a)      a.begin(), a.end()
#define bye         exit(0)
#define mp          make_pair
#define ff          first
#define ss          second
#define L(x)        ((x) << 1)
#define R(x)        ((x) << 1 | 1)
#define SZ(a)       (ll)(a).size()
#define pb          push_back
#define eb          emplace_back
#define eps         1e-9
#define inf         (1000000000)
#define infl        (1000000000000000000LL)
#define cs(p)       printf("Case %d:", (p)++)
#define ptc(c)      putchar(c)
#define gtc()       getchar()
#define nl          puts("")
#define sp          printf(" ")
#define out(a)      printf("%lld", (ll)(a))
#define SET(a, x)   memset((a), x, sizeof(a))
#define dbg(x)      cerr << "--- " << #x << " = " << (x) << '\n'
 
ll bgm(ll a, ll b, ll m) {
    b = (b == -1) ? (m - 2) : b;
    a %= m;
    ll rem = 1;
    while(b != 0) {
        if(b&1)
            rem = (rem * a) % m;
        a = (a * a) % m;
        b >>= 1;
    }
    return rem;
}
 
inline ll in() {
    ll a;
    assert(scanf("%lld", &a) != EOF);
    return a;
}
 
const int MAX = 100000 + 5;
const int LEN = 50;
const ll MOD = 1000000007;
 
int n;
ll a[MAX];
 
ll dp[MAX];
 
ll solve(int pos) {
    if(pos > n) {
        return inf;
    }
    if(pos == n) {
        return 0;
    }
    ll &ret = dp[pos];
    if(ret != -1) {
        return ret;
    }
    return ret = min(abs(a[pos + 1] - a[pos]) + solve(pos + 1), abs(a[pos + 2] - a[pos]) + solve(pos + 2));
}
 
int main() {
  	SET(dp, -1);
    n = in();
    for(int i = 1; i <= n; i++) {
        a[i] = in();
    }
    out(solve(1)), nl;
    return 0;
}

Measured memory_bytes: 3328
// review

#include <iostream>
#include <vector>

using namespace std;
const int MAXN = 2*1e5 + 10;

int n;
int a[MAXN];
int b[MAXN];

void solve() {
  int totalCnt = 0;
  for (int i=n;i>0;i--) {
    int cnt = 0;
    for (int j=i;j<=n;j+=i) {
      if (b[j] == 1) {
        cnt++;
      }
    }
    if (a[i] != cnt % 2) {
      b[i] = 1;
      totalCnt++;
    }
  }
  cout << totalCnt << endl;
  for (int i=1;i<=n;i++) {
    if (b[i] == 1) {
      cout << i << endl;
    }
  }
}

int main() {
  cin >> n;
  for (int i=1;i<=n;i++) {
    cin >> a[i];
  }
  solve();
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll m=1e9+7;
ll lev=0;
ll n,k;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p)%m;
p=(p*p)%m;
k>>=1;
}
return a;
}
using namespace std;
vector<ll> v[1000000+1];
ll vis[1000000+1]={0};
void dfs(ll u,ll p,ll lev)
{
    vis[u]=lev;
for(auto x: v[u])
{
if(x!=p)
{
dfs(x,u,lev+1);
}
}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
  
  double r;
  cin>>r;
  double ans=3.1415926535*r*2;
  printf("%.10f",ans); 
     cout<<"\n"; 
 } 
}


Measured memory_bytes: 27236
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var N int
	fmt.Scan(&N)
	L := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < N; i++ {
		L[i] = nextInt(sc)
	}
	sort.Ints(L)
	ans := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			A, B := L[i], L[j] // A<B
			// 三角形の成立条件 B<C<A+B を満たすCを２分探索で探す
			AB := A + B
			r := lowerbound(L, AB) // 半開区間で考える
			l := j + 1
			ans += max(0, r-l)
		}
	}
	fmt.Println(ans)
}
func lowerbound(v []int, k int) int {
	l, r := -1, len(v)
	for r-l > 1 {
		m := l + (r-l)/2
		if v[m] >= k {
			r = m
		} else {
			l = m
		}
	}
	return r
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pair<ll, ll>> vpll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin >> x;
    if (x >= 30) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

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

  map<string, bool> dict;
  while ( n-- ) {
    string c, s;
    cin >> c >> s;

    if ( c == "insert" ) {
      dict[s] = true;
    } else {
      if ( dict.count(s) ) cout << "yes" << endl;
      else cout << "no" << endl;
    }     
  }
  
  return 0;
}



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

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  int n;
  cin >> n;
  ll k;
  cin >> k;
  ll ans = k;
  rep(i, n-1){
    ans *= k-1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
R,S,P=map(int,input().split()) #RSP グーチョキパー
T=list(input())

c=0

def jan(a):
    if a=="r":
        return P
    elif a=="s":
        return R
    elif a=="p":
        return S
    else:
        return 0

for i in range(K,N):
    if T[i-K]==T[i]:
        T[i]="o"

for i in T:
    c+=jan(i)

print(c)

Measured memory_bytes: 4084
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define endl "\n"
inline bool EQ(double a, double b)
{
    return fabs(a - b) < 1e-9;
}
const int INF = 1 << 29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }

inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int &n, int b) { n |= two(b); }
inline void unset_bit(int &n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n)
{
    int res = 0;
    while (n && ++res)
        n -= n & (-n);
    return res;
}
template <class T>
void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
void chmin(T &a, const T &b) { a = min(a, b); }

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

    ll n, k;
    cin >> n >> k;
    ll a[n];
    REP(i, n)
    cin >> a[i];
    sort(a, a + n);
    ll ans = 0;
    REP(i, k)
    {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
while True:
    N = input()
    if N==0: break
    cards = raw_input()
    ba = 0
    player = [0]*N
    for i, card in enumerate(cards):
        pid = i % N
        if card=='S':
            ba += player[pid]+1
            player[pid] = 0
        elif card=='L':
            player[pid] += ba+1
            ba = 0
        elif card=='M':
            player[pid] += 1
    player.sort()
    print ' '.join(map(str, player)), ba

Measured memory_bytes: 4224
import java.util.*;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;

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();
			
		}
		HashMap<Integer,Boolean> map = new HashMap<Integer,Boolean>();
		for(int i = 0; i < N; i++) {
			if(map.containsKey(A[i])) {
				map.put(A[i], !map.get(A[i]));
			} else {
				map.put(A[i], true);
			}
		}
		int sum = 0;
		for(int i = 0; i < N; i++) {
			if(map.get(A[i])) {
				sum++;
				map.put(A[i], false);
			}
		}
		System.out.println(sum);
		
	}
}

Measured memory_bytes: 56540
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

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


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;

  /* input */
  vector<int> x_coord(n);
  vector<int> y_coord(m);
  rep(i, n) {
      cin >> x_coord[i];
  }
  rep(i, m) {
      cin >> y_coord[i];
  }

  sort(x_coord.begin(), x_coord.end());
  sort(y_coord.begin(), y_coord.end());
  /* check */
  string ans = "War";
  rep(j, n) {
      if ((x_coord[j] > x && x_coord[j] <= y) && 
          (x_coord[n-1] < y_coord[0]) &&
          (y_coord[0] > x && y_coord[0] <= y)) {
          ans = "No War";
      }
  }
  rep(j, m) {
      if ((x_coord[j] > x && x_coord[j] <= y) && 
          (x_coord[n-1] < y_coord[0]) &&
          (y_coord[0] > x && y_coord[0] <= y)) {
          ans = "No War";
      }
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    ll n,d,a,ans=-1,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>d>>a;
        ans+=a;
        sum+=d*a;
    }
    ans+=(sum-1)/9;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n, k, s = map(int, input().split())
if k == 0:
    if s == 10**9:
        print(' '.join([str(s - 1)]*n))
    else:
        print(' '.join([str(s + 1)]*n))
else:
  first = [str(s)]*k
  if s == 1:
    second = [str(2)]*(n - k)
  else:
    second = [str(max(1, s - 1))]*(n - k)
  print(' '.join(first + second))

Measured memory_bytes: 7012
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	printf("%d\n",a[n/2+1]-a[n/2]);
	return 0;
}

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

int main(){

    double n, m, d; cin >> n >> m >> d;
    
    double ans = m - 1.0;
    if(d == 0){
        ans /= n;
    }else{
        ans = ans * 2 * (n - d) / (n * n);
    }

    printf("%.10f\n", ans);
    return 0;
}

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

void solve(long long A, long long B)
{
    if (A != 1 && B != 1)
        cout << 1 << endl;
    else if (A != 2 && B != 2)
        cout << 2 << endl;
    else
        cout << 3 << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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

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

  ll a,b,c,k;
  cin>>a>>b>>c>>k;

  //a[0], a[1], ..., と実験
  if(k%2) cout << b-a << endl;
  else cout << a-b << endl;
  
  return 0;
}


  
  /*
  if(k%2){
    ll ta, tb, tc;
    ta = b+c;
    tb = a+c;
    tc = a+b;
    a = ta, b = tb, c = tc;
    k--;
  }
  
  ll cnt = k/2;  
  while(cnt > 0){    
    ll ta = 2*a+b+c;
    ll tb = a+2*b+c;
    ll tc = a+b+2*c;    
    if(ta > 1e18 || tb > 1e18 || tc > 1e18){
      //cout << cnt << endl;
      cout << ta << " " << tb << " " << tc << endl;
      cout << "Unfair" << endl; return 0;
    }
    a = ta, b = tb, c = tc;
    cnt--;
  }
  cout << a-b << endl;
  */


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

using namespace atcoder;

using Mint = modint998244353;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int n, k;
    std::cin >> n >> k;
    std::vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> p[i];
        --p[i];
    }
    
    fenwick_tree<Mint> fw(n);
    fenwick_tree<int> fw2(n);
    
    Mint pr = 1 - Mint(k).inv();
    std::vector<Mint> pw(n);
    pw[0] = 1;
    for (int i = 1; i < n; ++i)
        pw[i] = pw[i - 1] * pr;
    
    Mint ans = 0;
    
    for (int i = 0; i < n; ++i) {
        auto v = pw[std::max(i, k - 1)];
        ans += (fw.sum(0, p[i]) - fw.sum(p[i], n)) * v;
        fw.add(p[i], v.inv());
        ans += fw2.sum(p[i], n);
        fw2.add(p[i], 2);
    }
    
    ans /= 2;
    std::cout << ans.val() << "\n";
    
    return 0;
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, X; cin >> N >> X;
  ll cnt = 0;
  ll pos = 0;
  for (ll i = 0; i <= N; i++) {
    ll l; cin >> l;
    if (pos <= X) cnt++;
    pos += l;
  }
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, T;
	cin >> N >> T;

	lint min_num = INF64;
	lint count = 0;
	lint diff = 0;
	for (int i = 0; i < N; i++)
	{
		lint tmp;
		cin >> tmp;

		min_num = min(min_num, tmp);
		if (diff < tmp - min_num)
		{
			diff = tmp - min_num;
			count = 1;
		}
		else if (diff == tmp - min_num)
		{
			count++;
		}
	}

	cout << count << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

a,b,c,d = load_list()

def f(n, x, y):
    return n // x + n // y - n // lcm(x, y)



print((b-a+1) - (f(b, c, d) - f(a-1, c, d)))

Measured memory_bytes: 38256