akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

s=input()

print(s[:4]+' '+s[4:])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define ps(s)     for(auto i:s){cout<<i<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll n,k;
	cin>>n>>k;
	vector<pair<int,int>>v(n);
	for(int i=0;i<n;i++){
		cin>>v[i].ff>>v[i].ss;
	}
	sort(all(v));
	ll ans;ll s=0;
	for(int i=0;i<n;i++){
		s+=v[i].ss;
		if(s>=k){ans=v[i].ff;break;}
	}
	cout<<ans;
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case "<<k<<": ";
		solve();
		//e;
	}
}

Measured memory_bytes: 4736
#include <algorithm>
#include <cstdio>

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

using namespace std;

struct edge{ int u,v,w; };

const int INF=1<<30;

int main(){
	int n,m,p; scanf("%d%d%d",&n,&m,&p);
	edge E[5000];
	rep(i,m){
		scanf("%d%d%d",&E[i].u,&E[i].v,&E[i].w);
		E[i].u--; E[i].v--; E[i].w-=p;
	}

	int d[2500];
	rep(u,n) d[u]=(u==0?0:INF);
	bool neg[2500]={};
	rep(t,4*n) rep(i,m) {
		int u=E[i].u,v=E[i].v,w=-E[i].w;
		if(d[u]<INF && d[v]>d[u]+w){
			d[v]=d[u]+w;
			if(t>=n-1) neg[v]=true;
		}
	}

	// set of vertices reachable from n-1 in the reversed graph
	bool vis[2500]={};
	vis[n-1]=true;
	rep(t,n) rep(i,m) {
		int u=E[i].u,v=E[i].v;
		if(vis[v]) vis[u]=true;
	}

	rep(u,n) if(neg[u] && vis[u]) { puts("-1"); return 0; }

	printf("%d\n",max(-d[n-1],0));

	return 0;
}


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

int main() {
	long long N,A,B,C,D,E;
	long long m;
	long long tmp;
	cin >> N >> A >> B >> C >> D >> E;
	m = min(A,min(B,min(C, min(D,E))));
	tmp = N%m == 0 ? N/m : N/m + 1;
	cout << tmp+4 << endl;

	return 0;
}

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

using namespace std;

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

    int n;
    cin >> n;

    const int m = n * (n - 1) / 2 - n / 2;
    const int sum = ((n & 1) ? n : n + 1);

    cout << m << endl;
    for (int v = 1; v <= n; ++v) {
        for (int u = v + 1; u <= n; ++u) {
            if (v + u != sum) cout << v << " " << u << "\n";
        }
    }

    return 0;
}


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

int main()
{
  int N; cin >> N;
  int H[100005];
  for (int i = 1; i <= N; i++)
  {
    cin >> H[i];
  }
  
  int cost[100005] = {};
  cost[1] = 0;
  cost[2] = abs(H[2] - H[1]);
  for (int j = 3; j <= N; j++)
  {
    cost[j] = min(cost[j - 1] + abs(H[j] - H[j - 1]), 
                  cost[j - 2] + abs(H[j] - H[j - 2]));
  }
  
  cout << cost[N] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 

int  A(int x){
    if(x>=0)return x;
    else return -x;
}

ll inv(ll x) {
	ll res = 1;
	ll k = N - 2;
	ll y = x%N;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N)*(y%N) % N;
		k /= 2;
	}
	return res;
}

unsigned long long popCount64bitB(unsigned long long x) 
{ 
    x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) 
      +  (x & 0x5555555555555555UL); 
    x = ((x & 0xccccccccccccccccUL) >> 2) 
      +  (x & 0x3333333333333333UL); 
    x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) 
      +  (x & 0x0f0f0f0f0f0f0f0fUL); 
    x = ((x & 0xff00ff00ff00ff00UL) >> 8) 
      +  (x & 0x00ff00ff00ff00ffUL); 
    x = ((x & 0xffff0000ffff0000UL) >> 16) 
      +  (x & 0x0000ffff0000ffffUL); 
    x = ((x & 0xffffffff00000000UL) >> 32) 
      +  (x & 0x00000000ffffffffUL); 
    return x; 
} 



