akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; i--)
#define REP(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define FORE(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fi   first
#define se   second
#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)

const int N = 1e5 + 5, oo = 1e9 + 5;
int n, dp[N], a[N], K;

// int Left(int id) {return (id << 1);}
// int Right(int id) {return (id << 1) + 1;}

// void build(int id, int L, int R) {
// 	if (L == R) {
// 		st[id] = oo;
// 		return;
// 	} else {
// 		int mid = (L + R) >> 1;
// 		build(Left(id),L, mid);
// 		build(Right(id), mid + 1, R);
// 	}
// }

// void update(int id, int L, int R, int val, int i) {
// 	if (L > i || R < i) return;
// 	if (L == R) {
// 		st[id] = val;
// 		return;
// 	} else {
// 		int mid = (L + R) >> 1;
// 		update(Left(id), L, mid, val, i);
// 		update(Right(id), mid + 1, R, val, i);
// 		st[id] = min(st[Left(id)], st[Right(id)]);
// 	}
// }

// int query(int id, int L, int R, int i, int j) {
// 	if (L < i || R > j) return -1;
// 	else if (L >= i && R <= j) return st[id];
// 	else {
// 		int mid = (L + R) >> 1;
// 		return min(query(Left(id), L, mid, i, j), query(Right(id), mid + 1, R, i, j));
// 	}
// }

void input() {
	scanf("%d%d", &n, &K);
	FOR(i, 1, n) scanf("%d", &a[i]);
	FOR(i, 2, n) dp[i] = oo;
}

void solve() {
	dp[1] = 0;
	FOR(i, 2, n) {
		FOR(j, max(1, i - K), i - 1) {
			dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
		}
	}
	printf("%d\n", dp[n]);
}

int main(int argc, char const *argv[])
{

	input();
	solve();

	return 0;
}


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

int main() {
	string nums;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> nums;
		for (int j = 0; j < nums.size() - 1; j++) {
			for (int k = 0; k < nums.size() - 1; k++) {
				if (nums[k] > nums[k + 1]) {
					string tmp;
					tmp = nums[k];
					nums[k] = nums[k + 1];
					nums[k + 1] = tmp[0];
				}
			}
		}
		int num1 = atoi(nums.c_str());
		string tmp="";
		for (int i = nums.size()-1; i >= 0; i--) {
			tmp += nums[i];
		}
		int num2 = atoi(tmp.c_str());
		cout << num2 - num1 << endl;
	}
}


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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long n;
        string s;
        cin >> n >> s;

        for (auto &c : s) c = (((c + n) - 'A') % 26) + 'A';
        cout << s << endl;
    }
}


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

int main() {
	long long n,k;
	cin >> n >> k;
	long long arr[n],ans = 0;
	
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
		if(arr[i] >= k) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4356
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
	
		var p = Input().ToInt();
		var n = p[0];
		var k = p[1];
		var a = Input().Select(long.Parse).ToArray();
		var queue = new Queue<long>();
		for(int i = 0; i < k; i++)
		{
			queue.Enqueue(a[i]);
		}
		
		for(int i = k; i < n; i++)
		{
			if(i != k-1)
			{
				var a1 = queue.Dequeue();
				if(a1 < a[i])
				{
					Console.WriteLine("Yes");
				}
				else
				{
					Console.WriteLine("No");
				}
				queue.Enqueue(a[i]);
			}
		}
		
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 48968
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define all(a) a.begin(), a.end()
ll N, M, V, P;
vector<ll> A, S;

int main(){
    cin >> N >> M >> V >> P;
    A.resize(N);
    rep(i, 0, N) cin >> A[i];
    sort(all(A));
    ll lb = -1, ub = N - 1;
    while(ub-lb > 1){
        ll mid = (lb + ub) / 2;
        vector<ll> b;
        rep(i, 0, N) if(mid != i) b.push_back(A[i]);
        ll base = A[mid] + M;
        ll ok = 0;
        reverse(all(b));
        bool bad = 0;
        rep(i, 0, b.size()){
            if(i < P - 1) ok += M;
            else if(base >= b[i]) ok += min(M, base-b[i]);
            else bad = 1;
        }
        if(bad) lb = mid;
        else if(ok >= M * (V-1)) ub = mid;
        else lb = mid;
    }
    cout << N - ub << endl;
}

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

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

  int sum = a+b;
  int div = a-b;
  int mult= a*b;
  if(sum >= div && sum >= mult) {
    cout<<sum;
  } else if (div>= sum  && div >= mult) {
    cout<<div;
  }else {
    cout<<mult;
  }
  
	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=2e5+10;
const int mod=1e9+7;
int a[maxn];
main(){
    int n;
    cin>>n;
    int tmp=0;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        tmp^=a[i];
    }
    for(int i=1;i<=n;++i)cout<<(a[i]^tmp)<<" ";
    cout<<endl;
}


Measured memory_bytes: 5124
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

