akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 200001
#define pb push_back
using namespace std;
int fa[N],c[N],n,siz[N],u[N],v[N],qi[N<<1],qfa[N<<1],qsiz[N<<1],qn,Q;vector<int> vc[N],seg[N<<2];long long ans[N];
struct edge{int v,next;edge(){}edge(int _v,int _next){v=_v;next=_next;}}e[N<<1];int head[N],sz;
void init(){memset(head,-1,sizeof(head));sz=0;}void insert(int u,int v){e[++sz]=edge(v,head[u]);head[u]=sz;}
int get(int a){return fa[a]?get(fa[a]):a;}void merge(int a,int b)
{
	if((a=get(a))==(b=get(b)))return;qi[++qn]=a;qfa[qn]=fa[a];qsiz[qn]=siz[a];qi[++qn]=b;qfa[qn]=fa[b];qsiz[qn]=siz[b];
	if(siz[a]<siz[b])swap(a,b);fa[b]=a;siz[a]+=siz[b];
}
void add(int l,int r,int p){for(l+=Q-1,r+=Q-1;l<=r;l>>=1,r>>=1){if(l&1)seg[l++].pb(p);if(!(r&1))seg[r--].pb(p);}}
void undo(){for(int _=2;_;--_)fa[qi[qn]]=qfa[qn],siz[qi[qn]]=qsiz[qn],--qn;}set<int> st;
void dfs(int x)
{
	for(int i=0;i<seg[x].size();++i)merge(u[seg[x][i]],v[seg[x][i]]);
	if(x>=Q)
	{
		if(x-Q+1<=n)
		{
			st.clear();for(int i=0;i<vc[x-Q+1].size();++i)for(int j=head[vc[x-Q+1][i]];~j;j=e[j].next)if(c[e[j].v]^x-Q+1)st.insert(get(e[j].v));
			for(set<int>::iterator it=st.begin();it!=st.end();++it)ans[x-Q+1]-=1ll*siz[*it]*(siz[*it]+1)/2;
		}
	}
	else dfs(x<<1),dfs(x<<1|1);for(int i=0;i<seg[x].size();++i)undo();
}
int main()
{
	init();scanf("%d",&n);for(int i=1;i<=n;++i)scanf("%d",c+i),siz[i]=1;Q=1;while(Q<n)Q<<=1;
	for(int i=1;i<n;++i)
	{
		scanf("%d%d",&u[i],&v[i]),insert(u[i],v[i]),insert(v[i],u[i]);
		if(c[u[i]]>c[v[i]])swap(u[i],v[i]);add(1,c[u[i]]-1,i);add(c[u[i]]+1,c[v[i]]-1,i);add(c[v[i]]+1,n,i);
	}
	for(int i=1;i<=n;++i)vc[c[i]].pb(i);for(int i=1;i<=n;++i)if(!vc[i].empty())ans[i]=1ll*n*(n+1)/2;dfs(1);
	for(int i=1;i<=n;++i)printf("%lld\n",ans[i]);fclose(stdout);return 0;
}

Measured memory_bytes: 94660
#include<iostream>

int main()
{
	int m[100], f[100], r[100];
	int count = 0;

	for (int i = 0; ; i++) {
		std::cin >> m[i] >> f[i] >> r[i];
		count++;
		if (m[i] == -1 && f[i] == -1 && r[i] == -1) {
			count--;
			break;
		}
	}

	for (int i = 0; i < count; i++) {
		if (m[i] == -1 || f[i] == -1)
			std::cout << "F" << std::endl;
		else if (m[i] + f[i] >= 80)
			std::cout << "A" << std::endl;
		else if (m[i] + f[i] < 80 && m[i] + f[i] >= 65)
			std::cout << "B" << std::endl;
		else if (m[i] + f[i] < 65 && m[i] + f[i] >= 50)
			std::cout << "C" << std::endl;
		else if (m[i] + f[i] < 50 && m[i] + f[i] >= 30 && r[i] < 50)
			std::cout << "D" << std::endl;
		else if (m[i] + f[i] < 50 && m[i] + f[i] >= 30 && r[i] >= 50)
			std::cout << "C" << std::endl;
		else if (m[i] + f[i] < 30)
			std::cout << "F" << std::endl;
	}
}

