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

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    if(B >= C) {
        cout << C+B << endl;
    }
    else {
        if(A+B >= C-1) {
            cout << C+B << endl;
        }
        else {
            cout << A+B+B+1 << endl;
        }
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	while ( stdin.hasNextInt() ) {

	    final int n = stdin.nextInt();
	    int[] array = new int[ n ];
	    for ( int i = 0; i < n; i++ ){
		array[ i ] = stdin.nextInt();
	    }
	    Arrays.sort( array );
	    int sum = 0;
	    int cum = 0;
	    for ( int i = 0; i < n; i++ ) {
		cum += array[ i ];
		sum += cum;
	    }
	    System.out.println( sum );
	}	
    }    
}

Measured memory_bytes: 27412
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(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 ull unsigned long long int
#define ll long long int
#define pb push_back
 
#define PI 3.1415926535897932385
#define INF 1e18
#define EPS 1e-7
#define MOD 1000000007 
                                 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}

 
int main() {
    
    fastio;
    int n;
    cin >> n;
    vector<ll> d, d2;
    rep(i, n)
    {
        ll x, y;
        cin >> x >> y;
        d.pb(x+y);
        d2.pb(x-y);
    }
    sort(d.begin(), d.end());
    sort(d2.begin(), d2.end());
    ll ans = d[n-1] - d[0];
    ans = max(ans, d2[n-1] - d2[0]);
    cout << ans;
    
 
    return 0; 
}

Measured memory_bytes: 6696
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
   vector<string> a(H);
  for(int i=0;i<H;i++){
    cin>>a[i];
    cout<<a[i]<<endl;
    cout<<a[i]<<endl;
  }
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, K, S;
    scan(N, K, S);
    if (N == K)
    {
        repeat(S).take(N).map!text().join(' ').writeln();
        return;
    }
    if (S == 10 ^^ 9)
    {

        repeat(S).take(K).map!text().join(' ').write();
        write(" ");
        repeat(S - 1).take(N - K).map!text().join(' ').write();
        return;
    }
    if (K == 0)
    {
        repeat(S + 1).take(N).map!text().join(' ').writeln();
        return;
    }
    repeat(S).take(K).map!text().join(' ').write();
    write(" ");
    repeat(S + 1).take(N - K).map!text().join(' ').write();
}


Measured memory_bytes: 5116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const int INF = INT_MAX / 2;