signed main(void){
    int a,b; cin>>a>>b;
    cout<<max(a - 2*b, 0LL)<<endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, m;
int cnt[100010];
int cnt2[100010];
int cnt3[100010];
int ans;

signed main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		cnt[a%m]++;
		cnt2[a]++;
	}
	for (int i = 1; i <= 100000; i++)cnt3[i%m] += cnt2[i] - cnt2[i] % 2;
	for (int i = 1; i < (m + 1) / 2; i++)ans += min(cnt[i], cnt[m - i]);
	ans += cnt[0] / 2;
	if (m % 2 == 0)ans += cnt[m / 2] / 2;
	for (int i = 1; i < m; i++) {
		if (cnt[i] <= cnt[m - i])continue;
		ans += min(cnt[i] - cnt[m - i], cnt3[i]) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,N;
  cin >>A>>B>>N;
  if(N %2 == 0){
    for(int i = 0;i<N/2;i++){
      if(A %2 == 1){
        A = A - 1;
      }
      A = A/2;
      B = A + B;
      if(B %2 == 1){
        B = B - 1;
      }
      B = B / 2;
      A = A + B;
    }
  }
  else{
    for(int i = 0;i<N/2;i++){
      if(A %2 == 1){
        A = A - 1;
      }
      A = A/2;
      B = A + B;
      if(B %2 == 1){
        B = B - 1;
      }
      B = B / 2;
      A = A + B;
    }
    if(A %2 == 1){
      A = A - 1;
    }
    A = A/2;
    B = A + B;
  }
  cout << A << " " << B << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

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

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n+1;

  while( head != tail){
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if (u.t > 0)enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }


  }

  
  return 0;
}



Measured memory_bytes: 11852
N = int(input())
A = list(map(int,input().split()))

MIN,MAX = 10**7,-10**7
ans = []
for i in range(N):
    if MIN > A[i]:
        MIN =A[i]
        min_i = i
    if MAX < A[i]:
        MAX = A[i]
        max_i = i

if abs(MIN) <= abs(MAX):
    for i in range(N):
        if A[i] < 0:
            A[i] += MAX
            ans.append([max_i+1,i+1])
    # print(A)

    for i in range(N-1):
        if A[i] > A[i+1]:
            A[i+1] += A[i]
            ans.append([i+1,i+2])

else:
    for i in range(N):
        if A[i] > 0:
            A[i] += MIN
            ans.append([min_i+1,i+1])
    # print(A)

    for i in range(N-1,0,-1):
        if A[i] < A[i-1]:
            A[i-1] += A[i]
            ans.append([i+1,i])
print(len(ans))
for a in ans:
    print(*a)






Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
ll D;
ll c[26];
ll s[366][26];
ll t[366];

//スコア計算
ll score(ll days){
	ll ans=0;
	ll last[26];
	rep(i,26)last[i]=0;
	for(ll d=1;d<=days;d++){
		ans+=s[d][t[d]];
		last[t[d]]=d;
		rep(i,26){
			ans-=c[i]*(d-last[i]);
		}
	}
	return ans;
}

ll whole_score;
ll score_typ[26];
void recalc(ll i){
	ll ans=0;
	ll last=0;
	for(ll d=1;d<=D;d++){
		if(t[d]==i){
			ans+=s[d][i];
			last=d;
		}
		ans-=c[i]*(d-last);
	}
	whole_score-=score_typ[i];
	score_typ[i]=ans;
	whole_score+=score_typ[i];
}
void init_score(){
	whole_score=0;
	rep(i,26){
		score_typ[i]=0;
		recalc(i);
	}
}

//貪欲法
void greedy(){
	for(ll d=1;d<=D;d++){
		ll ma=-1e17,pt=0;
		rep(i,26){
			t[d]=i;
			ll res=score(d);
			if(ma<res){
				ma=res;
				pt=i;
			}
		}
		t[d]=pt;
	}
}

//局所探索を焼き鈍しに変更
void local_search(){
	for(ll u=100000;u>=0;u--){
		ll d=rand()%D+1;
		ll q=rand()%26;
		ll b=t[d];
		ll bef_score=whole_score;
		t[d]=q;
		recalc(b);
		recalc(q);
		ll aft_score=whole_score;
		if(bef_score>aft_score+u){
			t[d]=b;
		}
		recalc(b);
		recalc(q);
	}
}


int main(){
	cin>>D;
	rep(i,26)cin>>c[i];
	for(ll d=1;d<=D;d++)rep(j,26)cin>>s[d][j];
	greedy();
	init_score();
	local_search();
	for(ll d=1;d<=D;d++){
		cout<<t[d]+1<<"\n";
	}
}


Measured memory_bytes: 3696
N = int(input())
input_list = list(map(int, input().split()))
pair_list = []
def triangle_check(a,b,c):
    return all([a+b>c, b+c>a, c+a>b, a!=b, b!=c,c!=a])

if N < 3:
    print(0)
else:
    for i in range(N):
        for j in range(i+1,N):
            for k in range(j+1,N):
                if triangle_check(input_list[i],input_list[j],input_list[k]):
                    pair_list.append([input_list[i],input_list[j],input_list[k]])
    print(len(pair_list))

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

