akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    UnionFind(int size) : par(size), rank(size) {
        REP(i, size) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }
    bool same(int x, int y) { return find(x) == find(y); }
};

int N, K, L;

typedef pair<int, int> P;

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

    cin >> N >> K >> L;

    UnionFind uf1(N + 1);
    UnionFind uf2(N + 1);

    REP(i, K) {
        int x, y;
        cin >> x >> y;
        uf1.unite(x, y);
    }
    REP(i, L) {
        int x, y;
        cin >> x >> y;
        uf2.unite(x, y);
    }

    map<P, int> m;
    REPS(i, N) {
        P p(uf1.find(i), uf2.find(i));
        if (m.find(p) != m.end()) {
            m[p]++;
        } else {
            m[p] = 1;
        }
    }
    REPS(i, N) {
        if (i != 1) cout << " ";
        P p(uf1.find(i), uf2.find(i));
        if (m.find(p) != m.end()) {
            cout << m[p];
        } else {
            cout << 0;
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 18176
//#pragma comment(linker, "/STACK:1024000000,1024000000")
/* vim: set fdm=marker */
//{{{
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < 0) return gcd(-a, b);
	if(b < 0) return gcd( a,-b);
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}

ll qpow(ll a, ll n, ll mod) {
	a %= mod;
	ll ans = 1LL;
	while(n) {
		if(n & 1) ans = (ans*a % mod);
		a = (a*a % mod);
		n >>= 1;
	}
	return ans;
}

inline ll rev(ll a, ll p) {
	return qpow(a, p - 2, p);
}

#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define rep(x, st, en) for(int x = st; x < en; x++)
#define pb push_back
#define mp make_pair
#define dbgm(msg, var) cerr<<#msg<<" "<<#var<<" = "<<var<<endl; 
#define dbg(var) cerr<<#var<<" = "<<var<<endl;
#define X first
#define Y second
#ifdef ALNDBG
namespace alndbg {
	clock_t s, e;
}
#endif

inline void tic() {
#ifdef ALNDBG
	alndbg::s = clock();
#endif
}

inline void toc() {
#ifdef ALNDBG
	alndbg::e = clock();
	cerr<<1000.0 * (alndbg::e - alndbg::s) / CLOCKS_PER_SEC<<" ms"<<endl;
#endif
}

//}}}

// -------------------- Spliters ------------------------
const int maxn =100 ;

char s[maxn];
char target[maxn] = "CODEFESTIVAL2016";

int main() {
	ios::sync_with_stdio(0);
	cin>>s;
	int ans = 0;
	rep(i, 0, 16) if(s[i] != target[i]) ans++;
	cout<<ans<<endl;
	return 0;
}
// --USE C++11
// *-USE O2


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
struct Point
{
  double x,y;
  Point(){x=0;y=0;}
  Point(double d_x,double d_y){x=d_x,y=d_y;}
  double operator*(Point obj){return obj.x*x+obj.y*y;}
  double operator%(Point obj){return obj.y*x-obj.x*y;}
  Point operator*(double b){Point tmp;tmp.x=x*b;tmp.y=y*b;return tmp;}
  Point operator/(double b){Point tmp;tmp.x=x/b;tmp.y=y/b;return tmp;}
  Point operator+(Point obj){Point tmp;tmp.x=x+obj.x;tmp.y=y+obj.y;return tmp;}
  Point operator-(){Point tmp;tmp.x=-x;tmp.y=-y;return tmp;}
  Point operator-(Point obj){Point tmp;tmp.x=x-obj.x;tmp.y=y-obj.y;return tmp;}
  Point operator-=(Point obj){x-=obj.x;y-=obj.y;return *this;}
  Point operator+=(Point obj){x+=obj.x;y+=obj.y;return *this;}
  Point operator/=(double b){x=x/b;y=y/b;return *this;}
  Point operator*=(double b){x=x*b;y=y*b;return *this;}
  double size(){return hypot(x,y);}
  Point unit(){return Point(x/size(),y/size());}
  Point normal(){return Point(y,-x);}
  double atan(){return atan2(y,x);}
};

bool operator<(Point a,Point b){return a.x!=b.x?a.x<b.x:a.y<b.y;}
bool operator>(Point a,Point b){return b<a;}
bool operator<=(Point a,Point b){return !(b<a);}
bool operator>=(Point a,Point b){return !(a<b);}
bool operator==(Point a,Point b){return (a-b).size()<eps;}
bool operator!=(Point a,Point b){return !(a==b);}

bool equal(double a,double b){return abs(a-b)<eps;}
double cross(Point a,Point b){return a%b;}
double dot(Point a,Point b){return a*b;}

