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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

signed main() {
    string S;
    int Q;
    cin >> S >> Q;
    int countT = 0;
    string be, en;
    be = en = "";
    rep(i, Q) {
        int T;
        cin >> T;
        if (T == 1) {
            countT++;
        } else {
            int F;
            cin >> F;
            if ((F + countT) % 2 == 1) {
                string c;
                cin >> c;
                be = c + be;
            } else {
                string c;
                cin >> c;
                en = en + c;
            }
        }
    }
    S = be + S + en;
    if (countT % 2 == 1) {
        reverse(S.begin(), S.end());
    }
    cout << S << endl;
}


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

int main() {
  int n;
  cin >> n;
  bool ans = false;
  
  for(int a = 1; a <= 9; a++){
    for(int b = 1; b <= 9; b++){
      if(n==a*b){
        ans = true;
        break;
      }
    }
  }
  
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n,w=map(int,input().split())
dp=[0]*(w+1)
for i in range(n):
    w2,v2=map(int,input().split())
    for j in range(w,w2-1,-1):
        tmp=dp[j-w2]+v2
        if tmp>dp[j]:
            dp[j]=tmp
print(dp[w])

Measured memory_bytes: 41324
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    vector<string> s(20005);
    int h,w;
    cin >> h >> w;
    rep(i,h) cin >> s[i];

    vector<vector<int> > left(h,vector<int>(w));
    vector<vector<int> > right(h,vector<int>(w));
    vector<vector<int> > up(h,vector<int>(w));
    vector<vector<int> > down(h,vector<int>(w));

    for(int i=0;i<h;i++){
        if(s[i][0]=='#') left[i][0]=-1;
        else left[i][0] = 0;
        for(int j=1;j<w;j++){
            if(s[i][j]=='#'){
                left[i][j]=-1;
                continue;
            }
            left[i][j] = left[i][j-1]+1;
        }
    }
    for(int i=0;i<h;i++){
        if(s[i][w-1]=='#') right[i][w-1]=-1;
        else right[i][w-1] = 0;
        for(int j=w-2;j>=0;j--){
            if(s[i][j]=='#'){
                right[i][j]=-1;
                continue;
            }
            right[i][j] = right[i][j+1]+1;
        }
    }
    for(int j=0;j<w;j++){
        if(s[0][j]=='#') up[0][j]=-1;
        else up[0][j] = 0;
        for(int i=1;i<h;i++){
            if(s[i][j]=='#'){
                up[i][j]=-1;
                continue;
            } 
            up[i][j] = up[i-1][j]+1;
        }
    }
    for(int j=0;j<w;j++){
        if(s[h-1][j]=='#') down[h-1][j]=-1;
        else down[h-1][j] = 0;
        for(int i=h-2;i>=0;i--){
            if(s[i][j]=='#'){
                down[i][j]=-1;
                continue;
            }
            down[i][j] = down[i+1][j]+1;
        }
    }
    int ans=0;
    rep(i,h) rep(j,w){
        if(s[i][j]=='#') continue;
        int count = left[i][j]+right[i][j]+up[i][j]+down[i][j]+1;
        ans = max(ans,count);
    }
    cout << ans << endl;
}

Measured memory_bytes: 67328
def main():
    n = int(input())

    ans = "No"
    for i in range(1, 10):
        q, r = divmod(n, i)
        if 1 <= q <= 9 and r == 0:
            ans = "Yes"
            break

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

ll maxi(ll a,ll b)
{
  if(a>b) return a;
  else return b;
}

ll mini(ll a,ll b)
{
  if(a>b) return b;
  else return a;
}

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

  ll s=mini(n,m/2);
  ll c=maxi(0,(m-2*s)/4);
  cout<<s+c<<endl;
}

Measured memory_bytes: 256
while True:
    s = input()
    if s == '-':
        break
    
    s = list(s)
    m = int(input())
    for i in range(m):
        h = int(input())
        for i in range(h):
            s.append(s.pop(0))
    
    st = ''.join(s)
    for i in range(len(st)):
        if i == len(st)-1:
            print(st[i])
        else:
            print(st[i],end='')
        



Measured memory_bytes: 5624
import heapq
from collections import deque


def main():
    N, M = list(map(int, input().split(' ')))
    tasks = list()
    for _ in range(N):
        req_day, reward = list(map(int, input().split(' ')))
        latest_start_day = M - req_day
        tasks.append((-reward, latest_start_day))
    # sort by desc order of latest_start_day
    tasks.sort(key=lambda t: t[1], reverse=True)
    tasks = deque(tasks)
    task_que = []
    neg_reward = 0
    for d in range(M, -1, -1):
        while len(tasks) > 0 and tasks[0][1] >= d:
            heapq.heappush(task_que, tasks.popleft())
        if len(task_que) == 0:
            continue
        # do task first with local max reward
        task = heapq.heappop(task_que)
        neg_reward += task[0]
    print(-neg_reward)


if __name__ == '__main__':
    main()


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

