akhauriyash/Code-Regression huggingface dataset:
N, M = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(N - 1 + M)]

from collections import defaultdict

nodes = list(range(1, N + 1))
edges = defaultdict(set)
rev_edges = defaultdict(set)

for a, b in AB:
    edges[a].add(b)
    rev_edges[b].add(a)

#print(vs)
#print(ws)

def TopologicalSort(nodes, edges, rev_edges):
    '''
    nodes     ... Node[]
    edges     ... Dict[From Node](To Node)
    rev_edges ... Dict[To Node](From Node)
    '''
    rev_edges_num = dict((n, len(rev_edges[n])) for n in nodes)
    L = []
    S = [n for n in nodes if not rev_edges_num[n]]
    while S:
        n = S.pop()
        L.append(n)
        for m in edges[n]:
            rev_edges_num[m] -= 1
            if not rev_edges_num[m]:
                S.append(m)
    
    # プロコン用なのでエラーチェックはしない

    return L

L = TopologicalSort(nodes, edges, rev_edges)

nrank = dict((n, r) for r, n in enumerate(L))

for n in range(1, N + 1):
    r = 0
    if rev_edges[n]:
        r = sorted(rev_edges[n], key=lambda x:nrank[x], reverse=True)[0]
    print(r)


Measured memory_bytes: 103188
use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    writeln!(output, "{}", buf.trim_right().replace("2017", "2018")).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "2017/01/07\n",
            "2018/01/07\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "2017/01/31\n",
            "2018/01/31\n",
        );
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()



using namespace std;



int main() {
  int N,M; cin>>N>>M;
  int ans = 0;
  ans += N*(N-1)/2;
  ans += M*(M-1)/2;
  
  //if(N %2 == M%2) ans += N * M;

 
cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int total = scan.nextInt();
		String hat = scan.next();
		int result = 0;

		Pattern p = Pattern.compile("R");
		Matcher m = p.matcher(hat);

		while (m.find()) {
			result++;
		}

		System.out.println(total / 2 < result ? "Yes" : "No");
	}
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
int gcd(int a, int b) 
{ 
	if (a == 0) 
		return b; 
	return gcd(b % a, a); 
} 
int invertBits(int num) 
{  
    int x = log2(num) + 1; 
    for (int i = 0; i < x; i++)  
       num = (num ^ (1 << i));  
   
    return num; 
} 
///////////////////////////////////////////////////////////////////////////////////////////////////////////
ll int m[101][100001];
ll int solve(ll int a[][2],ll int n,ll int curr,ll int rem)
{
	//cout<<curr<<" ";
	ll int wt=a[curr][0];
	if(m[curr][rem]!=0)
	{
		return m[curr][rem];
	}
	if(rem==0)
	{
		return 0;
	}
	if(curr==n-1)
	{
		if(a[curr][0]<=rem)
		{
			return a[curr][1];
		}
		else
		{
			return 0;
		}
	}
	ll int a1=0,a2=0;
	if(a[curr][0]<=rem)
	{
		a1=solve(a,n,curr+1,rem-a[curr][0])+a[curr][1];	
		a2=solve(a,n,curr+1,rem);
		a1=max(a1,a2);
	}
	else
	{
		a1=solve(a,n,curr+1,rem);
	}
	return m[curr][rem]=a1;
}
int main()
{
	ll int w,n,i,j;
	cin>>n>>w;
	memset(m,0,sizeof(m));
   	ll int a[n][2];
   	for(i=0;i<n;i++)
   	{
   		cin>>a[i][0]>>a[i][1];
	}
	cout<<solve(a,n,0,w);
	return 0;
}

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

