akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# Your code here!
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])
# op = ["+++", "++-", "+-+", "+--", "-++", "-+-", "--+", "---"]
if a + b + c + d == 7:
    print("{0}+{1}+{2}+{3}=7".format(str(a), str(b), str(c), str(d)))
elif a + b + c - d == 7:
    print("{0}+{1}+{2}-{3}=7".format(str(a), str(b), str(c), str(d)))
elif a + b - c + d == 7:
    print("{0}+{1}-{2}+{3}=7".format(str(a), str(b), str(c), str(d)))
elif a + b - c - d == 7:
    print("{0}+{1}-{2}-{3}=7".format(str(a), str(b), str(c), str(d)))
elif a - b + c + d == 7:
    print("{0}-{1}+{2}+{3}=7".format(str(a), str(b), str(c), str(d)))
elif a - b + c - d == 7:
    print("{0}-{1}+{2}-{3}=7".format(str(a), str(b), str(c), str(d)))
elif a - b - c + d == 7:
    print("{0}-{1}-{2}+{3}=7".format(str(a), str(b), str(c), str(d)))
elif a - b - c - d == 7:
    print("{0}-{1}-{2}-{3}=7".format(str(a), str(b), str(c), str(d)))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N;
    cin >> N;
    ll m = 0, a = 0, r = 0, c = 0, h = 0;
    int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
    int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
    int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};
    rep(i, N){
        string S;
        cin >> S;
        if(S[0] == 'M') m++;
        if(S[0] == 'A') a++;
        if(S[0] == 'R') r++;
        if(S[0] == 'C') c++;
        if(S[0] == 'H') h++;
    }
    ll D[5];
    D[0] = m, D[1] = a, D[2] = r, D[3] = c, D[4] = h;
    ll ans = 0;
    rep(i, 10){
        ans += D[P[i]] * D[Q[i]] * D[R[i]];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

    // solution comes here
    long long N, K, a, b;
    cin >> N >> K;

    if(K%2) {
        a = N/K;
        cout << a*a*a << "\n";
    }
    else {
        b = a = N/K;
        if(N%K >= K/2) b++;
        cout << a*a*a + b*b*b << "\n";
    }
}

Measured memory_bytes: 256
def count_dot(lis):
    c=0
    for i in lis:
        if not(i=='.'):
            return c
        c+=1

def solve(N):
    a=[]
    dot =[]
    for i in range(N):
        a.append([char for char in input()])
        dot.append(count_dot(a[i]))

    for i in range(N):
        for j in range(len(a[i])):
            if a[i][j]=='.':
                a[i][j]=' '

    for i in range(1,N):
        #print(type(dot[i]))
        a[i][dot[i]-1]='+'
        k=1
        while True:
#            print(i-k,dot[i]-1)
            if a[i-k][dot[i]-1] == ' ':
                a[i-k][dot[i]-1]='|'
                k += 1
            else:
                break

    for i in range(N):
        for char in a[i]:
            print(char,end='')
        print()

while True:
    N=int(input())
#    print(N)
    if N==0:
        break
    solve(N)



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

int main() {
    string S;
    cin >> S;
    int cnt = 0;
    int max = 0;
    rep(i,3) {
        if(S.at(i) == 'R') {
            cnt++;
        } else {
            if(cnt > max) max = cnt;
            cnt = 0;
        }
    }
    if(cnt > max) max = cnt;
    cout << max << endl;
}

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

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

    string strlist[n];
    string tmp_str;
    for(int i=0;i<n;i++){ 
        cin >> tmp_str;
        sort(tmp_str.begin(), tmp_str.end());
        strlist[i] = tmp_str;
    }
    sort(strlist,strlist+n);

    // check anagram
    long long anagram_cnt = 0;
    long long total = 0;
    string check = strlist[0];
    for(int i=1;i<n;i++){
        if(check == strlist[i]){
            total++;
        } else {
            anagram_cnt = anagram_cnt + (total*(total+1)/2);
            check = strlist[i];
            total = 0;
        }
    }

    cout << anagram_cnt + (total*(total+1)/2) << endl;
    return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<vector>
#define NIL -1
using namespace std;

struct Node {
	int parent = NIL;
	int left = NIL;
	int right = NIL;
};

Node node[25];
int depth[25];
int height[25];

void initDepth(int k,int d) {
	depth[k] = d;
	if (node[k].left != NIL) {
		initDepth(node[k].left, d + 1);
	}
	if (node[k].right != NIL) {
		initDepth(node[k].right, d + 1);
	}
	return;
}

int initHeight(int k) {
	int h1 = 0, h2 = 0;
	if (node[k].left != NIL) {
		h1 = initHeight(node[k].left) + 1;
	}
	if (node[k].right != NIL) {
		h2 = initHeight(node[k].right) + 1;
	}

	return height[k] = max(h1, h2);
}

int getBro(int k) {
	if (node[k].parent == NIL) { return NIL; }
	if (node[node[k].parent].left == k) {
		return node[node[k].parent].right;
	}
	return node[node[k].parent].left;
}

void getType(int k) {
	if (node[k].parent == NIL) { cout << "root"; return; }
	if (node[k].left == NIL && node[k].right == NIL) { cout << "leaf"; return; }
	cout << "internal node";
}

int getDegree(int k) {
	int num = 0;
	if (node[k].left != NIL) { num++; }
	if (node[k].right != NIL) { num++; }
	return num;
}

int root(int k=0) {
	int root = 0;
	while (node[root].parent != NIL) {
		root = node[root].parent;
	}
	return root;
}


