akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {
  string S;
  cin >> S;
  string erase_list[4] = {"dream", "dreamer", "erase", "eraser"};
  for (string& s : erase_list) reverse(s.begin(), s.end());
  string now;
  for (int i = S.size() - 1; i >= 0; --i) {
    now += S[i];
    for (string s : erase_list)
      if (now == s) now.clear();
  }
  cout << (now.empty() ? "YES" : "NO") << endl;
  return 0;
}

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int ll
//#define endl '\n'

int n,K;
int dp[52][107][2517];

int32_t main()
{
    IOS
    cin>>n>>K;
    dp[0][0][0]=1;
    for (int i=0;i<n;i++)
        for (int j=0;j<=n;j++)
            for (int k=0;k<=n*n;k++)
        {
            dp[i+1][j+2][k+j+2]=(dp[i+1][j+2][k+j+2]+dp[i][j][k])%mod;
            dp[i+1][j][k+j]=(dp[i+1][j][k+j]+(j+1)*dp[i][j][k])%mod;
            if (j>=2) dp[i+1][j-2][k+j-2]=(dp[i+1][j-2][k+j-2]+((j/2)*(j/2))%mod*dp[i][j][k])%mod;
        }
    cout<<dp[n][0][K]<<endl;
}


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

int main(){
    int s;
    cin >> s;
    vector<bool> vec(10010, false);
    vec[s] = true;
    int i=1;
    while(true){
        if(s % 2 == 0) s /= 2;
        else  s = 3*s + 1;
        i++;
        if(vec[s]) break;
        else vec[s] = true;
    }
    cout<<i;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;

char str[N];
int cnt[N];
int main() {
    cin >> str;
    int n = strlen(str);

    for (int i = 0 ; i < n ; ++ i) {
        ++ cnt[str[i] - 'a'];
    }
    for (int i = n ; i >= 0 ; -- i) {
        if (i < n) -- cnt[str[i] - 'a'];
        int pa = 0;
        for (int j = 0 ; j < 26 ; ++ j) {
            if (cnt[j] > 1) {
                pa = 1;
                break;
            }
        }
        if (pa) continue;

        for (int j = i == n ? 0 : str[i] - 'a' + 1 ; j < 26 ; ++ j) {
            cnt[j] ++;
            if (cnt[j] <= 1) {
                str[i] = 'a' + j;
                str[i + 1] = 0;
                cout << str << endl;
                return 0;
            }
            -- cnt[j];
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

int main (){

    int N, M, X;

    cin >> N >> M >> X;

    vector<vector<int>> A(N,vector<int>(M));
    vector<int> C(N);

    rep(i,0,N) {
        cin >> C[i];
        rep(j,0,M) {
            cin >> A[i][j];
        }
    }
    int ans = INF;
    for (int bit = 0; bit < (1<<N); ++bit){
        vector<int> M_sum(M,0);
        int C_sum = 0;

        rep(i,0,N) {
            if (bit>>i & 1) {
                C_sum += C[i];
                rep(j,0,M) {
                    M_sum[j] += A[i][j];
                }
            }
        }
        bool hoge = true;
        rep(i,0,M) {
            if(M_sum[i]<X) {
                hoge = false;
            }
        }

        if (hoge) {
            ans = min(ans,C_sum);
        }
    }

    if (ans== INF) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }

}





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

int main(){
    int n;cin>>n;
    vector<int> sequence(n);for(int i=0;i<n;i++){cin>>sequence[i];}
    int acc = 0;
    for (auto s : sequence){
        if (s % 2 == 0){
            acc++;
        }
    }
    cout << pow(3.0, n) - pow(2.0, acc) << endl;
    return 0;

}

Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int a,b,c,k;
  cin>>a>>b>>c>>k;
  int sum=0;
  if(k<=a) sum+=k;
  else if(k>a){
    sum=sum+a;k-=a;
    if(b>=k) sum+=0;
    else if(b<k)
    { sum+=0;
      k-=b;
      if(c>=k) sum+=(k*-1);
      else sum+=(c*-1);
}
 
}
cout<<sum;
}

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

public class Main {
    static IO io = new IO();

    public static void main(String[] args) {

        StringBuilder sb = new StringBuilder(io.next());
        System.out.println(sb.reverse());

    }

    static class IO extends PrintWriter {
        private final InputStream in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        IO() {
            this(System.in);
        }

        IO(InputStream source) {
            super(System.out);
            this.in = source;
        }

        boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        }

        boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        String next() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        long nextLong() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
                throw new NumberFormatException();
            }
            return (int) nl;
        }

        public void close() {
            super.close();
            try {
                in.close();
            } catch (IOException ignored) {
            }
        }
    }
}

Measured memory_bytes: 24080
import numpy as np
N = int(input())
A = np.array(input().split(),dtype = np.int64)
B = np.array(input().split(),dtype = np.int64)
C = np.array(input().split(),dtype = np.int64)
A.sort()
B.sort()
C.sort()