int main(){
  int A, B;
  cin >> A >> B;

  int count = 0;

  for(int i = A; i < B + 1; i++){

    int copy = i;
    int original = i;

    // iの桁数を計算する
    int ten = 10;
    int digit = 1;
    while(copy / ten >= 1){
      ten *= 10;
      digit++;
    }
    
    // iを反転した値を計算する
    int divide = 1;
    for(int j = 1; j < digit; j++){
      divide *= 10;
    }
    
    int sum = 0;
    int multiply = 1;
    for(int j = digit; j >= 1; j--){
      int palindromic = copy / divide;
      sum += palindromic * multiply;
      
      multiply *= 10;
      
      copy %= divide;
      
      divide /= 10;
    }

    if(original == sum){
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3576
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner;


$N = $sc->nextInt();
$cake = 4;
$donuts = 7;
$sum = 0;
for ($i = 0; $i <= 100 / $donuts; $i++) {
    for ($j = 0; $j <= 100 / $cake; $j++) {
      $sum = $cake * $j + $donuts * $i;
      if ($sum === $N){
          $flag = true;
          break 2;
      }
    }
}

echo $flag ? 'Yes' : 'No';

Measured memory_bytes: 4732
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! 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")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
    }
    println!("{}", k * (k - 1).pow(n as u32 - 1))
}

// fn main() {
//     input! {
//         h: usize,
//         w: usize,
//         s: [chars; h]
//     }
//     let xy = [
//         // [-1i32, 1i32],
//         [0i32, 1i32],
//         // [1i32, 1i32],
//         [-1i32, 0i32],
//         [1i32, 0i32],
//         // [-1i32, -1i32],
//         [0i32, -1i32],
//         // [1i32, -1i32],
//     ];
//     let mut s = s;
//     for y in 0..h {
//         for x in 0..w {
//             if s[y][x] == '.' {
//                 continue;
//             }
//             let mut b = false;
//             for i in 0..4 {
//                 let xx = x as i32 + xy[i][0] as i32;
//                 let yy = y as i32 + xy[i][1] as i32;
//                 if xx < 0 || w as i32 <= xx {
//                     continue;
//                 }
//                 if yy < 0 || h as i32 <= yy {
//                     continue;
//                 }
//                 if s[yy as usize][xx as usize] == '#' {
//                     b = true;
//                 }
//             }
//             if !b {
//                 println!("No");
//                 return;
//             }
//         }
//     }
//     println!("Yes")
// }


Measured memory_bytes: 4352
a,b,c = (int(i) for i in input().split())
if a==b==c and a%2==0: print(-1)
else:
	answer = 0
	while all(i%2==0 for i in [a,b,c]):
		a,b,c = (b+c)//2,(c+a)//2,(a+b)//2
		answer += 1
	print(answer)

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

int N;
string S[200010];

int main()
{
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        cin >> S[i];
    }
    sort(S, S + N);
    int res = 1;
    for(int i = 0; i < N - 1; i++)
    {
        if(S[i] != S[i + 1]) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 9888
#include <stdio.h>
long long a, b, k;
int main() {
	scanf("%lld%lld%lld", &a, &b, &k);
	if (a < k) {
		k -= a;
		a = 0;
	}
	else {
		a -= k;
		k = 0;
	}
	if (b < k) {
		b = 0;
	}
	else {
		b -= k;
	}
	printf("%lld %lld\n", a, b);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;
int n, a[25], mark, cnt=0;
int main()
{
	cin>>n;
	for(int i=1; i<=n; i++)
		cin>>a[i];
	for(int i=2; i<n; i++)
	{
		if(a[i]>a[i-1]&&a[i]<a[i+1])
			cnt++;
		else if(a[i]<a[i-1]&&a[i]>a[i+1])
			cnt++;
		else
			continue;
	}
	cout<<cnt<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

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

    ll left = 0, right = N - 1;
    ll cnt = 0;
    while(left < right) {
        while(C[left] == 'R' && left < right) ++left;
        while(C[right] == 'W' && left < right) --right;
        if(left >= right) break;
        C[left] = 'R';
        C[right] = 'W';
        ++cnt;
    }
    
    PR(cnt);


    return 0;
}

/*



*/

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

int N;
string S, ans;

bool attempt(string init) {
	ans = init;
	for (int i = 2; i < N; i++) {
		if (ans[i - 1] == 'S') {
			if (S[i - 1] == 'o') ans += ans[i - 2];
			else {
				if (ans[i - 2] == 'S') ans += 'W';
				else ans += 'S';
			}
		} else {
			if (S[i - 1] == 'x') ans += ans[i - 2];
			else {
				if (ans[i - 2] == 'S') ans += 'W';
				else ans += 'S';
			}
		}
	}
//	printf("generated %s\n", ans.c_str());
	
	if (ans[S.length() - 1] == 'S') {
		if (S[S.length() - 1] == 'o' && ans[S.length() - 2] != ans[0]) return 0;
		if (S[S.length() - 1] == 'x' && ans[S.length() - 2] == ans[0]) return 0;
	} else {
		if (S[S.length() - 1] == 'o' && ans[S.length() - 2] == ans[0]) return 0;
		if (S[S.length() - 1] == 'x' && ans[S.length() - 2] != ans[0]) return 0;
	}
	//printf("meow\n");
	if (ans[0] == 'S') {
		if (S[0] == 'o' && ans[S.length() - 1] != ans[1]) return 0;
		if (S[0] == 'x' && ans[S.length() - 1] == ans[1]) return 0;
	} else {
		if (S[0] == 'o' && ans[S.length() - 1] == ans[1]) return 0;
		if (S[0] == 'x' && ans[S.length() - 1] != ans[1]) return 0;
	}
	printf("%s\n", ans.c_str());
	return 1;
}

int main() {
	scanf("%d", &N);
	cin >> S;
	if (attempt("SS")) return 0;
	if (attempt("SW")) return 0;
	if (attempt("WS")) return 0;
	if (attempt("WW")) return 0;
	printf("-1\n");
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define all(x) (x).begin(),(x).end()
#define print(x) if(x)cout<<"YES\n";else cout<<"NO\n";
#define f(i,x,y) for(ll i=x;i<=y;i++)
#define rf(i,x,y) for(ll i=x;i>=y;i--)
#define pb push_back
#define F first
#define S second
using namespace std;
int main()
{
// #ifndef HP
//   freopen("in.txt", "r", stdin);
//   freopen("out.txt", "w", stdout);
// #endif

  fastio;
  int t = 1;
  //cin >> t;
  while (t--)
  {
    string s;
    cin >> s;
    if (s[s.size() - 1] == 's')
      s += "es";
    else
      s += "s";
    cout << s << endl;
  }
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int kase,n,a[200010],num[200010];
long long sum=0;
void merge(int l,int r)
{
//	cout<<l<<" "<<r<<endl;
	int m=l+(r-l)/2;
	if(r-l<1)return;
	for(int i=l;i<=r;i++)num[i]=a[i];
	sort(num+l,num+m+1,greater<int>());
    sort(num+m+1,num+r+1,greater<int>());
    for(int i=l,j=m+1;i<=m&&j<=r;i++)
    {
    	while(num[i]<=num[j]&&j<=r)j++;
    	sum+=r-j+1;
    //	cout<<i<<j<<sum<<endl;
	}
	merge(l,m);
	merge(m+1,r);
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) 	cin>>a[i];
	merge(1,n);
	cout<<sum<<endl;
	
}


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

using namespace std;
using ll = long long;
ll n,k, a[300005],f[300005];
bool check(ll time){
    ll need=0;
    for(int i=0;i<n;i++){
        if(a[i]*f[i] > time){
                need = need + (a[i] - (time/f[i]));
        }
    }
    if(need<=k)
        return true;
    else    return false;
}
int main() {
    
    cin>>n>>k;
    for(int i=0;i<n;i++)    cin>>a[i];
    for(int i=0;i<n;i++)    cin>>f[i];
    sort(a,a+n);
    sort(f,f+n,greater<ll>());
    ll l=0,h=1e18,mid;
    while(l+1<h){
        mid=(l+h)/2;
        if(check(mid)){
            h=mid;
        }
        else{
            l=mid;
        }
    }
    if(check(min(l,h))) cout<<min(l,h);
    else    cout<<max(l,h);
}

Measured memory_bytes: 3840
input_line = input().split()

num_array = int(input_line[0])
num_equal = int(input_line[1])

input_line = input()
array_str = input_line.split()

array = list(map(int, array_str))

for index, number in enumerate(array):
    if number == 1:
        index_min = index
        break

# from forward

equalized = 1
i = 1
while equalized < num_array:
    equalized += (num_equal - 1)
    # print(i, equalized)
    i += 1

print(i - 1)


Measured memory_bytes: 14584
#include<iostream>
using namespace std;
int a[100000], n, k, m, r;
void Div(int l, int s) {
	int p = l * 10, q = s;
	for (int i = 0; i < r + 10; i++) {
		a[i] += p / q; p = p%q; p *= 10;
	}
	for (int i = r + 10; i >= 1; i--) {
		if (a[i] >= 10) { a[i - 1] += a[i] / 10; a[i] %= 10; }
	}
}
int main() {
	while (true) {
		for (int i = 0; i < 10200; i++)a[i] = 0;
		cin >> n >> k >> m >> r; if (n == 0)break;
		Div(1, n);
		if (m == 1) { for (int i = 1; i < n; i++) { Div(1, n*i); } }
		cout << a[0] / 10 << '.'; for (int i = 0; i < r; i++)cout << a[i] % 10; cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3040
require 'pp'

def gets; ARGF.gets; end

class Solver

  def main
    a = gets.chomp.to_i
    b = gets.chomp.to_i

    if a > b
      puts "GREATER"
    elsif a == b
      puts "EQUAL"
    else
      puts "LESS"
    end
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 2172
def solve(n, m, ABC):
    distance = [None] * n
    distance[0] = 0

    for _ in range(n - 1):
        for a, b, c in ABC:
            if distance[a - 1] is None:
                continue
            if distance[b - 1] is None or distance[b - 1] < distance[a - 1] + c:
                distance[b - 1] = distance[a - 1] + c

    for _ in range(n - 1):
        for a, b, c in ABC:
            if distance[a - 1] is None or distance[b - 1] is None:
                continue
            if distance[b - 1] < distance[a - 1] + c:
                distance[b - 1] = distance[a - 1] + c
                if b == n:
                    return 'inf'

    return distance[n - 1]

_n, _m = map(int, input().split())
_ABC = [list(map(int, input().split())) for _ in range(_m)]
print(solve(_n, _m, _ABC))


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define     fast                    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define     ll                      long long
#define     pb                      push_back
#define     M                       1000000007
using namespace std;
int main()
{
    ll n,x,y,sum=0;
    cin>>x>>y;
    if(x<10 && y<10) cout<<x*y<<endl;
    else cout<<"-1"<<endl;

}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
string s,t;
int dp[2011][2011];
int used[2011][2011];
string solve(){
  string ans="";
  int i=s.size()-1;
  int j=t.size()-1;
  while(i>0&&j>0){
    if(used[i][j]==1)ans+=t[j],i--,j--;
    else if(used[i][j]==2)i--;
    else j--;
  }
  return ans;
}
int main(){
  while(cin>>s){
    memset(dp,0,sizeof(dp));
    memset(used,0,sizeof(used));
    t=s;
    reverse(s.begin(),s.end());
    t="@"+t;
    s="@"+s;
    for(int i=1;i<s.size();i++)
      for(int j=1;j<t.size();j++)
    if(s[i]==t[j]){
      if(dp[i-1][j]>=dp[i-1][j-1]+1) dp[i][j]=max(dp[i][j],dp[i-1][j]),used[i][j]=2;
       
      else dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1),used[i][j]=1;
    }
        else{
      if(dp[i-1][j]>=dp[i][j-1])dp[i][j]=max(dp[i][j],dp[i-1][j]),used[i][j]=2;
      else dp[i][j]=max(dp[i][j],dp[i][j-1]),used[i][j]=3;
    }
    cout<<solve()<<endl;
  }
}

Measured memory_bytes: 34612
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n != 0) {
		sum += n % 10; n /= 10;
	}
	return sum;//Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	Rapid_pleaseAC_fast;
	llint k;
	vint s = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	cin >> k;
	cout << s.at(k-1) << endl;
	please AC;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			int X = sc.nextInt(), A = sc.nextInt(), B = sc.nextInt();
			if(A >= B){
				System.out.println("delicious");
			}else if(B - A <= X){
				System.out.println("safe");
			}else{
				System.out.println("dangerous");
			}
		}
	}
}


Measured memory_bytes: 21972
K = int(input())
TMP = K

RW = list(input())
W=0
cnt=0

#print(RW)

while K >=0:
    if RW[K-1]=='W':
        K=K-1
        continue
    else:
        while W<K:
           # print(W,K)
            if RW[W]=="W":
                RW[K-1], RW[W] = RW[W], RW[K-1]
                #print(RW)
                cnt += 1
                # K=K-1
                break
            else:
                W=W+1
        K=K-1
        
#print(cnt)
K=TMP
sw = False
while K >=1:
    if sw == False:
        if RW[K-1]=="R":
            sw = True
    else:
        if RW[K-1]=="W":
            cnt += 1
            #print(cnt,K)

    K=K-1

print(cnt)

Measured memory_bytes: 10744
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <cmath>

using namespace std;

int totalNum(vector<int> A, int i){
    //タイムオーバーしたうんコード
    int total = 0;

    if(i == 1){
        A[0] = 0;
    }else if(i == A.size()){
        A[A.size() - 1] = A[A.size() - 2];
    }else{
        A[i - 1] = A[i - 2];
    }

    total += abs( A[A.size() - 1] - 0);
    total += abs( A[0] - 0);
    for(int j = 1; j < A.size(); j++){
        //std::cout << A[j];
        total += abs( A[j] - A[j-1]);
    }
    //std::cout << std::endl;

    return total;
}

int main(){

    int N = 0;
    cin >> N;
    vector<int> A(N, 0);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    int total = 0;
    A.push_back(0);
    A.insert(A.begin(),0);
    //for(int i = 0; i < A.size(); i++){
    //    std::cout << A[i];
    //}
    //std::cout << std::endl;

    for(int i = 1; i < A.size(); i++){
        //std::cout << totalNum(A, i) << std::endl;
        total += abs( A[i] - A[i - 1] ); 
    }

    //std::cout << total << std::endl;

    for(int i = 1; i <=N; i++){
        std::cout << total + abs(A[i-1] - A[i+1]) - (abs(A[i-1] - A[i]) + abs(A[i] - A[i+1])) << std::endl;
    }


    //std::sort(ABC.begin(),ABC.end());
    //int i = 0;

}

Measured memory_bytes: 1656
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]

