akhauriyash/Code-Regression huggingface dataset:
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn lastnum_index(array: &Vec<i32>) -> usize {
    let mut max = 0;
    let mut index = 0;
    for x in 0..array.len() {
        let maxt = (10 - array[x] % 10) % 10;
        if maxt > max {
            max = maxt;
            index = x;
        }
    }

    index
}

fn all_time(array: Vec<i32>) -> i32 {
    let index = lastnum_index(&array);
    let mut sum = 0;
    for x in 0..array.len() {
        let e = array[x];
        if x == index || e % 10 == 0 {
            sum += e;
        } else {
            sum += (e / 10 + 1) * 10;
        }
    }

    sum
}

fn main() {
    let mut vec = Vec::<i32>::new();
    for x in 0..5 {
        let line = read_vec::<i32>();
        vec.push(line[0]);
    }
    println!("{}", all_time(vec));
}


Measured memory_bytes: 4352
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
sum1 = 0
sum2 = 0
for j in range(N):
    if j%2 == 0:
        sum1 = sum1 + a[j]
    elif j%2 ==1:
        sum2 = sum2 + a[j]
print(sum1 - sum2)


Measured memory_bytes: 3060
import scala.io.StdIn

object Main extends App {
  
  val n = StdIn.readLine().toInt
  val linse = (0 until n).map(_ => StdIn.readLine())
  
  //val combis = List('M','A','R','C','H').combinations(3)
  //println(combis.mkString(" "))

  val members = linse.filter{p =>
    p.charAt(0) == 'M' || p.charAt(0) == 'A' || p.charAt(0) == 'R' || p.charAt(0) == 'C' || p.charAt(0) == 'H'
  }.groupBy(name => name.charAt(0)).map(a => a._1 -> a._2.size)

  val combis = members.keys.toList.combinations(3)
  //println(combi.mkString(" "))

  val result = combis.foldLeft(0L){ (acc, l) =>
    acc + (members.get(l(0)).getOrElse(0).toLong * 
      members.get(l(1)).getOrElse(0).toLong * members.get(l(2)).getOrElse(0).toLong)
  }

  println(result)

}

Measured memory_bytes: 44040
import queue

H, W = list(map(int, input().split()))
board = []
for i in range(H):
    board.append(input())

d = [[0 for i in range(W)] for j in range(H)]

dx = (1, 0, -1, 0)
dy = (0, 1, 0, -1)

sx, sy = 0, 0 # スタートの座標
gx, gy = H-1, W-1 # ゴールの座標

def bfs():
    que = queue.Queue()
    # すべての点をINFで初期化
    for i in range(H):
        for j in range(W):
            d[i][j] = float("inf")
    # スタート地点をキューに入れて、その点の距離を0にする
    que.put((sx, sy))
    d[sx][sy] = 0
    
    # キューが空になるまでループ
    while que.qsize() > 0:
        # キューの先頭を取り出す
        p = que.get()
        # 取り出してきた状態がゴールなら探索をやめる
        if p[0] == gx and p[1] == gy:
            break
        # 移動4方向をループ
        for i in range(4):
            # 移動した後の点を(nx, ny)とする
            nx, ny = p[0] + dx[i], p[1] + dy[i]
            
            # 移動が可能かの判定とすでに訪れたことがあるかの判定
            if 0 <= nx < H and 0 <= ny < W:
                if board[nx][ny] != "#" and d[nx][ny] == float("inf"):
                    que.put((nx, ny))
                    d[nx][ny] = d[p[0]][p[1]] + 1
    return d[gx][gy]

def solve():
    res = bfs()
    if type(res) != int:
        print(-1)
        return
    sharp_num = 0
    for l in board:
        for c in l:
            if c == "#":
                sharp_num += 1
    print(H*W - res - sharp_num - 1)
    
    
    
solve()

Measured memory_bytes: 4208
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
var N=Arr.shift()-0;
for(var I=0;I<N;I++){
   var v=Arr[I]-0;
   var obj={};
   obj[v]=true;
   var cnt=0;
   while(true){
      if(v<10)break;
      var str=v+"";
      var max=[];
      for(var i=1;i<str.length;i++){
         var a=parseInt(str.slice(0,i),10);
         var b=parseInt(str.slice(i),10);
         max.push(a*b);
      }
      v=Math.max.apply(null,max);
      if(obj.hasOwnProperty(v)){
         cnt=-1;
         break;
      }
      obj[v]=true;
      cnt++;
   }
   console.log(cnt);
}

Measured memory_bytes: 10520
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;


const int MAX_V = 310;
const int INF = 1000000000;

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

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

