akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{

    lli n, k;
    string s;
    cin>>n>>k>>s;
    lli ans = 0;
    for(int i = 0; i < n - 1; i ++) {
        ans += (s[i] == s[i + 1]);
    }

    lli cnt = 0;
    for(int i = 0; i < n; ) {
        int j = i + 1;
        while(j < n and s[i] == s[j])
            j ++;
        cnt ++;
        i = j;
    }

    while(cnt > 2 and k > 0) {
        cnt -= 2;
        ans += 2;
        k --;
    }

    while(cnt > 1 and k > 0) {
        k --;
        cnt --;
        ans ++;
    }

    cout<<ans;

    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 512
// Shift-JIS（シフトジス）

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

int n;
int p[20];

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

    int ans = 0;
    for (int i = 1; i < n - 1; i++)
    {
        if (p[i] > p[i - 1])
        {
            if (p[i] < p[i + 1])
            {
                ans++;
            }
        }
        else
        {
            if (p[i] > p[i + 1])
            {
                ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

int N;
double dp[310][310][310];

double rec(int i, int j, int k) {
    if (dp[i][j][k] >= 0) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0.0;

    double res = 0.0;
    if (i > 0) res += i * rec(i-1, j, k);
    if (j > 0) res += j * rec(i+1, j-1, k);
    if (k > 0) res += k * rec(i, j+1, k-1);
    res += N;
    res *= 1.0 / (i + j + k);
    return dp[i][j][k] = res;
}

int main() {
    cin >> N;
    int a = 0, b = 0, c = 0;
    rep(i, N) {
        int x; cin >> x;
        if (x == 1) a++;
        else if (x == 2) b++;
        else c++;
    }
    memset(dp, -1, sizeof(dp));
    cout << fixed << setprecision(16) << rec(a, b, c) << endl;
}


Measured memory_bytes: 233088
#include<bits/stdc++.h>
#define e 1000000007
#define PB push_back
#define MP make_pair
#define lli long long int
#define pll pair< lli,lli >
#define pls pair< lli,string >
#define pii pair< int,int >
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli n,x=0;
	cin>>n;
	lli a[n];
	for(int i=0;i<n;i++)cin>>a[i],x=x^a[i];
	if(x==0)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 1024
import math

a,b,C= map(float,(input().split()))
Crad=C/180*math.pi

H = b*math.sin(Crad)
S = H * a/2


L=math.sqrt((a-b*math.cos(Crad))**2+H**2)+a+b
print(S)
print(L)
print(H)

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


public class hello
{
    public static int[] dx, dy;

    public static void Main()
    {
        dx = new int[] { 0, 1, 1, 1,  };
        dy = new int[] { 1, 1, 0, -1 };
        var n = int.Parse(Console.ReadLine().Trim());
        var p = 0;
        while (p < n)
        {
            var s = "";
            for (int i = 0; i < 5; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                for (int j = 0; j < 4; j++) s += line[j];
            }
            getAns(s);

            p++;
        }
    }
    static void getAns(string s)
    {
        var hs = new HashSet<string>();
        var q = new Queue<string>();
        var ans = int.MaxValue;
        q.Enqueue(s);
        while (q.Count() > 0)
        {
            var w = q.Dequeue();
            ans = Min(ans, w.Length);
            var a = stringToarray(w);
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    if (a[i, j] == '\0') goto exit;
                    for (int k = 0; k < 4; k++)
                    {
                        var x = i + dx[k];
                        var y = j + dy[k];
                        if (x >= 0 && x < 5 && y >= 0 && y < 4 && a[i, j] == a[x, y])
                        {
                            var t = a[i, j];
                            a[i, j] = '0';
                            a[x, y] = '0';
                            var ts = arrayTostring(a, w.Length );
                            if (hs.Add(ts))     q.Enqueue(ts);
                            a[i, j] = t;
                            a[x, y] = t;
                        }
                    }
                }
            }
            exit:;
        }
        Console.WriteLine(ans);
    }
    static string arrayTostring(char[,] a, int n)
    {
        var c = 0;
        var ans = "";
        for (int i = 0; i < 5; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                if (a[i, j] != '0') ans += a[i, j];
                c++;
                if (c == n) return ans;
            }
        }
        return ans;
    }
    static char[,] stringToarray(string s)
    {
        var a = new char[5, 4];
        if (s.Length == 0) return a;
        var p = 0;
        var sL = s.Length;
        while (true)
        {
            for (int i = 0; i < 5; i++)
                for (int j = 0; j < 4; j++)
                {
                    if (s[p] != '0') a[i, j] = s[p];
                    p++;
                    if (p >= sL) return a;
                }
        }
    }
}


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

#define int long long
#define pii pair<int, int>
#define pb push_back
 
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int N;
    cin >> N;
    int X[N];
    for(int i = 0; i < N; i++){
        cin >> X[i];
    }
    int res = 1e18;
    for(int  i = 1 ; i <= 100; i++){
        int cur = 0;
        for(int j = 0; j < N ; j++){
            cur += (X[j] - i) * (X[j] - i);
        }
        res = min(res, cur);
    } 
    cout << res << endl;
    return 0;
}

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

