akhauriyash/Code-Regression huggingface dataset:
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

#define BUFF_SIZE 4096

typedef struct {
    intmax_t x;
    intmax_t y;
} COORDINATE;

typedef struct {
    intmax_t writeidx;
    intmax_t readidx;
    intmax_t count;
    COORDINATE buff[BUFF_SIZE];
} FIFO;

void fifo_init(FIFO *fifo)
{
    fifo->writeidx = 0;
    fifo->readidx = 0;
    fifo->count = 0;
}

void fifo_enqueue(FIFO *fifo, const COORDINATE *v)
{
    intmax_t i;

    if (v == NULL)
        return;

    if (fifo->count < BUFF_SIZE) {
        i = fifo->writeidx;
        fifo->count++;
        fifo->buff[i] = *v;
        fifo->writeidx = (i + 1) % BUFF_SIZE;
    }
}

int64_t fifo_dequeue(FIFO *fifo, COORDINATE *r)
{
    intmax_t i;

    if (r == NULL)
        return 1;

    if (fifo->count == 0)
        return 1;

    i = fifo->readidx;
    *r = fifo->buff[i];
    fifo->count--;
    fifo->readidx = (i + 1) % BUFF_SIZE;

    return 0;
}

int main(int argc, char const *argv[])
{
    intmax_t H, W;
    char S[50][51];
    intmax_t ans = 0;

    scanf("%jd%jd", &H, &W);
    for (int i = 1; i <= H; i++) {
        scanf("%s", &S[i][1]);
    }

    for (size_t sx = 1; sx <= W; sx++) {
        for (size_t sy = 1; sy <= H; sy++) {
            char s[50][51];
            intmax_t a[50][50] = { 0 };
            FIFO fifo;
            COORDINATE xy[5];

            if (s[sy][sx] == '#')
                continue;

            fifo_init(&fifo);

            for (int i = 1; i <= H; i++) {
                strcpy(&s[i][1], &S[i][1]);
            }

            xy[0].x = sx;
            xy[0].y = sy;

            s[xy[0].y][xy[0].x] = ',';
            fifo_enqueue(&fifo, &xy[0]);

            while (fifo_dequeue(&fifo, &xy[0]) == 0) {
                xy[1].x = xy[0].x - 1;
                xy[1].y = xy[0].y;
                xy[2].x = xy[0].x;
                xy[2].y = xy[0].y - 1;
                xy[3].x = xy[0].x + 1;
                xy[3].y = xy[0].y;
                xy[4].x = xy[0].x;
                xy[4].y = xy[0].y + 1;

                for (int i = 1; i < 5; i++) {
                    if (s[xy[i].y][xy[i].x] == '.') {
                        a[xy[i].y][xy[i].x] = a[xy[0].y][xy[0].x] + 1;
                        s[xy[i].y][xy[i].x] = ',';
                        fifo_enqueue(&fifo, &xy[i]);
                    }
                }
            }

            for (size_t gy = 1; gy <= H; gy++) {
                for (size_t gx = 1; gx <= W; gx++) {
                    if (a[gy][gx] > ans) {
                        ans = a[gy][gx];
                    }
                }
            }
        }
    }

    printf("%jd\n", ans);
}


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

template<class T> bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}

template<class T> bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

const ll MAX = 100010;

int main(int argc, char **argv)
{
	ll n; cin >> n;
	ll h[MAX], dp[MAX];

	for (ll i = 0; i < n; ++i) cin >> h[i];
	for (ll i = 0; i < n; ++i) dp[i] = INF;

	dp[0] = 0;
	for (ll i = 0; i < n; ++i)
	{
		chmin(dp[i+1], abs(h[i]-h[i+1])+dp[i]);
		chmin(dp[i+2], abs(h[i]-h[i+2])+dp[i]);
	}

	std::cout << dp[n-1] << std::endl;

}


Measured memory_bytes: 1792
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;



int main()
{
	ll N, D, A;
	cin >> N >> D >> A;

	std::vector<std::pair<ll, ll>> E(N);
	std::list<std::pair<ll, ll>> B;

	for (ll i = 0; i < N; ++i)
	{
		cin >> E[i].first >> E[i].second;
	}
	sort(E.begin(), E.end());

	ll Damage = 0;
	ll Times = 0;
	for (ll i = 0; i < N; ++i)
	{
		ll x = E[i].first;

		while (!B.empty() && B.front().first < x)
		{
			Damage -= B.front().second;
			B.pop_front();
		}

		ll HP = E[i].second - Damage;
		
		ll t = std::max
		(
			HP / A + (HP%A != 0),
			0ll
		);
		if (HP < 0) { t = 0; }

		Damage += A*t;
		B.emplace_back(x + 2 * D, A*t);
		Times += t;
	}
	cout << Times << endl;

	return 0;
}