int main(){
    int N; cin >> N;
    int prev; cin >> prev;
    int cnt = prev;
    for (int i = 1; i < N; i++)
    {
        int h; cin >> h;
        if(h>prev) cnt += h-prev;
        prev = h;
    }
    cout << cnt << endl;    
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

INF = 10**10
M = 4*10**5 + 10

N = int(input())
PUs = [[] for _ in range(M)]
PRs = [[] for _ in range(M)]
PDs = [[] for _ in range(M)]
PLs = [[] for _ in range(M)]
nUs = [[] for _ in range(M)]
nRs = [[] for _ in range(M)]
nDs = [[] for _ in range(M)]
nLs = [[] for _ in range(M)]
xUs = [[] for _ in range(M)]
xDs = [[] for _ in range(M)]
yLs = [[] for _ in range(M)]
yRs = [[] for _ in range(M)]

for _ in range(N):
    X, Y, U = input().split()
    X, Y = int(X), int(Y)
    if U == 'L':
        PLs[X+Y].append((X, U))
        nLs[X-Y].append((X, U))
        yLs[Y].append((X, U))
    elif U == 'R':
        PRs[X+Y].append((X, U))
        nRs[X-Y].append((X, U))
        yRs[Y].append((X, U))
    elif U == 'U':
        PUs[X+Y].append((X, U))
        nUs[X-Y].append((X, U))
        xUs[X].append((Y, U))
    else:  # U == 'D'
        PDs[X+Y].append((X, U))
        nDs[X-Y].append((X, U))
        xDs[X].append((Y, U))

def func(P1s, P2s, dir1, dir2):
    dist = INF
    for z in range(M):
        Ps = sorted(P1s[z] + P2s[z])
        for i in range(len(Ps)-1):
            if Ps[i][1] == dir1 and Ps[i+1][1] == dir2:
                d = Ps[i+1][0] - Ps[i][0]
                if d < dist:
                    dist = d
    return dist

ans = INF
dists = []
dists += [func(PRs, PUs, 'R', 'U') * 2]
dists += [func(PDs, PLs, 'D', 'L') * 2]
dists += [func(nRs, nDs, 'R', 'D') * 2]
dists += [func(nUs, nLs, 'U', 'L') * 2]
dists += [func(yRs, yLs, 'R', 'L')]
dists += [func(xUs, xDs, 'U', 'D')]

ans = min(dists)
if ans == INF:
    print('SAFE')
else:
    print(ans*5)


Measured memory_bytes: 308604
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define F first
#define S second
#define pi 6.28318530717958623200
using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;

int main()
{

    float r;
    cin>>r;
    float res=(r)*pi;
    printf("%.4f\n",res);

    return 0;
}


Measured memory_bytes: 3788
n = int(input())

T = 0
X = 0
Y = 0
for i in range(n):
  t, x, y = map(int, input().split())
  dt = t - T
  dist = abs(X - x) + abs(Y - y)
  if dt < dist:
    print("No")
    exit()
  
  if dt % 2 == 0:
    if dist % 2 != 0:
      print("No")
      exit()
  else:
    if dist % 2 == 0:
      print("No")
      exit()

print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long int ll;
#define REP(i, I, N) for (ll i = I; i < N; ++i)
#define rep(i, N) REP(i, 0, N)

int main() {
    ll n, m, l, r;
    cin >> n >> m;
    ll ans = 0;
    ll mn = 100001, mx = -100001;
    vector<ll> lm(m), rm(m);
    rep(i, m) {
        cin >> l >> r;
        mx = max(l, mx);
        mn = min(r, mn);
    }

    REP(i, 1, n + 1) {
        if (mx <= i && i <= mn) {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

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

N, W = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(N)]

INFTY = -1
MAX_V = 10**5
dp = [[INFTY]*(MAX_V+1) for _ in range(N)]
dp[0][S[0][1]] = S[0][0]

for i in range(1, N):
    w, v = S[i]
    for j in range(v):
        dp[i][j] = dp[i-1][j]

    if dp[i-1][v] == -1:
        dp[i][v] = w
    else:
        dp[i][v] = min(dp[i-1][v], w)

    for j in range(v+1, MAX_V+1):
        if dp[i-1][j] == -1 and dp[i-1][j-v] == -1:
            continue
        elif dp[i-1][j] == -1:
            if dp[i-1][j-v]+w > W:
                continue
            else:
                dp[i][j] = dp[i-1][j-v]+w
        elif dp[i-1][j-v] == -1:
            dp[i][j] = dp[i-1][j]
        else:
            if dp[i-1][j-v]+w > W:
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v]+w)

for i in range(MAX_V, 0, -1):
    if dp[N-1][i] != -1:
        print(i)
        break


Measured memory_bytes: 121708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
inline constexpr ll Inf = (1ULL << 62) -1;

class unionfind {
    std::vector<int> parents;
    std::vector<int> sizes;
    public:
        unionfind(int n) : parents(n), sizes(n, 1) { iota(begin(parents), end(parents), 0); }
        int root(int x) { if (parents[x] == x) return x; else return parents[x] = root(parents[x]); }
        bool is_same(int x, int y) { return root(x) == root(y); }
        int size(int x) { return sizes[x]; }
        void unite(int x, int y) {
            int rx = root(x);
            int ry = root(y);
            if (rx == ry)
                return;
            parents[rx] = ry;
            sizes[ry] += sizes[rx];
            sizes[rx] = 0;
        }
};

int main() {
    ll N, M;
    cin >> N >> M;
    unionfind uf(N);
    rep(i,M) {
        ll a,b;
        cin >> a >> b;
        uf.unite(a-1,b-1);
    }
    int ans = 0;
    rep(i,N) {
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
}


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

int main(void){
    int a = 0, b = 0, c = 0; 

    scanf("%d%d%d", &a, &b, &c);

    if(a + b >= c){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;

} 


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n,q,l,r;
  char s[100000];
  int count,flag=0;
  int pos[100001];
  scanf("%d %d\n",&n,&q);
  scanf("%s\n",s);
  for(int j=0;j<n;j++){
    if(s[j]=='A') flag=1;
    else if(s[j]=='C'&&flag==1){
      count++;
      flag=0;
    }else flag=0;
    pos[j+1]=count;
  }
  for(int i=0;i<q;i++){
    scanf("%d %d\n",&l,&r);
    count=pos[r]-pos[l];
    printf("%d\n",count);
  }
  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100005;

struct node{
	int a,b;
	bool operator <(const node &u)const{
		return a<u.a;
	}
}p[N];

int n,L[N],R[N],mlen,ans,l=0,r=1e9+2,mn,m;

inline void solve(){
	for(int i=1;i<=n;i++)
	    p[i].a=max(0,R[i]-l),p[i].b=max(0,r-L[i]);
	sort(p+1,p+n+1);
	
	mn=p[1].b;
	for(int i=2;i<=n;i++) ans=max(ans,mn+p[i].a),mn=min(mn,p[i].b);
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) 
	    scanf("%d%d",L+i,R+i),R[i]++,mlen=max(mlen,R[i]-L[i]),l=max(l,L[i]),r=min(r,R[i]);
	ans=max(0,r-l)+mlen;
	solve();
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],vis[5001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
    ll ans=1;
    for(int i=1; i<=n; i++)
        ans*=a;
    return ans;
}

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

   ll d;
   cin>>d;
   if(d==1)
   {
       cout<<0<<endl;
   }
   else
   {
       cout<<1<<endl;
   }

    return 0;
}


Measured memory_bytes: 3612
# import itertools
# import math
# import sys
# import numpy as np

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# X, N = map(int, input().split())
# P = list(map(int, input().split()))
# Q = list(map(int, input().split()))
# S = input()

# d = sorted(d.items(), key=lambda x:x[0]) # keyでsort
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement([i for i in range(1, M + 1)], N))
# print(a[0][0])
# print(conditions[0])

