akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

struct Color{

	int c,d;
};

struct Edge{
	Edge(int arg_from,int arg_to){
		from = arg_from;
		to = arg_to;
	}
	int from,to;
};

struct Info{
	Info(int arg_color_id,int arg_num_nodes,int arg_num_edge,int arg_boss,int arg_num_color){
		color_id = arg_color_id;
		num_nodes = arg_num_nodes;
		num_edge = arg_num_edge;
		boss = arg_boss;
		num_color = arg_num_color;
	}

	int color_id,num_nodes,num_edge,boss,num_color;
};

struct Node{


	int get_loc(int color_id){

		auto at = MAP.find(color_id);
		if(at == MAP.end()){

			MAP[color_id] = V.size();
			V.push_back(Info(color_id,1,0,color_id,0));
		}
		return MAP[color_id];
	}

	int get_boss(int color_id){

		int loc = get_loc(color_id);

		if(V[loc].boss == V[loc].color_id){

			return V[loc].color_id;
		}else{

			return V[loc].boss = get_boss(V[loc].boss);
		}
	}

	void unite(int a,int b){

		edge.push_back(Edge(a,b));

		int a_boss = get_boss(a);
		int b_boss = get_boss(b);
		int a_loc = get_loc(a_boss);
		int b_loc = get_loc(b_boss);

		V[a_loc].num_edge++;

		if(a_boss == b_boss){

			ans -= V[a_loc].num_color;
			V[a_loc].num_color = min(V[a_loc].num_edge,V[a_loc].num_nodes);
			ans += V[a_loc].num_color;

			return;
		}

		ans -= (V[a_loc].num_color+V[b_loc].num_color);

		V[b_loc].num_edge += V[a_loc].num_edge;
		V[b_loc].num_nodes += V[a_loc].num_nodes;
		V[a_loc].boss = b_boss;
		V[b_loc].num_color = min(V[b_loc].num_edge,V[b_loc].num_nodes);

		ans += V[b_loc].num_color;
	}

	map<int,int> MAP;
	vector<Edge> edge;
	vector<Info> V;
	int ans;
};

int N,K;
int root = 0;
int index_table[SIZE],ans[SIZE];
vector<int> G[SIZE];
Node nodes[SIZE];
Color color[SIZE];


void dfs(int node_id,int parent){

	index_table[node_id] = node_id;
	nodes[node_id].unite(color[node_id].c,color[node_id].d);

	int tmp = node_id;

	for(int i = 0; i < G[node_id].size(); i++){

		int child = G[node_id][i];
		if(child == parent)continue;

		dfs(child,node_id);
		child = index_table[child];

		if(nodes[tmp].edge.size() < nodes[child].edge.size()){

			swap(tmp,child);
		}
		for(int k = 0; k < nodes[child].edge.size(); k++){

			nodes[tmp].unite(nodes[child].edge[k].from,nodes[child].edge[k].to);
		}
	}

	ans[node_id] = nodes[tmp].ans;
	index_table[node_id] = tmp;
}

int main(){

	scanf("%d %d",&N,&K);

	for(int i = 0; i < N; i++){

		nodes[i].ans = 0;
	}

	int from,to;

	for(int loop = 0; loop < N-1; loop++){

		scanf("%d %d",&from,&to);
		from--;
		to--;

		G[from].push_back(to);
		G[to].push_back(from);
	}

	for(int i = 0; i < N; i++){

		scanf("%d %d",&color[i].c,&color[i].d);
		color[i].c--;
		color[i].d--;
	}

	dfs(root,-1);

	for(int i = 0; i < N; i++){

		printf("%d\n",ans[i]);
	}

	return 0;
}



Measured memory_bytes: 133528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9+1;
const ll LINF = 1e18+1;
const long double PI = acos(-1.0);

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}
template<typename T> T lcm(T a,T b){return a*b/gcd(a, b);}


