akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
#define vecout(v,n) for(int i=0; i<n; i++)cout<<v[i]<<" "; cout<<endl;

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}

//x未満の要素数を返す二分探索関数
int b_s(vector<int>&vecxx, int xx) {
	if (xx <= vecxx[0]) { //x以下の要素数を返させる時は"<"に変える
		return 0;
	}
	if (vecxx.back() < xx) { //x以下の要素数を返させる時は"<="に変える
		return vecxx.size();
	}
	int aa1 = 0, aa2 = vecxx.size() - 1, aa3;
	while (aa1 + 1 < aa2) {
		aa3 = (aa1 + aa2) / 2;
		if (vecxx[aa3] >= xx) { //x以下の要素数を返させる時は">"に変える
			aa2 = aa3;
		}
		else {
			aa1 = aa3;
		}
	}
	return aa2;
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す

int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}




signed main() {
	int h,n,a;
	cin >> h>>n;
	rep(i, n) {
		cin >> a;
		h -= a;
	}
	if (h <= 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define res register int
#define ll long long
#define inf 0x3f3f3f3f
#define N 100050
using namespace std;
int a[N],n,m,tot,ans;
inline bool cmp(res x,res y)
{
	return x>y;
}
int main()
{
	scanf("%d",&n);
	for(res i=1;i<=n;i++)
	scanf("%d",&a[i]);
	sort(a+1,a+1+n,cmp); 
	for(res i=1;i<=n;i++)
            if(i+1>a[i+1]){
                res j=i+1,ans=0;
                while(a[j]==i)ans^=1,j++;
                if((ans||((a[i]-i)&1)))puts("First");
                else puts("Second");
                return 0;
            }
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
	int a[2][3000];
	int i=0;
	int j;
	
	while(1){
		scanf("%d %d",&a[0][i],&a[1][i]);
		if(a[0][i]==0 && a[1][i]==0)break;
		i++;
	}
	for(j=0;j<i;j++){
		if(a[0][j]>a[1][j]){
			printf("%d %d\n",a[1][j],a[0][j]);
		}else
		printf("%d %d\n",a[0][j],a[1][j]);
	}
	return 0;
}

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

class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        sc.useDelimiter("[\n]+");
        String s = sc.next();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c >= 'a' && c <= 'z') {
                System.out.print((char)(c - 'a' + 'A'));
            } else {
                System.out.print(c);
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 26036
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]"):
    keihin = set()
    for s in S:
        keihin.add(s)
    print(len(keihin))
    return


# 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)
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
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)


if __name__ == '__main__':
    main()


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

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

int main() {
    int a,b;
    char op;
    cin >> a >> op >> b;
    if(op == '+'){
        cout << a+b << endl;
    }else if(op == '-'){
        cout << a-b << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        String s = sc.next();
        if (s.equals("snuke")) {
          char c = (char) (65 + j);
          String ans = "";
          ans += c;
          ans += i + 1;
          System.out.println(ans);
          return;
        }
      }
    }

  }
}

Measured memory_bytes: 39332
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

struct point {
	int A, B;
	bool operator < (const point& b) {
		return A > b.A;
	}
};
point P[100010];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> P[i].A >> P[i].B;
	}
	sort(P, P + N);
	int ans = 0;
	ans += P[0].A + P[0].B;
	cout << ans << endl;
}

Measured memory_bytes: 4396
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;

typedef long long ll;
const int maxn=1e5+10;
int a[maxn];
bool cmp(int a,int b){
	return  a>b;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	} 
	sort(a,a+n,cmp);
	ll a1=0,a2=0;
	bool f=1;
	for(int i=0;i<n-1;i++){ 
		if(f&&a[i]==a[i+1]){
			a1=a[i];
			f=0;
			i=i+2; 
		//	printf("%d",a1); 
		} 
		if(!f&&a[i]==a[i+1]){
			a2=a[i];
		//	printf("%d",a2);
			break;
		
		} 
	} 
	if(!a1||!a2) printf("0\n");
	else
		printf("%lld\n",a1*a2);
	/*
	test input
	for(int i=0;i<n;i++){
		printf("%d ",a[i]);
	}
	*/
	
	return 0;
	
}

