akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[]) {
    int r, d, x;
    cin >> r >> d >> x;

    for (size_t i = 0; i < 10; i++) {
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
using namespace std;

int fac(int n){
    if(n == 1){
        return 1;
    }
    return n*fac(n-1);
}
int main(){
    int n;
    int p[10][2];
    cin >> n;
    for(int i=0; i<n; ++i){
        cin >> p[i][0] >> p[i][1];
    }
    double dis;
    double ans = 0;
    for(int i=0; i<n-1; ++i){
        for(int j=i+1; j<n; ++j){
            dis = pow(pow((p[i][0]-p[j][0]), 2) + pow((p[i][1]-p[j][1]), 2), 0.5);
            ans += dis * (fac(n-1)*2);
        }
    }
    ans /= fac(n);
    printf("%.16lf\n", ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int n,a,b;
cin>>n;
if(n==1)
{
cout<<"Hello World"<<endl;
return 0;
}
else if(n==2)
{
cin>>a;
cin>>b;
cout<<a+b<<endl;
return 0;
}
return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
now = a[0]
for i in range(1,n):
    now = math.gcd(now, a[i])
print(now)

Measured memory_bytes: 90556
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, m);
    Cins(int, n, s);
    Cins(int, m, t);
    
    // dp0[i][j] : s[i-1], t[j-1] まで見た時の共通部分列の個数
    vc<vc<ll>> dp(n+1, vc<ll>(m+1, 0));
    For(i, n+1) dp[i][0] = 1;
    For(j, m+1) dp[0][j] = 1;
    
    for(int i = 1; i <= n; i ++) for(int j = 1; j <= m; j ++){
        dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + MOD) % MOD;
        if(s[i-1] == t[j-1]){
            dp[i][j] = (dp[i][j] + dp[i-1][j-1]) % MOD;
        }
    }
    Cout(dp[n][m]);
}


Measured memory_bytes: 31616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Moonlight Farm
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		Main main = new Main();

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int N = parseInt(line);
			if (N == 0) break;

			Crop[] crops = new Crop[N];
			for (int i = 0; i < N; i++) {
				crops[i] = main.new Crop(br.readLine());
			}
			Arrays.sort(crops);

			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < N; i++) {
				sb.append(crops[i].getName()).append("\n");
			}
			sb.append("#");
			System.out.println(sb.toString());

		} //end while
	} //end main

	class Crop implements Comparable<Crop> {

		private String L;
		private int P, A, B, C, D, E, F, S, M;
		private double efficiency;

		Crop(String str) {
			StringTokenizer st = new StringTokenizer(str);
			this.L = st.nextToken();
			this.P = parseInt(st.nextToken());
			this.A = parseInt(st.nextToken());
			this.B = parseInt(st.nextToken());
			this.C = parseInt(st.nextToken());
			this.D = parseInt(st.nextToken());
			this.E = parseInt(st.nextToken());
			this.F = parseInt(st.nextToken());
			this.S = parseInt(st.nextToken());
			this.M = parseInt(st.nextToken());
			this.efficiency = setEfficiency();
		}

		String getName() {
			return this.L;
		}

		double getEfficiency() {
			return this.efficiency;
		}

		private double setEfficiency() {
			int income = S * F * M - P;
			int required = A + B + C + ((D + E) * M);
			return (double) income / required;
		}

		@Override
		public int compareTo(Crop o) {

			int negate = -1;

			if (this.getEfficiency() < o.getEfficiency()) {
				return -1 * negate;
			} else if (this.getEfficiency() > o.getEfficiency()) {
				return 1 * negate;
			} else {
				return this.getName().compareTo(o.getName());
			}
		}
	}
}

Measured memory_bytes: 28240
n = int(input())
A = list(map(int,input().split()))

Counter = [0 for i in range(10**5)]
ans = 0

for i in range(n):
    Counter[A[i]] += 1

for i in range(10**5-2):
    ans = max(ans,Counter[i]+Counter[i+1]+Counter[i+2])

print(ans)