INF = float('inf')

def dfs(cur, a, b, c):
    if cur == N:
        if min(a, b, c) > 0:
            return abs(a -A) + abs(b - B) + abs(c - C) - 30
        else:
            return INF

    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 9256
#include <stdio.h>

int main(void)
{
    int n, i; 
    scanf("%d", &n);

    int a[n];
    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    
    for(i = n - 1; i >= 0; i--){
        printf("%d", a[i]);
        if(i){
            printf(" ");
        }
    }
    printf("\n");

    return 0;
}


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

    int H;
    int P[10][5]; //パズル
    int score; //総得点
    int check; //連続した玉があるか

void renzoku_check() 
{
    for (int i = 0; i < H; i++) {
        if ((P[i][0] == P[i][1]) && (P[i][0] == P[i][2]) && (P[i][0] != P[i][3]) && (P[i][0] != 0)) {
            score += 3*P[i][0];
            P[i][0] = 0;
            P[i][1] = 0;
            P[i][2] = 0;
            check = 1;
        }
        if ((P[i][0] == P[i][1]) && (P[i][0] == P[i][2]) && (P[i][0] == P[i][3]) && (P[i][0] != P[i][4]) && (P[i][0] != 0)) {
            score += 4*P[i][0];
            P[i][0] = 0;
            P[i][1] = 0;
            P[i][2] = 0;
            P[i][3] = 0;
            check = 1;
        }
        if ((P[i][0] == P[i][1]) && (P[i][0] == P[i][2]) && (P[i][0] == P[i][3]) && (P[i][0] == P[i][4]) && (P[i][0] != 0)) {
            score += 5*P[i][0];
            P[i][0] = 0;
            P[i][1] = 0;
            P[i][2] = 0;
            P[i][3] = 0;
            P[i][4] = 0;
            check = 1;
        }
        if ((P[i][1] == P[i][2]) && (P[i][1] == P[i][3]) && (P[i][0] != P[i][2]) && (P[i][4] != P[i][2]) && (P[i][1] != 0)) {
            score += 3*P[i][1];
            P[i][1] = 0;
            P[i][2] = 0;
            P[i][3] = 0;
            check = 1;
        }
        if ((P[i][1] == P[i][2]) && (P[i][1] == P[i][3]) && (P[i][1]== P[i][4]) && (P[i][0] != P[i][1]) && (P[i][1] != 0)) {
            score += 4*P[i][1];
            P[i][1] = 0;
            P[i][2] = 0;
            P[i][3] = 0;
            P[i][4] = 0;
            check = 1;
        }
        if ((P[i][2] == P[i][3]) && (P[i][2] == P[i][4]) && (P[i][1] != P[i][2]) && (P[i][2] != 0)) {
            score += 3*P[i][2];
            P[i][2] = 0;
            P[i][3] = 0;
            P[i][4] = 0;
            check = 1;
        }
    }
}

