akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
h = [int(x) for x in input().split()]
dp = [0] * N

for i, hi in enumerate(h):
    if i == 0:
        continue
    if i - K < 0:
        dp[i] = min(dpk + abs(hi-hk) for dpk, hk in zip(dp[:i], h[:i]))
    else:
        dp[i] = min(dpk + abs(hi-hk) for dpk, hk in zip(dp[i-K:i], h[i-K:i]))

print(dp[-1])

Measured memory_bytes: 14104
/*
ex4_3
tomatokan
*/
#include<stdio.h>
int get_snow_depth(int,int);

int main(void){
    int height_west,height_east;
    scanf("%d",&height_west);
    scanf("%d",&height_east);
    printf("%d",get_snow_depth(height_west,height_east));
    return 0;
}

int get_snow_depth(int west,int east){
    return (east*east-2*east*west+west*west-east-west)/2;
}

Measured memory_bytes: 128
N = int(input())
A = [int(input()) for i in range(N)]
array = []
ans = 0
A.sort()
count = 0

for i in range(N):
  count += 1
  if i == N-1:
    if count%2 == 1:
      ans += 1
#    print(A[i], count, ans)
    
#  elif A[i] == A[i+1]:
#    print(A[i], count, ans)
    
  elif A[i] != A[i+1]:
    if count % 2 == 1:
      ans += 1
#    print(A[i], count, ans)
    count = 0

print(ans)

Measured memory_bytes: 7388
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define assign(x,val) memset(x,val,sizeof(x))
#define motherfucker  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define for0(i,n) for(ll i=0;i<n;++i)
#define for1(i,n) for(ll i=1;i<=n;++i)
#define ford(i,n) for(ll i=n;i>=1;--i)
#define forg(i,a,b) for(ll i=a;i<b;++i)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpl;
long long mod = 1000000007;
const long double PI = (long double)(3.1415926535897932384626433832795);
inline void yes(){cout<<"YES\n";}
inline void no(){ cout<<"NO\n";}
inline void notposs(){cout<<-1<<endl;}
bool tests = 0;
ll binpow(ll a, ll b, ll mo){
	ll ans = 1;
	while(b){
		if(b&1){
			ans*=a;
			ans%=mod;
		}
		a*=a;
		a%=mo;
		b/=2;
	}
	return ans;
}

ll fn(ll n, ll r){
	ll num = 1, denom = 1;
	for(int i = n - r  + 1; i <=n;++i){
		num*=i;
		num%=mod;
	}
	for(int i = 1; i<= r;++i){
		denom*=i;
		denom%=mod;
	}
	return (num*(binpow(denom,mod - 2, mod) + mod))%mod;
}



void solve(){
	ll n, a, b;cin>>n>>a>>b;
	ll ans = binpow(2,n,mod) - 1;
	ll tempans = 2*mod - fn(n, a) - fn(n, b);
	ans%=mod;
	tempans%=mod;
	ans += tempans;
	ans += mod;
	ans%=mod;
	cout<<ans<<endl;
}
 