int ccw(Point a,Point b,Point c)
{
  b=b-a;
  c=c-a;
  if(b%c>0) return +1;
  else if(b%c<0)return -1;
  else if(b*c<0) return +2;
  else if(b.size()<c.size()) return -2;
  else return 0;
}

int main(int argc,char const* argv[])
{
  int n;
  cin >> n;
  ll rc=0,lc=0;
  for(int i=0;i<n;i++)
    {
      int a,b;
      char c;
      cin >> a >> c >> b;
      if(c=='(') lc+=b;
      else if(c==')') rc+=b;
      if(lc==rc)
	{
	  cout << "Yes" << endl;
	}
      else
	{
	  cout << "No" << endl;
	}
    }
    
  return 0;
}
			       
	



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1000000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll N;

ll cnt(ll x,ll y){
    ll res = 0;
    rep(i,6){
        if(i == 0){
            if(x == y && x <= N) res++;
            if(x > N) break;
        }else if(i == 1){
            if(x*10+y <= N) res++;
            else break;
        }else{
            ll l = 0,r = pow(10,i-1)-1;
            while(r-l > 1){
                ll mid = (r+l)/2;
                if(x*pow(10,i)+mid*10+y >= N){
                    r = mid;
                }else{
                    l = mid;
                }
            }
            if(x * pow(10,i) + r * 10 + y > N){
                r--;
            }
            if(r >= 0){
                if(x * pow(10,i) + r * 10 + y <= N){
                    res += r+1;
                }else{
                    break;
                }
                
            }
        }
    }
    return res;
}

