akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <inttypes.h>
#include <string.h>

double notomamiko(uint64_t sinntasu) {
	uint64_t hayamin = sinntasu;
	uint64_t kugyu = 0;
	while (hayamin > 0) {
		kugyu += hayamin % 10;
		hayamin /= 10;
	}
	return (double)sinntasu / kugyu;
}

uint64_t get_next_9(uint64_t mimorinn) {
	char horieyui[99];
	size_t l;
	uint64_t delta = 10;
	snprintf(horieyui, sizeof(horieyui), "%"PRIu64, mimorinn);
	l = strlen(horieyui) - 1;
	while (l > 0 && horieyui[l] == '9') {
		l--;
		delta *= 10;
	}
	return mimorinn / delta * delta + (delta - 1);
}

int main(void) {
	uint64_t K, i;
	uint64_t inorinn = 1;
	uint64_t sikachann;
	if (scanf("%"SCNu64, &K) != 1) return 1;
	for (i = 0; i < K; i++) {
		printf("%"PRIu64"\n", inorinn);
		inorinn++;
		while (notomamiko(inorinn) > notomamiko(sikachann = get_next_9(inorinn))) {
			inorinn = sikachann;
		}
	}
	return 0;
}

/*
i桁の整数kについて
例えばi=3
100 <= k <= 999
S(100)=1 <= S(k) <= S(999)=27

(10**(k-1))/(9*i) <= k/S(k) <= (10**k)-1

-----

予想 : 1桁or最初の位以外がすべて9 ←→ すぬけ数
この予想はハズレ

-----

予想：桁の数字を下から9にしていき、以上なら出力

*/

/* 実験プログラム → gnuplot */
#if 0
#include <stdio.h>

int S(int n) {
	int r = 0;
	while (n > 0) {
		r += n % 10;
		n /= 10;
	}
	return r;
}

int main(void) {
	int i;
	printf("i     S(i) i/S(i)\n");
	for (i = 1; i <= 10000; i++) {
		int si = S(i);
		printf("%5d %4d %9.3f\n", i, si, (double)i / si);
	}
	return 0;
}
#endif

/* 新実験プログラム */
#if 0
#include <stdio.h>

int S(int n) {
	int r = 0;
	while (n > 0) {
		r += n % 10;
		n /= 10;
	}
	return r;
}

int si[100001];
double isi[100001];
double min[100001];
int min_index[100001];

int main(void) {
	int i;
	for (i = 1; i <= 100000; i++) {
		si[i] = S(i);
		isi[i] = (double)i / si[i];
	}
	min[100000] = isi[100000];
	min_index[100000] = 100000;
	for (i = 99999; i >= 1; i--) {
		min[i] = min[i + 1];
		min_index[i] = min_index[i + 1];
		if (isi[i] < min[i]) {
			min[i] = isi[i];
			min_index[i] = i;
		}
	}
	printf("i      S(i) i/S(i) min      min_index maybe_sunuke\n");
	for (i = 1; i <= 100000; i++) {
		printf("%6d %4d %9.3f %9.3f %6d    %s\n",
			i, si[i], isi[i], min[i], min_index[i], isi[i] <= min[i] ? "YES!!!!!!!" : "NO");
	}
	return 0;
}
#endif


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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<string> cand = {};
    string tmp;
    for(int i=0; i<N; ++i){
        cin >> tmp;
        cand.push_back(tmp);
    }
    sort(cand.begin(), cand.end());
    decltype(cand)::iterator result = unique(cand.begin(), cand.end());
    cand.erase(result, cand.end());
    cout << cand.size() << endl;

    return 0;
}