int main() {
  int a, b;
  cin >> a >> b ;
  cout << (a+b+2-1)/2 << endl;
  
/*
整数型の割り算の計算結果は使用する言語によって異なりますが，多くの言語では切り捨てです．
a÷bの計算結果を切り上げする場合には(a+b-1)/bと書くと計算結果が切り上げになります．

a = x+y
b = 2
(a+b+2-1)/2
*/
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
using namespace std;
int v[10000];
bool check(int x)
{
    while(x)
    {
        if(v[x%10]==1)
        {
            return false;
        }
        x/=10;
        }
        return true;
}
int main()
{
    int x;
    int n,k;
    cin>>n>>k;
    memset(v,0,sizeof(v));
    for(int i=0;i<k;i++)
    {
        cin>>x;
        v[x]=1;
    }
    for(int i=n;;i++)
    {
        if(check(i))
        {
               cout<<i<<endl;
               break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <utility>
#define ff first
#define ss second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF=1e9+250;
LL mod=1e9+7;
const int N=100005;


LL fac[200005];
LL ie[200005],inv[200005];
void inv_init(int n){
    inv[1]=1;
    for(int i=2;i<=n;i++){
        inv[i]=(mod-mod/i)*inv[mod%i]%mod;
    }
}
void com_init(int n){
    inv_init(n);
    ie[0]=fac[0]=1;
    for(int i=1;i<=n;i++){
        fac[i]=fac[i-1]*i%mod;
        ie[i]=ie[i-1]*inv[i]%mod;
    }
}
LL com(int n,int m){//计算C(n,m) n个元素中选m 
    return  fac[n]*ie[n-m]%mod*ie[m]%mod;
}
int main(){
    com_init(200000);
	int h,w,x,y;
	cin>>h>>w>>x>>y;
	
	int xx=h-x;
	LL ans=0;
    for(int i=y+1;i<=w;i++){
        ans=(ans+com(xx+i-2,i-1)*com(h+w-(xx+1)-i,w-i))%mod;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>
#include <cctype>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
  int N;
  cin>>N;
  int cou=0;
  for(int n=1;n<=N;n++){
    for(int x=1;x<n;x++){
      if(n<x*x)
        break;
      for(int y=1;y<n-x;y++){
        if(n<x*x + y*y + x*y||n<x*x)
          break;
        for(int z=1;z<n-x-y;z++){
          if(x*x + y*y + z*z + x*y + y*z + z*x>n||n<x*x||n<x*x + y*y + x*y){
            break;
          }
          if(x*x + y*y + z*z + x*y + y*z + z*x==n){
            cou++;
          }
        }
      }
    }
    cout<<cou<<endl;
    cou=0;
  }
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt(), b = scan.nextInt(), c = scan.nextInt();

        String ans = a < b && b < c ? "Yes" : "No";

        System.out.println(ans);
    }
}

Measured memory_bytes: 26180
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#define MAX_N  ((1 << 18) - 1)
#define MAX_L  100000

#define min(a, b)  ((a) < (b) ? (a) : (b))
#define max(a, b)  ((a) > (b) ? (a) : (b))

int n;
int val[MAX_N], wgt[MAX_N];

int dpn;

typedef struct wgtval {
  int wgt, val;
} wgtval;

struct wgtval_list {
  int size;
  wgtval *list;
} dp[MAX_N];

#define set_wgtval(wv, w, v)  ((wv).wgt = (w), (wv).val = (v))

int compare_wgt(const void *a, const void *b)
{
  const wgtval *p = a;
  const wgtval *q = b;
  if (p->wgt == q->wgt) {
    return p->val < q->val ? -1 :
           p->val > q->val ?  1 : 0;
  }
  return p->wgt < q->wgt ? -1 : 1;
}

void compute_dp()
{
  int u;

  /* initialize */
  dpn = min(n, 1 << 12);
  dp[0].size = 2;
  dp[0].list = malloc(2 * sizeof(wgtval));
  set_wgtval(dp[0].list[0], 0, 0);
  set_wgtval(dp[0].list[1], wgt[0], val[0]);

  /* compute the dp table */
  for (u = 1; u < dpn; u++) {
    int parent = (u - 1) / 2;
    int tail, i;

    dp[u].size = dp[parent].size * 2;
    dp[u].list = malloc(dp[u].size * sizeof(wgtval));
    for (i = 0; i < dp[parent].size; i++) {
      dp[u].list[i * 2] = dp[parent].list[i];
      set_wgtval(dp[u].list[i * 2 + 1],
                 dp[parent].list[i].wgt + wgt[u],
                 dp[parent].list[i].val + val[u]);
    }
    qsort(dp[u].list, dp[u].size, sizeof(wgtval), compare_wgt);

    /* remove unnecessary entries */
    tail = 0;
    for (i = 1; i < dp[u].size; i++) {
      if (dp[u].list[i].wgt > MAX_L) {
        break;
      }
      if (dp[u].list[tail].wgt == dp[u].list[i].wgt) {
        dp[u].list[tail] = dp[u].list[i];
      } else if (dp[u].list[tail].val < dp[u].list[i].val) {
        tail++;
        dp[u].list[tail] = dp[u].list[i];
      }
    }
    dp[u].size = tail + 1;
  }
}

int bsearch_right(wgtval *list, int size, int target)
{
  int lo = 0;
  int hi = size;
  while (lo < hi) {
    int mid = (lo + hi) / 2;
    if (target < list[mid].wgt) {
      hi = mid;
    } else {
      lo = mid + 1;
    }
  }
  return lo;
}

int solve(int u, int l)
{
  int parent;
  int s;

  if (u < dpn) {
    int x = bsearch_right(dp[u].list, dp[u].size, l) - 1;
    return dp[u].list[x].val;
  }

  parent = (u - 1) / 2;
  s = solve(parent, l);
  if (l >= wgt[u]) {
    int t = val[u] + solve(parent, l - wgt[u]);
    s = max(s, t);
  }
  return s;
}

int main()
{
  int i, q;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &val[i], &wgt[i]);
  }

  compute_dp();

  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    int u, l;
    scanf("%d%d", &u, &l);
    printf("%d\n", solve(u - 1, l));
  }

  return 0;
}


Measured memory_bytes: 82068
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n;cin>>n;
	int c[4]={};
	fori(n){
		string s;cin>>s;
		if(s=="AC"){
			++c[0];
		}
		if(s=="WA"){
			++c[1];
		}
		if(s=="TLE"){
			++c[2];
		}
		if(s=="RE"){
			++c[3];
		}
	}
	cout
	<<"AC x "<<c[0]<<"\n"
	<<"WA x "<<c[1]<<"\n"
	<<"TLE x "<<c[2]<<"\nRE x "<<c[3];
}

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

