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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(c)     for(bool p=1;p;p=next_permutation(ALL(c)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<typename T>string join(const vector<T>& v, string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(d.length());}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v)
{if(SZ(v))s<<join(v,", ");return s;}

const ll inf = 1e15;
const ll mod = 1e9+7;
const double eps = 1e-10;

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

struct edge { ll from, to, cost; };
edge es[2002];

ll d[1002];
ll V, E;

void bellman_ford(ll s) {
    REP(i, V) d[i] = inf;
    d[s] = 0;
    REP(i, V-1) REP(j, E) {
        edge e = es[j];
        if (d[e.from] == inf) continue;
        d[e.to] = min(d[e.to], d[e.from] + e.cost);
    }
}

bool find_negative_loop() {
    memset(d, 0, sizeof(d));
    REP(i, V) REP(j, E) {
        edge e = es[j];
        if (d[e.to] > d[e.from] + e.cost) {
            d[e.to] = d[e.from] + e.cost;
            if (i == V - 1) return true;
        }
    }
    return false;
}

bool find_negative_loop(ll t) {
    vector<bool> negative(V, false);
    REP(i, V) REP(j, E) {
        edge e = es[j];
        if (d[e.from] == inf) continue;
        
        if (d[e.to] > d[e.from] + e.cost) {
            d[e.to] = d[e.from] + e.cost;
            negative[e.to] = true;
        }
        if (negative[e.from]) negative[e.to] = true;
    }
    return negative[t];
}

int main() {
    ll N, M; cin >> N >> M;
    REP(i, M) {
        ll a, b, c; cin >> a >> b >> c;
        a--; b--;
        es[i] = (edge){a, b, -c};
    }
    
    V = N; E = M;
    bellman_ford(0);
    if (find_negative_loop(N-1)) cout << "inf" << endl;
    else cout << -d[N-1] << endl;
    
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
a = N%K
b = abs((N%K) - K)

if N//K==0:
    if abs(N-K) > N:
        print(str(N))
    else:
        print(str(abs(N-K)))
elif N%K==0 or N==0:
    print("0")
elif K==2:
    print("1")
else:
    if a < b:
        print(str(a))
    else:
        print(str(b))


Measured memory_bytes: 3060
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

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

const int MAX = 10000;

void Main() {
  string s;
  cin >> s;
  if (s.size() %2) {
    cout << "No" << endl;
    return;
  }
  rep(i, s.size()) {
    if (i%2==0 && s[i] == 'h') continue;
    if (i%2==1 && s[i] == 'i') continue;
    cout << "No" << endl;
    return;
  }
  cout << "Yes" << endl;
  return;
}

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


Measured memory_bytes: 256
n,q = map(int,input().split())
s = input()
a = [0]*2
for i in range(2,n+1):
    a += [a[i-1]+s[i-2:i].count('AC')]
ans = []
for _ in range(q):
    l,r = map(int,input().split())
    ans.append(a[r]-a[l])
print(*ans, sep='\n')

Measured memory_bytes: 13452
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

ll a[100002] = {};
ll b[100001] = {};
int main() {
	ll n; cin >> n;
	repe(i, 1, n + 1) cin >> a[i];
	repe(i,1,n)cin >> b[i];


	ll ans = 0;
	repe(i, 1, n) {
		if (a[i] >= b[i]) {
			ans += b[i];
		}
		else {
			ans += a[i];
			ll r = b[i] - a[i];
			if (a[i + 1] >= r) {
				ans += r;
				a[i + 1] -= r;
			}
			else {
				ans += a[i + 1];
				a[i + 1] = 0;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
	int N, K;

	scanf("%d %d", &N, &K);

	long double result = 0;

	for (int i = 1; i <= N; ++i)
	{
		int temp = i;
		long double probability = 1;

		while (temp < K)
		{
			temp *= 2;
			probability /= 2;
		}

		result += probability;
	}

	printf("%.10Lf\n", result / N);

	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using static Scanner;

class Program
{
    static void Main() => new Program().Solve();

    public void Solve()
    {
        int n = ReadInt();
        var a = ReadLong(n).ToArray();
        var dic = new Dictionary<long, long>();
        dic[0] = 1;
        for (int i = 0; i < n; i++)
        {
            if (i > 0) a[i] += a[i - 1];
            if (dic.ContainsKey(a[i])) dic[a[i]]++;
            else dic[a[i]] = 1;
        }
        Console.WriteLine(dic.Values.Sum(x => x * (x - 1) / 2));
    }
}

static class Scanner
{
    static Queue<string> que = new Queue<string>();
    public static string Read() { if (!que.Any()) foreach (var s in Console.ReadLine().Split()) que.Enqueue(s); return que.Dequeue(); }
    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());
    public static decimal ReadDecimal() => decimal.Parse(Read());
    public static IEnumerable<string> Read(long n) { for (long i = 0; i < n; i++) yield return Read(); }
    public static IEnumerable<int> ReadInt(long n) => Read(n).Select(int.Parse);
    public static IEnumerable<long> ReadLong(long n) => Read(n).Select(long.Parse);
    public static IEnumerable<double> ReadDouble(long n) => Read(n).Select(double.Parse);
    public static IEnumerable<decimal> ReadDecimal(long n) => Read(n).Select(decimal.Parse);
}

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

typedef long long int ll;

#define MAX 200005
set<int> adj[MAX];
bool vis[MAX];

int dfs(int s){
	int ret = 1;
	vis[s] = true;
	for(auto v : adj[s]){
		if(!vis[v]){
			ret+=dfs(v);
		}
	}
	return ret;
}

int main(){
	int n, m; scanf("%d %d",&n, &m);
	
	for(int i=0;i<=n;i++) vis[i] = false;
	
	for(int i=0;i<m;i++){
		int u, v; scanf("%d %d",&u,&v);
		adj[u].insert(v);
		adj[v].insert(u);
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			int tmp = dfs(i);
			ans = max(ans, tmp);
		}
	}
	printf("%d",ans);
	
}


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

int main(void) {
    int r, d, x;
    
    scanf("%d %d %d", &r, &d, &x);
    long long ans = x;
    for(int i = 0; i < 10; i++){
        ans = r * ans - d;
        printf("%lld\n", ans);
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll h, w, k;
string s[303];
ll piece[303][303];
ll dy[4]={0, 1, 0, -1};
ll dx[4]={1, 0, -1, 0};
int main(){
    cin>>h>>w>>k;
    REP(i, 0, h) cin>>s[i];

    ll cnt=1;
    REP(i, 0, h){
        REP(j, 0, w){
            if(s[i][j]!='#') continue;
            
            ll l=0, u=0, r=0, d=0;
            // left
            while(j-l>0){
                l++;
                if(s[i][j-l]=='#' || piece[i][j-l]!=0){
                    l--;
                    break;
                }
            }

            // up
            while(i-u>0){
                u++;
                bool goPos=true;
                REP(jj, 0, l+1){
                    if(s[i-u][j-jj]=='#' || piece[i-u][j-jj]!=0){
                        goPos=false;
                        break;
                    }
                }
                if(!goPos){
                    u--;
                    break;
                }
            }

            // right
            while(j+r<w-1){
                r++;
                bool goPos=true;
                REP(ii, 0, u+1){
                    if(s[i-ii][j+r]=='#' || piece[i-ii][j+r]!=0){
                        goPos=false;
                        break;
                    }
                }
                if(!goPos){
                    r--;
                    break;
                }
            }

            // down
            while(i+d<h-1){
                d++;
                bool goPos=true;
                REP(jj, -l, r+1){
                    if(s[i+d][j+jj]=='#' || piece[i+d][j+jj]!=0){
                        goPos=false;
                        break;
                    }
                }
                if(!goPos){
                    d--;
                    break;
                }
            }

            REP(y, i-u, i+d+1){
                REP(x, j-l, j+r+1){
                    piece[y][x]=cnt;
                }
            }
          
            cnt++;
        }
    }

    REP(i, 0, h){
        REP(j, 0, w-1){
            cout<<piece[i][j]<<" ";
        }
        cout<<piece[i][w-1]<<endl;
    }
    return 0;
}

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

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

  int count = 1;
  int sum = y + (z * 2);
  while (x - sum >= y + z) {
    sum += y + z;
    count ++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
/*input 
999983
*/ 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ld double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e16;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int k;
    cin>>k;
    int cur=0;
    REP1(i,k){
        cur=(cur*10+7)%k;
        if(cur==0){
            cout<<i;
            return 0;
        }
    }
    cout<<-1;
}


Measured memory_bytes: 3636
//
//  main.cpp
//  zoj2853
//
//  Created by cfhaiteeh on 14/03/2018.
//  Copyright © 2018 cfhaiteeh. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#define  LL long long

using namespace  std;
const int maxn=2*123456;
struct he{
    int l,r;
}edge[maxn];
int fa[maxn];

int ai[maxn];
int n;
void init(){
    memset(fa,0,sizeof(fa));
    for(int i=1;i<=n;i++)scanf("%d",&ai[i]);
    for(int i=1;i<=n;i++)edge[i].l=edge[i].r=0;
    for(int i=1;i<=n;i++){
        int p=fa[ai[i]-1];
        if(p==0){
            edge[i].l=0;
            
        }
        else{
            edge[i].l=p;
            edge[p].r=i;
        }
        fa[ai[i]]=i;
    }
}
int ans;
void play(){
    ans=1e9;
 
    for(int i=1;i<=n;i++){
        if(edge[i].r==0){
            int st=i;
            int sum=1;
            while(edge[st].l!=0){
                st=edge[st].l;
                sum++;
            }
            ans=min(n-sum,ans);
        }
    }
}
void pri(){
    
    printf("%d\n",ans);
}
int main() {
    // insert code here...
  //  LL t=1000000000000000000
    while(scanf("%d",&n)!=EOF){
        init();
        play();
        pri();
    }
    return 0;
}


Measured memory_bytes: 3584
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] ans=new int[n];
		for(int i=1; i<n; i++){
			int a=sc.nextInt()-1;
			ans[a]++;
		}
		for(int i=0; i<n; i++){
			System.out.println(ans[i]);
		}
	}
}


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

using namespace std;

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

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back
#define pb push_back

vector<int> a;
vector<int> b;
vector<int> c;


int main(void){
  int n;
  int ans = 0;
  cin >> n;
  a.resize(n);
  b.resize(n);
  c.resize(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n-1) cin >> c[i];
  c[n-1] = 0;

  rep(i,n){
    ans += b[a[i]-1];
    if (i != 0 && a[i] == a[i-1]+1){
      ans += c[a[i-1]-1];
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p = sorted(p,reverse=True)
q = sorted(q,reverse=True)
r = sorted(r,reverse=True)
p = p[:X]
q = q[:Y]
tmp_rev = p+q
tmp = sorted(tmp_rev)
ans = sum(tmp)
a = len(tmp)
b = len(r)
if a<=b:
  for x,y in zip(tmp,r[:a]):
    if y>x:
      ans+=y-x
    else:
      break
else:
  for x,y in zip(tmp[:b],r):
    if y>x:
      ans+=y-x
    else:
      break
      
print(ans)

Measured memory_bytes: 110060
//PLUS ULTRA

#include<bits/stdc++.h>
using namespace std;
     
     
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define mp make_pair
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define nfor(i,st,n) for(int i = st; i >= n ; i--)
#define ss second
#define ff first

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

const int N = 1e5 + 10 , mod =  1000000007;

void solve(){

	int n;
	cin >> n;

	ll sum  = 0;


	forn(i,0,n+1){
		if(i%3!= 0 && i % 5 != 0)sum += i;

	}
    

	cout << sum << endl;

}

int main(){
    SPEED;

  solve();

    return 0;
}
      
       


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;int x,y;
if(n<15)
{

x=800*n;
y=0;
}
else
{
x=800*n;
y=200*(n/15);
}
int z=x-y;
cout<<z;
}


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

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

using namespace std;

typedef long long ll; 



int main(){

    int n;
    scanf("%d",&n);

    ll a[n];

    list<ll> list_1;
    list<ll> list_2;
    //vector<ll>::iterator it;

    rep(i,n) cin>>a[i];

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

        list_1.push_back(a[i]);

        list_2.push_front(a[i]);
        

        list_1.swap(list_2);


    }

    for(list<ll>::iterator it=list_1.begin();it!=list_1.end();++it){

        cout<<*it<<" ";

    }

    cout<<endl;


}

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

using namespace std;

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  int cnt=0;
  while(1){
    bool ans=false;
    rep(i,n){
      if(a[i]%2==1) ans=true;
        a[i]/=2;
    }
    if(ans)break;
    cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main(void){
	long long n, i, num, kind = 0, over = 0;
	long long card[100001] = {};
	
	scanf("%lld", &n);
	
	for (i = 0; i < n; i++){
		scanf("%lld", &num);
		if (card[num-1] == 0) kind++;
		else over++;
		card[num-1] = 1;
	}
	
	if (over%2) over++;
	
	over = n-over;
	
	printf("%lld\n", over);
	
	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int x = 1;
  for (int i = 0; i < N; i++) {
    if (x < K) {
      x = 2 * x;
    } else {
      x = x + K;
    }
  }
  cout << x;
}


Measured memory_bytes: 3512
from itertools import groupby
def rfe_tuple(S):
    grouped = groupby(S)
    res = []
    for k, v in grouped:
        res.append((k, str(len(list(v)))))
    return res

def resolve():
    s = input()
    ls = rfe_tuple(s)
    ans = [0] * len(s)
    n = 0
    for lr,i in ls:
        i = int(i)
        if lr=='R':
            n += i
            ans[n-1] += i-i//2
            ans[n] += i//2
        else:
            ans[n-1] += i//2
            ans[n] += i-i//2
            n += i
    print(*ans)
resolve()

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int num = 0;
  for (int i = 0; i < n; i++) {
    while (a.at(i) % 2 == 0) {
      a.at(i) /= 2;
      num++;
    }
  }
  cout << num;
  return 0;
}


Measured memory_bytes: 256
use std::io::stdin;
fn get_string() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

macro_rules! input {
    ($single:ty) => ( get_string().parse::<$single>().unwrap() );
    ($plural:ty,) => ({
        let line = get_string();
        line.split_whitespace().map(|v| v.parse::<$plural>().unwrap()).collect::<Vec<$plural>>()
    });
    ($($plural:ty),+) => ({
        let line = get_string();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$plural>().unwrap()),+)
    });
    ($single:ty; $times:expr) => ( (0..$times).map(|_| input!($single)).collect::<Vec<$single>>() );
    ($($plural:ty),+; $times:expr) => ( (0..$times).map(|_| input!($($plural),+)).collect::<Vec<($($plural),+)>>() );
}

#[allow(dead_code)]
fn get_value<T: std::str::FromStr>() -> T {
    get_string().parse().ok().unwrap()
}
#[allow(dead_code)]
fn get_values_for<T: std::str::FromStr>(times: u64) -> Vec<T> {
    (0..times).map(|_| get_value()).collect()
}
#[allow(dead_code)]
fn get_vector<T: std::str::FromStr>() -> Vec<T> {
    get_string()
        .split_whitespace()
        .map(|v| v.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn get_vectors_for<T: std::str::FromStr>(times: u64) -> Vec<Vec<T>> {
    (0..times).map(|_| get_vector()).collect()
}

fn main() {
    let r = input!(u64);
    let ans;
    if r < 1200 {
        ans = "ABC";
    } else if r < 2800 {
        ans = "ARC";
    } else {
        ans = "AGC";
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#pragma region Macros
#include <bits/stdc++.h>

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

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

void solve() {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n+1);
    for (int i=1; i<n+1; i++) {
        cin >> a.at(i);
    }

    for (int i=2; i<n+1; i++) {
        a.at(i) += a.at(i-1);
    }
    for (int i=0; i<n+1; i++) {
        a.at(i) = (a.at(i) - i) % k;
    }

    ll res = 0;
    map<int, int> mp;
    mp[a.at(0)]++;
    for (int i=1; i<n+1; i++) {
        if (i >= k) mp[a.at(i-k)]--;
        res += mp[a.at(i)];
        mp[a.at(i)]++;
    }

    cout << res << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 11264
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}
/*
ll Integer_factorization(ll n){
    ll num = 0;
    ll ndash = n;
    if(n == 1) return 1;
    ll a = 2;
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    return num;
}
*/

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}

void solve() {
    
    int a[5];
    int m = 10;
    int index = 0;
    for(int i = 0;i < 5;i++) {
        cin  >> a[i];
        if(m > a[i]%10 && a[i]%10 != 0){
             index = i;
             m = a[i]%10;
        }
    }
    int    ans = 0;
    for(int i = 0;i < 5;i++){
        if(i != index) ans += a[i] + (10 - (a[i]%10?a[i]%10:10));
        else ans+=a[index];
    }
    cout << ans << endl;
    
    
}




int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 256
H, W = map(int, input().split())
pic = [list(input()) for _ in range(H)]
ans = 'Yes'
for i in range(H):
    for j in range(W):
        if pic[i][j] == '#':
            if j != 0 and pic[i][j-1] == '#':
                continue
            if j != W-1 and pic[i][j+1] == '#':
                continue
            if i != 0 and pic[i-1][j] == '#':
                continue
            if i != H-1 and pic[i+1][j] == '#':
                continue
            ans = 'No'
            print(ans)
            exit()
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<31)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

ll n, m;

ll fact(ll x) {
    if (x == 0)
      return 1;
    return x * fact(x - 1) % MOD;
}

ll xpowy(ll x, ll y) {
    ll res = 1LL;
    while (y > 0) {
        if ((y & 1))
        res = res * x % MOD;
        x = x * x % MOD;
        y >>= 1;
    }
    return res;
}

  // Combination
ll comb(ll x, ll y) {
    ll a = fact(x);
    ll b = a * xpowy(fact(y), (MOD - 2)) % MOD;
    ll c = b * xpowy(fact(x - y), (MOD - 2)) % MOD;
    return c % MOD;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> m;
    if (0 <= max(n, m) - min(n, m) && max(n, m) - min(n, m) <= 1) 
        cout << (((fact(max(n, m)) % MOD) * fact(min(n, m)) % MOD) % MOD ) * comb(2, (n == m ? 1 : 2)) % MOD << endl;
    else 
        cout << 0 << endl; 
    return 0;
}


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

int array[201];
int main(){
    int n;
    int n2;
    int m;
    int i, j;
    int tarohana;
    int current;
    int a[2];
    int finish;
    cin >> n;
    while(n){
        n2 = n*2;
        for(i=0;i<n2;i++){
            array[i] = 2;
        }
        for(i=0;i<n;i++){
            cin >> m;
            array[m-1] = 1;
        }
        a[0] = n;
        a[1] = n;
        tarohana = 1;
        while(true){
            for(i=0;i<n2;i++){
                if(array[i] == tarohana){
                    array[i] = 0;
                    a[tarohana-1]--;
                    finish = tarohana;
                    tarohana = 3 - tarohana;
                }
                if(!a[0] || !a[1]){
                    break;
                }
            }
            if(!a[0] || !a[1]){
                break;
            }
            tarohana = finish;
        }
        cout << a[1] << endl << a[0] << endl;
        cin >> n;
    }
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void){
	
	int i,k,p;
	int dev;
	
	scanf("%d",&i);
	
	while(i > 0){
		
		scanf(" %d %d",&k,&p);
		
		dev = k % p;
		
		if(dev == 0){
			dev = p;
		}
		
		printf("%d\n",dev);
		
		i--;
	}
	
	return(0);
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int n = scanner.nextInt();
		    
		    System.out.println(n * (n + 1)/2);
		    
		    scanner.close(); }
		  }

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int x; cin>>x;
    if(x==0)cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 3616
#129_D
h, w = map(int, input().split())
s = [input() for _ in range(h)]

L = [[0]*w for _ in range(h)]
R = [[0]*w for _ in range(h)]
U = [[0]*w for _ in range(h)]
D = [[0]*w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue
        elif j == 0:
            L[i][j] = 1
        else:
            L[i][j] = L[i][j-1] + 1
            
for i in range(h):
    for j in range(w-1, -1, -1):
        if s[i][j] == '#':
            continue
        elif j == w-1:
            R[i][j] = 1
        else:
            R[i][j] = R[i][j+1] + 1
            
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue
        elif i == 0:
            U[i][j] = 1
        else:
            U[i][j] = U[i-1][j] + 1
            
for i in range(h-1, -1, -1):
    for j in range(w):
        if s[i][j] == '#':
            continue
        elif i == h-1:
            D[i][j] = 1
        else:
            D[i][j] = D[i+1][j] + 1

ans = 0
for i in range(h):
    for j in range(w):
        x = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
        ans = max(ans, x)
        
print(ans)

Measured memory_bytes: 179716
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 200200
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define LL long long
using namespace std;

int n;
LL t;
int main()
{
	scanf("%d %lld",&n,&t);
	LL sum=0,l=0,r=0;
	rep(i,1,n) {
		LL j;
		scanf("%lld",&j);
		if (r<j) {
			sum+=r-l+1;
			l=j;
		}
	//	printf("%lld\n",l);
		r=j+t-1;
	}
	printf("%lld\n",sum+r-l+1);
	return 0;
 } 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n;
  cin >> n;
  int a = n;
  int f = 0;
  REP(i,9){
    int div = 1;
    REP(j,8-i) div *= 10;
    f += a/div;
    a %= div;
  }
  //cout << f << endl;


  if(n%f == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

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

int main(){
  
  int a,b;
  cin>>a>>b;
  if(b%a==0)cout<<a+b<<endl;
  else cout <<b-a<<endl;
}



Measured memory_bytes: 3600
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

#define REP(I, S, E) for (decltype(S + E) I = (S), _E = (E); I < _E; ++I)
#define REP_REV(I, S, E) for (decltype(S + E) I = (E)-1, _S = (S); I >= _S; --I)

using i64 = std::int64_t;
using std::cin;
using std::cout;
using std::endl;

template <typename T>
static auto vec_new(T const &init, std::size_t len) -> std::vector<T> {
    return std::vector<T>(len, init);
}

static auto pow(i64 x, i64 n, i64 P) -> i64 {
    x %= P;
    auto y = 1L;

    while (true) {
        REP(i, 0, 2) {
            if (n <= 0) {
                return y % P;
            }

            if (n % 2 != 0) {
                y *= x;
                n -= 1;
            }

            x *= x;
            n /= 2;
        }

        y %= P;
        x %= P;
    }
}

auto main() -> signed {
    i64 P;
    cin >> P;

    auto A = vec_new(0L, P);
    REP(i, 0, P) { cin >> A[i]; }

    auto fact = vec_new(0L, P);
    fact[0] = 1L;
    fact[1] = 1L;
    REP(n, 2, P) { fact[n] = n * fact[n - 1] % P; }

    auto fact_inv = vec_new(0L, P);
    REP(n, 0, P) { fact_inv[n] = pow(fact[n], P - 2, P); }

    auto combo = [&](i64 n, i64 k) {
        auto z = fact[n];
        z *= fact_inv[k];
        z *= fact_inv[n - k];
        return z % P;
    };

    auto B = vec_new(0L, P);
    REP(i, 0, P) {
        if (A[i] == 0) {
            continue;
        }

        REP(k, 0, P) {
            auto b = combo(P - 1, k);
            b *= pow((P - i), P - 1 - k, P);
            B[k] -= b;
        }

        B[0] += 1;
    }

    REP(i, 0, P) {
        if (i != 0) {
            cout << ' ';
        }

        cout << (B[i] % P + P) % P;
    }
    cout << endl;
}


Measured memory_bytes: 384
module ABC130

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_B
  private :: calculate_num_bounce

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_B

    ! variables for this <subroutine>
    integer(INT32) :: num_landing_all
    integer(INT32) :: coordinate_limit

    ! array for this <subroutine>
    integer(INT32), dimension(:), allocatable :: coordinate_landing

    ! STEP.01
    ! read out the number of times to land
    ! read out the upper limit of coordinate
    read(unit=INPUT_UNIT, fmt=*) num_landing_all, coordinate_limit

    ! STEP.02
    ! allocate the array to store the coordinates to land
    allocate( coordinate_landing(1:num_landing_all) )

    ! STEP.03
    ! read out the coordinates to land
    read(unit=INPUT_UNIT, fmt=*) coordinate_landing(1:num_landing_all)

    ! STEP.04
    ! output the result
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') calculate_num_bounce(num_landing_all, coordinate_landing, coordinate_limit)

    ! STEP.END
    return

  end subroutine task_B

  function calculate_num_bounce (num_landing_all, data_cd_landing, data_cd_limit) result(num_landing)

    ! arguments for this <function>
    integer(INT32), intent(in) :: num_landing_all
    integer(INT32), intent(in) :: data_cd_landing(1:num_landing_all)
    integer(INT32), intent(in) :: data_cd_limit

    ! return value of this <function>
    integer(INT32) :: num_landing

    ! variables for this <function>
    integer(INT32) :: coordinate_reached(1:num_landing_all)

    ! support variables for this <function>
    integer(INT32) :: itr

    ! STEP.01
    ! initialize ...
    ! 1. the number of times to land
    ! 2. the coordinate to reach
    num_landing           = 1_INT32
    coordinate_reached(1) = data_cd_landing(1)

    ! STEP.02
    ! calculate the coordinate to reach
    do itr = 2_INT32, num_landing_all, 1_INT32
      coordinate_reached(itr) = coordinate_reached(itr-1) + data_cd_landing(itr)
    end do

    ! STEP.03
    ! calculate the number of times to bounce before reaching the limit
    do itr = 1_INT32, num_landing_all, 1_INT32
      if (coordinate_reached(itr) .le. data_cd_limit) then
        num_landing = num_landing + 1_INT32
      else
        exit
      end if
    end do

    ! STEP.END
    return

  end function calculate_num_bounce

end module ABC130


program main

  ! <module>s to import
  use, non_intrinsic :: ABC130

  ! require all variables to be explicitly declared
  implicit none

  call task_B

end program main

Measured memory_bytes: 256
//?????????????????¨
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
	// TODO ?????????????????????????????????????????????
		Scanner kb=new Scanner(System.in);
int[][] a=new int[10000][2];
int i=0;
int dCount=0;
		while(true){
		a[i][0]=kb.nextInt();
		a[i][1]=kb.nextInt();
	
		if(a[i][0]==0&&a[i][1]==0){
			i++;
			dCount=i;
			break;
		}
		i++;
}
		
int oneTimeNum=0;
		for(int j=0;j<=dCount;j++){
			if(a[j][0]==0&&a[j][1]==0){
				break;
			}
		else if(a[j][0]>a[j][1]){
			oneTimeNum=a[j][0];
			a[j][0]=a[j][1];
			a[j][1]=oneTimeNum;
			System.out.printf("%d %d\n"
					,a[j][0],a[j][1]);
			continue;
			}
			System.out.printf("%d %d\n"
					,a[j][0],a[j][1]);
		}
		
	}

}

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

int main() {
int n,t,a;
cin >> n >> t >> a;
vector<double> A(n);

rep(i,n){
  int h;
  cin >> h;
  A.at(i) = abs(a-(t - h*0.006));
}
int ans;
double min = 1000000000;
rep(i,n){
  if(min > A.at(i)){
    ans = i+1;
    min = A.at(i);
  }
}
cout << ans << endl;

 }


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
deque<PII> dq;
int n;
bool b[510][510];
int d[510][510];
int a[250010];
vector<PII> v;
int d1[4]={1,-1,0,0};
int d2[4]={0,0,1,-1}; 
int res,xr,yr;
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n*n;i++) scanf("%d",&a[i]),a[i]--;
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<n;j++)
		{
			b[i][j]=1,d[i][j]=1e9;
			if (!i || i==n-1 || !j || j==n-1)
				v.push_back(MP(i,j)),d[i][j]=0;
		}
	}
	for (int i=0;i<n*n;i++)
	{
		if (i) dq.push_back(MP(xr,yr));
		else for (int j=0;j<v.size();j++) dq.push_back(v[j]);
		while (!dq.empty())
		{
			int x=dq.front().Fst,y=dq.front().Snd;
			dq.pop_front();
			for (int j=0;j<4;j++)
			{
				int xi=x+d1[j],yi=y+d2[j];
				if (xi<0 || yi<0 || xi>=n || yi>=n) continue;
				if (d[xi][yi]<=d[x][y]+b[x][y]) continue;
				d[xi][yi]=d[x][y]+b[x][y];
				if (b[x][y]) dq.push_back(MP(xi,yi));
				else dq.push_front(MP(xi,yi));
			}
		}
		xr=a[i]/n,yr=a[i]%n;
		res+=d[xr][yr],b[xr][yr]=0;
	}
	printf("%d",res);
	return 0;
} 

