akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    ll P = T1 * (A1 - B1), Q = T2 * (A2 - B2);
    if (P < 0)
    {
        P *= -1;
        Q *= -1;
    }
    if ((P + Q) < 0)
    {
        ll syo = (-P) / (P + Q);
        if ((-P) % (P + Q) == 0)
        {
            putout(syo * 2);
        }
        else
            putout(syo * 2 + 1);
    }
    if ((P + Q) == 0)
        putout("infinity");
    if ((P + Q) > 0)
        putout(0);
    return 0;
}


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

int main(){
  while(1){
    int n,m;
    cin >> n >> m;
    if(n==0&&m==0)break;
    vector<int> a,b;
    int a_sum=0,b_sum=0;
    for(int i=0;i<n;i++){
      int I;
      cin >> I;
      a.push_back(I);
      a_sum+=I;
    }
    for(int i=0;i<m;i++){
      int I;
      cin >> I;
      b.push_back(I);
      b_sum+=I;
    }
    int sum=1000;
    pair<int,int> mem;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        if(a_sum-a[i]+b[j]==b_sum-b[j]+a[i]){
          if(min(sum,a[i]+b[j])!=sum){
            mem.first=a[i];
            mem.second=b[j];
            sum=a[i]+b[j];
          }
        }
      }
    }
    if(sum==1000){
      cout << -1 << endl;
    }else{
      cout << mem.first << " "<< mem.second << endl;
    }
  }
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(LL, n, p);
	IN(string, s);
	
	vector<LL> c(p);
	c[0]++;
	LL x = 0, e = 1;
	dec(i, n) {
		(x += e * (s[i] - '0')) %= p;
		(e *= 10) %= p;
		c[x]++;
	}
	
	LL ans = 0;
	if(p == 2 || p == 5) {
		inc(i, n) {
			if((s[i] - '0') % p == 0) { ans += i + 1; }
		}
	} else {
		inc(i, p) { ans += c[i] * (c[i] - 1) / 2; }
	}
	OUT(ans);
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  char c;
  ll a,b;
  cin>>a>>c>>b;
  ans(c=='+',a+b,a-b);

  return 0;
}

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

using namespace std;

int main(){
    int x,y;
    int num_x,num_y;
    vector<int> v_x;
    vector<int> v_y;

    while(cin >> x >> y){
        num_x = x;
        num_y = y;
        if(num_x == 0 && num_y == 0){
            break;
        }
        if(num_x > num_y){
            num_x = y;
            num_y = x;
        }
        v_x.push_back(num_x);
        v_y.push_back(num_y);
    }

    for(int i = 0; i < v_x.size(); i++){
        cout << v_x[i] << " " << v_y[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
#define rep(it,st,en) for(int it=(st);it<(int)(en);++it)
#define allof(c) (c).begin(), (c).end()
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define X first
#define Y second
typedef long long int ll; 
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
const int INF=(int)1e9; 
const double EPS=(ld)1e-7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string col = "RGBY";
    int h,w,d;
    cin>>h>>w>>d;
    if(d%2 == 1){
        rep(i,0,h){
            rep(j,0,w){
                cout<<col[(i+j)%2];
            }
            cout<<"\n";
        }
    }
    else{
        int k = d/2;
        vector<vector<int> > v(h,vector<int>(w));
        auto dist = [&](int x, int y, int a, int b){ return abs(x-a) + abs(y-b);};
        auto at = [&](int x, int y, int c){
            rep(i,x-k-2,x+k+2) rep(j,y-k-2,y+k+2){
                if(i>=0 && i<h && j>=0 && j<w){
                    if(dist(i,j,x,y) < k || dist(i,j,x,y+1) < k){
                        v[i][j] = c;
                    }
                }
            }
        };
        rep(t,0,4){
            int x=0,y=0;
            if(t%2 ==  1) x = k, y = k;
            if(t > 1)  x += d;
            rep(i,-2*(h+w+10),2*(h+w+10)) rep(j,-2*(h+w+10),2*(h+w+10)){
                if(i%d == 0 && j%(2*d) == 0){
                    at(x+i,y+j+(d*(((i/d)%2+1)%2)),t+1);
                }
            }
        }
        rep(i,0,h){
            rep(j,0,w){
                cout<<col[v[i][j]-1];
            }
            cout<<"\n";
        }
    }
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

LL solve(LL n) {
  if(n<10) return n;
  if(n<100) return 9;
  if(n<1000) return n-90;
  if(n<10000) return 909;
  if(n<100000) return n-9090;
  return 90909;
}

int main(void)
{
  LL n;
  cin >> n;
  cout << solve(n) << endl;
  return 0;
}


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

int main()
{
	int N;
	long long L[87];
	cin >> N;

	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i <= N; i++) {
		L[i] = L[i - 1] + L[i - 2];
	}

	cout << L[N] << endl;
}

Measured memory_bytes: 256
if __file__.startswith('/tmp/'):
	import sys; sys.stdin = open('input.txt')

MOD = 10**9 + 7

h, w, a, b = map(int, raw_input().split())

def inv(x):
	return pow(x, MOD-2, MOD)

x = [1]
y = [1]

for k in xrange(1, h - a):
	x.append(((x[-1] * (b - 1 + k)) % MOD) * inv(k) % MOD)

for k in xrange(1, h):
	y.append(((y[-1] * (w - b - 1 + k)) % MOD) * inv(k) % MOD)

ans = 0
for k in xrange(h - a):
	ans = (ans + x[k] * y[h - k - 1]) % MOD

print ans

Measured memory_bytes: 8708
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0)
        cout<<(b-a)/2;
    else{

        cout<<min(a-1+(b-a-1)/2+1,n-b+(b-a-1)/2+1);


    }



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  cout << s.substr(0,4) << " " << s.substr(4) << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <map>
#include<queue>

const int INF = 1 << 28;
const long long MOD = 1000000007;
using namespace std;
using Graph = vector<vector<int>>;

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

vector<int> seen(50,-1);
int counter_for_dfs = 0;
void dfs(Graph &G, int v) {
	seen[v] = counter_for_dfs;
	counter_for_dfs++;
	for (auto v_next : G[v]) {
		if (seen[v_next]>=0)continue;

		dfs(G, v_next);
	}
}

void bfs(Graph &G) {
	vector<int> dist(G.size(), -1);
	queue<int> que;
	
	dist[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
		}
	}
	for (auto i : dist) {
		cout << i << " ";
	}
}