using lint = long long int;
using pii = std::pair<int, int>;

using std::vector;
using std::deque;

deque<int> de;

int main(void) {
	int N;
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		int temp;
		scanf("%d", &temp);
		if ((N - i) % 2 == 0) {
			de.push_front(temp);
		}
		else {
			de.push_back(temp);
		}
	}

	for (int i = 1; i <= N; i++) {
		printf("%d ", de.front());
		de.pop_front();
	}

	return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

char in[105];

bool chk[105];
bool tchk[105];
int main() {
	scanf("%s", in);

	int N = strlen(in), i, j, k, ans = INF;
	for (i = 0; i < 26; i++) {
		for (j = 0; j < N; j++) chk[j] = (in[j] == 'a' + i);
		
		int c = 0, x = N;
		for (c = 0;; c++) {
			for (j = 0; j < x; j++) if (!chk[j]) break;
			if (j >= x) {
				ans = min(ans, c);
				break;
			}
			if (x == 1) break;
			for (j = 0; j + 1 < x; j++) tchk[j] = chk[j] | chk[j + 1];
			for (j = 0; j + 1 < x; j++) chk[j] = tchk[j];
			x--;
		}
	}
	return !printf("%d\n", ans);
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main (String[] args){
    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int result = a+b;

    if(result<c){
          System.out.println("No");
    }else{
    System.out.println("Yes");
    }
  }
}


Measured memory_bytes: 21844
const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);

const solve = (arr1, arr2) => arr2.filter(x => arr1.some(y => x == y)).length;

const data1 = line[1].split(' ').map(x => parseInt(x));
const data2 = line[3].split(' ').map(x => parseInt(x));

console.log(solve(data1, data2));



Measured memory_bytes: 17928
n, t = gets.split.map(&:to_i)
ab = n.times.map {gets.split.map(&:to_i)}.sort_by{|e| e[0]}

dp = Array.new(t)
dp[0] = max = 0
dp[ab[0][0]] = max = ab[0][1] if ab[0][0] < t
ans = ab[0][1]
ab.shift

ab.each do |a, b|
    ans = max + b if ans < max + b

    (t-a-1).downto(0) do |i|
        next if dp[i].nil?
        x = dp[i] + b
        dp[i+a] = x if dp[i+a].nil? || dp[i+a] < x
        max = x if max < x
    end
end

puts ans


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