Measured memory_bytes: 56260
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: i32 = iter.next().unwrap().parse().unwrap();
    let m: i32 = iter.next().unwrap().parse().unwrap();
    let c: i32 = iter.next().unwrap().parse().unwrap();

    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();

    let b = buf.split_whitespace()
        .map(|x| x.parse::<i32>().unwrap())
        .collect::<Vec<_>>();

    let mut result: i32 = 0;

    for i in 0..n {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();

        let a = buf.split_whitespace()
            .map(|x| x.parse::<i32>().unwrap())
            .collect::<Vec<_>>();

        let mut sum: i32 = 0;

        for j in 0..m {
            sum += a[j as usize]*b[j as usize];
        }

        sum += c;

        if sum > 0 {
            result+=1;
        }
    }

    println!("{}", result);
    /*
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let h: u32 = iter.next().unwrap().parse().unwrap();
    let w: u32 = iter.next().unwrap().parse().unwrap();
    */

}


Measured memory_bytes: 4352
H,W,K = map(int,input().split())
S = tuple(tuple(input()) for i in range(H))
ans = [[0 for i in range(W)] for j in range(H)]
num = 1
no_itigo = []
for i in range(H):
    if '#' in S[i]:
        fs = S[i].index('#')
        for j in range(fs+1):
            ans[i][j] = num
        for j in range(fs+1,W):
            if S[i][j] == '#':
                num += 1
            ans[i][j] = num
        num += 1
    else:
        no_itigo.append(i)
if no_itigo:
    yes_itigo = tuple(sorted(list(set(range(H))-set(no_itigo))))
    for i in range(yes_itigo[0]):
        ans[i] = ans[yes_itigo[0]]
    itigo_num = 0
    for i in range(yes_itigo[0]+1,H):
        if i in yes_itigo:
            itigo_num += 1
        else:
            ans[i] = ans[yes_itigo[itigo_num]]
for i in ans:
    print(' '.join(map(str,i)))

Measured memory_bytes: 7796
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long a[100010] = { 0 }, b[100010] = { 0 }, c[100010] = { 0 };
int main() {
    string s;
    cin >> s;
    int n = s.size();
    a[0] = 0;
    b[0] = 0;
    c[0] = 0;
    long long t = 1;
    for (int i = 0; i < n; i++) {
        if (s[i] != '?') {
            if (s[i] == 'A') {
                a[i + 1] += t;
            }
            else if (s[i] == 'B') {
                b[i + 1] += a[i];
            }
            else if (s[i] == 'C') {
                c[i + 1] += b[i];
            }
            a[i + 1] += a[i];
            b[i + 1] += b[i];
            c[i + 1] += c[i];
        }
        else {
            a[i + 1] += a[i] * 3;
            a[i + 1] += t;
            b[i + 1] += b[i] * 3;
            b[i + 1] += a[i];
            c[i + 1] += c[i] * 3;
            c[i + 1] += b[i];
            t *= 3;
        }
        a[i + 1] %= 1000000007;
        b[i + 1] %= 1000000007;
        c[i + 1] %= 1000000007;
        t %= 1000000007;
    }
    cout << c[n] % 1000000007 << endl;
}

