akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX;
using namespace std;
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	ll x,ans=0;
	cin>>x;
	ans+=x/11*2;
	x%=11;
	if(x>0){
		ans++;
		x-=6;
	}
	if(x>0){
		ans++;
	}
	cout<<ans<<endl;
	
//////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
const int maxm=1e6+5;
struct Node{
    int a,b;
}e[maxm];
vector<int>g[maxm];
int n,k;
int temp;
int limit;
void dfs(int x,int fa,int dep){
    if(dep>limit)return ;
    temp++;
    for(int v:g[x]){
        if(v==fa)continue;
        dfs(v,x,dep+1);
    }
}
int solve1(int x){
    temp=0;
    dfs(x,x,0);
    return n-temp;
}
int solve2(int p){
    temp=0;
    dfs(e[p].a,e[p].b,0);
    dfs(e[p].b,e[p].a,0);
    return n-temp;
}
signed main(){
    cin>>n>>k;
    for(int i=1;i<n;i++){
        int a,b;cin>>a>>b;
        e[i]={a,b};
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans=1e9;
    limit=k/2;
    if(k%2==0){
        for(int i=1;i<=n;i++){
            int t=solve1(i);
            ans=min(ans,t);
        }
    }else{
        limit=k/2;
        for(int i=1;i<n;i++){
            int t=solve2(i);
            ans=min(ans,t);
        }
    }
    cout<<ans<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 27140
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

A, B, C, K = LI()

ans = 0

if A >= K:
    ans = K
else:
    ans = A
    K -= A

    if B >= K:
        pass
    else:
        K -= B

        ans -= K

print(ans)


Measured memory_bytes: 67468
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  string S;
  cin >> S;
  if (S.substr(0, 4) == "YAKI")
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
while gets
  n, a, b, c, x = $_.split.map(&:to_i)
  break if n == 0
  res = gets.split.map(&:to_i).reduce(0){ |cnt, i|
    if x != i && cnt != -1
      until x == i
        x = (a * x + b) % c
        cnt += 1
        break if cnt > 10000
      end
    end
    x = (a * x + b) % c
    if cnt == -1 then cnt
    elsif cnt <= 10000 then cnt + 1
    else -1
    end
  }
  p res >= 0 ? res - 1 : res
end

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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll power(ll x, ll y, ll p = MOD){  
    ll res = 1LL; 
    x = x % p;
    if (x == 0) return 0;
    while (y > 0){
        if (y & 1LL)  
            res = (res*x) % p;
        y = y>>1LL; 
        x = (x*x) % p;  
    }  
    return res;  
}  

int main(){
	IO
	ll n, W;
	cin >> n >> W;

	ll weight[n], value[n];
	for(int i = 0; i < n; ++i) {
		cin >> weight[i] >> value[i];
	}

	ll mx_value = *max_element(value, value + n);
	mx_value = mx_value*n;

	vll prev(mx_value + 1, INF), curr(mx_value + 1, INF);
	prev[0] = 0;
	prev[value[0]] = weight[0];

	for(int i = 1; i<n; ++i) {
		for(int v = mx_value; v >= 0; --v) {
			if(prev[v] != INF && (v + value[i] <= mx_value)) {
				
				curr[v + value[i]] = min(curr[v + value[i]], prev[v] + weight[i]);
				// cout << prev[v] << " " << weight[i] << " " << curr[v + value[i]] << endl;
			}
			curr[v] = min(curr[v], prev[v]);
		}

		for(int j = 0; j<= mx_value; ++j) {
			// cout << curr[j] << " ";
			prev[j] = curr[j];
			curr[j] = INF;
		}
	}
	
	int mx = 0;
	for(int i = 0; i <= mx_value; ++i) {
		if(prev[i] <= W) {
			mx = max(mx, i);
		}
	}
	cout << mx << endl;
	return 0;
}

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

namespace F
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int K = int.Parse(strs[0]);
            int N = int.Parse(strs[1]);
            line = Console.ReadLine();
            strs = line.Split(' ');
            int[] A = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(strs[i]);
            }
            int max = 0;
            for(int i = 0; i < N - 1; i++)
            {
                if (max < A[i + 1] - A[i]) max = A[i + 1] - A[i];
            }
            if (max < (K - A[N - 1]) + A[0]) max = (K - A[N - 1]) + A[0];


            Console.WriteLine(K - max) ;
        }
    }
}


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