abcs = "abcdefghijklmnopqrstuvwxyz"
ans = ""
while(N > 0):
    # if N == 26:
    #     ans += "z"
    #     break
    N -= 1
    _ = N % 26
    # print(N % 26)
    N //= 26
    # print(N)
    ans += abcs[_]
    # print()

print(ans[::-1])


Measured memory_bytes: 9152
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

ll x1,x2,x3,x4,x5;
ll solve(){
   ll ans=0;
   

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

    cin>>x1>>x2>>x3>>x4>>x5;
    if(x1==0){
        cout<<1<<endl;
        return 0;
    }
        if(x2==0){
        cout<<2<<endl;
        return 0;
    }
        if(x3==0){
        cout<<3<<endl;
        return 0;
    }
        if(x4==0){
        cout<<4<<endl;
        return 0;
    }
        if(x5==0){
        cout<<5<<endl;
        return 0;
    }
    //cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 3612
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int man = 2e5+10;
#define IOS ios::sync_with_stdio(0)
template <typename T>
inline T read(){T sum=0,fl=1;int ch=getchar();
for(;!isdigit(ch);ch=getchar())if(ch=='-')fl=-1;
for(;isdigit(ch);ch=getchar())sum=sum*10+ch-'0';
return sum*fl;}
template <typename T>
inline void write(T x) {static int sta[35];int top=0;
do{sta[top++]= x % 10, x /= 10;}while(x);
while (top) putchar(sta[--top] + 48);}
template<typename T>T gcd(T a, T b) {return b==0?a:gcd(b, a%b);}
template<typename T>T exgcd(T a,T b,T &g,T &x,T &y){if(!b){g = a,x = 1,y = 0;}
else {exgcd(b,a%b,g,y,x);y -= x*(a/b);}}
#ifndef ONLINE_JUDGE
#define debug(fmt, ...) {printf("debug ");printf(fmt,##__VA_ARGS__);puts("");}
#else
#define debug(fmt, ...)
#endif
typedef long long ll;
#define int long long
const ll mod = 1e9+7;
vector<int>a1,a2,a3;
int n;
ll k;

bool check1(ll mid){
    ll sum = 0;
    for(int i = 0,j = 0;i < a1.size();i++){
        while(j<a2.size()&&1ll*a1[i]*a2[j]>mid)j++;
        if(j<a2.size()&&1ll*a1[i]*a2[j]<=mid)sum += a2.size() - j;
    }
    return sum >= k;
}

bool check2(ll mid){
    //x*x
    ll sum = 0;
    for(int i = 0,j = a2.size() - 1;i < a2.size();i++){
        if(1ll*a2[i]*a2[i]<=mid)sum--;
        while(j>=0&&1ll*a2[i]*a2[j]>mid)j--;
        if(j>=i&&1ll*a2[i]*a2[j]<=mid)sum += j - i + 1;
    }
    for(int i = a1.size()-1,j = 0;i >= 0;i--){
        if(1ll*a1[i]*a1[i]<=mid)sum--;
        while(j<a1.size()&&1ll*a1[i]*a1[j]>mid)j++;
        if(j<=i&&1ll*a1[i]*a1[j]<=mid)sum += i - j + 1;
    }
    //cout<< sum << endl;
    return sum >= k;
}

signed main() {
    #ifndef ONLINE_JUDGE
        //freopen("in.txt", "r", stdin);
        //freopen("out.txt","w",stdout);
    #endif
    cin >> n >> k;
    for(int i = 1;i <= n;i++){
        int x;cin >> x;
        if(x<0)a1.push_back(x);
        else if(x>0)a2.push_back(x);
        else a3.push_back(x);
    }
    sort(a1.begin(),a1.end());
    sort(a2.begin(),a2.end());
    ll x = a1.size(),y = a2.size(),z = a3.size();
    //cout << x << ' ' << y << ' ' << z << endl;
    if(x*y>=k){
        ll l = -1e18,r = -1,ans = 0;
        while(l<=r){
            ll mid = (l + r) >> 1;
            if(check1(mid))r = mid - 1,ans = mid;
            else l = mid + 1;
        }
        cout << ans << endl;
    }else if(x*y + x*z + y*z + z*(z-1)/2 >= k){
        cout << 0 << endl;
    }else{
        k -= x*y + x*z + y*z + z*(z-1)/2;
        ll l = 1,r = 1e18,ans = 0;
        while(l<=r){
            ll mid = l + r >> 1;
            if(check2(mid))r = mid - 1,ans = mid;
            else l = mid + 1;
        }
        //cout << 11 << endl;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2548
N = int(input())
s=['0','3','5','7']
must = ['3','5','7']
count = 0
for i_9 in range (4):
    for i_8 in range (4):
        for i_7 in range (4):
            for i_6 in range (4):
                for i_5 in range (4):
                    for i_4 in range (4):
                        for i_3 in range (4):
                            for i_2 in range (4):
                                for i_1 in range (4):
                                    num =s[i_9]+s[i_8]+s[i_7]+s[i_6]+s[i_5]+s[i_4]+s[i_3]+s[i_2]+s[i_1]
                                    num = int(''.join(list(map(str,num))))
                                    if (num<=N) & ('0' not in list(str(num))) & ('3' in list(str(num))) & ('5' in list(str(num))) & ('7' in list(str(num))) :
                                        count +=1
                                        
print(count)


Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, m;
	while(cin>>n>>m){
		if(!(n&&m))break;
		long double g[n][n];
		/* dp[a][b]??????a?????????b?????\?????????????????????a?????§????????????????????§??? */
		long double dp[m][n];
		for(int i = 0; i < n; i++){for(int j = 0; j < n; j++){scanf("%Lf", &g[i][j]);}}
		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				dp[i][j] = 0;
			}
		}
		for(int i = 0; i < n; i++) dp[0][i] = 1;

		for(int i = 1; i < m; i++){
			for(int j = 0; j < n; j++){
				for(int k = 0; k < n; k++){
					dp[i][j] = max(dp[i][j], dp[i - 1][k] * g[k][j]);
				}
			}
		}
		long double res = 0;
		for(int i = 0; i < n; i++){
			res = max(res, dp[m - 1][i]);
		}
		printf("%.2Lf\n", res);
	}

	return 0;
}

