akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min, Ordering,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::num::{NonZeroU32, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Index, IndexMut, Mul, MulAssign, Neg, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,
    SubAssign,
};
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, multinomial, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, Num, NumAssignOps, NumOps, One, Pow, Zero};
use permutohedron::Heap;
use proconio::{
    fastout, input, is_stdin_empty,
    marker::{Bytes, Chars, Isize1, Usize1},
};
use rand::random;

pub const MOD10E9_7: usize = 1000000007;
pub const MOD99_: usize = 998244353;
pub const MAX: usize = std::usize::MAX;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 65;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize,
        mut f: [usize; n]
    }

    f.sort();

    let mut heap = BinaryHeap::new();
    heap.push(f.pop().unwrap());

    let mut ans = 0usize;

    for _ in 1..n {
        let p = f.pop().unwrap();
        ans += heap.pop().unwrap();
        heap.push(p);
        heap.push(p);
    }

    println!("{}", ans);
}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x,y,z; cin>>x>>y>>z;
  
  int res = (x-z)/(y+z);
  
  cout<<res;
  
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

using ll = long long;

int main()
{
    int N,K;
    cin >> N >> K;
    int x[100];
    for(int i = 0; i < N; ++i) cin >> x[i];
    int dist = 0;
    for(int i = 0; i < N; ++i){
        dist += 2*min(abs(K-x[i]), x[i]);
    }
    cout << dist << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define vec vector
#define pb push_back
#define s(x) scanf("%d",&x)
#define all(x)	x.begin(),x.end()
#define pii pair<int,int>
#define fi first
#define se second
#define mod 1000000007
#define SZ 200005
#define endl "\n"
#define trc(x) cerr << #x << ": " << x << endl
#define trcc(x,y) cerr << #x << ": " << x << endl << #y << ": " << y << endl << endl
#define boost ios::sync_with_stdio(0);cin.tie(0)

int n, m, k, x;



void purple18()
{
	string ss;
	cin>>ss;

	if(ss=="RRR") {
		cout << 3; 
	}
	else if(ss=="RRS" || ss=="SRR"){
		cout << 2;
	}
	else if(ss=="RSS" || ss=="SRS"||ss=="SSR" || ss=="RSR"){
		cout << 1;
	}
	else
	{
		cout << 0;
	}
	



}




signed main() {
	boost;
	int t=1;
	// cin>>t;
	while(t--) purple18();
}

Measured memory_bytes: 3552
#include <iostream>
#include <cstdio>
#include <list>
#include <cstring>


using namespace std;


int main()
{
    list<int> v;
    int n;
    scanf("%d",&n);
    char a[13];
    int b;
    char *str1="insert",*str2="delete",*str3="deleteFirst",*str4="deleteLast";
    while(n--)
    {
        scanf("%s",a);
        if(strcmp(a,str1)==0)
        {
            scanf("%d",&b);
            v.push_front(b);
        }
        else if(strcmp(a,str2)==0)
        {
            scanf("%d",&b);
            for(list<int>::iterator it=v.begin();it!=v.end();it++)
            {
                if(*it==b)
                {
                    v.erase(it);
                    break;
                }
            }
        }
        else if(strcmp(a,str3)==0)
        {
            v.pop_front();
        }
        else if(strcmp(a,str4)==0)
        {
            v.pop_back();
        }
    }

    int i=0;
    for(list<int>::iterator it=v.begin();it!=v.end();it++)
    {
        if(i++)
        {
            printf(" %d",*it);
        }
        else
        {
            printf("%d",*it);
        }

    }
    printf("\n");

    return 0;
}






Measured memory_bytes: 34472
lines = $stdin.read
array = lines.split("\n")

N,K = array[0].split(" ").map(&:to_i)
A   = array[1].split(" ").map(&:to_i)

ans = A.dup.inject(Hash.new(0)) { |h,v| h[v] += 1; h }

if ans.keys.length > K
  req = ans.keys.length - K
  ts = ans.sort_by {|_key, value| value}
  count = ts.take(req).map{|k,v| v}.inject(&:+)
  puts count
else
  puts 0
end


Measured memory_bytes: 45120
# 123456 * 2 以下の素数を列挙
MAX = 123456 * 2
prime = [True] * (MAX+1)
count = [0] * (MAX+1)
tmp = 0
prime[0] = False
prime[1] = False
for i in range(2, MAX+1):
    if prime[i]:
        tmp += 1
        for j in range(i * 2, MAX+1, i):
            prime[j] = False
    count[i] = tmp

# 個数出力
while True:
    n = int(input())
    if n == 0:
        break
    print(count[n * 2] - count[n])



Measured memory_bytes: 9876
#include <cstdio>
#include <vector>
#include <algorithm>

int n,m,c[100005];
std::vector<std::pair<int,int> > s[100005];

inline void Modify(int x,int v){for(;x<=m;x+=x&-x)c[x]+=v;}
inline int Query(int x,int s=0){for(;x;x^=x&-x)s+=c[x];return s;}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1,l,r;i<=n;++i)
    {
        scanf("%d%d",&l,&r);
        s[r-l+1].push_back(std::make_pair(l,r));
    }
    for(int d=1;d<=m;++d)
    {
        for(auto i:s[d])Modify(i.first,1),Modify(i.second+1,-1),--n;
        int Ans=n;
        for(int i=d;i<=m;i+=d)Ans+=Query(i);
        printf("%d\n",Ans);
    }
    return 0;
}

