akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = 1e9+7;

ll pow(int x, int n) //x^n
{
	if (n == 0) return ll(1);
	if (n == 1) return ll(x);
	if (n % 2 == 1)
	{
		return x * pow(x,n-1) % MOD;
	}
	else
	{
		ll p = pow(x,n/2);
		return p * p % MOD;
	}
}

int main()
{
	string L;
	cin >> L;
	int N = L.size();
	ll ans = 0;
	int cnt = 0;
	rep(i,N)
	{
		if (L[i] == '1')
		{
			ans = (ans + pow(3,N-i-1) * pow(2,cnt)) % MOD;
			cnt++;
		}
	}
	ans = (ans + pow(2,cnt)) % MOD;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define sz(x) (int)(x.size())
#define fr(i, a, b) for(int i=a;i<b;++i)
#define fdr(i, a, b) for(int i=b-1;i>=a;--i)
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

string F = "Fennec";
string S = "Snuke";

int const N = 2e5 + 41; 
vector<int> e[N];
int par0[N], par1[N];
int col[N];
int n;

void dfs0(int u, int p, int par[N]){
	par[u] = p;
	fr(i, 0, sz(e[u])){
		int to = e[u][i];
		if(to == p) continue;
		dfs0(to, u, par);
	}
}

void dfs1(int u, int p, int color){
	col[u] = color;
	fr(i, 0, sz(e[u])){
		int to = e[u][i];
		if(to == p) continue;
		if(col[to] != 0 && col[to] != col[u]) continue;
		dfs1(to, u, color);
	}
}

void solve(){
	cin >> n;
	fr(i, 0, n-1){
		int u, v;
		cin >> u >> v;
		--u;--v;
		e[u].pb(v);
		e[v].pb(u);
	}

	dfs0(0, -1, par0);
	dfs0(n-1, -1, par1);
	col[0] = 1;
	col[n-1] = 2;

	int v1 = 0;
	int v2 = n-1;
	int move = 1;
	while(true){
		if(move){
			v1 = par1[v1];
			if(v1 == v2) break;
			col[v1] = 1;
		}else{
			v2 = par0[v2];
			if(v1 == v2) break;
			col[v2] = 2;
		}
		move ^= 1;
	}

	dfs1(0, -1, 1);
	dfs1(n-1, -1, 2);
	int b = 0;
	fr(i, 0, n){ 
		if(col[i] == 1) ++b;
		else --b;
		assert(col[i] != 0);
	}
	if(b > 0) cout << F;
	else cout << S;
	cout << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();


	return 0;
}

Measured memory_bytes: 17408
#include<stdio.h>
int main(void){
	int n,i,a,max=1,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(max<a){max=a;}
		sum+=a;
	}
	printf(2*max<sum?"Yes":"No");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpii vector<pii>
#define P pair<ll, ll>
#define V vector<ll>
#define C vector<char>
#define vpiii vector<piii>
#define vpll vector<pll>
#define vplll vector<plll>
#define mod 1000000007
#define rep(i, s, n) for (ll i = (ll)(s); i < (ll)(n); i++)
ll maax=1000001;
ll p[10000001];

 ll dp[200000];

int inv(ll x,ll y)
{
	//ll y=mod-2;
	unsigned int res=1;
	while(y>0)
	{
		if(y&1)
			res=(res*x)%mod;
		y=y>>1;
		x=(x*x)%mod;
	}
	return res;
}
void seive()
{
	p[0]=1;
	p[1]=1;
	for(int i=2;i<maax;i++)
	{
		if(p[i]==0)
		{
			for(int j=2*i;j<maax;j+=i)
			{
				if(p[j]==0)
					p[j]=i;
	
			}
			p[i]=i;
		}
	}
}
ll md(ll a){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}
int main()
{
	 ll h,w,ans=0;
    cin>>h>>w;
    vector<vector<char>>t(h+2,vector<char>(w+2));
    rep(i,1,h+1){
        rep(j,1,w+1){
            cin>>t[i][j];
        }
    }
 
    rep(sy,1,h+1){
        rep(sx,1,w+1){
            vector<vector<ll>>d(h+2,vector<ll>(w+2,-1));
            queue<pair<ll,ll>>que;
            que.push({sy,sx});
            d[sy][sx]=0;
            while(!que.empty()){
                P p=que.front();
                ll i=p.first,j=p.second;
                que.pop();
                if(t[i][j]=='.'){
                    if(t[i][j]==t[i+1][j]&&d[i+1][j]==-1){
                        d[i+1][j]=d[i][j]+1;
                        que.push({i+1,j});
                    }
                    if(t[i][j]==t[i][j+1]&&d[i][j+1]==-1){
                        d[i][j+1]=d[i][j]+1;
                        que.push({i,j+1});
                    }
                    if(t[i][j]==t[i][j-1]&&d[i][j-1]==-1){
                        d[i][j-1]=d[i][j]+1;
                        que.push({i,j-1});
                    }
                    if(t[i][j]==t[i-1][j]&&d[i-1][j]==-1){
                        d[i-1][j]=d[i][j]+1;
                        que.push({i-1,j});
                    }
                }
                if(d[i][j]!=-1){
                    ans=max(ans,d[i][j]);
                }
            }
        }
    }
    cout<<ans<<endl;
		


}


Measured memory_bytes: 256
/*
Original problem: 
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

const ll mod = 1e9+7;

namespace SOLVE {
    void main() {
		ll n;
        cin >> n;
		cout << 3 * n * n << endl;
    }
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

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

#define SIZE 200010

int main() {
    int n;
    int a[SIZE], left[SIZE], right[SIZE];
    std::cin >> n;
    for (int i=0; i<n; ++i) std::cin >> a[i];
    left[0] = a[0]; right[n-1] = a[n-1];
    // left[i]  : a[0], a[1], .., a[i]で最大のもの
    // right[i] : a[i], a[i+2], .., a[n-1]で最大のもの
    for (int i=1; i<n; ++i) left[i] = std::max(left[i-1], a[i]);
    for (int i=n-2; i>=0; --i) right[i] = std::max(right[i+1], a[i]);

    std::cout << right[1] << '\n';
    for (int i=1; i<n-1; ++i) std::cout << std::max(left[i-1], right[i+1]) << '\n';
    std::cout << left[n-2] << '\n';

    return 0;
}



Measured memory_bytes: 3968
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

typedef long long ll; //64bit型
using namespace std;
const ll INF = 1LL << 20;

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

int main()
{
        int A, B, C, D, E;
        cin >> A >> B >> C >> D >> E;
        vector<int> Time = {A, B, C, D, E};
        vector<int> index = {0, 1, 2, 3, 4};

        vector<int> nextTime(5);

        for (int i = 0; i < 5; i++)
        {
                if (Time[i] % 10 == 0)
                        nextTime[i] = Time[i];

                nextTime[i] = (Time[i] + 10 - 1) / 10 * 10;
        }

        int ans = (int)1e9;
        do
        {
                int res = 0;

                for (int i = 0; i < 5; i++)
                {
                        while (res % 10 != 0)
                                res++;
                        res += Time[index[i]];
                }
                ans = min(ans, res);

        } while (next_permutation(index.begin(), index.end()));

        cout << ans << endl;

        return 0;
}


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

int main()
{
    int N;
    cin >> N;
    long long dp[100000];
    long long  h[100000];
    for(int i = 0;i < N; ++i)
    {
        cin >> h[i];
        dp[i] = 10000000000;
    }
    dp[0] = 0;
    for(int i = 0; i < N; ++i)
    {
        dp[i + 1] = min(dp[i + 1],dp[i] + abs(h[i + 1] - h[i]));
        dp[i + 2] = min(dp[i + 2],dp[i] + abs(h[i + 2] - h[i]));
    }

    cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

int main(void){
	double x1, x2, y1, y2;
	double sub1, sub2;
	double pow1, pow2;
	double distance;
	
	scanf("%lf %lf %lf %lf", &x1, &x2, &y1, &y2);
	
	sub1 = x1 - y1;
	sub2 = x2 - y2;

	pow1 = pow(sub1, 2);
	pow2 = pow(sub2, 2);
	
	distance = sqrt(pow1 + pow2);
	
	printf("%f\n", distance);
	
	return 0;
}

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

int N;
int s[128];
int sum = 0;

int input(){
	sum = 0;
	std::cin >> N;
	for( int i = 0; i < N; i++ ){
		std::cin >> s[i];
		sum += s[i];
	}
	return 0;
}

int run(){
	if( sum % 10 != 0 ){
		std::cout << sum << std::endl;
		return 0;
	}
	std::sort(&s[0], &s[N]);
	for( int i = 0; i < N; i++ ){
		if( (sum-s[i]) % 10 != 0 ){
			sum -= s[i];
			break;
		}
	}
	if( sum % 10 == 0 ){
		std::cout << 0 << std::endl;
	}else{
		std::cout << sum << std::endl;
	}
	return 0;
}

int main(){
	input();
	run();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,sum=0;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>arr[i],sum+=arr[i];
    int q;
    cin>>q;
    while(q--){
        int a,b;
        cin>>a>>b;
        a--;
        sum-=arr[a];
        sum+=b;
        cout<<sum<<endl;
        sum-=b;
        sum+=arr[a];
    }


    return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

// ABC094 at 2018/04/14

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solveA();
    }

    private void solveA() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int X = sc.nextInt();
        if ((X - A) < 0) {
            System.out.println("NO");
        } else if (B < (X - A)) {
            System.out.println("NO");
        } else if ((A + B) < X) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }
    }

    private void solveB() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveC() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveD() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveE() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveF() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

}

Measured memory_bytes: 21076
S = input()

first = S[:2]
second = S[2:]

cond1 = 1 <= int(first) <= 12
cond2 = 1 <= int(second) <= 12

if cond1 and cond2:
    ans = 'AMBIGUOUS'
elif cond1:
    ans = 'MMYY'
elif cond2:
    ans = 'YYMM'
else:
    ans = 'NA'
print(ans)

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

int main(){
  int x;
  cin >> x;
  if(x == 1){
    cout << 1 << endl;
    return 0;
  }
  int res = 0;
  for(int i = 2 ; i <= x ; i++){
    int j = i*i;
    while(j * i <= x){
      j *= i;
    }
    if(j <= x){
      res = max(res, j);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)

#include<iostream>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_map>
#include<fstream>
#include<iomanip>
#include<string>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<sstream>
#include<cstdio>
#include<ctime>
#include<cstdlib>
#include <assert.h>
#define pb push_back
#define INF 0x3F3F3F3F //int 下较大值
#define inf 0x3F3F3F3F3F3F3F3F  // ll 下较大值 
#define moD 1000000003
#define pii pair<ll,ll>
#define eps 1e-10
#define equals(a,b) (fabs(a-b)<eps)
#define bug puts("bug")
#define re  register
#define fi first
#define se second
typedef  long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll Mod = 998244352;
const int maxn = 2e6 + 10;
const double Inf = 10000.0;
const double PI = acos(-1.0);
using namespace std;


int bitcount(int x) {
    return x == 0 ? 0 : bitcount(x / 2) + (x & 1);
}


ll mul(ll a, ll b, ll m) {
    ll res = 0;
    while (b) {
        if (b & 1) res = (res + a) % m;
        a = (a + a) % m;
        b >>= 1;
    }
    return res % m;
}

ll quickPower(ll a, ll b, ll m) {
    ll base = a;
    ll ans = 1ll;
    while (b) {
        if (b & 1) ans = mul(ans, base, m);
        base = mul(base, base, m);
        b >>= 1;
    }
    return ans;
}

ll ksm(ll a, ll b, ll m) {
    ll base = a % m;
    ll ans = 1ll;
    while (b) {
        if (b & 1) ans *= base, ans %= m;
        base *= base, base %= m;
        b >>= 1;
    }
    return ans;
}



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

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

int readint() {
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}

ll readll() {
    ll x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}

ull readull() {
    ull x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}

void Put(ll x) {
    if (x < 0) putchar('-'), x *= -1;
    if (x > 9) Put(x / 10);
    putchar(x % 10 + '0');
}

double a[1005], b[1005];
double c[1005];

int n;
int k;

inline bool cmp(double a, double b) {
    return a > b;
}

bool check(double mid) {
    double sum = 0;
    for (int i = 1; i <= n; i++) c[i] = a[i] - mid * b[i];
    sort(c + 1, c + n + 1,cmp);
    for (int i = 1; i <= n - k ; i++) sum += c[i];
    return sum >= 0;
}

int main() {
    int x = readint();
    if (x) puts("0");
    else puts("1");
}


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

int main(){
  char ch;
  int count[26] = {0};
  int i;

  while(cin >> ch){
    if(isalpha(ch) != 0){
      count[tolower(ch) - 'a']++;
    }
  }
  for(i = 0; i < 26; i++){
    cout << (char)(i + 'a') << " : " << count[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1140
N = int(input())
S = list(map(int, input().split()))

data = [0]*(N+1)
for num in S:
    data[num] += 1

ans = 0
for num in data:
    if num < 2:
        continue
    ans += num*(num-1)//2

for num in S:
    if data[num] < 2:
        print(ans)
    else:
        print(ans-data[num]+1)


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

using namespace std;

#define str to_string
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()

#define MAX_N 101


int N;
int table[MAX_N];
long long memo[MAX_N][21][2];

long long dfs(int offset, long long val, bool plus) {
  if (memo[offset][val][plus?1:0] != -1) return memo[offset][val][plus?1:0];
  int v = val;
  if (plus) v += table[offset];
  else      v -= table[offset];
  if (v < 0 || v > 20) return 0;
  // end-
  if (offset == N-1) {
    if (v == table[N]) return 1;
    else return 0;
  }

  return memo[offset][val][plus?1:0] = dfs(offset+1, v, true) + dfs(offset+1, v, false);
}

int main() {
  cin >> N;
  rep(i, N) {
    cin >> table[i];
  }

  rep(i, MAX_N) rep(j, 21) rep(k, 2) memo[i][j][k] = -1;
  auto answer = dfs(1, table[0], true) + dfs(1, table[0], false);
  cout << answer << '\n';
  return 0;
}

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

using namespace std;

int n, m, x, y;
vector<int> Rank(100001, 0);
vector<int> parent(100001, 0);

int find(int x);
bool isSame(int x, int y);
void unite(int x, int y);


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

    vector<int> p(n+1, 0);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &p[i]);
    }
    
    for (int i = 1; i <= n; i++ ) {
        Rank[i] = 0;
        parent[i] = i;
    }

    for (int i = 0; i < m; i++) {
        scanf("%d %d", &x, &y);
        
        if (!isSame(x, y)) 
            unite(x, y);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (isSame(i, p[i]))
                ans++;
    }

    cout << ans << '\n';


}


int find(int x) {
    if (x == parent[x]) return x;
    else {
        return parent[x] = find(parent[x]);
    }
}

bool isSame(int x, int y) {
    return find(x) == find(y);
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) return;

    if (Rank[x] < Rank[y]) {
        parent[x] = y;
    } 
    else {
        parent[y] = x;
        if (Rank[x] == Rank[y]) 
            Rank[x]++;
    }
}


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

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

    double x = floor(n / 2.0);

    double prob = 0;
    if (n % 2 == 0)
    {
        prob = 0.5;
    }
    else
    {
        prob = (x + 1) / n;
    }

    cout << prob << endl;

    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        k: usize,
        q: usize,
        ds: [usize; k],
        qs: [(usize, usize, usize); q]
    }
    for &(n, x, m) in &qs {
        let mut dac = vec![0; k + 1];
        for i in 0..k {
            dac[i + 1] = dac[i] + ds[i] % m;
        }
        let mut nps = vec![0; k + 1];
        for i in 0..k {
            nps[i + 1] = nps[i] + if ds[i] % m > 0 {1} else {0};
        }
        let x = x % m;
        let c = dac[k] / m;
        let r = dac[k] % m;
        let a = (n - 1) / k;
        let b = (n - 1) % k;
        println!("{}", nps[k] * a + nps[b] - (c * a + (x + r * a + dac[b]) / m));
    }
}


Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int a[10];

bool check(int x) {
	while (x) {
		int tmp = x % 10;
		if (a[tmp] == 1) return false;
		x /= 10;
	}
	return true;
}

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < k; ++i) {
		int x;
		scanf("%d", &x);
		a[x] = 1;
	}
	while (1) {
		if (check(n)) {
			printf("%d\n", n);
			break;
		}
		++n;
	}
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d = new int[n];
        for (int i = 0; i < d.length; i++)
            d[i] = sc.nextInt();
        Arrays.sort(d);
        int count = d[n / 2] - d[n / 2 - 1];
        System.out.println(count);
    }
}


Measured memory_bytes: 50892
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

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


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

	int n;
	vd x(3), y(3);
	double a1, a2, b1, b2, c1, c2;
	double px, py, r;

	cin >> n;

	for (; n > 0; n--){
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2];

		a1 = 2 * (x[1] - x[0]);
		b1 = 2 * (y[1] - y[0]);
		c1 = x[0] * x[0] - x[1] * x[1] + y[0] * y[0] - y[1] * y[1];

		a2 = 2 * (x[2] - x[0]);
		b2 = 2 * (y[2] - y[0]);
		c2 = x[0] * x[0] - x[2] * x[2] + y[0] * y[0] - y[2] * y[2];

		px = (b1*c2 - b2*c1) / (a1*b2 - a2*b1);
		py = (c1*a2 - c2*a1) / (a1*b2 - a2*b1);
		r = sqrt((px - x[0])*(px - x[0]) + (py - y[0])*(py - y[0]));

		printf("%.3lf %.3lf %.3lf\n", px, py, r);
	}

}

Measured memory_bytes: 1268
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end
a,b = inps
puts ((a == "H")^(b =="H"))? "D" : "H"

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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N;
    cin >> N;
    vector<string> list(N);
    for (int i = 0; i < N; i++)
        cin >> list[i];
    bool x = true;
    for (int i = 1; i < N; i++)
        if (list[i - 1][list[i - 1].size() - 1] != list[i][0])
            x = false;
    sort(list.begin(), list.end());
    for (int i = 1; i < N; i++)
        if (list[i - 1] == list[i])
            x = false;
    cout << (x ? "Yes" : "No");
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] num = new int[N][3];
		int[][] flag = new int[N][3];
		int[] point = new int[N];
		for(int i=0;i<flag.length;i++)Arrays.fill(flag[i], -1);
		Arrays.fill(point, 0);
		for(int i=0;i<N;i++){
			for(int j=0;j<3;j++){
				num[i][j] = sc.nextInt();
			}
		}
		
		for(int i=0;i<3;i++){		//ラウンド数
			for(int j=0;j<N;j++){
				if(flag[j][i]!=-1)continue;//既にどこかと同じであったらcontinue
				for(int k=0;k<N;k++){//自分自身と同じ数字を全員から探索
					if(num[j][i]==num[k][i]&&j!=k){//もし同じ数字（ただし自分以外)だったらフラグを立てる
						flag[j][i] = 1;
						flag[k][i] = 1;
					}
				}
			}
		}
		for(int i=0;i<N;i++){
			for(int j=0;j<3;j++){
				if(flag[i][j]!=1){
					point[i] += num[i][j];
				}
			}
		}
		for(int i=0;i<N;i++){
			System.out.println(point[i]);
		}
		
	}

}

Measured memory_bytes: 21020
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

class UnionFind {
private:
	vector<int> data;
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }

public:
	UnionFind(int size) : data(size, -1) { }
	bool is_same(int x, int y) { return root(x) == root(y); }
	lint size(int x) { return -data[root(x)]; }

	void unify(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
};

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	lint N, M;
	cin >> N >> M;
	
	vector<pair<int, int>> bridge(M);
	for (int i = 0; i < M; i++) cin >> bridge[i].first >> bridge[i].second;

	vector<lint> ans(M);
	lint unconf = N * (N - 1) / 2, tmp;
	UnionFind land(N);
	for (int i = M - 1; i >= 0; i--) {

		ans[i] = unconf;
		tmp = land.size(bridge[i].first - 1) * land.size(bridge[i].second - 1);
		land.unify(bridge[i].first - 1, bridge[i].second - 1);
		
		// unify前後でtmpの大きさが変化していなかったら既に同根である島をつないだだけなので引かない
		unconf -= tmp == land.size(bridge[i].first - 1) * land.size(bridge[i].second - 1) ? 0 : tmp;

	}

	for (const auto &elem : ans) cout << elem << "\n";

	return 0;
}

Measured memory_bytes: 3328
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())

if m1 == 12:
    if m2 == 1:
        print(1)
        exit()

if m1 + 1 == m2:
    print(1)
    exit()
else:
    print(0)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;


int main(){
    vec t(2),a(2), b(2);
    rep(i,2) cin>>t[i];
    rep(i,2) cin>>a[i];
    rep(i,2) cin>>b[i];
    ll p = 0;
    p += t[0]*a[0] + t[1]*a[1];
    p -= t[0]*b[0] + t[1]*b[1];
    if(p == 0){
        cout<<"infinity"<<endl;
        return 0;
    }
    if(p < 0){
        swap(a,b);
        p = -p;
    }
    ll q = t[0]*b[0] - t[0]*a[0];
    if(q < 0){
        cout<<0<<endl;
        return 0;
    }
    if(q%p == 0){
        cout<<q/p * 2<<endl;
    }else{
        cout<<q/p * 2 + 1<<endl;
    }
}

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

int main(){
  int N;
  cin >> N;
  vector<int> t(N+1,0);
  vector<int> x(N+1,0);
  vector<int> y(N+1,0);
  
  for(int i=1; i<N+1; i++){
    cin >> t[i] >> x[i] >> y[i];
  }
  
  bool reachable = true;
  for(int i=0; i<N; i++){
    int time  = t[i+1] - t[i];
    int xdist = abs(x[i+1] - x[i]);
    int ydist = abs(y[i+1] - y[i]);
    int dist  = xdist + ydist;
    if(dist > time || (dist % 2) != (time % 2)){
      reachable = false;
      break;
    } 
  }

  if(reachable){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 1408
n=gets.to_i
10**n-9**n*2+8**n
a10=1
a9=1
a8=1
mod=1000000007
n.times do
  a10=a10*10%mod
  a9=a9*9%mod
  a8=a8*8%mod
end
puts (a10-2*a9+a8)%mod


Measured memory_bytes: 21408
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb emplace_back
typedef pair<int,int> pi;
#define int ll

int n, a[300005], ans=-1e18, l[300005], r[300005];
priority_queue<int> pq2;
priority_queue<int,vector<int>,greater<int> > pq1;

int32_t main() {
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n * 3; ++i) cin >> a[i];
	int sum1 = 0, sum2 = 0;
	for (int i = 0; i < n * 3; ++i) {
		if (pq1.size() < n) {pq1.emplace(a[i]); sum1 += a[i];}
		else if (pq1.top() <= a[i]) {
				sum1 -= pq1.top();
				sum1 += a[i];
				pq1.pop();
				pq1.emplace(a[i]);
		}
		l[i] = sum1;
	}
	for (int i = n * 3 - 1; i >= 0; --i) {
		if (pq2.size() < n) {pq2.emplace(a[i]); sum2 += a[i];}
		else if (pq2.top() >= a[i]) {
			sum2 -= pq2.top();
			sum2 += a[i];
			pq2.pop();
			pq2.emplace(a[i]);
		}
		r[i] = sum2;
	}
	// for (int i = 0; i < n * 3; ++i) {
	// 	cout << l[i] << ' ';
	// }
	// cout << '\n';
	// for (int i = 0; i < n * 3; ++i) {
	// 	cout << r[i] << ' ';
	// }
	for (int i = n - 1; i < n * 2; ++i) {
		ans = max(ans, l[i] - r[i+1]);
	}
	cout << ans;
	return 0;
}
/*
10 50 1
*/


Measured memory_bytes: 11800
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for(int i = (s); i < (e); i++)
#define FOE(i,s,e) for(int i = (s); i <= (e); i++)
#define FOD(i,s,e) for(int i = (s); i >= (e); i--)
#define ll long long
#define pb push_back
#define mp make_pair

int n, m, x, y, z, k, w;
ll high, low, mid, tmp, a, b;
int A[100005];

int main ()
{
	scanf("%d", &n);
	FOR(i, 0, n) scanf("%d", &A[i]);
	
	high = 100000000000000ll;
	low = 0ll;
	
	while (high - low > 1ll)
	{
		mid = (high + low) / 2;
		tmp = mid;
		FOR(i, 0, n) tmp = tmp - tmp % A[i];
		if (tmp > 2) high = mid;
		else low = mid; 
	}
	
	b = low;
	
	high = 100000000000000ll;
	low = 0ll;
	
	while (high - low > 1ll)
	{
		mid = (high + low) / 2;
		tmp = mid;
		FOR(i, 0, n) tmp = tmp - tmp % A[i];
		if (tmp < 2) low = mid;
		else high = mid; 
	}
	
	a = high;
	
	tmp = a;
	FOR(i, 0, n) tmp = tmp - tmp % A[i];
	
	if (tmp != 2) printf("-1\n"); else printf("%lld %lld\n", a, b);
	return 0;
}
	
	
	

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

using namespace std;

const int INF = 1 << 29;
const int MAX_N = 16;

int d[1 << MAX_N];
int e[MAX_N][MAX_N+1];

int main ( void )
{
	int n;
	while (cin >> n, n) {
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n+1; ++j) {
				cin >> e[i][j];
			}
		}
		fill(d, d+(1 << n), INF);
		d[0] = 0;
		for (int state = 0, I = 1 << n; state < I; ++state) {
			for (int i = 0; i < n; ++i) {
				if (state & (1 << i)) { continue; }
				int next = state | (1 << i);
				d[next] = min(d[next], d[state] + e[i][0]);
				for (int j = 0; j < n; ++j) {
					if (state & (1 << j)) {
						d[next] = min(d[next], d[state] + e[i][j+1]);
					}
				}
			}
		}
		cout << d[(1 << n) - 1] << endl;
	}
	return 0;
}

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

