akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

template<typename T>
using V = vector<T>;

int main() {
	for (int N; (N = in());) {
		int W = in(), H = in();
		V<V<int>> v = V<V<int>>(H + 1, V<int>(W + 1)), w = v;
		while (N--) {
			int x = in(), y = in();
			v[y][x] = 1;
		}
		for (int i = 1; i <= H; i++)
			for (int j = 1; j <= W; j++) {
				v[i][j] = v[i - 1][j] + v[i][j];
				w[i][j] = v[i][j] + w[i][j - 1];
			}
		int S = in(), T = in(), m = 0;
		for (int i = T; i <= H; i++)
			for (int j = S; j <= W; j++)
				m = max(m, w[i][j] - w[i - T][j] - w[i][j - S] + w[i - T][j - S]);
		outl(m);
	}
}


Measured memory_bytes: 2520
N = int(input())
A = list(map(int, input().split()))
result = 0

while True:
    if A[0] % 2 == 1:
        break
    
    A[0] //= 2
    result += 1

for i in range(1, N):
    if result == 0:
        break
    
    counter = 0
    
    for j in range(result):
        if A[i] % 2 == 1:
            break
        
        A[i] //= 2
        counter += 1

    result = min(result, counter)

print(result)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
#define ll long long
int main()
{
	int n; 
	cin>>n;
	ll a[n];
	int best=-1;
	int cur=0;
	for(int i=0;i<n;i++)
	{ 
	cin>>a[i];
	}
	for(int i=1;i<n;i++){
		if(a[i]<=a[i-1])
		{
			cur++;
		}
		else
		{
			best=max(best,cur);
			cur=0;
		}
	}
	best=max(best,cur);
	cout<<best;
}
			

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	int x,y;
	while(1){
		scanf("%d%d",&x,&y);
		if(x==0 && y==0)break;
		if(x<y){
			printf("%d %d\n",x,y);
		}
		else{
			printf("%d %d\n",y,x);
		}
	}
	return 0;
}

Measured memory_bytes: 2688
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n,A,B;
int ar[100005];
int main(){
  cin>>n>>A>>B;
  REP(i,n) cin>>ar[i];

  lint res=0;
  REP(i,n-1){
    lint walk=(ar[i+1]-ar[i])*(lint)A;
    res+=min(walk,(lint)B);
  }
  cout<<res<<endl;
  return 0;
}





Measured memory_bytes: 640
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;
#define int long long

typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;

const int arr=2e6+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;

///---program start---///

bool use[ar][ar];
int dist[ar][ar];

main()
{
    #ifdef Barik
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif

    fast;

    int n,m;
    cin>>n>>m;
    string a[n];
    for (int i=0;i<n;i++){
        cin>>a[i];
    }
    queue<pii> q;
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            if (a[i][j]=='#'){
                use[i][j]=1;
                q.push(mp(i,j));
                dist[i][j]=0;
            }
        }
    }
    auto ok=[&](int i,int j)
    {
        return i>=0&&i<n&&j>=0&&j<m
        &&a[i][j]=='.'
        &&!use[i][j];
    };
    while (!q.empty()){
        pii now=q.front();
        q.pop();
        if (ok(now.fir-1,now.sec)){
            use[now.fir-1][now.sec]=1;
            dist[now.fir-1][now.sec]=dist[now.fir][now.sec]+1;
            q.push(mp(now.fir-1,now.sec));
        }
        if (ok(now.fir+1,now.sec)){
            use[now.fir+1][now.sec]=1;
            dist[now.fir+1][now.sec]=dist[now.fir][now.sec]+1;
            q.push(mp(now.fir+1,now.sec));
        }

        if (ok(now.fir,now.sec-1)){
            use[now.fir][now.sec-1]=1;
            dist[now.fir][now.sec-1]=dist[now.fir][now.sec]+1;
            q.push(mp(now.fir,now.sec-1));
        }
        if (ok(now.fir,now.sec+1)){
            use[now.fir][now.sec+1]=1;
            dist[now.fir][now.sec+1]=dist[now.fir][now.sec]+1;
            q.push(mp(now.fir,now.sec+1));
        }
    }
    int ans=0;
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            ans=max(ans,dist[i][j]);
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 37684
#include<iostream>
std::string s;
int k,i;
main(){
  for(std::cin>>s>>k;s[i]-'\0';++i)s[i]-'a'&&k>'z'-s[i]?k-='z'-s[i]+1,s[i]='a':0;
  s[i-1]=(s[i-1]-'a'+k)%26+'a';
  std::cout<<s<<'\n';
}


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