int main(){
    cin >> N;
    ll ans = 0;
    FOR(i,1,10){
        FOR(j,1,10){
            ans += cnt(i,j) * cnt(j,i);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 512
import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;
import std.numeric;

void main()
{
    auto nm = readln.chomp.split.to!(long[]);
    long N = nm[0];
    long M = nm[1];

    long[] A = new long[](M);
    long[] B = new long[](M);

    foreach (i; 0 .. M)
    {
        auto ab = readln.chomp.split.to!(long[]);
        A[i] = ab[0];
        B[i] = ab[1];
    }

    zip(A, B).sort!((a, b) => a[1] < b[1]);
    long cnt;
    long x = long.min;
    foreach (i; 0 .. M)
    {
        // writeln(A[i], ", ", B[i]);
        if (x < A[i])
        {
            x = B[i] - 1;
            cnt++;
        }
    }
    cnt.writeln;
}


Measured memory_bytes: 4860
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  double n, d;
  cin >> n >> d;
  cout << ceil(n / (2 * d + 1));

  return 0;
}

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

#define sz(o) ((int)o.size())
#define all(o) o.begin(), o.end()
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define repr(i, a, b) for(int i = (a); i >= (b); i--)

typedef long long int ll;
typedef vector<ll> vll;
typedef vector<int> vi;


void solve(int testcase) {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    rep(i, 1, a){
        if(i < a) ans++;
        else if(b>=a) ans++;
    }
    cout << ans;
}

int main(){
    #ifdef VPAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << setprecision(2);
    clock_t b = clock();
    int t = 1;
    //cin >> t;
    rep(tt, 1, t) solve(tt);
    clock_t e = clock();
    cerr << (double(e - b) / CLOCKS_PER_SEC) << " sec";
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
int n, m, L[N], R[N];
vector<int> open[N], close[N];
long long val[N];

long long st[4 * N], lazy[4 * N];

void push(int v) {
	st[v * 2] += lazy[v];
	lazy[v * 2] += lazy[v];
	st[v * 2 + 1] += lazy[v];
	lazy[v * 2 + 1] += lazy[v];
	lazy[v] = 0;
}

long long query(int v, int tl, int tr, int l, int r) {
	if (l > r) {
		return LLONG_MIN;
	}
	if (tl == l && tr == r) {
		return st[v];
	}
	push(v);
	int m = (tl + tr) / 2;
	long long ql = query(v * 2, tl, m, l, min(m, r));
	long long qr = query(v * 2 + 1, m + 1, tr, max(l, m + 1), r);
	return max(ql, qr);
}

void update(int v, int tl, int tr, int l, int r, long long val) {
	if (l > r) {
		return;
	}
	if (tl == l && tr == r) {
		st[v] += val;
		lazy[v] += val;
		return;
	}
	push(v);
	int m = (tl + tr) / 2;
	update(v * 2, tl, m, l, min(m, r), val);
	update(v * 2 + 1, m + 1, tr, max(l, m + 1), r, val);
	st[v] = max(st[v * 2], st[v * 2 + 1]);
}

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

	cin >> n >> m;

	int l, r;
	for (int i = 1; i <= m; i++) {
		cin >> l >> r >> val[i];
		l--, r--;
		L[i] = l;
		R[i] = r;
		open[l].emplace_back(i);
		close[r + 1].emplace_back(i);
	}

	long long active = 0;
	for (int i = 0; i < n; i++) {
		for (int p : close[i]) {
			int l = L[p];
			int r = R[p];
			active -= val[p];
			update(1, 0, n, l, r, +val[p]);
		}

		long long opt = active + max(0LL, query(1, 0, n, 0, i - 1));

		for (int p : open[i]) {
			int l = L[p];
			int r = R[p];
			opt += val[p];
			active += val[p];
			update(1, 0, n, l, r, -val[p]);
		}

		update(1, 0, n, i, i, opt);
	}

	for (int p : close[n]) {
		int l = L[p];
		int r = R[p];
		active -= val[p];
		update(1, 0, n, l, r, val[p]);
	}

	cout << max(query(1, 0, n, 0, n - 1), 0LL) << '\n';

	return 0;
}


Measured memory_bytes: 37760
import numpy as np
#import heapq
N = int(input())
A = []
for _ in range(N):
  A.append(int(input()))
A = np.array(A)
A_max_1 = np.max(A)
A_max_index = np.argmax(A)
A = np.delete(A, A_max_index)
A_max_2 = np.max(A)
answer = []
for i in range(N):
  if not i == A_max_index:
    answer.append(A_max_1)
  else:
    answer.append(A_max_2)
for i in range(N):
  print(answer[i])


Measured memory_bytes: 21812
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;

int A,B;
string str;
int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> A >> B;
    cout << A - B +1 << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <map>

using namespace std;

int H, A[500001];

int parent(int i) {
	return i / 2;
}

int left(int i) {
	return 2 * i;
}

int right(int i) {
	return 2 * i + 1;
}

void maxHeapify(int i) {
	int l = left(i);
	int r = right(i);
	int largest = i;
	if (l <= H && A[l] > A[i]) {
		largest = l;
	}
	if (r <= H&&A[r] > A[largest]) {
		largest = r;
	}
	if (largest != i) {
		int temp = A[i];
		A[i] = A[largest];
		A[largest] = temp;
		maxHeapify(largest);
	}
}

int main() {
	cin >> H;
	for (int i = 1; i <= H; i++) {
		cin >> A[i];
	}
	for (int i = H / 2; i >= 1; i--) {
		maxHeapify(i);
	}
	for (int i = 1; i <= H; i++) {
		printf(" %d", A[i]);
	}
	printf("\n");
}

Measured memory_bytes: 3100
// C++ program to print all increasing sequences of 
// length 'k' such that the elements in every sequence 
// are from first 'n' natural numbers. 
#include<bits/stdc++.h> 
using namespace std; 

int cnt = 0;

vector<vector<int>> v;

int bst = 0;
// A utility function to print contents of arr[0..k-1] 
void printArr(int arr[], int k) 
{ 
	int curr = 0;
	for(auto it: v){
		int a = it[0], b = it[1], c = it[2], d = it[3];
		if (arr[b-1] - arr[a-1] == c){
			curr += d;
		}

	}
	bst = max(bst, curr);
} 

// A recursive function to print all increasing sequences 
// of first n natural numbers. Every sequence should be 
// length k. The array arr[] is used to store current 
// sequence. 
void printSeqUtil(int n, int k, int &len, int arr[]) 
{ 
	// If length of current increasing sequence becomes k, 
	// print it 
	if (len == k) 
	{ 
		printArr(arr, k); 
		return; 
	} 

	// Decide the starting number to put at current position: 
	// If length is 0, then there are no previous elements 
	// in arr[]. So start putting new numbers with 1. 
	// If length is not 0, then start from value of 
	// previous element plus 1. 
	int i = (len == 0)? 1 : arr[len-1]; 

	// Increase length 
	len++; 

	// Put all numbers (which are greater than the previous 
	// element) at new position. 
	while (i<=n) 
	{ 
		arr[len-1] = i; 
		printSeqUtil(n, k, len, arr); 
		i++; 
	} 

	// This is important. The variable 'len' is shared among 
	// all function calls in recursion tree. Its value must be 
	// brought back before next iteration of while loop 
	len--; 
} 

// This function prints all increasing sequences of 
// first n natural numbers. The length of every sequence 
// must be k. This function mainly uses printSeqUtil() 
void printSeq(int n, int k) 
{ 
	int arr[k]; // An array to store individual sequences 
	int len = 0; // Initial length of current sequence 
	printSeqUtil(n, k, len, arr); 
} 

// Driver program to test above functions 
int main() 
{ 
	int k = 10, n = 10;
	int q; 
	cin >> k >> n >> q;

	for (int i = 0; i < q; ++i)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		v.push_back({a, b, c, d});
	}

	printSeq(n, k); 
	cout<<bst;
	return 0; 
} 


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<queue<int>> A(n);
    for (auto &a: A){
        for (int i = 0; i < n - 1; i++){
            int b;
            cin >> b;
            a.push(--b);
        }
    }

    queue<array<int, 3>> Q;
    vector<bool> used(n);
    for (int i = 0; i < n; i++){
        if (used[i])
            continue;
        if (used[A[i].front()])
            continue;
        if (A[A[i].front()].front() == i){
            Q.push({i, A[i].front(), 1});
            used[i] = true;
            used[A[i].front()] = true;
            A[A[i].front()].pop();
            A[i].pop();
        }
    }

    int ans = 0;
    vector<int> turns(n);
    while(!Q.empty()){
        array<int, 2> K = {Q.front()[0], Q.front()[1]};
        int turn = Q.front()[2];
        ans = max(ans, turn);
        Q.pop();
        for (const auto &i: K){
            if (A[i].empty() or A[A[i].front()].empty())
                continue;
            if (A[A[i].front()].front() == i){
                if (turns[i] >= turn or turns[A[i].front()] >= turn)
                    continue;
                Q.push({i, A[i].front(), turn + 1});
                turns[i] = turn;
                turns[A[i].front()] = turn;
                A[A[i].front()].pop();
                A[i].pop();
            }
        }
    }

    for (int i = 0; i < n; i++){
        if (A[i].size() > 1){
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main()
{
    int n;
    cin >> n;
    int sum = 0;

    int arr[205][205];
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            arr[i][j] = __gcd(i, j);
        }
    }

    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            for(int k=1; k<=n; k++)
            {
                int g = arr[i][j];
                sum += arr[g][k];
            }
        }
    }

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