Measured memory_bytes: 1152
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  vector<string> S(N);
  rep(i, N)cin >> S[i];
  bool ok=true;
  rep(i, N-1){
    ok = ok and S[i][S[i].size()-1] == S[i+1][0];
  }
  set<string> s;
  rep(i, N)s.insert(S[i]);
  ok = ok and s.size() == N;
  if(ok)cout << "Yes";
  else cout << "No";
  return 0;
}


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

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        int[] time = new int[5];
        for(int i = 0; i < 5; i++){
            time[i] = scan.nextInt();
        }

        int[] time2 = new int[5];
        for(int i = 0; i < 5; i++){
            time2[i] = (int)ceil( (double)(time[i])/10.0 ) * 10;
        }


        int max = 0;
        int count = 0;
        int tmp =0;
        for(int i = 0; i < 5; i++){

            tmp = time2[i]-time[i];
            if(max <= tmp){
                max = tmp;
                count = i;
            }
        }

        int ans = 0;
        for(int i = 0; i < 5; i++) {

            if(i == count){

                ans += time[i];

            }else{

                ans += time2[i];
            }
        }

        System.out.println(ans);
    }
}

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

int main()
{
    long long int a,b,n;
    long long int c,d;

    cin>>n>>a>>b;
    if(a>b)
    {
        cout<<"0";
        return 0;
    }
     if(n==1)
    {
        if(a==b)
        {
        cout<<"1";
        return 0;
        }
        else{
            cout<<"0";
            return 0;
        }
    }
    if(a==b)
    {
        cout<<"1";
        return 0;
    }
    c=(n-2)*b;
    d=(n-2)*a;
    if(d>c)
        swap(c,d);
    cout<<c-d+1;
}


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

#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define f(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pc __builtin_popcount // counts number of 1's in bin(num)
#define pb push_back
#define mp make_pair

// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";

void solve(){
	int n,m; cin >> n >> m;
	ll h[n];
	bool ans[n];
	f(i,0,n) ans[i] = 1;
	f(i,0,n) cin >> h[i];
	f(i,0,m){
		int a,b; cin >> a >> b;
		--a; --b;
		if(h[a] > h[b]){
			ans[b] = 0;
		} else if(h[a] < h[b]){
			 ans[a] = 0;
		}else{
			 ans[a] = 0;
			 ans[b] = 0;
		}
	}
	int l = 0;
	f(i,0,n){
		if(ans[i] == 1) l++;
	}
	cout << l;
}

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








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

int main() {
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;

  int moneyA = 0, moneyC = 0;

  for (int i = 0; i < N; i += A) {
    moneyA += B;
  }

  for (int i = 0; i < N; i += C) {
    moneyC += D;
  }

  moneyA <= moneyC ? cout << moneyA << endl : cout << moneyC << endl;
}


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

int main()
{
	string T;
	cin >> T;
	int count = 0, temp = 0;
	for (int i = 0; i < T.size(); i++){
		if (T[i] != 'A' && T[i] != 'G' && T[i] != 'C' && T[i] != 'T'){
			count = max(temp, count);
			temp = 0;
		} else {
			temp++;
		}
	}
	count = max(temp, count);
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import fractions

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)

A, B = inm()


def solve():
    x = fractions.gcd(A, B)
    ans = 0
    for k in range(2, x + 1):
        if k * k > x:
            break
        cnt = 0
        while x % k == 0:
            x //= k
            cnt += 1
        if cnt:
            ans += 1
    if x > 1:
        ans += 1
    return ans + 1


print(solve())