cnt_a = np.searchsorted(A,B,side='left')
unavailabel_cnt_c = np.searchsorted(C,B,side='right')
cnt_c = N-unavailabel_cnt_c
ans = (cnt_a*cnt_c).sum()
print(ans)

Measured memory_bytes: 33684
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,i;
    string ch;
    cin>>n>>k>>ch;
    for(i=0;i<n;i++)
    {
        if(i+1==k)
        {
            ch[i]=ch[i]+32;
        }
        cout<<ch[i];
    }
    cout<<endl;
    return 0;
}


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

int map[16][16];
bool can[16][16];

int main(){
  int a,b,n;
  int x,y;

  while(1){
    cin >> a >> b;
    if(!a && !b)break;

    for(int i=0;i<a;i++){
      for(int j=0;j<b;j++){
	can[i][j] = true;
	map[i][j] = 0;
      }
    }

    cin >> n;
    for(int i=0;i<n;i++){
      cin >> x >> y;
      can[x-1][y-1] = false;
    }

    map[0][0] = 1;
    for(int i=0;i<a;i++){
      for(int j=0;j<b;j++){
	if(i>0 && can[i][j]){
	  map[i][j] += map[i-1][j];
	}
	if(j>0 && can[i][j]){
	  map[i][j] += map[i][j-1];
	}
      }
    }

    cout << map[a-1][b-1] << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];
    sort(all(A));
    int ok = N-1;
    int ng = -1;
    int mid;
    while(ok-ng>1) {
        mid = (ok + ng) / 2;
        ll s = 0;
        REP(i,mid + 1) s += A[i];
        bool flag = true;
        FOR(i,mid+1,N) {
            if(2*s<A[i]) {
                flag = false;
                break;
            } else {
                s += A[i];
            }
        }
        if(flag) ok = mid;
        else ng = mid;
    }
    cout << N - ok << endl;
    return 0;
}


Measured memory_bytes: 1024
#-*- coding: utf-8 -*-
#入力
A = int(raw_input())
B = int(raw_input())
C = int(raw_input())
D = int(raw_input())
E = int(raw_input())

#リスト化
list = [A, B, C, D, E]