Measured memory_bytes: 3952
n = int(input())
bounds = [list(map(int, input().split())) for _ in range(n)]
upper = sorted([b[1] for b in bounds])
lower = sorted([b[0] for b in bounds])

if n % 2 == 0:
	u_mid2 = upper[n // 2 - 1] + upper[n // 2]
	l_mid2 = lower[n // 2 - 1] + lower[n // 2]
	print(u_mid2 - l_mid2 + 1)
else:
	print(upper[n // 2] - lower[n // 2] + 1)


Measured memory_bytes: 50740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> count(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		if (a == 1 || b == n) {
			count[--a]++;
			count[--b]++;
		}
	}

	for (int i = 1; i < n - 1; i++) {
		if (1 < count[i]) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    string sa(a, (char)('0' + b));
    string sb(b, (char)('0' + a));
    cout << min(sa, sb) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m;
    cin >> m;
    cout << 48 - m << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=110;
int mp[maxn][maxn],h,w,n,a[maxn*maxn];
int main()
{
	scanf("%d%d",&h,&w);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int x=1,y=1,flag=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=a[i];j++)
		{
			mp[x][y]=i;
			y+=flag;
			if(y==0)
			{
				y=1;
				flag=1;
				x++;
			}
			if(y==w+1)
			{
				y=w;
				flag=-1;
				x++;
			}
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<w;j++)
			printf("%d ",mp[i][j]);
		printf("%d\n",mp[i][w]);
	}
	return 0;
}

Measured memory_bytes: 384
use std::collections::*;
use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: usize,
        m: usize,
        a: [usize; n]
    }

    let sum_vote: usize = a.iter().sum();
    let sum_vote = sum_vote as f64;
    let m = m as f64;
    let mut cnt = 0;
    for i in 0..a.len() {
        if a[i] as f64 >= sum_vote/(4.*m) {
            cnt += 1;
        }
    }

    println!("{}", if cnt as f64 >= m { "Yes" } else { "No" });

}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, llint> E;

llint H, W, h, w;

int main(void)
{
	cin >> H >> W >> h >> w;
	if(H%h == 0 && W%w==0){
		cout << "No" << endl;
		return 0;
	}
	
	cout << "Yes" << endl;
	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			if(i % h == 0 && j % w == 0) cout << -400*(h*w-1)-1 << " ";
			else cout << 400 << " ";
		}
		cout << endl;
	}
	
	return 0;
}


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    int H,W,K;
    cin>>H>>W>>K;
    V<V<char>> c(H,V<char>(W));
    REP(i,H) REP(j,W) cin>>c[i][j];

    LL ans = 0;
    for(LL i=0; i<(1LL<<(H+W)); i++){
        Vi row(H),col(W);
        for(LL j=0; j<(H+W);j++){
            if((i>>j)&1){
                if(j<H){
                    row[j] = 1;
                }else{
                    col[j-H] = 1;
                }
            }
        }
        int cnt = 0;
        REP(y,H){
            if(row[y] == 1) continue;
            REP(x,W){
                if(col[x] == 1) continue;
                if(c[y][x] == '#') cnt++;
            }
        }
        if(cnt==K) ans++;
    }

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

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;


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

    int h,a; cin >> h >> a;

    if(h%a==0)cout << h/a << endl;
    else cout << h/a + 1 << endl;


    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,a,b = LI()
    print(min(n*a,b))
    return