vector<int> arr[100005];
vector<int> visited(100005,0);

void dfs(int i)
{
    visited[i]++;
    for(auto j:arr[i])
    {
        if(!visited[j])
        {
            dfs(j);
        }
    }
}
void solve()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        arr[a].push_back(b);
        arr[b].push_back(a);
    }
    int comp = 0;
    for(int i=1;i<=n;i++)
    {
        if(!visited[i])
        {
            comp++;
            dfs(i);
        }
    }
    cout<<comp-1<<endl;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll t;
    solve();
}





Measured memory_bytes: 9584
def solve():
  N, K = [int(i) for i in input().split()]
  h = [int(i) for i in input().split()]

  minimumCost = [0] * N

  for currentIndex in range(1, N):
    minimumCost[currentIndex] = min(minimumCost[previousIndex] + abs(h[currentIndex] - h[previousIndex]) for previousIndex in range(max(currentIndex - K, 0), currentIndex))

  print(minimumCost[N - 1])

solve()


Measured memory_bytes: 13928
s = input()
t = input()
#print(s, t)
ans = "No"
c = len(s)
for i in range(c):
  for j in range(c):
    si = s[(j+i)%c:(j+i)%c+1]
    tj = t[j:j+1]
    #print(i, j, si, tj)
    if si != tj:
      break
  else:
    ans = "Yes"
    break
    