int main() 
{
	int n,m,q;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> m;
		for (int o = 0; o < 2; o++) {
			cin >> q;
			if (q != NIL) {
				if (o == 0) {
					node[m].left = q;
					node[q].parent = m;
					continue;
				}
				node[m].right = q;
				node[q].parent = m;
			}
		}
	}
	initDepth(root(), 0);
	initHeight(root());
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << node[i].parent << ", sibling = " << getBro(i) << ", degree = " << getDegree(i)
			<< ", depth = " << depth[i] << ", height = " << height[i] << ", "; 
		getType(i);
		cout << endl;
	}
	
}


Measured memory_bytes: 3128
// https://atcoder.jp/contests/abc066/tasks/abc066_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

vector<int> z_algorithm(const string &s) {
    vector<int> prefix(s.size());
    for (int i = 1, j = 0; i < s.size(); i++) {
        if (i + prefix[i - j] < j + prefix[j]) {
            prefix[i] = prefix[i - j];
        } else {
            int k = max(0, j + prefix[j] - i);
            while (i + k < s.size() && s[k] == s[i + k])
                ++k;
            prefix[i] = k;
            j = i;
        }
    }
    prefix[0] = (int)s.size();
    return prefix;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int maxv = 0;
    s = s.substr(0, s.length() - 1);
    auto t = z_algorithm(s);
    REP(i, t.size()) {
        if (i <= t[i]) {
            maxv = max(maxv, i);
        }
    }
    cout << maxv * 2 << endl;
    return 0;
}


Measured memory_bytes: 256
//2020-08-30, Sun

#include<iostream>
using namespace std;

int sumer(int i) {
    int sum = 0;
    while (i > 0) {
        sum += i % 10;
        i /= 10;
    }
    return sum;
}