#B
def B():
    s = S()
    print(s.count("1"))
    return

#C
def C():
    n = list(map(int, S()))
    k = 0
    s = sum(n)
    for i in range(len(n)):
        k *= 10
        k += n[i]
    if k%s == 0:
        print("Yes")
    else:
        print("No")
    return

#D
def D():
    n = I()
    a = LI()
    ans = float("inf")
    for i in range(n):
        m = 0
        while a[i]%2 == 0:
            m += 1
            a[i] //= 2
        ans = min(m,ans)
    print(ans)
    return

#E
def E():
    n = I()
    f = LIR(n)
    p = LIR(n)

    return

#F
def F():
    n,k = LI()
    a = LI()
    d = defaultdict(int)
    for i in a:
        d[i] += 1
    d = list(d.values())
    d.sort()
    ans = 0
    for i in range(len(d)-k):
        ans += d[i]
    print(ans)
    return

#G
def G():
    n,c = LI()
    ch = LIR(n)
    T = [[0 for i in range(100002)] for j in range(c+1)]
    for s,t,cha in ch:
        T[cha-1][s] += 1
        T[cha-1][t+1] -= 1
    for i in range(c):
        for j in range(100000):
            T[i][j+1] += T[i][j]
            if T[i][j] >= 1:
                T[i][j] = 1
    ans = 0
    for i in range(100001):
        m = 0
        for j in range(c+1):
            m += T[j][i]
        ans = max(m,ans)
    print(ans)
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    G()


Measured memory_bytes: 128348
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int x,y; cin >> x >> y;
	int res = 0;
	if(x <= 3) res += 100000 * (4-x);
	if(y <= 3) res += 100000 * (4-y);
	if(x == 1 && y == 1) res += 400000;
	cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

int main(){
    ll n,k;cin>>n>>k;
    ll a[n+1];
    
    for(int i=1;i<=n;i++){
    	cin>>a[i];
	}
	
	ll vis[n+1]={};
	ll ct=1,node=1,cycle;
	
	while(vis[node]==0){
		vis[node]=1;
		//ct++;
		node=a[node];
		if(vis[node]!=0){
			cycle=node;
		}
	}
	
	node=1;
	
	while(node!=cycle){
		k--;
		node=a[node];
		if(k==0){
			cout<<node<<endl;return 0;
		}
	}
	
	node=cycle;
	for(int i=1;i<=n;i++){
		vis[i]=0;
	}
	
	while(vis[node]==0){
		vis[node]=ct;
		ct++;
		node=a[node];
	}
	
	ct--;
	k++;
	k=k-(k/ct)*ct;
	
	if(k==0){
		for(int i=1;i<=n;i++){
			if(vis[i]==ct){
				cout<<i<<endl;return 0;
			}
		}
	}
	
	for(int i=1;i<=n;i++){
			if(vis[i]==k){
				cout<<i<<endl;return 0;
		}
	}
	
	return 0;
}

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

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

    int UP,DOWN;
    UP   = s/100;
    DOWN = s%100;


    //YY -> 0~99 | MM -> 1~12
    int state = 0;
    if(DOWN >= 1 && DOWN <= 12){
        ++state;
    }
    if(UP >= 1 && UP <= 12){
        if(state == 0){
            cout<<"MMYY";
            state = -1;
        }
        if(state == 1){
            cout<<"AMBIGUOUS";
            state = -1;
        }
    }
    if(state == 0)cout<<"NA";
    if(state == 1)cout<<"YYMM";
}

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