Measured memory_bytes: 3368
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def mapline(t = int):
    return map(t, sysread().split())
def mapread(t = int):
    return map(t, read().split())

def counts(A):
    L = A.bit_length()
    ans = 0
    for l in range(L):
        if l == 0:
            s = A // 2
            s = s % 2
            if A % 2:
                ans = s ^ 1
            else:
                ans = s
        else:
            if (A >> l) & 1:
                v = A - ((A >> l) << l) + 1
                if v % 2:
                    ans |= 1 << l
    return ans

def run():
    A, B = mapline()
    a = counts(A-1)
    b = counts(B)

    print(a ^ b)
if __name__ == "__main__":
    run()


Measured memory_bytes: 9408
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

void main() {
    int N, K;
    scanf("%d %d\n", &N, &K);
    int[][] X = new int[][10];
    foreach (i; 0 .. N) {
        int c, g;
        scanf("%d %d\n", &c, &g);
        g--;
        X[g] ~= c;
    }
    foreach (i; 0 .. 10) {
        X[i] = X[i].sort!"a > b".array;
    }
    int[][] Y = new int[][10];
    foreach (i; 0 .. 10) {
        Y[i] = new int[X[i].length + 1];
        Y[i][0] = 0;
        foreach (int j; 1 .. cast(int)X[i].length + 1) {
            Y[i][j] = Y[i][j - 1] + X[i][j - 1] + (j - 1) * 2;
        }
    }
    // X.writeln;
    // Y.writeln;
    int cache[10][2000]; memset(cast(void*)cache, -1, cache.sizeof);
    int dfs(int index, int r) {
        //[index, r].writeln;
        if (index == 10) return 0;
        if (cache[index][r] >= 0) return cache[index][r];
        int ret = 0;
        foreach (i; 0 .. min(r, X[index].length) + 1) {
            ret = max(ret, dfs(index + 1, r - i) + Y[index][i]);
        }
        return cache[index][r] = ret;
    }
    dfs(0, K).writeln;
}

Measured memory_bytes: 1176
package main

import (
"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)

	as := scanNums(n)

	answer(m, as)
}

func answer(m int, as *[]int) {
	var sum = sumArray(as)
	var y = 0
	for _, v := range *as {
		if sum <= v*4*m {
			y += 1
			if m <= y {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}

func sumArray(nums *[]int) int {
	res := 0
	for _, v := range *nums {
		res += v
	}
	return res
}

func scanNums(len int) *[]int {
	var num int
	nums := make([]int, len)
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums[i] = num
	}
	return &nums
}

Measured memory_bytes: 512
use std::fmt::Debug;

fn read_line() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("No Line");
    buffer
}
fn read_value<T: std::str::FromStr>() -> T {
    read_line().trim().parse().ok().unwrap()
}
fn read_values<T: std::str::FromStr>() -> Vec<T> {
    read_line().trim().split(' ').map(|x| x.parse().ok().expect("Can't Parse")).collect::<Vec<T>>()
}
fn read_multi_line<T: std::str::FromStr>(count: usize) -> Vec<T> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for i in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(buffer.parse().ok().expect("Can't Parse"));
    }
    vec
}
trait VecWrap<T> {
    type Element;
    fn as_vec(&self) -> &Vec<Self::Element>;
    fn count_if<F: Fn(&Self::Element) -> bool>(&self, predicate: &F) -> usize {
        let mut count = 0;
        for e in self.as_vec() {
            if predicate(e) {
                count += 1;
            }
        }
        count
    }
}
impl <T> VecWrap<T> for Vec<T> {
    type Element = T;
    fn as_vec(&self) -> &Vec<T> {
        self
    }
}
macro_rules! ignore {
    ($id:ident) => {};
}
macro_rules! assign {
    (let $($id:ident),* = $value:expr) => {
        let ($($id), *) = {
            let mut iter = $value.into_iter();
            ($({ignore!($id); iter.next().unwrap()}), *)
        }
    };
}
fn inspect<T: Debug>(vec: &Vec<T>) -> () {
    if let Some(first) = vec.first() {
        println!("Vec({:?}", first);
        for i in 1..vec.len() {
            println!(", {:?}", vec[i]);
        }
        println!(")");
    }else {
        println!("Vec()");
    }
}

