akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define INF 1000000007
#define MOD 1000000007
#define ARRAY_MAX 105

typedef struct edge{

    int from;
    int to;
    int cost;
}EDGE;


void warshal_floyd(vector<vector<int> >& dp){
    REP(k,ARRAY_MAX){
        REP(i,ARRAY_MAX){
            REP(j,ARRAY_MAX){
                dp[i][j] = min(dp[i][j],dp[i][k] + dp[k][j]);
            }
        }
    }
}


int main(){

    int n,m;
    int a,b,c;
    cin >> n >> m;
    vector<vector<int> > mini_cost(ARRAY_MAX,vector<int>(ARRAY_MAX));
    vector<vector<int> > area(ARRAY_MAX,vector<int>(ARRAY_MAX));

    REP(i,ARRAY_MAX){
        REP(j,ARRAY_MAX){
            mini_cost[i][j] = area[i][j] = INF;
            if(i == j){
                mini_cost[i][j] = area[i][j] = 0;
            }
        }
    }

    REP(i,m){
        cin >> a >> b >> c;
        a--;
        b--;
        mini_cost[a][b] = mini_cost[b][a] = c;
        area[a][b] = area[b][a] = c;
    }

    warshal_floyd(mini_cost);

    REP(i,n){
        REP(j,n){
            if(mini_cost[i][j] == -1 || mini_cost[i][j] == 0){
                continue;
            }
            if(mini_cost[i][j] == area[i][j]){
                m--;
                mini_cost[i][j] = mini_cost[j][i] = -1;
            }
        }
    }
    cout << m << endl;
    


    return 0;
}


Measured memory_bytes: 384
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    n, a, b = map(int, input().split())
    
    res = 0
    for i in range(1, n+1):
        if a <= sum(list(map(int, list(str(i))))) <= b:
            res += i
    
    print(res)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  vector<int> c(n);
  rep(i, n) cin >> c[i];
  sort(c.begin(), c.end(), greater<int>());
  int a = 0, b = 0;
  rep(i, n){
    if(i % 2 == 0){
      a += c[i];
    }else{
      b += c[i];
    }
  }
  cout << a - b << endl;
}


Measured memory_bytes: 3584
#include <stdio.h>
int main(void)
{
  int i,j,n,m,v,x;
  scanf("%d %d",&n,&m);
  int a[100][100];
  int b[100];
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(i=0;i<m;i++){
    scanf("%d",&b[i]);
  }
  for(i=0;i<n;i++){
    x=0;
    for(j=0;j<m;j++){
      v=a[i][j]*b[j];
      x+=v;
    }
    printf("%d\n",x);
  }
  return 0;
}

Measured memory_bytes: 640
# https://atcoder.jp/contests/aising2019/submissions/3986315

import sys

sys.setrecursionlimit(2 * 10 ** 5)

H, W = map(int, input().split())
s = [input() for _ in range(H)]

ans = 0

dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]

un_reached = [[True for i in range(W)] for j in range(H)]


def dfs(x, y):
    un_reached[x][y] = False
    if s[x][y] == '#':
        cc[1] += 1
    else:
        cc[0] += 1
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0 <= nx < H and 0 <= ny < W and s[nx][ny] != s[x][y] and un_reached[nx][ny]:
            dfs(nx, ny)


for i in range(H):
    for j in range(W):
        if un_reached[i][j]:
            cc = [0 for _ in range(2)]  # [wt, bk]
            dfs(i, j)
            ans += cc[1] * cc[0]
print(ans)


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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  long long n, ans = 0;
  cin >> n; 

  if (n&1) {
    cout << 0 << '\n';
    return 0;
  }

  n /= 2;
  while (n) {
    n /= 5;
    ans += n;
  }
  cout << ans << '\n';
}

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

Q=int(input())
x = [list(map(int, input().split())) for i in range(Q)]

sum=0
num=[0]*100010

for i in range(N):
    num[A[i]]+=1
    sum+=A[i]

for i in range(Q):
    b=x[i][0]
    c=x[i][1]

    sum=sum-b*num[b]+c*num[b]
    num[c]+=num[b]
    num[b]=0

    print(sum)


Measured memory_bytes: 92504
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

const int N = 8;
const int M = 1000;
string res[N+1];
int pre[M+1];
char ans[M+1][M+1];

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

	int n;
	cin >> n;

	res[3] = "aa...b..b";
	res[4] = "aacdbbcdefggefhh";
	res[5] = "beg..beg..cffiic.hjjddhkk";
	res[6] = "aabee.d.b..fdcc..fgg.iij..hl.j..hlkk";
	res[7] = "beh....beh....cf.jj..cf.kk..dgg..mmd.i..nn..illoo";

	pre[0] = -1;
	for (int i = 4; i <= n; ++i) {
		if (pre[i-4]) pre[i] = 4;
		if (pre[i-5]) pre[i] = 5;
		if (pre[i-6]) pre[i] = 6;
		if (pre[i-7]) pre[i] = 7;
	}
	pre[3] = 3;

	if (pre[n] == 0) {
		cout << "-1\n";
	} else {
		for (int x = 0; x < n; ++x) {
			for (int y = 0; y < n; ++y) ans[x][y] = '.';
		}
		for (int m = n; m > 0; m -= pre[m]) {
			int a = m - pre[m];
			int b = m - pre[m];
			for (int x = 0; x < pre[m]; ++x) {
				for (int y = 0; y < pre[m]; ++y) {
					ans[a+x][b+y] = res[pre[m]][x + pre[m]*y];
				}
			}
		}
		for (int x = 0; x < n; ++x) {
			for (int y = 0; y < n; ++y) cout << ans[x][y];
			cout << '\n';
		}
	}
}


