akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
  int N, a, b, c, d ;
  cin >> N ;
  
  a = N/1000;
  b = (N-1000*a)/100;
  c = (N-1000*a-100*b)/10;
  d = N-1000*a-100*b-10*c;
    
  if ( b == c ) {
    if ( a == b ) {
      cout << "Yes" << endl;
    }
    else if ( c == d ) {
      cout << "Yes" << endl;      
    }
    else {
      cout << "No" << endl;   
    }
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in sys.stdin.readline().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v

def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N = int(input())
    A = sorted(li_input(), reverse=True)

    ans = 10**100
    ans_i = -1

    for i in range(len(A)-1):
        g = gcd(A[-1], A[i])

        if g < ans:
            ans = g
            ans_i = i

    print(max(
        gcd_list(A[:-1]),
        gcd_list(A[:ans_i] + A[ans_i+1:])
    ))


main()


Measured memory_bytes: 15672
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = [0 for _ in range(N+1)]
for i in range(N):
    B[i+1] = B[i]+A[i]
C = {}
for i in range(N+1):
    b = B[i]%M
    if b not in C:
        C[b] = 0
    C[b] += 1
cnt = 0
for b in C:
    cnt += (C[b]*(C[b]-1))//2
print(cnt)

Measured memory_bytes: 63000
# ABC 066 B
S =input()

m = 0
for i,s in enumerate(S):
    tmp = S[:-1-i]
    tmp1 = tmp[:len(tmp)//2]
    tmp2 = tmp[len(tmp)//2:]
    if len(tmp)%2==0 and(tmp1==tmp2):
        m = max(m,len(tmp))
print(m)

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


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

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

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}

int ans_gu_choki_per(char te, int c, int d, int e ) {
  if(te = "r") return e;
  else if(te = "s") return c;
  else if(te = "p") return d;
  else return 0;
//  return abs(a-b)*abs(a-b);
}
int ans_gu_choki_per_2(char te, int c, int d, int e ) {
  if(te = "r") return c;
  else if(te = "s") return d;
  else if(te = "p") return e;
  else return 0;
//  return abs(a-b)*abs(a-b);
}

//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
  int  a ,b, c, d, e, X, Y ,r;
//  long long  a, b, c, d, e, X, Y;
  //  double  c;
//  int  A[200003]={};
  int  A[100003]={};
  int  B[100003]={};
  int  C[100003][100001]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  int ans_ac=0;
  int ans_wa=0;
  int max=0;
  int sum=0;
  int addr=0;
  int ptn=0;
  long long  tmp=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%d%d", &a, &b);
  if(a==b)   printf("Yes\n");
  else    printf("No\n");
  
return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int main(){
	int k;
	int x[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	cin >> k;
	cout << x[k - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
f(n)=factorial(n)

function main()
	s = readline() |> chomp
	l = length(s)
	g = 0
	k = 0
	for i in 1:l
		if s[i] == 'g'
			g += 1
		else
			g -= 1
		end
	end
	println(div(g,2))
end

main()

Measured memory_bytes: 163052
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


class BIT {
private:
    int bit[200010] = {};

public:
    int sum(int i) {
        int s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & (-i);
        }
        return s;
    }

    void add(int n, int i, int k) {
        while (i <= n) {
            bit[i] += k;
            i += i & (-i);
        }
    }

};

int main(void) {
	int n, k, i, a[200003];
    ll r[200003] = {}, ans;
    set<ll> s;
    vector<ll> v;

    BIT rd;

	scanf("%d%d", &n, &k);
	for (i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}

	for (i = 1; i <= n; i++) {
		r[i] = r[i - 1] + a[i] - k;
	}

    for (i = 0; i <= n; i++) {
        if (s.find(r[i]) == s.end()) {
            v.push_back(r[i]);
            s.insert(r[i]);
        }
    }

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

    for (i = 0; i <= n; i++) {
        r[i] = (ll)(lower_bound(v.begin(), v.end(), r[i]) - v.begin() + 1);
    }

    ans = 0;
    for (i = 0; i <= n; i++) {
        ans += rd.sum(r[i]);
        rd.add(n + 1, r[i], 1);
    }

    printf("%lld\n", ans);

	return 0;
}

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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define int ll

void solve()
{
    int n;
    cin>>n;
    vector<pair<int,int>> vec(4);
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        if(i==0){
            vec[0]={x+y,x+y};
            vec[1]={x-y,x-y};
            vec[2]={-x+y,-x+y};
            vec[3]={-x-y,-x-y};
        }else{
            vec[0]={max(vec[0].first,x+y),min(vec[0].second,x+y)};
            vec[1]={max(vec[1].first,x-y),min(vec[1].second,x-y)};
            vec[2]={max(vec[2].first,-x+y),min(vec[2].second,-x+y)};
            vec[3]={max(vec[3].first,-x-y),min(vec[3].second,-x-y)};
        }
    }
    cout<<max({vec[0].first-vec[0].second,vec[1].first-vec[1].second,vec[2].first-vec[2].second,vec[3].first-vec[3].second});
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
def main():
    n = int(input())
    *a, = map(int, input().split())
    cs = [a[0]]*n
    for i in range(1, n):
        cs[i] = a[i]+cs[i-1]
    o = float("inf")
    for i in range(n):
        l, r = cs[i], cs[-1]-cs[i]
        tmp = max(l, r) - min(l, r)
        o = tmp if tmp<o else o
    print(o)

if __name__ == "__main__":
    main()


Measured memory_bytes: 98124
#include<iostream>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int x1,y1,x2,y2;
    int x3,y3,x4,y4;
    int dx,dy;
    while(cin>>x1>>y1>>x2>>y2)
    {
        //cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<endl;
        dx=abs(x1-x2);
        dy=abs(y1-y2);
        if(x1<=x2&&y1>=y2)
        {
            x3=x2+dy;
            y3=y2+dx;
            x4=x1+dy;
            y4=y1+dx;
        }
        else if(x2>=x1&&y2>=y1)
        {
            x3=x2-dy;
            y3=y2+dx;
            x4=x1-dy;
            y4=y1+dx;
        }
        else if(x1>=x2&&y1>=y2)
        {
            x3=x2+dy;
            y3=y2-dx;
            x4=x1+dy;
            y4=y1-dx;
        }
        else if(x1>=x2&&y2>=y1)
        {
             x3=x2-dy;
             y3=y2-dx;
             x4=x1-dy;
             y4=y1-dx;
        }
        cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,-1,1};
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; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,d;
    cin >> N >> d;
    vector<int> p(N);
    rep(i,N) cin >> p[i];
    int sum = 0;
    rep(i,N){
        sum += max(0,p[i]-d);
    }
    if(sum == 0){
        cout << "kusoge\n";
    }else{
        cout << sum << "\n";
    }
    return 0;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


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

    int ans = a+b+c-max(max(a,b),c);

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


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		String S = sc.next();

		sc.close();

		for (int i = 0; i < S.length(); i++) {
			out.print("x");
		}
		out.println();

	}

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


Measured memory_bytes: 22608
s = input() 
t = input()

nums = len(s)
numt = len(t)


if t == s + "a":
	print("Yes")
elif t == s + "b":
	print("Yes")
elif t == s + "c":
	print("Yes")
elif t == s + "d":
	print("Yes")
elif t == s + "e":
	print("Yes")
elif t == s + "f":
	print("Yes")
elif t == s + "g":
	print("Yes")
elif t == s + "h":
	print("Yes")
elif t == s + "i":
	print("Yes")
elif t == s + "j":
	print("Yes")
elif t == s + "k":
	print("Yes")
elif t == s + "l":
	print("Yes")
elif t == s + "m":
	print("Yes")
elif t == s + "n":
	print("Yes")
elif t == s + "o":
	print("Yes")
elif t == s + "p":
	print("Yes")
elif t == s + "q":
	print("Yes")
elif t == s + "r":
	print("Yes")
elif t == s + "s":
	print("Yes")
elif t == s + "t":
	print("Yes")
elif t == s + "u":
	print("Yes")
elif t == s + "v":
	print("Yes")
elif t == s + "w":
	print("Yes")
elif t == s + "x":
	print("Yes")
elif t == s + "y":
	print("Yes")
elif t == s + "z":
	print("Yes")
else:
  print("No")

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

int main()
{
    int h,m,s;
    while(cin >> h >> m >> s)
    {
        if(h==-1&&m==-1&&s==-1)break;
        int rest[3]={};
        rest[2]=120*60-( 60*60*h + 60*m + s);
        int rest3[3]={};
        rest3[2]=rest[2] * 3;
        //rests -= (h*60*60 + m*60 + s);
        rest[0] = rest[2]/3600;
        rest[1] = (rest[2] - rest[0]*3600)/60;
        rest[2] = rest[2] % 60;
        rest3[0] = rest3[2] / 3600;
        rest3[1] = (rest3[2] - rest3[0]*3600)/60;
        rest3[2] = rest3[2] % 60;
        string ans1 = "",ans2="";
        char t1[2],t2[2];
        for(int i=0;i<3;i++)
        {
            t1[0] = (char)(rest[i]/10 +'0');
            t1[1] = (char)(rest[i]%10 +'0');
            t2[0] = (char)(rest3[i]/10 +'0');
            t2[1] = (char)(rest3[i]%10 +'0');
            ans1 += t1[0];
            ans1 += t1[1];
            ans2 += t2[0];
            ans2 += t2[1];
            if(i==2)break;
            ans1+= ":"; ans2+= ":";
        }
        cout << ans1<< endl;
        cout << ans2 << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;


int main(){
    int x;
    cin>>x;
    string ans;
    if(x<1200)ans="ABC";
    else ans="ARC";
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 2000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

ll n,a[maxn],b[maxn],c[maxn];

inline ll read()
{
	ll x=0,w=1,x2=0,base=1e9; char c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	if(c=='.')
	{
		while(c<'0'||c>'9') c=getchar();
		while(c<='9'&&c>='0') {x2=(x2<<1)+(x2<<3)+c-'0'; base/=10; c=getchar();}
		return x*1e9+x2*base;
	}
	else return x*1e9;
}

ll dp[55][55];

int main()
{
	ll n,ans=0; cin>>n; rep(i,1,n) a[i]=read();
	rep(i,1,n)
	{
		int c1=0,c2=0;
		while(a[i]%2==0) a[i]/=2,c1++; c1=min(18,c1);
		while(a[i]%5==0) a[i]/=5,c2++; c2=min(18,c2);
		rep(j,18-c1,50) rep(k,18-c2,50) ans+=dp[j][k];
		dp[c1][c2]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5104
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n = int(input())
ab = [tuple(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[1])

time = 0
for a, limit in ab:
    time += a
    if limit < time:
        print("No")
        break
else:
    print("Yes")


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

int main(void){
    int n, d;
    cin >> n >> d;

    vector<int> x(n), y(n);
    rep(i,n) cin >> x[i] >> y[i];

    vector<ll> dist2(n);
    rep(i,n) dist2[i] = (ll)x[i]*x[i] + (ll)y[i]*y[i];

    int cnt = 0;
    rep(i,n) if (dist2[i] <= (ll)d*d) cnt++;

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 6424
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.immutable._
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}

object Main {
  val m = (1 << 9) - 1

  def solve(sc: => Scanner): Unit = {
    val H, W = sc.nextInt
    val A = Array.fill(H)(sc.next)
    val B = Array((1, 0), (0, 1), (-1, 0), (0, -1))
    println(if ((0 until H).map(i =>
      (0 until W).map(j =>
        if (A(i)(j) == '#') {
          (0 until 4).map { k =>
            val now = (B(k)._1 + i, B(k)._2 + j)
            if (0 <= now._1 && now._1 < H && 0 <= now._2 && now._2 < W && A(now._1)(now._2) == '#') (true) else (false)
          }.fold(false)((a, b) => a | b)
        } else (true)
      ).fold(true)((a, b) => a & b)
    ).fold(true)((a, b) => a & b)) ("Yes") else ("No"))
  }

  def recursive(now: Int, A: Array[List[Int]]): Int = {
    if (A(now).size == 0) (now) else {
      val next = A(now).head
      A(now) = A(now).filter(_ != next)
      A(next) = A(next).filter(_ != now)
      recursive(next, A)
    }
  }

  def check(A: Array[List[Int]]): Boolean = {
    A.map(_.size == 0).fold(true)((a, b) => a & b)
  }

  def shift(n: Long): Long = {
    if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)
  }

  def unShift(n: Long): Long = {
    if (n == 0) (0) else (unShift(n >> 1) + 1)
  }

  def calc(v: Long): Long = (v + 1) * v / 2

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

object Util {
  def getPermutation(begin: Long = 0): Stream[Long] =
    Stream.cons(begin, getPermutation(begin + 1))

  def getPrimeList(): Stream[Long] =
    getPrimeListRecursive(getPermutation(begin = 2))

  private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =
    Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))

  def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)
}

Measured memory_bytes: 28092
s = list(input())

n = len(s)

cnt = 0
ans = 0

for i in range(n):
    if "A" in s[i] or "T" in s[i] or "C" in s[i] or "G" in s[i]:
        cnt += 1
        ans = max(ans,cnt)
    else:
        cnt = 0

print(ans)

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

signed main(){
    cin.tie(0);
    int n;cin>>n;
    vector<int> a(n);rep(i,n)cin>>a[i];
    int q;cin>>q;
    vector<int> qs(q);rep(i,q)cin>>qs[i];
    vector<bool> v(40001,0);
    int sum=0;
    rep(b,1<<n){
        sum=0;
        rep(j,n){
            if(b&(1<<j))sum+=a[j];
        }
        v[sum]=1;
    }
    rep(i,q){
        if (v[qs[i]] == 1)
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }

    return 0;
}


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

int main(){
  int A[5],B[5];
  for(int i=0;i<5;i++){
    cin>>A[i];
    B[i] = A[i]%10;
    if(B[i] == 0) B[i]=10;
  }
  int m=10;
  for(int i=0;i<5;i++){
    m = min(m,B[i]);
  }
  int ans = 0;
  for(int i=0;i<5;i++){
    ans += (A[i]-1)/10*10+10;
  }
  ans -=10;
  ans += m;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
    public static void main (String[] args) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String text = br.readLine();
	String decryptedText;
	while (text != null) {   
	    while (true) {
		decryptedText = decrypt(text);
		if (decryptedText.contains("the") || decryptedText.contains("this") ||
		    decryptedText.contains("that")) {
		    System.out.println(decryptedText);
		    break;
		}
		text = decryptedText;
	    }
	    text = br.readLine();
	}
    }
    public static String decrypt (String text) {
	char[] ctext = text.toCharArray();
	char letter;
	for (int i = 0; i < ctext.length; i++) {
	    letter = ctext[i];
	    if ('a' <= letter && letter <= 'z') {
	        if ('z' < ++letter) {
		    letter = 'a';
		}
	    }
	    ctext[i] = letter;
	}
	return String.valueOf(ctext);
    }
}

Measured memory_bytes: 23952
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    string t;
    cin>>t;
    cout<<t.substr(0,4)<<" "<<t.substr(4,8)<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        
        String a = scan.nextLine();
        String b = scan.nextLine();
        String a2 = a + a;
        
        if(a2.contains(b)){
            
            System.out.println("Yes");
            
        }else{
        
            System.out.println("No");
            
        }
        
    }
}


Measured memory_bytes: 26284
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	static class Node {
		int id;
		int uDist, vDist;
		Set<Integer> connNodes;

		Node(int id) {
			this.id = id;
			this.connNodes = new HashSet<>();
		}
	}

	int N, u, v;
	Node[] nodes;
	int result = -1;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	void labelUDist(int targetId, int dist, int parentId) {
		nodes[targetId].uDist = dist;
		for (int id : nodes[targetId].connNodes) {
			if (parentId == id) {
				continue;
			}
			labelUDist(id, dist + 1, targetId);
		}
	}

	void labelVDist(int targetId, int dist, int parentId) {
		nodes[targetId].vDist = dist;
		for (int id : nodes[targetId].connNodes) {
			if (parentId == id) {
				continue;
			}
			labelVDist(id, dist + 1, targetId);
		}
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Integer.parseInt(tokens[0]);
		u = Integer.parseInt(tokens[1]) - 1;
		v = Integer.parseInt(tokens[2]) - 1;
		nodes = new Node[N];
		for (int i = 0; i < N; ++i) {
			nodes[i] = new Node(i);
		}
		for (int i = 0; i < N - 1; ++i) {
			tokens = in.readLine().split(" ");
			int a = Integer.parseInt(tokens[0]) - 1;
			int b = Integer.parseInt(tokens[1]) - 1;
			nodes[a].connNodes.add(b);
			nodes[b].connNodes.add(a);
		}
		// 距離のラベル付け
		labelUDist(u, 0, -1);
		labelVDist(v, 0, -1);
	}

	void calc() {
		// vDist > uDistの条件を満たす場所で，vDistが最大の場所が理論上の場所
		int goal = v;
		int dist = 0;
		for (int i = 0; i < N; ++i) {
			Node node = nodes[i];
			if (node.uDist < node.vDist) {
				if (dist < node.vDist) {
					dist = node.vDist;
					goal = node.id;
				}
			}
		}
		result = dist - 1;

	}

	void showResult() {
		System.out.println(result);
	}
}

Measured memory_bytes: 95632
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         998244353
#define mode        1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265359

const int N = 2e5+5;


void solve()
{
      ll a,b,c;
      cin>>a>>b>>c;
      if(a==b && b==c) cout<<"Yes";
      else cout<<"No";
}

int main()
{
    speed_up
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    set<string>st;
    rep(i,n){
        string s;
        cin>>s;
        st.insert(s);
    }   
    cout<<st.size()<<endl;
    return 0;
}

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

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

    if(a <  b) cout << "a < b" <<endl;
    if(a > b) cout << "a > b" <<endl;
    if(a == b) cout << "a == b" <<endl;

}




Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;


int main(){
	string S;
	cin >> S;
	int result = 0;
	for(int i = 0 ; i < S.length(); i++){
		if(S[i]=='+'){
			result++;
		}else{
			result--;
		}
	}
	cout << result << endl;
	return 0;
}


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

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

      int[] a = new int[4];
      a[0] = N / 1000;
      for(int i = 1; i < 4; i++){
          N    = a[i] = N % (int)Math.pow(10, 4 - i);
          a[i] = a[i] / (int)Math.pow(10, 3 - i);
          }
      if((a[0] != a[1] && a[1] != a[3]) || a[1] != a[2]){
         System.out.println("No");
         }
      else{
          System.out.println("Yes");
          }
   }
}


