akhauriyash/Code-Regression huggingface dataset:
from functools import reduce
import math
import collections
import itertools
def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    d = collections.defaultdict(int)
    for _ in range(N):
        S = input()
        d[S[0]] += 1
    seq = ('M','A','R','C','H')
    ans = 0
    for i in list(itertools.combinations(seq,3)):
        ans += d[i[0]] * d[i[1]] * d[i[2]]
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n;
	string s;
	cin >> n >> s;
	
	static int cnt[2][200010];
	cnt[0][0] = 0;
	rep1(i,n){
		cnt[0][i] = cnt[0][i-1];
		if(s[i-1] == '#')cnt[0][i] ++;
	}
	cnt[1][n+1] = 0;
	rrep1(i,n){
		cnt[1][i] = cnt[1][i+1];
		if(s[i-1] == '.')cnt[1][i] ++;
	}
	
	/*rep1(i,n){
		cout << cnt[0][i] << " " << cnt[1][i] << endl;
	}*/
	
	int ret = n;
	rep(i,n+1){
		ret = min ( ret , cnt[0][i]+cnt[1][i+1] );
	}
	cout << ret << endl;
}



Measured memory_bytes: 2180
"""
 SpeedForces
 Ah shit here we go again

"""

from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def solve():
    n,k,q = vv()
    lazy = [0]*(n+1)
    for i in range(q):
        a = int(input())
        lazy[a]+=1
    for i in range(1,n+1):
        if(k+lazy[i]-q > 0):
            pr("Yes")
        else:
            pr("No")




    return
















def main():
    # for _ in range(int(input())):
        solve()

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
pr = print
if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")
ll = lambda : list(map(int,input().split()))
vv = lambda :map(int,input().split())
# endregion

if __name__ == "__main__":
    main()

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

int main()
{
    double a,b,h,m,d,dsq;
    double t;
    cin>>a>>b>>h>>m;
    t=30*h-5.5*m;
    if(t>180)
        t=360-t;
    t=(t*M_PI)/180;
    dsq=a*a+b*b-2*a*b*cos(t);
    d=sqrt(dsq);
    cout<<fixed<<setprecision(20)<<d<<"\n";
    return 0;
}


Measured memory_bytes: 4224
#include <stdio.h>

typedef struct{
	int to;
	int from;
	int cost;
} edge;

const int INF = 10000000000;

int main(void)
{
	edge edges[10005];
	int ch[105];
	int n, m, ind;
	int i, j, a, b, v;
	int min, sum_cost;
	
	while (1){
		scanf("%d %d", &n, &m);
		
		if (n == 0 && m == 0) break;
		
		for (i = 0; i < n; i++) ch[i] = 0;
		
		for (i = 0; i < m; i++){
			scanf("%d %d %d", &a, &b, &v);
			edges[i].from = a;
			edges[i].to = b;
			edges[i].cost = v;
		}
		
		sum_cost = 0;
		ch[0] = 1;
		
		for (i = 0; i < n; i++){
			min = INF;
			
			for (j = 0; j < m; j++){
				if ( (ch[edges[j].from] == 1 && ch[edges[j].to] == 0) || (ch[edges[j].from] == 0 && ch[edges[j].to] == 1)){
					if (edges[j].cost < min){
						min = edges[j].cost;
						ind = j;
					}
				}
			}
			
			if (min == INF) break;
			
			if (ch[edges[ind].from] == 1 && ch[edges[ind].to] == 0){
				ch[edges[ind].to] = 1;
			}
			else{
				ch[edges[ind].from] = 1;
			}
			sum_cost += edges[ind].cost;
		}
		
		
		printf("%d\n", sum_cost);
	}
	
	return (0);
}

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



void solve(long long A, long double B){
    long long b = B*100 + 0.5;
    long long ans = A*b;
    ans /= 100;
    cout << ans << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long double B;
    scanf("%Lf",&B);
    solve(A, B);
    return 0;
}


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

using namespace std;
//const int OO = 0x3f3f3f3f;
const long long OO = (long long) 1e18+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(long long i = a ; i < n ; ++i)
#define lpr(i,a,n) for(long long i = a ; i >= n ; --i)
#define rep(i,vec) for(ll i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(ll i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef   long long ll;
typedef   unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

using namespace std;
ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);


int N,w;

ll mem[100005];




int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
//#ifndef ONLINE_JUDGE
//   freopen( "output.txt" , "w" , stdout ) ;
//   freopen( "input.txt" , "r" , stdin ) ;
//#endif


    cin >> N >> w;
    /// mem OO
    lp(i,0,100005) mem[i] = OO;
    mem[0] = 0;
    ll ans = 0;
    lp(ilp,0,N){
        ll weight,value;
        cin >> weight >> value;
        lpr(i,100004-value,0){
            mem[i+value] = min(mem[i+value],mem[i]+weight);
            if(mem[i+value]<=w) ans = max(ans,i+value);
        }

    }
    cout << ans;


    return 0;
}


Measured memory_bytes: 4380
fun main(args: Array<String>) {
    val (x,y) = readLine()!!.split(" ").map{it.toLong()}
    println(x * y / gcd(x.toInt(), y.toInt()).toLong())
}
 