Measured memory_bytes: 7936
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		int size = readInt();
		for (int i = 0; i < size; i++) {
			boolean yes = false;
			int[] a = readInts();
			for (int j = 0; j < a.length; j++) {
				a[j] *= a[j];
			}
			for (int j = 0; j < a.length && !yes; j++) {
				yes = (a[j] == (a[(1 + j) % 3] + a[(2 + j) % 3]));
			}
			System.out.println(yes ? "YES" : "NO");
		}

	}

	static BufferedReader br = new BufferedReader(new InputStreamReader(
			System.in));

	private static int[] readInts() throws IOException {
		String readLine = br.readLine();
		if (readLine == null) {
			return null;
		}
		String[] s = readLine.split(" ");
		int[] result = new int[s.length];
		for (int i = 0; i < result.length; i++)
			result[i] = Integer.parseInt(s[i], 10);

		return result;
	}

	private static int readInt() throws IOException {
		return Integer.parseInt(br.readLine(), 10);
	}
}

Measured memory_bytes: 10000
a = []
b = []
ans = 'No'

for i in range(3):
    a.extend([int(s) for s in input().split()])
n = int(input())
for j in range(n):
    value = int(input())
    b.append(value)
    if value in a:
        a[a.index(value)] = '*'

if a[0] == a[1] == a[2] or a[3] == a[4] == a[5] or a[6] == a[7] == a[8] or a[0] == a[4] == a[8]:
    ans = 'Yes'
if a[0] == a[3] == a[6] or a[1] == a[4] == a[7] or a[2] == a[5] == a[8] or a[2] == a[4] == a[6]:
    ans = 'Yes'
print(ans)

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