void drow()
{
    for (int i = 1; i < H; i++) {
        for (int j = 0; j < 5; j++) {
            if (P[i][j] == 0) {
                for (int k = i; k > 0; k--) {
                    P[k][j] = P[k-1][j];
                }
                P[0][j] = 0;
            }
        }
    }
}

int main()
{
    while(1)
    {
        cin >> H;
        if (H == 0) {
            break;
        }
        for (int i = 0; i < H; i++) { //パズル初期化
            for (int j = 0; j < 5; j++) {
                cin >> P[i][j];
            }
        }
        score = 0;

        while(1)
        {
            check = 0;
            renzoku_check();
            if (check == 0) break;
            drow();
        }
        
        cout << score << endl;


    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;
struct Node{
    int num;
    int pre;
    int cnt;
};
int main(int argc, char const *argv[]){
    char a;
    cin >> a;
    if('a'<=a&&a<='z'){
        cout << "a" << endl;
    }else{
        cout << "A" << endl;
    }
    return 0;
}




Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define var auto
using ll = long long;
const char newl = '\n';
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {if(a > b) a = b;}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {if(a < b) a = b;}

using namespace std;

signed main(){
    while(true){
        int h, w;
        cin >> h >> w;
        if (h == 0) return 0;
        vector<string> s(h);
        for (int i = 0; i < h; i++) cin >> s[i];

        vector<pair<int, int>> dirs{
            make_pair(1, 1),
            make_pair(0, 1),
            make_pair(-1, 1),
            make_pair(1, 0),
            make_pair(-1, 0),
            make_pair(1, -1),
            make_pair(0, -1),
            make_pair(-1, -1),
        };

        string longest = "";

        unordered_set<string> se{};
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                for (auto&& dir : dirs){
                    int y = i, x = j;
                    string cur = "";
                    cur += s[y][x];
                    do{
                        y += dir.first;
                        x += dir.second;
                        if (y < 0) y += h;
                        if (x < 0) x += w;
                        if (h <= y) y -= h;
                        if (w <= x) x -= w;
                        if (y == i && x == j) break;
                        cur += s[y][x];
                        //cout << cur << endl;
                        if (!se.insert(cur).second){
                            if (cur.size() > longest.size() || (cur.size() == longest.size() && cur < longest)) longest = cur;
                        }
                    }
                    while (true);
                }
            }
        }


        cout << (longest.size() == 0 ? "0" : longest) << endl;
    }
}