#10で割ったあまり,一番小さい数字を取得
list10 = map(lambda x: -(-x // 10), list)
#print(list10)
list20 = map(lambda x: x * 10, list10)
#print(list20)
list30 = [x - y for (x, y) in zip(list20, list)]
#print(list30)

lmaxindex = list30.index(max(list30))
#print(lmaxindex)
max = list[lmaxindex]
#print(max)

#リストから一番小さいのを削除する
list.pop(lmaxindex)

list2 = map(lambda x: -(-x // 10), list)
list3 = map(lambda x: x * 10, list2)
list3.append(max)
#print(list3)
print(sum(list3))


Measured memory_bytes: 2568
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
from fractions import gcd

sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())
 
def inp_list(): return list(map(int, sys.stdin.readline().split()))

def lcm(x, y): return (x * y) // gcd(x, y)


a, b = inp_list()
for n in range(1251):
    wo_tax_a = int(n * 0.08)
    wo_tax_b = int(n * 0.10)
    if wo_tax_a == a and wo_tax_b == b:
        print(n)
        exit()
print(-1)


Measured memory_bytes: 67180
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N, W = map(int, input().split())
vw = [list(map(int, input().split())) for _ in range(N)]


dp = [[0]*(W+1) for _  in range(N+1)]

for i in range(1, N+1): # watasu=
    v, w = vw[i-1]
    for j in range(W+1):
        if j-w>=0:
            dp[i][j] = max(dp[i-1][j-w]+v, dp[i-1][j], dp[i][j-w]+v)
        else:
            dp[i][j] = dp[i-1][j]
print(max(dp[N]))



Measured memory_bytes: 42352
#include <stdio.h>
#include <stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
    Q[tail]=x;
    if(tail+1 >= LEN+1) tail=0;
    else Q[tail++]=x;
}

P dequeue(){
    P x=Q[head];
    if(head+1 >= LEN+1) head=0;
    else head++;
    return x;
}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  head=0;
  tail=n+1;

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  
  while(head!=tail){
      u=dequeue();
      if(u.t>q){
          u.t=u.t-q;
          enqueue(u);
          elaps=elaps+q;
      }
      else if(u.t!=0){
          elaps=elaps+u.t;
          printf("%s %d\n", u.name, elaps);
      }
      
  }
  return 0;
}


Measured memory_bytes: 11944
#include<iostream>
#include<vector>
#include<string>
#define N 246913
using namespace std;

int main() {
	vector<bool>hantei(N, true);
	vector<int>sosuu(N);
	for (int a = 0; a < N; a++) {
		hantei[a] = true;
	}
	sosuu[0] = sosuu[1] = 0;
	int s = 0;
	for (int b = 2; b < N; b++) {
		if (hantei[b]) {
			s++;
			for (int c = b * 2; c < N; c += b) hantei[c] = false;
		}
		sosuu[b] = s;
	}
	int d;
	while (cin >> d, d) {
		cout << sosuu[d * 2] - sosuu[d] << endl;
	}
}

Measured memory_bytes: 3636
import math
a,b,x= map(int, input().split())
x/=a

if a*b>=2*x:
    print (math.degrees(math.pi/2-math.atan(2*x/(b**2))))
else:
    y=2*x/a-b
    try:
        print(math.degrees(math.pi/2-math.atan(a/(b-y))))
    except ZeroDivisionError:
        print(0)


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

int main(){
    long long ans = 0;
    int n, m;
    scanf("%d%d",&n,&m);
    for(int i=m+1;i<=n;i++){
        long long mok = n / i;
        ans += mok * (i - m);
        if((n%i) >= m){
            ans += (n%i) - m + 1;
        }
    }
    if(m == 0) ans -= n;
    printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        int main()
        {
        string s;
        cin>>s;
        int cnta=0;
        int cntb=0;
        for(int i=0; i<s.size(); i++)
        {
            if(i%2==0&&s[i]!='1') {++cnta;}
            else if(i%2!=0&&s[i]!='0'){++cnta;}
     
            else if(i%2==0&&s[i]!='0') {++cntb;}
            else if(i%2!=0&&s[i]!='1'){++cntb;}
        }
        cout<<min(cnta,cntb)<<endl;
        }

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <limits.h>

typedef long long ll;

ll min(ll a,ll b){
	if(a<b){return a;}
	else{return b;}
}

ll f(ll b,ll n){

	ll ret;

	if(n<b){ret=n;}
	else{ret=f(b,n/b)+(n%b);}

	return ret;

}

int main(){

	ll n,s;

	scanf("%lld",&n);
	scanf("%lld",&s);

	ll ans=LLONG_MAX;

	ll b;

	if(n-s==0ll){ans=n+1ll;}
	else if(n-s>0ll){
		for(b=2ll;b<=(ll)sqrt((double)n-(double)s)+2ll;b+=1ll){
			if((n-s)%(b-1ll)==0ll){
				if(f(b,n)==s){
					ans=min(ans,b);
				}
				if(((n-s)/(b-1ll))+1ll>=2ll){
					if(f(((n-s)/(b-1ll))+1ll,n)==s){
						ans=min(ans,((n-s)/(b-1ll))+1ll);
					}
				}
			}
		}
	}

	if(ans<LLONG_MAX){printf("%lld\n",ans);}
	else{printf("-1\n");}

	return 0;
}

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

int solve(int N, int Q) {
    vector<int> date(110, 0);
    int M;
    int day;
    for (int i = 0; i < N; i++) {
        cin >> M;
        for (int i = 0; i < M; i++) {
            cin >> day;
            date[day]++;
        }
    }

    for (int i = 0; i < date.size(); i++) {
        if (date[i] >= N) return i;
    }
    for (int j = N; j >= Q; j--) {
        for (int i = 0; i < date.size(); i++) {
            if (date[i] >= j) return i;
        }
    }
    return 0;
}

int main(void) {
    int N, Q;
    vector<int> ans;
    while (1) {
        cin >> N >> Q;
        if (!N && !Q) break;
        ans.push_back(solve(N, Q));
    }
    for (int i : ans) cout << i << endl;
}


Measured memory_bytes: 3004
#include<iostream>
#include<queue>
#include<cstring>

using namespace std;

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

char dis[60][60][60][60];

struct State {
  int tx, ty, kx, ky, cost;
};

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int main() {
  int x, y, tx, ty, kx, ky, d[60][60];
  while (true) {
    cin >> x >> y;
    if (x == 0 && y == 0) break;
    cin >> tx >> ty >> kx >> ky;
    --tx, --ty, --kx, --ky;
    rep (i, y) rep (j, x) cin >> d[i][j];
    queue<State> que;
    State s;
    s.tx = tx;
    s.ty = ty;
    s.kx = kx;
    s.ky = ky;
    s.cost = 0;
    que.push(s);
    memset(dis, -1, sizeof(dis));
    int res = 101;
    while (!que.empty()) {
      s = que.front();
      que.pop();
      if (dis[s.tx][s.ty][s.kx][s.ky] != -1) continue;
      if (s.cost > 100) break;
      if (s.tx == s.kx && s.ty == s.ky) {
	res = s.cost;
	break;
      }
      dis[s.tx][s.ty][s.kx][s.ky] = s.cost;
      rep (i, 4) {
	State next = s;
	next.tx += dx[i];
	next.ty += dy[i];
	next.kx -= dx[i];
	next.ky -= dy[i];
	if (next.tx < 0 || x <= next.tx) next.tx -= dx[i];
	if (next.ty < 0 || y <= next.ty) next.ty -= dy[i];
	if (next.kx < 0 || x <= next.kx) next.kx += dx[i];
	if (next.ky < 0 || y <= next.ky) next.ky += dy[i];
	if (d[next.ty][next.tx] == 1) {
	  next.tx -= dx[i];
	  next.ty -= dy[i];
	}
	if (d[next.ky][next.kx] == 1) {
	  next.kx += dx[i];
	  next.ky += dy[i];
	}
	next.cost++;
	que.push(next);
      }
    }
    if (res == 101) cout << "NA" << endl;
    else cout << res << endl;
  }
  return 0;
}

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

using namespace std;
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
  int n;
  while(cin >> n){
    int ans=0;
    rep(i,10)rep(j,10)rep(k,10)rep(l,10){
      ans+=i+j+k+l==n;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(){
  int d,s,i,j,y,y2;
  
  while(scanf("%d",&d)!=EOF){
    j=600/d;
    s=0;
    y=0;
    for(i=0;i<j-1;i++){
      y=y+d;
      y2=y*y;
      s=s+d*y2;
    }
    printf("%d\n",s);
  }
  return(0);
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdlib.h>
using namespace std;
int main()
{
	int a,b;
	char p;
	cin>>a>>p>>b;
	if(p=='+')
		cout<<a+b<<endl;
	else if(p=='-')
		cout<<a-b<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0;char ch=getchar();
	while (!isdigit(ch)) ch=getchar();
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x;
}
int n,cnt[10],ans=0,mn=0;
int main(){
	n=read();
	for (int i=1;i<=n;++i){
		int x=read();
		if (x<400){
			if (!cnt[1]) cnt[1]=1,++ans,++mn;
		}
		else if (x<800){
			if (!cnt[2]) cnt[2]=1,++ans,++mn;
		}
		else if (x<1200){
			if (!cnt[3]) cnt[3]=1,++ans,++mn;
		}
		else if (x<1600){
			if (!cnt[4]) cnt[4]=1,++ans,++mn;
		}
		else if (x<2000){
			if (!cnt[5]) cnt[5]=1,++ans,++mn;
		}
		else if (x<2400){
			if (!cnt[6]) cnt[6]=1,++ans,++mn;
		}
		else if (x<2800){
			if (!cnt[7]) cnt[7]=1,++ans,++mn;
		}
		else if (x<3200){
			if (!cnt[8]) cnt[8]=1,++ans,++mn;
		}
		else ++ans;
	}
	printf ("%d %d",max(mn,1),ans);
	return 0;
}


Measured memory_bytes: 256
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 1000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

typedef long long ll;
// #define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int n, a; cin >> n >> a;
  cout << n*n - a << endl;

  return 0;
}

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

using namespace std;

void solve()
{
	vector<int> Vec(5);
	for(unsigned int i = 0; i < Vec.size(); ++i)
	{
		cin >> Vec[i];
	}
	sort(Vec.begin(), Vec.end());
	for(unsigned int i = Vec.size() - 1; i > 0; --i)
	{
		cout << Vec[i] << " ";
	}
	cout << Vec[0] << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#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 pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

int n,m,dp[(1 << 16)][15];
vector<P> g[15];

int solve(int s){
	REP(i, 0, (1 << 16)) REP(j, 0, 15) dp[i][j] = INF;
	dp[0][s] = 0;
	
	REP(i, 0, (1 << n)){
		REP(j, 0, n){
			if(dp[i][j] == INF) continue;
			for(auto e:g[j]){
				if((i >> e.first) & 1) continue;
				dp[i | (1 << e.first)][e.first] = min(dp[i | (1 << e.first)][e.first], dp[i][j] + e.second);
			}
		}
	}
	
	return dp[(1 << n) - 1][s];
}

int main(){
	cin >> n >> m;
	REP(i,0,m){
		int a,b,c; cin >> a >> b >> c;
		g[a].push_back({b, c});
	}
	
	int mi = INF;
	REP(i,0,n) mi = min(mi, solve(i));
	cout << (mi == INF ? -1 : mi) << endl;
	return 0;
}



Measured memory_bytes: 6980
import java.util.Scanner;

public class Main {

    private static int A, B, C;

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

        A = sc.nextInt();
        B = sc.nextInt();
        C = sc.nextInt();
        System.out.println(solve());
    }

    private static int solve() {
        int sum = A + B + C;
        int max = Math.max(Math.max(A, B), C);

        int diff = max * 3 - sum;
        if ( diff % 2 == 0 ) {
            return diff / 2;
        } else {
            return diff / 2 + 2;
        }
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    for(int i=0;i<n;i++)s[i]-='0';
    long long x=0;
    if(k==2 || k==5){
        for(int i=0;i<n;i++)if(s[i]%k==0)x+=i+1;
        cout<<x<<endl;
        return 0;
    }
    long long p=1,wa=0;
    long long amari[k]={};
    amari[0]++;
    for(int i=n-1;i>=0;i--){
        wa=(wa+p*s[i])%k;
        amari[wa]++;
        p=p*10%k;
    }
    for(int i=0;i<k;i++)x+=amari[i]*(amari[i]-1)/2;
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 3752
// --------------
// Tejas Pandey  |
// 01 - 12 - 19  |
// SUMOMITO PC'19|
// --------------

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

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		int n;
		cin >> n;
		int ig1 = 0,ig2 = 0,ig3 = 0;
		ll ans = 1;
		for(int i = 0;i < n;i++){
			int k;
			cin >> k;
			ll cur = 0;
			if(k == ig1) cur++;
			if(k == ig2) cur++;
			if(k == ig3) cur++;
			if(cur == 3) ig1++;
			else{
				if(k == ig1) ig1++;
				else if(k == ig2) ig2++;
				else ig3++;
			}
			ans *= cur;
			ans %= mod;
			
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_N 100

typedef struct{
  char Mark;
  int num;
} Card;

void swap(int*,int*);
void swap2(char*,char*);
void bubbleSort(Card*,int);
void selectionSort(Card*,int);
void print(Card*,int);
int isStable(Card*,Card*,int);

int main(){
  int N,i;
  char ch;
  Card a[MAX_N],b[MAX_N];
  scanf("%d\n",&N);
  for(i = 0 ; i < N ; i++){
    scanf("%c%d%c",&a[i].Mark,&a[i].num,&ch);
    b[i] = a[i];
  }
  bubbleSort(a,N);  
  selectionSort(b,N);
  print(a,N);
  puts(isStable(a,a,N) ? "Stable" : "Not stable");
  print(b,N);
  puts(isStable(a,b,N) ? "Stable" : "Not stable");
  return 0;
}

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

void swap2(char *a,char *b){
  char temp;
  temp = *a;
  *a = *b;
  *b = temp;
}

void bubbleSort(Card *c,int N){
  int i,j;
  for(i = 0 ; i < N ; i++){
    for(j = N-1 ; j > i ; j--){
      if(c[j].num < c[j-1].num){
        swap(&c[j].num,&c[j-1].num);
        swap2(&c[j].Mark,&c[j-1].Mark);
      }
    }
  }
}

void selectionSort(Card *c,int N){
  int i,j,min;
  for(i = 0 ; i < N ; i++){
    min = i;
    for(j = i+1 ; j < N ; j++){
      if(c[j].num < c[min].num){
        min = j;
      }
    }
    swap(&c[i].num,&c[min].num);
    swap2(&c[i].Mark,&c[min].Mark);
  }
}

void print(Card *c,int N){
  int i;
  for(i = 0 ; i < N ; i++){
    printf("%c%d%c",
           c[i].Mark,c[i].num,(i < N-1 ? ' ' : '\n'));
  }
}

int isStable(Card *a,Card *b,int N){
  int i,flag = 1;
  for(i = 0 ; i < N ; i++){
    if(a[i].Mark != b[i].Mark){
      flag = 0;
      break;
    }
  }
  return flag;
}

Measured memory_bytes: 608
import java.util.Scanner;
public class Main {

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

}

Measured memory_bytes: 27220
import java.util.Scanner;

public class Main{


    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    	int Time = sc.nextInt();
    	int h = Time / 60 / 60;
    	int m = Time / 60 - h * 60;
    	int s = Time - m * 60 - h * 60 * 60;
        System.out.println(h + ":" + m + ":" + s);
        sc.close();
    }

}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        long sum = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 3 == 0 || i % 5 == 0)
                continue;
            sum += i;
        }

        System.out.println(sum);
    }

    public static long gcd(long a, long b) {
        long max = Math.max(a, b);
        long min = Math.min(a, b);

        long re = max % min;
        if (re == 0)
            return min;
        return gcd(min, re);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32760
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		
		long[][] as = new long[2][N];
		long[][] dp = new long[2][N];
		
		for(int i = 0; i < 2; i++){
			for(int j = 0; j < N; j++){
				as[i][j] = sc.nextLong();
			}
		}
		
		dp[0][0] = as[0][0];
		
		for(int i = 0; i < 2; i++){
			for(int j = 0; j < N; j++){
				if(i != 0){
					dp[i][j] = Math.max(dp[i][j], dp[i - 1][j] + as[i][j]);
				}
				if(j != 0){
					dp[i][j] = Math.max(dp[i][j], dp[i][j - 1] + as[i][j]);
				}
			}
		}
		
		System.out.println(dp[1][N - 1]);
		
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}	
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23124
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var H = ReadLongs();

            var count = 0L;
            var highest = H[0];
            for (int i = 0; i < N; i++)
            {
                if (highest <= H[i])
                {
                    count++;
                    highest = Math.Max(highest, H[i]);
                }
            }

            return count;
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

#define DATA_LEN 80

void clear_int(int num[], int length)
{
  int i;
  for (i = 0; i < length; i++) {
    num[i] = 0;
  }
}

void clear_char(char str[], int length) {
  int i;
  for (i = 0; i < length; i++) {
    str[i] = '\0';
  }
}

int read_data(int num[], int length) {
  char str[DATA_LEN + 2];
  int i, j;
  char tmp[3];

  clear_int(num, length);

  fgets(str, sizeof(str), stdin);
  if (strchr(str, '\n') == NULL) {
    while (getchar() != '\n')
      ;
    return 9;
  }
  if (str[strlen(str) - 1] == '\n') {
    str[strlen(str) - 1] = '\0';
  }

  for (i = strlen(str) - 1, j = 0; i >= 0; i -= 2, j++) {
    if (i == 0) {
      strncpy(tmp, str, 1);
    } else { 
      strncpy(tmp, str + i - 1, 2);
    }
    tmp[2] = '\0';

    num[j] = atoi(tmp);
    clear_char(tmp, 3);
  }
  return 0;
}

void num2s(int num[], int num_length, char s[], int str_length)
{
  char tmp[3];
  int i;
  int isHead;

  isHead = 1;

  clear_char(s, str_length);

  for (i = num_length - 1; i >= 0; i--) {
    if (num[i] != 0) {
      break;
    }
  }
  if (i == num_length) {
    s[0] = '0';
    s[1] = '\0';
  } else {
    for ( ; i >= 0; i--) {
      clear_char(tmp, 3);
      if (isHead) {
        sprintf(tmp, "%d", num[i]);
        isHead = 0;
      } else {
        sprintf(tmp, "%02d", num[i]);
      }
      strcat(s, tmp);
    }
  }
}

int main(void)
{
  int n;
  int num1[DATA_LEN / 2], num2[DATA_LEN / 2], answer[DATA_LEN / 2];
  char str[DATA_LEN + 1];
  int i, ret_a, ret_b, j;
  int num_len;
  char buf[100];

  num_len = DATA_LEN / 2;

  fgets(buf, sizeof(buf), stdin);
  n = atoi(buf);
  for (j = 0; j < n; j++) {
    ret_a = read_data(num1, num_len);
    ret_b = read_data(num2, num_len);
    if (ret_a == 9 || ret_b == 9) {
      printf("overflow\n");
      continue;
    }
    clear_int(answer, num_len);

    for (i = 0; i < num_len; i++) {
      answer[i] = num1[i] + num2[i];
      if ((i != 0) && (answer[i - 1] >= 100)) {
        answer[i]++;
        answer[i - 1] -= 100;
      }
    }
    if (answer[i - 1] >= 100) {
      printf("overflow\n");
      continue;
    }

    num2s(answer, num_len, str, DATA_LEN + 1);

    if (strlen(str) == 0) {
      strcpy(str, "0");
    }

    printf("%s\n", str);
  }

  return 0;
}

Measured memory_bytes: 576
#include<iostream>
#include<cstdio>
using namespace std;
#define MOD 1000000007
int n,f[1000010];
int main()
{
	scanf("%d",&n);f[n]=n;f[n-1]=1ll*n*n%MOD;
	for(int i=n-2,s=0;i>0;--i)s=(s+f[i+3])%MOD,f[i]=(f[i+1]+1ll*(n-1)*(n-1)+s+i+1)%MOD;
	printf("%d\n",f[1]);
	return 0;
}


Measured memory_bytes: 4096
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fill(x,c) memset(x,c,sizeof(x))
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int SIZE = 1e6+10;
ll a[SIZE];
int main() {
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n,m,p,ans1=0,ans2=0;
	string s;
	cin>>n>>m;
	map<ll,pair<string,ll> > M;
	rep(i,0,m){
		cin>>p>>s;
		if(M.count(p)){
			if(M[p].fi=="AC");
			else{
				if(s=="WA")M[p].se++;
				else{
					ans1++;
					ans2+=M[p].se;
					M[p] = {"AC",0};
				}
			}
		}else{
			if(s=="AC"){
				ans1++;
				M[p] = {"AC",0};
			}else{
				M[p] = {"WA",1};
			}
		}
	}
	cout<<ans1<<" "<<ans2;
  	return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

// 素数判定
bool is_prime(ll n) {
    if(n == 1) return false;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return true;
}

int main(){
  ll N; cin>>N;
  vector<ll> a(N);

  rep(i,N) cin>>a[i];

  ll yon = 0;
  ll ni = 0;
  ll it = 0;

  rep(i,N){
    if(a[i]%4==0) yon++;
    else if(a[i]%2==0) ni++;
    else it++;
  }

  //check
  if(ni==0 and yon+1 >= it){
    cout<<"Yes"<<endl;
  }
  else if(it > yon){
    cout<<"No"<<endl;
  }
  else cout<<"Yes"<<endl;

}


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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    string rev_S;
    reverse_copy(S.begin(), S.end(), back_inserter(rev_S));

    string first = S.substr(0, (S.length()-1)/ 2);
    string rev_first;
    reverse_copy(first.begin(), first.end(), back_inserter(rev_first));

    string last = S.substr((S.length()+3)/ 2 - 1, (S.length()-1)/ 2);
    string rev_last;
    reverse_copy(last.begin(), last.end(), back_inserter(rev_last));
    if (S == rev_S && first == rev_first && last == rev_last)
        cout << YES << endl;
    else
        cout << NO << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define NIL -1

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j;

  int u,v,c,k;
  int min = INFTY;
  int M[MAX][MAX],vis[MAX],cost[MAX],p[MAX];

  /*for(i=0;i<MAX;i++){
    for(j=0;j<MAX;j++){
      M[i][j]=INFTY
    }
    p[i]=NIL;
    d[i]=0;
    }*/
  
  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }

  /*

    your code
    
  */

  for(i=0;i<n;i++){
    cost[i]=INFTY;
    p[i]=NIL;
    vis[i]=0;
  }
  cost[0]=0;
  
  while(1){
    u=NIL;
    min=INFTY;
 
    for(i=0;i<n;i++){
      if (cost[i]<min && !vis[i]){
	u=i;
	min=cost[i];
      }
    }
    
    if(u==NIL) break;
    vis[u]=1;
    
    for(v=0;v<n;v++){
      if(cost[u]+M[u][v]<cost[v] && !vis[v]){
	cost[v]=cost[u]+M[u][v];
	p[v]=u;
      }
    }
  }
    


  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, cost[i]);
  }

  return 0;
}