const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
int main() {
    int n,k,q;
    cin >> n >> k >> q;
    vi a(n,0);
    REP(i, q){
        IN(int, l);
        a[l-1]++;
    }
    REP(i, n){
        Yes(k-q+a[i]>0);
    }
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const ll mod = 1e9+7;
const int MAX = 2e5;
vector<vector<int>> g(MAX);
vector<ll> dp1(MAX,0);
vector<ll> dp2(MAX,0);
vector<ll> ans(MAX,0);
vector<ll> per(MAX+1,1);
 
void extgcd(ll a, ll b, ll &x, ll &y) {
  if(b == 0) {
    x = 1;
    y = 0;
    return;
  }
  extgcd(b, a%b, y, x);
  y -= a/b*x;
  return; 
}
 
ll mod_inverse(ll a, ll m = mod) {
  ll x, y;
  extgcd(a,m,x,y);
  return (m + x % m) % m;
}
 
ll dfs1(int u, int p) {
  ll res = 1;
  for(auto e : g[u]) {
    if(e != p) res += dfs1(e,u);
  }
  return dp1[u] = res;
}
 
ll dfs2(int u, int p) {
  ll res = 1;
  int c = 0;
  for(auto e : g[u]) {
    if(e != p) {
      (res *= dfs2(e,u)) %= mod;
      (res *= mod_inverse(per[dp1[e]])) %= mod;
      c += dp1[e];
    }
  }
  return dp2[u] = (res * per[c]) % mod;
}
 
void dfs3(int u, int p, int q, ll r) {
  ll res = r;
  (res *= mod_inverse(per[q])) %= mod;
  ll c = q;
  for(auto e : g[u]) {
    if(e != p) {
      c += dp1[e];
      (res *= dp2[e]) %= mod; 
      (res *= mod_inverse(per[dp1[e]])) %= mod; 
    } 
  }
  ans[u] = (per[c] * res) % mod;
  for(auto e : g[u]) {
    if(e != p) {
      ll a = ans[u];
      (a *= per[dp1[e]]) %= mod;
      (a *= mod_inverse(per[c])) %= mod;
      (a *= per[c-dp1[e]]) %= mod;
      (a *= mod_inverse(dp2[e])) %= mod;
      dfs3(e,u,c+1-dp1[e],a);
    }
  }
}
 
int main(){
  int n;
  cin >> n;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for(ll i = 1; i <= MAX; i++) per[i] = (per[i-1] * i) % mod; 
  dfs1(0,-1);
  dfs2(0,-1);
  dfs3(0,-1,0,1);
  rep(i,n) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 20212
import java.util.Scanner;

public class Main {
    Main(){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        double c;
        c = (double)a/b;
        System.out.println((a/b) + " " + (a%b));
        System.out.printf("%.8f\n", c);
    }

    public static void main(String[] args){
        new Main();
    }
}



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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, Q;
    cin >> A >> B >> Q;
    ll s[A], t[B];
    for(int i = 0; i < A; i++) {
        cin >> s[i];
    }
    for(int i = 0; i < B; i++) {
        cin >> t[i];
    }
    for(int q = 0; q < Q; q++) {
        ll x;
        cin >> x;
        ll sl, sr, tl, tr;
        sr = lower_bound(s, s + A, x) - s;
        sl = sr - 1;
        tr = lower_bound(t, t + B, x) - t;
        tl = tr - 1;
        ll ans = INF;
        if(sr < A && tr < B) {
            ans = min(ans, max(s[sr], t[tr]) - x);
        }
        if(sl >= 0 && tr < B) {
            ans = min(ans, min(t[tr] - x, x - s[sl]) + t[tr] - s[sl]);
        }
        if(sr < A && tl >= 0) {
            ans = min(ans, min(s[sr] - x, x - t[tl]) + s[sr] - t[tl]);
        }
        if(sl >= 0 && tl >= 0) {
            ans = min(ans, x - min(s[sl], t[tl]));
        }
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define INF INT_MAX
#define cases(t) ll t; cin>>t; while(t--)
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }

#define pb push_back
#define mp make_pair
#define ii pair<int,int>
#define msi map<string,int>

int main(){
	IOS
	ll h,w,k,totcnt = 0;
	cin>>h>>w>>k;
	char c[h][w];
	for(ll i = 0; i < h; ++i){
		for(ll j = 0; j < w; ++j){
			cin>>c[i][j];
			if(c[i][j] == '#') totcnt++;
		}
	}
	ll black,ans = 0;
	for(ll maskR = 0; maskR < 1<<h; ++maskR){
		for(ll maskC = 0; maskC < 1<<w; ++maskC){
			black = 0;
			for(ll i = 0; i < h; ++i){
				for(ll j = 0; j < w; ++j){
					if(((maskR >> i) & 1) == 0 and ((maskC >> j) & 1) == 0 and c[i][j] == '#'){
						black+=1;
					}
				}
			}
			if(black == k)
				ans+=1;
		}
	}
	cout<<ans;

		
return 0;
}

Measured memory_bytes: 3620
S = input()
T = input()
t = len(T)

for i in range(len(S)-t, -1, -1):
    for j in range(t):
        k = S[i+j]
        if k != T[j] and k != "?":
            break
    else:
        print((S[:i]+T+S[i+t:]).replace("?", "a"))
        exit()
print("UNRESTORABLE")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int a,b; 
	cin>>a>>b; 
 	a--;
  	b--;
	int ans = b/a; 
	if(b%a)ans++;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
import numpy as np

n, m = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(m)]

lr_np = np.array(lr)

l = lr_np[:, 0]
r = lr_np[:, 1]

ans = r.min()-l.max()+1
ans = ans if ans>0 else 0
print(ans)

Measured memory_bytes: 37868
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[10]={};
for(int i=0;i<10;i++)cin>>a[i];
sort(a,a+10);
reverse(a,a+10);
printf("%d\n%d\n%d\n",a[0],a[1],a[2]);
}