fun gcd(a: Int, b: Int) :Int{
    if (b == 0) return Math.abs(a)
    return gcd(b, a % b)
}
 

Measured memory_bytes: 37944
#include <iostream>
#include <cstdio>
#include <cstring>

#define Max 100005

using namespace std;

int n,num1,num2,f[Max];

int main(){
    cin>>n;
    memset(f,0x7f,sizeof f);
    f[0]=0;
    num1=num2=1;
    for(int i=1;i<=7;i++){
        num1*=6;num2*=9;
        for(int j=1;j<=100000;j++){
            f[j]=min(f[j],f[j-1]+1);
            if(j>=num1){
                f[j]=min(f[j],f[j-num1]+1);
            }
            if(j>=num2){
                f[j]=min(f[j],f[j-num2]+1);
            }
        }
    }
    cout<<f[n]<<endl;
    return 0;
}


Measured memory_bytes: 640
<?php
// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d %d %d %d %d %d", $A, $B, $C, $D, $E, $F);

$mmax = -1;
for ($aa = 0; $aa <= $F; $aa += $A * 100) {
    for ($bb = 0; $bb <= ($F - $aa); $bb += $B * 100) {
        if (DEBUG) echo "max:" . ($aa + $bb) * $E / 100 . "\n";
        for ($cc = 0; $cc <= ($aa + $bb) * $E / 100; $cc += $C) {
            for ($dd = 0; $dd <= ($aa + $bb) * $E / 100 - $cc; $dd += $D) {
                if ($aa + $bb == 0) continue;
                if ($aa + $bb + $cc + $dd > $F) continue;
                $noudo = ($cc + $dd) / ($cc + $dd + $aa + $bb);
                if (DEBUG) printf("waterA:%d waterB:%d sugarC:%d sugarD:%d noudo:%.6f\n", $aa, $bb, $cc, $dd, $noudo);
                if ($noudo > $mmax) {
                    $total = $aa + $bb + $cc + $dd;
                    $sugar = $cc + $dd;
                    $answer = "{$total} {$sugar}\n";
                    $mmax = $noudo;
                }
            }
        }
    }
}
echo $answer;


Measured memory_bytes: 4728
#!/usr/bin/env python3

f_in = []
while True:
  n,x = map(int,input().split())
  if n == 0 and x == 0:
    break
  else:
    f_in.append([n,x])

for step in range(len(f_in)):
  counter = 0
  for i in range(1,f_in[step][0]):
    for j in range(i+1,f_in[step][0]):
      check = f_in[step][1] - (i+j)
      if j < check and check <= f_in[step][0]:
        counter += 1
  print(counter)


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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> x(n);
    int pre = -INF;
    int z = n;
    rep(i,n){
        cin>>x[i];
        if(pre < 0 && x[i] >= 0) z = i;
        pre = x[i];
    }
    int res = INF;
    rep(i,k+1){
        int l = z+i-k, r = z+i-1;
        if(l<0 || n<=r) continue;
        int lv = max(-x[l],0), rv = max(x[r],0);
        res = min({res, lv*2+rv, lv+rv*2});
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }

const int maxn = 2e5 + 5;
ll dp[maxn][3];
ll sum[maxn];
ll a[maxn];
int n;

ll f(int i, int skip){
  if(i >= n) return 0;
  if(skip == (2 - (n % 2 == 0))) return sum[i];
  if(dp[i][skip] != -1) return dp[i][skip];
  ll ret = a[i] + f(i + 2, skip);
  ret = max(ret, f(i + 1, skip + 1));
  return dp[i][skip] = ret;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sum[n - 1] = a[n - 1];
  sum[n - 2] = a[n - 2];
  for(int i = n - 3; i >= 1; i -= 2){
    sum[i] += sum[i + 2] + a[i];
    sum[i - 1] += sum[i + 1] + a[i - 1];
  }
  if(n % 2 == 1) sum[0] += sum[2] + a[0];
  memset(dp, -1, sizeof dp);
  cout << f(0, 0);
}

