akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int collision_detection(double x1, double y1, double x2, double y2, double r1, double r2){
	double d = ((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
	double sr = ((r1+r2)*(r1+r2));
	double dr = ((r1-r2)*(r1-r2));
	if( d > sr ){
		return 0;
	}else if( d < sr && dr < d){
		return 1;
	}else if(dr > d){
		return (r1>r2)? 2 : -2;
	}else{
		return 1;
	}
}

int main(){
	int n, ans;
	double xa, ya, ra, xb, yb, rb;

	cin >> n;
	for(int i=0 ; i<n ; i++){
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		ans = collision_detection( xa, ya, xb, yb, ra, rb);
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int MAX = 10000;
int A[MAX];

int main()
{
	int n;
	string aws = "Yes";
	scanf("%d", &n);
	int l, m;
	set <string> s;
	string str, st;
	for (int i = 0; i < n; i++)
	{
		if( i == 0)
		{
			cin >>  st;
			s.insert(st);
			l = st.size();
		}
		else
		{
			cin >> str;
			s.insert(str);
			m = str.size();
			if (st[l-1] != str[0])
				aws = "No";
			l = m;
			st = str;
		}
	}
	if (s.size() != n)
		aws = "No";
	cout << aws << endl;
  	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
N, M = map(int, input().rstrip().split())
A = list(map(int, input().rstrip().split()))

B = []
C = []
for _ in range(M):
    b, c = map(int, input().rstrip().split())
    B.append(b)
    C.append(c)

Index = sorted(range(M), key=lambda i: C[i], reverse=True)

sum = 0
A.sort()
for index in Index:
    if A and A[0] >= C[index]:
        break
    count = 0
    i = 0
    while True:
        if i >= len(A):
            break
        if A[i] < C[index] and count < B[index]:
            sum += C[index]
            A.pop(i)
            # print(A)
            count += 1
            continue
        if A[i] >= C[index] or count >= B[index]:
            break
        i += 1

if A:
    for a in A:
        sum += a

print(sum)


Measured memory_bytes: 22004
import math

a, b, c = list(map(int, input().split()))

pc = math.pi * c / 180
s = a * b * math.sin(pc) / 2
l = a + b + math.sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * math.cos(pc))
h = s / a * 2
print(s)
print(l)
print(h)



Measured memory_bytes: 5712
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

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

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  LL ans = 0;
  for (int i = k; i < a.size(); i ++) {
    ans += a[i];
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
#define MAX 200000

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

int members[5]; //MARCH

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

void solve(void){
    int n;

    cin >> n;
    rep(n, i){
        char s[11]; cin >> s;
        if (s[0] == 'M') members[0]++;
        if (s[0] == 'A') members[1]++;
        if (s[0] == 'R') members[2]++;
        if (s[0] == 'C') members[3]++;
        if (s[0] == 'H') members[4]++;
    }
    //rep(5, i) cout << members[i];
    ll ans = 0;
    vector<int> w = {0,0,1,1,1};
    do{
        ll temp = 1;
        rep(5, i){
            if (w[i] == 1) temp*= members[i];
        }
        ans += temp;
    }while(next_permutation(w.begin(), w.end()));
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)

let () =
  let s = read_line () in
  range 0 (String.length s) 
  |> List.map (fun i -> (i, s.[i]))
  |> List.filter (fun (i, _) -> i mod 2 = 0)
  |> List.map snd
  |> List.iter (printf "%c");
  printf "\n"


Measured memory_bytes: 14336
object Main {

  // TODO: ....
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val M, V, P = sc.nextLong()
    val A = Array.fill(N)(sc.nextLong()).sorted(Ordering.Long.reverse)

    // 最初のスコアからM人のジャッジがV問のスコアを1ずつあげる
    // その際に問題が大きい順に並べられP問が選ばれる
    // 同スコアの場合は任意に決定されるということは, P+X問実際には選択されうるということ
    // 可能性判定すれば良い
    // 問題によって後から加算されるスコアが変動したりしない
    // まず問題の初期スコアで昇順ソートしておいて
    // c(Ai) := 初期点Aiを持つ問題が問題セットに採用される可能性を持つか？
    // という関数で二分探索すれば良さそう
    // では、そのような判定をどのように行うか？というところである
    // 無難に考えると, 対象の点数が最大まで加算された場合に採用できるか？
    // という制約をさらに加える (= Ai + M, 全員のジャッジがその問題を選んだケース)
    // 自分の点は最大に加算し, それ以外の V - 1問 について小さい順に M点加算させた場合
    // 自分の点がP問内に入るか？という判定である,
    // 実際に全てに加算させる必要はなく
    // 小さい順に並べた時の P min (V - 1) 番目の点数 以上の場合, 採用できる！
    // ↑ 怪しい
    // 既に選択した問題が 最大上昇の M 点加算されるという想定だと,
    // 元々のスコアが Ai より以下のものに対してはどうやっても勝てる（同スコアなら選ばれるので）
    // (N - |Ai以下の数|) >= V の時, Ai以上の数も選んでいく必要がある
    // (V - (N - |Ai以下の数|)) 問だけ, M人のジャッジが選ぶことになる
    // ((Aij + M) < Aij') のような Aij'が存在する場合, そもそも勝てないので, それらの問題は
    // 毎回選択することにする.
    // (実際には (V - (N - |Ai以下の数|)) - (|(Aij + M) < Aij'となるAij'|))問だけ, M人のジャッジが選ぶことになる
    // 各Aij'問題で, どれだけ上げられるか?の許容量は
    // ((Aij + M) - Aij') >= 0の場合, (((Aij + M) - Aij') min M)回だけ選択されても良い
    // もし, この許容量内で収まる場合には問題なく選べる
    // 一回で減らせるのは(((Aij + M) - Aij') min M)までだが,
    // これを ((V - (N - |Ai以下の数|)) * M) 点減らし切れればOK
    // もし減らしきらないうちに ((Aij + M) < Aij') のような Aij'が出てきてしまうと
    // ceil(残りの点 / M)の選択し分だけ勝てないものが出てくるので, それが > P の時NGです
    def solve(N: Int, M: Long, V: Long, P: Long, A: Array[Long]): Int = {
      def check(i: Int): Boolean = {
        if (i + 1 <= P) return true
        if (A(i) + M < A(P.toInt - 1)) return false
        def loop(j: Int, acm: Long): Long =
          if (j < i) loop(j + 1, acm + (((A(i) + M - A(j)) min M) max 0))
          else acm + (N - i - 1) * M
        loop(P.toInt - 1, P * M) >= (M * V)
      }

      def lowerBounds2(): Int = {
        def loop(left: Int, right: Int): Int = {
          if (right - left > 1) {
            val mid = left + (right - left) / 2
            if (check(mid)) loop(mid, right)
            else loop(left, mid)
          } else left
        }
        loop(-1, N)
      }
      lowerBounds2() + 1
    }

    println(solve(N, M, V, P, A))
  }

}


Measured memory_bytes: 57636
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;

P project(P a,P b,P c){
  double k=real((c-a)/(b-a))*abs(b-a);
  return a+(b-a)/abs(b-a)*k;
}

int main(){
  int n;
  double ax,ay,bx,by,cx,cy;
  cin>>ax>>ay>>bx>>by>>n;
  while(n--){
    cin>>cx>>cy;
    P p=project(P(ax,ay),P(bx,by),P(cx,cy));
    printf("%.8f %.8f\n",p.real(),p.imag());
  }
  return 0;
}

Measured memory_bytes: 1272
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        Console.WriteLine(n * PI * 2);
    }
}

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

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define FILE "taming"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const ull ULLINF = numeric_limits<ull>::max();
const double PI = acos(-1.0);

long long x[100010], v[100010], d[100010], f[100010];

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

    #ifdef LOCAL
        assert(freopen("input.txt", "r", stdin));// assert(freopen("output.txt", "w", stdout));
    #else
        //assert(freopen(FILE".in", "r", stdin)); assert(freopen(FILE".out", "w", stdout));
    #endif
    int n;
    long long c;
    cin >> n >> c;
    for(int i = 0; i < n; i++)
        cin >> x[i] >> v[i];
    long long ans = 0;
    long long bal = 0;
    for(int i = n - 1; i >= 0; i--) {
        bal += v[i] + x[i] - (i + 1 == n ? c : x[i + 1]);
        d[i] = bal;
        if(i < n - 1)
            d[i] = max(d[i], d[i + 1]);
        ans = max(bal, ans);
    }
    bal = 0;
    for(int i = 0; i < n; i++) {
        bal += v[i] - x[i] + (i > 0 ? x[i - 1] : 0);
        f[i] = bal;
        if(i > 0)
            f[i] = max(f[i], f[i - 1]);
        ans = max(bal, ans);
        ans = max(bal - x[i] + (i + 1 < n ? d[i + 1] : 0), ans);
    }
    bal = 0;
    for(int i = n - 1; i >= 0; i--) {
        bal += v[i] + x[i] - (i + 1 == n ? c : x[i + 1]);
        ans = max(bal - c + x[i] + (i - 1 >= 0 ? f[i - 1]: 0), ans);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, w; cin>>n>>w;
	int wt[n+1], value[n+1];
	int total_value=0;
	for(int i=0;i<n;i++){
		cin>>wt[i]>>value[i];
		total_value+=value[i];
	}
	int dp[total_value+1];
	dp[0]=0;
	for(int i=1;i<=total_value;i++)
		dp[i]=1e9+9;
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=total_value;j>=value[i-1];j--){
			dp[j] = min(dp[j], dp[j-value[i-1]] + wt[i-1]);
			if(dp[j]<=w)
				ans=max(ans, j);
		}
	} 
	cout << ans << endl;
}