print(ans)    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(12)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
//#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
ll MOD=1000000007;
 
ll gcd(ll a,ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
/*ll ncr(ll n,ll r)
{
	if(n==1 || r==0)
	return 1;
	if(r>n/2)
	r=n-r;
	ll ans=1;
	for(ll i=1;i<=r;i++)
	{
		ans=((ans * n )/i);
		n--;
	}
	return ans;
}*/
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow(ll a,ll b,ll m)
{
	ll ans=1;
	while(b>0)
	{
		if(b&1)
			ans=(ans*a)%m;
		b=b/2;
		a=(a*a)%m;
	}
	return ans;
}
 
ll modinv(ll k)
{
	return pow(k,MOD-2,MOD);
}

ll ncr(ll n,ll c)
{
    ll t=1;
    c=min(c,n-c);
    for(ll i=1;i<=c;i++)
    {
     	t=(t*(n-i+1))%MOD;
        t=(t*modinv(i))%MOD;
	}
    return t;
}
int main()
{
	string s;
	cin>>s;
	ll x=0,y=0;
	for(ll i=0;i<3;i++)
	{
		if(s[i]=='A')
		x++;
		else
		y++;
	}
	if(x==3 || y==3)
	cout<<"No";
	else
	cout<<"Yes";
}

Measured memory_bytes: 256
# 9 6 0 9500000000
require 'pp'
class PriorityQueue
  attr_reader :data
  def initialize(array = [])
    @data = []
    array.each{|a| add(a)}
  end

  def add(element)
    @data.push(element)
    bottom_up
  end

  # @return Integer
  def peek
    @data[0]
  end

  # @return Integer
  def poll
    if size == 0
      return nil
    elsif size == 1
      return @data.pop
    else
      min = @data[0]
      @data[0] = @data.pop
      top_down
      return min
    end
  end

  # @return Integer
  def size
    @data.size
  end

  private

  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end


  def bottom_up
    idx = size - 1
    while(has_parent?(idx))
      parent_idx = parent_idx(idx)
      if @data[parent_idx] < @data[idx]
        swap(parent_idx, idx)
        idx = parent_idx
      else
        return
      end
    end
  end

  def top_down
    idx = 0
    while (has_child?(idx))
      a = left_child_idx(idx)
      b = right_child_idx(idx)
      if @data[b].nil?
        c = a
      else
        c = @data[a] >= @data[b] ? a : b
      end
      if @data[idx] < @data[c]
        swap(idx, c)
        idx = c
      else
        return
      end
    end
  end


  # @param Integer
  # @return Integer
  def parent_idx(idx)
    (idx - (idx.even? ? 2 : 1)) / 2
  end

  # @param Integer
  # @return Integer
  def left_child_idx(idx)
    (idx * 2) + 1
  end

  # @param Integer
  # @return Integer
  def right_child_idx(idx)
    (idx * 2) + 2
  end

  # @param Integer
  # @return Boolent
  def has_child?(idx)
    ((idx * 2) + 1) < @data.size
  end

  def has_parent?(idx)
    idx > 0
  end
end
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
# pp a

pq = PriorityQueue.new
a.each do |aa|
  pq.add aa
end
# pp pq
m.times do |i|
  poped = pq.poll
  pq.add (poped / 2.0).floor
end

p pq.data.inject(:+)


Measured memory_bytes: 14328
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,m = inm()
s = input().strip()
seq = [n]
p = n
while p>0:
    ddprint("p {}".format(p))
    p0 = p
    for i in range(max(0,p-m),p):
        if s[i]=='0':
            ddprint("add {}".format(i))
            seq.append(i)
            p = i
            break
    if p==p0:
        print(-1)
        exit()
seq.reverse()
for i in range(len(seq)-1):
    printn(str(seq[i+1]-seq[i])+' ')
print('')


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	multiset<ll> arr;
	F0R(i, N) {
		ll x; cin >> x; arr.insert(x);
	}

	int ans = 0;
	ll left_over = 0;
	for (int bit = 40; bit >= 0; --bit) {
		int parity = (left_over & (1LL << bit)) > 0;
		ll remove = -1;
		for (ll x : arr) {
			ll rem = (x % (1LL << (bit + 1)));
			if (rem == (1LL << bit)) remove = x;
			parity ^= rem >= (1LL << bit);
		}
		if (parity == 1) {
			if (remove == -1) {
				print(-1); return 0;
			}
			arr.erase(arr.find(remove));
			left_over ^= (remove - 1);
			++ans;
		}
	}
	print(ans);
}

