akhauriyash/Code-Regression huggingface dataset:
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "sort"
)

func Solve() {
  var N int
  NextInt(&N)
  R := []int{0}
  W := []int{N + 1}
  for i, s := range NextLine() {
    if s == 'R' {
      R = append(R, i + 1)
    } else {
      W = append(W, i + 1)
    }
  }
  sort.Sort(sort.Reverse(sort.IntSlice(R)))
  sort.Ints(W)
  c := 0
  for R[c] > W[c] { c++ }
  Write(c)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntSlice(A *[]int) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]int, 0)
    return
  }
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatSlice(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]float64, 0)
    return
  }
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(S ...interface{}) {
  fmt.Fprintln(writer, S...)
}
func WriteIntSlice(A []int) {
  B := make([]interface{}, len(A))
  for i, a := range A { B[i] = a }
  fmt.Fprintln(writer, B...)
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 8936
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int n,x,t;
    cin >> n >> x >> t;
    int ans = 0;
    int k = 0;
    rep(i,10000){
        k += x;
        ans += t;
        if(n <= k){
            //cout << k << endl;
            break;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	vector<int> ans;

	while (true)
	{
		int x, y, s;
		cin >> x >> y >> s;

		if (x == 0 && y == 0 && s == 0)
		{
			break;
		}

		vector<pair<int, int>> vec;

		REP (i, 1, s)
		{
			REP (j, 1, s) {
				int t = i * (100 + x) / 100 + j * (100 + x) / 100;

				if (t == s)
				{
					pair<int, int> p = make_pair(i, j);
					vec.push_back(p);
				}
			}
		}

		int max = 0;
		rep (i, vec.size())
		{
			int t = vec[i].first * (100 + y) / 100 + vec[i].second * (100 + y) / 100;

			if (max < t)
			{
				max = t;
			}
		}

		ans.push_back(max);
	}

	rep (i, ans.size())
	{
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
    int h,a;
    cin >> h >> a;
    cout << ceil((double)h / a) << '\n';
   cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

Measured memory_bytes: 256
/* longhoang08 */
#include <bits/stdc++.h>
#define maxn 100010
#define cmax 1000000007
#define llmax (1LL << 61)
#define el '\n'
#define pb push_back
#define mp make_pair
#define getbit(s,i) ((s>>(i-1))&1)
#define bug(X) { cerr << #X << " = " << (X) << endl; }
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define For(i,a,b) for(int i = a; i <= b; i++)
#define Ford(i,a,b) for(int i = a; i >= b; i--)
#define Forv(i,v) for(int i = 0, _v = v.size(); i < _v; i++)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> ptq;

int n, x, y, z;
ll f[maxn];
ptq a[maxn];

bool cmp(ptq a, ptq b)
{
    return a.first - a.second > b.first - b.second;
}

int main()
{
    if (fopen("a.txt","r"))
    {
        freopen("a.txt","r",stdin);
        //freopen("b.txt","w",stdout);
    } else IOS;
    cin >> x >> y >> z;
    int n = x + y + z;
    ll sum = 0;
    For(i,1,n)
    {
        ll temp;
        cin >> a[i].first >> a[i].second >> temp;
        a[i].first -= temp;
        a[i].second -= temp;
        sum += temp;
    }
    sort(a+1,a+n+1,cmp);
    priority_queue < ll, vector <ll>, greater <ll> > q;
    ll cur = 0;
    For(i,1,n)
    {
        q.push(a[i].first);
        cur += a[i].first;
        if (q.size() > x)
        {
            cur -= q.top();
            q.pop();
        }
        f[i] = cur;
    }
    while (!q.empty()) q.pop();
    cur = 0;
    ll res = -llmax;
    Ford(i,n,x+1)
    {
        q.push(a[i].second);
        cur += a[i].second;
        if (q.size() > y)
        {
            cur -= q.top();
            q.pop();
        }
        if (q.size() == y) res = max(res, cur + f[i-1]);
    }
    cout << res + sum;
}



Measured memory_bytes: 3704
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int n; int i;
	cin >> n;
	ll a, x[100000], sum[100000];
	for (i = 0; i < n; i++) {
		cin >> a; x[i] = a;
	}
	sort(x, x + n);
	sum[0] = x[0];
	for (i = 1; i < n; i++) {
		sum[i] = sum[i - 1] + x[i];
	}
	int count = 1;
	for (i = n - 2; i >= 0; i--) {
		if (sum[i] * 2 < x[i + 1])break;
		count++;
	}
	cout << count << endl;
	char nyaa;
	cin >> nyaa;
	return 0;
}

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

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

void solve() {
    int n;
    cin >> n;

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

    vector<int> dp(n+1);
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    dp[2] = abs(h[0] - h[2]);

    for (int i = 3; i < n; i++) {
        dp[i] = min(dp[i - 2] + abs(h[i - 2] - h[i]), dp[i - 1] + abs(h[i - 1] - h[i]));
        assert(true);
    }

    cout << dp[n-1];
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

constexpr int steps[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int H, W;
    cin >> H >> W;
    vector<Vi> mas(H + 2, Vi(W + 2, 1));
    queue<tuple<int, int, int>> q;
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < W; j++) {
            if (s[j] == '#') {
                mas[i + 1][j + 1] = 1;
                q.emplace(i + 1, j + 1, 0);
            }
            else {
                mas[i + 1][j + 1] = 0;
            }
        }
    }

    int ans = 0;

    while (!q.empty()) {
        int u, v;
        int cnt;
        tie(u, v, cnt) = q.front();
        q.pop();

        bool is_hashi = true;
        for (int i = 0; i < 4; i++) {
            int un, vn;
            un = u + steps[i][0];
            vn = v + steps[i][1];
            if (mas[un][vn] == 0) {
                mas[un][vn] = 1;
                q.emplace(un, vn, cnt + 1);
                is_hashi = false;
            }
        }

        if (is_hashi) {
            ans = max(ans, cnt);
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  
  string s;
  cin >> s;
  
  if (s == "Sunny") cout << "Cloudy" << endl;
  else if (s == "Cloudy") cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
  
}


Measured memory_bytes: 256
from collections import deque
import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [D, N] = [int(input_raw[0]), int(input_raw[1])]
    if N != 100:
        print (100**D)*N
    else:
        print (100**D)*N + 100**D

if __name__ == '__main__':
    main()

Measured memory_bytes: 2936
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::string s;
    std::cin >> n >> s;

    int ret = 0;
    for (int i = 0; i < 1000; i++) {
        int first = i % 10, second = i / 10 % 10, third = i / 100;
        auto j = s.find_first_of('0' + third);
        auto k = s.find_first_of('0' + second, j + 1);
        auto l = s.find_first_of('0' + first, k + 1);
        if (j != std::string::npos && k != std::string::npos && l != std::string::npos) ret++;
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#define all(x) (x).begin(),(x).end()
typedef long long ll;

using namespace std;

int main()
{
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx;
    int dy = ty - sy;
    string S = "";
    for(int i=0; i<dy; i++) S += "U";
    for(int i=0; i<dx; i++) S += "R";
    for(int i=0; i<dy; i++) S += "D";
    for(int i=0; i<dx; i++) S += "L";
    S += "L";
    for(int i=0; i<dy+1; i++) S += "U";
    for(int i=0; i<dx+1; i++) S += "R";
    S += "D";
    S += "R";
    for(int i=0; i<dy+1; i++) S += "D";
    for(int i=0; i<dx+1; i++) S += "L";
    S += "U";
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 3612
import java.io.*;
import java.util.*;

public class Main {
    public static int MAXN = 1600;

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        String str=cin.nextLine();
        
        out.print(str.charAt(0));
        out.print(str.length()-2);
        out.println(str.charAt(str.length()-1));
        out.flush();
        out.close();
        cin.close();
    }
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    vector<ll>cnt(1001001,0);
    ll n,c;cin >>n>>c;
    vector<pair<ll,P>>ch(n);
    for (int i = 0; i < n; ++i) {
        ll s,t,c;
        cin >>s>>t>>c;
        P p={s,t};
        ch[i]={c,p};
    }
    sort(all(ch));
    for (int i = 0; i < n;i++) {
        if(ch[i].first==ch[i+1].first){
            ll s=ch[i].second.first;
            ll f;
            while (ch[i].first==ch[i+1].first&&ch[i].second.second==ch[i+1].second.first){
                i++;
            }
            f=ch[i].second.second;
            cnt[s-1]++;
            cnt[f]--;
        }
        else {
            ll s=ch[i].second.first;
            ll f=ch[i].second.second;
            cnt[s-1]++;
            cnt[f]--;
        }
    }
//    for (int i = 0; i < 13; ++i) {
//        cout <<i<<" "<<cnt[i]<<endl;
//    }
    ll ans=0;ll now=0;
    for (int i = 0; i < 1001001; ++i) {
        now+=cnt[i];
        ans=max(ans,now);
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 10368
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int N;
    cin>>N;
    vector<int>A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    sort(A.begin(),A.end());
    int B=0;
    for(int i=0;i<(N-1);i++){
        B+=A[i];
    }
    cout<<B+(A[N-1]/2)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

int main()
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll N = 3;
  std::vector< ll > va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }
  std::sort(va.begin(), va.end());

  ll sum = 0LL;
  sum += (va[2] - va[0]) / 2;
  sum += (va[2] - va[1]) / 2;

  if ((va[2] - va[0]) % 2 == 1 && (va[2] - va[1]) % 2 == 1) {
    sum += 1;
  } else if ((va[2] - va[0]) % 2 == 1 && (va[2] - va[1]) % 2 == 0) {
    sum += 2;
  } else if ((va[2] - va[0]) % 2 == 0 && (va[2] - va[1]) % 2 == 1) {
    sum += 2;
  }

  print(sum);
  return 0;
}


Measured memory_bytes: 256
n = int(input())
ba = []
now = 0
ans = "Yes"

for _ in range(n):
    a,b = map(int,input().split())
    ba.append([b,a])
    
ba = sorted(ba)

for i in range(n):
    now += ba[i][1]
    
    if ba[i][0] < now:
        ans = "No"
        break
        
print(ans)

Measured memory_bytes: 39680
#include <cstdio>

int main(){
    int H, W;
    while(true){
        scanf("%d %d", &H, &W);
        if (H==0 && W==0){
            break;
        }
        for(int i = 0; i<H; i++){
            for(int j=0; j<W; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


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

int main() {
  int a,b,x,y;
  cin >> a >> b;
  x = a % 2;
  y = b % 2;
  if ((x == 0)||(y == 0)) {
    cout << " Even " << endl;
  }
  else {
    cout << " Odd " << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  for(int i = 0;; i++) {
    if((i + 1) * 8 / 100 == A && (i + 1) * 10 / 100 == B) {
      cout << i + 1 << endl;
      break;
    }
    if((i + 1) * 8 / 100 == A + 1) {
      cout << -1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
def main():
    N, A, B = map(int, input().split())

    if (A + B) % 2 == 0:
        print(abs(A - ((A + B) // 2)))
    else:
        Y = min(B - 1, N - A)

        c = 0
        if 1 < A:
            c += A - 1
        c += 1
        B1 = B - c
        A1 = 1
        X = abs(A1 - ((A1 + B1) // 2)) + c
        if B1 < A1:
            X = 9999999999999999999999999999

        c = 0
        if B < N:
            c += N - B
        c += 1
        A2 = A + c
        B2 = N
        Z = abs(A2 - ((A2 + B2) // 2)) + c
        if B2 < A2:
            Z = 9999999999999999999999999999

        print(min(Y, X, Z))


main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9+7;



int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	char c;
	cin>>c;
	cout<<++c;
	
	return 0;
}
	
	
	
	
	
	
	
	
	
	
	

























Measured memory_bytes: 256
from collections import deque

def unification(string):

    n = len(string)

    if n == 1:
        return 0

    q = deque()
    idx = 2
    q.appendleft(string[0])
    q.appendleft(string[1])
    count = 0

    while idx < n:
        while len(q) > 1 and q[0] != q[1]:
            q.popleft()
            q.popleft()
            count += 2

        q.appendleft(string[idx])
        idx += 1

    if len(q) > 1 and q[0] != q[1]:
        q.popleft()
        q.popleft()
        count += 2

    return count


if __name__ == "__main__":
    string = input()
    print(unification(string))

Measured memory_bytes: 44908
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
using namespace std;

int main(void) {
  int n;
  cin >> n;
  long long arr[n], brr[n] = {0};
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < n; i += 2) {
    brr[(i + 1) / 2] = arr[n - i - 1];
    if(n - ((i + 1) / 2) - 1!=(i+1)/2)
    brr[n - ((i + 1) / 2) - 1] = arr[n - i - 2];
  }
  for (int i = 0; i < n; i++) {
    cout << brr[i] << " ";
  }
  return 0;
}


Measured memory_bytes: 5248
from collections import deque
n, m = map(int, input().split())
lis = [0]*(n+1)
c = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    c[a].append(b)
    c[b].append(a)
    
que = deque([1])
check = [0 for i in range(n+1)]
check[1] = 1
while que:
    now = que.popleft()
    nx = c[now]
    for i in nx:
        if check[i] == 1:
            continue
        check[i] = 1
        lis[i] = now
        que.append(i)
if 0 in lis[2:]:
    print("No")
else:
    print("Yes")
    for i in lis[2:]:
        print(i)

Measured memory_bytes: 35504
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
	double crackSpeed;
	
	crackSpeed = -1;
	cin >> crackSpeed;
	
	while (crackSpeed >= 0) {
		
		double crackTime = crackSpeed / 9.8;
		double crackDist = 4.9 * crackTime * crackTime;
		
		int numFloor = 1;
		
		while ((double)(5 * numFloor - 5) < crackDist) numFloor++;
		
		cout << numFloor << endl;
		
		crackSpeed = -1;
		cin >> crackSpeed;
	}
	
	return 0;
}

Measured memory_bytes: 1224
#include<iostream>

#define MAX 10

typedef struct{
    int k[MAX];
    int count;
}S;

using namespace std;
int main(){
    int N,M;
    int p[MAX];
    int i,j;
    S s[MAX];
    int k;
    int s_num;
    int switch_;
    int count;
    cin >> N >> M;
    
    
    for(i=0;i<M;i++){
        for(j=0;j<N;j++){
            s[i].k[j] = 0;
        }
    }
    for(i=0;i<M;i++){
        cin >> k;
        for(j=0;j<k;j++){
            cin >>s_num;
            s[i].k[s_num - 1] = 1;
        }
    }
    for(i=0;i<M;i++){
        cin >> p[i];
    }
    switch_ = 0;
    count = 0;
    while( switch_ < (1 << N)){
        for(i=0;i<M;i++){
            s[i].count = 0;
            for(j=0;j<N;j++){
                if(switch_ >> ( j ) & 0x01 && s[i].k[j] == 1){
                    s[i].count++;
                }
            }
            if( s[i].count % 2 != p[i]){
                break;
            }
        }
        if( i == M){
            count++;
        }
        switch_++;
    }
    
    cout << count << endl;
    return 0;
    
}


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

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

const int SIZE = 100000 + 10;
const ll MOD = 1000000000 + 7;
inline ll add(ll a, ll b) {
  return (a+b) % MOD;
}
inline ll sub(ll a, ll b) {
  return (a+MOD-b) % MOD;
}
inline ll mul(ll a, ll b) {
  return (a*b) % MOD;
}

ll fact[SIZE];
ll inv[SIZE];
ll invsum[SIZE];

void init() {
  fact[0] = 0, fact[1] = 1;
  for(int i = 2; i < SIZE; i++) {
    fact[i] = mul(i, fact[i-1]);
  }
  inv[0] = 0, inv[1] = 1;
  invsum[0] = 0, invsum[1] = 1;
  for(int i = 2; i < SIZE; i++) {
    inv[i] = MOD - (MOD / i) * inv[(int)MOD % i] % MOD;
    invsum[i] = add(invsum[i-1], inv[i]);
  }
  //  for(int i = 1; i <= 5; i++) {
  //    cout << i << " " << fact[i] << " " << inv[i] << " " << invsum[i] << endl;
  //  }

}

int main() {
  init();
  int N; cin>>N;
  vector<ll> A(N);
  ll ans = 0;
  
  REP(i,N) {
    cin>>A[i];
    ll work = mul(A[i], fact[N]);
    ll work1 = sub(add(invsum[N-i], invsum[i+1]), 1);
    //    cout << i << " " << A[i] << " " << work << " " << work1 << " ";
    work = mul(work, work1);
    ans = add(ans, work);
    //    cout << work << " " << ans << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int n;
  cin >> n;
  ll x[n],y[n];
  for(int i=0;i<n;i++) cin >> x[i] >> y[i];
  ll p,q;
  int ans = n;
  int temp = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      p = x[i] - x[j];
      q = y[i] - y[j];
      if(p == 0 && q == 0) continue;
      temp = 0;
      for(int u=0;u<n;u++){
        for(int v=u+1;v<n;v++){
          if(p == x[u]-x[v] && q == y[u]-y[v]) temp++;
          if(p == x[v]-x[u] && q == y[v]-y[u]) temp++;
        }
      }
      ans = min(ans,n-temp);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define tt this->
#define ll long long
using namespace std;
int main ()
{
string s;
cin>>s;
if (s[2]==s[3]&&s[4]==s[5])cout<<"Yes";
else
    cout<<"No";

    return 0;
}

/*
▀█████████▄     ▄████████    ▄████████    ▄████████
  ███    ███   ███    ███   ███    ███   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
 ▄███▄▄▄██▀    ███    ███  ▄███▄▄▄▄██▀   ███    ███
▀▀███▀▀▀██▄  ▀███████████ ▀▀███▀▀▀▀▀   ▀███████████
  ███    ██▄   ███    ███ ▀███████████   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
▄█████████▀    ███    █▀    ███    ███   ███    █▀
                            ███    ███

*/


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


using namespace std;


int main(void) {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> graph(N + 1);
    vector<bool> discovered(N + 1, false);
    vector<int> sign(N + 1);

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    queue<int> q;
    q.push(1);
    discovered[1] = true;
    while (!q.empty()) {
        int now = q.front();
        q.pop();

        for (auto e : graph[now]) {
            if (discovered[e])
                continue;
            sign[e] = now;
            discovered[e] = true;
            q.push(e);
        }
    }

    bool success = true;
    for (int i = 1; i <= N; i++) {
        if (!discovered[i]) {
            success = false;
            break;
        }
    }
    if (success) {
        cout << "Yes" << endl;
        for (int i = 2; i <= N; i++) {
            cout << sign[i] << endl;
        }
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 10188
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(a>0&&c>0)
	{
		if(c-b<=0){
			c=0;
			break;
		}
		c-=b;
		a-=d;
	}
	if(c==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
 } 

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = 0; i < k; i++) {
		if (i % 2 == 0) {
			if (a % 2 == 1) a--;
			b += (a /= 2);
		}
		else {
			if (b % 2 == 1) b--;
			a += (b /= 2);
		}
	}
	cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=5005;
const long long INF=4557430888798830399;
int n,A,B;
int a[N];
long long dp[N][N];
long long ans=INF;
int main()
{
    memset(dp,63,sizeof(dp));
	scanf("%d%d%d",&n,&A,&B);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	dp[0][0]=0;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=n;j++)
        	if(a[i]>j) dp[i][j]=min(dp[i][j],dp[i-1][j]+A),dp[i][a[i]]=min(dp[i][a[i]],dp[i-1][j]);
			else dp[i][j]=min(dp[i][j],dp[i-1][j]+B);
	for(int i=0;i<=n;i++)
		ans=min(ans,dp[n][i]);
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 195968
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <string.h>
typedef long long ll;


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

	cin>>n;
	int m[2][15];
	memset(m,0,sizeof(m));

	for (int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		for (int j=0;j<a;j++)
		{
			int x,y;
			cin>>x>>y;
			x--;
			m[y][i] |= (1<<x);
		}
		m[1][i]|=(1<<i);
	}

	int ret=0;
	for (int i=1;i<(1<<n);i++)
	{
		int h=0,u=0;
		for (int j=0;j<n;j++)
		{
			if (i&(1<<j))
			{
				u|=m[0][j];
				h|=m[1][j];
			}
		}

		if ((u&h)==0 && (h==i))
		{
			cerr<<"OK i="<<i<<" h="<<h<<" u="<<u<<endl;
			int c=0;
			for(int b=i; b; b&=(b-1)) c++;
			if (c>ret) ret=c;
		}else
			cerr<<"NG i="<<i<<" h="<<h<<" u="<<u<<endl;
	}
	cout << ret << endl;
}



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

def prime_list(n):
  prime = [2]
  limit = int(n ** 0.5)
  data = [i + 1 for i in range(2, n, 2)]
  while True:
    p = data[0]
    if limit <= p:
      return prime + data
    prime.append(p)
    data = [e for e in data if e % p != 0]
    
p = prime_list(101000)
#print(p[:10])

for pp in p:
  if pp >= N:
    print(pp)
    exit()

Measured memory_bytes: 45676
#include<stdio.h>
#define N 100
#define INF 10000000
int min(int,int);
int main(){
  int i,j,k,l,n,p[N+1],m[N+1][N+1];
  scanf("%d",&n);
  for(i = 1;i <= n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }
  for(i = 1;i <= n;i++){
    m[i][i]=0;
  }
  for(l = 2;l <= n;l++){
    for(i = 1;i <= n-l+1;i++){
      j=i+l-1;
      m[i][j]=INF;
      for(k = i;k < j;k++){
        m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}
int min(int x,int y){
  if(x > y){
    return y;
  }
  else return x;
}

Measured memory_bytes: 636
// Do you knOW what it feels like?

		// To be TorTured by your own MinD?

	// I don't wanna feel the PAIN.

// I BeG you to KILL me, pleASE...

#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Os")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()

typedef int ll;
typedef pair<ll,ll> pll;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=3e2+10, lg=20, mod=1e9+7, inf=1e18;

string s;
ll k,dp[maxn][maxn][maxn],ans=1;

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>s>>k;
	for(int i=0;i<SZ(s);i++)for(int j=0;j<=k;j++) dp[i][i][j]=1;
	for(int t=2;t<=SZ(s);t++)for(int l=0,r;l<=SZ(s)-t;l++){	r=l+t-1;
		for(int tg=0;tg<=k;tg++){
			dp[l][r][tg]=max(dp[l+1][r][tg],dp[l][r-1][tg]);
			if(tg!=0 || s[l]==s[r]) dp[l][r][tg]=max(dp[l][r][tg],dp[l+1][r-1][tg-(s[l]!=s[r])]+2);
			ans=max(ans,dp[l][r][tg]);
		}
		//cout<<l<<' '<<r<<' '<<dp[l][r][1]<<endl;
	}
	cout<<ans;
	
	return 0;
}



















Measured memory_bytes: 112896
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
using I = pair<int, int>;
using Compare = function<bool(int, int)>;
#define fst first
#define snd second

vector<I> func(const vector<I>& is, int p) {
  auto lcmp = [&](int i, int j) {
    if (is[i].snd != is[j].snd) return is[i].snd < is[j].snd;
    return i < j;
  };
  auto rcmp = [&](int i, int j) {
    if (is[i].fst != is[j].fst) return is[i].fst > is[j].fst;
    return i < j;
  };

  set<int, Compare> L(lcmp), R(rcmp);
  for (int i = 0; i < is.size(); i++) {
    L.insert(i);
    R.insert(i);
  }
  set<int, Compare> S[2] = {L, R};
  vector<I> ans;
  while (ans.size() < is.size()) {
    int i = *S[p].begin();
    ans.push_back(is[i]);
    S[0].erase(i);
    S[1].erase(i);
    p ^= 1;
  }
  return ans;
}

ll calcCost(const vector<I>& is) {
  ll ans = 0;
  int p = 0;
  for (const I& i : is) {
    if (i.fst <= p && p <= i.snd) {
      continue;
    }
    if (p < i.fst) {
      ans += i.fst - p;
      p = i.fst;
    } else {
      ans += p - i.snd;
      p = i.snd;
    }
  }
  ans += abs(p);
  return ans;
}

int main() {
  int N;
  while (cin >> N) {
    vector<I> is(N);
    for (int i = 0; i < N; i++) cin >> is[i].first >> is[i].second;
    ll ans = max(calcCost(func(is, 0)), calcCost(func(is, 1)));
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 20964
s = int(input())
alist = []
alist.append(s)
while True:
  if (s % 2) == 0:
    a = s / 2
    if a not in alist:
      alist.append(a)
      s = a
    else:
      print(len(alist) + 1)
      break
  else:
    a = s * 3 + 1
    if a not in alist:
      alist.append(a)
      s = a
    else:
      print(len(alist) + 1)
      break

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, K; cin >> N >> K;
	vector<int> bkt(N, 0);
	for (int i = 0; i < N; ++i) {
		int a; cin >> a; --a;
		++bkt[a];
	}
	sort(bkt.begin(), bkt.end());
	auto ub = upper_bound(bkt.begin(), bkt.end(), 0);
	int kind = N - (ub - bkt.begin());
	int ans = 0;
	while (kind > K) {
		ans += *ub;
		++ub;
		--kind;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::string s; std::cin >> s;
  auto ret = 0;
  rep(d, 1, n) {
    auto cnt = 0;
    rep(i, 0, n - d) {
      auto j = i + d;
      if (s[i] == s[j]) cnt++;
      else cnt = 0;
      cmx(ret, std::min(d, cnt));
    }
  }
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 3 * 1e5 + 5;
const ll mod = 1e6 + 3;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
bool f(const string &a, int x, int y){
    while(x < y){
        if(a[x] != a[y])
            return 0;
        x++;y--;
    }
    return 1;
}
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    string s;
    cin >> s;
    if(f(s, 0, sz(s) - 1) && f(s, 0, (sz(s) - 1) / 2 - 1) && f(s, (sz(s) + 3) / 2 - 1, sz(s) - 1))
        cout << "Yes\n";
    else cout << "No\n";
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define data(x,y) (data){x,y}
using namespace std;
const int N=1<<19;
inline int gi() {
  char ch=getchar(); int q=0,x=0;
  while(ch<'0'||ch>'9') q=(ch=='-'?1:q),ch=getchar();
  while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
struct data{
  int x,y;
  void calc(const data &c){
    if (c.x>x)
      swap(x,y),x=c.x;
    else
      y=max(y,c.x);
    if (c.y>y)
      y=c.y;
  }
}w[N];
int ans[N];
int main(){
  int n=gi(),S=(1<<n),s;
  for (int i=0; i<S; ++i) s=gi(),w[i]=data(s,0);
  for (int t=1; t<S; t<<=1)
    for (int i=0; i<S; i+=t<<1)
      for (int j=0; j<t; ++j)
	w[i+j+t].calc(w[i+j]);
  for (int i=0; i<S; ++i) ans[i]=w[i].x+w[i].y;
  for (int i=1; i<S; ++i)
    printf("%d\n",ans[i]=max(ans[i],ans[i-1]));
  return 0;
}

Measured memory_bytes: 8192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            string[] NK = Console.ReadLine().Split(' ');
            int N = int.Parse(NK[0]);
            int K = int.Parse(NK[1]);

            string[] P = Console.ReadLine().Split(' ');

            int[] p = new int[N];

            for(int i = 0; i < N; i++)
            {
                p[i] = int.Parse(P[i]);
            }

            Array.Sort(p);

            int answer = 0;

            for(int i = 0; i < K; i++)
            {
                answer += p[i];
            }

            Console.WriteLine(answer);
        }
    }
}

Measured memory_bytes: 27664
from collections import Counter

# 再帰回数のエラー？と思われるので再帰上限を変更 10**3→10**9
import sys
sys.setrecursionlimit(10 ** 9)

def main(N, M, C):
    lst = [n for n in range(N)] # 初期値はすべてがそれぞれ根である状態

    def get_root(x):    # 根を得る関数
        if lst[x] == x: # それ自身が根である場合
            return x
        else:   # 根が別のものである場合
            lst[x] = get_root(lst[x])   # 経路圧縮あり (ある種「メモ再帰化」)
            return lst[x]
            # return get_root(lst[x]) # 経路圧縮なし (わかりやすい，ただの再帰関数)

    def unite(x, y):    # 集合の連結を行う関数
        root_x = get_root(x)
        root_y = get_root(y)
        if root_x != root_y:    # 根が違う (=異なる集合) ならば
            lst[root_x] = root_y

    {unite(*c) for c in C}  # 集合の連結を行う．

    print(max(Counter(map(get_root, lst)).values()))


if __name__ == '__main__':
    N, M = list(map(int, input().split()))
    C = set()
    for _ in range(M):
        C.add(tuple(map(lambda x:int(x)-1, input().split())))   # pythonのindexに合わせるために "-1"
    main(N, M, C)


Measured memory_bytes: 52700
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e18+1

using ll = long long;
const ll mod = LLONG_MAX;


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

edge es[2010];
int d[1010];//最短距離　入力を負にしてヒックリカセス
int V,E;
void shrtest_path(int s){
  rep(i,V)d[i]=INF;

  d[s]=0;
  rep(cnt,V+1){
    bool update=false;
    rep(i,E){
      edge e=es[i];
      if(d[e.from]!=INF && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;

        update=true;
        if(cnt>=V){

          cout<<"inf"<<endl;


        }
      }


    }
    if(!update)break;
  }
}

bool find(){
  rep(i,V)d[i]=0;
  rep(i,V){
    rep(j,E){
      edge e = es[j];
      if(d[e.to]>d[e.from]+e.cost){
        d[e.to] = d[e.from] +e.cost;

        if(i==V-1)return true;
      }
    }
  }
  return false;
}



signed main(){
  cin>>V>>E;
  rep(i,E){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    es[i].from=a;
    es[i].to=b;
    //入力　負
    es[i].cost=-c;
  }

  bool changed[2*V];
  rep(i,V){
    d[i] = INF;
    changed[2*i]=false;
    changed[2*i+1]=false;
  }
  d[0]=0;
  int xc=2*V;
  rep(i,xc){
      rep(j,E){
        edge e = es[j];
          if( d[ e.to ] > d[e.from]+e.cost ){
            d[e.to] = d[e.from] +e.cost;

              if( e.to== V-1 )
                  changed[i]=true;
          }
      }
  }

  if(changed[2*V-1]){
    cout<<"inf"<<endl;
  }else{
    cout<<-d[V-1]<<endl;
  }

  return 0;



}


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

using namespace std;
typedef long long ll;

string s;
int sz;
ll old, d = 0, ans;

void dfs(int rem, int mask, ll p) {
  if (rem == 0) {
    ll nd = min(abs(p - old), (ll)pow(10, sz) - abs(p - old));
    if (nd < d) return;
    if (nd == d) ans = min(ans, p);
    else ans = p;
    d = nd;
    return;
  }
  for (int i = 0; i < 10; i++) {
    if ((mask >> i & 1) == 0) {
      dfs(rem - 1, mask | (1 << i), p * 10 + i);
    }
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  cin >> s;
  sz = s.size();
  old = atoll(s.c_str());
  dfs(sz, 0, 0);
  cout << setfill('0') << right << setw(sz) << ans << endl;

  return 0;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

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

    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    vi p(a), q(b), r(c);
    rep(i, 0, a) { cin >> p[i]; }
    rep(i, 0, b) { cin >> q[i]; }
    rep(i, 0, c) { cin >> r[i]; }

    // O(alog(a))
    sort(p.begin(), p.end());
    // O(blog(b))
    sort(q.begin(), q.end());

    priority_queue<int> p_queue, q_queue;
    rep(i, a - x, a) { p_queue.push(-p[i]); }
    rep(i, b - y, b) { q_queue.push(-q[i]); }

    // O(c(log(a) + log(b)))
    rep(i, 0, c) {
        int pi = -p_queue.top();
        int qi = -q_queue.top();

        if (r[i] < pi && r[i] < qi) { continue; }
        if (pi < qi) {
            p_queue.pop();
            p_queue.push(-r[i]);
        } else {
            q_queue.pop();
            q_queue.push(-r[i]);
        }
    }

    ll ans = 0;
    while (!p_queue.empty()) {
        ans -= p_queue.top();
        p_queue.pop();
    }
    while (!q_queue.empty()) {
        ans -= q_queue.top();
        q_queue.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2552
#include <iostream>
#include <cstdlib>
using namespace std;
int x,a,b;
void solve()
{
    if (abs(x-a)<abs(x-b)) cout<<"A";
    else cout<<"B";
    cout<<endl;
}
int main()
{
    while(cin>>x>>a>>b)
        solve();
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long
int main() {
    ll w,h,x,y;
    cin >> w >> h >> x >> y ;
    cout << (double)w * h / 2 << endl;
    if ((x == (double)w/2) && (y == (double)h/2)) {
        cout << '1';
    }
    else {
        cout << '0';
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<bitset>
#include<cstdio>
#include<iomanip>

#define PII pair<int,int>
#define LLI long long int

using namespace std;

int main(){
	int N;cin>>N;
	vector<vector<int> >abc(N,vector<int>(3));
	for(int i=0;i<N;i++)for(int j=0;j<3;j++)cin>>abc[i][j];
	vector<vector<int> >dp(N,vector<int>(3,0));
	for(int i=0;i<N;i++){
		for(int j=0;j<3;j++){
			if(i==0)dp[0][j]=abc[0][j];
			else{
				dp[i][j]=abc[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
			}
		}
	}
	int ans=max(max(dp[N-1][0],dp[N-1][1]),dp[N-1][2]);
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 11136
class Tree():
    def __init__(self, n, edge):
        self.n = n
        self.tree = [[] for _ in range(n)]
        for e in edge:
            self.tree[e[0] - 1].append(e[1] - 1)
            self.tree[e[1] - 1].append(e[0] - 1)

    def setroot(self, root):
        self.root = root
        self.parent = [None for _ in range(self.n)]
        self.parent[root] = -1
        self.depth = [None for _ in range(self.n)]
        self.depth[root] = 0
        self.order = []
        self.order.append(root)
        stack = [root]
        while stack:
            node = stack.pop()
            for adj in self.tree[node]:
                if self.parent[adj] is None:
                    self.parent[adj] = node
                    self.depth[adj] = self.depth[node] + 1
                    self.order.append(adj)
                    stack.append(adj)

    def rerooting(self, func, merge, ti, ei):
        dp = [ti for _ in range(self.n)]
        lt = [ei for _ in range(self.n)]
        rt = [ei for _ in range(self.n)]
        inv = [ei for _ in range(self.n)]
        self.setroot(0)
        for node in self.order[::-1]:
            tmp = ti
            for adj in self.tree[node]:
                if self.parent[adj] == node:
                    lt[adj] = tmp
                    tmp = func(tmp, dp[adj])
            tmp = ti
            for adj in self.tree[node][::-1]:
                if self.parent[adj] == node:
                    rt[adj] = tmp
                    tmp = func(tmp, dp[adj])
            dp[node] = tmp
        for node in self.order:
            if node == 0:
                continue
            merged = merge(lt[node], rt[node])
            par = self.parent[node]
            inv[node] = func(merged, inv[par])
            dp[node] = func(dp[node], inv[node])
        return dp

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
E = [tuple(map(int, input().split())) for _ in range(N - 1)]

T = Tree(N, E)

def func(node, adj):
    return node * (adj + 1) % M

def merge(lt, rt):
    return lt * rt % M

ti = 1
ei = 0

D = T.rerooting(func, merge, ti, ei)

print('\n'.join(map(str, D)))

Measured memory_bytes: 56348
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0)
int s[1 << 20];
int D[20][1 << 20];
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n;
    fi>>n;
    for (int i = 1;i <= n;++i) fi>>s[i];
    int cnt = n;
    int l;
    fi>>l;
    for (int i = n;i;--i)
    {
        while (s[cnt] - s[i] > l) --cnt;
        D[0][i] = cnt;
    }
    for (int k = 1;k < 20;++k)
        for (int i = 1;i <= n;++i)
            D[k][i] = D[k-1][D[k-1][i]];
    int Q;
    fi>>Q;
    while (Q--)
    {
        int a,b;
        fi>>a>>b;
        if (a > b) swap(a,b);
        int ans = 0;
        for (int k = 19;k+1;--k)
            if (D[k][a] < b)
                ans += 1 << k,a = D[k][a];
        ++ans;
        fo << ans << '\n';
    }
    return 0;
}




Measured memory_bytes: 9088