Measured memory_bytes: 4012
//
//AtCoder Beginner Contest 047
//C
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

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

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    string s;
    cin >> s;
    
    int ans = 0;
    char prv = s[0];
    REP(i,s.size()){
        if (prv != s[i]) ans++;
        prv = s[i];
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3752
N = int(input())
A = list(map(int, input().split()))
INF = 10**9

dp0 = [0]
dp1 = [-INF-1]

for i, x in enumerate(A):
  dp0.append( max(dp0[i] + x, dp1[i] - x) )
  dp1.append( max(dp0[i] - x, dp1[i] + x) )

print(dp0[-1])

Measured memory_bytes: 24320
#include <cstdio>
#include <cmath>
#include <algorithm>

long double pi = acosl(-1.0L);

int main() {
  long double a, b, x;
  scanf("%Lf %Lf %Lf", &a, &b, &x);

  long double h = x / a / a;
  long double theta;
  if (x == a*a*b) {
    theta = 0.0;
  } else if (x*2 >= a*a*b) {
    long double y = std::max(0.0L, 2*(b-h));
    // theta = std::acos(a / std::hypot(a, y));
    // theta = std::atan2(y, a);
    theta = std::atan(y / a);
  } else {
    long double y = 2*a*h / b;
    // theta = std::acos(y / std::hypot(b, y));
    // theta = std::atan2(b, y);
    theta = std::atan(b / y);
  }

  theta *= 180.0L / pi;
  printf("%.20Lf\n", theta);
}


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)
#define lmax  3234566667