Measured memory_bytes: 16140
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
const ll INF_ll=4611686018427387903;
const int N=2e5+10;
int n,a[N];ll dp[N][5],ans;
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(register int i=1;i<=n;i++){
		dp[i][0]=dp[i-1][0]+a[i];
		dp[i][1]=min(dp[i-1][1],dp[i-1][0])+(a[i]? (a[i]&1):2);
		dp[i][2]=min(dp[i-1][2],min(dp[i-1][1],dp[i-1][0]))+((a[i]&1)^1);
		dp[i][3]=min(dp[i-1][3],min(dp[i-1][2],min(dp[i-1][1],dp[i-1][0])))+(a[i]? (a[i]&1):2);
		dp[i][4]=min(dp[i-1][4],min(dp[i-1][3],min(dp[i-1][2],min(dp[i-1][1],dp[i-1][0]))))+a[i];
	}
	ans=dp[n][0];
	for(register int i=1;i<5;i++)ans=min(ans,dp[n][i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8832
#!/usr/bin/env python3
MOD = 998244353

class Factorial:
    def __init__(self, n, mod):
        self.f = f =[0] * (n + 1)
        f[0] = b = 1
        for i in range(1, n + 1):
            f[i] = b = b * i % mod
        self.inv = inv = [0] * (n + 1)
        inv[n] = b = pow(self.f[n], -1, mod)
        for i in range(n, 0, -1):
            inv[i - 1] = b = b * i % mod
        self.mod = mod

    def factorial(self, i):
        return self.f[i]

    def ifactorial(self, i):
        return self.inv[i]

    def C(self, n, k):
        if not 0 <= k <= n: return 0
        return self.f[n] * self.inv[n - k] * self.inv[k] % self.mod

    def P(self, n, k):
        if not 0 <= k <= n: return 0
        return self.f[n] * self.inv[n - k] % self.mod

    def H(self, n, k):
        if (n == 0 and k > 0) or k < 0: return 0
        return self.f[n + k - 1] * self.inv[k] % self.mod * self.inv[n - 1] % self.mod


# pA + qB = K
n, a, b, k = map(int, input().split())
F = Factorial(n, MOD)
c = 0
for p in range(k // a + 1):
    q, _ = divmod(k - p*a, b)
    if _:continue
    c = (c + F.C(n, p) * F.C(n, q)) % MOD
print(c)

Measured memory_bytes: 32560
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    int a[103];
    Scd(N);
    Rep(i,N){
        Scd(a[i]);
    }

    sort( a,a+N );
    reverse( a,a+N );

    int cnt = 0;
    int ai = 0;
    int pre = a[ai];
    int maxser = 0;
    bool imp = false;
    for(int i = N; i > 0; i-- ){
        cnt = 0;
        while( ai < N && a[ai] == i ){
            maxser = max( a[ai] , maxser );
            cnt++;
            ai++;
        }
        if( maxser ){
            if( i == (maxser+1)/2 ){
                if( cnt != (1 + maxser%2)  ) imp = true;
                break;
            }
            if( cnt < 2  ) imp = true;
        }
        if( imp ) break;
    }
    printf ( imp ? "Impossible\n" : "Possible\n");

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

ll Pow(ll a, ll b){
	ll res = 1;
	while(b){
		if(b & 1){
			res = (res * a) % mod;
		}
		a = (a * a) % mod;
		b >>= 1;
	}
	return res;
}

int main()
{
	int n;
	cin >> n;
	vector<int> a(n + 1);
	vector<int> used(n, -1);
	int f, b;
	for(int i = 0;i < n + 1;i++){
		cin >> a[i]; a[i]--;
		if(used[a[i]] != -1){
			f = used[a[i]];
			b = i;
		}
		used[a[i]] = i;
	}
	vector<ll> fac(n + 2), rfac(n + 2);
	fac[0] = rfac[0] = 1;
	for(int i = 1;i <= n + 1;i++){
		fac[i] = (fac[i - 1] * i) % mod;
		rfac[i] = Pow(fac[i], mod - 2);
	}
	for(int i = 1;i <= n + 1;i++){
		ll res = (fac[n + 1] * rfac[i] % mod * rfac[n + 1 - i] % mod);
		res = (res - (n - b + f < i - 1 ? 0 : fac[n - b + f] * rfac[i - 1] % mod * rfac[n - b + f - i + 1] % mod) + mod) % mod;
		cout << res << endl;
	}
	return 0;
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

void solve(){
	ll a, b;
	double c;
	cin >> a >> c;
	
	b = (c*100 + .5);
	
	ll res = (a * b);
	res /= 100;
	cout << res;
}

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

	solve();
    
    return 0;
}


Measured memory_bytes: 3728
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  LL N, Z, W; cin >> N >> Z >> W;
  vector<LL> a(N); cin >> a;
  if (N == 1) cout << abs(a[N-1] - W) << endl;
  else cout << max(abs(a[N-1] - W), abs(a[N-1]-a[N-2])) << endl;
}


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

int main() {
	long long ans=0,k;
	vector<int> a,b;
	long long n;
	cin >> n;
	for(auto i=1;i<=n+1;i++) {
		cin >> k;
		a.push_back(k);
	}
	for(auto i=1;i<=n;i++) {
		cin >> k;
		b.push_back(k);
	}
	for(auto i=0;i<n;i++) {
		int x =min(a[i],b[i]);
		a[i] -= x, b[i]-=x;
		ans+= x;
		x = min(a[i+1],b[i]);
		a[i+1] -= x, b[i] -= x;
		ans+=x;
	}
	cout << ans << endl;
	return 0;
}

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

bool PrimeCheck(int n){
    if(n==1) return false;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0) return false;
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    int ans = 0;
    rep(i,n){
        int a;
        cin >> a;
        if(PrimeCheck(a)) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3068
import java.util.Scanner

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val m = scn.nextInt()
	var ans = 0
	if (n>1) ans += n*(n-1)/2
	if (m>1) ans += m*(m-1)/2
	print(ans)
}

Measured memory_bytes: 29356
class SegTreeIndex(object):
    # 区間の最小 or 最大値とその index を取得
    # 検証: https://yukicoder.me/submissions/376308
    __slots__ = ["elem_size", "tree", "default", "op", "index", "op2"]
    def __init__(self, a: list, default=float("inf"), op=lambda a,b: b if a>b else a, op2=lambda a,b:a>b):
        # 同じ場合最左のインデックスを返す
        # 最小値・最左: default=float("inf"), op=lambda a,b: b if a>b else a, op2=lambda a,b:a>b
        # 最大値・最左: -float("inf"), max, lambda a,b:a<=b
        from math import ceil, log
        real_size = len(a)
        self.elem_size = elem_size = 1 << ceil(log(real_size, 2))
        self.tree = tree = [default] * (elem_size * 2)
        self.index = index = [0] * (elem_size * 2)
        tree[elem_size:elem_size + real_size] = a
        index[elem_size:elem_size + real_size] = list(range(real_size))
        self.default = default
        self.op = op
        self.op2 = op2
        for i in range(elem_size-1, 0, -1):
            v1, v2 = tree[i<<1], tree[(i<<1)+1]
            tree[i] = op(v1, v2)
            index[i] = index[(i<<1) + op2(v1, v2)]

    def get_value(self, x: int, y: int) -> tuple:  # 半開区間
        l, r = x + self.elem_size, y + self.elem_size
        tree, op, op2, index = self.tree, self.op, self.op2, self.index
        result_l = result_r = self.default
        idx_l = idx_r = -1
        while l < r:
            if l & 1:
                v1, v2 = result_l, tree[l]
                result_l = op(v1, v2)
                if op2(v1, v2)==1:
                    idx_l = index[l]
                l += 1
            if r & 1:
                r -= 1
                v1, v2 = tree[r], result_r
                result_r = op(v1, v2)
                if op2(v1, v2)==0:
                    idx_r = index[r]
            l, r = l >> 1, r >> 1
        result = op(result_l, result_r)
        idx = idx_r if op2(result_l, result_r) else idx_l
        return result, idx

    def set_value(self, i: int, value: int) -> None:
        k = self.elem_size + i
        self.tree[k] = value
        self.update(k)

    def update(self, i: int) -> None:
        op, tree, index, op2 = self.op, self.tree, self.index, self.op2
        while i > 1:
            i >>= 1
            v1, v2 = tree[i<<1], tree[(i<<1)+1]
            tree[i] = op(v1, v2)
            index[i] = index[(i<<1) + op2(v1, v2)]

def main():
    N, M = map(int, input().split())
    S = list(map(int, input()))
    dp = [10 ** 9] * (N + 1)
    seg = SegTreeIndex(dp)
    from_ = [-10000000] * (N + 1)
    seg.set_value(0, 0)
    for i, c in enumerate(S[1:], 1):
        if c == 1:
            continue
        v, idx = seg.get_value(max(i - M, 0), i)
        if v == 1000000000:
            print(-1)
            exit()
        from_[i] = idx
        seg.set_value(i, v + 1)
    n = seg.tree[N + seg.elem_size]
    # print(seg.tree[seg.elem_size:seg.elem_size+N+1])
    # print(from_)

    Ans = []
    v = N
    while v != 0:
        v_ = from_[v]
        Ans.append(v - v_)
        v = v_
    Ans.reverse()
    print(" ".join(map(str, Ans)))


main()


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

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){return a/GCD(a,b)*b;}

const int INF=1e9;
const double eps=0.0000000001;

int main(){
  ll n;
  bool c=0;
  cin >> n;
  ll a[1000000],b[1000000]={0};
  FOR(i,n){
    cin >> a[i];
    b[a[i]]++;
  }
  if(n%2==1){
    FOR(i,(n-1)/2+1){
      if(i!=(n-1)/2){
        if(b[n-1-i*2]!=2)c=1;
      }else{
        if(b[0]!=1)c=1;
      }
    }
  }else{
    FOR(i,n/2){
      if(b[n-1-i*2]!=2)c=1;
    }
  }
  ll ans=1;
  if(c){
    cout << 0 << endl;
  }else{
    FOR(i,n/2){
    ans=ans*2%MOD;
    }
    cout << ans << endl;
  }
  
}


Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb2l(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

bool isp(string &s,ll i,ll j){
    ll f=1;
    while(i<=j && f){
        if(s[i]!=s[j])
        f=0;
        i++,j--;
    }
    return f;
}
void solve(){
    long double n;
    cin>>n;
    long double k=3.0*3.0*3.0;
    n=n*n*n;
    cout<<fixed;
    cout<<setprecision(12)<<n/k;

  
  }
int main(){
    ll t=1;
   // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import collections

N=int(input())
S=[]
for i in range(N):
    S.append(str(input()))

c = collections.Counter(S)

ans = c.most_common()[0][1]

a=sorted([i[0] for i in c.items() if i[1] == ans])
            
for i in a:
    print(i)
    





Measured memory_bytes: 45040
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int N; cin>>N;
	vector<ll> a(N), b(N);
	ll sum_a = 0, sum_b = 0;
	rep(i,N){
		cin>>a[i];
		sum_a += a[i];
	}
	rep(i,N){
		cin>>b[i];
		sum_b += b[i];
	}
	ll disp = sum_b - sum_a;
	ll conf_a = 0;
	ll conf_b = 0;
	ll discount = 0;
	rep(i,N){
		if(a[i] == b[i])continue;
		if(a[i]>b[i]){
			ll rent = min(conf_b, a[i]-b[i]);
			conf_b -= rent;
			b[i] += rent;
			ll ope = a[i]-b[i];
			discount += ope;
			conf_a += ope*2;
		}else if(a[i]%2 == b[i]%2){
			ll rent = min(conf_a, b[i]-a[i]);
			conf_a -= rent;
			a[i] += rent;
			ll ope = (b[i]-a[i])/2;
			discount += ope;
			conf_b += ope;
		}else{
			if(conf_b == 0){
				conf_a += 2;
				discount ++;
				b[i]++;
			}else{
				conf_b--;
				b[i]++;
			}
			ll rent = min(conf_a, b[i]-a[i]);

			conf_a -= rent;
			a[i] += rent;
			ll ope = (b[i]-a[i])/2;
			discount += ope;
			conf_b += ope;
		}
		// printf("[%d]:<conf_a, conf_b> = [%lld, %lld]\n",i,conf_a, conf_b);
	}
	bool ans = true;
	conf_a += 2*max(0LL,disp-discount);
	conf_b += max(0LL, disp-discount);
	// cout<<conf_a<<' '<<conf_b<<endl;
	if(discount>disp)ans = false;
	if(conf_a != conf_b)ans = false;
	cout<<((ans)?"Yes":"No")<<endl;
	return 0;
}

// int main(){
// 	ll N; cin>>N;
// 	vector<ll> a(N);
// 	vector<ll> b(N);
// 	ll sa = 0, sb = 0; 
// 	rep(i,N){cin>>a[i]; sa += a[i];}
// 	rep(i,N){cin>>b[i]; sb += b[i];}
// 	ll dif = 0;
// 	rep(i,N)if(a[i]%2 != b[i]%2) ++ dif;
// 	bool ans;
// 	ll dis = 0;
// 	rep(i,N)if(a[i]>b[i])dis += a[i]-b[i];
// 	ll dis2 = 0;
// 	rep(i,N)if(a[i]<b[i])dis2 += b[i]-a[i];
// 	if(sb-sa < 0 || abs(sb-sa)%2 != dif%2 || dis > abs(sb-sa) || dis2 > abs(sb-sa)*2)ans = false;
// 	else ans = true;
	
// 	cout<<((ans)?"Yes":"No")<<endl;
// 	return 0;
// }

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int *H = new int[N];
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  int cnt = 1;
  for (int i = 1; i < N; i++) {
    bool flag = true;
    for (int j = 0; j <= i - 1; j++) {
      if (H[j] > H[i]) {
        flag = false;
        break;
      }
    }
    if (flag) cnt++;
  }
  cout << cnt << "\n";
  return 0;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static readonly string NA = "NA";

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();

                string head = s.Substring(0, 2);

                switch (head)
                {
                    case ">'":
                        sb.AppendLine(CheckA(s));
                        break;
                    case ">^":
                        sb.AppendLine(CheckB(s));
                        break;
                    default:
                        sb.AppendLine(NA);
                        break;
                }
            }
            Console.Write(sb);
        }

        static string CheckA(string s)
        {
            if (s[s.Length - 1] != '~') return NA;

            string temp = s.Substring(2, s.Length - 3);

            string[] t = temp.Split('#');

            if (t.Length != 2) return NA;

            if (t[0].Length == 0) return NA;
            if (t[1].Length == 0) return NA;

            if (t[0].Length != t[1].Length) return NA;

            if (!t[0].All(n => n == '=')) return NA;
            if (!t[1].All(n => n == '=')) return NA;

            return "A";
        }

        static string CheckB(string s)
        {
            string tale = s.Substring(s.Length - 2, 2);

            if (tale != "~~") return NA;

            string temp = s.Substring(2, s.Length - 4);

            if (!temp.Contains("Q=")) return NA;

            temp = temp.Replace("Q=", "");

            if (temp.Length != 0) return NA;

            return "B";
        }
    }
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