/*
B

const int maxn=1e5+10;
char s[maxn];
bool f=false;
bool ab[30];
int main(){
	scanf("%s",s);
	int len=strlen(s);
	memset(ab,0,sizeof(ab));
	for(int i=0;i<len;i++){
		if(!ab[s[i]-'a']) {
			ab[s[i]-'a']=true;
		}
	} 
	for(int i=0;i<26;i++){
		if(!ab[i]){
			 printf("%c\n",i+'a');
			 f=true;
			 break;
		} 
	}
	if(!f) printf("None\n");
	return 0;
}

*/


/*
A
int main(){
	int x,a,b;
	scanf("%d%d%d",&x,&a,&b);
	if(abs(a-x)<abs(b-x)) printf("A\n");
	else printf("B\n");
	return 0;
} 
*/


Measured memory_bytes: 640
#include<iostream>
#include <functional>
#include<algorithm>
#include <cmath>
#include <string>
#include <map>
using namespace std;

int main(){

	int max=0;
	string a;
	map<string,int> s;
	string x,y;
	
	cin>>a;
	s[a]++;
	x=y=a;
	
	while(cin>>a){
		s[a]++;
		if(y.size()<a.size())
			y=a;
		if(s[a]>max){
			max=s[a];
			x=a;
		}
	}
	
		cout<<x<<" "<<y<<endl;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;
ll a[N];
map<ll,ll>ci,cj1,cj2;
int main()
{
	ll n;cin>>n;
	for(ll i=1;i<=n;i++)
	{
		cin>>a[i];
		ci[i+a[i]]++;
		cj1[i-a[i]]++;
	}
	ll cnt=0;
	for(ll i=1;i<=n;i++)
	{
		cj2[i-a[i]]++;
		cnt+=cj1[i+a[i]]-cj2[i+a[i]];
	}
	cout<<cnt;
	return 0;
}

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

int main(){
  string S;cin>>S;
  priority_queue<int> ans;
  int l=S.size();
  for(int i=2;i<l;i+=2){
    int j=i/2;
    string T1=S.substr(0,j);
    string T2=S.substr(j,j);
    if(T1==T2) ans.push(i);
  }
  cout<<ans.top()<<endl;
}
    


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

int n;
string s;
set <string> g;

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> s;

		g.insert(s);
	}

	cout << g.size() << endl;
}


Measured memory_bytes: 19224
using System;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        long n = long.Parse(Console.ReadLine());
        long[] abcde = new long [5];
        abcde[0] = long.Parse(Console.ReadLine());
        abcde[1] = long.Parse(Console.ReadLine());
        abcde[2] = long.Parse(Console.ReadLine());
        abcde[3] = long.Parse(Console.ReadLine());
        abcde[4] = long.Parse(Console.ReadLine());

        //abcdeからMINを見つける
        long min = abcde.Min();

        //MINの時の最短時間を考える
        long ans = 5;
        if (n >= min)
        {
             ans += (n-1)/min;
             
        }
       
        Console.WriteLine(ans);

    }
}


Measured memory_bytes: 13268
#include <iostream>

using namespace std;

