akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007
#define int int64_t

signed main(){
	int n,y;cin>>n>>y;
	int ans[3]={-1,-1,-1};
	for(int t=0;t<=n;t++){
		for(int f=0;f<=n;f++){
			int m=n-t-f;
			if(m>=0&&10000*t+5000*f+1000*m==y){
				printf("%lld %lld %lld\n",t,f,m);
				return 0;
			}
		}
	}
	printf("-1 -1 -1\n");
}

Measured memory_bytes: 256
#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>;
 
int main() {
  int n, r;
  cin >> n >> r;
  int ans = r + 100*max(0,10-n);
  cout << ans << endl;
  return 0;
}

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


int main() {
	string t; 
	cin >> t;
	for (int i = 0; i < t.size(); i++) {
		char temp = t[i];
		if (temp == '?') {
			t[i] = 'D';
		}
	}
	cout << t;
}

Measured memory_bytes: 3748
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    x = I()
    ans = 0
    if x < 600:
        ans = 8
    elif x < 800:
        ans = 7
    elif x < 1000:
        ans = 6
    elif x < 1200:
        ans = 5
    elif x < 1400:
        ans = 4
    elif x < 1600:
        ans = 3
    elif x < 1800:
        ans = 2
    else:
        ans = 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9208
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

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

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

class ATherefore {
    int n;
public:
	void solve(std::istream& cin, std::ostream& cout) {
	    cin >> n;
        string s = "pphbhhphph";
        cout << s[n % 10] << "on" << endl;
	}
};


int main() {
	ATherefore solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3608
from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
K = int(input())

ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            num = gcd(i,j)
            num = gcd(num,k)
            ans += num

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 67636
N,M = map(int,input().split())
AB = [[int(i) for i in input().split()] for _ in range(N)]

AB.sort(key = lambda x:x[0])

ans = 0
cnt = 0
for A,B in AB:
    ans += A * min(B, M - cnt)
    cnt += min(B, M - cnt)
    if cnt == M:
        break

print(ans)

Measured memory_bytes: 22756
n,q=map(int, input().split())
s=input()
acl=[]
for i in range(n-1):
    if s[i:i+2]=='AC':acl.append(i)
import bisect
for i in range(q):
    l,r=map(int, input().split())
    #print(bisect.bisect_left(acl,l-1))
    #print(bisect.bisect_right(acl,r-2))
    print(bisect.bisect_right(acl,r-2)-bisect.bisect_left(acl,l-1))

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	if(n==1){
		cout << "a";
		return 0;
	}
	vector<string>s[10];
	s[0].push_back("a");
	for(ll i=1;i<10;i++){
		for(ll j=0;j<s[i-1].size();j++){
			string now=s[i-1][j];
			ll last=0;
			for(ll k=0;k<now.size();k++){
				last=max(last,ll(now[k]-'a'));
			}
			//cout <<i<<j<<last;
			for(ll k=0;k<=last+1;k++){
				char next='a'+k;
			//	cout << next<<endl;
				s[i].push_back(now+next);
				if(i+1==n){
					cout <<now+next<<endl;
				}
			}
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 11380
//Program.cpp
//Author : Aaryan Srivastava 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#define pb push_back
#define popb pop_back
#define ull unsigned long long  
#define beg begin
#define mp make_pair
#define pii pair<int, int>
#define piii pair<pii,int>
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second 
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using ll = long long;
#define int ll
const int N = 1e5 + 5 ;
const int mod = 1e9 + 5 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace std;
#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#define AaryanS 0 
#endif

template <typename T> void max_self(T &a, T b) {a = max(a,b) ;}
#define debug(x) mycerr << #x << " "  << x << endl ;

vector<int> adj[N+1];
vector<int> dp(N+1,-1);
int dfs(int u){
	if(dp[u] != -1)
		return dp[u] ;
	int res = 0;
	for(auto it : adj[u])
		max_self(res,1+dfs(it)) ;
	return dp[u] = res ;
}
void solve()
{
	int n,m ;
	cin >> n >> m ;
	int x,y; 
	while(m--){
		cin >> x >> y ;
		adj[x].pb(y) ;
	}
	int ans = 0 ;
	repA(i,1,n){
		if(dp[i] != -1)
			continue ;
		max_self(ans,dfs(i)) ;
	}
	cout << ans ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, tt = 0;
   // cin >> TC ;
    while(tt++ < TC)
    {
        //cout << "Case " << t << ":\n" ;
        solve();
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 8576
def myAnswer(N:int,A:list) -> int:
   if(N == 1): return 1
   pre = A.pop(0)
   counter = 1
   state = 0 # 0:どちらでもない状態、1:単調非減少、2:単調非増加
   for a in A:
      if(pre == a):
         pre = a
         continue
      if(state == 0):
         if(pre < a):
            state = 1
         else:
            state = 2
      elif(pre < a and state == 2):
         counter += 1
         state = 0
      elif(pre > a and state == 1):
         counter += 1
         state = 0
      pre = a
   return counter

def modelAnswer():
   return
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A[:]))
if __name__ == '__main__':
   main()

Measured memory_bytes: 14428
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str;
            str = Console.ReadLine ().Split (' ');

            int N = int.Parse (str[0]);
            str = Console.ReadLine ().Split (' ');

            char[] A = new char[N];
            int Rnum = 0;
            for (int i = 0; i < N; i++)
            {
                A[i] = str[0][i];
                if (A[i] == 'R') Rnum++;
            }
            int ans = 0;
            for (int i = 0; i < Rnum; i++)
            {
                if (A[i] == 'W') ans++;
            }
            Console.WriteLine (ans);
        }
    }

    class MyLibrary
    {
        public static int GCD (int a, int b)
        {
            if (a % b == 0) return b;
            return GCD (b, a % b);
        }
    }
}