ll k, kc = 0;

void rec(ll l, ll ke, ll mk)
{
  if(ke == mk) {
    kc ++;
    //    cout << l << endl;
    if(kc == k) {
      cout << l << endl;
      exit(0);
    }
  } else { 
    int s, e;
    s = l % 10 - 1;
    e = l % 10 + 1;
    if(l % 10 == 0) { s = 0 ; e = 1;}
    if(l % 10 == 9) { s = 8 ; e = 9;}
    for(int i = s; i <= e; i++) {
      rec(l*10+i, ke + 1, mk);
    }
  }
}

int main(void)
{
  ll keta = 1;
  ll lc = 0;
  cin >> k;
  while(1) {
    REP1(i, 9) {
      rec(i, 1, keta);
    }
    keta ++;
  }
}


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

using LL = long long;

struct Edge {LL from, to, t;};
struct Tree {
  LL height;
  vector<Edge> edge;
};

int main() {
  int N, M; LL X;
  cin >> N >> M >> X;

  vector<Tree> tree(N);
  for(auto& i: tree) cin >> i.height;

  for(int i = 0; i < M; ++i) {
    int A, B, T;
    cin >> A >> B >> T;
    --A; --B;
    if(T <= tree[A].height) tree[A].edge.push_back({A, B, T});
    if(T <= tree[B].height) tree[B].edge.push_back({B, A, T});
  }

  vector<LL> d(N, -1);
  using Q = tuple<LL, LL, int>;
  priority_queue<Q, vector<Q>, greater<Q>> q;
  q.emplace(0, -X, 0);
  while(!q.empty()) {
    LL t, u; int v;
    tie(t, u, v) = q.top();
    q.pop();
    if(v == N-1) {
      auto c = X + t + t + tree[v].height + u + u;
      if(d[v] == -1) d[v] = c;
      else           d[v] = min(d[v], c);
      continue;
    }
    if(d[v] != -1 && d[v] <= t + u) continue;
    d[v] = t + u;
    for(auto& e: tree[v].edge) q.emplace(t + e.t, max({u, -X, -(t+e.t+tree[e.to].height)}), e.to);
  }

  cout << d[N-1] << endl;
}

Measured memory_bytes: 75040
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{

    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(NK[0] - NK[1] + 1);
        }
    }
}

Measured memory_bytes: 28232
S=input()
count = 0
cnt = 0
if int(S[2])==0 :
    if int(S[3])!=0:
        count+=1
elif int(S[2])==1:
    if int(S[3])<=2:
        count += 1
if int(S[0])==0:
    if int(S[1])!=0:
        cnt += 1
elif int(S[0])==1:
    if int(S[1])<=2:
        cnt += 1
if count == 1 and cnt == 1:
    print("AMBIGUOUS")
elif count==1:
    print("YYMM")
elif cnt==1:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define emp emplace
#define fi first
#define se second
#define INF 0x3f3f3f3f
typedef long long ll;
typedef pair<int, int> ii;

int main(void) {
	ios_base::sync_with_stdio(false);

	string s; cin >> s;

	if (s.size() == 26) {
		if (s == "zyxwvutsrqponmlkjihgfedcba") cout << -1 << endl;
		else {
			set<char> st;

			for (int i = 25; i >= 0; i--) {
				for (char c : st) {
					if (c > s[i]) {
						for (int j = 0; j < i; j++) cout << s[j];
						cout << c << endl;
						return 0;
					}
				}
				st.emp(s[i]);
			}

			assert(0);
		}
		return 0;
	}

	set<char> st;
	for (char c : s) st.emp(c);

	for (char c = 'a'; c <= 'z'; c++) {
		if (!st.count(c)) {
			cout << s << c << endl;
			return 0;
		}
	}


	return 0;
}


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

