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

#define rep(i, u) for (int i = 0; i < u; i++)

using ll = long long;
using ull = unsigned long long;

int main() {
  int h, w;
  while (true) {
    cin >> h >> w;
    if (h == 0 && w == 0) break;
    rep(i, h) {
      rep(j, w) {
        if (i == 0 || i == h - 1 || j == 0 || j == w - 1) cout << '#';
        else cout << '.';
        if (j == w - 1) cout << endl;
      }
      if (i == h - 1) cout <<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3008
/*
    Mbak Rose Dong
*/
#include<bits/stdc++.h>
using namespace std;
long long int dp[100100];
int main()
{
    int i,j,x,y,ans,curr=0,n,m,c;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++)
    {
        int v,w;
        scanf("%d %d",&w,&v);
        for(j=m-w;j>=0;j--)
        {
            if(dp[j+w] < dp[j] + v)
                dp[j+w] = dp[j] + v;
        }
    }
    cout << dp[m] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cmath>

#define INF 1000000000
#define REP(i,n) for(int i=0; i<n; i++)
#define REP_R(i,n,m) for(int i=m; i<n; i++)
#define MAX 55

using namespace std;

vector<int> primes;

// エラトステネスの篩
void sieve(int N) {
  std::vector<int> v;
  for (int i=0; i<N; i++) {
    v.push_back(1);
  }

  for (int i=2; i<sqrt(N); i++) {
    if (v[i]) {
      for (int j=0; i*(j+2) < N; j++) {
        v[i *(j+2)] = 0;
      }
    }
  }

  for (int i=2; i<N; i++) {
    if (v[i]) {
      primes.push_back(i);
    }
  }
}

int N;
int dp[MAX + 5];
std::vector<int> v;

int main() {
  std::vector<int> five_primes;

  scanf("%d", &N);
  sieve(55555);

  REP(i,primes.size()) {
    if (primes[i] % 5 == 1) {
      five_primes.push_back(primes[i]);
    }
  }

  REP(i,N) {
    printf("%d ", five_primes[i]);
  }

  cout << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    vector<int[2]> A(N);
    REP(j,2) REP(i,N) cin>>A[i][j];
    int dp[2]={};
    REP(i,N){
        dp[0]=dp[0]+A[i][0];
        dp[1]=max(dp[0]+A[i][1],dp[1]+A[i][1]);
    }
    cout<<dp[1]<<endl;
}


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

//??????????????§
int n;
int Y,M,D;
int ans;

int main() {
	cin>>n;
	for (int i = 0; i < n; i++) {
		//?????????
		ans=0;

		//??\???
		cin>>Y>>M>>D;
		
		//D??\?????????1??\
		if (Y % 3 == 0 || M % 2 == 1) {
			ans+=21-D;
		}
		else ans+=20-D;

		M++;
		//??????1??\????????´1???1??\
		if (Y % 3 == 0) {
			ans+=(11-M)*20;
		}
		else {
			ans+=(11-M)*20;
			ans-=int((12-M)/2);
		}

		Y++;
		//?????´1???1??\???1000??´1???1??\
		ans+=(1000-Y)*(20*5+19*5);
		ans+=5*int((1002-Y)/3);

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

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

int main()
{
    long int n,i,k=0;
    float p,j,m;
    cin>>n>>m;
    long int a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
        j=j+a[i];
    p=1/(4*m);
    p=p*j;
    for(i=0;i<n;i++)
        if(a[i]>=p)
            k++;
    if(k>=m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
  return 0;
}

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

int main(){
  int N; cin >> N;
  if(N<=2){
    cout << 1 << endl;
    return 0;
  }
  vector<int> MY(N);
  cin >> MY[0];
  int ans=1;
  int m=0;
  for(int i=1;i<N;i++){
    cin >> MY[i];
    if((MY[i]>MY[i-1] && m==-1) || (MY[i]<MY[i-1] && m==1)){
      ans++;
      m=0;
    }
    else if(m==0){
      if(MY[i]>MY[i-1]){
        m=1;
      }
      if(MY[i]<MY[i-1]){
        m=-1;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<stack>
#include<queue>
#include<cstdio>
using namespace std;

#define X_MAX 100+10
#define Y_MAX 100+10

#define Vertical 1
#define Horizontal 0

int my[4] = { 1,-1,0,0 };
int mx[4] = { 0,0,1,-1 };

struct ST
{
	int came[Y_MAX][X_MAX];
	int now_y;
	int now_x;
};


void paint_V(int*map , int col)
{
	int i;
	for (i = 0; i < 2; i++)
	{
		*(map + i) = col;
	}
}

void paint_H(int*map, int col)
{
	int i;
	for (i = 0; i < 4; i++)
	{
		*(map + i) = col;
	}
}


void chek(int map[Y_MAX][X_MAX],int lx,int ly)
{
	int i, j;
	for (i = 0; i <= ly+1;i++)
	{
		for (j = 0; j <= lx+1; j++)
		{
			cout << map[i][j];
		}
		cout << endl;
	}
}


int main(void)
{
	ST an = {0}, tmp;
	queue<ST> ma;

	int lx, ly, n;
	int sx, sy, gx, gy;
	int col, VorH,set_x,set_y;
	int i, j;

	while ((cin >> lx >> ly), lx!=0&&ly!=0)
	{
		int goal = 0;
		int map[Y_MAX][X_MAX] = { 0 };
		cin >> sx >> sy >> gx >> gy >> n;

		for (i = 0; i < n; i++)
		{
			cin >> col >> VorH >> set_x >> set_y;
			if (VorH == Vertical)
			{
				for (j = 0; j < 4; j++)
				{
					paint_V(map[set_y + j] + set_x, col);
				}
			}
			else
			{
				for (j = 0; j < 2; j++)
				{
					paint_H(map[set_y + j] + set_x, col);
				}
			}
		}
		
		int s_col = map[sy][sx];
		if (s_col == 0)
		{
			cout << "NG\n";
			continue;
		}

		an.now_y = sy;
		an.now_x = sx;
		ma.push(an);

		//chek(map, lx, ly);

		while (!ma.empty())
		{
			an = ma.front();
			ma.pop();
			//an.came[an.now_y][an.now_x] = -1;
			if (map[an.now_y][an.now_x] == s_col)
			{
				map[an.now_y][an.now_x] = -1;

				//printf("y=%d,x=%d\n", an.now_y, an.now_x);
				//chek(an.came, lx, ly);

				if (an.now_y == gy && an.now_x == gx)
				{
					goal = 1;
					break;
				}

				tmp = an;

				for (i = 0; i < 4; i++)
				{
					if (map[an.now_y + my[i]][an.now_x + mx[i]] == s_col/* && an.came[an.now_y + my[i]][an.now_x + mx[i]] == 0*/)
					{
						tmp.now_y = an.now_y + my[i];
						tmp.now_x = an.now_x + mx[i];
						ma.push(tmp);
					}
				}
			}
		}
		if (goal == 1)
		{
			while (!ma.empty())
			{
				ma.pop();
			}
			cout << "OK\n";
		}
		else
		{
			cout << "NG\n";
		}


	}
	return 0;
}


Measured memory_bytes: 3364
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N,M,L;
  cin>>N>>M>>L;
  VI A(M),B(M),C(M);
  rep(i,M) cin>>A[i]>>B[i]>>C[i];
  int Q;
  cin>>Q;
  VI S(Q),T(Q);
  rep(i,Q) cin>>S[i]>>T[i];
  vector<vector<ll>> X(N,vector<ll> (N));
  rep(i,N) rep(j,N) X[i][j]=1000000000000;
  rep(i,M){
    X[A[i]-1][B[i]-1]=C[i];
    X[B[i]-1][A[i]-1]=C[i];
  }
  rep(i,N) X[i][i]=0;
  rep(k,N) rep(i,N) rep(j,N) X[i][j]=min(X[i][j],X[i][k]+X[k][j]);
  vector<vector<ll>> Y(N,vector<ll> (N));
  rep(i,N) rep(j,N) Y[i][j]=1000000000000;
  rep(i,N) rep(j,N) if(X[i][j]<=L) Y[i][j]=1;
  rep(i,N) Y[i][i]=0;
  rep(k,N) rep(i,N) rep(j,N) Y[i][j]=min(Y[i][j],Y[i][k]+Y[k][j]);
  rep(i,Q){
    if(Y[S[i]-1][T[i]-1]==1000000000000) cout<<-1<<endl;
    else cout<<Y[S[i]-1][T[i]-1]-1<<endl;
  }
}


Measured memory_bytes: 3072
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

void solve(istream &cin) {
    ll N;
    cin >> N;
    if(!cin) return;
    ll pre = 0;
    ll newk = 101;
    for (int i = 0; i < N; ++i) {
        ll a;
        cin >> a;
        if(pre == a){
            pre = newk++;
        }
        else{
            pre = a;
        }
    } // end i
    cout << newk - 101 << endl;


    
}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test.txt";
    auto fs = fstream(test_cases, fstream::in);
    while(fs) {
        solve(fs);
    }
#else
    solve(cin);
#endif
    return 0;
}


Measured memory_bytes: 256
n = int(input())
xyh = []
for i in range(0,n):
    X,Y,h = map(int,input().split())
    xyh.append((X,Y,h))
from operator import itemgetter
xyh.sort(key=itemgetter(2))
xyh.reverse()

ans = ()
for i in range(0,101):
    for j in range(0,101):
        flag = "f"
        x,y,h = xyh[0]
        H = h + abs(x-i)+abs(y-j)
        for x,y,h in xyh:
            if H ==  h + abs(x-i)+abs(y-j) and h != 0:
                flag = "t"
            elif H <=  h + abs(x-i)+abs(y-j) and h == 0:
                flag = "t"
            else:
                flag = "f"
                break
        if flag == "t":
            ans = (i,j,H)
Cx,Cy,H = ans
print(Cx,Cy,H)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int dp[10009][109][2],a[10009],mod=1e9+7,sm,n;
int bt(int id,int x,int o)
{
    //cout<<id<<" "<<x<<" "<<o<<"\n";
    if(id==n)
    {
        if(x==0)return 1;
        else return 0;
    }
    int &ret=dp[id][x][o];
    if(ret!=-1)return ret;
    ret=0;
    int mx=10,oo=0;
    if(o)mx=a[id]+1;
    for(int i=0;i<mx;i++)
    {
        if(i==mx-1&&o)oo=1;
        ret+=bt(id+1,(x+i)%sm,oo);
        ret%=mod;
    }
    return ret;
}
string s;
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>s>>sm;
    n=s.size();
    for(int i=0;i<n;i++)
    {
        a[i]=s[i]-'0';
    }
    cout<<(bt(0,0,1)-1+mod)%mod<<"\n";
}


Measured memory_bytes: 9600
import sys


n,p=map(int,input().split())
a=list(map(int,input().split()))
c=0
for i in a:
    if(i%2!=0):
        c+=1
if(c==0):
    if(p==0):print(2**n)
    else:print(0)
else:
    print(2**(n-1))

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

using i64 = int64_t;

constexpr i64 MOD = 1e9 + 7;

i64 extgcd(i64 a, i64 b, i64 &x, i64 &y) {
    i64 d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

i64 multi_inv(i64 a, i64 md) {
    i64 x, y;
    extgcd(md, a, x, y);
    return (y > 0 ? y : md + y);
}

std::map<i64, i64> prime_factor(i64 n) {
    std::map<i64, i64> res;
    for (i64 i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1)
        res[n] = 1;
    return res;
}

i64 repeated_squaring(i64 x, i64 n) {
    i64 res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    vector<i64> v;
    for(int i=0;i<n;++i){
        i64 a;
        cin >> a;
        v.push_back(a);
    }
    map<i64, i64> mp;
    for(auto e: v){
        auto pf = prime_factor(e);
        for(auto e2: pf){
            mp[e2.first] = max(mp[e2.first], e2.second);
        }
    }

    i64 p = 1;
    for(auto e: mp){
        p *= repeated_squaring(e.first, e.second);
        p %= MOD;
    }
    i64 m = p;
    i64 ans = 0;
    for(auto e: v){
        i64 b = m * multi_inv(e, MOD);
        ans += b;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    while(true) {
        int m;
        cin>>m;
        if(m==0)break;
        vector<pair<int,int>> s;
        for(int i = 0;i < m;++i) {
            int x,y;
            cin>>x>>y;
            s.emplace_back(y,x);
        }
        int n;
        cin>>n;
        vector<pair<int,int>> p;
        set<pair<int,int>> ps;
        for(int i = 0;i < n;++i) {
            int x,y;
            cin>>x>>y;
            p.emplace_back(y,x);
            ps.insert(p[i]);
        }
        int sy=s[0].first,sx=s[0].second;
        int yo,xo;
        bool ok;
        for(int i = 0;i < n;++i) {
            yo=sy-p[i].first;
            xo=sx-p[i].second;
            ok=true;
            for(int j = 0;j < m;++j) {
                if(ps.find(make_pair(s[j].first-yo,s[j].second-xo))==ps.end()) {
                    ok=false;
                    break;
                }
            }
            if(ok) {
                cout<<-xo<<" "<<-yo<<endl;
                break;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3104
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

N, K = map(int, input().split())
S = list(input())
a = []
rei = 0
ichi = 0
reicnt = 0
ichicnt = 0
for i in S:
    if i == '1':
        if rei > 0:
            a.append((0, rei))
            reicnt+=1
        rei = 0
        ichi += 1
    else:
        if ichi > 0:
            a.append((1, ichi))
            ichicnt += 1
        rei += 1
        ichi = 0
if rei > 0:
    a.append((0, rei))
    reicnt += 1
if ichi > 0:
    a.append((1, ichi))
    ichicnt+=1
if reicnt <= K:
    print(N)
else:
    zero = deque([0])
    kk = 0
    count = 0
    mx = 0
    ind = 0
    for i in a:
        if i[0] == 0:
            count += i[1]
            zero.append(count)
            kk += 1
            if kk > K:
                ind += 1
            mx = max(mx, count - zero[ind])
        else:
            count += i[1]
            mx = max(count - zero[ind], mx)
    print(mx)


Measured memory_bytes: 15160
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int n; bool b; cin >> n;
	cout << 0 << endl;
	string s; cin >> s;
	if (s == "Vacant")return 0;
	b = s == "Female";
	int le = 0, ri = n;
	while (ri - le > 1) {
		int mid = (le + ri) / 2;
		cout << mid << endl;
		cin >> s; if (s == "Vacant")return 0;
		bool c= s == "Female";
		if (mid % 2) {
			if ((!b && !c) || (b && c))ri = mid;
			else le = mid;
		}
		else {
			if ((!b && !c) || (b && c))le = mid;
			else ri = mid;
		}
	}
}

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

namespace SorLorE
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] data = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            Conpare.Judje(data[0], data[1]);
        }
    }
    class Conpare
    {
        static public void Judje(int a,int b)
        {
            string relation;
            if (a > b) relation = ">";
            else if (a < b) relation = "<";
            else relation = "==";
            Console.WriteLine("a " + relation + " b");
        }

    }
}

Measured memory_bytes: 9468
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;




#define NMAX (100001)
#define INF (100000000000000)
vector<pair<ll, int> > G[NMAX];
ll cost[NMAX];
bool done[NMAX] = { false };
ll ans[NMAX] = { 0 };

void dijkstra(int root)
{
	priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > PQ;
	pair<ll, int> current;	/* first: cost, second: index */
	ll next_cost;
	int current_index, next_index;

	rep(i, NMAX) cost[i] = INF;

	cost[root] = 0;
	PQ.push(make_pair(0, root));

	while (!PQ.empty()) {
		current = PQ.top();
		PQ.pop();

		current_index = current.second;

		if (done[current_index]) continue;
		done[current_index] = true;

		rep(i, G[current_index].size()) {
			next_index = G[current_index][i].second;
			next_cost = G[current_index][i].first;

			if ((!done[next_index])
				&& (cost[next_index] > cost[current_index] + (ll)next_cost)) {
				cost[next_index] = cost[current_index] + (ll)next_cost;
				PQ.push(make_pair(cost[next_index], next_index));
			}
		}
	}
}

int main()
{
	int N, a, b, c, Q, K, x, y;

	cin >> N;
	rep(i, N - 1) {
		cin >> a >> b >> c;
		G[a].push_back(make_pair(c, b));
		G[b].push_back(make_pair(c, a));
	}

	cin >> Q >> K;

	dijkstra(K);

	rep(i, Q) {
		cin >> x >> y;
		ans[i] = cost[x] + cost[y];
	}

	rep(i, Q) cout << ans[i] << '\n';

	return 0;
}

Measured memory_bytes: 11120
#include<stdio.h>
int main()
{
  int K;
  scanf("%d",&K);
  int i,j,l;
  int a,b,c,tmp,r;
  unsigned long sum=0;
  for(i=1;i<K+1;i++){
    for(j=1;j<K+1;j++){
      for(l=1;l<K+1;l++){
        a=i;
        b=j;
        c=l;
        if(a<b){
          tmp=a;
          a=b;
          b=tmp;
        }
        r = a % b;
        while(r!=0){
          a = b;
          b = r;
          r = a % b;
        }
        if(b<c){
          tmp=c;
          c=b;
          b=tmp;
        }
        r = b % c;
        while(r!=0){
          b = c;
          c = r;
          r = b % c;
        }
        sum=sum+c;
      }
    }
  }
  printf("%lu",sum);
  return 0;
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,k,Sum,Mod=1e9+7,a[101],sum[101],dp[101][100001];
int Dp_Rec(int n, int k)
{
    if(!(sum[n] >= k && n)) return 0;  
    if(dp[n][k]) return dp[n][k];
    if(!(n || k) || !k) return dp[n][k] = 1;
    return dp[n][k] = ((k - a[n] > 0) ? Dp_Rec(n,k-1) + Dp_Rec(n-1,k) - Dp_Rec(n-1,k-a[n]-1) : Dp_Rec(n,k-1) + Dp_Rec(n-1,k)) % Mod;
}
main()
{
    cin >> n >> k;
    for(int i=1; i<=n; i++)
        cin >> a[i],sum[i] = sum[i-1] + a[i];
    cout << (Dp_Rec(n,k) + Mod) % Mod;
}

Measured memory_bytes: 83072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
bool tv[100002][30];

int main(void){
    ll n, c;
    cin >> n >> c;

    rep(i, 0, n){
        ll tmp1, tmp2, tmp3;
        cin >> tmp1 >> tmp2 >> tmp3;
        tmp3--;
        rep(j, tmp1, tmp2 + 1){
            tv[j][tmp3] = true;
        }
    }

    ll sum = 0;
    rep(i, 1, 100002){
        ll num = 0;
        rep(j, 0, c){
            if(tv[i][j]) num++;
        }
        sum = max(num, sum);
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3200
n = int(input())
v = list(map(int, input().split()))
v.sort()

maximum = v[-1]
v.remove(maximum)
while len(v)!=1:
    tmp = (v[0]+v[1])/2
    v.remove(v[1])
    v.remove(v[0])
    v.insert(0, tmp)

print((maximum + v[0])/2)

Measured memory_bytes: 3064
N = gets.to_i
 
#禁止されるパターン
# (AGCT) = (0123)として
# .012, .102, .021, 0.12, 01.2の5パターン
 
dp = Array.new(N+1){Array.new(4){Array.new(4){Array.new(4,0)}}}
 
#初期化。012,102,021の3パターンが禁止
4.times do |p3|
  4.times do |p2|
    4.times do |p1|
      if ![p3,p2,p1].join.match(/012|102|021/)
        dp[3][p3][p2][p1] = 1
      end
    end
  end
end
 
 
(3..N-1).each do |n|
  4.times do |p3|
    4.times do |p2|
      4.times do |p1|
        4.times do |a|
          if ![p3,p2,p1,a].join.match(/.012|.102|.021|0.12|01.2/)
            dp[n+1][p2][p1][a] += dp[n][p3][p2][p1]
            dp[n+1][p2][p1][a] %= (10**9+7)
          end
        end
      end
    end
  end
end
 
cnt = 0
4.times do |p3|
  4.times do |p2|
    4.times do |p1|
      cnt += dp[N][p3][p2][p1]
      cnt %= (10**9 + 7)
    end
  end
end
 
p cnt

Measured memory_bytes: 2556
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
const int MAX_N = 100010;

int N;
int a[MAX_N], b[MAX_N], c[MAX_N];

int dp[MAX_N][3];

int Solve(int day, int prev)
{
    if (day == N) return 0;

    if (prev >= 0 && dp[day][prev] >= 0) return dp[day][prev];

    int res = 0;
    array<int, 3> h = {a[day], b[day], c[day]};
    rep(i, 0, 3)
    {
        if (i == prev) continue;

        chmax(res, h[i] + Solve(day + 1, i));
    }
    return dp[day][prev] = res;
}

void _main()
{
    memset(dp, -1, sizeof(dp));
    cin >> N;
    rep(i, 0, N) cin >> a[i] >> b[i] >> c[i];
    cout << Solve(0, -1) << endl;
}


Measured memory_bytes: 10368
#include <iostream>
using namespace std;
#define f(a,b) ((x[i]-x[(i+1)%3])*(b-y[i])-(y[i]-y[(i+1)%3])*(a-x[i]))
int main()
{
	double x[4],y[4];
	while(cin>>x[0]>>y[0]){
		for(int i=1;i<4;i++) cin>>x[i]>>y[i];
		bool f=false;
		for(int i=0;i<3;i++){
			if(f(x[(i+2)%3],y[(i+2)%3])*f(x[3],y[3]) < 0){
				f = true;
				break;
			}
		}
		if(f) cout<<"NO\n";
		else cout<<"YES\n";
	}
	return 0;
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int, input().split()))

before = a[0]
ok = "" #増加ならTrue
cnt = 0
for i in range(1,n):
  if ok == "":
    if before < a[i]:
      ok = True
    elif before > a[i]:
      ok = False
  elif ok:
    if before > a[i]:
      cnt += 1
      ok = ""
  elif not ok:
    if before < a[i]:
      cnt += 1
      ok = ""
  before = a[i]
print(cnt+1)

Measured memory_bytes: 14252
#include <stdio.h>

int main(){

int a,b;

while(1){
	scanf("%d%d", &a, &b);
	if((a == 0) && (b == 0)){
		break;
	}
	if(a < b){
		printf("%d %d\n", a, b);
	}else {
		printf("%d %d\n", b, a);
}
}
return 0;
}

Measured memory_bytes: 600
#pragma GCC optimize("O3", "unroll-loops")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int n; ll k;
vector<ll> a, f;

bool possible(ll score) {
	ll tmp = 0;
	for (int i = 0; i < n; ++i) {
		if (a[i] * f[i] <= score) continue;
		tmp += a[i] - (score / f[i]);
	}
	return tmp <= k;
}

signed main() {
	cin >> n >> k;
	a.resize(n);  f.resize(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i) cin >> f[i];
	sort(a.begin(), a.end());
	sort(f.begin(), f.end());
	reverse(f.begin(), f.end());
	ll ok = 1000000000000LL, ng = -1;
	while (ok - ng > 1) {
		ll mid = (ng + ok) / 2;
		if (possible(mid)) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
	return 0;
}

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

int main() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    int w=0, r=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
        {
            r++;
        }
        else{
            w++;
        }
    }
    int ans=0;
    for(int i=0;i<r;i++)
    {
        if(s[i]=='W')
        {
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3744
import math
def main():

    N = int(input())

    d = [2 for _ in range(N+1)]
    d[1] = 1

    v = int(math.sqrt(N))

    for i in range(2, v+1):
        u = i
        for j in range(2, N//i+1):
            u += i
            d[u] += 1 + (j > v)

    ans = 0
    for i in range(1, N+1):
        ans += i * d[i]
    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 217720
a,b,m=map(int,input().split())

a=list(map(int,input().split()))
b=list(map(int,input().split()))

ans=min(a)+min(b)

for i in range(m):
  x,y,c=map(int,input().split())
  ans=min(ans,a[x-1]+b[y-1]-c)
print(ans)

Measured memory_bytes: 18736
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), cum(N+1);
    REP(i,N){
        cin >> A[i];
        A[i]--;
    }
    REP(i,N) cum[i+1] = (A[i] + cum[i]) % K;
    map<ll, ll> mp;
    ll ans = 0;
    REP(i,N+1){
        ans += mp[cum[i]];
        mp[cum[i]]++;
        if(i - K + 1 >= 0) mp[cum[i-K+1]]--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	ll n; cin >> n;
	ll ans = n;
	
	for(ll i = 1; i * i <= n; i++) if(n % i == 0){
		ll j = n / i;
		ans = min(ans, i + j - 2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(d2 == 1) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
ans=0
n=int(input())
lis=input()
lis=lis.split(" ")
for i in range(0,n):
    lis[i]=int(lis[i])
    ans=ans^lis[i]
ans_lis=[]
for i in range(0,n):
    ans_lis.append(lis[i]^ans)
for i in range(0,n):
    print(ans_lis[i],end=" ")
        


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

int m,d,ans;

int main(){
	scanf("%d%d",&m,&d);
	for(int i=22;i<=d;++i){
		if(i%10<2)continue;
		if((i%10)*(i/10)<=m)++ans;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        int tmp,case_num = 1;
 
        while((tmp = sc.nextInt()) != 0){
            System.out.printf("Case %d: %d\n",case_num++, tmp);
        }
    }
}


Measured memory_bytes: 69060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	double ans = 0.00000;
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		int now = i;
		double no = 1.0/n;
		int sum = 0;
		while(now<k)
		{
			now*=2;
			sum++;
		}
		double m = 0.5;
		m = pow(m,sum);
		no*=m;
		ans+=no;
	}
	printf("%.12f\n",ans);
	return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();
		int ans=1;
		for(int i=2;i<=x;i++) {
			int tmp=i;
			if(tmp*i>x) {
				System.out.println(ans);
				return;
			}
			while(tmp<x) {
				tmp*=i;
				if(tmp*i>x) {
					break;
				}
			}
			if(ans<tmp) {
				ans=tmp;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
int MOD=1000000007;
int inf=1e9+7;
signed main(){
    int n,k;cin>>n>>k;
    vector<pair<int,int>> res;
    if(k>(n-1)*(n-2)/2){
        cout<<-1<<endl;
        return 0;
    }
    int m=0;
    rep1(i,n){
        for(int j=i+1;j<=n;++j){
            res.push_back({i,j});
            ++m;
        }
    }
    int cur=n-1;
    while(k>0){
        --k;
        res[cur].first=inf;
        res[cur].second=inf;
        --m;++cur;
    }
    cout<<m<<"\n";
    for(auto& val:res){
        if(val.first==inf){
            continue;
        }
        cout<<val.first<<" "<<val.second<<"\n";
    }
    return 0;
}

Measured memory_bytes: 512
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int S = nextInt();
		int W = nextInt();
		if(S<=W){
			System.out.println("unsafe");

		}else{
			System.out.println("safe");
		}


	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

class node{
	public:
		node* left;
		node* right;
		node* p;
		int key;
		node(){
			left=NULL;
			right=NULL;
			p=NULL;
		}
		node(int k){
			left=NULL;
			right=NULL;
			p=NULL;
			key=k;
		}
};

node* root=NULL;
int a[500002];
int n=0;

void insert(node*);
void print();
void preorder(node*);
void midorder(node*);

void insert(node* z){
	node *y=NULL;
	node *x=root;
	while(x!=NULL){
		y=x;
		if(z->key<x->key)x=x->left;
		else x=x->right;
	}
	z->p=y;
	if(y==NULL){
		// delete root;
		root=z;
	// cout<<"root:"<<root->key<<endl;
	}else if(z->key<y->key)y->left=z;
	else y->right=z;
}

void print(){
	midorder(root);
	cout<<endl;
	preorder(root);
	cout<<endl;
}

string find(int k){
	node* x=root;
	while(x!=NULL){
		if(x->key==k)return "yes";
		if(k<x->key)x=x->left;
		else x=x->right;
	}
	return "no";
}

void midorder(node* i){
	if(i==NULL)return;
	midorder(i->left);
	// if(i!=root)cout<<" "<<i->key;
	cout<<" "<<i->key;
	midorder(i->right);
}

void preorder(node* i){
	if(i==NULL)return;
	// if(i!=root)cout<<" "<<i->key;
	cout<<" "<<i->key;
	preorder(i->left);
	preorder(i->right);
}

int main(void){
	int q,k;
	string s;
	cin>>q;
	while(q--){
		cin>>s;
		if(s[0]=='i'){
			cin>>k;
			insert(new node(k));
		}else if(s[0]=='p'){
			print();
		}else if(s[0]=='f'){
			cin>>k;
			cout<<find(k)<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 21904
#include <iostream>
using namespace std;
int main(){
    int m,f,r;
    while (1){
        cin>>m>>f>>r;
        if (m==-1&&f==-1&&r==-1){
            break;
        }else if(m==-1||f==-1){
            cout<<"F"<<endl;
        }else{
            int sum=m+f;
            if (sum>=80){
                cout<<"A"<<endl;
            }else if(sum>=65){
                cout<<"B"<<endl;
            }else if(sum>=50){
                cout<<"C"<<endl;
            }else if(sum>=30){
                if(r>=50){
                    cout<<"C"<<endl;
                }else{
                    cout<<"D"<<endl;
                }
            }else{
                cout<<"F"<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int x, t;
  cin >> x >> t;
  if(x-t<=0) co(0);
  else co(x-t);
  
  return 0;
}


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

const int MINIMAX = 100;
const int MAX = 10000;
int main() {
	int H, W, N, a[MAX], show[MINIMAX], count = 0, write = 0;
	cin >> H >> W >> N;
	for (int i = 0;i < N;i ++) cin >> a[i];
	for (int i = 1;i < N;i ++) a[i] += a[i - 1]; // aを累積和にする
	for (int i = 0;i < H;i ++) {
		for (int j = 0;j < W;j ++) {
			count ++;
			if (a[write] < count) write ++;
			show[j] = write + 1;
		}
		if (i % 2) {
			for (int j = 0;j < W - 1;j ++) {
				cout << show[j] << " ";
			}
			cout << show[W - 1];
		} else {
			for (int j = W - 1;j > 0;j --) {
				cout << show[j] << " ";
			}
			cout << show[0];
		}
		if (i + 1 < H) cout << endl;
	}
	return 0;
}
// 単に、常に連続になるような書き方を取ればいい。
// 例
// →→→→↓
// ↓←←←←
// →→→→↓
// ↓←←←←
// →→→→→のように

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,K;
LL A[100010];
LL B[100010];
LL C[100010];
int main(){
	cin>>N>>K;
	LL now=0;
	REP(i,N){
		cin>>A[i];
		if(A[i]>0){
			B[i]=A[i];
			now+=B[i];
		}else{
			C[i]=A[i];
		}
	}
	REP(i,N){
		if(i==0){
			continue;
		}
		B[i]=B[i]+B[i-1];
		C[i]=C[i]+C[i-1];
	}
	/*REP(i,N){
		cout<<B[i]<<" ";
	}
	cout<<endl;
	REP(i,N){
		cout<<C[i]<<" ";
	}
	cout<<endl;*/
	LL ans=0;
	REP(i,N){
		int s=i;
		int e=i+K-1;
		if(e>=N)continue;
		LL b=B[e];
		LL c=C[e];
		if(i!=0){
			b-=B[s-1];
			c-=C[s-1];
		}
		//cout<<b<<" "<<c<<" "<<now<<endl;
		//黒
		ans=max(ans,now+c);
		//白
		ans=max(ans,now-b);
	}
	cout<<ans<<endl;
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<ll> acc(N + 1);
    for (int i = 0; i < N; i++) {
        acc[i + 1] = acc[i] + A[i];
    }


    ll ans = 1LL << 60;
    for(int j = 1; j < N; j++) {
        int i1 = lower_bound(all(acc), acc[j] / 2) - acc.begin();
        int k1 = lower_bound(all(acc), acc[j] + (acc[N] - acc[j]) / 2) - acc.begin();

        vector<int> I = {i1};
        vector<int> K = {k1};

        if (i1 - 1 >= 0) {
            I.push_back(i1 - 1);
        }
        if (k1 - 1 > j) {
            K.push_back(k1 - 1);
        }

        for(int u = 0; u < I.size(); u++) {
            for(int v = 0; v < K.size(); v++) {
                int i = I[u], k = K[v];
                vector<ll> area = {
                    acc[i],
                    acc[j] - acc[i],
                    acc[k] - acc[j],
                    acc[N] - acc[k]
                };
                sort(all(area));
                ans = min(ans, area.back() - area[0]);
            }
        }
    }
    cout << ans << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	ll n, k; cin >> n >> k;

	ll r = n % k;
	ll s = abs(n % k - k);

	ll m = min(r, s);
	dunk(min(m, n));
	return 0;
}


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

int main(){
  std::string w;
  std::cin >> w;
  std::map<char, int> mapAlphabet;
  for(int i = 0; i < w.size(); i++){
    if(mapAlphabet.find(w.at(i)) == mapAlphabet.end()) mapAlphabet[w.at(i)] = 1;
    else mapAlphabet[w.at(i)]++;
  }
  int tempValue;
  bool isBeautiful = true;
  for(auto x: mapAlphabet){
    tempValue = x.second;
    if(tempValue % 2 != 0){
      isBeautiful = false;
      break;
    }
  }
  if(isBeautiful) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())

flg = 0
i = 1


while 1:
    if i > 100:
        flg = 1
        break
    if (i*a)%b == c:
        flg == 0
        break
    i+=1

if flg == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

// const long long N = ;
long long n, a, b, v[55], nr1, nr2, sum;

long long choose(long long n, long long k) {
  long long r = 1;
  long long d;
  if (k > n) return 0;
  for (d=1; d <= k; d++) {
    r *= n--;
    r /= d;
  }
  return r;
}


int main() {
	ios_base::sync_with_stdio(false);

	cin >> n >> a >> b;
	for(long long i = 1; i <= n; i++) 
		cin >> v[i];
	sort(v + 1, v + n + 1, greater <long long> ());

	for(long long i = 1; i <= a; i++) {
		sum += v[i];
		nr1 += (v[i] == v[a]);
	}


	for(long long i = a + 1; i <= n ;i++)
		nr2 += (v[i] == v[a]);
	
	if(v[1] == v[a]) {
		long long nrc = 0;
		for(int c = a; c <= b; c++)
			nrc += choose(nr1 + nr2, c);			

		cout << fixed << setprecision(9) << 1. * sum / a << '\n' << nrc << '\n';
		return 0;
	}
	cout << fixed << setprecision(9) << 1. * sum / a << '\n' << choose(nr1 + nr2, nr1) << '\n';

}	

	

Measured memory_bytes: 256
#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;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 


ll ans[55555];
int main()
{

	int n,x,y; cin>>n>>x>>y;
	x--; y--;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int dist=abs(i-j);
			dist=min(dist,abs(i-x)+1+abs(y-j));
			dist=min(dist,abs(i-y)+1+abs(x-j));
			ans[dist]++;
		}
	}
	for(int i=1;i<=n-1;i++)
	{
		cout<<ans[i]<<'\n';
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;


int main(void) {
  ll n;
  scanf("%lld", &n);
  ll res = n*(n-1)/2;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn =new Scanner(System.in);
		int n = scn.nextInt();
		int b = scn.nextInt();
		for(int i=0;i<=1000;i++){
		   if(Math.floor((i*0.08))==n && Math.floor((i*0.1))==b){
			   System.out.println(i);
			   return;
		   }
		}
		System.out.println("-1");
		

	}

}


Measured memory_bytes: 25044
L, R = map(int, input().split())

if R-L >= 2019:
  print(0)
  exit(0)
  
ans = 2019
for i in range(L, R):
  for j in range(i+1, R+1):
    mod = (i*j) % 2019
    if mod < ans:
      ans = mod
      
print(ans)

Measured memory_bytes: 3060
#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>;

int main(){
   int x;
   cin >> x;
   if(x>=30)
      cout << "Yes" << endl;
   else
      cout << "No" << endl;
   return 0;  
}

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

char Capital(char c)
{
	int i = c;

	if(97<=i && i <= 122)
	{
		return i-32;
	}

	return c;
}

int main()
{
	std::string sentence;

	getline(std::cin,sentence);

	for(size_t i=0; i<sentence.length(); ++i)
	{
		std::cout << Capital(sentence[i]);
	}

	std::cout << '\n';
}

Measured memory_bytes: 1168
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 25 23:46:59 2019

@author: over-
"""


S=input()
L=len(S)
if L%2 ==1:
    L-=1
    S=S[:int(L/2)]+S[int(L/2)+1:]

N=int(L/2)
count=0
for i in range(N):
    if S[i]!=S[-i-1]:
        count+=1
        
print(count)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;

int n;
int q, k;
vector<pair<int, long long> > tree[100010];
long long depth[100010];
int x[100010], y[100010];

void dfs(int v, int p, long long d) {
	depth[v] = d;
	for (auto &e : tree[v]) {
		if (e.first == p) {
			continue;
		}
		dfs(e.first, v, d + e.second);
	}
}

int main() {
	cin >> n;
	imfor(i, n - 1) {
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		pair<int, long long> p1 = make_pair(b, c);
		pair<int, long long> p2 = make_pair(a, c);
		tree[a].push_back(p1);
		tree[b].push_back(p2);
	}
	cin >> q >> k;
	k--;
	dfs(k, -1, 0);
	imfor(i, q) {
		cin >> x[i] >> y[i];
		x[i]--;
		y[i]--;
	}
	imfor(i, q) {
		cout << depth[x[i]] + depth[y[i]] << endl;
	}
}

Measured memory_bytes: 15104
N,C  = map(int, input().split())
t_max = 2*10**5
c_imos = [[0]*t_max for t in range(C)]
# 前処理 : 同一チャンネルのときはくっつけられる
c_imos = [[0]*t_max for t in range(C)]

for i in range(N):
    s,t,c = map(int, input().split())
    c -= 1
    s -= 1
    # t -= 1
    c_imos[c][s] += 1
    c_imos[c][t] -= 1
    
ans = [0] * t_max
from itertools import accumulate
for c_ in c_imos:
    acc = list(accumulate(c_))
    ans = [a+min(1,b) for a,b in zip(ans,acc)]
print(max(ans))


Measured memory_bytes: 96884
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> s(M);
    rep(i, M) {
        int k;
        cin >> k;
        rep(j, k) {
            int _s;
            cin >> _s;
            s[i] |= 1 << (_s - 1);
        }
    }
    vector<int> p(M);
    rep(i, M) cin >> p[i];

    int ans = 0;
    for (int bit = 0; bit < (1 << N); ++bit) {
        bool allOn = true;
        rep(i, M) {
            int a = bit & s[i];
            int parity = 0;
            rep(j, N) parity ^= (a >> j) & 1;
            if (parity != p[i]) allOn = false;
        }
        if (allOn) ans++;
    }
    write(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	lint X, Y;
	cin >> X >> Y;
	int cnt = 0;
	while (X <= Y) {
		X *= 2;
		cnt++;
	}
	cout << cnt << endl;
}




Measured memory_bytes: 256