Measured memory_bytes: 28664
# coding:utf-8

import sys


input = sys.stdin.readline


def inpl(): return list(map(int, input().split()))


while True:
    N, T, L, B = inpl()
    if N == 0: break
    lose = [int(input()) for _ in range(L)]
    back = [int(input()) for _ in range(B)]
    mass = [0] * (N + 1)
    for l in lose:
        mass[l] = 1
    for b in back:
        mass[b] = 2

    dp = [[0] * (N + 1) for _ in range(T + 3)]
    dp[0][0] = 1.0

    for i in range(T + 1):
        for j in range(N):
            if dp[i][j] == 0.0:
                continue
            for k in range(1, 7):
                curr = j + k
                if curr > N: curr = N - curr % N
                if mass[curr] == 0:  # 通常マス
                    dp[i + 1][curr] += dp[i][j] / 6.0
                elif mass[curr] == 1:  # Loseマス
                    dp[i + 2][curr] += dp[i][j] / 6.0
                else:  # Backマス
                    dp[i + 1][0] += dp[i][j] / 6.0

    ans = 0
    for i in range(T + 1):
        ans += dp[i][N]
    print('{:.6f}'.format(ans))



Measured memory_bytes: 5952
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			P = scanner.nextInt();
			Q = scanner.nextInt();
			A = scanner.nextInt();
			N = scanner.nextInt();
			if ((P | Q | A | N) == 0)
				break;
			System.out.println(dfs(P, Q, 0, 1, 1));

		}
	}

	private int dfs(int p, int q, int depth, int r, int prd) {
		if (p == 0)
			return 1;
		int ans = 0;
		for (int i = r; i * prd <= A; i++) {
			if ((N - depth) * q < i * p)
				break;
			if (i * p < q)
				continue;
			ans += dfs(i * p - q, i * q, depth + 1, i, prd * i);
		}
		return ans;
	}

	int P, Q, A, N;
}

Measured memory_bytes: 23700
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    string s;
    scan(s);

    auto cnt = new int[](3);

    foreach (ch ; s) {
        cnt[ch - 'a']++;
    }

    cnt.sort();

    writeln(cnt[2] - cnt[0] <= 1 ? "YES" : "NO");
}



struct UnionFind {
    private {
        int N;
        int[] p;
        int[] rank;
    }

    this (int n) {
        N = n;
        p = iota(N).array;
        rank = new int[](N);
    }

    int find_root(int x) {
        if (p[x] != x) {
            p[x] = find_root(p[x]);
        }

        return p[x];
    }

    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y) {
        int u = find_root(x), v = find_root(y);

        if (u == v) return;

        if (rank[u] < rank[v]) {
            p[u] = v;
        }
        else {
            p[v] = u;

            if (rank[u] == rank[v]) {
                rank[u]++;
            }
        }
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}



struct Queue(T) {
    private {
        int N, head, tail;
        T[] data;
    }

    this(int n) {
        N = n + 1;
        data = new T[](N);
    }

    bool empty() {
        return head == tail;
    }

    bool full() {
        return (tail + 1) % N == head;
    }

    T front() {
        return data[head];
    }

    void push(T x) {
        assert(!full);
        data[tail++] = x;
        tail %= N;
    }

    void pop() {
        assert(!empty);
        head = (head + 1) % N;
    }

    void clear() {
        head = tail = 0;
    }
}

Measured memory_bytes: 508
#include <climits>
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>

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

using namespace std;
using ll = long long;

const ll M = 1e9 + 7;
ll pow2[2020];

vector< pair<int, int> > adj_list[1010];

int pred[1010];
int weights[1010];
bool in_pq[1010];