int main(){
  string s;
  cin >>s;
  int ans = 0;
  if(s[0]=='1') ans++;
  if(s[1]=='1') ans++;
  if(s[2]=='1') ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    char mass[55][55];
    int h, w;
    scanf("%d""%d", &h, &w);
    for(int i = 0; i < h; i++){
        scanf("%s", mass[i]);
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(mass[i][j] == '#'){
                if(mass[i - 1][j] != '#' && mass[i + 1][j] != '#' && mass[i][j - 1] != '#' && mass[i][j + 1] != '#'){
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int W,H;
bool inrange(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define MP make_pair
string alpha="abcdefghijklmnopqrstuvwxyz";
signed main(){
    string s; cin>>s;
    map<char,int>mp;
    rep(i,s.size())mp[s[i]]++;
    string ans;
    if(s.size()!=26){
        rep(i,alpha.size()){
            if(mp[alpha[i]])continue;
            else{
                cout<<s<<alpha[i]<<endl;
                return 0;
            }
        }
    }else{
        string temp;
        int index=0;
        char key;
        for(int i=s.size()-1;i>=0;i--){
            if(i==s.size()-1){
                temp.push_back(s[i]);
                continue;
            }else{
                if(s[i]>temp.back()){
                    temp.push_back(s[i]);
                }else{
                    key=s[i];
                    index=i;
                    break;
                }
            }
        }
        char candi='|';
        rep(i,temp.size()){
            if(key<temp[i]&&candi>temp[i])
                candi=temp[i];
        }
        if(temp.size()==26)return cout<<-1<<endl,0;
        rep(i,index)cout<<s[i];
        cout<<candi<<endl;
    }
}


Measured memory_bytes: 256
n = gets.to_i
nums = gets.split

bub_nums = nums.clone
bub_count = 0
for c in 0..(n-2) do #01234
  for d in 0..n-c-2 do #0=>0123 1=>012 3=>0
    if bub_nums[d][1].to_i > bub_nums[d+1][1].to_i
      bub_nums[d], bub_nums[d+1] = bub_nums[d+1], bub_nums[d]
      bub_count += 1
    end
  end
end
puts bub_nums.join(" ")
puts "Stable"

sel_nums = nums
sel_count = 0
for i in 0..n-2
  minid = i
  for k in i..n-1 do
    if sel_nums[minid][1].to_i > sel_nums[k][1].to_i
      minid = k
    end
  end
  #print i != minid
  if i != minid
    sel_nums[minid], sel_nums[i] = sel_nums[i], sel_nums[minid]
    sel_count += 1
  end
  #puts nums.join(" ")
end
puts sel_nums.join(" ")

if sel_nums == bub_nums
  puts "Stable"
else
  puts "Not stable"
end


Measured memory_bytes: 6876
import sys

def solve():
    A, B, C, D = [int(i) for i in input().split()]
    ans = sys.maxsize * -1
    X = [0, A, B] if A <= 0 <= B else [A, B]
    Y = [0, C, D] if A <= 0 <= B else [C, D]
    for x in X:
        for y in Y:
            ans = max(ans, x * y)
    print(ans)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 61724
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main(void)
{
  unsigned short *A, *B;
  
  int C[VMAX+1];
  int n, i, j;
  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=0;i<=VMAX;i++) C[i] = 0;
  
  for(i=0;i<n;i++) {
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  
  for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];
  
  for(j=1;j<=n;j++) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i=1;i<=n;i++) {
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 9572
#include <bits/stdc++.h>
typedef long long ll;
#define fr first
#define sc second
#define int ll

using namespace std;
const int MN = 1e2+7;
const int MK = 1e5+7;
const int MOD = 1e9+7;

int a[MN], cnt[5];
int ps[MN][MK], dp[MN][MK];

signed main(){
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)cin >> a[i];
    for(int i = 0; i < n; i++){
        //cout << i << " : \n";
        for(int j = 0; j <= k; j++){
            if(i == 0){
                dp[i][j] = (a[0] >= j);
                continue;
            }
            if(j <= a[i]){
                dp[i][j] = ps[i-1][j] % MOD;
                continue;
            }
            dp[i][j] = MOD + ps[i-1][j] - ps[i-1][j-a[i]-1];
            //cout << dp[i][j] << ' ';
            dp[i][j] %= MOD;
        }
        //cout << endl;
        ll w = 0;
        for(int j = 0; j <= k; j++){
            w += dp[i][j];
            w %= MOD;
            ps[i][j] = w;
            //cout << ps[i][j] << ' ';
        }
        //cout << "\n------------\n";
    }
    cout << dp[n-1][k] % MOD;
}


Measured memory_bytes: 160000
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'

int main() {
    string s;
    cin >> s;
    int tamanio;
    bool si=false;
    tamanio=s.size();
    for(int i=0;i<tamanio;i++){
        if(s[i]=='7') si=true;
    }
    if(si) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

#define LB(v, x) (lower_bound(ALL(v), x) - v.begin())
#define UB(v, x) (upper_bound(ALL(v), x) - v.begin())

int main() {
	IN(int, n, m, k);
	vector<LL> a(n), b(m), sa(n + 1), sb(m + 1);
	cin >> a >> b;
	inc(i, n) { sa[i + 1] = sa[i] + a[i]; }
	inc(i, m) { sb[i + 1] = sb[i] + b[i]; }
	
	int ans = 0;
	incII(i, 0, n) {
		if(sa[i] > k) { break; }
		setmax(ans, i + UB(sb, k - sa[i]) - 1);
	}
	OUT(ans);
}


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

#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    string s;cin >> s;
    bool can = true;
    rep(i,3) if(s[i]==s[i+1]) can = false;
    cout << (can? "Good" : "Bad") << '\n';
}


Measured memory_bytes: 256
w,h,n=map(int,input().split())
xmin=0
xmax=w
ymin=0
ymax=h
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        xmin=max(x,xmin)
    elif a==2:
        xmax=min(x,xmax)
    elif a==3:
        ymin=max(y,ymin)
    else:
        ymax=min(y,ymax)
print(max(0,xmax-xmin)*max(0,ymax-ymin))



Measured memory_bytes: 9184
import sys
from collections import *
import heapq
import math
from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
s=input()
dic=defaultdict(list)
for i in range(n):
    if not s[i] in dic:
        dic[s[i]]=[i]
    else:
        dic[s[i]].append(i)
# print(dic)
se=set(dic["B"])
# print(se)
ans=len(dic["R"])*len(dic["G"])*len(dic["B"])
for i in range(len(dic["R"])):
    for j in range(len(dic["G"])):
        l,r=min(dic["R"][i],dic["G"][j]),max(dic["R"][i],dic["G"][j])
        if r+(r-l) in se:
            ans-=1
        if l-(r-l) in se:
            ans-=1
        if (r-l)%2==0 and l+(r-l)//2 in se:
            ans-=1
print(ans)


Measured memory_bytes: 69880
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

typedef long long ll;

ll n, m, k;

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

	vector<ll> prefx(n + 2), x(k + 1);
	vector<ll> prefy(m + 2), y(k + 1);

	for (ll i = 1; i <= k; i ++) {
		cin >> x[i] >> y[i];

		prefx[x[i]]++; prefx[x[i] + 1]--;
		prefy[y[i]]++; prefy[y[i] + 1]--;
	}

	for (ll i = 1; i <= n; i ++) {
		prefx[i] += prefx[i - 1];
	}

	for (ll i = 1; i <= m; i++) {
		prefy[i] += prefy[i - 1];
	}

	ll maxx = -1;
	for (ll i = 1; i <= n; i ++) {
		maxx = max(maxx, prefx[i]);
	}

	ll maxy = -1;
	for (ll i = 1; i <= m; i ++) {
		maxy = max(maxy, prefy[i]);
	}

	ll cntx = 0;
	for (ll i = 1; i <= n; i++) {
		if (prefx[i] == maxx) {
			cntx++;
		}
	}

	ll cnty = 0;
	for (ll i = 1; i <= m; i ++) {
		if (prefy[i] == maxy) {
			cnty++;
		}
	}

	ll count = 0;
	for (ll i = 1; i <= k; i ++) {
		if (prefx[x[i]] + prefy[y[i]] == maxx + maxy) {
			count++;
		}
	}

	if (count == cntx * cnty) {
		cout << maxx + maxy - 1 << endl;
	}
	else {
		cout << maxx + maxy << endl;
	}

	return 0;
}

Measured memory_bytes: 12752
#!/usr/bin/env python3
import sys


def solve(P: int, Q: int, R: int):
    a = P + Q
    b = Q + R
    c = R + P
    print(min([a, b, c]))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    P = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(P, Q, R)

if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

void solve() {
  int x, a, b;
  string ans = "";
  cin >> x >> a >> b;
  if (b <= a) {
    ans = "delicious";
  } else if (b <= a + x) {
    ans = "safe";
  } else if (b > a + x) {
    ans = "dangerous";
  }

  cout << ans << endl;
}

signed main() {
  solve();

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int n;
string s;
Int a, b;
vector<int> edge[2000];
int cnt[2000];
int dep[2000];
Int dist;
P solve(int x, int last = -1){
    if(last == -1)dep[x] = 0;
    P res = {0, 0};
    cnt[x] = s[x] == '1';
    dist += dep[x] * (s[x] == '1');
    for(auto to:edge[x]){
        if(to == last)continue;
        dep[to] = dep[x] + 1;
        P tmp= solve(to, x);
        cnt[x] += cnt[to];
        tmp.first += cnt[to];
        tmp.second += cnt[to];
        if(tmp.first < res.second){
            res.second = res.second - tmp.first;
        }
        else if(tmp.second > res.first){
            res.second = tmp.second - res.first;
        }
        else res.second = 0;
        res.first += tmp.first;
    }
    return res;
}


int main(){
    cin >> n;
    cin >> s;
    for(int i = 0;i < n-1;i++){
        cin >> a >> b;
        a--;b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    Int ans = LINF;
    for(int i = 0;i < n;i++){
        dist = 0;
        if(solve(i).second != 0)continue;
        if(dist % 2 == 1)continue;
        ans = min(ans, dist / 2);
    }

    if(ans == LINF)ans = -1;
    cout << ans << endl;    
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test int t;cin>>t;while(t--)
int mini(int a,int b)
{
    if(a>b)return b;
    return a;
}
signed main(){
    fast
    int n,k;
    cin>>n>>k;
    int a[n+1],b[n+1];
    f0(i,0,n)cin>>a[i+1];
    f0(i,0,n)cin>>b[i+1];int max=-10000000000000;
    f0(i,1,n+1)
    {
        vector<int>v;int c=0,d=0;int g=i;int r=0;
        while(c!=i&&r!=k)
        {
             c=a[g];
             d+=b[c];r++;
            v.pb(b[c]);
            if(d>max)max=d;
            g=a[g];
           
            
        }if(r==k)continue;
        if(d<=0)
        {
           continue;
        }
        else{
            int u=0;
             u=(k)/(v.size());
            d*=u-1;
            f0(l,0,v.size())
            { d+=v[l];
                if(d>max)max=d;
                
            }
            f0(l,0,((k)%v.size()))
            {
                
                d+=v[l];
                if(d>max)max=d;
            }
            
        }}cout<<max<<endl;
        
    
}

Measured memory_bytes: 3792
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        x: i64,
        l: [i64; n],
    }

    let mut ans = 1;
    let mut cur = 0;

    for &a in l.iter() {
        cur += a;
        if cur <= x {
            ans += 1;
        }
    }

    println!("{}", ans);
}


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

int main(){
	int N, i=0, ans;
	cin >> N;
	
	if(N%111==0)	ans = N;
	
	else if(N<111)	ans = 111;
	else if(N>111){
		do{
			i++;
		}while(N-111*i >= 111);
		ans = 111*(i+1);
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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


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

    string S, T, U;
    cin >> S >> T;

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

    if (U == S) --a;
    if (U == T) --b;

    cout << a << " " << b << endl;

}


Measured memory_bytes: 256
n = int(input())
AC, WA, TLE, RE = 0, 0, 0, 0
for i in range(n):
    word = input()
    if word == 'AC':
        AC += 1
    if word == 'WA':
        WA += 1
    if word == 'TLE':
        TLE += 1
    if word == 'RE':
        RE += 1
print('AC x {}'.format(AC))
print('WA x {}'.format(WA))
print('TLE x {}'.format(TLE))
print('RE x {}'.format(RE))

Measured memory_bytes: 9196
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
	int n;
	scanf("%d", &n);
	
	int *array = malloc(sizeof(int)*n);
	
	int i;
	for(i=0;i<n;i++) {
		scanf("%d", array+i);
	}
	
	int max = -1.0e9;
	int min = *array;
	
	for(i=1;i<n;i++) {
		if(*(array+i)-min > max) {
			max = *(array+i)-min;
		}
		if(*(array+i) < min) {
			min = *(array+i);
		}
	}
	
	printf("%d\n", max);
	
	free(array);
	
	return 0;
}
	
	



Measured memory_bytes: 2320
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n, k;
  cin >> n >> k;
  
  
  ll ans = 0;
  for (ll j = k; j <= n + 1; j++){
    ans = (ans + (j*(2*n-j+1) - j*(j-1))/2 + 1) % MOD;
  }
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static CompareInfo ci = new System.Globalization.CultureInfo("ja-JP").CompareInfo;
        private static int Compare(string a, string b) { return ci.Compare(a, b, System.Globalization.CompareOptions.Ordinal); }

        static long Solve(long N, long A, long B)
        {
            return N / (A + B) * A + Math.Min(N % (A + B), A);
        }

        static void Main(string[] args)
        {
            var V = ReadLongs();
            Console.WriteLine(Solve(V[0], V[1], V[2]));
        }
    }
}


Measured memory_bytes: 13140
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	H := oneInt()
	fmt.Print(attack(H))
}

func attack(hp int) int {
	if hp == 1 {
		return 1
	}

	return 1 + 2*attack(hp/2)
}

func searchAbove(slice []int, target int, index int) int {
	for i := index + 1; i < len(slice); i++ {
		v := slice[i]
		if v >= target {
			return i
		}
	}
	return -1
}

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


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

int	main() {
	int N,M;
  	cin >> N >> M;
  	vector<int> road(N+1);
  
  	for (int i=0; i < M;i++) {
      int a, b;
      cin >> a >> b;
      	road.at(a)++;
      	road.at(b)++;
    }
  
  	for (int i=1; i<N+1; i++) {
    	cout << road.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

int n, m, temp, k;
int a[10];
int b[10]={-1, 2,5,5,4,5,6,3,7,6};
string dp[10010];

string larger(string x, string y){
  if(x.size()<y.size()) return y;
  else if(x.size()>y.size()) return x;
  else if(x<y) return y;
  else return x;
}

int main(){
  REP(i, 10) a[i]=-1;
  cin>>n>>m;

  REP(i, n+1) dp[i]="";
  dp[1]="x";
  REP(i, m){
    cin>>temp;
    a[temp]=b[temp];
  }
  string temp;
  FOR(i, 1, n+1){
    FOR(j, 1, 10){
      if(a[j]==-1 || i-a[j]<0)continue;
      if(dp[i-a[j]] == "x") continue;
      temp = dp[i-a[j]] + to_string(j);
      dp[i]= larger(dp[i], temp);
    }
    if(dp[i]=="") dp[i]="x";
    //cout<<i<<" "<<dp[i]<<endl;
  }

  cout<<dp[n]<<endl;
  return 0;
}


Measured memory_bytes: 32384
n,m=map(int,input().split())
# Union-Find
a=list(range(n))
def find(x):
  g = x
  while g != a[g]: g = a[g]
  a[x] = g
  return g

for _ in range(m):
  x,y=map(int,input().split())
  x,y=find(x-1),find(y-1)
  if x == y: continue
  a[y]=x

count=[0]*n
for i in range(n):
  count[find(i)] += 1
print(max(count))


Measured memory_bytes: 18476
#include <algorithm>
#include <cstdio>
struct data
{
	int l, r, len; 
	inline void input()
	{
		scanf("%d%d", &l, &r);
		len = r - l + 1; 
	}
	inline bool operator <(const data &a) const
	{
		return len < a.len; 
	}
} arr[300005]; 
int sum[100005], n, m; 
inline void modify(int pos, int x)
{
	for (; pos <= m; pos += pos & -pos)
		sum[pos] += x; 
}
inline int query(int pos)
{
	int res = 0; 
	for (; pos; pos -= pos & -pos)
		res += sum[pos]; 
	return res; 
}
int main()
{
	// freopen("ARC068-E.in", "r", stdin); 
	scanf("%d%d", &n, &m); 
	for (int i = 0; i < n; i++)
		arr[i].input(); 
	std::sort(arr, arr + n); 
	for (int i = 1, idx = 0; i <= m; i++)
	{
		while (idx < n && arr[idx].len <= i)
		{
			modify(arr[idx].l, 1); 
			modify(arr[idx++].r + 1, -1); 
		}
		int ans = n - idx; 
		for (int j = i; j <= m; j += i)
			ans += query(j); 
		printf("%d\n", ans);
	}
	return 0; 
}


Measured memory_bytes: 4736
#include <iostream>
using namespace std;
int main(){
	int a[3],b,n,j,i,k;
	for(n=0;n<3;n++){
		cin>>a[n];
	}
		for(n=0;n<2;n++){
			for(j=n+1;j<3;j++){
				if(a[n]>a[j]){
					i=a[n];
					a[n]=a[j];
					a[j]=i;
				}
			}
		}
		for(k=0;k<2;k++){
			cout<<a[k]<<" ";
		}
		cout<<a[2]<<endl;
	return 0;
}

Measured memory_bytes: 1160
import java.lang.Math.abs

//package atcoder// TODO: ←消す

fun main(args: Array<String>) = ABC161C.main()

object ABC161C {
    fun log(message: Any?) {
        println(message)// TODO: ←消す
    }

    fun main() {
        val (N, K) = readLongs()

        var x = N
        while (true) {
            val next = next(x, K)
            if (x > next) x = next
            else break
        }
        println(x)
    }

    fun next(x: Long, K: Long): Long {
        return if (K <= x) {
            val minus = K * (x / K)
            if (minus != 0L) abs(minus - x) else abs(K - x)
        } else {
            abs(K - x)
        }
    }


    /*####################################################################################*/

    fun readLong() = readLine()!!.toLong()
    fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
}

Measured memory_bytes: 37900
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int needl = 0;
    int count = 0;
    for(int i = 0;i < S.size();i++) {
        if(S.at(i) == '(') {
            count++;
        }
        else {
            if(count == 0) {
                needl++;
            }
            else {
                count--;
            }
        }
    }
    for(int i = 0;i < needl;i++) {
        cout << '(';
    }
    cout << S;
    for(int i = 0;i < count;i++) {
        cout << ')';
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
   int n, x, i, min, max;
   long sum;

   scanf("%d", &n);

   scanf("%d", &x);
      min = max = sum = x;

   for (i=1; i<n; i++){
      scanf("%d", &x);

      if (x<min)
         min = x;

      if (x>max)
         max = x;

      sum = sum + x;
   }

   printf("%d %d %ld\n", min, max, sum);

   return 0;
}

Measured memory_bytes: 1820
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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;}

typedef long long lint;

using namespace std;
lint gcd(lint a,lint b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint a,b,c,d,ans=0;
	cin>>a>>b>>c>>d;
	ans+=(b-a+1);
	ans-=(b/c-(a-1)/c);
	ans-=(b/d-(a-1)/d);
	lint dev = c*d/gcd(c,d);
	ans+=(b/dev-(a-1)/dev);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  cout << fixed << setprecision(20);
  int a,b,x;
  cin >> a >> b >> x;
  double A=a, B=b, X=x;
  double T;
  if (x*2<=a*a*b){
    T = (A*B*B)/(2*X);
  } else {
    T = (2*B/A)-(2*X/A/A/A);
  }
  cout << atan(T)/3.141592653589793*180;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string a, b;
    cin >> a;
    cin >> b;
    int n = a.size();
    for(int i=0; i<n-1; i++) {
        cout << a[i] << b[i];
    }
    cout << a[n-1];
    if(a.size()==b.size()) cout << b[n-1];
    cout << endl;
    return 0;
}


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

using namespace std;

map<int, int> m;
vector<int> v;

int main () {
    int n, ans = 0;
    cin >> n;
    for(int i = 1 ; i <= n ; i ++ ) {
        int x;
        cin >> x;
        if(!m[x]) v.push_back(x);
        m[x] ++ ;
    }
    int flag = v.size();
    for(int i = 0; i < flag ; i ++ )
        if(m[v[i]] >= v[i]) 
            ans += m[v[i]] - v[i];
        else
            ans+=m[v[i]];
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 5112
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC019A {
    class Program {
        static void Main(string[] args) {
            int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int Q = input[0];
            int H = input[1];
            int S = input[2];
            int D = input[3];
            long N = int.Parse(Console.ReadLine());
            long[] four = { Q * 8, H * 4, S * 2, D };
            long[] three = { Q * 4, H * 2, S };
            long ans = 0;
            long num = N / 2;
            ans += four.Min() * num;
            N -= num * 2;
            ans += three.Min() * N;
            Console.WriteLine(ans);
        }
    }
}


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

int main(){
  int n,l;
  cin >> n >> l;
  int t[9999];
  for(int i=1;i<=n;++i){
	  t[i] = l+i-1;
  }	  
  int sum = 0;
  for(int i=1;i<=n;++i){
	  sum += t[i];
  }
  int r = l+n-1;
  if(l>=0) cout << sum-t[1] << endl;
  else if(r<=0) cout << sum-t[n] << endl;
  else cout << sum << endl;
  return 0;
}

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

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

const int INF = 1000000007;

int main(void){
	int n, k; cin>>n>>k;
	int h[n] = {0};
	for(int i=0;i<n;i++) cin>>h[i];

	sort(h, h+n);
	
	int minv = INF;
	for(int i=0;i<n - k + 1;i++) {
		minv = min(minv, h[i + k - 1] - h[i]);
	}

	cout<< minv <<endl;

	/*int b[n] = {0};
	sort(h, h+n);
	for(int i=0;i<n-1;i++) b[i] = h[i + 1] - h[i];
	//sort(b, b+(n-1));

	//for(int i=0;i<n-1;i++) cout<<b[i]<<" ";
	//cout<<endl;
	
	int minv = INF;
	for(int i=0;i<(n-1) - (k-1) + 1;i++) {
		minv = min(minv, b[i + (k-1) - 1] + b[i]);
	}

	cout<< minv <<endl;
	*/
	
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

void max_heapify(int *heap, int i) {
	int heap_size, L, R, largest, tmp;

	heap_size = heap[0];
	L = 2*i;
	R = 2*i + 1;
	if (L <= heap_size && heap[L] > heap[i]) {
		largest = L;
	} else {
		largest = i;
	}
	if (R <= heap_size && heap[R] > heap[largest]) {
		largest = R;
	}
	if (largest != i) {
		tmp = heap[i];
		heap[i] = heap[largest];
		heap[largest] = tmp;
		max_heapify(heap, largest);
	}
}

int main(void) {
	int *heap, key, index, half, tmp;
	char cmd[20];

	heap = malloc(sizeof(int) * 2000001);
	heap[0] = 1;
	while (1) {
		scanf("%s %d ", cmd, &key);
		if (cmd[0] == 'i') {
			heap[0]++;
			index = heap[0];
			heap[index] = key;

			half = index / 2;
			while (index > 1 && heap[half] < heap[index]) {
				tmp = heap[index];
				heap[index] = heap[half];
				heap[half] = tmp;
				index /= 2;
				half = index / 2;
			}
		} else if (cmd[1] == 'x') {
			printf("%d\n", heap[1]);
			heap[1] = heap[heap[0]];
			heap[0]--;
			max_heapify(heap, 1);
		} else {
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 6380
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <unordered_map>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>
 
#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
 
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e10
 
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; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
using namespace std;

int main()
{
    ll n;
    cin >> n;
    vector<ll> va(n+1);
    vector<ll> vb(n);
    rep(i, n+1) cin >> va[i];
    rep(i, n) cin >> vb[i];

    ll ans = 0;
    rep(i, n){
        if(va[i] >= vb[i]){
            ans += vb[i];
            va[i] -= vb[i];
        }else{
            ans += va[i];
            ans += min(va[i+1], vb[i]-va[i]);
            ll vtmp = va[i+1] - (vb[i] - va[i]);
            if (vtmp < 0) va[i+1] = 0;
            else va[i+1] = vtmp;
        }
    }
    cout << ans << endl;


}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i ,m, n) for(int i = m; i >= n; i--)
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define ll long long
#define INF 999999999
#define IOS cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<ll,ll> LP;
typedef pair<ll,LP> LPP;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

int main() {
    
    int N; cin >> N;
    vector<int> T; vector<int> b; int count=0;
    vector<int> A(200020);
    for(int i=0;i<N;i++){
        int a; cin >> a;
        T.push_back(a);
    }
    
    for(int i=N-1;i>=0;i--){
        if(T[i]==A[i+1]%2);
        else{
            for(int j=1;j*j <= i+1;j++){
                if((i+1)%j==0){
                    A[j]++;
                    if(j*j != i+1)A[(i+1)/j]++;
                }
            }
            b.push_back(i+1); count++;
        }
    }
    reverse(b.begin(),b.end());
    cout << count << endl;
    for(int i=0;i<b.size();i++)
    cout << b[i] << " " << flush;
    if(b.size()!=0)cout << endl;

    return 0;
}


Measured memory_bytes: 3572
N,M = map(int,input().split())
a = []
b = []
for i in range(M):
    x,y = map(int,input().split())
    a.append(x)
    b.append(y)
if max(a) <= min(b):
    print(min(b)-max(a)+1)
else:
    print(0)


Measured memory_bytes: 10996
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string hoge; cin>>hoge;
    map<char,int>mp;
    rep(i,hoge.size())mp[hoge[i]]++;
    cout<<min(mp['K'],min(mp['U'],min(mp['P'],mp['C'])))<<endl;
}

Measured memory_bytes: 3172
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	ms := make(map[int]bool)
	mg := make(map[int]bool)
	var a, b int
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b)
		if a == 1 {
			ms[b] = true
		}
		if b == n {
			mg[a] = true
		}
	}

	for k := range mg {
		if ms[k] {
			fmt.Println("POSSIBLE")
			return
		}
	}
	fmt.Println("IMPOSSIBLE")
}


Measured memory_bytes: 8576
// https://atcoder.jp/contests/abc149/tasks/abc149_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

const int SZ = 1e5 + 10;

// constexprな素数列挙(エラトステネスの篩)
// https://259-momone.hatenablog.com/entry/2018/05/06/015026
template <int N> struct Prime {
    bool b[N + 1]; // trueなら素数
    constexpr Prime() : b() {
        fill_n(b, N + 1, true);
        b[0] = b[1] = false;
        for (int_fast64_t i = 2; i <= N; ++i) {
            if (b[i]) {
                for (int_fast64_t j = i * i; j <= N; j += i) {
                    b[j] = false;
                }
            }
        }
    }
};
Prime<SZ> prime;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X;
    cin >> X;
    while (true) {
        if (prime.b[X]) {
            cout << X << endl;
            break;
        }
        X++;
    }
    return 0;
}


Measured memory_bytes: 3712