Measured memory_bytes: 6888
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    let mut a: String = read();
    let mut b: String = read();
    let aa: bool = a.pop().unwrap() == 'H';
    let bb: bool = b.pop().unwrap() == 'H';
    println!("{}", if !aa ^ bb { "H" } else { "D" })
}


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

#define MOD 1000000007
const long long INF = 1LL << 60;

vector<pair<ll,ll>> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define MAX_N 100010
bool x[MAX_N];
ll num[MAX_N];
 
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n,all=0,ans=INF,al=0;
    cin >> n;
    ll x[n];
    for (ll i=0;i<n;i++){
        cin >> x[i];
        all+=x[i];
    }
    for (ll i=0;i<n;i++){
        al+=x[i];
        if (al>=all/2){
            ans=min(abs(all-al-al),abs(all-(al-x[i]))-(al-x[i]));
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int q;
  int order;
  int x;
  int d;
  deque<int> deq;
  cin >> q;
  for (int i = 0; i < q; i++)
  {
    cin >> order;
    switch (order)
    {
    case (0):
      cin >> d;
      cin >> x;
      if (d == 1)
      {
        deq.push_back(x);
      }
      else
      {
        deq.push_front(x);
      }
      break;
    case (1):
      cin >> x;
      cout << deq.at(x) << endl;
      break;
    case (2):
      cin >> d;
      if (d == 1)
      {
        deq.pop_back();
      }
      else
      {
        deq.pop_front();
      }
      break;
    }
  }
}


Measured memory_bytes: 4640
#include <iostream>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define MAX 2
int main(void)
{
	int a,b;
	int ttmp;
	double tmp;

	cin >> a;
	cin >> b;

	ttmp = a/b;
	tmp = (double)a/(double)b;

	printf("%d ", ttmp);
	printf("%d ", a%b);
	printf("%lf\n", tmp);

	return 0;
}



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

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

    int x = n/4;

    for(int i = 0;i<=x;i++){
        int left = n-4*i;
        int y = left/7;
        if(y*7 == left){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
	int n;
	cin >> n;
	string a;
	cin >> a;
	vector<int> b(n);
	for (int i = 0; i < n; i++) {
		if (a[i] == 'W') b[i] = -1;
		else b[i] = 1;
	}
	vector<int> c(n);
	c[0] = b[0];
	for (int i = 1; i < n; i++) c[i] = c[i - 1] + b[i];
	int m=-1000000;
	int p;
	for (int i = 0; i < n; i++) if (m < c[i]) m = c[i], p = i;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (i < p) {
			if (b[i] == -1) ans++;
		}
		if (i > p) {
			if (b[i] == 1) ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 2948
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	lnt n,k;
	std::cin >> n >> k;
	std::vector<lnt> a(n);
	rep(i,n) std::cin >> a[i];
	lnt l=0,r=1e9+1;
	while(r-l>1) {
		lnt o=(r+l)/2;
		// how many times needed
		lnt count=0;
		rep(i,n) {
			count+=(a[i]-1)/o;
		}
		if(count<=k) r=o;
		else l=o;
	}
	print(r);
}


Measured memory_bytes: 4708
def calc():
  H,W,M = map(int, input().split())
  s = []
  hcount = [0]*H
  wcount = [0]*W
  for m in range(M):
    h,w = map(int, input().split())
    h = h - 1
    w = w - 1
    hcount[h] = hcount[h] + 1
    wcount[w] = wcount[w] + 1
    s.append((h,w))
  hmax = max(hcount)
  wmax = max(wcount)
  hmode = [h for h, x in enumerate(hcount) if x == hmax]
  wmode = [w for w, y in enumerate(wcount) if y == wmax]
  s = tuple(s)
  S = set(s)
  for h in hmode:
    for w in wmode:
      if ((h,w) not in S):
        return hmax + wmax
  return hmax + wmax - 1
  
if __name__ == '__main__':
    print(calc())

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	string s,t;cin>>s>>t;
	cout<<t<<s<<endl;
}

Measured memory_bytes: 256
#include<iostream>
    using namespace std;
    int main()
    {
      int arr[32]={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};
      int n;
      cin>>n;
      n=n-1;
      cout<<arr[n];  
      return 0;
    }

Measured memory_bytes: 256
#pragma GCC optimize ("O3", "unroll-loops")
#pragma GCC target ("avx")
#include <stdio.h>

constexpr char* S_OUT[31] = {
    "0\n", "1\n", "2\n", "3\n", "4\n", "5\n", "6\n", "7\n", "8\n", "9\n", "10\n",
    "11\n", "12\n", "13\n", "14\n", "15\n", "16\n", "17\n", "18\n", "19\n", "20\n",
    "21\n", "22\n", "23\n", "24\n", "25\n", "26\n", "27\n", "28\n", "29\n", "30\n"
};

constexpr unsigned int InputSize = 1e6;
constexpr unsigned int OutputSize = 1e5;
char Input[InputSize];
char* pointer = Input;
char Output[OutputSize];
char* m_buffer = Output;

inline unsigned int getInt(void){
    unsigned int res = 0;
    do{ res = 10 * res + (*(pointer++) - '0'); } while(*pointer >= '0');
    return res;
}

inline void out(const unsigned int v){
    char* str = S_OUT[v];
    while(*str) *(m_buffer++) = *(str++);
}

unsigned int n;
unsigned int N;
constexpr unsigned int SIZE = (1U << 19) + 1;
unsigned int data[2 * SIZE];

inline void set(void){
    n = getInt(); N = 1U << (31 - __builtin_clz(n)); while(N < n) N <<= 1;
    ++pointer; // \n
    unsigned int i, j;
    for(i = 0, j = N; i < n; ++i, ++j) data[j] = 1U << (*(pointer++) - 'a');
    for(i = N - 1; i ; --i){
      j = i << 1; data[i] = data[j] | data[j | 1U];
    }
}

inline void query(void){
    pointer += 3;
    if(*(pointer - 2) == '1'){
        unsigned int index = getInt() - 1;
        unsigned char idx = *((++pointer)++) - 'a';
        data[index += N] = 1U << idx;
        for(unsigned int i = index; i >= 2; i >>= 1) data[i >> 1] = data[i] | data[i ^ 1];
    }
    else{
        unsigned int l = getInt() + N - 1; pointer++;
        unsigned int r = getInt() + N;
        unsigned int res = 0;
        while(l < r){
            if(l & 1) res |= data[l++]; l >>= 1;
            if(r & 1) res |= data[--r]; r >>= 1;
        }
        out(__builtin_popcount(res));
    }
}

int main(void){
    fread(Input, sizeof(char), InputSize, stdin);
    set(); ++pointer;
    unsigned int q = getInt();
    while(q--) query();
    fwrite(Output, sizeof(char), m_buffer - Output, stdout);
    return 0;
}


Measured memory_bytes: 5120
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<cctype>
#include<cmath>
#include<cassert>
#include<deque>
using namespace std;
int main()
{
	int N;
	cin >> N;
	cout << N/3;
	return 0;
}

Measured memory_bytes: 256
N = 26
ord_a = ord('a')
S = [ord(s) - ord_a for s in input()]
K = int(input())


for i in range(len(S)):
    r = (N - S[i]) % N
    if K >= r:
        K -= r
        S[i] = 0


S[-1] += K % N
S[-1] %= N

answer = ''.join(chr(s + ord_a) for s in S)
print(answer)


Measured memory_bytes: 4796
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,s,ans1,ans2;
	while(true){
	cin>>n;
	if(n==0)
		break;
	ans1=0,ans2=100000;
	for(int i=0;i<n;i++){
		int count=0;
		for(int j=0;j<5;j++){
			cin>>s;
			count+=s;
		}
		ans1=max(ans1,count);
		ans2=min(ans2,count);
	}
	cout<<ans1<<" "<<ans2<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep2(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const ll mod = 1e9+7;
int gcd(int a, int b){if(a<b) swap(a,b); if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

long long N, M, K, H, W, L, R;

int main(){
  cin >> H >> W;
  vvi c(10,vi(10));
  rep(i,10)rep(j,10) cin >> c[i][j];
  vvi wall(H,vi(W));
  rep(i,H)rep(j,W) cin >> wall[i][j];
  
  rep(k,10){
    rep(i,10){
      rep(j,10){
        c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
      }
    }
  }
  /*
  rep(i,10){
    rep(j,10){
      cout << c[i][j] << " ";
    }
    cout << endl;
  }*/
  
  ll ans = 0;
  rep(i,H){
    rep(j,W){
      if(wall[i][j]== -1) continue;
      ans += c[wall[i][j]][1];
    }
  }
    
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
int op(int a, int b){
    return max(a, b);
}
int e(){ 
    return 0;
}
int main(){
    int n, k;
    cin >> n >> k;
    vector<int>v(n + 3);
    int mx = 0;
    for(int i = 1; i <= n; i++){
        cin >> v[i];
        mx = max(mx, v[i]);
    }
    segtree<int, op, e> seg(mx + 5);
    vector<int>dp(n + 3, 0);
    for(int i = 1; i <= n; i++){
        int x = max(v[i] - k, 0);
        int y = min(v[i] + k, mx);
        int p = seg.prod(x, v[i] + 1);
        int q = seg.prod(v[i], y + 1);
        if(p == 0){
            dp[i] = 1;
        }
        else{
            dp[i] = dp[p] + 1;
        }
      	if(q != 0){
          	dp[i] = max(dp[i], dp[q] + 1);
        }
        seg.set(v[i], i);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans, dp[i]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 9764
#include<iostream>
#include<cmath>
using namespace std;
 
int main() {
  int A,B,H,M;
  cin>>A>>B>>H>>M;
  long double hdeg = 360.L * (60.L*H+M) / 720.L;
  long double mdeg = 360.L * M / 60.L;
  long double deg = hdeg - mdeg;
  if (deg < 0) deg += 360.L;
  if (deg > 180) deg = 360.L - deg;

  long double ans = sqrt(A*A + B*B - 2*A*B*cos(M_PI * deg / 180));
  printf("%.10Lf\n", ans);
  return 0;
}

Measured memory_bytes: 3512
#include <iostream>
#include <bits/stdc++.h>
#define ll long long int 
#define MOD 1e9 + 7 
#define INF 1<<30
using namespace std ;


int main() {
        ios::sync_with_stdio(false);
        string s ; 
        cin >> s ;
        if(s[0] == '9' || s[1] == '9') 
                cout << "Yes" << endl ; 
        else 
                cout << "No" << endl ; 
        return 0 ;
}

Measured memory_bytes: 256