int main(){
	int d;
	while(cin>>d){
		int ans = 0;
		for(int i=1; i<600/d; i++){
			int in = d*i;
			ans += (in*in)*d;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	vector<int>v(N);
	for (auto&i : v)cin >> i;
	vector<int>sum(N);
	for (int i = 0; i < M; i++) {
		cin >> K;
		for (int j = 0; j < N; j++) {
			if (v[j] <= K) {
				sum[j]++;
				break;
			}
		}
	}
	int ans = 0;
	for (int i = 1; i < N; i++) {
		if (sum[ans] < sum[i])ans = i;
	}
	cout << ans + 1 << endl;
	return 0;
}


Measured memory_bytes: 3128
#include<stdio.h>
int main()
{
  int n,s,x,t,mn,mx,av;
 
  while(1){
  t=0;
  mn=1000;
  mx=0;
    scanf("%d",&n);
    if(n==0)break;
    for(x=0;x<n;x++){
      scanf("%d",&s);
      t=t+s;
      if(mn>s){mn=s;}
      if(mx<s){mx=s;}
    }
      av=(t-mn-mx)/(n-2);
      printf("%d\n",av);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int H,W,K;
    char s[314][314];
    int d[314][314]={};
    cin >> H >> W >> K;
    REP(i,H){
        REP(j,W){
            cin >> s[i][j];
        }
    }
    int now=1;
    REP(i,H){
        REP(j,W){
            if(s[i][j]=='#'){
                d[i][j]=now;
                now++;
            }
        }
    }
    
    
    REP(j,W){
        REP(i,H){
            if(i!=0 && d[i][j]==0){
                d[i][j]=d[i-1][j];
            }
        }
        RREP(i,H){
            if(i!=H-1 && d[i][j]==0){
                d[i][j]=d[i+1][j];
            }
        }
    }
    
    bool E[314]={};
    REP(j,W){
        bool emp=true;
        REP(i,H){
            if(d[i][j]!=0)emp=false;
        }
        
        E[j]=emp;
    }
    
    REP(j,W){
        if(j==0)continue;
        if(E[j]==true){
            REP(i,H){
                d[i][j]=d[i][j-1];
            }
        }
    }
    
    
    REP(i,310){
        E[i]=false;
    }
    REP(j,W){
        bool emp=true;
        REP(i,H){
            if(d[i][j]!=0)emp=false;
        }
        
        E[j]=emp;
    }
    
    
    RREP(j,W){
        if(j==W-1)continue;
        if(E[j]==true){
            REP(i,H){
                d[i][j]=d[i][j+1];
            }
        }
    }
    
    
    
    REP(i,H){
        REP(j,W){
            if(j!=0)cout << " ";
            cout << d[i][j];
        }cout << endl;
    }cout << endl;
    return 0;
}



Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

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

    string s,t;
    cin>>s>>t;
    t.pop_back();
    if(s==t){cout<<"Yes";}
    else{cout<<"No";}

    return (0);
}


Measured memory_bytes: 3576
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#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 {
#ifdef LOCAL
~debug() { cerr << '\n'; }
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
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e6 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int x ; 
    cin >> x ; 
    cout << (x / 500) * 1000 + (x % 500) / 5 * 5 << endl;
    return 0 ;
}

Measured memory_bytes: 256
import math
A = list(map(int,"\n".join([input() for i in range(3)]).strip().split()))
N = int(input())
B = [int(input()) for i in range(N)]
size = 3
punched = set()

corrects = []
# 縦の揃い方
corrects += [{i + size*j for i in range(size)} for j in range(size)]
# 横の揃い方
corrects += [{j + size*i for i in range(size)} for j in range(size)]
# 斜めの揃い方
corrects += [{i + size*i for i in range(size)}]
corrects += [{(size - 1 - i) + size*i for i in range(size)}]

def punch(b, A, punched):
    for i in range(len(A)):
        if b == A[i]: punched.add(i)
          
for b in B:
    punch(b, A, punched)
    
for correct in corrects:
    if correct.issubset(punched):
        print("Yes")
        break
else:
  	print("No")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define	debug(ccc)	cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e6+10;
const ll inf = 1e18;

ll power(ll a,ll n){
	if(n==0){
		return 1;
	}
	ll b = power(a,n/2);
	b = b*b%mod;
	if(n%2) b= b*a%mod;
	return b;
}

int add(int a,int b){ return (a+b)%mod;}
int mul(int a,int b){ return (ll)a*b%mod;}


char s[1010];

int main(){
 // 	freopen("nice.in","r",stdin);
 // freopen("nice.out","w",stdout);
	scanf("%s",s);
	int n = strlen(s);
	int mask = 0,f=0;
	REP(i,n){
		if(s[i]=='N')	mask|=1;
		if(s[i]=='S')	mask|=2;
		if(s[i]=='W')	mask|=4;
		if(s[i]=='E')	mask|=8;
	}
	// printf("%d\n",mask);
	// int sum1 = (mask&1) ,sum2 = (mask)&4;
	if(((int)(mask&1) + ((mask&2)>>1))%2 || ((int)((mask&4)>>2) + ((mask&8)>>3))%2){
		printf("No\n");
	} else printf("Yes\n");
	return 0;
}



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

const ll INF = (1ll << 60) - 1;

struct Segment {
    int n;
    vector<ll> node;

    Segment(int N) {
        n = 1;
        while (n < N) n *= 2;

        // ノード数は ceil(log2(N))^2 * 2 (葉数が2べきとなるよう調整)
        node.assign(2 * n - 1, INF);
    }

    void update(int k, ll a) {  // k番目の値をaに変更
        // k番目の葉 : k+n-1
        k += n - 1;
        node[k] = a;

        // 子 → 親 : (k-1)/2
        // 親 → 子(1,2) : 2*k + (1,2)
        while (k > 0) {
            k = (k - 1) / 2;
            node[k] = min(node[2 * k + 1], node[2 * k + 2]);
        }
    }

    ll find_min(int a, int b, int k = 0, int l = 0, int r = -1) {  // [a,b)の最小値を返す
        if (r < 0) r = n;

        // 含まない
        if (r <= a || b <= l) return INF;
        // 完全に含む
        if (a <= l && r <= b)
            return node[k];
        else {
            ll vl = find_min(a, b, 2 * k + 1, l, (l + r) / 2);
            ll vr = find_min(a, b, 2 * k + 2, (l + r) / 2, r);

            return min(vl, vr);
        }
    }
};

struct Range {
    int l, r;
    ll c;
};
bool operator<(const Range& x0, const Range& x1) {
    return (x0.l == x1.l ? x0.r < x1.r : x0.l < x1.l);  //<で昇順
}

int main() {
    int n, m;
    cin >> n >> m;
    Segment tree(n);
    vector<Range> v(m);
    for (int i = 0; i < m; i++) {
        cin >> v[i].l >> v[i].r >> v[i].c;
        v[i].l--, v[i].r--;
    }
    sort(v.begin(), v.end());
    tree.update(0, 0);
    for (int i = 0; i < m; i++) {
        tree.update(v[i].r, min(tree.find_min(v[i].r, v[i].r + 1), tree.find_min(v[i].l, v[i].r) + v[i].c));
    }
    ll ans = tree.find_min(n - 1, n);
    cout << (ans == INF ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    //vector<vector<vector<int>>> hotel(4,vector<int>(3,vector<int>(10,0)));
    int hotel[4][3][10] = {0};
    int n;
    cin >> n;
    rep(i,n){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        a--; b--; c--;
        hotel[a][b][c] += d;
    }
    rep(i,4){
        rep(j,3){
            rep(k,10){
                cout << ' ' << hotel[i][j][k];
            }
            cout << endl;
        }
        if(i != 3){
            rep(i,20){
                cout << '#';
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3128
using System;

namespace ABC_157_A_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            if (N % 2 == 0) Console.WriteLine(N / 2);
            if (N % 2 != 0) Console.WriteLine(N % 2 + N / 2);
            Console.ReadKey();
        }
    }
}

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

using namespace std;

int h[100005];
long long cost[100005];

int main(){

	int n,k;
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> h[i];
		cost[i] = 1e18+7;
	}
	cost[0] = 0;
	for(int i=1;i<n;i++){
		for(int j=1;j<=k;j++){
			if(j>i)
				break;
			cost[i] = min(cost[i],cost[i-j]+abs(h[i]-h[i-j]));
		}
	}
	cout << cost[n-1];
}

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

#define int long long
#define  IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int INF=1e11;

vector<int> v;

void sol(){
    priority_queue<int,vector<int>,greater<int>> pq;
    map<int,int> mp;
    for(int i=1;i<=9;i++) {
        pq.push(i);
        mp[i]=1;
    }
    while(!pq.empty() && v.size()<=100010) {
        int x=pq.top();
        pq.pop();

        v.push_back(x);

        int last=x%10;

        int num1=-1,num2=-1,num3=x*10+last; //same

        if(last==0) { //ek age
            num1=x*10+(last+1);
        } else if(last==9) { //ek piche
            num2=x*10+(last-1);
        } else {
            num1=x*10+(last+1);
            num2=x*10+(last-1);
        }

        if(num1!=-1 && num1<=INF && !mp[num1]) {
            pq.push(num1);
            mp[num1]=1;
        }
        if(num2!=-1 && num2<=INF && !mp[num2]) {
            pq.push(num2);
            mp[num2]=1;
        }
        if(num3!=-1 && num2<=INF && !mp[num3]) {
            pq.push(num3);
            mp[num3]=1;
        }
    }
}

signed main() {
    sol();
    int k;
    cin>>k;
    cout<<v[k-1]<<"\n";
    return 0;
}

Measured memory_bytes: 20708
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const int N = 100100;
int n, k;
int ans;
vector<int> g[N];

int dfs(int v) {
	int x = 0;
	for (int u : g[v]) {
		int y = dfs(u);
		if (v != 0 && y == k)
			ans++;
		else
			x = max(x, y);
	}
	return x + 1;
}

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		int v;
		scanf("%d", &v);
		v--;
		if (i == 0) {
			if (v) ans++;
			continue;
		}
		g[v].push_back(i);
	}
	dfs(0);
	printf("%d\n", ans);

	return 0;
}


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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//------------------------------------------------------------------
#define prt4(v1, v2, v3, v4) cout << (v1) << " " << (v2) << " " << (v3) << " " << (v4) << "\n"