fn main() {
    let n = read_value::<usize>();
    let str = read_line().chars().collect::<Vec<_>>();
    let r_count = str.count_if(&|&x| x == 'R') as i64;
    let g_count = str.count_if(&|&x| x == 'G') as i64;
    let b_count = str.count_if(&|&x| x == 'B') as i64;
    let mut result = r_count * g_count * b_count;
    for len in 1 ..= n / 2 {
        for mid in len .. n - len {
            if str[mid] != str[mid - len] && str[mid - len] != str[mid + len] && str[mid] != str[mid + len] {
                result -= 1;
            }
        }
    }
    println!("{}", result);
}


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

int main(){
    int n;
    cin >> n;
    vvi vec(n, vi(3));
    rep(i,n-1)rep(j,3) cin >> vec[i][j];

    rep(i,n){
        int time = 0;
        time += vec[i][1];
        time += vec[i][0];
        REP(j,i+1,n-1){
            //printf("%d ", time);
            if (time < vec[j][1]){
                time = vec[j][1];
                time += vec[j][0];
            }
            else if (time % vec[j][2] == 0){
                time += vec[j][0];
            }
            else {
                time = ((time+vec[j][2]-1)/vec[j][2]) * vec[j][2];
                time += vec[j][0];
            }
        }
        cout << time << endl;
    }

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
  int a[5];
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  
  int min_index = 0;
  int min_number = 9;
  
  for(int i=0; i<5; i++)
  {
    int n = a[i] % 10;
    if(n!=0 && n < min_number)
    {
      min_number = n;
      min_index = i;
    }
  }
  
  int time = 0;
  
  for(int i=0; i<5; i++)
  {
    if(i==min_index) continue;
    
    time += ceil(a[i]/10.0) * 10;
  }
  
  time += a[min_index];
  
  cout << time << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

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

    bool isbroken[n] = {};
    rep(i, m){
        ll a;
        cin >> a;
        a--;
        isbroken[a] = true;
    }

    ll dp[n+1];
    if(isbroken[0])dp[0] = 0;
    else dp[0] = 1;

    if(isbroken[1])dp[1] = 0;
    else dp[1] = dp[0] + 1;

    for(ll i = 2; i < n; ++i){
        if(isbroken[i]){
            dp[i] = 0;
            continue;
        }
        dp[i] = dp[i-1] + dp[i-2];
        dp[i] %= MOD;
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  int N;
  cin >> N;
  vector<int> p(N), q(N);
  for(int i = 0; i < N; i++){
    cin >> p.at(i);
  }
  q = p;
  sort(ALL(q));
  int counter = 0;
  for(int i = 0; i < N; i++){
    if(p.at(i) != q.at(i)) counter++;
  }
  cout << (counter == 2 || counter == 0? "YES": "NO") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int n,a=0,b=0,c=0,ans=0;
    cin>>n;
 
    rep(i,n){
        string s;
        cin>>s;
        int t=s.size()-1;
        if(s[0]=='B')b++;
        if(s[t]=='A')a++;
        if(s[0]=='B'&&s[t]=='A')c++;
 
        rep(j,t){
            if(s[j]=='A'&&s[j+1]=='B')ans++;
        }
    }
 
    if(a==b&&b==c)a--;
    if(a<0)a=0;
    cout<<ans+min(a,b)<<endl;
    
    return 0;
}

Measured memory_bytes: 256
a, b, c, d = list(input())
for i in range(2 ** 3):
    ls = ['+'] * 3
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = '-'
    if eval(a + ls[0] + b + ls[1] + c + ls[2] + d) == 7:
        print(a+ls[0]+b+ls[1]+c+ls[2]+d + '=7')
        break

Measured memory_bytes: 3064
#include<iostream>
#include<numeric>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    
    ll ans=0;
    if(a>k) ans=k;
    else if(a+b>k) ans=a;
    else ans=a-(k-(a+b));
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cassert>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// 0 or 1
bool solve_01(V<int> a) {
    int n = int(a.size());
    //for (int x: a) cerr << x << endl;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if ((i & (n - 1 - i)) == 0) {
            ans ^= a[i];
        }
    }
    return ans;
}

// 02, 1
bool solve_is1(V<int> a) {
    V<int> a2;
    for (int x: a) a2.push_back(x % 2);
    return solve_01(a2);
}