int main(){
  string s;
  cin >> s;
  if(s.size() == 2) cout << s << endl;
  else cout << s[2] << s[1] << s[0] << endl;

}


Measured memory_bytes: 764
//#include<cstdio>
//#include<cassert>
//#include<iostream>
//#include<cstring>
//#include<algorithm>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((int)1e6 + 5)
#define MAXL ((ll)1e18 + 5)
#define MAX_X ((ll)1e5 + 2)
#define pi (2.0*acos(0))
#define M ((int)1e6 + 7)
#define MOD ((int)1e9 + 7)
#define NN ((int)1e6 + 7)
#define N ((int)2e5 + 7)
#define eps (0)
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define logn 29
#define endl "\n"
#define mp make_pair
#define BUCK 105
#define LEF (idx<<1)
#define RIG ((idx<<1)|1)
//#define int ll


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;

/*fast io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/




typedef tree < pair < ll, pair < ll, ll > >,  null_type,  less < pair < ll, pair < ll, ll > > >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;
/// o_set s;
/// s.order_of_key(k) : Number of items strictly smaller than k .
/// *(s.find_by_order(k)) : K-th element in a set (counting from zero).



int main()
{
    fastio;
    ll a , v , b , w ,t;
    cin>>a>>v>>b>>w>>t;
    a = abs(a-b);
    if(v<=w) cout<<"NO\n";
    else{
        if(t*(v-w)>=a) cout<<"YES\n";
        else cout<<"NO\n";
    }
    return 0;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define N 300005
using namespace std;
int i,j,k,l,s,n,m,A,B,ans;
struct node {
	int x,y;
}Ans[N];
int main() {
	scanf("%d%d%d",&n,&A,&B);
	if (1ll*A*B<n) return puts("-1"),0;	
	if (A+B-1>n) return puts("-1"),0;
	if (B==1&&A==n) {
		for (i=1;i<=n;i++) printf("%d ",i); return 0;
	}
	if (B==1) return puts("-1"),0;
	Ans[ans=1].x=n-A+1,Ans[1].y=n;
	n-=A; B--;
	while (n%B) Ans[++ans].x=n-(n/B),Ans[ans].y=n,n-=(n/B)+1,B--;
	int gt=n/B;
	for (i=1;i<=B;i++) Ans[++ans].x=n-(gt)+1,Ans[ans].y=n,n-=(gt);
	for (i=1;i<=ans;i++) for (j=Ans[i].x;j<=Ans[i].y;j++) printf("%d ",j);
}

Measured memory_bytes: 3456
#include <cstdio>

int main(){
	int caseNum = 1;
	while(true){
		int n;
		scanf("%d", &n);
		if(n == 0){ break; }
		int table[10][10];
		for(int i = 0, x = 0, y = 0, v = 0; i < n * n; i++){
			table[x][y] = i + 1;
			if(v == 0){
				x++; y--;
				if(y < 0 && x >= n){
					y = 1;
					x = n - 1;
					v = 1;
				}else if(y < 0){
					y = 0;
					v = 1;
				}else if(x >= n){
					y += 2;
					x = n - 1;
					v = 1;
				}
			}else{
				x--; y++;
				if(x < 0 && y >= n){
					x = 1;
					y = n - 1;
					v = 0;
				}else if(x < 0){
					x = 0;
					v = 0;
				}else if(y >= n){
					x += 2;
					y = n - 1;
					v = 0;
				}
			}
		}
		printf("Case %d:\n", caseNum);
		for(int y = 0; y < n; y++){
			for(int x = 0; x < n; x++){
				printf("%3d", table[x][y]);
			}
			puts("");
		}
		caseNum++;
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void){
    int a,b,an;
    char op;
    for(;;){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?') break;
        switch(op){
            case '+':
                an=a+b;
                break;
            case '-':
                an=a-b;
                break;
            case '*':
                an=a*b;
                break;
            case '/':
                an=a/b;
                break;
        }
        printf("%d\n",an);
    }
    return 0;
}

Measured memory_bytes: 600
#include <iostream>

int gcd(int a, int b)
{
    if (a < b)
    {
        return gcd(b, a);
    }

    if (b == 0)
    {
        return a;
    }

    return gcd(b, a % b);
}

int main()
{
    int k = 0;
    std::cin >> k;

    long long sum = 0;
    for (auto a = 1; a <= k; ++a)
    {
        for (auto b = 1; b <= k; ++b)
        {
            for (auto c = 1; c <= k; ++c)
            {
                sum += gcd(gcd(a, b), c);
            }
        }
    }

    std::cout << sum;
    return 0;
}

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


/*define*/
int year;
string X;
double X_l, yen;