int main() {
	int n;
	cin >> n;
	vector<char> sL(n), sR(n);
	for (int i = 0; i < n; i++) {
		cin >> sL[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> sR[i];
	}

	map<pair<string, string>, int> mpL;
	for (int bit = 0; bit < 1<<n; bit++) {
		string reds = "", blues = "";
		for (int i = 0; i < n; i++) {
			if (bit & 1<<i) {
				reds.push_back(sL[i]);
			}
			else {
				blues.push_back(sL[i]);
			}
		}
		mpL[make_pair(reds, blues)]++;
	}

	long long ans = 0;
	for (int bit = 0; bit < 1<<n; bit++) {
		string reds = "", blues = "";
		for (int i = 0; i < n; i++) {
			if (bit & 1<<i) {
				reds.push_back(sR[i]);
			}
			else {
				blues.push_back(sR[i]);
			}
		}
		reverse(reds.begin(), reds.end());
		reverse(blues.begin(), blues.end());
		ans += mpL[make_pair(blues, reds)];
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 60868
import java.util.*;
class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
  	int n=sc.nextInt();
  	int[] a= new int[n];
  	for(int b=0;b<n;b++){
   	a[b]=sc.nextInt();
    }
    int count=0;
    for(int b=0;b<n;b++){
    int ad=sc.nextInt();
    count+=ad;
    ad=0;
    }
  	int[] c=new int[n-1];
    for(int b=0;b<n-1;b++){
   	c[b]=sc.nextInt();
    }
  	for(int d=0;d<n-1;d++){
    if((a[d]+1)==a[d+1]){ count+=c[a[d]-1];}
    }
  	System.out.println(count);

}
}

Measured memory_bytes: 21716
import java.util.Scanner;
class Main{
	
    public void solve(){
		Scanner sc = new Scanner(System.in);
		int ninzu, k;
		int ban;
      for(int i=0; i<4; i++){
	  	ban=sc.nextInt();
		if(ban ==1){
			k=6000;
		}else if(ban ==2){
			k=4000;
		}else if(ban ==3){
			k=3000;
		}else{
			k=2000;
		}
		
		ninzu=sc.nextInt();
		int uriage = k * ninzu;;
		System.out.println(uriage);
      }
    }
	    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17328
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n<=999) {
			System.out.println("ABC");
		}
		else {
			System.out.println("ABD");
		
		// your code goes here
		}
    }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
int n, m, k, ans = INT_MAX;
vector<vector<char>>arr;
vector<vector<vector<pair<int, int>>>>d;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
int dz[] = {0, 2, 3, 1};
bool valid(int i, int j)
{
    return (i >= 0 && i < n && j >= 0 && j < m && arr[i][j] == '.');
}
void dijkstra(pair<int, int>s)
{
    set<vector<int>> q;
    for(int i = 0;i < 4;++i)
    {
        d[s.F][s.S][i] = {1, 0};
        q.insert(vector<int>{1, 0, i, s.F, s.S});
    }
    while(q.size())
    {
        vector<int>v = *q.begin();
        q.erase(q.begin());
        for(int i = 0;i < 4;++i)
        {
            int new_x = v[3] + dx[i];
            int new_y = v[4] + dy[i];
            if(!valid(new_x, new_y))
                continue;
            int new_strokes = v[0];
            int new_des = v[1];
            int new_dir = v[2];
            if(v[2] != dz[i])
            {
                ++new_strokes;
                new_des = 1;
                new_dir = dz[i];
            }
            else if(v[1] + 1 > k)
            {
                ++new_strokes;
                new_des = 1;
            }
            else
                ++new_des;
            vector<int>tmp = {new_strokes, new_des, new_dir, new_x, new_y};
            if(make_pair(new_strokes, new_des) < d[new_x][new_y][dz[i]])
            {
                q.erase(vector<int>{d[new_x][new_y][dz[i]].F, d[new_x][new_y][dz[i]].S, dz[i], new_x, new_y});
                d[new_x][new_y][dz[i]] = {new_strokes, new_des};
                q.insert(tmp);
            }
        }
    }
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m >> k;
    pair<int, int>src, des;
    cin >> src.F >> src.S >> des.F >> des.S;
    --src.F, --src.S, --des.F, -- des.S;
    arr = vector<vector<char>>(n, vector<char>(m));
    d = vector<vector<vector<pair<int, int>>>>(n, vector<vector<pair<int, int>>>(m, vector<pair<int, int>>(4, make_pair(INT_MAX, INT_MAX))));
    for(int i = 0;i < n;++i)
        for(int j = 0;j < m;++j)
            cin >> arr[i][j];
    dijkstra(src);
    for(int i = 0;i < 4;++i)
        ans = min(ans, d[des.F][des.S][i].F);
    cout << (ans == INT_MAX ? -1 : ans);
    return 0;
}