Measured memory_bytes: 2176
#include <iostream>
using namespace std;
int main(){
	int i,j,n;
	while(cin >> n, n){
		int p,s[2][14]={0};
		for(i=1;i<=n;i++) cin >> s[0][i];
		for(p=0;;p++){
			for(i=1;i<=n;i++){
				s[1][i]=0;
				for(j=1;j<=n;j++) 
					if(s[0][j] == s[0][i]) s[1][i] ++;
			}
			for(i=1;i<=n;i++) if(s[0][i] != s[1][i]) break;
			if(i>n) break;
			for(i=1;i<=n;i++) s[0][i] = s[1][i];
		}
		cout << p << endl;
		for(i=1;i<=n;i++) cout << s[1][i] << (i==n?"":" ");
		cout << endl;
	}
}

Measured memory_bytes: 0
from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def yes(n): print("Yes" if n else "No")
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

n,m,X,Y = f()
x = f()
y = f()
max_x = max(x)
min_y = min(y)
if min_y - max_x >= 1:
    for i in range(max_x+1, min_y+1):
        if X < i <= Y:
            print("No War")
            break
    else:
        print("War")
else:
    print("War")

Measured memory_bytes: 3700
N = int(input())
S = [int(c) for c in input()]

count = 0

for i in range(10):
    if i in S[:N-2]:
        a = S.index(i)
        for j in range(10):
            if j in S[a+1:N-1]:
                b = S[a+1:N-1].index(j) +a+1
                for k in range(10):
                    if k in S[b+1:]:
                        count +=1
print(count)                        

Measured memory_bytes: 132292
import java.util.Scanner;



public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] array = new int[6 + 1];
		array[0] = 0;
		for (int i = 1; i < array.length; i++) {
			array[i] = scan.nextInt();
		}
		int q = scan.nextInt();
		Dice dice = new Dice(array);
		int part1; int part2;
		for (int i = 0; i < q; i++) {
			part1 = scan.nextInt();
			part2 = scan.nextInt();
			array = dice.check(part1, part2);
			System.out.println(array[3]);
		}
		scan.close();
	}
}
	

class Dice {
	private int[] num = new int[6 + 1];
	Dice() {
	}

	Dice(int[] array) {
		for (int i = 0; i < array.length; i++) {
			this.num[i] = array[i];
		}
	}
	
	public int[] getNum() {
		return this.num;
	}
	
	public int getNumber(int i) {
		return this.num[i];
	}
	
	// ??????????????¢??????????????????
	public int[] roll(int[]ary, String order) {
		int now_1 = 1;	int now_2 = 2;	int now_3 = 3;	int tmp;
		int[] array = ary;
		char[] check = {'N', 'E', 'S', 'W'};
		for (int i = 0; i < order.length(); i++) {
			for (int j = 0; j < check.length; j++) {
				if (order.charAt(i) == check[j]) {
					switch (j + 1) {
						case 1:
							tmp = now_1;
							now_1 = now_2;
							now_2 = 7 - tmp;
							break;
						case 2:
							tmp = now_1;
							now_1 = 7 - now_3;
							now_3 = tmp;
							break;
						case 3:
							tmp = now_1;
							now_1 = 7 - now_2;
							now_2 = tmp;
							break;
						case 4:
							tmp = now_1;
							now_1 = now_3;
							now_3 = 7 - tmp;
							break;
					}
				}
			}
		}
		int[] cp_array = new int[array.length];
		cp_array[1] = array[now_1]; cp_array[2] = array[now_2];
		cp_array[3] = array[now_3]; cp_array[4] = array[7 - now_3];
		cp_array[5] = array[7 - now_2]; cp_array[6] = array[7 -now_1];
		return cp_array;
	}
	
	
	// 3?????¨?????????????????????
	public int[] check(int part1, int part2) {
		String[] str = {"null", "N", "N", "N", "E", "WW"};
		int sum = 0;
		int[] array = new int[num.length];
		for (int i = 0; i < num.length; i++) {
			array[i] = num[i];
		}
		boolean decision = false;
		for (int i = 0; i < str.length; i++) {
			array = this.roll(array, str[i]);
			for (int j = 0; j < 4; j++) {
				if (array[1] == part1) {
					if (array[2] == part2) {
						sum = array[3];
						decision = true;
						break;
					} else {
						//array = turn(array);
						array = this.roll(array, "NWS");
					}
				} else {
					break;
				}
			}
			if (decision) break;
		}
		

		return array;
	}
}

Measured memory_bytes: 26176
#include<iostream>
using namespace std;
int main()
{
int k[2];
int h[2];
int a,b,c,d;
cin>>h[0]>>h[1]>>k[0]>>k[1]>>a>>b>>c>>d;
int ht= (((h[0]/10)*c)+(h[0]*a))+((h[1]/20*d)+(h[1]*b));
int kt= (((k[0]/10)*c)+(k[0]*a))+((k[1]/20*d)+(k[1]*b));
if(ht>kt){
cout<<"hiroshi"<<endl;
}
else if(ht<kt)
{
cout<<"kenjiro"<<endl;
}
else {
cout<<"even"<<endl;
}

return 0;
}