Measured memory_bytes: 11600
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int mod=998244353;
int main(){
    ll n;cin>>n;
    ll ans=0;
    ll ma=0;
    rep(i,n){
        ll a;cin>>a;
        if(ma+1==a){
            ma=a;
            continue;
        }else{
            ans+=(a-1)/(ma+1);
            ma=max(ma,1LL);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
#define MAX 20000
typedef pair < int , int > Pi;
typedef pair < int , Pi > Pii;
#define fr first
#define sc second
int main(){
  int n, m;
  Pii tsm[MAX];
  while(cin >> n >> m , n){
    for(int i = 0 ; i < m ; i++ ){
      cin >> tsm[i].fr >> tsm[i].sc.fr >> tsm[i].sc.sc;
      tsm[i].sc.fr--,tsm[i].sc.sc--;
    }
    sort( tsm, tsm + m);
    bool c[MAX] = {};
    c[0] = true;
    int ret = 1;
    for(int i = 0 ; i < m ; i++ ){
      if(c[tsm[i].sc.fr] && !c[tsm[i].sc.sc]++) ret++;
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1424
#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, k, ans = 1e+9;
    cin >> n >> k;
    vector<int> x(n);
    rep(i,n) cin >> x.at(i);
    rep(j, n - k + 1){
        int l = x[j];
        int r = x[j + k - 1];
        int tmp = min(abs(l) + abs(r-l), abs(r) + abs(r-l));
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    // 整数の入力
    int N,A;
    cin >> N ;
    cin >> A ;
    // 出力

    int flag = 0;
    int total = 0;
    for(int i=0;i<21;i++){
        for(int j=0;j<A+1;j++){
	    total = 500*i + j;
	    if(total == N){
	        flag += 1;
	    }
	}
    }
    if(flag>0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

#define foru(i, l, r) for (register int i = l; i <= r; i++)
#define ford(i, r, l) for (register int i = r; i >= l; i--)

int K, mp[505][505], N;

int main() {
  //  freopen("c.in", "r", stdin);
  //  freopen("c.out", "w", stdout);
  scanf("%d", &K);
  if (K <= 500) {
    N = K;
    for (int col = 1; col <= N; col++)
      for (int i = 0, j = col - 1; i < N; i++, j = (j + N - 1) % N)
        mp[i][j] = col;
    printf("%d\n", N);
    for (int i = 0; i < N; i++)
      for (int j = 0; j < N; j++) printf("%d%c", mp[i][j], " \n"[j == N - 1]);
  } else {
    N = 500;
    for (int col = 1; col <= N; col++)
      for (int i = 0, j = col - 1; i < N; i++, j = (j + N - 1) % N)
        mp[i][j] = col;
    for (int col = 1; N + col <= K; col++)
      for (int i = 0, j = col - 1; i < N; i++, j = (j + N - 1) % N)
        if (i & 1) mp[i][j] = N + col;
    printf("%d\n", N);
    for (int i = 0; i < N; i++)
      for (int j = 0; j < N; j++) printf("%d%c", mp[i][j], " \n"[j == N - 1]);
  }
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  vector<i64> a(n);
  for (i64 i = 0; i < n; i++)
    cin >> a[i];
  double tmp = 0;
  for (i64 i = 0; i < n; i++)
    tmp += 1.0 / a[i];
  cout << fixed << setprecision(10) << 1.0 / tmp << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    x, a = map(int, input().split())
    print(0 if x < a else 10)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


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


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29292
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    X = int(input())

    p = []
    def pow5(n):
        nonlocal p
        if len(p) > n:
            return p[n]
        ans = pow(n,5)
        p += ans,
        return ans

    a = 0
    b = 0
    while True:
        if abs(X) + pow5(b) == pow5(a) or abs(X) - pow5(b) == pow5(a) :
            a5 = pow5(a)
            b5 = pow5(b)
            if X == a5 - b5:
                print(a,b)
            elif X == a5 + b5:
                print(a, -b)
            elif X == -a5 - b5:
                print(-a, b)
            else:
                print(-a, -b)
            return
        while abs(X) + pow5(b) > pow5(a):
            a += 1
            if abs(X) + pow5(b) == pow5(a) or abs(X) - pow5(b) == pow5(a) :
                a5 = pow5(a)
                b5 = pow5(b)
                if X == a5 - b5:
                    print(a,b)
                elif X == a5 + b5:
                    print(a, -b)
                elif X == -a5 - b5:
                    print(-a, b)
                else:
                    print(-a, -b)
                return
        a = 0
        b += 1

main()


Measured memory_bytes: 8972
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
// in fenwick always use size as 1000010
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,k;cin >> n >> m >> k;ll a[n];ll b[m];
    for (int i = 0; i < n; ++i)
    {
    	cin >> a[i];
    	if(i)a[i]+=a[i-1];
    }
    for (int i = 0; i < m; ++i)
    {
    	cin >> b[i];if(i)b[i]+=b[i-1];
    }
    ll ans=0;
    auto it=upper_bound(b,b+m,k);
    if(it!=b)
    {
    	it--;ans=max(ans,it-b+1);
    }
    for (int i = 0; i < n; ++i)
    {
    	ll d=a[i];
    	ll dans=i+1;
    	if(a[i]>k){ans=max(ans,i);break;}
    	auto it=upper_bound(b,b+m,k-a[i]);
    	ans=max(ans,dans+it-b);
    }
    cout << ans;
    }

Measured memory_bytes: 6740
#include<bits/stdc++.h>
using namespace std;
int mochi[101];
int main()
{
	int ans,i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&mochi[i]);
	}
	sort(mochi+0,mochi+n);
	ans=unique(mochi,mochi+n)-mochi;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,K=map(int,input().split())
    h=[int(input()) for _ in range(N)]+[INF]*K
    h.sort()
    ans=INF
    for i in range(N):
        ans=min(ans,h[i+K-1]-h[i])
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 47324
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20)
#define int long long
#define double long double
#define gcd __gcd
#define lcm(a, b) (a / gcd(a, b) * b)
#define factorial(a) (a < 2 ? 1 : factorial(a - 1) * a)
#define summation(a) (a < 1 ? 0 : (a * a + a) / 2)
const int INF = 1e18, MOD = 1e9 + 7;

vector<int> fact;

void modinit(int n) {
    fact.push_back(1);
    int now = 1;
    for (int i = 1; i <= n; i++) {
        now *= i;
        now %= MOD;
        fact.push_back(now);
    }
}

int modpow(int x, int n) {
    return n < 1 ? 1 : modpow(x * x % MOD, n / 2) * (n % 2 ? x : 1) % MOD;
}

int modcomb(int n, int r) {
    if (n < r) return 0;
    return fact[n] * modpow(fact[n - r], MOD - 2) % MOD * modpow(fact[r], MOD - 2) % MOD;
}

int n, k;

signed main() {
    INCANT;
    cin>>n>>k;
    int a[1111];
    for (int i = 0; i < n; i++) {
        cin>>a[i];
    }
    sort(a, a + n);
    int res = 0;
    for (int i = 0; i < k; i++) {
        res += a[i];
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3624
package main

import (
	"fmt"
)

func main() {
	k, s := 0, ""
	fmt.Scanf("%d", &k)
	fmt.Scanf("%s", &s)

	if len(s) > k {
		fmt.Println(s[:k] + "...")
	} else {
		fmt.Println(s)
	}
}


Measured memory_bytes: 1816
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))

#define INF 1000000000

int array_min_max(int* p, int n,bool f)  //f: true→min false→max
{
	int tmp;

	if (f)
		tmp = INF;
	else
		tmp = 0;

	for (int i = 0; i < n; i++)
	{
		if (f)
		{
			if (p[i] < tmp)
				tmp = p[i];
		}
		else
		{
			if (p[i] > tmp)
				tmp = p[i];
		}
	}
	return tmp;
}

int main()
{
	int a[5];
	int k;

	for (int i = 0; i < 5; i++)
		scanf("%d", &a[i]);

	scanf("%d", &k);

	if (a[4] - a[0] > k)
	{
		printf(":(\n");
		return 0;
	}

	//for (int i = 0; i < 4; i++)
	//{
	//	if (a[i + 1] - a[i] > k)
	//	{
	//		printf(":(\n");
	//		return 0;
	//	}
	//}
	printf("Yay!\n");

}

Measured memory_bytes: 128
#include <stdio.h>
#define MAX 101


int main(void)
{
  int i, j, n, t=0, hikaku=0, delmax, delmin, sum=0;
  int heikin;
  int point[MAX];


  while(t!=1)
    {
      scanf("%d",&n);
      
      if(n==0)
	t = 1;

      else
	{
	  for(i=0;i<n;i++)
	    {
	      scanf("%d",&point[i]);
	    }
	  
	  /*CHECK!!!
	    for(i=0;i<=n-1;i++)
	    {
	    printf("point[%d] %d\n",i,point[i]);
	    }
	  */
	  
	  for(i=0;i<=n-1;i++)
	    {
	      if(hikaku<=point[i])
		{
		  hikaku = point[i];
		  delmax = i;
		}
	    }
	  hikaku = 1001;
	  for(i=0;i<=n-1;i++)
	    {
	      if(hikaku>=point[i])
		{
		  hikaku = point[i];
		  delmin = i;
		}
	    }
	  
	  for(i=0;i<=n-1;i++)
	    {
	      sum = sum + point[i];
	    }
	  
	  sum = sum - (point[delmin] + point[delmax]);
	  //printf("%d\n",sum);

	  if(n-3==0)
	    {
	      heikin = sum;
	    }
	  else
	    {
	      heikin = sum / (n-2);
	    }

	  printf("%d\n",heikin);
	  hikaku = 0;
	  delmax = 0;
	  delmin = 0;
	  sum = 0;
	}
    }
  return 0;
}

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

#define ll long long

using namespace std;

ll gcd(ll a, ll b){
  if(a < b) swap(a, b);
  
  ll r = a % b;
  if(r == 0) return b;
  else return gcd(b, r);
}

int main(){
  int n;
  cin >> n;
  
  ll t, a;
  cin >> t >> a;
  ll g = gcd(t, a);
  t /= g;
  a /= g;
  
  for(int i = 1; i < n; i++){
    ll t_in, a_in;
    cin >> t_in >> a_in;
    
    g = gcd(t_in, a_in);
    t_in /= g;
    a_in /= g;
    
    ll m = max(((t - 1) / t_in + 1), ((a - 1) / a_in + 1));
    t = m * t_in;
    a = m * a_in;
  }
  
  cout << t + a << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;
 
#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)
 
const int N=3e5+50,M=1<<18,P=1e9+7; 
 
int n,m,p[N],vis[N],col[N];
vector<int> g[N]; 
 
bool fail;
void dfs(int v,int c=0){
	col[v]=c;
	for(int d:g[v]){
		if(col[d]==-1){
			dfs(d,c^1);
		}else{
			if((col[d]^col[v])!=1)fail=true;
		}
	}
}
 
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	//freopen("dat.in","r",stdin); 
	//freopen("my.out","w",stdout); 
#endif
	scanf("%d%d",&n,&m); 
	rep(i,1,n){
		p[i]=i;
	}
	rep(i,1,m){
		int u,v;
		scanf("%d%d",&u,&v); 
		g[u].pb(v),g[v].pb(u); 
	}
	long long x=0,y=0,z=0,ans=0;
	memset(col,-1,sizeof(col)); 
	rep(i,1,n){
		if(col[i]==-1){
			fail=false,dfs(i); 
			if(g[i].empty())++z;
			else{
				x+=!fail;
				y+=fail;
			}
		}
	}
	ans+=z*n+x*x*2+2*x*y+y*y+(n-z)*z;
	printf("%lld\n", ans);
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
#define MP make_pair
#define PB push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
#define mod 1000000007
int n;
vector <int> gp[100005];
int c[100005];
int va[100005];
int value;
int dfs(int i,int par)
{
	if(gp[i].size()==1)
		return 0;
	// cout<<i<<" "<<c[value]<<endl;
	va[i]=c[value];
	value--;
	for(int j: gp[i])
	{
		if(j!=par)
		{
			dfs(j,i);
		}
	}
	return 0;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	f(i,0,n-1)
	{
		int a,b;
		cin>>a>>b;
		gp[a].push_back(b);
		gp[b].push_back(a);
	}
	f(i,1,n+1)
	{
		cin>>c[i];
		// c[i].ss=i;
	}
	sort(c+1,c+n+1);
	int su=0;
	f(i,1,n)
	{
		su+=c[i];
	}
	cout<<su<<endl;
	int val=1;
	f(i,1,n+1)
	{
		if(gp[i].size()==1)
		{
			va[i]=c[val];
			val++;
		}
		else if(gp[i].size()==0)
		{
			va[i]=c[val];
			val++;
		}
	}
	f(i,1,n+1)
	{
		if(gp[i].size()>1)
		{
			value=n;
			dfs(i,0);
			break;
		}
	}
	f(i,1,n+1)
	{
		cout<<va[i]<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3456
a, b, c = map(int, input().split())		# 5 7 2

l = [a,b,c]
l.sort()
a = l[0]
b = l[1]
c = l[2]

c = c - a
b = b - a
a = a - a

#print(a,b,c)

ans = 0
i = c - b

b += i
a += i
ans += i

#print(a,b,c, ans)

i = (b-a)//2

a += i*2
ans += i

#print(a,b,c, ans)

if a!=b:
	ans += 2

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <climits>

int count(const int n, const int k, const int sum) {
	static std::vector<std::vector<std::vector<int>>> memo(21, std::vector<std::vector<int>>(11, std::vector<int>(156, -1)));
	if (k == 0) return (sum == 0) ? 1 : 0;
	if (n == 0) return 0;
	if (sum <= 0) return 0;
	if (memo[n][k][sum] == -1) {
		memo[n][k][sum] = count(n - 1, k, sum);
		if (sum >= n) {
			memo[n][k][sum] += count(n - 1, k - 1, sum - n);
		}
	}
	return memo[n][k][sum];
}
int main() {
	while (true) {
		int n, k, s; std::cin >> n >> k >> s;
		if (n == 0) return 0;
		std::cout << count(n, k, s) << std::endl;
	}
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
int main(){
  int n;
  cin >> n;
  double ans=0;
  for(int i=0;i<n;i++){
    double a;
    string s;
    cin >> a >> s;
    if(s=="JPY")  ans+=a;
    else ans+=380000.0*a;
  }
  output(ans,10);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int x, i, j, flag;
  cin >> x;
  for(i=x; ; i++){
    flag=0;
    for(j=2; j*j<=i; j++)
      if(i%j==0){
        flag++;
        break;
      }
    if(flag==0){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N;
	string S, T;
	cin >> N;
	cin >> S >> T;

	string ans;
	for(int i=0; i<N; i++){
		ans += S[i];
		ans += T[i];
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
// copied
#include<bits/stdc++.h>
#define ll long long
#define pa pair<ll,int>
#define mo 1000000007
#define N 100005
using namespace std;
ll ds[N],dt[N],ways[N],wayt[N];
struct edge{int to,next,v;}e[N*4];
int head[N],vis[N];
int n,m,s,t,tot,ans;
priority_queue<pa > q;
void add(int x,int y,int v){
	e[++tot]=(edge){y,head[x],v};
	head[x]=tot;
}
void dijk_heap(int S,ll *dis,ll *way){
	for (int i=1;i<=n;i++)
		dis[i]=1e18,vis[i]=0,way[i]=0;
	dis[S]=0; way[S]=1;
	while (!q.empty()) q.pop();
	q.push(pa(0,S));
	while (!q.empty()){
		int x=q.top().second; q.pop();
		if (vis[x]) continue; vis[x]=1;
		for (int i=head[x];i;i=e[i].next){
			ll tmp=dis[x]+e[i].v;
			if (dis[e[i].to]>tmp){
				dis[e[i].to]=tmp;
				way[e[i].to]=0;
				q.push(pa(-tmp,e[i].to));
			}
			if (dis[e[i].to]==tmp)
				way[e[i].to]=(way[e[i].to]+way[x])%mo;
		}
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&s,&t);
	for (int i=1;i<=m;i++){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		add(x,y,z);
		add(y,x,z);
	}
	dijk_heap(s,ds,ways);
	ans=1ll*ways[t]*ways[t]%mo;
	dijk_heap(t,dt,wayt);
	for (int i=1;i<=n;i++)
		if (ds[i]*2==ds[t]&&ds[i]+dt[i]==ds[t])
			ans=(ans+mo-1ll*ways[i]*ways[i]%mo*wayt[i]%mo*wayt[i]%mo)%mo;
	for (int x=1;x<=n;x++)
		for (int i=head[x];i;i=e[i].next)
			if (ds[x]+e[i].v+dt[e[i].to]==ds[t])
				if (ds[x]*2<ds[t]&&dt[e[i].to]*2<ds[t])
					ans=(ans+mo-1ll*ways[x]*wayt[e[i].to]%mo*ways[x]%mo*wayt[e[i].to]%mo)%mo;
	printf("%d\n",ans);
}


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

const int N = 500 + 5;
int edge[N][N];

void gao(int a, int b,int cnt) {
    if(a>=b)
    return;
    int ls=a,le=(a+b)/2;
    int rs=le+1,re=b;
    for(int i=ls;i<=le;i++)
        for(int j=rs;j<=re;j++)
        edge[i][j]=edge[j][i]=cnt;
    gao(ls,le,cnt+1);
    gao(rs,re,cnt+1);
}

int main() {
    int n;
    cin>>n;
    gao(1, n,1);
    for(int i=1;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            if(j!=i+1)
            cout<<" ";
            cout<<edge[i][j];
        }
        
        cout<<endl;
    }
}

Measured memory_bytes: 1536
# -*- coding: utf-8 -*-
import sys
from math import gcd
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
A=list(map(int,input().split()))
ans=A[0]
for x in A[1:]:
    ans=gcd(ans,x)
print(ans)

Measured memory_bytes: 86372
#include<iostream>

using namespace std;

int n;
long long ans=0;
long long a[105];
char ch,my[100];

int main()
{
	cin>>n;
	getchar();
	for(int i=1;i<=n;i++)
	{
		cin>>my;
		ch=my[0];
		if(ch=='M')a[1]++;
		if(ch=='A')a[2]++;
		if(ch=='R')a[3]++;
		if(ch=='C')a[4]++;
		if(ch=='H')a[5]++;
		
	}
	

	ans+=a[1]*a[2]*a[3];
	ans+=a[1]*a[2]*a[4];
	ans+=a[1]*a[2]*a[5];
	ans+=a[1]*a[3]*a[4];
	ans+=a[1]*a[3]*a[5];
	ans+=a[1]*a[4]*a[5];
	ans+=a[2]*a[3]*a[4];
	ans+=a[2]*a[3]*a[5];
	ans+=a[2]*a[4]*a[5];
	ans+=a[3]*a[4]*a[5];
	
	
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P  = pair <int, int>;

#define rep(i, n)     for (int i = 0; i < (int) (n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp)   for (auto &i : mp)

const int INF = 1001001001;

int main()
{
  int x, n;
  cin >> x >> n;
  vector <int> p(n);
  rep(i, n) cin >> p[i];
  vector <int> elim_100(102);
  repr(i, 1, 102) {
    elim_100[i] = i;
    rep(j, n) {
      // std::cout << p[j] << '\n';
      if (i == p[j]) {
        elim_100[i] = 1000;
      }
    }
    // std::cout << elim_100[i] << '\n';
  }
  int dif_prv = INF;
  int dif     = 102;
  ll  ans     = 0;
  repr(i, 0, 102) {
    dif = abs(elim_100[i] - x);
    // std::cout << dif << '\n';
    if (dif_prv > dif) {
      ans     = i;
      dif_prv = dif;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
	int h, w;
	cin >> h >> w;
	string s[h];
	for(int i = 0; i < h; i++) cin >> s[i];
	for(int i = 0; i < h * 2; i++){
		for(int j = 0; j < w; j++) cout << s[i / 2][j];
		cout << endl;
	}
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long ans=-1e18;
        ans=max(ans,a*c);
        ans=max(ans,a*d);
        ans=max(ans,b*c);
        ans=max(ans,b*d);

        cout<<ans<<endl;
    /*
    //同符号
    if(a*b>=0 && c*d>=0){
        if(a*c>0){
        //同符号
        cout<<max(abs(a),abs(b))*max(abs(c),abs(d))<<endl;
        }
        else{
        //答えが0以下確定
        cout<<min(abs(a),abs(b))*min(abs(c),abs(d))<<endl;
        return 0;
        }
    }
    else{
        l
    }
    */
    return 0;

}
/*


*/


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


using namespace std;

int main() {
  
  int N, ans;
  cin >> N;
  ans = 0;
  
  for (int i = 0 ; i < N ; i++){
    
    int l,r;
    cin >> l >> r;
    
    ans += r - l + 1;
    
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(void){

	int y,x;
	cin >> y >> x;

	string a(2+x,'#');

	cout << a << endl;

	for(int i = 0; i < y; i++){
		string s;
		cin >> s;
	
		cout << '#' << s << '#' << endl;;
	
	}

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(void){
    std::string S, a="", b="";
    int ans=0;
    std::cin >> S;

    for (char s: S){
        a += s;
        if (a != b){
            ++ans;
            b = a;
            a = "";
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3740
#include<stdio.h>
int main(void){
    int S;
    scanf("%d", &S);
    int upper, lower;
    upper = S / 100;
    lower = S % 100;

    if((0 < upper && upper <= 12) && (0 < lower && lower <= 12)){
        printf("AMBIGUOUS\n");
    }else if (!(0 < upper && upper <= 12) && (0 < lower && lower <= 12))
    {
         printf("YYMM\n");
    }else if ((0 < upper && upper <= 12) && !(0 < lower && lower <= 12))
    {
        printf("MMYY\n");
    }else
    {
        printf("NA\n");
    }
    
    
    

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI                acos(-1)
#define pb                emplace_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define forr(i, b, e)     for(ll i = b; i < e; i++)
#define forg(i, b, e, m)  for(ll i = b; i < e; i+=m)
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

typedef long long       ll;
typedef pair<ll, ll>  ii;
typedef vector<ll>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = ll(1e9 + 7);
#define tam 123456
struct Nodo
{   
    int x,y;
    ll p;
    Nodo(){}
};
ll dist[tam];
int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    int n,m,rest;
    int x,y,p;
    cin>>n>>m>>p;
    Nodo v;
    vector<Nodo> ar;
    forr(i,0,m)
    {
        cin>>v.x>>v.y>>v.p;
        v.p=p-v.p;
        ar.pb(v);
    }
    const ll inf=1e18;
    forr(i,0,tam)
        dist[i]=inf;
    dist[1]=0;
    forr(i,0,2*n)
    {
        forr(j,0,ar.size())
        {
            x=ar[j].x;y=ar[j].y;p=ar[j].p;
            if (dist[x]==inf)continue;
            if (i<n)
            {
                if (dist[y]>dist[x]+p)
                    dist[y]=max(-inf,min(inf,dist[x]+p));
            }
            else
            {
                if (dist[y]>dist[x]+p)
                {
                    dist[y]=-inf;
                }
            }
        }
    }
    if (dist[n]==-inf)
        cout<<-1<<"\n";
    else
        cout<<max(-dist[n],0ll)<<"\n";
}
// PLUS ULTRA!


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef pair<int, int> pii;
#define X first
#define Y second
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int conv(int n, vector<int> &a){
    vector<int>::iterator it = lower_bound(a.begin(), a.end(), n);
    if(*it == n){
        return 2*(it -a.begin()) +1;
    }
    return 2*(it -a.begin());
}

void dfs(int x, int y, vector<vector<bool> > &used, vector<vector<bool> > &field){
    if(used[x][y] || field[x][y]) return;
    used[x][y] = true;
    for(int i=0; i<4; i++){
        dfs(x+dx[i], y+dy[i], used, field);
    }
}

int main(){
    while(1){
        int w,h;
        cin >> w >> h;
        if(w==0) break;

        int n;
        cin >> n;
        vector<vector<pii> > a(n, vector<pii>(2));
        vector<int> x(2*n), y(2*n);
        for(int i=0; i<n; i++){
            cin >> a[i][0].X >> a[i][0].Y >> a[i][1].X >> a[i][1].Y;
            x[2*i] = a[i][0].X;
            x[2*i+1] = a[i][1].X;
            y[2*i] = a[i][0].Y;
            y[2*i+1] = a[i][1].Y;
        }
        x.push_back(0);
        y.push_back(0);
        x.push_back(w);
        y.push_back(h);
        sort(x.begin(), x.end());
        x.erase(unique(x.begin(), x.end()), x.end());
        sort(y.begin(), y.end());
        y.erase(unique(y.begin(), y.end()), y.end());

        vector<vector<bool> > field(2*x.size()+1, vector<bool>(2*y.size()+1, true));
        for(int i=1; i<(int)field.size()-1; i++){
            for(int j=1; j<(int)field[0].size()-1; j++){
                field[i][j] = false;
            }
        }
        for(int i=0; i<n; i++){
            int xa = conv(a[i][0].X, x);
            int ya = conv(a[i][0].Y, y);
            int xb = conv(a[i][1].X, x);
            int yb = conv(a[i][1].Y, y);
            for(int j=xa; j<=xb; j++){
                for(int k=ya; k<=yb; k++){
                    field[j][k] = true;
                }
            }
        }

        int count = 0;
        vector<vector<bool> > used(field.size(), vector<bool>(field[0].size(), false));
        for(int i=1; i<(int)field.size()-1; i++){
            for(int j=1; j<(int)field[0].size()-1; j++){
                if(used[i][j] || field[i][j]) continue;
                count++;
                dfs(i, j, used, field);
            }
        }
        cout << count << endl;
    }
    return 0;
}


Measured memory_bytes: 29000
// template.cpp {{{
#include <bits/stdc++.h>
using namespace std;

using lint = long long;
#define reps(i, a, n) for (lint i = (a); i < (lint)(n); ++i)
#define rep(i, n) reps(i, 0, n)
struct pre_{pre_(){cin.tie(0);ios::sync_with_stdio(0);}} pre__;
// }}}

signed main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  int res = 0;
  if (a < 0) {
    res += abs(a) * c + d;
    a = 0;
  }

  cout << res + (b - a) * e << endl;
}

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

int n;
int len;
int ans = 0;

void dfs(int i, int sum) {
  if (i > len) return;

  string s = to_string(sum);
  bool is3 = s.find('3') != string::npos;
  bool is5 = s.find('5') != string::npos;
  bool is7 = s.find('7') != string::npos;

  if ((is3 && is5 && is7) && sum <= n) {
    ans++;
  }

  dfs(i + 1, sum * 10 + 3);
  dfs(i + 1, sum * 10 + 5);
  dfs(i + 1, sum * 10 + 7);

  return;
}

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

  cin >> n;
  len = to_string(n).length();

  dfs(0, 0);

  cout << ans << endl;

  return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n, d, x;
    cin >> n >> d >> x;
    rep(i, n) {
        int a;
        cin >> a;
        x = x + (d - 1) / a + 1;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ddcc2020
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int t = 0;
            if(int.Parse(s[0]) == 1 && int.Parse(s[1]) == 1){
                t = 400000;
            }
            Console.WriteLine(t + Func(int.Parse(s[0])) + Func(int.Parse(s[1])));
        }
        static int Func(int s){
            if(s == 1){
                return 300000;
            }
            if(s == 2){
                return 200000;
            }
            if(s == 3){
                return 100000;
            }
            return 0;
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll; 
#define int ll   
#define long int
#define pb push_back
#define all int i=0; i<n; i++
#define INF 10000000000000000

#define Nirvana ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define mod 1000000007;

long expo(long base, long exp) 
{ 
    long t = 1L; 
    while (exp > 0)  
    { 
        if (exp % 2 != 0) 
            t = (t * base) ; 
  
        base = (base * base) ; 
        exp /= 2; 
    } 
    return t; 
} 
long powmod(long base, long exp) 
{ 
    long t = 1L; 
    base%=mod;
    while (exp > 0)  
    { 
        if (exp % 2 != 0) 
            t = (t * base)%mod ; 
  
        base = (base * base)%mod ; 
        exp /= 2; 
    } 
    return t%mod; 
} 

#define pow expo

int abso(int k){
	if(k < 0)return -1 * k;
	else return k;
}
int ceilo(int l, int r){
	return l/r + min(l%r, int(1));
}
int flooro(int l, int r){
	return l/r;
}
vector<int>f;
int Logn(int n,  int r) 
{ 
    return (n > r - 1) ? 1 + Logn(n / r, r) : 0; 
}
int n, q;
vector<int>g[200005];

int32_t main(){
	int n;
	cin>>n;
	int cnt[n];
	fill(cnt, cnt+n, 0);
	for(int i=0; i<n-1; i++){
		int x;
	
		cin>>x;	x--;
		cnt[x]++;
	}
	for(int i=0; i<n; i++)cout<<cnt[i]<<endl;
}

Measured memory_bytes: 9852
import math
import itertools
n = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

cnt_p, cnt_q = 1, 1
p = tuple(P)
q = tuple(Q)
for a in sorted(itertools.permutations(P)):
  if a != p:
    cnt_p += 1
  else:
    break
for b in sorted(itertools.permutations(Q)):
  if b != q:
    cnt_q += 1
  else:
    break
print(abs(cnt_p-cnt_q))

Measured memory_bytes: 8052
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int S = sc.nextInt();
			if ((n | S) == 0)
				break;
			int[] c = new int[101];
			for (int i = 0; i < n; i++) {
				c[sc.nextInt()]++;
			}
			int ans = 0;
			for (int i = 1; i < 101; i++) {
				for (int j = i; j < 101; j++) {
					if (i + j > S)
						if (i == j)
							ans += c[i] * (c[i] - 1) / 2;
						else
							ans += c[i] * c[j];
				}
			}
			System.out.println(ans);
		}
	}
}

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


int main() {
    ll N,A,B;
    cin>>N>>A>>B;
    if(A==0){
        cout<<0<<endl;
        return 0;
    }
    ll amari=N%(A+B);
    ll b=N/(A+B);
    if(amari<=A)cout<<A*b+amari<<endl;
    else cout<<A*b+A<<endl;

}

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


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

  vector<int> p(N + 1),n(N + 1,0);
  for(int i = 1;i <= N;i++) {
      cin >> p.at(i);
      if(p.at(i) != i) n.at(i)++;
  }

    int num = 0;
  for(int i = 1;i <=N;i++) {
      if(n.at(i) == 1) num++;
  }

  if(num <= 2) {
      cout << "YES" << endl;
  }else {
      cout << "NO" << endl;
  }
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define modulo 1000000007
typedef long long int ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

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

	ll ans(0);
	if(a-b > c) ans = 0;
	else ans = c - (a-b);

	cout << ans << endl;
	return 0;
}


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

int main (){
  int a,b,c;
  double s;
  cin>>a>>b>>c;
  s=(a+b+c)/2.0;
  double ret; 
  ret=sqrt(s*(s-a)*(s-b)*(s-c));
  cout<<ret;
  return 0;
}
  

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    int high;
    int low;
    int sa;
    
    public void solve(){
        Scanner sc = new Scanner(System.in);
        for(int i = 1;i <= 7;i ++){
			high = sc.nextInt();
			low = sc.nextInt();
			sa = high - low;
        	System.out.println(sa);
        }
    }
    
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17332
N, K = map(int, input().split())
S = input()
pre = S[0]
partl = [0]
for i, s in enumerate(S[1:], 1):
    if pre != s:
        partl.append(i)
    pre = s
partl.append(N)

ans = 0
for i in range(len(partl)):
    if partl[i] == N:
        break
    elif S[partl[i]] == '1':
      ans = max(ans, partl[min(i+K*2+1, len(partl)-1)] - partl[i])
    else:
      ans = max(ans, partl[min(i+K*2, len(partl)-1)] - partl[max(0, i-1)])

print(ans)

Measured memory_bytes: 46320
import java.util.*;
public class Main{
    public static void main(String args[]) {
        Scanner sc= new Scanner(System.in);
        int arr[] = new int[3];
        arr[0] =sc.nextInt();
        arr[1] =sc.nextInt();
        arr[2] =sc.nextInt();
        int ans = 0;
        Arrays.sort(arr);
        for(int i=1;i<3;i++){
            ans+=arr[i]-arr[i-1];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def is_even(S):
    if len(S) % 2 != 0:
        return False
    if S[: len(S) // 2] == S[len(S) // 2 :]:
        return True
    else:
        return False


def main():
    S = readline().strip()
    S = S[:-1]

    for w in range(len(S), 0, -1):
        for i in range(len(S) - w + 1):
            if is_even(S[i : i + w]):
                print(w)
                return

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 66484
H,W = map(int, input().split())
a = [0 for _ in range(H)]

for i in range(H):
	a[i] = '#'+input()+'#'
    
for i in range(H+2):
	if i == 0 or i == H+1:
		print('#'*(W+2))
	else:
		print(a[i-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb push_back;
#define sp " ";
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    int p,n,k,r=0;
    vector<int> a;
    cin>>n;
    rep(i,n){
        int s;
        cin>>s;
        a.push_back(s);
    }
    sort(a.begin(),a.end());
    p=a.at(a.size()-1);
    rep(i,n){
        int t=min(a.at(i),p-a.at(i));
        if(t>r){
            r=t;
            k=a.at(i);
        }
    }
    cout<<a.at(a.size()-1)<<" "<<k<<endl;
}

Measured memory_bytes: 892
#include <stdio.h>

int main()
{
  int A, B;
  scanf("%d %d", &A, &B);
  
  if(A+B <= A-B)
  {
    if(A-B > A*B)
    {
      printf("%d\n", A-B);
    }
  }
  else
  {
    if(A*B <= A+B)
    {
      printf("%d\n", A+B);
    }
  }

  if(A-B <= A*B)
  {
    if(A*B > A+B)
    {
      printf("%d\n", A*B);
    }
  }
  
  if( (A+B == A-B) && (A-B == A*B))
    printf("%d\n", A+B);
  
  return 0;
}

Measured memory_bytes: 128
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll maxi=0,f=0,mini=INF,sum=0;
    string str1,str2;
    ll h,w;
    ll n;
    ll a,b;
    cin>>str1;
    rep(i,str1.length()-2){
        ll s=stoll(str1.substr(i,3));
        mini=min(mini,abs(s-753));
    }
    cout<<mini<<endl;
    return 0;
}


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

int main(){
   int N;
   cin >> N;
   vector<int> A(N);
   for (int i=0; i<N; i++){
      cin >> A.at(i);
   }
   vector<int> A2(N);
   A2 = A;
   sort(A2.begin(), A2.end());
   for (int i=0; i<N; i++){
      if (A.at(i) == A2.at(N-1)){
         cout << A2.at(N-2) << endl;
      } else{
         cout << A2.at(N-1) << endl;
      }
   }
}



Measured memory_bytes: 3200
using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int K = int.Parse(input[1]);

        int[] p = new int[N];
        input = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++)
        {
            p[i] = int.Parse(input[i]);
        }

        List<int> tmp = new List<int>(p);
        tmp.Sort();

        int total = 0;
        for (int i = 0; i < K; i++)
        {
            total += tmp[i];
        }

        Console.WriteLine(total);
    }
}

Measured memory_bytes: 28176
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    bool flat = 0;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(i*j==n){
                flat =1;
            }
        }
    }
    if(flat==1)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define rep(i, a, n) for(int i = a; i < (n); i ++)
using namespace std;

int main()
{
  int64_t l0 = 2;
  int64_t l1 = 1;
  
  int n;
  cin >> n;
  
  if (n == 1)
  {
    cout << l1;
    return 0;
  }
  else if (n == 2)
  {
    cout << l1 + l0;
    return 0;
  }
  
  int64_t lk, lk1, lk2;
  lk = l0 + l1;
  lk1 = l1;
  lk2 = l0;
  int64_t tmp1;
  rep(i, 3, n + 1)
  {
    tmp1 = lk1;
    lk2 = lk1;
    lk1 = lk;
    lk = lk + tmp1;
  }
  
  cout << lk;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	@SuppressWarnings("resource")
	void run() {

		//
		// 画面入力
		//
		Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int displayedRate = sc.nextInt();

    	int innerRate = 0;
    	if(10 <= n){
    		innerRate = displayedRate;
    	}else{
    		innerRate = displayedRate + 100*(10-n);
    	}
    	System.out.println(innerRate);

	}
	
    public static void main(String[] args) {
        new Main().run();
    }
}

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

#define MAX_N 100

// string S = "?tc????";
// string T = "coder";
// string S = "??p??d??";
// string T = "abc";
string S;
string T;

int main() {
    cin >> S;
    cin >> T;
    int target_index = -1;

    // int tmp = S.find(T);
    // if (tmp >= 0) {
    //     for (int i = 0; i < S.length(); i++) {
    //         if (S[i] == '?') {
    //             cout << 'a';
    //         } else {
    //             cout << S[i];
    //         }
    //     }
    //     printf("\n");
    //     return 0;
    // }

    for (int i = 0; i < S.length() - T.length() + 1; i++) {
         // 作成できるか
        bool is_enable = true;

        for (int j = 0; j < T.length(); j++) {
            if (S[i + j] != T[j] && S[i + j] != '?') {
                is_enable = false;
                break;
            }
        }
        if (is_enable) {
            target_index = i;
            // if (T[0] <= 'a') {
            //     break;
            // }
        }
    }

    if (target_index == -1) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    
    // 置き換え
    for (int i = 0; i < S.length(); i++) {
        if (i < target_index || target_index + T.length() - 1 < i) {
            if (S[i] == '?') {
                cout << 'a';
            } else {
                cout << S[i];
            }
        } else {
            cout << T[i - target_index];
        }
    }
    printf("\n");
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& e : a) cin >> e;
  int all = accumulate(begin(a), end(a), 0, bit_xor<>());
  for (int i = 0; i < n; ++i) {
    cout << (all ^ a[i]) << " \n"[i == n - 1];
  }
}


Measured memory_bytes: 3976
import collections
n, k = map(int, input().split())
p = list(map(int, input().split()))
selected = []
ans = 0
cnt = 0
choice = collections.defaultdict(int)
for i in range(len(p)):
    choice[p[i]] += 1
for v in sorted(choice.keys()):
    if cnt < k:
        if choice[v] > k - cnt:
            ans += v * k - cnt
            k -= k - cnt
        else:
            ans += v * choice[v]
            k -= choice[v]
print(ans)


Measured memory_bytes: 9560
/*
      author  : nishi5451
      created : 14.08.2020 18:56:30
*/

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


int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int i=1; i<=n-1; i++){
        string l,r;
        l = s.substr(0,i);
        r = s.substr(i,n-i);
        vector<bool> dl(26,false),dr(26,false);
        rep(i,int(l.size())){
            dl[l[i]-'a']=true;
        }
        rep(i,int(r.size())){
            dr[r[i]-'a']=true;
        }
        int sum = 0;
        rep(i,26){
            if(dl[i]==true && dr[i]==true) sum++;
        }
        ans = max(sum,ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3536