ans = [0] * 4

for i in range(N):
    s = input()
    if 'AC' == s:
        ans[0] += 1
    elif 'WA' == s:
        ans[1] += 1
    elif 'TLE' == s:
        ans[2] += 1
    elif 'RE' == s:
        ans[3] += 1

print('AC x', ans[0])
print('WA x', ans[1])
print('TLE x', ans[2])
print('RE x', ans[3])


Measured memory_bytes: 9200
#include<iostream>
using namespace std;
int main()
{
    string a;   
	bool v[2]={0}; 
    cin>>a; 
    for(int i=0;i<a.length();i++)
	{ 
        if(a[i]=='C') 
		  v[0]=1; 
        if(a[i]=='F'&&v[0])  
		  v[1]=1; 
    }
    if(v[1]) 
	  cout<<"Yes"; 
    else cout<<"No"; 
    return 0;
}

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

using namespace std;

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

constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n), f(n);
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    for(int i=0;i<n;++i){
        cin >> f[i];
    }
    sort(a.rbegin(), a.rend());
    sort(f.begin(), f.end());

    ll ng = -1, ok = 1e13;
    while(ok-ng > 1) {
        ll mid = (ng+ok) / 2;
        ll cnt = 0;
        for(int i=0;i<n;++i) {
            if(a[i] * f[i] > mid) {
                ll aa = mid / f[i];
                cnt += a[i] - aa;
            }
        }

        if(cnt <= k) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    cout << ok << endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    string s; cin >> s;
    int slen = s.length();
    bool flg = true;
    if(s.at(0) == '0' || s.at(slen-1) == '1') flg = false;
    for(int i = 0; i < slen/2; ++i) {
        if(s.at(i) != s.at(slen-2-i)) {
            flg = false;
            break;
        }
    }

    if(!flg) {
        cout << -1 << endl;
        return 0;
    }

    s.at(slen-1) = '1';
    queue<int> que;
    for(int i = 1; i <= slen; ++i) {
        if(s.at(i-1) == '1') que.push(i);
    }

    for(int i = 1; i < slen; ++i) {
        if(i == que.front()) que.pop();
        cout << i << " " << que.front() << endl;
    }
}

Measured memory_bytes: 1920
#include <iostream>

int main(void)
{
	int H, W;
	while (true)
	{
		std::cin >> H >> W;
		if (H == 0 && W == 0) break;
		for (int i = 0; i < W; i++) {
			std::cout << '#';
		}
		std::cout << std::endl;
		for (int i = 1; i < H - 1; i++) {
			std::cout << '#';
			for (int i = 1; i < W - 1; i++) {
				std::cout << '.';
			}
			std::cout << '#';
			std::cout << std::endl;
		}
		for (int i = 0; i < W; i++) {
			std::cout << '#';
		}
		std::cout << std::endl;
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1152
S = input()

def calc(n):
    P = [(n >> i) % 2 for i in range(len(S)-1)]
    tmp = ""
    for i, s in enumerate(S):
        tmp += s
        if i < len(S)-1 and P[i] == 1:
            tmp += "+"
    return eval(tmp)

ans = 0
for i in range(2 ** (len(S)-1)):
    ans += calc(i)
print(ans)

Measured memory_bytes: 3060
import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;


public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long k = sc.nextLong();
		long sum = 0;
		for(int i = 1; i <= k; i++) {
			for(int j = i; j <= k; j++) {
				for(int n = j; n <= k; n++) {
					//System.out.println("Debug");
					if(i==j&&j==n) {
						sum+=solve(i,j,n);
					}
					else if(i!=j&&j!=n&&n!=i) {
						sum+=solve(i,j,n)*6;
					}
					else{
						sum+=solve(i,j,n)*3;
					}
				}
			}
		}
		System.out.println(sum);
	}
	private static long solve(long i, long j, long n) {
		long tmp;
		long a = i;
		long b = j;
		long gcd;
		while((tmp = b % a) != 0) {
			b=a;
			a=tmp;
		}
		gcd = a;
		long c;
		if(n<gcd) {
			a = n;
			c = gcd;
		}
		else {
			a = gcd;
			c = n;
		}
		while((tmp = c % a) != 0) {
			c=a;
			a=tmp;
		}
		//System.out.println(a);
		return a;
	}
}

Measured memory_bytes: 36248
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define itrep(type, it, t) for(type::iterator it=t.begin(); it!=t.end(); it++)
using namespace std;

#define ll long long