Measured memory_bytes: 21972
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int t = sc.nextInt();
		int a = sc.nextInt();
		double mindiff = Double.MAX_VALUE;
		
		int check = 0;
		int[] h = new int[n];
		
		for(int i = 0;i<n;i++) {
			h[i] =sc.nextInt();
			double T = t-h[i] * 0.006;
			double diff = Math.abs(a-T);
			if(mindiff > diff) {
				mindiff = diff;
				check = i;
			}
		}
		System.out.println(check+1);
	}
}

Measured memory_bytes: 23380
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 100005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   cout<<(1000 - (n%1000))%1000<<endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
using namespace std;
 
int main(){
  // むずすぎぃ
  double a, b, c, d, e, f;
  while( cin >> a >> b >> c >> d >> e >> f){
    double y = ( a * f - c * d) / ( a * e - b * d);
    double x = ( c - b * y ) / a;
    cout << fixed << setprecision(3) << x << " " << y << endl;
  }
  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        int count = 0;
        string s = Console.ReadLine();  //標準入力
        string t = Console.ReadLine();  //標準入力
        for (int j = 0; j < 3; j++)
        {
            if (s.Substring(j, 1) == t.Substring(j, 1))
                count++;
        }

        Console.WriteLine(count);
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <stdbool.h>

bool is_leap_year(int y);
int get_leap_years(int* leap_years_list, int year_begin, int year_end);


int main()
{
    int leap_years_list[1000]; //A.D. 0 - A.D. 3000 の間に閏年は高々1000個しかない

    bool first_set = true; //一つ目のセットの前にだけは改行を入れてはいけないので

    while (true) {
        int year_begin, year_end;

        //読み込み
        scanf("%d %d", &year_begin, &year_end);

        //終了判定
        if (year_begin == 0 && year_end == 0) {
            break;
        }

        //閏年を計算する
        int leap_years_count = get_leap_years(leap_years_list, year_begin, year_end);

        //セットとセットの間には空行を入れる
        if (first_set) {
            first_set = false;
        } else {
            putchar('\n'); //putcharは一文字だけ出力する関数です
        }

        //閏年を出力
        if (leap_years_count == 0) {
            puts("NA"); //putsは与えられた文字列を出力した後改行する関数です
        } else {
            for (int i = 0; i < leap_years_count; i++) {
                printf("%d\n", leap_years_list[i]);
            }
        }
        
    }
}

bool is_leap_year(int y)
{
    if (y % 400 == 0) {
        return true; 
    } else if (y % 100 == 0) {
        return false;
    } else {
        return y % 4 == 0;
    }
}

int get_leap_years(int* leap_years_list, int year_begin, int year_end)
{
    int year;
    int i = 0;
    for (year = year_begin; year <= year_end; ++year){
        if (is_leap_year(year) == true) {
        *(leap_years_list + i) = year;
        ++i;
        }
    }
    return i;
}

Measured memory_bytes: 1048
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str.
   builtin functions :
   __builtin_popcount(n) : no. of set bits in n.
   __builtin_parity(n) : parity of no. of set bits
   __builtin_clz(n) : no. of leading zeros before 1
   __builtin_ctz(n) : no of zeros from last to first occurrence of 1
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll binlen(ll a)
{
	ll v = 0;
	for(ll i=0;i<61;++i)
	{
		v += (1ll<<i);
		if(a<=v) return i;
	}
}

ll ar[M];
vector<pi> adj;
vector<ll> tmp,sm;

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

	ll n,k,q,i,b,v,mn = 1e9,j,l,s;

	cin >> n >> k >> q;

	for(i=1;i<=n;++i)
	{
		cin >> ar[i];
		adj.pb(pi(ar[i],i));
	}
	
	sort(all(adj));

	for(auto u:adj)
	{
		i = u.ss;
		b = 0;
		v = 0;
		for(j=1;j<=n;++j)
		{
			if(ar[j]<u.ff)
			{
				l = j-b-1;
				if(l>=k)
					v += l-k+1;
				b = j;
			}
		}
		l = j-b-1;
		if(l>=k)
			v += l-k+1;
		b = j;
		if(v>=q)
		{
			b = 0;
			for(j=1;j<=n;++j)
			{
				if(ar[j]<u.ff)
				{
					l = j-b-1;
					if(l>=k)
					{
						sort(all(tmp));
						for(s=0;s<l-k+1;++s)
							sm.pb(tmp[s]);
					}
					b = j;
					tmp.clear();
				}
				else
					tmp.pb(ar[j]);
			}
			l = j-b-1;
			if(l>=k)
			{
				sort(all(tmp));
				for(s=0;s<l-k+1;++s)
					sm.pb(tmp[s]);
			}
			tmp.clear();
			b = j;
			sort(all(sm));
			mn = min(mn,sm[q-1]-sm[0]);
			sm.clear();
		}
	}

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


Measured memory_bytes: 3724
sx,sy,tx,ty = map(int,input().split())
no1 = ''
for i in range(ty-sy):
    no1 += 'U'
for i in range(tx-sx):
    no1 += 'R'
no2 = ''
for i in range(ty-sy):
    no2 += 'D'
for i in range(tx-sx):
    no2 += 'L'
print(no1+no2+'LU'+no1+'RD'+'RD'+no2+'LU')


Measured memory_bytes: 9244
#include<cstdio>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<iostream>
#define MAXN 100005
#define LL long long
#define ULL unsigned LL
#define rg register
#define lowbit(x) (-(x) & (x))
#define ENDL putchar('\n')
#define DB double
//#pragma GCC optimize(2)
//#pragma G++ optimize(3) 
//#define int LL
using namespace std;
inline int read() {
	int f = 1,x = 0;char s = getchar();
	while(s < '0' || s > '9') {if(s == '-') f = -1;s = getchar();}
	while(s >= '0' && s <= '9') {x = x * 10 - '0' + s;s = getchar();}
	return x * f;
}
int n,m,i,j,s,o,k;
int h[MAXN];
bool f[MAXN];
signed main() {
	n = read(); m = read();
	for(int i = 1;i <= n;i ++) {
		h[i] = read(); f[i] = 1;
	}
	for(int i = 1;i <= m;i ++) {
		s = read();o = read();
		if(h[s] <= h[o]) f[s] = 0;
		if(h[o] <= h[s]) f[o] = 0;
	}
	int ans = 0;
	for(int i = 1;i <= n;i ++) {
		ans += f[i];
	}
	printf("%d\n",ans);
	return 0;
}  

Measured memory_bytes: 4248
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#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>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int n, m;
  cin >> n >> m;

  vector<vector<int>> Graph(n, vector<int>(0));
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    Graph[a].push_back(b);
    Graph[b].push_back(a);
  }

  queue<int> que;
  vector<int> dist(n, -1);
  vector<int> res(n-1);
  dist[0] = 0;
  que.push(0);

  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (int nv : Graph[v]) {
      if (dist[nv] != -1) continue;
      dist[nv]  = dist[v]+1;
      res[nv-1] = v;
      que.push(nv);
    }
  }

  cout << "Yes" << endl;
  rep(i,n-1) cout << res[i]+1 << endl;
  return 0;
}