Measured memory_bytes: 12800
import Control.Applicative
import Control.Monad
import Data.List

solve :: Int -> [Int] -> Int
solve n as = sum cs
  where
    bs = take (2 * n) (sortBy (flip compare) as)
    f [] = []
    f (x:y:ys) = y : f ys
    cs = f bs

main :: IO ()
main = do
    n <- readLn :: IO Int
    as <- fmap read . words <$> getLine :: IO [Int]
    print $ solve n as

Measured memory_bytes: 119164
#include <iostream>

using namespace std;

int main()
{
    int a,b,multiple;
    cin>>a>>b;
    if((a>=1 && a<=9) && (b>=1 && b<=9))
    {
      multiple = a*b;
      cout<<multiple<<endl;
    }
    else
        cout<<"-1"<<endl;
    return 0;
}


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

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
Node * find(Node *u, int k) {
    while(u != NIL && k != u->key) {
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}
int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
        if(com[0] == 'f') {
            scanf("%d",&x);
            Node *t = find(root,x);
            if(t != NIL) printf("yes\n");
            else printf("no\n");
        } else if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 20612
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int n, W, v[101], w[101];
ll dp[100001];
int main()
{
    IOS
    //bfreopen("balalance.in", "r", stdin);
    cin >> n >> W;
    for (int i = 0; i < n; ++i) {
        cin >> w[i] >> v[i];
    }
    for (int i = 0; i < n; ++i) {
        for (int rem = W; rem >= w[i]; --rem) {
            dp[rem] = max(dp[rem], v[i]+dp[rem-w[i]]);
        }
    }
    cout << dp[W] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}

int main(){
    ll k,a,b;
    cin >> k >> a >> b;
    nfor(i, a, b + 1){
        if(i % k == 0){
            pf("OK");
            return 0;
        }
    }
    pf("NG");
    return 0;
}



Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define in auto&it
#define out auto it 
#define rep(i,si,n) for(int i=si;i<n;++i)
#define all ar.begin(),ar.end()
const double pi=acos(-1);
int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		//freopen("error.txt","w",stderr);
	#endif
	fastio
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;++i){
		ans=(ans*10+7)%n;
		if(!ans){
			cout<<i;
			return 0;
		}
	}
	cout<<-1;
	//cerr<<"time:  "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<'\n';
	return 0;
}


Measured memory_bytes: 3656
import math
a,b,c=map(int,input().split())
print('{:.5f}'.format(a*b*math.sin(math.radians(c))/2))
print('{:.5f}'.format(a+b+(a**2+b**2-2*a*b*math.cos(math.radians(c)))**(1/2)))
print('{:.5f}'.format(b*math.sin(math.radians(c))))


Measured memory_bytes: 5724
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;



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

    vvi dis(n, vi(n, -1));
    rep(i, n) {
        queue<int> q;
        q.push(i);
        dis[i][i] = 0;
        while(!q.empty()) {
            int now = q.front();
            q.pop();
            if(now == x) {
                if(dis[i][y] == -1) {
                    q.push(y);
                    dis[i][y] = dis[i][now]+1;
                } 
            }
            if(now == y) {
                if(dis[i][x] == -1) {
                    q.push(x);
                    dis[i][x] = dis[i][now]+1;
                } 
            }
            if(now && dis[i][now-1] == -1) {
                q.push(now-1);
                dis[i][now-1] = dis[i][now]+1;
            }
            if(now != n-1 && dis[i][now+1] == -1) {
                q.push(now+1);
                dis[i][now+1] = dis[i][now]+1; 
            }
        }
    }
    vi ans(n-1);
    rep(i, n) {
        rep(j, n) {
            if(!dis[i][j]) continue;
            ans[dis[i][j]-1]++;
        }
    }

    rep(i, n-1) {
        cout << ans[i]/2 << endl;
    }
}

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

int main(){
	int N, K;
	long long ans = 0;
	cin >> N >> K;
	
	ans += K;
	for(int i = 1; i < N; ++i){
			ans *= K - 1;
	}
	cout << ans << endl;	
}

Measured memory_bytes: 256
w = int(input())
n = int(input())
li = list(range(1, w + 1))
for i in range(n):
    a, b = map(int, input().split(','))
    a -= 1; b -= 1
    li[a], li[b] = li[b], li[a]

for x in li:
    print(x)

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

#define F first
#define S second

using namespace std;
typedef long long ll;

const int max_n = 500022, inf = 1000111222;

int n, m, a, b;

int main() {
  cin >> n >> m >> a >> b;
  for (int i = 0; i < n; ++i) {
    for (int q = 0; q < m; ++q) {
      cout << (((q < a) ^ (i < b)) ? 0 : 1);
    } cout << "\n"; }
  return 0;
}


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