Measured memory_bytes: 6096
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int64_t N;
std::string S;
void func(char now = 'a')
{
    if (S.size() == N) {
        out << S << '\n';
        return;
    }
    for (char c = 'a';c < now; ++c)
    {
        S.push_back(c);
        func(now);
        S.pop_back();
    }
    S.push_back(now);
    func(now+1);
    S.pop_back();
}

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);
    in >>N;
    func();

    return 0;
}
#endif


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

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    int ans = 1;
    for (int i = 1; i < N; i++) {
        if (s[i] != s[i-1]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
import sys

while True:
    n = int(sys.stdin.readline().rstrip())
    if n == 0:
        break;
    dic = {}
    for i in range(n):
        k,v = sys.stdin.readline().rstrip().split(' ')
        dic[k] = v
    n = int(sys.stdin.readline().rstrip())
    ret = []
    for i in range(n):
        d = sys.stdin.readline().rstrip()
        if d in dic.keys():
            ret.append(dic[d])
        else:
            ret.append(d)
    print(''.join(ret))

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

// clang-format off
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
// clang-format on

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

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

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (abs(a - b) % 2 != 0) {
        print("IMPOSSIBLE");
    } else {
        print((a + b) / 2);
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int > h;
vector<long> cost;


int solve(int i){
	if(i==0){
		cost[i]=0;
		return cost[i];
	}
	else if(i==1){
		cost[i]=abs(h[1]-h[0]);
	}
	else if(cost[i]!=-1)
		return cost[i];
	else{
		cost[i]=min(abs(h[i-1]-h[i])+solve(i-1),(abs(h[i-2]-h[i])+solve(i-2)));
		return cost[i];
	}

}


	
int main(){
	cin>>n;
	h.assign(n,0);
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	cost.assign(n,-1);
	cout<<solve(n-1);
	return 0;
}



Measured memory_bytes: 4480
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.size = [1] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
            self.size[x] += self.size[y]
            self.size[y] = 0
        else:
            self.par[x] = y
            self.size[y] += self.size[x]
            self.size[x] = 0
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

n, m = map(int,input().split())
edges = []
for i in range(m):
    a,b = map(int,input().split())
    edges.append([a-1,b-1])

uf = UnionFind(n)
point = n*(n-1)//2
ans = []

while edges:
    ans.append(point)
    a, b = edges.pop()
    pa = uf.find(a)
    pb = uf.find(b)
    if not uf.same_check(pa, pb):
        point -= (uf.size[pa] * uf.size[pb])
    uf.union(a,b)
print(*ans[::-1],sep="\n")


Measured memory_bytes: 26308
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> A >> B;
    for (int i = ceil(A / 0.08); i < (A + 1) / 0.08; i++) {
        if (B / 0.1 <= i && i < (B + 1) / 0.1) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <map>
#include <set>
#include <queue>

#define LL long long

using namespace std;

int n, a, b, c;

int main()
{
	//freopen("test_in.txt", "r", stdin);
	//freopen("test_out.txt", "w", stdout);
	cin>>a>>b>>c;
	if(a > b)	swap(a, b);
	if(b > c)	swap(b, c);
	if(a > b)	swap(a, b);
	//a <= b <= c
	int ans;
	if((c-a)%2 == 0 && (c-b)%2 == 0)
		ans = (c-a)/2 + (c-b)/2;
	else if((c-a)%2 != 0 && (c-b)%2 != 0)
		ans = (c-a)/2 + (c-b)/2 + 1;
	else
		ans = (c-a)/2 + (c-b)/2 + 2;
	cout<<ans<<endl;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    ll A[N];
    ll B[N][N]={};

    rep(i,N){
        ll r; cin>>r;
        rep(j,r){
            ll x,y; cin>>x>>y; --x;
            if(y==0) y=-1;
            B[i][x]=y;
        }
    }

    ll z=1<<N;
    ll ans=0;
    rep(i,z){
        bool flag=true;
        bool ins[N]={};
        ll buf=0;
        rep(j,N){
            ins[j]=(i>>j)&1;
            if(ins[j]) ++buf;
        }

        rep(j,N){
            if(!ins[j]) continue;
            rep(k,N){
                if(B[j][k]==-1 and ins[k]==true) flag=false;
                if(B[j][k]==1 and ins[k]==false) flag=false;
            }
        }

        if(flag){
            maxi(ans,buf);
        }
    }
    cout<< ans<<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
    "a" => "vowel",
    "z" => "consonant",
    "s" => "consonant"
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        c: String,
    }

    let vowel = ["a", "i", "u", "e", "o"];

    let ans = match vowel.iter().find(|&&x| x == c) {
        Some(_) => "vowel",
        None => "consonant"
    };

    ans.to_string()
}

Measured memory_bytes: 4352
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val Array(a, b, c) = sc.nextLine.split(" ").map(_.toInt)
    if (c < a | c > b) println("No")
    else println("Yes")
  }
}


Measured memory_bytes: 25548
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> x >> y >> k;

	if(x+k <= y-k+1){
		REP(i, x, x+k){
			cout << i << endl;
			}
		REP(i, y-k+1, y+1){
			cout << i << endl;
		}
	}
	else{
		REP(i, x, y+1){
			cout << i << endl;
		}
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m;
int deg[200005];
int dir[200005],depth[200005];
vector<int> g[200005];
vector<pair<int,int> > ans;
void dfs(int x,int fa){
    for(int i=0;i<g[x].size();i++){
    	int y=g[x][i];
		if(y==fa)	continue;
		if(!depth[y]){
            depth[y]=depth[x]+1;
            dfs(y,x);
        }
        else if(depth[y]<depth[x]){
            deg[x]^=1;
            ans.push_back(make_pair(x,g[x][i]));
        }
    }
    if(deg[x]&1){
        deg[x]^=1;
        ans.push_back(make_pair(x,fa));
    }
    else if(fa){
        deg[fa]^=1;
        ans.push_back(make_pair(fa,x));
    }
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int u,v;cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	if(m&1)	return puts("-1"),0;
	depth[1]=1;
	dfs(1,0);
	for(int i=0;i<ans.size();i++)
		cout<<ans[i].first<<" "<<ans[i].second<<endl;
	return 0;
}

Measured memory_bytes: 19828
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted([(j, i) for i, j in enumerate(a)])[::-1]
    dp = [0]
    for i in range(n):
        dp2 = [0]*(i+2)
        A, p = a[i]
        for j in range(i+1):
            right = n-i-1+j
            dp2[j] = max(dp2[j], dp[j]+abs(p-right)*A)
            dp2[j+1] = max(dp2[j+1], dp[j]+abs(p-j)*A)
        dp = dp2
    print(max(dp2))


main()


Measured memory_bytes: 9404
import java.util.*;
import java.lang.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer n = Integer.parseInt(scanner.next());
        Integer d = Integer.parseInt(scanner.next());
        Integer[][] x = new Integer[n][d];

        for(int i = 0; i < n; i++) {
            for(int j = 0; j <d; j++ ) {
                x[i][j] = Integer.parseInt(scanner.next());
            }
        }

        int count = 0;
        ArrayList<Integer> intList = new ArrayList<Integer>();
        for(int i =0; i < n; i++) {
            for(int j = i+1; j < n; j++) {
                int total = 0;
                for(int k = 0; k < d; k++) {
                    total += (int) Math.pow(x[i][k] - x[j][k], 2);
                }
                intList.add(total);
            }
        }

        count = 0;
        for (int i = 0; i < intList.size(); i++) {
            if ((Math.sqrt(intList.get(i)) == Math.floor(Math.sqrt(intList.get(i))))
                    && !Double.isInfinite(Math.sqrt(intList.get(i)))) {
                count++;
            }
        }

        System.out.println(count);
    }
}

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