vector<vector<int>> G;
vector<int> A;
vector<int> B;

void dfs(int t, vector<int> &V, int cnt) {
    V[t] = cnt;
    for (auto e : G[t]) {
        if (V[e] != -1) continue;
        dfs(e, V, cnt + 1);
    }
}

int main() {
    int N, u, v;
    cin >> N >> u >> v;
    --u;
    --v;
    G.resize(N);
    A.resize(N, -1);
    B.resize(N, -1);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(u, A, 0);
    dfs(v, B, 0);


    int ans    = 0;
    rep(i, N) {
        if (B[i] > A[i]) ans = max(ans,B[i]);
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
	if(b&1)
		r=(r*a)%m;
	b=b/2;
	a=(a*a)%m;
	}
	return r%m;
}



int main() {
    ll a,b; cin>>a>>b;
    if(2*b-a>=0)cout<<0<<endl;
    else cout<<a-2*b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <bitset>
#include <utility>
#include <sstream>
#include <fstream>
#include <stack>
#include <cstdlib>
#include <complex>
#include <set>

using namespace std;

#define INF 1070000000LL
#define pb push_back
#define irep(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) irep(i,0,n)

typedef long long lint;
typedef pair<int, int> pint;
struct Edge{
    int to,weight;
};
typedef vector<vector<Edge> > Graph;


int main(){
    int n;
    string s;
    cin >> n >> s;
    int count = 0;
    rep(i,n)if(s[i] == '#')++count;
    int mini = n-count;
    int temp = mini;
    rep(i,n){
	if(s[i] == '#'){
	    ++temp;
	    mini = min(mini, temp);
	}
	else{
	    --temp;
	    mini = min(mini, temp);
	}
    }
    cout << mini << endl;
}


Measured memory_bytes: 832
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main(){
    char c, S[101], T[101];
    bool ans = false;
    int l;

    scanf("%s", S);
    scanf("%s", T);

    l = strlen(S);

    for(int i=0; i<l; i++){
        if(strcmp(S, T) == 0){
            ans = true;
            break;
        }
        c = S[l-1];
        for(int j=l-2; j>=0; j--){
            S[j+1] = S[j];

        }
        S[0] = c;
    }
    if(ans){
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)

#define PI 3.1415926535897932385
#define INF 1e18
#define EPS 1e-7
#define MAXN 1000000005
#define MOD 1000000007

void ayn(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

ll gcd(ll a, ll b)
{
    if (a == 0) return b;
    return gcd(b % a, a);
}
ll modpow(ll b, ll e, ll mod=MOD) {
    ll ans=1; for(;e;b=b*b%mod,e/=2) if(e&1) ans=ans*b%mod; return ans; }
ll mulmod(ll a, ll b, ll mod)
{
    ll res = 0;
    a = a % mod;
    while (b > 0)
    {
        if (b % 2 == 1) res = (res + a) % mod;
        a = (a * 2) % mod;
        b /= 2;
    }
    return res % mod;
}
int binCoeff(int n, int k)
{
    int C[n + 1][k + 1]; int i, j;
    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {
            if (j == 0 || j == i) C[i][j] = 1;
            else C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }
    return C[n][k];
}

const int maxn = 100005;
int dfs(ll v, ll ans2, vector<bool>& visited, vector<vector<ll>>& vc){
    visited[v]=true;
    ans2++;
    for(auto z:vc[v])
    {
        if(!visited[z])
        {
           ans2+=dfs(z,0,visited,vc);
        }
    }
    return ans2;
}

ll conv(string n)
{
    string num = n;
    ll dec_value = 0;
    int base = 1;

    int len = num.length();
    for (int i=0; i<len; i++) {
        if (num[i] == '1') dec_value += base;
        base = base * 2;
    }
    return dec_value;
}

int main(){
    fastio;
    ayn();
    ll t; t=1;
    while(t--){
        string s; cin>>s;
        if(s[1]=='B') cout<<"ARC";
        else cout<<"ABC";
    }
    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main(){
	int n,k,i,o,j,m;
	scanf("%d%d",&n,&k);
	m=k;
	for(j=0;j<n;j++){
		scanf("%d%d",&i,&o);
		k+=i-o;
		if(k<0){m=0;break;}
		if(m<k)m=k;
	}
	printf("%d\n",m);
	return 0;
}


Measured memory_bytes: 2052
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N, M, X, Y, x[1000],y[1000];
    cin>>N>>M>>X>>Y;
    for(int i=0;i<N;i++){
        cin>>x[i];
        X=max(X,x[i]);
    }
    for(int i=0;i<M;i++){
        cin>>y[i];
        Y=min(Y,y[i]);
    }
    if(Y>X)cout<<"No War"<<endl;
    else cout<<"War"<<endl;
    return 0;
}

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

int main(){
  string a;
  cin >> a;
  if(a == "SSS") cout << 0 << endl;
  if(a == "SSR") cout << 1 << endl;
  if(a == "SRS") cout << 1 << endl;
  if(a == "RSS") cout << 1 << endl;
  if(a == "SRR") cout << 2 << endl;
  if(a == "RSR") cout << 1 << endl;
  if(a == "RRS") cout << 2 << endl;
  if(a == "RRR") cout << 3 << endl;
return 0;
}


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

int main()
{
	int table[10][10] = { { 0 } };
	int x, y, size;
	while (scanf("%d,%d,%d", &x,&y, &size) != EOF)
	{
		switch (size)
		{
		case 1:
		{
			table[y][x]++;
			if (x - 1 >= 0)table[y][x - 1]++;
			if (x + 1 <= 9)table[y][x + 1]++;
			if (y - 1 >= 0)table[y - 1][x]++;
			if (y + 1 <= 9)table[y + 1][x]++;
		}break;
		case 2:
		{
			table[y][x]++;
			if (x - 1 >= 0)
			{
				table[y][x - 1]++;
				if (y - 1 >= 0)table[y - 1][x - 1]++;
				if (y + 1 <= 9)table[y + 1][x - 1]++;

			}
			if (x + 1 <= 9)
			{
				table[y][x + 1]++;
				if (y - 1 >= 0)table[y - 1][x + 1]++;
				if (y + 1 <= 9)table[y + 1][x + 1]++;
			}
			if (y - 1 >= 0)table[y - 1][x]++;
			if (y + 1 <= 9)table[y + 1][x]++;
		}break;
		default:
		{
			table[y][x]++;
			if (x - 1 >= 0)
			{
				table[y][x - 1]++;
				if (y - 1 >= 0)table[y - 1][x - 1]++;
				if (y + 1 <= 9)table[y + 1][x - 1]++;
				if (x - 2 >= 0)table[y][x - 2]++;
			}
			if (x + 1 <= 9)
			{
				table[y][x + 1]++;
				if (y - 1 >= 0)table[y - 1][x + 1]++;
				if (y + 1 <= 9)table[y + 1][x + 1]++;
				if (x + 2 <= 9)table[y][x + 2]++;
			}
			if (y - 1 >= 0)
			{
				table[y - 1][x]++;
				if (y - 2 >= 0)table[y - 2][x]++;
			}
			if (y + 1 <= 9)
			{
				table[y + 1][x]++;
				if (y + 2 <= 9)table[y + 2][x]++;
			}
		}break;
		}
	}
	int cnt=0, i, j, max = 0;
	for (j = 0; j < 10; j++)
	{
		for (i = 0; i < 10; i++)
		{
			if (table[j][i] > max)max = table[j][i];
			if (table[j][i] == 0)cnt++;
		}
	}
	printf("%d\n%d\n", cnt, max);
	return 0;
}

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

int main() {
    int N,d,r;
    cin >> N;
    r = N;
    
    rep(i,N+1) {
        int c=0,t=i;

        while(t>0) {
            c += t%6;
            t /= 6;
        }
        t = N-i;
        while(t>0) {
            c += t%9;
            t /= 9;
        }

        r = min(r,c);
    }

    cout << r << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <map>

using namespace std;
using lli = long long int;
using ll = long long;

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

    map<string, int> mp;    //  文字列 → 整数 の連想配列
    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    mp["SAT"] = 1;

    cout << mp[S] << endl;
}


Measured memory_bytes: 256
A,B,C,D = [int(x) for x in input().split()]
def gdc(x,y):
  if x%y == 0:
    return y
  else:
    return gdc(y,x%y)
g = C*D//gdc(D,C)
count= B-A+1-B//C+(A-1)//C-B//D+(A-1)//D+B//g-(A-1)//g
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, k;
    cin >> n >> k;

    vector<long long> vec(n);
    for(long long i = 0; i < n; i ++){
        ll a;
        cin >> a;
        a--;
        vec[i] = a;
    }

    ll count = 1;

    /*
    rep(i,n){
        cout << vec[i] << " ";
    }
    br;
    */
    

    vector<ll> ans;
    ans.push_back(0);
    map<ll,ll> mp;

    ll tmp = 0;
    count = 0;
    mp[0] = 0;
    while(true){
        if(mp.count(vec[tmp]) != 0){
            count++;
            break;
        }else{
            count++;
            tmp = vec[tmp];
            ans.push_back(tmp);
            mp[tmp] = count;
        }
    }

    /*
    rep(i,ans.size()){
        cout << "ans[" << i << "] = " << ans[i] << endl;
    }
    */
    
    //cout << count << endl;
    //cout << mp[vec[tmp]] << endl;

    ll mod = count - mp[vec[tmp]];
    //cout << "mod = " << mod << endl;
    //cout << "count = " << count << endl;
    k -= mp[vec[tmp]];
    if(k < 0){
        k += mp[vec[tmp]];
        cout << ans[k] + 1 << endl;
    }else{
        ll tmp2 = k % mod;
        cout << ans[tmp2 + mp[vec[tmp]]] + 1 << endl;
    }
    
    

}

Measured memory_bytes: 18472
n = int(input())
c=[]
s=[]
f=[]
for i in range(n-1):
    tmp = list(int(i) for i in input().split())
    c.append(tmp[0])
    s.append(tmp[1])
    f.append(tmp[2])

for i in range(n-1):
    time_sum = 0
    for j in range(i,n-1):
        if time_sum < s[j]:
            time_sum = s[j]
        elif time_sum%f[j]!=0:
            time_sum += f[j]-time_sum%f[j]
        time_sum += c[j]
    print(time_sum)
print(0)

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

int main() {
  string S;
  cin >> S;
  int counter = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'o') {
      counter += 100;
    }
  }
  cout << 700 + counter << endl;
}


