akhauriyash/Code-Regression huggingface dataset:
import sys
range = xrange
input = raw_input

MOD = 10**9+7

def modinv(x):
    return pow(x,MOD-2,MOD)

def nck(n,k):
    a = 1
    b = 1
    c = 1
    for i in range(1,n+1):
        a = a*i%MOD
    for i in range(1,k+1):
        b = b*i%MOD
    for i in range(1,n-k+1):
        c = c*i%MOD
    return a*modinv(b*c%MOD)%MOD
        
n,m,k = [int(x) for x in input().split()]

inv = modinv(n*m)
m1inv = modinv(n*m-1)

ans = 0

def summer(x):
    return x*(x-1)//2

p = (k*inv%MOD)*(m1inv*(k-1)%MOD)%MOD

xfac = n*n*p%MOD
for xi in range(m):
    ans += xfac * summer(m-xi)%MOD

yfac = m*m*p%MOD
for yi in range(n):
    ans += yfac * summer(n-yi)%MOD
#for xi in range(m):
#    for yi in range(n):
#        ans += n*p%MOD * summer(m-xi)%MOD
#        ans += m*p%MOD * summer(n-yi)%MOD
        #for xj in range(m-xi):
        #    s = xj
        #    ans += n*s*p%MOD
        
        #for yj in range(n-yi):
        #    s = yj
        #    ans += m*s*p%MOD
        
        #for xj in range(m):
        #    for yj in range(n):
        #        s = abs(xi-xj) + abs(yi - yj)     
        #        ans += p*s%MOD
print nck(n*m,k)*ans%MOD


Measured memory_bytes: 32284
import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}


func main() {
    let hw = readWords { Int($0)! }
    let h = hw[0]
    let w = hw[1]

    let grid = (1...h).map { _ in Array(readLine()!) }

    let makeGrid = { (1...h).map { _ in [Int](repeating: 0, count: w) } }
    var L = makeGrid()
    var R = makeGrid()
    var U = makeGrid()
    var D = makeGrid()

    for i in 0..<h {
        for j in 0..<w {
            if j == 0 { 
                L[i][j] = 1
                R[i][w-j-1] = 1
            } else {
                L[i][j] = L[i][j-1] + 1
                R[i][w-j-1] = R[i][w-j] + 1 
            }

            if i == 0 {
                U[i][j] = 1
                D[h-i-1][j] = 1
            } else {
                U[i][j] = U[i-1][j] + 1
                D[h-i-1][j] = D[h-i][j] + 1
            }

            if grid[i][j] == "#" {
                L[i][j] = 0
                U[i][j] = 0
            }

            if grid[i][w-j-1] == "#" {
                R[i][w-j-1] = 0
            }

            if grid[h-i-1][j] == "#" {
                D[h-i-1][j] = 0
            }
        }
    }

    var ans = 0
    for i in 0..<h {
        for j in 0..<w {
            ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
        }
    }

    print(ans)
}


main()

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

using namespace std;

#define int long long

void solve() {
    int k, x;
    cin >> k >> x;
    if (k * 500 < x) cout << "No";
    else cout << "Yes";
}

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


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split( )))
c=a[0]
for i in range(1,n-1):
	if i%2!=0:
		c=c-a[i]
	else:
		c=c+a[i]