Measured memory_bytes: 8324
#D-Face Produces Unhappiness
N, K = map(int, input().split())
S = str(input())

def count_LRorRL(l):
    ans = 0
    l_index = [l[i]+l[i+1] for i in range(0,N-1)]
    ans += l_index.count('LR')
    ans += l_index.count('RL')
    return ans

def count_LLorRR(l):
    ans = 0
    l_index = [l[i]+l[i+1] for i in range(0,N-1)]
    ans += l_index.count('LL')
    ans += l_index.count('RR')
    return ans
  
if count_LRorRL(S) > 2*K:
    print(count_LLorRR(S)+2*K)
else:
    print(count_LLorRR(S)+count_LRorRL(S))


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

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

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

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  int num = g*10+b;
  if(num % 4 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

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

int main(){
	int a;
	char in[100];
	scanf("%d",&a);
	scanf("%s",in);

	if(a%2==1){
		printf("No");
	}else{
		int temp = a/2;
		bool out = true;
		for(int i=0;i<temp;i++){
			if(in[i]!=in[i+temp]){
				out = false;
			}
		}
		if(out == true){
			printf("Yes");
		}else{
			printf("No");
		}
	}

	return 0;
}

Measured memory_bytes: 128
N = int(input())

lst_S = []
for i in range(N):
    lst_S.append(input().split())
    lst_S[i][0] = int(lst_S[i][0])
    lst_S[i][1] = int(lst_S[i][1])

bote_A = lst_S[0][0]
bote_B = lst_S[0][1]

for i in range(1, N):
    bai_A = (bote_A - 1) // lst_S[i][0]
    bai_B = (bote_B - 1) // lst_S[i][1]

    bai = max(bai_A, bai_B) + 1

    bote_A = lst_S[i][0] * bai
    bote_B = lst_S[i][1] * bai

ans = bote_A + bote_B

print(ans)

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

using namespace std;
using ll = long long;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 998244353

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N;
int M;

bool conn[777][777];

void init()
{
	cin >> N >> M;
	rep(i, 777) rep(j, 777) conn[i][j] = i != j;
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		a--;b--;
		conn[a][b] = conn[b][a] = false;
	}
}