ll prim(int n, tuple<int, int, int>& e) {
    int w1, u0, u1;
    int u, v, w;
    ll r;

    priority_queue<
        pair<int, int>,
        vector< pair<int, int> >,
        greater< pair<int, int> > > pq;
    
    fill(pred, pred + n, -1);
    fill(weights, weights + n, INT_MAX);

    tie(w1, u0, u1) = e;

    weights[u0] = weights[u1] = 0;
    pred[u1] = u0;

    rep(v, 0, n) {
        pq.push(make_pair(weights[v], v));
    }

    fill(in_pq, in_pq + n, true);
    in_pq[u0] = in_pq[u1] = false;

    for (int u : {u0, u1}) {
        for (auto p : adj_list[u]) {
            tie(w, v) = p;
            if (in_pq[v]) {
                if (w < weights[v]) {
                    pred[v] = u;
                    weights[v] = w;
                    pq.push(p);
                }
            }
        }
    }

    while (!pq.empty()) {
        auto p = pq.top();
        pq.pop();
        tie(w, u) = p;
        in_pq[u] = false;
        for (auto p : adj_list[u]) {
            tie(w, v) = p;
            if (in_pq[v]) {
                if (w < weights[v]) {
                    pred[v] = u;
                    weights[v] = w;
                    pq.push(p);
                }
            }
        }
    }

    r = w1;
    rep(i, 0, n) {
        r += weights[i];
    }

    return r;
}

int solve(int n, int m, ll x, vector< tuple<int, int, int> >& edges) {
    int s, t;
    ll y, r;
    ll ans;

    s = 0;
    t = 0;
    for (auto e : edges) {
        y = prim(n, e);
        if (y < x) {
            ++s;
        } else if (y == x) {
            ++t;
        }
    }

    if (t == 0) {
        return 0;
    }

    r = 1;
    int mi = max(t, m - s - t + 1) + 1;
    rep(i, 0, mi) {
        pow2[i] = r;
        r <<= 1;
        r %= M;
    }
    if (s == 0) {
        ans = (pow2[t] - 2) * pow2[m - t];
    } else {
        ans = (pow2[t] - 1) * pow2[m - s - t + 1];
    }
    return (int)(ans % M);
}

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

    int n, m;
    ll x;
    int u, v, w;
    vector< tuple<int, int, int> > edges;
    
    cin >> n >> m;
    cin >> x;
    rep(i, 0, m) {
        cin >> u >> v >> w;
        --u; --v;
        edges.push_back(make_tuple(w, u, v));
        adj_list[u].push_back(make_pair(w, v));
        adj_list[v].push_back(make_pair(w, u));
    }

    cout << solve(n, m, x, edges) << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

bool input(vs& v)
{
	v.resize(18);
	REP(i, 18)
	{
		cin >> v[i];
		if (v[i] == "#") return false;
	}
	return true;
}

vs to_clock(vs& v)
{
	vs res(3, string("@@@"));
	REP(i, 3)REP(j,3)res[i][j] = v[2-j][i];
	return res;
}

vs to_cclock(vs& v)
{
	vs res = v;
	REP(i, 3) res = to_clock(res);
	return res;
}

vs reverse(vs& v)
{
	vs res = v;
	REP(i, 3)REP(j, 3) res[i][j] = v[2 - i][2 - j];
	return res;
}

struct Room
{
	vs front, right, back, left, top, bottom;
	Room(vs v)
	{
		FOR(i, 0, 3) front.push_back(v[i]);
		FOR(i, 3, 6) right.push_back(v[i]);
		FOR(i, 6, 9) back.push_back(v[i]);
		FOR(i, 9, 12) left.push_back(v[i]);
		FOR(i, 12, 15) top.push_back(v[i]);
		FOR(i, 15, 18) bottom.push_back(v[i]);
	}
	void to_front()
	{
		vs nfront, nright, nback, nleft, ntop, nbottom;
		nfront = bottom;
		ntop = front;
		nback = reverse(top);
		nbottom = reverse(back);
		nleft = to_cclock(left);
		nright = to_clock(right);
		front = nfront;
		right = nright;
		back = nback;
		left = nleft;
		top = ntop;
		bottom = nbottom;
	}
	void to_back() 
	{
		REP(i, 3) to_front();
	}
	void to_right()
	{
		vs nfront, nright, nback, nleft, ntop, nbottom;
		ntop = to_clock(left);
		nleft = to_clock(bottom);
		nbottom = to_clock(right);
		nright = to_clock(top);
		nfront = to_clock(front);
		nback = to_cclock(back);
		front = nfront;
		right = nright;
		back = nback;
		left = nleft;
		top = ntop;
		bottom = nbottom;
	}
	void to_left()
	{
		REP(i, 3) to_right();
	}
};

bool check(Room& room)
{
	vs a = room.front, b = room.back;
	bool f1 = false, f2 = false;
	REP(i, 3)
	{
		if (a[2][i] == '*') f1 = true;
		if (b[2][i] == '*') f2 = true;
	}
	return f1 && f2;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	vs v;
	while (input(v))
	{
		Room room(v);
		queue<pair<Room, int>> que;
		que.emplace(room, 0);
		while (!que.empty())
		{
			Room tmp = que.front().first; int t = que.front().second;
			que.pop();
			if (check(tmp))
			{
				cout << t << endl;
				break;
			}
			Room nx = tmp;
			nx.to_front();
			que.emplace(nx, t + 1);
			nx = tmp;
			nx.to_back();
			que.emplace(nx, t + 1);
			nx = tmp;
			nx.to_right();
			que.emplace(nx, t + 1);
			nx = tmp;
			nx.to_left();
			que.emplace(nx, t + 1);
		}
		
	}
	return 0;
}