Measured memory_bytes: 35080
fun main(args: Array<String>) {
    val S  = readLine()!!
    var ans = 0L
    var BC = 0
    var n = S.length - 1
    while (n >= 0) {
        if (n >= 1 && S[n - 1] == 'B' && S[n] == 'C') { n--; BC++ }
        else if (S[n] == 'A') ans += BC else BC = 0
        n--
    }
    println(ans)
}


Measured memory_bytes: 34260
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int a[] = fs.nextIntArray(3*n);
		
		Queue<Integer> pql = new PriorityQueue<>(); 
		Queue<Integer> pqr = new PriorityQueue<>((i1,i2)->i2-i1);//大きいものから出してくれる
		
		long suml[] = new long[n+1];
		long sumr[] = new long[n+1];
		
		for(int i=0;i<n;i++) {
			suml[0] += a[i];
			pql.offer(a[i]);
		}
		for(int i=2*n;i<3*n;i++) {
			sumr[0] += a[i];
			pqr.offer(a[i]);
		}
		
		for(int i=n;i<2*n;i++) {
			if(pql.peek()<a[i]) {
				int rm = pql.poll();
				pql.offer(a[i]);
				suml[i-n+1]=suml[i-n] + a[i] - rm;
			}
			else {
				suml[i-n+1]=suml[i-n];
			}
		}
		for(int i=2*n-1;i>=n;i--) {
			if(pqr.peek()>a[i]) {
				int rm = pqr.poll();
				pqr.offer(a[i]);
				sumr[2*n - i] = sumr[2*n-i-1] + a[i] - rm;
			}
			else {
				sumr[2*n-i]=sumr[2*n-i-1];
			}
		}
		long INF = Long.MAX_VALUE/2;
		long ans = -INF;
		for(int i=0;i<n+1;i++) {
			long sum = suml[i] - sumr[n-i];
			ans = Math.max(ans,sum);
		}
		System.out.println(ans);
		

		
		
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 64000
from collections import defaultdict
d = defaultdict(set)
n, m = map(int, input().split())
for _ in range(m):
    a, b = map(int, input().split())
    d[a].add(b)