Measured memory_bytes: 144696
#include<bits/stdc++.h>
using namespace std;
int main(){
	string str;
	cin>>str;
	for(int i=0;i<str.size();i++){
		if(str[i]=='A'&&str[i+1]=='C'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace ConsoleApp
{
    class Program
    {

        static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            var a = ReadLine().Split().Select(long.Parse).ToArray();
            long sum = 0;
            long c = 0;
            int r = 0;
            for (int l = 0; l < n;l++){

                while(r < n && (sum ^ a[r]) == sum + a[r]){
                    sum += a[r];
                    r++;

                }

                c += r - l;

                if(r == l)
                    r++;
                else
                    sum -= a[l];
                
            }

            WriteLine(c);
        }

        static long Xor(long a , long b){

            var s1 =  Convert.ToString(a,2) ;
            var s2 =  Convert.ToString(b, 2);

            var len = Max(s1.Length, s2.Length);
            s1 = s1.PadLeft(len, '0');
            s2 = s2.PadLeft(len, '0');

            string res = "";

            for (int i = 0; i < len;i++)
            {
                if((s1[i] == '0' && s2[i] == '1') 
                ||(s1[i] == '1' && s2[i] == '0'))
                    res = res + '1' ;
                else
                    res = res + '0' ;
                
            }
            return Convert.ToInt32(res,2);
        }

    }

}


Measured memory_bytes: 37724
#include <bits/stdc++.h>
using namespace std;
         
    int main() {
        int N, M;
        cin >> N >> M;

        int A, B;

        if(N > 2){
            A = (N * (N-1))/2;
        }
        else if(N == 2){
            A = 1;
        }
        else{
            A = 0;
        }

        if(M > 2){
            B = (M * (M-1))/2;
        }
        else if(M == 2){
            B = 1;
        }
        else{
            B = 0;
        }

        cout << A + B << endl;
        }

Measured memory_bytes: 256
#include<stdio.h>
int main(void){

    int N;
    int flag=0;
    int i;
    int a[100];
    scanf("%d",&N);
    if(N>=1&&N<=100){
        for(i=0;i<N;i++){
            scanf("%d",&a[i]);
        }
        for(i=0;i<N;i++){
            if(a[i]%2==0){
                if(a[i]%3==0||a[i]%5==0){
                }else{
                    flag++;
                }
            }
        }
    }else{
        exit(1);
    }
    if(flag){
        printf("DENIED");
    }else{
        printf("APPROVED");
    }
    return 0;
}

Measured memory_bytes: 128
use std::collections::HashMap;

fn main() {
    let buf = io::read_string();
    let mut sc = io::Scanner::new(&buf);
    let n: usize = sc.read();
    let primes: Vec<usize> = vec![2, 3, 5, 7, 11, 13, 17, 19, 23, 29];
    let mut a = Vec::new();
    for i in 0..primes.len() {
        for j in i+1..primes.len() {
            if primes[i] * primes[i] * primes[i] * primes[j] <= 200 {
               a.push(primes[i] * primes[i] * primes[i] * primes[j]);
            }
        }
    }
    for i in 0..primes.len() {
        for j in i+1..primes.len() {
            for k in j+1..primes.len() {
                if primes[i] * primes[j] * primes[k] <= 200 {
                    a.push(primes[i] * primes[j] * primes[k]);
                }
            }
        }
    }
    let m = a.into_iter().filter(|i| i % 2 != 0 && i <= &n).count();
    println!("{}", m);
}

#[allow(dead_code)]
mod io {
    use std;
    use std::io::Read;
    use std::str::{FromStr, SplitWhitespace};
    pub struct Scanner<'a> {
        pub iter: SplitWhitespace<'a>,
    }
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }
        pub fn read<T: FromStr>(&mut self) -> T {
            self.iter
                .next()
                .unwrap()
                .parse()
                .ok()
                .expect("parsing failed")
        }
        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.read()).collect()
        }
    }
    pub fn read_string() -> String {
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
}


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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

int main(){
  int n; cin >> n;
  string s;
  vi min(26,100);
  rep(i,n){
    vi in(26);
    cin >> s;
    rep(j,s.size()) in[s[j]-'a']++;
    rep(j,26) if(min[j]>in[j]) min[j] = in[j];
  }
  rep(i,26) rep(j,min[i]) cout << (char)(i+'a');
  cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<utility>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<limits>
#include <bitset>      


#define LL long long
#define f first
#define s second
#define pb push_back
#define mp make_pair


using namespace std;

const LL max_LL = numeric_limits<LL>::max(); 

double dp[3000][3000];

 

int main(){

    int n;
    cin >> n;

    double p[n+1];

    for(int i = 1; i <= n; i++) cin >> p[i];

    dp[0][0] = 1;

    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= i; j++){
            dp[i][j] = dp[i-1][j] * (1 - p[i]);
            if(j > 0) dp[i][j] += dp[i-1][j-1] * p[i];
           }
      }
    
    double ans = 0;
    
    // number of heads i > n/2
    for(int i = n/2 + 1; i <= n; i++){
         ans += dp[n][i];
      }
    
    cout.precision(10);
    cout << ans;


    
    return 0;

}


Measured memory_bytes: 68864
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0

for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i + 100*j + 50*k == X:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

using namespace std;

int bubbleSort(int A[], int N) {
  int sw = 0;

  bool flag = true;
  while (flag) {
    flag = false;
    for (int j = N - 1; j >= 1; j--) {
      if (A[j] < A[j - 1]) {
        swap(A[j], A[j -1]);
        sw++;
        flag = true;
      }
    }
  }

  return sw;
}