int color[777];

pair<int, int> dfs(int city, int col)
{
	if (color[city]) {
		if (color[city] == col) {
			return MP(0, 0);
		} else {
			cout << -1 << endl;
			exit(0);
		}
	}
	color[city] = col;
	pair<int, int> res;
	if (col == 1) res.first++;
	else res.second++;
	rep(i, N) {
		if (conn[city][i]) {
			auto t = dfs(i, 3 - col);
			res.first += t.first;
			res.second += t.second;
		}
	}
	return res;
}

void solve()
{
	vector<pair<int, int>> v;
	rep(i, N) {
		if (color[i] == 0) {
			auto t = dfs(i, 1);
			if (t.first > t.second) swap(t.first, t.second);
			v.PB(t);
		}
	}
	sort(all(v), [](auto a, auto b) {return (a.first - a.second) < (b.first - b.second);});
	int x = 0, y = 0;
	for (auto i : v) {
		if (x < y) {
			x += i.second;
			y += i.first;
		} else {
			x += i.first;
			y += i.second;
		}
	}
	cout << x * (x - 1) / 2 + y * (y - 1) / 2 << endl;
}


Measured memory_bytes: 896
#include <cstdio>
#include <algorithm>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using usize = std::size_t;

i32 main() {
	i32 k;
	char s[101];
	scanf("%d%s", &k, s);
	for (i32 i = 0; s[i]; ++i) {
		if (i >= k) {
			printf("...");
			break;
		}
		putchar(s[i]);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 1656
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())



void init() {

}

void input() {

}

void solve() {
   LL a;
   cin >> a;
   LL res = 1000;
   while(a >= 100) {
     chmin(res, abs(753LL - a%1000));
     a /= 10;
   }
   cout << res << endl;
}

int main() {
	init();
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N, x;
  cin >> N;
  x = 0;
  
  for(int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    
    x += r-l+1;
    
  }
  
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod =  1000000007;
//const ll maxn = 1000000000;
// const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
  ll l,r,ans=10000;
  cin>>l>>r;
  if(r-l>=2019)cout<<0<<endl;
  else{
  int mini=min(l%2019,r%2019);
  int maxi=max(l%2019,r%2019);
  
  for(ll i =mini;i<maxi;i++){
              for(ll j=i+1;j<=maxi;j++){
                  ll mod2019=i*j%2019;
                  ans=min(ans,mod2019);
              }
  }
  
  cout<<ans<<endl;
  }
}
   



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

int n, k;
bool v[15];

bool f(int p) {
	for (; p; p /= 10) if (v[p % 10]) return 0;
	return 1;
}

int main()
{
	int t;
	cin >> n >> k;
	while (k--) scanf("%d", &t), v[t] = 1;
	for (; ; n++) if (f(n)) return !printf("%d", n);
	return 0;
}

Measured memory_bytes: 256