Measured memory_bytes: 804
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = "Yes";
        int b = sc.nextInt();
		int c = 0;
        if(a*500<b){s = "No";}
		System.out.println(s);
	}
}

Measured memory_bytes: 21844
import bisect
import itertools
n,m,k = map(int,input().split())
A = [0]+list(map(int,input().split()))
B = [0]+list(map(int,input().split()))

#累積和
a_cum = list(itertools.accumulate(A))
b_cum = list(itertools.accumulate(B))

ans=0
#b_cumを固定して2部探索
#aを読んだときに、k-a残りでどこまで読めるか2ブタン
#bisect_leftならある値未満、bisect_rightならある値以下を探索
for a_i,a in enumerate(a_cum):
    if a>k:
        break
    #0を入れてるので-1する
    b_i = bisect.bisect_right(b_cum,k-a)-1
    ans = max(ans,a_i+b_i)
print(ans)


Measured memory_bytes: 47272
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=1e9+7;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    ll n;
    cin >> n;
    ll m=n;
    ll d=0;
    while (m>0) {
        d+=m%10;
        m/=10;
    }
    if (n%d==0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0; 
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			
			int A = scan.nextInt();
			int B = scan.nextInt();
			
			System.out.println(A*B);
			
			
			
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 35796
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

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

const ll INF = 1 << 30;
// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

class BIT{
public:    
    BIT(){}
    BIT(int n){
        init(n);
    }
    void init(int n){
        size = n;
        FOR(i, 1, size+1){
            data[i] = 0;
        }
    }
    void add(int k, int v){
        while(k <= size){
            data[k] += v;
            k += k & -k;
        }
    }
    ll sum(int k){
        int sum = 0;
        while(k > 0){
            sum += data[k];
            k -= k & -k;
        }
        return sum;
    }
private:
    static const int MAX_N = 100001;
    ll data[MAX_N];
    int size;
};

int N, K;
BIT bit;

int main(){
    while(std::cin >> N >> K, N){
        bit.init(N);

        FOR(i, 1, N+1){
            int n;
            std::cin >> n;

            bit.add(i, n);
        }

        ll res = -INF;
        FOR(i, 1, N+1){
            if(i+K-1 <= N){
                res = std::max(res, bit.sum(i+K-1) - bit.sum(i-1));
            }
        }

        std::cout << res << std::endl;
    }
}

Measured memory_bytes: 1936
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

s = 0

for i in range(N):
   
    s = s + B[(A[i]-1)]

    if (A[i-1]+1) == A[i] and not i == 0:
        s = s + C[A[i-1]-1]


print (s)

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

#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define pb push_back
#define fi first
#define se second

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}
ll LCM(ll x, ll y){
	return x/GCD(x, y)*y;
}