int main() {
  int N;
  cin >> N;

  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int sw = bubbleSort(A, N);

  for (int i = 0; i < N; i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl << sw << endl;

  return 0;
}

Measured memory_bytes: 1160
/*
    A - Five Antennas
    https://atcoder.jp/contests/abc123/tasks/abc123_a
*/
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int pos[5] = {};
    for (int i = 0; i < 5; i++) {
        cin >> pos[i];
    }

    int k;
    cin >> k;

    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            if (pos[j] - pos[i] > k) {
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

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

int main()
{
    int n; cin >> n;
    int l;
    REP(n)
    {
        string s, ans, now = "0";
        cin >> s; l = (s.size())/3 + 1;
        //cout << "length = "<< l << endl;
        int pos = 0;
        now[0] = s[0];
        ans = now;
        rep(j,l - 1)
        {
            if(s[j*3+2] == '>') pos++;
            else pos--;
            now[0] = s[j*3 + 3];

            if(pos < 0){ ans = now + ans; pos++;}
            else if(pos == ans.size()){ ans = ans + now;}

        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <iostream>

long long gcd(long long a, long long b) { return (b > 0) ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

int main(int argc, char ** argv)
{
  int a, b;
  std::cin >> a >> b;
  std::printf("%lld\n", lcm(a, b));
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
const int N=1e5+2;
ll d[102][N];
int main()
{
    ft
    ll t,i,j,n,m,s=0,l,r;
    cin>>n>>m;
    ll w[n+1],v[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
        s+=v[i];
    }
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=s;j++)
        {
           d[i][j]=1e15;
        }
    }
    d[0][0]=0;
    for(i=1;i<=n;i++)
    {
        for(j=0;j<=s;j++)
        {
            if(v[i]>j)
            {
                d[i][j]=d[i-1][j];
            }
            else
            {
                d[i][j]=min(d[i-1][j],d[i-1][j-v[i]]+w[i]);
            }
        }
    }
    for(i=s;i>=0;i--)
    {
        if(d[n][i]<=m)
        {
            cout<<i<<"\n";
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 82564
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<ll> a(100005,0);
    int n,b;
    cin >> n;
    rep(i,n){
        cin >> b;
        if (b == 0){
            a[0]++;
            a[1]++;
            continue;
        }
        a[b-1]++;
        a[b]++;
        a[b+1]++;
    }
    ll ans = 0;
    rep(i,100001){
        if (a[i] > ans){
            ans = a[i];
        }
    }
    PRINT(ans);
}    


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

/*int main(){
  ll x=0;
  cin>>x;
  ll ansa,ansb=0;
  bool finished=false;
  vector<ll> vec(100000000);
  rep(i,100000000){
    vec.at(i)=i*i*i*i*i;
  }
  for(ll i=-100000;i<100000;a+=1){
    int q=i*i*i*i*i;
    
  }
}*/









int main() {
  ll x=0;
  cin>>x;
  ll ansa,ansb=0;
  bool finished=false;
  if(x%2==0){
    for(ll b=-40000;b<40000;b+=2){
      for(ll a=0;a<40000;a+=2){
        if(a*a*a*a*a-b*b*b*b*b==x){
          finished=true;
          ansa=a;
          ansb=b;
          break;
        }//if
      }//fora
      if(finished){
        break;
      }
    }//forb
    if(!finished){
      for(ll b=-40001;b<40001;b+=2){
        for(ll a=1;a<40001;a+=2){
          if(a*a*a*a*a-b*b*b*b*b==x){
            finished=true;
            ansa=a;
            ansb=b;
            break;
          }//if
        }//fora
        if(finished){
          break;
        }
      }//forb
    }
  }else{
    for(ll b=-40001;b<40001;b+=2){
      for(ll a=0;a<40000;a+=2){
        if(a*a*a*a*a-b*b*b*b*b==x){
          finished=true;
          ansa=a;
          ansb=b;
          break;
        }//if
      }//fora
      if(finished){
        break;
      }
    }//forb
    if(!finished){
      for(ll b=-40000;b<40000;b+=2){
        for(ll a=1;a<40001;a+=2){
          if(a*a*a*a*a-b*b*b*b*b==x){
            finished=true;
            ansa=a;
            ansb=b;
            break;
          }//if
        }//fora
        if(finished){
          break;
        }
      }//forb
    }
  }
  cout<<ansa<<" "<<ansb;
}

Measured memory_bytes: 3632
S = input()
ans = 0
flag = False #繰り上がりありならTrue
flag2 = False #前が5ならTrue
for k in range(len(S)):
  n = int(S[-k-1])
  if flag2:
    if n < 5:
      flag = False
    else:
      flag = True
  if flag:
    n += 1
  if n == 5:
    ans += 5
    flag2 = True
    flag = False
  elif n < 5:
    ans += n
    flag2 = False
    flag = False
  else:
    ans += 10-n
    flag2 = False
    flag = True
if flag:
  ans += 1
print(ans)

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

int main() {
  int N; cin >> N; // ４桁の整数
  int i1,i2,i3,i4; // Ｎを１桁ごとに分割

  i1 = N /1000;
  i2 = (N - i1 * 1000 ) / 100;
  i3 = (N - i1 * 1000 - i2 * 100 ) / 10;
  i4 = N % 10;
  
  if ( i2 == i3 ) {
    if ( i2 == i1 || i2 == i4 ) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
      cout << "No" << endl;
  }

//   cout << i1 << i2 << i3 << i4 << endl;
  
}



Measured memory_bytes: 256
k, n = map(int,input().split())
a = [int(x) for x in input().split()]
b = [0] *(n)
for i in range(n-1):
    b[i] =a[i+1]-a[i]
b[n-1] = a[0] + k - a[n-1]
 
print(k - max(b))

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


const int mod = 1e9+7;
int a[105];
int n,k;
int s[105];
bool c[105][100005];
int f[105][100005];

void inp()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    cin >> a[i];
    for (int i = n; i > 0; i--)
    s[i] = s[i+1] + a[i];
}


int tryyy(int p, int cand)
{
    if (cand < 0) return 0;
    if (cand > s[p]) return 0;
    if (p == n) return 1;
    if (cand == 0) return 1;
    if (c[p][cand]) return f[p][cand];
    c[p][cand] = true;
    int tmp = 0;
    /*int las = min(a[p],cand);
    for (int i = 0; i <= las; i++)
    {
        tmp = (tmp + tryyy(p+1, cand - i))%mod;
    }*/
    tmp = (tryyy(p,cand-1) + tryyy(p+1,cand) - tryyy(p+1, cand - a[p]-1)) % mod;
    tmp = (tmp + mod) %mod;
    f[p][cand] = tmp;
    return tmp;
}


void proc()
{
    for (int i = 0; i <= k-1; i++)
    tryyy(1,i);
}


void test()
{
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= k; j++)
        cout << tryyy(i,j) << ' ';
        cout << endl;
    }
}


int main()
{
    //freopen("file.inp","r",stdin);
    inp();
    proc();
    cout << tryyy(1,k);
    //test();
    return 0;
}


Measured memory_bytes: 51072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  string s, t;
  cin >> s >> t;

  int ans = 0;
  rep(i, 3) {
    if (s[i] == t[i]) ans++;
  }
  cout << ans << endl;
}


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

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int) 1e5;
const int INF = (int) 1e9 + 7;

int main(int argc, char *argv[])
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);

	int a[6];
	int ans = 1;
	for (int i = 1; i <= 5; ++i) {
		sf("%d", &a[i]);
		if (a[i] == 0) ans = i;
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 3752
// Wrongri-La Shower

#include <iostream>
#include <queue>
#include <stack>
#include <tuple>

typedef long long ll;
typedef std::tuple<int,ll> P;

template <int n>
class UnionFind{
public:
    UnionFind(){
        init();
    }
    void init(){
        for(int i=0;i<n;i++){
            par[i] = i;
            rank[i] = 0;
            weight[i] = 0ll;
        }
    }
    P find(int x){
        if(x == par[x])return std::make_tuple(x, weight[x]);

        int prev_x = x;
        ll w = 0;
        while(x != par[x]){
            w += weight[x];
            // w_queue.push(w);
            // v_stack.push(x);

            x = par[x];
        }

        par[prev_x] = x;
        weight[prev_x] = w;
        
        return std::make_tuple(x, w);
    }
    bool same(int x, int y){
        return std::get<0>(find(x)) == std::get<0>(find(y));
    }
    void unite(int x, int y, int l){
        P xp = find(x), yp = find(y);
        ll wx, wy;
        std::tie(x, wx) = xp;
        std::tie(y, wy) = yp;
        
        if(x == y){return;}
        
        if(rank[x] > rank[y]){
            par[y] = x;
            weight[y] = wx - wy + l;
        }else{
            par[x] = y;
            weight[x] = wy - wx - l;
            if(rank[x] == rank[y]){rank[y]++;}
        }
    }
    int rank[n], par[n];
    ll weight[n];
};

UnionFind<100001> uf;

int main(){
    std::ios_base::sync_with_stdio(false);
    
    int N, M;
    while(std::cin >> N >> M, N || M){
        uf.init();

        for(int i=0;i<M;i++){
            char c;
            std::cin >> c;
            
            if(c == '!'){
                int a, b, c;
                std::cin >> a >> b >> c;

                uf.unite(a, b, c);
            }else{
                int a, b;
                std::cin >> a >> b;

                if(!uf.same(a, b)){
                    std::cout << "UNKNOWN" << std::endl;
                }else{
                    P ap = uf.find(a), bp = uf.find(b);
                    ll wa = std::get<1>(ap), wb = std::get<1>(bp);

                    std::cout << wb-wa << std::endl;
                }
            }
        }
    }
}

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

int main(){
    int n;
    cin>>n;
    int flg = 0;

    for(int i=1;i<10;i++){
        for(int j = 1;j<10;j++){
            if(n == i*j)flg = 1;
        }
    } 
    if(flg == 1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans += sc.nextInt() - 1;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 25704
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::min;

fn main() {
    let n = read::<usize>();
    let k = read::<usize>();

    let mut w = vec![0; n];    
    let mut v = vec![0; n];    
    for i in 0..n {
        w[i] = read::<usize>();
        v[i] = read::<usize>();
    }

    let mut dp = vec![vec![100_100_100_1; 100_100 as usize]; n+1];

    dp[0][0] = 0;

    for i in 0..n {
        for j in 0..100_100 as usize {
            if v[i] <= j {
                dp[i+1][j] = min(dp[i+1][j], dp[i][j-v[i]]+w[i]);
            }
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }
    let mut ans :usize = 0;
    for i in 0..100_100 {
        if dp[n][i] <= k {
            ans = i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 106748
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int sx = sc.nextInt();
    int sy = sc.nextInt();
    int tx = sc.nextInt();
    int ty = sc.nextInt();
    
    StringBuilder ans = new StringBuilder();
    for (int y = sy; y < ty; y++) {
      ans.append('U');
    }
    for (int x = sx; x < tx; x++) {
      ans.append('R');
    }
    for (int y = ty; y > sy; y--) {
      ans.append('D');
    }
    for (int x = tx; x > sx; x--) {
      ans.append('L');
    }

    ans.append('L');
    for (int y = sy; y < ty+1; y++) {
      ans.append('U');
    }
    for (int x = sx-1; x < tx; x++) {
      ans.append('R');
    }
    ans.append('D');
    ans.append('R');
    for (int y = ty; y > sy-1; y--) {
      ans.append('D');
    }
    for (int x = tx+1; x > sx; x--) {
      ans.append('L');
    }
    ans.append('U');

    System.out.println(ans.toString());
  }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <list>
#include <algorithm>
using namespace std;

int main() {
	list<int> L;
    list<int>::iterator cur = L.end();
	int num_query; scanf("%d", &num_query);
	int command, tmp;
	for (int loop = 0; loop < num_query; loop++) {
		scanf("%d", &command);
		switch (command) {
		case 0:
			scanf("%d", &tmp);
            cur = L.insert(cur, tmp);
			break;
		case 1:
			scanf("%d", &tmp);
            if (tmp > 0) {
				for (int i = 0; i < +tmp; i++) cur++;
			} else {
				for (int i = 0; i < -tmp; i++) cur--;
			}
			break;
		case 2:
            cur = L.erase(cur);
			break;
    	}
	}
    for (int x: L) printf("%d\n", x);
	return 0;
}



Measured memory_bytes: 18308
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int number[10001];
    for(int i=1;i<10000;i++)number[i]=i*i;
    while(cin>>n,n){
        vector<int> num;
        for(int i=1;i<n;i++)num.push_back(number[i]%n);
        sort(num.begin(),num.end());
        num.erase(unique(num.begin(),num.end()),num.end());
        int ans[5000]={};
        for(int i=0;i<num.size();i++){
            for(int j=0,k;j<num.size();j++){
                k=num[i]-num[j];
                if(k<0)k+=n;
                if(k>n/2)k=n-k;
                ans[k]++;
            }
        }
        for(int i=1;i<=n/2;i++)cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 1384
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (int)1e9
#define OO (ll)1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=55;
map<string,int>mp;
int main()
{
    IO;
    int n;
    cin >> n;
    while(n--){
        string s;
        cin >> s;
        ++mp[s];
    }
    int m;
    cin >> m;
    while(m--){
        string s;
        cin >> s;
        --mp[s];
    }
    int Max=0;
    for(auto i:mp)
        Max=max(Max,i.s);
    cout<<Max<<endl;
    re 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

"1 2 3 4 5を配列に"
A = list(map(int, input().split()))
A.sort()
count = A.count(A[0])
remain = len(A) - count
if remain % (K-1) == 0:
  print(remain//(K-1))
else:
  print((remain//(K-1))+1)


Measured memory_bytes: 13812
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100

string s;

// char X[100][100];
// int dp[1000000001];

int main(void){
    cin >> s;
    int n = s.length();
    vector<int> x(n);
    REP(i,0,n) x[i] = s[i] - '0';
    int k = n/2+1;
    int med = x[n/2];
    // cout << 1 << endl;
    // cout << med << endl;
    while((x[k-1] == med && x[n-k] == med) && k <= n) {
        k++;
    }
    k--;
    
    cout << k << endl;
    }
    


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

using namespace std;

#define vec vector
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long

int n;
vec<ll> a;

ll solve(int h)
{
	ll ret = a[0];
	int k = 0;
	rep(i, n - 1) {
		if ((h / (int)pow(2, i)) % 2) {
			k++;
			ret += (int)pow(10, k) * a[i + 1];
		} else {
			k = 0;
			ret += a[i + 1];
		}
	}
	return ret;
}


int main(void)
{
	string s;
	cin >> s;
	n = (int)s.length();
	rep(i, n) a.push_back((int)s[i] - (int)'0');
	reverse(a.begin(), a.end());
	ll ans = 0;
	int Max = (int)pow(2, n - 1);
	rep(i, Max) {
		ans += solve(i);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 100000007
typedef long long ll;
using namespace std;

int main(){
	string s;
	cin>>s;
	string t="CODEFESTIVAL2016";
	int ans=0;
	lol(i,s.size())ans+=(s[i]!=t[i]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

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

  int n;
  cin >> n;
  int p[n];
  for(int i = 0; i < n; i++) cin >> p[i];

  int j = 0;
  for(int i = 1; i < n; i++){
    if(p[j] < p[i]) j = i;
  }

  int sum = 0;
  for(int i = 0; i < n; i++){
    if(i == j) sum += p[i] / 2;
    else sum += p[i];
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String []args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        if (a > b) {
            System.out.println("a > b");
        } else if (a == b) {
            System.out.println("a == b");
        } else {
            System.out.println("a < b");
        }
    }
}


Measured memory_bytes: 26244
#include <cstdio>

/*
max(N- [x2, ..., xN] [ 1 2 3 4 ... 4 3 2], 0)

(1 + z + z^2 + ... + z^N) (1 + z^2 + z^4 + ... + z^{2N}) ...
f(z) = 1/[(1-z){(1-z^2)(1-z^3)...(1-z^{N/2})}^2]


[z^N] (N f(z) - z * f'(z))/(1-z)
[z^N] (f(z)(N - z * f'(z)/f(z)))/(1-z)

f'(z)/f(z) = 1/(1-z) + 2(2z/(1-z^2) + 3z^2/(1-z^3) + ...

log f = \sum_{i=2}^{N/2}

f(z) = (1-z)(1-z^{N/2+1})^2(1-z^{N/2+2})^2... / [(1-z)(1-z^2)...]^2

*/

int n, m;

int dp[5001];

int main(){
  scanf("%d%d", &n, &m);

  dp[0] = 1;
  dp[1] = m-1;
  if(n & 1){
    dp[(n+1)/2] += m-1;
    if(dp[(n+1)/2] >= m) dp[(n+1)/2] -= m;
    dp[(n+1)/2+1] = 1;
  }
  for(int i = (n+1)/2+1; i <= n; i++){
    for(int j = n; j >= i; j--){
      dp[j] -= dp[j-i];
      if(dp[j] < 0) dp[j] += m;
    }
    for(int j = n; j >= i; j--){
      dp[j] -= dp[j-i];
      if(dp[j] < 0) dp[j] += m;
    }
  }
  for(int i = 0; i <= n; i++){
    for(int j = 1; ; j++){
      int k = j * (3 * j - 1) / 2;
      if(k > i) break;
      if(j&1){
        dp[i] += dp[i - k];
        if(dp[i] >= m) dp[i] -= m;
      }
      else {
        dp[i] -= dp[i - k];
        if(dp[i] < 0) dp[i] += m;
      }
      k += j;
      if(k > i) break;
      if(j&1){
        dp[i] += dp[i - k];
        if(dp[i] >= m) dp[i] -= m;
      }
      else {
        dp[i] -= dp[i - k];
        if(dp[i] < 0) dp[i] += m;
      }
    }
  }
  for(int i = 0; i <= n; i++){
    for(int j = 1; ; j++){
      int k = j * (3 * j - 1) / 2;
      if(k > i) break;
      if(j&1){
        dp[i] += dp[i - k];
        if(dp[i] >= m) dp[i] -= m;
      }
      else {
        dp[i] -= dp[i - k];
        if(dp[i] < 0) dp[i] += m;
      }
      k += j;
      if(k > i) break;
      if(j&1){
        dp[i] += dp[i - k];
        if(dp[i] >= m) dp[i] -= m;
      }
      else {
        dp[i] -= dp[i - k];
        if(dp[i] < 0) dp[i] += m;
      }
    }
  }

/*
  for(int i = 0; i <= n; i++) dp[i] = 1;
  for(int i = 2; i <= n/2; i++){
    for(int j = i; j <= n; j++){
      dp[j] += dp[j-i];
      if(dp[j] >= m) dp[j] -= m;
    }
    for(int j = i; j <= n; j++){
      dp[j] += dp[j-i];
      if(dp[j] >= m) dp[j] -= m;
    }
  }
 

  if(n & 1){
    for(int j = (n+1)/2; j <= n; j++){
      dp[j] += dp[j-(n+1)/2];
      if(dp[j] >= m) dp[j] -= m;
    }
  }
*/

  int c = 0;
  for(int i = 0; i <= n; i++){
    c = (c + (long long) (n - i) * dp[i]) % m;
  }

  printf("%d\n", c);

  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int A, B, K;

int main() {
    cin >> A >> B >> K;

    vi ans(1, 1);
    for (int i = 2; i <= 100; i++) {
        if (A % i == 0 and B % i == 0) {
            ans.push_back(i);
        }
    }

    cout << ans[ans.size() - K] << endl;
    return 0;
}


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

const int INF = 1001001001;
int a[12][12];

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    rep(i,n) {
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }

    int ans = INF;
    rep(s,1<<n) {
        int cost = 0;
        vector<int> u(m);
        rep(i,n) {
            if (s>>i&1) {
                cost += c[i];
                rep(j,m) u[j] += a[i][j];
            }
        }
        bool check = true;
        rep(j,m) if (u[j] < x) check = false;
        if (check) ans = min(ans, cost);
    }
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main (int argc, char** argv)
{
    int sec, h, m;
    scanf("%d", &sec);

    h = sec / 3600;
    if (h > 0) {
        sec-= (3600 * h);
    }    

    m = sec / 60;
    if (m > 0) {
        sec-= (60 * m);
    }    

    printf("%d:%d:%d\n", h, m, sec);
    return 0;
}

Measured memory_bytes: 592
kk = list(map(int, input().split()))
a = kk[0] - (kk[0] % kk[1])
b = a / kk[1]

if (kk[0] % kk[1]) == 0:
  answer = b * kk[2]
else:
  answer = (b + 1) * kk[2]
print(int(answer))

Measured memory_bytes: 9168
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<unordered_map>
#include<queue>
using namespace std;
const unsigned int M = 1000000007; 
int main()
{
	long long int k;cin>>k;
	if(k<=9){cout<<k<<endl;}
	else
	{
		long long int count=0,i,u;
		queue<long long int>q;
		map<long long int,long long int>m;
		map<long long int,long long int>m1;
		for(i=1;i<=9;i=i+1){q.push(i);}
			while(count!=(k))
			{
				count=count+1;
				u=q.front();q.pop();
				m[count]=u;
				if(u%10!=0)q.push(u*10 + u%10 -1);
				q.push(u*10 + u%10);
				if(u%10!=9){q.push(u*10 + u%10 +1);}
				
			}
			cout<<m[k]<<endl;
	}
}

Measured memory_bytes: 8064
import array
import collections


Edge = collections.namedtuple("Edge", "start end weight")


class UnionFind(object):

    def __init__(self, number_of_nodes):  # 初期化
        self.par = array.array("L", range(number_of_nodes))
        self.rank = array.array("L", (0 for i in range(number_of_nodes)))

    def root(self, node):  # 根を求める
        if self.par[node] == node:
            return node
        else:
            r = self.root(self.par[node])
            self.par[node] = r  # 経路圧縮
            return r

    def in_the_same_set(self, node1, node2):  # 同じ集合に属するか
        return self.root(node1) == self.root(node2)

    def unite(self, node1, node2):  # 属する集合を併合
        x = self.root(node1)
        y = self.root(node2)
        if x == y:
            pass
        elif self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


# Kruskal法により最小全域木を求める
def compute_mst_kruskal(max_v, edges):
    edges.sort(key=lambda edge: edge.weight)
    uf = UnionFind(max_v)
    mst = []
    for edge in edges:
        if not uf.in_the_same_set(edge.start, edge.end):
            uf.unite(edge.start, edge.end)
            mst.append(edge)
    return mst



N = int(input())
xy = [list(map(int, input().split())) + [i] for i in range(N)]
sort_x = sorted(xy,key = lambda x:x[0])
sort_y = sorted(xy,key = lambda x:x[1])
#print(sort_x,sort_y)

max_v, max_e = N,2*N
entire = []
for i in range(1,N):
    entire.append([sort_x[i][2], sort_x[i-1][2],sort_x[i][0] - sort_x[i-1][0]])
    entire.append([sort_y[i][2], sort_y[i-1][2],sort_y[i][1] - sort_y[i-1][1]])
#print(entire)
edges = [Edge(*k) for k in entire]
#print(edges)
# max_v, max_e = map(int, input().split())
#edges = [Edge(*map(int, input().split())) for _ in range(max_e)]
mst = compute_mst_kruskal(max_v, edges)
print(sum(edge.weight for edge in mst))

Measured memory_bytes: 73588
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int a, b , c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    for(int i= 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if(500 * i + 100 * j + 50 * k == x) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>

using namespace std;

int N;
string A,B,C;
int main(){
    cin >> N >> A >> B >> C;
    int ans = 0;
    for(int i=0; i<N; i++) {
        int cnt = 0;
        if( A[i] - B[i] ) cnt++;
        if( A[i] - C[i] ) cnt++;
        if( B[i] - C[i] ) cnt++;
        if( cnt == 3 ) cnt = 2;
        else if( cnt > 0 ) cnt = 1;
        ans += cnt;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def main():

    N,A,B = map(int,input().split())
    ans = 0

    for outer in map(str,range(1,N+1)):
        inner = sum([int(inner) for inner in outer])
        if A<=inner and inner <= B:
            ans += int(outer)

    print(ans)



if __name__== "__main__":
    main() 






Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <algorithm>

const int N = 2e5 + 10;

std::vector<std::pair<int, int>> edges[N];
int weight[N], sign[N];
int mark[N];
int left, right;

bool solve(int u, int w, int s) {
  if (mark[u]) return w == weight[u] && sign[u] == s;
  if (s < 0) right = std::min(right, w);
  else left = std::max(left, -w);
  weight[u] = w;
  sign[u] = s;
  mark[u] = 1;
  for (auto &e: edges[u]) {
    if (!solve(e.first, e.second - w, -s)) return false;
  }
  return true;
}

int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < q; ++i) {
    int x, y, w;
    scanf("%d%d%d", &x, &y, &w);
    --x, --y;
    edges[x].emplace_back(y + n, w);
    edges[y + n].emplace_back(x, w);
  }
  for (int i = 0; i < n + m; ++i) if (!mark[i]) {
    left = 0, right = 2e9;
    if (!solve(i, 0, 1)) {
      puts("No");
      return 0;
    }
    if (left > right) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 15104
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long double L; cin >> L;
    L /= 3;
    cout << fixed << setprecision(12) << L * L * L << endl;


    return 0;
}


Measured memory_bytes: 256