int main(void) {

    ll  K, N;
    cin >> K >> N;

    ll A[N];
    rep(i, N) {
        cin >> A[i];
    }

    ll mx = (K+A[0]) - A[N-1];
    cerr << mx << endl;
    for(int i=1; i<N; i++) {
        mx = max(mx, A[i] - A[i-1]);
        cerr << mx << endl;
    }

    cout << (K - mx);
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it!= v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >> (istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
#define MOD 1000000007

int main(){
  ins(S);
  S.insert(S.begin() + 4 , ' ');
  out(S);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n >= 0) {
			if(n % 4 == 0 || n % 7 == 0) {
				System.out.println("Yes");
				return;
			}
			n -= 11;
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 23892
#include<iostream>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<map>

using namespace std;

const int AC=100005;

long long n,m,lcm,an,am,ren,rem;
char s[AC],t[AC];
map <long long,char> x;

inline long long gcd(long long a,long long b)
{
	if ( b==0 ) return a;
	return gcd(b,a%b);
}

int main()
{
	scanf("%lld%lld",&n,&m);
	scanf("%s",s);
	getchar();
	scanf("%s",t);
	if ( s[0]!=t[0] )
	{
		printf("-1\n");
		return 0;
	}
	if ( n==m )
		for ( int i=0;i<n;i++ )
			if ( s[i]!=t[i] )
			{
				printf("-1\n");
				return 0;
			}
	lcm=n*m/gcd(n,m);
	an=lcm/n;
	am=lcm/m;
	ren=1;
	rem=1;
	for ( long long i=0;i<n;i++ )
	{
		x[ren]=s[i];
		ren+=an;
	}
	for ( long long i=0;i<m;i++ )
	{
		if ( x.count(rem) ){
			if ( x[rem]!=t[i] ){
		   	    printf("-1\n");
		        return 0;
	        }
		}
		rem+=am;
	}
	printf("%lld",lcm);
	return 0;
}

Measured memory_bytes: 6144
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    ans = 0
    mi = 0
    ma = n+1
    m = n*(n+1) >> 1
    for i in range(1,n+2):
        if i >= k:
            ans += ma-mi
            ans %= mod
        mi += i
        ma += n-i
        mi %= mod
        ma %= mod
    print(ans)
    return

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


Measured memory_bytes: 69648
def prime_list(n):
    # n以下の自然数で素数か否かのリストを作成
    ans = [True for _ in range(n+1)]
    ans[0] = False
    ans[1] = False
    for i in range(2,n+1):
        if ans[i]:
            for j in range(2*i,n+1,i):
                ans[j] = False
    return ans

prime = prime_list(10**5)
like = [0 for i in range(10**5+1)]
for i in range(3,10**5+1,2):
    if prime[i] and prime[(i+1)//2]:
        like[i] = 1
for i in range(1,10**5+1):
    like[i] += like[i-1]

q = int(input())
for i in range(q):
    l,r = map(int,input().split())
    print(like[r]-like[l-1])

Measured memory_bytes: 7192
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int n,m;
int a[1100],b[1100];

int main(){
  cin>>n>>m;
  FOR(i,1,n+1){
    cin>>a[i];
  }
  FOR(i,1,m+1){
    cin>>b[i];
  }
  sort(a+1,a+n+1);
  sort(b+1,b+m+1);

  rep(i,n){
    if(a[i]==a[i+1]){
      cout<<0<<endl;
      return 0;
    }
  }
  rep(i,m){
    if(b[i]==b[i+1]){
      cout<<0<<endl;
      return 0;
    }
  }
  reverse(a+1,a+n+1);
  reverse(b+1,b+m+1);

  int x=0,y=0;
  ll ans=1;
  rrep(i,n*m){
    bool p=(a[x+1]==i),q=(b[y+1]==i);
    if(p&&q){
      x++;
      y++;
    }
    if(p&&!q){
      x++;
      ans*=y;
      ans%=M;
    }
    if(!p&&q){
      y++;
      ans*=x;
      ans%=M;
    }
    if(!p&&!q){
      ans*=x*y-(n*m-i);
      ans%=M;
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <bitset>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

const int N = 4010;
const int mod = 998244353;

bitset <N> x, y, G, a[10];
int n;

bitset <N> gcd(bitset <N> A, bitset <N> B)
{
    int i = N - 1, j = N - 1;
    while(1)
    {
        for(; ~i && !A[i]; --i);
        for(; ~j && !B[j]; --j);
        if (i == -1) return B;
        if (j == -1) return A;
        if (i > j) A ^= (B << (i - j));
            else B ^= (A << (j - i));
    }
}

int div(bitset <N> A, bitset <N> B)
{
    int i = N - 1, j = N - 1, ans = 0;
    for(; ~j && ~B[j]; --j);
    for(; i >= j; --i)
    {
        ans = (ans * 2 + (A[i] ? 1 : 0)) % mod;
        if (A[i] != y[i]) y ^= B << (i - j);
    }
    for(int i = N - 1; ~i; --i) if (A[i] < y[i])
    {
        ans = (ans - 1 + mod) % mod;
        break;
    }
    else if (A[i] > y[i]) break;
    return ans;
}

int main()
{
    cin >> n >> x;
    FOR(i, 1, n) cin >> a[i];
    G = a[1];
    FOR(i, 2, n) G = gcd(G, a[i]);
    printf("%d\n", (div(x, G) + 1) % mod);
    return 0;
}
;


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

dish_list = []
for i in range(n):
    ai, bi = list(map(int, input().split()))
    dish_list.append([ai, bi, ai+bi])


dish_list.sort(key = lambda x:x[2], reverse=True)


a, b =0, 0
turn = 1
for i in range(n):
    if turn ==1:
        a+=dish_list[i][0]
    else:
        b+=dish_list[i][1]
    turn*=-1

# print(a, b)
# a, b = 0, 0
# def dfs(dish_list, turn):
#     if dish_list==[]:
#         return
#     # print("=================")
#     # print(dish_list)
#     global a
#     global b
#
#
#     #評価値が最大の皿をみつける
#     max_id = 0
#     max_p = 0
#     for i, dish in enumerate(dish_list):
#         if dish[2] > max_p:
#             max_p = dish[2]
#             max_id = i
#
#     #幸福度を加算
#     # print(max_id, max_p)
#     if turn == -1:
#         a+=dish_list[max_id][0]
#     elif turn == 1:
#         b+=dish_list[max_id][1]
#
#     #評価値最大のさらを削除した新しい皿のリストを作る
#     new_list = [list for i, list in enumerate(dish_list) if i!=max_id]
#     dfs(new_list, turn*(-1))
#
# dfs(dish_list, -1)

# print(a, b, a-b)

print(a-b)

Measured memory_bytes: 24872
#include <stdio.h>
long long mod=1e9+7;
long long vis[100005],a[100005]={1,1,2};
int main()
{
    long long i,x,n,k;
    scanf("%lld%lld",&n,&k);
    for(i=1; i<=k; i++)
    {
        scanf("%lld",&x);
        vis[x]=1;
    }
    if(vis[1]) a[1]=0;
    for(i=2; i<=n; i++)
    {
        if(vis[i]) a[i]=0;
        else a[i]=(a[i-1]%mod+a[i-2]%mod)%mod;
    }
    printf("%lld\n",a[n]);
    return 0;
}



Measured memory_bytes: 1664
#!/usr/bin/env python
#-*- coding: utf-8 -*-

from collections import defaultdict
from math import factorial as f
from fractions import gcd as g

n = int (raw_input ())
k = int (raw_input ())

ret = 1
for i in range (n):
    ret = min (2 * ret, ret + k)
print ret


Measured memory_bytes: 4392
N,M = map(int,input().split())
A = list(map(int,input().split()))

R = [A[0]%M]


for i in range(1,N):
  R.append((R[-1]+A[i])%M)



import collections
c = collections.Counter(R)


ans = 0
for key in c:
  if key == 0:
    ans += (c[key]*(c[key]+1))/2
  else:
    ans += (c[key]*(c[key]-1))/2
  



print(int(ans))


Measured memory_bytes: 63256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

ll zz(ll a, ll b) {
	ll x = a * b;
	if (a < b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return x / b;
}


ll fun(ll n, ll a, ll b) {
	ll ab = zz(a, b);

	return n-( n / a + n / b - n / ab);

}

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;


	cout << fun(b, c,d) - fun(a-1, c, d) << endl;

	return 0;
}



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

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

  ll M = N.length();

  ll dp[2][K+2][M+2];
  for(ll i = 0; i < K+2; i++){
    for(ll j = 0; j < M+2; j++){
      dp[0][i][j] = 0;
      dp[1][i][j] = 0;
    }
  }
  //vector<ll> dp(M+1, 0);
  dp[0][0][1] = 1;
  dp[1][1][1] = 1;
  dp[0][1][1] = N[0] - '1';
  
  for(ll i = 0; i < M; i++){
    ll num = N[i] - '0';
    //dp[0][0][i+1] = 1;
    for(ll j = 0; j <= K; j++){
      if(num != 0)
        dp[1][j+1][i+1] += dp[1][j][i];
      else
        dp[1][j][i+1] += dp[1][j][i];
      if(num > 1){
        dp[0][j+1][i+1] += (num - 1) * dp[1][j][i];
      }
      if(num > 0)
        dp[0][j][i+1] += dp[1][j][i];

      dp[0][j+1][i+1] += 9 * dp[0][j][i];
      
      dp[0][j][i+1] += dp[0][j][i];
    }
  }
  cout << dp[0][K][M] + dp[1][K][M] << endl;
}

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

#define LL long long

int n;
int a[55];
LL ans;

inline LL solve(int l, int r, LL x, LL y)
{
	if(l + 1 >= r) return 0;
	LL ans = 1e18;
	for(int i = l + 1; i <= r - 1; i++)
		ans = min(ans, solve(l, i, x, x + y) + solve(i, r, x + y, y) + 1ll * a[i] * (x + y));
	return ans;
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);

	printf("%lld", solve(1, n, 1, 1) + a[1] + a[n]);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <cassert>
using namespace std;
bool ok(string &x)
{
	for (int i = 0; i < x.length(); ++i)
	{
		if(x[i] != x[0])
			return false;
	}
	return true;
}
int main()
{
	string x;
	cin>>x;
	int ans = 1000000000;
	for (int i = 0; i < 26; ++i)
	{
		int op = 0;
		string y = x;
		while(!ok(y))
		{
			string z = "";
			for (int j = 0; j + 1 < y.length(); ++j)
			{
				if(y[j] - 'a' == i || y[j+1] - 'a' == i)
					z+=(char)(i + 'a');
				else
					z+=y[j];
			}
			y = z;
			op++;
		}
		// cout<<op<<" "<<i<<" "<<y<<"\n";
		ans = min(ans, op);
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "5 10 2" ].solve == 3 );
	assert( [ "6 20 7" ].solve == 2 );
	assert( [ "1 100 1" ].solve == 100 );
}



import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto l = 0L;
	auto r = 0L;
	auto d = 0L;
	input.front.formattedRead!"%s %s %s"( l, r, d );
	
	auto ans = 0L;
	foreach( i; l .. r + 1 )
	{
		ans += ( i % d == 0 );
	}
	return ans;
}


Measured memory_bytes: 2844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println(new Main().password(Integer.parseInt(scanner.nextLine())));
		scanner.close();
	}
	
	public int password(int n) {
		int pass = 1;
		for(int i = 0; i < 3; i++) {
			pass *= n;
		}
		return pass;
	}
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
//    int a[n+1];
    int b;
    int cnt=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&b);
        if(b>=k){
            cnt++;
        }
    }
    cout<<cnt;

}