// 0,2
bool solve_is2(V<int> a) {
    V<int> a2;
    for (int x: a) a2.push_back(x / 2);
    return solve_01(a2);
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    V<int> a;
    bool exist1 = false;
    for (char& c : s) {
        a.push_back(c - '1');
        if (a.back() == 1) exist1 = true;
    }

    if (solve_is1(a)) {
        cout << 1 << endl;
        return 0;
    }

    if (exist1) {
        cout << 0 << endl;
    } else {
        if (solve_is2(a)) {
            cout << 2 << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 17172
#include <iostream>
#include <stack>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;



int main(){
    stack<int> S1;
    stack<pair<int,int> > S2;
    char ch;
    int sum=0;
    for(int i=0;cin>>ch;i++){
        if(ch=='\\') S1.push(i);
        else if(ch=='/' && S1.size() >0){
            int j=S1.top();S1.pop();
            sum+= i-j;
            int a=i-j;
            while(S2.size() > 0 && S2.top().first >j){
                a+=S2.top().second; S2.pop();
            }
            S2.push(make_pair(j,a));
        }
        
    }
    vector<int> ans;
    while(S2.size()>0){ans.push_back(S2.top().second);S2.pop();}
    reverse(ans.begin(),ans.end());
    cout<<sum<<endl;
    cout<<ans.size();
    for(int i=0;i<ans.size();i++){
        cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;
return 0;
}


Measured memory_bytes: 3220
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
#define N 100005
#define ll long long
int n,a,b,c,Q,K,cnt,last[N],deep[N],fa[N][18];ll Sum[N][18];
struct road{int to,nex,v;}e[N<<1];
queue<int>q;
void adde(int u,int v,int w) {e[++cnt].to=v,e[cnt].v=w,e[cnt].nex=last[u],last[u]=cnt;}
void bfs()
{
	/*fa[x][0]=fath,deep[x]=deep[fath]+1;
	for(int k=last[x];k;k=e[k].nex)
		if(e[k].to^fath) Sum[e[k].to][0]=e[k].v,dfs(e[k].to,x);*/
	q.push(1);
	while(!q.empty())
	{
		int top=q.front();q.pop();
		for(int k=last[top];k;k=e[k].nex)
			if(!fa[e[k].to][0]&&e[k].to^1)
				fa[e[k].to][0]=top,deep[e[k].to]=deep[top]+1,Sum[e[k].to][0]=e[k].v,q.push(e[k].to);
	}
}
ll solve(int x,int y)
{
	ll res=0;
	if(deep[x]<deep[y]) swap(x,y);
	for(int j=17;~j;j--) if(deep[x]-(1<<j)>=deep[y]) res+=Sum[x][j],x=fa[x][j];
	if(x^y)
	{
		for(int j=17;~j;j--) if(fa[x][j]^fa[y][j])
			res+=Sum[x][j]+Sum[y][j],x=fa[x][j],y=fa[y][j];
		res+=Sum[x][0]+Sum[y][0],x=fa[x][0],y=fa[y][0];
	}
	return res;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++) scanf("%d%d%d",&a,&b,&c),adde(a,b,c),adde(b,a,c);
	bfs();
	for(int j=1;j<18;j++)
		for(int i=1;i<=n;i++)
			fa[i][j]=fa[fa[i][j-1]][j-1],Sum[i][j]=Sum[i][j-1]+Sum[fa[i][j-1]][j-1];
	scanf("%d%d",&Q,&K);
	while(Q--) scanf("%d%d",&a,&b),printf("%lld\n",solve(a,K)+solve(b,K));
	return 0;
}

Measured memory_bytes: 25984
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {

    public static void main(String args[]) throws IOException {
        FastReader in = new FastReader();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        Task.solve(in, out);
        out.close();
    }

    static class Task {

        public static void solve(FastReader in, PrintWriter out) {
            int[] a = new int[3];
            for(int i=0;i<3;i++){
                a[i] = in.nextInt();
            }
            Arrays.sort(a);
            int ans =0;
            ans += a[1]- a[0];
            ans += a[2]- a[1];
            System.out.println(ans);
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21460
import java.util.*;

public class Main{
	
	int [] data, work;
	boolean [] used;
	String ans, op = "+-*";
	int n = 4;
	boolean flg;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			
			data = new int[n];
			int temp = 0;
			for(int i = 0; i < n; i++){
				data[i] = sc.nextInt();
				temp = temp | data[i];
			}
			if(temp == 0)break;
			
			used = new boolean[n];
			ans = null;
			work = new int[n];
			flg = false;
			dfs(0);
			if(! flg) System.out.println(0);
		}
	}

	private void dfs(int deep) {
		if(flg) return;
		if(deep == n){
			check();
			return;
		}
		for(int i = 0; i < 4; i++){
			if(! used[i]){
				used[i] = true;
				work[deep] = data[i];
				dfs(deep + 1);
				used[i] = false;
				work[deep] = -1;
			}
		}
	}

	private void check() {
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				for(int k = 0; k < 3; k++){
					if(flg) return;
					if(calc(calc(calc(work[0], work[1], i), work[2], j), work[3], k) == 10){
						flg = true;
						System.out.printf("((%d %c %d) %c %d) %c %d\n", work[0], op.charAt(i), work[1], op.charAt(j),
								work[2], op.charAt(k), work[3]);
					}
					
					else if(calc(calc(work[0], work[1], i), calc(work[2], work[3], k), j) == 10){
						flg = true;
						System.out.printf("(%d %c %d) %c (%d %c %d)\n", work[0], op.charAt(i), work[1], op.charAt(j),
								work[2], op.charAt(k), work[3]);
					}
					
					else if(calc(calc(work[0], calc(work[1], work[2], j), i), work[3], k) == 10){
						flg = true;
						System.out.printf("(%d %c (%d %c %d)) %c %d\n", work[0], op.charAt(i), work[1], op.charAt(j),
								work[2], op.charAt(k), work[3]);
					}
					
					else if(calc(work[0], calc(calc(work[1], work[2], j), work[3], k), i) == 10){
						flg = true;
						System.out.printf("%d %c ((%d %c %d) %c %d)\n", work[0], op.charAt(i), work[1], op.charAt(j),
								work[2], op.charAt(k), work[3]);
					}
					
					else if(calc(work[0], calc(work[1], calc(work[2], work[3], k), j), i) == 10){
						flg = true;
						System.out.printf("%d %c (%d %c (%d %c %d))\n", work[0], op.charAt(i), work[1], op.charAt(j),
								work[2], op.charAt(k), work[3]);
					}
				}
			}
		}
	}

	private int calc(int a, int b, int c) {
		switch (c) {
		case 0:
			return a + b;
		case 1:
			return a-b;
		case 2:
			return a*b;
		}
		return 0;
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 12000
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int n, m;
	while(scanf("%d%d", &n, &m), n){
		vvi door(n);
		rep(i, m){
			int s, t;
			scanf("%d%d", &s, &t);
			--s;
			--t;
			door[s].push_back(t);
			door[t].push_back(s);
		}
		
		int mask = 0;
		rep(i, n){
			int a;
			scanf("%d", &a);
			mask |= a<<i;
		}
		
		vvi sw(n);
		rep(i, n){
			int k;
			scanf("%d", &k);
			sw[i].assign(k, 0);
			rep(j, k){
				int r;
				scanf("%d", &r);
				sw[i][j] = r - 1;
			}
			sort(sw[i].begin(), sw[i].end());
		}
		
		vector<vector<bool> > visited(1<<n, vector<bool>(n, false));
		vector<vector<pii> > pre(1<<n, vector<pii>(n, pii(-1, 0)));
		queue<pii> Q;
		pii first(mask, 0);
		visited[first.first][first.second] = true;
		Q.push(first);
		while(!Q.empty()){
			pii data = Q.front();
			Q.pop();
			rep(i, door[data.second].size()){
				if(data.first & (1 << door[data.second][i])){
					pii next(data.first, door[data.second][i]);
					if(!visited[next.first][next.second]){
						visited[next.first][next.second] = true;
						pre[next.first][next.second] = data;
						Q.push(next);
					}
				}
			}
			
			rep(i, sw[data.second].size()){
				if(data.second == sw[data.second][i])
					continue;
				pii next(data.first ^ (1 << sw[data.second][i]), data.second);
				if(!visited[next.first][next.second]){
					visited[next.first][next.second] = true;
					pre[next.first][next.second] = data;
					Q.push(next);
				}
			}
		}
		
		pii goal(1<<(n-1), n-1);
		if(visited[goal.first][goal.second]){
			vector<pii> way;
			for(pii now = goal; now.first != -1; now = pre[now.first][now.second])
				way.push_back(now);
			
			reverse(way.begin(), way.end());
			printf("You can go home in %d steps.\n", way.size()-1);
			
			reep(i, 1, way.size()){
				if(way[i].second != way[i-1].second){
					printf("Move to room %d.\n", way[i].second+1);
				}else{
					int diff = way[i].first ^ way[i-1].first;
					rep(j, n){
						if(diff == 1<<j){
							printf("Switch %s room %d.\n", (way[i].first & diff) ? "on" : "off", j+1);
							break;
						}
					}
				}
			}
		}else{
			bool found = false;
			rep(i, 1<<n){
				if(visited[i][n-1]){
					found = true;
					break;
				}
			}
			puts(found ? "You can not switch off all lights." : "Help me!");
		}
	}
	return 0;
}

Measured memory_bytes: 4492
#define CPP17
#include <limits>
#include <initializer_list>
#include <utility>
#include <bitset>
#include <tuple>
#include <type_traits>
#include <functional>
#include <string>
#include <array>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <complex>
#include <random>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <regex>
#include <cassert>
#include <cstddef>
#ifdef CPP17
#include <variant>
#endif

#define endl codeforces

#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)

using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
using size_type = ssize_t;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

template <typename T, std::size_t Head, std::size_t... Tail> 
struct multi_dim_array { using type = std::array<typename multi_dim_array<T, Tail...>::type, Head>; };

template <typename T, std::size_t Head> 
struct multi_dim_array<T, Head> { using type = std::array<T, Head>; };

template <typename T, std::size_t... Args> using mdarray = typename multi_dim_array<T, Args...>::type;

#ifdef CPP17
template <typename T, typename F, typename... Args> 
void fill_seq(T &t, F f, Args... args) { 
    if constexpr (std::is_invocable<F, Args...>::value) { 
        t = f(args...); 
    } else { 
        for (size_type i = 0; i < t.size(); i++) fill_seq(t[i], f, args..., i); 
    } 
}
#endif

template <typename T> vec<T> make_v(size_type sz) { return vec<T>(sz); }

template <typename T, typename... Tail> 
auto make_v(size_type hs, Tail&&... ts) { 
    auto v = std::move(make_v<T>(std::forward<Tail>(ts)...)); 
    return vec<decltype(v)>(hs, v); 
}

namespace init__ { 
struct InitIO { 
    InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } 
} init_io; 
}
#define CPP17


int main() {
    ll n, d;
    std::cin >> n >> d;
    ll ans = 0;
    while (n--) {
        ll x, y;
        std::cin >> x >> y;
        ll d2 = x * x + y * y;
        ans += (d2 <= d * d);
    }
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int count=0;
    for(int i=0;i<s.length();i++)
    {
        if(i%2==0)
        {
           if(s[i]=='R'||s[i]=='D'||s[i]=='U')
                count++;
        }
        else
        {
            if(s[i]=='L'||s[i]=='D'||s[i]=='U')
                count++;
        }
    }
   if(count==s.length())
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())
MOD = 10**9 + 7

dp = [[0 for _ in range(W)] for _ in range(H + 1)]

dp[0][0] = 1
fib = [1] * (W + 2)
for i in range(2,W+2) :
    fib[i] = fib[i - 1] + fib[i - 2]

def pat(w) :
    if w < 1 :
        return 1
    else :
        return fib[w + 1]

for i in range(H) :
    for j in range(W) :
        dp[i+1][j] = (dp[i+1][j] + dp[i][j] * pat(j - 1) * pat(W - j - 2)) % MOD
        if j > 0 :
            dp[i+1][j-1] = (dp[i+1][j-1] + dp[i][j] * pat(j - 2) * pat(W - j - 2)) % MOD
        if j <= W - 2 :
            dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j] * pat(j - 1) * pat(W - j - 3)) % MOD