Measured memory_bytes: 3180
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
    char pic[100][100];
    char c;
    int H,W;
    int i,j;
    scanf("%d%d\n",&H,&W);
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            scanf("%c",&pic[i][j]);
        }
        scanf("%c",&c);
    }
    for(i=-1;i<=H;i++){
        for(j=-1;j<=W;j++){
            if(i>=0&&i<H&&j>=0&&j<W) printf("%c",pic[i][j]);
            else printf("#");
        }
        printf("\n");
    }
    return  0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll h, w;
  cin >> h >> w;
  ll x[h][w], y[h][w];
  ll count = 0;
  
  for(i = 0; i < h; i++)
    for(j = 0; j < w; j++){
      cin >> x[i][j];
      y[i][j] = x[i][j];
    }
        
  for(i = 0; i < h; i++){
    for(j = 0; j < w - 1; j++){
      if(x[i][j] % 2 != 0){
        x[i][j]--;
        x[i][j + 1]++;
        count++;
        
      }
    }
  }
  for(i = 0; i < h - 1; i++){
    if(x[i][w - 1] % 2 != 0){
      x[i][w - 1]--;
      x[i + 1][w - 1]++;
      count++;
    }
  }
  
  cout << count << endl;
  
  for(i = 0; i < h; i++){
    for(j = 0; j < w - 1; j++){
      if(y[i][j] % 2 != 0){
        y[i][j]--;
        y[i][j + 1]++;
        cout << i+1 spa j+1 spa i+1 spa j+2 << endl;
      }
    }
  }
  for(i = 0; i < h - 1; i++){
    if(y[i][w - 1] % 2 != 0){
      y[i][w - 1]--;
      y[i + 1][w - 1]++;
      cout << i+1 spa w spa i+2 spa w << endl;
    }
  }

  return 0;
}

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

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
char c;
bool flag;

//----------------------------------------------------------------------


int main(void) {
  string a, b, c;
  double d, e;

  cin >> a >> b;

  c = a + b;

  d = stoi(c);

  e = sqrt(d);


  if (ceil(e) == floor(e)) {
	cout << "Yes" << endl;
  }
  else {
	cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;
const double pi=acos(-1.0);
const double eps=1e-9;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair <int,int>
#define piii pair < pii, int>
#define pll pair <long long , long long>
#define plll pair <pll , long long>
#define hjsagjfasjg y1
typedef long long ll;

const int N=(int)1e5+5;
int n,m,ans,cnt[N],a,b;
bool can[N];

int main()
{
	ios:: sync_with_stdio(false);
	cin >> n >> m;
	can[0]=true;
	for(int i=0;i<n;i++)
		cnt[i]++;
	for(int i=0;i<m;i++)
	{
		cin >> a >> b;
		a--;b--;
		cnt[a]--;
		cnt[b]++;
		if(can[a])
			can[b]=true;
		if(cnt[a]==0)can[a]=false;
	}
	for(int i=0;i<n;i++)
		if(can[i])ans++;
	cout << ans;
	return 0;
}

Measured memory_bytes: 768
n = int(input())
a = [int(x) for x in input().split()]


cnt = -1
tmp = True
while tmp:
    cnt += 1
    for i in range(n):
        if a[i] % 2 == 0:
            a[i] = a[i] // 2
        else:
            tmp = False

print(cnt)



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


Measured memory_bytes: 2044
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a * b});
    return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n=int(input())
l=[[float("INF")]*3 for i in range(n)]
l[0]=list(map(int,input().split()))
for day in range(1,n):
    f=list(map(int,input().split()))
    for choice in range(3):
        l[day][choice]=max(l[day-1][j]+f[choice] for j in range(3) if j!=choice)
print(max(l[-1]))

Measured memory_bytes: 22804
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << endl;
using LL=long long;
using VI=vector<int>;
using VL=vector<long long>;
using VS=vector<string>;
using VVI=vector<vector<int>>;
using PII=pair<int, int>;
const int inf = (int)1e9;
const LL mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

