akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
vector<ll> a,ans;
vector<ll> p;
vector<int> ki[220000];
const ll INF = 100100100100100100LL;
void dfs(int now,int last = -1){
    int ind = lower_bound(p.begin(),p.end(),a[now])- p.begin();
    ll old = p[ind];
    
    p[ind] = a[now];
    ans[now] = lower_bound(p.begin(),p.end(),INF)-p.begin();
    
    for(auto next:ki[now]){
        if(next == last)continue;

        dfs(next,now);
    }
    p[ind] = old;
}
int main()
{
    int n;cin >> n;
    a.resize(n);
    ans.resize(n);
    p = vector<ll>(n,INF);
    
    rep(i,n)cin >> a[i];
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        ki[a].push_back(b);
        ki[b].push_back(a);
    }
    dfs(0);
    rep(i,n)cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 30888
n = gets.to_i
as = gets.split.map(&:to_i)
rains = [as.map.with_index { |a, i| i.even? ? a : -a }.inject(:+)]
(n-1).times do |i|
  rains << 2 * as[i] - rains[i]
end
puts rains.join(" ")


Measured memory_bytes: 14124
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n, k = BigInt(sc.nextBigInteger())
    println(k * pow(k - 1, n - 1))
  }

  def pow(n: BigInt, k: BigInt): BigInt = {
    if (k == 0) {
      1
    } else if (k == 1) {
      n
    } else if (k % 2 == 0) {
      pow(n * n, k / 2)
    } else {
      n * pow(n, k - 1)
    }
  }
}