Measured memory_bytes: 256
L = [
    1,
    1,
    1,
    2,
    1,
    2,
    1,
    5,
    2,
    2,
    1,
    5,
    1,
    2,
    1,
    14,
    1,
    5,
    1,
    5,
    2,
    2,
    1,
    15,
    2,
    2,
    5,
    4,
    1,
    4,
    1,
    51,
]
print(L[int(input()) - 1])



Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;


int main() {

	ll N, M, C;
	cin >> N >> M >> C;

	ll B[100];
	repn(i, M) cin >> B[i];

	ll A[100][100];

	repn(i, N)repn(j, M) cin >> A[i][j];

	ll ans = 0;

	repn(i, N) {
		ll v = 0;
		repn(j, M) v += A[i][j] * B[j];

		if (v > -C) { ans++; }
	}

	cout << ans;


	
	system("PAUSE");
}

Measured memory_bytes: 504
alf = [0]*26

cnt = 0
s = []
while True:
    try:
        s.append(input().lower())
    except EOFError:
        break
    cnt += 1

for i in range(cnt):
    for st in s[i]:
        if ord('a') <= ord(st) and ord(st) <= ord('z'):
            alf[ord(st)-ord('a')] += 1
        

for i in range(26):
    print(chr(i+ord('a')) + " : " + str(alf[i]))