template <class T>void Sort(T & a) { sort(a.begin(), a.end()); }
template <class T>void ReSort(T& a) { sort(a.rbegin(), a.rend()); }
template <class T>void Reverse(T& a) { reverse(a.begin(), a.end()); }
template <class T>void Unique(T& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T>auto Max(T a) { return *max_element(a.begin(), a.end()); }
template <class T>auto Min(T a) { return *min_element(a.begin(), a.end()); }
template <class T, class U>int Count(T a, U c) { return count(a.begin(), a.end(), c); }

//INPUT//
void CINPUT() {}
template<class H, class ...T> void CINPUT(H&& h, T&& ...t) { cin >> h; CINPUT(forward<T>(t)...); }
#define in(...) int __VA_ARGS__; CINPUT(__VA_ARGS__);
#define IN(T,...) T __VA_ARGS__; CINPUT(__VA_ARGS__);
#define Vin(T,name,n) int n; cin>>n; vector<T> name(n); for(auto &i : name)cin>>i;
#define VIn(T,name,n) vector<T> name(n); for(auto &i : name)cin>>i;
#define VIn2(T,name,name2,n) vector<T> name(n),name2(n); rep(i,n)cin>>name[i]>>name2[i];

//OUTPUT//
void print() { cout << endl; }
template <class H> void print(H&& h) { cout << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cout << h << " "; print(forward<T>(t)...); }
template<class T>void out(T n) { cout << n << endl; }
template<class T>void out(vector<T> a, string sep = " ", string end = "\n") { for (int i = 0; i < (int)a.size(); ++i)cout << a[i] << (i == (int)a.size() - 1 ? end : sep); }
void yes(bool f) { puts(f ? "yes" : "no"); }
void Yes(bool f) { puts(f ? "Yes" : "No"); }
void YES(bool f) { puts(f ? "YES" : "NO"); }
void Yay(bool f) { puts(f ? "Yay!" : ":("); }
void poss(bool f) { puts(f ? "possible" : "impossible"); }
void Poss(bool f) { puts(f ? "Possible" : "Impossible"); }
void POSS(bool f) { puts(f ? "POSSIBLE" : "IMPOSSIBLE"); }

int main() {
	VIn(int, a, 3);
	ReSort(a);
	out(a[0] * 10 + a[1] + a[2]);
}

Measured memory_bytes: 256
def main():
    K, T = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    if T == 1:
        print(A[0] - 1)
    else:
        A.sort()
        print(max(A[-1] - sum(A[:-1]) - 1, 0))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Scanner;
 
/*
 * メモ
 * Scanner:nextは空白か改行までの単語
 * String[][] c = new String[h][w];
 * TemplateMain,"template_input.txt"
 * 0.5 == 1.0/2
 * Integer.valueOf(char)はダメ、(String)
 */
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		
		System.out.println((x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)?"Yes":"No");
	}
}


Measured memory_bytes: 26332
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
//#define int long long
const int INF = 1 << 30;

signed main(){

  int D; cin >> D;
  vector<int> C(26);
  for(int i = 0; i < 26; i++){
    cin >> C[i];
  }

  vector<vector<int>> S(D, vector<int>(26));
  for(int i = 0; i < D; i++){
    for(int j = 0; j < 26; j++){
      cin >> S[i][j];
    }
  }

  random_device seed_gen;
  mt19937_64 rnd(seed_gen());
  uniform_int_distribution<int> dist_T(0, 25);

  int score = -INF;
  vector<int> ans(D);
  clock_t start = clock();
  while(true){
    int res = 0;
    vector<int> L(26, -1);
    vector<int> dp(D);
    for(int i = 0; i < D; i++){
      int T = dist_T(rnd);
      res += S[i][T];
      L[T] = i;
      for(int j = 0; j < 26; j++){
        res -= C[j] * (i - L[j]);
      }
      dp[i] = T+1;
    }
    if(score < res){
      score = res;
      ans = dp;
    }

    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    if(time >= 1950) break;
    //cout << dp << " " << res << endl;
  }

  for(int p : ans){
    cout << p << endl;
  }

  return 0;
}

Measured memory_bytes: 3720
n = int(input())
l = list(map(int,input().split()))
s = 1
if 0 in l:
  print(0)
  exit()
for i in range(n):
  if s>10**18:
    print(-1)
    exit()
  else:
    s *= l[i]
if s>10**18:
    print(-1)
else:
  print(s)

Measured memory_bytes: 21644
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int inf = 1000000000; // 10^9

int main(){
   int d,n;scanf("%d %d",&d,&n);
   if(d==0){
      if(n==100)printf("%d",101);
      else printf("%d",n);
   }
   else if(d==1){
      if(n==100)printf("%d",10100);
      else printf("%d",n*100);
   }
   else {
      if(n==100)printf("%d",1010000);
      else printf("%d",n*10000);
   }
}


Measured memory_bytes: 128
import sys

input = sys.stdin.readline


def main():
    n = int(input().strip()[-1])
    if n in [2, 4, 5, 7, 9]:
        print('hon')
    elif n in [0, 1, 6, 8]:
        print('pon')
    else:
        print('bon')


if __name__ == '__main__':
    main()