int add_edge(int f, int t, int c){
	int r = G[t].size();
	G[f].push_back((edge){t, c, r});
	G[t].push_back((edge){f, 0, G[f].size() - 1});
	return r;
}

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, m, s, t;
	scanf("%d%d", &n, &m);
	vector<int> x(m + 1), y(m + 1), r(m + 1);
	for(int i = 1; i <= m; ++i){
		scanf("%d%d", &x[i], &y[i]);
		add_edge(x[i], y[i], 1);
		r[i] = add_edge(y[i], x[i], 1);
	}
	scanf("%d%d", &s, &t);
	int f = max_flow(s, t);
	vector<int> ans;
	for(int i = 1; i <= m; ++i){
		if(G[x[i]][r[i]].cap > 0){
			ans.push_back(i);
		}
	}
	printf("%d\n%d\n", f, ans.size());
	for(int i = 0; i < ans.size(); ++i){
		printf("%d\n", ans[i]);
	}
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
//
	int n;
	long double sum = 0;
	cin >> n;
	vector<long double>a(n);
	rep0(i, n - 1)cin >> a[i];
	rep0(j, n - 1) {
		sum += 1 / a[j];
	}
	sum = 1 / sum;
	cout<<sum<<endl;

	return 0;
}

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

// ABC172 D - Sum of Divisors

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N; cin >> N;
  ll ans = 0;
  for(ll i = 1; i <= N; i++){
    ll n = N/i;
    ans += i*(n*(n+1)/2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
[a, b, c,\
 d, e, f,\
 g, h, i] = map(int, open(0).read().split())

x1 = 0
[y1, y2, y3] = [a - x1, b - x1, c - x1]
[x1, x2, x3] = [a - y1, d - y1, g - y1]

good = [(e, f), (h, i)] == [(x2 + y2, x2 + y3), (x3 + y2, x3 + y3)]
if good:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
w, h, n = map(int, input().split())
xya = [list(map(int, input().split())) for i in range(n)]

z = [[0 for i in range(w)] for i in range(h)]  # z =[[0]*w]*hとすると、一つの要素を書き換えたときに同時に他の要素も変更になるのでよくない。
ans = 0

for i in range(n):
    if xya[i][2] == 1:
        for j in range(h):
            z[j][:xya[i][0]] = [1]*xya[i][0]
    elif xya[i][2] == 2:
        for j in range(h):
            z[j][xya[i][0]:] = [1]*(w-xya[i][0])
    elif xya[i][2] == 3:
        z[:xya[i][1]] = [[1]*w]*xya[i][1]
    elif xya[i][2] == 4:
        z[xya[i][1]:] = [[1]*w]*(h-xya[i][1])

for i in range(len(z)):
    ans += z[i].count(0)

print(ans)


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

int main() {
	int a,b;
	cin>>a>>b;
	int sum=0;
	map<int,int> m;
	for(int i=1;i<=999;i++)
	{
	    sum+=i;
	    if(sum-a>0)
	    {
	        m[sum-a]++;
	    }
	}
	for(int i=999;i>=1;i--)
	{
	    int sum1 = (i*(i+1))/2;
	    if(m[sum1-b]>0)
	    {
	        cout<<sum1-b<<endl;
	        break;
	    }
	}
	return 0;
}


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

int gcd(int a, int b){
  if(b > a) swap(a, b);
  if(b == 0) return a;
  return gcd(a%b, b);
}

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

  int lcm = N * 2 / gcd(N, 2);

  cout << lcm << endl;

  return 0;

}

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

namespace StronglyConnectedComponents
{
    class StronglyConnectedComponents
    {
        readonly int n;

        Dictionary<int, List<int>> G, Rev_G;
        List<int> st;
        bool[] visited;
        int[] cmp;

        public StronglyConnectedComponents(int n)
        {
            this.n = n;

            G = new Dictionary<int, List<int>>();
            Rev_G = new Dictionary<int, List<int>>();
            for (int i = 0; i < n; i++)
            {
                G.Add(i, new List<int>());
                Rev_G.Add(i, new List<int>());
            }
        }

        public void AddEdge(int from, int to)
        {
            G[from].Add(to);
            Rev_G[to].Add(from);
        }

        public void MakeSet()
        {
            st = new List<int>();
            cmp = new int[n];
            visited = new bool[n];

            for (int i = 0; i < n; i++)
            {
                if (!visited[i]) DFS(i);
            }

            visited = new bool[n];

            int cnt = 0;

            for (int i = st.Count - 1; i >= 0; i--)
            {
                int v = st[i];

                if (!visited[v]) Rev_DFS(v, cnt++);
            }
        }

        public bool IsSame(int x, int y)
        {
            return cmp[x] == cmp[y];
        }

        private void DFS(int v)
        {
            visited[v] = true;

            foreach (var next in G[v])
            {
                if (!visited[next]) DFS(next);
            }
            st.Add(v);
        }

        private void Rev_DFS(int v, int cnt)
        {
            visited[v] = true;
            cmp[v] = cnt;

            foreach (var next in Rev_G[v])
            {
                if (!visited[next]) Rev_DFS(next, cnt);
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int V = int.Parse(input[0]);
            int E = int.Parse(input[1]);

            StronglyConnectedComponents SCC = new StronglyConnectedComponents(V);

            for (int i = 0; i < E; i++)
            {
                input = Console.ReadLine().Split(' ');
                int s = int.Parse(input[0]);
                int t = int.Parse(input[1]);

                SCC.AddEdge(s, t);
            }

            SCC.MakeSet();

            StringBuilder sb = new StringBuilder();
            int Q = int.Parse(Console.ReadLine());

            for (int i = 0; i < Q; i++)
            {
                input = Console.ReadLine().Split(' ');
                int u = int.Parse(input[0]);
                int v = int.Parse(input[1]);

                sb.AppendLine(SCC.IsSame(u, v) ? "1" : "0");
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 15132
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define DEBUG false

int main(){

	ll n, m;
	while(cin >> n >> m){
		if(n == 0 && m == 0) break;
		vector<ll> p(n+1);
		rep(i, n) cin >> p[i];
		
		rep(i, n){
			REP(j, i, n){
				p.push_back(p[i] + p[j]);
			}
		}
		
		SORT(p);
		
		ll ans = 0;

		rep(i, p.size()){
			auto it2 = upper_bound(p.begin(), p.end(), m - p[i]);
			if(it2 == p.begin()) continue;
			it2--;
			if(p[i] > *it2) break;
			ans = max(ans, p[i] + *it2);
		}
		
		cout << ans << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 10880
N = gets.to_i
xs = Array.new(N)
ys = Array.new(N)
N.times do |i|
  xs[i], ys[i] = gets.split.map(&:to_i)
end

c = Array.new(N){|i| i}

combi = c.permutation.to_a
ans = 0

combi.each do |cm|
  path_length = 0
  for i in 1...cm.length do
    tmp = (xs[cm[i-1]] - xs[cm[i]]) ** 2 + (ys[cm[i-1]] - ys[cm[i]]) ** 2
    tmp = Math.sqrt(tmp)
    path_length += tmp
  end
  ans += path_length
end


puts ans / (combi.length)


Measured memory_bytes: 8188
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define cst first
#define dur second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 5e2 + 5, M = 2 * N + 5;

int n, x[N], k, sum;
int a[N], b[N];

int main(){
    scanf("%d%d", &n, &k);
    for(int i = 0 ; i < n ; ++i)
        scanf("%d", x + i), sum += x[i];
    vector<int> div;
    for(ll i = 1 ; i * i <= sum ; ++i){
        if(sum % i)continue;
        div.emplace_back(i);
        div.emplace_back(sum / i);
    }
    sort(div.rbegin(), div.rend());
    for(auto num : div){
        // cout << "Num = " << num << endl;
        vector<int> v;
        for(int i = 0 ; i < n ; ++i)
            v.emplace_back(x[i] % num);
        sort(v.begin(), v.end());
        for(int i = 1 ; i <= n ; ++i)
            a[i] = a[i - 1] + v[i - 1];
        b[n + 1] = 0;
        for(int i = n ; i ; --i){
            int tmp = (num - v[i - 1]);
            if(tmp == num)tmp = 0;
            b[i] = b[i + 1] + tmp;
        }
        bool ok = false;
        for(int i = 1 ; i < n && !ok; ++i)
            if(a[i] == b[i + 1] && a[i] <= k)ok = true;
        if(ok){
            printf("%d\n", num);
            return 0;
        }
    }
}


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

using namespace std;

string s;

typedef long double lint;

lint a, b, h, m;

lint pi = 3.14159265358979323846D;

int main()
{
    cin >> a >> b >> h >> m;

    lint y = 2 * pi * (h * 60 + m) / (12.0D * 60);
    lint z = 2 * pi * (m)          / (60.0D);

    lint w = fabs(y - z);

    if(w > pi)
        w = 2 * pi - w;

    //cout << w << "\n";

    lint rez = sqrt(a*a + b*b - 2 * a *b*cos(w));

    cout << fixed << setprecision(10) << rez << "\n";

    return 0;
}


Measured memory_bytes: 4168
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s; cin >> s;
	int N = count(s.begin(), s.end(), 'N');
	int S = count(s.begin(), s.end(), 'S');
	int W = count(s.begin(), s.end(), 'W');
	int E = count(s.begin(), s.end(), 'E');
	auto sgn = [](int a){
		if(a) return 1;
		return 0;
	};
	if(sgn(N) != sgn(S) || sgn(W) != sgn(E)) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)

N=int(input())
Hn=list(map(int,input().split()[:N]))

ret=0
tmp=0
for i in range(N-1):
    if Hn[i] >= Hn[i+1]:
        tmp+=1
    else:
        if tmp > ret:
            ret=tmp
        tmp=0
if tmp > ret:
    ret=tmp

print(ret)


Measured memory_bytes: 14864
n,k = map(int,input().split())
#逆元nCr
mod = 10**9+7
def cmb(n,r,mod):
    r = min(r, n-r)
    return (fact[n] * factinv[r] * factinv[n-r]) % mod
def h(n,r,mod):
    return cmb(n+r-1,r,mod)
def makefact(n,mod):
    fact = [1,1]
    factinv = [1,1]
    inv = [0,1]
    for i in range(2,n+1):
        fact.append((fact[-1]*i) % mod)
        inv.append(-inv[mod%i]*(mod//i)%mod)
        factinv.append((factinv[-1]*inv[-1])%mod)
    return fact,factinv
fact,factinv = makefact(n,mod)


ans = 0
for i in range(min(n,k+1)):
    ans = (ans+cmb(n,i,mod)*h(n-i,i,mod))%mod
print(ans)

Measured memory_bytes: 80880
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=105;
int n,m,w1,dp[N][N*3];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x>y?x=y:0;}
	template <class T> inline void apx(T &x,const T y){x<y?x=y:0;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	n=nxi(),m=nxi();
	for(int i=1; i<=n; ++i){
		int w=nxi(),v=nxi();
		if(i==1) w1=w;
		int dlt=w-w1;
		for(int j=i; j>=1; --j){
			for(int k=j*3; k>=dlt; --k){
				apx(dp[j][k],dp[j-1][k-dlt]+v);
			}
		}
	}
	int ans=0;
	for(int i=1; m>=w1*i&&i<=n; ++i){
		for(int j=std::min(i*3,m-w1*i); ~j; --j){
			apx(ans,dp[i][j]);
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



int main(){
    int n;
    cin >> n;
    VEC(ll, a, n);
    sort(ALL(a), greater<ll>());
    ll base = a[0];

    ll mid = INF;
    REP(i, 1, n - 1){
        if(abs(base / 2 - a[i]) < abs(base / 2 - mid)){
            mid = a[i];
        }
    }
    cout << base << " " << mid << endl;
}



Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int GCD( int m, int n )
{
	
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}
int LCM( int m, int n )
{
	
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / GCD(m, n)) * n); 
}
int main()
{
	int n,m;
	while(cin>>n>>m){
		cout<<GCD(n,m)<<" "<<LCM(n,m)<<endl;
	}
}

Measured memory_bytes: 1160
mod = 10 ** 9 + 7

N = int(input())

x = list(map(int,input().split()))
now = 1

nmul = 1
ans = 1

for i in range(N):

    if x[i] >= now:
        now += 2
        
        ans *= nmul
        ans %= mod
        
        nmul += 1

    else:
        ans *= nmul
        ans %= mod

print (ans)


Measured memory_bytes: 62704
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
    string s;
    int n,q;

    cin >>n >>q;
    cin >>s;

    vector<int> ctable (s.size()+1, 0);

    for(int i = 1; i < s.size() ; i++){
        if(s[i-1] == 'A' && s[i] =='C'){
            ctable[i] = ctable[i-1] + 1;
        }else{
            ctable[i] = ctable[i-1];
        }
    }

    for(int i = 0; i < q; i++){
        int l,r;
        cin >>l >>r;

        printf("%d\n", ctable[r-1] - ctable[l-1]);
    }

    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================
int sum = 0;
void judge(vector<int>& x)
{
	rep(i, sz(x))
	{
		if (x[i] == 0)continue;
		const int b = x[i];
		rep(j, b) {
			int a = i;
			while (a < sz(x) && x[a] != 0)
			{
				x[a]--; a++;
			}
			sum++;
		}
	}
}

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;

int main()
{
	cin >> n; vector<int> h(n); rep(i, n)cin >> h[i];
	judge(h);
	cout << sum << endl;

	return 0;
}


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

const ll INF = 1001001001;

const double PI=3.141592653;

const ll sosu = 1000000007;//大きい素数

//提出のときに言語がc＋＋似合っていることを確認する

ll f(ll x){
  if(x==1) return 1;
  return 2*f(x/2)+1;
}
int main(){
  ll h;cin>>h;
  cout<<f(h)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	char c;
	cin >> c;
	c++;
	col(c);

	return 0;
}


Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


X, Y = MI()
for i in range(101):
    for j in range(101):
        if i + j == X and 2 * i + 4 * j == Y:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 63220
#include<bits/stdc++.h>
using namespace std;
#define N 100005
int n,ans,now;
struct V {
	int k,num;
	bool operator <(const V a)const {
		if(k^a.k)return k>a.k;
		return num<a.num;
	}
} A[N];
set<int>S;
set<int>::iterator fo;
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++)scanf("%d",&A[i].k),A[i].num=i;
	sort(A+1,A+n+1);
	for(int i=1; i<=n; i++) {
		fo=S.lower_bound(A[i].num);
		if(fo==S.end())ans++;
		else S.erase(fo);
		S.insert(A[i].num);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 5760
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

bool is753number(int n) {
    string s = to_string(n);
    return s.find('3') != string::npos && s.find('5') != string::npos && s.find('7') != string::npos;
}

ll N;
int ans = 0;

void dfs(ll n) {
    if (n > N) return;
    else if (is753number(n)) ans++;
    dfs(10 * n + 3);
    dfs(10 * n + 5);
    dfs(10 * n + 7);
}

int main() {
    cin >> N;
    dfs(0);
    write(ans);
}

Measured memory_bytes: 256
/*
  || Shree Ganeshay Namah ||

     || Jai Shree Ram ||
  || Nabh Sparsham Diptam ||
*/
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define mod 1000000007
#define block 180
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f1 first
#define s1 second
int jai_shree_ram()
{
    return 1;
}
int shree_ganeshay_namah()
{
    return 1;
}
ll power(ll x,ll y)
{
    ll r=1;
    while(y>0)
    {
        if(y%2!=0)
            r=r*x;
        x=x*x;
        y=y/2;
    }
    return r;
}
ll ncr(ll n,ll k)
{

    ll c[k+1];
    memset(c,0,sizeof(c));
    c[0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=min(i,k);j>0;j--)
            c[j]=c[j]+c[j-1];
    }
    return c[k];
}

bool prime[500001];
void sieve()
{
    ll i,j;
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(i=2;i<=sqrt(100001);i++)
    {
        if(prime[i])
        {
            for(j=i*i;j<=100001;j=j+i)
                prime[j]=false;
        }
    }
}

vector<ll>g[500000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,i,j;
    cin>>n;
    cout<<(n%1000==0?(n/1000):(n/1000+1))*1000-n;
    return 0;

}


Measured memory_bytes: 15364
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    ll K;
    cin >> N >> K;
    vector<ll> A(N);
    for (int n = 0; n < N; ++n) cin >> A[n];
    ll Sum = 0;
    for (int n = 0; n < N; ++n) Sum += A[n];
    
    set<ll, greater<ll>> Dev;
    for (int i = 1; i * i <= Sum; ++i) {
        if (Sum%i == 0) {
            Dev.insert(i);
            Dev.insert(Sum / i);
        }
    }
    
    for (auto f : Dev) {
        if (f == 1) {
            cout << 1 << endl;
            break;
        }
        
        vector<ll> Temp(N);
        for (int n = 0; n < N; ++n) {
            Temp[n] = A[n]%f;
        }
        sort(Temp.begin(), Temp.end());
        int nSum = 0;
        for (int n = 0; n < N; ++n) nSum += Temp[n];
        int k = nSum/f;
        int nMin = 0;
        for (int l = 0; l < N-k; ++l) nMin += Temp[l];
        if (nMin <= K) {
            cout << f << endl;
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 512
#[allow(dead_code)]
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

#[allow(unused_macros)]
macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

#[allow(unused_macros)]
macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } }
// macro_rules! debug { ($x: expr) => () }

#[allow(dead_code)]
fn show<T>(iter: T) -> String
where
    T: Iterator,
    T::Item: std::fmt::Display
{
    let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e));
    res.pop();
    res
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::collections::btree_map::Entry::{Occupied, Vacant};

fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }
    
    let (n, c) = readl!(usize, usize);
    let d: Vec<_> = (0..c).map(|_| readlvec!(i64)).collect();
    
    let cv: Vec<Vec<_>> = (0..n).map(|_| readlvec!(i64).into_iter().map(|x| x-1).collect()).collect();
    


    let mut cov = vec![vec![0; c]; 3];
    for (i, row) in cv.iter().enumerate() {
        for (j, &e) in row.iter().enumerate() {
            cov[(i+j)%3][e as usize] += 1;
        }
    }
    let cov = cov;

    let inf = 1_000_000_000_000;
    let mut ans = inf;
    for c0 in 0..c {
        for c1 in 0..c { 
            for c2 in 0..c {
                if c0 == c1 || c1 == c2 || c0 == c2 {
                    continue;
                }
                let ccv = [c0, c1, c2];
                let mut cost = 0;
                for (i, cr) in cov.iter().enumerate() {
                    for (&ce, dr) in cr.iter().zip(d.iter()) {
                        cost += ce*dr[ccv[i]];
                    }
                }
                ans = min(ans, cost);
            }
        }
    }
    printfln!("{}", ans);
}


Measured memory_bytes: 6396
import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
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

class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents[i]: 要素iの親要素の番号
        # 要素iが根の場合、parents[i] = -(そのグループの要素数)
        self.parents = [-1] * n
    def find(self, x):
        if 0 > self.parents[x]:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    # 要素xが属するグループの要素数を返す
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    # 全ての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if 0 > x]
    # グループの数を返す
    def group_count(self):
        return len(self.roots())
    # 辞書{根の要素: [そのグループに含まれる要素のリスト], ...}を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    # print()での表示用
    # all_group_members()をprintする
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M, K = MAP()

tree = UnionFind(N)
friends = [[] for _ in range(N)]

for _ in range(M):
	A, B = MAP()
	tree.union(A-1, B-1)
	friends[A-1].append(B-1)
	friends[B-1].append(A-1)

blocks = [[] for _ in range(N)]

for _ in range(K):
	C, D = MAP()
	blocks[C-1].append(D-1)
	blocks[D-1].append(C-1)

for i in range(N):
	blocks_cnt = 0
	for j in blocks[i]:
		if tree.same(i, j):
			blocks_cnt += 1
	print(tree.size(i) - len(friends[i]) - 1 - blocks_cnt, end=" ")
print()


Measured memory_bytes: 46520
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MOD = 998244353;
Int dp[330][330][330], tmp0[330][330], tmp1[330][330];
vector<int> posnum(const string &S) {
    vector<int> ans;
    int cnt = 0;
    for (auto c : S) {
        if (c == '0') {
            ans.push_back(cnt);
            cnt = 0;
        } else {
            cnt++;
        }
    }
    ans.push_back(cnt);
    return ans;
}
int main() {
    string S; cin >> S;
    int K; cin >> K;
    auto A = posnum(S);
    int ones = count(begin(S), end(S), '1');
    K = min(K, ones);
    dp[A.size()][K][0] = 1;
    for (int i = A.size(); i > 0; i--) {
        memset(tmp0, 0, sizeof(tmp0));
        memset(tmp1, 0, sizeof(tmp1));
        for (int k = 0; k <= K; k++) {
            for (int t = 0; t <= K; t++) {
                tmp0[k][0] += dp[i][k][t];
                tmp0[k][t + 1] -= dp[i][k][t];
                int m = min(A[i - 1], k);
                tmp1[k - m][t + m] += dp[i][k][t];
                tmp1[k][t] -= dp[i][k][t];
            }
        }
        for (int k = 0; k <= K; k++) {
            for (int t = 0; t <= K; t++) {
                tmp0[k][t + 1] += tmp0[k][t];
            }
        }
        for (int k = 0; k <= K; k++) {
            for (int t = K; t > 0; t--) {
                tmp1[k + 1][t - 1] += tmp1[k][t];
            }
        }
        for (int k = 0; k <= K; k++) {
            for (int t = 0; t <= K; t++) {
                dp[i - 1][k][t] += tmp0[k][t] + tmp1[k][t];
                dp[i - 1][k][t] %= MOD;
            }
        }
    }
    Int ans = 0;
    for (int k = 0; k <= K; k++) {
        ans += dp[0][k][0];
    }
    cout << ans % MOD << '\n';
    return 0;
}


Measured memory_bytes: 63968
N = int(input())
P = list(map(int, input().split()))

# N = 5
# P = [4, 2, 5, 1, 3]

ans = 0
min = 2 * 10**5
for i in range(0, N):
    # i = 1
    if min > P[i]:
        min = P[i]
    if P[i] <= min:
        ans += 1

print(ans)

Measured memory_bytes: 24744
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

#define MEM(a,b)    memset(a, b, sizeof(a))
#define UN(a)       sort(all(a)), a.erase(unique(all(a)), a.end())
#define REV(a)      reverse(all(a))
#define MP(a, b)    make_pair(a, b)
#define PAIR(a, b)  pair<int, int>(a, b)

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

const int MOD = 1e9 + 7;
const int maxn = 1;
const double EPS = 1e-8;

class AFavoriteSound {
public:
	void solve(std::istream& in, std::ostream& out) {
    	int a, b, c;
    	in >> a >> b >> c;
    	out << min(c, b/a) << endl;
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	AFavoriteSound solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  
  for(int i=0; i<n; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  
  cout << vec.at(n-1) - vec.at(0) << endl;
}

Measured memory_bytes: 256
length = int(input())
values = input()
continued_l = len(values)
x = 0
max_x = 0
for c in values:
    if c == 'I':
        x += 1
    elif c == 'D':
        x -= 1
    if x > max_x:
        max_x = x
print(max_x)


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main(){
	string s;
	while (cin >> s) {
		if (s == "#")break;
		int y, m, d; cin >> y >> m >> d;
		if (y < 31 || (y == 31 && m < 5)) {
			cout << s << " " << y << " " << m << " " << d << endl;
		}
		else {
			cout << "? " << y-30 << " " << m << " " << d << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3092
/**
 *    author:  FromDihPout
 *    created: 2020-08-09
**/

#include <bits/stdc++.h>
using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    string s;
    cin >> n >> s;
    char prev = '*';
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] != prev) {
            prev = s[i];
            ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}

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

const int N = 1e5+5, M = 1e5+5, OO = 0x3f3f3f3f;
int a[3];



int main(){
    for(int i=0 ; i<3 ; ++i)scanf("%d",a+i);
    int ans=0;
    sort(a,a+3);
    ans += (a[2]-a[0])/2;
    a[0] += ((a[2]-a[0])/2)*2;
    ans += (a[2]-a[1])/2;
    a[1] += ((a[2]-a[1])/2)*2;
    sort(a,a+3);
    if(a[0]==a[1] && a[0]!=a[2])++ans;
    else if(a[0]!=a[1])ans+=2;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
import sys
import math
N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
e = 0

for i in range(len(L)):
    s = 0
    s = L[i]
    for j, b in enumerate(L[i+1:]):
        if L[i] == b:
            continue
        g = s + b
        for w, n in enumerate(L[i+j+2:]):
            if n == b or n == L[i]:
                continue

            a = g - n
            if a > 0:
                e += 1

print(e)


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

int main() {
  long long n, m, i = 1, ans = 1;
  cin >> n >> m;
  if (n == 1) {
    cout << m << "\n";
  } else {
    while ((i <= m) && (i * n <= m)) {
      if (m % i == 0) {
        ans = i;
      }
      i++;
    }
    cout << ans << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int S,a,b,c;
    scanf("%d",&S);
    a=S/3600;
    b=(S-a*3600)/60;
    c=S-(a*3600+b*60);
    printf("%d:%d:%d\n",a,b,c );
    return 0;
}


Measured memory_bytes: 2128
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n%2){
        cout << 2*n << endl;
    }else{
        cout << n << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/**
 *COYG, 14 FA Cups we are back baby
 */
#include <bits/stdc++.h>
using namespace std;
#define mod 		1000000007
#define ll 		long long
#define mp 		make_pair
#define pb 		push_back
#define forn(i,n) 	for(int i=0;i<n;i++)
#define for1(i,n) 	for(int i=1;i<n;i++)
#define ford(i,n) 	for(int i=n-1;i>=0;i--)
#define vi 		vector<int>
#define vl 		vector<ll>
#define pii 		pair<int,int>
#define pll 		pair<ll,ll>
#define vpi 		vector<pair<int,int> >
#define vpl		vector<pair<ll,ll> >
#define vvi 		vector<vector<int> >
#define vvl 		vector<vector<ll> >
#define ull 		unsigned long long
#define IOS 		ios_base::sync_with_stdio(false);
#define PI 		3.1415926535897932384626
#define ff 		first
#define ss 		second
#define char2Int(c) 	(c-'0')
#define FOREACH(i,t) 	for (auto i=t.begin(); i!=t.end(); i++)
#define clr(a,x) 	memset(a,x,sizeof(a)) //set elements of array to some value
#define all(x)		(x).begin(),(x).end()//cout<<"Case #"<<zzz<<": ";
#define plll pair<ll,pll >
double dp[301][301][301];int n;
double getans(int curr[])
{
    if(dp[curr[0]][curr[1]][curr[2]]!=-1)return dp[curr[0]][curr[1]][curr[2]];
    double mult=((double)n-(double)curr[0])/(double)n;
    mult=(double)1/mult;
    double ans=mult;
    for(int i=1;i<3;i++)
    {
        int curr1[3];forn(j,3)curr1[j]=curr[j];
        if(curr[i]>0)
        {
            --curr1[i];++curr1[i-1];
            ans+=mult*(((double)curr[i]/(double)n)*getans(curr1));
        }
    }
    if(n>curr[0]+curr[1]+curr[2])
    {
        int curr1[3];forn(j,3)curr1[j]=curr[j];
        ++curr1[2];
        ans+=mult*(((double)(n-(curr[0]+curr[1]+curr[2]))/(double)n)*getans(curr1));
    }
    dp[curr[0]][curr[1]][curr[2]]=ans;
    return ans;
}
void solve()
{
    cin>>n;
    forn(i,n+1)forn(j,n+1)forn(k,n+1)dp[i][j][k]=-1;int curr[3]={0,0,0};
    forn(i,n){int x;cin>>x;if(x==1)++curr[1];else if(x==2)++curr[2];}
    dp[n][0][0]=0;
    cout<<setprecision(16)<<getans(curr)<<endl;
}
int main()
{
    IOS;cin.tie(NULL);
    int zz;zz=1;
    //cin>>zz;
    for(int zzz=1;zzz<=zz;zzz++)
    {
        solve();
    }
    return 0;
}


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

int main  () {
  int N, K;
  cin >> N >> K;
  vector<int> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data[i];
  }
  sort(data.begin(), data.end(), greater<int>());
  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += data[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, k := scanInt(), scanInt()
	xm := make(map[int]bool)
	for i := 0; i < k; i++ {
		d := scanInt()
		for i := 0; i < d; i++ {
			a := scanInt()
			xm[a] = true
		}
	}
	fmt.Println(n - len(xm))
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,m;
  cin >> n >> m;
  vector<pll> c(n);
  for(ll i=0;i<n;i++) {
    ll a,b;
    cin >> a >> b;
    c[i]={a,b};
  }
  sort(c.begin(),c.end());
  ll ans=0;
  for(ll i=0;i<n;i++) {
    if(c[i].second<=m) {
      ans+=c[i].first*c[i].second;
      m-=c[i].second;
    }
    else if(m) {
      ans+=c[i].first*m;
      m=0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cmath>

int main(int argc, const char * argv[]) {
    int A(0), B(0), H(0), M(0);
    scanf("%d %d %d %d", &A, &B, &H, &M);

    if (H >= 12) {
        H -= 12;
    }

    double pi = 3.141592653589793;
    double initialRadian = pi / 2.0;

    int elapseA = (H * 60) + M;
    double vA = ((2.0 * pi) / (12.0 * 60.0)) * -1.0;
    double xA = A * std::cos((elapseA * vA) + initialRadian);
    double yA = A * std::sin((elapseA * vA) + initialRadian);

    double vB = ((2.0 * pi) / 60.0) * -1.0;
    double xB = B * std::cos((M * vB) + initialRadian);
    double yB = B * std::sin((M * vB) + initialRadian);

    double dis = std::sqrt(std::pow(xB - xA, 2) + std::pow(yB - yA, 2));

    std::cout << std::fixed << std::setprecision(20) << dis;

    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define INF 1e9
#define eps 1e-6
typedef long long ll;
using namespace std;

int n, r;

int main(){

	scanf("%d%d", &n, &r);
	if(n >= 10) printf("%d\n", r);
	else printf("%d\n", r + 100 * (10 - n));

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
int main(){
	int n,ans=0;
	cin >> n;
	for (int i=1;i<n;i++){
		for (int j=1;j<=n/i;j++){
			int a=n-i*j;
			float b=n-i*j;
			if (a==b&&a!=0){
				ans++;
			}
		}
	}
	cout << ans;
} 


Measured memory_bytes: 3620
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,n) for(int i = -1; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = unsigned long long;

const int m = 10000000;

ll to[m];

int main() {

	ll n , s=0;

	cin >> n;

	rep(i, n) {

		ll x;
		cin >> x;
		to[x]++;
		s += x;
	}

	ll q;

	cin >> q;

	rep(i, q) {
		ll b, c;

		cin >> b >> c;
	
		s -= b * to[b];
		s += c * to[b];

		to[c] += to[b];
		to[b] = 0;
		 
		cout << s << endl;

	}


	return 0;
}

Measured memory_bytes: 4328
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

////////// 二項係数(N<=10^7) //////////

ll fac[MAX],finv[MAX],inv[MAX];

// テーブルを作る前処理
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(ll i=2; i<MAX; ++i){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

// 二項係数計算
ll COM(ll n,ll k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

//////////////////////////////////////////////////

int main(){
  ll N,ans=0;
  cin>>N;
  COMinit();
  ll cnt[N];
  REP(i,N) cnt[i]=0;
  
  for(ll i=1; i<=N-1; ++i){
    cnt[i]=COM(i-1,N-1-i)*fac[i];
    cnt[i]%=MOD;
    cnt[i]*=fac[N-1-i];
    cnt[i]%=MOD;
    ans+=(cnt[i]-cnt[i-1])*i;
    ans%=MOD;
  }
  
  if(ans<0) ans+=MOD;
  co(ans);
  return 0;
}

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

typedef long long ll;

int
main(void){
  
  int n; cin >> n;
  string s; cin >> s;
  int arr[10010];

  for(int i = 0; i < s.length(); i++){
    arr[i] = s[i] + n;
    if(arr[i] > 90){
      int diff = arr[i] - 90;
      arr[i] = 64 + diff;
    }
  }
  
  for(int i = 0; i < s.length(); i++){
    printf("%c",arr[i]);
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

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

int main(void) {
    long long int a,b;
    long long int p,q;

    cin>>a>>b;

    if(a!=b){
        if(a>b){
            FOR(i,1,a){
                cout<<b;
            }
        }else{
            FOR(i,1,b){
                cout<<a;
            }
        }
    }else{
        FOR(i,1,a){
            cout<<b;
        }
    }
}


Measured memory_bytes: 256