Measured memory_bytes: 10528
#include <stdio.h>

int main(void){
    int a,b;
    char op;
    for(;;){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?') break;
        if(op=='+') printf("%d\n",a+b);
        if(op=='-') printf("%d\n",a-b);
        if(op=='*') printf("%d\n",a*b);
        if(op=='/') printf("%d\n",a/b);
    }
    return 0;
}


Measured memory_bytes: 2692
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::*;
use proconio::{input, fastout, marker::*};

#[fastout]
fn main() {
  input!{
      s:Chars,
      t:Chars
  }
  let mut ans = 10000;
  for i in 0..s.len()-t.len()+1 {
      let mut anss = 0;
      for l in 0..t.len() {
          if s[i+l] != t[l]{
            anss += 1;
          }
      }
      if ans > anss {ans = anss;}
  }
  println!("{}",ans);
}


Measured memory_bytes: 2208
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	string s, t;
	cin >> s >> t;
	int n=s.size();
	for(int i=0; i<n; i++){
		s=s.back()+s.substr(0,n-1);
		if(s==t){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<bitset>
#include<cmath>
using namespace std;

int h, w, a[80][80], b[80][80], mid = 6480;
bitset<12960> dp[2][80], temp;
 
int main() {
  scanf("%d%d", &h, &w);
  for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) scanf("%d", &a[i][j]);
  for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) scanf("%d", &b[i][j]);
  dp[0][0][mid+a[0][0]-b[0][0]] = true;
  dp[0][0][mid-a[0][0]+b[0][0]] = true;
  for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) if (i + j > 0) {
    if (i == 0) temp = dp[i&1][j-1];
    else if (j == 0) temp = dp[!(i&1)][j];
    else temp = dp[!(i&1)][j] | dp[i&1][j-1];
    int x = abs(a[i][j]-b[i][j]);
    dp[i&1][j] = (temp >> x) | (temp << x);
  }
  for (int i = 0;; i++) if (dp[!(h&1)][w-1][mid-i] || dp[!(h&1)][w-1][mid+i]) {
    printf("%d\n", i);
    return 0;
  }
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    int N = 1407;
    int K = 38;
    cout<<N<<" "<<K<<endl;
    for(int i=0; i<K; i++)
    {
        cout<<1<<" ";
        for(int j=0; j<K-1; j++)
        {
            cout<<j+2+(K-1)*i;
            if(j!=K-2)
                cout<<" ";
        }
        cout<<endl;
    }

    for(int i=0; i< K-1; i++)
    {
        for(int j=0; j<K-1; j++)
        {
            cout<<i+2<<" ";
            for(int a= 1; a<K; a++)
            {
                cout<<(a*i+j)%(K-1)+2+(K-1)*a;
                if(a!=K-1)
                    cout<<" ";
            }
            cout<<endl;
        }

    }
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#define MAX 500000