int main(void){
  int h, w;
  cin >> h >> w;
  v2(a, h, w, 0);
  rep(i,h){
    rep(j,w){
      cin >> a[i][j];
    }
  }

  vector<vector<int>> ans;
  rep(i,h){
    rep(j,w-1){
      vector<int> tmp;
      if(a[i][j]%2==1){
        a[i][j]--;
        a[i][j+1]++;
        tmp.push_back(i+1);
        tmp.push_back(j+1);
        tmp.push_back(i+1);
        tmp.push_back(j+2);
      }
      if(tmp.size()==4) ans.push_back(tmp);
    }
  }

  rep(i,h-1){
    vector<int> tmp;
    if(a[i][w-1]%2==1){
      a[i][w-1]--;
      a[i+1][w-1]++;
      tmp.push_back(i+1);
      tmp.push_back(w);
      tmp.push_back(i+2);
      tmp.push_back(w);
    }
    if(tmp.size()==4) ans.push_back(tmp);
  }

  prt(ans.size());
  rep(i,ans.size()){
    prt4(ans[i][0], ans[i][1], ans[i][2], ans[i][3]);
  }
}


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

using namespace std;
int main(){
	int aa, ab, ac, ad, ae;
	double ba, bb, bc, bd, be;
	char ca, cb, cc;
	int i, j, l;
	double p = 3.141592653589;
	//////////////////////////////////////
	cin >> ba ;
	//cout << aa * aa * p << " " << 2 * p * aa << endl;
	printf("%f %f\n", ba * ba * p, 2 * p * ba);


}


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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
mint COMB(ll n, ll r) {
  mint ret = 1;
  for(ll i=0; i<r; ++i) ret *= n-i;
  for(ll i=1; i<=r; ++i) ret /= i;
  return ret;
}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  int k = in();
  ++n;
  mint ans = 0;
  REPS(i,k,n+1) {
    int tmp = n-i+1+(n-i) * (i-1);
    ans += tmp;
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 3632
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (win, osx, linux)
 * Author: step_by_step
 * Time: 2020-03-19 17:35:03
**/

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("circus.in", "r", stdin);
    //freopen("circus.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c << "\n";
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>


enum
{
	SSx,
	SWx,
	WSx,
	WWx,
};


int inv(char c)
{
	if(c=='S') return 'W';
	return 'S';
}


int solve(char *s, char *r, int n)
{
	int i;

	for(i=1;i<n;i++)
	{
		if(s[i]=='o')
		{
			if(r[i]=='S')
			{
				r[i+1]=r[i-1];
			}
			else
			{
				r[i+1]=inv(r[i-1]);
			}
		}
		else
		{
			if(r[i]=='S')
			{
				r[i+1]=inv(r[i-1]);
			}
			else
			{
				r[i+1]=r[i-1];
			}
		}
	}
	if(r[0]!=r[n]) return 0;

	if(r[0]=='S')
	{
		if(s[0]=='o') return (r[n-1]==r[1]);
		else return (r[n-1]==inv(r[1]));
	}
	else
	{
		if(s[0]=='o') return (r[n-1]==inv(r[1]));
		else return (r[n-1]==r[1]);
	}
}


int main(void)
{
	int N;
	static char s[100000+1];
	static char r[100000+2];

	while(scanf("%d%100000s", &N, s)==2)
	{
		r[N]='\0';

		r[0]=r[1]='S';
		if(solve(s, r, N))
		{
			r[N]='\0';
			printf("%s\n", r);
			continue;
		}
		r[0]='S';
		r[1]='W';
		if(solve(s, r, N))
		{
			r[N]='\0';
			printf("%s\n", r);
			continue;
		}
		r[0]='W';
		r[1]='S';
		if(solve(s, r, N))
		{
			r[N]='\0';
			printf("%s\n", r);
			continue;
		}
		r[0]='W';
		r[1]='W';
		if(solve(s, r, N))
		{
			r[N]='\0';
			printf("%s\n", r);
			continue;
		}
		printf("-1\n");
	}

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define pb push_back
#define int long long
#define str string
using namespace std;
const int M = 1e9 + 7;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> ans(n);
    for (int a = 1; a <= n; a++) {
        for (int b = a + 1; b <= n; b++) {
            int m = b - a;
            m = min(m, 1+abs(a-x)+abs(b-y));
            ans[m]++;
        }
    }
    for (int g = 1; g <= n - 1; g++) cout << ans[g] << '\n';
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll a,b;

int main(){
  cin>>a>>b;
  if(a+b==15){
    cout<<"+"<<endl;
  }else if(a*b==15){
    cout<<"*"<<endl;
  }else{
    cout<<"x"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
program aaa;
var
  n,i,t,ans:longint;
  a:array[1..1000]of longint;
  procedure qsort(l,r:longint);
  var i,j,k,t:longint;
  begin
    i:=l; j:=r; k:=a[(i+j)shr 1];
    repeat
      while a[i]>k do inc(i);
      while a[j]<k do dec(j);
      if i<=j then
              begin
                t:=a[i]; a[i]:=a[j]; a[j]:=t;
                inc(i); dec(j);
              end;
    until i>j;
    if i<r then qsort(i,r);
    if j>l then qsort(l,j);
  end;
begin
  readln(n);
  for i:=1 to n do
    read(a[i]);
  qsort(1,n);
  t:=1;  ans:=0;
  for i:=1 to n do
  begin
    ans:=ans+a[i]*t;
    t:=-t;
  end;
  writeln(ans);
  readln;
  readln;
end.         

Measured memory_bytes: 128
while True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
        break
     
    for h in range(H):
        for w in range(W):
            if h == 0 or h == H-1 or w == 0 or w == W - 1:
                print('#', end='')
            else:
                print('.', end='')
        print()
     
    print()

Measured memory_bytes: 9068
#include <bits/stdc++.h>
#define P pair<int,int>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
	int n, X;
	cin >> n >> X;
	int a[n];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		X -= a[i];
		ans++;
	}
	sort(a, a + n);
	cout << ans + (X / a[0]) << endl;
	return 0;
}

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

int main()
{
	int a,b;
	int cost;
	cin>>a>>b;
	if(a<=5)
	{
		cost=0;
		
	}
	else if(a>=13)
	{
		cost=b;
	}
	else
	{
		cost=b/2;
	}
	cout<<cost;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        2005
#define mod         1000000007
using namespace std;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,i,j,mx=0;
    char ch;
    cin>>n>>m;
    ll a[n][m];
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin>>ch;
            if(ch=='#'){
                a[i][j]=0;
            }
            else{
                a[i][j]=1;
            }
        }
    }
    ll left[n][m],right[n][m],top[n][m],bottom[n][m];
    memset(left,0,sizeof(left));
    memset(right,0,sizeof(right));
    memset(top,0,sizeof(top));
    memset(bottom,0,sizeof(bottom));
    for(i=0;i<n;i++){
        left[i][0]=a[i][0];
        right[i][m-1]=a[i][m-1];
    }
    for(i=0;i<m;i++){
        top[0][i]=a[0][i];
        bottom[n-1][i]=a[n-1][i];
    }
    for(i=0;i<n;i++){
        for(j=1;j<m;j++){
            if(a[i][j]==1){
                left[i][j]=left[i][j-1]+1;
            }
        }
    }
    for(i=0;i<n;i++){
        for(j=m-2;j>=0;j--){
            if(a[i][j]==1){
                right[i][j]=right[i][j+1]+1;
            }
        }
    }
    for(i=0;i<m;i++){
        for(j=1;j<n;j++){
            if(a[j][i]==1){
                top[j][i]=top[j-1][i]+1;
            }
        }
    }
    for(i=0;i<m;i++){
        for(j=n-2;j>=0;j--){
            if(a[j][i]==1){
                bottom[j][i]=bottom[j+1][i]+1;
            }
        }
    }
  /*  for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cout<<left[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cout<<right[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cout<<top[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cout<<bottom[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;*/
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            mx=max(mx,left[i][j]+right[i][j]+top[i][j]+bottom[i][j]-3);
        }
    }
    cout<<mx;
}

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

