akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

long long int pw(long long int x) {
	long long int ans = 1;
	int i = 5;
	while(i--) {
		ans *= x;
	}
	return ans;
}

int main() {
	
	long long int x ; cin >>x;
	// let A and B are both positive;
	
	for(int i=-1000; i<=1000; i++) {
		for(int j=-1000; j<=1000; j++) {
		  long long int sum1 = pw(i) - pw(j);
		  if (sum1 == x) {
			  cout<<i<<" "<<j<<endl;
			  return 0;
		  }
	  }
  }
   
	return 0;
}


Measured memory_bytes: 3556
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=998244353;
int dp[305][305][305],n,k,ans=0,nxt[305];
char s[305];
int M(int x){return x>=mod?x-mod:x;}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	scanf("%d",&k);
	dp[0][0][0]=1;
	nxt[n+1]=n+1;
	for(int i=n;i>0;i--)
	{
		if(s[i]=='0')nxt[i]=i;
		else nxt[i]=nxt[i+1];
	}
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			if(j==n)continue;
			for(int k=0;k<=i;k++)
			{
				if(i<n)dp[i+1][j+1][k]=M(dp[i+1][j+1][k]+dp[i][j][k]);
				if(s[j+1]=='0'&&i<n)dp[i+1][j][k+1]=M(dp[i+1][j][k+1]+dp[i][j][k]);
				if(s[j+1]=='1'&&j<i)
				{
					if(i==n)dp[i][j+1][k]=M(dp[i][j+1][k]+dp[i][j][k]);
					else if(nxt[j+1]<=i+1)dp[i+1][nxt[j+1]][k]=M(dp[i+1][nxt[j+1]][k]+dp[i][j][k]);
				}
			}
		}
	}
	ans=0;
	for(int i=0;i<=min(n,k);i++)ans=M(ans+dp[n][n][i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 56892
#include<iostream>
#include <iomanip>
#include<algorithm>
using namespace std;
int main()
{
	int h[1000],w[1000],n=1000,i=0;
	for(;i<n;i++)//????????\????????¨
	{	cin>>h[i]>>w[i];//?????´????¬¬i?????°??????0,0?????????????????¢???????????°???,??????i?°±??????????????\???????°??????°???,?????\????????\?????????.h????????????w?????????

	if(h[i]==0&&w[i]==0)
		break;
    }
	//??????1??°h-1????????????????????????1???h-1?????????????????????,??????????????????????????°??????
    for(int j=0;j<i;j++)
	{
	for(int k=0;k<w[j];k++)
		cout<<"#";
	cout<<endl;
	for(int k=1;k<h[j]-1;k++)
		{
			for(int m=0;m<w[j];m++)
		{
				if(m==0)
				{cout<<"#";
				continue;//????????\????¬???????
				}
				if(m!=w[j]-1)
					cout<<".";
				else
				cout<<"#"<<endl;
		}
	    }
	for(int k=0;k<w[j];k++)
		cout<<"#";
	cout<<endl<<endl;
	}
}


	

Measured memory_bytes: 3016
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

class mod {
public:
    mod() {m_n = 0;}
    mod(ll n) {if (n >= 0) m_n = n % MOD; else m_n = n % MOD + MOD;}
    friend bool operator== (const mod& a, const mod& b) {return a.m_n == b.m_n;}
    friend bool operator!= (const mod& a, const mod& b) {return !(a == b);}
    friend mod operator+ (const mod& a, const mod& b) {return (a.m_n + b.m_n) % MOD;}
    friend mod& operator+= (mod& a, const mod& b) {return a = a + b;}
    friend mod operator- (const mod& a) {return -a.m_n;}
    friend mod operator- (const mod& a, const mod& b) {return (a.m_n + (-b.m_n)) % MOD;}
    friend mod& operator-= (mod& a, const mod& b) {return a = a - b;}
    friend mod operator* (const mod& a, const mod& b) {return (a.m_n * b.m_n) % MOD;}
    friend mod& operator*= (mod& a, const mod& b) {return a = a * b;}
    friend mod mod_pow(const mod& n, ll r) {
        if (r == 0) {
            return 1;
        } else if (r < 0) {
            return mod_pow(n, (MOD - 2) * (-r));
        } else if (r % 2 == 0) {
            mod tmp = mod_pow(n, r / 2);
            return tmp * tmp;
        } else {
            return n * mod_pow(n, r - 1);
        }
    }
    friend mod operator/ (const mod& a, const mod& b) {return a * mod_pow(b, -1);}
    friend mod& operator/= (mod& a, const mod& b) {return a = a / b;}
    friend ostream& operator<< (ostream& os, const mod& n) {os << n.m_n; return os;}
    friend istream& operator>> (istream& is, mod& n) {ll tmp; is >> tmp; n = mod(tmp); return is;}
private:
    ll m_n;
};

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> A(M+1);
    for (int m = 0; m < M; ++m) cin >> A[m];
    vector<mod> DP(N+1);
    DP[0] = 1;
    int mTmp = 0;
    for (int n = 1; n <= N; ++n) {
        if (A[mTmp] == n) {
            DP[n] = 0;
            ++mTmp;
        } else {
            DP[n] = DP[n-1];
            if (n >= 2) DP[n] += DP[n-2];
        }
    }
    cout << DP[N] << endl;

    return 0;
}


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

using namespace std;

int main() {
    float A,B;

    cin >> A >> B;

    int res = -1;

    for(int i=0;i<1010;i++){
        if((int)((float)i * 0.08) == A && (int)((float)i * 0.1) == B){
            res = i;
            break;
        }
    }

    cout << res;

}

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


int main(){
    int N, M, X;
    cin >> N >> M >> X;

    int l = 0, r = 0;
    while(M--){
        int A;
        cin >> A;
        if(A < X) l++;
        else r++;
    }
    cout << min(l, r) << endl;
}

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

int main(){
    
	string s; cin >> s;
	if (s == "Sunny")cout << "Cloudy" << endl;
	if (s == "Cloudy")cout << "Rainy" << endl;
	if (s == "Rainy")cout << "Sunny" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(int i = (a); i<(b); ++i)
#define rep(i, n) for (int i=0; i<(n); ++i)
#define out(x) cout << x << endl

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A+B+C <= 21){
        out("win");
    }
    else out("bust");
}

