akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <set>
#include <map>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()

using namespace std;

int main(){
	string s;
	map<char, bool> bo;
	map<char, bool> si;
	map<char, bool> mu;

	bo['a'] = bo['i'] = bo['u'] = bo['e'] = bo['o'] = true;
	for (char c = 'a'; c <= 'z'; c++) {
		if (bo[c] == false) {
			si[c] = true;
		}
	}
	mu['k'] = mu['s'] = mu['t'] = mu['h'] = mu['p'] = true;

	while (cin >> s && s != "#") {
		
		s += "@@";

		vector<string> v;
		vector<int> k;
		for (int i = 0;i < s.size();) {
			if (s[i] == '@')break;
			string t; 
			
			if (i >= 1 && bo[s[i]] && s[i] == s[i - 1]) { //テゥツ閉キテゥツ淞ウ
				t += s.substr(i, 1);
				i += 1;
				k.push_back(5);
			}
			else
			if (bo[s[i]]) {
				t += s.substr(i, 1);
				i++;
				k.push_back(0);
			}else
			if (si[s[i]] && bo[s[i + 1]]) {
				t += s.substr(i, 2);
				i += 2;
				k.push_back(2);
			}else
			if (si[s[i]] && s[i] != 'y' && s[i] != 'w' && s[i + 1] == 'y' && bo[s[i + 2]]) {
				t += s.substr(i, 1) + s.substr(i + 2, 1);
				i += 3;
				k.push_back(3);
			}else
			if (si[s[i]] && s[i] == s[i + 1]) { //テ、ツソツεゥツ淞ウ
				t += s.substr(i, 1);
				i += 1;
				k.push_back(4);
			}else
			if (s[i] == 'n') {
				if (s[i + 1] == '\'') {
					t += s.substr(i, 2);
					i += 2;
				}
				else {
					t += s.substr(i, 1);
					i += 1;
				}
				k.push_back(1);
			}
			v.push_back(t);
		}
		vector<bool> f(v.size(), false);

		//i u
		rep(i, v.size()) {
			if (k[i] != 5) {
				rep(j, v[i].size()) {
					if (v[i][j] == 'i' || v[i][j] == 'u') {
						char pr = '@';
						if (j >= 1)pr = v[i][j - 1];
						else if(i >= 1){
							pr = v[i - 1].back();
						}
						char ne = '@';
						if (j + 1 < v[i].size())ne = v[i][j + 1];
						else if(i + 1 < v.size()){
							ne = v[i + 1].front();
						}
						if (mu[pr] && (mu[ne] || ne == '@')) {
							f[i] = true;
						}
					}
				}
			}
		}

		//a o
		rep(i, v.size()) {
			if (v[i].size() >= 2) {
				if (mu[v[i][0]] && (v[i][1] == 'a' || v[i][1] == 'o')) {
					int ta = -1;
					char now = v[i][1];
					for (int j = i + 1; j < v.size(); j++) {
						if (v[j].size() >= 2 && mu[v[j][0]] && v[j][1] == now) {
							ta = j;
						}
						else {
							break;
						}
					}
					if (ta != -1) {
						for (int j = i; j < ta; j++) {
							f[j] = true;
						}
					}
				}
			}
		}

		int fl = 0;
		rep(i, v.size()) {
			if (f[i]) {
				if (fl == 1) {
					f[i] = false;
					fl = 0;
				}
				else {
					fl = 1;
				}
			}
			else {
				bool b = false;
				rep(j, v[i].size()) {
					if (bo[v[i][j]]) {
						b = true;
					}
				}
				if (b) {
					fl = 0;
				}
			}
		}

		rep(i, v.size()) {
			if (k[i] == 3) {
				v[i] = v[i].substr(0, 1) + "y" + v[i].substr(1, 1);
			}
			if (f[i]) {
				rep(j, v[i].size()) {
					if (bo[v[i][j]]) {
						cout << '(';
					}
					cout << v[i][j];
					if (bo[v[i][j]]) {
						cout << ')';
					}
				}
			}
			else {
				cout << v[i];
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(void){
    int n;
    cin>>n;
    map<int,int> m;
    for(int i=0;i<n;++i) {
        int a;
        cin >> a;
        ++m[a];
    }
    int ans = 0;
    for ( auto i = m.begin(); i != m.end() ; ++i ) {
        // std::cout << key << " => " << value << "\n";
        if( i->second == i->first) {
            continue;
        }
        if( i->second < i->first) {
            ans +=  i->second;
            continue;
        }
        ans +=  i->second - i->first;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 6272
#include <iostream>
using namespace std;
long long n, p, a, s, ans, d[55][5005]={1};
int main() {
	int i, j;
	cin>>n>>p;
	for(i=1; i<=n; i++) {
		cin>>a;
		for(j=s; j>=0; j--)
			if(d[i-1][j]) {
				d[i][j] += d[i-1][j];
				d[i][j+a] += d[i-1][j];
			}
		s += a;
	}
	for(j=p; j<=s; j+=2) ans += d[n][j];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String SA = in.next();
            String SB = in.next();
            String SC = in.next();
            int ia = 0, ib = 0, ic = 0;
            int p = 0;
            while (true) {
                char win = 0;
                switch (p) {
                    case 0:
                        if (ia >= SA.length()) {
                            win = 'A';
                        } else {
                            p = SA.charAt(ia++) - 'a';
                        }
                        break;
                    case 1:
                        if (ib >= SB.length()) {
                            win = 'B';
                        } else {
                            p = SB.charAt(ib++) - 'a';
                        }
                        break;
                    default:
                        if (ic >= SC.length()) {
                            win = 'C';
                        } else {
                            p = SC.charAt(ic++) - 'a';
                        }
                        break;
                }
                if (win != 0) {
                    out.println(win);
                    return;
                }
            }
        }

    }
}



Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};

int h, n;
int *a, *b, *f;

const int inf = 100000000;

int main() {
	cin >> h >> n;
	a = new int[n + 10];
	b = new int[n + 10];
	f = new int[h + 1];

	for (int i = 0; i < n; ++i) {
		scanf("%d%d", &a[i], &b[i]);
	}
	for (int i = 0; i <= h; ++i) {
		f[i] = inf;
	}
	f[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= h; ++j) {
			f[j] = min(f[j], f[max(j - a[i], 0)] + b[i]);
		}
	}
	cout << f[h] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int W,H,N;cin>>W>>H>>N;
  vector<int>X1;
  vector<int>X2;
  vector<int>Y1;
  vector<int>Y2;
  X1.push_back(0);
  X2.push_back(W);
  Y1.push_back(0);
  Y2.push_back(H);
  for(int i=0;i<N;i++){
    int x,y,a;
    cin>>x>>y>>a;
    if(a==1){
      X1.push_back(x);
    }
    else if(a==2){
      X2.push_back(x);
    }
    else if(a==3){
      Y1.push_back(y);
    }
    else{
      Y2.push_back(y);
    }
  }
  sort(X1.begin(),X1.end());
  sort(X2.begin(),X2.end());
  sort(Y1.begin(),Y1.end());
  sort(Y2.begin(),Y2.end());
  cout<<max(0,X2.at(0)-X1.at(X1.size()-1))*max(0,Y2.at(0)-Y1.at(Y1.size()-1))<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int r,c;	//変数の定義
	
	scanf("%d %d",&r,&c);	//最初の入力
	
	long int array[r + 1][c + 1];	//配列の定義
	
	for(int i = 0;i < r;i++){
		array[i][c] = 0;	//行の合計の初期化
	}
	
	for(int j = 0;j < c;j++){
		array[r][j] = 0;	//列の合計の初期化
	}
	
	array[r][c] = 0;		//全体の合計の初期化
	
	for(int i = 0;i < r;i++){
		for(int j = 0;j < c;j++){
			scanf("%ld",&array[i][j]);		//要素の入力
			array[i][c] += array[i][j];		//行の合計に足していく
			array[r][j] += array[i][j];		//列の合計に足していく
			array[r][c] += array[i][j];		//全体の合計に足していく
		}
	}
	
	for(int i = 0;i <= r;i++){
		for(int j = 0;j <= c;j++){
			printf("%ld",array[i][j]);	//出力
			if(j != c){
				printf(" ");	//行の最後を除き、空白で区切る
			}
		}
		printf("\n");	//行毎に改行
	}
	
	return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define maxm 
#define mod 
#define maxn 
int b[100100], a[110][110];
int main()
{
	int h, w, n;
	
	scanf("%d%d", &h, &w);
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &b[i]);
	}
	int loc = 1;
	for (int i = 0; i < h; i++) {
		if (i & 1) {
			for (int j = w - 1; j >= 0; j--) {
				while (b[loc] == 0) loc++;
				a[i][j] = loc;
				b[loc]--;
			}
		} else {
			for (int j = 0; j < w; j++) {
				while (b[loc] == 0) loc++;
				a[i][j] = loc;
				b[loc]--;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w - 1; j++) {
			printf("%d ", a[i][j]);
		}
		printf("%d\n", a[i][w - 1]);
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
#include <vector>

using namespace std;

typedef long long ll;

int main(){
	int D, T, S;
	cin >> D >> T >> S;
	if(T*S >= D){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	return 0;
}


Measured memory_bytes: 3572
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

# 尺取
N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))

s = 0
x = 0
l = 0
r = 0
ans = 0
while l < N:
    while r < N and s + A[r] == x ^ A[r]:
        s += A[r]
        x ^= A[r]
        r += 1
    ans += r - l
    # print(l, r, s, x)
    s -= A[l]
    x ^= A[l]
    l += 1
print(ans)


Measured memory_bytes: 30852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	srand(time(NULL));
	ll x, y;
	cin >> x >> y;
	if (x % y == 0)
	{
		cout << -1 << endl;
	}
	else
	{
		do
		{
			ll randint = rand() + 1;
			if (x * randint % y != 0)
			{
				cout << x * randint << endl;
				break;
			}
		} while (true);
	}
}

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

using namespace std;

int main(){
    int n, ma = 1e9, x,cnt=0;
    scanf("%d",&n);
    for(int i =1;i<=n;i++){
        scanf("%d",&x);
        if(x < ma) cnt++,ma=x;
    }
    printf("%d",cnt);
}


Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    io.Source.stdin.getLines foreach (n => println(pi(n.toInt)))
  }
  val primes: Vector[Int] = (2 #:: Stream.from(3,2).filter(n=> Primes.miller_rabin_test(n))).take(1000).toVector
  val pi_cache: collection.mutable.Map[Int, Int] = collection.mutable.Map.empty
  val phi_cache: collection.mutable.Map[(Int, Int), Int] = collection.mutable.Map.empty

  def bisect(n: Int): Int = {
    def loop(left: Int, right: Int): Int = {
      val mid = (left + right) / 2
      if (primes(mid) <= n && n < primes(mid+1)) mid+1
      else if (n < primes(mid)) loop(left, mid)
      else loop(mid+1, right)
    }
    if (n < primes.head) 0
    else if (n >= primes.last) primes.length
    else loop(0, primes.length)
  }
  def pi(x: Int): Int =
    pi_cache.getOrElseUpdate(x,
      if (x <= primes.last) bisect(x)
      else {
        val a = pi(Math.sqrt(Math.sqrt(x)).toInt)
        val b = pi(Math.sqrt(x).toInt)
        val c = pi(Math.cbrt(x).toInt)
        var result = phi(x, a) + ((b + a - 2) * (b - a + 1)) / 2
        for (i <- a + 1 to b) {
          val w = x / primes(i - 1)
          val b_i = pi(Math.sqrt(w).toInt)
          result -= pi(w)
          if (i <= c)
            for (j <- i to b_i)
              result = result - pi(w / primes(j - 1)) + j - 1
        }
        result
      }
    )
  def phi(x: Int, a:Int): Int =
    phi_cache.getOrElseUpdate(
      (x,a),
      {
        if (a == 1) (x + 1) / 2
        else phi(x, a - 1) - phi(x / primes(a - 1), a - 1)
      }
    )
  object Primes {
    private def mod_exp(x: Int, n: Int, m: Int): Int = {
      def loop(x: Int, n: Int, acc: Int): Int = {
        if (n == 0) acc
        else loop (
          (x * x) % m,
          n >> 1,
          if ((n & 1) == 1) (acc * x) % m else acc
        )
      }
      loop(x,n,1)
    }
    private def div_pow_2(d: Int, s: Int = 0): (Int, Int) ={
      if ((d % 2) != 0) (d,s)
      else div_pow_2(d/2, s+1)
    }
    private def miller_rabin(n: Int, a: Int): Boolean = {
      val (d,s): (Int, Int) = div_pow_2(n-1)
      val a_exp_d: Int = mod_exp(a,d,n)
      def double(x: Int): Int = mod_exp(x,2,n)
      def loop(e: Int, i: Int): Boolean = {
        if (i == 0) false
        else if (e == n-1) true
        else loop(double(e), i-1)
      }
      a_exp_d == 1 || loop(a_exp_d, s)
    }
    def miller_rabin_test(n: Int, k: Int = 20): Boolean = {
      def loop(i: Int): Boolean = {
        if (i == 0) true
        else {
          val a = scala.util.Random.nextInt(n-1)+1
          if (miller_rabin(n,a)) loop(i-1)
          else false
        }
      }
      if (n < 2) false
      else loop(k)
    }
  }
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

void solve()
{
    int N; cin >> N;
    if(N % 10 == 9 || N / 10 == 9) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    solve();

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

int main(){
 int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;

  int n;
  n=max(x,y);
  
  int res=1000000000;
  for(int i=0;i<=n;i++){
   res=min(res,2*c*i+max(0,x-i)*a+max(0,y-i)*b);
  }
  
 cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,k,a[10000],b=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
	cin>>a[i];
  }
  sort(a,a+n,greater<int>());
  for(int i=0;i<k;i++){
	b+=a[i];
  }
  cout<<b<<"\n";
}

Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << min(A, B) + min(C, D) << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
x=[]
d=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    d[a-1].append(b-1)
    d[b-1].append(a-1)
    x.append((a-1,b-1))
ans=0
for i in x:
    t=set([i[0]])
    r=set()
    while len(t):
        o=t.pop()
        for j in d[o]:
            if j not in r and len(set([o,j])&set([i[0],i[1]]))!=2:
                r.add(j)
                t.add(j)
    if len(r)!=n: ans+=1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

ll n,k;
ll dp[101][N];
ll a[101];

ll dps(ll i,ll l,ll r)
{
    ll x=0,y=0;
    if(l!=-1)
    {
        x=dp[i][l];
    }
    y=dp[i][r];
    return (y-x+hell)%hell;
}
void solve()
{
    cin>>n>>k;
    rep(i,1,n+1)
    {
        cin>>a[i];
    }
    rep(i,0,k+1)
        dp[0][i]=1;
    rep(i,1,n+1)
    {
        dp[i][0]=1;
        rep(j,1,k+1)
        {
            dp[i][j]=(dp[i][j-1]+dps(i-1,j-min(j,a[i])-1,j))%hell;
        }
    }
    cout<<dps(n,k-1,k)<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 82536
n, k = map(int,input().split())
n_k = [0 for i in range(n)]
for i in range(k):
  _n = int(input())
  _k = list(map(int, input().split()))
  for i in _k:
    n_k[i-1] += 1

print(len([1 for i in n_k if i==0]))

Measured memory_bytes: 9196
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    ll N;
    cin >> N;

    if (N % 1000 == 0)
        cout << 0 << endl;
    else
        cout << (N / 1000 + 1) * 1000 - N << endl;

    return 0;
}

Measured memory_bytes: 3640
# -*- Coding: utf-8 -*-
a, b = map(int, input().split())
def my_gcd(a, b):
  if b == 0:
    return a
  else:
    return my_gcd(b, a % b)

gcd = my_gcd(a, b)
sqrt_gcd = int(gcd ** 0.5)
div_list = []
i = 2
res_gcd = gcd

while i <= sqrt_gcd:
  if res_gcd % i == 0:
    div_list.append(i)
    res_gcd = res_gcd / i
  else:
    i += 1
  if res_gcd == 1:
    break
if res_gcd > 1:
  div_list.append(gcd)
uni_cd = list(set(div_list))
ans = 1 + len(uni_cd)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
int main(){
    ld n,k;
    cin >> n >> k;
    int ans = 0;
    while(true){
        if(pow(k,ans+1) > n){
            ans++;
            break;
        }
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

struct STX {
    int s, t, x;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    int n, q;
    cin >> n >> q;
    vector<STX> stx(n);
    rep(i, n) cin >> stx[i].s >> stx[i].t >> stx[i].x;
    set<pair<int, int>> d;
    vector<int> ans(q, -1);
    rep(i, q) {
        int tmp;
        cin >> tmp;
        d.insert(make_pair(tmp, i));
    }
    sort(all(stx), [](const STX &a, const STX &b) { return a.x < b.x; });
    rep(i, n) {
        int l = stx[i].s - stx[i].x;
        int r = stx[i].t - stx[i].x;
        auto it = d.lower_bound(make_pair(l, -1));
        while(it != d.end()) {
            if (it->first >= r) break;
            ans[it->second] = stx[i].x;
            d.erase(it++);
        }
    }
    rep(i, q) printf("%d\n", ans[i]);
    return 0;
}


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

int main() {
	int min = 10000, a, b, c,d;
	char str[100] = {};
	cin >> str;
	for (int i = 2; str[i] != '\0'; i++) {
		a = (str[i - 2] - '0') * 100;
		b = (str[i - 1] - '0') * 10;
		c = str[i] - '0';
		d = a + b + c;
		if (753 >= d && min > 753 - d) min = 753 - d;
		else if (753 < d && min > d - 753) min = d - 753;
	}
	cout << min;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e2+5;
const ll INF = 2e18;
 
inline ll gcd(ll a,ll b){
	return b ?gcd(b,a%b) :a;
}
 
int main()
{
	ll n,ans = 0;
	cin >> n;
	for(ll i = 1;i <= n;++i){
		for(ll j = 1;j <= n;++j){
			for(ll k = 1;k <= n;++k){
				ans += gcd(i,gcd(j,k));
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3596
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
	public static long sumXOR(long arr[], int n) 
    { 
    	long mod= (long)1e9+7;
        long sum = 0; 
        for (long i = 0; i <61; i++)  
        { 
            long zc = 0;  
            long idsum = 0;  
            long k=(long)(1l << i);// fuck this "1l" 
            // for long you have to write 1 as long otherwise
            // we will get the wrong result
            for (int j = 0; j < n; j++) 
            { 
                if ((arr[j]&k)==0) 
                    {zc++;}  
            }             
            k%=mod;
            long x=(long)zc*(n-zc);
            x%=mod;
            idsum = (long) x*k;  
            sum = (long)(sum+idsum)%mod;  
        } 
        return sum; 
    } 
public static void main(String[] args) throws FileNotFoundException, IOException{
       Scanner s=new Scanner(System.in);
      int n=s.nextInt();
      long[] arr=new long[n];
      for(int i=0;i<n;i++){
      	arr[i]=s.nextLong();
      } 	
      long res=sumXOR(arr,n);
      System.out.println(res);
      }
        }
    


Measured memory_bytes: 99480
import Data.Map ((!))
import qualified Data.Map as M

main = readLn>>=print.solve

solve :: Int -> Int
solve n = M.foldr (+%) 0 $ ans !! n
  where
  ans = replicate 3 M.empty
        ++ M.fromList [([a,b,c],1)
                      | a<-"ACGT", b<-"ACGT", c<-"ACGT"
                      , [a,b,c] `notElem` ["AGC","ACG","GAC"] ]
         : map f (drop 3 ans)
  f pMap = foldl g M.empty [[a,b,c,d] | a<-"ACGT", b<-"ACGT", c<-"ACGT", d<-"ACGT"]
    where
    g cMap ['A','G','C', _ ] = cMap
    g cMap [ _ ,'A','G','C'] = cMap
    g cMap ['A','C','G', _ ] = cMap
    g cMap [ _ ,'A','C','G'] = cMap
    g cMap ['G','A','C', _ ] = cMap
    g cMap [ _ ,'G','A','C'] = cMap
    g cMap ['A', _ ,'G','C'] = cMap
    g cMap ['A','G', _ ,'C'] = cMap
    g cMap head4 = M.insertWith (+%) (init head4) (pMap!tail head4) cMap

a +% b = mod (a+b) 1000000007

Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main() {
	int n;cin >> n;
    LV a(n);
    REP(i,n) cin >> a[i];

    llong sum = 0;REP(i,n) sum+=a[i];
    double half = sum/2.0;llong s=0;
    double be = half;
     REP(i,n){
         s+=a[i];
         if(abs(half-s)>be){
             break;
         }
         be = abs(half-s);
    }
    cout << (int)(be*2) << endl;
    return 0;

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1e9+7
int main(){
	int n,w; cin>>n>>w;
	
	vector<int> dp(1e5+1,INF);
	
	dp[0]=0;
	
	for(int i=0;i<n;i++){
		int weight,value; cin>>weight>>value;
		for(int j=1e5;j>=value;j--){
			dp[j]=min(dp[j],dp[j-value]+weight);
		}
	}
	for(int i=1e5;i;i--){
		if(dp[i]<=w){
			cout<<i;
			return 0;
		}
	}
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
bool type[100010];
int main() {
	int N;
	cin >> N;
	string s;
	cin >> s;
	s.push_back(s[0]);
	bool ok = 0;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			type[0] = i;
			type[1] = j;
			for (int k = 2; k <= N + 1; k++) {
				if (type[k - 1]) {
					if (s[k - 1] == 'o') type[k] = type[k - 2];
					else type[k] = !type[k - 2];
				}
				else {
					if (s[k - 1] == 'o') type[k] = !type[k - 2];
					else type[k] = type[k - 2];
				}
			}
			if (type[0] == type[N] && type[1] == type[N + 1]) {
				ok = 1;
				break;
			}
		}
		if (ok) break;
	}
	if (!ok) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 0; i < N; i++) {
		if (type[i]) cout << "S";
		else cout << "W";
	}
	cout << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
// #include <string>
// #include <climits>
// #include <algorithm>
// #include <set>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int n,mod = 1e9+7;
	cin >> n;

	vector<vector<int> > comp(n,vector<int>(n,0));
	vector<int> dp(1<<n,0);

	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin >> comp[i][j];
	dp[0] = 1;
	
	for(int i=0;i<(1<<n)-1;i++){
		int m = __builtin_popcount(i);
		for(int j=0;j<n;j++){
			int temp = i|(1<<j);
			if(comp[m][j]&&temp!=i)
				dp[temp] = (dp[i]+dp[temp])%mod;
 		}
	}
	cout << dp[(1<<n)-1];
}

Measured memory_bytes: 11444
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s,t;
    cin >> s;
    cin >> t;
    const char * sc = s.c_str();
    const char * tc = t.c_str();
    for(int i=0;i<s.length();i++){
        if(sc[i]!=tc[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <unordered_set>

using namespace std;

int main() {
  string o, e;
  cin >> o >> e;
  int io = 0, ie = 0;

  while (true) {
    if (io < o.size())
      cout << (char)o[io++];
    if (ie < e.size())
      cout << (char)e[ie++];

    if (io == o.size() && ie == e.size())
      break;
  }
  cout << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
const int N=1e5+10;

int main(){
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin>>n;
  vector<vector<int> > dp(n,vector<int>(3,0));
  vector<vector<int> > a(n,vector<int>(3,0));
  for(int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
  dp[0][0]=a[0][0]; dp[0][1]=a[0][1]; dp[0][2]=a[0][2];
  for(int i=1;i<n;i++){
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
    dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];
  }
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
  return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
    return 0;
}

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

using namespace std;

const int N = 1e5 + 100;
long long a[N];
int main() {
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i ++) scanf("%lld", &a[i]);
	long long sum = 0;
	for(int i = 1; i <= n; i ++) sum += max(0LL, a[i]);
	int ub = 1;
	long long cur = 0;
	long long ans = -(1LL << 60);
	for(int lb = 1; lb + m - 1 <= n; lb ++) {
		while(ub <= lb + m - 1) {
			sum -= max(0LL, a[ub]);
			cur += a[ub];
			ub ++;
		}
		ans = max(ans, sum + max(cur, 0LL));
		sum += max(0LL, a[lb]);
		cur -= a[lb];
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から


typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    //a>=b
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

#define MOD ((ll)1e+9 + 7)



//cout<<fixed<<setprecision(10);
int main(){
    int n;
    cin>>n;
    vector<int> p(n);
    rep(i,n){
        cin>>p[i];
    }
    int cnt=0;
    for(int i=1;i<n-1;i++){
        int tmp[3]={p[i-1],p[i],p[i+1]};
        sort(tmp,tmp+3);
        if(tmp[1]==p[i]) cnt++;
    }
    cout<<cnt<<endl;



    return 0;
}



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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

void ALLOUT_NUMBER(vector<ll> V)
{
    ll N = V.size();
    for(ll i=0;i<N;i++)
    {
        cout << V[i];
        if(i<N-1) cout << ' ';
    }
    cout << endl;
}

template<class T>
void OUT0(T N)
{
    cout << N << endl;
}

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

ll log2_N(ll N)
{
    for(ll i=0;;i++)
    {
        if((1<<i)>=N)
        {
            return i;
        }
    }
}

vector<ll> Basically_move(ll N, ll K, vector<ll> A)
{
    for(ll i=0;i<min(log2_N(N)+100,K);i++)
    {
        vector<ll> UpDown(N+1,0);
        for(ll j=0;j<N;j++)
        {
            UpDown[max(0LL,j-A[j])]++;
            UpDown[min(N,j+A[j]+1)]--;
        }
        vector<ll> next(N);
        next[0] = UpDown[0];
        for(ll j=1;j<N;j++)
        {
            next[j] = next[j-1] + UpDown[j];
        }
        A = next;
    }
    return A;
}

int main()
{
    ll N,K;
    cin >> N >> K;

    vector<ll> A(N);
    ALLIN1_NUMBER(A);

    ALLOUT_NUMBER(Basically_move(N,K,A));

    return 0;
}

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

int find_substring(char str[], char sub[]){
    char *p1, *p2, *p3;
    int i,j;
    int flag = 0;

    p1 = str; p2 = sub;

    for(i=0; i<strlen(str); i++){
        if(flag == 1) break;
        if(*p1 == *p2){
            p3 = p1;
            for(j=0; j<strlen(sub); j++){
                if(*p3 == *p2){
                    p3++;
                    p2++;
                }
                else
                    break;
            }
            p2 = sub;/*Important!!*/
            if(j == strlen(sub))
                flag = 1;
        }
        *p1++;
    }
    return flag;
}

int main(){
    
    char str[201];
    char s[301];
    char sub[201];
    int i, j;

    /*get input*/
    fgets(str, sizeof(str), stdin);
    fgets(sub, sizeof(sub), stdin);
    /*replace '\n' of input to '\0'*/
    str[strlen(str)-1] = '\0';
    sub[strlen(sub)-1] = '\0';
    /*copy the first line twice to s*/    
    strcpy(s, str);
    strcat(s, str);
    //printf("%s\n", s);

    if(find_substring(s, sub) == 1)
        printf("Yes\n");
    else
        printf("No\n");
}



Measured memory_bytes: 2064
d,g = map(int,input().split())
ary = [list(map(int,input().split())) for _ in range(d)]
s = set(i for i in range(d))
ans = float("Inf")
for i in range(2**d):
    a = []
    total,count = 0,0
    for j in range(d):
        if i >> j & 1:
            a.append(j)
    for x in a:
        total += 100*(x+1)*ary[x][0]+ary[x][1]
        count += ary[x][0]
    if total >= g:
        ans = min(ans,count)
        continue
    for y in sorted(s - set(a),reverse=True):
        if total + 100*(y+1)*(ary[y][0]-1) >= g:
            count += -(-(g-total) // (100*(y+1)))
            ans = min(ans,count)
            break
        total += 100*(y+1)*(ary[y][0]-1)
        count += ary[y][0]-1
    if total >= g:
        ans = min(ans,count)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#define EPS 1e-6
#define INF 2147483647
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define llINF 9223372036854775807

using namespace std;
int main(){
  int n;
  string str;
  cin>>n;
  cin>>str;
  int toji=0;
  int hira=0;
  for(int i=0;i<str.size();i++){
    if(hira==0&&str[i]==')'){
      toji++;
    }else if(str[i]=='('){
      hira++;
    }else if(str[i]==')'){
      hira--;
    }
  }
  for(int i=0;i<toji;i++)
    cout<<'(';
  cout<<str;
  for(int i=0;i<hira;i++)
    cout<<')';
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

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

typedef long long ll;

using namespace std;

int INF = 1e9;

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

  sort(a.begin(), a.end());
  sort(f.begin(), f.end(), greater<ll>());

  ll su = 0;
  rep(i,n) su += a[i];
  if(su <= k){
    cout << 0 << endl;
    return 0;
  }

  ll mi = 0, ma = 0;
  rep(i,n) ma = max(ma, a[i]*f[i]);

  while((ma-mi) > 1){
    ll kd  = 0;
    ll mid = (ma + mi) / 2;
    rep(i,n){
      kd += a[i] - min(a[i], mid / f[i]);
    }
    if(kd <= k) ma = mid;
    else        mi = mid;
  }  
  cout << ma << endl;
}


Measured memory_bytes: 3328
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)

//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

ll x[100005];
ll y[100005];

void solve()
{
    IN(a, b, m);
    ll mx = INF;
    rep(i, a)
    {
        cin >> x[i];
        chmin(mx, x[i]);
    }
    ll my = INF;
    rep(i, b)
    {
        cin >> y[i];
        chmin(my, y[i]);
    }
    ll res = mx + my;
    rep(i, m)
    {
        IN(d, e, f);
        chmin(res, x[d-1] + y[e-1] - f);
    }
    cout << res << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

int main() {
  int A, B, X;
  std::cin >> A >> B >> X;

  int cats = X - A;
  if ( cats == 0 ) {
    std::cout << "YES" << std::endl;
  } else if ( cats > 0 ) {
    cats -= B;
    if ( cats <= 0 ) {
      std::cout << "YES" << std::endl;
    } else {
      std::cout << "NO" << std::endl;
    }
  } else {
    std::cout << "NO" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;


int main()
{
	double t, x;
	cin >> t >> x;
	
	cout << t / x << endl;
	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("myfile.in","r",stdin);freopen ("myfile.out","w",stdout);
#define mod 1000000007
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
using namespace std;

ll n,m,ar[N],sum;


int main()
{
	fast;
	cin>>n>>m;
	ll x=max(n,m)-1;
	ll y=min(n,m);
	cout<<max(n,m)+max(y,x);

}

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

using namespace std;

void go(int a[],int n,int p)
{
    int i;
    if(p==n)
    {
        for(i=0;i<n;i++)
            printf("%c",a[i]+'a');
        printf("\n");
        return;
    }

    int maxi=-1;
    for(i=0;i<p;i++)
        maxi=max(maxi,a[i]);
    maxi++;

    for(i=0;i<=maxi;i++)
    {
        a[p]=i;
        go(a,n,p+1);
    }
}

int main()
{
    int n;
    int a[10]={0};

    scanf("%d",&n);
    go(a,n,0);

    return 0;
}

Measured memory_bytes: 1536
import heapq
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

if any(a>b for a,b in zip(A,B)):
    print(-1)
    exit()

def pb(i):
    return i-1 if i-1 >= 0 else N-1
def nx(i):
    return i+1 if i+1 < N else 0

hq = []
for i,(a,b) in enumerate(zip(A,B)):
    if a <= b - B[pb(i)] - B[nx(i)]:
        hq.append(-(b*N+i))
heapq.heapify(hq)

ans = 0
while hq:
    i = (-heapq.heappop(hq)) % N
    if B[i] == A[i]: continue
    l = B[pb(i)]
    r = B[nx(i)]
    if B[i]-l-r < A[i]: continue
    k = (B[i]-A[i]) // (l+r)
    ans += k
    B[i] -= k*(l+r)
    ll = B[pb(pb(i))]
    rr = B[nx(nx(i))]
    if A[nx(i)] <= r - B[i] - rr:
        heapq.heappush(hq, -(r*N + nx(i)))
    if A[pb(i)] <= l - B[i] - ll:
        heapq.heappush(hq, -(l*N + pb(i)))

if all(a==b for a,b in zip(A,B)):
    print(ans)
else:
    print(-1)

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

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

int N;
VI A, B, C;
int main() {
    std::cin >> N;
    A.resize(N), B.resize(N), C.resize(N);
    REP(i, N) std::cin >> A[i];
    REP(i, N) std::cin >> B[i];
    REP(i, N) std::cin >> C[i];

    SORT(A), SORT(B), SORT(C);

    auto _BEGIN_A = A.begin();
    auto _BEGIN_B = B.begin(), _END_B = B.end();
    auto _END_C   = C.end();

    long long sum = 0;

    auto itb = _BEGIN_B;
    while( itb != _END_B ){
        int b = *itb;
        auto next = std::upper_bound(ALL(B), b);
        long nb = (int)(next - itb);

        auto ita = std::lower_bound(ALL(A), b);
        if(ita == _BEGIN_A) {
            itb = next;
            continue;
        }
        long na = (int)(ita-_BEGIN_A);

        auto itc = std::upper_bound(ALL(C), b);
        if(itc == _END_C) {
            itb = next;
            continue;
        }
        long nc = (int)(_END_C - itc);
        
        sum += na * nb * nc;
        itb = next;
    }
    std::cout << sum << std::endl;
}

Measured memory_bytes: 1408
#include <math.h>

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

const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<unsigned long long> a(n);
  vector<ll> rui(n + 1, 0);
  rui[0] = 0;
  rep(i, n) {
    cin >> a[i];
    rui[i + 1] += a[i] + rui[i];
    rui[i + 1] %= MOD;
    // cout << rui[i + 1] << " ";
  }

  unsigned long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (i >= 1) {
      ans += (rui[i] * a[i]) % MOD;
      ans %= MOD;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 6356
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let (n, m): (usize, usize) = (read(), read());
    let mut uft = UFT::new(n);
    for _ in 0..m {
        let a: usize = read();
        let b: usize = read();
        uft.merge(a - 1, b - 1);
    }
    use std::collections::HashSet;
    let mut roots = HashSet::new();
    for i in 0..n {
        let root = uft.root(i);
        roots.insert(root);
    }
    println!("{}", roots.len() - 1)
}

/// Union Find Tree
pub struct UFT {
    pub par: Vec<usize>,
    pub rank: Vec<usize>,
}
impl UFT {
    #[allow(dead_code)]
    pub fn new(n: usize) -> Self {
        UFT {
            par: (0..n).collect(),
            rank: vec![0; n],
        }
    }
    #[allow(dead_code)]
    pub fn root(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            x
        } else {
            let p = self.par[x];
            let pp = self.root(p);
            self.par[x] = pp;
            pp
        }
    }
    #[allow(dead_code)]
    pub fn merge(&mut self, x: usize, y: usize) {
        let x = self.root(x);
        let y = self.root(y);
        if x == y {
            return;
        }
        if self.rank[x] < self.rank[y] {
            self.par[x] = y;
        } else {
            self.par[y] = x;
            if self.rank[x] == self.rank[y] {
                self.rank[x] += 1;
            }
        }
    }
}


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

int main(){
    int N;cin>>N;
    int h[N];
    rep(i,N)cin>>h[i];
    int sum=accumulate(h,h+N,0);
    int count=0;
    while(sum){
        rep(i,N){
            if(i==N-1 and h[i])count++;
            else if(h[i] and h[i+1]==0)count++;
            if(h[i]){
                h[i]--;
                sum--;
            }
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256