Measured memory_bytes: 256
#include<iostream>
using namespace ::std;
int main(){
	char a[1001];
	int b;
	b=0;
	cin>>a;
	while(a[b]!='\0'){
		b++;
	}
	if(a[b-1]=='s'){
		cout<<a<<"es"<<endl;
	
	}
	else{
		cout<<a<<"s"<<endl;
	}
}

Measured memory_bytes: 3636
s = input()
t = input()
S = len(s)
T = len(t)

ans = []
for i in range(S - T + 1):
    tmp = list(s)
    cnt = 0
    for j in range(T):
        if s[i + j] == t[j] or s[i + j] == "?":
            cnt += 1
            tmp[i + j] = t[j]
        if cnt == T:
            ans.append("".join(tmp).replace("?", "a"))

if len(ans) > 0:
    print(min(ans))
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  char s[256],t[256];
  scanf("%s",&s);
  scanf("%s",&t); 
  int i=0;
  int c=0;
  while(s[i]!=0) {
    if (s[i]==t[i]) c++;
    i++;
  }
  if (i==c) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<std::string> s(n);
	for(auto& v: s) cin >> v;
	

	std::vector<std::pair<int, int>> pos, neg;
	for(auto t: s) {
		int A = 0, tmp = 0;
		for(auto c: t) {
			tmp += (c == ')');
			tmp -= (c == '(');
			A = std::max(A, tmp);
		}

		reverse(begin(t), end(t));
		int B = 0; tmp = 0;
		for(auto c: t) {
			tmp += (c == '(');
			tmp -= (c == ')');
			B = std::max(B, tmp);
		}

		if(B - A >= 0) {
			pos.push_back({A, B});
		} else {
			neg.push_back({B, A});
		}
	}
	sort(begin(pos), end(pos));
	sort(begin(neg), end(neg), std::greater<>());

	int now = 0;
	bool ans = true;
	for(auto [A, B]: pos) {
		if(now - A < 0) ans = false;
		now += B - A;
	}
	for(auto [B, A]: neg) {
		if(now - A < 0) ans = false;
		now += B - A;
	}
	ans &= (now == 0);

	if(ans) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 42552
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		long a = parseLong(sc.next());
		long b = parseLong(sc.next());
		long c = parseLong(sc.next());
		sc.close();
		long ans = 0;
		if(a%2==1&b%2==1&c%2==1) {
			ans = Math.min(Math.min(a*b, b*c),c*a);
		}
		out.println(ans);
	}
}