Measured memory_bytes: 27432
#include<bits/stdc++.h>
#define ll  long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb push_back
#define Max(x,y,z) max(x,max(y,z))
#define f first
#define s second
#define lbd lower_bound
#define sz(x)       (ll)x.size()
#define pi 3.1415926536
#define mod 1000000007
using namespace std;
void solve()
{
    ll n,m,k,y,x,res=0,l,cnt0=0,z,sum1=0,cnt1=0,h,res1,cnt=0;
    cin>>n>>m;
    ll ar[m+1]={0};
    y=n;
    while(y--)
    {
        cin>>k;
        rep(i,0,k)
        {
            cin>>x;
            ar[x]++;
        }
    }
    rep(i,1,m+1)
    if(ar[i]==n)
        cnt++;
    cout<<cnt;

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;

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

    ll n;
    cin >> n;

    for (ll i = 1; i <= 3500; i++)
    {
        for (ll j = 1; j <= 3500; j++)
        {
            ll kc = 4 * i * j - n * (i + j);
            ll kp = n * i * j;

            if (kc <= 0)
                continue;

            if (kp % kc == 0)
            {
                cout << i << " " << j << " " << kp / kc << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int calc(int x) {
	int ret = 0;
	while(x % 100 == 0) {
		x /= 100;
		++ret;
	}
	return ret;
}
int main() {
	int D, N;
	cin >> D >> N;
	int cnt = 0, val = 0;
	while(cnt < N) {
		++val;
		if(calc(val) == D) ++cnt;
	}
	cout << val << '\n';
	return 0;
}




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

int n;
const int nmax = 100000;
int v[nmax-1];
int w[nmax-1];

vector<int> output(const vector<int> &cost)
{
    vector<int> res;
    int now = 1;
    for (auto v : cost)
    {
        for (int i=1; i<v; i++)
        {
            res.push_back(now + i);
        }
        res.push_back(now);
        now += v;
    }
    return res;
}

int main()
{
    cin >> n;
    if (n == 2)
    {
        cout << "1 2" << endl;
        return 0;
    }

    vector<vector<int> > To(n);
    for (int i = 0; i < n - 1; i++)
    {
        cin >> v[i] >> w[i];
        v[i]--;
        w[i]--;
        To[v[i]].emplace_back(w[i]);
        To[w[i]].emplace_back(v[i]);
    }

    vector<int> score(n), isEnd(n);
    for (int i = 0; i < n; i++)
    {
        if (To[i].size() == 1)
        {
            score[To[i][0]]++;
            isEnd[i] = 1;
        }
    }

    int startp = -1;
    for (int i = 0; i < n; i++)
    {
        if (To[i].size() - score[i] > 2)
        {
            cout << "-1\n";
            return 0;
        }
        if (To[i].size() - score[i] <= 1 && !isEnd[i]) startp = i;
    }

    vector<int> costVec;
    while (1)
    {
        costVec.push_back(score[startp] + 1);
        int nextp = -1;
        isEnd[startp] = 1;
        for (auto v : To[startp]) if (!isEnd[v]) nextp = v;
        if (nextp < 0) break;
        startp = nextp;
    }

    costVec[0]--;
    costVec.insert(costVec.begin(), 1);
    costVec.back()--;
    costVec.push_back(1);

    vector<int> res1 = output(costVec);
    reverse(costVec.begin(), costVec.end());
    vector<int> res2 = output(costVec);
    int flg = -1;
    for (int i=0; i<res1.size(); i++)
    {
        if (flg == -1)
        {
            if (res2[i] < res1[i]) flg = 2;
            if (res2[i] > res1[i]) flg = 1;
        }
    }
    for (int i=0; i<res1.size(); i++) cout << (flg==2 ? res2[i] : res1[i]) << " ";
    cout << endl;
}


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

int main(){
	vector<int> a(6), c(4);
	vector<bool> t(4);
	for(int i = 0; i < 4; i++)
	{
		t[i] = false;
	}
	
	for(int i = 0; i < 6; i++)
	{
		cin >> a[i];
		if (a[i] == 1) {
			t[0] = true;
			c[0] += 1;
		}else if (a[i] == 2)
		{
			t[1] = true;
			c[1] += 1;
		}else if (a[i] == 3)
		{
			t[2] = true;
			c[2] += 1;
		}else if (a[i] == 4)
		{
			t[3] = true;
			c[3] += 1;
		}
		
	}
	string ans = "YES";
	for(int i = 0; i < 4; i++)
	{
		if (!t[i]) {
			ans = "NO";
		}
		if (c[i] > 2) {
			ans = "NO";
		}
		
		
	}
	cout << ans << endl;
	
	
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(; sc.hasNext();) {
			int c1 = sc.nextInt();
			int c2 = sc.nextInt();
			int c3 = sc.nextInt();
			boolean[] open = new boolean[10];
			open[c1-1] = open[c2-1] = open[c3-1] = true;
			int num = c1 + c2;
			int cnt = 0;
			for(int i=0;i<10;i++) {
				if( !open[i] && num + (i+1) <= 20 ) cnt++; 
			}
			if(cnt>=4) System.out.println("YES");
			else System.out.println("NO");
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a;
  while(cin >>n &&n){
    string s;
    vector<pair<string,pii>> m(n);
    rep(i,n){
      cin >> s;
      m[i].fi = s;
      rep(j,n-1){
        cin >> a;
        if(a == 0)
          m[i].se.fi++;
        else if(a == 1){
          m[i].se.se++;
        }
      }
    }
    sort(all(m),[](const pair<string,pii> &a,const pair<string,pii> &b){
        if(a.se.fi == b.se.fi) return a.se.se < b.se.se;
        return a.se.fi > b.se.fi;
        });
    for(auto it = m.begin(); it != m.end(); ++it){
      cout << it->fi << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3136
n = int(input())
h = list(map(int,input().split()))
inf = 10**9
dp = [inf]*(10**5)
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(1,n-1):
    dp[i+1]=dp[i]+abs(h[i+1]-h[i])
    dp[i+1]=min(dp[i+1], dp[i-1]+abs(h[i+1]-h[i-1]))
print(dp[n-1])

Measured memory_bytes: 13980
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		double x1, y1, x2, y2;
		x1 = scan.nextDouble();
		y1 = scan.nextDouble();
		x2 = scan.nextDouble();
		y2 = scan.nextDouble();
		
		double d = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
		System.out.println(d);
		
		scan.close();
		
	}

}

Measured memory_bytes: 28116
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    ll x;

    cin >> x;
    
    ll s = 0, i = 0;
    vector<pair<ll, int>> v;
    while(abs(s) < 1e18) {
        s = i * i * i * i * i;
        v.bash({s, i});
        v.bash({-s, -i});
        ++i;
    }

    sort(ALL(v));
    
    for(auto&&a:v) {
        auto p = *lower_bound(ALL(v), pair<ll,int>(a.first - x, -INF));
        if(a.first - p.first == x) {
            cout << a.second __ p.second << endl;
            return 0;
        }
    }

    return 1;
    
  
    return 0;
}



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

int main(void){
  string s; cin >> s;
  int price=700;
  for(int i=0; i<3; i++){
    if(s.at(i) == 'o') price += 100;
  }
  cout << price << endl;
  return 0;             
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
double pi = 3.141592653589793;
ll mod = 1000000007;

int main() {
    int A, B, X;
    cin >> A >> B >> X;
    if(A <= X && X <= A + B) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

int main() {
	int n;
	scanf("%d", &n);
	char w[200][1000];
	for (int i = 0; i < n; i++) {
		scanf("%s", &w[i]);
	}

	int flg_link = 1;
	for (int i = 1; i < n; i++) {
		if (w[i - 1][strlen(w[i - 1]) - 1] != w[i][0]) {
			flg_link = 0;
			break;
		}
	}

	int flg_unique = 1;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (strcmp(w[i], w[j]) == 0) {
				flg_unique = 0;
				break;
			}
		}
		if (flg_unique == 0) break;
	}

	printf(flg_link && flg_unique ? "Yes" : "No");
	return 0;
}

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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
#define v vector
// Template END

int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}

signed main(){
    int s ; cin >> s ;
    // assert( s <= 2000 ) ;
    v<int> dp( s + 1, 0 ) ;
    dp[0] = 1 ;
    // dp[3] = 1 ;
    for( int i = 3 ; i <= s ; i++ ){
        for( int j = 3 ; ( i - j ) >= 0 ; j++ ){
            ( dp[i] += dp[i-j] ) %= mod ;
        }
    }
    cout << dp[s] ;
    return 0 ;   
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	int n = sz(s);
	vi pre(n+1);
	rep(i,0,n) pre[i+1] = pre[i] ^ (1<<(s[i]-'a'));
	map<int,int> dp;
	dp[pre[0]] = 0;
	rep(i,1,n+1){
		int mn = dp.count(pre[i]) ? dp[pre[i]] : n+n;
		rep(j,0,26){
			int val = pre[i]^(1<<j);
			if(dp.count(val))
				mn = min(mn, 1+dp[pre[i]^(1<<j)]);
		}
		dp[pre[i]] = mn;
	}
	cout << max(1, dp[pre[n]]) << endl;
}

Measured memory_bytes: 10644
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

typedef pair<int , pair<int, int> > edge;

int main(){
	int n, m;
	
	while(cin >> n >> m, (n||m)){
		
		int res = 1, t, s, d;
		vector<edge> vc;
		
		for(int i=0; i<m; ++i){
			
			cin>>t>>s>>d;
			vc.push_back(make_pair(t, make_pair(s, d)));
		}
		
		sort(vc.begin(), vc.end());
		
		set<int> infect;
		infect.insert(1);
		
		for(int i=0; i<m; ++i){
			
			if(infect.count(vc[i].second.first) && !infect.count(vc[i].second.second)){
				infect.insert(vc[i].second.second); 
				res++;
			}
		}
		
		cout << res << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2108
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;

int main(){
	fast_io();
	const int N = 1005;
	int div[N] = {};
	int cnt[N] = {};
	int n;
	cin >> n;
	fu(i,2,n){
		if(!div[i]){
			for(int j = i;j <= n;j+=i){
				div[j] = i;
			}
		}
	}
	fu(i,2,n){
		int ind = i;
		while(ind > 1){
			++cnt[div[ind]];
			ind/=div[ind];
		}
	}
	ll ans = 1;
	fu(i,2,n){
		ans = ans * (cnt[i] + 1) % MOD;
	}
	cout << ans << '\n';
}



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

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

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

    ll N,K; cin >> K >> N;

    ll st; cin >> st;
    ll p = st;

    ll ma = 0;
    ll t;

    for (int i = 0;i < N-1;i++){
         cin >> t;
        ma = max(ma,t-p);
        p = t;
    }

    ma = max(st+(K-t),ma);

    cout << K-ma << endl;

    return 0;

}

Measured memory_bytes: 256
class UnionFind:
  
  def __init__(self, n):
    self.par = [i for i in range(n)]
    self.rank = [0]*n
    self.size = n
  def find(self, x):
    if self.par[x]==x:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]
  
  def unite(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x==y:
      return
    self.size -= 1
    if self.rank[x]<self.rank[y]:
      self.par[x] = y
    else:
      self.par[y] = x
      if self.rank[x]==self.rank[y]:
        self.rank[x] += 1
  
  def same(self, x, y):
    return self.find(x)==self.find(y)
  
  def size(self):
    return len(set(self.par))

N, M = map(int, input().split())
union = UnionFind(N)
for i in range(M):
  x, y, z = map(int, input().split())
  union.unite(x-1, y-1)

print(union.size)

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

int main(){
  int k,t;
  cin>>k>>t;
  vector<int> a(t);
  rep(i,t){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  int m = a[t-1];
  rep(i,t-1){
    m-=a[i];
  }
  cout<<max(m-1,0)<<endl;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N, K, R, S, P, ans = 0;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    for (int i = 0; i < N; i++) {
        if (i < K) {
            if (T.at(i) == 'r') {
                ans += P;
            }
            if (T.at(i) == 's') {
                ans += R;
            }
            if (T.at(i) == 'p') {
                ans += S;
            }
        }
        else {
            if (T.at(i - K) == T.at(i)) {
                T.at(i) = 'b';
                continue;
            }
            else {
                if (T.at(i) == 'r') {
                    ans += P;
                }
                if (T.at(i) == 's') {
                    ans += R;
                }
                if (T.at(i) == 'p') {
                    ans += S;
                }
            }
        }
        
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);

int main () {
  int n, d;
  cin >> n >> d;
  cout << dup(n,2*d+1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;


int main(int argc, char const *argv[]) {
	ll n,k;
	cin>>n>>k;
	vector<ll> a(n);
	rep(i,n) cin>>a[i];
	vector<ll> b(a);

	ll tmp = 0ll;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < i; ++j) {
			if (a[j] > a[i]) tmp++;
		}
	}
	tmp%=MOD;
	// cout << tmp << endl;
	
	ll ans = (tmp*k)%MOD;
	// cout << ans << endl;
	

	sort(b.begin(), b.end());
	--k;
	k%=MOD;
	ll sum = (k*(k+1)/2);
	sum%=MOD;
	rep(i,n) {
		ll x = a[i];
		auto itr = upper_bound(b.begin(), b.end(), x);
		ll t = b.end()-itr;
		// printf("x = %lld, t = %lld, sum = %lld\n",x,t,sum);
		ans += (t*sum)%MOD;
		ans%=MOD;
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

D1 = T1 * A1 - T1 * B1
D2 = T1 * A1 + T2 * A2 - T1 * B1 - T2 * B2

if D1 * D2 > 0:
    print(0)
elif D2 == 0:
    print("infinity")
else:
    D1 = abs(D2 - D1)
    D2 = abs(D2)
    c = (D1 // D2) * 2 - 1
    if D1 % D2 == 0:
        c -= 1
    print(c)


Measured memory_bytes: 38508
#include <stdio.h>
int main(){
	long long n;
	for(;~scanf("%lld",&n)&&n;){
		long long r=0;
		int i=2;
		for(;;i++){
			long long x=n-(long long)i*(i-1)/2;
			if(x<i)break;
			if(x%i==0)r++;
		}
		printf("%lld\n",r);
	}
	return 0;
}

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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int b = count(S.begin(), S.end(), '#');
    int ans = N-b;
    int bcnt = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == '#') bcnt++;
        ans = min(ans, bcnt+(N-1-i-(b-bcnt)));
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int a, b, k; cin >> a >> b >> k;

  if ((b-a+1) < k*2) {
    for(int i = a; i<=b; i++) {
      p(i);
    }
  } else {
    for(int i = a; i<a+k; i++) {
      p(i);
    }

    for(int i = b-k+1; i<=b; i++) {
      p(i);
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    map<ll, ll> mp;
    rep(i, n) {
        ll a;
        cin >> a;
        mp[a]++;
    }

    ll ans = 0;
    for(auto p : mp) {
        ll x = p.first;
        ll y = p.second;
        if(y < x) {
            ans += y;
        }
        else {
            ans += y - x;
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define INF 1000000001
#define MOD 1000000007

using namespace std;



int main() {
	string s;
	cin >> s;
	int n = s.size();
	int flag;
	if (s[0] == 'B') flag = 1;
	else flag = 0;
	int cnt = 0;
	FOR(i,1, n) {
		if (flag) {
			if (s[i] == 'W') {
				cnt++;
				flag = 0;
			}
		}
		else {
			if (s[i] == 'B') {
				cnt++;
				flag = 1;
			}

		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 234567;
int p[MAXN];
int Q[MAXN];

int main() {
    int N;
    //freopen("01.txt", "r", stdin);
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) {
        scanf("%d", &p[i]);
        Q[p[i]] = i;
    }
    int pre = 0, ans = 0, cnt = 0;
    for (int i = 1; i <= N; i++) {
        if (Q[i] < pre) {
           cnt = 1;
        } else cnt++;
        pre = Q[i];
        ans = max(cnt, ans);
    }
    printf("%d\n", N - ans);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef pair<int, int> P;
typedef long long int ll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int n;

int main(){
	while(cin >> n){
		if(n == 0) break;
		int ans[10];
		int t = 0, m = 0;
		int d[10][10];
		fill((int*)d,(int*)(d+10), INF);
		clr(ans,0);
		rep(i,10) d[i][i] = 0;
		rep(i,n){
			int temp1, temp2, temp3; scanf("%d%d%d", &temp1, &temp2, &temp3);
			d[temp1][temp2] = temp3; d[temp2][temp1] = temp3;
			if(m < temp1) m = temp1;
			if(m < temp2) m = temp2;
		}
		m++;
		rep(k,m) rep(i,m) rep(j,m) d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
		rep(i,m) rep(j,m) ans[i] += d[i][j];
		for(int i = 1; i < m; i++){
			if(ans[t] > ans[i]) t = i;
		}
		cout << t << " " << ans[t] << endl;
	}
}

Measured memory_bytes: 1244
#include<stdio.h>
#include<ctype.h>

int main(void)
{
    char c;
    int i, count['z'-'a'+1];
    
    for ( i=0; i<'z'-'a'+1; ++i)
        count[i] = 0;
    
    while ( (c=getchar()) != EOF) {
        if ( isalpha(c))
            ++count[tolower(c)-'a'];
    }
    
    /* 書き出し */
    for ( i=0; i<'z'-'a'+1; ++i)
        printf("%c : %d\n", 'a'+i, count[i]);
        
    return 0;
}


Measured memory_bytes: 2040
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <ctype.h>

char s[100010];
int buf[100010];
int ind;
int b1[100010];
int b2[100010];

int main(void)
{
  int l,run,i,j;
  fgets(s,100010,stdin);
  
  ind = 0;
  l = strlen(s);
  while(s[l-1] != '0' && s[l-1] != '1'){
    l--;
  }
  for(i=0;i<l;){
    for(j=i;j<l;j++){
      if(s[i]!=s[j]) break;
    }
    run = j-i;
    buf[ind++] = run;
    i += run;
  }
  if( ind<=1 ){
    printf("%d\n",l);
  } else if(ind==2){
    printf("%d\n", (buf[0]>buf[1] ? buf[0] : buf[1]));
  } else {
    j = 0;
    int min_v = 1000000000;
    for(i=0;i<ind-1;i++){
      j += buf[i];
      int v = j > l-j ? j : l-j;
      if(v<min_v) min_v = v;
    }
    printf("%d\n",min_v);
  }
  return EXIT_SUCCESS; 
}



Measured memory_bytes: 512
import sys

for s in sys.stdin:
    out = ""
    i = 0
    while True:
        if i > len(s)-2 :
            break
        if s[i] == "@":
            out += s[i+2]*int(s[i+1])
            i += 2
        else:
            out += s[i]
        i += 1
    print out

Measured memory_bytes: 4196
number=['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']
a=int(input())
print (number[a-1])

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

int main(){
  int N;
  cin >> N;
  int M = 100*(N%10)+10*(N/10%10)+N/100;
  if (N==M){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
signed main()
{
	int n, ans = 0;
	char s[100000];
	scanf("%d\n%s", &n, s);
	char t = '0';
	for(int i = 0; i < n; ++i)
	{
		if(t != s[i])
		{
			t = s[i];
			++ans;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 384
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[fastout]
fn main() {
    input!(n: usize, w: [Chars; n]);

    for i in 0..w.len() - 1 {
        if w[i][w[i].len() - 1] != w[i + 1][0] {
            println!("No");
            return;
        }
    }

    let ss: std::collections::HashSet<String> = w.iter().map(|x| x.into_iter().collect()).collect();
    if w.len() != ss.len() {
        println!("No");
        return;
    }
    println!("Yes");
}


Measured memory_bytes: 2160
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;


//ある一日でコンテストタイプtiを開催した場合の得点
int calc_point(int stf, vector<vector<int>>sds, vector<int>cs, int d, vector<int>lds, int ti){
    int cnt = 0;
    stf += sds[d][ti];
    for (int j=0; j<26; j++)cnt += cs[j]*(d+1-lds[j]);
    
    stf -= cnt;
    return stf;
}


int main() {
    int D;
    cin >> D;
    vector<int>cs(26);
    vector<vector<int>>sds(D, vector<int>(26));
    for (int i=0; i<26; i++)cin >> cs[i];

    for (int i=0; i<D; i++){
        for (int j=0; j<26; j++){
            cin >> sds[i][j];
        }
    }
    //貪欲法
    int stf = 0;
    vector<int>lds(26);
    for (int i=0; i<D; i++){
        int last_ti, last_score;
        last_ti = last_score = -INF;
        for (int j=0;j<26; j++){
            if (i <= 37){
                //cout << "j: "  << j << endl;
            }
            int score = calc_point(stf, sds, cs, i, lds, j);
            if (score >last_score){
                last_score = score;
                last_ti = j;
            }
        }
        lds[last_ti] = i+1;
        stf = last_score;

        cout << last_ti+1 << endl;
        //cout << "i: " << i << endl;
    }

}

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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n;
  string s;
  cin >> n >> s;

  vector<vector<int>> cnt(n + 1, vector<int> (3, 0));

  map<char, int> m;
  m['R'] = 1;
  m['G'] = 2;
  m['B'] = 0;

  for (int i = 1; i <= n; ++i) {
    cnt[i] = cnt[i-1];
    cnt[i][m[s[i-1]]]++;
  }

  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      if (s[i-1] == s[j-1]) continue;
      int d = m[s[i-1]] + m[s[j-1]];
      ans += cnt[i-1][3-d];
    } 
  }

  for (int i = 0; i < n; ++i) {
    for (int j = 1; j < n; ++j) {
      int l = i + j, r = i + 2 * j;
      if (r >= n) break;
      if (s[i] == s[l] || s[l] == s[r] || s[r] == s[i]) continue;
      ans--;
    }
  }

  cout << ans << '\n';
}

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

using namespace std;

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

  string s;
  cin >> s;
  set<char> hash;
  for (auto &c : s) hash.insert(c);
  cout << (hash.size() == s.size() ? "yes" : "no") << endl;

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
#include<functional>
using namespace std;
#pragma warning(disable: 4996)
long long n, k, a[100009], b[100009], maxn;
int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++)cin >> a[i] >> b[i];
	for (int i = 29; i >= 0; i--) {
		if ((k / (1LL << i)) % 2 == 0 && i >= 1)continue;
		long long V = 0;
		for (int j = 29; j >= i + 1; j--) { V += (1LL << j)*((k / (1LL << j)) % 2); }
		for (int k = i - 1; k >= 0; k--)V += (1 << k);
		if (i == 0 && (k / (1LL << i)) % 2 == 1)V++;
		long long sum = 0;
		for (int j = 1; j <= n; j++) { if ((a[j] | V) == V)sum += b[j]; }
		maxn = max(maxn, sum);
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;

int main(){
string s;
cin>>s;

int A[s.size()+1]={};
int L[100000]={};
int R[100000]={};
char b='R';
R[0]=1;
int r=0,l=0;
for(int i=1;i<s.size();i++){
if(s[i]=='L'){
L[l]++;
}
else{
R[r]++;
}
if(s[i]!=b && s[i]=='L'){
r++;
}
else if(s[i]!=b && s[i]=='R'){
l++;
}
b=s[i];
}

int k=0;
for(int i=0;i<r;i++){
    int sum=R[i]+L[i];
    if(sum%2==0 && R[i]%2==0){
    A[R[i]+k]=sum/2;
    A[R[i]+k+1]=sum/2;
    }
    else if(sum%2==0 && R[i]%2==1){
    A[R[i]+k]=(sum+1)/2;
    A[R[i]+k+1]=(sum+1)/2;
    }
    if(sum%2==1 && R[i]%2==0){
    A[R[i]+k]=sum/2;
    A[R[i]+k+1]=(sum+1)/2;
    }
    else if(sum%2==1 && R[i]%2==1){
    A[R[i]+k]=(sum+1)/2;
    A[R[i]+k+1]=sum/2;
    }
    k+=sum;
}
for(int i=1;i<=s.size();i++){
    cout<<A[i]<<" ";
}
 return 0;
}

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

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    for(int i=0;i<h;i++){
        cin >> s[i];
    }

    bool ok = false;

    for(int x=0;x<h;x++){
        for(int y=0;y<w;y++){
            if(s[x][y] == '#'){
                ok = false;
                for(int dir = 0;dir < 4;dir++){
                    int nh = x + dx[dir];
                    int nw = y + dy[dir];
                    if(nh<0||nh>=h||nw<0||nw>=w) continue;

                    if(s[nh][nw] == '#') ok = true;
                }
                if(!ok){cout << "No" << endl;return 0;}
            }           
        }
    }
    cout << "Yes" << endl;

}


Measured memory_bytes: 256
MOD = 10**9 + 7
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
    for j in range(i+1,n):
        if a[i] > a[j]:
            ans += k*(k+1)//2
        if a[i] < a[j]:
            ans += k*(k-1)//2
        ans %= MOD

print(ans)

Measured memory_bytes: 42220
#include<cstdio>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	int q=a+b,w=a-b,e=a*b;
	if (q>w) w=q;
	if (w>e) e=w;
	printf("%d",e);
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(30) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,0,0);
  P.pb(1);
  rep(i,1,8){
    P.pb(pow(6,i));
    P.pb(pow(9,i));
  }
  Vec(dist,lli,200000,-1);
  dist[0]=0;
  queue<lli>que;
  que.push(0);
  while(!que.empty()){
    auto x=que.front();que.pop();
    for(auto nx:P){
      if(x+nx>150000)continue;
      if(dist[x+nx]!=-1)continue;
      dist[x+nx]=dist[x]+1;
      que.push(x+nx);
    }
  }
  Out(dist[N]);
}

Measured memory_bytes: 2176
#include <iostream>
using namespace std;
long long a[100005];
int main()
{
	long long n,i,ans=0;
	cin>>n;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n;i++)
	{
		if(a[i]==i)
		{
			ans++;
			i++;
		}
	}
	cout<<ans;
}

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

int main() {
  int a, b, i;
  int tmp, remained, reverse = 0;
  int sum = 0;
  
  cin >> a >> b;
  
  for(i = a; i <= b; i++)
  {
    tmp = i;
    
    while(tmp != 0)
    {
      remained = tmp % 10;
      reverse = reverse * 10 + remained;
      tmp /= 10;
    }
    
    if(reverse == i)
      sum++;
    
    reverse = 0;
  }
    
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long
signed main() {
	int n, c, sum = 0; cin >> n >> c;
	for (int i = 0; i < c; i++) {
		int p; cin >> p; sum += p;
	}n++;
	cout << (sum + n - 1) / n << endl;
}


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

int main() {
  int N, K; cin >> N >> K;
  long long ans = 0;
  if (K == 0) {
    cout << (long long)N * (long long)N << endl;
    return 0; 
  }
  for (int i = 1; i <= N; i++) {
    ans += (N/i) * max(i-K, 0) + max(N%i-K+1, 0);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
  string str;

  cin >> str;

  for (int i  = str.length() - 2; i >= 0; i -= 2) {
    if(str.substr(0, i / 2) == str.substr(i / 2, i / 2)) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}



Measured memory_bytes: 384
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define gcd __gcd
#define lcm(n, m) n * m / gcd(n, m)
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// rtsq ルート, int 2*10^9, __gcd

int main() {
  int N, b = 0;
  dl M, a = 0;
  ci(N, M);
  ve<int> A(N);
  rep(i, N){
    ci(A.at(i));
    a += A.at(i);
  }
  rep(i, N){
    if(A.at(i) >= a / (4 * M)){
      b ++;
    }
  }
  if(b >= M){
    co("Yes");
    rt;
  }
  co("No");
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
p = list(map(int,input().split()))
ret = 0
for i in range(1,len(p)-1):
    if p[i-1] < p[i] and p[i] <= p[i+1]:
        ret += 1
    if p[i+1] < p[i] and p[i] <= p[i-1]:
        ret += 1
print(ret)


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();

		int[]a = new int[n];

		for (int i=0; i<n; i++){
			a[i] = sc.nextInt();
		}


		for (int i=k; i<n; i++){
			if (a[i-k] < a[i]){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}


}

Measured memory_bytes: 60208
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<20;

int N,M;
int a[9];
int t[9]={2,5,5,4,5,6,3,7,6};
int c[9];
int x[9];
int ans[9];

int mini=10;
vector<int> v;
int k;

bool check(){
    int ab=0,ac=0;
    for (int i = 0; i < 9; i++) {
        ab+=ans[i];
        ac+=x[i];
    }
    if(ab<ac){
        return true;
    }
    else if(ac==ab){
        for (int i = 8; i >= 0; i--) {
            if(ans[i]>x[i]) return false; 
            else if(ans[i]<x[i]) return true;
        }
        return false;
    }
    else return false;
}

void dfs(int z){
    if(z==-1){
        int p=0;
        for (int i = 0; i < 9; i++) {
            p+=t[i]*x[i];
        }
        if(p>N) return;
        if((N-p)%mini!=0) return;
        x[k]=(N-p)/mini;
        if(check()){
            for (int i = 0; i < 9; i++) {
                ans[i]=x[i];
            }
        }
        x[k]=0;
        return ;
    }
    for (int i = 0; i < 6; i++) {
        x[v[z]]=i;
        dfs(z-1);
        x[v[z]]=0;
    }
}

int main(){
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> a[i];
        a[i]--;
        c[a[i]]=1;
    }
    if(c[8]){
        t[5]=0;
        c[5]=0;
    }
    if(c[4]){
        t[2]=0;
        t[1]=0;
        c[2]=0;
        c[1]=0;
    }
    else if(c[2]){
        t[1]=0;
        c[1]=0;
    }
    for (int i = 0; i < M; i++) {
        if(t[a[i]]<=mini&&c[a[i]]){
            mini=t[a[i]];
            k=a[i];
        }
    }
    c[k]=0;
    for (int i = 0; i <9; i++) {
        if(c[i]) v.pb(i);
    }
    dfs(v.size()-1);
    for (int i = 8; i >= 0; i--) {
        for (int j = 0; j < ans[i]; j++) {
            cout << i+1;
        }
    }
    cout << "\n";
    return 0;
}



Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    l = len(s)
    for i in range(l-1):
        if s[i:i+2] == 'AC':
            return 'Yes'

    return 'No'


print(main())




Measured memory_bytes: 8132
#include<stdio.h>
int A[5000000],cnt;
void merge(int left,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  int L[n1],R[n2];
  for(i=0; i<n1; i++){
    L[i]=A[left+i];
  }
  for(i=0; i<n2; i++){
    R[i]=A[mid+i];
  }
  L[n1]=2147483647;
  R[n2]=2147483647;
  i=0;
  j=0;
  for(k=left; k<right; k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }
    else{
      A[k]=R[j];
      j++;
    }
    cnt++;
  }
}
  
void mergeSort(int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(left,mid);
    mergeSort(mid,right);
    merge(left,mid,right);
  }
}

int main(){
  int i,n;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }

  mergeSort(0,n);

  for(i=0; i<n; i++){
    if(i)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",cnt);

  return 0;
}



Measured memory_bytes: 5688
n,m=map(int,input().split())
List=[list(map(int,input().split())) for i in range(m)]


s=[x[0] for x in List]
c=[x[1] for x in List]

def has_duplicates(seq):
    return len(seq) != len(set(seq))

def not_has_duplicates2(seq):
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    return len(seq) == len(unique_list)

def get_unique_list(seq):
  seen = []
  return [x for x in seq if x not in seen and not seen.append(x)]
  
if has_duplicates(s) and not_has_duplicates2(List):
  print(-1)
else:
  new_List=get_unique_list(List)
  result=0
  for i in range(0,len(new_List)):
    result+=new_List[i][1]*(10**(n-new_List[i][0]))
  if n==1 and result==0:
    print(0)
  elif [1, 0] in new_List:
    print(-1)
  elif result<10**(n-1):
    result+=10**(n-1)
    print(result)
  else:
    print(result)
    

Measured memory_bytes: 3064
S, T, q, *L = open(0).read().split()
sa = [0]
sb = [0]
ta = [0]
tb = [0]
for c in S:
  if c=='A':
    sa.append(sa[-1]+1)
    sb.append(sb[-1])
  else:
    sa.append(sa[-1])
    sb.append(sb[-1]+1)
for c in T:
  if c=='A':
    ta.append(ta[-1]+1)
    tb.append(tb[-1])
  else:
    ta.append(ta[-1])
    tb.append(tb[-1]+1)
for a,b,c,d in zip(*[iter(map(int,L))]*4):
  nsa = sa[b]-sa[a-1]
  nsb = sb[b]-sb[a-1]
  nta = ta[d]-ta[c-1]
  ntb = tb[d]-tb[c-1]
  mb = ntb-nsb
  ma = nta-nsa
  if (2*mb+ma)%3==(2*ma+mb)%3==0:
    print('YES')
  else:
    print('NO')

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


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

struct edge {int to, cost; };

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

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

ll LCM(ll a, ll b){
  if(a<b) swap(a,b);
  return a/GCD(a,b)*b;
}

int main(){
  ll n, m, x;
  cin >> n >> x >> m;
  int cycle, start;
  ll tmp = x;
  vector<ll> vec;
  vec.push_back(x);
  vector<bool> is_exist(m+1, false);
  is_exist[tmp] = true;
  ll ans = 0;
  for(int i=1; i<=m; i++){
    tmp *= tmp;
    tmp %= m;
    if(is_exist[tmp]){
      for(int j=0; j<i; j++){
        if(vec[j]==tmp){
          start = j;
          cycle = i-j;
          break;
        }
      }
      break;
    }
    is_exist[tmp] = true;
    vec.push_back(tmp);
  }
  if(n < start){
    for(int i=0; i<n; i++){
      ans += vec[i];
    }
    cout << ans << endl;
    return 0;
  }
  
  for(int i=0; i<start; i++){
      ans += vec[i];
  }
  n -= start;
  ll s_tmp = 0;
  for(int i=start; i<=start+cycle; i++){
    s_tmp += vec[i];
  }
  ans += s_tmp*(n/cycle);
  if(n%cycle>0){
    for(int i=start; i<start+n%cycle; i++){
      ans += vec[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3876
#include <stdio.h>
#include <math.h>
#define int long long

int ketaf(int,int);

signed main(void)
{
	int n,a,b,i,keta,min=11;
	scanf("%lld",&n);
	for(i=1;i*i<=n;i++)
	{
		/* fprintf(stderr,"mai=%d\n",i); */
		if(n%i==0)
			{
			a=i,b=n/i;
			keta=ketaf(a,b);
			if(keta<min){min=keta;}
			}
	/* if(end==1){break;} */
	}
	printf("%lld\n",min);
return 0;
}

int ketaf(int a,int b)
{
	int i=1,ka=1,kb=1;
	while(1)
	{
		/* fprintf(stderr,"kfi=%d",i ); */
		i*=10;
		if(a/i>=1){ka++;}
		if(b/i>=1){kb++;}
		if(a/i==0 && b/i==0){break;}
	}
	if(ka>=kb){return ka;}
	else{return kb;}
}





Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  if(K<=A){
  cout<<K;
  }else if(K<=A+B){
  cout<<A;
  }else{
  int D=K-A-B;
  cout<<A-D;
  }
}

Measured memory_bytes: 3160