long double a, n, t = 0.25, qq, hh, ss, dd;
long long q, h, s, d, ans;

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

    for (int i = 0; i < 4; ++i) {
        cin >> a;
        if (i == 0) {
            q = a;
        }
        else if (i == 1) {
            if (q * 2 < a) {
                h = q * 2;
            }
            else {
                h = a;
            }
        }
        else if (i == 2) {
            if (q * 4 > a and h * 2 > a) {
                s = a;
            }
            else if (q * 4 > h * 2 and a > h * 2) {
                s = h * 2;
            }
            else {
                s = q * 4;
            }
        }
        else {
            if (q * 8 > a and h * 4 > a and s * 2 > a) {
                d = a;
            }
            else if (a > q * 8 and h * 4 > q * 8 and s * 2 > q * 8) {
                d = q * 8;
            }
            else if (a > h * 4 and q * 8 > h * 4 and s * 2 > h * 4) {
                d = h * 4;
            }
            else {
                d = s * 2;
            }
        }
    }
    cin >> n;

    //cout << fixed;
    //cout.precision(20);

    while (n > 0.000) {
        //cout << n << endl;
        if (n - 2.0 >= 0.0) {
            ans += d;
            n -= 2.0;
            //cout << d << endl;
        }
        else if (n - 1.0 >= 0.0) {
            ans += s;
            n -= 1.0;
            //cout << s << endl;
        }
        else if (n - 0.5 >= 0.0) {
            ans += h;
            n -= 0.5;
            //cout << h << endl;
        }
        else {
            ans += q;
            n -= 0.25;
            //cout << q << endl;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine();
            var b = Console.ReadLine();
            for (int i = 0; i < b.Length; i++)
            {
                Console.Write("{0}{1}",a[i],b[i]);
            }
            if (a.Length > b.Length) Console.Write(a[a.Length-1]);
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 11220
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M, Q = MAP()
L = [LIST() for i in range(Q)]

ans = 0
A_list = list(combinations_with_replacement(range(1, M+1), N))
for A in A_list:
    tmp = 0
    for a, b, c, d in L:
        if A[b-1] - A[a-1] == c:
            tmp += d
    ans = max(tmp,ans)
print(ans)



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

cnt = 0
m,d = map(int, input().split())
for i in range(1, m+1):
        for j in range(11, d+1):
                d1 = j//10
                d2 = j%10
                if d1 * d2 == i and d1>1 and d2 > 1:
                        cnt += 1
print(cnt)


Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;
const long double PI=3.1415926535;

int main() {
  ll N;
  cin>>N;
  ll a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  ll ans=0,cnt=0,c=1;
  if(a[0]!=0){
    c=0;
  }
  for(int i=0;i<N;i++){
    if(i==N-1){
      ans+=a[i];
    }
    else if(a[i]+1==a[i+1]){
      cnt++;
    }
    else if(a[i]+1<a[i+1]){
      c=0;
      break;
    }
    else{
      ans+=a[i];
    }
  }
  if(c){
    cout<<ans;
  }
  else{
    cout<<-1;
  }
}

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

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

  vector<int> a(N);
  rep(i, N) cin >> a[i];

  vector<int> v;
  rep(i, N) rep(j, a[i]) v.push_back(i + 1);

  rep(i, H) {
    rep(j, W) {
      int k = j;
      if (i % 2 != 0)
        k = W - 1 - j;
      if (j != 0)
        cout << " ";
      cout << v[i * W + k];
    }
    cout << endl;
  }
}

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

int main(){
	int n;
	cin >> n;
	vector<int> w(n);

	int sum = 0;
	rep(i, n){
		cin >> w.at(i);
		sum += w.at(i);
	}

	int diff = sum;
	int totyu = 0;
	rep(i, n){
		totyu += w.at(i);
		diff = min(diff, abs(totyu - (sum - totyu)));
	}

	cout << diff << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int taka, aoki;
	taka = a / d;
	if (a % d != 0)	taka++;
	aoki = c / b;
	if (c % b != 0)	aoki++;
	if (taka < aoki)	cout << "No" << endl;
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

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

int main(){
    int a, b, x;
    cin >> a >> b >> x;
    if(a>x){
        cout << "NO" << endl;
        return 0;
    }
    if(a+b<x){
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
	long int n;
	long long int k;
	long long int a[100000];
	cin>>n>>k;
	long long int maxa=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		maxa=(maxa>a[i]?maxa:a[i]);
	}
	long long int counter=0;
	long long int poo=1;
	long long int b[1000];
	int maxe=0;
	long long int ki[100];
	for(int i=0;maxa>=poo||k>=poo;i++)
	{
		int count=0;
		for(int j=0;j<n;j++)
		{
			if((a[j]-(a[j]/(poo*2))*poo*2)/poo){count++;}else{}
		}
		b[i]=count;
		if((k-(k/(poo*2))*poo*2)/poo){ki[i]=1;}else{}
		poo=poo*2;
		maxe=i;
	}
	int eval=0;
	for(int i=maxe;i>=0;i--)
	{
		poo=poo/2;
		if(ki[i]==1){
			if(n<=2*b[i]){
				counter+=poo*b[i];eval=1;}
			else{counter+=(n-b[i])*poo;}
		}else if(eval==1){
				if(n<=2*b[i]){
				counter+=poo*b[i];eval=1;}
			else{counter+=(n-b[i])*poo;}
		}else {counter+=poo*b[i];}
	}
	cout<<counter;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())
#define AsceSort(a) sort(a.begin(),a.end())

using namespace std;
typedef long long ll;

int main(void) {
	int a, b, k;
	cin >> a >> b >> k;
	int exchange;
	REPS(i, k) {
		if (i % 2 != 0) {
			if (a % 2 != 0) {
				a--;
				b +=a/2;
				a = a / 2;
			}
			else {
				b += a / 2;
				a = a / 2;
			}
		}
		else {
			if (b % 2 != 0) {
				b--;
				a += b / 2;
				b = b / 2;
			}
			else {
				a += b / 2;
				b = b / 2;
			}
		}
	}
	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int m, n;
    int cnt;
    int i;
    int tmp;

    while (1){
        scanf("%d", &m);
        if (m == 0){
            break;
        }
        scanf("%d", &n);

        cnt = 0;

        for (i = m; i <= n; i++){
            tmp = i;

            while (tmp % 2 == 0){
                tmp /= 2;
            }
            while (tmp % 3 == 0){
                tmp /= 3;
            }
            while (tmp % 5 == 0){
                tmp /= 5;
            }
            if (tmp == 1){
                cnt++;
            }
        }
        printf("%d\n", cnt);
    }

    return (0);
}

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


void solve(long long N, long long M, std::vector<long long> A){
    priority_queue<long long> que;
    for(auto a: A) que.push(a);
    for(int i = 0; i < M; ++i){
        long long max_val = que.top();
        que.pop();
        que.push(max_val/2);
    }
    long long ans = 0;
    while(!que.empty()){
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 5044
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

struct Sieve {
	vector<bool> sieve;
	vector<long long> primes;
	Sieve(int n) : sieve(n*n) {
		for (unsigned i = 2; i < sieve.size(); ++i) if (!sieve[i]) {
			primes.push_back(i);
			if (i < n) for (unsigned j = i*i; j < sieve.size(); j += i) sieve[j] = true;
		}
	}
};

int N;
Sieve sie(317);
map<long long, long long> p2;

// Norm
long long f(long long n) {
	for (auto p : sie.primes) {
		auto p3 = p*p*p;
		if (n < p3) break;
		while (n % p3 == 0) {
			n /= p3;
		}
	}
	return n;
}

// Pair
long long g(long long n) {
	long long x = n;
	long long m = 1;
	for (auto p : sie.primes) {
		if (p*p*p > n) break;
		int c = 0;
		while (x % p == 0) {
			x /= p;
			++c;
		}
		if (c % 3 == 1) {
			m *= p * p;
		} else if (c % 3 == 2) {
			m *= p;
		}
	}
	m *= p2.count(x) ? p2[x] : x * x;
	return m;
}

int main() {
	for (auto p : sie.primes) {
		p2[p*p] = p;
	}
	cin >> N;
	int one = 0;
	map<long long, pair<int, int>> cnt;
	for (int i = 0; i < N; ++i) {
		long long si;
		cin >> si;
		long long y = f(si);
		long long z = g(si);
		if (y == 1) {
			one = 1;
		} else {
			if (y < z) ++cnt[y].first; else ++cnt[z].second;
		}
	}
	int r = one;
	for (auto p : cnt) {
		r += max(p.second.first, p.second.second);
	}
	cout << r << endl;
}


Measured memory_bytes: 7168
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        String s1 = sc.next(), s2 = sc.next();
        int n = Integer.parseInt(s1 + s2);
        for (int i = 1; i < n; i++) {
            if (i*i == n) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
int a[55];
int main ()
{
    int n,k;
    cin>>n>>k;
    for (int i =0;i<n;i++) cin>>a[i];
        sort(a,a+n);
    reverse (a,a+n);
    int res = 0;
    for (int i = 0; i<k;i++) res+=a[i];
        cout<<res<<endl;
    return 0;

}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_end().to_owned()
}

fn main() {
    let n = read!(usize);
    match n % 10 {
        2 | 4 | 5 | 7 | 9 => {
            println!("hon");
        },
        0 | 1 | 6 | 8 => {
            println!("pon");
        },
        _ => {
            println!("bon");
        }
    }
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
#define ll long long
#define Mod 1000000007

using namespace std;

int main() {
    ll n;cin>>n;
    ll a[n];for(ll i=0;i<n;i++)cin>>a[i];
    ll cnt=0;
    for(ll i=1;i<n-1;i++){
        if((a[i]>a[i-1] && a[i]<a[i+1]) || (a[i]<a[i-1] && a[i]>a[i+1]))cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]

i = 1
count = 0
find = False
for _ in range(N):
    count += 1
    i = A[i-1]
    if i == 2:
        find = True
        break

if find:
    print(count)
else:
    print(-1)

Measured memory_bytes: 7084
import java.util.Scanner;

class Main {

	Scanner sc = new Scanner(System.in);



	public int[][] dp=new int[11][350];
	public int dfs(int pos,int v,int bit){
		if(pos==11)return v==s?1:0;
		dp[pos][v]++;
		int res=0;
		for(int i=0;i<=9;i++){
			if(((bit>>i)&1)==0)
				res+=dfs(pos+1,v+(pos+1)*i,bit|(1<<i));
		}
		return res;
	}

	int n,s;
	public void run() {
		dfs(0,0,0);
		while(sc.hasNext()){
			n=sc.nextInt();s=sc.nextInt();
			if(s>=350)ln(0);
			else ln(dp[n][s]);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
	public static void pr(Object o) {
		System.out.print(o);
	}
	public static void ln(Object o) {
		System.out.println(o);
	}
	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 20228
#include <cstdio>
int main(){
    long long n,m;
    scanf("%lld %lld",&n,&m);
    long long ans=0;
    if(n<=m/2){
        m -= 2*n;
        ans += n+m/4;
    }else{
        ans += m/2;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
n,m = map(int,input().split())
A = []
B = []
for i in range(m):
  a,b = map(int,input().split())
  A.append(a)
  B.append(b)
for j in range(1,n+1):
  print(A.count(j)+B.count(j),end='\n')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
#define inf 1e9
#define F first
#define S second
#define dbg(x) cout<<#x<<" value : "<<x<<"\n";
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define rep__(i,j,k) for(int i = (j); i < (k); i++)
#define per(i,j,k) for(int i = (j); i >= (k); i--)
#define per__(i,j,k) for(int i = (j); i > (k); i--)
#define mst(a,b) memset(a,b,sizeof(a))
#define sf(n) scanf("%d",&n)
#define stf(n,m) scanf("%d%d",&n,&m)
#define pf(n) printf("%d\n",n)
#define slf(n) scanf("%lld",&n)
#define plf(n) printf("%lld\n",n)
priority_queue<int,vector<int>,less<int> > q;
const int N=1e3+10;
const int mod=1e9+7;
int n;
int a[N];
double sum;
int main()
{
	sf(n);
	rep(i,1,n)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	sum=((a[1]+a[2])/2.0);
	rep(i,3,n){
		sum=((a[i]+sum)/2.0);
	}
	printf("%.6f",sum);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define MP make_pair
#define PB push_back
#define ff first
#define ss second
#define TR(it,c) for( typeof(c.begin()) it = c.begin(); it != c.end(); ++it )
#define TRR(it,c) for( typeof(c.rbegin()) it = c.rbegin(); it != c.rend(); ++it
#define REP(i,a) for (int i = 0; i < (a); i++)
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)

#define DRI(a) int a; scanf("%d", &a);
#define DRII(a, b) int a, b; scanf("%d %d", &a, &b);
#define DRIII(a, b, c) int a, b, c; scanf("%d %d %d", &a, &b, &c);
#define RI(a) scanf("%d", &a);
#define RII(a, b) scanf("%d %d", &a, &b);
#define RIII(a, b, c) scanf("%d %d %d", &a, &b, &c);
#define MM(arr, num) memset((arr), (num), sizeof((arr)))
#define DEB(x) cerr << ">>> " << (#x) << " -> " << (x) << endl;
#define DEBA(x,n) cerr << (#x) << " "; deba((x),(n));
void deba(int * a, int n){ cerr << "| "; REP(i,n) cerr << a[i] << " "; cerr << "|" << endl;}


inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

const int INF = 1<<30;
typedef long long ll;
typedef unsigned long long ull;
/*******************************************************/

char ss[123456];

int main() {

  scanf("%s",ss);
  int len = strlen(ss);
  int w,e,s,n;
  w = s = e= n = 0;
  REP(i,len){
    if (ss[i] == 'W') w++;
    if (ss[i] == 'E') e++;
    if (ss[i] == 'N') n++;
    if (ss[i] == 'S') s++;
  }
  if (e && !w) cout << "No" << endl;
  else if (!e && w) cout << "No" << endl;
  else if (!s && n) cout << "No" << endl;
  else if (s && !n) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807

signed main()
{
  int x=0,y=0,z=0,w=0,n=1,m=0;
  string s;
  rep(i,3){
    std::cin >> x;
    y+=x;
  }
  std::cout << ((y>21)?"bust":"win") << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <fstream>
#include <sstream>
#include <math.h>
#include <memory>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <time.h>
#include <stdio.h>
#include <deque>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr
#define CHK(i,j)(i & (1 << j))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

int N, A;
int X[100];
ll dp[51][51][3010]; //i枚目までのカードでj枚選んで合計がkである組合せ

void solve() {
	ll ans = 0;
	dp[0][0][0] = 1;
	int c = 0;


	FOR(i, 0, N) FOR(j, 0, N) FOR(k, 0, 2500) if(dp[i][j][k]){
		dp[i + 1][j][k] += dp[i][j][k];
		dp[i + 1][j + 1][k + X[i]] += dp[i][j][k];
		//printf("%d %d %d  %ld\n", i, j, k, dp[i][j][k]);
	}

	FOR(j, 1 , N+1) {
		ans += dp[N][j][A*j];
	}

	cout << ans << endl;
}

int main() {
	cin >> N >> A;

	REP(i, N) {
		cin >> X[i];
	}

	solve();

	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
 
#define int long long 
#define pb emplace_back
#define all(s) s.begin(),s.end()
#define pii pair<int,int>
#define fr first
#define sc second
#define bst ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define no cout << "No" << endl;
#define yes cout << "Yes" << endl;

using namespace std;

const int N = 5e5 + 10, mod = 1e9 + 7, inf = 1e18 + 7, logn = 23;
const double pi = acos(-1);


void solve() {
	//soln
	int x;
	cin >> x;
	if(x >= 30) {
		yes;
	} else {
		no;
	}
}

main() {
	bst;
	int t = 1;
	//cin >> t;
	while(t--) {
		solve();
	}
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;
template <typename Int, Int MOD, int N>
struct comb_util {
	std::array<Int, N + 1> fc, ifc;

	comb_util() {
		fc[0] = 1;
		for (int i = 1; i <= N; i++) fc[i] = fc[i - 1] * i % MOD;
		ifc[N] = inv(fc[N]);
		for (int i = N - 1; i >= 0; i--) ifc[i] = ifc[i + 1] * (i + 1) % MOD;
	}

	Int fact(Int n) { return fc[n]; }

	Int inv_fact(Int n) { return ifc[n]; }

	Int inv(Int n) { return pow(n, MOD - 2); }

	Int pow(Int n, Int a) {
		Int res = 1, exp = n;
		for (; a; a /= 2) {
			if (a & 1) res = res * exp % MOD;
			exp = exp * exp % MOD;
		}
		return res;
	}

	Int perm(Int n, Int r) {
		if (r < 0 || n < r)
			return 0;
		else
			return fc[n] * ifc[n - r] % MOD;
	}

	Int binom(Int n, Int r) {
		if (n < 0 || r < 0 || n < r) return 0;
		return fc[n] * ifc[r] % MOD * ifc[n - r] % MOD;
	}

	Int homo(Int n, Int r) {
		if (n < 0 || r < 0) return 0;
		return r == 0 ? 1 : binom(n + r - 1, r);
	}
};

using comb = comb_util<long long, 1000000007, 3000000>;
comb cb;
vector<vector<int> > g;
int res = 0;
int N;
int dfs(int a, int p) {
	int sz = 1;
	int ans = cb.pow(2, N - 1);
	vector<int> X;
	for (int i : g[a]) {
		if (i != p) {
			int t = dfs(i, a);
			X.push_back(t);
			sz += t;
		}
	}
	X.push_back(N - sz);
	for (int i : X) {
		ans -= cb.pow(2, i) - 1;
	}
	ans--;
	ans %= MOD;
	ans += MOD;
	ans %= MOD;
	res = (res + ans) % MOD;
	return sz;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	g.resize(N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(0, -1);
	res = (res * cb.pow(cb.inv(2), N)) %MOD;
	cout << res << endl;
}


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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    //I don't care about anybody, and fuck ratings! I'll go to google!
    ll n, moves = 1000000000000000; cin>>n;
    bool prime = 1;
    for(ll i = 2; i*i<=n; i++){
        if(n%i==0){
            prime = 0;
            moves = min(moves, i+(n/i)-2);
        }
    }
    if(prime) cout<<n-1<<"\n";
    else cout<<moves<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

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

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int N; cin>>N;
    int s[N];
    int sum = 0;
    REP(i,N) {
        cin>>s[i];
        sum += s[i];
    }
    sort(s,s+N);
    if (sum%10!=0) {
        cout<<sum<<endl;
        return 0;
    }
    REP(i,N) {
        if ((sum-s[i])%10!=0) {
            cout<<sum-s[i]<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
int main(void)
{
  int l,i,j,con=0;
  char s[101],s1[51]={0},s2[51]={0};
  
  scanf("%s",s);
  l = strlen(s);
  j=l-1;
  for(i=0; i<=j; i++)
  {
    s1[i]=s[i];
    s2[i]=s[j];
    if(i==j) break;
    j--;
  }
  for(i=0; i<=j; i++)
  {
    if(s1[i]!=s2[i]) con++;
  }
  printf("%d\n",con);
  return 0;
}

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

int store[107];
int n;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> store[i];

    int cnt = store[1];

    for (int i = 2; i <= n; i++) {

        //cnt += store[i];

        if (store[i] > store[i-1]) cnt = (cnt + store[i]) - store[i-1];

    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
n = int(input())
a = [0]*n
x = [[0] *n for i in range(n)]
y = [[0] *n for i in range(n)]
ans = 0
for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        x[i][j],y[i][j] = map(int,input().split())
        x[i][j]-=1
def honest(i,j):
    return (i>>j)%2 ==1
def check(m):
    for i in range(n):
        if not honest(m,i) :continue
        for j in range(a[i]):
            if y[i][j] == 1 and honest(m,x[i][j]) == 0:
                return False
            if y[i][j] == 0 and honest(m,x[i][j]) == 1:
                return False
    return True
def count(c):
    cnt = 0
    for i in range(c//2+5):
        cnt+= (c >> i)%2
    return cnt
for i in range(2**n):
    if check(i):
        ans = max(ans,count(i))
    
        
        
        
print(ans)
        


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

int main() {
  int n;  cin >> n;
  vector<int> cards(n);
  for(int i = 0; i < n; i++){
    cin >> cards.at(i);
  }
  
  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());
  
  int alice = 0, bob = 0;
  for(int i = 0; i < n; i++){
    //cout << cards.at(i)<< endl;
    if(i%2==0)
      alice += cards.at(i);
    else
      bob += cards.at(i);
  }
  //cout << "Alice=" << alice << " Bob=" << bob << endl;
  cout << abs(alice - bob) << endl;
}


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

int main()
{
    int N;
    std::cin >> N;
    int sn=std::sqrt(N);
    while(!(N==sn*sn)){
        N--;
        sn=std::sqrt(N);
    }
    std::cout<<N<<std::endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> card(N);
  
  for (int i = 0; i < N; i++) {
    cin >> card.at(i);
  }
  
  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  
  bool ab = true;
  int Ap = 0;
  int Bp = 0;
  
  for (int i = 0; i < N; i++) {
    
    if (ab) {
      Ap += card.at(i);
      ab = false;
    }
    else {
      Bp += card.at(i);
      ab = true;
    }
  }
  
  cout << Ap - Bp << endl;
  
}

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String[] strArray = new String[n];

		for(int i = 0; i < strArray.length ;i++){
			strArray[i] = br.readLine();

			String[] strParseByHoshino = strArray[i].split("Hoshino",-1);

			//Hoshino???????????§?????????Hoshina??§???????????´???
			if(strParseByHoshino.length >= 2){
				for(int j = 0; j < strParseByHoshino.length ; j++){
					System.out.print(strParseByHoshino[j]);
					if(j < strParseByHoshino.length - 1){
						System.out.print("Hoshina");
					}
				}
				System.out.println();
			}
			else {
				System.out.println(strArray[i]);
			}
		}
	}

}

Measured memory_bytes: 24212
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;

#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rrep(i,N) for(int i=(int)(N)-1;i>=0;--i)
#define debug(x) cout<<#x<<"="<<x<<endl;
constexpr ll MOD=1000000007;
constexpr ll INF=1LL<<60;
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;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
    int w,d;
    while((cin>>w>>d,w|d)){
        int W[21],D[21];
        rep(i,21){W[i]=0;D[i]=0;}
        rep(i,w){
            int h;cin>>h;
            W[h]++;
        }
        rep(i,d){
            int h;cin>>h;
            D[h]++;
        }
        int res=0;
        rrep(i,21){
            res+=max(D[i],W[i])*i;
        }
        cout<<res<<endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n, k;
	cin >> n;
	cin >> k;
	int curr = 1;

	for(int i = 0; i < n;i++){
		if(curr < k) curr *= 2;
		else curr += k;
	}

	cout << curr << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll roundd(ll x,ll n){
  if(x>n){return x%n;}
  else if(x<0){return x%n+n;}
  else return x;
}
ll gcd(ll a,ll b){
   if (a%b == 0){
        return(b);
    }
    
   else{
       return(gcd(b, a%b));
    }
}
int main(){
  ll n;cin>>n;
  vector<vp> g(n);
  rep(i,0,n-1){
    ll u,v,w;cin>>u>>v>>w;
    u--;v--;
    g[u].push_back(make_pair(v,w%2));
    g[v].push_back(make_pair(u,w%2));
  }
  vll cost(n,-1);
  cost[0]=0;
  queue<ll> q;
  q.push(0);
  while(!q.empty()){
    ll tmp=q.front();
    q.pop();
    for(auto u:g[tmp]){
      if(cost[u.first]==-1){
        q.push(u.first);
        cost[u.first]=cost[tmp]+u.second;
        cost[u.first]%=2;
      }
    }
  }
  rep(i,0,n){
    cout<<cost[i]%2<<endl;
  }

}



Measured memory_bytes: 11396
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        int l = s.length();

        if((l%2==0 && s.charAt(0)==s.charAt(l-1)) || (l%2!=0 && s.charAt(0)!=s.charAt(l-1))){
            System.out.println("First");
        }
        else{
            System.out.println("Second");
        }
    }
}

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

void BubbleSort(int *a, size_t n, int *swapCount)
{
	for (int i = 0; i < n - 1; i++)
		for (int j = n - 1; j > i; j--)
		{
			if (a[j] < a[j-1])
			{
				int tmp = a[j];
				a[j] = a[j-1];
				a[j-1] = tmp;
				
				(*swapCount)++;
			}
		}
}
void Print(int *a, size_t n)
{
	for (int i = 0; i < n; i++)
	{
		cout << a[i];
		if (i == n-1)
			cout << endl;
		else
			cout << " ";
	}
}
int main()
{
	int swapCount = 0;
	int a[100] = {0};
	int n;
	
	cin >> n;
	
	int v;
	for (int i = 0; i < n; i++)
	{
		cin >> v;
		a[i] = v;
	}
	BubbleSort(a, n, &swapCount);
	Print(a, n);
	cout << swapCount << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

long long powmod(long long a,long long b){
    long long c=1;
    while(b>0){
        if(b&1) c=a*c%mod;
        a=a*a%mod;
        b>>=1;
    }
    return c;
}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,k,a;
	cin >> n >> k;
	rep(i,n) cin >> a;
	n--;
	k--;
	cout << (n%k?n/k+1:n/k) << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def solve(N):

    ans = 0
    for x in range(1, N + 1):
        y = int(N / x)
        ans += y * (y + 1) * x // 2

    return ans


def main():

    N = in_n()
    print(solve(N))


def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', '(i4,)')(solve)
    cc.compile()


if __name__ == '__main__':
    import sys
    if sys.argv[-1] == 'ONLINE_JUDGE':
        cc_export()
        exit(0)
    from my_module import solve
    main()


Measured memory_bytes: 27312
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>

using namespace std;

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

typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	char str[128];
	map<int, int> data;
	while(fgets(str, 128, stdin), str[0] != '\n'){
		int a, b;
		sscanf(str, "%d,%d", &a, &b);

		if(data.count(a))
			data[a]--;
		else
			data[a] = -1;
	}

	while(fgets(str, 128, stdin) != NULL){
		int a, b;
		sscanf(str, "%d,%d", &a, &b);
		if(data.count(a))
			data[a] = abs(data[a]) + 1;
	}

	for(map<int,int>::iterator itr = data.begin(); itr != data.end(); ++itr){
		if(itr->second < 0)
			continue;
		printf("%d %d\n", itr->first, itr->second);
	}

	return 0;
}

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

int main()
{
  ll n, k; cin>>n>>k;
  vector<ll> v(100010, 0);
  rep(i, n) {
    ll a,b; cin>>a>>b;
    v[a] += b;
  }
  for (int i=1; i<=100000; i++) {
    if (k <= v[i]) {
      cout << i << endl;
      break;
    }
    k -= v[i];
  }

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_N 101
#define MAX_V 203

using namespace std;

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

struct edge { int to, cap, rev; };

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap) {
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}

int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    for (int i = 0; i < G[v].size(); ++i) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t) {
    int flow = 0;
    for(;;) {
        fill(used, used + MAX_V, false);
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
}

int main() {
    int N;
    cin >> N;
    int a[MAX_N], b[MAX_N], c[MAX_N], d[MAX_N];
    for (int i = 0; i < N; ++i) {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> c[i] >> d[i];
    }
    
    int s = 2 * N, t = s + 1;
    
    for (int i = 0; i < N; ++i) {
        add_edge(s, i, 1);
    }
    for (int j = 0; j < N; ++j) {
        add_edge(j + N, t, 1);
    }
    
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (a[i] < c[j] && b[i] < d[j]) {
                add_edge(i, j + N, 1);
            }
        }
    }
    
    cout << max_flow(s, t) << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  int result = 0;
  if (A > K)
  {
    result += K;
    K = 0;
  }
  else
  {
    result += A;
    K -= A;
  }

  if (B > K)
  {
    K = 0;
  }
  else
  {
    K -= B;
  }

  result -= K;

  cout << result << endl;
}


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

int main(void)
{
     char str2[4];
     char str[4];
     int i=0;

	scanf("%s", str);

     i = strlen(str);

	if(i==2){
     printf("%s",str);
	}else{
     str2[2]=str[0];
     str2[1]=str[1];
     str2[0]=str[2];
     printf("%s",str2);
	}
     return 0;

}




Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n;
  cin >> n;

  string s = to_string(n);
  ll mod = 0;
  for(char c : s) {
    mod += c - '0';
  }

  if (n % mod == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3680
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll MOD=1000000007;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int n;
ll dp[2005];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	dp[0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;i-j>=3;j++)
		{
			dp[i]+=dp[j];
			dp[i]%=MOD;
		}
	}
	cout<<dp[n];
	return 0;
}


Measured memory_bytes: 3648