print(dp[H][K-1] % MOD)

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

void Main() {
  string s, t;
  cin >> s >> t;
  bool eq = true;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != t[i]) eq = false;
  }
  if (eq) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 3652
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector.Unboxed as VU
import Data.Bool (bool)

main :: IO ()
main = do
  let
    modulus = 998244353 :: Int
  [_, s] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    f :: [Int] -> Int
    f = VU.last . foldl step (VU.iterateN (succ s) (const 0) 1)
      where
        step :: VU.Vector Int -> Int -> VU.Vector Int
        step v x = VU.map (`mod` modulus) . (VU.zipWith (+) <$> VU.map (2 *) <*> (VU.replicate x 0 VU.++)) $ v
  as <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  print . f $ as

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 6116
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int n = sc.nextInt();
            int x = sc.nextInt();

            if (n == 0 && x == 0)
                break;

            int r = 0;
            for (int a = 1; a <= n; a++)
                for (int b = 1; b <= n; b++)
                    for (int c = 1; c <=n; c++)
                        if (a < b && b < c && a + b + c == x)
                            r++;
            System.out.println(r);
        }
    }
}



Measured memory_bytes: 26484
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		long money = scanner.nextLong();

		long coins500 = money / 500;
		long remainder = money % 500;
		long coins5 = remainder / 5;
		
		long maxHappy = coins500 * 1000 + coins5 * 5;
		System.out.println(maxHappy);

		scanner.close();

	}

}