using namespace std;

double frac(int n){
  if(n==1)return (double)1;
  return (double)n*frac(n-1);
}

int main(){
  double ret = 0;
  int n; cin >> n;
  vector<int> v(n);
  vector<pair<double,double>> vp(n);
  for(auto &x:vp){
    cin >> x.first >> x.second;
  }
  iota(v.begin(),v.end(),0);
  do{
    double cnt =0.0;
    for(int i=1;i<n;i++){
      double x2 = (vp[v[i]].first-vp[v[i-1]].first);
      x2*=x2;
      double y2 = (vp[v[i]].second-vp[v[i-1]].second);
      y2*=y2;
      cnt+=sqrt(x2+y2);
    }
    ret+=cnt;
  }while(next_permutation(v.begin(),v.end()));
  printf("%.12f\n",ret/frac(n));
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt(), c = scanner.nextInt(), x = scanner.nextInt();
			System.out.println(IntStream.rangeClosed(0, a)
					.map(i -> (int) IntStream.rangeClosed(0, b)
							.filter(j -> (x >= (i * 500 + j * 100)) && (x <= (i * 500 + j * 100 + c * 50))).count())
					.sum());
		}
	}
}


Measured memory_bytes: 36120
#include <stdio.h>
int main(void)
{
　int D;
　int N;
 　scanf("%d %d", &D,&N);
 　
if(N!=100){　
　switch(D){
　    case 0:
　       printf("%d",N);
　       break;
　   case 1:
　       printf("%d",100*N);
　       break;
　   case 2:
　       printf("%d",10000*N);
　       break;
　  default:break;
　}}
　else {switch(D){
　    case 0:
　       printf("%d",101);
　       break;
　    case 1:
　       printf("%d",10100);
　       break;
　   case 2:
　       printf("%d",1010000);
　       break;
　   default:break;
　}}
  return 0;
}
　

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
    string s; cin >> s;
    int n = s.size();
    
    string t1, t2;
    rep(i, n){
        t1.pb('0' + (i%2));
        t2.pb('0' + ((i+1)%2));
    }
    
    int cnt1 = 0;
    int cnt2 = 0;
    
    rep(i, n){
        if(s[i] != t1[i]) cnt1++;
        if(s[i] != t2[i]) cnt2++;
    }
    
    cout << min(cnt1, cnt2) << endl;
    return;
}

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

