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

int main(){
  int N, T;
  cin >> N >> T;
  int c[1005], t[1005];
  int mini = 2000;
  for(int i = 0;i < N; ++i){
    cin >> c[i] >> t[i];
    if(t[i] <= T){
      mini = min(mini, c[i]);
    }
  }
  if(mini == 2000){
    cout << "TLE" << endl;
  }else{
    cout << mini << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include <stdint.h>
#include <inttypes.h>

#define M 500000
#define INFTY 1000000001

int count;

void merge(int *, int ,int ,int );
void mergeSort(int *, int , int );
  
int main(){
  int S[M];

  int i,j,n;
  int l, mid , r;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  l=0;
  r=n;
  
  mergeSort(S,l,r);

  
  printf("%d",S[0]);
  for(i=1;i<n;i++)
    printf(" %d",S[i]);
  printf("\n");
  printf("%d\n",count);
  
  return 0;

}


void merge(int *A, int left, int mid,int right)
{
  int i,j,k,n1,n2;
  int L[M],R[M];

  
  n1 = mid - left;
  n2 = right - mid;


  
  /* L[0...n1], R[0...n2] を生成*/
  for (i = 0;i<n1;i++)
      L[i] = A[left + i];
  for (i = 0;i< n2;i++)
    R[i] = A[mid + i];
  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
    for (k = left;k<right;k++){
      count++;
      if (L[i] <= R[j]){
       A[k] = L[i];
      
       i = i + 1;
     }
     else{ 
       A[k] = R[j];
       j = j + 1;
     }
    }

 }
 
void mergeSort(int *A, int left, int right)
   {
     int mid;


     
     if (left+1 < right){
       mid = ((left) + (right))/2;
       mergeSort(A, left, mid);
       mergeSort(A, mid, right);
       merge(A, left, mid, right);
     }
   }



Measured memory_bytes: 5636
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
pair<int,int>A[233333];int n,m,d;
priority_queue<int,vector<int>,greater<int>>q,v;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%d%d",&A[i].first,&A[i].second);
	sort(A+1,A+n+1);
	for(int i=d=1;i<=n;++i)if(d<=m&&A[i].first>=d)q.push(A[i].second),++d;else q.push(A[i].second),v.push(q.top()),q.pop();
	for(int i=d;i<=m&&!v.empty();++i)if(i>=v.top())v.pop();
	printf("%d",v.size());return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<ll> l(n);
  rep(i,n){
    cin>>l[i];
  }
  int ans=0;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      for(int k=j+1; k<n; k++){
        if(l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i]&&l[i]+l[j]>l[k]&&l[j]+l[k]>l[i]&&l[k]+l[i]>l[j]) ans++;
      }
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int n,c,t=0;
string itos(ll a)
{
	string s;
	while(a>0)
	{
		int e=a%10ll;
		s+=e+'0';
		a/=10ll;
	}
	reverse(s.begin(),s.end());
	return s;
}
bool is_palindrome(ll p)
{
	string s=itos(p);
	if(s[n]!=(c+'0'))return false;
	for(int i=0;i<((int)s.size())/2;i++)
	{
		if(s[i]!=s[s.size()-1-i])return false;
	}
	return true;
}
bool is_prime(ll x)
{
	for(ll i=2;i*i<=x;i++)
	{
		if(x%i==0)return false;
	}
	return true;
}
int main()
{
	cin >> n >> c;
	if(c>=0)t=1;
	if(n==1&&c<0)
	{
		cout << 11 << endl;
		return 0;
	}
	if(c<0)
	{
		for(int i=0;i<2*n;i++)cout << 9;
		cout << endl;
		return 0;
	}
	int mx=((int)pow(10,2*n+t))-1,mi=((int)pow(10,2*n+t-1));
	for(int i=mx;i>=mi;i--)
	{
		if(!is_palindrome(i))continue;
		if(!is_prime(i))continue;
		cout << i << endl;
		return 0;
	}
	cout << ((int)pow(10,2*n+t))-1 << endl;
	return 0;
}

Measured memory_bytes: 1248
#include<stdio.h>
int main()
{
	long long w,h,x,y;
	while(~scanf("%lld%lld%lld%lld",&w,&h,&x,&y))
	{
		printf("%.6lf ",(double)(w*h)/2.0);
		double xx=w*1.0/2.0;
		double yy=h*1.0/2.0;
		if((xx==x)&&(yy==y))
		{
			printf("1\n");
	    }
		else
		{
			printf("0\n");
		}
	}
	return 0;
}

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

def trial_division(n):
    if n < 2:
        return []
    res = []
    tmp = n
    for i in range(2, int(n**0.5)+1):
        c = 0
        if tmp%i == 0:
            while tmp%i == 0:
                c += 1
                tmp //= i
            res.append([i, c])
    if tmp != 1:
        res.append([tmp, 1])
    return res

div = trial_division(n)
c = 0
for d in div:
    k = d[1]
    i = 1
    while k-i >= 0:
        c += 1
        k -= i
        i += 1
print(c)

Measured memory_bytes: 9436
n=int(input())
l=list(map(int,input().split()))

cnt=0
ans=0

lis=[(l[i+1]-l[i]) for i in range(n-1)]

for i in lis:
  if i<=0:
    cnt+=1
  else:
    ans=max(cnt, ans)
    cnt=0
    
ans=max(cnt, ans)
    
print(ans)

Measured memory_bytes: 20648
#include <cstdio>
#include <vector>
#include <queue>
#include <cstdint>
#include <algorithm>
using namespace std;

typedef int64_t i64;
const i64 mod = 1e9 + 7;

int main()
{
	i64 n, k;

	scanf("%lld%lld", &n, &k);

	int sq = 0;
	while((sq + 1) * (sq + 1) <= n) {
		sq += 1;
	}

	vector<i64> maxi(sq * 2);

	for(int i = 0; i < sq; i++) {
		maxi[i] = i + 1;
	}
	for(int i = sq; i < sq * 2; i++) {
		maxi[i] = n / maxi[sq * 2 - 1 - i];
	}

	vector<i64> prev(sq * 2), cur(sq * 2, 1);

	for(int step = 1; step <= k; step++) {

		swap(prev, cur);
		fill(cur.begin(), cur.end(), 0);

		cur[0] = prev[sq * 2 - 1];

		for(int i = 1; i < sq * 2; i++) {
			i64 r = maxi[i] - maxi[i - 1];
			i64 v = r * prev[sq * 2 - 1 - i];
			cur[i] = (cur[i - 1] + v) % mod;
		}
	}

	printf("%lld\n", cur[sq * 2 - 1]);

	return 0;
}


Measured memory_bytes: 1664
class Dice:
 
    def __init__(self, faces):
        self.faces = tuple(faces)
 
    def roll_north(self):
        self.faces = (self.faces[1], self.faces[5], self.faces[2],
                      self.faces[3], self.faces[0], self.faces[4])
 
    def roll_south(self):
        self.faces = (self.faces[4], self.faces[0], self.faces[2],
                      self.faces[3], self.faces[5], self.faces[1])
 
    def roll_west(self):
        self.faces = (self.faces[2], self.faces[1], self.faces[5],
                      self.faces[0], self.faces[4], self.faces[3])
 
    def roll_east(self):
        self.faces = (self.faces[3], self.faces[1], self.faces[0],
                      self.faces[5], self.faces[4], self.faces[2])
 
    def rotate(self):
        self.faces = (self.faces[0], self.faces[2], self.faces[4],
                      self.faces[1], self.faces[3], self.faces[5])
 
    def number(self, face_id):
        return self.faces[face_id - 1]
 
    def issame(self, other_dice):
        for i in range(4):
            if self.faces[0] == other_dice.faces[0]:
                for j in range(4):
                    if self.faces == other_dice.faces:
                        return True
                    self.rotate()
            self.roll_north()
 
        for i in range(4):
            if self.faces[0] == other_dice.faces[0]:
                for j in range(4):
                    if self.faces == other_dice.faces:
                        return True
                    self.rotate()
            self.roll_east()
        return False
 
dice_list = []
n = int(input())
for i in range(n):
    dice_list.append(Dice([int(a) for a in input().split()]))
 
res = "Yes"
for i in range(n):
    for j in range(i + 1, n):
        if dice_list[i].issame(dice_list[j]):
            res = "No"
            break
print(res)

Measured memory_bytes: 7804
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
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;
}