int main(){
/*inputs*/
    std::cin >> X;
    year = 0;
    yen = 100;
    X_l = std::stod(X);
/*syori*/
    while(yen < X_l){
        year++;
        yen = floor(yen*1.01);
    }
    
    std::cout << year;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef pair<int,int> pii;
typedef long long int ll; 
typedef tree<pii,null_type,less<pii>,rb_tree_tag, \
tree_order_statistics_node_update> ordered_set;

#define int ll   
#define long int
#define pb push_back
#define all int i=0; i<n; i++
#define INF 10000000000000000

#define Nirvana ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define mod 1000000007
#define pii pair<int, int> 
long expo(long base, long exp, int m) 
{ 
    long t = 1L; 
    while (exp > 0)  
    { 
        if (exp % 2 != 0)  t = (t * base)%m ; 
        base = (base * base)%m ; 
        exp /= 2; 
    } 
    return t%m; 
} 
#define pow expo
#define pi acos(-1.00)

int dp[20001];
int h,n;
int a[20001];
int b[20001];

int32_t main(){
	cin>>h>>n;
	for(all){
		cin>>a[i]>>b[i];
	}
	fill(dp, dp+20001, INF);
	dp[0] = 0;

	for(int i=1; i<=20000; i++){
		for(int j=0; j<n; j++){
			if(a[j]>i)continue;
			dp[i] = min(dp[i], dp[i - a[j]] + b[j]);
		}
	}
	int ans = INF;
	
	for(int i=h; i<=20000; i++){
		ans = min(ans, dp[i]);
		//cout<<dp[i]<<endl;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 384
R, C = map(int, raw_input().split())
chart = [map(int, raw_input().split()) for r in range(R)]
col = [0] * C
for r in range(R):
    row = chart[r]
    row.append(sum(row))
    print ' '.join(map(str, row))
    for c in range(C):
        col[c] += row[c]
for c in range(C):
    print col[c],
print sum(col)

Measured memory_bytes: 6408
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    string s;
    cin>>s;
    int b=0,e=s.length()-1;
    while(b<e){
        if(s[b]!='A')   b++;
        else if(s[e]!='Z')   e--;
        else break;
    }
    cout<<e-b+1<<endl;
    return 0;
}



Measured memory_bytes: 720
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] A = new int[3][3];
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		int N = sc.nextInt();
		int[] B = new int[N];
		for(int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				for(int k = 0; k < N; k++) {
					if(A[i][j] == B[k]) {
						A[i][j] = 0;
						break;
					}
				}
			}
		}
		if((A[0][0] == 0 && A[0][1] ==0 && A[0][2] == 0)
				|| (A[1][0] == 0 && A[1][1] ==0 && A[1][2] == 0)
				|| (A[2][0] == 0 && A[2][1] ==0 && A[2][2] == 0)
				|| (A[0][0] == 0 && A[1][0] ==0 && A[2][0] == 0)
				|| (A[0][1] == 0 && A[1][1] ==0 && A[2][1] == 0)
				|| (A[0][2] == 0 && A[1][2] ==0 && A[2][2] == 0)
				|| (A[0][0] == 0 && A[1][1] ==0 && A[2][2] == 0)
				|| (A[0][2] == 0 && A[1][1] ==0 && A[2][0] == 0)
				) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>

