akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
int main(){
    int w,h,n;
    cin>>w>>h>>n;
    int xmax = w,xmin = 0;
    int ymax = h,ymin = 0;
    vector<int> x(n),y(n),a(n);
    rep(i,n){
        cin>>x[i]>>y[i]>>a[i];
    }
    rep(i,n){
        if(a[i]==1){
            xmin = max(xmin,x[i]);
        }
        if(a[i]==2){
            xmax = min(xmax,x[i]);
        }
        if(a[i]==3){
            ymin = max(ymin,y[i]);
        }
        if(a[i]==4){
            ymax = min(ymax,y[i]);
        }
    }
    if(xmax-xmin<0 && ymax-ymin<0){
        cout<<0<<endl;
        return 0;
    }
    cout<<max(0,(xmax-xmin)*(ymax-ymin))<<endl;

}

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

int main(){
    int n ;
    cin >> n ;
    vector<int> b(n-1) ;
    for (size_t i = 0; i < n-1; i++)
    {
        cin >> b.at(i) ;
    }
    int64_t ans = 0 ;
    ans += b.at(0) ;
    for (size_t i = 1; i < n-1; i++)
    {
        ans += min(b.at(i-1) , b.at(i)) ;
    }
    ans += b.at(n-2) ;
    cout << ans <<endl ;
    
}

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

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();
            string t = Console.ReadLine();

            long cnt = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] != t[i])
                {
                    cnt++;
                }
            }

            string result = cnt.ToString();

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27428
package main

import (
	"fmt"
)

func main() {
	var n, cnt int
	var s string
	fmt.Scan(&n, &s)
	rs := []rune(s)
	for _, v := range rs {
		if string(v) == "R" {
			cnt++
		}
	}
	if cnt > n/2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


int main(){fastio
    
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll ans=-100,c=-1;
    rep(i,0,n-1){
        if(i==0||a[i-1]>=a[i]){
            c++;
            Max(ans,c);
        }else{
            c=0;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


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

#define lint long long

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

    int h[N + 1];

    for(int i = 1; i < N + 1; ++i){
        cin >> h[i];
    }
    
    int dp[N + 1];

    dp[N] = 0;
    dp[N - 1] = abs(h[N] - h[N - 1]);

    if(N < 3){
        cout << dp[1] << endl;
        return 0;
    }
    for(int i = N - 2; i > 0; --i){
        dp[i] = min(dp[i + 1] + abs(h[i] - h[i + 1]), dp[i + 2] + abs(h[i] - h[i + 2]));
    }
    
    cout << dp[1] << endl;
}

Measured memory_bytes: 1024
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


s,w = list(map(int, input().split()))
if s<=w:
    ans = "unsafe"
else:
    ans = "safe"
print(ans)

Measured memory_bytes: 61896
/*input
8 5
7 5 3 5 4
12 5 8
16 2 1
3 1 5
17 12 17
19 7 5
12 2 19
4 1 3
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<pair<int,int> > mv;
int times[100005];
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,m,i,j,a,k=0,b,sum=0,A,B,C;
	cin>>n>>m;
	for(i=1;i<n;i++)
	{
		mv.push_back(make_pair(i,2));
	}
	cin>>a;
	for(i=1;i<m;i++)
	{
		cin>>b;
		if(a>b)
		{
			mv.push_back(make_pair(b,0));
			mv.push_back(make_pair(a,1));
		}
		else
		{
			mv.push_back(make_pair(a,0));
			mv.push_back(make_pair(b,1));
		}
		a=b;
	}
	sort(mv.begin(),mv.end());
	for(i=0;i<mv.size();i++)
	{
		/*cout<<mv[i].first<<" "<<mv[i].second<<"\n";*/
		if(mv[i].second==0) k++;
		if(mv[i].second==2) times[mv[i].first]=k;
		if(mv[i].second==1) k--;
	}
	for(i=1;i<n;i++)
	{
		cin>>A>>B>>C;
		sum+=min(C+B*times[i],A*times[i]);
		/*cout<<times[i]<<"\n";*/
	}
	cout<<sum << "\n";
	return 0;
}

Measured memory_bytes: 11220
#挿入ソート
def print_output(_list):
    for index in range(len(_list)):
        if index == len(_list) - 1:
            print(_list[index])
        else:
            print(_list[index],end=' ')

target_length = int(input())
target_list = list(map(int,input().split()))
print_output(target_list)
for index in range(1, target_length):
    v = target_list[index]
    j = index -1
    while (j >= 0 and target_list[j] > v):
        target_list[j + 1] = target_list[j]
        j -= 1
    target_list[j + 1] = v
    print_output(target_list)


Measured memory_bytes: 5984
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define VI vector<int>
#define VII vector<vector<int>>
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)