const bool DEBUG = false;

int N;
vector<long long> A;

vector<long long> dp;

void input() {
  cin >> N;
  A = vector<long long>(N);
  for (size_t i = 0; i < N; i++) cin >> A[i];
}

long long lis(const vector<long long>& x) {
  // longest increasing subsequence
  dp = vector<long long>(x.size(), 1e18);
  for (size_t i = 0; i < x.size(); i++) {
    decltype(dp)::iterator itr = lower_bound(dp.begin(), dp.end(), x[i]);
    *itr = x[i];
  }
  return distance(dp.begin(), lower_bound(dp.begin(), dp.end(), 1e18));
}

long long lnis(const vector<long long>& x) {
  // longest non-increasing subsequence
  auto y = x;
  reverse(y.begin(), y.end());
  dp = vector<long long>(x.size(), 1e18);
  for (size_t i = 0; i < x.size(); i++) {
    decltype(dp)::iterator itr = upper_bound(dp.begin(), dp.end(), y[i]);
    *itr = y[i];
  }
  return distance(dp.begin(), lower_bound(dp.begin(), dp.end(), 1e18));
}

int main(int argc, char const* argv[]) {
  input();
  cout << lnis(A) << endl;
  return 0;
}


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

int main(void)
{
	int a, b, C;
	double c, rad;
	
	scanf("%d %d %d", &a, &b, &C);
	
	rad = C*M_PI/180;
	c = sqrt(a*a+b*b-2*a*b*cos(rad));
	
	printf("%f\n", (a*b*sin(rad))/2.0);
	printf("%f\n", a+b+c);
	printf("%f\n", b*sin(rad));
	
	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,X;
int A[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>X;
	FOR(i,N) cin>>A[i];
	ll tot=0;
	
	FOR(i,N-1) {
		if(i==0) {
			if(A[i]+A[i+1]>X) {
				x = min(A[i+1],A[i]+A[i+1]-X);
				tot+=x;
				A[i+1]-=x;
				if(A[i]+A[i+1]>X) {
					tot += A[i]-X;
				}
			}
			
		}
		else {
			if(A[i]+A[i+1]>X) {
				x = A[i]+A[i+1]-X;
				tot+=x;
				A[i+1]-=x;
			}
		}
	}
	cout<<tot<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

typedef long long ll;


int main() {

    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);


    long long int n = 0, a = 0, b = 0;
    cin >> n >> a >> b;
    long long ans = n/(a + b) * a;
    if(n%(a + b) > a) ans+= a;
    else ans += n%(a + b);

    cout << ans << endl;
    
    
}


Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

// long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a;
// }

// int binary_search(int key) {
//     int ng = -1;
//     int ok = (int)a.size();
//     while(abs(ok - ng) > 1) {
//         int mid = (ok + ng) / 2;
//         if(isOK(mid, key))
//             ok = mid;
//         else
//             ng = mid;
//     }
//     return ok;
// }

// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W
// int MOD = 1000000007;

int main() {
    string S;
    cin >> S;
    auto f = [](string s) {
        int L = s.length();
        for(int i = 0; i < L / 2; i++) {
            if(s[i] != s[L - i - 1]) {
                return false;
            }
        }
        return true;
    };

    string ans = "No";
    int L = S.length();
    if(f(S) && f(S.substr(0,(L-1)/2)) && f(S.substr((L+3)/2-1, L-(L+3)/2+1))){
        ans = "Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

#define MAX_V 100010


struct edge{
    int to;
    int cost;
};

int V;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>>que;
    fill(d, d + MAX_V, INF * INF);
    d[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v] < p.first)continue;

        for(int i = 0; i < G[v].size(); i++){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(){
   cin >> V;
   rep(i, V - 1){
       ll a, b, c;
       cin >> a >> b >> c;
       edge e1 = {b, c};
       edge e2 = {a, c};

       G[a].push_back(e1);
       G[b].push_back(e2);
   }

   int q, k;
   cin >> q >> k;
   dijkstra(k);

   rep(i, q){
       ll x, y;
       cin >> x >> y;
       cout << d[x] + d[y] << endl;
   }
}



Measured memory_bytes: 8820
#include<bits/stdc++.h>
const int MAXN = 4e5 + 10;
using namespace std;
int n;
int A[MAXN], B[MAXN], ta[MAXN], tb[MAXN], sa, sb, tot = 0, date[MAXN], fa[MAXN];
int find(int x) {
    return fa[x] == x ? fa[x] : fa[x] = find(fa[x]);
}
int unionn(int x, int y) {
    fa[x] = y;
}
int main() {
    scanf("%d",&n);
    for(int i = 1; i <= n; i++)scanf("%d",&A[i]),sa ^= A[i]; A[n + 1] = sa;
    for(int i = 1; i <= n; i++)scanf("%d",&B[i]),sb ^= B[i]; B[n + 1] = sb;
    n++;
    memcpy(ta, A, sizeof(A)); memcpy(tb, B, sizeof(B));
    sort(ta + 1, ta + n + 1); sort(tb + 1, tb + n + 1);
    for(int i = 1; i <= n - 1; i++) if(ta[i] != tb[i]) return puts("-1"), 0;
 
    int ans = 0, sum = 0;
    for(int i = 1; i <= n; i++) 
        if(A[i] != B[i] || (i == n)) {
            date[++sum] = A[i]; date[++sum] = B[i];
            if(i < n)ans++;
        }
    if(ans == 0) return puts("0"), 0;
 
    sort(date + 1, date + sum + 1);
    sum = unique(date + 1, date + sum + 1) - date - 1;
    for(int i = 1; i <= sum; i++) fa[i] = i;
    for(int i = 1; i <= n; i++)
        if(A[i] != B[i]) {
            A[i] = lower_bound(date + 1, date + sum + 1, A[i]) - date;
            B[i] = lower_bound(date + 1, date + sum + 1, B[i]) - date;
            unionn(find(A[i]), find(B[i]));
        }
 
    for(int i = 1; i <= sum; i++)
        if(fa[i] == i) ans++;
    printf("%d", ans - 1);
 
    return 0;
}

Measured memory_bytes: 8832
#include <iostream>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)

typedef struct{ string name; int time; } Proc;

int main(void){
    int N, Q;
    cin >> N >> Q;
    
    queue<Proc> que;
    rep(i, N) {
        Proc p;
        cin >> p.name >> p.time;
        que.push(p);
    }
    
    int sum = 0;
    while(!que.empty()){
        Proc p = que.front(); que.pop();
        if(p.time <= Q){
            sum += p.time;
            cout << p.name << " " << sum << endl;
        }else{
            sum += Q;
            p.time -= Q;
            que.push(p);
        }
    }
    
    return 0;
}


Measured memory_bytes: 6288
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const int P = 998244353;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
map <string, int> dp;
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int solve(string s) {
	if (dp.count(s)) return dp[s];
	int &ans = dp[s]; ans = 0;
	if (s.size() == 0) return ans = 1;
	if (s.size() == 1) return ans = s[0] - '0' + 1;
	int len = s.size(); string x, y; x.push_back(s[0]);
	for (int i = 1; i < len; i++) y.push_back(s[i]);
	update(ans, 1ll * solve(x) * solve(y) % P);
	for (int i = 1; i <= len / 2; i++) {
		string x; for (int j = 1; j <= i; j++)
			x.push_back(s[j - 1]);
		for (int j = i + 1, k = 2 * i; k <= len; j += i, k += i) {
			for (int l = j; l <= k; l++)
				chkmin(x[l - j], s[l - 1]);
			string y; for (int l = k + 1; l <= len; l++)
				y.push_back(s[l - 1]);
			update(ans, 1ll * solve(x) * solve(y) % P);
		}
	}
	return ans;
}
int main() {
	string s; cin >> s;
	writeln(solve(s));
	return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<utility>
#include<vector>

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

using namespace std;

int main(int argc, char const *argv[]) {
    int x;
    cin >> x;

    for(int i=0;i<=25;i++){
        for(int j=0;j<=14;j++){
            if(4*i+7*j == x){
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a,b,c,k;
    scanf("%d %d %d", &a, &b, &c);
    scanf("%d", &k);
    while(b <= a){
        b *= 2;
        k--;
    }
    while(c <= b){
        c *= 2;
        k--;
    }
    (k >= 0)? printf("Yes") : printf("No");
}

Measured memory_bytes: 1728
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#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++)
const long long INF =  999999999;

int p[2][10];
int main(){
  int N;
  cin>>N;
  vector<int> v(N);

  REP(i,N){
    cin>>p[0][i];
    v[i]=p[0][i];
  }
  sort(v.begin(),v.end());

  REP(i,N){
    cin>>p[1][i];
  }
  int a[2];
  REP(j,2){
    int count=0;
    do {
          count++;
          bool flag=true;
          REP(i,N){
            if(p[j][i]!=v[i]){
              flag=false;
              break;
            }
          }
          if(flag)a[j]=count;
    } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成
  }
  cout<<abs(a[1]-a[0])<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <map>
#include <cmath>
#include <bitset>
#include <deque>
#define MAX_N 100
#define MAX_T 200
#define INF (1LL<<31)
#define fst first
#define snd second
typedef long long ll;
typedef std::pair<int,int> ii;
using namespace std;
 
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max(0, min(b,d)-max(a,c))<<endl;
  return 0;
}


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

int main()
{
  float r;
  cin >> r;
  cout << 2.000000000 * r * 3.14159265358979 << endl;
  return 0;
}


Measured memory_bytes: 3784
def re_push(stack,num):#re_push and return max
    count = 0
    pre = num
    ma = 0
    while True:
        count += 1
        cur = stack.pop()
        if cur <= num:
            ma = max(ma,(count-1) * pre)
            stack += [cur]
            stack += [num]*(count-1)
            break
        if cur < pre:
            ma = max(ma,(count-1) * pre)
            stack += [cur]*count
            count = 0
        pre = cur
    return ma
            
while True:
    H,W = map(int, raw_input().split(" "))
    if (H,W) == (0,0):
        break
    field = [raw_input() for _ in xrange(H)]
    table = [[0]*(W+1) for _ in xrange(H)]
    for y in xrange(H-1,-1,-1):
        for x in (x for x in xrange(W-1,-1,-1) if field[y][x] != "*"):
            table[y][x] = table[y][x+1] + 1
    ma = 0
    for x in xrange(W):
        stack = [0,table[0][x]]
        for y in xrange(1,H):
            if table[y-1][x] > table[y][x]:
                ma = max(ma, re_push(stack,table[y][x]))
            stack.append(table[y][x])
        ma = max(ma, re_push(stack,0))
    print ma

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



int main(){
  set<char> r;
  r.insert('q');
  r.insert('w');
  r.insert('e');
  r.insert('r');
  r.insert('t');
  r.insert('a');
  r.insert('s');
  r.insert('d');
  r.insert('f');
  r.insert('g');
  r.insert('z');
  r.insert('x');
  r.insert('c');
  r.insert('v');
  r.insert('b');


  while(1){
  int count=0;
  char w='l';
  string s;
  getline(cin,s);
  if(s=="#"){break;}
  if(r.find(s[0])!=r.end()){w='r';}
  for(int i=1;i<s.size();i++){
    if(r.find(s[i])!=r.end() && w=='l'){w='r'; count++; continue;}
    if(r.find(s[i])==r.end() && w=='r'){w='l'; count++;}
  }
  cout<<count<<endl;
  }
  return 0;
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
bool edge[3030][3030]; 
ll a[3030][3030];
int n;
ll ans;
bool flag;
int main()
{
	cin>>n;
	REP(i,n)
		REP(j,n)
			cin>>a[i][j];
	REP(k,n)
		REP(i,n)
			REP(j,n)
			{
				if(i==j||i==k||j==k)continue;
				if(a[i][j]==a[i][k]+a[k][j])
                    edge[i][j]=1; 
                if(a[i][j]>a[i][k]+a[k][j])
                    flag=1;
			 } 
	if(flag){
		cout<<-1<<endl;
		return 0;
	}
	REP(i,n)
		REP(j,n)
			if(!edge[i][j])ans+=a[i][j];
	cout<<ans/2<<endl;		
	return 0;
}


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

long long GCD(long long a, long long b)
{
    if (a < b) swap(a, b);

    if (b == 0) return a;

    long long mod = a % b;
    a = b;
    b = mod;
    return GCD(a, b);
}

int main()
{
    long long A, B;
    cin >> A >> B;

    long long gcd = GCD(A, B);
    long long lcm = A * B / gcd;

    cout << lcm << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a [32]int = [32]int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
	var p int
	fmt.Scanf("%d",&p)
	fmt.Println(a[p-1])

}

Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;
#define LL long long

LL N,M,ans,r,a,col[8];

pair<LL, LL>bc;
vector<pair<LL, LL>>BC;
int main() {
	vector<LL> A;
	cin >> N;


	for (int i = 0; i < N; i++) {
		cin >> a;
		if (a < 3200) {
			for (int j = 0; j < 8; j++) {
				if(a>=400*j&&a<400*(j+1))
				col[j]++;
			}
		}
		else r++;
		}
	for (int i = 0; i < 8; i++) {
		if (col[i] > 0)ans++;
	}
		M = ans + r;
	if (ans == 0)ans = 1;
		cout<<ans<<" "<<M<<endl;


	return 0;

}


Measured memory_bytes: 256
import math
a,b,C=map(int,input().split())
c=(a**2+b**2-2*b*a*math.cos(math.radians(C)))**0.5
L=a+b+c
s=(a+b+c)/2
S=(s*(s-a)*(s-b)*(s-c))**0.5
h=2*S/a
print(S,L,h,sep='\n')


Measured memory_bytes: 5728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
    private static final Object[] Compiler = null;

    public static void main(String[] args)throws IOException{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String[] nk = input.readLine().split(" ");
        int n = Integer.parseInt(nk[0]);
        int k = Integer.parseInt(nk[1]);
        String[] array = input.readLine().split(" ");
        List<Long> list =
            Arrays
              .stream(array)
              .map(Long::valueOf)
              .collect(Collectors.toList());;
        long time = 0;
        if(n<=k){
            System.out.println(0);
            return;
        }
        //asList(s);は固定長のlistを返す
        //List<Integer> list = Arrays.asList(hn);

        Collections.sort(list,Collections.reverseOrder());
        if(k>0){
            list.subList(0, k).clear();
        }
        time = list.stream()
                   .mapToLong(Long::longValue)
                   .sum();
        System.out.println(time);

        }

    }


Measured memory_bytes: 68504
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

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

type Job struct {
	A, B int
}

func main() {
	defer stdout.Flush()
	N := readInt()
	J := make([]Job, N)
	for i := range J {
		J[i].A = readInt()
		J[i].B = readInt()
	}

	pq := new(PriorityQueue)

	for _, x := range J {
		// push(x)
		heap.Push(pq,x)
	}
	t := 0
	for pq.Len() != 0  {
		j := heap.Pop(pq).(Job)
		t += j.A
		if j.B < t {
			println("No")
			return
		}
	}
	println("Yes")

}

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

type PriorityQueue []Job

func (pq PriorityQueue) Len() int {
	return len(pq)
}

func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].B < pq[j].B
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *PriorityQueue) Push(x interface{}) {
	old := *pq
	*pq = append(old, x.(Job))
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old) - 1
	x := old[n]
	*pq = old[:n]
	return x
}

Measured memory_bytes: 20224
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。(int64_t)
int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    for(ll i = 1; i <= N; i++){
        if(i % 3 != 0 && i % 5 != 0){
            ans+=i;
        }
    }
    cout << ans << endl;
}


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

int main(){
	vector<int> v(394, -1000000000);
	v[0] = 0;
	int n, m, s, l, p, w;
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> s >> l >> p;
		for(int j = s; j < 394; ++j){
			for(int k = min(j, l); k >= s; --k){
				v[j] = max(v[j], v[j-k] + p);
			}
		}
	}

	cin >> m;
	vector<int> ans(m);
	for(int i = 0; i < m; ++i){
		cin >> w;
		ans[i] = v[w];
	}
	if(*min_element(ans.begin(), ans.end()) < 0){
		ans.assign(1, -1);
	}
	for(int i = 0; i < ans.size(); ++i){
		cout << ans[i] << '\n';
	}
}

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

int n;
long long sum1[200004], xor1[200004];

int main() {
	cin>>n;
	long long t;
	sum1[0] = 0, xor1[0] = 0;
	for(int i = 1;i<=n;i++){
		cin>>t;
		sum1[i] = sum1[i-1]+t;
		xor1[i] = (xor1[i-1]^t);
	}
	long long cnt = 0;
	int lo = 0, hi = 1;
	for(hi = 1;hi<=n;hi++){
		while(sum1[hi]-sum1[lo] != (xor1[hi]^xor1[lo]))	lo++;
		cnt += hi-lo;
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
using namespace std;
#include<vector>
#include<algorithm>
struct rangefreq{
	int n;
	vector<vector<int> >dat;
	rangefreq(const vector<int>&v={})
	{
		n=1;
		while(n<v.size())n<<=1;
		dat.assign(2*n-1,{});
		for(int i=0;i<v.size();i++)dat[i+n-1].push_back(v[i]);
		for(int i=n-2;i>=0;i--)
		{
			dat[i].resize(dat[i*2+1].size()+dat[i*2+2].size());
			merge(dat[i*2+1].begin(),dat[i*2+1].end(),
				dat[i*2+2].begin(),dat[i*2+2].end(),
				dat[i].begin()
			);
		}
	}
	int query(int a,int b,int x,int k=0,int l=0,int r=-1)//[a,b) count(*<x)
	{
		if(r<0)r=n;
		if(b<=l||r<=a)return 0;
		else if(a<=l&&r<=b)return lower_bound(dat[k].begin(),dat[k].end(),x)-dat[k].begin();
		else return query(a,b,x,k*2+1,l,(l+r)/2)+query(a,b,x,k*2+2,(l+r)/2,r);
	}
};
int n,m,q;
main()
{
	cin>>n>>m>>q;
	vector<int>x,y;
	vector<pair<int,int> >xy;
	for(int i=0;i<m;i++)
	{
		int a,b;cin>>a>>b;
		x.push_back(a);
		y.push_back(b);
		xy.push_back(make_pair(a,b));
	}
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	sort(xy.begin(),xy.end());
	vector<int>id;
	for(int i=0;i<m;i++)
	{
		id.push_back(lower_bound(y.begin(),y.end(),xy[i].second)-y.begin());
	}
	rangefreq P(id);
	for(int i=0;i<q;i++)
	{
		int a,b;cin>>a>>b;
		int xl=lower_bound(x.begin(),x.end(),a)-x.begin();
		int xr=upper_bound(x.begin(),x.end(),b)-x.begin();
		int yl=lower_bound(y.begin(),y.end(),a)-y.begin();
		int yr=upper_bound(y.begin(),y.end(),b)-y.begin();
		cout<<P.query(xl,xr,yr)-P.query(xl,xr,yl)<<endl;
	}
}

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

#define rep1(i, a, n) for (int i = a; i < n; i++)
#define rep2(i, a, n) for (int i = n; i >= a; i--)
#define asc(v) sort(v.begin(), v.end())
#define desc(v) sort(v.begin(), v.end(), greater<int>())

using namespace std;

int main() {
  int N, cnt = 0;
  cin >> N;
  rep1(i, 0, N) {
    int a;
    cin >> a;
    while (a % 2 == 0) {
      a = a / 2;
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, d;
    cin >> n >> d;
    int each = 2*d + 1;
    if(n%each == 0)
        cout << n/each << '\n';
    else
        cout << n/each + 1 << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

const int CN = 3e5 + 5;

int read(){
    int s = 0,ne = 1; char c = getchar();
    while(c < '0' || c > '9') ne = c == '-' ? -1 : 1, c = getchar();
    while(c >= '0' && c <= '9') s = (s << 1) + (s << 3) + c - '0', c = getchar();
    return s * ne;
}

int H, W, M; vector<int> line[CN];
class SGT {
  public: int d[CN << 2];
    #define lc k << 1
    #define rc k << 1 | 1
    void md(int l, int r, int k, int p, int x){
        if(l == r) return (void)(d[k] += x);
        int m = (l + r) >> 1; if(p <= m) md(l, m, lc, p, x); else md(m + 1, r, rc, p, x);
        d[k] = max(d[lc], d[rc]);
    }
    int qu() {return d[1];}
} D;

int main()
{
    // freopen("_in.in", "r", stdin);

    H = read(), W = read(), M = read();
    for(int i = 1; i <= M; i++){
        int h = read(), w = read(); line[h].push_back(w), D.md(1, W, 1, w, 1);
    }

    int ans = 0;
    for(int i = 1; i <= H; i++){
        int sz = line[i].size();
        for(int j = 0; j < sz; j++) D.md(1, W, 1, line[i][j], -1);
        ans = max(ans, sz + D.qu());
        for(int j = 0; j < sz; j++) D.md(1, W, 1, line[i][j], 1);
    }

    printf("%d", ans);
}

Measured memory_bytes: 24232
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int a, b, m;
    cin >> a >> b >> m;
    vector<int> v(a), u(b);
    rep(i, a) cin >> v[i];
    rep(i, b) cin >> u[i];

    vector<int> res(m);
    rep(i, m){
        int x, y, c;
        cin >> x >> y >> c;
        res[i] = v[x-1] + u[y-1] - c;
    }
    sort(all(res));

    sort(all(v));
    sort(all(u));
    cout << min(res[0], v[0]+u[0]) << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	vi conto1;
	vi contoN;
	makei(N);
	makei(M);
	rep(M) {
		makei(a);
		makei(b);
		if (a == 1)conto1.push_back(b);
		else if (b == 1)conto1.push_back(a);
		else if (a == N)contoN.push_back(b);
		else if (b == N)contoN.push_back(a);
	}
	sort(all(conto1));
	sort(all(contoN));
	auto it1 = conto1.begin();
	auto itN = contoN.begin();
	while (it1 != conto1.end() && itN != contoN.end()) {
		if ((*(it1)) == (*(itN))) { say("POSSIBLE"); re; }
		else if ((*(it1)) < (*(itN)))++it1;
		else ++itN;
	}
	say("IMPOSSIBLE");
}

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

using namespace std;

class DisjointSet {
private:
	vector<int> rank, size, p;
	int num = 0;
public:
	DisjointSet() {}
	DisjointSet(int n) {
		num = n;
		rank.assign(n, 0);
		size.assign(n, 1);
		p.assign(n, 0);
		for (int i = 0; i < n; i++) p[i] = i;
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	void unite(int x, int y) {
		x = root(x), y = root(y);
		if (x == y) return;
		num--;
		if (rank[x] > rank[y]) {
			p[y] = x;
			size[x] += size[y];
		} else {
			p[x] = y;
			size[y] += size[x];
			if (rank[x] == rank[y]) rank[y]++;
		}
	}

	int root(int x) {
		return p[x] == x ? x : p[x] = root(p[x]);
	}

	int get_size(int x) {
		return size[root(x)];
	}

	int forest_size() {
		return num;
	}
};

int main() {
	int n, m; cin >> n >> m;
	DisjointSet dj(n);
	while (m--) {
		int a, b; cin >> a >> b;
		dj.unite(a - 1, b - 1);
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) ans = max(ans, dj.get_size(i));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5636
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>


using namespace std;
typedef long long ll;


int main(){

    ll N, M;
    cin >> N >> M;

    vector<pair <ll, ll> > PY(M);
    vector<ll > num(N, 0);
    vector<vector<ll > > memo;
    memo = vector<vector<ll >>(N, vector<ll >(0, 0));

    vector<vector<pair<int,int>>> t_memo(N);

    ll P, Y;

    for(ll i = 0; i < M; i++){
        cin >> P >> Y;
        memo[P-1].push_back(Y);
        t_memo[P-1].push_back(make_pair(Y,i));      
    }

    for(ll i = 0; i < N; i++){
        sort(t_memo[i].begin(), t_memo[i].end());
    }

    vector<string > result(M, "");
    
    for(ll i = 0; i < N; i++){
        if(t_memo[i].size() == 0){
            continue;
        }
        for(ll j = 0; j < t_memo[i].size(); j++){
            //ll t = t_memo[i][j].first;
            //t_memo[i][j].first = t_memo[i][j].second;
            //t_memo[i][j].second = t;
            ostringstream ss;
            ss << setw(6) << setfill('0') << to_string(i+1) << setw(6) << setfill('0') << to_string(j+1);
    
            result[t_memo[i][j].second] = ss.str();
            //cout << "(" << t_memo[i][j].first << ":" << t_memo[i][j].second << ")" ;
        }
    }
    
    //表示
    for(ll i = 0; i < M; i++){
        cout << result[i] << endl;
    }

    

}

Measured memory_bytes: 20224
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAX=10005;
const int INF=0x3f3f3f3f;
const int MOD=1000000007;
int n,ans=INF;
int f(int x){
    if(x==0) return 0;
    return f(x/10)+x%10;
}
int main(){
    scanf(" %d",&n);
    for(int i=1;i<n;i++){
        ans=min(ans,f(i)+f(n-i));
    }
    printf("%d\n",ans);
}


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

int main() {
  double N, T, A;
  cin >> N >> T >> A;
  vector<double> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  double mi = 1e9;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    double tmp = abs(A - (T - H.at(i) * 0.006));
    if (tmp < mi) mi = tmp, ans = i + 1;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7
struct Edge {
	int from, to, cost;
	Edge(int from, int to, int cost)
		: from(from), to(to), cost(cost) {};
};

typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main()
{
	ll n;
	ll x;
	ll res = 0;

	cin >> n >> x;

	cout << 3 * (n - gcd(n,x)) << endl;
	return 0;
}

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


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                long A = scan.nextLong();
                double B = scan.nextDouble()+0.001;
                long x = (long)B;
                double B1 = (B-x)*10;
                long y = (long)B1;
                double B2 = (B1-y)*10;
                long z = (long)B2;

                long ans1 = (A*(100*x+10*y+z))/100;
                System.out.println(ans1);
        }
}

Measured memory_bytes: 37336
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())
As = []
Bs = []
movies = [[] for x in range(31)]
for n in range(N):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    As.append(a)
    Bs.append(b)
    for day in range(a, b+1):
        movies[day].append(n)

picked = [False] * N
ans = 0
for day in range(31):
    # ????????????????????????
    unseen_movies = [m for m in movies[day] if not picked[m]]

    # ???????????????????????????
    if len(unseen_movies) == 0:
        ans += 50
    else:
        # ????????????????????????????????????????????£??¨????????????????????????????????????
        lastday = 1000
        should_see = -1
        for m in unseen_movies:
            if Bs[m] < lastday:
                lastday = Bs[m]
                should_see = m
        picked[should_see] = True
        ans += 100
print(ans)

Measured memory_bytes: 7732
from collections import defaultdict
dic = defaultdict(int) #初期化する関数。

N = int(input())
if N == 1:
  print(1)
  exit()
X = []
for i in range(N):
  x,y = map(int,input().split())
  X.append([x,y])

for i in range(N):
  for j in range(i+1,N):
    p = X[i][0] - X[j][0]
    q = X[i][1] - X[j][1]
    if p <0:
      p = -p;q=-q
    if p == 0 and q < 0:
      q=-q
    dic[(p,q)] +=1

path = max(dic.values())
ans = N-path
#print(dic)
print(ans)

Measured memory_bytes: 9484