Measured memory_bytes: 5712
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define N 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))
#define cio ios::sync_with_stdio(false);
int s[100010];
struct node{
    int a, b;
}q[100010];
int main()
{
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> s[i];
    for(int i = 1; i <= m; i++) cin >> q[i].a >> q[i].b;
    map<int,int>jud;
    for(int i = 1; i <= m; i++){
        int x = q[i].a;
        int y = q[i].b;
        if(s[x]>s[y]){
            jud[y] = -1;
        }
        if(s[y]>s[x]){
            jud[x] = -1;
        }
        if(s[y]==s[x]){
            jud[x] = -1;
            jud[y] = -1;
        }
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(jud[i]==0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 9492
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    int[] inputArray;

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

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
int k = sc.nextInt();
int[] array = new int[n];

for(int i=0; i<n; i++){
array[i] = sc.nextInt();
}

Arrays.sort(array);

int sum = 0;

for(int i=n-1; i>=n-k; i--){
sum+= array[i];
}

System.out.println(sum);
    }

}


Measured memory_bytes: 21716
import sys
from heapq import heappush, heappop


N, Q = map(int, input().split())
P = []
for i in range(1, N + 1):
    s, t, x = map(int, sys.stdin.readline().split())
    P.append((s - x, t - 1 - x, x))
P.sort()


q = []
cur = 0
ans = [-1] * Q
for i, d in enumerate(map(int, sys.stdin)):
    while cur < N and P[cur][0] <= d:
        s, t, x = P[cur]
        heappush(q, (x, t))
        cur += 1
    while q:
        x, t = q[0]
        if d <= t:
            ans[i] = x
            break
        else:
            heappop(q)

print(*ans, sep='\n')

Measured memory_bytes: 108348
using System;
using System.Collections.Generic;
using System.Linq;

namespace ACorWA
{
    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');

            int allCases = int.Parse(input[0]);
            int attempts = int.Parse(input[1]);
            

            if(allCases == attempts)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13140
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
    int n;
    cin>>n;
    cout<<(n+1)/2;
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 256
from _collections import deque


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
import scipy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/arc081/tasks/arc081_b
# D - Coloring Dominoes
"""
need to consider the case that ticket is not enough to lower everything
"""
N = gi()
A = [0] * N

for i in range(N):
    A[i] = gi()

ans = 0
for i in range(N):
    pairs = A[i] // 2
    ans += pairs
    A[i] -= pairs * 2
    if A[i] % 2:
        if i + 1 < N and A[i + 1]:
            ans += 1
            A[i] -= 1
            A[i + 1] -= 1

print(ans)


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

#define CNST_DAY 365
#define NUM_CONTEST 26


int D,c[NUM_CONTEST+1]={},s[CNST_DAY+1][NUM_CONTEST+1]={},last[NUM_CONTEST+1]={},t[CNST_DAY+1]={};
long v[CNST_DAY+1]={};

void Scoring(int d){
    int i;
    v[d]=v[d-1]+s[d][t[d]];
    for(i=1;i<=NUM_CONTEST;i++){
        v[d]-=c[i]*(d-last[i]);
    }
    return;
}

int main(void){

    int i,j,k,d,n;
    int dmin,*dp,*qp;
    long M;

    //入力
    scanf("%d",&D);
    for(d=1;d<=NUM_CONTEST;d++){
        scanf("%d",&c[d]);
    }
    for(d=1;d<=D;d++){
        for(i=1;i<=NUM_CONTEST;i++){
            scanf("%d",&s[d][i]);
        }
    }
    for(d=1;d<=D;d++){
        scanf("%d",&t[d]);
    }
    scanf("%ld",&M);
    dp=(int *)malloc((M+1)*sizeof(int));
    qp=(int *)malloc((M+1)*sizeof(int));
    for(j=1;j<=M;j++){
        scanf("%d %d",&dp[j],&qp[j]);
    }

    //変更と出力
    for(j=1;j<=M;j++){
        t[dp[j]]=qp[j];
        for(i=1;i<=NUM_CONTEST;i++){
            last[i]=0;
        }
        for(d=1;d<=D;d++){
            v[d]=0;
        }
        for(d=1;d<=D;d++){
            //開催するコンテストt[d]を決めた後
            last[t[d]]=d;
            Scoring(d);
        }
        printf("%ld\n",v[D]);
    }

    free(dp);
    free(qp);
    return 0;
}

Measured memory_bytes: 2152
n, k = gets.chomp.split(' ').map(&:to_i)
w = n.times.map{gets.chomp.to_i}

N_MAX = K_MAX = 100000
W_MAX = 10000

left = 0
right = N_MAX * W_MAX
mid = nil

load_buggage = -> (p) do
  i = 0
  0.step(k-1) do |j|
    s = 0
    #STDERR.puts "  kj=#{j}"
    while s + w[i] <= p
      s += w[i]
      #STDERR.puts "    #{i}: w[#{i}]=#{w[i]}, s=#{s}"
      i += 1
      break if i == n
    end
    break if i == n
  end
  #STDERR.puts "load: #{i}"
  i
end

until (right - left) == 1 do
  mid = (left + right) / 2
  #STDERR.puts "L=#{left}, M=#{mid}, R=#{right}"
  v = load_buggage.(mid)
  if (v >= n)
    right = mid
  else
    left = mid
  end
end

puts right


Measured memory_bytes: 9804
import java.util.*;

public class Main {
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		@SuppressWarnings("unchecked")
		ArrayList<String>[] a = new ArrayList[6];
		for(int i=0;i<6;i++) a[i] = new ArrayList<String>();
		String[][] b = new String[6][n];
		int[][] c = new int[6][n];
		

		String s;
		int m;
		int p;
		for(int i=0;i<n;i++){
			s = sc.next();
			m = sc.nextInt();
			p = s.length();
			if(a[p].indexOf(s)==-1){
				b[p][a[p].size()] = s;
				c[p][a[p].size()] = m;					
				a[p].add(s);

			}else{
				c[p][a[p].indexOf(s)] += m;
			}
		}
		
		for(int i=1;i<6;i++){
			Collections.sort(a[i]);
			for(int j=0;j<a[i].size();j++){
				for(int k=0;k<a[i].size();k++){
					if(a[i].get(j).compareTo(b[i][k])==0){
						System.out.println(b[i][k] + " " + c[i][k]);
						break;
					}
				}
			}
		}
	}	
}

Measured memory_bytes: 40364
/* 
 * File:   main.cpp
 * Author: Sebastian Hall
 * Created on August 20, 2020, 7:27 PM
 * Purpose: https://atcoder.jp/contests/dp/tasks/dp_d
 */

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double triple;

int main() {
    ios::sync_with_stdio(false);
    //Declare variables
    ll n = 0, w = 0;
    
    cin>>n>>w;
    
    vector<ll> dp(w + 1);
    
    //Read in items weights and values
    for(int i = 0; i < n; ++i) {
        ll weight = 0, value = 0;
        
        cin>>weight>>value;
        
        //For each index where weight would fill bag all the way to empty bag
        for(ll j = w - weight; j >= 0; --j) {
            dp[j + weight] = max(dp[j + weight], dp[j] + value);//Value where item would be added is max of current value or value if item is added
        }
    }
    
    //Output answer
    cout<<dp[w]<<endl;

    //A Sebastian Production
    return 0;
}

Measured memory_bytes: 4024
#include<stdio.h>

int main(void)
{

	int a,b;

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

	if(a<b){
		printf("a < b\n");
}
	else if(a==b){
		printf("a == b\n");
}
	else{
		printf("a > b\n");
}
return 0;
}


Measured memory_bytes: 2064
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    real a, b, h, m;
    scan(a, b, h, m);
    // writeln(PI);
    double h_angle = ((60 * h + m) / 720) * 2 * PI;
    // writeln(h_angle);
    //12時間=720分で360°
    double m_angle = (m / 60) * 2 * PI;
    // writeln(m_angle);
    //60分で360°
    double angle = h_angle - m_angle;
    // writeln(angle);
    double ans = a ^^ 2 + b ^^ 2 - (2 * a * b * cos(angle));
    writef("%.10f", sqrt(ans));

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3876
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
//これがdiff300台ってマジ？怖い
int countCharType(string,string);

int main(){
  int n;
  string s;
  cin >> n >> s;
  
  int ans = 0; //最大の文字種類和
  for(int i = 1; i < n; i++){
    string s1 = s.substr(0,i);
    string s2 = s.substr(i);
    int charType = countCharType(s1,s2);
    ans = max(ans,charType);
  }
  cout << ans << endl;
}

//XとYのどちらにも含まれている文字の種類数(bothExist)を計算
int countCharType(string s1,string s2){
  sort(s1.begin(),s1.end());
  int bothExist = 0;
  rep(i,s1.size()){
    if(i==0 || s1[i] != s1[i-1]){ //Xのi番目とi-1番目の文字が異なる場合、
      if(s2.find(s1[i]) != -1) bothExist++; //i番目の文字がYに存在するか確認
    }
  }
  return bothExist;
}
  

Measured memory_bytes: 256
#include<stdio.h>
void func(int j){
	int s,m,h;
	s=j%60;
			j-=s;
			m=(j%3600)/60;
			j-=m;
			h=j/3600;
	if(m>9&&s>9)
		printf("0%d:%d:%d\n",h,m,s);
	else if(m>9&&10>s)
		printf("0%d:%d:0%d\n",h,m,s);
	else if(10>m&&10>s)
		printf("0%d:0%d:0%d\n",h,m,s);
	else printf("0%d:0%d:%d\n",h,m,s);
}
	int main(){
		int h,m,s,j,i;
		while(1){
			scanf("%d %d %d",&h,&m,&s);
			if(h==-1&&m==-1&&s==-1)break;
			j=7200-3600*h-60*m-s;
			i=j*3;
			func(j);
			func(i);
		}
		return 0;
}

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

long long int N, a, x = 111, b, i;

int main(){
    scanf("%lld", &N);
    for(; i < N; ++i){
        scanf("%lld", &b);
        if(b % 10){
            x = min(x, b);
        }
        a += b;
    }
    cout << ((x ^ 111) ? ((a % 10) ? a : a - x) : 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define endl '\n'
#define pb push_back
#define mod 1000000007
#define db(i) cout<<i<<" ";
#define db1(i) cout<<"("<<i<<")";
#define db2(i) cout<<"["<<i<<"]";
#define db3(i) cout<<"{"<<i<<"}";
#define ff first 
#define ss second
#define vv vector
#define pp pair
#define pi acos(-1);
#define printarr(a,n) cout<<"[";for(int i=0;i<n;i++){db1(a[i]);}cout<<"]";

using namespace std;

bool isprime(int n)
{
    for(int i=2;i<=sqrt(n);i++)
        if(n%i==0)
        return false;
    return true;
}
int maxarr(int *a,int n)
{
    int val=a[0];
    for(int i=1;i<n;i++)
    {
        if(val<a[i])
        {
            val=a[i];
        }
    }
    return val;
}

int minarr(int *a,int n)
{
    int val=a[0];
    for(int i=1;i<n;i++)
    {
        if(val>a[i])
        {
            val=a[i];
        }
    }
    return val;
}


int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
} 
int power(int x, int y, unsigned int p=ULLONG_MAX)  
{  
    int res = 1;     
    x = x % p; 
    if (x == 0) 
      return 0; 
    while (y > 0)  
    {    
        if (y & 1)  
           res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}
bool cmp(const pair<int,int> &a,const pair<int,int> &b)
{
    if(a.ss<b.ss)
        return true;
    else if(a.ss>b.ss)
        return false;
    else
    {
        if(a.ff<b.ff)
            return true;
        else
            return false;
    }
    
}
bool cmp1(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.ss<b.ss);
}


//if no test cases add coments for reading




signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n,m,s1,s2;
        cin>>n>>s1;
        cin>>m>>s2;
        int ti;
        cin>>ti;
        if(n<m)
        {
            n+=(ti*s1);
            m+=(ti*s2);
            if(n>=m)
            {
                cout<<"YES";
            }
            else
            {
                cout<<"NO";
            }
        }
        else if(n>m)
        {
            n-=(ti*s1);
            m-=(ti*s2);
            if(n<=m)
            {
                cout<<"YES";
            }
            else
            {
                cout<<"NO";
            }
            
            
        }
        else
        {
            cout<<"YES";
        }
        
     
      
    }
   
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  int n,t,a;
  cin >> n >> t >> a;
  vector<int> h=input(n);
  vector<int> diff(n,0);
  rep(i,n){
    diff[i]=abs((t*1000-h[i]*6)-a*1000);
  }
  int x=1000000000,res=0;
  rep(i,n){
    if(x>diff[i]){
      x=diff[i];
      res=i;
    }
  }
  cout << res+1 << endl;
}