int main() {
  int n, m;
  int t[105];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
  }
  int p, x;
  cin >> m;
  for (int j = 0; j < m; j++) {
    cin >> p >> x;
    int sum = 0;
    for (int i = 1; i <= n; i++) {
      if (i == p) {
        sum += x;
      } else {
        sum += t[i];
      }
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <cstring>
using namespace std;
char v[1001];
int main(){
	cin>>v;
	int s=-1;
	bool flag,flag2;
	flag=flag2=false;
	while(1){
		s++;
		if(v[s]=='C'){
			flag=true;
			break;
		}
		//cout<<v[s];
		if(s==strlen(v))
			break; 
	}
	if(!flag){
		cout<<"No";
		return 0;
	}
	//cout<<s;
	while(1){
		s++;
		if(v[s]=='F'){
			flag2=true;
			break;
		}
	//	cout<<v[s];
		if(s==strlen(v))
			break; 
	}
	if(!flag2){
		cout<<"No";
		return 0;
	}
	//cout<<s;
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
    int N, K, X, Y, ans;
    scanf("%d", &N);
    scanf("%d", &K);
    scanf("%d", &X);
    scanf("%d", &Y);

    if(N<=K){
        ans = N * X;
    }else{
        ans = K * X + (N - K) * Y;
    }

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
public class Main{
  public static void main(String[] args) {
    for(int i=1; i<=9; i++){
      for(int j=1; j<=9; j++){
        int ans = 0;
        ans += (i*j);
        System.out.println(i + "x" + j + "=" +  ans);
      }
    }
  }
}

Measured memory_bytes: 24132
#include "stdio.h"

int main(void)
{
	int n,i,t;
 	scanf("%d",&n);
 	for(i=1;i<=n;i++)
 	{
 		if(i%3==0)
 		{
 			printf(" %d",i);
 			continue;
 		}
 		t=i;
 		while(t>2)
 		{
 			if(t%10==3)
 			{
 				printf(" %d",i);
 				break;	
 			}
 			t /= 10;
 		}
 	}
 	printf("\n");
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int n;
    cin >> n;
    int answer = 0;
    int min = 2000000;
    int num;
    for(int i = 0; i < n; i++){
        cin >> num;
        if(min >= num){
        min = num;
        answer++;
        }
    }
    cout << answer << endl;
}

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

int main(){
    int x;
    cin >> x;
    long long happiness = 0;
    happiness += (x / 500) * 1000;
    x %= 500;
    happiness += (x / 5) * 5;

    cout << happiness << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
// #include "../../Template.cpp"
const int mod = (1e9) + 7;
 
int32_t main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> arr(n+1, vector<int>(m+1, 0));
    for(int i = 0; i < n; i ++) {
        for(int j = 0; j < m; j ++) {
            char ch; cin >> ch;
            arr[i][j] = ch == '.';
        }
    }
    vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
    dp[n-1][m-1] = 1;
    for(int i = n-1; i >= 0; i --) {
        for(int j = m-1; j >= 0; j --) {
            if(i == n-1 && j == m-1) {
                continue;
            }
            if(arr[i][j] == 0) continue;
            dp[i][j] = (arr[i+1][j]*dp[i+1][j]) + (arr[i][j+1]*dp[i][j+1]);
            dp[i][j] %= mod;
        }
    }
    cout << dp[0][0] << endl;
    return 0;
}

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

int main() {
 int a,b ;
  cin >> a >> b ;
 
  if (a%2 == 0 || b%2 == 0){
   cout << "Even" << endl;
  }
  
  else {
   cout << "Odd" << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    ll n,a,b;
    cin >> n >> a >> b;
    cout << n /(a + b) * a + min(n % (a + b), a) << endl;
    return 0;
}

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

int main(){
    int n, k, x, dist;
    cin >> n >> k;
    for (int i=0; i<n; i++) {
        cin >> x;
        if (x < (k - x)) {
            dist += 2*x;
        }
        else {
            dist += 2*(k-x);
        }
    }
    cout << dist << endl;
}

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

int main() {
	int n; cin >> n;
	vector<int> l(n), r(n);
	for (int i = 0; i < n; i++) cin >> l[i] >> r[i];

	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += (r[i] - l[i] + 1);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

int main() {
  int K, X;
  cin >> K >> X;
  for (int i = X - K + 1; i <= X + K - 1; ++i) {
    if (-1000000 <= i and i <= 1000000) {
      cout << i << " ";
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll basis[60];
ll insert(ll mask){
	ll p=1;
	for(ll i=0;i<60;i++){
		if(!(mask&p)){
			p*=2;
			continue;
		}
		if(!basis[i]){
			basis[i]=mask;
			return 1;
		}
		mask^=basis[i];
		p*=2;
	}
	return 0;
}
void solve(){
	ll n;
	cin>>n;
	string s;
	vector<ll> v(n);
	for(ll i=0;i<n;i++)
	cin>>v[i];
	cin>>s;
	for(ll i=n-1;i>=0;i--)
	if(s[i]=='0')
	insert(v[i]);
	else if(s[i]=='1'){
		if(!insert(v[i]))
		continue;
		cout<<"1\n";
		return;
	}
	cout<<"0\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    cin>>qc;
    for(ll i=1;i<=qc;i++){
		solve();
		for(ll j=0;j<60;j++)
		basis[j]=0;
	}	
}


Measured memory_bytes: 3612
#include "bits/stdc++.h"
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define vvi vector<vi>
#define pi pair<int, int>
#define rep(i,a,b) for (int i = a; i < b; i++)
#define F first
#define S second
#define endl "\n"
#define umap unordered_map<int, int>
#define uset unordered_set<int>
#define MOD 1000000007
using namespace std;

int main()
{
    FAST_IO;
    string s;
    cin >> s;
    int c = 0, res = 0;
    rep(i, 0, s.length())
    {
        if (s[i] == 'R')
        {
            c++;
            res = max(c, res);
        }
        else
        {
            c = 0;
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

int main() {
	int now = 0;
	int cnt = 0;
	int ans = 0;
	makei(N);
	makev(a, N);
	sort(all(a));
	rep(N) {
		if (a[i] != now) {
			if (cnt < now)ans += cnt;
			else ans += cnt - now;
			cnt = 1;
			now = a[i];
		}
		else ++cnt;
	}
	if (cnt < now)ans += cnt;
	else ans += cnt - now;
	say(ans);
}

Measured memory_bytes: 640
n = int(input())
ans=1
b=0
thre = 10**18
flag=0
num=list(map(int,input().split()))
for i in range(n):
  if(num[i]==0):
    print(0)
    flag=1
    
if(flag==0):
  for i in range(n):
    ans*=num[i]
    if(ans>thre):
      print('-1')
      b=1
      break
    
if(flag==0 and b==0):
  print(ans)


Measured memory_bytes: 21784
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<unistd.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ST first
#define ND second
#define ll long long
#define ld long double
using namespace std;
using namespace __gnu_pbds;
 
// replace ll with pair if multiset needed
typedef tree<pair<int,int>, null_type, greater<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ordered_set secik;
 
const ll INF = 1e9 + 9;
const ll MOD = 1e9 + 7;
const long long LINF = (ll)1e18 + 3;
const int SIZE = 2e5 + 6;
 
// secik.insert({x, t++});
// secik.erase(secik.lower_bound({x,-1}));
// *secik.find_by_order(x)).first << "\n";
// secik.order_of_key(x)
 
//random_device device;
//mt19937 gener(device());
//uniform_int_distribution<int> gen(0,n-1);

const int XD = 1e5 + 269;

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

	int n,w; cin >> n >> w;

	vector<ll> dp(XD);

	for(int i = 1; i < XD; i++){
		dp[i] = LINF;
	}

	for(int i = 0; i < n; i++){
		ll x,y; cin >> x >> y;	
		for(int i = XD - y - 1; i >= 0; i--){
			dp[i + y] = min(dp[i + y],dp[i] + x);
		} 
	}

	for(int i = XD - 1; i >= 0; i--){
		if(dp[i] <= w){
			cout << i;
			return 0;
		}
	}







}

Measured memory_bytes: 1024
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll a,b,k;
  cin>>a>>b>>k;
  if(a>k){
    a-=k;
  }else if(a<=k){
    k-=a;
    a=0;
    b-=k;
  }
  cout<<a<<' '<<max(ll(0),b)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int w,h; cin >> w >> h;
    char fl[h+2][w+2];
    for(int i = 0; i < h+2; i++){
        if(i == 0 || i == h+1){
            for(int j = 0; j < w+2; j++){
                fl[i][j] = '.';
            }    
        }
        else{
            for(int j = 0; j < w+2; j++){
                if(j == 0 || j == w+1) fl[i][j] = '.';
                else cin >> fl[i][j];
            }
        }
    }

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(fl[i][j] == '#'){
                int c = 0;
                if(fl[i-1][j] == '#') c++;
                if(fl[i+1][j] == '#') c++;
                if(fl[i][j+1] == '#') c++;
                if(fl[i][j-1] == '#') c++;
                if(c == 0){cout << "No" << endl; return 0;}
            }
        }
    }

    cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n,k,a[100000];
	cin>>n>>k;
	for (int i = 0; i < n; ++i){
		cin>>a[i];
	}

	int g=0;
	while(n>k+(k-1)*(g-1)){
		g++;
	}

	cout<<g<<endl;

}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

import sys
from operator import itemgetter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,M=MAP()
A=LIST()
BC=[None]*M
for i in range(M):
    b,c=MAP()
    BC[i]=(b, c)

A.sort()
BC.sort(key=itemgetter(1), reverse=True)

idx=0
A2=[0]*N
for i in range(M):
    b,c=BC[i]
    if idx<N:
        for j in range(idx, idx+b):
            if j==N: break
            A2[j]=c
        idx+=b

ans=0
for i in range(N):
    ans+=max(A[i], A2[i])
print(ans)


Measured memory_bytes: 22504
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;

int main() {

    int N,M,ans=0;
    cin>>N>>M;

    vector<int> p(M);
    // for(int i=0; i<N; i++){cin>>A[i];}
     vector<vector<int>> A(M,vector<int>(10));
     for(int i=0; i<M; i++){
       int k;
       cin>>k;
       for(int j=0; j<10-k; j++){A[i].pop_back();}
       for(int j=0; j<k; j++){cin>>A[i][j];}}
  	 for(int i=0; i<M; i++)cin>>p[i];
  
  for(int b=0; b<(1<<N); b++){
      bitset<10> bits(b);
      vector<int> now(M,0);
    
      for(int i=0; i<M; i++){
        for(int j=0; j<A[i].size(); j++){
        if(bits.test(A[i][j]-1))now[i]++;}}
        // for(int i=0; i<M; i++){cout<<now[i]; if(i==M-1)cout<<endl;}
      for(int i=0; i<M; i++){
    	if(now[i]%2!=p[i])break;
        if(i==M-1)ans++;}
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    int count=0;
    for(int i=0;i<s.length()-1;i++){
      if(s.charAt(i)!=s.charAt(i+1)){
        count++;
      }
    }
    System.out.println(count);
  }
}

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

//template
#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 ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end



int main(){
   int n,x; scanf("%d%d",&n,&x);
   vector<int> a(n); rep(i,0,n)scanf("%d",&a[i]);
   sort(ALL(a));
   rep(i,0,n){
      if(x<a[i]){
         printf("%d\n",i);
         return 0;
      }
      x-=a[i];
   }
   if(x)printf("%d\n",n-1); else printf("%d\n",n);
   return 0;
}

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

typedef long long int ll;

bool isPrime(ll n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

int main()
{
    ios::sync_with_stdio(false);
  
  	ll i,j,n,m;
  	cin >> n >> m;
  
  	cout << (3*n+m)/2 << '\n';
}

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

using namespace std;

int main()
{
    string shead, stail="", s2;
    int n, q;
    bool top = true;

    cin >> shead;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> q;
        if(q == 1) {
            top = !top;
        } else {
            cin >> q >> s2;
            if((top && q == 1) || (!top && q == 2)) {
                stail += s2;
            } else {
                shead += s2;
            }
        }
    }

    if(top) {
        reverse(stail.begin(), stail.end());
        cout << stail << shead << endl;
    } else {
        reverse(shead.begin(), shead.end());
        cout << shead << stail << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
def convert(s): 
  
    # initialization of string to "" 
    new = "" 
  
    # traverse in the string  
    for x in s: 
        new += x  
  
    # return string  
    return new 
k=int(input())
s=input()
if len(s)<=k:
  print(s)
else:
  a=[]
  for i in range(k):
    a.append(s[i])
  a.append('...')
  print(convert(a))

Measured memory_bytes: 9184
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second

using namespace std;

const long long MOD = (long long)1e9 + 7;

long long n, a[409], dp[409][409], sum[409];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> a[1];
	sum[1] = a[1];
	for (int i = 2; i <= n; i++) {
		cin >> a[i];
		sum[i] = sum[i - 1] + a[i];
	}
	memset(dp, 0x3f, sizeof(dp));
	dp[1][1] = 0;
	for (int i = 2; i <= n; i++) {
		dp[i][i] = 0;
		for (int j = i - 1; j > 0; j--) {
			for (int k = i - 1; k >= j; k--)
				dp[i][j] = min(dp[i][j], dp[k][j] + dp[i][k + 1] + sum[i] - sum[j - 1]);
		}
	}
	cout << dp[n][1] << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 1536
/***************************************************
 * Problem Name : F - LCS.cpp
 * Problem Link : https://atcoder.jp/contests/dp/tasks/dp_f
 * OJ           : atCoder
 * Verdict      : Trying
 * Date         : 2019-01-26
 * Problem Type : easy dp
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<cstring>
#include<string>
#include<sstream>
#include<cmath>
#include<vector>
#include<queue>
#include<cstdlib>
#include<deque>
#include<stack>
#include<map>
#include<set>
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define FileRead freopen ("/home/saikat/Desktop/logN/input.txt", "r", stdin);
#define FileWrite freopen ("/home/saikat/Desktop/logN/output.txt", "w", stdout);
#define SET(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define pll pair <ll, ll>
#define debug cout <<"#########\n";
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define Pow2(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define Max3(a, b, c) max(a, max(b, c))
#define Min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 3005
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
std::string NumberToString ( T Number ) {
    std::ostringstream ss;
    ss << Number;
    return ss.str();
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
string A, B, ans = "";
int dp[MAX][MAX];
int LCS (int i, int j) {
    if (i == (int) A.size() || j == (int) B.size() ) {
        return 0;
    }

    if (dp[i][j] != -1) return dp[i][j];

    int cnt = 0;

    if (A[i] == B[j]) {
        cnt = 1 + LCS (i + 1, j + 1);

    } else {
        int val1 = LCS (i + 1, j);
        int val2 = LCS (i, j + 1);
        cnt =  max (val1, val2);
    }

    return dp[i][j] = cnt;
}
void printALCS (int i, int j) {
    if (i == (int) A.size() || j == (int) B.size() ) {
        cout << ans << "\n";
        return;
    }

    if (A[i] == B[j]) {
        ans += A[i];
        printALCS (i + 1, j + 1);

    } else {
        if (dp[i + 1][j] > dp[i][j + 1]) printALCS (i + 1, j);
        else {
            printALCS (i, j + 1);
        }
    }
}
int main () {
    __FastIO;
    cin >> A >> B;
    SET (dp, -1);
    LCS (0, 0);
    printALCS (0, 0);
    return 0;
}


Measured memory_bytes: 35840
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    string s; cin >> s;
    if (s=="RRR") cout << 3 << endl;
    else if (s=="SRR") cout << 2 << endl;
    else if (s=="RRS") cout << 2 << endl;
    else if (s=="SSS") cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3624
import math
from collections import deque


def check(A, d, K):
    diff = []
    for a in A:
        if a % d != 0:
            diff.append(a % d)
    totalinc = 0
    diff.sort()
    q = deque(diff)
    cnt = 0
    while len(q):
        x = q.popleft()
        cnt += x
        totalinc += x
        while len(q) and q[-1] + totalinc >= d:
            y = q.pop()
            totalinc -= d-y
    cnt += totalinc
    return cnt <= K


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    total = sum(A)
    divs = [1, total]
    rt = int(math.sqrt(total))
    for i in range(2, rt+1):
        if total % i == 0:
            divs.append(i)
            if i**2 != total:
                divs.append(total//i)
    ans = 0
    for d in divs:
        if check(A, d, K):
            ans = max(ans, d)
    print(ans)


if __name__ == "__main__":
    main()


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


int main() {
    ll n, k;
    cin >> n >> k;

    ll ans = 0;
    if (n - 2 < 11) {
        for (ll i = 1; i <= n - 2; i++) {
            for (ll j = 1; j <= 5; j++) {
                if (9 * (7 * (i - 1) + j + 8) % 11 == k) ans++;
            }
        }
    } else {
        for (ll i = 1; i <= 11; i++) {
            for (ll j = 1; j <= 5; j++) {
                if (9 * (7 * (i - 1) + j + 8) % 11 == k) ans++;
            }
        }
        ans *= (n - 2) / 11;
        for (ll i = 1; i <= (n - 2) % 11; i++) {
            for (ll j = 1; j <= 5; j++) {
                if (9 * (7 * (i - 1) + j + 8) % 11 == k) ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int N, W[100];
    cin >> N;
    for(int i=0; i<N; i++) cin >> W[i];
    int S = accumulate(W, W+N, 0);
    int ans = S;
    for(int i=0; i<N; i++){
        int s = 0;
        for(int j=0; j<=i; j++) s += W[j];
        ans = min(ans, abs(S-2*s));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
int main(){
  int n,c;
  cin >> n >>c ;
  
  long long val[n],wt[n];
  for(int i=0;i<n;i++){
 	cin >> wt[i] >> val[i] ;
  }
  
  long long  dp[n+1][c+1] ;
  
  for(int i=0;i<=n;i++){
    for(int j=0;j<=c;j++){
      if(i==0 || j==0)
        dp[i][j]=0;
      else if(wt[i-1]<=j){
        dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]] , dp[i-1][j]) ;
      }else{
        dp[i][j]=dp[i-1][j];
      }
      
    }
  }
  
  cout<<dp[n][c] ;
  
  return 0;
}


Measured memory_bytes: 82476
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

typedef long long int ll;
using namespace std;
using namespace __gnu_pbds;
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

typedef tree< pair < ll, ll >, null_type, less< pair < ll, ll > >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll mod = 998244353;
const ll MAXN = 1e5+5;
const ll inf = 1e18;

int main()
{
    fastio;
    ll n;
    cin >> n;
    vector < ll > v(8, 0), a(n);
    ll cnt = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        ll b = a[i] / 400;
        if(b < 8) v[b]++;
        else cnt++;
    }
    ll ans = 0;
    for(int i = 0; i < 8; i++){
        if(v[i]) ans++;
    }
    cout << max((ll)1, ans) << " " << ans + cnt;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define MAX 2000000001
#define INF 2000000001
 
void maxHeapify(int i);
int extract();
void increaseKey(int,int);
void insert(int);
int H,A[MAX+1];
 
int main(){
  int key;
  char com[10];
 
  while(1){
      scanf("%s",com);
 
      if(com[0]=='e'&&com[1]=='n') break;
 
      if(com[0]=='i'){
          scanf("%d",&key);
          insert(key);
      }
      else{
          printf("%d\n",extract());
      }
  }
 
  return 0;
}
 
int parent(i){
  return floor(i/2);
}
 
int left(i){
  return 2*i;
}
 
int right(i){
  return 2*i+1;
}
 
void maxHeapify(int i){
  int l, r, largest, tmp;
  l=left(i);
  r=right(i);
 
  if(l<=H && A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=H && A[r]>A[largest]) largest=r;
 
  if(largest!=i){
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(largest);
  }
}
 
int extract(){
    int max;
 
    if(H<1) return -INF;
 
    max=A[1];
    A[1]=A[H--];
    maxHeapify(1);
 
    return max;
}
 
void increaseKey(int i,int key){
    int tmp;
 
    if(key<A[i]) return;
 
    A[i]=key;
 
    while(i>1&&A[i/2]<A[i]){
        tmp=A[i];
        A[i]=A[i/2];
        A[i/2]=tmp;
 
        i/=2;
    }
}
 
void insert(int key){
    H++;
 
    A[H]=-INF;
 
    increaseKey(H,key);
}



Measured memory_bytes: 5652
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n, k; cin >> n >> k;
  Vll a(n); cin >> a;

  Vll p1(n+1), p2(n+1), s(n+1);

  rep(i, n) s[i+1] = s[i] + a[i];
  rep(i, n) p1[i+1] = p1[i] + max(a[i], 0ll);
  drep(i, n) p2[i] = p2[i+1] + max(a[i], 0ll);

  ll ans = -INFll;
  for (int i = 0; i+k <= n; ++i) {
    ll x = max(s[i+k] - s[i], 0ll);
    x += p1[i] + p2[i+k];
    chmax(ans, x);
  }

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


Measured memory_bytes: 3456
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include<limits.h>
#include<iomanip>
typedef long long ll;
using namespace std;

int main() {
    int a;
    cin >> a;
    if(a%2==0) cout << a/2-1 << endl;
    else cout << a/2 << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io;
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(){
    let mut s = String::new();
    io::stdin().read_line(&mut s);
    println!("{}", s.chars().filter(|&c| c == '1' ).count());
}

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

int main() {
        int n;
        long long int x[200010],copy[200010];
        cin>>n;
        for(int i=0; i<n; ++i) {
                cin>>x[i];
                copy[i]=x[i];
        }

        sort(copy,copy+n);

        long long int large=copy[n/2], small=copy[(n-1)/2];
        for(int i=0; i<n; ++i){
                if(x[i]<=small)cout<<large<<endl;
                else cout<<small<<endl;
        }
        return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main()
{
  ll n;
  cin >> n;
  vector<char> a;
  while (n > 0) {
    int i = n % 26;
    if (i == 0){
      a.push_back('z');
      n -= 1;
    } else {
      a.push_back('a' + i - 1);
    }
    n /= 26;
  }
  reverse(a.begin(), a.end());
  for (char x : a) {
    cout << x;
  }
  cout << "\0" << endl;
}



Measured memory_bytes: 3596
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;
int inf=1<<29;
long long llinf=1ll<<60;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
int dp[1000001];
int dp_o[1000001];
int pn[200];
int po[200];

int main(void){
    int n,i,j=0,s;
    rep(i,200){
        pn[i]=i*(i+1)*(i+2)/6;
        if(pn[i]%2)po[j++]=pn[i];
    }
    s=j;
    rep(i,1000001)dp[i]=dp_o[i]=inf;
    dp[0]=dp_o[0]=0;
    rep(i,200){
        for(j=pn[i];j<1000001;j++){
            dp[j]=min(dp[j-pn[i]]+1,dp[j]);
        }
    }
    rep(i,s){
        for(j=po[i];j<1000001;j++){
            dp_o[j]=min(dp_o[j-po[i]]+1,dp_o[j]);
        }
    }
    while(1){
        n=in();
        if(!n)break;
        print2(dp[n],dp_o[n]);
    }
    return 0;
}


Measured memory_bytes: 9492
import java.util.*;
/**
 * @author yamato
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int min = Math.min(a, b);
		int max = Math.max(a, b);
		String ans = "";
		int i;
		for(i=0;i<max;i++) {
			ans += Integer.toString(min);
		}
		System.out.print(ans);
		
	}

}


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

int main() {
int a, b;
cin>> a >> b;
if (a<b) cout << "a < b" << endl;	
else if ( a > b ) cout << "a > b" << endl;
 else cout << "a == b" << endl;

// your code goes here
	return 0;
}

Measured memory_bytes: 1156