int heap[MAX];

void swap(int i,int j){
  int buf = heap[i];
  
  heap[i] = heap[j];
  heap[j] = buf;
}

void maxHeap(int H, int i) {
  int l = 2 * i, r = 2 * i + 1;
  int largest = i;
  
  if (l <= H && heap[l] > heap[i])largest = l;
  if (r <= H && heap[r] > heap[largest])largest = r;
  if (largest != i) {
    swap(i, largest);
    maxHeap(H, largest);
  }
}

void buildMaxHeap(int H) {
  for (int i = H / 2; i >= 1; i--) {
    maxHeap(H, i);
  }
}

int main() {
  int H;
  
  scanf("%d", &H);
  for(int i = 1; i <= H; i++) scanf("%d", &heap[i]);
  buildMaxHeap(H);
  for(int i = 1; i <= H; i++) printf(" %d", heap[i]);
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 3680
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <tuple>
#include <vector>

std::tuple<long, long> fight(long m, long f)
{
  if (m <= f) {
    f -= m;
    m = 0;
  } else {
    m -= f;
    f = 0;
  }
  return std::make_tuple(m, f);
}

long solve(
    int n,
    std::vector<long> monster_counts,
    const std::vector<long>& fighter_powers)
{
  const auto sum0 =
      std::accumulate(monster_counts.begin(), monster_counts.end(), 0l);
  for (int i = 0; i < n; ++i) {
    auto& m1 = monster_counts[i];
    auto f = fighter_powers[i];
    std::tie(m1, f) = fight(m1, f);
    if (f > 0) {
      auto& m2 = monster_counts[i + 1];
      std::tie(m2, f) = fight(m2, f);
    }
  }

  return sum0
      - std::accumulate(monster_counts.begin(), monster_counts.end(), 0l);
}

int main()
{
  int n;
  std::cin >> n;

  std::vector<long> monster_counts(n + 1);
  for (auto& a : monster_counts) {
    std::cin >> a;
  }

  std::vector<long> fighter_powers(n);
  for (auto& b: fighter_powers) {
    std::cin >> b;
  }

  std::cout << solve(n, monster_counts, fighter_powers) << std::endl;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
    	Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();
        int x = scanner.nextInt();
        k = k * 500;
        if(k>=x){
        	System.out.println("Yes");
            }
       	else{
        	System.out.println("No");
            }
        }
    }

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