Measured memory_bytes: 256
n = int(input())

dict_card = {}

for cnt in range(n):
    card_suit, card_num = input().split()

    dict_card[(card_suit, card_num)] = ""


for suit in ("S", "H", "C", "D"):
    for num in map(str, range(1, 13 + 1)):
        if (suit, num) not in dict_card:
            print(f"{suit} {num}")



Measured memory_bytes: 5608
#include <stdio.h>
#include <stdlib.h>

#define MAX 5000000
#define KEYMAX 2000000000

void maxHeapify(int i);
//void swap(int*, int*);

int H, A[MAX+1];

int main(){
  int i;
  scanf("%d",&H);
  if(H < 1 || H > (MAX/10))
    exit(1);

  for(i = 1; i <= H; i++){
    scanf("%d",&A[i]);
    if(A[i] < (KEYMAX * (-1)) || A[i] > KEYMAX)
      exit(1);
  }

  for(i = H/2; i >= 1; i--)
    maxHeapify(i);

  for(i = 1; i <= H; i++)
    printf(" %d",A[i]);

  printf("\n");

  return 0;
}

void maxHeapify(int i){
  int l, r, largest;
  int temp;
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= H && A[l] > A[i])
    largest = l;
  else
    largest = i;
  if(r <= H && A[r] > A[largest])
    largest = r;

  if(largest != i){
    //swap(&A[i],&A[largest]);
    int temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(largest);
   }
}

/*void swap(int *a, int *b){
  int temp;

  temp = *a;
  *a = *b;
  *b = temp;
  }*/



Measured memory_bytes: 3684
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N = 100003;

int a[N], n = 0, tot = 0, b[N];