Measured memory_bytes: 35824
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
using namespace std;

int main() {

    int n;
    int maxColor = 0;

    cin >> n;
    vector<vector<pair<int, int>>> edges(n + 1);
    vector<int> edgesColor(n);

    for(int i = 1; i <= n - 1; ++i) {
        int v, e;
        cin >> v >> e;
        edges[v].emplace_back(e, i);

    }

    queue<pair<int, int>> q;
    vector<pair<int, int>> answerEdges;
    q.push(make_pair(1, 0));


    while(!q.empty()) {

        auto vertex = q.front(); q.pop();
        int v = vertex.first;
        int color = vertex.second != 1 ? 1 : 2;
        
        for(int i = 0; i < edges[v].size(); ++i) {
            
            q.push(make_pair(edges[v][i].first, color));
            answerEdges.emplace_back(edges[v][i].second, color);
            
            maxColor = max(maxColor, color);

            color++;
            if(color == vertex.second)
                color++;
        }

    }

    cout << maxColor << endl;

    sort(answerEdges.begin(), answerEdges.end(), [](auto const &l, auto const &r) { return l.first < r.first; });
    for(int i = 0; i < answerEdges.size(); ++i) {
        cout << answerEdges[i].second << endl;
    }

    return 0;

}

Measured memory_bytes: 6072
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

	set<string> st;
	range(i,1,min<int>(6,s.size() + 1)){
		rep(j,s.size() - i + 1){
			st.emplace(s.substr(j,i));
		}
	}

	cout << *next(st.begin(), k - 1) << endl;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

// struct path
// {
//     pair<ll, ll> f;
//     pair<ll, ll> t;
// };

// struct cmp
// {
//     bool operator() ( path a, path b ) const
//     { return std::make_pair(a.f,a.t) > std::make_pair(b.f,b.t) ; }
// };


void solve()
{
    ll k;
    cin>>k;
    string x;
    cin>>x;
    ll n = x.size();
    if(n<=k)
    {
        cout<<x<<endl;
    }
    else
    {
        while(x.size()>k)
        {
            x.pop_back();
        }
        cout<<x<<"..."<<endl;
    }
    
    
    
}   

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3648