Measured memory_bytes: 5564
#include <iostream>
using namespace std;
int main(){
	int n, k,d,a,ans=0,list[1010];
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			cin >> a;
			list[a] = a;
		}
	}
	for (int i = 1; i <= n; i++)
		if (list[i] != i)
			ans++;
	cout << ans;
}

Measured memory_bytes: 3632
n = int(input())
card = []

for i in range(n):
    x,y,h = [int(i) for i in input().split()]
    card.append([x,y,h])


 
def check(cx,cy):
    needH = -1
    for i in range(n):
        x,y,h = card[i]

        if h>0:
            global H
            H = abs(x-cx)+abs(y-cy)+h
            if needH == -1:
                needH = H
            else:
                if needH != H:
                    return False
    
    for i in range(n):
        x,y,h = card[i]

        if h==0:
            dist = abs(x-cx)+abs(y-cy)
            if H > dist:
                return False
    else:
        return True

    
for i in range(101):
    for j in range(101):
        if check(i,j):

            print("{} {} {}".format(i,j,H))

Measured memory_bytes: 3064
import sys, math, bisect


if(__name__ == "__main__"):
    """
    N = int( input().strip() )
    Length = list( map(int, input().strip().split() ) )
    """
    N = int( input().strip() )
    Length = list( map(int, input().strip().split() ) )
    Length.sort()
    comb = 0
    if(N<3):
        print(0)
    else:
        for i in range(N-1, 1, -1):
            c = Length[i]
            for j in range(i-1, 0, -1):
                b = Length[j]
                if(c>b):
                    for k in range(j-1, -1, -1):
                        if(Length[k] < b and Length[k]+b > c):
                            comb += 1
                            
        print(comb)


Measured memory_bytes: 9220
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first

using namespace std;
typedef long long ll;

typedef pair<int,int> pii;
const int maxn = 5e5 + 10;
int mi[30][30],cnt[30];
int32_t main(){
    ll n,m;
    cin >> n >> m;
    if (n * 2 <= m){
        cout << n + (m - 2 * n) / 4 << endl;
    }else cout << m / 2 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i,n;
  long max=0,min=0,sum=0;
  int num[10000];
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&num[i]);
  }
  min=num[0];
  max=num[0];

  for(i = 0;i < n;i++){
    if(num[i] < min){
      min = num[i];
    }
    else if(num[i] > max){
      max = num[i];
    }
    sum += num[i];
  }

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

  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main()
{
  unsigned int b, n, m;
  fscanf(stdin, "%u", &n);
  m=n;
  int i=0;
  char c;
  char buf[33];
  buf[32]=0;
  char buf2[33];
  buf2[32]=0;
  buf2[31]='0';
  char buf3[33];
  buf3[0]='0';
  for (b = 2147483648U; b>0; b>>=1) {
    printf("%d", n/b);
    buf[i]='0'+1-n/b;
    if(i>0) buf2[i-1]='0' + n/b;
    buf3[i+1]='0' + n/b;
    i++;
    n%=b;
  }
  buf3[32]=0;
  printf("\n");
  puts(buf);
  puts(buf2);
  puts(buf3);

  return 0;
}