using namespace std;

int n, cnt;
struct st
{
    int x, y;
    int clr;
} a[205];

set<int>se;

bool cmp(st p, st q)
{
    if(p.x < q.x) return true;
    return false;
}

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < 2 * n; i++)
    {
        scanf("%d%d", &a[i].x, &a[i].y);
        if(i >= n) a[i].clr = 1;
    }
    sort(a, a + 2 * n, cmp);
    for(int i = 0; i < 2 * n; i++)
    {
        if(a[i].clr == 0) se.insert(a[i].y);
        else
        {
            set<int>::iterator it;
            it = se.lower_bound(a[i].y);
            if(se.begin() != it)
            {
                it--;
                se.erase(it);
                cnt++;
            }
        }
    }
    printf("%d", cnt);
    return 0;
}


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

int main(){
    int hour, minute, second, input;
    cin >> input;

    hour = input / 3600;
    minute = (input - hour * 3600) / 60;
    second = input % 60;

    cout<< hour << ":" << minute << ":" << second << endl;

    return 0;
}

Measured memory_bytes: 1168
if __name__ == "__main__":
    n, w = map(int, input().split())
    v = []
    ws = []
    for _ in range(n):
        vi, wi = map(int, input().split())
        v.append(vi)
        ws.append(wi)
    
    dp = []
    for _ in range(n + 1):
        dp.append([0] * (w + 1))
    # dp[1][w[0]] = v[0]
    
    for i in range(1, n + 1):
        for j in range(1, w + 1):
            dp[i][j] = dp[i - 1][j]
            if j - ws[i - 1] >= 0:
                dp[i][j] = max(dp[i][j], dp[i - 1][j - ws[i - 1]] + v[i - 1])
    ans = (-1) * float('inf')
    print(max(dp[n]))