Measured memory_bytes: 3120
using System;
using System.Collections.Generic;

namespace PrimeNumber
{
    class Program
    {
        private static bool IsPrime(int n)
        {
            if (n < 2) return false;
            if (n == 2) return true;
            if (n % 2 == 0) return false;

            double l = Math.Sqrt(n);

            for (var i = 3; i <= l; i += 2)
            {
                if (n % i == 0)
                {
                    return false;
                }
            }
            
            return true;
        }

        static void Main(string[] args)
        {
            var nums = new List<int>();

            int num;

            while (int.TryParse(Console.ReadLine(), out num))
                nums.Add(num);

            foreach (var n in nums)
            {
                var count = 0;
                for (var i = 2; i <= n; i++)
                  if(IsPrime(i)) count++;
                Console.WriteLine(count);
            }
        }
    }
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver2 {
 public:
  int n, T;
  vector<LL> a, b;
  Solver2(LL n, LL T) : n(n), T(T), a(n), b(n){};

  void solve() {
    for (int i = 0; i < n; ++i) {
      cin >> a[i] >> b[i];
    }
    vector<int> perm, perm0;
    for (int i = 0; i < n; ++i) {
      if (a[i] == 0)
        perm0.push_back(i);
      else
        perm.push_back(i);
    }
    sort(perm.begin(), perm.end(), [&](int x, int y) -> bool { return a[y] * (b[x] + 1) < a[x] * (b[y] + 1); });
    sort(perm0.begin(), perm0.end(), [&](int x, int y) -> bool { return b[x] < b[y]; });
    vector<LL> dp(50, T + 1);
    dp[0] = 0;
    for (auto i : perm) {
      for (int j = 50 - 1; j >= 1; --j) {
        dp[j] = min(dp[j], (a[i] + 1) * (dp[j - 1] + 1) + b[i]);
      }
    }
    DBG(dp)
    vector<LL> dp2(1, 0);
    for (auto i : perm0) {
      dp2.push_back(b[i] + 1);
    }
    for (int i = 1; i < dp2.size(); ++i) {
      dp2[i] += dp2[i - 1];
    }
    int ans = 0;
    for (int i = 0; i < 50; ++i) {
      if (dp[i] <= T) {
        LL rem = T - dp[i];
        int c = distance(dp2.begin(), upper_bound(dp2.begin(), dp2.end(), rem)) - 1;
        ans = max(ans, i + c);
      }
    }
    cout << ans << endl;
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, t;
  std::cin >> n >> t;

  Problem::Solver2 sol(n, t);
  sol.solve();
  return 0;
}


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

struct Node
{
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node *find(Node *root, int key)
{
	while (root != NIL && key != root->key)
	{
		if (key < root->key) root = root->left;
		else root = root->right;
	}
	return root;
}

void insert(int key)
{
	Node *x = root;
	Node *y = NIL;
	Node *z;

        z = (Node *)malloc(sizeof(Node));
	z->key = key;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL)
	{
		y = x;
		if (z->key < x->key) x = x->left;
		else x = x->right;
	}

	z->parent = y;
	if (y == NIL) root = z;
	else
	{
		if (z->key < y->key) y->left = z;
		else y->right = z;
	}
}

void inorder(Node *root)
{
	if (root == NIL) return;
	inorder(root->left);
	cout << " " << root->key;
	inorder(root->right);
}

void preorder(Node *root)
{
	if (root == NIL) return;
	cout << " " << root->key;
	preorder(root->left);
	preorder(root->right);
}

int main()
{
	int n, key;
	string str;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> str;
		if (str == "find")
		{
			cin >> key;
			Node *t = find(root, key);
			if (t != NIL) cout << "yes" << endl;
			else cout << "no" << endl;
		}
		else if (str == "insert")
		{
			cin >> key;
			insert(key);
		}
		else if (str == "print")
		{
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 21760
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).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; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

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

ll C[51][51]; 
void comb_table(int N){
  for(int i=0;i<=N;++i) for(int j=0;j<=i;++j){
    if( j==0 or j==i ) C[i][j]=1LL;
    else C[i][j] = (C[i-1][j-1]+C[i-1][j]);
  }
  return;
}

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N, A, B; std::cin >> N >> A >> B;
  std::vector<ll> v(N); rep(i,N) std::cin >> v[i];

  // sort site uekara Ako
  std::sort( all(v), [](ll x, ll y) { return x > y; } );
  ll ave = 0.;
  rep(i,A) ave += v[i];
  std::cout << std::fixed << std::setprecision(10) << (double)ave/(double)A << std::endl;

  // upper Ako a kind of value
  int a_th_val_num = 0, a_th_val_pos = 0;
  for(int i = 0; i < N; ++i){
    if(v[i] == v[A-1]){
      a_th_val_num++;
      if(i<A){
        a_th_val_pos++;
      }
    }
  }

  comb_table(N);
  ll cnt = 0LL;
  if(a_th_val_pos==A){
    for(a_th_val_pos=A; a_th_val_pos<=B; ++a_th_val_pos){
      cnt += C[a_th_val_num][a_th_val_pos];
    }
  }else{
    cnt += C[a_th_val_num][a_th_val_pos];
  }
  
  std::cout << cnt << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int N=1e6+5;

int n,m,a[N],cnt[3],ord[3],s[4],L[N],R[N],A,B,C;
char st[N];

bool cmp(int x,int y) {return cnt[x]<cnt[y];}

int Id(int b,int c) {
	if (b&&c) return 1;
	if (b) return 2;
	if (c) return 3;
	return 0;
}

void del(int x) {L[R[x]]=L[x];R[L[x]]=R[x];}

int main() {
	scanf("%s",st+1);n=strlen(st+1);
	for(int l=1,r=0;l<=n;l=r+1) {
		while (r<n&&st[r+1]==st[l]) r++;
		a[++m]=st[l]-'A';
	}
	a[0]=3;a[m+1]=4;
	fo(i,1,m) cnt[a[i]]++;
	fo(i,0,2) ord[i]=i;
	sort(ord,ord+3,cmp);
	A=ord[0];B=ord[1];C=ord[2];
	if (!cnt[A]) return 0;
	bool cb=0,cc=0;
	fo(i,1,m) {
		if (a[i]==A) {
			s[Id(cb,cc)]++;
			cb=cc=0;
		}
		if (a[i]==B) cb=1;
		if (a[i]==C) cc=1;
	}
	s[Id(cb,cc)]++;

	R[0]=1;fo(i,1,m) L[i]=i-1,R[i]=i+1;L[m+1]=m;
	if (a[1]==C&&a[2]==A&&s[1]+s[2]<s[3]) del(1),s[3]--,cnt[C]--;
	if (a[m]==C&&a[m-1]==A&&s[1]+s[2]<s[3]) del(m),s[3]--,cnt[C]--;
	fo(i,2,m-1) if (a[i]==C&&a[L[i]]==A&&a[R[i]]==A&&s[1]+s[2]<s[3]) del(L[i]),del(i),s[3]--,cnt[A]--,cnt[C]--;
	for(int i=R[0];i!=m+1;i=R[i]) 
		if (cnt[C]>cnt[B]&&a[i]==C) 
			if (a[L[i]]!=a[R[i]]) del(i),cnt[C]--;
	
	for(int i=R[0];i!=m+1;i=R[i])
		if (cnt[A]!=cnt[B]) {
			if (a[i]==B&&a[L[i]]==C&&a[R[i]]!=a[L[L[i]]]) del(L[i]),del(i),cnt[B]--,cnt[C]--;
			if (a[i]==C&&a[L[i]]==B&&a[R[i]]!=a[L[L[i]]]) del(L[i]),del(i),cnt[B]--,cnt[C]--;
		}
	for(int i=R[0];i!=m+1;i=R[i]) putchar(a[i]+'A');
	return 0;
}

Measured memory_bytes: 13824
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int Left[2100][2100], Right[2100][2100], Up[2100][2100], Down[2100][2100];

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int h, w;
    cin >> h >> w;
    string s[h];
    rep(i, h) cin >> s[i];

    // Left
    rep(i, h) {
        int cur = 0;
        rep(j, w) {
            if (s[i][j] == '#') cur = 0;
            else cur++;
            Left[i][j] = cur;
        }
    }
    // Right
    rep(i, h) {
        int cur = 0;
        for (int j = w - 1; j >= 0; --j) {
            if (s[i][j] == '#') cur = 0;
            else cur++;
            Right[i][j] = cur;
        }
    }
    // Up
    rep(j, w) {
        int cur = 0;
        rep(i, h) {
            if (s[i][j] == '#') cur = 0;
            else cur++;
            Up[i][j] = cur;
        }
    }
    // Down
    rep(j, w) {
        int cur = 0;
        for (int i = h - 1; i >= 0; --i) {
            if (s[i][j] == '#') cur = 0;
            else cur++;
            Down[i][j] = cur;
        }
    }

    int res = 0;
    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '#') continue;
            chmax(res, Left[i][j] + Right[i][j] + Up[i][j] + Down[i][j] - 3);
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 72576
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
 
using namespace std;
 
const int N = 2000;
 
double dp[2][N];
int n, t;
 
void init(){
  fill(dp[0], dp[2], 0.0);
  dp[0][0] = 1.0;
  for(int i=0;i<t;i++){
    int cur = i % 2;
    int nxt = (i + 1) % 2;
    for(int j=0;j<n;j++) dp[nxt][j] = 0.0;
    for(int j=0;j<n;j++){
      for(int k=0;k<6;k++){
    dp[nxt][(j+k)%n] += dp[cur][j] / 6.0;
      }
    }
  }
}
 
int main(){
  while(cin >> n >> t && (n|t)){
    init();
    string s;
    cin >> s;
    double ans = 0.0;
    for(int i=0;i<n;i++){
      double sum = 0.0;
      for(int j=0;j<n;j++){
    int p = (i + j) % n;
    if(s[p] == 'R'){
      sum += dp[t%2][j];
    }
      }
      ans = max(ans, sum);
    }
    printf("%.10f\n", ans);
  }
  return 0;
}

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




int cldnum[100001] = {0};


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

    int rflag = 1;
    int lflag = 0;
    int blocknum = 0;
    int lpos;
    s.push_back('R');
    for (int i = 1; i < s.size(); i++)
    {
        if (rflag > 0){
            if (s[i] == 'R'){
                rflag++;
            } else {
                blocknum += rflag;
                rflag = 0;
                lflag = 1;
                lpos = i;
            }
        } else {
            if (s[i] == 'R'){
                blocknum += lflag;
                lflag = 0;
                rflag = 1;
                if (blocknum % 2 == 0){
                    cldnum[lpos] = blocknum / 2;
                    cldnum[lpos - 1] = blocknum / 2;
                } else {
                    if (((lpos - i) % 2) == 0){                        
                        cldnum[lpos] = blocknum / 2;
                        cldnum[lpos - 1] = blocknum / 2 + 1;
                    } else {        
                        cldnum[lpos] = blocknum / 2 + 1;
                        cldnum[lpos - 1] = blocknum / 2;
                    }
                }
                blocknum = 0;
            } else {
                lflag++;
            }
        }
    }

    for (int i = 0; i < s.size() - 1; i++){
            cout << cldnum[i] << " ";
    }
    cout << endl;
}

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

int main(int argc, char *argv[]) {
	int W = 0;
	int a = 0;
	int b = 0;
	int min_move = 0;
	std::cin >> W;
	std::cin >> a;
	std::cin >> b;

	
	if (a == b) {
		min_move = 0;  // もともと連結されている
	} else if (a > b) {
		// a > b のとき
		// a <= b < a + W であればよい
		if (a > b + W) {
			min_move = a - (b + W);
		}
	} else {
		// a < b のとき、かつ
		// b + W < a のとき、動かす必要がある
		if (b > a + W) {
			min_move = b - (a + W);
		}
	}

	std::cout << min_move << std::endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())

B= list(map(int,input().split()))

sum=0
for i in range(len(B)):
    #print(i)
    if i==0:
        sum+=B[i]
    elif B[i-1]<B[i]:
        sum+=B[i-1]
    else:
        sum+=B[i]
    

sum+=B[len(B)-1]
print(sum)



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

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