Measured memory_bytes: 2104
import scala.io.StdIn.{readLine,readInt}

object Main extends App {

  def exec(w:String):Unit =  {
    val len = w.length

    def shuffle(i:Int, cnt:Int):String =
      if(i == 0) (w drop (cnt%len))+(w take (cnt%len)) else shuffle(i-1, cnt+readInt)

    if(w=="-") return else { println(shuffle(readInt, 0));exec(readLine) }
  }
  exec(readLine)
}

Measured memory_bytes: 43688
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 2e5 + 5, M = N * 2 , inf = 1e9 + 7;
using namespace std ;

bool vis[N] ;
int n, rt, S, e, ter[M], nxt[M], lnk[N], dep[N], fa[N], ans ;
struct edge {
	int x, y ;
} ed[N] ;

void add(int x, int y) {
	ter[++ e] = y, nxt[e] = lnk[x], lnk[x] = e ;
}

void dfs(int p, int las) {
	for (int i = lnk[p] ; i; i = nxt[i]) if (ter[i] != las) {
		dep[ter[i]] = dep[p] + 1 ;
		fa[ter[i]] = p ;
		dfs(ter[i], p) ;
	}
}

void dfs2(int p, int las, int len) {
	if (ans == inf) return ;
	if (dep[p] < len) return ;
	if (dep[p] == len) {
		ans = max(ans, len * 2) ;
		return ;
	}
	if (vis[p]) {
		ans = inf ;
		return ;
	}
	for (int i = lnk[p] ; i; i = nxt[i]) if (ter[i] != las) dfs2(ter[i], p, len + 1) ;
	ans = max(ans, dep[p] * 2) ;
}

bool chk(int x, int y) {
	if (dep[x] < dep[y]) swap(x, y) ;
	if (fa[x] == y) return false ;
	if (fa[fa[x]] == y) return false ;
	if (fa[x] == fa[y]) return false ;
	return true ;
}

int main() {
	scanf("%d%d%d", &n, &S, &rt) ;
	rep(i, 1, n - 1) scanf("%d%d", &ed[i].x, &ed[i].y) ;
	int x, y ;
	rep(i, 1, n - 1) {
		scanf("%d%d", &x, &y) ;
		add(x, y), add(y, x) ;
	}
	dfs(rt, 0) ;
	rep(i, 1, n - 1) if (chk(ed[i].x, ed[i].y)) vis[ed[i].x] = vis[ed[i].y] = true ;
	rep(i, 1, n) lnk[i] = 0 ;
	rep(i, 1, e) nxt[i] = 0 ; e = 0 ;
	rep(i, 1, n - 1) add(ed[i].x, ed[i].y), add(ed[i].y, ed[i].x) ;
	dfs2(S, 0, 0) ;
	if (ans == inf) {
		printf("-1\n") ;
	} else printf("%d\n", ans) ;
	return 0 ; 
}

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

using namespace std;
typedef long long ll;
typedef pair <int,int> pa;
const int N = 2e5+100;
int n, c;
int p[N];
int ans;
struct node
{
    int l, r, c;
    bool operator <(const node &x) const {
            if(c == x.c) return l<x.l;
            return c<x.c;
    }
}a[N];
void solve()
{
    cin >> n >> c;
    for(int i = 1; i <= n; i++){
        cin>> a[i].l >> a[i].r >> a[i].c;

    }
   // vector <pa> ve;
   sort(a+1,a+1+n);
    for(int i=1;i<=n;i++){
            int l=a[i].l, r=a[i].r;
        while(a[i].c==a[i+1].c && r==a[i+1].l){
            r=a[i+1].r;
            i++;
        }

        //ve.push_back(make_pair(l-1,r));
        p[l-1]++;
        p[r]--;
    }
   /* for(auto v:ve){
        p[v.first]++;
        p[v.second]--;
    }*/
    ans=p[0];
    for(int i=1;i<=1e5+100;i++) {
        p[i]+=p[i-1];
        ans=max(p[i],ans);
    }
    cout<<ans<<endl;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    solve();
    return 0;
}


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

int n, y;