int main() {
	int n, k; cin >> n >> k;
	int p[1005];
	rep(i, 0, n) cin >> p[i];
	sort(p, p+n);
	int ans = 0;
	rep(i, 0, k) ans += p[i];
	cout << ans << endl;
	return 0;
}

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

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

  if (S == "A"){
    cout << "T" << endl;
  }
  else if (S == "T")
  {
    cout << "A" << endl;
  }
  else if (S == "G")
  {
    cout << "C" << endl;
  }
  else
  {
    cout << "G" << endl;
  }
  
  
  
  
}

Measured memory_bytes: 3548
/*#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>
*/
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define rrep()
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    double x;
    while(cin>>x){
        if(x<=48.00)cout<<"light fly";
        else if(x<=51.00)cout<<"fly";
        else if(x<=54.00)cout<<"bantam";
        else if(x<=57.00)cout<<"feather";
        else if(x<=60.00)cout<<"light";
        else if(x<=64.00)cout<<"light welter";
        else if(x<=69.00)cout<<"welter";
        else if(x<=75.00)cout<<"light middle";
        else if(x<=81.00)cout<<"middle";
        else if(x<=91.00)cout<<"light heavy";
        else cout<<"heavy";
        cout<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define ll long long
#define arena ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main() 
{
    ll k;
    cin>>k;
    ll a,b;
    cin>>a>>b;
    ll x=(a-1)/k;
    ll y=b/k;
    if(y-x>0)
    cout<<"OK";
    else
    cout<<"NG";
}

Measured memory_bytes: 3632
N,M,C=gets.split.map(&:to_i)
bs=gets.split.map(&:to_i)
ans=0
N.times do
  ai=gets.split.map(&:to_i)
  v=0
  M.times{|i| v+=ai[i]*bs[i]}
  ans+=1 if v+C>0
end
puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> pii;

int main(void) {

    int H, W, D; cin >> H >> W >> D;
    vector<pii> coords(H*W+1);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int A; cin >> A;
            coords[A] = pii(i, j);
        }
    }

    vector<int> dist(H*W+1);
    for (int i = 1; i <= H*W; i++) {
        if (i <= D) {
            dist[i] = 0;
        } else {
            pii Lc = coords[i-D];
            pii Rc = coords[i];
            dist[i] = dist[i-D] + abs(Lc.first-Rc.first) + abs(Lc.second-Rc.second);
        }
    }

    int Q; cin >> Q;
    for (int i = 0; i < Q; i++) {
        int L, R; cin >> L >> R;
        cout << dist[R] - dist[L] << endl;
    }
    return 0;
}