int main(void){
    ll x;
    cin>>x;
    ll ans = 0;
    ll y = x/500;
    ans = 1000*y;
    x = x- 500*y;
    ll u = x/5;
    ans += 5*u;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,a,b,c,i;
	while(scanf("%d",&n)!=EOF)
	{
		for(i=0;i<n;i++)
		{
			scanf("%d %d %d",&a,&b,&c);
			if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a)
				printf("YES\n");
			else
				printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
'use strict'
function main(inp) {
  inp = inp.split('\n')
  const N = inp.shift() - 0
  inp = inp[0].split(' ').map(n => n - 0)
  let max = 0

  for (let i = 0; i < N; i++) {
    if (max < inp[i]) max = inp[i]
    if (max - 2 >= inp[i]) {
      console.log('No')
      return
    }
  }
  console.log('Yes')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
import numpy as np

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

div2 = list(map(lambda x: (x + 1) % 2, A))
div3 = list(map(lambda x: x % 3, A))
div5 = list(map(lambda x: x % 5, A))

A = np.array(A)
div2 = np.array(div2)
div3 = np.array(div3)
div5 = np.array(div5)

Approve = A * div2 * div3 * div5

if all([Approve[i] == 0 for i in range(len(Approve))]):
    print('APPROVED')
else:
    print('DENIED')

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

llong gcd(llong x, llong y) {
  if (x < y) swap(x, y);
  if (y == 0) return x;
  gcd(y, x % y);
}
llong lcm(llong x, llong y) { return x / gcd(x, y) * y; }
llong f(llong x, llong c, llong d) {
  llong res = x;
  res -= x / c;
  res -= x / d;
  res += x / lcm(c, d);
  return res;
}
int main() {
  llong a, b, c, d;
  cin >> a >> b >> c >> d;
  llong ans = f(b, c, d) - f(a - 1, c, d);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(){
	int N;
	scanf("%d",&N);
	vector<long long>v(N+1);
	for(int i=1;i<=N;i++)scanf("%lld",&v[i]);
	sort(v.begin()+1,v.end());
	vector<long long>w(N+1);
	for(int i=1;i<=N;i++)w[i]=w[i-1]+v[i];
	int M;
	scanf("%d",&M);
	vector<long long>p(M);
	for(int i=0;i<M;i++){
		long long x;
		scanf("%lld",&x);
		auto it=upper_bound(v.begin(),v.end(),x);
		p[i]=w[distance(v.begin(),--it)];
	}
	for(int i=0;i<M;i++){
		long long x;
		scanf("%lld",&x);
		puts(p[i]>=x?"Yes":"No");
	}
}

Measured memory_bytes: 7860
const input = require("fs").readFileSync("/dev/stdin", "utf8").trim();
// var input = `dreamerer`;
input = input.split('').reverse().join('');
const STRINGS = ['dream', 'dreamer', 'erase', 'eraser'].map(s => s.split('').reverse().join(''));

while(1) {
    var canDivide = false;
    for (var i = 0; i < STRINGS.length; i++) {
        var s = STRINGS[i];
        var divide = input.substring(0, s.length);
        if (divide === s) {
            input = input.substring(s.length);
            canDivide = true;
            continue;
        }
    }
    if (!canDivide) {
        break;
    }
}

console.log(input === '' ? 'YES' : 'NO');


Measured memory_bytes: 11468
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int maxn=1e6+10;
int n;
ll f[maxn];
int main()
{
	cin>>n;
	f[0]=1;
	for (int i=3;i<=n;i++) f[i]=(f[i-3]+f[i-1])%mod;
	cout<<f[n]<<endl;
	return 0;
}



Measured memory_bytes: 3624
N = int(input())
W = ['0'] * N
for i in range(N):
    W[i] = input()
if len(set(W)) != N:
    print("No")
    exit()
k = W[0][-1]
for i in range(1,N):
    if W[i][0] != k:
        print("No")
        exit()
    k = W[i][-1]
print("Yes")

Measured memory_bytes: 3064
// フェルマーの小定理
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	m = 1000000007
)

func mpow(x int, n int) int {
	result := 1
	for n != 0 {
		if n&1 == 1 {
			result *= x
			result %= m
		}
		x *= x
		x %= m
		n >>= 1
	}
	return result
}

func mcomb(n int, k int) int {
	a := 1
	b := 1
	for i := 0; i < k; i++ {
		a *= n - i
		a %= m
		b *= i + 1
		b %= m
	}
	return a * mpow(b, m-2) % m
}

func main() {
	n := readInt()
	a := readInt()
	b := readInt()

	result := mpow(2, n) - 1
	result -= mcomb(n, a)
	result += m
	result %= m
	result -= mcomb(n, b)
	result += m
	result %= m
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 1804
/* tempate
 *
 *
 */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    ll res = 1;
    if(abs(n - m) <= 1){
        if(n > m){
            for(ll i = m; i >= 2; i--){
                res = (((res * i) % MOD) * i) % MOD;
            }
            res = (res * n) % MOD;
            cout << res << endl;
            return 0;
        }
        else if(n == m){
            for(ll i = n; i >= 2; i--){
                res = (((res * i) % MOD) * i) % MOD;
            }
            res = (res * 2) % MOD;
            cout << res << endl;
            return 0;
        }
        else if(n < m){
            for(ll i = n; i >= 2; i--){
                res = (((res * i) % MOD) * i) % MOD;
            }
            res = (res * m) % MOD;
            cout << res << endl;
            return 0;
        }
    }
    else{
        res = 0;
        cout << res << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b;
    cin >> a >>b;
    int c = a/b;
    int d = a%b;
    double e = (double)a/(double)b;
    cout << c << " " << d << " " ;
    printf("%.8lf\n",e);
}


Measured memory_bytes: 3224
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
typedef long long ll;
#define rep(i, z, n) for(int i = z; i < n; i++)
//const int INF = 1<<29;
const ll MOD = 1000000007;
#define P pair<int, int>
using namespace std;


int main(){
    int N;
    cin >> N;
    int sum = 0, fin = 0;
    rep(i, 0, N){
        int C, D;
        cin >> C >> D;
        if(C == D){
            sum++;
            fin = max(sum, fin);
        }
        else{
            sum = 0;
        }
    }
    if(fin >= 3){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

int main(){
  int n,k,i;
  cin>>n>>k;
  int L[n];
  for(i=0;i<n;i++){
  	cin>>L[i];
  }
  sort(L,L+n,greater<int>());
  int sum=0;
  for(i=0;i<k;i++){
    sum+=L[i];
  }
  cout<<sum;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, l) = readLine()!!.split(' ').map { it.toInt() }
    val s = Array<String>(n){""}
    repeat(n) {
        s[it] = readLine()!!
    }
    s.sort()
    s.forEach {
        print(it)
    }
    println()
}


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

const ll ofs = 1e17;

int main(){
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);

	int n;
	cin >> n;
	
	vector<ll> xs(n), ys(n);
	rep(i,0,n) cin >> xs[i] >> ys[i];
	trav(x, xs) x += ofs;

	ll lo = 0, hi = 4e17+1;

	auto in = [&](ll x, ll y){
		if (y <= 0) return x+y >= 0 && !((x+y)&(-y));	
		return -x-1 >= 0 && x+y >= 0
					&& !((x+y)&(-x-1));
	};
	
	auto ge = [&](ll pos){
		bool ans = false;
		rep(i,0,n) if(in(xs[i]-pos, ys[i])) ans = !ans;
		return ans;
	};

	while(lo+1 < hi){
		ll mi = (lo+hi)/2;
		if(ge(mi)) lo = mi;
		else hi = mi;
	}
	cout << lo-ofs << endl;
}


Measured memory_bytes: 1792
/*
--> WHEN IT'S OBVIOUS THAT THE GOAL CANNOT BE REACHED,
	DON'T ADJUST THE GOALS,
	ADJUST THE ACTION STEPS.

--> THE WAY YOU CONQUER SELF-DOUBT IS BY DOING THINGS THAT MAKE YOU UNCOMFORTABLE.

--> IT IS DURING OUR DARKEST MOMENTS WE MUST FOCUS TO SEE LIGHT.
*/

#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <climits>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortAll(x) sort(all(x))
#define sz(x) (int)x.size()
#define clr(x) memset(x, 0, sizeof(x))
#define PI 3.1415926535897932384626
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef pair< int, int >	pii;
typedef pair< ll, ll >		pl;
typedef vector< int >		vi;
typedef vector< ll >		vl;
typedef vector< pii >		vpii;
typedef vector< pl >		vpl;
typedef vector< vi >		vvi;
typedef vector< vl >		vvl;

const int MOD = 1e9 + 7;

ll power(ll a, ll b)
{
	ll ans = 1;

	while (b > 0)
	{
		if (b & 1)
			ans *= a;
		a = a * a;
		b >>= 1;
	}
	return ans;
}

ll powm(ll a, ll b)
{
	a %= MOD;
	ll ans = 1;

	while (b > 0)
	{
		if (b & 1)
			ans = (ans * a) % MOD;
		a = (a * a) % MOD;
		b >>= 1;
	}
	return ans;
}

//================================

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

	int A[n];
	for (int &x : A)
		cin >> x;

	int ans = A[n - 1] - A[0];
	for (int i = 1; i < n; i++)
		ans = min(ans, (k - A[i]) + A[i - 1]);

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
import sys
from itertools import starmap
readline = sys.stdin.readline
class Segment(object):
    __slots__ = ('fi', 'se')
    def __init__(self, fi, se):
        self.fi = fi
        self.se = se
def cross(a, b):
    return a.real * b.imag - a.imag * b.real
def dot(a, b):
    return a.real * b.real + a.imag * b.imag
def norm(base):
    return abs(base) ** 2
def project(s, p2):
    base = s.fi - s.se
    r = dot(p2 - s.fi, base) / norm(base)
    return s.fi + base * r
s = Segment(*(starmap(complex, zip(*[map(int, readline().split())] * 2))))
n = int(readline())
for _ in [0] * n:
    p2 = complex(*map(float, readline().split()))
    ap = project(s, p2)
    print(ap.real, ap.imag)

Measured memory_bytes: 7908
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long ans = 0;
		for (int i = 1; i < n+1; i++) {
			if (i % 3 != 0 && i % 5 != 0) {
				ans += i;
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 27228
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

ll sum[100100];
vector<P> v;

int
main(void){  
  ios_base::sync_with_stdio(false);

  ll n, k;
  cin >> n >> k;
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    v.push_back(make_pair(a, b));
  }
  sort(v.begin(), v.end());

  ll cnt = 0LL;
  REP(i, n){
    cnt += v[i].second;
    if(cnt >= k) {cout << v[i].first << endl; return 0;}
  }
  
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,x,m;
    int mini=100000;
    int cnt=0;
    cin>>a>>x;
    for(int i=0; i<a; i++)
    {
        cin>>m;
        if(x>=m)
        {
            x-=m;
            cnt++;
        }
        else
            break;
        if(mini>m)
            mini=m;
    }
    while(x>=mini)
    {
        x-=mini;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    long double ans = 0;
    vector<ll> p(N+1, 1);
    repr(i, 1, N+1) p[i] = p[i-1]*i;

    rep(i, N) repr(j, i+1, N){
        ans += 2*p[N-1]*sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) );
    }
    ans /= p[N];
    cout << setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

const int inf=1000000007;
int dp[410][410];
int a[41],b[41],c[41];
int main(){
    int n,ma,mb;
    cin>>n>>ma>>mb;
    rep(i,n) cin>>a[i]>>b[i]>>c[i];
    rep(i,10*n){
        rep(j,10*n) dp[i][j]=inf;
    }
    dp[0][0]=0;
    rep(i,n){
        for(int j=10*n;j>=a[i];--j){
            for(int k=10*n;k>=b[i];--k){
            dp[j][k]=min(dp[j][k],dp[j-a[i]][k-b[i]]+c[i]);
            }
        }
    }
    int ans=inf;
    rep(i,10*n){
        rep(j,10*n){
            if(i*mb==j*ma&&(i!=0&&j!=0)) ans=min(ans,dp[i][j]);
        }
    }
    if(ans==inf) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)


int main(){
    long double N;
    cin >> N;
    for(long double h = 1; h <= 3500;++h){
        for(long double n = 1; n <= 3500; ++n){
            long double w = N*h*n / (4.0L*n*h - N*n - N*h);
            if(w == ceil(w) && w > 0 && w < LINF) {
                cout << (int)h << " " << (int)n << " " << (int)w << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <complex>
#include <cstdio>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = (1e-10);    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// 内積　dot(a,b) = |a||b|cosθ
D dot(P a, P b) {
  return (conj(a)*b).X;
}
// 外積　cross(a,b) = |a||b|sinθ
D cross(P a, P b) {
  return (conj(a)*b).Y;
}

int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

int main() {
  double xa, ya, xb, yb, xc, yc, xd, yd;
  while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd) != EOF) {
    P p[4] = {P(xa, ya), P(xb, yb), P(xc, yc), P(xd, yd)};

    bool ok = true;
    for (int i = 0; i < 4; i++) {
      if (ccw(p[i], p[(i+1)%4], p[(i+2)%4]) != ccw(p[(i+1)%4], p[(i+2)%4], p[(i+3)%4])) {
        ok = false;
        break;
      }
    }

    if (ok) {
      std::cout << "YES" << std::endl;
    }else {
      std::cout << "NO" << std::endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1228
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var dn = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var k = (int)Math.Pow(100, dn[0]);
        var z = dn[1] * k;
        Console.WriteLine(z / k < 100 ? z : z + k);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
 
int main(){
int n;
ll k;
	cin >> n >> k;
vector<int> a(n);
vector<int> f(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> f[i];
  
  sort(a.begin(),a.end());
  sort(f.begin(),f.end());
  reverse(f.begin(),f.end());
  
  // ２分探索
  ll l = -1 , r =1e12;
  
  while(l+1<r){
  	ll c = (l+r)/2;
    bool ok = [&]{
    	ll s=0;
        rep(i,n){
        	s += max(0ll,a[i]-c/f[i]);
        }
      return s <= k ;
    }();
    if(ok) r = c; else l = c;
  }
  cout << r << endl;
  return 0;
}

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

int main(){
  int A,B,maxn;
  int c[3];
  cin >> A >> B;

  c[0] = A+B;
  maxn = c[0];
  c[1] = A-B;
  c[2] = A*B;

  for(int i=0;i<3;i++){
    maxn = max(maxn,c[i]);
  }
  
  cout << maxn << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   
  int a,b,c;
  int x,n,i;
   
  scanf("%d",&n);
  if( n == 2){
    scanf("%d%d",&a,&b);
     
    if( a > b ){
      x = a;
      a = b;
      b = x;
    }
    while(1){
      x = b % a;
      if( x == 0 )break;
      b = a;
      a = x;
    }
     
  }
  else {
    scanf("%d%d%d",&a,&b,&c);
    if( a > b ){
      x = a;
      a = b;
      b = x;
    }
    if( b > c ){
      x = b;
      b = c;
      c = x;
    }
    if( a > b ){
      x = a;
      a = b;
      b = x;
       
    }
     
    while(1){
      x = c % b;
      if( x == 0 )break;
      c = b;
      b = x;
    }
    while(1){
      x = b % a;
      if( x == 0 )break;
      b = a;
      a = x;
    }
  }
 
 
  for( i = 1 ; i <= a ; i++ ){
    if( a % i == 0 ){
      printf("%d\n", i);
    } 
     
  } 
   
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

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

  cin >> n;
  vector<int> l(n);

  REP(i, n) cin >> l[i];

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

  cout << (l[n / 2] - (l[n / 2 - 1])) << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
	ll n, x;
	cin >> n >> x;

	ll cnt = 0;

	vector<ll> box;
	for (ll i = 0; i < n; i++)
	{
		ll tmp;
		cin >> tmp;
		box.push_back(tmp);
	}

	for (int i = 0; i < n - 1; i++)
	{
		if (box[i] > x)
		{
			cnt += box[i] - x;
			box[i] = x;
		}

		while (i < n && box[i] + box[i + 1] > x)
		{
			ll gap = box[i] + box[i + 1] - x;
			cnt += gap;
			if (gap > box[i + 1])
			{
				gap -= box[i + 1];
				box[i + 1] = 0;
				box[i] -= gap;
			}
			else
			{
				box[i + 1] -= gap;
			}
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 1400
def q(a,h):
 d[a]=str(h)
 for b in t[a]:q(b,h+1)
t,p,d={},{},{}
for _ in[0]*int(input()):
 e=input().split()
 t[e[0]]=e[2:]
 for i in e[2:]:p[i]=e[0]
r=(set(t)-set(p)).pop()
p[r]='-1'
q(r,0)
print('\n'.join(f"node {i}: parent = {p[i]}, depth = {d[i]}, {'root'if'-1'==p[i]else'internal node'if t[i]else'leaf'}, [{', '.join(t[i])}]"for i in map(str,sorted(map(int,t)))))


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    map <string, ll> mp ;
    ll n ;
    string s ;
    cin >> n ;
    for (int i = 0; i < n; i++) {
        cin >> s ;
        mp[s]++ ;
    }
    cout << "AC x " << mp["AC"] << endl ;
    cout << "WA x " << mp["WA"] << endl ;
    cout << "TLE x " << mp["TLE"] << endl ;
    cout << "RE x " << mp["RE"] << endl ;

    return 0 ;
}


Measured memory_bytes: 3648
//       ###
//      #---##
//  ####-0----##
// ####--------#
//     #--------#
//     ##-------#
//      #-------#
//      #-------#
//     ##--------#
//     #---------# ##### 
//     #-------##-------#######           																																									Ya katala
//     #------#----------------#
//    #------##-----------------#
//    #------##------------------#
//    #-----#---------------------#
//    #-----##---------------------#
//     #------##--------------------#
//      #-------##-------------------#
//       #--------##------------------#
//        ############################ #
//             ||           ||
//             ||           ||
//             ||           ||
//             ||           ||
//          ####|        ####|




#include <bits/stdc++.h>

#define for0(i , v) for (int i = 0 ; i < v.size() ; i++)
#define for1(i , n) for (int i = 1 ; i <= n ; i++)
#define AIDS ios_base::sync_with_stdio(0)
#define pb push_back
#define pp pop_back
#define sz(a) a.size()
#define all(x) x.begin() , x.end()
#define F first
#define S second
#define mp make_pair
#define ld long double
#define ll long long
#define pii pair<int, int>
#define in insert

const int N = 1e6 + 3;
const ll INF = 1e18 + 100;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int dx[] = {0 , 1 , 0 , -1 , 0};
const int dy[] = {0 , 0 , 1 , 0 , -1};
const char dd[] = {' ' , 'D' , 'R' , 'U' , 'L'};

using namespace std;

int digits(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

int main () {
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
	AIDS;
	int n;
	cin >> n;
	int mini = inf;
	for (int i = 1 ; i < n ; i++) {
		mini = min(mini , digits(i) + digits(n - i));
	}
	cout << mini;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main() {
    ll n,m,k; cin >> n >> m >> k;
    string ans = "No";

    rep(i,m+1){
        rep(j,n+1){
            if(i*(n-j) + j*(m-i) == k) ans = "Yes";
        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3596
import collections
import sys
input = lambda: sys.stdin.readline().strip()

def main():
    N,M = map(int,input().split())
    H_list = list(map(int,input().split()))
    ab_list = [list(map(int,input().split())) for _ in range(M)]

    ab_dict = {i: [] for i in range(N)}
    for a,b in ab_list:
        a,b = a-1,b-1
        ab_dict[a].append(b)
        ab_dict[b].append(a)

    ans = 0
    for k,v_list in ab_dict.items():
        for v in v_list:
            if H_list[v] >= H_list[k]:
                break
        else:ans += 1
    print(ans)

main()


Measured memory_bytes: 56420
N = int(input())
d = list(map(int, input().split()))

accum = [0 for _ in range(N)]

for i, _d in enumerate(d):
  if i == 0:
    accum[i] = _d
  else:
    accum[i] = accum[i-1] + _d

res = 0
for i, _d in enumerate(d):
  if i < N-1:
    res += d[N-i-1] * accum[N-i-2]
  
print(res)

Measured memory_bytes: 3064
#include <cstdio>
using namespace std;

int max( int a, int b ){
  if ( a > b ) return a;
  return b;
}

int n,h;
int Max = 0, total = 0;

int main(){
  	
  	scanf("%d",&n);
  	for ( int i = 0; i < n; i++ ){
    	scanf("%d",&h);
      	if ( Max <= h ) total++;
      	Max = max( Max, h );
    }
  	printf("%d\n",total);
	return 0;
}

Measured memory_bytes: 128
import itertools
n, m, x = map(int, input().split())
ca = []
for _ in range(n):
    ca.append(list(map(int, input().split())))

prices = []
best_skill = [0]*m
for i in range(1, n+1):
    n_list = [i for i in range(n)]
    for N in itertools.combinations(n_list, i):
        skill = [0]*m
        price = 0
        for j in N:
            price += ca[j][0]
            for k in range(1, m+1):
                skill[k-1] += ca[j][k]
        if min(skill) >= x:
            prices.append(price)

if prices:
    print(min(prices))
else:
    print(-1)

Measured memory_bytes: 9256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define forn(i, n) for (int i = 0; i < (int) (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int count  = 0;
    for(int i = 0; i < s.size()-1;++i){
        if(s[i] != s[i+1]){
            count++;
        }
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> v;
  for(int i = 0; i < 3; i++){
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  sort(v.begin(), v.end());
  cout <<  v[2]*10 + v[1] + v[0] << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,ans=0;
    cin>>n;
    if(n%2==1) cout<<0<<endl;
    else{
        for(long long i=10;i<=1e18;i*=5){
            ans+=n/i;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T>
T largestrectangle(vector<T> &v){
  int n=v.size();
  T res=0;
  using P = pair<int, T>;
  stack<P> sp;
  sp.emplace(-1,T(0));
  for(int i=0;i<n;i++){
    int j=i;
    while(sp.top().second>v[i]){
      j=sp.top().first;
      if(sp.top().second)
        res=max(res,(i-j+1)*(sp.top().second+1));
      sp.pop();
    }
    if(sp.top().second<v[i]) sp.emplace(j,v[i]);
  }
  while(!sp.empty()){
    if(sp.top().second)
      res=max(res,(n-sp.top().first+1)*(sp.top().second+1));
    sp.pop();
  }
  return res;
}

//INSERT ABOVE HERE
signed main(){
  int h,w;
  cin>>h>>w;
  vector<string> st(h);
  for(int i=0;i<h;i++) cin>>st[i];

  int ans=max(h,w);
  vector<int> vv(w-1,0);
  for(int i=0;i+1<h;i++){
    for(int j=0;j+1<w;j++){
      int cnt=0;
      for(int a=0;a<2;a++)
        for(int b=0;b<2;b++)
          cnt+=st[i+a][j+b]-'0';
      if(cnt&1) vv[j]=0;
      else vv[j]++;
    }
    chmax(ans,largestrectangle(vv));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;

vector<vector<int>> edges, rev, depths;
queue<int> Q;

int parent[100010];
int rem[100010];
int dist[100010];
bool seen[100010];

int main() {
   int N, M, n1, n2;
   scanf("%d %d", &N, &M);
   edges.assign(N + 5, vector<int>());
   rev.assign(N + 5, vector<int>());
   depths.assign(N + 5, vector<int>());
   for (int i = 0; i < N + M - 1; i++) {
      scanf("%d %d", &n1, &n2);
      edges[n1].push_back(n2);
      rev[n2].push_back(n1);
   }//for
   for (int i = 1; i <= N; i++) {
      if (rev[i].empty())
         Q.push(i), depths[0].push_back(i);
       rem[i] = (int)rev[i].size();
   }//if
   while (!Q.empty()) {
      int curr = Q.front();
      Q.pop();
      for (auto& e : edges[curr]) {
         if (!--rem[e]) {
            Q.push(e);
            dist[e] = dist[curr] + 1;
            depths[dist[e]].push_back(e);
         }//if
      }//for
   }//while
   for (int i = N; i >= 0; i--) {
      for (auto& curr : depths[i]) {
         for (auto& e : edges[curr]) {
            if (!seen[e]) {
               seen[e] = 1;
               parent[e] = curr;
            }//if
         }//for
      }//for
   }//while
   for (int i = 1; i <= N; i++)
      printf("%d\n", parent[i]);
   return 0;
}//main


Measured memory_bytes: 18560
#include<iostream>
#include<cmath>

using namespace std;

bool is_room(int S){

  for(int i=1;i*i<=S;i++)
    if((S-i)%(2*i+1)==0)return true;
  return false;
}

int main(void){

  int n,S,cnt=0;

  cin >> n;
  while(n--){
    cin >> S;
    if(!is_room(S))cnt++;
  }
  cout << cnt << endl;

  return 0;
}

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

string build1(int x, int y){
  return string(x, 'R') + string(y, 'U');
}

string build2(int x, int y){
  return string(x, 'L') + string(y, 'D');
}

string rev(string s){
  reverse(s.begin(), s.end());
  return s;
}

int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int dx = tx-sx;
  int dy = ty-sy;
  string ans = build1(dx, dy) + build2(dx, dy) +
    "D" + build1(dx+1, dy+1) + "LU" + build2(dx+1, dy+1) + "R";

  cout << ans << endl;
  cerr << ans.size() << endl;
}


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

#define ll long long

using namespace std;
const ll INF = (ll) 1e17;

int main() {
    int  n;
    cin >> n;
    vector < vector < pair<ll,ll> > > g (n);
    for (ll i = 0; i < n - 1; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        g[a].push_back(make_pair(b, c));
        g[b].push_back(make_pair(a, c));
    }

    int m, s;
    cin >> m >> s;
    s--;
    vector<ll> d (n, INF),  p (n);
    d[s] = 0;
    set < pair<int,int> > q;
    q.insert (make_pair (d[s], s));
    while (!q.empty()) {
        int v = q.begin()->second;
        q.erase (q.begin());

        for (size_t j=0; j<g[v].size(); ++j) {
            ll to = g[v][j].first,
                    len = g[v][j].second;
            if (d[v] + len < d[to]) {
                q.erase (make_pair (d[to], to));
                d[to] = d[v] + len;
                p[to] = v;
                q.insert (make_pair (d[to], to));
            }
        }
    }
    for (ll i = 0; i < m; i++) {
        ll x, y;
        cin >> x >> y;
        x--, y--;
        cout << d[x] + d[y] << "\n";
    }
}

Measured memory_bytes: 14576
#include <stdio.h>

int main()
{
	int W,H,x,y,r;

	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

	if(x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H){

		printf("Yes\n");
	}
	else{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 584
// https://atcoder.jp/contests/abc116/tasks/abc116_a

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

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int a[3];

  cin >> a[0] >> a[1] >> a[2];

  sort(a, a + 3);

  cout << a[0] * a[1] / 2 << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(int i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    int x,n;
    cin>>x>>n;
    int a[n];
    unordered_map<int,int>mp;
    rep(i,0,n)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    int i=0;
    while(true)
    {
        if(mp[x-i]==0)
        {
            cout<<x-i<<endl;
            break;
        }
        else if(mp[x+i]==0)
        {
            cout<<x+i<<endl;
            break;
        }
        
        i++;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main()
{
    char S[2][3];
    cin >> S[0][0] >> S[0][1] >> S[0][2];
    cin >> S[1][0] >> S[1][1] >> S[1][2];

    if(S[0][0] == S[1][2] && S[1][0] == S[0][2] && S[0][1] == S[1][1])  cout << "YES\n";
    else    cout << "NO\n";
        
}

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#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 all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

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

const ll LINF = 2e18;
const int INF = 1e9;

ll N;
vector<char> c;

void solve() {
  ll r = 0;
  rep(i, N) if (c.at(i) == 'R') r++;

  ll ans = r;
  ll w = 0;
  rep(i, N) {
    if (c.at(i) == 'R')
      r--;
    else
      w++;
    ans = min(ans, max(r, w));
  }

  cout << ans << endl;
}

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

  cin >> N;
  c.resize(N);
  string s;
  cin >> s;
  rep(i, N) c.at(i) = s.at(i);
  solve();

  return 0;
}


Measured memory_bytes: 3780
#include<cstdio>
#include<algorithm>
#include<cstring>
int n,k,num[100050],zer;
int ton1[100050],ton2[100050],ans=0;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&num[i]);
	std::sort(num+1,num+n+1);
	num[0]=0xbfbfbfbf;
	ans=num[n+1]=0x3f3f3f3f;
	memset(ton1,0x3f,sizeof ton1);
	memset(ton2,0x3f,sizeof ton2);
	for(int i=0;i<=n;i++)
		if(!num[i]||(num[i]<0&&num[i+1]>0)){zer=i; break;}
	if(!num[zer]) k--,zer--;
	ton1[0]=ton2[0]=0;
	
	for(int i=zer;i>=1;i--) ton1[zer-i+1]=-num[i];
	for(int i=(num[zer+1]?zer+1:zer+2);i<=n;i++)
		ton2[i-zer-1+(bool)(num[zer+1])]=num[i];
	for(int i=0;i<=k;i++)
		ans=std::min(ans,(ton1[k-i]+ton2[i]+std::min(ton1[k-i],ton2[i])));
	printf("%d\n",ans);
	return 0;
}

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

int solve(int i){
    if (dp[i] != -1)
        return  dp[i];
    if (i == 1)
        return dp[i] = 0;
    if (i == 2)
        return dp[i] = abs(h[1] - h[2]);
    return dp[i] = min(abs(h[i] - h[i-1]) + solve(i -1 ), abs(h[i] - h[i-2]) + solve(i - 2));
}

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int n;
    cin >> n;
    memset(dp, -1, sizeof dp);
    
    rep(i, 1, n + 1)
        cin >> h[i];
    cout << solve( n) << '\n';
    return 0;   
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cctype>
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
int n, pre, d, x, ans = 1;
int main()
{
    n = read();
    for(int i = 1; i <= n; ++i)
    {
        int x = read();
        if(!pre) pre = x;
        else if(!d)
        {
            if(pre < x) d = 1;
            else if(pre > x) d = -1; 
        }
        else if(pre*d > x*d) d = 0, ++ans;
        pre = x;
    }
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;


int main() {

 ll n;
  cin>>n;
  Vec vec(100,0);
  int ct=0;
  
   while(n!=0){
       int x = n%26;
       if(x==0){
           x=26;
           vec[ct]=x;
           n=(n/26)-1;
           ct++;
       }
       else{
           vec[ct]=x;
           n=n/26;
           ct++;
       }
      
  }
  string s="";
  
  for(int i=0;i<ct;i++){
      char q;
      
      q=vec[i]+96;
    s+=q;
  }
  reverse(s.begin(), s.end());

  
 cout<<s<<endl;


}
  


Measured memory_bytes: 3604
al = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
n = int(input())
s = input()
ans =[]
for i in s:
  num = al.index(i)
  num = (num + n ) % 26
  ans.append(al[num])
p=''.join(ans)
print(p)

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

int main()
{
   int R;
   cin>>R;
  
  if(R<1200){
     cout<<"ABC"<<endl;
  }
  if(1200<=R && R<2800){
    cout<<"ARC"<<endl;
  }
  if(2800<=R){
    cout<<"AGC"<<endl;
  }
  
  return 0;


}


Measured memory_bytes: 256