using namespace std;

int main() {
	int n,d;
	cin >>n>>d;
	vector<vector<double>> x(n, vector<double>(d));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < d; j++)
		{
			cin >> x.at(i).at(j);
		}		
	}
	int ans=0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i+1; j < n; j++)
		{
			double dis2=0;
			for (int k = 0; k < d; k++)
			{
				dis2 += (x.at(i).at(k) - x.at(j).at(k) )* (x.at(i).at(k) - x.at(j).at(k) );
			}
			if(sqrt(dis2)==ceil(sqrt(dis2))) ans+=1;		
		}
	}
	
	cout <<ans;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int x;
  for (int i = 0; i < 10000; i++) {
    std::cin >> x;
    if (x == 0) {
      break;
    }
    std::cout << "Case " << i + 1 << ": " << x << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3072
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
long int dp[100005],h[100005];
long int min(long int a,long int b)
{
    if(a>=b)
        return b;
    else
        return a;
}
void rec(long int n)
{
    if(n==1)
        dp[1]=0;
    else if(n==2)
        dp[2]=labs(h[2]-h[1]);
    else
    {
        if(dp[n-1]==-1)
            rec(n-1);
        if(dp[n-2]==-1)
            rec(n-2);
        dp[n]=min(dp[n-1]+labs(h[n]-h[n-1]),dp[n-2]+labs(h[n]-h[n-2]));
    }
}
int main()
{
    memset(dp,-1,100005*sizeof(long int));
    long int n;
    scanf("%ld",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%ld",&h[i]);
    }
    rec(n);
    printf("%ld\n",dp[n]);
    return 0;
}


Measured memory_bytes: 4864
s = gets.chomp
if s =~ /^.*keyence$/ || s = ~ /^k.*eyence$/ || s =~ /^ke.*yence$/ ||
    s =~ /^key.*ence$/ || s =~ /^keye.*nce$/ || s =~ /^keyen.*ce$/ ||
    s =~ /^keyenc.*e$/ || s =~ /^keyence.*$/
  puts 'YES'
else
  puts 'NO'
end


Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define num(a) a-'0'
#define maxself(a,b) if(b>a)a=b
#define minself(a,b) if(b<a)a=b;
#define debug(x) cout<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define vl vector<long long int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define ln "\n"
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF=1e9+7;
ll INF=1e11;

void solve(){
	ll n;
	cin>>n;
	int h=1;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			h=i;
		}
	}
	cout<<(h-1)+(n/h)-1<<ln;
}