Measured memory_bytes: 61664
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	k := getNextInt(scanner)
	s := getNextString(scanner)

	ans := 0

	for i := 1; i < n; i++ {
		if s[i-1] == s[i] {
			ans++
		}
	}

	fmt.Fprintln(writer, minint(ans+k*2, n-1))
	writer.Flush()
}

func minint(a int, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 896
n=int(input())
a=list(map(int,input().split()))

l=[]
for x in range(n-1):
    if a[x+1]==a[x]:l.append(0)
    if a[x+1]>a[x]:l.append(1)
    if a[x+1]<a[x]:l.append(-1)

for x in range(n-1):
    if l.pop(-1)==1:
        l.append(1)
        l.append(-1)
        break

m=1000
p=0
for i,x in enumerate(l):
    if x==1:
        t=m//a[i]
        m-=t*a[i]
        p+=t
    if x==-1:
        m+=p*a[i]
        p=0
print(m)

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
int p[100010];
int n,l,t,pos,to;
int main()
{
	scanf("%d%d%d",&n,&l,&t);
	int delta;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&pos,&to);
		if(to==1)
		{
			p[i]=pos+t;
			p[i]%=l;
			delta+=(pos+t)/l;
		}
		else
		{
			p[i]=pos-t;
			p[i]%=l;
			delta+=(pos-t)/l;
			if(p[i]<0)
			{
				p[i]+=l;
				delta--;
			}
		}
	}
	sort(p+1,p+n+1);
	((delta%=n)+=n)%=n;

	for(int i=delta+1;i<=n;i++) printf("%d\n",p[i]);
    for(int i=1;i<=delta;i++) printf("%d\n",p[i]);
}

Measured memory_bytes: 1536
N = int(input())
list = list(input().split())

count = 0
for i in range(N):
  minj = i
  for j in range(i, N):
    if int(list[j]) < int(list[minj]):
      minj = j

  tmp = list[i]
  list[i] = list[minj]
  list[minj] = tmp
  if minj != i: count += 1
print(' '.join(list))
print(count)


Measured memory_bytes: 5596
/*  ***  In The Name of God ... ***  */ 
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;


#define int long long
#define all(v) v.begin() , v.end()
#define pb push_back
#define endl '\n' 
template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = 1000 + 10 , mod = 1e9 + 7 ;

int n , cnt [ N ] ; 

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n ;
	vector < int > pr ; 
	for ( int i = 2 ; i < N ; i++ ) {
		bool isok = 1 ;
		for ( int j = 2 ; j < i ; j++ )
			isok &= ( i % j != 0 ) ;
		if ( isok )
			pr . push_back ( i ) ; 
	}
	int ans = 1 ; 
	for ( int i = 1 ; i <= n ; i++ ) {
		for ( auto p : pr ) {
			int cur = i , t = 0 ;
			while ( cur % p == 0 )
				cur /= p , t++ ;
			cnt [ p ] += t ; 
		}
	}
	for ( auto p : pr )
		( ans *= ( cnt [ p ] + 1 ) ) %= mod ;
	cout << ans << '\n' ; 
}


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