int main()
{
    int i, j, k;

    cin >> n >> y;

    for(i=0; i<=2000; i++)
        for(j=0; j<=2000-i; j++)
            for(k=0; k<=2000-i-j; k++)
                if(i*10000+j*5000+k*1000==y && i+j+k==n)
                {
                    cout << i << " " << j << " " << k;
                    return 0;
                }

    cout << "-1 -1 -1";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int W;
	int H;
	int x;
	int y;
	int r;
	
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if((x+r<=W)&&(y+r<=H)&&(x-r>=0)&&(y-r>=0)&&(x>0)&&(y>0)){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
#!/usr/bin/env python3

import sys

n = int(input())

if n == 3:
    print("2 5 63"); sys.exit(0)

eight = [2, 3, 4, 6, 8, 9, 10, 12]
ct = [[],
      [6],
      [2, 4],
      [2, 4, 6],
      [2, 3, 4, 9],
      [2, 3, 4, 6, 9],
      [2, 3, 4, 8, 9, 10],
      [2, 3, 4, 6, 8, 9, 10]]

twelves = n // 8
mod = n % 8
res = []
for i in range(twelves):
    for j in range(8):
        res.append(i * 12 + eight[j])
for c in ct[mod]:
    res.append(twelves * 12 + c)

for i, r in enumerate(res):
    if i > 0:
        print(" ", end="")
    print(r, end="")



Measured memory_bytes: 4548
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    vector<pair<int, int>> a;
    vector<pair<int, int>> b;
    REP(i, n)
    {
        int x, y;
        cin >> x >> y;
        a.push_back(make_pair(x, y));
    }
    REP(i, n)
    {
        int x, y;
        cin >> x >> y;
        b.push_back(make_pair(x, y));
    }

    sort(b.begin(), b.end());
    int pairs = 0;
    REP(i, n)
    {
        int maxy = -1, pos = -1;
        REP(j, n)
        {
            if (b[i].first > a[j].first && b[i].second > a[j].second)
            {
                if (maxy < a[j].second)
                {
                    maxy = a[j].second;
                    pos = j;
                }
            }
        }
        if (pos >= 0)
        {
            a[pos].first = 1000;
            a[pos].second = 1000;
            pairs++;
        }
    }
    cout << pairs << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,l;
  cin >> n >> l;
  vector<string> s(n);
  rep(i,n){
    cin >> s[i];
  }
  sort(s.begin(),s.end());
  string ans = "";
  rep(i,n){
    ans+=s[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int a,b;cin>>a>>b;
  if(a%2==1 && b%2==1){
    P("Yes");
  }else{
    P("No");
  }
  return 0;
}


Measured memory_bytes: 892
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int ll

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 2e5 + 20 ;
int n , a[N] , l[N] , r[N] , ans ;

int sec[N] , sz ;

int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

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

	sz = 0 ;
	sec[sz ++] = -1 ;
	for (int i = 0 ; i < n ; i ++) {
		while (~sec[sz - 1] && a[sec[sz - 1]] > a[i]) sz -- ;
		l[i] = sec[sz - 1] ;
		sec[sz ++] = i ;
	}

	sz = 0 ;
	sec[sz ++] = n ;
	for (int i = n - 1 ; ~i ; i --) {
		while (sec[sz - 1] != n && a[sec[sz - 1]] >= a[i]) sz -- ;
		r[i] = sec[sz - 1] ;
		sec[sz ++] = i ;
	}

	for (int i = 0 ; i < n ; i ++) ans += 1ll * (r[i] - i) * (i - l[i]) * a[i] ;

	cout << ans << '\n' ;
}


Measured memory_bytes: 6528
def keta(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n = int(n / 10)
    return sum

N,A,B = map(int, input().split())
total = 0
for i in range(1,N+1):
    sum = keta(i)
    if (sum >= A) and (sum <= B):
        total += i
print(total)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <iomanip>
#include <functional>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

template<class T>
void VPout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n';
    }
    cout<<"end\n"<<endl;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));

ll dp[210000][5];


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); 
    cout<<fixed<<setprecision(10);
    
    int l;
    cin>>l;
    vector<ll> a(l);
    for(int i=0;i<l;i++){
        cin>>a[i];
    }
    for(int i=0;i<210000;i++){
        for(int j=0;j<5;j++) dp[i][j]=INF;
    }
    dp[0][0]=0;
    dp[0][1]=0;
    dp[0][2]=0;
    dp[0][3]=0;
    dp[0][4]=0;
    for(int i=0;i<l;i++){
        for(int j=0;j<=4;j++){
            if(dp[i][j]==INF) continue;
            ll next=dp[i][j];
            if(j==0){
                next+=a[i];
            }else if(j==1){
                if(a[i]!=0) next+=a[i]%2;
                else next+=2;
            }else if(j==2){
                next+=(a[i]+1)%2;
            }else if(j==3){
                if(a[i]!=0) next+=a[i]%2;
                else next+=2;
            }else{
                next+=a[i];
            }
            for(int k=j;k<=4;k++){
                chmin(dp[i+1][k],next);
            }
        }
    }
    ll ans=INF;
    for(int i=0;i<5;i++){
        chmin(ans,dp[l][i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9984
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

#define REP(i,m,M) for(int i=m; i<M; i++)
#define REPR(i,M,m) for(int i=M; i>m; i—-)
#define REPLL(i,m,M) for(ll i=m; i<M; i++)
#define REPLLR(i,M,m) for(ll i=M; i>m; i—-)
#define ALL(v) v.begin(),v.end()


int main(int argc, const char * argv[]) {

    int N;
    string S;
    cin >> N;
    cin >> S;
    
    int L = (int)S.length();
    int NumE = 0;
    for (int l=0; l<L; ++l) {
        if (S[l] == 'E') NumE++;
    }
    
    int Tmp = NumE;
    if (S[0] == 'E') Tmp--;
    int Res = Tmp;
    for (int l=1; l<L; ++l) {
        if(S[l-1] == 'W') Tmp++;
        if(S[l] == 'E') Tmp--;
        if(Tmp < Res) Res = Tmp;
    }
    
    cout << Res << endl;

    return 0;
}


Measured memory_bytes: 900