  sort(s.begin(), s.end());
  string alphabet = "abcdefghijklmnopqrstuvwxyz";
  int idx = 0;
  for (int i = 0; i < s.size(); i++) {
    if (alphabet[idx] == s[i]) idx++;
  }

  if (idx < 26) cout << alphabet[idx] << endl;
  else cout << "None" << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;

int main(void) {
  ll h;
  cin >> h;
  ll n = 0;
  while (h != 1) {
    h = floor(h / 2);
    n++;
  }
  ll ans = pow(2, n+1) - 1;
  cout << ll(pow(2, n+1)) - 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <climits>
#include <functional>

template <typename T>
struct SegmentTree{
private:
  using F = std::function<T(T,T)>;
  int n;
  F f;
  T ti;
  std::vector<T> dat;
public:
  SegmentTree(){};
  SegmentTree(F f,T ti) : f(f),ti(ti) {}
  void build(int n_){
    n = n_;
    dat.assign(2*n,ti);
  }
  void build(const std::vector<T> &v){
    int n_ = v.size();
    build(n_);
    for(int i = 0; i < n; ++i) dat[n+i]=v[i];
    for(int i = n-1; i >= 0; --i)
      dat[i]=f(dat[2*i+0],dat[2*i+1]);
  }
  void set_val(int k,T x){
    dat[k+=n] = x;
    while(k > 0){
      k = k/2;
      dat[k]=f(dat[2*k+0],dat[2*k+1]);
    }
  }
  int query(int a,int b, int lb, int ub){
    if(a == b) return 0;
    int ret = 0;
    auto g = [](T v, int lb, int ub){
               return upper_bound(v.begin(), v.end(), ub) - lower_bound(v.begin(), v.end(), lb);
             };
    for(int l = a+n, r = b+n; l < r; l >>= 1, r >>= 1){
      if(l&1) ret += g(dat[l++],lb,ub);//vl = f(vl,dat[l++]);
      if(r&1) ret += g(dat[--r],lb,ub);//vr = f(dat[--r],vr);
    }
    return ret;
  }
};


#include <algorithm>
#include <iostream>
using namespace std;

int main(){
  using T = vector<int>;
  function<T(T,T)> f = [](T a, T b){
                         int n = a.size();
                         a.insert(a.end(),b.begin(),b.end());
                         inplace_merge(a.begin(),a.begin()+n,a.end());
                         return a;
                       };
  T ti = {};
  
  int D;
  cin >> D;
  vector<T> X(D);
  for(int i = 0; i < D; ++i){
    int x;
    cin >> x;
    X[i].emplace_back(x);
  }
  SegmentTree<T> st(f,ti);
  st.build(X);

  int Q;
  cin >> Q;
  while(Q--){
    int l, r, e;
    cin >> l >> r >> e;
    --l,--r;
    int a = min(X[l][0],X[r][0]);
    int b = max(X[l][0],X[r][0]);
    ++r;
    cout << r-l-st.query(l,r,a-e,b+e) << endl;
  }
}



Measured memory_bytes: 25644
b,c=0,1
import math
while True:
    n=int(input())
    if n==0:
        break
    a=math.factorial(n)
    a=str(a)
    while True:
        if a.endswith('0'*c) is True:
            c+=1
        else:
            c-=1
            break
    print(c)


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

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset ((a), v, sizeof (a))

using namespace std;

typedef long long ll;
typedef pair <int, int> ii;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ii> vii;

int n, m, k;
bool can[1000005];

int main () {
	scanf ("%d %d %d", &n, &m, &k);
	for (int i = 0; i <= m; ++i) {
		for (int j = 0; j <= n; ++j) {
			can[n * i + j * (m - 2 * i)] = true;
		}
	}

	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= m; ++j) {
			can[m * i + j * (n - 2 * i)] = true;
		}
	}