Measured memory_bytes: 3824
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.collections.ArrayList

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, q) = readIntegerList()
    val aList = readLongList()
    val fTree = FenwickTree(aList.toLongArray())
    repeat(q) {
        val (a, b, c) = readLongList()
        when (a) {
            0L -> fTree.add(b.toInt(), c)
            else -> out.println(fTree.sum(b.toInt(), c.toInt()))
        }
    }
}


/**
 * Fenwick tree(0-indexed).
 * https://github.com/da-louis/ac-library-kt/blob/master/src/main/kotlin/jp/atcoder/library/kotlin/fenwickTree/FenwickTree.kt
 *
 * convert from [AtCoderLibraryForJava - FenwickTree](https://github.com/NASU41/AtCoderLibraryForJava/blob/24160d880a5fc6d1caf9b95baa875e47fb568ef3/FenwickTree/FenwickTree.java)
 */
class FenwickTree(private val n: Int) {
    private val data: LongArray = LongArray(n)

    /**
     * Fenwick tree constructor.
     */
    constructor(data: LongArray) : this(data.size) {
        build(data)
    }

    /**
     * Add value x to p.
     */
    fun add(p: Int, x: Long) {
        var vp = p
        assert(vp in 0 until n)
        vp++
        while (vp <= n) {
            data[vp - 1] += x
            vp += vp and -vp
        }
    }

    /**
     * Calc sum [l, r].
     */
    fun sum(l: Int, r: Int): Long {
        assert(l in 0..r && r <= n)
        return sum(r) - sum(l)
    }

    private fun sum(r: Int): Long {
        var vr = r
        var s: Long = 0
        while (vr > 0) {
            s += data[vr - 1]
            vr -= vr and -vr
        }
        return s
    }

    private fun build(dat: LongArray) {
        System.arraycopy(dat, 0, data, 0, n)
        for (i in 1..n) {
            val p = i + (i and -i)
            if (p <= n) {
                data[p - 1] += data[i - 1]
            }
        }
    }
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 107800
n, m, x = map(int, input().split())
keep = []
ans = 10**10
for i in range(n):
    c = list(map(int, input().split()))
    keep.append(c)
for j in range(2**n):
    bag = [0] * m
    total = 0
    check = 1
    for k in range(n):
        if ((j >> k) & 1):
            for l in range(m):
                bag[l] += keep[k][l + 1]
            total += keep[k][0]
    for a in range(m):
        if bag[a] < x:
            check *= 0
    if ans * check > total:
        ans = total
if ans == 10**10:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9200
import java.util.Scanner;

public class Main {
	public static final int N=8;
	public static final int free=-1;
	public static final int not_free=1;

	static int row[]=new int [N];
	static int col[]=new int [N];
	static int dpos[]=new int [2*N-1];
	static int dneg[]=new int [2*N-1];
	static boolean x[][]=new boolean [N][N];

	public static void initialize(){
		for(int i=0;i<N;i++){
			row[i]=free;
			col[i]=free;
		}
		for(int i=0;i<2*N-1;i++){
			dpos[i]=free;
			dneg[i]=free;
		}
	}
	public static void print(){
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				if(x[i][j]){
					if(row[i]!=j){
						return;
					}
				}
			}
		}
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				if(row[i]==j){
					System.out.print("Q");
				}else{
					System.out.print(".");
				}
			}
			System.out.println();
		}
	}
	public static void solve(int i){
		if(i==N){
			print();
			return;
		}
		for(int j=0;j<N;j++){
			if(col[j]==not_free || dpos[i+j]==not_free || dneg[i-j+N-1]==not_free)
				continue;

			row[i]=j;
			col[j]=dpos[i+j]=dneg[i-j+N-1]=not_free;

			solve(i+1);

			row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=free;
		}
	}
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		initialize();
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				x[i][j]=false;
			}
		}
		int k=stdIn.nextInt();
		for(int i=0;i<k;i++){
			int r=stdIn.nextInt();
			int c=stdIn.nextInt();
			x[r][c]=true;
		}
		solve(0);
	}
}