int main(){
	
	motherfucker
	ll t = 1;
	if(tests) cin>>t;
	for0(i, t){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>

using namespace std;
int main()
{
	int A, B, C = 0;
	cin >> A >> B >> C;

	if (A + B < C) { cout << "No"; }
	else { cout << "Yes"; }

	return 0;
}

Measured memory_bytes: 256
n,d=map(int,input().split())
l=[list(map(int,input().split())) for i in range (n)]

ans=0
for i in range(n):
    for k in range(i+1,n):
        t=0
        for j in range(d):
            t=t+(l[i][j]-l[k][j])**(2)
        t=t**(1/2)
        if t==int(t):
            ans=ans+1          
print(ans)
         

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys

INF = 10**9


def dfs(cur, ia, ib, ic):
    if(cur == N):
        return abs(ia-A) + abs(ib-B) + abs(ic-C) - 30 if min(ia,ib,ic) > 0 else INF

    ret0 = dfs(cur+1, ia, ib, ic)
    ret1 = dfs(cur+1, ia+l[cur], ib, ic) + 10
    ret2 = dfs(cur+1, ia, ib+l[cur], ic) + 10
    ret3 = dfs(cur+1, ia, ib, ic+l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)


def solve(N: int, A: int, B: int, C: int, l: "List[int]"):
    print(dfs(0,0,0,0))

    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long lo;
const int mod=1000000007,N=500005;
lo a,b,c,d,e,f,g,h[N],arr[N];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// freopen("in.txt","r",stdin);
	// freopen("out.txt","w",stdout);
	cin >> a >> b;
	if(a==1 or b==1) cout << 1 << endl;
	else cout << (lo)(ceil((double)(a*b)/2)) << endl;
}

Measured memory_bytes: 256
function main()
  
  (a,b,c,d) = map(x -> parse(Int,x), split(readline()))
  
  if abs(a-c) <= d
    println("Yes")
  elseif abs(a-b) <= d && abs(b-c) <= d
    println("Yes")
  else
    println("No")
  end
  
end

main()

Measured memory_bytes: 109704
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


void Main(){
    int A, B;
    cin >> A >> B;
    int N = A+B;
    cout << 6-N << el;
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<pll> vll;
typedef vector<vl> vvl;

#define fori(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i >= 0; i--)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define trav(x, a) for (auto &x : a)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define sz(a) (int)(a).size()
#define fi first
#define se second

clock_t time_p = clock();
void time_taken()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

const ll mod = 1e9 + 7;
const ll INF = 1e18;

const int maxn = 1e5 + 5;

vi adj[maxn];

int dfs(int u){
    vi vals;
    for (int v : adj[u])
    {
        vals.pb(dfs(v));
    }
    sort(all(vals));
    int len = sz(adj[u]);
    int depth = 0;
    for (int i = len - 1; i >= 0; i--)
    {
        depth = max(depth, 1 + i + vals[len - i - 1]);
    }
    return depth;
}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    int n;
    cin >> n;
    rep(i, 2, n)
    {
        int x;
        cin >> x;
        adj[x].pb(i);
    }

    cout << dfs(1) << endl;

    time_taken();
    return 0;
}

Measured memory_bytes: 17052
import java.io.*;
import java.util.*;
public class Main {
    static boolean check(String s){
        if (s.length()<=1)
            return true;
        for (int i =0;i<s.length()/2;i++){
            if (s.charAt(i)!=s.charAt(s.length()-i-1))
                return false;
        }
        return true;
    }
    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        String s= sc.next();
        if (check(s)&&check(s.substring(0,(s.length()-1)/2))&&check(s.substring((s.length()+3)/2-1)))
            pw.println("Yes");
        else pw.println("No");
        pw.flush();
    }
    static int gcd(int x,int y){
        if (x==0)
            return y;
        return gcd(y%x,x);
    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }

}

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