ans=[]
ans.append(abs(c+a[-1]))
x1=abs((c+a[-1])//2)
t=x1
for i in range(n-1):
	t=abs(t-a[i])
	ans.append(2*t)
print(*ans)



Measured memory_bytes: 14028
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <tuple>

using Bool = bool;
using Int = long long int;
template <class T, class U>
using Pair = std::pair<T, U>;
template <class T>
using Vector = std::vector<T>;

template <class Cost = Int>
struct Edge {
    Int src, dst;
    Cost cost;
    Edge(Int src = -1, Int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};
template <class Cost = Int>
using Edges = Vector<Edge<Cost>>;

struct UnionFind {
    Vector<Int> par;

    void init() {
        std::iota(par.begin(), par.end(), 0);
    }

    UnionFind(Int n) : par(n) { init(); }

    Int find(Int v) {
        return v == par[v] ? v : par[v] = find(par[v]);
    }

    void unite(Int u, Int v) {
        u = find(u), v = find(v);
        par[v] = u;
    }

    Bool same(Int u, Int v) { return find(u) == find(v); }
};

int main() {
    Int n, m;
    std::cin >> n >> m;

    Edges<Int> edges(m);
    for (auto& e : edges) {
        std::cin >> e.src >> e.dst >> e.cost;
        --e.src, --e.dst;
    }
    std::sort(edges.begin(), edges.end());

    auto build = [&](Int skip) {
        UnionFind uf(n);
        Vector<Int> mst;
        Int cost = 0;

        for (Int i = 0; i < m; ++i) {
            const auto& e = edges[i];
            if (i == skip || uf.same(e.src, e.dst)) continue;

            uf.unite(e.src, e.dst);
            cost += e.cost;
            mst.push_back(i);
        }

        return std::make_pair(cost, mst);
    };

    Int mincost;
    Vector<Int> minmst;
    std::tie(mincost, minmst) = build(-1);

    Int num = 0, costsum = 0;
    for (auto t : minmst) {
        Int cost;
        Vector<Int> mst;
        std::tie(cost, mst) = build(t);

        if (mst.size() < n - 1 || cost > mincost) {
            ++num;
            costsum += edges[t].cost;
        }
    }

    std::cout << num << ' ' << costsum << std::endl;
    return 0;
}



Measured memory_bytes: 4204
N = int(input())
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
total = sum(aaa)
for i in range(N - 1, -1, -1):
    if aaa[i + 1] > bbb[i]:
        aaa[i + 1] -= bbb[i]
    else:
        bbb[i] -= aaa[i + 1]
        aaa[i + 1] = 0
        aaa[i] = max(0, aaa[i] - bbb[i])
print(total - sum(aaa))


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b ;
    cin >> a >> b;
    cout << a * b << " " << 2 * (a + b) << endl;
    return 0;
}


Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

class _Class
{
	void _Do()
	{
		//
		var _s = _stringArray();
		var N_ = int.Parse(_s[0]);
		var M_ = int.Parse(_s[1]);

		long a = 0;
		long z = 1000000007;

		if (N_ == M_) {
			a = 1;
			for (int i = 1; i <= N_; i++)
			{
				a *= i;
				a = a % z;
			}
			a*= a;
			a = a % z;
			a *= 2;
			a = a % z;
			Console.WriteLine(a);
			return;
		} else if (Math.Abs(N_-M_)==1) {
			a = 1;
			for (int i = 1; i <= N_; i++)
			{
				a *= i;
				a = a%z;
			}
			for (int i = 1; i <= M_; i++)
			{
				a *= i;
				a = a % z;
			}
			Console.WriteLine(a);
			return;
		}

		Console.WriteLine(0);

	}

	static void Main(string[] args)
	{
		new _Class()._Do();
	}


	// 1
	string[] _stringArray()
	{
		return Console.ReadLine().Split();
	}

	// 2.1 -2,147,483,648 ~ +2,147,483,647
	int[] _intArray()
	{
		var _s = Console.ReadLine().Split();

		var x = new int[_s.Length];
		for (var i = 0; i < _s.Length; i++)
			x[i] = int.Parse(_s[i]);

		return x;
	}

	// 2.2 -9,223,372,036,854,775,808 ~ +9,223,372,036,854,775,807
	long[] _longArray()
	{
		var _s = Console.ReadLine().Split();

		var x = new long[_s.Length];
		for (var i = 0; i < _s.Length; i++)
			x[i] = long.Parse(_s[i]);

		return x;
	}
}


Measured memory_bytes: 13140
S = input()
if S != S[::-1]:
    print("No")
elif S[:(len(S)-1)//2] != S[:(len(S)-1)//2][::-1]:
    print("No")
elif S[(len(S)+3)//2-1:] != S[(len(S)+3)//2-1:][::-1]:
    print("No")
else:
    print("Yes")

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N+2);
  for(int i=1;i<=N;i++){
    cin >> A.at(i);
  }
  A.front()=0;
  A.back()=0;
  int64_t sum=0;
  for(int i=1;i<N+2;i++){
    sum+=abs(A.at(i)-A.at(i-1));
  }
  vector<int64_t> ans(N,sum);
  for(int i=1;i<=N;i++){
    ans.at(i-1)-=abs(A.at(i)-A.at(i-1));
    ans.at(i-1)-=abs(A.at(i+1)-A.at(i));
    ans.at(i-1)+=abs(A.at(i+1)-A.at(i-1));
    cout << ans.at(i-1) << endl;
  }
  return 0;
}


Measured memory_bytes: 2432
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);




        while (true) {
            int x = sc.nextInt();
            int y = sc.nextInt();

            if (x == 0 && y == 0) break;
            if (y < x) {
                int tmp = x;
                x = y;
                y = tmp;
            }

            System.out.println(x + " " + y);
        }


    }

}


Measured memory_bytes: 34488
#include<stdio.h>
#include<string.h>
#define max(a,b) (a>b?a:b)
int main()
{
    long long int a,b,c,d,maxi=0;
    scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    maxi=max(a*c,b*d);
    maxi=max(maxi,a*d);
    maxi=max(maxi,b*c);
    printf("%lld\n",maxi);
    return 0;
}