Measured memory_bytes: 3284
Public Class Program
  Shared Sub Main()
    Dim a As Integer() = Array.ConvertAll(Of String, Integer)(Console.ReadLine().Split(" "), AddressOf Integer.Parse)
    Dim ans As String = If(a(0) + a(1) + a(2) >= 22, "bust", "win")
    Console.WriteLine(ans)
  End Sub
End Class

Measured memory_bytes: 11092
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


N, Q = ds_in()
S = s_in()
move_list = []
for _ in range(Q):
    t, d = s_in().split()
    move_list.append([t, d])


def disappear(place, array):
    if place == -1:
        return (False, False)
    else:
        left = False
        right = False
        for i in range(Q):
            current_char = array[place]
            t, d = move_list[i]
            if t == current_char:
                if d == 'R':
                    place += 1
                else:
                    place -= 1
                if place < 0:
                    left = True
                    break
                elif place > N-1:
                    right = True
                    break
        return (left, right)


def bisect_left(array):
    start, end = -1, N
    while end - start > 1:
        t = start + (end-start)//2
        if disappear(t, array)[0]:
            start = t
        else:
            end = t
    return start


def bisect_right(array):
    start, end = -1, N
    while end - start > 1:
        t = start + (end-start)//2
        if disappear(t, array)[1]:
            end = t
        else:
            start = t
    return start


list_s = list(S)
left = bisect_left(list_s)
right = bisect_right(list_s)
print(right - left)


Measured memory_bytes: 27312
import sys
input=sys.stdin.readline
d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
    sub=list(map(int,input().split()))
    s.append(sub)

last=[-1]*26
import random

for i in range(d):
    print(random.randint(1,26))

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

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

  int b = 0;
  for (int i=0; i<n-1; i++) {
    if (s[i] == s[i+1]) {
      cout<<i+1<<" "<<i+2<<endl;
      return 0;
    }
    if (i == n-2) {
      break;
    }
    if (s[i] == s[i+2]) {
      cout<<i+1<<" "<<i+3<<endl;
      return 0;
    }
  }
  cout<<"-1 -1"<<endl;
}

Measured memory_bytes: 512
n = int(input())
As = []
for i in range(n):
    a = int(input())
    ps = []
    for _ in range(a):
        x,y = map(int, input().split())
        ps.append((x,y))
    As.append(ps)

def check(ps,honests):
    for x, y in ps:
        x -= 1
        if y == 1 and honests[x] == 0:
            return False
        if y == 0 and honests[x] == 1:
            return False
    return True
        

# 無矛盾かどうかを全探索
ans = 0
for b in range(2**n):
    honests = []
    is_ok = True
    for j in range(n):
        honests.append(b & (1<<j)>0)
    for ps,h in zip(As,honests):
        if h:
            is_ok &= check(ps,honests)
    if is_ok:
        ans = max(ans,sum(honests))
print(ans)

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