int main() {
	int N;
	cin >> N;
	vector <int> v( N );
	vector <int> c( N );
	rep( i, 0, N )
		cin >> v[ i ];
	rep( i, 0, N )
		cin >> c[ i ];
	int lim = (int)pow(2, N);
	int maximum = -k_mod;
	rep(bit,0,lim){
		int cost = 0;
		int sum = 0;
		fprintf(stderr, "(%d)", bit);
		rep(i,0,N){
			if (bit & (1 << i)){
				cost += c[i];
				sum += v[i];
			}
		}
		fprintf(stderr, "\n");
		if (maximum < sum-cost)
			maximum = sum-cost;
	}
	cout << maximum << endl;
}


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

int main(){
	int n, m;
	cin >> n >> m;
	
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	
	vector<pair<int, int>> p(m); //c,b�̏�
	for(int i = 0; i < m; i++) cin >> p[i].second >> p[i].first;
	sort(p.begin(), p.end());
	
	int num = 0;
	for(int i = m-1; i >= 0; i--){
		int b = p[i].second, c = p[i].first;
		while(a[num] < c && b > 0){
			a[num++] = c;
			b--;
		}
	}
	
	long long ans = 0;
	for(int i = 0; i < n; i++) ans += a[i];
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1408
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)


int main()
{
	int n, m;
	vector<string> a(50);
	vector<string> b(50);
	cin >> n >> m;
	string forFill = "";
	FOR(i, 0, 50) {
		forFill += " ";
	}
	fill(a.begin(), a.end(), forFill);
	fill(b.begin(), b.end(), forFill);
	FOR(i, 0, n) {
		cin >> a[i];
	}
	FOR(j, 0, m) {
		cin >> b[j];
	}
	bool result = false;
	FOR(i, 0, n-m+1) {
		FOR(j, 0, n - m + 1) {
			if (a[i][j] == b[0][0]) {
				result = true;
				FOR(x, 0, m) {
					FOR(y, 0, m) {
						if (a[i + x][j + y] != b[x][y]) {
							result = false;
						}
					}
				}
				if (result == true) {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
def main():
    n, k = map(int,input().split())
    li = list(map(int,input().split()))
    pi_list = [(i + 1) / 2 for i in li]
    spot = 0
    for i in range(k):
        spot += pi_list[i]
    ans_li = []
    ans_li.append(spot) 
    for i in range(n-k):
        spot -= pi_list[i]
        spot += pi_list[i+k]
        ans_li.append(spot)
    print(max(ans_li))

if __name__ == '__main__':
    main()

Measured memory_bytes: 25060
class Array
  def abs; map{|k| k.abs } end
end

n = gets.to_s.to_i
a = gets.to_s.split.map{|t|t.to_i}

n_nega = 0
ans_sum = 0
abs_min = 1_000_000_000

a.each do |t|
  
  ab = t.abs
  
  ans_sum += ab
  
  abs_min = ab if abs_min > ab
  
  n_nega += 1 if t < 0
  
end

puts n_nega.even? ? ans_sum : ans_sum - abs_min * 2 

Measured memory_bytes: 8580
from collections import deque
H,W = map(int, input().split())
A = []
for _ in range(H):
    temp = list(input())
    A.append(temp)
ans = 0
Q = deque([])
break_loop = 1
def bfs(x,y):
    global break_loop
    next_ = [[x+1,y],[x-1,y],[x,y+1],[x,y-1]]
    for i in next_:
        if 0 <= i[0] <= H-1 and 0 <= i[1] <= W-1 and A[i[0]][i[1]] == ".":
            break_loop = 0
            A[i[0]][i[1]] = "#"
            Q.append([i[0],i[1]])

for j in range(H):
    for k in range(W):
        if A[j][k] == "#":
            Q.append([j,k])

while len(Q) > 0:
    break_loop = 1
    for _ in range(len(Q)):
        Q_next = Q.popleft()
        bfs(Q_next[0],Q_next[1])
    if break_loop:
        break
    else:
        ans += 1
print(ans)

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


int main()
{
    string s;
    cin >> s;
    string ans;
    string tmp="";
    rep(i,s.length()){
        switch (s[i])
        {
        case 'A':
        case 'C':
        case 'G':
        case 'T':
            tmp += s[i];
            if(i==s.length()-1&&tmp.length()>ans.length()) ans=tmp;
            break;
        default:
            if(tmp.length()>ans.length()) ans=tmp;
            tmp="";
            break;
        }
    }
    cout << ans.length() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n;
    while(cin>>n){
        int ans=0;
        for(int i=0; i<n; ++i)
            cin>>a[i];
       int tmp=n-1;
        for(int i=n-2; i>=0; --i){
            if(a[i]<a[i+1])
                tmp=i;  
            ans=max(ans, tmp-i);
        }
        cout<<ans<<endl;
    }
  return 0;
}




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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

int ans = 0;
int n, digitCount;
int kind[] = {0, 3, 5, 7};

void is753(int array[]) {
  int target = 0;
  REP(i, digitCount) { target += array[i] * pow(10, i); }
  if (target > n) return;
  int remain;
  bool is3, is5, is7;
  is3 = is5 = is7 = false;
  while (target != 0) {
    remain = target % 10;
    if (remain == 7) {
      is7 = true;
    } else if (remain == 5) {
      is5 = true;
    } else if (remain == 3) {
      is3 = true;
    } else {
      return;
    }
    target /= 10;
  }
  if (is7 == true && is5 == true && is3 == true) ans++;
}

void dfs(int array[], int index) {
  if (index >= digitCount) {
    is753(array);
    return;
  }
  for (int i = 0; i < 4; i++) {
    array[index] = kind[i];
    dfs(array, index + 1);
  }
}

signed main() {
  n = read();
  digitCount = 0;
  int tmp = n;
  while (tmp != 0) {
    tmp /= 10;
    digitCount++;
  }
  int array[digitCount];
  dfs(array, 0);
  print(ans);
}


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

int main(){
    string s;
    cin >> s;
    int swap = 0;
    int count = 0;
    char last = s[0];

    for(int i = 1; i < s.size(); ++i){
        char curr = s[i];
        if(curr != last){
            last = curr;
            continue;
        }
        if(curr == '0'){
            last = '1';
        }else{
            last = '0';
        }
        swap++;
    }
    cout << swap << endl;

}

Measured memory_bytes: 3712
using System;

class MyClass
{
    static void Main(string[] args)
    {
        System.Collections.ArrayList al = new System.Collections.ArrayList();
        string str = "";
        while ((str = Console.ReadLine()) != null)
        {
            al.Add(int.Parse(str));
        }
        al.Sort();
        al.Reverse();
        Console.WriteLine(al[0]);
        Console.WriteLine(al[1]);
        Console.WriteLine(al[2]);
    }
}


Measured memory_bytes: 20148
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#define inf 2147483647
#define eps 1e-9
#define lb(x) (x&-x)
#define mod 1000000007
#define mp make_pair
using namespace std;
typedef int ll;
typedef pair<int,int> pr;
int n,m,ans=1,tot=0,tmp,t1,t2,t[500001],a[100001],b[100001],h[100001];
pr p[100001];
bool cmp(pr a,pr b){
	return a.first==b.first?a.second>b.second:a.first<b.first;
}
void add(int u,int x){
	for(;u<=n;u+=lb(u)){
		t[u]=(t[u]+x)%mod;
	}
}
int query(int u){
	int ret=0;
	for(;u;u-=lb(u)){
		ret=(ret+t[u])%mod;
	}
	return ret;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=m;i++)scanf("%d",&b[i]);
	for(int i=1;i<=n;i++){
		if(a[i]>b[1]&&a[i]<b[m]){
			tmp=lower_bound(b+1,b+m+1,a[i])-b;
			//if(a[i]==b[tmp])continue;
			p[++tot]=pr(a[i]-b[tmp-1],b[tmp]-a[i]);
			h[tot]=b[tmp]-a[i];
		}
	}
	sort(h+1,h+tot+1);
	t1=unique(h+1,h+tot+1)-h-1;
	for(int i=1;i<=tot;i++){
		p[i].second=lower_bound(h+1,h+t1+1,p[i].second)-h;
	}
	sort(p+1,p+tot+1,cmp);
	t2=unique(p+1,p+tot+1)-p-1;
	for(int i=1;i<=t2;i++){
		tmp=query(p[i].second-1)+1;
		ans=(ans+tmp)%mod;
		add(p[i].second,tmp);
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

signed main(){
	cout<<fixed<<setprecision(7);

	int N, A[200];
	
	cin>>N;
	
	rep(i,N){
		cin>>A[i];
	}
	for(int i = 1; i <= 101; i++){
		bool flag = true;
		int xx = 0;
		for(int j = 0; j < N; j++){
			xx += A[j];
			xx -= i;
			if(xx < 0)flag = false;
		}
		if(flag == false){
			cout<<i-1<<endl;
			break;
		}
	}
	
	return 0;
}


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

int main(){
	while( 1 ){
		int N, Q;
		cin >> N >> Q;
		if( N == 0 ) break;
		int list[101], i, j;
		for( i = 1; i < 101; i++ ){
			list[i] = Q;
		}
		for( i = 0; i < N; i++ ){
			int M, date;
			cin >> M;
			for( j = 0; j < M; j++ ){
				cin >> date;
				list[date]--;
			}
		}
		int ans = 0;
		for( i = 0; i < 101; i++ ){
			if( list[i] <= 0 ){
				if( ans == 0 || list[i] < list[ans] ){
					ans = i;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
 
const int N = 1e5 + 5;
 
int x, n;
int a[N];
 
int32_t main()
{
    cin >> x >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int off = 0; ;off++)
    {
        int val = x - off;
        int flag = 1;
        for(int i = 1; i <= n; i++)
            flag &= (a[i] != val);
        if(flag)
        {
            cout << val;
            return 0;
        }
        val = x + off;
        flag = 1;
        for(int i = 1; i <= n; i++)
            flag &= (a[i] != val);
        if(flag)
        {
            cout << val;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3596
#include<stdio.h>
int main(void)
{
    int h,m,s,S;
    scanf("%d",&S);
    
    h=S/3600;
    m=S%3600/60;
    s=S%3600%60;
    
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}


Measured memory_bytes: 2140
#include <set>
#include <vector>
#include <iostream>

int main() {
    int N;

    std::cin >> N;

    std::set<int> set_A;

    for (int i = 0; i < N; ++i) {
        int inp;
        std::cin >> inp;
        set_A.insert(inp);
    }

    if (set_A.size() == N) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 9600
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int r;
   cin >> r;
   cout << 3*r*r << endl;
   return 0;
}


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

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    x -= a;
    while (true) {
        if(x < b) break;
        x -= b;
    }
    cout << x << endl;
    return 0;
}

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

n, m = map(int, input().split())
if n == 1 and m == 1:
    print(1)
    sys.exit(0)
if n == 1:
    print(m - 2)
    sys.exit(0)
if m == 1:
    print(n - 2)
    sys.exit(0)

print(n * m - (n * 2 + m * 2 - 4))


Measured memory_bytes: 61940
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  areaX := nextInt()
  areaY := nextInt()
  x := nextInt()
  y := nextInt()
  r := nextInt()
  if 0 <= x - r && x + r <= areaX && 0 <= y - r && y + r <= areaY {
      fmt.Println("Yes")
  } else {
      fmt.Println("No")
  }
}


func nextInt() (int) {
    sc.Scan()
    v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}



Measured memory_bytes: 1112
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    string S;
    cin >> S;
    int ans = 0;
    for(int i=0;i<S.size();i++){
        if(S[i] == '+'){
            ans++;
        }
        else{
            ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3184
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  queue<int> Q;
  vector<int> seki(17);
  Q.push(0);
  int time = 0;
  int hoge[100];
  while(1) {
    REP(i, 17) if (seki[i]) seki[i]--;
    if (Q.size() && Q.front() >= 100) break;
    bool f = 0;
    do {
      if (Q.empty()) break;
      int a = Q.front();
      if (a >= 100) break;
//    cout << "a" << " " << a << endl;
      f = 0;
      
      int num = a%5==1 ? 5 : 2;
      int tmp = 0;
      REP(i,17) {
        if (seki[i] == 0) ++tmp;
        else tmp = 0;
        if (tmp >= num) {
          for (int j=i-tmp+1; j<=i; ++j) {
//            cout << j << endl;
            hoge[a] = time - a*5;
            seki[j] = 17*(a%2)+3*(a%3)+19;
          }
          Q.pop();
          f = 1;
          break;
        }
      }
      // cout << time << endl;
      // FOR(it, seki)
      //   cout << *it << " ";
      // cout << endl;
    } while(f);
    
    time++;
    if (time % 5 == 0) Q.push(time/5);
  }
  int n;
  while(cin >> n) {
    cout << hoge[n] << endl;
  }
}

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

int is_prime(int n) {
  for (int i = 2; i < n; i++) {
    if (i * i > n) break;
    if (n % i == 0) return false;
  }
  return true;
}

int main() {
  int X; cin >> X;
  if (X <= 2) cout << 2 << endl;
  else {
    int n = X; if (n % 2 == 0) n += 1;
    while (!is_prime(n)) n += 2;
    cout << n << endl;
  }
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self):
        self.data = {}
        self.heights = {}
        self.sizes = {}

    def get_num_trees(self):
        return len(self.heights)

    def get_tree_size(self, a):
        return self.sizes[self.get_root(a)]

    def add_node(self, a):
        self.data[a] = a
        self.heights[a] = 1
        self.sizes[a] = 1

    def get_root(self, a):
        nodes = [a]
        while nodes[-1] not in self.heights:
            nodes.append(self.data[nodes[-1]])
        for x in nodes:
            self.data[x] = nodes[-1]
        return nodes[-1]

    def union(self, a, b):
        root_a = self.get_root(a)
        root_b = self.get_root(b)
        if root_a == root_b:
            return
        if self.heights[root_a] > self.heights[root_b]:
            a, b = b, a
            root_a, root_b = root_b, root_a
        self.data[root_a] = root_b
        self.heights[root_b] = max(self.heights.pop(root_a) + 1, self.heights[root_b])
        self.sizes[root_b] += self.sizes.pop(root_a)

    def find(self, a, b):
        return self.get_root(a) == self.get_root(b)


N, M = map(int, input().split())
uf = UnionFind()
for i in range(1, N + 1):
    uf.add_node(i)

for _ in range(M):
    A, B = map(int, input().split())
    uf.union(A, B)

print(max(uf.sizes.values()))

Measured memory_bytes: 50288
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    for (int i = 0; i < 4; i++)
    {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    sort(ALL(a));
    int ans=INF;
    do
    {
        int suma=a[0]+a[1];
        int sumb=a[2]+a[3];
        int sum=abs(suma-sumb);
        chmin(ans,sum);
    } while (next_permutation(a.begin(), a.end()));
    cout << ans << "\n";
}



Measured memory_bytes: 3220
n, k = map(int,input().split())
s = list(input())
 
if s[k-1] == "A":
  s[k-1] = "a"
elif s[k-1] == "B":
  s[k-1] = "b"
elif s[k-1] == "C":
  s[k-1] = "c"
 
print("".join(s))

Measured memory_bytes: 3060
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}


int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    ll x = readInt(), y = readInt();
    ll min_ans = 1e18;
	vector<int> h = { -1, 1 };
	for (int i : h)
		for (int n : h)
			if (y * i >= x * n) {
				ll ans = (i < 0) + (n < 0) + (y * i - x * n);
				min_ans = min(min_ans, ans);
			}
	cout << min_ans << endl;
	return 0;                                             
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath>
#include <math.h>
using namespace std;

int main(){
    double N,ans;
    cin>>N;
    ans=round(N/1.08);
    if(floor(ans*1.08)!=N) {
        if(N<=10) cout<<":("<<endl;
        else if(floor((ans+1)*1.08)==N)cout<<ans+1<<endl;
        else cout<<":("<<endl;
    }
    else cout<<ans<<endl;
}

Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i)

groups = []
gi = 0
A.each do |a|
  groups[gi] ||= []
  if a == 0
    gi += 1
    next
  end
  groups[gi] << a
end

ans = 0
groups_size = groups.size
groups.each_with_index do |group, idx|
  minus_count = group.count { |a| a < 0 }
  if minus_count.odd? && gi == 0
    sorted_group = group.sort_by { |a| a.abs }
    ans += sorted_group[1..-1].inject(0) { |sum, a| sum + a.abs } - sorted_group[0].abs
  else
    ans += group.inject(0) { |sum, a| sum + a.abs }
  end
end

puts ans

Measured memory_bytes: 16892
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=200086;
const int maxm=400086;
int head[maxn],Next[maxm],to[maxm],vis[maxn],cnt;
long long ans;
int a[maxn],p[maxn],f[maxn],n;
inline int Read(){
	int x=0;char c=getchar();
	while (!isdigit(c))c=getchar();
	while (isdigit(c)){
		x=(x<<1)+(x<<3)+c-48;
		c=getchar();
	}
	return x;
}
int main(){
	n=Read();
	for (int i=1;i<=n;i++){
		a[i]=Read();
	}
	if (a[1]){
		printf("-1");
		return 0;
	}
	for (int i=2;i<=n;i++){
		if (a[i]-a[i-1]>=2){
			printf("-1");
			return 0;
		}
	}
	for (int i=2;i<=n;i++){
		if (!a[i])continue;
		if (a[i]==a[i-1]+1)ans++;
		else ans+=a[i];
	}
	printf("%lld",ans);
	return 0;
}

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

int main() {
    vector<int> X(4);
    for(int i=0;i<4;i++)
    {
      cin>>X.at(i);
    }
    
  
     int a=X.at(0)-X.at(2);
     int b=X.at(1)-X.at(3);
  
  //  cout<<a<<b<<endl;
  
    int c=X.at(2)+b;
    int d=X.at(3)-a;
  
    
  
    int e=-a;
    int f=-b;
  
    int g=X.at(0)-f;
    int h=X.at(1)+e;
  
    cout<<c<<" "<<d<<" "<<g<<" "<<h<<endl;
  
  
  
  
}

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

int main(){
  int N;
  cin >> N;
  int res = 0;
  for (int a = 0; a <= N/4; ++a) {
    for (int b = 0; b <= N/7; ++b) {
      int total = 4*a + 7*b;
      if (total == N) ++res;
    }
  }
  if(res > 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

typedef long long LL;
#define MAXN 100010

int L[MAXN], R[MAXN];


struct nodeL
{
	int x;
	bool operator < (const nodeL &t)const
	{
		if (L[x] == L[t.x]) return x < t.x;
		return L[x] < L[t.x];
	}
};

struct nodeR
{
	int x;
	bool operator < (const nodeR &t)const
	{
		if (R[x] == R[t.x]) return x < t.x;
		return R[x] < R[t.x];
	}
};

set<nodeL> setL;
set<nodeR> setR;
 
void go(int &now, int &to, LL &tmp)
{
	int l = L[to], r = R[to];
	if (l <= now && now <= r) return;
	if (now < l) tmp += l - now, now = l;
	else if (now > r) tmp += now - r, now = r;
}
int main()
{
	//freopen("in.txt", "r", stdin);
	int n;	
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> L[i] >> R[i];
	
	LL ans = 0, tmp = 0;
	int now = 0, to;
	for (int i = 1; i <= n; ++i)
	{
		setL.insert((nodeL){i});
		setR.insert((nodeR){i});
	}
	for (int i = 1; i <= n; ++i)
	{
		//cout << setL.size() << " " << setR.size() << endl;
		if (i & 1)
		{
			to = (*setL.rbegin()).x;
			setL.erase((nodeL){to});
			setR.erase((nodeR){to});
		}
		else
		{
			to = (*setR.begin()).x;
			setL.erase((nodeL){to});
			setR.erase((nodeR){to});
		}
	//	cout << to << endl;
		//cout << now << " " << tmp << endl;
		go(now, to, tmp);
	}
	tmp += abs(now);
	ans = max(ans, tmp);
	now = 0; tmp = 0;
	for (int i = 1; i <= n; ++i)
	{
		setL.insert((nodeL){i});
		setR.insert((nodeR){i});
	}
	for (int i = 1; i <= n; ++i)
	{
		if (!(i & 1))
		{
			to = (*setL.rbegin()).x;
			setL.erase((nodeL){to});
			setR.erase((nodeR){to});
		}
		else
		{
			to = (*setR.begin()).x;
			setL.erase((nodeL){to});
			setR.erase((nodeR){to});
		}
	//	cout << to << endl;
		go(now, to, tmp);
		//cout << now << " " << tmp << endl;
	}
	tmp += abs(now);
	ans = max(ans, tmp);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<vector<pair<int, int> > > e(N, vector<pair<int, int> >());
  REP(i, N-1){
    int u, v, w; cin >> u >> v >> w; u--; v--;
    e[u].push_back({v, w});
    e[v].push_back({u, w});
  }
  vector<int> ans(N, -1);
  queue<pair<int, int> > q;
  q.push({0, 0});
  ans[0] = 0;
  while(!q.empty()){
    auto p = q.front(); q.pop();
    for(auto &i : e[p.first]){
      if(ans[i.first] != -1) continue;
      if(i.second%2 == 0){
        ans[i.first] = ans[p.first];
      }else{
        ans[i.first] = (ans[p.first] == 0 ? 1 : 0);
      }
      q.push(i);
    }
  }
  for(auto &i : ans) cout << i << endl;
}

Measured memory_bytes: 6784
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
constexpr double pi = M_PI;
using namespace std;

#define int long long

signed main()
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    int plug = 1;
    while (plug < b) {
        plug -= 1;
        plug += a;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

double dp[610];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,m;
    cin >> n >> m;
    vvi G(n);
    rep(_,m) {
        int s,t;
        cin >> s >> t;
        s--; t--;
        G[s].pb(t);
    }
    auto f = [&](int s,int t)->double {
        rep(i,n) dp[i] = inf;
        dp[n-1] = 0;
        rrep(i,n-1) {
            int sz = G[i].size();
            if(i == s) sz--;
            if(sz) dp[i] = 0;
            for(int j : G[i]) {
                if(i == s and j == t) continue;
                dp[i] += (dp[j]+1)/sz;
            }
        }
        return dp[0];
    };
    double ans = f(-1,-1);
    vp can;
    rep(i,n) {
        double mx = 0;
        for(int j : G[i]) chmax(mx,dp[j]);
        for(int j : G[i]) if(dp[j] == mx) can.eb(i,j);
    }
    for(auto p : can) chmin(ans,f(p.first,p.second));
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int N,K;
  cin>>N>>K;
  
  int count=0;
  while(N>0){
    N/=K;
    ++count;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
from itertools import permutations
from collections import Counter

def main():
    H, W = map(int, input().split())
    cost = [[0]*10 for _ in range(10)]

    for i in range(10):
        line = tuple(map(int, input().split()))
        for j, e in enumerate(line):
            cost[i][j] = e

    seq = (0, 2, 3, 4, 5, 6, 7, 8, 9)
    for i in range(2, 10):
        for p in permutations(seq, i):
            temp = sum([cost[p[j]][p[j+1]] for j in range(i-1)])
            temp += cost[p[-1]][1]
            cost[p[0]][1] = min(cost[p[0]][1], temp)

    c = Counter()
    for _ in range(H):
        temp = Counter(tuple(map(int, input().split())))
        c += temp

    ans = 0
    for i in seq:
        ans += c[i] * cost[i][1]
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 44252
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    int s[26]={0},l,p,i,f=0;
    char a[26];
    cin>>a;
    l=strlen(a);
    for(i=0;i<l;i++)
    {
        p=a[i];
        p=p-97;
        //cout<<p<<endl;
        s[p]++;
        //cout<<s[p]<<endl;
    }
    for(i=0;i<26;i++)
    {
        if(s[i]>1)
        {
            cout<<"no"<<endl;
            f=1;
            break;
        }
    }
    if(f==0)
    {
        cout<<"yes"<<endl;
    }
}


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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;

int e;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = INT_MAX / 2;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	while (1) {
		cin >> e;
		if (e == 0) break;
		LL ans = INF;
		int dx, dy, dz;
		for (LL z = 0;z < 100 + 1;z++) {
			for (LL y = 0;y < 1000 + 1;y++) {
				if (e - z * z * z - y * y < 0) continue;
				LL x = e - z * z * z - y * y;
				ans = min(ans, x + y + z);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3228
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int n,m;
vector<pair<int,int>> g[111];
int mat[111][111];
int on[111];
int List[111],l;

int f(int cur){
	if(cur == n){
		if(l <= 1) return 0;
		int res = 0;
		rep(i,l){
			int x = INF;
			rep(j,l) x = min(x, mat[List[i]][List[j]]);
			res += x;
		}
		return res;
	}
	int res = f(cur+1);
	int ok = 1;
	rep(i,l)if(!mat[cur][List[i]]){
		ok=0; break;
	}
	if(ok){
		List[l++] = cur;
		res = max(res, f(cur+1));
		l--;
	}
	return res;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>n>>m;
	rep(i,n){
		mat[i][i] = INF;
	}
	rep(i,m){
		int u,v,F;
		cin>>u>>v>>F;
		u--;v--;
		g[u].pb(mp(v,F));
		g[v].pb(mp(u,F));
		mat[u][v] = mat[v][u] = F;
	}
	l=0;
	cout<<f(0)<<endl;
}

Measured memory_bytes: 1256
N = int(input())
ans = 0
for n in range(1,N+1,2):
    d = set()
    m = 1
    while m*m <= n:
        if n%m==0:
            d.add(m)
            d.add(n//m)
        m += 1
    if len(d)==8:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#define N 100

void bubbleSort(int A[],int n);
  
int main(){
  int buf,n,i,j=0,flag = 0;
  int A[N];
  
  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<n;i++){
    for(j=n-1;j>=i;j--){
      if(A[j+1]<A[j]){
	buf = A[j+1];
	A[j+1] = A[j];
	A[j] = buf;
	flag++;
      }
    }
  }
  
  bubbleSort(A,n);
  printf("%d\n",flag);
  
  return 0;
}

void bubbleSort(int A[],int n){
  int i;
  
  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int a, c;
    char b;
    while(cin >> a >> b >> c, b != '?'){
        if(b == '*'){
            cout  << a * c  <<endl;
        }
        if(b == '-'){
            cout <<a-c <<endl;
        }
        if(b == '+'){
            cout <<a+c <<endl;
        }
        if(b == '/'){
            cout <<a/c<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int a,b,c;

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

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

  else
    cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
using namespace std;

string s;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> s;
    if( s=="AAA" || s=="BBB" ){
        cout << "No";
    }else{
        cout << "Yes";
    }

    return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n, m;
	cin >> n >> m;
	set<P> sp;
	rep(i, m){
		int s, c;
		cin >> s >> c;
		sp.insert(make_pair(s, c));
	}

	rep(i, 1000){
		vi dig;
		dig.push_back(i % 10);
		int nx = i / 10;
		while(nx != 0){
			dig.push_back(nx % 10);
			nx /= 10;
		}
		if(dig.size() != n) continue;
		bool flg = true;
		reverse(all(dig));
		for(auto t : sp){
			if(dig[t.first-1] != t.second){
				flg = false;
			}
		}

		if(flg){
			cout << i << endl;
			return 0;
		}
		dig.clear();
	}
	cout << -1 << endl;
	return 0;
}

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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            var ans = "ABC" + GetStr();

            Console.WriteLine(ans);


            Console.Out.Flush();
            Console.ReadKey();
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public Double[] GetDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V,W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W,X>(out T a, out U b, out V c, out W d,out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);e = cv<X>(ar[4]);
        }
    }
}

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

static const int MAX = 200000;

int main(){
    int R[MAX], n;

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> R[i];
    }
    int max = R[1] - R[0];
    int c = max;
    int min = R[0]<R[1]?R[0]:R[1];

    for(int i=2;i<n;i++){
        c = R[i] - min;
        if(c > max){
            max = c;
        }
        if(min > R[i]){
            min = R[i];
        }
    }
    cout << max << endl;
}


Measured memory_bytes: 3836
#include <iostream>

int main() {
    std::string n;
    std::cin>>n;
    long long ans=0;
    for(char x : n){
        ans+=x-'0';
    }
    if(ans%9==0){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3748