int main() {
	scanf("%d", &tot);
	for (int i = 1; i <= tot; ++i) scanf("%d", b + i);
	a[n = 1] = b[1]; for (int i = 2; i <= tot; ++i) if (b[i] != b[i - 1]) a[++n] = b[i];
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (a[i] < a[i + 1]) {
			++i;
			while (a[i] < a[i + 1] && i < n) ++i;
		} else {
			++i;
			while (a[i] > a[i + 1] && i < n) ++i;
		}
		++ans;
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 896
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n, h, w := io.NextInt(), io.NextInt(), io.NextInt()
	count := 0
	for i := 0; i+h <= n; i++ {
		for j := 0; j+w <= n; j++ {
			count++
		}
	}
	io.Println(count)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1776
#include<stdio.h>
#include<math.h>
int cpcc(int p0[2],int r0,int p1[2],int r1,double s[2],double t[2]){
  int x1=p1[0]-p0[0],y1=p1[1]-p0[1],sx=y1,sy=-x1,a=x1*x1+y1*y1,b=r0*r0-r1*r1+a;
  double c=sqrt(a),d=b/(2*c),e=sqrt(r0*r0-(long long)b*b/(4.0*a));  
  if(a>(r0+r1)*(r0+r1))return 0;
  s[0]=p0[0]+(x1*d+sx*e)/c;
  s[1]=p0[1]+(y1*d+sy*e)/c;
  t[0]=p0[0]+(x1*d-sx*e)/c;
  t[1]=p0[1]+(y1*d-sy*e)/c;
  return 1;
}
int main(){
  int p0[2],p1[2],r0,r1,j;
  double a[2][2],e=0.0000005;
  scanf("%d %d %d %d %d %d",&p0[0],&p0[1],&r0,&p1[0],&p1[1],&r1);
  cpcc(p0,r0,p1,r1,a[0],a[1]);
  if(fabs(a[0][0]-a[1][0])<e)j=a[0][1]+e<a[1][1]?0:1;
  else                       j=a[0][0]+e<a[1][0]?0:1;
  printf("%.9f %.9f %.9f %.9f\n",a[j][0],a[j][1],a[1-j][0],a[1-j][1]);
  return 0;
}

Measured memory_bytes: 636
uses crt;
const m = 100000;
var
        g: array [0..100,0..m] of int64;
        c,a: array [0..100] of longint;
        n,k,i,j,w: longint;
begin
        clrscr;
        read (n); readln (w);
        for i:=1 to n do
        readln (a[i], c[i]);

        i:=0;
        repeat
                inc(i);
                for j:=1 to w do
                begin
                        if j < a[i] then g[i,j]:= g[i-1,j] else
                        if g[i-1,j] >= g[i-1, j- a[i]] + c[i] then g[i,j]:= g[i-1,j] else
                        g[i,j]:= g[i-1, j- a[i]] + c[i];
                end;
        until i=n;

        write (g[n,w]);
        readln;
end.

Measured memory_bytes: 78464
#include <iostream>

using namespace std;

int main() {
    int H, W;
    while (true) {
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout <<endl;
    }

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  queue<int> q;
  for(int i=0; i<pow(2,n); i++) {
    int x;
    cin >> x;
    q.push(x);
  }
  while(q.size()>1) {
    int x=q.front();q.pop();
    int y=q.front();q.pop();
    q.push(x==y?x:max(x-y,y-x));
  }
  cout << q.front() << endl;
  return 0;
}


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

int main(){
    int n,ans=0;
    cin>>n;
    vector<int>b(n-1);
    for(int i=0;i<n-1;i++){
        cin>>b[i];
        //cout<<b[i]<<endl;
    }
   /* sort(b.begin(),b.end());
    //cout<<b[5]<<endl;
    for(int i=0;i<n-1;i++){
    cout<<b[i]<<endl;
    }*/
 for(int i=0;i<n-2;i++){
    if(b[i]<=b[i+1]){
        ans+=b[i];
        //cout<<b[i]<<endl;
    }
    else{
        ans+=b[i+1];
        //cout<<b[i+1]<<endl;
    }
 }
 cout<<b[0]+ans+b[n-2]<<endl;
 return 0;
}



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

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,a,b;
    cin>>n>>a>>b;
    string s;
    cin>>s;
    int now=0;
    int rank=1;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='a' && now<a+b)
        {
            cout<<"Yes"<<"\n";
            now++;
        }
        else if(s[i]=='b' && now<a+b && rank<=b)
        {
            cout<<"Yes"<<"\n";
            now++;
            rank++;
        }
        else
        cout<<"No"<<"\n";

    }
    
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define F(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define VE(i,v) for(int i = 0;i < (v).size();i++)

using namespace std;
#define trace(...) cerr<<__FUNCTION__<<":"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned int ui;
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
typedef pair<ll,ll> pll;
typedef vector<pll> vpll; 
 




int main()

{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	int T;
	T=1;
	for(int tc=1; tc<=T;tc++)
	{
		int ans = 0;
		int N;
		cin>>N;
		vi A(N);
		vii xy[20];
		for(int i =0; i < N; i++)
		{
			cin >> A[i];
			for(int j =0; j < A[i]; j++)
			{
				int x, y;
				cin >> x>>y;
				x--;
				//trace(i, A[i], x , y);
				xy[i].pb({x,y});
			}
		}
		/*for(int i=0; i < N; i++)
		{
			for(auto yx: xy[i])
			{
				trace(i, yx.first, yx.second);
			}
		}*/
		for(int i =1 ;i <(1<<N); i++)
		{
			bool chk = true;
			for(int j =0; j < N; j++)
			{
				if(i&(1<<j))
				{
					//trace(i, j);
					for(auto yx: xy[j])
					{
						int x = yx.first;
						int y = yx.second;
						int lt = (i&(1<<x))>>x;
						//trace(i, j , x, y, lt);
						if(lt!=y)
						{
							chk = false;
							break;
						}
					}
				}
				if(!chk)
					break;
			}
			//trace(i, chk);
			if(chk)
				ans = max(ans, __builtin_popcount(i));
		}
		cout<<ans<<"\n";


	}
 
 
 
	return 0;
}
 
 


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

using namespace std;

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

int main() {
  int w, h, n;
  cin >> w >> h >> n;
  if (w < h) {
    swap(w, h);
  }

  cout << (n + w - 1) / w << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
LL V[1<<18];
LL W[1<<18];
int Q;

LL dp[512][100011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%lld%lld", V+i+1, W+i+1);

    for (int v=1; v<=N && v<512; v++) {
	memcpy(dp[v], dp[v/2], sizeof dp[0]);
	for (int i=100000; i>=W[v]; i--) amax(dp[v][i], dp[v][i-W[v]] + V[v]);
	REP (i, 100001) amax(dp[v][i+1], dp[v][i]);
    }

    scanf("%d", &Q);
    vector<pair<int, LL> > h;
    REP ($, Q) {
	int v, L;
	scanf("%d%d", &v, &L);

	h.clear();
	h.emplace_back(0, 0);
	int cur = v;
	while (cur >= 512) {
	    int len = h.size();
	    REP (i, len) {
		LL weight = h[i].first + W[cur];
		if (weight <= L) {
		    LL value = h[i].second + V[cur];
		    h.emplace_back(weight, value);
		}
	    }
	    cur /= 2;
	}

	LL ans = 0;
	EACH (e, h) {
	    amax(ans, dp[cur][L - e->first] + e->second);
	}

	printf("%lld\n", ans);
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 407172
# include "iostream"
# include "cstring"
# include "cstdio"

using namespace std;

const int maxm=1e5+10;

int Len;
char S[maxm];

int Check(int N){
	register int i,Mid=N>>1;
	for(i=1;i<=Mid;i++){
		if(S[i]!=S[i+Mid]) return 0;
	}
	return N;
}

int main(){
	register int i,Ans=0;
	scanf("%s",S+1);
	Len=strlen(S+1);
	for(i=2;i<Len;i+=2){
		Ans=max(Ans,Check(i));
	}
	printf("%d",Ans);
	return 0;
}

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

int main() {

string S; cin >> S; 
  if(S[2]==S[3] && S[4]==S[5]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<math.h>

#define DIV 1000000007
using namespace std;
using ll = long long;

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

	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];

	deque<int> clr;
	clr.push_back(A[0]);
	for (int i = 1; i < N; i++) {
		if (A[i] <= clr[0]) {
			clr.push_front(A[i]);
		}
		else {
			if (clr.size() == 1) {
				clr[0] = A[i];
			}
			else {
				int it = lower_bound(clr.begin(), clr.end(), A[i])
					- clr.begin() - 1;
				clr[it] = A[i];
			}
		}
	}
	/*
	for (int i = 0; i < clr.size(); i++) {
		cout << clr[i] << " ";
	}
	cout << endl;
	*/
	cout << clr.size() << endl;
}


Measured memory_bytes: 1024
s = input()
s1 = int(s[:2])
s2 = int(s[2:])
if s1 != 0 and s2 != 0 and s1 < 13 and s2 < 13:
    print('AMBIGUOUS')
elif s1 != 0 and s1 < 13 and (s2 == 0 or s2 > 12):
    print('MMYY')
elif (s1 == 0 or s1 > 12) and s2 != 0 and s2 < 13:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 3060
def hit_blow(arr1, arr2)
  n, m = 0, 0
  
  4.times do |i|
    n += 1 if arr1[i] == arr2[i]
    m += 1 if arr1.include?(arr2[i])
  end
  
  return [n, m - n]
end

while gets
  arr1, arr2 = $_.split, gets.split
  puts hit_blow(arr1, arr2).join(" ")
end

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

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int N ,Y, x, y, z;
	
	cin >> N >> Y;
	
	for(x=0; x<=N; x++){
		for(y=0; y<=N; y++){
			z = N-x-y;
			if(x*10000+y*5000+z*1000 == Y && z >= 0){
				cout << x << " " << y << " " << z;
				return 0;
			}
		}
	}
	
	cout << -1 << " " << -1 << " " << -1;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 10000

typedef struct{
  int id;
  int parent;
  int left;
  int right;
  int depth;
  int sibling;
  int height;
} Node;

Node T[N];
void Depth(int, int);
int Height(int);
void Sibling(int);

int main(){
  int root,n,i,id;

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

  for(i = 0; i < n; i++){
    scanf("%d",&id);
    scanf(" %d %d",&T[id].left,&T[id].right);
    if(T[id].left != -1) T[T[id].left].parent = id;
    if(T[id].right != -1) T[T[id].right].parent = id;
  }

  for(i = 0; i < n; i++){
    if(T[i].parent == -1) root = i;
  }

  Depth(root,0);
  Height(root);
  Sibling(n);

  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, sibling = %d, ",i,T[i].parent,T[i].sibling);
    printf("degree = ");
    if(T[i].left != -1 && T[i].right != -1) printf("2");
    else if(T[i].left != -1 || T[i].right != -1) printf("1");
    else printf("0");
  printf(", depth = %d, height = %d, ",T[i].depth,T[i].height);
    if(T[i].parent == -1) printf("root");
    else if(T[i].left == -1 && T[i].right == -1) printf("leaf");
    else printf("internal node");
    printf("\n");
  }
  return 0;
}

void Sibling(int n){
  int i;
  for(i = 0; i < n; i++){
    T[i].id = i;
  }
  for(i = 0; i < n; i++)
    if(T[i].parent == -1) T[i].sibling = -1;
    else if(T[T[i].parent].right != T[i].id) T[i].sibling = T[T[i].parent].right;
    else if(T[T[i].parent].left != T[i].id) T[i].sibling = T[T[i].parent].left;
  return;
}


void Depth(int child, int d){
  if(child == -1) return ;
  T[child].depth = d;
  Depth(T[child].left,++d);
  Depth(T[child].right,d);
}

int Height(int u){
  int a,b;
  a = b = 0;
  if(T[u].left != -1) a = 1 + Height(T[u].left);
  if(T[u].right != -1) b = 1 + Height(T[u].right);
  if(a < b){
    T[u].height = b;
    return b;
  }
  T[u].height = a;
  return a;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;

int main() {
    char A, B; cin >> A >> B;
    if (A < B) {
        cout << "<" << endl;
    } else if (A == B) {
        cout << "=" << endl;
    } else {
        cout << ">" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll n,m,d;cin>>n>>m>>d;if(d)d=2*(n-d);else d=n;
  printf("%.20f",(double)(m-1)*d/(double)(n*n));cout<<endl;
  return 0;
}

Measured memory_bytes: 3736
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // B - *e**** ********e* *e****e* ****e**

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        String s = sc.next();

        int k = sc.nextInt();

        char[] sb = s.toCharArray();

        StringBuilder sbr = new StringBuilder();

        for (int i = 0; i < n; i++) {
            sbr = sbr.append((sb[i] == sb[k -1]) ? sb[i] : '*');
        }
        
        System.out.println(String.valueOf(sbr));
    }

}

Measured memory_bytes: 21844
#include <iomanip>
#include <iostream>
#include <cmath>

using namespace std;

int main(){
	double a, b, deg, rad;
	cin >> a >> b >> deg;
	rad = deg / 180 * 3.141592653589793;
	double bsin = b * sin(rad);
	cout << fixed << setprecision(5);
	cout << a * bsin / 2 << endl;
	cout << a + b + sqrt(a*a + b*b - 2*a*b*cos(rad)) << endl;
	cout << bsin << endl;
}

Measured memory_bytes: 3492
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, M: int, Q: int, L: "List[int]", R: "List[int]", p: "List[int]", q: "List[int]"):
    t = [[0] * (N + 1) for _ in range(N + 1)]
    for Li, Ri in zip(L, R):
        Li -= 1
        Ri -= 1
        t[Li + 1][Ri + 1] += 1
    for i in range(N):
        for j in range(N + 1):
            t[i + 1][j] += t[i][j]
    for i in range(N + 1):
        for j in range(N):
            t[i][j + 1] += t[i][j]
    for pi, qi in zip(p, q):
        pi -= 1
        qi -= 1
        print(t[N][qi + 1] - t[pi][qi + 1])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    L = [int()] * (M)  # type: "List[int]"
    R = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        L[i] = int(next(tokens))
        R[i] = int(next(tokens))
    p = [int()] * (Q)  # type: "List[int]"
    q = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        p[i] = int(next(tokens))
        q[i] = int(next(tokens))
    solve(N, M, Q, L, R, p, q)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27720
#include<stdio.h>

#define N 100
#define BLACK 0
#define WHITE 1
#define INF 100000000
#define NIL -1
 
void dijkstra(void);

int A[N][N],n;

int main()
{
	int i,j,u,k,v,c;
	
	scanf("%d",&n);
	
	for(i = 0; i < n; i++){
		for(j = 0; j < n; j++){
			A[i][j] = INF;
		}
	}
	
	for(i = 0;i < n; i++){
		scanf("%d%d",&u,&k);
		for(j = 0; j < k; j++){
			scanf("%d%d",&v,&c);
			A[u][v] = c;
		}
	}
	
	dijkstra();
	
	return 0;
}

void dijkstra(){
	
	int u,v,i,mincost;
	int d[N],pi[N],color[N];
 
  for(u = 0; u < n; u++){
    d[u] = INF;
    pi[u] = NIL;
    color[u] = WHITE;
  }
 
  d[0] = 0;
 
  while(1){
    mincost = INF;
    for(i = 0; i < n; i++){
      if(color[i] != BLACK && d[i] < mincost){
    mincost = d[i];
    u = i;
      }
    }
    if(mincost == INF) break;
 
    color[u] = BLACK;
   
    for(v = 0; v < n; v++){
      if(color[v] != BLACK && A[u][v] + d[u] < d[v] && A[u][v] != -1){
    pi[v] = u;
    d[v] = A[u][v] +d[u];
      }
    }
   
  }
  for(u = 0; u < n; u++){
  printf("%d %d\n",u,d[u]);
  }
  
}

Measured memory_bytes: 636
#include <stdio.h>
int main(void)
{
  char a,b;

  scanf("%c %c", &a, &b);

  if(a == 'H')
    printf("%c\n", b);
  else if(b == 'H')
    printf("D\n");
  else
    printf("H\n");

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main() {
	string n;
	cin >> n;
	for (int i = 0; i < 3; ++i) {
		if (n[i] == '1') {
			cout << '9';
		}
		else {
			cout << '1';
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String... args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    scan.close();

    int tmp_ans = 0;
    boolean flg_ans = false;
    for(int i=1; i<=9; i++) {
      tmp_ans = N/i;
      if(N%i == 0 && 1 <= tmp_ans && tmp_ans <= 9) {
        flg_ans = true;
        break;
      }
    }

    System.out.println(flg_ans ? "Yes" : "No");
  }
}

Measured memory_bytes: 22228
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      int r = sc.nextInt();
      int D = sc.nextInt();
      int x = sc.nextInt();    
      
      for(int i =0; i<10; i++){
      x=r*x-D;  
      System.out.println(x);
         }
    }
}

Measured memory_bytes: 21716
# coding: utf-8

def pattern1(N, A, B):
  left = B - 1
  right= N - A
  if left < right:
    return left
  else:
    return right  
      
def pattern2(N, A, B):
  round_elapsed_mid = (A - 1) + 1
  B_position = B - round_elapsed_mid
  offset = B_position - 1
  if offset % 2 == 0:
    return (offset // 2 + round_elapsed_mid)
  
def pattern3(N, A, B):
  round_elapsed_mid = (N - B) + 1
  A_position = A + round_elapsed_mid
  offset = N - A_position
  if offset % 2 == 0:
    return (offset // 2 + round_elapsed_mid)

N, A, B = (int(n) for n in input().split())
offset = B - A
if offset % 2 == 0:
  print(offset // 2)
else:
  candi1 = pattern1(N, A, B)
  candi2 = pattern2(N, A, B)
  candi3 = pattern3(N, A, B)
  print(min([candi1, candi2, candi3]))
  

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	long long H[100002] = {0};

	cin >> N;
	for(int i=1; i<=N; i++){ cin >> H[i]; }

	for(int i=N-1; i>=1; i--){
		long long a = H[i];
		long long b = H[i+1];
		if(a - b >= 2){
			printf("No\n");
			return 0;
		}
		else if(a - b == 1){
			H[i]--;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(void) {
  int a,b,C;
  double S,L,h;
  cin >> a >> b >> C;
  S = 1.0 / 2.0 * a * b * sin(M_PI / 180 * C);
  L = a + b + sqrt(a * a + b * b - 2.0 * a * b * cos(M_PI / 180 * C));
  h = b * sin(M_PI / 180 * C);
  cout << fixed << setprecision(9) << S << endl << L << endl << h << endl;
  return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define REP(i,b,n) for(i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))

using namespace std;

int n, nums[200] = {0};
long long dp[200][30] = {0};

long long solve()
{
	CLR(dp);
	dp[0][nums[0]] = 1;
	
	FOR(j, 0, n-1)
	{
		FOR(i, 0, 21)
		{
			if( dp[j][i] != 0 )
			{
				if( i + nums[j+1] <= 20 )
					dp[j+1][i+nums[j+1]] += dp[j][i];
				
				if( i - nums[j+1] >= 0 )
					dp[j+1][i-nums[j+1]] += dp[j][i];
			}
		}
	}

	return dp[n-2][nums[n-1]];
}

int main()
{
	cin >> n;
	
	FOR(i, 0, n)
	{
		cin >> nums[i];
	}
	
	cout << solve() << endl;
	
	return 0;
}

Measured memory_bytes: 0
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma region header
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
#pragma endregion
#pragma endregion



int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	lint n; cin >> n;
	vector<lint> c(n - 1), s(n - 1), f(n - 1);
	for (int i = 0; i < n - 1; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}	
	for (int i = 0; i < n - 1; i++) {
		lint sum = 0;
		for (int j = i; j < n - 1; j++) {
			if (sum <= s[j]) sum = s[j] + c[j];
			else {
				if ((sum - s[j]) % f[j] == 0) sum += c[j] + (sum - s[j]) % f[j];
				else sum += c[j] + (f[j] - (sum - s[j]) % f[j]);
			}
		}
		cout << sum << endl;
	}
	cout << 0 << endl;

	return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int mp[555][555];

int main(){
	
	int n;cin >> n;
	int k = n;
	
	if(n == 1){
		cout << 1 << endl << 1 << endl;
		return 0;
	}
	
	bool flag = (n % 2 == 1);
	n = (n + 3) / 4;n *= 2;
	REP(i,n){
		REP(j,n){
			if(i % 2){
				mp[i][j] = (i + j) % n;
			}
			else {
				mp[i][j] = n + ((i + j) % n);
				if(mp[i][j] >= k)mp[i][j]-=n;
			}
		}
	}
	
	cout << n << endl;
	REP(i,n){
		REP(j,n){
			cout << mp[i][j] + 1 << " ";
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 2304
import java.util.*;
import java.math.*;
import java.io.*;


public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] v = new int[n];
        int[] c = new int[n];
        for(int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }
        int ans = 0;
        for(int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
        }

        boolean[] use = new boolean[n];


        while(true) {
            int id = -1;
            int max = 0;
            for(int i = 0; i < n; i++) {
                if(use[i]) continue;
                if(max < v[i] - c[i]) {
                    max = v[i] - c[i];
                    id = i;
                }
            }
            if(id == -1) break;
            use[id] = true;
            ans += max;
        }
        System.out.println(ans);




    } 
}

Measured memory_bytes: 23636
import sys
import os
import bisect, collections, copy, itertools, math, string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int, input().split()))
def LS(): return list(input().split())

def solve():
	n = I()
	A = LI()

	dic = {}
	for i in range(n):
		dic.setdefault(i+1, 0)

	for a in A:
		dic[a] = dic[a] +  1

	for key in dic:
		print(dic[key])
	
if __name__ == '__main__':
	solve()


Measured memory_bytes: 40976
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int n, l;
  vector<string> S;
  cin >> n >> l;
  S.resize(n);
  loop(i,0,n) cin >> S[i];
  sort(S.begin(), S.end());
  for (auto&&s: S) cout << s;
  cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

void m_sort(int numbers[], int temp[], int left, int right);
void merge(int numbers[], int temp[], int left, int mid, int right);

int main(){
	int n,k;
	int *p;
	int *np;
	int *temp;
	int minsum = 0;
	scanf("%d %d",&n,&k);
	p = (int *)calloc(n, sizeof(int));
	temp = (int *)calloc(n, sizeof(int));
	np = p;
	for(int i=0; i<n; i++){
		scanf("%d",np);
		np++;
	}
	m_sort(p, temp, 0, n-1);
	
	np = p;
	for(int i=0; i<k; i++){
		minsum += *np;
		np++;
	}
	
	printf("%d",minsum);
	
	return 0;
}

void m_sort(int numbers[], int temp[], int left, int right){
  int mid;

  if (right > left){
    mid = (right + left) / 2;
    m_sort(numbers, temp, left, mid);
    m_sort(numbers, temp, mid+1, right);

    merge(numbers, temp, left, mid+1, right);
  }
}


void merge(int numbers[], int temp[], int left, int mid, int right){
  int i, left_end, num_elements, tmp_pos;

  left_end = mid - 1;
  tmp_pos = left;
  num_elements = right - left + 1;

  while ((left <= left_end) && (mid <= right)){
    if (numbers[left] <= numbers[mid]){
      temp[tmp_pos] = numbers[left];
      tmp_pos = tmp_pos + 1;
      left = left +1;
    }else{
      temp[tmp_pos] = numbers[mid];
      tmp_pos = tmp_pos + 1;
      mid = mid + 1;
    }
  }

  while (left <= left_end){
    temp[tmp_pos] = numbers[left];
    left = left + 1;
    tmp_pos = tmp_pos + 1;
  }
  while (mid <= right){
    temp[tmp_pos] = numbers[mid];
    mid = mid + 1;
    tmp_pos = tmp_pos + 1;
  }

  for (i=0; i <= num_elements; i++){
    numbers[right] = temp[right];
    right = right - 1;
  }
}


Measured memory_bytes: 1744
#include<stdio.h>

int main(){
  int N;
  long H, W;

  scanf("%d %ld %ld", &N, &H, &W);

  int i;
  int c = 0;

  long h, w;

  for(i = 0; i < N; i++){
    scanf("%ld %ld", &h, &w);
    if(h >= H && w >= W) c++;
  }

  printf("%d\n", c);

  return 0;
}


Measured memory_bytes: 128
n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
    s=input()
    if s=='AC':
        ac+=1
    elif s=='WA':
        wa+=1
    elif s=='TLE':
        tle+=1
    else:
        re+=1
print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))

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

int main(){
    int n, m;
    cin >> n;
    vector<string> s(n);
    for(int i = 0;i < n;i++)cin >> s.at(i);
    cin >> m;
    vector<string> t(m);
    for(int i = 0;i < m;i++){
        cin >> t.at(i);
    }
    vector<int> count(n, 0);
    for(int i = 0;i < n;i++){
        string memo = s.at(i);
        for(int j = 0;j < n;j++){
            if(memo == s.at(j))count.at(i)++;
        }
        for(int j = 0;j < m;j++){
            if(memo == t.at(j))count.at(i)--;
        }
    }
    sort(count.begin(), count.end());
    if(count.at(n - 1) <= 0)cout << 0 << endl;
    else cout << count.at(n - 1) << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int k[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
int n;
cin>>n;
cout<<k[n-1]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=true;

/*---------------------------------------------------*/

int main(){
  int n,k;
  ll a[100005]={0},r[100005]={0};
  cin>>n>>k;
  REP(i,1,n+1){
    cin>>a[i];
  }
  r[0]=max(ll(0),a[0]);
  rep(i,n+1)r[i]=max(ll(0),a[i]);
  REP(i,1,n+1){
    r[i]+=r[i-1];
    a[i]+=a[i-1];
  }
  ll ans=-LINF;
  REP(i,0,n-k+1){
    ll tmp=(r[i]-r[0])+(r[n]-r[k+i]);
    ans=max(ans,max(tmp,tmp+(a[k+i]-a[i])));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: u64,
        m: u64,
        a: [u64;m]
    };

    let mut sum = 0;
    for i in a.iter() {
        sum += i;
    }

    if sum > n {
        println!("-1")
    } else {
        println!("{}", n - sum)
    }
}


Measured memory_bytes: 2244
from collections import Counter
N=int(input())
S=[input() for _ in range(N)]

C=Counter(S)
A=[]
B=[]
T=[]

for i,j in C.most_common():
    A.append(i)
    B.append(j)
for k in range(len(A)):
    if B[k]==B[0]:
        T.append(A[k])
T=sorted(T)
for m in range(len(T)):
  print(T[m])


Measured memory_bytes: 49264
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end()
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;

int main() {
	int n, a, b; CI n >> a >> b;
	CO min(n * a, b) EN;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ab = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();
            int z = 0;
            int a = ab[0];
            int b = ab[1];
            z = b - a;
            z = z * (z + 1) / 2;
            z = z - b;
            Console.WriteLine(z);
        }
    }
}
//int[] N = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();

Measured memory_bytes: 28240
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
cin.tie(0);
int n,k;
cin >>n;
k=n%10;
if(k==2||k==4||k==5||k==7||k==9)cout << "hon";
else if(k==3)cout <<"bon";
else cout <<"pon";

return 0;
}


Measured memory_bytes: 3584
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

n,m=map(int, input().split())
uf1=UnionFind(n)
k=set()
for i in range(m):
    a,b=map(int, input().split())
    a,b=a-1,b-1
    if a>b:
        a,b=b,a
    k.add((a,b))
for a,b in k:
    uf1.union(a,b)

for i in range(n):uf1.find(i)
from collections import *
ans=Counter(uf1.par)

print(ans.most_common()[0][1])

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

using namespace std;


int main(int argc, char *argv[])
{
	int N;
	string S;
	cin >> N >> S;
	
	int count = 0;
	string str = S;
	string tgt = "ABC";
	size_t len = tgt.length();
	size_t pos = S.find(tgt);
	while (pos != string::npos) {
		count++;
		S = S.substr(pos + len);
		pos = S.find(tgt);
	}

	cout << count << endl;


	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S;
    cin >> S;
    int cnt = 0;
    ll ans = 0;
    rep(i, S.size()) {
        if (S[i] == 'W') {
            ans += cnt;
        } else {
            cnt++;
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

int main(){
    int n;
    vector<int>a(9);
    vector<int>b(1000000);
    vector<int>c(9);
    for(int i=0;i<9;i++){
        cin>>a[i];
        c[i]=0;
    }
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>b[i];
        for(int j=0;j<9;j++){
            if(b[i]==a[j]){
                c[j]=1;
            }
        }
    }
    if(c[0]==1&&c[1]==1&&c[2]==1){
        cout<<"Yes"<<endl;
    }
    else if(c[3]==1&&c[4]==1&&c[5]==1){
        cout<<"Yes"<<endl;
    }
    else if(c[6]==1&&c[7]==1&&c[8]==1){
        cout<<"Yes"<<endl;
    }
    else if(c[0]==1&&c[3]==1&&c[6]==1){
        cout<<"Yes"<<endl;
    }
    else if(c[1]==1&&c[4]==1&&c[7]==1){
        cout<<"Yes"<<endl;
    }
    else if(c[2]==1&&c[5]==1&&c[8]==1){
        cout<<"Yes"<<endl;
    }
    else if(c[0]==1&&c[4]==1&&c[8]==1){
        cout<<"Yes"<<endl;
    }
    else if(c[2]==1&&c[4]==1&&c[6]==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 4096
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N, K;
    cin >> N >> K;

    vector<int> a(N);
    REP(i, N) cin >> a[i];

    // Grundy数
    vector<int> dp(K + 1);
    dp[0] = 0;
    FOR(i, 1, K) {
        set<int> s;
        REP(j, N) {
            if (i - a[j] < 0) continue;
            s.insert(dp[i - a[j]]);
        }
        while (s.count(dp[i])) {
            dp[i]++;
        }
    }
    cout << (dp[K] > 0 ? "First" : "Second") << endl;

    return 0;
}


Measured memory_bytes: 1024