int main() {
  int N, M;
  cin >> N;
  M = N;
  
  int sum_of_dig = 0;
  
  rep(i, 9){
    sum_of_dig += M%10;
    M /= 10;
  }
  
  if(N%sum_of_dig==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = 0;
    if (a <= c && c <= b && b <= d)
    {
        x = b - c;
    }
    else if (a <= c && c <= d && d <= b)
    {
        x = d - c;
    }
    else if (c <= a && a <= d && d <= b)
    {
        x = d - a;
    }
    else if (c <= a && a <= b && b <= d)
    {
        x = b - a;
    }

    cout << x << endl;
}

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

int a[200001];

int main(){
    int n, k;
    cin >> n >> k;
    for(int i=0; i < n; i++) {
        int temp;
        cin >> temp;
        a[temp] += 1;
    }

    int kind = 0;
    for(int i=0; i <= 200001; i++) if(a[i] != 0)kind += 1;
    if(kind - k <= 0){
        cout << 0 << endl;
        return 0;
    }

    int ans = 0;
    sort(a, a + 200001);
    for(int i = 200001 - kind; i < 200001 - k; i++) ans += a[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char s[100], tmp[100];
int top;
int n, nn;
int main() {
    scanf("%s", s + 1);
    n = strlen(s + 1);
    nn = n;
    for (int i = 1; i <= nn; i++) {
        if (s[i] != s[nn - i + 1]) {
            puts("No");
            return 0;
        }
    }
    nn = (n - 1) / 2;
    for (int i = 1; i <= nn; i++) {
        if (s[i] != s[nn - i + 1]) {
            puts("No");
            return 0;
        }
    }
    nn = (n + 3) / 2;
    for (int i = nn; i <= n; i++) {
        tmp[++top] = s[i];
    }
    for (int i = 1; i <= top; i++) {
        if (tmp[i] != tmp[top - i + 1]) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <random>
#include <time.h>
#include <chrono>
#include <cmath>
using namespace std;

int main() {
    int K;
    cin >> K;
    if (K % 2 == 0) {
        cout << (K / 2)*(K / 2);
    }
    else {
        cout << (K / 2)*(1 + K / 2);
    }
    return 0;
}

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

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[][] list = new int[m][3];
        for (int i = 0; i < m; i++) {
            list[i][0] = scan.nextInt();
            list[i][1] = scan.nextInt();
            list[i][2] = i;
        }
        int[] n_cnt = new int[n];
        String[] ans = new String[m];
        Arrays.sort(list, (a, b) -> a[1] - b[1]);
        for (int i = 0; i < m; i++) {
            ans[list[i][2]] = String.format("%06d%06d", list[i][0], ++n_cnt[list[i][0] -1]);
        }
        for (int i = 0; i < m; i++) {
            System.out.println(ans[i]);
        }
    }
}

Measured memory_bytes: 155120
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
 
#define PI 3.14159265
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
const ll limit = 2e9;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};
 
//const int mod = 998244353;
 
struct dsu{
	int parent[N];
	int cont;
	void make_set(int n){
		for(int i = 1; i <= n; i++)
			parent[i] = i;
		cont = n;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a);
		b = find_set(b);	
		if(a != b){
			parent[b] = a;
			cont--;
		}
	}
};

int w[107];
vector<pair<int,int> > g[107];
void add(int u, int v, int w){
    g[u].push_back(make_pair(v,w));
    g[v].push_back(make_pair(u,w));
}
int findTheCity(int n, vector<vector<int>>& edges, int dt) {
    for(int i = 0; i < (int)edges.size();i++){
        int u = edges[i][0];
        int v = edges[i][1];
        int w = edges[i][2];
        add(u,v,w);
    }
    
	
	int ans = inf;
	for(int i = 0; i < n; i++){
		clr(w,inf);
		w[i] = 0;
		for(int k = 1; k <= n-1; k++){
			for(int j = 0; j < n; j++){
				for(int l = 0; l < (int)g[j].size(); l++){
					int u = j;
					int v = g[j][l].first;
					int weigth = g[j][l].second;
					if(w[u] + weigth < w[v]){
						w[v] = w[u] + weigth;
					}
				}
			}
		}
		int cont = 0;
		cout<<i<<":\n";
        for(int k = 0; k < n; k++){
            if(k != i && w[k] <= dt){
				cout<< k<<"-"<<w[k];
                cont++;
            }
            cout<<endl;
        }
        
		ans = min(cont, ans);
	}
	
	return ans;
}

ll h[200007];
int main(){
	int n, k; cin >> n >> k;
	
	for(int i = 1; i <= n;i++){
		cin>>h[i];
	}
	ll sum = 0;
	sort(h+1,h+1+n);
	for(int i = 1; i <= n-k; i++){
		sum += h[i];
	}
	cout<<sum;
	return 0;
}












Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
typedef long long lint;
const int N=1e5+2;
int n;
lint dp[2][3];

template <class T> inline void apx(T &x,const T y){
	if(x<y) x=y;
}

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

int main(){
	n=nxi();
	dp[1][0]=nxi();
	dp[1][1]=dp[1][2]=-1e13;
	for(int i=2;i<=n;++i){
		char op;
		while((op=getchar())!='-'&&op!='+');
		const int hx=nxi(),p=i&1;
		const int cur=hx*(op=='+'?1:-1);
		dp[p][0]=dp[p^1][0]+cur;
		dp[p][1]=dp[p^1][1]-cur;
		dp[p][2]=dp[p^1][2]+cur;
		apx(dp[p][1],dp[p][2]);
		apx(dp[p][0],dp[p][1]);
		if(op=='-'){
			apx(dp[p][1],dp[p^1][0]-hx);
			apx(dp[p][2],dp[p^1][1]+hx);
		}
	}
	lint ans=-1e16;
	for(int i=0;i<3;++i){
		apx(ans,dp[n&1][i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
program ABC167B
    implicit none
    integer(8)::A,B,C,K
    read*,A,B,C,K
    if(K>=A+B)then
        print'(i0)',A-(K-A-B)
    else if(K>=A)then
        print'(i0)',A
    else
        print'(i0)',K
    end if
end program ABC167B

Measured memory_bytes: 2840
#include <bits/stdc++.h>
using namespace std ;
int main()
{
    int a , x = 0  ;
    cin >> a ;
    for(int i=1 ; i <= a ; i++){
        for(int j=i ; j <= a ; j++){
            if(i % 2 == 1 && j % 2 == 0)
            x++ ;
            else if(i % 2 == 0 && j % 2 == 1)
            x++ ;
            else
            continue ;
        }
    }
    cout << x ;

    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <algorithm>

#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main(int argc, char *argv[]){

  int N, M;
  cin >> N >> M;
  int res = pow(2, M) * (1800*M + 100*N);
  cout << res << endl;

  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
typedef vector<int>vint;
typedef pair<int,int>pint;

const int SIZE=100000;


int N,T,Q;
int A[SIZE],D[SIZE];

int dp[SIZE];

signed main(){
    cin>>N>>T>>Q;
    rep(i,N)cin>>A[i]>>D[i];

    rep(i,N){
        if(D[i]!=2)continue;
        if(i==0)dp[i]=A[i]-T;
        else if(D[i-1]==1)dp[i]=max(A[i]-T,A[i]-(A[i]-A[i-1])/2);
        else dp[i]=max(A[i]-T,dp[i-1]);
    }

    for(int i=N-1;i>=0;i--){
        if(D[i]!=1)continue;
        if(i==N-1)dp[i]=A[i]+T;
        else if(D[i+1]==2)dp[i]=min(A[i]+T,A[i]+(A[i+1]-A[i])/2);
        else dp[i]=min(A[i]+T,dp[i+1]);
    }

    while(Q--){
        int x;cin>>x;x--;
        cout<<dp[x]<<endl;
    }
    return 0;
}

Measured memory_bytes: 5416
#include<iostream>
#include<strings.h>
using namespace std;
int main(){
    int n;
    string f[150];
    while(1){
        int left=0,right=0;
        int count = 0,flag =0;
        cin >> n;
        if(n==0)break;
        for(int i=0;i<n;i++){
            cin >> f[i];
        }
        for(int i=0;i<n;i++){
            
            if(flag==0){
                if(f[i]=="lu"){
                    left = 1;
                }else if(f[i]=="ru"){
                    right = 1;
                }else if(f[i]=="ld"){
                    left = 0;
                }else if(f[i]=="rd"){
                    right = 0;
                }
            }else if(flag ==1){
                if(f[i]=="lu"){
                    left = 0;
                }else if(f[i]=="ru"){
                    right = 0;
                }else if(f[i]=="ld"){
                    left = 1;
                }else if(f[i]=="rd"){
                    right = 1;
                }
            }
            if(i>=1&&right==1&&left==1){
                count++;
                right=0;
                left=0;
                if(flag==0){
                    flag = 1;
                }else{
                    flag = 0;
                }
            }
        }
        cout << count <<endl;
    }
    return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  int n;
  scanf("%d",&n);
  while(n --> 0){
    int h,m;
    scanf("%d:%d",&h,&m);
    double hh,mm;
    mm = m * (360.0/60.0);
    hh = (h + (m/60.0)) * (360.0/12.0);
    /*
    int hhh,mmm;
    hhh = round(hh*2);
    mmm = round(mm*2);
    */
    double diff = abs(hh - mm);
    if(diff > 180) diff = 360 - diff;

    if(diff >= 90) puts("safe");
    else if(diff < 30) puts("alert");
    else puts("warning");
  }
  return 0;
}

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

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

Measured memory_bytes: 3636
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair <int, int> pii;
#define pb push_back
#define f first
#define s second
#define sz(x) (int)x.size()
map < int , int > cnt;
int a[2000 * 100 + 5];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	cout.tie(0);
	int n, ans = 0;
	cin >> n;
	cnt[0]++;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		a[i] += a[i - 1];
		cnt[a[i]]++;
	}
	for(auto it : cnt)
		ans += it.s * (it.s - 1) / 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 14336
#include<iostream>
#include<cstdio>
#include<sstream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstring>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N = 1005;
const int inf = 0x3f3f3f3f;
int gcd(int a,int b)
{
	int t;
	while(b)
	{
		t=a%b;
		a=b;
		b=t;
	}
	return a;
}
int gcdx(int a,int b,int c)
{
	return gcd(gcd(a,b),c);
} 
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	for(int k=1;k<=n;k++)
	ans+=gcdx(i,j,k);
	cout<<ans;
	return 0;
}

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

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

vector<ll> table(100, -1);
ll fibo(ll n) {
  if (n <= 1) return 1;
  if (table[n] != -1) return table[n];
  return table[n] = fibo(n - 1) + fibo(n - 2);
}

int main() {
  ll input(n);
  cout << fibo(n) << endl;
}



Measured memory_bytes: 3116
/*  ex2_3
	UMAboogie */

#include <stdio.h>

int main(void){
	int side, white;
    //次の入力でマス目の一辺の長さを変数sideに受け取る
  	scanf("%d\n",&side);
    //次の入力で白く塗るマスの数を変数whiteに受け取る
    scanf("%d\n",&white);
  	//マス目の総数を計算し、変数pixelに代入する
  	int pixel = side*side;
    //黒く塗るマスの数を計算し、変数blackに代入し、表示する
    int black = pixel - white;
    printf("%d\n",black);
  	return 0;
}

Measured memory_bytes: 128
N = int(input())
S = input()
r,g,b = S.count('R'),S.count('G'),S.count('B')
#rgbでr,g,bがすべて異なる組み合わせ数
total = r*g*b
# そこからj-i=k-jの組み合わせを引く
for i in range(0,N-2):
    for j in range(i+1,N-1):
        k = 2*j-i
        if k >= N: break;
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            total-=1
# flg = [[[0 for i in range(N)] for j in range(N)] for k in range(N)]

print(total)


Measured memory_bytes: 73660
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  LL n; cin >> n;
  LL ans = n;
  for (LL i = 1; i * i <= n; i ++) {
    if (n % i == 0) {
      ans = min(ans, (i - 1) + (n / i - 1));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math
from collections import deque


def solve(N: int, D: int, A: int, X: "List[int]", H: "List[int]"):
    M = sorted([(X[i], H[i]) for i in range(N)])
    DD = 2*D
    result = 0
    revert = deque()
    currentDamage = 0
    for m in M:
        while len(revert) > 0 and revert[0][0] < m[0]:
            currentDamage -= revert[0][1]
            revert.popleft()
        nextDamage = max(0, m[1] - currentDamage)
        needAttack = math.ceil(nextDamage/A)
        currentDamage += needAttack * A
        result += needAttack
        if needAttack > 0:
            revert.append((m[0]+2*D, needAttack*A))
    print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    X = [int()] * (N)  # type: "List[int]"
    H = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        X[i] = int(next(tokens))
        H[i] = int(next(tokens))
    solve(N, D, A, X, H)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67880
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int64_t N;
  int64_t M;
  int sum=0;
  cin >> N;
  for(int64_t i=2;i*i<=N;i++){
    M=N;
    while(M%i==0){
      M /= i;
    }
    if(M%i==1){
      sum++;
    }
    if(N%i==1){
      sum++;
    }
    if(N==i*i+1){
      sum--;
    }
  }
  sum += 2;
  if(N==2){sum=1;}
  cout << sum << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<typename Num>
        constexpr Num mypow(Num a, long long b) {
            if(b==0)return 1;
            if (a==0)return 0;
            Num x = 1;
              while (b > 0) {
                if(b & 1)x*=a;
                a*=a;
                b >>= 1;
              }
              return x;
        }

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n,m,k;
        cin>>n>>m>>k;
        vl A(n);
        vl B(m);
        rep(i,n)cin>>A[i];
        rep(i,m)cin>>B[i];
        vl sumA(n+1,0);
        vl sumB(m+1,0);
        rep(i,n){
            sumA[i+1]=sumA[i]+A[i];
        }
        rep(i,m){
            sumB[i+1]=sumB[i]+B[i];
        }
        ll res=0;
        rep(i,n+1){
            auto itr=upper_bound(all(sumB),k-sumA[i]);
            ll x=itr-sumB.begin();
            if(x==0)break;
            x--;
            chmax(res,i+x);
        }
        cout<<res<<endl;
    }

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

int main(void) {
  int i, n, j, k;
  double x1, y1, x2, y2, x3, y3;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
    double xt1 = (x1 + x2) / 2, xt2 = (x3 + x2) / 2, yt1 = (y1 + y2) / 2, yt2 = (y3 + y2) / 2;
    double t1 = y1 - y2, t2 = y2 - y3;
    double x, y, k1, k2;
    if(!t1) {
      x = xt1;
      k2 = -(x2 - x3) / (y2 - y3);
      y = k2 * (x - xt2) + yt2;
    } else if(!t2) {
      x = xt2;
      k1 = -(x1 - x2) / (y1 - y2);
      y = k1 * (x - xt1) + yt1;
    } else {
      k1 = -(x1 - x2) / (y1 - y2), k2 = -(x2 - x3) / (y2 - y3);
      x = ((k1 * xt1 - k2 * xt2) - (yt1 - yt2)) / (k1 - k2);
      y = k1 * (x - xt1) + yt1;
      //printf("%f %f ", k1, k2);
    }
    double r = sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
    //printf("%f %f %f %f\n", xt1, yt1, xt2, yt2);
    printf("%.3f %.3f %.3f\n", x, y, r);
  }
  return 0;
}


Measured memory_bytes: 2548
#include<cstdio>
#include<queue>
#include<algorithm>

using namespace std;

int main(){
    int num_queue,num_query;
    int command,queue_idx,val;
    
    scanf("%d %d",&num_queue,&num_query);
    priority_queue<int> queue_array[num_queue];
    
    for(int i = 0;i < num_query;i++){
        scanf("%d %d",&command,&queue_idx);
        if(command == 0){
            scanf("%d",&val);
            queue_array[queue_idx].push(val);
        }else if (command == 1){
            if(!queue_array[queue_idx].empty()) printf("%d\n",queue_array[queue_idx].top());
        }else{
            if(!queue_array[queue_idx].empty()) queue_array[queue_idx].pop();
        }
    }
    
    return 0;
}


Measured memory_bytes: 3584
K = int(input())

t = [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]
print(t[K - 1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

vector<vector<int>> to;
vector<int> cnt;

void dfs(int i, int p)
{
	for (auto e : to[i])
	{
		if(e != p)
		{
			cnt[e] += cnt[i];
			dfs(e, i);
		}
	}
	return;
}

void solve()
{
	int n, q; cin >> n >> q;
	to = vector<vector<int>>(n);
	rep(i, n-1)
	{
		int a, b; cin >> a >> b;
		a--;b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	cnt = vector<int>(n, 0);
	rep(i ,q)
	{
		int p, x;cin >> p >> x;
		p--;
		cnt[p] += x;
	}
	dfs(0,-1);
	rep(i, n)cout << cnt[i] << " ";
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 23552
//Volume0-0038
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

class Num {
	public int num = 1;
}

public class Main {

    //declare
	private static ArrayList<Integer>   ar   = new ArrayList<Integer>(),
	                                    list = new ArrayList<Integer>();
	private static HashMap<Integer,Num> map  = new HashMap<Integer,Num>();

	public static void main(String[] args){

		String   result;
		String[] s;
		int      card;

		//initialize
		init();

        //input
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
        	ar.clear();
        	map.clear();
        	s = sc.nextLine().split(",");
        	for(int i=0;i<5;i++){
        		card = Integer.parseInt(s[i]);
        		ar.add(card);
        		if(map.containsKey(card)){
        			map.get(card).num++;
        		} else {
        			map.put(card, new Num());
        		}
        	}

        	//calculate
        	Collections.sort(ar);

        	out:{
        		if(include(4))  {result = "four card" ; break out;}
        		if(include(2,3)){result = "full house"; break out;}
        		if(straight())  {result = "straight"  ; break out;}
        		if(include(3))  {result = "three card"; break out;}
        		if(include(2,2)){result = "two pair"  ; break out;}
        		if(include(2))  {result = "one pair"  ; break out;}
                                 result = "null"      ;
        	}

        	//output
        	System.out.println(result);
        }
	}

	private static void init(){
		for(int i=1;i<15;i++){
			list.add(i);
		}
	}

	private static boolean include(int i){
		boolean ret = false;
		Collection<Num> cl = map.values();
		for(Num n:cl){
			if(n.num == i){
				ret = true;
			}
		}
		return ret;
	}

	private static boolean include(int i,int j){

		boolean ret = false;

		if(i != j){
			if(include(i) && include(j)){ret = true;}
		} else {
			int cnt = 0;
			Collection<Num> cl = map.values();
			for(Num n:cl){
				if(n.num == i){
					cnt++;
				}
			}
			if(cnt > 1){ret = true;}
		}
		return ret;
	}

	private static boolean straight(){
		boolean ret   = false;
		int     match = 0;
		for(int i=list.indexOf(ar.get(0)),j=0; i<list.size() && j<ar.size();i++,j++){
			if   (list.get(i) == ar.get(j)){match++;}
			else                           {break;}
		}
		if     (match == 5){ret = true;}
		else if(ar.contains(1)){
			ar.remove(0);
			ar.add(14);
			ret = straight();}
		return ret;
	}
}

Measured memory_bytes: 17204
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const ll MOD = 1000000007;
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; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }
template<int mod>
struct ModInt {
    using ll = long long; ll x;
    ModInt() : x(0) {}
    ModInt(int y) : x(y >= 0 ? ll(y % mod) : (ll)((mod - (-y) % mod))) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
    ModInt &operator+=(const ModInt &rhs) { if((x += rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &rhs) { if((x += mod - rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &rhs) { x = x * rhs.x % mod; return *this; }
    ModInt &operator/=(const ModInt &rhs) { *this *= rhs.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(const ModInt &rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(const ModInt &rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(const ModInt &rhs) const { return ModInt(*this) /= rhs; }
    ModInt operator==(const ModInt &rhs) const { return x == rhs.x; }
    ModInt operator!=(const ModInt &rhs) const { return x != rhs.x; }
    friend ostream &operator<<(ostream &os, const ModInt &rhs) { return os << rhs.x; }
    friend istream &operator>>(istream &is, ModInt &rhs) { ll t; is >> t; rhs = ModInt<mod> (t); return (is); }
private:
    ModInt inverse() const { ll a = x, u = 1LL, v = 0LL, t, b = (ll)mod; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return  ModInt(u); }
};
using mint = ModInt<MOD>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, T;
    cin >> A >> B >> T;
    int ans = 0;
    while((T+0.5) > 0){
        ans+=B;
        T-=A;
    }
    cout << ans-B << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const ll MOD = (ll)1e9+7LL;
const int N = (int)1e5+99;
ll poww(ll x, ll eks) {
    if(eks==0LL) return 1LL;
    if(eks==1LL) return x;
    ll taj=poww(x, eks/2);
    return taj % MOD * taj % MOD * (eks&1?x:1LL) % MOD;
}
ll n, k, res[N], sol;
int main() {
    IOS; cin >> n >> k;
    for(ll i=k; i>0LL; --i) {
        res[i]=poww(k/i, n);
        for(ll j=2LL*i; j<=k; j+=i) {
            res[i]=(res[i]-res[j]+MOD)%MOD;
        }
        sol=(sol+res[i]*i)%MOD;
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 4388
#include<iostream>
#include<cstring>

typedef std::pair<int, int> P;

int n, m;
int scene[101][101];

P ok(int pic[51][51]){
	for (int i = 0; i <= n - m; i++){
		for (int j = 0; j <= n - m; j++){
			P ret;
			for (int k = m - 1; k >= 0; k--){
				for (int l = m - 1; l >= 0; l--){
					if (pic[k][l] != -1 && scene[i + k][j + l] != pic[k][l])goto next;
					else if (pic[k][l] != -1)ret = P(j + l, i + k);
				}
			}
			return ret;
		next:;
		}
	}
	return P(10000, 10000);
}

void r(int pic[51][51]){
	int out[51][51];
	int ox = 0, oy = 0;
	for (int i = 0; i < m; i++){
		for (int j = m - 1; j >= 0; j--){
			out[oy][ox] = pic[j][i];
			ox++;
			if (ox == m)ox = 0, oy++;
		}
	}
	memcpy(pic, out, sizeof(out));
}

int main(){
	while (true){
		int pic[51][51];

		std::cin >> n >> m;
		if (n == 0 && m == 0)break;

		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				std::cin >> scene[i][j];
			}
		}

		for (int i = 0; i < m; i++){
			for (int j = 0; j < m; j++){
				std::cin >> pic[i][j];
			}
		}

		P min(10000, 10000);
		for (int i = 0; i < 4; i++){
			P p = ok(pic);
			r(pic);
			if (p.second < min.second)min = p;
			else if (p.second == min.second&&p.first < min.first)min = p;
		}

		if (min.first == 10000)std::cout << "NA" << std::endl;
		else std::cout << min.first + 1 << " " << min.second + 1 << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#define intt long long

int main() {
	intt N; std::cin >> N;
	std::vector<intt> a(N);
	for (auto& r : a) std::cin >> r;
	intt count = 0;
	intt t = 1;
	while (true) {
		if (t == 2) {
			std::cout << count << std::endl;
			return 0;
		}
		t = a[t - 1];
		++count;
		if (count >= N + 1)
			break;
	}
	std::cout << -1 << std::endl;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(int)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef long double ld;
typedef int ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const int SIZE=2*1e5;
const int INF=1LL<<30;
const LL p=7+1e9;
int fi=0,se=-1;
string T,P;
int last[30];
int main(){
	cin >> T >> P;
	REP(i,30) last[i]=-1;
	REP(i,T.size()){
		if(T[i]==P[fi]){
			fi++;
			last[T[i]-'a']=fi;
		}else if(last[T[i]-'a']!=-1){
			se=max(se,last[T[i]-'a']);
		}
		if((fi==se)){
			cout << "no" << endl;
			return 0;
		}
	}
	if(fi==P.size())
		cout << "yes" << endl;
	else 
		cout << "no" << endl;
	return 0;
}

Measured memory_bytes: 4192
#include <stdio.h>
#define max 45
#define nil -1
int F[max], n;
int fib(int);
int main()
{
  int i;
  
  scanf("%d",&n);

  for(i = 0 ; i <= n ; i++) F[i] = nil;

  printf("%d\n",fib(n));

  return 0;
}

int fib(int n)
{
  if(n == 0 || n ==1) return F[n] = 1;
  if(F[n] != nil) return F[n];
  return F[n] = fib(n-2) + fib(n-1);
}



Measured memory_bytes: 2052
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VI h(n);
    REP(i,0,n) cin >> h[i];
    VI dp(n);
    dp[1] = abs(h[1] - h[0]);
    REP(i,2,n) dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    cout << dp[n-1] << endl;
}

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

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath> 
#include<cstring>
using namespace std;

int main()
{
	double v;
	while(cin>>v)
	{
		double h=v*v/(2*9.8);
		int n=ceil((double)(h+5)/5);
		if(h==0)
		  cout<<"0"<<endl;
		else
		  cout<<n<<endl;
	} 
 return 0;
} 

Measured memory_bytes: 1228