int main(){
	boost_io;
	solve();
	return 0;
}

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

const double INF = 1<<21;

struct town{
    double x, y;
};

int main(){
    int n, p[8];
    town t[8];
    cin >> n;
    rep(i,n){
        town a;
        cin >> a.x >> a.y;
        t[i] = a;
    }
    rep(i,n) p[i] = i+1;
    
    double avg = 0;
    double cnt = 0;
    do{
        double len = 0;
        for(int i = 0; i < n-1; i++){
            town t1 = t[p[i]-1], t2 = t[p[i+1]-1];
            len += sqrt((t1.x - t2.x)*(t1.x - t2.x) + (t1.y - t2.y)*(t1.y - t2.y));
        }
        avg += len;
        cnt++;
    }while(next_permutation(p,p+n));

    printf("%lf\n", avg/cnt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

    ll size(int x){
        return Size[root(x)];
    }
};

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, R;
    cin >> N >> R;
    UnionFind uni(N + 1);
    for(int i = 1; i <= N; i++) {
        int P;
        cin >> P;
        uni.merge(i, P);
    }
    bitset<150001> dp;
    dp[0] = 1;
    for(int i = 1; i <= N; i++) {
        if(uni.root(i) != i) continue;
        dp |= dp<<uni.size(i);
    }
    if(dp[min(R, N - R)]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 7584
#include <iostream>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int n,y;
int main() {
    cin >> n >> y;
    int a=0,b=0,c=0;
    int ra=-1,rb=-1,rc=-1;
    REP(i,9){
        b=i;
        int y1 = y-5000*b;
        REP(j,n-i+1){
            a = j;
            c = n-i-j;
            if((a*10000+c*1000)==y1){
                ra=a;
                rb=b;
                rc=c;
            }
        }
    }
    
    cout << ra << " " << rb << " "<< rc << endl;
    return 0;
}


Measured memory_bytes: 256