int main(int argc, char const *argv[]) {
    string s;
    int cnt=0;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='2'){
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


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



struct Point{
  double x;
  double y;
};

void ko(int d, struct Point p1, struct Point p2){
  struct Point s, t, u;
  double k;

  if(d == 0) return;

  k = M_PI * 60.0 / 180.0;

  s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
  s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
  t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
  t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
  u.x = (t.x - s.x) * cos(k) - (t.y - s.y) * sin(k) + s.x;
  u.y = (t.x - s.x) * sin(k) + (t.y - s.y) * cos(k) + s.y;

  ko(d-1, p1, s);
  printf("%.8f %.8f\n", s.x, s.y);
  ko(d-1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  ko(d-1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  ko(d-1, t, p2);
}

int main(){
  struct Point p1, p2;
  int n;

  scanf("%d", &n);

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;

 printf("%.8f %.8f\n", p1.x, p1.y);
 ko(n, p1, p2);

 printf("%.8f %.8f\n", p2.x, p2.y);

 return 0;
}



Measured memory_bytes: 2096
MOD = 10**9 + 7
fac = [1,1] # 階乗 n!
inv = [0,1] # 逆元 1/n
finv = [1,1] # 逆元の階乗 (n^-1)! = (1/n)!

def finv_init(n, m):
    for i in range(2, n+1):
        fac.append( (fac[-1] * i ) % m )
        inv.append( (-inv[m%i] * (m//i)) % m )
        finv.append( (finv[-1] * inv[-1]) % m )

def nPr(n, r, m): return fac[n] * finv[n-r]

n, m = map(int, input().split())
finv_init(m, MOD)
ans = 0
for d in range(0, n+1):
    a = nPr(m-d, n-d, MOD) * nPr(n, d, MOD) * finv[d] % MOD
    if d & 1: a = -a
    ans += a; ans %= MOD
ans *= nPr(m, n, MOD)
print(ans % MOD)


Measured memory_bytes: 68552
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define LL long long
using namespace std;
inline int get_num() {
    char c;
    int f = 1, num = 0;
    while ((c = getchar()) == ' ' || c == '\n' || c == '\r')
        ;
    if (c == '-')
        f = -1;
    else
        num = c - '0';
    while (isdigit(c = getchar())) num = num * 10 + c - '0';
    return num * f;
}
const int MAXN = 1e5 + 7;
struct re {
    int a, b;
    bool operator<(const re &a) const { return b < a.b; }
} v[MAXN];
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        v[i].a = i;
    }
    for (int i = 1; i <= n; i++) {
        cin >> v[i].b;
    }
    sort(v + 1, v + 1 + n);
    for (int i = 1; i <= n; i++) {
        cout << v[i].a << " ";
    }
    return 0;
}

Measured memory_bytes: 1536
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

A, B, C, X, Y = map(int, input().split())

ans = 0
if X >= Y:
    ans = min(A*X+B*Y, C*(Y)*2+A*(X-Y))
else:
    ans = min(A*X+B*Y, C*(X)*2+B*(Y-X))


ans = min(ans, C*max(X, Y)*2)
print(ans)


Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
using namespace std;
void trace(int A[],int N){
	int i;
	for(int i=0;i<N;i++){
		if(i>0){
			printf(" ");
		}
		printf("%d",A[i]);
	}
	printf("\n");
}

void insertionSort(int A[],int N){
	int j,i,v;
	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;
		trace(A,N);
	}
}

int main(){
	int N,i,j;
	int A[100];
	scanf("%d",&N);
	for(i=0;i<N;i++)
		scanf("%d",&A[i]);
		
	trace(A,N);
	insertionSort(A,N);
	
	return 0;
}


Measured memory_bytes: 3232
N, M = [int(_) for _ in input().split()]
bridge = [[int(_) for _ in input().split()] for _ in range(M)]

bridge.reverse()
bridge = bridge[:-1]

inconvenience = N * (N - 1) // 2
inconvenience_history = [inconvenience]


class UnionFind:
    def __init__(self, N):
        self.par = [i for i in range(N + 1)]
        self.rank = [0] * (N + 1)
        self._number = [1] * (N + 1)

    def root(self, i):
        if self.par[i] == i:
            return i
        self.par[i] = self.root(self.par[i])
        return self.par[i]

    def tree_rank(self, i):
        return self.rank[self.root(i)]

    def number(self, i):
        return self._number[self.root(i)]

    def union(self, i, j):
        _root_i = self.root(i)
        _root_j = self.root(j)
        if _root_i == _root_j:
            return
        else:
            if self.tree_rank(i) < self.tree_rank(j):
                self.par[_root_i] = _root_j
                self._number[_root_j] += self._number[_root_i]
            else:
                self.par[_root_j] = _root_i
                self._number[_root_i] += self._number[_root_j]
                if self.tree_rank(i) == self.tree_rank(j):
                    self.rank[_root_i] += 1


islands = UnionFind(N)

for A_i, B_i in bridge:

    root_A = islands.root(A_i)
    root_B = islands.root(B_i)

    if root_A == root_B:
        inconvenience_history.append(inconvenience)
        continue
    else:
        improvement = islands.number(A_i) * islands.number(B_i)
        islands.union(A_i, B_i)

        inconvenience -= improvement
        if inconvenience == 0:
            inconvenience_history += [0] * (M - len(inconvenience_history))
            break
        inconvenience_history.append(inconvenience)

print(*inconvenience_history[::-1], sep='\n')


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

int n, m;

int main(){
  cin >> n >> m;
  cout << (1900 * m + 100 * (n - m)) * pow(2, m) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e4+10;
int n,c[maxn],ans,u,v,b[maxn],pt;
vector<int> a[maxn];
void dfs(int nod,int pa){
    b[nod]=c[pt];
    pt--;
     ans+=c[pt];
    for(int i:a[nod]){
        if(i!=pa){
            dfs(i,nod);
        }
    }
    return;
}
 
 
int main(){
    scanf("%d",&n);
  pt=n;
    for(int i=1;i<n;i++){
        scanf("%d%d",&u,&v);
        a[u].push_back(v);
        a[v].push_back(u);
    }
    for(int i=1;i<=n;i++)
        scanf("%d",&c[i]);
    sort(c+1,c+1+n);
    dfs(1,0);
    printf("%d\n",ans);
    for(int i=1;i<=n;i++)
        printf("%d ",b[i]);
}

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

int main() {
	int a,s=0;
	string k = "YES";
	for(int i = 0;i < 3;i++)
	{
		cin >> a;
		if(a == 5 || a == 7)
		{
			s += a;
		}
		else
		{
			k = "NO";
			break;
		}
	}
	if(s != 17)
	{
		k = "NO";
	}
    cout << k << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int limit = 50;

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

bool graph[limit][limit];
bool visited[limit];

void dfs(int v) {
    visited[v] = true;
    for (int v2 = 0; v2 < n; ++v2) {
        if (graph[v][v2] == false) continue;
        if (visited[v2] == true) continue;
        dfs(v2);
    }
}

int main(void) {
    cin >> n >> m;

    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    int ans = 0;

    for (int i = 0; i < m; ++i) {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

        for (int j = 0; j < n; ++j) {
            visited[j] = false;
        }

        dfs(0);

        bool bridge = false;
        for (int j = 0; j < n; ++j) {
            if (visited[j] == false) {
                bridge = true;
            }
        }
        if (bridge) {
            ans += 1;
        }

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
require "prime"

n = gets.to_i
count = 0

(1..n).each do |i|
  next if i % 2 == 0
  if i.prime_division.map{|a|a[1]}.reduce(1){|a,e| a*=e+1} == 8
    count += 1
  end
end

puts count

Measured memory_bytes: 1916
package main

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

func main() {
	rdr := NewReader(10)
	l1 := ReadInts(rdr)
	l2 := ReadInts(rdr)
	l3 := ReadInts(rdr)

	a1 := l2[0] - l1[0]
	a2 := l3[0] - l1[0]

	x := a1 == l2[1]-l1[1] && a1 == l2[2]-l1[2]
	y := a2 == l3[1]-l1[1] && a2 == l3[2]-l1[2]

	if x && y {
		fmt.Println("Yes")
		return
	}

	fmt.Println("No")
}

type Reader struct {
	rdr  *bufio.Reader
	size int
}

func NewReader(size int) *Reader {
	return &Reader{
		bufio.NewReaderSize(os.Stdin, size),
		size,
	}
}

func ReadLine(r *Reader) string {
	buf := make([]byte, 0, r.size)
	for {
		line, isPrefix, err := r.rdr.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}

func ReadStrs(r *Reader) []string {
	return strings.Split(ReadLine(r), " ")
}

func ReadInts(r *Reader) []int {
	a := ReadStrs(r)
	n := make([]int, 0)
	for _, v := range a {
		if i, e := strconv.Atoi(v); e == nil {
			n = append(n, i)
		}
	}
	return n
}


Measured memory_bytes: 640
N, M, S = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    a, b, l = map(int, input().split())
    G[a].append([b, l])
INF = 10**10


def bellman_ford(G, N, S):

    res = [INF for _ in range(N)]
    res[S] = 0
    for _ in range(N-1):
        for i in range(N):
            if res[i] == INF:
                continue
            for sa, sb in G[i]:
                res[sa] = min(res[sa], res[i]+sb)
    for i in range(N):
        if res[i] == INF:
            continue
        for sa, sb in G[i]:
            if res[sa] > res[i]+sb:
                return False
    return res


res = bellman_ford(G, N, S)
if res == False:
    print("NEGATIVE CYCLE")
else:
    for i in range(N):
        if res[i] == INF:
            print("INF")
        else:
            print(res[i])



Measured memory_bytes: 6068
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S=in<string>();
    int i=0;
    int j=S.length()-1;
    int ans=0;
    while(i<j){
        if(S[i]==S[j]){
            i++;j--;continue;
        }else if(S[i]=='x'){
            ans++;
            i++;
        }else if(S[j]=='x'){
            j--;
            ans++;
        }else{
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

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

int main() {
    int w;
    string s;

    cin >> s;
    cin >> w;

    string ans;

    for (int i = 0; i < s.size(); i += w) {
        ans.push_back(s.at(i));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/*
ツ閉カツ篠堋療アツづ個右ツ端ツつゥツづァツ債カツ端ツづ可嘉アツづィツ債楪づ楪づ?つォツづ? ツ湘ィツ余(%)ツづーツ使ツつ、ツづ?渉按猟敖つオツづ「ツつキツつ「
 */
#include <iostream>
using namespace std;

bool AcontainsB(string A, string B){
  int m = A.length();
  int n = B.length();

  for(int i = 0; i < m; i++){
    bool flg = true;

    for(int j = 0; j < n; j++){
      if(A[(i + j) % m] != B[j]){
        flg = false;
        break;
      }
    }

    if(flg) return true;
  }

  return false;
}

int main(){
  string s;
  int n, ans = 0;

  cin >> s;
  cin >> n;

  for(int i = 0; i < n; i++){
    string t;
    cin >> t;

    if(AcontainsB(t, s)){
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 0
/*      ex2_3
        Tarara  */
#include <stdio.h>
int main()
{
    int length; // マス一辺の長さ
    int whites; // 白くぬるマスの数
    scanf("%d", &length);
    scanf("%d", &whites);

    // 黒く塗るマスの数
    int blacks = length * length - whites;
    printf("%d\n", blacks);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
 
using namespace std ;
 
typedef double D ;
typedef long long ll ;
typedef long double ld ;
typedef unsigned int ui ;
typedef unsigned long long ull ;
 
# define F first
# define S second
# define R return
# define C continue 
# define pb push_back 
# define pf push_front
# define mp make_pair
 
# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp
 
# define vi vector <int>
# define vb vector <bool>
# define vll vector <ll>
# define vs vector <string>
 
# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >
 
# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >
 
# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >
# define vvpii vector < vector < pii > >
 
# define Fi(i,L,R) for (int i = L ; i <= R ; i++)
# define Fd(i,R,L) for (int i = R ; i >= L ; i--)
# define fast ios_base :: sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0)
 
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))
 
#define inf INT_MAX
const ld PI = 3.1415926535897932384626 ;
const ll MOD = 1e9 + 7 ;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve (int test_case)
{
	int n , m ;
	cin >> n >> m ;
	
	vi a (n) ;
	
	int sum = 0 ;
	
	Fi(i , 0 , n-1)
	{
		cin >> a[i] ;
		sum += a[i] ;
	}
	    
	float req = float(sum)/float(4*m) ;
	
	int count = 0 ;
	
	Fi(i , 0 , n-1)
	{
		
		if (float(a[i]) < req)
		    continue ;
		else
		    ++count ;
	}
	
	if (count >= m)
	{
		cout << "Yes" ;
	}
	else
	{
		cout << "No" ;
	}
}
 
int main()
{
	//freopen ("input.txt","r",stdin) ;
	//freopen ("output.txt","w",stdout) ;
	fast ;
	int tc = 1 ;
//	cin >> tc ;
	for(int t = 1 ; t <= tc ; ++t)
	{
		solve(t) ;
	}
	return 0 ;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

typedef long long LL;

using namespace std;

int MAX = 100000;
int prime[100000+2]       = {0};
int like2017[100000+2]    = {0};
int like2017SUM[100000+2] = {0};

int isPrime(LL p){
	if(p<=1) return 0;
	if(p==2 || p==3 || p==5 || p==7) return 1;
	if(p==4 || p==6 || p==8 || p==9) return 0;

	LL i;
	int ret = 1;
	for(i=2; i*i<=p; i++){
		if(p%i==0 && i!=p){
			ret = 0;
			break;
		}
	}
	return ret;
}

void init2017(){
	for(int i=1; i<=MAX; i++){
		if(isPrime((LL)i)==1) prime[i] = 1;
	}
	for(int i=1; i<=MAX; i++){
		if(prime[i]==1 && prime[(i+1)/2]==1){
			like2017[i] = 1;
		}
		like2017SUM[i] = like2017SUM[i-1] + like2017[i] ;
	}
}

int main(int argc, char* argv[]){
	int Q;
	int l, r;

	cin >> Q;
	init2017();

	for(int i=1; i<=Q; i++){
		long long num = 0;
		int l, r;
		cin >> l >> r;
		num = like2017SUM[r] - like2017SUM[l-1];
		cout << num << endl ;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,l;
int a[125252];

int main(){
  scanf("%d%d",&n,&l);
  REP(i,n)scanf("%d",a+i);
  int last = -1;
  REP(i,n-1){
    if(a[i]+a[i+1] >= l){
      last = i;
      break;
    }
  }
  if(last==-1){
    puts("Impossible");
  }else{
    puts("Possible");
    REP(i,last){
      printf("%d\n",i+1);
    }
    FORR(i,last+1,n-1){
      printf("%d\n",i+1);
    }
    printf("%d\n",last+1);
  }
  return 0;
}


Measured memory_bytes: 1152
#include <iostream>

#define N_MAX 500

using namespace std;

int main(){
    int N;
    int row_count_black[N_MAX] = {0};
    int col_count_black[N_MAX] = {0};
    int row_all_black = 0;
    int col_all_black = 0;
    bool all_white = true;
    char a[N_MAX][N_MAX];
    cin >> N;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cin >> a[i][j];
            if(a[i][j] == '#'){
                all_white = false;
                col_count_black[j]++;
                row_count_black[i]++;
            }
        }
    }
    if(all_white)cout << -1 << endl;
    else{
        for(int i = 0; i < N; i++){
            if(row_count_black[i] == N) row_all_black++;
            if(col_count_black[i] == N) col_all_black++;
        }
        if(row_all_black != 0){
            cout << N - col_all_black << endl;
        }else{
            int min_ops = INT32_MAX;
            //i番目のrowを黒にする
            for(int i = 0; i < N; i++){
                if(col_count_black[i] == 0){
                    min_ops = min(min_ops, N-row_count_black[i]+1);
                }else{
                    min_ops = min(min_ops, N-row_count_black[i]);
                }
            }
            cout << N - col_all_black + min_ops << endl;
            //cout << N << ' ' << col_all_black << ' ' <<  min_ops << endl;
        }
    }
}

Measured memory_bytes: 512
def main(input = STDIN)
  prev_hash = Hash.new{0}
  while (datum = input.gets) != "\n"
    datum = datum.split(",").map(&:to_i)
    prev_hash[datum[0]] += 1
  end
  this_hash = Hash.new{0}
  this = []
  while (datum = input.gets)
    datum = datum.split(",").map(&:to_i)
    this.push(datum[0])
    this_hash[datum[0]] += 1
  end
  this.sort!.uniq!
  this.each{|c|
    if (prev_hash[c] != 0 and this_hash[c] != 0)
      puts c.to_s + " " + (prev_hash[c] + this_hash[c]).to_s + "\n"
    end
  }
end
main

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

int main() {

	int n;
	cin >> n;

	int h[30];

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

	int count = 0;
	int max = h[0];

	for (int i = 1; i < n; i++) {
		if (h[i] >= max) {
			count++;
			max = h[i];
		}
	}

	cout << 1 + count << endl;

	return 0;

}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
ans = 1

n, k = map(int, input().split())
a = list(map(int, input().split()))

if n == k:
    for x in a:
        ans *= x
        ans %= MOD
    print(ans % MOD)
    exit()

pos = []
neg = []

for x in a:
    if x >= 0:
        pos.append(x)
    else:
        neg.append(x)

pos.sort(reverse=True)
neg.sort()

if len(pos) == 0 and k % 2:
    for i in range(1, k+1):
        ans *= neg[-i]
        ans %= MOD
    print(ans % MOD)
    exit()

pi = 0
ni = 0
if k % 2:
    ans *= pos[pi]
    pi += 1
    k -= 1

while k > 0:
    if pi < len(pos) - 1:
        sp = pos[pi] * pos[pi + 1]
    else:
        sp = 0
    
    if ni < len(neg) - 1:
        sn = neg[ni] * neg[ni + 1]
    else:
        sn = 0
    
    if sp > sn:
        ans *= sp
        pi += 2
    else:
        ans *= sn
        ni += 2
    
    ans %= MOD
    k -= 2

print(ans % MOD)


Measured memory_bytes: 31720
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int nmax=40,abmax=10,inf = 1000000;
int N,Ma,Mb;
int a[nmax],b[nmax],c[nmax];
int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];

int main(){
  cin >> N >> Ma >> Mb;
  for(int i=0;i<N;i++)cin >> a[i] >> b[i] >> c[i];
  for(int i=0;i<=N;i++){
    for(int j=0;j<=400;j++){
      for(int k=0;k<=400;k++){
	dp[i][j][k]=inf;
      }
    }
  }
  dp[0][0][0]=0;

  for(int i=0;i<N;i++){
    for(int ca=0;ca<=400;ca++){
      for(int cb=0;cb<=400;cb++){
	if(dp[i][ca][cb]==inf)continue;
	dp[i+1][ca][cb]=min(dp[i][ca][cb],dp[i+1][ca][cb]);
	dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]);
	
      }
    }
  }
  int ans=inf;
  for(int ca=1;ca<=400;ca++){
    for(int cb=1;cb<=400;cb++){
      if(ca*Mb==cb*Ma)ans=min(ans,dp[N][ca][cb]);
    }
  }
  if(ans==inf)ans=-1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 25984
n,m = map(int,input().split())
ps = [0] * m
for i in range(m):
    ps[i] = list(map(str,input().split()))
if m == 0:
    print(0,0)
    exit()
countA = [0] * n
countW = [0] * n
cn = 0
for item in ps:
    if item[1] == 'AC' and countA[int(item[0])-1] == 0:
        countA[int(item[0])-1] = 1
        cn += countW[int(item[0])-1]
    else:
        countW[int(item[0])-1] += 1
print(sum(countA),cn)

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

Graph graph;
vector<int> min_cost;
vector<int> tintin;

void Dijkstra(int s) {
  //昇順でfirstを小さい方から取る
  min_heap<P> que;
  min_cost[s] = 0;
  que.emplace(0, s);

  while (!que.empty()) {
    int now_cost, now_node;
    tie(now_cost, now_node) = que.top();
    que.pop();

    if (min_cost[now_node] < now_cost)
      // queの値より新しいcostの方が小さいとき見ない
      continue;

    rep(i, 0, graph[now_node].size()) {
      int next_node, next_cost;
      tie(next_node, next_cost) = graph[now_node][i];

      //最短経路更新
      if (chmin(min_cost[next_node], min_cost[now_node] + next_cost)) {
        tintin[next_node] = now_node;
        que.emplace(min_cost[next_node], next_node);
      }
    }
  }
}

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int V, E;
  cin >> V >> E;

  min_cost.resize(V + 5, INF);
  graph.resize(V + 5);
  tintin.resize(V + 5);

  rep(i, 0, E) {
    int a, b;
    cin >> a >> b;
    graph[a].emplace_back(b, 1);  //グラフの構築
    graph[b].emplace_back(a, 1);
  }

  bool jud = true;
  vector<int> ans(V);
  Dijkstra(1);
  rep(i, 2, V + 1) if (min_cost[i] == INF) return cout << "No\n", 0;

  cout << "Yes\n";
  rep(i, 2, V + 1) cout << tintin[i] << '\n';

  return 0;
}

Measured memory_bytes: 20288
#include<stdio.h>

int main(void)
{
  char b;
  
  scanf("%s",&b);
  
  if(b=='A')
    printf("T");
  if(b=='T')
    printf("A");
  if(b=='C')
    printf("G");
  if(b=='G')
    printf("C");
    
  
  
 return 0 ;
}

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

int main(){
    int n, l, i, a = 999999, s = 0;
    cin >> n >> l;
    for(i=0; i<n; i++){
        s += i+l;
        if(abs(a) > abs(l+i)){
            a = l+i;
        }
    }
    cout << s - a;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())

W = [] 
for _ in range(n):
    W.append(int(input()))

left = 0 
right = 100_000 * 10_000

while left < right - 1:
    P = (right + left) // 2
    i = 0
    for _ in range(k):
        if i == n: break
        s = 0
        while s + W[i] <= P:
            s += W[i]
            i += 1
            if i == n: break
    if i >= n:
       right = P
    else:
       left = P
print(right)




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

#define ll long long
#define pb push_back
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))

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

    int a, b;
    cin >> a >> b;
    (a+b>=10) ? cout << "error\n" : cout << a + b << "\n";
    return 0;
}


Measured memory_bytes: 256
ans = ''
r, c = map(int, input().split(' '))
i = 0
L = [0] * (c + 1)
while i < r:
    a = list(map(int, input().split(' ')))
    atot = 0
    j = 0
    while j < c:
        atot += a[j]
        L[j] += a[j]
        j += 1
    ans += ' '.join(map(str, a)) + ' ' + str(atot) + '\n'
    L[c] += atot
    i += 1
if ans != '':
    ans += ' '.join(map(str, L))
    print(ans)


Measured memory_bytes: 5680
object Main {

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

    val N = sc.nextInt()

    // 先頭に0のつかない10進数表記で表した時に, Aの末尾の桁が
    // Bの先頭の桁に等しく, Aの先頭の桁が, Bの末尾の桁に等しい組みの数
    // c_{i,j} := kの先頭の桁の数はiに等しく, 末尾の桁の数はjに等しい数
    def solve(N: Int): Int = {
      val c = Array.fill(10, 10)(0)
      for {
        i <- 1 to N
        iS = i.toString
        h = iS.head - '0'
        l = iS.last - '0'
      } c(h)(l) += 1

      (for {
        h <- 1 to 9
        l <- 1 to 9
      } yield c(h)(l) * c(l)(h)).sum
    }

    println(solve(N))
  }

}


Measured memory_bytes: 55568
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-20;
const long INF = 1e10;


int main(){
	LL N;
	cin>>N;
	int cnt=0;
	while(N>3){
		N=N/3+(N%3!=0);
		cnt++;
	}
	if(N!=0)cnt++;
	cout<<cnt<<endl;
	return 0;
}

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

int main(){
    int a,b,c;
    cin >>a>>b>>c;
    if(a==1&&b==1){
        cout <<"Open"<<endl;
    }else if(c==1){
        cout <<"Open"<<endl;
    }else{
        cout <<"Close"<<endl;
    }
    
return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    long long L[110]={};
    
    cin >> N;
    for(int i=0;i<N;i++) cin >> L[i];
    
    
    int count = 0;
    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++){
                long long l_side = max({L[i],L[j],L[k]});
                if(L[i]!=L[j] and L[i]!=L[k] and L[j]!=L[k] and L[i]+L[j]+L[k]>2*l_side) {
                    count++;
                  //  cout << L[i] << L[j] << L[k] << endl;
                }
            }
        }
    }
    
    cout << count;
}

Measured memory_bytes: 3640
//Binary Search Tree Ｉ
//2019-01-11
//Ebitani Akira

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x -> left != NIL)
    x = x -> left;

  return x;

}

Node treeMaximum(Node x){
  while(x -> right != NIL)
    x = x -> right;

  return x;

}

Node treeSearch(Node u, int k){
  if(u == NIL && k == u -> key)
    return u;

  else if(k < u -> key)
    return treeSearch(u -> left, k);
  else
    return treeSearch(u -> right, k);

}

Node treeSuccessor(Node x){
  Node A;

  if(x -> right != NIL)
    return treeMinimum(x -> right);

  A = x -> parent;

  while(A != NIL && x == A -> right){
    x = A;
    A = A ->parent;
  } 

  return A;
  
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z -> left == NIL || z -> right == NIL)
    y = z;
  else
    y = treeSuccessor(z);

  if(y -> left != NIL)
    x = y -> left;
  else
    x = y ->right;

  if(x != NIL)
    x -> parent = y -> parent;

  if(y -> parent == NIL)
    root = x;
  else if(y == y -> parent -> left)
    y -> parent -> left = x;
  else
    y -> parent -> right = x;

  if(y != z)
    z -> key = y -> key;    

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;

    if(z -> key < x -> key)
      x = x -> left;
    else
      x = x -> right;

  }
  z -> parent = y;

  if(y == NIL)
    root = z;
  else if(z -> key < y -> key)
    y -> left = z;
  else
    y -> right = z;

}

void inorder(Node u){
  if(u == NIL){
    return;
  }
  inorder(u -> left);
  printf(" %d", u -> key);
  inorder(u -> right);
  

}
void preorder(Node u){
  if(u == NIL){
    return;
  }
    printf(" %d", u -> key);
    preorder(u -> left);
    preorder(u -> right);
  
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  if(n > 500000){
    printf("命令の数が大きすぎます。\n");
    exit(1);
  }

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25148
#include <iostream> 
#include <cassert>
#include <cctype>
using namespace std;

string S;
size_t cur;

int digit() {
  assert(isdigit(S[cur])); // S[cur]が数字でなければストップ。正しく動作すれば実行されない。
  int n = S[cur] - '0';
  cur++;
  return n;
}

int number() {
  int n = digit();
  while (cur < S.size() && isdigit(S[cur])) {
    n = n * 10 + digit();
  }
  return n;
}

int factor();
int term() {
  int a = factor();
  while (cur < S.size() && (S[cur] == '*' || S[cur] == '/')) {
    char op = S[cur++];
    int b = factor();
    if (op == '*') {
      a *= b;
    } else {
      a /= b;
    }
  }
  return a;
}

int expression();
int factor() {
  if (S[cur] != '(') return number();
  assert(S[cur] == '(');
  cur++;
  int n = expression();
  assert(S[cur] == ')');
  cur++;
  return n;
}

int expression() {
  int a = term();
  while (cur < S.size() && (S[cur] == '+' || S[cur] == '-')) {
    char op = S[cur++];
    int b = term();
    if (op == '+') {
      a += b;
    } else {
      a -= b;
    }
  }
  return a;
}

int parse() { return expression(); }

int main() {
  int N;
  cin >> N;
  for (int i=0; i<N; i++) {
    cur = 0;
    cin >> S;
    S.resize(S.size()-1); // 最後の=はいらない
    cout << expression() << endl;
  }
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef valarray<double> vad;

int main(){
    int n;
    cin >> n;
    vad x(n), y(n);
    REP(i, n) cin >> x[i];
    REP(i, n) cin >> y[i];
    double d1, d2, d3, di;
    vad tmp = abs(x-y);
    di = tmp.max();
    d1 = tmp.sum();
    vad tmp2 = tmp * tmp;
    d2 = sqrt(tmp2.sum());
    tmp *= tmp2;
    d3 = cbrt(tmp.sum());
    cout << fixed << setprecision(5)
    << d1 << endl << d2 << endl << d3 << endl << di << endl;
}

Measured memory_bytes: 3480
a, b, c, x, y = map(int, input().split())
if c * 2 < a + b:
    t = c * min(x, y) * 2
    if x - y > 0:
        if c * 2 < a:
            t += c * (x - y) * 2
        else:
            t += a * (x - y)
    else:
        if c * 2 < b:
            t += c * (y - x) * 2
        else:
            t += b * (y - x)
else:
    t = a * x + b * y
print(t)

Measured memory_bytes: 3064
N=int(input())
T,A=map(int,input().split())
H = list(map(int,input().split()))
ind = -1
dis = 10**5
for i in range(len(H)):
  dx = abs(A - (T-H[i]*0.006))
  if dis > dx:
    dis = dx
    ind = i
print(ind+1)

Measured memory_bytes: 3064
from collections import deque

N = int(input())
A = [['nul']] + [list(map(int, input().split())) for _ in range(N)]

# how many times each player matched
c = [0 for _ in range(N + 1)]
predeq = deque([])

for i in range(1, N + 1):
    j = A[i][c[i]]
    if i == A[j][c[j]] and i < j:
        predeq.append((i, j))

ans = 0
while predeq:
    # print(predeq)
    postdeq = deque([])
    for i, j in predeq:
        c[i] += 1
        c[j] += 1
        if c[i] < N - 1:
            k = A[i][c[i]] # next player
            if A[k][c[k]] == i:
                postdeq.append((i, k))
        if c[j] < N - 1:
            k = A[j][c[j]]
            if A[k][c[k]] == j:
                postdeq.append((j, k))
    ans += 1
    predeq = postdeq

if c == [0] + [N - 1] * N:
    print(ans)
else:
    print(-1)


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

int main() {
  string s;
  cin>>s;
  
  if(s=="a"||s=="i"||s=="u"||s=="e"||s=="o"){
    cout<<"vowel"<<endl;
  }
  
  else{
    cout<<"consonant"<<endl;
  }
  
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long ans;
string s;
main()
{
	cin>>s;
	int nowa=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='A')nowa++;
		else if(s[i]=='C')nowa=0;
		else
		{
			if(i+1<s.size()&&s[i+1]=='C')
			{
				ans+=nowa;
				i++;
			}else nowa=0;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640