Measured memory_bytes: 25500
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

char S[2000];
vi adjList[2000];
int size[2000],need[2000],sum[2000],dd = 0;
int doDFS(int u,int p,int d) {
    int i;
    size[u] = (S[u] == '1'),need[u] = 0,sum[u] = 0;
    if (S[u] == '1') dd += d;
    vpii vv;
    for (i = 0; i < adjList[u].size(); i++) {
        int v = adjList[u][i];
        if (v != p) {
            size[u] += doDFS(v,u,d+1);
            vv.pb(mp(need[v]+size[v],sum[v]+size[v]));
            sum[u] += sum[v]+size[v];
        }
    }
    int sum = 0;
    for (i = 0; i < vv.size(); i++) sum += vv[i].second;
    need[u] = (sum & 1) ? 1:0;
    for (i = 0; i < vv.size(); i++) {
        if (vv[i].first > sum-vv[i].second) need[u] = vv[i].first-(sum-vv[i].second);
    }
    return size[u];
}
int main() {
    int i;
    int N,u,v;
    scanf("%d",&N);
    for (i = 0; i < N; i++) scanf(" %c",&S[i]);
    for (i = 0; i < N-1; i++) {
        scanf("%d %d",&u,&v);
        u--,v--;
        adjList[u].pb(v);
        adjList[v].pb(u);
    }

    int ans = 1e9;
    for (i = 0; i < N; i++) {
        dd = 0,doDFS(i,-1,0);
        if (need[i] == 0) ans = min(ans,dd/2);
    }
    if (ans == 1e9) printf("-1\n");
    else printf("%d\n",ans);

    return 0;
}