def solve(n, d):
    for a in d[1]:
        if n in d[a]:
            return 'POSSIBLE'
    return 'IMPOSSIBLE'


print(solve(n, d))


Measured memory_bytes: 74256
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
int main()
{
	int n = in(), q = in();
	vector<priority_queue<int>>Q(n);
	REP(i, q)
	{
		int t, x;
		switch (in())
		{
		case 0:
			t = in(), x = in();
			Q[t].push(x);
			break;
		case 1:
			t = in();
			if (Q[t].size() != 0)cout << Q[t].top() << endl;
			break;
		case 2:
			t = in();
			if (Q[t].size() != 0)Q[t].pop();
			break;
		}
	}
}


Measured memory_bytes: 4132
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
using namespace std;
#define int long long int
#define mod 1000000007
int fact[2000201];
void function2()
{
	fact[0]=1;
	int j;
	for(j=1;j<=2000200;j++)
	{
		fact[j]=(j*fact[j-1])%mod;
	}
}
int power(int a,int b)
{
	if(b==0)
	  return 1;
    else
    {
		int r=power(a,b/2);
		int x=(r*r)%mod;
		if(b%2==0)
		{
			return x;
		}
		else
		{
			return (a*x)%mod;
		}
	}
}
int ncr(int n,int r)
{
	int answer=fact[n];
	answer*=power(fact[n-r],mod-2);
	answer=answer%mod;
	answer*=power(fact[r],mod-2);
	answer=answer%mod;
	return answer;
}
int32_t main()
{
	function2();
	int k;
	cin>>k;
	string str;
	cin>>str;
	int n=str.size();
	int answer=0;
	int j;
	for(j=k;j>=0;j--)
	{
		int here=power(26,j);
		int ways=ncr(n+k-j-1,n-1);
		ways*=power(25,k-j);
		ways%=mod;
		ways*=here;
		ways%=mod;
		answer+=ways;
		answer=answer%mod;
	}
	cout<<answer<<endl;
}


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

int main(void)
{
    int N, ok = 1;
    scanf("%d", &N);
    int nx = 0, ny = 0, nt = 0;
    for(int i = 1; i <= N; i++)
    {
        int t, x, y;
        scanf("%d %d %d", &t, &x, &y);
        if(abs(x - nx) + abs(y - ny) > abs(t - nt)) ok = 0;
        else if(abs(x - nx + y - ny) % 2 != abs(t - nt) % 2) ok = 0;
        else t = nt, x = nx, y = ny;
    }
    puts(ok ? "Yes" : "No");
    return 0;
}


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

string s, ans;

int main()
{
	cin >> s;
	// int st = 0, res = 0;
	// for(int i=0; i<=s.size(); i++)
	// {
	// 	if (i == s.size() || (s[i]=='P' && i+1<s.size() && s[i+1]=='P'))
	// 	{
	// 		int val = i-st;
	// 		if (res < val)
	// 		{
	// 			res = val;
	// 			ans = string(s.begin()+st, s.begin()+i);
	// 		}
	// 		st = i+1;
	// 	}
	// }

	for(int i=0; i<s.size(); i++)
	{
		if (s[i] == '?') s[i] = 'D';
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 3764
import Foundation

extension String {
    func wordsMap<T>(_ f: (Substring) -> T?) -> [T] {
        return self.split(separator: " ").compactMap(f)
    }
}

private func readWords<T>(_ f: (Substring) -> T?) -> [T] {
    return readLine()!.wordsMap(f)
}

extension Optional {
    func pleaseAC(){
        print(self!)
    }
}

readLine().map { line -> Any in 
    let n = Int(line)!
    var s = 0
    while s < n {
        s += 1000
    }

    return s - n
}
.pleaseAC()


Measured memory_bytes: 13144
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,num;
	scanf("%d%d",&n,&num);
	if(n>=13)
		printf("%d",num);
	else if(n>=6)
		printf("%d",num/2);
	else
		printf("0");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
using System.Diagnostics;

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];
    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    private long NextLong()
    {
        return long.Parse(Next());
    }
}