int abs(int a, int b){
    if (a<b){
        return b-a;
    }else{
        return a-b;
    }
}


int main(){
    long long n,k;
    cin >> n >> k;
    set<int> S;
    
    long long f;
    if (k == 1){
        cout << 0 << endl;
        return 0;
    }
        n %= k;
    long long mini = min(n,k-n); 
    cout << mini << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <map>
#include <vector>
#include <algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(itn i=a;i>=b;i--)
using namespace std;
const int Mod=1e9+7;
typedef long long ll;
ll ans,Ans,fib[105]={1,1},x,y;
vector<pair<ll,ll> >p[105];
int main(){
	rep(i,2,90) fib[i]=fib[i-1]+fib[i-2];
	//rep(i,1,100) if(fib[i]>1e18) printf("Here %d\n",i);
	p[1].push_back(make_pair(1,2));
	p[1].push_back(make_pair(1,3));
	p[1].push_back(make_pair(1,4));
	rep(i,1,90){
		for(int j=0;j<p[i].size();j++){
			ll u=p[i][j].second,v=p[i][j].first+u;
			for(;v<=fib[i+3]+fib[i];v+=u){
				p[i+1].push_back(make_pair(u,v));
			}
		}
	}
	int T;
	scanf("%d",&T);
	while(T--){
		scanf("%lld%lld",&x,&y);
		if(x>y) swap(x,y);
		for(ans=1,Ans=0;fib[ans+1]<=x&&fib[ans+2]<=y;ans++); printf("%d ",ans);
		if(ans==1){
			printf("%lld\n",x*y%Mod);
			continue;
		}
		for(int j=0;j<p[ans-1].size();j++){
			ll u=p[ans-1][j].first,v=p[ans-1][j].second;
			if(v<=x) Ans=(Ans+(y-u)/v%Mod)%Mod;
			if(v<=y) Ans=(Ans+(x-u)/v%Mod)%Mod;
		}
		printf("%lld\n",Ans);
	}
	return 0;
}

Measured memory_bytes: 4096
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
		char[] a = sc.next().toCharArray();
		int ans=0;
		for (int i=0;i<3;i++){
			if (a[i]=='1'){
            	ans+=1;
            }
        }
        System.out.print(ans);
    }
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main() {
    string s;
    bool pri = 0;
    cin >> s;
    for (int i = 0; i < s.length(); ++i) {
        if(s[i] == 'A'){
            if(i+1 != s.length() && s[i+1] == 'C'){
                cout << "Yes";
                pri = 1;
                break;
            }
        }
    }
    if(!pri){
        cout <<"No";
    }
    return 0;
}


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

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> l(n);

	for(int i = 0 ; i < n ; i++ ){
		cin >> l[i];
	}
	
	sort(l.begin() , l.end() , greater<int>() );
	
	int ans = 0;
	for(int i = 0 ; i < k ; i++ )
		ans += l[i];
	
	cout << ans << endl;
	
}

Measured memory_bytes: 256
K, A, B = map(int,input().split())
if A + 2 >= B:
    ans = K + 1
elif K <= A:
    ans = K + 1
else:
    # A-1回たたく
    time = K - (A-1)
    ans = A 
    # n回 A枚をBに交換する 2*n回数分の操作
    n = time // 2
    mod = time % 2
    ans += n*(-A + B)
    ans += mod

print(ans)

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