int main(){

    long long D, G;
    cin >> D >> G;
    vector<long long> p(D), c(D);
    for(int i = 0; i < D; i++) cin >> p[i] >> c[i];

    long long ans = 1e12;
    for(int bit = 0; bit < (1 << D); bit++){
        
        long long sum = 0, num = 0;
        
        // コンプリートボーナスをゲットした場合
        for(int i = 0; i < D; i++){
            if(bit & (1 << i)){
                sum += c[i] + p[i] * (i + 1) * 100;
                num += p[i];
            }
        }

        // 得点の総和を満足しているかどうか
        if(sum >= G){
            ans = min(ans, num);
        }else{
            for(int i = D - 1; i >= 0; i--){
                // コンプリートボーナスを取っているところは飛ばす
                if(bit & (1 << i)) continue;
                for(int j = 0; j < p[i] && sum < G; j++){
                    sum += (i + 1) * 100;
                    num++;
                }
            }
            ans = min(ans, num);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, L;
    cin >> N >> L;
    int a[100010];
    rep(i, N) {
        cin >> a[i];
    }
    int maxpair = 0;
    int idx = 0;
    rep(i, N - 1) {
        if (maxpair < a[i] + a[i + 1]) {
            maxpair = a[i] + a[i + 1];
            idx = i + 1;
        }
    } 
    if (maxpair < L) {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    rep(i, N - 1) {
        if (i + 1 < idx) cout << i + 1 << endl;
        else break;
    }
    rrep(i, N - 1) {
        if (i > idx) cout << i << endl;
        else break;
    }
    cout << idx << endl;


    return 0;
}


Measured memory_bytes: 1280
n = int(input())
b = [int(i) for i in input().split()]
le = n
ans = []
for i in range(n):
  for j,bj in enumerate(b[::-1]):
    if j+bj > le:
      print(-1)
      exit()
    if j+bj == le:
      ans.append(bj)
      b = b[:le-j-1]+b[le-j:]
      le -= 1
      break
      
for i in ans[::-1]:
  print(i)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>
#include <map>
#include <set>
#include <functional>

using namespace std;

int main()
{
  int x;
  cin >> x;
  if (x == 1)
    cout << 0 << endl;
  else
    cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

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

    vector<int> u(n, 0);
    u[n-1] = s[n-1] - '0';
    int ten = 1;
    for(int i = n-2; i >= 0; i--){
        ten *= 10;
        ten %= 2019;
        int x = (s[i] - '0') * ten + u[i + 1];
        x %= 2019;
        u[i] = x;
    }

    int ans = 0;
    rep(i, n)if(u[i] == 0)ans++;
    map<int, int> mp;
    rep(i, n){
        mp[u[i]]++;
    }
    for(auto i = mp.begin(); i != mp.end(); i++){
        int k = i->second;
        if(k > 1){
            ans += k * (k - 1) / 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4360
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int N; cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++) cin >> X[i];


    long long ans = 1e18;
    for (int p = 0; p <= 100; p++) {
        long long tmp = 0;
        for (auto x : X) {
            tmp += (x - p) * (x - p);
        }
        ans = min(ans, tmp);
    }

    cout << ans << endl;
}


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

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, a[101010];

int main() {
	cin >> n;
	REP(i, n)cin >> a[i];
	int cnt = 0;
	REP(i, n) {
		int minj = i;
		for (int j = i; j < n; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}

		}
		if(a[i]!=a[minj])cnt++;
		swap(a[i], a[minj]);
	}
	REP(i, n)cout << a[i] << (i != n - 1 ? " " : "\n");
	cout << cnt << endl;
}


Measured memory_bytes: 3116
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  string s;
  cin >> s;
  rep(i,s.size())cout << "x";
  //cout << endl;
}

Measured memory_bytes: 256
io = STDIN
$ar=[]

n,$m=io.gets.split.map(&:to_i)
n.times do
  xyz=io.gets.split.map(&:to_i)
  $ar << xyz
end
def cnv(zyx,abc)
  zyx.zip(abc).inject(0){|s,(i,j)|s+i*j}
end
def calc(salt)
  $ar.map{|xyz|cnv(xyz,salt)}.sort_by{|a|-a}.take($m).inject(:+)||0
end
ans=0
[
[1,1,1],
[-1,1,1],
[1,-1,1],
[1,1,-1],
[-1,-1,1],
[-1,1,-1],
[1,-1,-1],
[-1,-1,-1],
].each do |salt|
  ans=[ans,calc(salt)].max
end
puts ans


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

int main(void){
   int n;
   cin>>n;
   vector<int> a(n);
   for(int i=0;i<n;i++){
      cin>>a[i];
   }
   vector<int> b(n);
   for(int i=0;i<n/2;i++){
      cout<<a[n-1-i*2]<<" ";
      a.erase(a.begin()+(n-1-i*2));
   }
   for(int i=0;i<a.size();i++){
      cout<<a[i]<<" ";
   }
   return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//コピペするとこ
struct card {char cha; int num;} ;

void print(vector<card> vec){
    int n = SZ(vec) ;
    REP(i,n){
		cout <<vec.at(i).cha ;
        cout <<vec.at(i).num ;
        if(i!=n-1){
            cout <<" ";
        }
    }
    cout <<endl ;
}

vector<card> bs(vector<card> vec){
    int n = SZ(vec) ;
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(vec.at(j).num<vec.at(j-1).num){
                card swap = vec.at(j) ;
                vec.at(j) = vec.at(j-1) ;
                vec.at(j-1) = swap ;
            }
        }
    }
    print(vec);
    cout <<"Stable"<<endl ;
    return vec ;
}

vector<card> ss(vector<card> vec){
    int n = SZ(vec) ;
    for(int i=0;i<n;i++){
        int minj = i ;
        for(int j=i;j<n;j++){
            if(vec.at(j).num<vec.at(minj).num){
                minj = j ;
            }
        }
        if(i!=minj){
            card swap = vec.at(i) ;
            vec.at(i) = vec.at(minj) ;
            vec.at(minj) = swap ;
        }
    }
    print(vec) ;
    return vec ;
}


//-------------------------------------------------


int main()
{
    int n ;
    cin >> n ;
    vector<card> car(n) ;
    vector<card> car1(n) ;
    vector<card> car2(n) ;
    REP(i,n){
        string s ;
        cin >> s ;
        car.at(i).cha = s.at(0) ;
        car.at(i).num = s.at(1)-'0' ;
    }
    car1 = bs(car) ;
    car2 = ss(car) ;
    
    bool flag = true ;
    
    REP(i,n){
        if(car1.at(i).num!=car2.at(i).num ||car1.at(i).cha!=car2.at(i).cha){
            flag = false ;
            break ;
        }
    }
    
    if(flag){
        cout <<"Stable"<<endl ;
    }
    else{
        cout <<"Not stable"<<endl;
    }
    
    
    return 0 ;
}


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

b = []

c = []

for i in range(a[0]):
    b.append(list(map(int,input().split())))

for i in range(a[0]):
    if b[i][1] <= a[1]:
        c.append(b[i])

c.sort()

if len(c) == 0:
    print("TLE")
else:
    print(c[0][0])

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 800005
#define ll long long
#define mod 924844033
int n, A[N], B[N], C[N], tot[N], fac[N], inv[N];
int cnt, tar[N], nex[N], fir[N], siz[N];
void Read(int &p)
{
	p = 0;
	char c = getchar();
	for (; c < '0' || c > '9'; c = getchar());
	for (; c >= '0' && c <= '9'; c = getchar())p = p * 10 + c - '0';
}
int Pow(int a, int k)
{
	if (!k)
		return 1;
	int p = Pow(a, k / 2);
	if (k & 1)
		return (ll)p * p % mod * a % mod;
	return (ll)p * p % mod;
}
int Add(int a, int b){return a + b >= mod ? a + b - mod : a + b;}
int Sub(int a, int b){return a - b < 0 ? a - b + mod : a - b;}
void DFT(int *A, int w, int f)
{
	for (int i = 1, j = 0; i < w; i++)
	{
		for (int d = w >> 1; j ^= d, ~j & d; d >>= 1);
		if (i < j)
			swap(A[i], A[j]);
	}
	for (int i = 1; i < w; i <<= 1)
	{
		int wn = Pow(5, (mod - 1) / (i << 1));
		if (f == -1)
			wn = Pow(wn, mod - 2);
		for (int j = 0; j < w; j += i << 1)
		{
			int w1 = 1;
			for (int k = 0; k < i; k++)
			{
				int x = A[j + k], y = (ll)A[j + k + i] * w1 % mod;
				A[j + k] = Add(x, y);
				A[j + k + i] = Sub(x, y);
				w1 = (ll)w1 * wn % mod;
			}
		}
	}
	if (f == -1)
	{
		int x = Pow(w, mod - 2);
		for (int i = 0; i < w; i++)
			A[i] = (ll)A[i] * x % mod;
	}
}
void Link(int a, int b)
{
	++cnt;
	tar[cnt] = b;
	nex[cnt] = fir[a];
	fir[a] = cnt;
}
void Dfs(int r, int fat)
{
	siz[r] = 1;
	for (int i = fir[r]; i; i = nex[i])
	{
		int v = tar[i];
		if (v != fat)
		{
			Dfs(v, r);
			tot[siz[v]]++;
			siz[r] += siz[v];
		}
	}
	tot[n - siz[r]]++;
}
int main()
{
	Read(n);
	for (int i = 1; i < n; i++)
	{
		int a, b;
		Read(a), Read(b);
		Link(a, b), Link(b, a);
	}
	Dfs(1, 0);
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = (ll)fac[i - 1] * i % mod;
	inv[n] = Pow(fac[n], mod - 2);
	for (int i = n; i >= 1; i--)
		inv[i - 1] = (ll)inv[i] * i % mod;
	for (int i = 1; i <= n; i++)
	{
		tot[i] = (ll)tot[i] * fac[i] % mod;
		A[i] = tot[i];
		B[i] = inv[n - i];
	}
	int w = 1;
	while (w <= 2 * n)w <<= 1;
	DFT(A, w, 1);
	DFT(B, w, 1);
	for (int i = 0; i < w; i++)
		C[i] = (ll)A[i] * B[i] % mod;
	DFT(C, w, -1);
	for (int i = n + 1; i <= 2 * n; i++)
	{
		int ans = (ll)C[i] * inv[i - n] % mod;
		ans = Sub((ll)fac[n] * inv[i - n] % mod * inv[2 * n - i] % mod * n % mod, ans);
		printf("%d\n", ans);
	}
}


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

int main()
{

    int n,x;
    while ( ~scanf("%d %d", &n, &x) )
    {
        int a[n];
        for (int i = 0; i < n; ++i)
        {
            scanf("%d", &a[i]);
        }

        long long cnt = 0;

        if ( a[0] > x )
        {
            cnt = a[0] -x;
            a[0] = a[0] - cnt;
        }
        for (int i = 1; i < n; ++i)
        {
            if ( a[i]+a[i-1] >x )
            {
                cnt = cnt + a[i]+a[i-1] -x;
                a[i] = a[i] - (a[i]+a[i-1] -x);
            }
        }
        printf("%lld\n", cnt);
    }
    return 0;
}


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

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}

