akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
const int NMAX=200004;

int n,k,v[NMAX],sol,cnt;
bool ok,cresc;

deque <int> dqMin,dqMax;

int main(){
    int i;
    cin>>n>>k;
    for(i=1;i<=n;++i){
        cin>>v[i];
        if(v[i]>=v[i-1])
            ++cnt;
        else
            cnt=1;
        ok=0;
        //deque min
        while(!dqMin.empty() && dqMin.back() > v[i])
            dqMin.pop_back();
        dqMin.push_back(v[i]);

        if(i>k && dqMin.front() == v[i-k])
            dqMin.pop_front();
        else if(i>k)
            ok=1;

        //deque max
        while(!dqMax.empty() && dqMax.back() < v[i]){
            dqMax.pop_back();
        }
        dqMax.push_back(v[i]);
        if(i>k && v[i] != dqMax.front())
            ok=1;

        if(i>k && dqMax.front() == v[i-k])
            dqMax.pop_front();

        //caz particular
        if(i == k && cnt != k)
            ok=1;
        if(cnt == k){
            if(!cresc)
                cresc=ok=1;
            else
                ok=0;
        }
        sol+=ok;
    }
    cout<<sol;
    return 0;
}



Measured memory_bytes: 1792
import collections
def C(n):
    return n * (n-1) // 2
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
d = {}
sm = 0
for k,v in c.most_common():
    d[k] = v
    sm += C(v)
for a in A:
    print (sm - d[a] + 1)

Measured memory_bytes: 38840
#import bisect

#def index(a, x):
#    'Locate the leftmost value exactly equal to x'
#    i = bisect.bisect_left(a, x)
#    if i != len(a) and a[i] == x:
#        return [1,i]
#    return [0,0]


N=int(raw_input())
D=sorted(map(int, raw_input().split()))
M=int(raw_input())
T=sorted(map(int, raw_input().split()))

DD={}
for d in D:
    if d not in DD:
        DD[d] = 1
    else:
        DD[d]+=1

ans=["NO","YES"]
a=1

for t in T:
    try:
        if DD[t]>0:
            DD[t]-=1
        else:
            a=0
            break
    except:
        a=0
        break
print ans[a]


Measured memory_bytes: 37076
a, b, c = map(int, input().split())
xa = 0
xb = 0 
xc = 0

if(a == b == c):
    if(a % 2 == 0):
        print(-1)
    else:
        print(0)    
else:
    cnt = 0
    while(a % 2 == 0 and b % 2 == 0 and c % 2 == 0):
        cnt += 1
        xa = b // 2 + c // 2
        xb = c - c // 2 + a // 2
        xc = a - a // 2 + b - b // 2
        a = xa
        b = xb
        c = xc
    print(cnt)


Measured memory_bytes: 3064
package main

import (
	"fmt"
	"strings"
)