	printf (can[k] ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 1280
package main

import (
	"fmt"
)

func solution(s string) string {
	if !isPalindrome(s) {
		return "No"
	}
	if !isPalindrome(s[:(len(s)-1)/2]) {
		return "No"
	}
	if !isPalindrome(s[-1+(len(s)+3)/2:]) {
		return "No"
	}
	return "Yes"
}

func isPalindrome(s string) bool {
	r := make([]rune, len(s))

	for i, v := range s {
		r[len(s)-1-i] = v
	}

	if s == string(r) {
		return true
	}

	return false
}

func main() {
	var s string
	fmt.Scan(&s)
	fmt.Println(solution(s))
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

//red:0 blue:1
signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	ll n;
	string s;
	cin>>n>>s;
	vector<string>red(1<<n,""),blue(1<<n,"");
	map<pair<string,string>,ll>mp;
	for(int i=0;i<(1<<n);++i){//前半分全列挙
		for(int j=0;j<n;++j){
			if(i>>j&1){
				red[i]+=string{s[n-1-j]};
			}
			else blue[i]+=string{s[n-1-j]};
		}
		//前半分について逆から読んだ赤、青と、後ろ半分についての青、赤が一致しているか調べる
		string ope="",ope2="";
		for(int j=0;j<n;++j){
			if(i>>j&1){
				ope+=string{s[n+j]};
			}
			else ope2+=string{s[n+j]};
		}
		mp[make_pair(ope,ope2)]++;
	}
	ll ans=0;
	for(int i=0;i<(1<<n);++i){
		ll x=mp[make_pair(blue[i],red[i])];
		ans+=x;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 96000
# 02-Getting_Started-Rectangle.py

# ????????¢?????¢?????¨??¨?????????
# ?????? a cm ?????? b cm ???????????¢?????¢?????¨??¨?????????????±???????????????°?????????????????????????????????

# Input
# a ??¨ b ????????????????????§????????????????????????????????????
# Output
# ??¢?????¨??¨?????????????????????????????§????????£????????????????????????????????????

# Sample Input
# 3 5
# Sample Output
# 15 16

# print("a??¨b?????\??????")
a,b=map(int,input().split())
# print("a=%d, b=%d."%(a,b))

# print("??¢??????%f ."%(a*b));
# print("??¨????????????%f ."%(2*a+2*b));
print("%d %d"%(a*b, 2*a+2*b));

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

int main() {
  int N;
  vector<int> H(100);
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  
  int ans = 0;
  int highest = 0;
  for(int i = 0; i < N; i++) {
    if(highest <= H.at(i)) {
      highest = H.at(i);
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 764
#include <stdio.h>

int main(int argc, char *argv[])
{
    int mat_a[100][100] = {}, mat_b[100][100] = {};
    int n, m, l;
    scanf("%d %d %d", &n, &m, &l);
    for (int row = 0; row < n; ++row)
    {
        for (int *elm = mat_a[row], *const end = elm + m; elm != end; ++elm)
        {
            scanf("%d", elm);
        }
    }
    for (int row = 0; row < m; ++row)
    {
        for (int *elm = mat_b[row], *const end = elm + l; elm != end; ++elm)
        {
            scanf("%d", elm);
        }
    }
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < l; ++j)
        {
            long cij = 0;
            for (int k = 0; k < m; ++k)
            {
                cij += mat_a[i][k] * mat_b[k][j];
            }
            printf("%ld%c", cij, j == l - 1 ? '\n' : ' ');
        }
    }
    return 0;
}



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

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

    vector<vector<int>> tree(N);
    for (int i = 0; i < M; i++)
    {
        int Ai, Bi;
        cin >> Ai >> Bi;
        Ai--;
        Bi--;
        tree.at(Ai).push_back(Bi);
        tree.at(Bi).push_back(Ai);
    }

    vector<int> res(N, -1);
    res.at(0) = 0;
    queue<int> q;
    q.push(0);
    while (!q.empty())
    {
        int n = q.front();
        q.pop();
        for (auto m : tree.at(n))
        {
            if (res.at(m) >= 0)
            {
                continue;
            }
            res.at(m) = n;
            q.push(m);
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i < N; i++)
    {
        cout << res.at(i) + 1 << endl;
    }
}

Measured memory_bytes: 10104
#input
n = int(input())
d1 = [0] * n
d2 = [0] * n
for i in range(n):
    d1[i],d2[i] = map(int, input().split())

def main():
    for i in range(n-2):
        #print ("{} {} {} {} {} {}".format(d1[i],d2[i],d1[i+1] ,d2[i+1],d1[i+2],d2[i+2]))
        if d1[i] == d2[i] and d1[i+1] == d2[i+1] and d1[i+2] == d2[i+2]:
            print('Yes')
            exit()
    print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9172
#include <iostream>
#include<vector>
#include<string>
#include<bits/stdc++.h>
#include<stdio.h>
#include<algorithm>
#define ll long long
#define ff first
#define ss second
#define mk make_pair
#define pb push_back
using namespace std;






int main(){


int k;

string a;
cin>>a;
k=a.size();
int an=0;
for(int i=0;i<k;i++)
    if(a[i]=='o')
    an++;
if(15-k+an>=8)
cout<<"YES"<<endl;
else cout<<"NO"<<endl;



}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int res = 0;
    REP(i, A + 1) {
        REP(j, B + 1) {
            REP(k, C + 1) {
                if (500 * i + 100 * j + 50 * k == X) {
                    res++;
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;


fn main() {
    input!{n:usize, a:[i32;n]};
    let mut ans = 0;
    for i in 0..n {
        if a[a[i] as usize -1] == i as i32 +1 { ans += 1; }
    }
    println!("{}", ans/2);
}

Measured memory_bytes: 4352
n = int(input())
a, b = [], []
for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
a.sort()
b.sort()
if n%2==0:
    p = n//2
    right = (a[p]+a[p-1])/2 - 0.5
    left = (b[p]+b[p-1])/2
    r = left-right
    if int(r)==r:
        print(int(r)*2)
    else:
        print(int(r)*2 +1)
else:
    p = n//2
    right = a[p]
    left = b[p]
    print(int(left-right)+1)

Measured memory_bytes: 25484
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n;
	while(cin>>n and n>0){
		int s[n]; rep(i,n) cin>>s[i];
		sort(s,s+n);
		int sum=0;
		for(int i=1;i<n-1;i++){
			sum+=s[i];
		}
		int ans=sum/(n-2);
		cout<<ans<<endl;
	}

	return 0;
}



Measured memory_bytes: 2988
def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    inlis.sort()

    ans = 100 ** 6
    for i in range(1, 101):
        tmp = 0
        for j in range(len(inlis)):
            tmp += (inlis[j] - i ) ** 2
            if tmp > ans:
                break
        if tmp < ans:
            ans = tmp
    print(ans)
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 63540
#include<bits/stdc++.h>
char s[101];
using namespace std;
int main() {
	cin >> s + 1;
	int len = strlen(s + 1);
	bool flag = true;
	for (int i = 1; i <= len; i++) {
		if (i % 2 == 0) {
			if (s[i] == 'R') {
				cout << "No";
				return 0;
			}
		}
		else {
			if (s[i] == 'L') {
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<long long int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(a[i] % 2 == 0){
            while(true){
                if(a[i] % 2 == 1){
                    break;
                }
                a[i] /= 2;
                cnt++;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 384
//1508
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
 
#define REP(i,b,n) for(int i=b;i<n;++i)
#define REPR(i,b,n) for(int i=n-1;i>=b;--i)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PI acos(-1.0)

using namespace std;

static const double EPS = 1e-9;
typedef pair<int, int> pii;
typedef long long ll;

#define LIM 24*60*60
int n;
int in[LIM+10];
int out[LIM+10];

int main(){
	
	int n;
	
	while(cin >> n, n){
	
		CLR(in);
		CLR(out);
	
		for(int i=0; i<n; ++i){
			int hh, mm, ss;
			scanf("%d:%d:%d", &hh, &mm, &ss);
			in[hh*60*60 + mm*60 + ss]++;
			scanf("%d:%d:%d", &hh, &mm, &ss);
			out[hh*60*60 + mm*60 + ss]++;
		}
		
		int res = 0;
		int t = 0;
		
		for(int i=0; i<LIM; ++i){
			
			t += in[i];
			t -= out[i];
			res = max(res, t);

		}
			
		cout << res << endl;	
	}
	
	return 0;
}

Measured memory_bytes: 1924
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int secs = sc.nextInt();
		
		int hours = 0;
		while(secs >= 3600) {
			hours +=1;
			secs -= 3600;
		}
		
		int mins = 0;
		while(secs >= 60) {
			mins +=1;
			secs -=60;
		}
		
		System.out.println(hours + ":" + mins + ":" + secs);
	}
}

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

#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

class CGCDOnBlackboard {
public:
	void solve(std::istream& in, std::ostream& out) {
        int N;
        in >> N;
        ll A[N];
        REP(i, N) in >> A[i];
        ll left[N+1], right[N+1];
        left[0] = A[0];
        right[N] = A[N-1];
        for (int i = 1; i <= N; i++) {
            left[i] = gcd(left[i-1], A[i-1]);
            right[N-i] = gcd(right[N-i+1], A[N-i]);
        }
        ll ans = 0;
        REP(i, N) {
            if (i == 0) ans = max(ans, right[1]);
            else if (i == N -1) ans = max(ans, left[N-1]);
            else ans = max(ans, gcd(left[i], right[i+1]));
        }
        out << ans << '\n';
	}
};


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


Measured memory_bytes: 2560
from collections import Counter #リストの出現数をカウント
n = int(input())
a =Counter( list( map(int,input().split()) ) ) #同行にk個入力した数字をリスト→カウントに変換
for i in range(1,n+1) : #1~n+1未満の数字をそれぞれカウントし、改行して表示
    print(a[i])

Measured memory_bytes: 34140
# 要復習
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    x, y = MAP()
    count = 0
    while x <= y:
        x = 2 * x
        count += 1
    print(count)
if __name__ == "__main__":
    main()




Measured memory_bytes: 5168
A = int(input())
B = int(input())
C = int(input())
X = int(input())
s = 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:
                s += 1
print(s)

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define INF (1<<29)

double dp[1<<15][15]; //second
int prevBit[1<<15][15];
int prevPos[1<<15][15];
int num[15], dist[15], cnt[15];

int main() {
	int n;
	cin >> n;
	REP(i, n) scanf("%d %d %d", &num[i], &dist[i], &cnt[i]);
	
	fill(dp[0], dp[1<<15], INF);
	REP(i, n) dp[1<<i][i] = 0.0;
	
	REP(i, 1<<n) REP(j, n) {
		if (dp[i][j] == INF) continue;
		
		int weight = 0;
		REP(k, n) if ((i >> k) & 1) weight += cnt[k] * 20;
		double speed = 2000.0 / (70.0 + weight);
		
		REP(k, n) if (((i >> k) & 1) == 0) {
			int next = i | (1 << k);
			double cost = abs(dist[j] - dist[k]) / speed;
			if (dp[next][k] > dp[i][j] + cost) {
				prevBit[next][k] = i;
				prevPos[next][k] = j;
				dp[next][k] = dp[i][j] + cost;
			}
		}
	}
	
	pair<double, int> m = make_pair(INF, -1);
	REP(i, n) m = min(m, make_pair(dp[(1<<n)-1][i], i));
	int nowPos = m.second;
	int nowBit = (1 << n) - 1;
	vector<int> ans;
		
	while (nowBit > 0) {
		ans.push_back(num[nowPos]);
		int nextBit = prevBit[nowBit][nowPos];
		int nextPos = prevPos[nowBit][nowPos];
		
		nowBit = nextBit;
		nowPos = nextPos;
	}
	
	reverse(ans.begin(), ans.end());
	REP(i, ans.size()) printf("%d%c", ans[i], i == ans.size() - 1 ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 8920
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,ans=0;
    for(int i=1;i<=3;i++)
    {
        scanf("%d",&a);
        ans=ans*10+a;
    }
    ans%4==0?printf("YES\n"):printf("NO\n");
    return 0;
}

Measured memory_bytes: 256
def binarySearch(n, a):
    ok = len(a)
    ng = -1
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        # print("n:", n, "idx:", mid, "val:", a[mid], ok, ng, file=sys.stderr)
        if a[mid] >= n:
            ok = mid
        else:
            ng = mid
    return ok


def resolve():
    import sys
    input = sys.stdin.readline
    n = int(input())
    a = [int(i) for i in input().split()]
    q = int(input())
    for _ in range(q):
        k = int(input())
        print(binarySearch(k, a))


resolve()



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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	char s[16];
	int n[16];
	rep(i, 10)
		cin >> s[i];

	rep(i, 10){
		if(i == 4 || i == 7)
			continue;

		n[i] = s[i] - '0';
	}

	if((n[0] * 10000000 + n[1] * 1000000 + n[2] * 100000 + n[3] * 10000 + n[5] * 1000 + n[6] * 100 + n[8] * 10 + n[9]) < 20190431)
		cout << "Heisei" << endl;
	else
		cout << "TBD" << endl;

	return 0;
}


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

using namespace std;

int main()
{
    unsigned long long a[100001];
    int nt[28]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103};
    int n;
    cin >> n;
    if (n<2)
    {
        cout << 0;
        return 0;
    }
    for (int i(1); i<=n; i++)
    {
        string s;
        cin >> s;
        a[i]=1;
        for (int j(0); j<s.length(); j++)
            a[i]*=nt[s[j]-'a'];
    }
    long long d(1),res(0);
    sort(a+1,a+1+n);
    for (int i(2); i<=n; i++)
    {
        if (a[i]==a[i-1])
            {
                d++;
                res+=(d-1);
            }
        else d=1;
    }
    cout << res;
}


Measured memory_bytes: 1024
x, k, d = map(int, input().split())
x = abs(x)
z = x//d
if x-k*d >= 0:
    print(x-k*d)
else:
    if (k-z)%2 == 0:
        print(x-z*d)
    else:
        print(abs(x-z*d-d))

Measured memory_bytes: 61852
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;
priority_queue<int,vector<int>,greater<int>> que;
     signed main(){
int n,ans=0;
cin>>n;
for(int i=0;i<n;i++)ans+=(n-i)*(n+1-i)/2;
//cerr<<ans<<endl;
int u,v;
for(int i=0;i<n-1;i++){
    cin>>u>>v;
    if(u>v)swap(u,v);
    ans-=u*(n+1-v);
}
cout<<ans<<endl;


     }


 


 






    





      

        


Measured memory_bytes: 3612
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_D&lang=jp


#include<iostream>
 using namespace std;

int main(){

 int n , a[10000] ;
 long min =0  , max = 0 , sum = 0 ;

 cin >> n ;

//初期値の処理
 cin >>a[1] ;
 min = a[1] ; max = a[1] ; sum = a[1] ;

        for (int i = 2 ; i <= n ; i = i + 1 )
 	{
 	cin >>a[i] ;

                if ( min > a[i] ){ //最小値の更新処理
                min = a[i] ;
                }else{
                //特に何もしない
                }

                if ( max < a[i] ){ //最大値の更新処理
                max = a[i] ;
                }else{
                //特に何もしない
                }
         
                sum = sum + a[i] ;

 	}

 cout << min << " " << max << " " << sum << endl; //結果の出力

 return 0;
 }


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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
double min(double a,double b){
  if(a<b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
int sum_keta(int n){
  if(n==0) return 0;
  return n%10 + sum_keta(n/10);
}
int main(void){
  int N; cin >> N;
  
  if(N%sum_keta(N)==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
int a,b;
int main(){
	scanf("%d%d",&a,&b);
	fo(c,1,3) if ((a*b*c)&1){
		printf("Yes\n");
		return 0;
	}
	printf("No\n");
	return 0;
} 

Measured memory_bytes: 128