int main() {
    int a, b, n, ans = 0;
    cin >> n >> a >> b;
    
    for (int i = 1; i <= n; i++) {
        int sum = sumer(i);
        if (sum >= a && sum <= b) {
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
//C
#include<stdio.h>
int main(void){
  int N,M;
  int i;
  int ans=0;
  int a,b;
  scanf("%d%d",&N,&M);
  int Takasa[N];
  int Hikui[N];
  for(i=1;i<=N;i++){
    scanf("%d",&Takasa[i]);
    Hikui[i]=0;
  }
  for(i=1;i<=M;i++){
    scanf("%d%d",&a,&b);
    if(Takasa[a]>=Takasa[b]){
      Hikui[b]=-1;
    }
    if(Takasa[b]>=Takasa[a]){
      Hikui[a]=-1;
    }
  }
  for(i=1;i<=N;i++){
    if(Hikui[i]==0){
      ans=ans+1;
    }
  }
  printf("%d",ans);
  return 0;
}

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

int main() {
  int a,b,c,k,d,ans;
  cin >> a >> b >> c >> k;
  d=max(a,b);
  ans = max(d,c);
  for(int i=0;i<k;i++)ans = ans*2;
  ans = ans+a+b+c-max(d,c);
  cout << ans << endl;
  return 0;
}
  


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

using namespace std;

typedef long long int ll;

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

  double a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;

  if (a == b) {
    cout << "YES\n";
    return 0;
  }

  if (w >= v) {
    cout << "NO\n";
    return 0;
  }

  double time = abs (a - b) / abs (v - w);

  if (time <= t) cout << "YES\n";
  else cout << "NO\n";
}


Measured memory_bytes: 3716
import sys
import math
#import random
#sys.setrecursionlimit(1000000)
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

ara=inara()

for i in range(5):
	if ara[i]==0:
		print(i+1)
		break


	


Measured memory_bytes: 62044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    ll ans = 0;
    map<int, int> m;
    rep(i,n) {
        int a; cin >> a;
        m[a]++;
    }
    for(auto num : m){
        if(num.first<num.second){
            ans += num.second - num.first;
        }else if(num.first>num.second){
            ans += num.second;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4736
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int ta[100010],nt[200010],to[200010],co[200010],g;
int bfs(int v,int s){
  int q[1000000],C[100010],t=0,r=1,i,max=0;
  for(i=0;i<v;i++)C[i]=1000000000;
  for(C[q[0]=s]=0;r-t;t++){
    for(i=ta[q[t]];i+1;i=nt[i]){//printf("%d %d %d\n",q[t],to[i],co[i]);
      if(C[to[i]]>C[q[t]]+co[i])C[q[r++]=to[i]]=C[q[t]]+co[i];
      if(max<C[to[i]])max=C[g=to[i]];//printf("m%d\n",max);
    }
  }
  return max;
}//*/
int tyokkei(int v,int e,int *a){
  int i,max=0;
  for(i=0;i<v;i++)ta[i]=-1;
  for(i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]     ];
    co[i+e]=co[i];
    ta[ a[i]]=i;
    ta[to[i]]=i+e;    
  }
  bfs(v,0);
  return bfs(v,g);
}
int main(){
  int n,a[100010],b[100010],i;
  scanf("%d",&n);
  for(i=0;i<n-1;i++)scanf("%d %d %d",&a[i],&to[i],&co[i]);
  printf("%d\n",tyokkei(n,n-1,a));
  return 0;
}

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

int main()
{
  int n, c = 0;
  cin >> n;
  int p[n + 1];
  for (int i = 1; i <= n; i++)
  {
    cin >> p[i];
  }
  for (int i = 1; i <= n - 2; i++)
  {
    if (p[i + 1] > p[i] && p[i + 1] < p[i + 2])
      c++;
    else if (p[i + 1] > p[i + 2] && p[i + 1] < p[i])
    {
      c++;
    }
  }

  cout << c << endl;
  return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b;
  c = b * 2;
  cout << max(a - c, 0) << endl;
}


Measured memory_bytes: 256
MOD = int(1e9) + 7
H, W = map(int, input().split())
maze = [list(input()) for _ in range(H)]
dp = [[0 for i in range(W)] for j in range(H)]
dp[0][0] = 1

for i in range(H):
    for j in range(W):
        if i + 1 < H and maze[i+1][j] == ".":
            dp[i+1][j] += dp[i][j]
            dp[i+1][j] %= MOD
        if j + 1 < W and maze[i][j+1] == ".":
            dp[i][j+1] += dp[i][j]
            dp[i][j+1] %= MOD
print(dp[H-1][W-1])

Measured memory_bytes: 122720
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

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

  vector<int> ans(1e4 + 5, 0);
  for (int i = 1; i < 110; i++) {
    for (int j = 1; j < 110; j++) {
      for (int k = 1; k < 110; k++) {
        int x = i * i + j * j + k * k + i * j + j * k + k * i;
        if (x < ans.size()) ans[x]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3616
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
if A==B:
    print('YES')
else:
    if A>B:
        if A-(V*T)<=B-(W*T):
            print('YES')
        else:
            print('NO')
    else:
        if A+(V*T)>=B+(W*T):
            print('YES')
        else:
            print('NO')

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s,t = input().split()

ans = ''
for i in range(2*n):
    if i % 2:
        ans += t[i//2]
    else:
        ans += s[i//2]
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int n;
int a[100001];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}	
	int ans=0,num=0;
	for(int i=1;i<=n+1;i++){
		if(a[i]==i)num++;
		if(a[i]!=i){
			if(num==1)ans+=1;
			if(num>1){
				ans+=num/2;
			    ans+=num%2;
			}
			num=0;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
int main()
{
	//ifstream cin("in.txt");
	//ofstream cout("out.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	map <string,int> days;
	days["MON"]=1;
	days["TUE"]=2;
	days["WED"]=3;
	days["THU"]=4;
	days["FRI"]=5;
	days["SAT"]=6;
	days["SUN"]=7;
	
	string s; cin>>s;
	int ans = days["SUN"] - days[s];
	if (!ans) ans = 7;
	cout<<ans<<endl;
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		int a,b;
		a = sc.nextInt();
		b = sc.nextInt();
		while(!(a == 0 && b == 0)){
			if(a >= b){
				System.out.println(b + " " + a);
			}else{
				System.out.println(a + " " + b);
			}
			a = sc.nextInt();
			b = sc.nextInt();
		}
	}
}

Measured memory_bytes: 36000
#include <iostream>

using namespace std;

int N, c, result = 0;

int main()
{
  cin >> N;
  int V[N];
  for(int n = 0; n < N; n++) {cin >> V[n];}
  for(int v : V)
  {
    cin >> c;
    if(v-c>0) {result += (v-c);}
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define hii cout << "hii" << endl
#define int long long
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 5e5 + 5;
const int MAX = 250000 + 5;
const int M = 1e6 + 5;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int INF = 1e18 + 8;
const int LG = 21;

int arr[N];
int DP[N];

int f(int idx)
{
	if(idx == 0)
	{
		return 1;
	}
	int & ret = DP[idx];
	if(~ret) return ret;
	ret = 0;
	for(int i = 3; i <= idx; i++)
	{
		ret += f(idx - i);
		ret %= mod;
	}
	return ret;
}

void solve()
{
	int n;
	cin >> n;
	memset(DP, -1, sizeof(DP));
	cout << f(n) << endl;
}


 
int32_t main() 
{	
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

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

using namespace std;

typedef long long ll;

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

const int MOD = 1e9 + 7;
const int N = 1e6 + 4;

vector<ll> solve(string s, ll n0, ll k0, ll R)
{
    vector<ll> ans(26);

    while (R)
    {
        if (R <= n0)
        {
            for (int i = 0; i < R; i++) ans[s[i] - 'a']++;
            break;
        }
        ll n = n0, k = k0;
        vector<ll> cnt0(26), cnt1(26);
        for (int i = 0; i < k; i++) cnt0[s[i] - 'a']++;
        for (int i = 0; i < n; i++) cnt1[s[i] - 'a']++;
        while (n + k <= R)
        {
            ll m = n + k;
            vector<ll> cnt2(26);
            for (int i = 0; i < 26; i++) cnt2[i] = cnt1[i] + cnt0[i];
            k = n;
            n = m;
            cnt0 = cnt1;
            cnt1 = cnt2;
        }
        R -= n;
        for (int i = 0; i < 26; i++)
            ans[i] += cnt1[i];
    }

    return ans;
}

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

    string s;
    cin >> s;
    {
        vector<int> z(s.size());
        int L = 0, R = 0;
        for (int i = 1; i < s.size(); i++)
        {
            z[i] = max(0, min(z[i - L], R - i));
            while (i + z[i] < s.size() && s[z[i]] == s[i + z[i]]) z[i]++;
            if (i + z[i] > R)
            {
                R = i + z[i];
                L = i;
            }
        }
        int len = s.size();
        for (int i = s.size() - 1; 2 * i > s.size(); i--)
        {
            if (i + z[i] == s.size())
            {
                len = i;
            }
        }
        while (s.size() > len) s.pop_back();
    }

    ll n = s.size();
    vector<int> z(s.size());
    int L = 0, R = 0;
    for (int i = 1; i < s.size(); i++)
    {
        z[i] = max(0, min(z[i - L], R - i));
        while (i + z[i] < s.size() && s[z[i]] == s[i + z[i]]) z[i]++;
        if (i + z[i] > R)
        {
            R = i + z[i];
            L = i;
        }
    }
    ll k = n;
    for (int i = 1; i < s.size(); i++)
    {
        if (i + z[i] == s.size())
        {
            k = i;
            break;
        }
    }
    if (n % k == 0)
    {
        vector<ll> cnt(26);
        ll L, R;
        cin >> L >> R;
        L--;
        ll c = R / k;
        for (int i = 0; i < k; i++)
        {
            if (i < R % k) cnt[s[i] - 'a'] += c + 1;
            else cnt[s[i] - 'a'] += c;
        }
        c = L / k;
        for (int i = 0; i < k; i++)
        {
            if (i < L % k) cnt[s[i] - 'a'] -= c + 1;
            else cnt[s[i] - 'a'] -= c;
        }
        for (int i = 0; i < 26; i++)
        {
            cout << cnt[i] << " ";
        }
    }
    else
    {
        ll L, R;
        cin >> L >> R;
        L--;
        vector<ll> cntR = solve(s, n, k, R);
        vector<ll> cntL = solve(s, n, k, L);
        for (int i = 0; i < 26; i++)
        {
            cout << cntR[i] - cntL[i] << " ";
        }
    }
}


Measured memory_bytes: 4452
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

vector<string> solve(int a, int b, char ca, char cb) {
	vector<string> r;
	if (a > 1) {
		--b;
		r.push_back(string(100, cb));
		while (a > 1) {
			int x = min(a - 1, 49);
			string s;
			for (int i = 0; i < x; ++i) {
				s += cb;
				s += ca;
			}
			s += string(100 - s.length(), cb);
			r.push_back(s);
			r.push_back(string(100, cb));
			a -= x;
		}
	}
	r.push_back(string(100, ca));
	while (b > 0) {
		int x = min(b, 49);
		string s;
		for (int i = 0; i < x; ++i) {
			s += ca;
			s += cb;
		}
		s += string(100 - s.length(), ca);
		r.push_back(s);
		r.push_back(string(100, ca));
		b -= x;
	}
	return r;
}

int main(int argc, char *argv[])
{
	int a, b;
	cin >> a >> b;
	vector<string> r = solve(min(a, b), max(a, b), a < b ? '.' : '#', a < b ? '#' : '.');
	cout << r.size() << " " << r[0].length() << endl;
	for (auto s : r) {
		cout << s << endl;
	}
	return 0;
}


Measured memory_bytes: 256
let [| sA; sB |] = stdin.ReadLine().Split(" ")

let [| a; b |] =
    stdin.ReadLine().Split(" ") |> Array.map int

stdin.ReadLine()
|> (fun x -> if sA = x then (a - 1, b) else (a, b - 1))
|> (fun (x, y) -> printfn "%d %d" x y)

Measured memory_bytes: 29820
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			int m = sc.nextInt();

			long k = sc.nextLong();

			long[] aBooks = new long[n];
			long[] bBooks = new long[m];
			
			long[] bSum = new long[m];

			for(int i = 0 ; i < n ; i++ ) {
				aBooks[i] = sc.nextLong();
			}

			for(int i = 0 ; i < m ; i++ ) {
				bBooks[i] = sc.nextLong();
				if ( i == 0 ) {
					bSum[i] = bBooks[i];
				}
				else {
					bSum[i] = bBooks[i] + bSum[i-1];
				}
				
			}

			long takeA = 0;
			int max = 0;
			int maxB = m-1;
			for(int i = -1 ; i < n ; i++ ) {
				
				int readed = i+1;
				if ( i > -1 ) {
					takeA += aBooks[i];
				}
				if ( takeA > k ) {
					break;
				}
				
				
//				System.out.println("## " + takeA);
				
				long rest = k - takeA;
//				for(int j = 0 ; j < m ; j++ ) {
//					if ( bBooks[j] <= rest ) {
//						rest -= bBooks[j];
//						readed++;
//					}
//					else {
//						break;
//					}					
//				}
				while ( maxB >= 0 && bSum[maxB] > rest ) {
					maxB--;
				}
//				System.out.println(maxB);
				
				readed += maxB+1;
				
				if ( readed > max) {
					max = readed;
				}
			}
			
			System.out.println(max);
		}
	}

}

Measured memory_bytes: 65884
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

    int n;
    cin >> n;
    int a[n + 5] = {};
    reps(i, n){
      cin >> a[i];
    }
    lol ans = 0;
    reps(i, n){
      ans += a[i] / 2;
      a[i] %= 2;
      ans += min(a[i], a[i + 1]);
      a[i + 1] -= min(a[i], a[i + 1]);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {

int n, a, b;
cin >> n >> a >> b;

 if ( a*n < b ){ 
 cout << a*n << endl;
 }
 else if (a*n > b ){
 cout << b << endl;
 }
 else {
 cout << b << endl;
 }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<sstream>
#include<set>
using namespace std;
set<int> a;
int N,ans;
void dfs(string s){
	set<int> b;
	int x=0;
	stringstream ss;
	ss<<s;
	ss>>x;
	if(x>N) return ;
	while(x){
		b.insert(x%10);
		x/=10;
	}
	if(b==a) ans++;
	dfs(s+"3");
	dfs(s+"5");
	dfs(s+"7");
}
int main()
{
	a.insert(3);
	a.insert(5);
	a.insert(7);
	ans=0;
	cin>>N;
	dfs("");
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean flag = true;
        Stack<String> st = new Stack<String>();
        while(true){
            String S = sc.nextLine();
            if(S.equals(".")) break;
            for(int i=0; i<S.length(); i++){
                char a = S.charAt(i);
                if(a == '(') st.push("(");
                else if(a == '[') st.push("[");
                else if(a==')' || a==']'){
                   if(st.empty()){
                        System.out.println("no");
                        flag = false;
                        break;
                   }else{
                       if(a==')' && st.peek().equals("(")) st.pop();
                       else if(a==']' && st.peek().equals("[")) st.pop();
                       else{
                           System.out.println("no");
                           flag = false;
                           break;
                       }
                   }
                }
            }
            if(flag) System.out.println(st.empty()?"yes":"no");
            flag = true;
            st.clear();
        }
    }
}


Measured memory_bytes: 43796
a,b,c=map(int,input().split())
k=int(input())
if c>b and b>a:
    print("Yes")
else:
    if b<=a:
        while(b<=a and k>0):
            b=b*2
            k-=1
    if c<=b:
        while(c<=b and k>0):
            c=c*2
            k-=1
    if c>b and b>a:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 9028
#include <stdio.h>
using namespace std;
int main(){
int n,x;
scanf("%d",&n);
for(int i = 1; i<= n; i++) {
if(i%3 == 0){
printf(" %d",i); 
}else{ x = i;
do{ if(x%10 == 3){
printf(" %d",i);
break; 
} 
x /=10;
}while(x);
} 
} 
printf("\n"); 
} 


Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll is_query = -(1LL<<62);
struct Line {
    ll m, b;
    mutable function<const Line*()> succ;
    bool operator<(const Line& rhs) const {
        if (rhs.b != is_query) return m < rhs.m;
        const Line* s = succ();
        if (!s) return 0;
        ll x = rhs.m;
        return b - s->b < (s->m - m) * x;
    }
};
struct HullDynamic : public multiset<Line> { // will maintain upper hull for maximum
    bool bad(iterator y) {
        auto z = next(y);
        if (y == begin()) {
            if (z == end()) return 0;
            return y->m == z->m && y->b <= z->b;
        }
        auto x = prev(y);
        if (z == end()) return y->m == x->m && y->b <= x->b;
        return (x->b - y->b)*(z->m - y->m) >= (y->b - z->b)*(y->m - x->m);
    }
    void insert_line(ll m, ll b) {
        auto y = insert({ m, b });
        y->succ = [=] { return next(y) == end() ? 0 : &*next(y); };
        if (bad(y)) { erase(y); return; }
        while (next(y) != end() && bad(next(y))) erase(next(y));
        while (y != begin() && bad(prev(y))) erase(prev(y));
    }
    ll eval(ll x) {
        auto l = *lower_bound((Line) { x, is_query });
        return l.m * x + l.b;
    }
};
void solve()
{
    ll n,c;
    cin>>n>>c;
    ll h[n];
    ll dp[n];
    for(int i=0;i<n;i++)
        cin>>h[i];
        HullDynamic e;
        e.insert_line(2ll*h[0],-(h[0]*h[0]));
    for(int i=1;i<n;i++)
    {
        dp[i]=-e.eval(h[i])+h[i]*h[i]+c;
        e.insert_line(2ll*h[i],-dp[i]-h[i]*h[i]);
    }
    cout<<dp[n-1];
}
int main()
{
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
}


Measured memory_bytes: 22144
import java.math.*; 
import java.util.*; 

public class Main{

	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in) ;
		int n = in.nextInt()   ;
		int[] a  = new int[n]  ; 
		long mod = 998244353   ;
		long S = 0;
				
		for(int i=0;i<n;i++) {
			a[i] = in.nextInt() ;
			S += (long) a[i] ;
			
		}
		
			
		long[] s2     = new long[301] ;
		long[] s3     = new long[301] ;
        s2[2] = 1 ;
		s3[3] = 1 ;
        
		for(int i=3;i<=300;i++){
			s2[i] = (1 + 2 * s2[i-1]) % mod ; 	
		}
			
		for(int i=4;i<=300;i++){
			s3[i] = (s2[i-1] + 3 * s3[i-1]) % mod ;
		}
				    

		long[] d1  = new long[90001] ;
		long[] d2  = new long[90001] ;
		
		for(int x :a) {
			for(int i=90000;i>=0;i--) {
		        if(d2[i] > 0) {
		            d2[i+x] = (d2[i+x] + 2 * d2[i]) % mod ;
		        }    		
			}
			
			for(int i=90000;i>=0;i--) {
		        if(d1[i] > 0) {
		            d1[i+x]  = (d1[i+x] + d1[i]) % mod    ;
		            d2[i+x]  = (d2[i+x] + d1[i]) % mod    ;
			    }
			}
			
		    d1[x] = (d1[x] + 1) % mod ;       
		    
		}
		    
		   
		
		long count = 0 ;

		for(int i=1; i <= (int) S / 2;i++){
			count = (count+d2[i]) % mod ;
		}
		
		System.out.println(6*(s3[n]-count+mod) % mod) ;
    }
}


Measured memory_bytes: 26708
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
// 104, 79, 118, 87
// 169, 133, 17, 98
// 180, 106, 125, 39
// 171, 42, 159, 14
// 45, 76, 101, 56
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	long long ret=0;
	long long ks=1;
	long long ret2=0;
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		printf("? %d %d %d %d\n",i,j,i,j);
		fflush(stdout);
		int t;
		scanf("%d",&t);
		if(t)ret=(ret+ks)%d;
		if(i==0)ret2=(ret2+ks)%d;
		ks=ks*2%d;
	}
	int sz=150;
	char *p = new char[sz*1000000];
	for(int i=0;i<sz*1000000;i++)p[i]='e';
	printf("! %lld\n",ret);
}

Measured memory_bytes: 147152
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

LL q, INF = 1e16;

int main() {
	multiset<LL> L, H;
	L.insert(-INF);
	H.insert(+INF);
	LL s = 0;
	LL Ls = 0, Hs = 0;
	
	int q;
	cin >> q;
	inc(i, q) {
		int t;
		cin >> t;
		if(t == 1) {
			LL a, b;
			cin >> a >> b;
			s += b;
			
			if(a < (* H.begin())) { L.insert(a); Ls += a; } else { H.insert(a); Hs += a; }
			
			while(SI(L) < SI(H)) {
				LL v = (* H.begin());
				L.insert(v); Ls += (v);
				auto it = H.begin();
				H.erase(it); Hs -= (v);
				
			}
			while(SI(L) > SI(H) + 1) {
				LL v = (* L.rbegin());
				H.insert(v); Hs += v;
				auto it = L.end();
				it = prev(it);
				L.erase(it); Ls -= v;
			}
			assert(SI(L) == SI(H) || SI(L) == SL(H) + 1);
		} else {
			//cout << "L: "; RF(e, L) { cout << e << " "; } cout << endl;
			//cout << "H: "; RF(e, H) { cout << e << " "; } cout << endl;
			LL p = (* L.rbegin());
			cout << p << " " << s + p * SI(L) - Ls + Hs - p * SI(H) << "\n";
		}
	}
	
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main (){
    int W,H,N,x,y,a,count=0;
    cin >> W >> H >> N;
    vector<vector<bool>> v(W,vector<bool>(H,true));

    for(int i=0;i<N;i++){
        cin >> x >> y >> a;
        
        if(a == 1){
            for(int j=0;j<x;j++){
                for(int k=0;k<H;k++){
                    v.at(j).at(k) = false;
                }
            }
        }
        if(a == 2){
            for(int j=x;j<W;j++){
                for(int k=0;k<H;k++){
                    v.at(j).at(k) = false;
                }
            }
        }
        if(a == 3){
            for(int j=0;j<W;j++){
                for(int k=0;k<y;k++){
                    v.at(j).at(k) = false;
                }
            }
        }
        if(a == 4){
            for(int j=0;j<W;j++){
                for(int k=y;k<H;k++){
                    v.at(j).at(k) = false;
                }
            }
        }
    }
    for(int i=0;i<W;i++){
        for(int j=0;j<H;j++){
            if(v.at(i).at(j) == true){
                count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
char str1[4001], str2[4001];
int len1, len2;
short cache[4000][4000];
 
int main(){
 
  while(scanf("%s%s", str1, str2) != EOF){
    int a, b, num, max=0;
    len1 = strlen(str1);
    len2 = strlen(str2);
    for(a=0;a<len1;a++){
      if(str1[a] == str2[0]) {cache[a][0] = 1;max = 1;}
     else {cache[a][0] = 0;}
    }
    for(a=1;a<len2;a++){
      if(str1[0] == str2[a]) {cache[0][a] = 1;max = 1;}
     else {cache[0][a] = 0;}
    }

    for(a =1;a<len1;a++){
      for(b=1;b<len2;b++){
        if(str1[a] == str2[b]){cache[a][b] = cache[a-1][b-1]+1;}
        else{cache[a][b] = 0;}
        if(cache[a][b] > max) {max = cache[a][b];}
      }
    }
        printf("%d\n", max);
  }

    return 0;
}

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

class mcomb {
public:
    vector<ll> fact, ifact;
    ll m;

    mcomb(ll n, ll m_=1e9+7): fact(n+1, 1), ifact(n+1), m(m_) {
        rep(i,n) fact[i+1] = (fact[i]*(i+1)) % m;
        ifact[n] = minv(fact[n]);
        rep(i,n) ifact[n-1-i] = (ifact[n-i]*(n-i)) % m;
    }

    ll operator()(ll n, ll k) {
        if(k < 0 || k > n) return 0;
        return (((ifact[k]*ifact[n-k]) % m)*fact[n]) % m;
    }

    ll minv(ll a) {
        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()
{
    const ll m = 1e9+7;
    ll n,k;
    cin >> n >> k;
    mcomb mc(n+1, m);

    rep(i,k) cout << (mc(n-k+1, i+1) * mc(k-1, i)) % m << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,j,k,tmp;
	char S[310],T[111];
	scanf("%s %s",S,T);
	for(k=0; S[k]!='\0'; k++){
	}
	for(i=0; i<k; i++){
		tmp=1;
		S[i+k]=S[i];
		for(j=0; j<k; j++){
			if(S[i+j]!=T[j]){
				tmp=0;
				break;
			}
		}
		if(tmp==1){
		printf("Yes\n");
		return 0;
		}
	}
	printf("No\n");
	
	return 0;
}


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

 
int main() {
  int64_t i,x,year,money=100,f=0;
  cin >> x;
  for(year=0;money<x;year++){
    money+=money/100;
    //cout << money << endl;
  }
  cout << year << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl "\n";
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,bool> pllb;
typedef pair<pair<ll,ll>,ll> plll;
 
const ll N = 1e5+10;
const ll INF = 1e9;
const ll N2 = 1010;
const int MOD = 1e9+7;

int n;
int arr[N][3];

int memo[N][3];

int dp(int idx,int lastAct)
{
    if(idx==n)
        return 0;
    int &ret = memo[idx][lastAct];
    if(~ret)
        return ret;
    ret = 0;
    if(lastAct==0)
        ret = max(arr[idx][1]+dp(idx+1,1),arr[idx][2]+dp(idx+1,2));
    if(lastAct==1)
        ret = max(arr[idx][0]+dp(idx+1,0),arr[idx][2]+dp(idx+1,2));
    if(lastAct==2)
        ret = max(arr[idx][0]+dp(idx+1,0),arr[idx][1]+dp(idx+1,1));
    return ret;
}

int main()
{
	fastio
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif

    memset(memo,-1,sizeof memo);
    cin >> n;
	for(int i = 0; i < n; i++)
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    cout << max(dp(0,0),max(dp(0,1),dp(0,2)));
}

Measured memory_bytes: 7296
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		sc.close();
		if (a <= b) {
			System.out.println(a);
		} else {
			System.out.println(a - 1);
		}
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	for (int i = 0; i < n; i++){
		cin >> v[i];
	}

	ll ans = 0;
	for (int all = 0; all <= min(k, n); all++){
		for (int i = 0; i <= all; i++){
			int l = i, r = all - i;
			int rem = k - all;
			priority_queue<int, vector<int>, greater<int> > que;
			for (int j = 0; j < l; j++){
				que.push(v[j]);
			}
			for (int j = 0; j < r; j++){
				que.push(v[n-j-1]);
			}
			ll tmp = 0;
			while (!que.empty()){
				if (que.top() < 0 && rem > 0){
					rem--;
					que.pop();
				}else{
					tmp += que.top();
					que.pop();
				}
			}
			ans = max(ans, tmp);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <queue>

using namespace std;

int main()
{
        // 整数の入力
    long long N,K,xi,yi,zi;
    cin >> N>> K;
    vector<long long> V;
    long long *maxs = new long long[101];
    fill(maxs,maxs+101,0);
    for (int i = 0;i< N;i++){
        long long temp;
        cin >> temp;
        V.push_back(temp);
    }

    for (int right = 0; right <= N;right++){
        for(int left = 0; left <= N - right;left++){
            vector<long long> current_takes;
            for(int i = 0; i <left;i++){
                current_takes.push_back(V[i]);
            }
            for(int i = 0; i <right;i++){
                current_takes.push_back(V[N-1-i]);
            }
            sort(current_takes.begin(),current_takes.end(),greater<long long>() );
            long long total = 0;
            for(int i = 0;i < right + left;i++){
                total += current_takes[i];
                if(total > maxs[2 * (right+left) - 1 -i]){
                    maxs[2 * (right+left) - 1 -i] = total;
                }
            }
        }
    }
    // long long maximum = 0;
    // for (int i = 0;i<= 2 *N;i++){
    //     cout << i << ":" << maxs[i] << endl;
    // }
    cout << *max_element(maxs,maxs+K+1) << endl;
    return 0;
}

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

using vec = complex<double>;
using line = pair<vec,vec>;
const double eps = 0.0000001;

double inner_product(vec u,vec v){
    return real(u*conj(v));
}
double cross_product(vec u,vec v){
    return imag(conj(u)*v);
}

double norm(vec& u){
    return abs(u);
}

vec projection(line l,vec p){//p???l???????°???±
    vec s=l.first, t=l.second;
    double k = inner_product(t-s,p-s)/inner_product(t-s,t-s);
    return (1.0-k)*s+k*t;
}

vec reflection(line l,vec p){
    return 2.0*projection(l,p)-p;
}

int ccw(vec& a, vec& b, vec& c){
    vec ab = b-a, ac = c-a;
    double o = cross_product(ab,ac);
    if(o>0) return 1; //CCW
    if(o<0) return -1; //CW
    if(inner_product(ab,ac)<0){
        return 2; //C-A-B
    }else{
        if(inner_product(ab,ab)<inner_product(ac,ac)){
            return -2; //A-B-C
        }else{
            return 0; //A-C-B
        }
    }
}

int main(void){
    double x,y;
    cin >> x >> y;
    vec p0(x,y);
    cin >> x >> y;
    vec p1(x,y);
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        cin>>x>>y;
        vec p2(x,y);
        switch(ccw(p0,p1,p2)){
            case 1:
                cout << "COUNTER_CLOCKWISE" << endl;
                break;
            case -1:
                cout << "CLOCKWISE" << endl;
                break;
            case 2:
                cout << "ONLINE_BACK" << endl;
                break;
            case -2:
                cout << "ONLINE_FRONT" << endl;
                break;
            case 0:
                cout << "ON_SEGMENT" << endl;
                break;
            default:
                ;
        }
    }
    return 0;
}

Measured memory_bytes: 3216
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=2e5+5;
int a[maxn];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=k+1;i<=n;i++)
    {
        int cur=a[i],pre=a[i-k];
        if(cur>pre)
            puts("Yes");
        else puts("No");
    }
    return 0;
}


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

int main() {
  string s; cin >> s;
  
  bool ans = true;
  vector<bool> alpha(26, false);
  
  for (int i = 0; i < s.size(); i++) {
    if (alpha[s[i] - 'a']) {
      ans = false;
      break;
    } else {
      alpha[s[i] - 'a'] = true;
    }
  }
  
  if (ans) cout << "yes" << endl;
  else cout << "no" << endl;
}

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

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

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

  cout << "Good";
}


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

typedef unsigned long long int ll; 
#define MOD 1000000007
#define rep(i,n) fp(i,0,n)  
#define fp(i,a,b) for(ll i=(a);i<(b);++i)
#define fn(i,a,b) for(ll i=(a);i>(b);i--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define ff first
#define ss second
typedef pair<ll, ll> pll; 
typedef vector<pll> vpll;
typedef vector<ll> vll;
#define rs(t) string t;cin>>t
#define ri(t) int t;cin>>t
#define rll(t) long long int t;cin>>t
#define mk make_pair
#define pb push_back
#define po pop_back




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

  cout << (n*(n-1))/2 << endl;
  return 0;
}

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

int main(){
    string str1,str2;
    cin >> str1 >> str2;
    if(str1.size()>str2.size()){
        cout << "GREATER" << "\n";
        return 0;
    }
    else if(str1.size()<str2.size()){
        cout << "LESS" << "\n";
        return 0;
    }
    else{
        for(int i=0;i<str1.size();i++){
            if((str1[i] - '0')>(str2[i] - '0')){
                cout << "GREATER" << "\n";
                break;
            }
            if((str1[i] - '0')<(str2[i] - '0')){
                cout << "LESS" << "\n";
                break;
            }
            if(i==str1.size()-1 && str1[i]==str2[i]){
                cout << "EQUAL" << "\n";
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#pragma GCC diagnostic error "-std=c++11"
#define ll long long
#define mp make_pair
using namespace std;
int a,b,c,d,t;
inline bool ok(int x){
	int Tb=x/(t+1),Ta=x-Tb;
	return bool(b-Tb>1ll*(a-Ta)*t);
}
int main(){
	int i,j,T,q;
	scanf("%d",&q);
	for(T=0;T<q;++T){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		t=(max(a,b)-1)/(min(a,b)+1)+1;
		int l=0,r=a+b,md,ans=a+b+1;
		while(l<=r){
			md=l+r>>1;
			if(ok(md)) r=md-1,ans=md;
			else l=md+1;
		}
		for(i=c;i<=min(ans,d);++i) putchar(i%(t+1)?'A':'B');
		for(i=max(c,ans+1);i<=d;++i) putchar((a+b-i+1)%(t+1)?'B':'A');
		putchar('\n');
	}
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int x[n],X[n];
	for(int i=0;i<n;i++){
		cin>>x[i];
		X[i]=x[i];
	}
	sort(X,X+n);
	int a=X[n/2-1],b=X[n/2];
	for(int i=0;i<n;i++){
		if(x[i]<b) cout<<b<<endl;
		else cout<<a<<endl;
	}
	return 0;
}


Measured memory_bytes: 3712
fun main(args: Array<String>) {
    val n = readInt()
    val a = readIntList()

    val normalDist = a.foldIndexed(0) {index: Int, prev: Int, current: Int ->
        when (index) {
            0 -> Math.abs(current)
            else -> prev + Math.abs(a[index - 1] - current)
        }
    } + Math.abs(a.last())

    for (i in 0 until n) {
        when(i) {
            0 -> {
                println(normalDist - Math.abs(a[0]) - Math.abs(a[0] - a[1]) + Math.abs(a[1]))
            }
            n - 1 -> {
                val element = a[a.lastIndex - 1]
                println(normalDist - Math.abs(a.last()) - Math.abs(a.last() - element) + Math.abs(element))
            }
            else -> {
                val prev = a[i - 1]
                val current = a[i]
                val next = a[i + 1]
                println(normalDist - Math.abs(current - prev) - Math.abs(next - current) + Math.abs(next - prev))
            }
        }
    }
}

fun printYesOrNo(flag: Boolean) {
    println(if (flag) "Yes" else "No")
}

fun readIntList(): List<Int> = readLine()!!.split(' ').map { it.toInt() }

fun readInt(): Int = readLine()!!.toInt()

fun err(print: Any) {
    System.err.println(print)
}

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

int main() {
	long long N, M;
	cin >> N >> M;
	vector<int> Yakusu;
	for (int i = 1; i <= (int)sqrt(M) + 1; i++) {
		if (M % i == 0) {
			Yakusu.push_back(i);
			Yakusu.push_back(M / i);
		}
	}
	sort(Yakusu.begin(), Yakusu.end(), greater<int>());
	for (int y : Yakusu) {
		if (N * y > M) continue;
		cout << y << endl;
		return 0;
	}
}


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

int main(){
  int a[100][100] = {{0}};
  int b[100][100] = {{0}};
  long c[100][100] = {{0}};
  int n,m,l;

  cin >> n >> m >> l;
  for(int in = 0; in < n; in++){
    for(int jm = 0; jm < m; jm++){
      cin >> a[in][jm];
    }
  }
  for(int jm = 0; jm < m; jm++){
    for(int kl = 0; kl < l; kl++){
      cin >> b[jm][kl];
    }
  }
  for(int jm = 0; jm < m; jm++){
    for(int kl = 0; kl < l; kl++){
      cin >> b[jm][kl];
    }
  }
  for(int in = 0; in < n; in++){
    for(int jm = 0; jm < m; jm++){
      for(int kl = 0; kl < l; kl++){
        c[in][kl] += a[in][jm] * b[jm][kl];
      }
    }
  }
  for(int in = 0; in < n; in++){
    for(int jl = 0; jl < l; jl++){
      cout << c[in][jl];
      if(jl != l-1){
        cout << " ";
      }
    }
    cout << endl;
  }
}



Measured memory_bytes: 3264