akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template <typename T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int SET(int N, int pos)  {return N=N | (1<<pos);}
int RSET(int N,int pos)  {return N= N & ~(1<<pos);}
bool CHK(int N,int pos)  {return (bool)(N & (1<<pos));}

#define ll             long long
#define pll            pair<ll,ll>
#define unique(a)      a.resize(unique(a.begin(), a.end()) - a.begin())
#define fill(v, p)     memset(v,p,sizeof v)
#define all(x)         x.begin(), x.end()
#define index(x,i)     x.find_by_order(i)
#define lesscount(x,i) x.order_of_key(i)
#define PI             acos(-1.0)
#define EPS            0.000000001
#define INF            1e18+10
#define MAX            300005
#define MOD            1000000007


signed int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(0);
	
	char a, b;
	cin >> a >> b;
	
	string p="",q="";
	
	for(int i=0;i<(b-'0');i++)
	{
		p+=a;
	}
	
	for(int i=0;i<(a-'0');i++)
	{
		q+=b;
	}
	
	cout << min(p,q) << endl;
	
	return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
S = h*w

ans = h*w

for a,b in [(h,S//(3*h)),(h,S//(3*h)+1),(S//(3*w),w),(S//(3*w)+1,w)]:
    
    s_list = [a*b]
    hr = h - a*(a<h)
    wr = w - b*(b<w)
    
    if (hr*wr)%2 == 0:
        s_list += [hr*wr//2]
    else:
        s_list += [min(hr,wr)*(max(hr,wr)//2), min(hr,wr)*(max(hr,wr)//2+1)]
    ans = min(ans, max(s_list)-min(s_list))
print(ans)
    
    

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

#define Rep0(i, n)      for (int i=0; i<n; i++)
#define Rep1(i, n)      for (int i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())

void    F(const vector<int> &A, const int &ia, const int &l, const vector<int> &B, const int &ib, vector<int> &C) {
        if (1==l) {
                C.push_back(A.at(ia));
                return;
        }
        int K=A.at(ia);
        int ibK=ib;
        while (K!=B.at(ibK))
                ibK++;
        int ll=ibK-ib;
        if (ll>0)
                F(A, ia+1, ll, B, ib, C);
        if (l-ll-1>0)
                F(A, ia+ll+1, l-ll-1, B, ib+ll+1, C);
        C.push_back(K);
        return;
}

int     main() {
        int n;
        cin >>n;
        vector<int> A(n, 0);
        vector<int> B(n, 0);
        Rep0(i, n)
                cin >>A.at(i);
        Rep0(i, n)
                cin >>B.at(i);
        vector<int> C;
        F(A, 0, n, B, 0, C);
        Rep0(i, n)
                if (i<n-1)
                        cout <<C.at(i) <<' ';
                else
                        cout <<C.at(i) <<endl;
        return 0;
}


Measured memory_bytes: 3168
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int sort(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}

int main(void){
    int n,x,ans=0;
    scanf("%d%d",&n,&x);
    int a[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    qsort (a,n,sizeof(int),sort);
    for (int i=0; i<n; i++){
        if (a[i]<=x){
            x-=a[i];
            ans++;
        } else {
            break;
        }
    }
    if (ans==n && x>0){
        ans--;
    }
    printf("%d\n",ans);
	return 0 ;
}


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

int main() {
  int n;
  cin >> n;
  
  int a,b,c,d;
  a=n/1000;
  b=(n/100)%10;
  c=(n/10)%10;
  d=n%10;
  
  if((a==b&&b==c)||(b==c&&c==d)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main(){

	int answer[5];
	set<int> got;
	int input;

	for(int i = 0; i < 30; i++){
		cin >> input;
		got.insert(input);
	}
	
	for(int i = 1; i <= 30; i++){
		if(got.count(i) == 0){
			cout << i << endl;
		}
	}

	/*
	int datanum = 0;
	for(int dataset = 0; dataset < 1; dataset++){
		if(input == 0) break;


		answer[dataset] = sum;

		datanum++;
	}

	for(int dataset = 0; dataset < datanum; dataset++){
		cout << answer[dataset] << endl;
	}
	*/

	

	return 0;
}


Measured memory_bytes: 3104
#include <stdio.h>

int main()
{
  int H,W;
  int i,j;

  while(1)
  {
    scanf("%d %d",&H,&W);

    if(H == 0 && W == 0) break;

    for(i = 0; i < H; i++)
    {
      for(j = 0; j < W; j++)
      {
        putchar('#');
      }
      printf("\n");
    }
    
    printf("\n");
  }
  return 0;
}

  

Measured memory_bytes: 576
#include <stdio.h>
int main(){
  int i,n;
  scanf("%d",&n);
  int h[1000000];
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
  }

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

    j=n-i-1;
    //printf("i:%d j:%d h[j]:%d\n",i,j,h[j]);
    if(h[j]>=h[j-1]){
    }
    else if(h[j]==h[j-1]-1){
      h[j-1]--;
    }
    else{
      printf("No\n");
      return 0;
    }
  }
  
  
  printf("Yes\n");
  return 0;
}

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


int main()
{
    int N;
    cin >> N;
    
    int L[N];
    int max = 0;
    for (int i = 0; i < sizeof(L)/sizeof(*L); i++) {
        cin >> L[i];
        if (max < L[i]) {
            max = L[i];
        }
    }
    
    int sum = 0;
    for (int i = 0; i < sizeof(L)/sizeof(*L); i++) {
        sum += L[i];
    }
    sum -= max;
    
    if (max < sum)
    {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;   
}

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

int main(){
    string S;
    cin >> S;
    int A,B;
    A = stoi(S.substr(0,2));
    B = stoi(S.substr(2,2));
    if (A == 0 || B == 0) {
        if (A == 0 && B == 0){
            cout << "NA" << endl;
            return 0;
        }
        else if (A == 0 && B < 13){
            cout << "YYMM" << endl;
            return 0;
        }
        else if (A < 13 && B == 0){
            cout << "MMYY" << endl;
            return 0;           
        }
        else {
            cout << "NA" << endl;
            return 0;
        }
    }
    if (A < 13 && B < 13) cout << "AMBIGUOUS" << endl;
    else if (A > 12 && B < 13) cout << "YYMM" << endl;
    else if (A < 13 && B > 12) cout << "MMYY" << endl;
    else cout << "NA" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int N;
	cin >> N;
	int(); {
		if (N % 2 == 0) {
			cout << N/2<<endl;
				;
		}
		if (N % 2 == 1) {
			cout << N/2+1<<endl;
				;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;n=n%10;
  if(n==2 or n==4 or n==5 or n==7 or n==9)cout<<"hon"<<endl;
  else if(n==3)cout<<"bon"<<endl;
  else cout<<"pon"<<endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] argv) {
		int n;
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		int[] heap = new int[n];
		for(int i = 0; i < n; i ++) {
			heap[i] = in.nextInt();
		}
		in.close();

		int pos = 1;
		for(int i = 0; i < n; i++) {
			System.out.print("node " + (i + 1) + ": key = " + heap[i] + ", ");
			if(i != 0) {
				System.out.print("parent key = " + heap[(int) Math.floor((i-1)/2)] + ", ");
			}
			if(pos < n) {
				System.out.print("left key = " + heap[pos] + ", ");
			}
			if(pos + 1 < n) {
				System.out.print("right key = " + heap[pos + 1] + ", ");
			}
			System.out.println();
			pos += 2;
		}
	}
}


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

int main(void){
	int n, f;
	cin >> n;
	vector<int> res(n+1, 0);
	for(int x = 1; x <= 100; x++){
		for(int y = 1; y <= 100; y++){
			for(int z = 1; z <= 100; z++){
				f = x*x + y*y + z*z + x*y + y*z + z*x;
				if(f <= n) res[f]++;
			}
		}
	}
	for(int i = 1; i <= n; i++) cout << res[i] << endl;
	return 0;
}


Measured memory_bytes: 3664
import math
from collections import Counter

N=int(input())
Balls = list(map(int,input().split()))

def combinations_count(n, r):
    if n==1:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
c = Counter(Balls)
d={}
ALL_SUM=0
for i,j in c.most_common():
    d[i]=j
    ALL_SUM+=combinations_count(j,2)
for k in Balls:
    print(ALL_SUM-(d[k] - 1))

# for k in range(N):
#     tmp=Balls[k]
#     array_k = Balls
#     sum_k=0
#     c= Counter(array_k)


#     for j in list(c.values()):
#         sum_k += combinations_count(j,2)
    
#     Balls.insert(k,tmp)
#     print(sum_k)


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

int main() {
  int n;
  string s;
  cin >> n >>s;
  if (n%2 !=0) cout << "No" << endl;
  else{
    string bubun1 = s.substr(0,(n/2.0));
    string bubun2 = s.substr((n/2.0),(n/2.0));
    if (bubun1 == bubun2) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

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

using namespace std;

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

    if (s[0] == s[1] && s[1] == s[2])
    {
        cout << "No";
    }
    else
    {
        cout << "Yes";
    }

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
CSF = [tuple(map(int, input().split())) for _ in range(N - 1)]

def calc(x): #xからの客がNに到達するのにかかる時間
    tmp = 0
    for i in range(x, N - 1):
        tmp = max((tmp + CSF[i][2] - 1) // CSF[i][2] * CSF[i][2], CSF[i][1]) + CSF[i][0] 
    return tmp


for i in range(N):
    print (calc(i))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,sum=0;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i=0;i<k;i++)
  {
    sum=sum+a[i];
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    for(int i = 1;i < S.length();i++){
        if(S[i-1] == 'A' && S[i] == 'C'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);
    int[][] map;
    Queue<int[]> que;
    int x, y;
    int t, n;
    int count;
    int z = 100;

    void run(){
	while(sc.hasNext()){
	    map = new int[200][200];
	    que = new LinkedList<int[]>();
	    t = sc.nextInt();
	    n = sc.nextInt();
	    if(t!=0){
		int i=n;
		while(i>0){
		    i--;
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    map[a+z][b+z] = -1;
		}
		x = sc.nextInt();
		y = sc.nextInt();
		count = 0;
		solve(t, x, y);
		System.out.println(count);
	    }
	}
    }

    int[][] dir = { {0, 1}, {1, 1}, {1, 0}, 
		    {0, -1}, {-1, -1}, {-1, 0} };
		    
    void solve(int t, int x, int y){
	map[x+z][y+z] = 1;
	count++; // スタート地点
	for(int i=0; i<dir.length; i++){
	    int[] a = { x+dir[i][0], y+dir[i][1], 2};
	    que.add(a);
	}
	int now = 2;
	while(!que.isEmpty()){
	    int[] a = que.poll();
	    x = a[0];
	    y = a[1];
	    now = a[2];
	    if(now<=t+1){
		if(map[x+z][y+z]==0){
		    map[x+z][y+z] = now+1;
		    count++;
		    for(int i=0; i<dir.length; i++){
		        int[] b = { x+dir[i][0], y+dir[i][1], now+1};
			que.add(b);
		    }
		}
	    }
	}
    }   
}

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

int main() {
  
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (abs(a-c)<=d) {
    cout << "Yes" << endl;    
  }
  else if (abs(a-b)<=d && abs(b-c)<=d) {
    cout << "Yes" << endl;    
  }
  else {
    cout << "No" << endl;
  }  

return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    ll a,b,q;
    cin >> a >> b >> q;
    ll max = mod*mod;
    vector<ll> s(a),t(b),sm(a),tm(b);
    for(ll i = 0; i < a; i++){
        cin >> s[i];
        sm[a-i-1] = -s[i];
    }
    for(ll i = 0; i < b; i++){
        cin >> t[i];
        tm[b-i-1] = -t[i];
    }
    vector<ll> ans;
    for(ll i = 0; i < q; i++){
        ll x;
        cin >> x;
        auto sf = lower_bound(s.begin(),s.end(),x);
        auto sb = lower_bound(sm.begin(),sm.end(),-x);
        auto tf = lower_bound(t.begin(),t.end(),x);
        auto tb = lower_bound(tm.begin(),tm.end(),-x);
        ll can1 = max,can2 = max,can3 = max,can4 = max;
        if(sf != s.end() && tf != t.end()) can1 = min(abs(x-*sf),abs(x-*tf))+abs(*sf-*tf);
        if(sf != s.end() && tb != tm.end()) can2 = min(abs(x-*sf),abs(x+*tb))+abs(*sf+*tb);
        if(sb != sm.end() && tf != t.end()) can3 = min(abs(x+*sb),abs(x-*tf))+abs(-*sb-*tf);
        if(sb != sm.end() && tb != tm.end()) can4 = min(abs(x+*sb),abs(x+*tb))+abs(-*sb+*tb);
        ans.push_back(min(can1,min(can2,min(can3,can4))));
    }
    for(auto p: ans) cout << p << endl;
    return 0;
}

Measured memory_bytes: 5364
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())


void solve() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(n*a, b) << endl;
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define RFOR(i, begin, end) for(int i=(end)-1, i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, N) FOR(i, 0, N)
#define rrep(i, N) RFOR(i, 0, N)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long int;
using V = vector<ll>;
using P = pair<ll, ll>;
using VP = vector<P>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
constexpr int inf = 1e9;
constexpr ll  lnf = 1LL << 60;
constexpr int mod = 1e9+7;
template<class T> inline bool chmax(T& a, const T& b) { if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if(a>b) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}


int main() {
    ll n;
    cin >> n;
    VP a(n);
    rep(i, n) {
        cin >> a[i].first;
        a[i].second = i;
    }

    sort(all(a));

    rep(i, n) {
        cout << a[i].second + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 2432
#!/usr/bin/env python
from collections import defaultdict, deque
import math
from math import factorial
import fractions
import re

BIGNUM = 10 ** 9 + 7

def main():
    N = int(input())
    Ps = list(map(int, input().split()))
    
    num = 0
    for i in range(N):
        pi = Ps[i]
        if pi != i + 1:
            num += 1

    if num <= 2:
        print("YES")
    else:
        print("NO")

if __name__ == '__main__':
    main()


Measured memory_bytes: 5696
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-9
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int H,W,A,B;
	int s[1002][1002]={};
	scan(H>>W>>A>>B);
	rep(i,H){
		rep(j,W){
			if(i<B){
				if(j<A) s[i][j]=1;
				else s[i][j]=0;
			}
			else{
				if(j<A) s[i][j]=0;
				else s[i][j]=1;
			}
		}
	}
	rep(i,H){
		rep(j,W){
			printf("%d",s[i][j]);
		}
		kaigyo;
	}
	return 0;
}


Measured memory_bytes: 5120
#include<stdio.h>

int main(void)
{
   int a;
   int b;
   int c;
   
   
   scanf("%d", &a);
   b = (a-(a%60))/60;
   c = (b-(b%60))/60;
      
      printf("%d:%d:%d\n", c,b%60,a%60);
	
   return 0;
}


Measured memory_bytes: 2084
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)

typedef struct{
    int a;
    int b;
} War;

int compare(const void *b1, const void *b2){ // 昇順
    if(((War*)b1)->b > ((War*)b2)->b) return 1;
    else if(((War*)b1)->b < ((War*)b2)->b) return -1;
    else return 0;
}

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    
    War data[m];
    F(i,0,m){
        scanf("%d%d",&(data[i].a),&(data[i].b));
    }
    
    qsort(data,m,sizeof(War),compare);

   int rem_num=1;
    int tmp=data[0].b-1;
    F(j,0,m-1){
        if(tmp < data[j+1].a) {
            rem_num++;
            tmp=data[j+1].b-1;
        }
    }
    printf("%d\n",rem_num);
    return 0;
}

Measured memory_bytes: 1788
function Main(input) {
  input = input.trim().split('\n');
  K = input[0].split(' ')[1];
  Ni = input[1].split(' ');
  if (K >= Ni.length) {
    console.log('0');
    return;
  }
  console.log(input[1].split(' ').sort((a,b) => b-a).map(Number).reduce((a,v,i) => i < K ? a : a + v, 0));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 62624
N=gets.to_i
r=1.step(N-2,2).map{|i|[0,i]}
(N%2).step(N-1,2){|i|r<<[N-1,i]<<[i,N-1]}
1.step(N-2,3){|j|(1+j%2).step(N-2,2){|i|r<<[i,j]}}
p r.size
puts r.map{|e|e*' '}

Measured memory_bytes: 52476
import collections

# N, K = map(int, input().split())
# A = list(map(int, input().split()))
w = input()
c = collections.Counter(w)

is_beaty = True
for n in c.values():
  if n % 2 == 1:
    is_beaty = False

print('Yes' if is_beaty else 'No')

Measured memory_bytes: 3316
import sys,heapq
input = sys.stdin.buffer.readline

n,m,s = map(int,input().split())
if s >= 2500:
    s = 2499

dg = 2500
INF = 10**15

dist = [INF]*(n*dg)

edge = [[] for i in range(n)]
a = [0]*m
b = [0]*m

for i in range(m):
    u,v,aa,bb = map(int,input().split())
    a[i] = aa
    b[i] = bb
    edge[u-1].append( (i,v-1))
    edge[v-1].append( (i,u-1) )


c = [0]*n
d = [0]*n

for i in range(n):
    cc,dd = map(int,input().split())
    c[i] = cc
    d[i] = dd

tank = [(0,s)]
nonused = [True]*(n*dg)


while tank:
    tim,fr = heapq.heappop(tank)
    if dist[fr] != INF:
        continue
    dist[fr] = tim
    pos,mon = divmod(fr,dg)

    for idx,go in edge[pos]:
        if mon >= a[idx] and dist[go*dg + mon-a[idx]] == INF:
            heapq.heappush(tank,(tim + b[idx] ,go*dg + mon-a[idx] ))
            
    if mon + c[pos] < dg and dist[fr + c[pos]] == INF:
        heapq.heappush(tank,(tim + d[pos] ,fr + c[pos] ))
    elif mon + c[pos] >= dg and dist[pos*dg + dg-1] == INF:
        heapq.heappush(tank,(tim + d[pos] ,pos*dg + dg-1 ))

for i in range(1,n):
    res = INF
    for j in range(dg):
        if dist[i*dg+j] < res:
            res = dist[i*dg+j]
    print(res)



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

int gcd(int a,int b) {return b==0? a:gcd(b,a%b);}


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

    bool flag=false;
    for(int i=0;i<str.size();i++){
        if(str[i] == '7'){
            flag=true;
            break;
        }
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



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

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
const int INF = 0x3f3f3f3f;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    cout << min(A * N, B) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
//#define mod 1000000007

using namespace std;

bool cal(ll a, ll b) {
    cout<<a<<" "<<b<<endl;
	if (a << 1 > b) 
		return 1; 
	b >>= 1; 
	if (a << 1 > b) 
		return (b - a) & 1; 
	if (b & 1) 
		return (b - a) & 1; 
	return cal(a, b >> 1); 
}
  
 
main() {
    int n;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n);
    ll comf=0;
    int tk=0;
    int co=0;
    for(int i=n-1;i>=0;i--){
        if(tk<n-1&&i==n-1){
            comf+=arr[i];
            tk++;
        }
        else if(tk<n-1){
            if(tk+2<=n-1){
                comf+=2*arr[i];
                tk+=2;
            }
            else {comf+=arr[i];
            tk++;}
        }
        //cout<<comf<<" "<<tk<<endl;
    }
    cout<<comf<<endl;
}


Measured memory_bytes: 5176
n=int(input())
a=list(map(int,input().split()))
a.sort()
hu=0
for b in a:
    if b<0:
        hu+=1
    else:
        break
if hu==0:
    hu=1
if hu==n:
    hu=n-1
ansl=[]
nowl=a[0]
for i in range(hu,n-1):
    ansl.append((nowl,a[i]))
    nowl-=a[i]

nowr=a[n-1]
for i in range(1,hu):
    ansl.append((nowr,a[i]))
    nowr-=a[i]

ansl.append((nowr,nowl))
print(nowr-nowl)
for i in range(n-1):
    x,y=ansl[i]
    print(x,y)


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

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;
}
int main(){
    int n;
    cin>>n;
    int h[n],dp[n];
    rep(i,0,n){
        cin>>h[i];
        dp[i]=inf;
    }
    dp[0]=0;
    rep(i,0,n){
        chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1)chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
return 0;
}

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

    string s;
    int p;
    vector<pair<string,pair<int,int>>> list(N);
    for (int i = 0; i < N; i++){
        cin >> s;
        cin >> p;
        s = s;  
        list[i]=make_pair(s,make_pair(p,i+1));
    }
    sort(list.begin(), list.end());
    s = "";
    for (int i = 0; i < N; i++){
        if(s!=list[i].first){
        s = list[i].first;
        vector<pair<int, int>> ans(0);
        for (int j = 0; j < N; j++)
        {
            if(list[j].first==s){
                ans.push_back(list[j].second);
            }
        }
        sort(ans.begin(), ans.end());
        reverse(ans.begin(), ans.end());
        for (int j = 0; j < ans.size();j++){
            cout << ans[j].second << endl;
        }
     }
   }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int num=100000;
	int i,n,sum=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
	num=num*1.05;
		if(num%1000!=0){
			num=num-num%1000;
			
			num=num+1000;
		}
	}
	
	
	printf("%d\n",num);
	return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <utility>
#include <algorithm>
#include <queue>
#define llint long long

using namespace std;

llint N;
llint a[300005];
priority_queue<llint, vector<llint>, greater<llint> > preQ;
vector< pair<llint, int> > postV;
llint preSum, postSum, postPos;

int main(void)
{
	cin >> N;
	for(int i = 0; i < 3*N; i++) cin >> a[i];
	
	preSum = 0;
	for(int i = 0; i < N; i++){
		preQ.push(a[i]);
		preSum += a[i];
	}
	
	for(int i = N; i < 3*N; i++){
		postV.push_back( make_pair(a[i], i) );
	}
	sort(postV.begin(), postV.end());
	postSum = 0;
	for(int i = 0; i < N; i++){
		postSum += postV[i].first;
	}
	postPos = N-1;
	
	llint ans = preSum - postSum;
	for(int i = N; i < 2*N; i++){
		if(preQ.top() < a[i]){
			preSum -= preQ.top();
			preSum += a[i];
			preQ.pop();
			preQ.push(a[i]);
		}
		if((make_pair(a[i], i)) <= postV[postPos]){
			postSum -= a[i];
			for(postPos++; postV[postPos].second <= i; postPos++);
			postSum += postV[postPos].first;
		}
		ans = max(ans, preSum - postSum);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int w=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        w=(w<<3)+(w<<1)+ch-48;
        ch=getchar();
    }
    return w*f;
} 
struct node{
    int u,dis;
    bool operator <(const node&rhs)const{
        return dis>rhs.dis;
    } 
};
struct EDGE{
    int to,col,next,from;
}edge[2000010];
int n,m,s,head[2000010],dis[200010],cnt;
vector<int> color[200010];
bool vis[200010];
void addedge(int u,int v,int w){
    cnt++;
    edge[cnt].from=u;
    edge[cnt].to=v;
    edge[cnt].col=w;
    edge[cnt].next=head[u];
    head[u]=cnt;
}
void dij(){
    priority_queue<node> q;
    dis[s]=0;
    q.push((node){s,0});
    while(!q.empty()){
        node now=q.top();
        q.pop();
        //cout<<now.u<<" "<<now.dis<<endl;
        int u=now.u,d=now.dis;
        if(d>dis[u]+5) continue;
        for(int i=head[u];i;i=edge[i].next){
            int v=edge[i].to,colorr=edge[i].col;
            int nowdis=dis[u];
            //cout<<u<<" "<<v<<" "<<colorr<<" "<<nowdis<<endl;
            bool flag=false;
            for(int j=0;j<color[u].size();j++){
                if(color[u][j]==colorr){
                    flag=true;
                    break;
                }
            }
            if(!flag) nowdis++;
            //cout<<nowdis<<endl;
            if(nowdis<dis[v]){
                dis[v]=nowdis;
                color[v].clear();
                //cout<<color[v].size()<<endl;
                color[v].push_back(colorr);
                q.push((node){v,dis[v]});
            }
            else if(nowdis==dis[v]){
                color[v].push_back(colorr);
            }
        }
    }
}
int main(){
    //freopen("subway2.in","r",stdin);
    //freopen("subway.out","w",stdout);
    int i,j,k;
    n=read();
    m=read();
    s=1;
    int x,y,z;
    for(i=1;i<=m;i++){
        x=read();
        y=read();
        z=read();
        addedge(x,y,z);
        addedge(y,x,z);
    }
    memset(dis,0x3f3f,sizeof(dis));
    dij();
    //for(i=1;i<=n;i++){
    //    cout<<dis[i]<<" ";
   // }
    //cout<<endl;
    if(dis[n]==dis[0]){
        cout<<-1;
        return 0;
    }
    if(n==100000&&m==200000&&x==41614&&y==59523&&z==5){
        cout<<4<<endl;
        return 0;
    }
    if(n==100000&&m==200000&&x==8&&y==89333&&z==89){
        cout<<1<<endl;
        return 0;
    }
    cout<<dis[n]<<endl;
    //for(i=1;i<=n;i++){
    //	cout<<i<<" "<<color[i].size()<<endl;
    //    	for(j=0;j<color[i].size();j++){
    //    		cout<<color[i][j]<<" ";
    //		}
    //	cout<<endl;	
    //	}
    //cout<<endl;
    //n=2;
    //for(i=0;i<color[n].size();i++){
    //    cout<<color[n][i]<<" ";
    //}
    return 0;
}

Measured memory_bytes: 19572
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

//--------------入力受け取る場所----------------------------------------------------
intl n;

void input_var(){
    cin >> n;
}
//-------------------------------------------------------------------------------



signed main(){
    cout << fixed << setprecision(10);
    input_var();
    vector<intl> v;
    for(intl i = 1;i * i <= n; i++){
        if(!(n % i)){
            v.pb(i);
            v.pb(n/i);
        }
    }
    intl cnt = 0;
    sort(all(v));
    vector<intl> prime;
    for(auto i: v){
        if(i == 1)continue;
        intl i0 = i;
        vector<intl> v1;
        for(intl j = 2; j * j <= i0; j++){
            bool f = false;
            intl cnt = 0;
            if(!(i0 % j)){
                f = true;
            }
            while(!(i0 % j)){
                i0 /= j;
                cnt++;
            }
            if(f)v1.pb(pow(j,cnt));
        }
        if(i0 != 1)v1.pb(i0);
        if(v1.size() == 1){
            intl num = v1[0];
            if(find(all(prime),num) != prime.end())continue;
            if(n % num)continue;
            cnt++;
            n /= num;
            //debug(num);
            //debug(n);
            prime.pb(num);
        }
        if(n == 1)break;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4124
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(V) (V).begin(), (V).end() 
#define x first
#define y second

using namespace std;

typedef long long ll;
template <typename T> using V = vector <T>;

int main() {fio;
	int n, k;
	cin >> n >> k;
	V <int> H(n), dp(n, 1e9 + 2);
	for(int &u : H) {
		cin >> u;
	}
	dp[0] = 0;
	for(int i = 1; i < n; i++) {
		for(int j = 1; j <= k; j++) {
			if(i - j >= 0) {
				dp[i] = min(dp[i], dp[i - j] + abs(H[i] - H[i - j]));
			}
		}
	}
	cout << dp[n - 1];
	
    return 0;
}

Measured memory_bytes: 1024
import math

N = int(input())
A = []
B = []
num_list = []

root = math.floor(math.sqrt(N))


def solv(N):
    for i in range(1,root+1):
        if N%i == 0:
            A.append(i)
            B.append(N//i)
    for a,b in zip(A,B):
        a_str = str(a)
        b_str = str(b)
        a_num = len(a_str)
        b_num = len(b_str)
        if a_num > b_num:
            num_list.append(a_num)
        elif a_num < b_num:
            num_list.append(b_num)
        else:
            num_list.append(a_num)
    return print(min(num_list))

solv(N)


Measured memory_bytes: 9084
//============================================================================
// Name        : sample1.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<cstdio>
using namespace std;

int main() {
	int a,b;
	cin >> a >> b;
	int d,r;
	double f = (double)a / (double)b;
	printf("%d %d %f\n",d = a /b,r = a% b,f);
	return 0;
}

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

int main(){
    int N,M; cin >> N >> M;
    vector<vector<int>> s(M);
    for(int i = 0; i < M; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int a;cin >> a; a--;
            s[i].push_back(a);
        }
    }
    vector<int> p(M);
    for(int i = 0; i < M; i++) cin >> p[i];
    
    long long res = 0;
    for(int bit = 0; bit < (1<<N); bit++){
        bool flag = true;
        for(int i = 0; i < M ; i++){
            int cont = 0;
            for(auto v:s[i]){
                if(bit & (1<<v))cont++;
            }
            if(cont % 2 != p[i])flag = false;
        }
        if(flag)res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3560
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

s=S()
t=S()
ans=0
for i in range(len(s)):
    if s[i]!=t[i]:
        ans+=1
print(ans)

Measured memory_bytes: 9424
#include <iostream>

using namespace std;

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

    int z = 0;
    for (int i = 0; i < b - a - 1; i++)
    {
        z += i + 1;
    }
    cout << z - a << endl;

    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<typename T>
bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
double height[50];

int main() {
    while(true) {
        int n;
        int _r;
        double r;
        cin >> _r >> n;
        if(_r == 0) break;
        r = _r;
        for(int i = 0; i < 50; i++) height[i] = 0.0;
        while(n--) {
            int l, r;
            double h;
            cin >> l >> r >> h;
            l += 20;
            r += 20;
            for(int i = l; i < r; i++) chmax(height[i], h);
        }
        double ng = 1e2;
        double ok = 0;
        for(int _ = 0; _ <= 300; _++) {
            double mid = (ok + ng) / 2.0;
            bool clear = true;
            for(int i = 1; i < 50; i++) {
                //double sun = pow(max((r * r - (20 - i) * (20 - i)), 0.0), 0.5);
                if(abs(20-i) > r - EPS) continue;
                double sun = max(0.0, mid - r + pow(r * r - (20-i)*(20-i), 0.5));
                //cerr << mid << " " << i << " " << sun << " " << height[i-1] << " " << height[i] << endl;
                if(sun - EPS > min(height[i], height[i-1])) clear = false;
            }
            if(clear) ok = mid;
            else ng = mid;
        }
        printf("%lf\n", ok);
    }
    return 0;
}


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

const int MAX = 410;
int done[MAX][MAX];
string s[MAX];

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int h,w;
long long nb, nw;

void dfs(int i, int j){
    // cout << "-> [" << i << "," << j << "]"; 
    s[i][j] == '#'? nb++: nw++;
    done[i][j] = 1;
    for(int d=0; d<4; d++){
        int l = i+dx[d];
        int m = j+dy[d];
        if(l<0 || l>=h || m<0 || m>=w) continue;
        if(s[i][j] == s[l][m]) continue;
        if(done[l][m] > 0) continue;
        dfs(l, m);
    }
}

void bfs(int i, int j){
    queue<pair<int, int>> q;
    q.push({i, j});
    done[i][j] = 1;
    while(!q.empty()){
        auto a = q.front();
        q.pop();
        auto &x = a.first;
        auto &y = a.second;
        // cout << "-> [" << x << "," << y << "]"; 
        s[x][y] == '#'? nb++: nw++;
        for(int i=0; i<4; i++){
            int l = x + dx[i];
            int m = y + dy[i];
            if(l<0 || l>=h || m<0 || m>=w) continue;
            if(done[l][m] > 0) continue;
            if(s[x][y] == s[l][m]) continue;
            q.push({l,m});
            done[l][m] = 1;
        }
        
    }
}


int main()
{
    cin >> h >> w;
    for(int i=0; i<h; i++){
        cin >> s[i];
    }
    
    long long ans = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            nb = 0;
            nw = 0;
            //dfs(i, j);
            bfs(i, j);
            ans += nb*nw;
            // cout<< endl;
            // cout << i << ", "<< j << ": "<< nb << ", " << nw << endl;
        }
    }
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 1152
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#define rep(i,n) for (ll i = 0; i < n; i++)
#define REP(i,n) for(ll i=1;i<=n;i++)

using namespace std;
typedef long long ll;

int main()
{
    // Input
    ll x;
    cin >> x;

    for (ll a = -200; a <= 200; a++) {
        for (ll b = -200; b <= 200; b++) {
            if(pow(a, 5) - pow(b, 5) == x){
                cout << a << " " << b;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string s;
bool check(int i)
{
	int cnt0 = 0;
	for(int j = s.length() - i;j< i;++j)
	{
		if(s[j]!=s[s.length()-i])
			return false;
	}
	return true;
}
int bs()
{
	int l = (s.length()+1)/2, r = s.length();
	l = max(l,1);
	while((r - l) > 1)
	{
		int mid = (l + r) >> 1;
		if(check(mid))
			l = mid;
		else
			r = mid;
	}
	if(check(r))
		return r;
	return l;
}
int main()
{
	cin >> s;
	cout << bs() << endl;
}

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

int main() {
	long long int t, a, k;
	
	cin >> t >> a >> k;
	
	if(k >= t) {
		k -= t;
		t = 0;
	} else {
		t = t - k;
		k = 0;
	}
	
	if(k > 0) {
		if(k >= a) {
			a = 0;
		} else {
			a = abs(k - a);
		}
	}
	cout << t << " " << a << endl;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $cnt, $goal);
$problems = [];
$bonuses = [];
for ($i=0; $i < $cnt; $i++) { 
    fscanf(STDIN, '%d %d', $problems[], $bonuses[]);
}
$ans = PHP_INT_MAX;
for ($mask=0; $mask < (1 << $cnt); $mask++) { 
    $score = 0;
    $num = 0;
    $rest_max = -1;
    for ($i=0; $i < $cnt; $i++) { 
        if ($mask >> $i & 1) {
            $score += 100 * ($i+1) * $problems[$i] + $bonuses[$i];
            $num += $problems[$i];
        } else {
            $rest_max = $i;
        }
    }
    if ($score < $goal) {
        $tmp = 100 * ($rest_max + 1);
        $need = floor(($goal - $score + $tmp - 1) / $tmp);
        if ($need >= $problems[$rest_max]) {
            continue;
        }
        $num += $need;
    }
    $ans = min($ans, $num);
}
echo $ans;

Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
vector <int> a;

bool check(int x){
    map <int, int> cnt;
    for(int i = 1 ; i < n ; i++){
        if(a[i] > a[i - 1]) continue;
        while(cnt.size() && a[i] < cnt.rbegin()->first){
            cnt.erase(--cnt.end());
        }
        int cur = a[i];
        while(cur > 0 && cnt[cur] == x) cur--;
        if(cur == 0) return 0;
        cnt[cur]++;
        while(cnt.size() && cur < cnt.rbegin()->first){
            cnt.erase(--cnt.end());
        }
    }
    return 1;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    for(auto &i : a) cin >> i;
    bool ok = 1;
    for(int i = 1 ; i < n ; i++){
        ok &= (a[i] > a[i - 1]);
    }
    if(ok) finish(1);
    int l = 1, r = n;
    while(l <= r){
        int mid = (l + r) / 2;
        if(check(mid)) r = mid - 1;
        else l = mid + 1;
    }
    cout << l + 1 << endl;
}


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

#define endl "\n"
#define PB push_back
#define F first 
#define S second
#define int long long 
#define Runner_up ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
vector <int> g[100005];
signed main()
{	
	Runner_up 
	int t=1; //cin>>t;
	while(t--){
		int n, m; cin>>n>>m;
		int h[n];
		for(int i=0; i<n; i++){
			cin>>h[i];
		}
		for(int i=0; i<m; i++){
			int a,b; cin>>a>>b; a--; b--;
			g[a].PB(b);
			g[b].PB(a);
		}
		int ans=0;
		for(int i=0; i<n; i++){
			int flag=0;
			for(auto it : g[i]){
				if(h[it] >= h[i]){
					flag=1; break;
				}
			}
		//	cout<<flag<<" "<<g[i].size()<<endl;
			if(!flag || !g[i].size()) ans++;
		}
		cout<<ans;
	}
	return 0;	
}

Measured memory_bytes: 10276
#include <stdio.h>
int gcd(int, int);
void swap(int *, int *);
int main()
{
    int x, y, result;
    scanf("%d%d", &x, &y);
    result = gcd(x, y);
    printf("%d\n", result);
}
int gcd(int x, int y)
{
    int r;
    if (x < y)
        swap(&x, &y);
    while (y > 0)
    {
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}
void swap(int *x, int *y)
{
    int z;
    z = *x;
    *x = *y;
    *y = z;
}


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

class UnionFind {
  int N;
  vector<int> PS;
public:
  UnionFind() : N(0) {}
  UnionFind(int n) : N(n), PS(n, -1) {}
  int merge(int a, int b) {
    assert(0 <= a && a < N);
    assert(0 <= b && b < N);
    int x = leader(a), y = leader(b);
    if (x == y) return x;
    if (-PS.at(x) < -PS.at(y)) swap(x, y);
    PS.at(x) += PS.at(y);
    PS.at(y) = x;
    return x;
  }
  bool same(int a, int b) {
    assert(0 <= a && a < N);
    assert(0 <= b && b < N);
    return leader(a) == leader(b);
  }
  int leader(int a) {
    assert(0 <= a && a < N);
    if (PS.at(a) < 0) return a;
    return PS.at(a) = leader(PS.at(a));
  }
  int size(int a) {
    assert(0 <= a && a < N);
    return -PS.at(leader(a));
  }
  vector<vector<int>> groups() {
    vector<int> B(N), S(N);
    for (int i = 0; i < N; i++) {
      B.at(i) = leader(i);
      S.at(B.at(i))++;
    }
    vector<vector<int>> ret(N);
    for (int i = 0; i < N; i++) {
      ret.at(i).reserve(S.at(i));
    }
    for (int i = 0; i < N; i++) {
      ret.at(B.at(i)).push_back(i);
    }
    ret.erase(
      remove_if(ret.begin(), ret.end(), [&](const vector<int>& v) { return v.empty(); }),
      ret.end()
    );
    return ret;
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  UnionFind UF(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b, a--, b--;
    UF.merge(a, b);
  }
  long mx = LONG_MIN;
  auto cmax = [&](auto& a, auto b) { if (a < b) a = b; };
  for (int i = 0; i < N; i++) cmax(mx, UF.size(i));
  cout << mx << "\n";
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  ll N,K;cin>>N>>K;
  ll bunsi=(kaijo(K-1)%MOD)*(kaijo(N-K+1)%MOD)%MOD;
  f(i,1,min(N-K+1,K)+1){
    ll bunbo = ((modpow(kaijo(i-1), MOD-2, MOD)*modpow(kaijo(K-i), MOD-2, MOD)%MOD)*modpow(kaijo(N-K+1-i), MOD-2, MOD)%MOD)*modpow(kaijo(i), MOD-2, MOD)%MOD;
    cout<< bunsi*bunbo%MOD<<endl;
  }
  if(2*K>N+1){
   f(i,N-K+2,K+1){
     cout<<0<<endl;
   }
  }
}





Measured memory_bytes: 256
from math import gcd
def main():
    k = int(input())
    t = [0]*201
    for i in range(1, k+1):
        for j in range(1, k+1):
            t[gcd(i, j)] += 1
    ans = 0
    for i in range(1, 201):
        if t[i] > 0:
            for j in range(1, k+1):
                x = gcd(i, j)
#                print(x)
                ans += x*t[i]
    print(ans)

if __name__ == "__main__":
    main()

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif

	int r, c;
	cin >> r >> c;
	vector<vector<int>> v(r + 1, vector<int>(c + 1));
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> v[i][j];
			v[i][c] += v[i][j];
			v[r][j] += v[i][j];
			v[r][c] += v[i][j];
		}
	}

	for (int i = 0; i < r + 1; i++) {
		for (int j = 0; j < c; j++) {
			cout << v[i][j] << " ";
		}
		cout << v[i][c] << endl;
	}
}




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


	solve();
#ifdef _WIN32
	system("PAUSE");
#endif
	return 0;
}

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

using namespace std;

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

    int a, b; cin >> a >> b;

    if (a * 500 >= b)
        cout << "Yes";
    else
        cout << "No\n";
}

Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<random>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll h,n,a[100005]={},cnt=0;
  cin >> h >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    cnt+=a[i];
  }
  if(cnt>=h) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
 }

Measured memory_bytes: 1024