Measured memory_bytes: 2176
//                          VIVEK UPADHYAY
//                          MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                           TAB -TAK CHODEGA NHI :D

// g++ -std=c++11 file_name.cpp
// ./file_name.out
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<"\n" ;
#define ok cout<<"ok\n" ;
#define dbg(x) cout<<#x<<" = "<<(x)<<"\n";
#define fill(A, VAL) memset(A, VAL, sizeof(A))
#define sz(a) ((int) a.size())
typedef long long ll;
const int MAXN = 2010 ;
const int MAX = 1e7 + 1 ;
const ll inf = 1e18 ;
ll gcd(ll a,ll b){
    
    if(a==0) return b;
    
    return gcd(b%a,a);
    
}
int main () {
    int A , B , K ;
    cin >>A >> B >> K ;
    int cnt = 0 ;
    vector<int> d ;
    for(int i = 1 ; i<=200 ;i++)
    {
        if(A%i==0 && B%i==0)  d.pb(i) ;
    }
    reverse(d.begin(),d.end()) ;
    cout<<d[K-1]<<endl;
    return 0 ;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main(): 

    a=[int(input()) for _ in range(5)]
    ans=10**5
    for i in range(5):
        tmp = a[i]
        for j in range(5):
            if i != j:
                if a[j]%10==0:
                    tmp += a[j]
                else:
                    tmp += (a[j]//10+1)*10
        ans=min(ans,tmp)
    print(ans)
    



if __name__ == "__main__":
    main()
    

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
	int n,i;										
	 int a[100];									
	(n<100);
	
	scanf("%d",&n);							
	 for(i=0 ;i<n ;i++)							
	 {
		 
		 scanf("%d",&a[i]);
		 ((0<=a[i])&&(a[i]<1000));
	 }
	for(i=i;i>0 ;i--)							
	{
		printf("%d",a[i-1]);
		if(!(i-1==0))
		{
			printf(" ");
		}
	}
	printf("\n"); 

	return 0;									
}	
		
			

												

Measured memory_bytes: 600
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    int n;
    cin >> n;
    int b[n-1];
    for(int i=0;i<n-1;i++) cin >> b[i];

    int ans=b[0];
    for(int i=0;i<n-2;i++) ans+=min(b[i],b[i+1]);
    ans+=b[n-2];

    cout << ans << endl;
}

Measured memory_bytes: 3600
use proconio::input;
use proconio::marker::Chars;

fn main() {
	input! {
		s: Chars,
		t: Chars,
	}
	for i in 0..s.len() {
		if s[i] != t[i] {
			println!("No");
			return;
		}
	}
	println!("Yes");
}


Measured memory_bytes: 2128