int main(){
	//freopen("readin.txt","r",stdin);
	int n;
	cin >> n;
	vector<int>v;
	for(int i = 0;i < n;i++){
		int a;
		scanf("%d",&a);
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	cout << v.back() - v.front() << endl;
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
L = set()
for i in range(m + 1):
    for j in range(n + 1):
        c = n * i + m * j - i * j * 2
        if c >= 0:
            L.add(c)
if k in L:
    print('Yes')
else:
    print('No')


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

int main() {
	int n,k;
	cin>>n>>k;
	int arr[n+1];
	for(int i=1;i<=n;i++)
	cin>>arr[i];
	int dp[n+1]={0};
	for(int i=2;i<=n;i++)
	{
		dp[i]=INT_MAX;
		for(int j=1;j<=k;j++)
		{
			if(i-j>0)
			dp[i]=min(dp[i],abs(arr[i]-arr[i-j])+dp[i-j]);
			else break;
		}
	}
	cout<<dp[n]<<"\n";
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
    char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
    vector<char*> v({token});
    while(token = strtok(NULL,", ")) v.push_back(token);
    return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
    debug() << " [" << args.back() << ": " << H << "] ";
    args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main(){
    IOS;
    int x;
    cin>>x;
    cout<<1-x;
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  cout << (n == m ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

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

int N;
int A[20], B[20];
int dp[20][1 << 20];

int main(void) {
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }
    REP(i, N) {
        cin >> B[i];
    }

    REP(i, N) REP(j, 1 << N) {
        dp[i][j] = INF;
    }

    REP(i, N) {
        dp[i][1 << i] = i;
    }
    REP(bit, 1 << N) {
        const int bit_cnt = __builtin_popcount(bit);
        REP(j, N) if ((bit & (1 << j)) && dp[j][bit] < INF) {
            const int cur_val = (abs(bit_cnt - j - 1) % 2 == 0 ? A : B)[j];
            REP(k, N) if ((bit & (1 << k)) == 0) {
                const int nxt_val = ((abs(bit_cnt - k) % 2 == 0 ? A : B)[k]);
                if (nxt_val < cur_val) continue;
                const int add = __builtin_popcount((bit ^ 0xffffffff) & ((1 << k) - 1));
                chmin(dp[k][bit | (1 << k)], dp[j][bit] + add);
            }
        }
    }

    // REP(i, N) REP(j, (1 << N)) cout << i << " " << j << " " << dp[i][j] << endl;

    int ans = INF;
    REP(i, N) {
        chmin(ans, dp[i][(1 << N) - 1]);
    }
    if (ans == INF) {
        ans = -1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 36096
#include <iostream>
#include <cstdint>
using namespace std;
uint64_t g(uint64_t n){
    return (n+1)/2 % 2;
}
uint64_t f(uint64_t n){
    if (n % 2) return g(n);
    else return g(n+1) ^ (n+1);
}
int main(){
    uint64_t A, B;
    cin >> A >> B;
    cout << (f(A-1) ^ f(B)) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int ans =0;
    int N = a;
    while (N > 0) {
      ans += N % 10;
      N /= 10;
    }
    if (a % ans == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
 
}
void solve()
{
	int n, m;
	cin >> n >> m;
	vector<pii> p(m);
	int ans = 0;
	rep(i, m) cin >> p[i].F >> p[i].S;
	rep(i, m){
		vector<vector<int> > g(n + 1);
		rep(j, m){
			if(i == j) continue;
			g[p[j].F].pb(p[j].S);
			g[p[j].S].pb(p[j].F);
		}
		queue<int> q;
		int cnt = 0;
		q.push(1);
		vector<int> u(n + 1);
		u[1] = 1;
		while(!q.empty()){
			int x = q.front();
			q.pop();
			++cnt;
			for(int to : g[x]){
				if(!u[to]){
					q.push(to);
					u[to] = 1;
				}
			}
		}
		ans += (cnt != n);
	}
	cout << ans;
}	 

 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

signed main() {
    string S;
    cin >> S;

    int N = S.size();
    vi counts;
    string st = "RL";
    int cur = 0;
    int cnt = 0;
    REP(i, N) {
        if (S[i] == st[cur]) cnt++;
        else {
            counts.pb(cnt);
            cnt = 1;
            cur = 1 - cur;
        }
    }
    counts.pb(cnt);

    int j = 0;
    vi ans(N, 0);
    for (int i = 0; i < counts.size(); i += 2) {
        int R = counts[i], L = counts[i+1];
        int m = min(R, L);
        int d = abs(R - L);

        j += R - 1;
        int aR = m + d / 2;
        int aL = m + d / 2;
        if (d % 2 == 1) {
            if (m % 2 == 0) {
                if (R > L) aR += 1;
                else aL += 1;
            } else {
                if (R > L) aL += 1;
                else aR += 1;
            }
        }

        ans[j] = aR;
        ans[j+1] = aL;
        j += 1 + L;
    }

    REP(i, N) {
        cout << ans[i] << " \n"[i == N-1];
    }

    return 0;
}


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

int main(){

string a;
cin >> a;
  int sum = 0;
  int len = a.size();
  for(int i=0;i<len;i++){
  sum += a[i]-48;
  }
  if(sum % 9 ==0)
     cout << "Yes"; 
  else
     cout << "No";
  return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>    //C++の標準ライブラリのヘッダを全て読み込む

#define _GLIBCXX_DEBUG

int main() {
    using std::cout;
    using std::endl;
    using std::cin;
    using std::string;
    using std::vector;

    int n, m, max;
    cin >> n;
    vector<string> blue (n);
    vector<int> point (n);
    for(int i=0; i < n; i++){
        cin >> blue.at(i);
    }

    cin >> m;
    vector<string> red (m);
    for(int i=0; i < m; i++){
        cin >> red.at(i);
    }

    for(int i=0; i < n; i++){
        for(int j=0; j < n; j++){
            point.at(i) += (blue.at(i) == blue.at(j)) ? 1 : 0;
        }
        for(int j=0; j < m; j++){
            point.at(i) += (blue.at(i) == red.at(j)) ? -1 : 0;
        }
    }

    max = *std::max_element(point.begin(), point.end());
    max = (max < 0) ? 0 : max;

    cout << max << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define rep(i,n) for(int i=0; i <(n); i++)

int compint(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}
int main(){
  char s[3];
  scanf("%s",s);
  int len=strlen(s);
  rep(i,len){
    if(s[i]=='9'){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll dp[105][8005];
int n,k;
ll modpow(ll x,ll n)
{
	ll res=1;
	while(n>0)
	{
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int main(){
	cin>>n>>k;
	dp[n+1][0] = 1;
	for(int i=n+1;i>=2;i--){
		for(int j=0;j<=8000;j++){
			if(dp[i][j] == 0) continue;
			for(int nxt=0;nxt<=k;nxt++){
				int add = (j+nxt)/(i-1);
				if(nxt > i-1){
					dp[i-1][j] = (dp[i-1][j]+dp[i][j])%mod;
				}
				else{
					dp[i-1][j+add] = (dp[i-1][j+add]+dp[i][j])%mod;
				}
			}
		}
	}
	ll ret = 0;
	ret = 1LL*(k+1)*k/2LL*n%mod*modpow(k+1,n-1)%mod;
	for(int i=0;i<=8000;i++){
		ret -= dp[1][i] * 1LL * i%mod;
	}
	ret = (ret%mod+mod)%mod;
	cout<<ret<<endl;
}

Measured memory_bytes: 4608
#include <iostream>
#include <vector>
#include <forward_list>
#include <queue>
#include <cstdio>

using namespace std;

#define _for(j,N) for(int i = (j); i < (N);++i)

vector<bool> pre;

int end_v = 0;
long weight = -1;

struct HeapNode{
    int t;
    long wt;
    HeapNode(int ti,long wti):t(ti),wt(wti){;}
    bool operator<(const HeapNode &rhs)const{
        return wt < rhs.wt;
    }
};
priority_queue<HeapNode> nq;

struct Graph{
    int V;
    vector<forward_list<HeapNode> >adj;
    Graph(int v):V(v){
        adj.resize(V);pre.resize(V);
    }
    void add_edge(int v,int t,long w){adj[v].push_front(HeapNode(t,w));adj[t].push_front(HeapNode(v,w));}
    void bfs(int v);
};

void Graph::bfs(int v){
    weight = 0;
    _for(0,V){pre[i] = false;}
    nq.push(HeapNode(v,0));
    while(!nq.empty()){
        HeapNode x = nq.top();
        nq.pop();
        int t;
        if(pre[(t = x.t)]) continue;
        pre[t] = true;
        long wt1 = x.wt;
        for(auto a = adj[t].begin();a != adj[t].end();++a){
            int w = a->t;
            if(pre[w]) continue;
            long wt2 = a->wt;
            nq.push(HeapNode(w,wt2 + wt1));
            if (wt2+wt1 > weight){
                weight = wt2 + wt1;
                end_v = w;
            }
        }
    }
}

int main()
{
    int V,v,w,wt;
    scanf("%d",&V);
    Graph G(V);
    _for(0,V-1){
        scanf("%d %d %d",&v,&w,&wt);
        G.add_edge(v,w,wt);
    }
    G.bfs(0);
    G.bfs(end_v);

    printf("%ld\n",weight);
    return 0;
}


Measured memory_bytes: 9912
def i():
    return int(input())
def i2():
    return map(int,input().split())
def s():
    return str(input())
def l():
    return list(input())
def intl():
    return list(int(k) for k in input().split())

k=i()
a,b=i2()
for i in range(1000):
	if i*k>=a and i*k<=b:
		print('OK')
		exit()
print('NG')

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

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

int main() {
    int n; cin >> n;
    int a, b; cin >> a >> b;

    string s;

    if ((b - a - 1) % 2)
        s = "Alice";
    else
        s = "Borys";

    cout << s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,n,x,min,dif;
  
  scanf("%d",&n);
  scanf("%d %d",&min ,&i);
  if((dif = i - min) < 0) {
    min = i;
  }
  for(i=2; i<n; i++){
    scanf("%d",&x);
    if(min>x) {
      min=x;
    }
   else if((min<=x) && (x-min > dif)) {
      dif = x - min;
    }
  }
  printf("%d\n",dif);
  return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define INF 1e9;
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> ans(n);
    vector<int> sum1(n+1), sum2(n+1);
    sum1[0] = 0;
    sum2[0] = 0;

    for (int i=1; 2*(i-1)<n; i++) {
        sum1[i] = sum1[i-1] + a[2*(i-1)];
    }
    for (int i=1; 2*i-1<n; i++) {
        sum2[i] = sum2[i-1] + a[2*i-1];
    }

    rep(i, n) {
        if (i % 2 == 0) {
            ans[i] = sum1[(n+1)/2] - sum2[(n+1)/2 - 1] - 2*sum1[i/2] + 2*sum2[i/2];
        } else {
            ans[i] = sum2[(n+1)/2 - 1] - sum1[(n+1)/2] -2*sum2[(i-1)/2] + 2*sum1[(i+1)/2];
        }

    }

    rep(i, n) cout << ans[i] << endl;

}

Measured memory_bytes: 2944
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		int r=cin.nextInt(),c=cin.nextInt();
		List<Integer> rsum=new ArrayList<>();
		for(int i=0;i<c;i++)rsum.add(0);
		
		for(int i=0;i<r;i++) {
			int sum=0;
			for(int j=0;j<c;j++) {
				int x=cin.nextInt();
				System.out.print(x+" ");
				sum+=x;
				rsum.set(j, rsum.get(j)+x);
			}
			System.out.println(sum);
		}
		
		int rcsum=0;
		for(int i=0;i<c;i++) {
			System.out.print(rsum.get(i)+" ");
			rcsum+=rsum.get(i);
		}
		System.out.println(rcsum);
	}
	
}


Measured memory_bytes: 40596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
typedef vector<vector<ll> > matrix;
const int mod = 1e9+7;
ll gcd(ll a,ll b){
	if(b==0)return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){ans = ans*base;ans = ans%mod;}
        base *= base;base%=mod;pow/=2;}return ans;
}
ll inv(ll x){return expo(x,mod-2);}

double pi = 3.141592653589793238462643;
double error = 0.0000001;
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
/* -------Template ends here-------- */

const int M = 100001;

vector<ll> vec;

int main(){
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);



    int n;
    si(n);
    ll el;

    for(int i = 1 ; i <= n ; i++){
        sll(el);
        vec.push_back(el);
    }

    ll ans = 0;

    ll large = 1e16;

    int steps = 0;

    while(1){
        sort(vec.begin() , vec.end());
        ll term = vec[n - 1];
        /*for(int i = 0 ; i < vec.size() ; i++){
            cout<<vec[i]<<"  ";
        }
        cout<<endl<<endl;*/
        if(term < n) break;
        ll lo = 0 , hi = large;
        ll here = 0;

        while(lo <= hi){
            ll mid = (lo + hi)/2;
            ll mak = term - mid*(n);
            if(mak >= n){
                lo = mid + 1;
            }
            else{
                here = mid;
                hi = mid - 1;
            }
        }
       // if(steps > 20) break;
        vec[n - 1] -= (here*n);

        for(int i = 0 ; i < n - 1 ; i++){
            vec[i] += (here);
        }

        ans += here;
    }

    cout<<ans;












}














Measured memory_bytes: 384
import java.io.*;
import java.util.*;

public class Main{
    static public void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        //BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //String[] buf = reader.readLine().split(" ");
        int n = sc.nextInt();
        long Mod = 1000000000+7;
        long[] a = new long[n];
        for(int i=0;i<n;i++) a[i] = sc.nextLong();
        long ans = 0L;
        for(int bit = 0; bit < 60; bit++){
            long mask = 1L << bit;
            long multi = mask%Mod;
            // one records how many numbers so far is '1' on this digit
            long zero = (mask&a[0])>0?0:1, one = (mask&a[0])>0?1:0;
            for(int i=1;i<n;i++){
                if((mask&a[i])>0){
                    // a[i] is 1 on this digit
                    ans += (multi)*zero;
                    one += 1;
                } else{
                    ans += (multi)*one;
                    zero += 1;
                }
                ans %= Mod;
            }
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 98316
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <string.h>

int mp[100000];
int a[100000 + 1];
 


int main() {

	int n, m;
	int l; std::string s;
	int ansa, answ;
	ansa = answ = 0;

	memset(mp, 0, sizeof(mp));

	std::cin >> n >> m;

	for (int i = 0; i < m; ++i) {

		std::cin >> l >> s;
		if (s == "WA" && mp[l] == 0) a[l]++;
		else if (s == "AC" && mp[l] == 0) { ansa++; mp[l] = 1; }

	}
	for (int i = 1; i <= n; i++)	if (mp[i] == 1)answ += a[i];
	
	std::cout << ansa << " " << answ << std::endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void)
{
    int h,w;
    int n;
    cin >> h >> w;
    cin >> n;

    vector<vector<int>> grid(h,vector<int>(w));
    vector<int> a;
    REP(i,n){
        int tmp;
        cin >> tmp;
        REP(j,tmp){
            a.push_back(i + 1);
        }
    }

    int cnt = 0;
    REP(i, h)
    {
        if(i % 2 == 0){
            REP(j,w){
                grid[i][j] = a[cnt];
                cnt++;
            }
        }
        else{
            REPR(j,w-1){
                grid[i][j] = a[cnt];
                cnt++;
            }
        }
    }

    REP(i,h){
        REP(j,w-1){
            cout << grid[i][j] << " ";
        }
        cout << grid[i][w-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
ll A[5000001],bin[5000001];
vector<int>v;
map<int,int>myMap;
set<int>mySet;
vector<pair<long double ,long double> >vp;
/* Precode Start Here *\



     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
double fact(ll n)
{
    double ans=1;
    for(int i=1;i<=n;i++)
    {
        ans*=i;
    }
    return ans;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n;
 long double  a,b;
 cin>>n;
 for(int i=0;i<n;i++)
 {
     cin>>a>>b;
     vp.push_back(make_pair(a,b));
 }
 for(int i=0;i<n;i++)
 {
     A[i]=i;
 }
 sort(A,A+n);
 long double sum=0,finsum=0;
 for(int j=0;j<n-1;j++)
     {
         //cout<<A[j]<<" ";
         long double x=vp[A[j]].first,y=vp[A[j]].second,x2=vp[A[j+1]].first,y2=vp[A[j+1]].second;
        long double dis=sqrt((x-x2)*(x-x2)+(y-y2)*(y-y2));
        sum+=dis;
     }
    // cout<<sum<<endl;
     finsum+=sum;
     sum=0;
 while(next_permutation(A,A+n))
 {
     for(int j=0;j<n-1;j++)
     {
        // cout<<A[j]<<" ";
         long double x=vp[A[j]].first,y=vp[A[j]].second,x2=vp[A[j+1]].first,y2=vp[A[j+1]].second;
        long double dis=sqrt((x-x2)*(x-x2)+(y-y2)*(y-y2));
        sum+=dis;
     }
     //cout<<sum<<endl;
     finsum+=sum;
    // cout<<endl;
     sum=0;
 }
 //cout<<finsum<<endl;
 cout<<setprecision(20)<<finsum/fact(n)<<endl;
return 0;
}



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

int main(void){
  int n;
  string s;
  
  cin >> n;
  cin >> s;
  
  int ans = 0;
  for(int i = 0; i < n - 2; i++){
    if(s.at(i) == 'A')
      if(s.at(i + 1) == 'B')
        if(s.at(i + 2) == 'C')
          ans ++;
  }
  
  cout << ans;
  return 0;
}


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

int main()
{
    int H, W;

    while (true) {
        cin >> H >> W;
        if( H==0 and W==0){
            break;
        }
        for(int i=0; i<H; ++i){
            for(int j=0; j<W; ++j){
                if( (i+j)%2 == 0 ){
                    cout << '#';
                }else{
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3088
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int N, ans[100'010];
vector<pii> adj[100'010];

void dfs(int u, int c);

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N;
	for (int i = 1; i < N; ++i)
	{
		int u, v;
		cin >> u >> v;
		adj[u].emplace_back(v, i);
		adj[v].emplace_back(u, i);
	}
	dfs(1, 0);
	int mx = 0;
	for (int i = 1; i < N; ++i)
	{
		mx = max(mx, ans[i]);
	}
	cout << mx << "\n";
	for (int i = 1; i < N; ++i)
		cout << ans[i] << "\n";
}

void dfs(int u, int c)
{
	int st = 1;
	for (auto& node : adj[u])
	{
		int v, idx;
		tie(v, idx) = node;
		if (ans[idx]) continue;
		if (st == c) st++;
		ans[idx] = st++;
		dfs(v, ans[idx]);
	}
}

Measured memory_bytes: 6912
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node { int p,l,r;};
struct Node T[MAX];
int n;

void preParse(int u){
  if(u==NIL)return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u == NIL)return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==NIL)return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(){

  int i,v,l,r,root;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l != NIL)T[l].p = v;
    if(r != NIL)T[r].p = v;
  }

  for(i=0;i<n;i++)if(T[i].p == NIL)root=i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}

Measured memory_bytes: 620
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>
#include <fstream>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))
#define sq5(x) ((x) * (x) * (x) * (x) * (x))

int main(void) {
	ll a;
	int x, y, z;
	scanf("%lld%1d.%1d%1d", &a, &x, &y, &z);
	ll c = (ll)(x * 100 + y * 10 + z);
	printf("%lld\n", a * c / 100);
	return 0;
}

Measured memory_bytes: 3828
import math
from numba import jit
n,k=map(int,input().split())
h=list(map(int,input().split()))
@jit
def a(N,K,H):
    s=[0]*n
    for i in range(1,N):
        total=math.inf
        for j in range(1,K+1):
            if i-j<0:
                break
            total=min(total,abs(H[i]-H[i-j])+s[i-j])
        s[i]=(total)
    print(s[-1])
a(n,k,h)

Measured memory_bytes: 117896
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
   double a;
   cin>>a;
   a/=3;
   cout<<a*a*a<<"\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
    
    
    char a;
    cin>>a;
    if(a=='A')cout<<'T';
    else if(a=='T')cout<<'A';
    else if(a=='G')cout<<"C";
    else cout<<"G";
    cout<<endl;
	
	

}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int i,a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<a[(n/2)]-a[(n/2)-1];
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

main(){
    string S;

    cin >> S;

    while(S.length() != 6){
        cin >> S;
    }
    
    string answer = S.at(2) == S.at(3) && S.at(4) == S.at(5) ? 
        "Yes" : "No";

    cout << answer;
}  

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] circle = new int[24];
        circle[0] = 1;
        for (int i = 0; i < n; i++) {
            int t = sc.nextInt();
            circle[t]++;
        }
        
        for (int i = 0; i <= 12; i++) {
            if (i == 0) {
                if (circle[i] > 1) {
                    System.out.println(0);
                    return;
                }
                continue;
            }
            
            if (i == 12) {
                if (circle[i] > 1) {
                    System.out.println(0);
                    return;
                }
                continue;
            }
            
            int t = circle[i];
            if (t >= 3) {
                System.out.println(0);
                return;
            } else if (t == 2) {
                circle[i] = 1;
                circle[24 - i] = 1;
            } else if (t == 1) {
                circle[i] = -1;
            }
        }
        
        int[] circle2 = new int[24];
        for (int i = 0; i < 24; i++) {
            if (circle[i] == 1) {
                circle2[i] = 1;
            }
        }
        
        int[] circle3 = new int[24];
        for (int i = 0; i < 24; i++) {
            if (circle2[i] == 1) {
                circle3[i] = 1;
            }
        }
        
        int max = 0;
        int combinationCount = (int)Math.pow(2, 11);
        for (int i = 0; i < combinationCount; i++) {
            String binaryNumber = Integer.toBinaryString(i);
            while (binaryNumber.length() < 11) {
                binaryNumber = "0" + binaryNumber;
            }
            
            for (int j = 0; j < 11; j++) {
                char c = binaryNumber.charAt(j);
                
                if (circle[j + 1] != -1) continue;
                
                if (c == '0') {
                    circle2[j + 1] = 1;
                } else {
                    circle2[24 - j - 1] = 1;
                }
            }
            
            int min = 100;
            int dif = 0;
            for (int j = 1; j < 24; j++) {
                if (circle2[j] == 1) {
                    min = Math.min(min, dif + 1);
                    dif = 0;
                } else {
                    dif++;
                }
            }
            
            min = Math.min(min, dif + 1);
            
            max = Math.max(max, min);
            
            for (int j = 0; j < 24; j++) {
                circle2[j] = circle3[j];
            }
        }
        
        System.out.println(max);
    }
}


Measured memory_bytes: 24148
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 2e5 + 5;
int n, m;
int a[maxn];
int b[maxn], cnt[maxn];
set<int> st;
int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> m;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	for(int i = 1; i <= n; i++) {
		int c = a[i];
		if(st.find(c) == st.end()) {
			for(int j = a[i] - cnt[a[i]] + 1; j <= a[i]; j++) {
				b[j - 1]++;
				if(j == a[i])
					st.insert(a[i]);
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++)
		if(!b[i])
			ans++;
//	cout << "B : ";
//	for(int i = 1; i <= n; i++)
//		cout << b[i] << " , ";
//	cout << endl;
//	cout << "ANS : " << ans << endl;
	while(m--) {
		int x, y;
		cin >> x >> y;
		int c = a[x];
		if(b[c - cnt[c]] == 1 && c - cnt[c] >= 0)
			ans++;
		if(c - cnt[c] >= 0)
			b[c - cnt[c]]--;
		cnt[c]--;
		cnt[y]++;
		if(b[y - cnt[y]] == 0 && y - cnt[y] >= 0)
			ans--;
		if(y - cnt[y] >= 0)
			b[y - cnt[y]]++;
		a[x] = y;
//		cout << "B : ";
//		for(int i = 1; i <= n; i++)
//			cout << b[i] << " , ";
//		cout << endl;
//		cout << "ANS : " << ans << endl;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 15488
import java.util.Scanner

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val y = scanner.nextInt()

    for (f in (0..n)) {
        for (h in (0..n)) {
            if (f + h <= n && 9000 * f + 4000 * h == y - 1000 * n) {
                println("$f $h ${n - f - h}")
                return
            }
        }
    }
    println("-1 -1 -1")
}

Measured memory_bytes: 31396
#include<stdio.h>
#include<string.h>
#define MAX 30


int main()
{
	char str[MAX];
	scanf("%s",str);
	int num = strlen(str);
	int i;
	for(i=0;i<num;i++)
	{
		printf("%c",str[num-i-1]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong(),A= sc.nextLong(),B= sc.nextLong();
		long wa =A+B;
		if(wa==0) {
			System.out.println(0);
		}else {
			long ans = (N/wa)*A;
			if (N%wa<=A) {
				ans+= N%wa;
			}else{
				ans+= A;
			}
			System.out.println(ans);
		}
	}

}

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

int main() {
  int a, b;
  
  cin >> a >> b;
  if ( a % 2 == 0 || b % 2 == 0 ) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(void) {
	int R[MAX], n;
	
	cin >> n;
	for(int i=0;i<n;i++) cin >> R[i];
	
	int maxv = -2000000000;
	int minv = R[0];
	
	for(int i=1; i<n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv,R[i]);
	}
	
	cout << maxv << endl;
	
	return 0;
}


Measured memory_bytes: 3852