Measured memory_bytes: 256
w,h,n=map(int,input().split())
l=[0,w,0,h]
for i in range(n):
  a,c,d=map(int,input().split())
  x= c if (d)//3 else a
  f=min if (d-1)%2 else max
  l[d-1]=f(l[d-1],x)
if l[0]<l[1] and l[2]<l[3]:
  print((l[1]-l[0])*(l[3]-l[2]))
else:print(0)

Measured memory_bytes: 3064
N=int(input())
l_2d = []
for i in range(N):
  l_2d.append(list(map(int,input().split())))
l_2d.sort(key=lambda x: x[1], reverse=False)
A=0
ANS='Yes'
for l in l_2d:
  A += l[0]
  if l[1] < A:
    ANS = 'No'
    break
print(ANS)

Measured memory_bytes: 53724
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(val) cerr << "Value " << #val << " : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ld epsilon = 10e-9;
const ll nax = 2e5+5;
ll n;
deque<ll>arr;	
	
int main(void){
	IOS
	cin >> n;
	for(int i=0;i<n;i++){
		ll x;
		cin >> x;
		arr.eb(x);
	}
	sort(arr.rbegin(), arr.rend());
	ll ans=0;
	ans=arr.front();
	arr.pop_front();
	for(int i=1;i+1<n;i++){
		if(i+2<n){
			ans+=(arr.front()*2);
			arr.pop_front();
			i++;
		}
		else{
			ans+=arr.front();
			arr.pop_front();
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define all(x) (x).begin(),(x).end()
#define lla(x) (x).rbegin(),(x).rend()
#define rep(i, n) for (int i = 0; i < n; i++)
#define Rep(i, n) for (int i = 1; i <= n; i++)

int n, m, a, b, c[10][10]={}, ans = 0;

main(){
    scanf("%d%d", &n, &m);
    vi s(n);
    rep(i, n)s[i]=i;
    while(m--){
        scanf("%d%d", &a, &b);
        a--;b--;
        c[a][b]++;c[b][a]++;
    }
    do {
        bool flag = true;
        for(int i=1; i<n; i++){
            if(!c[s[i-1]][s[i]]) flag = false;
        }
        ans += flag;
    } while (next_permutation(s.begin()+1, s.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<int>num(N);
  for(int i=0; i<M; i++){
    int a,b;
    cin >> a >> b;
    for(int j=0; j<N; j++){
      if ((a-1 == j) || (b-1 == j)){
        num.at(j) ++;
        continue;
      }
      else
        continue;
    }
  }
  for(int i=0; i<N; i++){
    cout << num.at(i) << endl;
  }
}

Measured memory_bytes: 256
import math
from functools import reduce
K = int(input())

def gcd(*numbers):
  return reduce(math.gcd, numbers)


ans = 0
#count = 0
for i in range(1, K + 1):
  for j in range(i, K + 1):
    for k in range(j, K + 1):
      #count += 1
      #print(count, gcd3(i, j, k))
      x = gcd(i, j, k)
      if i == j:
        if j == k:
          ans += x
        else:
          ans += 3 * x
      else:
        if i == k:
          ans += 3 * x
        elif j == k:
          ans += 3 * x
        else:
          ans += 6 * x
          

print(ans)  


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> x(n), y(n);
	for(int i = 0; i < n; ++i){ cin >> x[i] >>  y[i]; }
	vector<int> xc(x), yc(y);
	sort(xc.begin(), xc.end());
	sort(yc.begin(), yc.end());
	xc.erase(unique(xc.begin(), xc.end()), xc.end());
	yc.erase(unique(yc.begin(), yc.end()), yc.end());
	for(int i = 0; i < n; ++i){
		x[i] = lower_bound(xc.begin(), xc.end(), x[i]) - xc.begin();
		y[i] = lower_bound(yc.begin(), yc.end(), y[i]) - yc.begin();
	}
	vector< vector<int> > image(yc.size(), vector<int>(xc.size()));
	for(int i = 0; i < n; ++i){ ++image[y[i]][x[i]]; }
	vector< vector<int> > integral(yc.size() + 1, vector<int>(xc.size() + 1));
	for(int i = 1; i <= yc.size(); ++i){
		int sum = 0;
		for(int j = 1; j <= xc.size(); ++j){
			sum += image[i - 1][j - 1];
			integral[i][j] = integral[i - 1][j] + sum;
		}
	}
	while(m--){
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		int xc1 = lower_bound(xc.begin(), xc.end(), x1) - xc.begin();
		int yc1 = lower_bound(yc.begin(), yc.end(), y1) - yc.begin();
		int xc2 = upper_bound(xc.begin(), xc.end(), x2) - xc.begin();
		int yc2 = upper_bound(yc.begin(), yc.end(), y2) - yc.begin();
		int answer = integral[yc2][xc2] - integral[yc2][xc1] - integral[yc1][xc2] + integral[yc1][xc1];
		cout << answer << endl;
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    stack<int> st;
    int ans = 0;
    rep(i, S.length()){
        if(st.empty()) st.push(S[i]-'0');
        else{
            if(st.top() == S[i]-'0') st.push(S[i]-'0');
            else{
                ans += 2;
                st.pop();
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
	string s;
	cin >> s;
	int c = 0;
	if (s.size() > 1) {
		for (int i = 1; i < s.size(); i++) {
			if (s[i-1] == s[i]) {
			} else {
				c++;
			}
		}
	}
	cout << c << endl;
	return 0;
}

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

int N, i, j, Ans, sub, judg, a, b, c;
int main()
{
	cin >> a >> b;
	if (a > 12)
		cout << b;
	else if (a > 5)
		cout << b / 2;
	else
		cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{

	public static void main(String[] args){

		Scanner sc =new Scanner(System.in);

		int n=sc.nextInt();
		int a[];
		a=new int [n];

		for(int i=0;i<n;i++)
			a[i]=sc.nextInt();
		
		selectionSort(a,n);

}

	private static void  selectionSort(int a[],int n) {

		int count=0,temp=0,minj;

		for(int i=0;i<n;i++) {
			minj=i;
			for(int j=i;j<n;j++) 
				if(a[j]<a[minj]) 
					minj=j;
				if(minj!=i) {
					temp=a[i];
					a[i]=a[minj];
					a[minj]=temp;
					count++;
				}
		}

		for(int i=0;i<n-1;i++)
			System.out.print(a[i]+" ");
		System.out.println(a[n-1]);
		System.out.println(count);

	}

}


Measured memory_bytes: 26264