int counter[200005] = {};
void bfs2(Graph &G,int p,int x) {
	vector<int> dist(G.size() , -1);
	queue<int> que;
	
	dist[p] = 0;
	que.push(p);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
			counter[g] += x;
		}
	}
}
int main()
{
	int n;
	std::cin >> n;
	std::vector<long int> h;
	std::vector<int> dp(100005, -1);
	for (int i = 0; i < n; i++) {
		long int a;
		std::cin >> a;
		h.push_back(a);
	}
	dp[n - 1] = 0;
	for (int i = n - 2; i >= 0; i--) {
		dp[i] = (h[i] >= h[i + 1]) ? (dp[i + 1] + 1) : 0;
	}
	int rslt = *std::max_element(dp.begin(), dp.end());


	std::cout << rslt;
	return 0;

}

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

int main() {
  int n,k; cin>>k>>n;
  vector<int> a(n);
  rep(i, n) cin>>a[i];

  sort(a.begin(), a.end());
  int res=a[n-1]-a[0];
  rep(i, n-1) {
    int tmp=(k-a[i+1])+a[i];
    res=min(res, tmp);
  }
  cout<<res<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#define n 36

struct Card{
  char suit;
  char value;
};

void BubbleSort(struct Card C[],int N){
  int i,j;
  struct Card a;

  for(i=0;i<N;i++){
    for(j=N-1;j>=i+1;j--){
      if(C[j].value < C[j-1].value){
        a = C[j];
        C[j] = C[j-1];
        C[j-1] = a;
      }
    }
  }
}

void SelectionSort(struct Card C[],int N){
  int i,j,minj;
  struct Card a;

  for(i=0;i<N;i++){
    minj = i;
    for(j=i;j<N;j++){
      if(C[j].value < C[minj].value){
        minj = j;
      }
    }
    a = C[i];
    C[i] = C[minj];
    C[minj] = a;
  }
}

int isStable(struct Card C1[],struct Card C2[],int N){
  int i,j;

  for(i=0;i<N;i++){
    if(C1[i].suit != C2[i].suit)return 0;
  }
  return 1;
}
  /*for(i=0;i<N;i++){                                                           
    for(j=i+1;j<N;j++){                                                         
      for(a=0;a<N;a++){                                                         
        for(b=a+1;b<N;b++){                                                     
        if(in[i] == in[j] && )*/
int main(){
  struct Card C1[101],C2[101];
  int i,N;
  scanf("%d\n",&N);
  for(i=0;i<N;i++){
    if(i!=N-1)scanf("%c%c ",&C1[i].suit,&C1[i].value);
    else scanf("%c%c",&C1[i].suit,&C1[i].value);
  }

  for(i=0;i<N;i++)C2[i] = C1[i];

  BubbleSort(C1,N);
  SelectionSort(C2,N);

  for(i=0;i<N;i++){
    if(i)printf(" ");
    printf("%c%c",C1[i].suit,C1[i].value);
  }
  printf("\nStable\n");
  for(i=0;i<N;i++){
    if(i)printf(" ");
    printf("%c%c",C2[i].suit,C2[i].value);
 }
  if(isStable(C1,C2,N)){
    printf("\nStable\n");
  }
  else printf("\nNot stable\n");

  return 0;
}



Measured memory_bytes: 2052
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.num = [1] * (n+1)#集合の要素の数
 
    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
 
    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.num[y]+=self.num[x]
        else:
            self.par[y] = x
            self.num[x]+=self.num[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
 
    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
n, m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
  a, b = map(int, input().split())
  uf.union(a,b)
  
ans = 0
for i in range(1, n+1):
  if uf.par[i]==i:
    ans+=1
print(ans-1)


Measured memory_bytes: 81088
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const int N = 6005;

#define ll long long

void exgcd(int a, int b, int& x, int& y) {
	if (!b) {
		x = 1, y = 0;
	} else {
		exgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
}

int inv(int a, int n) {
	int x, y;
	exgcd(a, n, x, y);
	return (x < 0) ? (x + n) : (x);
}

int Mod;

class Z {
	public:
		int v;

		Z() : v(0) {	}
		Z(int x) : v(x){	}
		Z(ll x) : v(x % Mod) {	}

		friend Z operator + (const Z& a, const Z& b) {
			int x;
			return Z(((x = a.v + b.v) >= Mod) ? (x - Mod) : (x));
		}
		friend Z operator - (const Z& a, const Z& b) {
			int x;
			return Z(((x = a.v - b.v) < 0) ? (x + Mod) : (x));
		}
		friend Z operator * (const Z& a, const Z& b) {
			return Z(a.v * 1ll * b.v);
		}
		friend Z operator ~(const Z& a) {
			return inv(a.v, Mod);
		}
		friend Z operator - (const Z& a) {
			return Z(0) - a;
		}
		Z& operator += (Z b) {
			return *this = *this + b;
		}
		Z& operator -= (Z b) {
			return *this = *this - b;
		}
		Z& operator *= (Z b) {
			return *this = *this * b;
		}
		friend boolean operator == (const Z& a, const Z& b) {
			return a.v == b.v;
		} 
};

typedef Z Zi;

int n;
Zi Inv[N];
Zi f[N][6015];

int main() {
	scanf("%d%d", &n, &Mod);
	const int off = 3005;
	f[0][off] = 1;
	Inv[0] = 0, Inv[1] = 1;
	int n3 = n * 3;
	for (int i = 2; i <= n3; i++) {
		Inv[i] = -Inv[Mod % i] * (Mod / i);
	}
	for (int i = 0; i < n3; i++) {
		int L = -(i >> 1), R = min(i, 3005);
		for (int j = L; j <= R; j++) {
			Zi v = f[i][j + off];
			if (!v.v) {
				continue;
			}
			v *= Inv[n3 - i];
			f[i + 3][j + off] += v;
			f[i + 2][j - 1 + off] += v;
			f[i + 1][min(j + 1, off) + off] += v;
		}
	}
	Zi ans = 0;
	for (int i = 0; i <= min(off, n * 3); i++) {
		ans += f[n3][i + off];
	}
	for (int i = 1; i <= n3; i++)
		ans *= i;
	printf("%d\n", ans.v);
	return 0;
}


Measured memory_bytes: 141312
from math import ceil
h,w,d=map(int,input().split())
x=ceil((h*w)/d)
num=[[[-1,-1] for j in range(x)] for i in range(d)]#あまりで場合分け(1→0)
mp=[[0]*x for i in range(d)]
a=[list(map(int,input().split())) for i in range(h)]
for i in range(h):
    for j in range(w):
        k,l=a[i][j]%d,a[i][j]//d
        if k==0:
            num[d-1][l-1]=[i,j]
        else:
            num[k-1][l]=[i,j]
for i in range(d):
    for j in range(x):
        if j!=x-1:
            if num[i][j+1]!=[-1,-1]:
                mp[i][j+1]+=(mp[i][j]+abs(num[i][j+1][0]-num[i][j][0])+abs(num[i][j+1][1]-num[i][j][1]))
            else:
                break
q=int(input())
for i in range(q):
    l,r=map(int,input().split())
    if l%d!=0:
        e,f=l//d,r//d
    else:
        e,f=l//d-1,r//d-1
    g= d-1 if l%d==0 else l%d-1
    if e==0:
        print(mp[g][f])
    else:
        print(mp[g][f]-mp[g][e])


Measured memory_bytes: 35692
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void) {

	int a, b;
	string op;

	while (true) {
		cin >> a;
		cin >> op;
		cin >> b;

		if (op == "?")   break;

		if (op == "+") {
			cout << a + b << endl;
		}
		else if (op == "-") {
			cout << a - b << endl;
		}
		else if (op == "*") {
			cout << a * b << endl;
		}
		else if (op == "/") {
			cout << a / b << endl;
		}
	}



	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N; cin >> N;
    vector<vector<int>> G(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b; cin >> a >> b; a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> color(N), ans(N);
    int c0 = 0, c1 = 0;
    function<void(int, int, int)> recur = [&](int node, int prev, int c) {
        color[node] = c;
        (c ? c1 : c0)++;
        for (int next : G[node]) if (next != prev) {
            recur(next, node, !c);
        }
    };
    recur(0, -1, 0);
    int sm = (c0 < c1 ? 0 : 1);
    if (min(c0, c1) <= N / 3) {
        vector<int> A, B;
        int t = 3;
        for (int i = 0; i < min(c0, c1); i++) {
            A.push_back(t), t += 3;
        }
        for (; t <= N; t += 3) B.push_back(t);
        for (t = 1; t <= N; t += 3) B.push_back(t);
        for (t = 2; t <= N; t += 3) B.push_back(t);
        for (int i = 0; i < N; i++) {
            if (color[i] == sm) ans[i] = A.back(), A.pop_back();
            else ans[i] = B.back(), B.pop_back();
        }
    } else {
        vector<int> A, B;
        for (int i = 1; i <= N; i += 3) {
            A.push_back(i);
        }
        for (int i = 2; i <= N; i += 3) {
            B.push_back(i);
        }
        int t = 3;
        while (A.size() != c0) A.push_back(t), t += 3;
        while (B.size() != c1) B.push_back(t), t += 3;
        for (int i = 0; i < N; i++) {
            if (color[i] == 0) ans[i] = A.back(), A.pop_back();
            if (color[i] == 1) ans[i] = B.back(), B.pop_back();
        }
    }
    for (int i = 0; i < N; i++) {
        cout << ans[i] << " \n"[i == N - 1];
    }
    return 0;
}


Measured memory_bytes: 22812
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;

int main(){
  int n;
  scanf("%d",&n);
  int a[n];
  REP(i,n) scanf("%d",&a[i]);

  int box[n] = {};
  int cnt = 0;
  REPR(i,n-1){
    int sum=0;
    for(int j = 2*(i+1); j < n+1; j += (i+1)) sum += box[j-1];
  	if(sum % 2 != a[i]){
      box[i]++;
      cnt++;
    }
  }
  
  printf("%d\n",cnt);
  REP(i,n) if(box[i]) printf("%d ",i+1);
  printf("\n");
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};

ll gcd(ll a,ll b){
    ll r=a%b; 
    while(r!=0){ 
      a=b; 
      b=r; 
      r=a%b; 
    }
    return b;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  if(n==1){cout<<m<<endl;return 0;}
  vector<ll> ma;
  ma.pb(1);
  for(int i=2;i<=sqrt(m);i++){
    if(m%i==0){ma.pb(i);ma.pb(m/i);};
  }
  sort(ALL(ma));
  for(int i=0;i<ma.size();i++){
    if(m/n<ma[i]){cout<<ma[i-1]<<endl;break;}
  }
  if(ma.size()==1)cout<<1<<endl;
  //  cout<<ma<<endl;
  return 0;
}


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

#define NIL -1
#define INF 1000000001

using namespace std;

void minChainMultiple(vector<vector<int> > &minMultipleArray,const vector<int> &matSizeArray){
    int n = (int) minMultipleArray.size();
    for(int l = 1;l < n;l++){
        for(int i = 0;i < n-l;i++){
            int j = i+l;
            minMultipleArray[i][j] = INF;
            for(int k = i;k < j;k++){
                minMultipleArray[i][j] = min(minMultipleArray[i][j],
                minMultipleArray[i][k] + minMultipleArray[k+1][j]+matSizeArray[i]*matSizeArray[k+1]*matSizeArray[j+1]);
            } 
        }
    }
    
}

int main(){
    int n;
    int row,column;
    scanf("%d",&n);
    vector<int> matSizeArray(n+1,0);
    vector<vector<int> > minMultipleArray(n,vector<int>(n,0)); 

    for(int i = 0; i < n;i++){
        scanf("%d %d",&row,&column);
        matSizeArray[i] = row;
        matSizeArray[i+1] = column;
    }
    minChainMultiple(minMultipleArray,matSizeArray);
    printf("%d\n",minMultipleArray[0][n-1]);
    return 0;
}


Measured memory_bytes: 3312
isprime :: Int -> Bool
isprime 1 = False
isprime 2 = True
isprime n = not $ or (map ((0==).(mod n)) [2..ceil])
    where ceil = ceiling (sqrt (fromIntegral n))
main = do
    n <- getLine >>= return . read
    numbers <- (sequence (take n (repeat getLine))) >>= return . (map read)
    print $ foldl (\acc x -> if isprime x then acc+1 else acc) 0 numbers 




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

using namespace std;

int main() {
	string s; cin >> s;
	
	int a = stoi(s.substr(0, 2)), b = stoi(s.substr(2, 2));
	int flag = 0;
	if (0 < a && a < 13) flag++;
	if (0 < b && b < 13) flag += 2;
	
	if (flag == 0) cout << "NA";
	else if (flag == 1) cout << "MMYY";
	else if (flag == 2)cout << "YYMM";
	else cout << "AMBIGUOUS";
	cout << endl;

	return 0;
}

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

int main()
{
  long long N;
  scanf("%lld",&N);
  N++;
  int C=0;
  while((1LL<<C)<=N){
    C++;
  }
  int t=1;
  vector<int> b,f;
  for(int k=C-2;k>=0;k--){
    f.push_back(t);
    t++;
    if((N>>k)&1){
      b.push_back(t);
      t++;
    }
  }
  printf("%d\n",2*(t-1));
  for(int i=1;i<t;i++){
    printf("%d ",i);
  }
  for(int x=b.size()-1;x>=0;x--){
    printf("%d ",b[x]);
  }
  for(int x=0;x<f.size();x++){
    printf("%d ",f[x]);
  }
  putchar('\n');
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>
using namespace std;
int main(){
  int N, M;
  cin >> N;
  cin >> M;
  vector<int> vec(M);
  for(int i=0; i<M; i++){
    cin >> vec.at(i);
  }
  int r;
  r = N - accumulate(vec.begin(), vec.end(), 0);
  if (r >= 0){
    cout << r;
  }else{
    cout << -1;
  }
}

Measured memory_bytes: 3668
ps, k = [int(input()), int(input()), int(input()), int(input()), int(input())], int(input())
f = True
for i in range(0, 5):
    for j in range(0, 5):
        if ps[j] - ps[i] > k:
            f = False
print('Yay!' if f else ':(')


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

int main(void) {
  int N, s1=0, s2=0, min=1000000;
  cin >> N;
  int w[N];
  
  for(int i=0; i<N; i++) cin >> w[i];
  
  for(int i=0; i<N; i++){
    for(int j=0; j<=i; j++)
      s1 += w[j];
    for(int k=0; k<N; k++)
      s2 += w[k];
    s2 -= s1;
    if(abs(s1-s2) <= min)
      min = abs(s1-s2);
    s1=0;
    s2=0;
  }
  
  cout << min << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(void){

	int i,a,b,tmp;
	for(i=0;i<10000;i++){
		cin>>a>>b;
		if(a==0&&b==0){
			return 0;
		}else{
			if(a>b){
				tmp=b;
				b=a;
				a=tmp;
			}
			cout<<a<<" "<<b<<endl;
		}
	}
   return 0;
}





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

int main(){
  int n;
  string s, t;
  cin >> n >> s >> t;
  string ans;
  for(int i=0; i<n; ++i){
    ans += s[i];
    ans += t[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
N, M  = map(int,input().split())
As = sorted(list(map(int,input().split())))
di = {}
for i in range(M):
    b, c = map(int,input().split())
    di[c] = di.get(c, 0) + b

keys = list(sorted(di.keys(), reverse=True))
ichi = 0
for i in range(N):
    try:
        if keys[ichi] > As[i]:
            As[i] = keys[ichi]
            di[keys[ichi]] -= 1
        else:
            break
        if di[keys[ichi]] == 0:
            ichi += 1
    except:
        pass
print(sum(As))


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

using mll = long long;
//using mIMAX = INT_MAX;
//using mIMIN = INT_MIN:
//using mLMAX = LLONG_MAX;
//using mLMIN = LLONG_MIN;

using mVecI = std::vector<int>;
using mVecL = std::vector<long long>;

using mSetI = std::set<int>;
using mSetL = std::set<long long>;
using mUSetI = std::unordered_set<int>;
using mUSetL = std::unordered_set<long long>;

using mMapII = std::map<int, int>;
using mMapIL = std::map<int, long long>;
using mMapLI = std::map<long long, int>;
using mMapLL = std::map<long long, long long>;
using mUMapII = std::unordered_map<int, int>;
using mUMapIL = std::unordered_map<int, long long>;
using mUMapLI = std::unordered_map<long long, int>;
using mUMapLL = std::unordered_map<long long, long long>;



int main()
{
    std::ios::sync_with_stdio(false);	
	int n;
    cin>>n;
    mUMapII A;
    for(int i = 0 ; i < n ; i++)
    {
        int tmp;
        cin>>tmp;
        A[tmp]++;
    }
    
    int x = 0;
    int y = 0;
    for(auto i = A.begin() ; i != A.end() ; i++)
    {
        int num = i->second;
        int length = i->first;
        if(num >=2)
        {
            if(length>x)
            {
                x = length;
                if(x>y)
                {
                    swap(x,y);
                }
                if(num >=4)
                {
                   x = y;
                }
            }
        
        }
    }
	cout<<(mll)x*y;
    return 0;
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
#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, n, m) for (int i = m; i < n; i++)
#define MM(i, n, m) for (int i = m; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
*/
int main()
{
    int N;
    cin >> N;
    string ans = "No";
    MM(i, 9, 1)
    {
        MM(j, 9, 1) {
            if(N == i*j)
                ans = "Yes";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x) {
  return x * x;
}

signed main() {
  int N, A;
  cin >> N >> A;

  cout << N * N - A << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;

    int ans1 = 100*a, ans2 = 0;
    rep(i,31){
        rep(j,31){
            int water = (a*i + b*j)*100;
            if(water > f) break;
            rep(ii,3001){
                rep(jj,3001){
                    int suger = c*ii + d*jj;
                    if(water + suger > f) break;
                    if(suger*100 > water*e) break;
                    if(ans2*(water+suger) < suger*(ans1+ans2)){
                        ans1 = water;
                        ans2 = suger;
                    }
                }
            }
        }
    }
    cout << ans1+ans2 << " " << ans2 << endl;
}

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

int main () 
{
    int n;
    std::cin >> n;
    
    for (int i = 1; i <= n; i++) 
    {
        int x = i;
        
        if (i % 3 == 0)
        {
            std::cout << " " << i;
        }
        else
        {
            while (x)
            {
                if (x % 10 == 3)
                {
                    std::cout << " " << i;
                    x = 0;
                }
                
                x /= 10;
            }
        }
    }
    
    std::cout << std::endl;
    
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define DEB 0
#define MAX 110000

bool tmp[MAX];
int primes[11000];
int sz;

void make_prime(){
  tmp[0]=tmp[1]=true;
  for(int i=2; i*i<=MAX; i++){
    if( !tmp[i] ){
      for(int j=i*2; j<MAX; j+=i){
	tmp[j]=true;
      }
    }
  }
  primes[sz++] = 2;
  for(int i=3; i<MAX; i+=2){
    if( !tmp[i] ){
      primes[sz++] = i;
    }
  }
}
int main(){
  int n;
  make_prime();
  
  while(scanf("%d",&n),n){
    int sum = 0;
    rep(i,n){
      sum += primes[i];
    }
    printf("%d\n",sum);
  }
  return 0;
}

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

using namespace std;

#define debug(x) cerr << #x << " -> " << x << "\n"

static const int INF = 1e9 + 7;
static const double EPS = 1e-10;
static const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
static const int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};

template<class T> ostream &operator<<(ostream &os, vector<T> &v){
  for(int i = 0; i < v.size(); i++){
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main(){
  int n, m;
  scanf("%d %d", &n, &m);
  unsigned long long ans = 0;
  vector<long long> moved(n, 0);
  int back, go;
  for(int i = 0; i < m; i++){
    scanf("%d", &go);
    if(i){
      moved[min(go, back) - 1]++;
      moved[max(go, back) - 1]--;
    }
    back = go;
  }
  for(int i = 0; i < n - 1; i++){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(i){moved[i] += moved[i - 1];}
    ans += min<unsigned long long>(moved[i] * a, moved[i] * b + c);
  }
  printf("%llu\n", ans);
  return 0;
}

Measured memory_bytes: 1796
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<random>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,t,a[400010],ans=0;
    cin>>n>>t;
    rep(i,n){
        cin>>a[i];
    }
    ans=t;
    rep2(i,1,n){
        ans+=min(t,a[i]-a[i-1]);
    }
    cout<<ans<<endl;
    return 0;
}


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

    #define M_PI       3.14159265358979323846   // pi

    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    typedef pair<ll, ll> P;
    typedef tuple<ll, ll, ll> t3;
    typedef tuple<ll, ll, ll, ll> t4;

    #define rep(a,n) for(ll a = 0;a < n;a++)

    static const ll INF = 1e15;

    template<typename T>
    static inline void chmin(T& ref, const T  value) {
        if (ref > value) ref = value;
    }

    template<typename T>
    static inline void chmax(T& ref, const T value) {
        if (ref < value) ref = value;
    }

    ll gcd(ll a, ll b) { while (b) a %= b, swap(a, b); return abs(a); }

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

    int main() {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        ll cd = lcm(c, d);
        ll x1 = b / c - (a - 1) / c;
        ll x2 = b / d - (a - 1) / d;
        ll x3 = b / cd - (a - 1) / cd;
        ll ans = x1 + x2 - x3;
        cout << b - (a-1) - ans << endl;
        return 0;
    }


Measured memory_bytes: 3632
/*#include <cstdio>
#include <algorithm>

using namespace std;

long long a[100043];

int main(int argc, char const *argv[]) {
  int n;
  scanf("%d", &n);
  long long res = 1;
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i) {
    res *= a[i];
    if (res > 1000000000000000000 || res < 0) {
      printf("-1\n");
      return 0;
    }
  }
  printf("%lld\n", res);
  return 0;
}*/
#include <iostream>
#include <vector>

using namespace std;

string s;
vector<int> ans;

int main(int argc, char const *argv[]) {
  long long a, b = 0;
  cin >> a >> s;
  int cnt = 0;
  bool flag = false;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '.') {
      flag = true;
      continue;
    }
    if (flag) ++cnt;
    b = b * 10 + s[i] - '0';
  }
  a *= b;
  if (a % 10 == 0) {
    a /= 10;
    --cnt;
  }
  if (a % 10 == 0) {
    a /= 10;
    --cnt;
  }
  while (a > 0) {
    if (cnt <= 0) {
      ans.push_back(a % 10);
    }
    a /= 10;
    --cnt;
  }
  if (ans.size() == 0) {
    printf("0\n");
  } else {
    for (int i = ans.size() - 1; i >= 0; --i) {
      printf("%d", ans[i]);
    }
    printf("\n");
  }
  return 0;
}

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

int main(){
  int n,i;
  string s;
  cin>>n;
  cin>>s;
  for(i=0;;i++){
    if(s[i]=='\0'){
      break;
    }
    s[i]+=n;
    if(s[i]>'Z'){
      s[i]-=26;
    }
    cout<<s[i];
  }
}

Measured memory_bytes: 256
n = int(input())
ary = [1]
x = 1
for i in range(6):
	x *= 6
	ary.append(x)
x = 1
for i in range(5):
	x *= 9
	ary.append(x)
ary.sort()

dp = [i for i in range(n+1)]

for i in range(1,n+1):
	for j in ary:
		if j > i:
			continue
		dp[i] = min(dp[i],dp[i-j]+1)
print (dp[n])

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define pb push_back
#define all(x) (x).begin(),(x).end()

const int mod = 1e9+7;

const int A = 26;
vector<int> pos[A];

int n;

const int N = 2002;
int dp[N][N];
int dfs(int l, int r){
    if(l>=n || r<0) return 0;
    if(dp[l][r]>=0) return dp[l][r];

    // printf(" (%d %d)\n", l,r);
    int ret = 0;

    rep(i,26){
        auto il = lower_bound(all(pos[i]),l);
        if(il == pos[i].end()) continue;

        auto ir = upper_bound(all(pos[i]),r);
        if(ir == pos[i].begin()) continue;
        --ir;

        int nl = *il, nr = *ir;
        if(nl<=nr){
            ++ret;
            if(nl<nr){
                ++ret;
                (ret += dfs(nl+1,nr-1)) %= mod;
            }
        }
    }

    return dp[l][r] = ret;
}

int main(){
    string s;
    cin >>s;
    n = s.size();

    rep(i,n) pos[s[i]-'a'].pb(i);

    memset(dp,-1,sizeof(dp));
    cout << dfs(0,n-1) << endl;
    return 0;
}



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

int main()
{
	while (1) {
		int a;
		cin >> a;
		if (a == 0)break;
		vector<int>b(a);
		for (int c = 0; c < a; c++) {
			cin >> b[c];
		}
		uint16_t e = 31;
		for (uint16_t f = 0; f < 6; f++){
			cout <<e<<endl;
			cout << (e - b[f % (b.size())]) << endl;
			e -= 5;
		}
		cout << 1 << endl << 0 << endl;
	}
}

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

int main()
{
    int a, b, c, k;
    int max_total = 0;

    scanf("%d %d %d %d", &a, &b, &c, &k);

    if (a >= k)
    {
        max_total = k;
    } else if ((a+b) >= k){
        max_total = a;
    } else {
        max_total = a + -1*(k - (a+b));
    }

    printf("%d", max_total);

    return 0;
}

Measured memory_bytes: 1732
def myAnswer(N:int,K:int,A:list) -> int:
   kinds = 0
   dic = {}
   for a in A:
      if(a in dic.keys()):
         dic[a]+=1
      else:
         dic[a]=1
         kinds +=1
   if(kinds <= K):return 0
   sub = kinds - K
   ans = 0
   dic2 = sorted(dic.items(), key=lambda x:x[1])
   for key,value in dic2:
      if(sub == 0):
         break
      else:
         ans += value
         sub -= 1
   return ans

def modelAnswer():
   return
def main():
   N,K = map(int,input().split())
   A = list(map(int,input().split()))
   print(myAnswer(N,K,A[:]))
if __name__ == '__main__':
   main()

Measured memory_bytes: 40628
def lcm(a, b):
    x = a * b
    if a < b:
        a, b = b, a
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b

    return x // b


A, B, C, D = map(int, input().split())

_lcm = lcm(D, C)

nA = (A - 1) // C + (A - 1) // D - (A - 1) // _lcm
nB = B // C + B // D - B // _lcm
print((B - A + 1) - (nB - nA))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int64_t X;
  int64_t A = 100LL;
  cin >> X;
  for (int64_t i = 1; i < 10000; i++) {
    A = (int64_t) (A *1.01);
    if (A >= X) {
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 3624
class UnionFindTree:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self._root(self.table[x])
            return self.table[x]

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def unite(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 > d2:
            self.table[r1] = r2
            self.table[r2] += d1
        else:
            self.table[r2] = r1
            self.table[r1] += d2


n, m = map(int, input().split())
edges = []
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges.append((a, b))
edges.reverse()
score = []
score.append(n * (n - 1) // 2)

uft = UnionFindTree(n)

for (a, b) in edges[:-1]:
    if uft.find(a, b):
        score.append(score[-1])
        continue

    root_a = uft.table[uft._root(a)]
    root_b = uft.table[uft._root(b)]
    score.append(score[-1] - root_a * root_b)
    uft.unite(a, b)

score.reverse()
print("\n".join(map(str, score)))

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n;
int a[maxn];



bool ok(int x, int y, int z) {
    return x+y>z;
}

bool test(int x, int y, int z) {
    if (x==y) return false;
    if (x==z) return false;
    if (y==z) return false;
    return ok(x,y,z) && ok(y,z,x) && ok(x,z,y);
}

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

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


    // set<vector<int>> st;
    int res = 0;

    for (int i=0; i<n; i++) {
	for (int j=i+1; j<n; j++) {
	    for (int k=j+1; k<n; k++) {
		if (test(a[i],a[j],a[k])) {
		    res++;
		    // vector<int> cur = {a[i],a[j],a[k]};
		    // sort(cur.begin(), cur.end());
		    // st.insert(cur);
		}
	    }
	}
    }

    out(res);

    // cout<<st.size()<<endl;
    
    
    return 0;
}


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

int main()
{
  int n, k;
  char s[100001];
  scanf("%d%d%s", &n, &k, s);
  int blk[100001];
  int* dst = blk + 1;
  for (char *p = s; *p;)
  {
    char* q = p;
    while (*p && *p == *q) ++p;
    *dst++ = p - q;
  }
  int nblk = dst - (blk + 1);
  *blk = 0;
  for (int i = 1; i <= nblk; ++i)
  {
    blk[i] += blk[i - 1];
  }
  int ans = 0;
  if (*s == '0')
  {
    ans = blk[std::min(2 * k, nblk)];
  }
  for (int i = ('1' - *s); i < nblk; i += 2)
  {
    ans = std::max(ans, blk[std::min(i + 2 * k + 1, nblk)] - blk[i]);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
//ll a[1000000+9]= {0};
using namespace std;

int main()
{
 string s;
 ll i,j;
 cin>>s;
 if((s[2]==s[3])&&(s[4]==s[5]))
 {
     cout<<"Yes"<<endl;
 }
 else
 {
     cout<<"No"<<endl;
 }


    return 0;
}



Measured memory_bytes: 256
use std::io;

fn main() {
    let mut ab = String::new();
    io::stdin().read_line(&mut ab).expect("error");
    let vec : Vec<_> = ab.split_whitespace().collect();
    let a: usize = vec[0].parse().unwrap();
    let b: usize = vec[1].parse().unwrap();

    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("error");
    let s = s.trim();

    // convert usize to u32
    let s_len: usize = s.chars().count();
    if a + b + 1 != s_len || s.chars().nth(a).unwrap() != '-' {
        println!("No");
    }
    else {
        let s_a: String = s.chars().take(a).collect();
        let s_b: String = s.chars().skip(a + 1).collect();

        let a_is_number = s_a.parse::<u32>().is_ok();
        let b_is_number = s_b.parse::<u32>().is_ok();

        if a_is_number && b_is_number {
            println!("Yes");
        }
        else {
            println!("No");
        }
    }
}


Measured memory_bytes: 4352
#include<stdio.h>

int main() {
	int n, i, j;
	int A[100];
	int minj = 0;
	int tmp = 0;;
	int k = 0;

	scanf("%d", &n);

	for (i = 0; i < n; i++) scanf("%d", &A[i]);

	for (i = 0; i < n; i++) {
		minj = i;

		for (j = i + 1; j < n; j++) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}

		if(minj != i) k++;

		tmp = A[i];
		A[i] = A[minj];
		A[minj] = tmp;
	}

	for (i = 0; i < n; i++) {
		printf("%d", A[i]);
		if (i != n - 1) printf(" ");
	}
	printf("\n");
	printf("%d\n", k);

	return 0;
}

Measured memory_bytes: 604
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



n, k = LI()
ret = 1
cnt = 0
while ret - 1 < n:
    ret *= k
    cnt += 1


print(cnt)


Measured memory_bytes: 39664
#include<stdio.h>
int main(void)
{
	int n,m,x,y,c=0,i,j,k,l;
	char a[50][50],b[50][50];
	scanf("%d %d", &n, &m);
	for(i=0; i<n; i++)
	scanf("%s", &a[i]);
	for(i=0; i<m; i++)
	scanf("%s", &b[i]);
	for(i=0; i<n-m+1; i++)
	{
		for(j=0; j<n-m+1; j++)
		{
			if(a[i][j]==b[0][0])
			{
				x=0;
				for(k=i; k<i+m; k++)
				{
					y=0;
					for(l=j; l<j+m; l++)
					{
						if(a[k][l]!=b[x][y])
						break;
						y++;
					}
					if(y<m)
					break;
					x++;
				}
				if(x==m)
				c=1;
			}
		}
	}
	if(c>0)
	printf("Yes\n");
	else
	printf("No\n");
	
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import numpy as np

N = input()
s = np.zeros((N, ), dtype=np.int32)
for i in range(N):
    s[i] = input()


s.sort()
largest_s = np.sum(s)

if largest_s % 10 != 0:
    print largest_s
    exit()

for i in range(N):
    if (largest_s - s[i]) % 10 != 0:
        print largest_s - s[i]
        exit()
print 0



Measured memory_bytes: 19388
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${@pT~FgM5PYxH|1i?&P;#V@NFbqz-ml=T>O<l<?dnpy_#?o-$BrH17S2!Z%yf2kz4-<9VUAMNU>%L5Ns8@@vV6Vjl{`iA?%b$m82A82r?XTBXVr+qEE=d~ciMC$zxV?;?AWLRXFFZiE7tKIgA|9|W9d${M;AfQ@2bZ=TH8m6gmG3P%OT`}hI+k%J6}{=fMJU=z;8zyII1Y}r*&jZkmU<Zy<?v7@KmE!y!p2<-i_f8suH(OvvHb0DsHS2U@_MysRNVNWWE#V|Ky|Va5@cV`yK6_LgRNRI2W5T;&zK_`K@t(?||s$I-tZVn5Rgv*j!ln6Q3aq#p6u)pn3A&S@ZA|`5CCnJng^fx@_vQn3{dR974>5=Pg8H-ua$gYwuUB5^k`eWIdqmDcJuo+#tA~F5xfAI-Qv__65^go26FrusT^d;g`TKU4hr->bf)qY=LpTdLwhZ2-QpFTuH?5ArpBW#^YYKDuPA+v-CAj5}Uc+0@?4-_#JW!Vd}7ver{v#cGq8Qo`|M*o^sicYjor%@ecrR")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 12920
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll x,a,b;
    cin>>x>>a>>b;
    if(b-a<=0)
    {
        cout<<"delicious"<<endl;
    }
    else if(b-a<=x)
    {
        cout<<"safe"<<endl;
    }
    else cout<<"dangerous"<<endl;
    return 0;
}


Measured memory_bytes: 256
n, m = list(map(int, input().split(" ")))
a_list = sorted(list(map(int, input().split(" "))), reverse=True)
if m == 0:
    print('Yes')
else:
    if a_list[m-1] >= sum(a_list) / (4 * m):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060