class Magatro
{
    private int A, B, C;
    private void Scan()
    {
        var sc = new Scanner();
        A = sc.NextInt();
        B = sc.NextInt();
        C = sc.NextInt();
    }

    public void Solve()
    {
        Scan();
        if(A==B)
        {
            Console.WriteLine(C);
        }
        else
        {
            if(B==C)
            {
                Console.WriteLine(A);
            }
            else
            {
                Console.WriteLine(B);
            }
        }
    }

    static public void Main()
    {
        new Magatro().Solve();

    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=105;
string maze[maxn];
bool vis[maxn][maxn][7][7];
int h,w;
bool dfs(int x,int y,int up=1,int ft=2,int bt=6,int bk=5,int lf=4,int rt=3)
{
    if(x<0||x>=h||y<0||y>=w) return false;
    if(vis[x][y][up][ft]||maze[x][y]=='#'||maze[x][y]-'0'!=bt) return false;
    if(x==h-1&&y==w-1) return true;
    vis[x][y][up][ft]=1;
    assert(up+bt==7&&ft+bk==7&&lf+rt==7);
    bool ret=0;
    ret|=dfs(x+1,y,bk,up,ft,bt,lf,rt);
    ret|=dfs(x-1,y,ft,bt,bk,up,lf,rt);
    ret|=dfs(x,y+1,lf,ft,rt,bk,bt,up);
    ret|=dfs(x,y-1,rt,ft,lf,bk,up,bt);
    return ret;
}
int main()
{
    cin>>h>>w;
    for(int i=0;i<h;i++) cin>>maze[i];
    if(dfs(0,0)) cout<<"YES\n";
    else cout<<"NO\n";
}


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

#pragma optimize("O3")

int V[5+(1<<18)];
int W[5+(1<<18)];

int dp[5+(1<<8)][100005];

const int INF = 1012345678;

int S, K;

int rec(int v, int L_rem, int bonus_value){
    if(L_rem < 0){
        return -INF;
    }else if(v < (1<<K)){
        return bonus_value + dp[v][L_rem];
    }

    return max(rec(v>>1, L_rem, bonus_value), rec(v>>1, L_rem-W[v], bonus_value+V[v]));
}


int main(){
    int N;
    scanf("%d", &N);

    for(int i = 1; i <= N; i ++){
        scanf("%d%d", &V[i], &W[i]);
    }

    int Q;
    scanf("%d", &Q);
    K = log2(N)/2;

    //printf("1<<K=%d\n", 1<<K);

    memset(dp, 0, sizeof(dp));
    for(int i = 1; i <= (1<<K); i ++){
        for(int j = 0; j <= 100000; j ++){
            int temp = dp[i>>1][j];
            if(j >= W[i]){
                temp = max(temp, V[i]+dp[i>>1][j-W[i]]);
            }
            dp[i][j] = temp;
        }
    }

    while(Q --){
        int v, L;
        scanf("%d%d", &v, &L);
        printf("%d\n", rec(v, L, 0));
    }

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) {
    cin >> a.at(i);
  }
  vector<bool> touched(N, false);
  bool bFound = false;
  int count = 0;
  
  int btn = a.at(0);
  touched.at(0) = true;
  while ( !touched.at(btn-1) ) {
    count++;
    touched.at(btn-1) = true;
    if ( btn == 2 ) {
      bFound = true;
      break;
    }
    btn = a.at(btn-1);
  }
  if ( bFound == false ) {
    count = -1;
  }
  cout << count << endl;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 1000020
#define MOD 998244353
using namespace std;

namespace Sieve
{
    bool u[N];
    int p[N], c;
    int f[N];

    void Sieve(void)
    {
        int i, j;

        f[1] = 1;
        for(i = 2; i < N; i ++)
        {
            if(!u[i])
            {
                p[c ++] = i;
                f[i] = -1;
            }
            for(j = 0; j < c && i * p[j] < N; j ++)
            {
                u[i * p[j]] = true;
                if(!(i % p[j]))
                    break;
                f[i * p[j]] = -f[i];
            }
        }
        // for(i=1;i<20;i++)cout<<f[i]<<' ';

        return;
    }
}

int a[N], f[N], g[N], h[N];

int Power(int x, int y)
{
    int o;

    for(o = 1; y; y >>= 1)
    {
        if(y & 1)
            o = (long long)o * x % MOD;
        x = (long long)x * x % MOD;
    }

    return o;
}

int main(void)
{
    int n, x;
    int i, j, y, o;

    Sieve::Sieve();
    scanf("%d", &n);
    for(i = 1; i <= n; i ++)
    {
        scanf("%d", &x);
        a[x] ++;
    }

    for(i = 1; i < N; i ++)
        for(j = 1; i * j < N; j ++)
        {
            f[i] += a[i * j];
            g[i] = (g[i] + (long long)a[i * j] * i * j % MOD) % MOD;
            h[i] = (h[i] + (long long)a[i * j] * i * j % MOD * i * j % MOD) % MOD;
        }
    for(i = 1, o = 0; i < N; i ++)
    {
        x = Power(i, MOD - 2);
        for(j = 1; i * j < N; j ++)
        {
            y = ((long long)g[i * j] * g[i * j] % MOD - h[i * j]) % MOD * 499122177 % MOD;
            // printf("at d = %d, k = %d : sum %d\n", i, j, g[i * j]);
            o = (o + (long long)Sieve::f[j] * x * y % MOD) % MOD;
        }
    }
    printf("%d\n", (o + MOD) % MOD);

    return 0;
}


Measured memory_bytes: 21632
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,h;
    cin >> n >> h;
    vll a(n),b(n);
    ll amax  = 0;
    REP(i,n){
        cin >> a[i] >> b[i];
        amax = max(amax,a[i]);
    }
    sort(rALL(b));
    ll ans = 0;
    REP(i,n){
        if(h<=0) break;
        if(b[i]<amax) break;
        h-=b[i];
        ans++;
    }
    if(h>0){
        ans += (h-1)/amax+1;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

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

	ll a, b, c;

	cin >> a >> b >> c;

	if (a + b < c) Out(a + b + 1 + b);
	else Out(b + c);
	
    return 0;
}

Measured memory_bytes: 256
N, X, M = map(int, input().split())
if X <= 1:
    print(X*N)
    exit()
check = [0]*(M+1)
check[X] += 1
A = X
last_count = 0
while True:
    A = (A**2)%M
    if check[A] != 0:
        last_count = sum(check)
        target_value = A
        break
    check[A] += 1
A2 = X
first_count = 0
while A2 != target_value:
    first_count += 1
    A2 = (A2**2)%M

roop_count = last_count-first_count

A3 = target_value
mass = A3
for i in range(roop_count-1):
    A3 = (A3**2)%M
    mass += A3
if roop_count == 0:
    print(N*X)
    exit()
if first_count != 0:
    ans = X
    A = X
    for i in range(min(N,first_count)-1):
        A = (A**2)%M
        ans += A
else:
    ans = 0
if N > first_count:
    ans += ((N-first_count)//roop_count)*mass
    A4 = target_value
    if (N-first_count)%roop_count >= 1:
        ans += A4
    for i in range(((N-first_count)%roop_count)-1):
        A4 = (A4**2)%M
        ans += A4
print(ans)

Measured memory_bytes: 67040
N, M = map(int,input().split())

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


print(cmb(N+M,2)-N*M)

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

int main(){
    int h,a;
    cin >> h >> a;
    cout << (h+a-1)/a << endl;
}

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

void fnInput(int &rnTrkSiz, vector<int> &rvnLod)
{
  int nLodSiz;
  cin >> nLodSiz >> rnTrkSiz;

  rvnLod.resize(nLodSiz);
  for (int i = 0; i < nLodSiz; i++)
    cin >> rvnLod[i];
}

int fnSimuAlloc(const vector<int> &cnrvnLod, int nTrkSiz, int nLimLod)
{
  int nCurLod;
  int nCntTrk = 0;

  for (int i = 0; i < cnrvnLod.size();    )
  {
    if (cnrvnLod[i] > nLimLod)  return 0;

    nCntTrk++;
    nCurLod = 0;
    while (i < cnrvnLod.size())
    {
      nCurLod += cnrvnLod[i];
      if (nCurLod > nLimLod)  break;

      i++;
    }
  }
  return (nCntTrk <= nTrkSiz);
}

void fnAlloc(const vector<int> &cnrvnLod, int nTrkSiz, int &rnMinLod)
{
  const int nMINLOD = 0;
  const int nMAXLOD = 1000000000;

  int nLow  = nMINLOD;
  int nHigh = nMAXLOD;
  rnMinLod  = nMAXLOD;

  while (nLow < nHigh)
  {
    int nLimLod = (nLow + nHigh) / 2;
    if (fnSimuAlloc(cnrvnLod, nTrkSiz, nLimLod))
    {
      rnMinLod = min(rnMinLod, nLimLod);
      nHigh = nLimLod;
    }
    else
      nLow = nLimLod + 1;
  }
}

void fnReSult(int nMinLod)
{
  cout << nMinLod << endl;
}

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

  int nTrkSiz, nMinLod = 0;
  vector<int> vnLod;

  fnInput(nTrkSiz, vnLod);
  fnAlloc(vnLod, nTrkSiz, nMinLod);
  fnReSult(nMinLod);

  return 0;
}

Measured memory_bytes: 3268
#include<iostream>

using namespace std;

int main(){
	int n,x,ans;
	cin>>n>>x;
	while(n!=0 or x!=0){
	ans=0;
	for(int i=1;i<n;i++){
		for(int j=i+1;j<n;j++){
			int k=x-i-j;
			if(k<=j){break;}
			else if(k<=n){ans++;}
		}
	}
	cout<<ans<<endl;
	cin>>n>>x;
	}
	return 0;
}



Measured memory_bytes: 3068
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<u32>();
    if n % 2 == 0 {
        println!("{}", (n/2)*(n/2));
    } else {
        println!("{}", (n/2+1)*(n/2));
    }
}


Measured memory_bytes: 4352