int main(){
    int N,x;
    cin>>N>>x;
    vector<int> A(N);
    rep(i,N) cin>>A[i];
    sort(all(A));
    int ans = 0;
    
    rep(i,N){
        if(x >= A[i]){
            if(i==N-1&&x>A[i]) --ans;
            x -= A[i];
            ++ans;
        }
        else break;
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
/* ex4_3
	kanon */

#include <stdio.h>
#include <math.h>

//n番目の塔の高さを求める
int calculate_height(int height_a,int height_b);

int main(void)
{

    //与えられる値を入れる数を宣言
    int height_a,height_b;

    //変数に値を入力する
    scanf("%d %d",&height_a,&height_b);
    
    int ans=calculate_height(height_a,height_b);
    printf("%d",ans);

    return 0;
}

int calculate_height(int height_a,int height_b){
    int snow_height=0;
    //高さを計算する
    int diff=height_b-height_a;
    for(int i=1;i<diff;i++){
        snow_height+=i;
    }
    return snow_height-height_a;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#define pb push_back
#define all(c) c.begin(),c.end()
#define uni(c) c.erase(unique(all(c)),c.end())
using namespace std;
int a,b;
int ret(int bow,int now,int k){
	int ans=0;
	int x=(int)a/(int)now,y=b/now;
	//cout<<now<<endl;
	if(!(x||y)){
		return 0;
	}
	x%=10,y%=10;
	//cout<<"  "<<x<<"   "<<y<<endl;
	
	if(x-bow>=y){
		ans=max(ans,ret(0,now*10,k)*10+x-bow-y);
	}else{
		if(k)
		ans=max(ans,ret(0,now*10,k-1)*10+x-bow-y+10);
		ans=max(ans,ret(1,now*10,k)*10+x-bow-y+10);
	}
	return ans;
}
int main(){
	int n;
	while(cin>>a>>b>>n){
		cout<<ret(0,1,n)<<endl;
		//bow,now,k
	}
	return 0;
}

Measured memory_bytes: 0
H,W = list(map(int,input().split()))

grid = [['_']*(W+2)]
for i in range(H):
    grid.append(list('_' + input() + '_'))
grid.append(['_']*(W+2))

dp = [[float('inf')]*(W+2) for i in range(H+2)]
dp[0][1] = 0
for c in range(1,H+1):
    for r in range(1,W+1):
        if grid[c][r] == '#':
            left = dp[c][r-1]+1 if grid[c][r-1] != '#' else dp[c][r-1]
            up = dp[c-1][r]+1 if grid[c-1][r] != '#' else dp[c-1][r]
            dp[c][r] = min(left,up)
        else:
            dp[c][r] = min(dp[c][r-1],dp[c-1][r])

print(dp[H][W])

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

typedef long long ll;

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

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int a,b;
	char op;
	cin >> a >> op >> b;
	if(op == '+'){
		ANS(a+b);
	}else{
		ANS(a-b);
	}
	return 0;
}


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

using namespace std;

int main()
{
    //system("chcp 65001");

    string S;
    cin >> S;

    //56 89
    if(S[5] == '0' && int(S[6]) <= 52 && int(S[8]) <= 51)
    {
        if(S[8] == '3' && S[9] == '1')
        {
            cout << "TBD";
            goto end;
        }
        cout << "Heisei";
    }
    else
    {
        cout << "TBD";
    }
    
    end:
    //cout << N;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    ArrayList<Integer> result = new ArrayList<Integer>();
	    while (true) {
		    String line = br.readLine();

		    if ("0".equals(line)) break;

		    int sum = 0;
		    for (int i = 0; i < line.length(); i++) {
		    	char c = line.charAt(i);
		    	sum += Character.getNumericValue(c);
		    }
		    result.add(sum);
	    }
	    
	    // Display Anaser
	    StringBuilder sb = new StringBuilder();
	    for (int i = 0; i < result.size(); i++) {
	    	sb.append(result.get(i));
    		sb.append("\n");
	    }
	    System.out.print(sb.toString());
	}
}

Measured memory_bytes: 24300
import sys
from collections import deque

input = sys.stdin.readline


def bfs(N):
    res = 0
    queue = deque(["3", "5", "7"])
    while queue:
        num = queue.popleft()
        if int(num) > N:
            break
        res += 1 if all(d in num for d in "357") else 0
        queue.append("".join([num, "3"]))
        queue.append("".join([num, "5"]))
        queue.append("".join([num, "7"]))
    return res


def main():
    N = int(input())

    ans = bfs(N)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 7532
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
int main()
{
    int n;
    cin >> n;
    vi s1(n+1,0);
    vi s2(n+1,0);
    rep(i, n)
    {
        int a;
        cin >> a;
        s1[i+1] += s1[i] + a;
    }
    rep(i, n)
    {
        int a;
        cin >> a;
        s2[i+1] += s2[i] + a;
    }
    int ans = 0;
    rep(i, n)
    {
        ans = max(ans, s1[i+1] + s2[n] - s2[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
N = int(input())
ans = 0
C = [[0]*10 for _ in range(10)]
for n in range(1, N+1):
    i, j = int(str(n)[0]), int(str(n)[-1])
    C[i][j] += 1
for i in range(10):
    for j in range(10):
        ans += C[i][j] * C[j][i]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int MAX_N = 13, INF = 0x3f3f3f3f;
int N, M;
struct Key
{
	int cost;
	vector<int> door;
}Keys[1006];

int dp[1<<MAX_N];

void solve()
{
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	for(int i=0;i<(1<<N);++i)if(dp[i]!=INF)for(int j=0;j<M;++j){
			int nex = i;
			for(int k=0;k<Keys[j].door.size();++k) nex |= (1<<(Keys[j].door[k]));
			dp[nex] = min(dp[nex], dp[i]+Keys[j].cost);
	}
	if(dp[(1<<N)-1]==INF) cout << -1 << "\n";
	else cout << dp[(1<<N)-1] << "\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> M;
	int b,c;
	for(int i=0;i<M;++i){
		cin >> Keys[i].cost >> b;
		while(b--){
			cin >> c;
			Keys[i].door.push_back(c-1);
		}
	}
	solve();
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int num;

	scanf("%d", &num);

	if (num % 10 == 3)
	{
		printf("bon\n");
	}
	else if(num % 10 == 0 || num % 10 == 1 || num % 10 == 6 || num % 10 == 8)
	{
		printf("pon\n");
	}
	else
	{
		printf("hon\n");
	}

	return 0;
}

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

struct UnionFind {
    vector<long long> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(long long N) : par(N) { //最初は全てが根であるとして初期化
        for(long long i = 0; i < N; i++) par[i] = i;
    }

    long long root(long long x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(long long x, long long y) { // xとyの木を併合
        long long rx = root(x); //xの根をrx
        long long ry = root(y); //yの根をry
        if (rx != ry) par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(long long x, long long y) { // 2つのデータx, yが属する木が同じならtrueを返す
        long long rx = root(x);
        long long ry = root(y);
        return rx == ry;
    }
};

int main(){
    long long N, K, L;
    cin >> N >> K >> L;
    UnionFind tree_road(N), tree_rail(N);
    long long p, q;
    for (long long i = 0; i < K; i++)
    {
        cin >> p >> q;
        tree_road.unite(p-1, q-1);
    }
    long long r, s;
    for (long long i = 0; i < L; i++)
    {
        cin >> r >> s;
        tree_rail.unite(r-1, s-1);
    }
    map<pair<long long, long long>, long long> mp;
    for (int i = 0; i < N; i++)
    {
        mp[{tree_road.root(i), tree_rail.root(i)}]++;
    }
    for (int i = 0; i < N; i++)
    {
        cout << mp[{tree_road.root(i), tree_rail.root(i)}] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MAXN = 301;



int main(){
    ll N; cin >> N; vector<ll> A(N), B(N), V(N);
    ll X = 0;
    for(int i = 0; i < N; i++) {cin >> A[i] >> B[i]; V[i] = A[i] + B[i]; X -= B[i];}
    sort(V.rbegin(), V.rend());
    for(int i = 0; i < N; i+=2){
        X += V[i];
    }
    cout << X << endl;
}

Measured memory_bytes: 2560
n = int(input())
c = input()
c = list(c)
arr = []
a = 0
b = c.count('R')
arr.append(max(a, b))
for i in range(n):
  if c[i] == 'W':
    a += 1
  elif c[i] == 'R':
    b -= 1
  arr.append(max(a, b))
ans = min(arr)
print(ans)

Measured memory_bytes: 18760
N = int(input())
L = list(map(int, input().split()))
#N=5
num=0
for a in range(1,N-1):
    for b in range(a+1,N):
        for c in range(b+1,N+1):
            #print(a,b,c)
            if L[a-1]!=L[b-1] and L[b-1]!=L[c-1] and L[c-1]!=L[a-1] :
                if L[a-1]+L[b-1]>L[c-1] and L[b-1]+L[c-1]>L[a-1] and L[a-1]+L[c-1]>L[b-1] :
                    num+=1
print(num)

Measured memory_bytes: 68712
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 9999999999
using namespace std;
typedef long long ll;


double dp[3000][3000];
double finres = 0.0;
double solve(vector <double> &arr,ll n)
{
    arr.insert(arr.begin(),0.0);
    
    int i,j;
    for(i=0;i<3000;i++)
    {
        for(j=0;j<3000;j++)
        {
            dp[i][j] = 0.0;       
        }
    }
    dp[0][0] = 1;
    for(i=1;i<=n;i++)
    {
        dp[i][j] = 0;
        for(j=0;j<=i;j++)
        {
            if(j>0)
                dp[i][j] += dp[i-1][j-1]*arr[i];
            dp[i][j] += dp[i-1][j]*(1-arr[i]);
        }
    }
    double ans = 0.0;
    for(i=1;i<=n;i++)
    {
        if(i>n-i)
            ans = ans + dp[n][i];
    }
    /*for(i=0;i<=n;i++)
    {
        for(j=0;j<=n;j++)
            cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    return ans;

}

int main()
{
    
    
        
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
      
    ll n,i,j;
    cin>>n;
    

    vector <double> arr(n);
    for(i=0;i<n;i++)
        cin>>arr[i];
    double res = solve(arr,n);
    printf("%.10f\n",res);
    return 0;
}


Measured memory_bytes: 70656
a,b,c=map(int,raw_input().split())
x = []
x.append(a)
x.append(b)
x.append(c)
f = True
x = sorted(x)
if x[0] != 5:
    f = False
elif x[1] != 5:
    f = False
elif x[2] != 7:
    f = False

if f:
    print 'YES'
else:
    print 'NO'


Measured memory_bytes: 2568
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
using ulong = unsigned long;
using ll = long long;

ll calc(ll s, ll l){
	ll ret;
	if(l % s == 0){
		ret =  2 * s * (l / s) - s;
	}else{
		ret =  2 * s * (l / s) + calc(l % s, s);
	}
	// cout<<s<<' '<<l<<' '<<ret<<endl;
	return ret;
	// return 2 * s * (l / s) + (l % s == 0 ? 0 : calc(l, l % s));
}

int main(){
	ll n, x;
	cin >> n >> x;
	// cout << n + calc(x, n - x) << endl;
	ll s = min(x, n - x), l = max(x, n - x);
	cout << n + calc(s, l) << endl;
	return 0;
}



Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c; cin >> a >> b >> c;
  if(b < c)swap(b,c);
  if(a < b)swap(a,b);
  if(make_tuple(a,b,c) == make_tuple(7,5,5))cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3544
/****************************
** In the name of Allah    **
** Author: Farhad          **
** From  : IIT,JU          **
*****************************/
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c)
        printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C (GCC 5.4.1)
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

typedef struct{
	int x;
	int y;
} XY;

int main(int argc, char const *argv[])
{
	int h,w;
	int sharp = 0;
	char a[10][10] = {'\0'};

	scanf("%d%d",&h,&w);
	for (int i = 0; i < h; ++i){
	  scanf("%s", a[i]);
	  for (int j = 0; j < w; ++j){
	    if(a[i][j] == '#')  ++sharp;
	  }
	}
	if(sharp == h + w - 1)  puts("Possible");
	else puts("Impossible");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
 vector<int>data(60);
  for(int i=0;i<N;i++){
  cin>>data.at(i);
  }
  sort(data.begin(),data.end());
  reverse(data.begin(),data.end());
  int count;
  for(int i=0;i<K;i++){
  count =count+data.at(i);
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;


int main(void) {
    priority_queue<long long> costs;

    long long n, m;
    cin >> n >> m;
    for (long long i = 0; i < n; i++) {
        long long cost;
        cin >> cost;
        costs.push(cost);
    }
    
    for (long long i = 0; i < m; i++) {
        long long current_max = costs.top();
        costs.pop();
        costs.push(current_max / 2);
    }
    
    long long res = 0;
    while( !costs.empty() ) {
        res += costs.top();
        costs.pop();
    }
    cout << res << endl;
}

Measured memory_bytes: 1400
s = input()
k = int(input())

if len(set(s)) == 1:
    print(len(s)*k//2)
    exit()

t1 = s + "#"
t2 = s * 2 +"#"
# t3 = s * 3 + "#"
# t4 = s * 4 + "#"

def f(text):
    start, end = 0, 0
    rc = []

    while start != len(text)-1:
        if text[start] == text[end]:
            end += 1
        else:
            rc.append(end-start)
            start = end

    return(rc)

first = sum([i//2 for i in f(t1)])
dif = sum([i//2 for i in f(t2)]) - sum([i//2 for i in f(t1)])

print(first + dif*(k-1))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#pragma 03
using namespace std;
int main(){
	ll a, b, c;
	ll k;
	cin >> a >> b >> c >> k;
	ll lol;
	if (k % 2 == 0) lol = 1;
	else lol = -1;
	cout << (a - b) * lol << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;
long long ans[1001][1001];
vector<int> Dist,Clouds;

int main(){
	int N,M,a;
	cin>>N>>M;
	for(int i=0;i<N;i++){
		cin>>a;
		Dist.push_back(a);
	}
	for(int j=0;j<M;j++){
		cin>>a;
		Clouds.push_back(a);
	}
	
	for(int i=0;i<N+1;i++){
		for(int j=i;j<M+1;j++){
			if(i==0){
				ans[i][j]=0;
			}else if(i==j){
				ans[i][j]=ans[i-1][j-1]+Dist[i-1]*Clouds[j-1];
			}else{
				ans[i][j]=min(ans[i-1][j-1]+Dist[i-1]*Clouds[j-1],ans[i][j-1]);
			}
		}
	}
	/*for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			cout<<ans[i][j]<<" ";
		}
		cout<<endl;
	}*/
		cout<<ans[N][M]<<endl;
	
}

Measured memory_bytes: 7512
import java.util.Scanner;

public class Main {

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

		int h = S / 3600;
		int m = (S%3600) / 60;
		int s = S % 60;

		System.out.println(h+":"+m+":"+s);


	}

}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;
  string S1,S2;
  cin >> S1;
  cin >> S2;
  string pattern = "";

  int index = 0;
  while(index < N){
    if(S1[index] == S2[index]){
      index++;
      pattern += "A";
    } else {
      index += 2;
      pattern += "B";
    }
  }
  ll ans = 1;
  if(pattern[0] == 'A') ans = 3;
  else ans = 6;

  for(int i = 1; i < pattern.size(); i++){
    if(pattern[i-1] == 'A' && pattern[i] == 'A'){
      ans *= 2;
    }
    if(pattern[i-1] == 'A' && pattern[i] == 'B'){
      ans *= 2;
    }
    if(pattern[i-1] == 'B' && pattern[i] == 'A'){
      ans *= 1;
    }
    if(pattern[i-1] == 'B' && pattern[i] == 'B'){
      ans *= 3;
    }
    ans %= MOD;
  }

  cerr << pattern << endl;
  cout << ans << endl;
}



Measured memory_bytes: 256
n, k = map(int, input().split())
A = list(map(int, input().split()))
sort_A = sorted(A, reverse = True)
mod = 10**9 + 7
mi = 0
cnt = 0
for i in range(n-1):
  a = A[i]
  for j in range(i+1, n):
    b = A[j]
    if a < b:
      mi += 1
for i in range(n-1):
  a = sort_A[i]
  for j in range(i+1, n):
    b = sort_A[j]
    if a > b:
      cnt += 1
print((cnt * (k*(k+1)//2) - (mi * k)) %mod)

Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String slist[] = s.split("");
        System.out.println(slist[0] + slist[1] + slist[2]);
    }
}


Measured memory_bytes: 38916
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define forn(a,b,c) for(int a=b;a<=c;a++)
#define ford(a,b,c) for(int a=b;a>=c;a--)
typedef pair<int,int> pii;
const int N=3e3+5;
const int mod=1e9+7;
int dp[N][N],s[N][N],n;
string str;
int add(int x, int y){ x+=y;if(x>=mod) x-=mod;return x;}
int sub(int x, int y){ x-=y;if(x<0) x+=mod;return x;}
int main()
{
    scanf("%d",&n);
    cin>>str;
    dp[1][1]=1;
    s[1][1]=1;
    s[1][n]=1;
    forn(i,2,n){
        if(str[i-2]=='>'){
            forn(j,1,i){
                dp[i][j]=sub(s[i-1][n],s[i-1][j-1]);
            }
        }
        else{
            forn(j,1,i){
                dp[i][j]=s[i-1][j-1];
            }
        }
        forn(j,1,n){
            s[i][j]=add(s[i][j-1],dp[i][j]);
           // printf("i:%d j:%d dp[i][j]:%d s[i][j]:%d\n",i,j,dp[i][j],s[i][j]);
        }
    }
    printf("%d\n",s[n][n]);
    return 0;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
typedef long long int ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define p push
#define p1 pop
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair<ll,ll>
#define e 1000000007
using namespace std;
ll w[102],v[102],n,memo[100001][101];
ll solve(ll i,ll w1)
{
   if(i==(n+1) || w1==0)
        return 0;
   if((w1-w[i])<0)
        return solve(i+1,w1);
    if(memo[w1][i]!=-1)
        return memo[w1][i];
    else
        memo[w1][i]=max(v[i]+solve(i+1,w1-w[i]),solve(i+1,w1));
    return memo[w1][i];
}
int main()
{
    ll w1;
    memset(memo,-1,sizeof(memo));
    cin>>n>>w1;
    for(int i=1;i<=n;++i)
        cin>>w[i]>>v[i];
    cout<<solve(1,w1);
}

Measured memory_bytes: 79104
/*
dpで書いたやつの解説

”i円までの最適を考える”
という感じで考える

i円集めるには高々i回
操作すればいいので
各要素をdp[i]=iで初期化

要素の個数は
9^7=4782969なので
5000000くらいあれば
十分

あとは配るdpで各要素を
最小化する

dp[n]を出力

補足として
要素数に十分ゆとりがあるから
i番目をi円集める最小
にするとわかりやすいかなと思って
出力がdp[n]でよい

では本文をどうぞ
*/
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n; ci(n);
  vll dp(5000000);
  FOR(i,1,5000000){
    dp[i]=i;
  }
  FOR(i,0,n){
    FOR(j,0,8){
      ll a=pow(6,j);
      ll b=pow(9,j);
      chmin(dp[i+a],dp[i]+1);
      chmin(dp[i+b],dp[i]+1);
    }
  }
  co(dp[n])
}


Measured memory_bytes: 39296
n = gets.to_i

edge = Array.new(n+1) {[]}
(n-1).times do
    a, b = gets.split.map(&:to_i)
    edge[a] << b
    edge[b] << a
end

vis = Array.new(n+1)
bfs =->(x, f, g) {
    que = [x]
    while now = que.shift
        edge[now].each do |e|
            next if f.(now, e)
            g.(now, e)
            que << e
        end
    end
}

vis[0] = vis[1] = 0
bfs.(1, ->(now,e){vis[e]}, ->(now,e){vis[e] = vis[now]+1})

vis[n] = 0
bfs.(n, ->(now,e){vis[e] <= vis[now].abs+1}, ->(now,e){vis[e] = vis[now]-1})

puts 2 * (vis.count {|e| e > 0} + 1) > n ? "Fennec" : "Snuke"

Measured memory_bytes: 25268
#ifdef __GNUC__
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#endif

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>

#include <string>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <cassert>//assert();
#include <fstream>
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)

/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#define PII pair<int,int>
/////////
using namespace::std;

// 最大公約数
template<class T>
inline T gcd(T a, T b){return b == 0 ? a : gcd(b, a % b);}
// 最小公倍数
template<class T>
inline T lcm(T a, T b){return a * b / gcd(a, b);}
////////////////////////////////

inline void solve(){
	int N;
	cin >> N;
	vector<int> A(N);
	int guu=0;
	int ki = 0;
	for(int i=0;i<N;++i){
		cin >> A[i];
		if( A[i] %2 == 0 ){
			++guu;
		}else{
			++ki;
		}
	}
	if( ki%2 == 1){
		if( guu > 0 ){
			cout << "NO" << endl;
			return;
		}
	}
	cout << "YES" << endl;
}

signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数をいっぱい表示する。16?

	solve();
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main()
{
	int N;
	scanf("%d",&N);
	int times=0;
	for(int i=0;i<N;i++)
	{
		int num;
		scanf("%d",&num);
		while(num%2==0)
			times++,num/=2;
	}
	printf("%d\n",times);
	return 0;
 } 

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

int n;

int main() { 

  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if ((x % 2 == 0 && (x % 3 != 0 && x % 5 != 0))) {
      puts("DENIED");
      return 0;
    }
  }

  puts("APPROVED");

  return 0;
}


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

using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

signed main(void)
{
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(x-a) < abs(x-b)) cout << "A" << endl;
  else cout << "B" << endl;

  return 0;
}


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

cost = 0
for i in range(N+1):
    cost += abs(A[i]-A[i+1])

for i in range(1,N+1):
    print(cost - abs(A[i-1]-A[i]) -abs(A[i]-A[i+1]) + abs(A[i-1]-A[i+1]))


Measured memory_bytes: 14048
//============================================================================
// Name        : aoj0108.cpp
// Author      : afterCmidday
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

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

int main() {
	int n, s[12], tmp[12], pre[12], exe;
	while(cin >> n,n){
		exe = 0;
		for(int i = 0 ;i < n;i++){
			cin >> s[i];
		}
		memset(pre,-1,sizeof(pre));
		while(true){
			int i;
			for(i = 0;i < n;i++){
				pre[i] = s[i];
				tmp[i] = s[i];
			}
			for(i = 0;i < n;i++){
				int cnt = 0;
				for(int j = 0;j < n;j++){
					if(tmp[i] == tmp[j]){
						cnt++;
					}
				}
				s[i] = cnt;
			}
			exe++;
			for(i = 0;i < n;i++){
				if(pre[i] != s[i]){
					break;
				}
			}
			if(i == n){
				break;
			}
		}
		cout << exe - 1 << endl;
		for(int i = 0;i < n;i++){
			cout << s[i];
			if(i != n - 1){
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    n = ni()
    a = na()

    larger = [i - a[i] for i in range(n)]
    larger_cnt = collections.Counter(larger)

    ans = 0
    for j in range(n):
        smaller = a[j] + j
        larger_cnt[j - a[j]] -= 1
        if smaller in larger_cnt.keys():
            if larger_cnt[smaller] != 0:
                ans += larger_cnt[smaller]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 44204
#include <bits/stdc++.h>
using namespace std;
using int64 = int64_t;
#define int int64

vector<int> d[101010];

signed main() {
  int n,m; cin>>n>>m;
  vector<int> p(m),y(m);
  for(int i=0;i<m;++i){
    cin>>p[i]>>y[i];
    d[p[i]].push_back(y[i]);    
  }
  for(int i=0;i<101010;++i){
    sort(d[i].begin(), d[i].end());
  }
  for(int i=0;i<m;++i){
    printf("%06ld%06ld\n", p[i], lower_bound(d[p[i]].begin(), d[p[i]].end(), y[i]) - d[p[i]].begin() + 1);
  }
  return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    vector<ll> pa, pb;
    pa.push_back(0);
    pb.push_back(0);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (ll i = 0; i < m; i++) {
        cin >> b[i];
    }
    for (ll i = 0; i < n; i++) {
        pa.push_back(pa[i] + a[i]);
    }
    for (ll i = 0; i < m; i++) {
        pb.push_back(pb[i] + b[i]);
    }

    ll ans = 0;
    ll j = m;
    for (ll i = 0; i <= n; i++) {
        if (pa[i] > k) {
            break;
        }
        while (pa[i] + pb[j] > k) {
            j--;
        }
        ans = max(ans, i + j);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11108
#include <stdio.h>
#include <math.h>


typedef struct kohho{
  double x;
  double y;
}kohho; 

int cohho(kohho, kohho, int);


main()
{

  kohho p1,p2;
  int n;

  p1.x = 0.0;
  p1.y = 0.0;
  p2.x = 100.0;
  p2.y = 0.0;

  scanf("%d",&n); 

 printf("%f %f\n",p1.x,p1.y);

 cohho(p1,p2,n);

  printf("%f %f\n",p2.x,p2.y);


  return 0;

}

 
int cohho(kohho p1, kohho p2, int n)
{

  kohho s,t,u;

  if(n == 0){
  return 0;
  }

  s.x = (p2.x - p1.x)/3.0 + p1.x;
  s.y = (p2.y - p1.y)/3.0 + p1.y;
  t.x = 2.0*(p2.x - p1.x)/3.0 + p1.x;
  t.y = 2.0*(p2.y - p1.y)/3.0 + p1.y;
  u.x = (1.0/2.0)*(t.x - s.x)-(sqrt(3.0)/2.0)*(t.y - s.y) + s.x;
  u.y = (sqrt(3.0)/2.0)*(t.x - s.x)+(1.0/2.0)*(t.y - s.y) + s.y;
  
  cohho(p1,s,n-1);
  printf("%f %f\n",s.x,s.y);
  cohho(s,u,n-1);
  printf("%f %f\n",u.x,u.y);
  cohho(u,t,n-1);
  printf("%f %f\n",t.x,t.y);
  cohho(t,p2,n-1);
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(5e2 + 5);

int h, w;
int a[MAX_N][MAX_N];

vector<tuple<int, int, int, int>> ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &h, &w);

  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j <= w; ++j) {
      scanf("%d", &(a[i][j]));
    }
  }

  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j < w; ++j) {
      if (a[i][j] % 2 == 1) {
        a[i][j] -= 1;
        a[i][j + 1] += 1;
        ans.push_back(make_tuple(i, j, i, j + 1));
      }
    }
  }

  for (int i = 1; i < h; ++i) {
    if (a[i][w] % 2 == 1) {
      a[i][w] -= 1;
      a[i + 1][w] += 1;
      ans.push_back(make_tuple(i, w, i + 1, w));
    }
  }

  printf("%d\n", ans.size());

  for (auto &e: ans) {
    printf("%d %d %d %d\n", get<0>(e), get<1>(e), get<2>(e), get<3>(e));
  }

  return 0;
}


Measured memory_bytes: 5232
#include <stdio.h>

int main(void){
  int s, h, m, ss;

  scanf("%d", &s);
  h = s / 3600;
  m = (s % 3600) / 60;
  ss = (s % 3600) % 60;

  printf("%d:%d:%d\n", h, m, ss);
}



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

int main() {
    int n;
    int v[100];
    int w[100];
    int W;

    cin>>n>>W;
    for (int i = 0; i < n; ++i) {
        cin>>v[i]>>w[i];
    }
    // i個選んだ時のWを超えない価値の最大値
    int dp[101][10001];
    for (int i = 0; i <= W; ++i) {
        dp[0][i] = 0;
    }

    for (int i = 0; i<n; ++i) {
        for (int k = 0; k <=W; ++k) {
            if (k >= w[i]) {
                dp[i+1][k] = max(dp[i][k-w[i]] + v[i], dp[i][k]);
            } else {
                dp[i+1][k] = dp[i][k];
            }
        }
    }

    cout<<dp[n][W]<<endl;
}


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

double f[310][310][310];

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

	int n; cin >> n;
	int c1 = 0, c2 = 0, c3 = 0;
	for (int i = 1; i <= n; ++i) {
		int x; cin >> x;
		c1 += (x == 1);
		c2 += (x == 2);
		c3 += (x == 3);
	}
	
	for (int k = 0; k <= n; ++k) {
		for (int j = 0; j <= n; ++j) {
			for (int i = 0; i <= n; ++i) {
				if (!i and !j and !k) {
					continue;
				}
				if (i + j + k > n) {
					continue;
				}
				double wait = (double) n / (i + j + k);
				double pi = (double) i / (i + j + k);
				double pj = (double) j / (i + j + k);
				double pk = (double) k / (i + j + k);
				
				if (i > 0) {
					f[i][j][k] += pi * f[i - 1][j][k];
				}

				if (j > 0) {
					f[i][j][k] += pj * f[i + 1][j - 1][k];
				}
				
				if (k > 0) {
					f[i][j][k] += pk * f[i][j + 1][k - 1];
				}
				f[i][j][k] += wait;
			}
		}
	}
	
	cout << setprecision(10);
	cout << fixed;
	cout << f[c1][c2][c3] << "\n";
	
}


Measured memory_bytes: 225536
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		private const int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start();
			//Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			//int l = int.Parse(Console.ReadLine());
			double l = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			double x = l / 3;
			Console.WriteLine(x * x * x);


			//Console.Out.Flush();
			//System.Diagnostics.Debug.WriteLine(sw.Elapsed);
		}
	}
}

Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello{
    public static void Main(){
        var list = new List<long>();
        var s = Console.ReadLine();
        for(var i = 0;i < s.Length - 2;i++){
            list.Add(long.Parse(s.Substring(i,3)));
        }
        var answers = list.Select(x => Math.Abs(x - 753)).ToList();
        Console.WriteLine(answers.Min());
    }
}


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

int main(int argc, char const *argv[])
{
  while(1)
  {
    int H, W;
    cin >> H >> W;
    if(H == 0 && W == 0) break;

    for(int i = 0; i < H; i++)
    {
      for(int j = 0; j < W; j++)
      {
        cout << (i == 0 || i == H-1 || j == 0 || j == W-1 ? "#" : ".") << flush;
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3092
import java.util.*;
import java.io.*;
import java.math.BigInteger;
 
public class Main {
	public static long mod = 1000000007;
	
	
	public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	int N = s.nextInt();
	int sum = 0;
	for(int i = 1; i < N; i++){
		sum += (N-1)/i;
	}

	System.out.println(sum);
	
	
	
    
  }
}

Measured memory_bytes: 35732
N, *B = map(int, open(0).read().split())

A = []
for _ in range(N):
    for i in reversed(range(len(B))):
        if B[i] == i + 1:
            A.append(B.pop(i))
            break
    else:
        print(-1)
        quit()

print(*reversed(A), sep='\n')


Measured memory_bytes: 3060
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
typedef long long int ll;
using namespace std;
int main(){
    string s; cin >> s;
    int cb = 0;
    ll ans = 0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='B') cb++;
        else ans += cb;
    }
    cout<< ans <<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,p; cin >> n >> p;
  int odd = 0, even = 0;
  rep(i,n){
    int a; cin >> a;
    even += a%2^1;
    odd += a%2;
  }
  ll ans = 1;
  if(even == n){
    if(p == 0) rep(i,n) ans *= 2;
    else ans = 0;
  }else rep(i,n-1) ans *= 2;
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  int a, b, c;
  string s, t;
  cin >> a >> s;
  if(s.size() > a){
    rep(i, a) cout << s.at(i);
    cout << "..."<<endl;
  }else{
    cout << s<<endl;
  }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int x = 0;
  int left = 0;
  int right = 0;
  rep(i,n){
    if(s[i] == '('){
      x++;
    }
    if(s[i] == ')'){
      if(x > 0) x--;
      else{
        left++;
      }
    }
  }
  rep(i,left) cout << '(';
  cout << s;
  rep(i,x) cout << ')';
}

Measured memory_bytes: 256
L1=input().split( )
[xp1,yp1,xp2,yp2]=[int(L1[0]),int(L1[1]),int(L1[2]),int(L1[3])]
direction=[xp2-xp1,yp2-yp1]
norm_direc=[(xp2-xp1)/((xp2-xp1)**2+(yp2-yp1)**2)**(1/2),(yp2-yp1)/((xp2-xp1)**2+(yp2-yp1)**2)**(1/2)]

q=int(input())
L=[]
for i in range(q):
    L2=input().split( )
    L.append([int(L2[0]),int(L2[1])])

Point=[]
for i in range(q):
    Point.append([(L[i][0]-xp1),(L[i][1]-yp1)])

Vec=[]
for i in range(q):
    Vec.append([L[i][0]-xp1,L[i][1]-yp1])
Proj=[]
for i in range(q):
    inter=Vec[i][0]*norm_direc[0]+Vec[i][1]*norm_direc[1]
    Proj.append([norm_direc[0]*inter,norm_direc[1]*inter])

L2=[]

for i in range(q):
    L2.append([xp1+Proj[i][0],yp1+Proj[i][1]])
for i in range(q):
    print(*L2[i])



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

const ll INF = 1e10;
ll N, K;
vector<ll> A;

int main() {
    cin >> N >> K;
    A.resize(N);
    rep(i, N) cin >> A[i];
    rep(i, N) A[i]--;

    vector<ll> s(N + 1);
    s[0] = 0;
    rep(i, N) s[i + 1] = (s[i] + A[i]) % K;

    map<ll, ll> mp;
    queue<ll> q;
    ll ans = 0;
    rep(j, N + 1) {
        ans += mp[s[j]];
        mp[s[j]]++;
        q.push(s[j]);
        while (q.size() >= K) {
            mp[q.front()]--;
            q.pop();
        }
    }
    cout << ans << endl;
}

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

int main() {
	int A, B;
	cin >> A >> B;
	cout << ((A * B & 1) == 1 ? "Yes" : "No");
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

偶数×自然数＝偶数
奇数×奇数＝奇数
よってA×Bの奇偶判定
*/

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
int main()
{
	ll H1,M1,H2,M2,K,ST,DEAD;
	cin>>H1>>M1>>H2>>M2>>K;
	ST=H1*60+M1;
	DEAD=H2*60+M2-K;
	cout<<DEAD-ST<<endl;
}

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

using namespace std;

typedef pair<int, int> interval;

int records[100001];

int main(int argc, char *argv[]) {
	int N, C;
	cin >> N >> C;

	vector<interval> ch[31];
	for (int i = 0; i < N; i++) {
		int si, ti, ci;
		cin >> si >> ti >> ci;
		ch[ci].push_back(interval(si, ti));
	}

	for (int i = 1; i <= C; i++) {
		sort(ch[i].begin(), ch[i].end());
		
		for (int j = ch[i].size() - 1; 1 <= j; j--) {
			if (ch[i][j - 1].second == ch[i][j].first) {
				ch[i][j - 1].second = ch[i][j].second;
				ch[i].erase(ch[i].begin() + j);
			}
		}
	}

	for (int i = 1; i <= C; i++)
		for (int j = 0; j < ch[i].size(); j++)
			for (int k = ch[i][j].first; k <= ch[i][j].second; k++)
				records[k]++;

	int ans = 0;
	for (int i = 1; i <= 100000; i++) {
		ans = max(records[i], ans);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1920
#include<stdio.h>
#define MAX 250

struct node{
  int key;
};

int r;

int Parent(int i){
  if(i == 1) return 0;
  return i / 2;
}
int Left(int i){
  if(r < (2 * i)) return 0;
  else return 2 * i;
}
int Right(int i){
  if(r < (2 * i + 1)) return 0;
  return (2 * i) + 1;
}

int main(){
  int i;
  struct node H[MAX];
  scanf("%d",&r);
  for(i = 1; i <= r; i++){
    scanf("%d", &H[i].key);
  }

  for(i = 1; i <= r; i++){
    printf("node %d: key = %d, ", i, H[i].key);
    if(Parent(i) != 0)
      printf("parent key = %d, ", H[Parent(i)].key);
    if(Left(i) != 0)
      printf("left key = %d, ", H[Left(i)].key);
    if(Right(i) != 0)
      printf("right key = %d, ", H[Right(i)].key);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2104
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    L, R, D = map(int, input().split())

    ans = 0

    for i in range(L, R + 1):
        if i % D == 0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9136