#pragma endregion


#include <stdio.h>

#include<stdio.h>

int _atoi(char *s, int len);
int _atoi(char *s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}
int main()
{
	int  i, len,tmp=0, n=1000;
	char s[11];

	s_cin(s);
	len = strlen(s);
	for (i = 0; i < len; i++) {
		tmp = abs(_atoi(&s[i], 3) - 753);
		if (n > tmp) n = tmp;
	}
	i_cout(n);
	return 0;
}



Measured memory_bytes: 128
import sys

def is_prime(x):
    if((x % 2 == 0 and x > 2) or x < 2):
        return 0
    elif(x <= 5):
        return 1
    a = 3
    while(a * a <= x):
        if(x % a == 0):
            return 0
        a += 2
    return 1

l = []
for i in sys.stdin:
    l.append(int(i))

for data in l:
    count = 0
    data1 = [i for i in range(1,data+1)]
    data2 = [i for i in range(data,0,-1)]
    for i in range(0,data):
        count += 1 if(is_prime(data1[i]) == 1 and is_prime(data2[i]) == 1) else 0
    print(count)


Measured memory_bytes: 6964
n = int(input())
b = list(map(int, input().split()))
ans = []
for i in range(n, 0, -1):
    for j in range(i, 0, -1):
        if b[j-1] == j:
            ans.append(j)
            b.pop(j-1)
            break
    else:
        print(-1)
        break
else:
    for i in ans[::-1]:
        print(i)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
    static void Main()
    {
        var abk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        var limit = Math.Min(abk[0], abk[1]);
        var nums = new List<int>();
        for (int i = 1; i <= limit; i++)
        {
            if (abk[0] % i == 0 && abk[1] % i == 0)
            {
                nums.Add(i);
            }
        }

        Console.WriteLine(nums[nums.Count - abk[2]]);
    }
}

Measured memory_bytes: 13396
# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, K = map(int, input().split())
        S = input().rstrip()

        score = 0
        for i in range(N - 1):
            if S[i] == S[i + 1]:
                score += 1
        print(min(N - 1, score + 2 * K))
            

# Run main
if __name__ == '__main__':
    AtCoder().main()


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

int main() {

    int N,X,T;
    cin>>N>>X>>T;

    int a=N%X;
    int b=N/X;

    if(a!=0){

        cout<<(b+1)*T<<endl;
    }

    else{

        cout<<b*T<<endl;
    }
}


Measured memory_bytes: 3632