Measured memory_bytes: 26272
s=input()
n=len(s)
# print(s[:int((n-1)/2)])
# print(s[int((n+3)/2):])
a=s[:(n-1)//2]
b=s[(n+3)//2-1:]

if s==s[::-1] and a==a[::-1] and b==b[::-1]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#ifndef ___Geometry_Library
#define ___Geometry_Library

// ------ Includes ------ //
#include <cmath>
#include <vector>
#include <complex>
#include <utility>
#include <algorithm>

// ------ Defines ------ //
typedef long double GType;
typedef std::complex<GType> Point;
typedef std::pair<Point, Point> Segment;

// ------ Constants ------ //
const GType EPS = 1.0e-10L;

// ------ Functions Level 1 ------ //
GType dot(const Point& p1, const Point& p2) {
	return (std::conj(p1) * p2).real();
}
GType cross(const Point& p1, const Point& p2) {
	return (std::conj(p1) * p2).imag();
}
int ccw(const Point& p1, const Point& p2, const Point& p3) {
	Point v1 = p2 - p1, v2 = p3 - p1;
	if (cross(v1, v2) > EPS) return +1;
	if (cross(v1, v2) < -EPS) return -1;
	if (dot(v1, v2) < -EPS) return +2;
	if (std::norm(v1) < std::norm(v2)) return -2;
	return 0;
}

// ------ Functions Level 3 ------ //
GType area(std::vector<Point> v) {
	GType ret = 0;
	for (int i = 0; i < v.size(); i++) {
		if (i + 1 != v.size()) ret += cross(v[i], v[i + 1]);
		else ret += cross(v[i], v[0]);
	}
	return std::abs(ret / 2);
}
int contain(std::vector<Point> v, Point p) {
	bool in = false;
	for (int i = 0; i < v.size(); i++) {
		Point a = v[i] - p, b = v[(i + 1 != v.size() ? i + 1 : 0)] - p;
		if (a.imag() > b.imag()) swap(a, b);
		if (a.imag() <= EPS && EPS < b.imag() && cross(a, b) < -EPS) in = !in;
		if (cross(a, b) == 0 && dot(a, b) <= 0) return 1;
	}
	return in ? 2 : 0;
}

#endif

#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, cx, cy;
int main() {
	while (cin >> n, n) {
		vector<Point> v(n);
		vector<int> sx, sy;
		for (int i = 0; i < n; i++) {
			cin >> cx >> cy;
			v[i] = Point(cx, cy);
			sx.push_back(cx);
			sy.push_back(cy);
		}
		vector<int> rx(4), ry(4);
		for (int i = 0; i < 4; i++) {
			cin >> rx[i] >> ry[i];
		}
		int xa = *min_element(rx.begin(), rx.end());
		int ya = *min_element(ry.begin(), ry.end());
		int xb = *max_element(rx.begin(), rx.end());
		int yb = *max_element(ry.begin(), ry.end());
		sx.push_back(xa);
		sy.push_back(ya);
		sx.push_back(xb);
		sy.push_back(yb);
		sort(sx.begin(), sx.end());
		sx.erase(unique(sx.begin(), sx.end()), sx.end());
		sort(sy.begin(), sy.end());
		sy.erase(unique(sy.begin(), sy.end()), sy.end());
		int ptlx = lower_bound(sx.begin(), sx.end(), xa) - sx.begin();
		int ptly = lower_bound(sy.begin(), sy.end(), ya) - sy.begin();
		int ptrx = lower_bound(sx.begin(), sx.end(), xb) - sx.begin();
		int ptry = lower_bound(sy.begin(), sy.end(), yb) - sy.begin();
		int ret = 0;
		for (int i = ptlx + 1; i <= ptrx; i++) {
			for (int j = ptly + 1; j <= ptry; j++) {
				double mx = (sx[i - 1] + sx[i]) * 0.5, my = (sy[j - 1] + sy[j]) * 0.5;
				if (contain(v, Point(mx, my))) ret += (sx[i] - sx[i - 1]) * (sy[j] - sy[j - 1]);
			}
		}
		int res = (int)(area(v) + 0.5);
		cout << res - ret << endl;
	}
	return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint comb(int a, int b){
	mint c=1, d=1, e=1;
	rep(i, a) c*=(i+1);
	rep(i, b) d*=(i+1);
	rep(i, a-b) e*=(i+1);

	return c/d/e;
}

int main(){
	int x, y;
	cin>>x>>y;

	mint ans=0;
	if((x+y)%3==0){
		int a=(x+y)/3;
		int b=x-a;
		if(0<=b && b<=a) ans=comb(a, b);
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3604
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int[] count, res;
    char[] ch;
    String str;
    int i, j, k;

    ch = new char[13]; count = new int[9]; res = new int[9];
    for(;sc.hasNext();){
      str = sc.next();
      for(i = 0;i < 9;i++){
        count[i] = 0; res[i] = 0;
      }
      for(i = 0;i < 13;i++){
        ch[i] = str.charAt(i);
        count[ch[i] - '1']++;
      }

      k = 0;
      for(i = 0;i < 9;i++){
        if(count[i] != 4){
          count[i]++;

          for(j = 0;j < 9;j++){
            if(count[j] >= 2){
              count[j] -= 2;
              if(count[j] >= 0 && (kotu(count, 4) || jyuntu(count, 4))){
                res[k++] = i + 1; count[j] += 2; break;
              }
              count[j] += 2;
            }
          }
          count[i]--;
        }
      }

      for(i = 0;i < k - 1;i++)out.print(res[i] + " ");
      out.println(res[i]);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }

  private static boolean kotu(int[] count, int t){
    int i, j;
    int[] c2;

    if(t == 0)return true;
    c2 = new int[9];
    for(i = 0;i < 9;i++)c2[i] = count[i];

    for(i = 0;i < 9;i++)if(c2[i] >= 3){
      c2[i] -= 3;
      return (kotu(c2, t - 1) || jyuntu(c2, t - 1));
    }

    return false;
  }
  private static boolean jyuntu(int[] count, int t){
    int i, j;
    int[] c2;

    if(t == 0)return true;
    c2 = new int[9];
    for(i = 0;i < 9;i++)c2[i] = count[i];

    for(i = 0;i < 7;i++){
      if(c2[i] > 0 && c2[i + 1] > 0 && c2[i + 2] > 0){
        c2[i]--; c2[i + 1]--; c2[i + 2]--;
        return (jyuntu(c2, t - 1) || kotu(c2, t - 1));
      }
    }
    return false;
  }
}

Measured memory_bytes: 21016
import kotlin.math.floor
import kotlin.math.sqrt

fun main(args: Array<String>) {
    val (n, d) = readIntList()
    val x = MutableList(n) { listOf<Int>() }
    for (i in 0 until n) {
        x[i] = readIntList()
    }

    var cnt = 0
    for (i in 0 until n) {
        for (j in i + 1 until n) {
            var tmp = 0.0
            for (k in 0 until d) {
                tmp += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k])
            }
            tmp = sqrt(tmp)
            if (tmp == floor(tmp)) {
                cnt++
            }
        }
    }
    println(cnt)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 36588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
#define repb(i, n) for (int i = (n - 1); i >= 0; i--)
#define repb2(i, a, n) for (int i = (n - 1); i >= (a); i--)
#define all(x) x.begin(), x.end()
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
inline void fastio() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
    fastio();
    int N;
    cin >> N;
    int pre_a = 0, ans = 0;
    rep(i, N) {
        int a;
        cin >> a;
        ans += max(0, a - pre_a);
        pre_a = a;
    }
    co(ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, count=0, ans1=0, ans2=0;
    string S;

    cin >> N >> S;

    for(i=0; i<N; i++){
        if(S[i]=='('){
            count++;
        }
        else if(S[i]==')'){
            if(count == 0){
                ans1++;
            }
            else{
                count--;
            }
        }
    }

    count = 0;
    for(i=N-1; i>=0; i--){
        if(S[i]==')'){
            count++;
        }
        else if(S[i]=='('){
            if(count == 0){
                ans2++;
            }
            else{
                count--;
            }
        }
    }

    if(ans1>=1){
        for(i=1; i<=ans1; i++){
            cout << '(';
        }
    }
    cout << S;
    if(ans2>=1){
        for(i=1; i<=ans2; i++){
            cout << ')';
        }
    }
    cout << endl;

    return 0;
}

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

int main(){

    int n;

    cin >> n;

    if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9){
        cout << "hon" << endl;
    }else if(n%10==0||n%10==1||n%10==6||n%10==8){
        cout << "pon" << endl;
    }else{
        cout << "bon" << endl;
    }

    //::system("pause");
    return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
	long long n,a,b;
	cin >>n>>a>>b;
	long long d=b-a;

	//d=(d!=0)?d:0;

	if(n!=1 and d >=0){
	cout<<(d*(n-2>0?n-2:0)+1)<<endl;
}
else if(n==1 and a==b){cout<<1<<endl;}else{
	cout<<0<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int min(ll a,ll b){
  if(a<b)
  return a;
  return b;
}
int main(){
  ll n,k;
  cin>>n>>k;
  vector<ll>v(n,0);
  int dp[100001];
  for(int i=0;i<100001;i++){
    dp[i]=INT_MAX;
  }
  dp[0]=0;
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<=i+k;j++){
      if(j<n){
        dp[j]=min(dp[j],dp[i]+abs(v[i]-v[j]));
      }
    }
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct node{
    int key;
    node* right;
    node* left;
    node* parent;
};

node *root;
//?????? node* NIL?????¶??¨NIL??£???NULL

//??????x??\???????°????
node* treeMinimum(node* x){
    while (x->left!=NULL)
        x=x->left;
    return x;
}

//????????????????????¶?????¨x????????????????????????????????????????°????
node* treeSuccessor(node* x){
    if(x->right!=NULL)
        return treeMinimum(x->right);
    //??\????????£????????¨x??????????????????????????????????¬?????????¶?????????
    //?????¨????????????????????????????????°????§???????
   //node* y=x->parent;
   // while(y!=NULL&&x==y->right){
        //x=y;
       // y=y->parent;
    //}
    //return y;
}

void treeDelete(node* z){
    //????????????????±?
    node* y;
    //y????????????
    node* x;

    //????????????????????????
    if(z->left==NULL||z->right==NULL)
        y=z;
    else
        y=treeSuccessor(z);

    //??????y????????????x???y????????????????????????
    if(y->left!=NULL)
        x=y->left;
    else
        x=y->right;

    //???x?????¶?????????????????????y?????¶??????
    if(x!=NULL)
        x->parent=y->parent;
    //??????y?????¶???????????\??????y???????????????x????????\??¶??????????????????
    //1. y????????????
    if(y->parent==NULL)
        root=x;
    //2. y?????¶??????????????????
    else if(y==y->parent->left)
        y->parent->left=x;
     //3. y?????¶??????????????????
    else
        y->parent->right=x;
    
    //
    if(y!=z)
        z->key=y->key;
    delete y;

}

//?????\
void insert(int k){
    node *y = NULL;
    node *x = root;
    node *z;

    z = new node;
    z->key=k;
    z->left=NULL;
    z->right=NULL;

    while(x!=NULL){
        y=x;
        if(z->key<x->key)
            x=x->left;
        else
            x=x->right;
    }

    z->parent=y;
    if(y==NULL)
        root=z;
    else{
        if(z->key<y->key)
            y->left=z;
        else
            y->right=z;
    }

}

//????´¢
node* find(node* u,int k){
    while(u!=NULL&&k!=u->key){
        if(k<u->key)
            u=u->left;
        else
            u=u->right;
    }
    return u;
}

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

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

int main(){
    int n,i,x;
    string com;

    scanf("%d",&n);

    for(i=0;i<n;i++){
        cin>>com;
        if(com[0]=='f'){
            scanf("%d",&x);
            node* t=find(root,x);
            if(t!=NULL)
                printf("yes\n");
            else
                printf("no\n");
        }
        else if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }
        else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        else if(com=="delete"){
            scanf("%d",&x);
            treeDelete(find(root,x));
        }
    }
}

Measured memory_bytes: 21940
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n: i64 = sc.input();
    let m: i64 = sc.input();
    let mut arr = vec![Vec::<i64>::new(); m as usize];
    for i in 0..m {
        let k: i64 = sc.input();
        for _ in 0..k {
            arr[i as usize].push(sc.input());
        }
    }
    let ps: Vec<i64> = sc.vec(m as usize);

    let mut ans = 0;
    for mask in 0..(1 << n) {
        let mut ok = true;
        for i in 0..m {
            let mut cnt = 0;
            for sw in &arr[i as usize] {
                if mask >> (sw - 1) & 1 == 1 {
                    cnt += 1;
                }
            }
            if cnt % 2 != ps[i as usize] {
                ok = false;
            }
        }
        if ok {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352