Measured memory_bytes: 640
import java.util.*;
		 import java.util.stream.Collectors;
		 import java.util.function.Function;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
				       Scanner sc= new Scanner(System.in);
		        char[] n = sc.nextLine().toCharArray();
		        for(int i=0;i<3;i++){
		            if(n[i]=='7'){
		                System.out.println("Yes");
		                return;
		            }
		            
		        }
		        System.out.println("No");


	}

}


Measured memory_bytes: 35780
#include <cassert>
#include <functional>
#include <vector>

template <typename Monoid> class SegmentTree {
public:
	using value_type = Monoid;
	using reference = value_type &;
	using const_reference = const value_type &;
	using container_type = std::vector<value_type>;
	using size_type = typename container_type::size_type;

private:
	const size_type size_, capacity;
	container_type tree;
	static size_type getsize(const size_type &size) noexcept {
		size_type ret = 1;
		while (ret < size)
			ret <<= 1;
		return ret;
	}
	void recalc(const size_type &index) {
		tree[index] = tree[index << 1] + tree[index << 1 | 1];
	}

public:
	SegmentTree(const size_type &size)
		: size_(size), capacity(getsize(size_)), tree(capacity << 1) {}
	void update(size_type index,
		const std::function<value_type(const_reference)> &f) {
		assert(index < size());
		index += capacity;
		tree[index] = f(tree[index]);
		while (index >>= 1)
			recalc(index);
	}
	void update(const size_type &index, const_reference data) {
		update(index, [&data](const_reference x) { return data; });
	}
	value_type range(size_type begin, size_type end) const {
		assert(begin <= end);
		assert(begin <= size());
		assert(end <= size());
		value_type retL, retR;
		for (begin += capacity, end += capacity; begin < end;
			begin >>= 1, end >>= 1) {
			if (begin & 1)
				retL = retL + tree[begin++];
			if (end & 1)
				retR = tree[end - 1] + retR;
		}
		return retL + retR;
	}
	size_type search(const std::function<bool(const_reference)> &b) const {
		if (b(value_type()))
			return 0;
		if (!b(tree[1]))
			return size() + 1;
		value_type acc;
		size_type i = 1;
		while (i < capacity)
			if (!b(acc + tree[i <<= 1]))
				acc = acc + tree[i++];
		return i - capacity + 1;
	}
	const_reference operator[](const size_type &index) const {
		assert(index < size());
		return tree[index + capacity];
	}
	size_type size() const noexcept { return size_; }
	bool empty() const noexcept { return !size_; }
};

#include<algorithm>
template <typename T> struct Mini {
	using value_type = T;
	T a;
	explicit Mini(const T &x = 2147483647) : a(x) {}
	Mini operator+(const Mini &o) const { return Mini(std::min(a, o.a)); }
};

#include <iostream>
int main(void) {
	using M = Mini<int>;
	int n, q;
	std::cin >> n >> q;
	SegmentTree<M> T(n);
	while (q--) {
		int c, x, y;
		std::cin >> c >> x >> y;
		if (c)
			std::cout << T.range(x, y + 1).a << std::endl;
		else
			T.update(x, M(y));
	}
	return 0;
}


Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
 
#define rep for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

vector<vector<int>> graph(100001,vector<int>());

int main(){
  int n,m;cin >> n >> m;
  priority_queue<int> que;
  rep{
    int ai;cin >> ai;
    que.push(ai);
  }
  for(int i =0;i<m;i++){
    int a = que.top()/2;
    que.pop();
    que.push(a);
  }
  long long ans = 0;
  for(int i = 0;i<n;i++){
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	auto isprime = [&] (int n) {
		if(n == 2) {
			return true;
		}
		for(int i = 2; i * i <= 2 * n; ++i) {
			if(n % i == 0) {
				return false;
			}
		}
		return true;
	};
	while(!isprime(n)) {
		++n;
	}
	cout << n << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include<cstdlib>

using namespace std;

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

	if (b.size() > a)
	{
		for (int i = 0; i < a; i++)
		{
			cout << b.at(i);
		}
		cout << "...";
	}
	else
	{
		cout << b;
	}

	cout << endl;

	system("pause");
}


Measured memory_bytes: 3576
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {
  int X, max = 1, v;
  scanf("%d", &X);
  for (int b = 2; b <= sqrt(X); b++) {
    for (int p = 2; (v = pow(b, p)) <= X; p++) {
      if (v > max) {
        max = v;
      }
    }
  }
  printf("%d\n", max);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) ((int)(v).size())
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1);

template <class T>
inline bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
int main(void) {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h.at(i);
    }
    vector<int> dp(n, 1e9);
    dp.at(0) = 0;
    dp.at(1) = abs(h.at(1) - h.at(0));
    for (int i = 2; i < n; i++) {
        chmin(dp.at(i), dp.at(i - 1) + abs(h.at(i - 1) - h.at(i)));
        chmin(dp.at(i), dp.at(i - 2) + abs(h.at(i - 2) - h.at(i)));
    }
    cout << dp.at(n - 1) << endl;
    return 0;
}

Measured memory_bytes: 3972