int main() {
    string s;
    cin>>s;
    if (s == "ABC") {
        cout<<"ARC"<<endl;
    } else {
        cout<<"ABC"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <queue>
#include <tuple>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <functional>

#pragma warning(disable : 4996)

using namespace std;

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

int R, W[2], H[2], X[2], Y[2], F[2][500][500], D[2][500][500];

int main()
{
	while (true)
	{
		scanf("%d", &R);

		if (R == 0) break;

		for (int i = 0; i < 2; i++)
		{
			scanf("%d", &W[i]);
			scanf("%d", &H[i]);
			scanf("%d", &X[i]); X[i]--;
			scanf("%d", &Y[i]); Y[i]--;

			for (int j = 0; j < H[i]; j++)
			{
				for (int k = 0; k < W[i]; k++)
				{
					scanf("%d", &F[i][j][k]);
				}
			}
		}

		memset(D, -1, sizeof(D));

		for (int i = 0; i < 2; i++)
		{
			D[i][Y[i]][X[i]] = 1;

			priority_queue<tuple<int, int, int>, vector<tuple<int, int, int> >, greater<tuple<int, int, int> > > que;

			que.push(make_tuple(0, X[i], Y[i]));

			while (!que.empty())
			{
				tuple<int, int, int> state = que.top(); que.pop();

				int d = get<0>(state);
				int x = get<1>(state);
				int y = get<2>(state);

				for (int dir = 0; dir < 4; dir++)
				{
					int x2 = x + dx[dir];
					int y2 = y + dy[dir];

					if (0 <= x2 && x2 < W[i] && 0 <= y2 && y2 < H[i])
					{
						if (D[i][y2][x2] == -1)
						{
							D[i][y2][x2] = max(d, F[i][y2][x2]);

							que.push(make_tuple(D[i][y2][x2], x2, y2));
						}
					}
				}
			}
		}

		vector<int> E[2];

		for (int i = 0; i < 2; i++)
		{
			for (int j = 0; j < H[i]; j++)
			{
				for (int k = 0; k < W[i]; k++)
				{
					E[i].push_back(D[i][j][k]);
				}
			}

			sort(E[i].begin(), E[i].end());
		}

		int ret = 999999999;

		int petl = E[0].size();
		int petr = E[1].size();

		for (int i = 0; i < R - 2; i++)
		{
			if (i < petl && R - i < petr)
			{
				ret = min(ret, E[0][i] + E[1][R - i - 2]);
			}
		}

		printf("%d\n", ret);
	}

	return 0;
}

Measured memory_bytes: 9232
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string str1;
    char ch;
    
    
    getline(cin,str1);

    for(int i=0;i<str1.length();i++){
       ch = str1.at(i);
       if ((ch>='a')&&(ch<='z')){
            ch = ch - 32;
       } 
       else if((ch>='A')&&(ch<='Z')){
            ch = ch + 32;
       }
       cout << ch;
    }
    
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 3164
N=int(input())
V=list(map(int, input().split()))

even=[[0,i] for i in range(10**5+1)]
odd=[[0,i] for i in range(10**5+1)]

for i in range(N):
    if i%2==0:
        even[V[i]][0]+=1
    else:
        odd[V[i]][0]+=1

even=sorted(even)
odd=sorted(odd)

n_even=even[-1][1]
n_odd=odd[-1][1]
if n_even!=n_odd:
    ans=N-(even[-1][0]+odd[-1][0])
    print(ans)

else:
    ans1=N-(even[-2][0]+odd[-1][0])
    ans2=N-(even[-1][0]+odd[-2][0])
    ans=min(ans1, ans2)
    print(ans)


Measured memory_bytes: 103688
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
    return 0;
}

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m, k;
    cin >> m >> k;

    if(m == 1) {
        if(k == 0) cout << "0 0 1 1" << ln;
        else cout << -1 << ln;
        return 0;
    }

    if(k < (int)pow(2, m)) {
        FORR(i, (int)pow(2, m) - 1, 0)if(i != k) cout << i << " ";
        cout << k << " ";
        FOR(i, 0, (int)pow(2, m) - 1)if(i != k) cout << i << " ";
        cout << k << ln;
    } else {
        cout << -1 << ln;
    }
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
char s[10];
int main() {
	int flag = 0;
	scanf("%s", s);
	int len = strlen(s);
	for(int i = 0; i < len - 1; i++) {
		if(s[i] == 'A' && s[i + 1] == 'C')flag = 1;
	}
	if(flag)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

long long N;

int calc(int N) {
    int res = 0;
    while (N > 0) {
        res += N % 10;
        N /= 10;
    }
    return res;
}

int main() {
    while (cin >> N) {
        long long res = 1LL<<60;
        for (int i = 1; i < N; ++i) {
            int j = N - i;
            long long tmp = calc(i) + calc(j);
            chmin(res, tmp);
        }
        cout << res << endl;
    }
}






















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

int main()
{
	int a,b;
	cin >> a >> b;
	if ((a*b) % 2 == 0) cout << "Even" << endl;
	else cout << "Odd" << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
final = ""
chars = "abcdefghijklmnopqrstuvwxyz"
dic = {i: chars[i] for i in range(0, 26)}
pw_26 = [26**i for i in range(13)]
cum = 0
digit = 0
for i in range(13):
    cum += pw_26[i]
    if N < cum:
        digit = i
        break
start_from = cum - pw_26[digit]
temp = N - start_from
digits = []
counter = 0
while counter < digit:
    res = temp % 26
    temp //= 26
    digits.append(res)
    counter += 1

for j in range(len(digits)):
    char = dic[digits[j]]
    final = char + final
print(final)

Measured memory_bytes: 9224
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

std::vector<std::pair<ll, int> > prime_factor(ll n) {
  std::vector<std::pair<ll, int> > ret;

  for (ll i = 2; i*i <= n; i++) {
    if (n % i != 0) { continue; }
    int exp_v = 0;
    while (n % i == 0) {
      exp_v++;
      n /= i;
    }
    ret.push_back( std::make_pair(i, exp_v) );
  }

  if (n != 1) {
    ret.push_back( std::make_pair(n, 1) );
  }

  return ret;
}

int main() {
  int n; cin >> n;
  auto vec = prime_factor(n);

  cout << n << ":";
  for (int i = 0; i < vec.size(); i++) {
    for (int j = 0; j < vec[i].second; j++) {
      cout << " " << vec[i].first;
    }
  }

  cout << endl;

  return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var vars = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var d = vars[3];
            var ac = Math.Abs(vars[2] - vars[0]);
            var ab = Math.Abs(vars[1] - vars[0]);
            var bc = Math.Abs(vars[2] - vars[1]);

            if(ac <= d || (ab <=d && bc<=d))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13396
class min_max_sum:
    def __init__(self,n=0,a=[],sum=0):
        self.n=n
        self.a=a
        self.sum=sum
    def mins(self):
        return min(self.a)
    def maxs(self):
        return max(self.a)
    def sums(self):
        for i in range(0,self.n):
            self.sum+=self.a[i]
        return self.sum
    
p=min_max_sum()
p.n=int(input())
p.a=list(map(int,input().split()))
print("%d %d %d"%(p.mins(),p.maxs(),p.sums()))
    


Measured memory_bytes: 6608
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <vector>
#include <set>
using namespace std;

int main(){
    int N, K,dif;
    cin >> N >> K;

    vector<int> h(N);

    for(int i = 0; i < N; i++){
        cin >> h.at(i);
    }

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

    int ans = h.at(K-1) - h.at(0);

    for(int i = 0; i < N; i++){
        if((i +  K - 1) == N){
            break;
        }
        dif = h.at(i + K - 1) - h.at(i);

        if(ans > dif){
            ans = dif;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

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

        int l = scanner.nextInt();

        double d =(double) l/3;
        double v = d*d*d;
        System.out.printf("%.12f\n",v);
       // System.out.println();
    }
}


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

int main()
{
    int n;
    cin>>n;
    long long a[n],ans=0;
    for(int i=0; i<n; i++)
        cin>>a[i];
    int k=n-1;
    sort(a,a+n,greater<long long>());
    for(int i=0; i<n-1 && k>0; i++)
    {
        ans+=a[i];
        k--;
        if(k==0) break;
        if(i==0) continue;
        ans+=a[i];
        k--;
    }
    cout<<ans<<endl;
    return 0;
}

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

int calc(int a, int b, int  flag){
    if(flag ==0) return a + b;
    else return a - b;
}


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

    int a,b,c,d;
    a = n[0] - '0';
    b = n[1] - '0';
    c = n[2] - '0';
    d = n[3] - '0';

    string op = "+-";
    for(int op1=0; op1<2; op1++){
        for(int op2=0; op2<2; op2++){
            for(int op3=0; op3<2; op3++){
                
                int sum = calc(a, b, op1);
                sum = calc(sum, c, op2);
                sum = calc(sum, d, op3);
                
                if(sum == 7){
                    cout << a << op[op1] << b << op[op2] << c << op[op3] << d << "=7";
                    return 0;
                }
            }   
        }   
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int x, t;
	cin >> x >> t;
	if (x>t) {
		cout << x - t << endl;
	}
	else {
		cout << 0 << endl;
	}
	
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace Paiza
{
    public class Hello
    {
        // Input data
        private static String [] gameObj;
        private static Stack<int> stack;

        public static void Main ()
        {
            ConsoleRead ();
            Method ();
        }

        private static void ConsoleRead ()
        {
            gameObj = System.Console.ReadLine ().Split ();
        }

        public static void Method ()
        {
            stack = new Stack<int> ();
            foreach (var item in gameObj) {
                int parsed = 0;
                if (int.TryParse (item, out parsed)) {
                    stack.Push (parsed);
                } else {
                    int y = stack.Pop ();
                    int x = stack.Pop ();
                    int result = Calc (x, y, item);
                    stack.Push (result);
                }
            }

            System.Console.WriteLine (stack.Pop());
        }

        private static int Calc (int x, int y, String ope)
        {
            if (ope.Equals ("+")) {
                return x + y;
            } else if (ope.Equals ("-")) {
                return x - y;
            } else if (ope.Equals ("*")) {
                return x * y;
            } else {
                return -10000;
            }
        }
	}
}

Measured memory_bytes: 10072
//encoding:utf-8
#include <iostream> //c++
#include<time.h> //時間にかんして
#include<stack> //スタックに関して　最新のデータから捨てる
#include<queue> //キューに関して　最古のデータから捨てる
#include<math.h>
#include<vector>
#include<algorithm> //sort とかにいる

#define ll long long
using namespace std;
int inf = INFINITY;
int main(){
  int n;
  cin>>n;
  long long a,b;
  a = 2;
  b = 1;
  for(int i=0;i<n;i++){
    swap(a,b);
    b = a+b;
  }
  cout<<a<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int K_MAX = 1e5+5;
vector<int> dp(K_MAX,1e9);
bool update(int &x,int y){
  if(x>y){
    x = y;
    return true;
  }
  return false;
}

int solve(){
  int K;cin >> K;
  deque<int> dq(1,1);
  dp[1] = 1;
  while(!dq.empty()){
    //cout << dq.front().first SP dq.front().second << endl;
    int u = dq.front(); dq.pop_front();
    if(u==0) return dp[0];
    if(update(dp[u*10%K], dp[u])) dq.push_front(u*10%K);
    if(update(dp[(u+1)%K], dp[u]+1)) dq.push_back((u+1)%K);
  }
  return dp[0];
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	if (A <= 8 && B <= 8)cout << "Yay!";
	else cout << ":(";
}


Measured memory_bytes: 256