Measured memory_bytes: 21588
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
	if (a == 0)
		return 1;
	else
		return (a * FACT(a - 1))%mod;
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
int MODnPr(int n, int r, int mod) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++) {
		sum *= i;
		sum = sum % MOD;
	}
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	return (n + 9) / 10 * 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
int MODPOW(int a, int n, int mod) {
	// a^n mod
	int ans = 1;
	while (n > 0) {
		if (n & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
	int N, K, Q,x;
	cin >> N >> K >> Q;
	vector<int>A(N+1);
	REP(i, Q) {
		cin >> x;
		A[x]++;
	}
	REP(i, N) {
		if (Q - A[i] < K)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

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

set<string> P;
int N, M;

bool exist(string s){
    for ( set<string>::iterator it = P.begin(); it != P.end(); it++ ){
	if ( s.size() <= (*it).size() && s == (*it).substr(0, s.size())) return true;
    }
    return false;
}

bool convert(string str, string &t){
    bool f;
    int p, e;

    if ( str.size() >= 2 && str.substr(str.size()-2, 2) == "/." ){
	str = str.substr(0, str.size()-1);
    }

    for(; (p = str.find("/./")) != string::npos; str.replace(p+1, 2, ""));

    for(; (p = str.find("/..")) != string::npos; ){
	if ( exist(str.substr(0, p+1) ) && p){
	    e = p + 3;
	    p--;
	    while( str[p] != '/') p--;
	    str.replace(p, e-p, "");
	} else return false;
    }
    t = str;
    if ( P.find(t) != P.end()) return true;
    t += (t[t.size()-1]=='/')?"index.html":"/index.html";
    if ( P.find(t) != P.end()) return true;

    return false;
}

main(){
    string path, t1, t2;
    while( cin >> N >> M && (N || M) ){
	P.clear();
	rep(i, N) { cin >> path; P.insert(path); }
	rep(i, M){
	    cin >> t1 >> t2;
	    string c1, c2;
	    if ( convert(t1, c1) && convert(t2, c2) ){
		if ( c1 == c2 ) cout << "yes" << endl;
		else cout << "no" << endl;
	    } else {
		cout << "not found" << endl;
	    }
	}
    }
}

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

int main(){
    ll n;
    cin>>n;
    n--;
    ll ans=n*(n+1)/2;

    cout<<ans<<endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

vector<vector<ll>> G;
vector<ll> visit;
vector<bool> used;
void dfs(ll v) {
    visit.pb(v);
    used[v] = true;
    EACH(to, G[v]) {
        if (!used[to]) {
            dfs(to);
            break;
        }
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    visit.clear();
    ll n, m; cin >> n >> m;
    G.resize(n);
    REP(i, m) {
        ll a, b; cin >> a >> b; --a, --b;
        G[a].pb(b);
        G[b].pb(a);
    }
    vector<ll> ans;
    used.assign(n, false);
    visit.clear(); dfs(0);
    RREP(i, visit.size()) {
        ans.pb(visit[i]+1);
    }
    visit.clear(); dfs(0);
    FOR(i, 1, visit.size()) {
        ans.pb(visit[i]+1);
    }
    cout << ans.size() << endl;
    cout << ans << endl;
}


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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int A=2019;
        string S;
        cin >>S;
        int N=S.size();
        vector<int> SS(N+1, 0);
        Rep1(i, N)
                SS.at(i)=S.at(i-1)-'0';
        vector<int> M(N+1, 0);
        vector<int> AA(N+1, 0);
        int ss=0;
        Rep1(i, N) {
                ss *=10;
                ss +=SS.at(i);
                ss %=A;
                M.at(i)=ss;
                int J=1;
                for (auto j=i-1; j>=0; j--) {
                        J*=10;
                        J%=A;
                        if (ss==((J*M.at(j))%A)) {
                                AA.at(i)=AA.at(j)+1;
                                break;
                        }
                }
        }
        int SSS=0;
        for (auto AAA: AA)
                SSS +=AAA;
        cout <<SSS <<endl;
        return 0;
}


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

int main(){
	int i,n;
	double ave,a,s[1001];
	while (1){
		scanf("%d",&n);
		if (n==0) break;
		ave=0.0;
		for (i=0;i<n;i++){
			scanf("%lf",&s[i]);
			ave+=s[i];
		}
		ave/=n;
		a=0.0;
		for (i=0;i<n;i++){
			a+=pow(s[i]-ave,2);
		}
		printf("%.8f\n",sqrt(a/n));
	}
	return 0;
}




Measured memory_bytes: 2108
a=(`fold -1 | sort -n | uniq -c`)
c=(`yes 0 | head -10`)
l=$((${#a[@]}))
s=0
i=0
while((i<l))
do
    s=$((s+a[i]*a[i+1]))
    i=$((i+2))
done
((s%9==0)) && echo Yes || echo No


Measured memory_bytes: 8560
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N = ns()

ans = [0, 1000000000]
kuri = [0, 0]
five = 0
for n in N[::-1]:
    n = int(n)
    # print(ans)
    ans_old = [ans[0], ans[1]]
    ans[0] = min(ans_old[0] + n, ans_old[1] + n + 1)
    ans[1] = min(ans_old[0] + 10 - n, ans_old[1] + 9 - n)
print(min(ans[0], ans[1] + 1))


Measured memory_bytes: 77940
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  cout<<a[n-1]-a[0];
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int n; cin >> n;
  int sum = 0;
  vector<int> t(n); 
  rep(i, n) {
    cin >> t[i];
    sum += t[i];
  }
  int m; cin >> m;
  vector<int> p(m), x(m); 
  rep(i, m) {
    cin >> p[i] >> x[i];
    p[i]--;
  }
  
  rep(i, m) {
    cout << sum - t[p[i]] + x[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256