func main() {
	ans := []string{}
	for {
		var H, W int
		fmt.Scan(&H, &W)
		if H+W == 0 {
			break
		}
		for i := range make([]int, H) {
			ans = append(ans, "")
			last := len(ans) - 1
			if i%2 != 0 {
				ans[last] += "."
			}
			ans[last] += strings.Repeat("#.", W)
			ans[last] = ans[last][:W]
		}
		ans = append(ans, "")
	}
	fmt.Println(strings.Join(ans, "\n"))
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long MOD = 998244353;

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

    ll n, k;
    cin >> n >> k;
    if (n >= k) n %= k;

    cout << min(n, k - n);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const ll mod = 998244353;
ll inv[2000000];
ll FactorialInv[2000000];
ll Factorial[2000000];
ll beki(ll a, ll b){
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    inv[1] = 1;
    FactorialInv[1] = 1;
    Factorial[1] = 1;
    Factorial[0] = 1;
    FactorialInv[0] = 1;
    inv[0] = 1;
    for(int i = 2; i < 2000000; i++){
        inv[i] = beki(i, mod - 2);
        Factorial[i] = Factorial[i - 1] * i % mod;
        FactorialInv[i] = FactorialInv[i - 1] * inv[i] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N, M;
ll ans = 0;

int main() {
    cin >> N >> M;
    init_combination();
    ll over = 0;
    for(ll two = M; two <= M + M / 2; two++) {
        ll one = M - (two - M) * 2;
        ll total = combination(N + two - 1, N - 1);
        ll just = N * combination(two - M + N - 2, N - 2);
        just %= mod;
        ll nowway = total - just - over + 2 * mod;
        nowway %= mod;
        ans += nowway * combination(N, one);
        ans %= mod;
        ans += just * combination(N - 1, one);
        ans %= mod;
        over += just;
        over %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 47104
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll i,j,k;
    bool F[N][10];
    ll P[N][11];
    for(i=0;i<N;i++){
      for(j=0;j<10;j++){
        cin >> F[i][j];
      }
    }
    for(i=0;i<N;i++){
      for(j=0;j<11;j++){
        cin >> P[i][j];
      }
    }
    bool x[10];
    int t;
    ll cnt[N];
    ll mx=-1000000000000,tmp;

    for(i=1;i<1024;i++){
      t=i;
      tmp=0;
      for(j=0;j<N;j++){
        cnt[j]=0;
      }
      for(k=0;k<10;k++){
        x[k]= t%2;
        t= t/2;
      }
      for(j=0;j<N;j++){
        for(k=0;k<10;k++){
          cnt[j]+=F[j][k]*x[k];
        }
      }
      for(j=0;j<N;j++){
        tmp=tmp+P[j][cnt[j]];
      }
      mx=max(mx,tmp);
    }
    cout << mx;
    return 0;
}


Measured memory_bytes: 256
from sys import exit

N = int(input())
H = [int(x) for x in input().split()]

if N == 1:
    print('Yes')
else:
    num = 0
    for h in H:
        if num - 1 <= h:
            num = max(num, h)
        else:
            print('No')
            exit()
    print('Yes')

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

bool checkPalindrome( const string S ){
  string sub1, sub2;
  if( S.size() % 2 == 1 ){
    sub1 = S.substr(0, (S.size()-1)/2);
    sub2 = S.substr( (S.size()-1)/2 + 1, (S.size()-1)/2 );
  }else{
    sub1 = S.substr(0, (S.size())/2);
    sub2 = S.substr( (S.size())/2 , (S.size())/2 );
  }

  for( int i = 0; i < sub2.size(); ++i ){
    if( sub1[i] != sub2[sub2.size()-1-i] ){
      return false;
    }
  }

  return true;
}

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

  if( checkPalindrome( S ) && checkPalindrome( S.substr( 0, (S.size()-1)/2 ) ) && checkPalindrome( S.substr( (S.size()+3)/2 - 1, (S.size()) - ((S.size()+3)/2 - 1)) ) ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
#include <stdio.h>
using namespace std;
typedef long long lli;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define forr(c, n) for (int i = c; i < n; i++)
#define forli(n) for (lli i = 0; i < n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())

//FUNCTONS
lli llipower(lli x, lli y)
{
    lli res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x);
        y = y >> 1;
        x = (x * x);
    }
    return res;
}
lli llipowerp(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli gcd(lli a, lli b)
{
    if (!a)
        return b;
    return gcd(b % a, a);
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
void printvec(vector<T> inp)
{
    for (int i = 0; i < inp.size(); i++)
    {
        cout << inp[i] << " ";
    }
    cout << endl;
}
template <typename T>
T ceildiv(T x, T y) { return 1 + ((x - 1) / y); }
lli modInverse(lli a, lli m)
{
    lli g = gcd(a, m);
    if (g != 1)
        return -1;
    else
        return llipowerp(a, m - 2, m);
}


int main()
{
    lli n,k;
    cin>>n>>k;
    cout<<min(n%k,abs(n-((n/k)+1)*k))<<endl;





}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pair = pair <int, int>;

int		main(void)
{
	int		k, s;
	cin >> k >> s;
	int		x, y, z;
	int		ans = 0;

	x = 0;
	while (x <= k){
		y = 0;
		while (y <= k){
			z = s - x - y;
			if (z >= 0 && z <= k)
				ans++;
			y++;
		}
		x++;
	}
	cout << ans;
}


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

int getDivisor(int index){
    int count=0;
    for(int i=2;i<=sqrt(index);i++){
        if(index%i==0){
            count++;
            if(index!=i*i){
                count++;
            }
        }
    }
    return count+2;
}
int main(){
    int n;
    cin>>n;
    int count=0;
    for(int i=0;i<=n;i++)
    {
        if(i%2!=0){
            if(getDivisor(i)==8){
                count++;
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string C;
    string vowel = "aiueo";
    cin >> C;
    if (vowel.find(C) != string::npos){
        cout << "vowel" << endl;
    }
    else{
        cout << "consonant" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
 
int main(){
	long long a,b;
	string s,s2;
 
	cin >> s;

	while(s.size() > 1){
		s = s.erase(s.size() - 1);
		
		if(s.substr(0, s.size() / 2) == s.substr(s.size() / 2)){
			break;			
		}
	}
 
 
	cout << s.size() << endl;
}

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;


int main(){

    string s;
    cin >> s;
    int n = s.size();

    int win = 0;
    int lose = 0;

    rep(i, n){
        if(i % 2 == 0){
            //gをだす
            if(s[i] == 'p'){
                lose++;
            }
        }else{
            //pをだす

            if(s[i] == 'g'){
                win++;
            }
        }
    }

    cout << win - lose << endl;

    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(){
	int n_nodes, n_edges;
	scanf("%d", &n_nodes);
	scanf("%d", &n_edges);
	long int height[n_nodes+1];
	//塔が良い->1;でない->0
	int is_tallest[n_nodes+1];
	for(int node_i = 1; node_i <= n_nodes; node_i++){
		scanf("%ld", &height[node_i]);
		is_tallest[node_i] = 1;
	}
	//ペア(edge_iで繋がるnode1, 2_i)で比較、tallestになり得るか判定
	for(int edge_i = 1; edge_i <= n_edges; edge_i++){
		int node1_i, node2_i;
		scanf("%d", &node1_i);
		scanf("%d", &node2_i);
		if(height[node1_i] > height[node2_i])
			is_tallest[node2_i] = 0;
		else if(height[node2_i] > height[node1_i])
			is_tallest[node1_i] = 0;
		else
			is_tallest[node1_i] = is_tallest[node2_i] = 0;
	}
	int ans = 0;
	for(int node_i = 1; node_i <= n_nodes; node_i++)
		ans += is_tallest[node_i];
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 2896
#include<bits/stdc++.h>
using namespace std;
map<char,string> l1;
map<string,char> l2;
void init(){
l1[' ']="101";
l1['\'']="000000";
l1[',']="000011";
l1['-']="10010001";
l1['.']="010001";
l1['?']="000001";
l1['A']="100101";
l1['B']="10011010";
l1['C']="0101";
l1['D']="0001";
l1['E']="110";
l1['F']="01001";
l1['G']="10011011";
l1['H']="010000";
l1['I']="0111";
l1['J']="10011000";
l1['K']="0110";
l1['L']="00100";
l1['M']="10011001";
l1['N']="10011110";
l1['O']="00101";
l1['P']="111";
l1['Q']="10011111";
l1['R']="1000";
l1['S']="00110";
l1['T']="00111";
l1['U']="10011100";
l1['V']="10011101";
l1['W']="000010";
l1['X']="10010010";
l1['Y']="10010011";
l1['Z']="10010000";
l2["00000"]='A';
l2["00001"]='B';
l2["00010"]='C';
l2["00011"]='D';
l2["00100"]='E';
l2["00101"]='F';
l2["00110"]='G';
l2["00111"]='H';
l2["01000"]='I';
l2["01001"]='J';
l2["01010"]='K';
l2["01011"]='L';
l2["01100"]='M';
l2["01101"]='N';
l2["01110"]='O';
l2["01111"]='P';
l2["10000"]='Q';
l2["10001"]='R';
l2["10010"]='S';
l2["10011"]='T';
l2["10100"]='U';
l2["10101"]='V';
l2["10110"]='W';
l2["10111"]='X';
l2["11000"]='Y';
l2["11001"]='Z';
l2["11010"]=' ';
l2["11011"]='.';
l2["11100"]=',';
l2["11101"]='-';
l2["11110"]='\'';
l2["11111"]='?';
}
string solve(string s){
string tmp = "";
for(int i=0;i<s.size();i++){
tmp += l1[s[i]];
}
while(tmp.size()%5!=0){
tmp += '0';
}
string res = "";
while(tmp.size()!=0){
res += l2[tmp.substr(0,5)];
tmp = tmp.substr(5);
}
return res;
}
int main(){
init();
string s;
while(getline(cin,s)){
cout<<solve(s)<<endl;
}
}

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

using namespace std;

class Query{
public:
    long b, c;

    bool operator<(const Query &q) const{
        if(c > q.c){
            return true;
        }else{
            return false;
        }
    }
};

int main(){
    long N, M;
    cin>>N>>M;
    
    vector<long> A(N);
    for(int i=0; i<N; ++i){
        cin>>A[i];
    }
    sort(A.begin(), A.end());

    vector<Query> query(M);
    for(int i=0; i<M; ++i){
        cin>>query[i].b>>query[i].c;
    }
    sort(query.begin(), query.end());

    long count = 0;
    for(int i=0; i<M; ++i){
        auto it = upper_bound(A.begin() + count, A.end(), query[i].c);
        long aa = min(query[i].b, long(distance(A.begin() + count, it)));
        fill(A.begin() + count, A.begin() + count + aa, query[i].c);
        //sort(A.begin(), A.end());
        count += aa;
    }
    cout<<accumulate(A.begin(), A.end(), 0LL)<<endl;

    return 0;
}


Measured memory_bytes: 2560
#include<cstdio>
using namespace std;
bool us[1000010]={false};
int p[1000010] = {0};
int main(){
    /*Eratosthenes*/
    p[0] = 2;
    for(int i = 0; i <= 1000010; i+=2){
        us[i] = true;
    }
     
    int cnt = 1;
    for(int i = 3; i <= 1000010; i+=2){
        int q = 0;
        if(us[i] == true)continue;
        else if(us[i] == false){
            p[cnt] = i;
            cnt++;
            us[i] = true;
            q = i;
            for(int j = q+q; j <= 1000010; j += q){
                us[j] = true;
            }
        }
    }
     
    int n;
    while(~scanf("%d",&n)){
        int x = 0;
        while(1){
            if(p[x] > n)break;
            x++;
        }
        printf("%d\n",x);
    }
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> cnt(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    ++cnt[a-1];
    ++cnt[b-1];
  }
  bool res = true;
  for (int i = 0; i < N; i++) {
    res &= cnt[i] % 2 == 0;
  }
  cout << (res ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int, int>;
constexpr array<int, 4> dx = {1, 0, -1, 0};
constexpr array<int, 4> dy = {0, 1, 0, -1};
constexpr int INF = 1234567890;
constexpr int MOD = 1000000000 + 7;
// constexpr int MOD = 998244353;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int fact(int n) { return n > 1 ? n * fact(n - 1) % MOD : 1; }
int modinv(int a)
{
    int b = MOD, u = 1, v = 0;
    while (b)
    {
        int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0)
        u += MOD;
    return u;
}
constexpr int modpow(int a, int n)
{
    int rtn = 1;
    while (n > 0)
    {
        if (n & 1)
            rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(10);

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    int ans = 0;

    // 各桁ごとに処理
    for (int i = 0; i < 61; i++)
    {
        // 2進数i桁目が0か1か見る
        int count = 0;
        for (auto &&ai : a)
            if (ai & (1LL << i))
                count++;

        // 0の数 * 1の数 * 2^i が(i+1)桁目の和
        const int increase = (count * (n - count) % MOD) * ((1LL << i) % MOD) % MOD;
        ans += increase % MOD;
        ans %= MOD;
    }
    cout << ans % MOD << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<long double> x(N),y(N);
  REP(i,N){
    cin>>x[i]>>y[i];
  }
  vector<int> nums(N);
  REP(i,N){
    nums[i]=i;
  }

  long double ans=0;
  do {
    REP(i,N-1){
      long double xd=x[nums[i]]-x[nums[i+1]];
      long double yd=y[nums[i]]-y[nums[i+1]];
      ans+=sqrt(xd*xd+yd*yd);
    }
  } while (std::next_permutation(nums.begin(), nums.end()));
  REP(i,N){
    ans/=(i+1);
  }
  cout<<setprecision(15)<<ans<<endl;
}


Measured memory_bytes: 256
// Problem : D - Banned K
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
#define ss second
#define ff first
#define vpii vector<pii>
#define vvi vector<vi>
#define pb push_back
#define vs vector<string>
#define all(x) x.begin(),x.end()
#define mii map<int,int>
const int inf=0x3f3f3f3f3f3f3f3f;
void print(vi &v){
    for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
    cout<<endl;
}
int power(int a,int b){
    int res = 1;
    while(b!=0){
        if(b&1){
            res *= a; 
        }
        a = (a * a);
        b = (b / 2);
    }
    return res;
}
int nc(int n){
	return n*(n-1)/2;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t = 1;
    while(t--){
        int n,i;
        cin>>n;
        vi v(n+1);
        mii m;
        for(i=1;i<=n;i++){
        	cin>>v[i];
        	m[v[i]]++;
        }
        int cnt=0;
        for(auto it=m.begin();it!=m.end();it++){
        	if(it->ss>=2)cnt+=nc(it->ss);
        }
        for(i=1;i<=n;i++){
        	int val;
        	if(m[v[i]]>2){
        		val = cnt-nc(m[v[i]])+nc(m[v[i]]-1);
        	}
        	else{
        		val = cnt-nc(m[v[i]]);
        	}
        	cout<<val<<endl;
        }
    }
    return 0;
}

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

int main(){
  set<string> st;
  int n;
  cin >>n;
  string x;
  for (int i=0;i<n;i++){
    cin>>x;
    st.insert(x);
  }
  cout<<st.size()<<endl;
  return 0;
}

Measured memory_bytes: 19252
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 200

int sp;
int stack[N];

void push(int x){
  if(sp == N-1) exit(1); // isFull
  sp = sp+1;
  stack[sp] = x;
}

int pop(void){
  if(sp == 0) exit(1); // isEmpty
  sp = sp-1;
  return stack[sp+1];
}

int main(){
  int a,b,x,i,ans;
  char form[N];

  // input
  while(scanf("%s",form) != EOF){

    // operate
    switch(form[0]){
    case '+':
      b = pop();
      a = pop();
      push(a+b);
      break;
    case '-':
      b = pop();
      a = pop();
      push(a-b);
      break;
    case '*':
      b = pop();
      a = pop();
      push(a*b);
      break;
    default:
      x = atoi(form);
      push(x);
      break;
    }

  }

  // output
  ans = pop();
  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
#include<unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;
int main() {
	cin >> N;
	vector<int>X(N),cX(N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &X[i]);
		cX[i] = X[i];
	}
	sort(cX.begin(), cX.end());
	ll medlow = cX[N / 2 - 1];
	ll medhigh = cX[N / 2];
	for (int i = 0; i < N; i++) {
		if (X[i] <= medlow)printf("%d\n",medhigh);
		else printf("%d\n", medlow);
	}
}

Measured memory_bytes: 3712
import sys
f = sys.stdin

n = int(f.readline())
s = [list(map(int, line.split())) for line in f]

p = [[i==j for j in range(n + 1)] for i in range(n + 1)]
c = [0] + [c for c,w in s]
sum_w = [0] + [w for c,w in s]
for i in range(1, len(sum_w)):
    sum_w[i] += sum_w[i - 1]
    
for length in range(n):
    for i in range(1, n + 1 - length):
        j = i + length
        if not p[i][j]:
            continue
        if j + 1 <= n:
            if sum_w[j] - sum_w[i - 1] <= c[j + 1]:
                p[i][j + 1] = True
        if sum_w[j] - sum_w[i - 1] <= c[i - 1]:
            p[i - 1][j] = True

dp = [999999999] * (n + 1)
dp[0] = 0
for b in range(1,n + 1):
    for e in range(1,n + 1):
        if p[b][e]:
            dp[e] = min(dp[e], dp[b - 1] + 1)

print(dp[-1])

Measured memory_bytes: 15724
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  double a,b,x;cin >>a>>b>>x;
  double PI = 4.0d * atan(1.0d);
  if(x>=a*a*b/2.0d){
    cout << setprecision(10)<<fixed <<180.0d/PI * atan(2.0d*(b*a*a - x)/(a*a*a)) << endl;
  } else {
    cout << setprecision(10)<<fixed <<90.0d - 180.0d/PI * atan(2.0d*x/(b*b*a)) << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
    long L,R;
    cin >> L >> R;

    long ans = 2019;
    bool flag = true;
    for(long i = L; i<R; i++){
        for(long j = i+1; j<=R ;j++){
            ans = min(ans, (i*j)%2019);
            if(ans == 0){
                flag = false;
                break;
            }
        }
        if(!flag){
            break;
        }
    }

    cout << ans <<endl;
}


Measured memory_bytes: 256
import sys

cnt = 1
input_arr = []
for l in sys.stdin:
  input_arr.append(l.split("\n")[0])
  if len(input_arr) == cnt:
      break
A, B = input_arr[0].split()
A = int(A)
B = int(B)
AB = A * B
if AB % 2 == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,x,y,tot,a[200000][2],first[200000];
long long cnt0,cnt1;
bool col[200000][2],u[200000];
void dfs(int x,int fa) {
	u[x]=1;
	int tw;
	for (int i=first[x];i;i=a[i][0]) {
        tw=a[i][1];
        if (tw==fa) continue;
        if (col[x][0]) col[tw][1]=1;
        if (col[x][1]) col[tw][0]=1;
        if (!u[tw]) dfs(tw,x);
    }
}
void ins_ed(int x,int y) {
    tot++;
    a[tot][1]=y;
    a[tot][0]=first[x];
    first[x]=tot;
}
int main() {
	scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++) {
        scanf("%d%d",&x,&y);
        ins_ed(x,y);
        ins_ed(y,x);
    }
    col[1][0]=1;
    dfs(1,0);
    for (int i=1;i<=n;i++) {
    	if (col[i][0]&&col[i][1]) {
    		printf("%lld",1ll*n*(n-1)/2-m);
    		return 0;
    	}
    	if (col[i][0]) cnt0++; else cnt1++;
    }
    printf("%lld",cnt0*cnt1-m);
    return 0;
}

Measured memory_bytes: 3584
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0]*(n+1)
    
    def Sum(self,i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
    
    def add(self,i,x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

class RangeUpdate:
    def __init__(self, n):
        self.p = BIT(n+1)
        self.q = BIT(n+1)
        
    def add(self,s,t,x):
        t+=1
        self.p.add(s,-x*s)
        self.p.add(t,x*t)
        self.q.add(s,x)
        self.q.add(t,-x)
        
    def Sum(self,s,t):
        t+=1
        return self.p.Sum(t) + self.q.Sum(t)*t-self.p.Sum(s)-self.q.Sum(s)*s
    
n, q = map(int, input().split())
tree = RangeUpdate(n)
for _ in range(q):
    a, *b = map(int,input().split())
    if a == 0:
        tree.add(b[0],b[1],b[2])
    else:
        print(tree.Sum(b[0],b[1]))


Measured memory_bytes: 11796
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let s = s.trim();

    let mut o = 0;
    let mut e = 0;
    for (i, v) in s.char_indices() {
        match (i % 2, v) {
            (0, '0') => o+=1,
            (0, '1') => e+=1,
            (1, '0') => e+=1,
            (1, '1') => o+=1,
            _ => {},
        }
    }
    println!("{}", if o < e { o } else { e });
}


Measured memory_bytes: 4352
object Main {
  def main(args: Array[String]): Unit = {
    val first  = Dice(io.StdIn.readLine().split(" ").map(_.toInt))
    val second = Dice(io.StdIn.readLine().split(" ").map(_.toInt))

    val answer =
      if (Dice.equals(first, second)) "Yes"
      else "No"

    println(answer)
  }

  case class Dice(upSide: Int, southSide: Int, eastSide: Int, westSide: Int, northSide: Int, downSide: Int) {
    import Direction._
    def spinClockwise: Dice = Dice(upSide, eastSide, northSide, southSide, westSide, downSide)
    def spinCounterclockwise: Dice = Dice(upSide, westSide, southSide, northSide, eastSide, downSide)
    def roll(direction: Direction): Dice = direction match {
      case North =>
        Dice(southSide, downSide, eastSide, westSide, upSide, northSide)
      case South =>
        Dice(northSide, upSide, eastSide, westSide, downSide, southSide)
      case West =>
        Dice(eastSide, southSide, downSide, upSide, northSide, westSide)
      case East =>
        Dice(westSide, southSide, upSide, downSide, northSide, eastSide)
    }
  }
  object Dice {
    def apply(sides: Array[Int]): Dice = Dice(sides(0), sides(1), sides(2), sides(3), sides(4), sides(5))

    def equals(d1: Dice, d2: Dice): Boolean = {
      import Direction._

      val sides = d1.northSide :: d1.westSide :: d1.southSide :: d1.eastSide ::
                  d1.northSide :: d1.westSide :: d1.southSide :: Nil
      @annotation.tailrec
      def sameDice(rolled: Option[Direction], d: Dice): Boolean = {
        val same =
          if (d1.upSide == d.upSide && d1.downSide == d.downSide) {
            sides.containsSlice(d.northSide :: d.westSide :: d.southSide :: d.eastSide :: Nil)
          } else if (d1.upSide == d.downSide && d1.downSide == d.upSide) {
            sides.containsSlice(d.northSide :: d.eastSide :: d.southSide :: d.westSide :: Nil)
          } else {
            false
          }
        if (same) {
          true
        } else {
          rolled match {
            case Some(North) => sameDice(Some(West), d.roll(North))
            case Some(West) => sameDice(None, d.roll(West))
            case _ => false
          }
        }
      }

      sameDice(Some(North), d2)
    }
  }

  sealed trait Direction
  object Direction {
    case object North extends Direction
    case object South extends Direction
    case object West extends Direction
    case object East extends Direction

    def apply(c: Char): Direction = c match {
      case 'N' => North
      case 'S' => South
      case 'E' => East
      case 'W' => West
      case _ => throw new Exception
    }
  }
}

Measured memory_bytes: 44036
#include <iostream>
#include <stdlib.h>

using namespace std;

void show(int n, int* series) {

	for (int i = 0; i < n; i++)
	{
		cout << series[i];
		if (i != (n - 1)) cout << " ";
		else cout << endl;
	}
}

void insertionSort(int n, int* series) {
	int v,j;
	for (int i = 1; i < n; i++)
	{
		v = series[i];
		j = i - 1;
		while(j >= 0 && series[j] > v) {
			series[j + 1] = series[j];
			j--;
		}
		series[j + 1] = v;
		show(n, series);
	}

}

int main() {
	int n, *series;
	cin >> n;

	series = (int *)malloc(sizeof(int) * n);

	for (int i = 0; i < n; i++)
	{
		cin >> series[i];
	}
	show(n, series);
	insertionSort(n,series);
	free(series);
	return 0;
}

Measured memory_bytes: 1196
#include <cstdio>

int main(){
    int N,K,X,Y,ans=0;
    scanf("%d%d%d%d",&N,&K,&X,&Y);
    for(int i=0; i<N; i++){
        ans += (i<K) ? X : Y;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}
vector<int> dx = {1,0};
vector<int> dy = {0,1};
void dfs(int H,int W,int nx,int ny,vector<vector<char>> &ban){
    ban.at(nx).at(ny) = '.';
    /*for(int i = 0;i<H;i++){
        for(int j = 0;j<W;j++){
            cout << ban.at(i).at(j);
        }
        cout << endl;
    }
    cout << endl;*/
    for(int i = 0;i<2;i++){
        if(dx.at(i)+nx < 0 || dx.at(i)+nx >= H || dy.at(i)+ny < 0 || dy.at(i)+ny >= W) continue;
        if(ban.at(dx.at(i)+nx).at(dy.at(i)+ny) != '#') continue;
        dfs(H,W,nx+dx.at(i),dy.at(i)+ny,ban);
        return;
    }
}

int main() {
    int H,W;cin >> H >> W;
    vector<vector<char>> ban(H,vector<char>(W));
    for(int i = 0;i<H;i++)for(int j = 0;j<W;j++)cin >> ban.at(i).at(j);
    
    dfs(H,W,0,0,ban);
    string ans = "Possible";
    for(int i = 0;i<H;i++){
        for(int j = 0;j<W;j++){
            if(ban.at(i).at(j) != '.') ans = "Impossible";
        }
    }
    cout << ans << endl;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> hs(N);
  rep(i, N) cin >> hs[i];

  vector<int> dp(N, INT_MAX);
  dp[0] = 0;
  rep(i, N-1) {
    for(int j = i-K+1; j <= i; j++) {
      if (j < 0) continue;
      int cost = abs(hs[j] - hs[i+1]);
      dp[i+1] = min(dp[i+1], dp[j]+cost);
    }
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int minbus;
  int mintra;
  minbus = min(A,B);
  mintra = min(C,D);
  cout << minbus+mintra << endl;
}


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

int main() {
 int num; cin >> num;
  
 vector<int> problems(num);
 for(int i = 0; i < num; i++) {
  cin >> problems.at(i);
 }
 std::stable_sort(problems.begin(), problems.end());
 
 int ans = problems.at(num/2) - problems.at((num/2)-1);
 
 cout << ans << endl;
  
  return 0; 
}


Measured memory_bytes: 3804
//author: dazhong_feliks

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

int main() {
  int N,A;
  cin >> N >> A;
  
  if ( N % 500 <= A ) 
    { cout << "Yes" << endl;
   }
    
  else if ( N % 500 >= A )
    { cout << "No" << endl;  
  }
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    char s[5];
    scanf("%s", s);
    int a = s[0] - 48;
    int b = s[1] - 48;
    int c = s[2] - 48;
    int d = s[3] - 48;

    if (a+b+c+d == 7) printf("%d+%d+%d+%d=7\n", a,b,c,d);
    else if (a+b+c-d == 7) printf("%d+%d+%d-%d=7\n", a,b,c,d);
    else if (a+b-c+d == 7) printf("%d+%d-%d+%d=7\n", a,b,c,d);
    else if (a+b-c-d == 7) printf("%d+%d-%d-%d=7\n", a,b,c,d);
    else if (a-b+c+d == 7) printf("%d-%d+%d+%d=7\n", a,b,c,d);
    else if (a-b+c-d == 7) printf("%d-%d+%d-%d=7\n", a,b,c,d);
    else if (a-b-c+d == 7) printf("%d-%d-%d+%d=7\n", a,b,c,d);
    else if (a-b-c-d == 7) printf("%d-%d-%d-%d=7\n", a,b,c,d);
}

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


void solve(long long N, long long T, long long A, std::vector<long long> H){
	int itr = 0;
	double ans = 1000000;
	for(int i = 0;i < H.size();++i){
		if(abs((double)T - (double)H[i] * 0.006 - (double)A) < ans){
			ans = abs((double)T - (double)H[i] * 0.006 - (double)A);
			itr = i;
		}
	}
	cout << itr+1 << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long T;
    scanf("%lld",&T);
    long long A;
    scanf("%lld",&A);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, T, A, std::move(H));
    return 0;
}


Measured memory_bytes: 256
import math
N,K=[int(s) for s in input().split()]
ls1=[int(s) for s in input().split()]
ls2=[int(s) for s in input().split()]
ls1.sort()
ls2.sort()
M=max([ls1[i]*ls2[N-1-i] for i in range(N)])
#print(M)
###aまで下げることが可能か？
def pos(a):
  s=0
  for i in range(N):
    s+=max([0,math.ceil(ls1[i]-a/ls2[N-1-i])])
  if s>K:
    return 0
  else:
    return 1
x=0
y=M//2
z=M
while z-x>1:
  if pos(y)==1:
    z=y
  else:
    x=y
  y=(x+z)//2
#  print(x,y,z)
if pos(y)==1:
  print(y)
else:
  print(z)
    


Measured memory_bytes: 119884
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  bool E = true;
  for (int i = 0; i < S.size(); i++){
    if (i % 2 == 0 && S[i] == 'L' || i % 2 == 1 && S[i] == 'R') E = false;
  }
  cout << (E ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <set>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;
typedef struct Point_Coordinates {
	int i, j;
	friend bool operator<(const Point_Coordinates& l, const Point_Coordinates& r) {
		return l.i < r.i;
	}
} point;


int main(void) {
	int num, i, h, w, ans = 0;
	ll x = 0, y = 0;
	cin >> h >> w >> num;
	point p;
	vector<int> a(h + 1, 0), b(w + 1, 0);
	vector<point> d(num);
	rep(i, num) {
		cin >> p.i >> p.j;
		d[i] = p;
		a[p.i]++;
		b[p.j]++;
	}
	p.i = p.j = 0;
	rep(i, a.size()) {
		if (p.i < a[i])
			p.i = a[i];
	}
	rep(i, a.size()) {
		if (a[i] == p.i)
			x++;
	}
	rep(i, b.size()) {
		if (p.j < b[i])
			p.j = b[i];
	}
	rep(i, b.size()) {
		if (b[i] == p.j)
			y++;
	}
	x *= y;
	rep(i, num) {
		if (a[d[i].i] == p.i && b[d[i].j] == p.j)
			x--;
	}
	ans = p.i + p.j;
	if (x == 0)
		ans--;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 7988
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
struct kenn{
  int aa;
  int bb;
  int warine;
};
int main(){
  int a,b,m;
  cin >> a >> b >> m;
  vector<int> an(a);
  vector<int> bn(b);
  struct kenn waribiki[m];
  int asyou = 0;
  asyou = 1000000;
  int bsyou = 0;
  bsyou = 1000000;
  for(int i = 0;i <= a - 1;i++){
    cin >> an[i];
    if(an[i] <= asyou){
      asyou = an[i];
    }
  }
  for(int j = 0;j <= b - 1;j++){
    cin >> bn[j];
    if(bn[j] <= bsyou){
      bsyou = bn[j];
    }
  }
  for(int i = 0;i <= m - 1;i++){
    cin >> waribiki[i].aa >> waribiki[i].bb >> waribiki[i].warine;
  }
  int kotae = 0;
  kotae = 10000000;
  kotae = min(kotae,asyou + bsyou);
  for(int i = 0;i <= m - 1;i++){
    kotae = min(kotae,an[waribiki[i].aa - 1] + bn[waribiki[i].bb - 1] - waribiki[i].warine);
  }
  cout << kotae << endl;
  return 0;
}

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

int main() {

    long long a,b,c;
    cin >> a >> b >> c;

    rep(i,a*b+1){
        if((a*i) % b == c){
            cout << "YES" << endl;
            return 0;
        }
    }
    
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define no cout<<"NO"<<endl;
#define pb push_back
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define mod 1000000007
#define gcd(x,y) __gcd(x, y)
using namespace std;
map<ll,ll>mp;
int main()
{
	ll n;
	cin>>n;
	ll a[n],sum=0;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		sum^=a[i];
	}
	for(ll i=0;i<n;i++)
	{
		cout<<(sum^a[i])<<" ";
	}
}

Measured memory_bytes: 5152
//om namah shivaay
//faith over fear
//no one wants to die,yet death is the destination we all share 
// don't think you are,know you are!!

#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[2*100002];

ll fun(ll m,ll n){
    ll s=0;
    forn(i,n){
        s+=(a[i]-1)/m;
    }
    return(s);
}

int main(){
    ll n,k;
    cin>>n>>k;
    forn(i,n) cin>>a[i];
    ll f=1,l=1e18;
    while(f<l){
        ll m=(f+l)/2;
        ll val=fun(m,n);
        if(val<=k) l=m;
        else f=m+1;
    }
    cout<<f;
}


Measured memory_bytes: 5148
#include<stdio.h>
int main()
{
    int a,i,d,j=0;
    scanf("%d",&a);
    for(i=1;i<=9;i++)
    {
       if(a%i==0)
    {
        d=a/i;
        if( d>=1 &&d<=9)

        {
            j++;
        }
    }
    }
    if(j>=1)
    {
        printf("Yes\n");
    }
    else
        printf("No\n");

    return 0;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll MOD = 1e9 + 7;
    ll hatenaCount = 0;
    vector<ll> ruisekiHatena(S.size() + 1);
    vector<ll> ruisekiA(S.size() + 1);
    vector<ll> ruisekiC(S.size() + 1);
    for (int i = 0; i < S.size(); i++)
    {
        ruisekiHatena.at(i + 1) = ruisekiHatena.at(i);
        ruisekiA.at(i + 1) = ruisekiA.at(i);
        ruisekiC.at(i + 1) = ruisekiC.at(i);
        if (S.at(i) == '?')
        {
            ruisekiHatena.at(i + 1)++;
        }
        else if (S.at(i) == 'A')
        {
            ruisekiA.at(i + 1)++;
        }
        else if (S.at(i) == 'C')
        {
            ruisekiC.at(i + 1)++;
        }
    }
    ll tripleHatenaToorisuu = 1;// 一つの?をBと決めたときの左の?を'A'、別の?を'C'と決めた時の通り数(全通りの1/27になる)
    for (int i = 1; i <= ruisekiHatena.at(S.size()) - 3; i++)
    {
        tripleHatenaToorisuu = (tripleHatenaToorisuu * 3) % MOD;
    }
    ll doubleHatenaToorisuu = 1; // 一つの?をBと決めたときの左の?か右の?どちらか一つを'A'または'C'と決めた時の通り数(逆は確定とする)(全通りの1/9になる)
    for (int i = 1; i <= ruisekiHatena.at(S.size()) - 2; i++)
    {
        doubleHatenaToorisuu = (doubleHatenaToorisuu * 3) % MOD;
    }
    ll hatenaToorisuu = 1; //ひとつの?をBと決めたとき、AまたはCが確定している時の通り数(全通りの1/3)
    for (int i = 1; i <= ruisekiHatena.at(S.size()) - 1; i++)
    {
        hatenaToorisuu = (hatenaToorisuu * 3) % MOD;
    }
    ll toorisuu = 1; //ABC全部確定の時の通り数(全通り数になる)
    for (int i = 1; i <= ruisekiHatena.at(S.size()); i++)
    {
        toorisuu = (toorisuu * 3) % MOD;
    }
    ll answer = 0;
    for (int i = 1; i < S.size() - 1; i++)
    {
        if (S.at(i) == 'B')
        {
            //確定Aと確定Cの分
            answer = (answer + toorisuu * ruisekiA.at(i) * (ruisekiC.at(S.size()) - ruisekiC.at(i + 1))) % MOD;
            //確定Aと?がCの分
            answer = (answer + hatenaToorisuu * ruisekiA.at(i) * (ruisekiHatena.at(S.size()) - ruisekiHatena.at(i + 1))) % MOD;
            //?がAと確定Cの分
            answer = (answer + hatenaToorisuu * ruisekiHatena.at(i) * (ruisekiC.at(S.size()) - ruisekiC.at(i + 1))) % MOD;
            //?がAと?がCの分
            answer = (answer + doubleHatenaToorisuu * ruisekiHatena.at(i) * (ruisekiHatena.at(S.size()) - ruisekiHatena.at(i + 1))) % MOD;
        }
        else if (S.at(i) == '?')
        {
            //確定Aと確定Cの分
            answer = (answer + hatenaToorisuu * ruisekiA.at(i) * (ruisekiC.at(S.size()) - ruisekiC.at(i + 1))) % MOD;
            //確定Aと?がCの分
            answer = (answer + doubleHatenaToorisuu * ruisekiA.at(i) * (ruisekiHatena.at(S.size()) - ruisekiHatena.at(i + 1))) % MOD;
            //?がAと確定Cの分
            answer = (answer + doubleHatenaToorisuu * ruisekiHatena.at(i) * (ruisekiC.at(S.size()) - ruisekiC.at(i + 1))) % MOD;
            //?がAと?がCの分
            answer = (answer + tripleHatenaToorisuu * ruisekiHatena.at(i) * (ruisekiHatena.at(S.size()) - ruisekiHatena.at(i + 1))) % MOD;
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 2896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

int h, w;
vector<vector<char>> vec;

vector<vector<int>> bfs(int sy, int sx) {
    vector<vector<int>> d(h, vector<int>(w, INF));
    queue<pair<int, int>> q;

    q.push(make_pair(sy, sx));
    d[sy][sx] = 0;

    while (!(q.empty())) {
        pair<int, int> now = q.front();
        q.pop();

        rep(i, 4) {
            int ny = now.first + dy[i];
            int nx = now.second + dx[i];

            if (!(0 <= ny && ny < h && 0 <= nx && nx < w)) continue;
            if (vec[ny][nx] == '.' && d[ny][nx] == INF) {
                q.push(pair<int, int>(ny, nx));
                d[ny][nx] = d[now.first][now.second] + 1;
            }
        }
    }

    return d;
}

int main() {
    cin >> h >> w;
    vec.resize(h);
    rep(i, h) {
        vec[i].resize(w);
        rep(j, w) cin >> vec[i][j];
    }

    int ans = 0;
    rep(sy, h) rep(sx, w) rep(gy, h) rep(gx, w) {
        if (vec[sy][sx] != '.') continue;
        if (vec[gy][gx] != '.') continue;

        auto d = bfs(sy, sx);
        chmax(ans, d[gy][gx]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

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

int main() {
    int64_t N, A, B;
    cin >> N >> A >> B;
    if (A==0) {
        cout << 0 << endl;
        return 0;
    }
    int64_t ret = (N/(A+B)) * A; 
    ret += min(A, N % (A+B));

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX = 200010;
int a[MAX];
int main() 
{
	int n;
	cin >> n;
	for(int i = 0; i < n; ++ i)
	{
		cin >> a[i];
	}
	
	int maxn = a[1] - a[0], minn = a[0];
	
	for(int i = 1; i < n; ++ i)
	{
		maxn = max(maxn, a[i] - minn);
		minn = min(minn, a[i]);
	}
	cout << maxn << endl;
	return 0;
}


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

int main(){
  int N, A[100001], B, a;
  long long sum = 0L;
  cin >> N;
  for(int i = 0;i <= N;i++)
    cin >> A[i];


  for(int i = 1;i <= N;i++){
    cin >> B;
    a = A[i - 1] - B;
    if(a < 0) {
      sum += A[i - 1];
      A[i] -= a * -1;
      if(A[i] > 0)sum += a * -1;
      else{
        sum += a * -1 + A[i];
        A[i] = 0;
      }
    }else{
      sum += B;
    }
  }
  cout << sum;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    cout << N * (N - 1)/ 2 << endl;


    return 0;
}


Measured memory_bytes: 256