akhauriyash/Code-Regression huggingface dataset:
using System;

class Program
{
    static void Main (string[] args) 
    {
        long N = long.Parse(Console.ReadLine());
        long[] P = new long[N];
        string[] str = Console.ReadLine().Split(' '); 
        for (int i = 0; i < P.Length; i++)
        {
            P[i] = long.Parse(str[i]);
        }

        long ans = 0;
        long min = P[0];
        for (int i = 0; i < N; i++)
        {
            bool flag = true;
            if (min < P[i])
            {
                flag = false;
            }
            if (flag) 
            {
                ans++;
                min = P[i];
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 32220
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} 



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

i64 N, K; cin >> N >> K;
int cnt = 0;
for (; N; N /= K) ++cnt;

cout << cnt << "\n";
return 0;
}
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define N 1000000

int main(){
  char A[N];
  int dp[N];
  int n; cin >> n;
  for (int i=0; i<n; i++){
    cin >> A[i];
  }
  dp[0]=0;

  //initialization
  for (int i=1; i<n; i++){
    if (A[i]=='E') dp[0]++;
  }

  for (int i=1; i<n; i++){
    int x=0, y=0;
    if (A[i]=='E') x = -1;
    if (A[i-1]=='W') y = 1;
    dp[i] = dp[i-1]+x+y;
  }
  int min=10000000;
  for (int i=0; i<n; i++){
    if (min>dp[i]) min = dp[i];
  }

  cout << min << endl;
}

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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="77675555555555555555555555555555555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[400002];
char bc[400002];
ll a_cnt[400002];
ll dp[400002];
ll len,ans;
int main(void){
    cin >> s;
    len = strlen(s);
    int ptr=0;
    for (int i=0;i<len;i++){
        assert(s[i]=='A'||s[i]=='B'||s[i]=='C');
        if (s[i]=='A'){
            a_cnt[ptr]++;
        }else{
            bc[ptr++]=s[i];
        }
    }
    bc[ptr]='\0';
    // cout << bc << endl;
    ll ans=0;
    for (int i=ptr-2;i>=0;i--){
        if (bc[i]=='B' && bc[i+1]=='C' && a_cnt[i+1]==0){
            dp[i]=dp[i+2]+1;
            // cout << "i: " << i << " dp: " << dp[i] << " a_cnt: " << a_cnt[i] << endl;
            ans+=a_cnt[i]*dp[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
// << left shift *2 and >>right shift /2
long long int mod97=1000000007;
double pi=3.1415926536;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
bool rev(long long int a,long long int b)
{
    if(a>b)return true;
    else return false;
}
bool compa(pair<string,pair<int,int>>a,pair<string,pair<int,int>>b)
{
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)
        return true;
        else
        return false;
    }
    if(a.first<b.first)
    return true;
    else 
    return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
double dp[3000][3000];
void solve()
{
    long long int n;cin>>n;
    double p[n];for(auto &x:p)cin>>x;
    
    dp[0][0]=1-p[0];dp[0][1]=p[0];
    for(long long int i=1;i<n;i++)
    {
        for(long long int j=0;j<=n;j++)
        {
            //head
            if(j>0)
            dp[i][j]+=p[i]*1.0*dp[i-1][j-1];
            //tail
            dp[i][j]+=(1-p[i])*dp[i-1][j];
        }
    }
    for(long long int i=0;i<0;i++)
    {
        for(long long int j=0;j<=n;j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
    double ans=0.000;
    for(long long int i=n/2+1;i<=n;i++)
    ans+=dp[n-1][i];
    cout<<fixed<<setprecision(10)<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;
    //cin>>t;long long int temp=t;
    while(t--)
    {
        //cout<<"Case "<<temp-t<<": ";
        solve();
    }
}


Measured memory_bytes: 74100
N, A, B, C = map(int,input().split())
ans = []
flag = True
cnt = 0
while True:
  cnt += 1
  if cnt > N:
    break
  s = input()
  if s == 'AB':
    if A == B == 0:
      flag = False
      break
    elif A == B == 1:
      if cnt == N:
        ans.append('A')
        break
      else:
        cnt += 1
        s = input()
        if s == 'AB':
          ans.append('A')
          ans.append('B')
          continue
        elif s == 'AC':
          ans.append('A')
          ans.append('C')
          B -= 1
          C += 1
          continue
        else:
          ans.append('B')
          ans.append('C')
          A -= 1
          C += 1
          continue
    elif A >= B:
      A -= 1
      B += 1
      ans.append('B')
      continue
    else:
      B -= 1
      A += 1
      ans.append('A')
      continue
  elif s == 'BC':
    if B == C == 0:
      flag = False
      break
    elif B == C == 1:
      if cnt == N:
        ans.append('B')
        break
      else:
        cnt += 1
        s = input()
        if s == 'BC':
          ans.append('B')
          ans.append('C')
          continue
        elif s == 'AB':
          ans.append('B')
          ans.append('A')
          C -= 1
          A += 1
          continue
        else:
          ans.append('C')
          ans.append('A')
          B -= 1
          A += 1
          continue
    elif B >= C:
      B -= 1
      C += 1
      ans.append('C')
      continue
    else:
      C -= 1
      B += 1
      ans.append('B')
      continue 
  else:
    if C == A == 0:
      flag = False
      break
    elif C == A == 1:
      if cnt == N:
        ans.append('C')
        break
      else:
        cnt += 1
        s = input()
        if s == 'AC':
          ans.append('C')
          ans.append('A')
          continue
        elif s == 'BC':
          ans.append('C')
          ans.append('B')
          A -= 1
          B += 1
          continue
        else:
          ans.append('A')
          ans.append('B')
          C -= 1
          B += 1
          continue
    elif A >= C:
      A -= 1
      C += 1
      ans.append('C')
      continue
    else:
      C -= 1
      A += 1
      ans.append('A')
      continue
if flag:
  print('Yes')
  for item in ans:
    print(item)
else:
  print('No')


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

using namespace std;


 
int main() {
   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
     
    int n;
    cin>>n;
    long int a[n],b[n],h,w,cnt=0;
    cin>>h>>w;
    long int i;
    for(i=0;i<n;++i)
      {
          cin>>a[i]>>b[i];
          if(a[i]>=h && b[i]>=w)
            cnt++;
      }
      
      cout<<cnt;
      
	return 0;
	
} 

Measured memory_bytes: 3712
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 13 17:57:26 2018

H 行 W 列のマス目があり、i 行目の j 列目のマスをマス (i,j) と呼びます。
このマス目には 1 から H×W までの整数が重複なく書かれており、マス (i,j) に書かれている整数は Ai,j です。
魔法少女であるあなたは、魔力 |x−i|+|y−j| を消費することでマス (i,j) に置かれた駒をマス (x,y) に瞬間移動させることができます。
あなたは、魔法少女としての能力を計るために、Q 回の実技試験を受けなければなりません。
i 回目の実技試験は、以下の手順で行われます。

•初めに、駒が整数 Li の書かれているマスに置かれている。
•駒の置かれているマスに書かれている整数を x とする。x が Ri でない限り、駒を x+D の書かれているマスに移動することを繰り返す。x=Ri となったら終了する。
•ただし、Ri−Li が D の倍数であることは保証される。

それぞれの実技試験に対し、あなたの消費する魔力の総和を求めてください。

H W D
A1,1 A1,2 … A1,W
:
AH,1 AH,2 … AH,W
Q
L1 R1
:
LQ RQ

入力
3 3 2
1 4 3
2 5 7
8 9 6
1
4 8

出力
5


@author: Yuya
"""

H,W,D = map(int,input().split())

Set = []
Dis = []

for i in range(D):
    tmp = []
    Set.append(tmp)
    tmp2 = []
    Dis.append(tmp2)

for i in range(H):
    A_i = list(map(int,input().split()))
    for j in range(W):
        tmp = A_i[j]%D
        now = [A_i[j], i, j]
        Set[tmp].append(now)

for i in range(D):
    Set[i].sort(key=lambda x:x[0])

for i in range(D):
    length = 0
    now = [Set[i][0][0], length]
    Dis[i].append(now)
    for j in range(1,len(Set[i])):
        length = length + abs(Set[i][j][1]-Set[i][j-1][1]) + abs(Set[i][j][2]-Set[i][j-1][2])
        now = [Set[i][j][0], length]
        Dis[i].append(now)
 
Q = int(input())


for i in range(Q):
    L, R = map(int,input().split())
    now_Set = L%D
    tL = (L-1)//D
    tR = (R-1)//D
    Power = Dis[now_Set][tR][1] - Dis[now_Set][tL][1]
    print(Power)

Measured memory_bytes: 44804
// in the name of Allah

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

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define max_n 7654321
#define mod 1000000007
#define inf ((int) (1e9+7))

#define PI acos(-1.0)
#define eps 1e-9

set <int> st;

void go(int idx, int num, int msk) {
	if(msk == 7) st.insert(num);
	if(idx == 10) return;
	go(idx+1, num*10 + 3, (msk | 1));
	go(idx+1, num*10 + 5, (msk | 2));
	go(idx+1, num*10 + 7, (msk | 4));
}

int main() {
	ios::sync_with_stdio(0); cin.tie(); cout.tie(0);
	go(1, 0, 0);
	vector <int> v;
	for(auto e : st) v.pb(e);
	int n;
	cin >> n;
	cout << upper_bound(v.begin(), v.end(), n) - v.begin() << endl;
	return 0;
}

Measured memory_bytes: 1792
import fractions

a, b, c, d = map(int, input().split())

c_d = (c * d) // fractions.gcd(c, d)

a -= 1

tmp_b = b - (b//c + b//d - b//c_d)
tmp_a = a - (a//c + a//d - a//c_d)

print(tmp_b-tmp_a)

Measured memory_bytes: 5048
//*****Jai Mata di*****//

#include<bits/stdc++.h>
using namespace std;
#define Nitroboost  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int 
const int MOD=1e9+7;
const int N=2e5+15;
#define pb push_back
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;


ll mod(ll x)
{
   return (x%MOD+MOD)%MOD;
}
ll mul(ll a,ll b)
{
    return mod(mod(a)*mod(b));
}
bool comp(ll a, ll b)
{
    return a>b;
}

int main()
{
    Nitroboost;


       ll n,k;
       cin>>n>>k;
       vector <ll> pos,neg;
       for(int i=0;i<n;i++)
       {
            ll x;
            cin>>x;
            if(x>0)
            {
                pos.pb(x);
            } 
            else
            {
                neg.pb(x);
            }
       }
       ll ans=1;
       if(pos.size()!=0)
       {
            if(k%2!=0)
            {
                sort(pos.begin(),pos.end());
                ans=mul(ans,pos.back());
                pos.pop_back();
                k-=1;
            }
            vector <ll> ok;
            sort(pos.begin(),pos.end(),comp);
            sort(neg.begin(),neg.end());
            for(ll i=0;(i+1)<pos.size();i+=2)
            {
                ok.pb(pos[i]*pos[i+1]);
            }
            for(ll i=0;(i+1)<neg.size();i+=2)
            {
                ok.pb(neg[i]*neg[i+1]);
            }
            if(pos.size()%2!=0 and neg.size()%2!=0)
            {
                ok.pb(pos.back()*neg.back());
            }
            sort(ok.begin(),ok.end(),comp);
            //deb(ok.size());
            for(int i=0;i<k/2;i++)
            {
                ans=mul(ans,ok[i]);
            }
            cout<<ans<<endl;
 
       }
       else
       {
            sort(neg.begin(),neg.end());
            if(k%2!=0)
            {
                reverse(neg.begin(),neg.end());
            }
            for(int i=0;i<k;i++)
            {
                ans=mul(ans,neg[i]);
            }
            cout<<ans<<endl;
       }
}

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

using namespace std;
using ll = long long;

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

	for(int ans = 1; ans < 100000; ans++) {
		if(ans * 8 / 100 == a and ans * 10 / 100 == b) {
			printf("%d\n", ans);
			return 0;
		}
	}
	printf("-1\n");
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

struct DisjointSet{
    vector<int> p;
    DisjointSet(int n): p(n){
        rep(i,n) p[i] = -1;
    }

    int root(int x){
        if(p[x]<0) return x;
        return p[x] = root(p[x]);
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        if(rx>ry) swap(rx,ry);
        p[rx] += p[ry];
        p[ry] = rx;
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int n; cin >> n;
    vector<P> x;
    vector<P> y;
    rep(i,n){
        int xi, yi; cin >> xi >> yi;
        x.push_back(make_pair(xi,i));
        y.push_back(make_pair(yi,i));
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    priority_queue<tuple<int,int,int> > pq;

    rep(i,n-1){
        pq.push(make_tuple(-abs(x[i].first-x[i+1].first), x[i].second, x[i+1].second));
        pq.push(make_tuple(-abs(y[i].first-y[i+1].first), y[i].second, y[i+1].second));
    }

    DisjointSet dis = DisjointSet(n);
    ll ans = 0;
    while(!pq.empty()){
        int s, t, e;
        tie(e,s,t) = pq.top(); pq.pop(); e = -e;
        if(!dis.same(s,t)){
            ans += e;
            dis.unite(s,t);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 10884
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v)cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clzll(x) - 1;	}

struct pair_hash{
	template<class T1, class T2>
	size_t operator() (const pair<T1, T2> &p) const {
		auto h1 = hash<T1>{}(p.first);
		auto h2 = hash<T2>{}(p.second);
		return h1 ^ h2;
	}
};

string s, t;


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

	cin >> s >> t;

	cout << t << s;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
#include <fstream>
#include <cassert>
//#include <bits/stdc++.h>
using namespace std;

//#include<bits/stdc++.h>


	
int main() {
	
	int n;
	cin >> n;
	vector<int>p,z;
	int r = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		p.push_back(t);
		z.push_back(t-i-1);
		r += t - i;
	}
	sort(z.begin(), z.end());
	int x = z[n / 2];
	long long int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += abs(z[i] - x);
	//	cout << ans << endl;
	}
//	int ans = r / n;
//	if (ans > 0)cout << 0 << endl;
//	 cout << z[n/2]<< endl;
	 cout << ans << endl;


	return 0;
}

Measured memory_bytes: 2036
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		System.out.println((b-a)==(c-b)?"YES":"NO");
		sc.close();
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;

    bool answer=false;

    for (int i=0;i<=n/4;i++) {
        for (int j=0;j<=n/7;j++) {
            if(i*4+j*7==n){
                answer=true;
            }
        }
    }

    if(answer){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


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

int main() {
	ios_base::sync_with_stdio(false);
	int n, x; cin >> n >> x;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	sort(a.begin(), a.end());
	int sum = 0, cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (sum + a[i] > x) break;
		sum += a[i], cnt++;
	}
	if (cnt == n && sum < x) cnt--;
	cout << cnt << '\n';
}

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

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

    if( N <= 111 ) cout << 111 << endl;
    else if( N <= 222 ) cout << 222 << endl;
    else if( N <= 333 ) cout << 333 << endl;
    else if( N <= 444 ) cout << 444 << endl;
    else if( N <= 555 ) cout << 555 << endl;
    else if( N <= 666 ) cout << 666 << endl;
    else if( N <= 777 ) cout << 777 << endl;
    else if( N <= 888 ) cout << 888 << endl;
    else if( N <= 999 ) cout << 999 << endl;

    return 0;
}


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

public class Main {
	
	public static void main(String[] args) {
		Pattern p = Pattern.compile("[ACGT]+");
		Scanner s = new Scanner(System.in);
		
		int result = 0;
		
		String inS = s.next();
		Matcher m = p.matcher(inS);
		for(int i=0;i<inS.length();i++) {
			if(m.find(i)) {
				int length = m.group().length();
				if(result < length) {
					result = length;
				}
			}
		}
		
		System.out.println(result);
		s.close();
		
	}

}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    vec<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    if(K==0){
        cout << *max_element(A.begin(),A.end()) << "\n";
        return 0;
    }

    auto check = [&](ll x){
        ll cnt = 0;
        for(int i=0;i<N;i++){
            cnt += (A[i]+x-1)/x-1;
        }
        return cnt<=K;
    };

    
    int l = 0,r = 1e9+1;   
    while(l+1<r){
        int m = (l+r)/2;
        (check(m)? r:l) = m;
    }

    cout << r << "\n";
}


Measured memory_bytes: 4756
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    vector<vector<int> >an(3, vector<int>(3));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> an.at(i).at(j);
        }
    }
    int n;
    cin >> n;
    vector<int>bn(n);
    for(int i = 0; i < n; i++){
        cin >> bn.at(i);
    }
    vector<vector<bool> >ck(3, vector<bool>(3));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(an.at(j).at(k) == bn.at(i)){
                    ck.at(j).at(k) = true;
                }
            }
        }
    }
    if((ck.at(0).at(0) && ck.at(0).at(1) && ck.at(0).at(2)) || (ck.at(1).at(0) && ck.at(1).at(1) && ck.at(1).at(2)) || (ck.at(2).at(0) && ck.at(2).at(1) && ck.at(2).at(2)) || (ck.at(0).at(0) && ck.at(1).at(0) && ck.at(2).at(0)) || (ck.at(0).at(1) && ck.at(1).at(1) && ck.at(2).at(1)) || (ck.at(0).at(2) && ck.at(1).at(2) && ck.at(2).at(2)) || (ck.at(0).at(0) && ck.at(1).at(1) && ck.at(2).at(2)) || (ck.at(0).at(2) && ck.at(1).at(1) && ck.at(2).at(0))){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#define r 6378.1

int main(void){
	double a,b,c,d;
	while(1){
		scanf("%lf %lf %lf %lf",&a,&b,&c,&d);
		if(b+d<-1.0)break;
		a=90.0-a;
		c=90.0-c;
		double x1=cos(b*M_PI/180.0)*sin(a*M_PI/180.0);
		double x2=cos(d*M_PI/180.0)*sin(c*M_PI/180.0);
		double y1=sin(b*M_PI/180.0)*sin(a*M_PI/180.0);
		double y2=sin(d*M_PI/180.0)*sin(c*M_PI/180.0);
		double z1=cos(a*M_PI/180.0);
		double z2=cos(c*M_PI/180.0);
		double e=sqrt(pow(x1-x2,2.0)+pow(y1-y2,2.0)+pow(z1-z2,2.0));
		double ang=acos(1.0-e*e/2.0);
		printf("%d\n",(int)(r*ang+0.5));
	}
	return 0;
}

Measured memory_bytes: 1108
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
S, T = ins().split()
assert len(S) == N
assert len(T) == N


def solve():
    res = []
    for i in range(N):
        res.append(S[i])
        res.append(T[i])
    return "".join(res)


print(solve())


Measured memory_bytes: 9144
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <chrono>
#include <stack>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

llong pow(int x, int n) {
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

int main() {
    int n;
    llong tmp;
    vector<llong > X1, X2;
    cin >> n;
    if (n == 2) {
        int a, b;
        cin >> a >> b;
        cout << b << endl;
        cout << a << endl;

        return 0;
    }
    rep(i, n) {
        cin >> tmp;
        X1.push_back(tmp);
        X2.push_back(tmp);
    }

    sort(X2.begin(), X2.end());

    vector<llong >::iterator itr;
    llong ll = X2[(n / 2) - 1], ul = X2[n / 2];
    for (int i = 0; i < X1.size(); ++i) {
        if (X1[i] <= ll) cout << ul << endl;
        else cout << ll << endl;
    }

    return 0;
}

Measured memory_bytes: 5476
n, m = map(int, input().split())

area_a = []
for i in range(n):
    array = input()
    area_a.append(array)

area_b = []
for i in range(m):
    array = input()
    area_b.append(array)

def check(i, j):
    flag = True
    for u in range(m):
        x = area_a[i+u][j:j+m]
        if x != area_b[u][:]:
            flag = False
            break
        else:
            continue
    if flag is True:
        print('Yes')
        exit()

for i in range(n-m+1):
    for j in range(n-m+1):
        check(i,j)

print('No')

Measured memory_bytes: 3064
#include <stdio.h>

int	main()
{
	long long	N, K;
	long long	nb;

	scanf("%lld %lld\n", &N, &K);
	nb = N;
	while (nb >= K && K > 1)
		nb %= K;
	if (K == 1)
		nb = 0;
	else if (nb > (K - nb))
		nb = K - nb;
	printf("%lld\n", nb);
	return (0);
}


Measured memory_bytes: 128
import java.util.*;

public class Main{
 public static void main(String[]a){
Scanner sc = new Scanner(System.in);
for(;;){
int n = sc.nextInt();
if(n ==0 ) {
break;
}
int[] p = new int[n];
int[] d = new int[n];
int max = 0;
int res = 0;
for(int i =0 ; i < n ; i++){
p[i] = sc.nextInt();
d[i] = sc.nextInt()+sc.nextInt();
if(max < d[i]){
max = d[i];
res = p[i];
}
}
System.out.println(res+" "+max);
}
}

} 

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2];


void solve()
{
	int m;
	cin >> n >> m;
	int days = 0;
	lop(i, 0, m) cin >> arr[i] , days += arr[i];
	if ( days > n ) cout << -1;
	else cout << n - days;

}

int32_t main()
{
	ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F first
#define S second
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define sz size()
#define all(A)    A.begin(), A.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define f0(i,b)   for(int i=0;i<(b);i++)
#define f1(i,b)   for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define mod 1000000007

#define forr(i,n)    for(i=0; i<n; i++)
#define whilee(i,t)  while(i!=t)
#define  sl(a)  scanf("%lld",&a)
#define  pl(a)  printf("%lld",a)

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);
//scanf("%d",&x);
//printf("%d\n",x);

//vector <int> A;
//deque <int> A;
//queue <int> A;
//stack <int> A;
//set <int> A;
//map <int,int> A;
//pair <int,int> A ;
//vector <pair <int,int>> A ;
//char ch;
//string S, T, U;
ll i, j, k, a, b, c, d, f, g, h, l, m, n, p, q, r, s, t, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    for(i=1; i<10; i++)
    {
        for(j=1; j<10; j++)
        {
            cout<<i<<"x"<<j<<"="<<i*j<<endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {

    long long int n;
    cin >> n;

    vector< long long int > v, w;

    for ( long long int i = 0; i < n; i++ ) {
        long long int in;
        cin >> in;
        v.push_back( in );
        w.push_back( in );
    }
    sort( w.begin(), w.end() );

    for ( long long int i = 0; i < n; i++ ) {
        if ( v[i] == w[ w.size() - 1 ] ) {
            cout << w[ w.size() - 2 ] << endl;
        } else {
            cout << w[ w.size() - 1 ] << endl;
        }
    }

    return 0;

}


Measured memory_bytes: 5732
require "set"

class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)

  def initialize
    @s = gets.chomp
    @t = gets.chomp
    @n = @s.size
    @st = Hash.new { |h, k| h[k] = Set.new }
    @ts = Hash.new { |h, k| h[k] = Set.new }
  end

  def solve
    rec
    valid?(@st) && valid?(@ts)
  end

  def rec
    n.times do |i|
      @st[s[i]] << t[i]
      @ts[t[i]] << s[i]
    end
  end

  def valid?(h)
    h.values.map(&:size).all?{ _1 == 1 }
  end

  def show(ans)
    puts ans ? "Yes" : "No"
  end
end

Problem.new.instance_eval do
  show(solve)
end


Measured memory_bytes: 15224
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};

int main() {
    ll a,b; cin >> a >> b;
    string s; cin >> s;
    rep(i,a){
        if(s[i] < '0' || s[i] > '9'){
            puts("No");
            return 0;
        }
    }
    if(s[a]!='-'){
        puts("No");
        return 0;
    }
    REP(i,a+1,a+b+1){
        if(s[i] < '0' || s[i] > '9'){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
signed main(){
	int n;
	cin>>n;
	int ans=0;
	for(int i=0;pow(10,i)<=n;i++){
		int sum=0,k=0,s=0;
		int p=n;
		while(p){
			if(k<i)sum+=9;
			else if(k==i)sum+=p%10-1,s++;
			else sum+=p%10;
			p/=10;
			k++;
		}
		if(s)ans=max(sum,ans);
	}
	int sum=0;
	while(n)sum+=n%10,n/=10;
	cout<<max(ans,sum)<<endl;
}

Measured memory_bytes: 512
include Math

def memo(m, xy)
    x1, y1 = xy[0]
    x2, y2 = xy[1]

    re = [[hypot(x2 - x1, y2 - y1)]]

    (m-2).times do |i|
        xn, yn = xy[i+2]

        case x2 <=> x1
        when -1
            j = yn > y2
        when 0
            j = !(y2 > y1) ^ (xn > x2)
        when 1
            j = yn < y2
        end
        
        re << [hypot(xn - x2, yn - y2), j]

        x1, y1 = x2, y2
        x2, y2 = xn, yn
    end
    re
end

loop do
    n = gets.to_i
    break if n == 0

    g1 = []
    g2 = []
    (n+1).times do |i|
        m = gets.to_i

        xy = []
        m.times {xy << gets.split.map(&:to_i)}

        if i == 0
            g1 << memo(m, xy)
            g1 << memo(m, xy.reverse)
        else
            g2 << memo(m, xy)
        end
    end

    ans = []
    g2.each_with_index {|g, i| ans << i + 1 if g == g1[0] || g == g1[1]}
    puts ans, "+++++"
end



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

int main() {
 int N, count;
  cin >> N;
  count = 0;
  vector<int> D1(N), D2(N);

  
 for(int i = 0; i < N; i++){
   cin >> D1[i] >> D2[i];
 }
  
  for(int i = 0; i < N-2; i++){
    if(D1[i] == D2[i] && D1[i+1] == D2[i+1] && D1[i+2] == D2[i+2]){
      count++;
    }
  }
  
    if(count == 0){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  
}


Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
n = int(input())
vl = list(map(int, input().split()))
cl = list(map(int, input().split()))

res = -1

for i in range(2**n):
    x = 0
    y = 0
    for j in range(n):
        if i>>j&1==1:
            x += vl[j]
            y += cl[j]
    res = max(res, x-y)

print(res)


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int H, W; cin >> H >> W;
    bool obs[H][W]; // 1次元目：行数、縦　2次元目：列数、横
    rep(i,H){
        string Si; cin >> Si;
        rep(j,W){
            if(Si[j] == '#') obs[i][j] = true;
            else obs[i][j] = false;
        }
    }
    int L[H][W];
    int R[H][W];
    int U[H][W];
    int D[H][W];
    rep(i,H){
        for(int j=0; j<W; j++){
            if(obs[i][j]){
                L[i][j] = 0;
            }else{
                if(j == 0) L[i][j] = 1;
                else L[i][j] = L[i][j-1] + 1;
            }
        }
        for(int j=W-1; j>=0; j--){
            if(obs[i][j]){
                R[i][j] = 0;
            }else{
                if(j == W-1) R[i][j] = 1;
                else R[i][j] = R[i][j+1] + 1;
            }
        }
    }
    rep(j,W){
        for(int i=0; i<H; i++){
            if(obs[i][j]){
                U[i][j] = 0;
            }else{
                if(i == 0) U[i][j] = 1;
                else U[i][j] = U[i-1][j]+1;
            }
        }
        for(int i=H-1; i>=0; i--){
            if(obs[i][j]){
                D[i][j] = 0;
            }else{
                if(i == H-1) D[i][j] = 1;
                else D[i][j] = D[i+1][j]+1;
            }
        }
    }
    int max_l = 0;
    /*
    rep(i,H){
        rep(j,W){
            cout << L
        }
    }
    */
    rep(i,H){
        rep(j,W){
            int light = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3;
            if(max_l < light) max_l = light;
        }
    }
    cout << max_l << endl;
}

Measured memory_bytes: 66688
s = input()
a = len(s)

b = []
for i in range(2**(a-1)):
    c = []
    for j in range(a-1):
        if i|(2**j) == i:
            c.append(1)
        else:
            c.append(0)
    b.append(c)
ans = 0
for i in b:
    count = 0
    ss = s[:]
    for j in range(a-1):
        if i[j] == 1:
            ss = ss[:j+1+count]+'+'+ss[j+1+count:]
            count += 1
    ans += eval(ss)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string str;
	cin>>str;
	map<char,int> m;
	for(int i=0;i<str.size();i++)
	{
		m[str[i]]++;
	}
	for(auto x:str)
	{
		if(m[x]!=2)
		{
			cout<<"No";
			return 0;
		}
		else
			continue;
	}
	cout<<"Yes";
	return 0;
}

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

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

    if((N%500) <= A){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
def main():
    *a, = map(int, input().split())
    evens = [x for x in a if x % 2 == 0]
    odds = [x for x in a if x % 2 == 1]

    if evens:
        if odds:
            ans = 1
            if len(evens) > len(odds):
                evens = (x + 1 for x in evens)
                odds.extend(evens)
                ma = max(odds)
                ans += sum((ma - x) // 2 for x in odds)
            else:
                odds = (x + 1 for x in odds)
                evens.extend(odds)
                ma = max(evens)
                ans += sum((ma - x) // 2 for x in evens)
        else:
            ma = max(evens)
            ans = sum((ma - x) // 2 for x in evens)
    else:
        ma = max(odds)
        ans = sum((ma - x) // 2 for x in odds)

    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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

const int INF = 1001001001;
const int MOD = 998244353;

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  int input;
  for(int i=0;i<n;i++){
    cin >> input;
    d.at(i) = input;    
  }
  if(d.at(0) != 0){
    cout << 0 << endl;
    return 0;
  }
  sort(d.begin(),d.end());
  if(d.at(1) == 0){
    cout << 0 <<endl;
    return 0;
  }
  ll ans = 1;
  int count = 0;
  int i = 1;
  int val = 1;
  for(int scope = 1;scope<=d.at(n-1);scope++){
    while(d.at(i) == scope){
      count++;
      ans = ans * val % MOD;
      if(i == (n-1)) break;
      i++;
    }
    val = count;
    count = 0;
  }
  cout << ans;
}

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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	if(n % 2 != 0){
		cout << "No" << endl;
		return 0;
	}
	rep(i, n/2){
		if(s[i] != s[n/2+i]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
    
#define int long long
    
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
    
using namespace std;
    
int dy[4]={1, 0, -1, 0};
int dx[4]={0, 1, 0, -1};

int v[3][105];
int n;

int srch(int y, int x, int u){
    if(y>=2 || x>=n) return u;
    return max(srch(y+dy[0], x+dx[0], u+v[y][x]), srch(y+dy[1], x+dx[1], u+v[y][x]));
}

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

    int ny, nx=ny=0;
    int t, a, b;
    REP(i, n){
        cin >> t >> a >> b;

        int m = abs(ny-b)+abs(nx-a);
        if(m > t){
            cout << "No" << endl;
            return 0;
        }
        else{
            if((t-m)%2){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn gcd(n: i64, m: i64) -> i64 {
    match (n, m) {
        (n, 0) => n,
        (n, m) => gcd(m, n % m)
    }
}

fn lcm(n: i64, m: i64) -> i64 {
    n * m / gcd(n, m)
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let A: i64 = sc.get();
    let B: i64 = sc.get();
    let C: i64 = sc.get();
    let D: i64 = sc.get();
    let mut ans_b = B;
    ans_b -= B / C;
    ans_b -= B / D;
    ans_b += B / lcm(C, D);
    let mut ans_a = A-1;
    ans_a -= (A-1) / C;
    ans_a -= (A-1) / D;
    ans_a += (A-1) / lcm(C, D);
    let ans = ans_b - ans_a;
    println!("{}", ans);
}


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

int main(){
	string s;
	int n;
	cin >> n;
	cin >> s;
	rep(i,s.length()){
		s[i] += n;
		if(s[i] >'Z'){
			s[i] -= 26;
		}
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    int N, i;
    cin >> N;
    int a[N];
    for (i=0; i<N; i++) {
        cin >> a[i];
    }
    
    sort(a, a + N, greater<int>());
    
    int sum = 0;
    
    for (i=0; i<N; i++) {
        sum = sum + pow(-1, i) * a[i]; 
    }
    cout << sum << endl;
    
    //getline(cin, str);
    //vector < vector < int > > A(x, vector<int>(y, 0));
    //int avg = round((float)accumulate(X.begin(), X.end(), 0.0) / N);
    //int c = stoi(a+b) *a and b are strings
    return 0;
}

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

int main ()
{
  int N, K;
  std::cin >> N >> K;
  std::vector<int> enemy;

  for (int i=0; i<N; i++)
    {
      int H;
      std::cin >> H;
      enemy.push_back(H);
    }

  std::sort(enemy.begin(), enemy.end());

  long ans = 0;

  auto diff = N - K;
  if (diff > 0)
    {
      for (int i=0; i<diff; i++)
        {
          ans += enemy[i];
        }
    }

  std::cout << ans << std::endl;

}


Measured memory_bytes: 1400
// Problem : D - Even Relation
// Contest : AtCoder Beginner Contest 126
// URL : https://atcoder.jp/contests/abc126/tasks/abc126_d
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcount(x)
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
cin>>n;
vp v[n+1];
for(int i=0;i<n;i++)
{
	int x,y,z;
	cin>>x>>y>>z;
	v[x].pb({z,y});
	v[y].pb({z,x});
}
int dis[n+1];int vis[n+1]={0};
memset(dis,-1,sizeof(dis));
queue<int> q;
q.push(1);
dis[1]=0;
while(!q.empty())
{
	int x=q.front();
	q.pop();
	for(pii i : v[x])
	{
		if(vis[i.se]==0)
		{
			dis[i.se]=dis[x]+i.f;
			q.push(i.se);
			vis[i.se]=1;
		}
	}
}
for(int i=1;i<=n;i++)
if(dis[i]&1)
cout<<1<<"\n";
else
cout<<0<<"\n";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t;
//cin>>t;
t=1;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 9472
#include<iostream>
#include<string>

using namespace std;

int main() {

	string n;
	int num;
	int sum = 0;

	cin >> n;

	int i = 0;
	while (true) {
		string a;
		a = n[i];
		if (n[i] == '\0')break;
		num = atoi(a.c_str());
		sum += num;
		i++;
	}

	if (sum % 9 == 0)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3740