Measured memory_bytes: 1736
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int ans = 0;
    FOR(i, a, b+1){
        string s = to_string(i);
        int l = s.length();
        bool isOK = true;
        REP(i, l/2){
            if(s[i] != s[l-1-i]){
                isOK = false;
            }
        }
        if(isOK){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math
N,M=map(int,input().split())

def nCr(n,r):
	return math.factorial(n)//((math.factorial(n-r)) * math.factorial(r))

if N >= 2:
	A=nCr(N,2)
else:
	A=0
if M >= 2:
	B=nCr(M,2)
else:
	B=0
print(A+B)

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

long gcd(long a, long b){
  if(a < b){
    int temp = a;
    a = b;
    b = temp;
  }
  if(a%b==0)return b;
  return  gcd(a-b, b);
}
int main(){
  long A, B;
  cin >> A >> B;
  long ans = gcd(A, B);
  cout << A*B/ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  ll x;
  int y;
};
bool operator<(const ST& a, const ST& b){
  if(a.x == b.x) return a.y > b.y;
  return a.x > b.x;
}

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

  vector<ST> v;
  rep(i,N){
    ll x, y;
    cin >> x >> y;
    v.push_back((ST){x,0});
    v.push_back((ST){y,1});
  }

  sort(ALLOF(v));

  ll ret = 0;
  rep(i,v.size()){
    if(v[i].y == 1){
      ret++;
      H -= v[i].x;
      if(H<=0) break;
    }else{
      ret += (H + v[i].x - 1) / v[i].x;
      break;
    }
  }

  cout << ret << endl;
  
  return 0;
}




Measured memory_bytes: 6256
import sys
input = sys.stdin.readline

n,m = map(int,input().split())

ps = [ list(input().split()) for _ in range(m) ]

ac_count_list = [0]*n
wa_count_list = [0]*n
wa_count = 0

for i in range(m):
    q = int(ps[i][0])
    if ps[i][1] == "AC":
        if ac_count_list[q-1] == 0:
            ac_count_list[q-1] = 1
            wa_count += wa_count_list[q-1]
        else:
            pass
    else:
        if ac_count_list[q-1]==0:
            wa_count_list[q-1] += 1

print(sum(ac_count_list),wa_count)

Measured memory_bytes: 27420
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll N,M,V,K;
vl a;

bool f(int I){
	if(N-I-K<1) return 1;
	vl b;
	for(int i=1;i<=N-I-K;i++) b.push_back(a[I+i]);
	ll x=a[I]+M,t=max(0LL,V-I-K);
	ll n=b.size(),sum=0;
	for(int i=0;i<n;i++) if(x<b[i]) return 0;
	for(int i=0;i<n;i++) sum+=min(M,x-b[i]);
	return sum/M>=t;
}

int main(){
	cin>>N>>M>>V>>K;
	a=vl(N);
	for(auto &i:a) cin>>i;
	sort(a.begin(),a.end());
	int l=-1,r=N-1;
	while(r-l>1){
		int m=(l+r)/2;
		if(f(m)) r=m;
		else l=m;
	}
	cout<<N-r<<endl;
}

Measured memory_bytes: 2880
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] count = new int[N];
    int ans =0;
    for (int i=1; i<=N; i++) {
      count[i-1] =0;
      for (int j=1; j<=i; j++) {
        if (i % 2 == 1) {
          if (i % j == 0) count[i-1]++;
        }
      }
    }
    for (int i=1; i<=N; i++) {
      if (count[i-1] == 8) ans++;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22868
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <math.h>
#include <iomanip>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX 200000
#define LARGENUM 1000000007
#define INF 9223372036854775807
#define ull unsigned long long 
typedef pair <int, int> P;

int main(){
    int N, ans = 0;
    cin >> N;
    int L[N];
    rep(i, N){
        cin >> L[i];
    }
    for (int i = 0; i < N - 2; i++){
        for (int j = i + 1; j < N - 1; j ++){
            for (int k = j + 1; k < N; k++){
                if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i]){
                    if (L[i] > L[j] && L[i] > L[k]){
                        if (L[i] < L[j] + L[k]) ans ++;
                    }
                    else if (L[j] > L[i] && L[j] > L[k]){
                        if (L[j] < L[i] + L[k]) ans ++;
                    }
                    else {
                        if (L[k] < L[i] + L[j]) ans ++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3188
#import numpy as np
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm


N = int(input())
#H1,M1,H2,M2,K= map(int,input().split())
#A = list(map(int,input().split()))
#B = list(map(int,input().split()))
#S= str(input())
l=[]
for i in range(N):
    B = int(input())
    l.append(B)

now=0
next=1
c=0
while c<10**6:
    now=next
    if now==2:
        print(c)
        exit()
    next=l[now-1]
    c+=1

print(-1)


Measured memory_bytes: 7084
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n, k;
    cin >> n >> k;
    cout << (n % k == 0 ? 0 : 1) << endl;
    return 0;
}


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

typedef long long LL;
typedef pair<int, int> pii;

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

template<typename T> bool chkmin(T&a, T b) { return a > b ? a = b, 1 : 0; }
template<typename T> bool chkmax(T&a, T b) { return a < b ? a = b, 1 : 0; }

const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;

int n;
pii p[maxn];
int d[maxn];
int L[maxn], R[maxn];

int idx(int v) { return lower_bound(d, d + n, v) - d + 1; }
bool cmp(const int &a, const int &b) { 
    return L[a] < L[b] || (L[a] == L[b] && R[a] < R[b]); 
}

int main() {
#ifndef ONLINE_JUDGE
	//freopen("infection.in", "r", stdin);
	//freopen("infection.out", "w", stdout);
#endif

	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
        scanf("%d%d", &p[i].fst, &p[i].snd), d[i] = p[i].snd;
    }

    sort(d, d + n);
    sort(p, p + n);

    memset(L, 0x3f, sizeof L);
    for(int i = 0; i < n; i++) { if(i) R[i] = R[i-1]; chkmax(R[i], idx(p[i].snd)); }
    for(int i=n-1; i >=0; i--) { if(n-1-i) L[i] = L[i+1]; chkmin(L[i], idx(p[i].snd)); }

    static int id[maxn];
    static LL sum[maxn], dp[maxn];
    
    for(int i = 0; i < n; i++) { id[i] = i; }
    sort(id, id + n, cmp);

    int j = 1;
    sum[0] = 1;

    for(int i = 0; i < n; i++) {
        int u = id[i];
        while(j <= R[u]) { sum[j] = (sum[j-1] + dp[j]) % mod; j++; }

        (dp[R[u]]  += sum[R[u]] - (L[u] > 1 ? sum[L[u]-2] : 0)) %= mod;
        (sum[R[u]] += sum[R[u]] - (L[u] > 1 ? sum[L[u]-2] : 0)) %= mod;
    }
    printf("%lld\n", (dp[n] + mod) % mod);
	return 0;
}

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

int main() {
	int i=0,j=0,y=0,x=1,m1=0,m2=0,m3=0;
string a,b,c;
cin>>a>>b>>c;
bool t=0;
while(t==0){
if(x==1){
	if(m1==a.size()){
	cout<<"A"<<endl;
	t=1;
	return 0;
}
if(a[i]=='b')
x=2;
else if(a[i]=='c')
x=3;
else
x=1	;
m1++;
i++;

}
if(x==2){
	if(m2==b.size()){
	cout<<"B"<<endl;
	t=1;
	return 0;
}
if(b[j]=='a')
x=1;
else if(b[j]=='c')
x=3;
else
x=2;
m2++;
j++;


}
if(x==3){
	if(m3==c.size()){
	cout<<"C"<<endl;
	t=1;
	return 0;
}
if(c[y]=='a')
x=1;
else if(c[y]=='b')
x=2;
else
x=3;
m3++;
y++;

}}return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long  N,a;cin >> N;
    std::vector<long> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    string ans;ans = "YES";
    std::sort(A.begin(),A.end());
    for(int i=0;i<N;i++){
        if(A[i] == A[i-1]){
            ans = "NO";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
    cin >> N;
   int K = N % 100 % 10;  
  if(K == 2 || K == 4 || K == 5 || K == 7 || K == 9 ){
    cout << "hon"<< endl; 
  }
  else if(K == 0 || K == 1 || K == 6 || K == 8){   
    cout << "pon" << endl;
  }
  else {
      cout << "bon" << endl;
  }
     
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define maxn 102000

using namespace std;
typedef long long ll;

bool f[maxn],g[maxn];
int a[maxn],n,d[maxn],ans,mx;
vector <int> h[maxn];

int main()
{
    scanf("%d",&n);
    memset(d,0,sizeof(d));
    for (int i=1;i<n;i++)
    {
        int u,v;scanf("%d%d",&u,&v);
        d[u]++; d[v]++;
        h[u].push_back(v);
        h[v].push_back(u);
    }
    mx=d[0];
    for (int i=1;i<n;i++) mx=max(mx,d[i]);
    if (mx<3) {printf("1\n"); return 0;}
    memset(f,true,sizeof(f));
    memset(g,false,sizeof(g));
    for (int i=0;i<n;i++)
    {
        if (d[i]==1)
        {
            ans++; f[i]=false;
            int t=h[i][0];
            while (d[t]==2)
            {
                f[t]=false;
                if (f[h[t][0]]) t=h[t][0]; else t=h[t][1];
            }
            g[t]=true;
        }
    }
    for (int i=0;i<n;i++) if (g[i]) ans--;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 6912
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>

using namespace std;
#define endl '\n'
#define pb push_back
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1e9 + 7)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) > "Yes" : "No" ) << endl


typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

void solve() {

	int n, x, m;
	cin >> n >> x >> m;
	int ans = fabs(m - x);

	REP(i, n) {
		cin >> m;
		ans = gcd(ans, fabs(m - x));
	}

	out(ans);

	return;
}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

Measured memory_bytes: 256
#include <iostream>

int N; //整数の長さN
int A[100]; //N個の数列A
int v;
int i,j,k;

int main() {
  std::cin >> N;
  for(i=0;i<N;i++) {
    std::cin >> A[i];
  }
  for(i=0;i<N;i++) {
    if(i==N-1) {
      std::cout << A[i];
    }
    else std::cout << A[i] << ' ';
  }
  std::cout << std::endl;
  for(i=1;i<N;i++) {
    v = A[i];
    j= i-1;
    while(j>=0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for(k=0;k<N;k++) {
      if(k==N-1) {
      std::cout << A[k];
      }
      else std::cout << A[k] << ' ';
    }
    std::cout << std::endl;
  }
  return(0);
}


Measured memory_bytes: 3092
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int dp[15][200100];
int p[15],c[15];
int main()
{
	int n,m,inf=200100;cin>>n>>m;m/=100;
	rep(i,n){
		cin>>p[i]>>c[i];c[i]/=100;
	}
	rep(i,15) rep(j,inf) dp[i][j]=inf;dp[0][0]=0;
	rep(i,n) rep(j,inf){
		if(dp[i][j]>=inf) continue;
		rep(k,p[i]){
			if(j+k*(i+1)<inf) dp[i+1][j+k*(i+1)]=min(dp[i+1][j+k*(i+1)],dp[i][j]+k);
		}
		if(j+p[i]*(i+1)+c[i]<inf) dp[i+1][j+p[i]*(i+1)+c[i]]=min(dp[i+1][j+p[i]*(i+1)+c[i]],dp[i][j]+p[i]);
	}
	int out=inf;
	REP(i,m,inf){
		out=min(out,dp[n][i]);
	}
	cout<<out<<endl;
}


Measured memory_bytes: 12032
import sys
from collections import deque
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    repn = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        repn[a - 1].append(b - 1)
        repn[b - 1].append(a - 1)

    """
    改良コードも試す。
    どっちが先にマスに色を塗るかは、要は両者のスタート地点からの距離を比べれば良い。
    前にもこの手の議論見た気がする。。。
    """

    # FennecとSnukeからのdepthを求める
    depth_from_Fennec = [-1] * N
    depth_from_Snuke = [-1] * N
    depth_from_Fennec[0] = 0
    depth_from_Snuke[N - 1] = 0

    q = deque([0])
    while q:
        u = q.popleft()
        for v in repn[u]:
            if depth_from_Fennec[v] != -1: continue
            depth_from_Fennec[v] = depth_from_Fennec[u] + 1
            q.append(v)
    q.append(N - 1)
    while q:
        u = q.popleft()
        for v in repn[u]:
            if depth_from_Snuke[v] != -1: continue
            depth_from_Snuke[v] = depth_from_Snuke[u] + 1
            q.append(v)

    Fennec = Snuke = 0
    for f, s in zip(depth_from_Fennec, depth_from_Snuke):
        if f <= s:
            Fennec += 1
        else:
            Snuke += 1
    if Fennec > Snuke:
        print("Fennec")
    else:
        print("Snuke")


if __name__ == "__main__":
    main()


Measured memory_bytes: 89520
#include<stdio.h>
#include<stdlib.h>

int main(){
  int a=0,b=0;
  
  char S[4];
  
  scanf("%s",S);

  int x = atoi(S);
  

  
  a = x/100;
  b = x%100;
  

  

  if(a <= 12 && a >= 1){
    if(b <= 12 && b >= 1){
      printf("AMBIGUOUS");
    }
    else {
      printf("MMYY");
    }
  }
  else {
    if(b <= 12 && b >= 1){
      printf("YYMM");
    }
    else{
      printf("NA"); 
    }
  }
    


  
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, K; cin >> N >> K;
    int ans = N - K + 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] abc = new int[3];
        int sum = 0;
        for(int i = 0;i < 3;i++){
            abc[i] = sc.nextInt();
            sum += abc[i];
        }
        Arrays.sort(abc);
        

        if((sum%2 == 0 && (abc[0]==abc[1]&&abc[1]==abc[2])) || abc[2] ==abc[1]+abc[0]){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
/*  `-._:  .:'   `:::  .:\           |\__/|           /::  .:'   `:::  .:.-'
        \      :          \          |:   |          /         :       /    
         \     ::    .     `-_______/ ::   \_______-'   .      ::   . /      
          |  :   :: ::'  :   :: ::'  :   :: ::'      :: ::'  :   :: :|       
          |     ;::         ;::         ;::         ;::         ;::  |       
          |  .:'   `:::  .:'   `:::  .:'   `:::  .:'   `:::  .:'   `:|       
          /     :           :           :           :           :    \       
         /______::_____     ::    .     ::    .     ::   _____._::____\      
                       `----._:: ::'  :   :: ::'  _.----'                    
                              `--.       ;::  .--'                           
                                  `-. .:'  .-'                               
                                     \    /                        
                                      \  /                                   
                                       \/  */

//ヾ(⌐■_■)ノ♪ ◢◤
#include <bits/stdc++.h>
#define int long long int
using namespace std;

main()
{
    int h,w;
    cin>>h>>w;
    char a[h][w];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
            cin>>a[i][j];
    }
    int dp[h+1][w+1];
    dp[h-1][w-1]=1;
    for(int i=h;i>=0;i--)
    {
        for(int j=w;j>=0;j--)
        {
            if(i==h||j==w)
                dp[i][j]=0;
            else if(i==h-1&&j==w-1)
                dp[i][j]=1;
            else if(a[i][j]=='#')
                dp[i][j]=0;
            else
                dp[i][j]=dp[i+1][j]+dp[i][j+1];
            dp[i][j]=dp[i][j]%1000000007;
        }
    }
    cout<<dp[0][0];
}

Measured memory_bytes: 9088
def prime_factorization(N):
	'''
	return: [[2,3], [3,5]] (2^3 * 3^5)
	        [] if N==1
	O(sqrt{N}) (maybe)
	'''
	ans = []
	cnt=0
	while N%2==0:
		cnt+=1
		N//=2
	if cnt!=0:
		ans.append([2,cnt])
	
	f = 3
	while f*f<=N:
		cnt=0
		while N%f==0:
			N//=f
			cnt+=1
		if cnt!=0:
			ans.append([f,cnt])
		f+=2
	if N!=1:
		ans.append([N,1])
	return ans


N = int(input())
ans = 0
for i in range(1,N+1,2):
	T = prime_factorization(i)
	s = 1
	for t in T:
		s *= t[1]+1
	if s==8:
		ans += 1
print(ans)


Measured memory_bytes: 3064
N = int(input())
hs = list(map(int,input().split()))

if N == 2:
    print(abs(hs[1] - hs[0]))
    exit()
if N == 3:
    print(abs(hs[1] - hs[0]))
    exit()

dp = [0] * N

dp[0] = 0
dp[1] = abs(hs[1] - hs[0])
dp[2] = abs(hs[2] - hs[0])
for i in range(3,N):
    dp[i] = min(dp[i-2]+abs(hs[i]-hs[i-2]), dp[i-1]+abs(hs[i]-hs[i-1]))

print(dp[-1])

Measured memory_bytes: 13928
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		
		String c;
		String msg;
		
		Scanner scan = new Scanner(System.in);
		c = scan.next();
		
		scan.close();
		
		if( "a".equals(c) || "i".equals(c) || "u".equals(c) || "e".equals(c) || "o".equals(c) ){
			msg = "vowel";
		}else{
			msg = "consonant";
		}
		
		System.out.println(msg);
	}
}

Measured memory_bytes: 10192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  string T;
  cin >>T;
  rep(i,T.size()){
    if(T[i] != T[T.size()-1-i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

std::string str_join(const std::string& s1,
                     const std::string& s2){
  std::string r{s1};
  auto n = s1.size();
  for(auto i=0ul; i < n; ++i){
    if(s2[i] == '?'){ continue; }
    
    if(r[i] == '?'){
      r[i] = s2[i]; 
      continue;
    }
    
    if(s1[i] != s2[i]){
      return std::string{};
    }
  }
  return r;
}


auto slide_join(const std::string& s1,
                const std::string& s2,
                const std::string& s3,std::size_t min){
  auto s1_s = s1.size();
  auto s2_s = s2.size();
  auto s3_s = s3.size();
  for(auto i=0; i < s2_s; ++i){
    if(i+s1_s > min){ break; }    
    auto n = std::min(s1_s,s2_s-i);
    auto t = str_join(s1.substr(0,n),s2.substr(i,n));
    if(t.empty()){ continue; }

    std::string r {};
    if(i){  r += s2.substr(0,i); }
    r += t;
    
    if(n < s1_s){
      r += s1.substr(n);
    }else if(i+n < s2_s){
      r += s2.substr(i+n);
    }
    
    auto r_s = r.size();
    
    for(auto j=i; j < r_s; ++j){
      if(j+s3_s > min){ break; }
      
      auto nn = std::min(s3_s,r_s-j);
      auto tt = str_join(s3.substr(0,nn),r.substr(j,nn));
      if(tt.empty()){ continue; }

      std::string rr{};
      if(j){ rr += r.substr(0,j); }
      rr += tt;
      
      if(nn < s3_s){
        rr += s3.substr(nn);
      }else if(j+nn < r_s){
        rr += r.substr(j+nn);
      }
      
      if(rr.size() < min){
        min = rr.size();
        break;
      }
    } // for j
    
  } // for i
  
  return min;
}

int main(){
  std::string a,b,c;
  std::cin >> a >> b >> c;

  auto min = a.size() + b.size() + c.size();
  
  min = slide_join(a,b,c,min);
  min = slide_join(b,a,c,min);
    
  min = slide_join(b,c,a,min);
  min = slide_join(c,b,a,min);

  min = slide_join(c,a,b,min);
  min = slide_join(a,c,b,min);
  
  std::cout << min << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
N,X = map(int,input().split())

P = [1]
H = [1]
for i in range(1,51):
    P.append(P[i-1]*2+1)
    H.append(H[i-1]*2+3)

def r(n,x):
    if x<=n:
        return 0
    if x==H[n]:
        return P[n]
    if x>=H[n-1]+2:
        return P[n-1]+1+r(n-1,x-H[n-1]-2)
    else:
        return r(n-1,x-1)

print(r(N,X))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

vector<i64> p,c;

int D;
int main(){
  cin >> D;
  i64 G;
  cin >> G;
  p.resize(D + 1);
  c.resize(D + 1);
  rep(i,1,D){
    cin >> p[i];
    cin >> c[i];
  }
  vector<int> idx;
  rep(i,1,D){
    idx.push_back(i);
  }
  i64 ans = 1e18;
  do{
    i64 s = 0;
    i64 cnt = 0;
    for(int i : idx){
      i64 k = (G - s) / i / 100 + min(1LL,(G - s) % (i * 100));
      k = min(k,p[i]);
      cnt += k;
      s += k * i * 100;
      s += c[i];
      if(s >= G) break;
    }
    ans = min(ans , cnt);
  }while(next_permutation(all(idx)));
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool solve() {
    char N[5];
    cin >> N;
    if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])) return true;
    return false;
}
int main() {
    cout << (solve() ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;

void dfs(ll curr, vector<ll> v[], vector<ll> &ts, bool vis[])
{
    vis[curr] = 1;
    for(auto it = v[curr].begin();it!=v[curr].end();it++)
    {
        if(!vis[*it])
                dfs(*it,v,ts,vis);        
    }
    
    ts.pb(curr);
}

void ts(vector<ll> v[], ll n, vector<ll> &ts)
{
    bool vis[n];
    memset(vis,0,sizeof(vis));
    
    for(ll i=0;i<n;i++)
    {
        if(!vis[i])
            dfs(i,v,ts,vis);
    }
    
    reverse(ts.begin(), ts.end());
    return;
}

int main()
{
   FAST/**/
   
   string s;
   cin>>s;
   
   ll n = s.length() + 1;
   vector<ll> v[n], g[n];
   for(ll i=0;i<n-1;i++)
   {
       if(s[i] == '>')
           v[i].pb(i+1), g[i+1].pb(i);
       else v[i+1].pb(i), g[i].pb(i+1);
   }
   
   set<pair<ll,ll>> st;
   for(ll i=0;i<n;i++)
        st.insert(mp(v[i].size(), i));
    
   ll vali[n];
   memset(vali,-1,sizeof(vali));
   for(ll i=0;i<n;i++)
   {
       if(v[i].size() == 0)
            vali[i] = 0;
   }
   
   bool vis[n];
   memset(vis,0,sizeof(vis));
   ll deg[n];
   for(ll i=0;i<n;i++)
        deg[i] = v[i].size();
    
   while(st.size()>0)
   {
       auto curr = *st.begin();
       st.erase(st.begin());
       vis[curr.second] = 1;
       for(auto it = g[curr.second].begin();it!=g[curr.second].end();it++)
       {
           if(vis[*it])
                continue;
           st.erase(mp(deg[*it],*it));
           deg[*it]--;
           st.insert(mp(deg[*it],*it));
           vali[*it] = max(vali[*it], vali[curr.second] + 1);
       }
   }
   
   ll ans = 0;
   for(ll i=0;i<n;i++)
        ans+=vali[i];
   
   cout<<ans;
   
   return 0;
}  
   

Measured memory_bytes: 95004
#include <iostream>
#include <vector>
#include <cstdint>

uint64_t GCD(uint64_t A, uint64_t B) {
  return A % B == 0 ? B : GCD(B, A % B);
}

std::vector<std::pair<uint64_t, uint64_t>> prime_factorize(uint64_t N) {
  std::vector<std::pair<uint64_t, uint64_t>> res(1, std::make_pair(1, 1));
  for (uint64_t i=2; i*i<=N; ++i) {
    if (N % i != 0) continue;
    int n = 0;
    while (N % i == 0) {++n; N /= i;}
    res.emplace_back(i, n);
  }
  if (N != 1) res.emplace_back(N, 1);
  return res;
}

int main() {
  uint64_t A, B;
  std::cin >> A >> B;
  
  auto pf = prime_factorize(GCD(A, B));
  std::cout << pf.size() << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
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; }
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<ll> T(N);
  vector<ll> A(N);
  vector<ll> t(N);
  vector<ll> a(N);
  

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

  t[0] = T[0];
  a[0] = A[0];
  
  for(ll i = 1;i<N;i++){
    ll k = max((t[i-1]+T[i]-1)/T[i],(a[i-1]+A[i]-1)/A[i]);
    t[i] = k*T[i];
    a[i] = k*A[i];

  }

    
  cout << t[N-1] + a[N-1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#define N 10
int main(int argc, const char * argv[])
{
    int x=0;
    int max1=-1;
    int max2=-2;
    int max3=-3;
    
    for(int j=0; j<N; j++){
        scanf("%d\n",&x);
        if(max1<=x){
            max3=max2;
            max2=max1;
            max1=x;
        }else if(max2<=x){
            max3=max2;
            max2=x;
        }else if(max3<=x){
            max3=x;
        }
    }
    printf("%d\n",max1);
    printf("%d\n",max2);
    printf("%d\n",max3);
}

Measured memory_bytes: 1196
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define endl '\n'
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int N = 0;

int gcd(int a,int b)
{
	if(!b) return a;
	return gcd(b,a%b);
}

int lcm(int a,int b)
{
	return a*b/gcd(a,b);
}

int main()
{
	ios::sync_with_stdio(0);
	int n,k,sum=0;
	cin>>n>>k;
	while(n--)
	{
		int a;
		cin>>a;
		if(a>=k)
		sum++;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();
        final int Q = sc.nextInt();
        final String S = sc.next();

        int[] a = new int[N+1];
        for (int i = 0; i  < N; i++) {
            if (i+1 < N && S.charAt(i) == 'A' && S.charAt(i+1) == 'C') {
                a[i+1] = a[i] + 1;
            } else {
                a[i+1] = a[i];
            }
        }

        for (int i = 0; i < Q; i++) {
            int l = Integer.valueOf(sc.next());
            int r = Integer.valueOf(sc.next());
            System.out.println(a[--r] - a[--l]);
        }
    }
}


Measured memory_bytes: 54664
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_A=10,MAX_B=10,INF=1e5;
int A,B,d[MAX_A][MAX_B];

int f[101][101];

int main(){
	cin>>A>>B;
	REP(i,A)REP(j,B){
		cin>>d[i][j];
	}
	REP(a,101){
		REP(b,101){
			REP(x,A){
				REP(y,B){
					f[a][b]=max(f[a][b],d[x][y]-(x+1)*a-(y+1)*b);
				}
			}
		}
	}
	bool ans=true;
	REP(x,A){
		REP(y,B){
			int td=INF;
			REP(a,101){
				REP(b,101){
					td=min(td,(x+1)*a+(y+1)*b+f[a][b]);
				}
			}
			if (td!=d[x][y]){
				ans=false;
			}
		}
	}
	if (ans){
		cout<<"Possible"<<endl<<101*2<<" "<<101*101+200<<endl;
		REP(i,100){
			cout<<i+1<<" "<<i+2<<" X"<<endl;
		}
		REP(i,100){
			cout<<i+102<<" "<<i+103<<" Y"<<endl;
		}
		REP(a,101){
			REP(b,101){
				cout<<a+1<<" "<<202-b<<" "<<f[a][b]<<endl;
			}
		}
		cout<<"1 202"<<endl;
	}else{
		cout<<"Impossible"<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int main() {
    ll T;
    cin>>N>>T;
    vec a(N), b(N), ord(N);
    rep(i,N) {
        cin>>a[i]>>b[i];
        ord[i] = i;
    }
    sort(ALL(ord), [&](int i, int j){
        if((b[i] + 1) * a[j] == (b[j] + 1) * a[i]) return b[i] > b[j];
        return (b[i] + 1) * a[j] < (b[j] + 1) * a[i];
    });
    mat dp(N, vec(35, INF));
    dp[0][0] = 0;
    dp[0][1] = a[ord[0]] + b[ord[0]] + 1;
    int until = N;
    if(a[ord[0]] == 0){
        until = 0;
    }else {
        reps(i, 1, N) {
            int id = ord[i];
            if (a[id] == 0) {

                //tyuui!!

                until = i;
                break;
            }
            rep(j, 35) {
                dp[i][j] = dp[i - 1][j];
                if (j != 0) dp[i][j] = min(dp[i][j], min(INF, (dp[i - 1][j - 1] + 1) * (a[id] + 1) + b[id]));
            }
        }
    }
    ll ans = 0;
    if(until < N){
        vec plus(N - until);
        Rreps(i,N,until){
            plus[N - 1 - i] = b[ord[i]] + 1;
            if(i != N - 1) plus[N - 1 - i] += plus[N - 2 - i];
        }
        if(until != 0) {
            rep(j, 35) {
                if (dp[until - 1][j] > T) continue;
                ll temp = 0;
                rep(k, N - until) {
                    if (dp[until - 1][j] + plus[k] <= T) temp = k + 1;
                }
                ans = max(ans, j + temp);
            }
        }else{
            rep(i,N) if(plus[i] <= T) ans = i + 1;
        }
    }else{
        rep(j,35) if(dp[N - 1][j] <= T) ans = j;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 67456
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int N, a[100010];
string S;


signed main(){
    cin >> N >> S;
    REP(st, 4){
        if(st & 1){
            a[0] = 1;
            if(st & 2) a[N - 1] = 1;
            else a[N - 1] = 0;
        }else{
            a[0] = 0;
            if(st & 2) a[N - 1] = 1;
            else a[N - 1] = 0;
        }
        REP(i, N){
            if(a[i] == 0){
                if(S[i] == 'o') a[(i + 1 + N) % N] = a[(i - 1 + N) % N]; 
                else a[(i + 1 + N) % N] = 1 - a[(i - 1 + N) % N];
            }else{
                if(S[i] == 'o') a[(i + 1 + N) % N] = 1 - a[(i - 1 + N) % N]; 
                else a[(i + 1 + N) % N] = a[(i - 1 + N) % N];
            }
        }
        if(st & 1){
            if(a[0] == 0) continue;
            if(st & 2){
                if(a[N - 1] == 0) continue;
            }else{
                if(a[N - 1] == 1) continue;
            }
        }else{
            if(a[0] == 1) continue; 
            if(st & 2){
                if(a[N - 1] == 0) continue;
            }else{
                if(a[N - 1] == 1) continue;
            }
        }
        REP(i, N){
            if(a[i] == 0) cout << "S";
            else cout << "W";
        }
        cout << endl;
        return 0;
    }
    PRINT("-1");
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
using namespace std;
typedef long long ll;

ll sqrtll(ll p) {
    ll ok = 0, ng = (1LL << 31);
    while (ng - ok > 1) {
        ll mid = (ok + ng) / 2;
        if (mid * mid < p) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    return ok;
}

int main() {
    int Q;
    cin >> Q;
    for (int q = 0; q < Q; ++q) {
        ll A, B;
        cin >> A >> B;
        if (A >= B) {
            swap(A, B);
        }  // A < B

        if (B - A <= 1) {
            cout << (A - 1) * 2 << endl;
        } else {
            ll C = sqrtll(A * B);
            if (C * (C + 1) >= A * B) {
                cout << 2 * C - 2 << endl;
            } else {
                cout << 2 * C - 1 << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N,K; cin>>N>>K;
    int counter=0;
    while(N>0) {
        N/=K;
        counter++;
    }
    cout<<counter<<endl;
}

Measured memory_bytes: 256