int main(){
    int N; cin>>N;
    int A[N],B[N],C[N];
    REP(i,N){
        cin>>A[i];
    }
    REP(i,N){
        cin>>B[i];
    }
    REP(i,N-1){
        cin>>C[i];
    }
    C[N-1]=0;
    int ans=0;
    REP(i,N){
        ans+=B[A[i]-1];
        if(i!=0 and (A[i-1]+1)==A[i]){
            ans+=C[A[i-1]-1];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<map>
using namespace std;
char a[10];
int main()
{
	map<int,int>mp;
	int n,m,i,p,ac=0,wa=0;scanf("%d%d",&n,&m);
	while(m--)
	{
		scanf("%d%s",&p,a);
		if(mp[p]==-1)continue;
		if(a[0]=='A')
		{
			wa+=mp[p];
			ac++;
			mp[p]=-1;
			continue;
		}
		mp[p]++;
	}
	printf("%d %d\n",ac,wa);
}

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

// func(s, t) は 2 つの文字列に同じ種類の文字が何種類入っているかを返す関数
int func(string s, string t) {
  int ans = 0;
  for(char c = 'a'; c <= 'z'; c++) {
    bool found_s = false, found_t = false;
    for(int i = 0; i < s.length(); i++) {
      if(s[i] == c) found_s = true;
    }
    for(int i = 0; i < t.length(); i++) {
      if(t[i] == c) found_t = true;
    }
    if(found_s && found_t) ans++;
  }
  return ans;
}


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

  int ans = 0;
  for(int i = 1; i < n-1; i++) {
    int tmp = func(s.substr(0, i), s.substr(i));
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
ll N, K;

int main() {
  cin >> N >> K;
  if(N < K*2 - 1) {
    cout << -1;
    return 0;
  }
  vector<ll> a, b;
  if(N & 1) {
    for(int i = K; i < K + N; i += 2) a.push_back(i);
    for(int i = N/2; i >= 0; --i) b.push_back(i + K + N);
    for(int i = K+1; i < K + N; i += 2) a.push_back(i);
    for(int i = N-1; i > N / 2; --i) b.push_back(i + K + N);
  } else {
    for(int i = K+1; i < K + N; i += 2) a.push_back(i);
    for(int i = N/2-1; i >= 0; --i) b.push_back(i + K + N);
    for(int i = K; i < K + N; i += 2) a.push_back(i);
    for(int i = N-1; i >= N / 2; --i) b.push_back(i + K + N);
  }
  for(int i = 0; i < N; ++i) cout << a[i] << " " << b[i] << " " << i + K + N * 2 << '\n';
  return 0;
}

Measured memory_bytes: 3952
use proconio::input;
use std::cmp::min;
const INF: i64 = 1_000_000_000;

fn main() {

	input!(n: usize, ma: usize, mb: usize, c: [(usize, usize, i64); n]);
	let mut dp = vec![vec![vec![INF; 401]; 401]; n+1];
	dp[0][0][0] = 0;
	for i in 0..n {
		for a in 0..=400 {
			for b in 0..=400 {
				let mut cost = dp[i][a][b];
				if a >= c[i].0 && b >= c[i].1 {
					cost = min(cost, dp[i][a-c[i].0][b-c[i].1] + c[i].2);
				}
				dp[i+1][a][b] = cost;
			}
		}
	}
	let mut cost_min = INF;
	for a in 1..=400 {
		for b in 1..=400 {
			if a * mb != b * ma { continue };
			cost_min = min(cost_min, dp[n][a][b]);
		}
	}
	if cost_min >= INF { cost_min = -1 };
	println!("{}", cost_min);
}

Measured memory_bytes: 54024
#include<vector>
#include <iostream>
#include<string>
#include <complex>
#include <algorithm>
#include<string>
#include <map>
#include <utility>

using namespace std;

int main(){

    double w, h;
    cin >> w;
    cin >> h;
    double x, y;
    cin >> x;
    cin >> y;

    cout << double(w)*double(h)/2;

    if(x + x == w && y + y == h){
        cout << " 1" << endl;
    }else{
        cout << " 0" << endl;
    }
    
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    double ans = v[0];
    for (int i = 1; i < n; i++)
        ans = (ans + v[i]) / 2;
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll A, B, C, X, Y;

void solve() {
	cin >> A >> B >> C >> X >> Y;
	ll ans = linf;
	for(int c = 0; c <= max(X, Y) * 2; c += 2) {
		ll res = 0;
		res += C * c;
		res += A * max(X - c / 2, 0ll);
		res += B * max(Y - c / 2, 0ll);
		MIN(ans, res);
	}
	cout << ans << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 枚数
        int N = sc.nextInt();
        // 合計金額
        int Y = sc.nextInt();
        // x=10000円札の枚数
        int z = 0;
        // y=5000円札の枚数
        int y = 0;

        int AnsZ = -1;
        int AnsY = -1;
        int AnsX = -1;
        for (z = 0; z <= N; z++) {
            for (y = 0; (y +z)<= N; y++) {
                int x=N-z-y;
                int tempY = 10000 * z + 5000 * y+1000*x;
                if (tempY == Y) {
                    // flag立てる
                    
                    AnsZ = z;
                    AnsY = y;
                    AnsX = x;
                    System.out.println(AnsZ+" "+ AnsY+" "+ AnsX);
                    return;
                }
            }
        }
        System.out.println(AnsZ+" "+ AnsY+" "+ AnsX);
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
 
int main() {
  int k,a,b;
  cin >> k >> a >> b;
  bool ans=0;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      ans=1;
    }
  }
  if(ans) cout <<"OK";
  else{
    cout << "NG";
  }
}
  

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    while (1) {
        C -= B;
        if (C <= 0) {
            cout << "Yes";
            break;
        }

        A -= D;
        if (A <= 0) {
            cout << "No";
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3632
def main():
    a,b,c,k = map(int,input().split())
    sum = 0

    if a >= k:
        print(k)
    else:
        sum += a
        k -= a
        if b >= k:
            print(sum)
        else:
            k -= b
            print(sum - k)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9112
#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> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int N; cin>>N;
	int ans  = 1000 - N%1000;
	if (ans == 1000)ans = 0;
	cout<<ans<<endl;
	return 0;
}

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

map<ll, int> prime_factor(ll n) {
    map<ll, int> ret;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

int main() {
    ll n, p;
    cin >> n >> p;
    map<ll, int> mp = prime_factor(p);

    ll ans = 1;
    for (auto &p : mp) {
        rep(i, p.second / n)
            ans *= p.first;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256