akhauriyash/Code-Regression huggingface dataset:
#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; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    string s; cin>>s;
    int n; scanf("%d",&n);
    bool f=1;
    rep(i,1,s.size())if(s[0]!=s[i])f=0;
    if(f){
        printf("%lld\n",(ll)(s.size()*n)/2);
        return 0;
    }
    ll cnt[110]={};
    int now=1;
    rep(i,0,s.size()-1){
        if(s[i]==s[i+1])now++;
        else cnt[now]+=n,now=1;
    }
    cnt[now]+=n;
    if(s[0]==s.back()){
        int idx=0,sum=0;
        while(s[idx]==s[0])idx++;
        cnt[idx]-=n-1; sum+=idx;
        idx=s.size()-1;
        while(s[idx]==s.back())idx--;
        cnt[s.size()-1-idx]-=n-1; sum+=s.size()-1-idx;
        cnt[sum]+=n-1;
        cerr<<sum<<endl;
    }
    ll ans=0;
    rep(i,1,110)ans+=1LL*cnt[i]*(i/2);
    printf("%lld\n",ans);
    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(20);
    ld l;
    cin >> l;
    cout << (l / 3.0) * (l / 3.0) * (l / 3.0) << "\n";
    return 0;
}

Measured memory_bytes: 256
N = int(input())
cnt = 0
flag = 0
for i in range(N):
    a,b = map(int,input().split())
    if a ==b:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        flag = 1
        break
if flag == 1:
    print("Yes")
else:
    print("No")

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

int main() {
vector<char> sta(3);
cin >> sta.at(0) >> sta.at(1) >> sta.at(2);

if (sta.at(0) == 'A' && sta.at(1) == 'A' && sta.at(2) == 'A') {
cout << "No" << endl;
} else if (sta.at(0) == 'B' && sta.at(1) == 'B' && sta.at(2) == 'B') {
  cout << "No" << endl;
}else {
  cout << "Yes" << endl;
}
}

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

using ll = long long;

int w[200],v[200],cap,n;
ll dp[100][200000];

ll call(int at,int weigh)
{
	if(at == n)return 0;
	if(dp[at][weigh] != -1)return dp[at][weigh];
	ll sum1 = 0,sum2 = 0;
	if(weigh+w[at] <= cap)sum1 = call(at+1,weigh+w[at])+v[at];
	sum2 = call(at+1,weigh);
	return dp[at][weigh] = max(sum1,sum2);
}


int main(int argc, char const *argv[])
{
	memset(dp,-1,sizeof dp);
	scanf("%d%d",&n,&cap);
	for(int i = 0; i < n;i++){
		scanf("%d %d",&w[i],&v[i]);
	}
	printf("%lld\n",call(0,0));
	return 0;
}

Measured memory_bytes: 156544
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+3];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=n-1;i>=1;i--)
	{
		if(a[i]-a[i+1]>=2)
		{
			cout<<"No";
			return 0;
		}
		if(a[i]-a[i+1]==1)
			a[i]--;
	}
	cout<<"Yes";
	return 0;
}

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

using namespace std;

int main()
{
  unsigned long long int n;
  cin>>n;
  unsigned long long int temp, sum;
  temp = n/500;
  sum = temp*1000;
  temp = n%500;
  temp = temp/5;
  sum += temp *5;
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = inf + 7;
const int N = (int)2e5 + 5;

bool isPal(string s){
	string t=s;
	reverse(all(s));
	return s==t;	
}

string toString(int n){
	int r=n;
	string s="";
	while(r!=0){
		s+=r%10;
		r/=10;
	}
	return s;
}

void solve(){
	string s;
	cin>>s;
	rep(i,sz(s)-1){
		if(s[i+1]==s[i]){
			cout<<"Bad";return;
		}
	}
	cout<<"Good";
}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
def xor_a2b(a,b) : 
    flg = a % 2 != 0
    
    if flg: 
        a += 1
    mod = (b - a) % 4
    if mod == 0:
        res = b
    elif mod == 1:
        res =  1
    elif mod == 2:
        res = b + 1
    else:
        res = 0
    if flg:
        return (a-1) ^ res
    else:
        return res
      
a,b = map(int,input().split())

print(xor_a2b(a,b))

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

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

  int N, K;
  string S;
  cin >> N >> K >> S;

  vector<int> v;
  if(S[0] == '1') {
    v.push_back(0);
  }
  char c = S[0];
  for (int i = 0; i < N; i++) {
    int cnt = 1;
    while(i + 1 < N) {
      if(S[i + 1] == c) {
        i++;
        cnt++;
      } else {
        break;
      }
    }
    v.push_back(cnt);
    c = (c == '0') ? '1' : '0';
  }
  
  int l = v.size();
  int *b = new int[l + 1]{};
  for (int i = 0; i < l; i++) {
    b[i + 1] = b[i] + v[i]; 
  }
  
  int ans = 0;
  for (int i = 0; i < l; i += 2) {
    if (i == 0) {
      int r = min(l, 2 * K);
      ans = b[r];
    } else {
      int r = min(l, i + 2 * K);
      ans = max(ans, b[r] - b[i - 1]);
    }
  }
  cout << ans << "\n";
  return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> x(n), y(n), h(n);
  for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> h[i];

  int MAXN = 100;

  for(int posY = 0; posY <= MAXN; posY++) {
    for(int posX = 0; posX <= MAXN; posX++) {
      // 頂上がどれくらいの高さであってほしいか
      // -1はまだよくわからない時、0以上は確定している時、
      // -2はダメだってわかった時
      int needH = -1;

      for(int i = 0; i < n; i++) {
        if(h[i] > 0) {
          // この頂点から見て、頂上がposY, posXの時に、
          // どのくらいの高さがあってほしいかを求める
          int tmp = h[i] + abs(posY - y[i]) + abs(posX - x[i]);
          if(needH == -1) {
            needH = tmp;
          } else {
            if(needH != tmp) {
              needH = -2;
              break;
            }
          }
        }
      }
      if(needH == -2) continue;

      for(int i = 0; i < n; i++) {
        if(h[i] == 0) {
          // 高さが0の場合に矛盾がないかどうかを調べる
          int dist = abs(posY - y[i]) + abs(posX - x[i]);
          if(needH > dist) {
            needH = -2;
            break;
          }
        }
      }
      if(needH == -2) continue;

      cout << posX << " " << posY << " " << needH << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    string S;
    cin>>S;
    if(S.at(2)==S.at(3) && S.at(4)==S.at(5)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<functional>
#include<string>
#include<vector>
#include<map>
using namespace std;
#define int long long
#define inf 1145141919810931
typedef pair<int, int> P;
struct edge { int to, cost; };
vector<edge>G[114514];
int d[114514];

void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P>>Q;
	fill(d, d + 114014, inf);
	d[s] = 0;
	Q.push(P(0, s));
	while (Q.size()) {
		P p = Q.top();
		Q.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				Q.push(P(d[e.to], e.to));
			}
		}
	}
}
signed main() {
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		G[a - 1].push_back({ b - 1,c });
		G[b - 1].push_back({ a - 1,c });
	}
	int q, k;
	cin >> q >> k;
	dijkstra(k - 1);
	for (int i = 0; i < q; i++) {
		int x, y;
		cin >> x >> y;
		printf("%lld\n", d[x - 1] + d[y - 1]);
	}
}

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

int main(){
    int n,cnt = 0,memo = 1e+9;
    cin >> n;
    int a[n],b[n];
    
    rep(i,0,n){
        cin >> a[i];
    }
    
    rep(i,0,a[0]+1){
        cnt = 0;
        rep(j,0,n){
            b[j] = a[j];
            //cout << b[j] << endl;
        }
        
        cnt += i;
        b[0] -= i;
        
        rep(j,0,n-1){
            cnt += b[j]*2;
            b[j+1] = max(0,b[j+1]-b[j]);
            b[j] = 0;
            //cout << cnt << endl;
        }
        
        cnt += b[n-1];
        //cout << cnt << endl;
        
        memo = min(memo,cnt);
    }
    
    cout << memo << endl;
    
        
    
    
    return 0;
}


Measured memory_bytes: 3172
//package com.company;

import java.util.Scanner;

public class Main {
    static int mod = 998244353;
    static long[][] nchoosek;
    public static void main(String[] args) {
        nchoosek = new long[4001][4001];
        for (int i = 0; i < nchoosek.length; i++) {
            nchoosek[i][0] = nchoosek[i][i] = 1;
        }
        for (int i = 2; i < nchoosek.length; i++) {
            for (int j = 1; j < i; j++) {
                nchoosek[i][j] = (nchoosek[i - 1][j] + nchoosek[i - 1][j - 1]) % mod;
            }
        }
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        for (int i = 2; i <= 2 * k; i++) {
            int pairs;
            if (i > k) {
                pairs = k - i / 2;
            } else {
                pairs = (i - 1) / 2;
            }
            int active = k - 2 * pairs;
            if (i % 2 == 0) active -= 1;
            long times2 = 1;
            long total = 0;
            for (int j = 0; j <= pairs; j++) {
                long choice = times2 * nchoosek[pairs][j] % mod;
                times2 = times2 * 2 % mod;
                // active >= 0, j >= 1, += n/n-1
                if (active + j - 1 < 0) continue;
                total += choice * nchoosek[n + active - 1][active + j - 1];
                if (i % 2 == 0) {
                    total += choice * nchoosek[n + active - 2][active + j - 1];
                }
                total %= mod;
            }
            System.out.println(total);
        }
    }
}


Measured memory_bytes: 168148
import numpy as np

n = int(input())

A = [int(input()) for i in range(n)]
A = np.array(A)
a_max = np.max(A)
a_max_ind = np.argmax(A)
A[a_max_ind] = 0

for i in range(n):
    if i != a_max_ind:
        print(a_max)
    else:
        print(np.max(A))


Measured memory_bytes: 21852
s = list(input())
n = len(s) + 1

i = 0
left = 0
right = 0
ans = 0
tmp = 0

while i < n-1:
	if s[i] == '<':
		break
	i += 1
	tmp += 1
ans += tmp * (tmp + 1) // 2
while i < n-1:
	if i == n-2:
		if s[i] == '>':
			right += 1
			break
		else:
			left += 1
			break
	if s[i] == '<' and s[i+1] == '>':
		left += 1
		while True:
			if s[i+1+right] == '>':
				right += 1
				if i+1+right == n-1:
					break
			else:
				break
		if left >= right:
			ans += left * (left + 1) // 2 + (right - 1) * right // 2
		else:
			ans += right * (right + 1) // 2 + (left - 1) * left // 2
		i += right + 1
		left = 0
		right = 0
	elif s[i] == '<':
		left += 1
		i += 1

print(ans + left * (left + 1) // 2 + right * (right + 1) // 2 )


Measured memory_bytes: 8092
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int cost = 1001;
		Scanner scanner = new Scanner(System.in);
		String NT[] = scanner.nextLine().split(" ",0);
		int N = Integer.parseInt(NT[0]);
		int T = Integer.parseInt(NT[1]);

		for(int i = 0; i < N; i++){
			scanner.hasNextLine();
			String nt[] = scanner.nextLine().split(" ",0);
			int n = Integer.parseInt(nt[0]);
			int t = Integer.parseInt(nt[1]);
			if(t <= T & n <= cost){
				cost = n;
			}
		}
		if(cost == 1001){
			System.out.print("TLE");
		}else{
			System.out.print(cost);
		}
	}

}


Measured memory_bytes: 21716
#include<stdio.h>
#define M 10001
int main(){
  int a,b,ab,o;
  char s[3];
  a=b=ab=o=0;
  while(scanf(" %*d%*c%s",s)!=EOF){
    if     (s[1]=='B')ab++;
    else if(s[0]=='B')b++;
    else if(s[0]=='A')a++;
    else              o++;
  }
  printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
  return 0;
}

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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll k;
    cin >> n >> k;
    vector<P> vp;
    REP(i, n){
        int a, b;
        cin >> a >> b;
        vp.push_back(make_pair(a, b));
    }
    sort(vp.begin(), vp.end());
    ll sum = 0;
    REP(i, n){
        sum += vp[i].second;
        if(sum >= k){
            cout << vp[i].first << "\n";
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 1400
# ABC092b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
d, x = map(int, input().split())
a = [int(input()) for _ in range(n)]

ans = x
for i in range(1, n+1):
    for j in range(1, d + 1, a[i - 1]):
        #print(i, j)
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>

using namespace std;

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


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

    vector<int> res;
    rep(i, N) {
        res.push_back(abs(L + i));
    }

    sort(res.begin(), res.end());
    ll ans = 0;
    rep2(i, 0, N) {
        if (abs(L + i) == res[0]){
            continue;
        }
        ans += L + i;
    }
    cout << ans << endl;

}


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

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

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

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

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

	LL N;
	string S;

	cin >> N;
	cin >> S;
	int ans = 0;
	for(int i=0; i<=999; i++){
		int c = 0;
		char pin[4] = {0};
		sprintf(pin, "%03d", i);
		for(int j=0; j<S.size(); j++){
			if(S[j] == pin[c]){
				c++;
				if(c > 2){
					break;
				}
			}
		}
		if(c > 2){
			ans++;
		}
	}

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3724
def bl(l):
    b=[]
    c=[]
    for (i,j) in enumerate(l):
        if(i==0):b.extend([j])
        elif(j>b[-1]):b.extend([j])
        elif(c and j>c[-1] and j<b[-1]):c.extend([j])
        elif(not c):c.extend([j])
        else:return 0
    return 1

l=[list(map(int,input().split())) for i in range(int(input()))]
[print("YES") if bl(i) else print("NO") for i in l]



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

using namespace std;

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

	vector<int> cost(n);
	for(auto &i: cost) scanf("%d", &i);

	vector<int> dp(n+1);
	dp[0] = 0;
	int temp = INT_MAX;
	for(int i = 1; i<n; i++){
		temp = INT_MAX;
		for(int j = max(0, i-k); j<i; j++){
			if(temp > (abs(cost[j] - cost[i]) + dp[j])) 
				temp = (abs(cost[j] - cost[i]) + dp[j]);
		}
		dp[i] = temp;
	}
	/*for(int i = 0; i<n; i++)
		printf("%d: %d\n", i, dp[i]);*/
	cout<<dp[n-1]<<"\n";
	return 0;
}

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


int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool ans = false;
  if (abs(a-c) <= d) ans = true;
  if (abs(a-b) <= d && abs(c-b) <= d) ans = true;
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
from sys import stdin
def main():
    input = stdin.readline
    n, k, c = map(int, input().split())
    s = input()

    l, r = [], []
    cur = 0
    count = 0

    while cur <= n:
        if s[cur] == "o":
            count += 1
            l.append((count, cur+1))
            cur += c

        cur += 1

    cur = n
    count = k

    while cur >= 0:
        if s[cur] == "o":
            r.append((count, cur+1))
            count -= 1
            cur -= c

        cur -= 1

    ans = (i[1] for i in set(l) & set(r))
    for i in sorted(ans):
        print(i)


if __name__ == '__main__':
    main()

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

// start ~ end の範囲内に##が含まれているかチェック
bool check(string s, int start, int end) {
  for (int i = start; i + 1 <= end; ++i) {
    if (s[i] == '#' && s[i + 1] == '#') return false;
  }
  return true;
}

int main() {
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  A--, B--, C--, D--;
  string S;
  cin >> S;
  bool ok = true;
  // ##が含まれてたらNG
  if (!check(S, A, C) || !check(S, B, D)) ok = false;
  // C > D の場合は B ~ D の間に...が含まれているかを確認する必要がある
  // ...が含まれていればすぬけ君がふぬけ君を追い抜かせる
  if (C > D) {
    bool over = false;
    for (int i = B; i <= D; ++i) {
      if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
        over = true;
        break;
      }
    }
    ok = over;
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;

int main(int, char**) {
	string s, t;
	cin >> s >> t;
	t.erase(t.size() - 1);
	if (s==t) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0; 
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int main(){

    int n,m;
    cin>>n>>m;
    char arr[n][m];
    for(int i = 0;i<n;i++){
        for(int j = 0;j<m;j++){
            cin>>arr[i][j];
        }
    }
    ll int dp[n][m];
    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    for(ll int i = 1;i<n;i++){
        if(arr[i][0]=='#')
            dp[i][0] = 0;
        else
            dp[i][0] = dp[i-1][0];
    }

    for(ll int i = 1;i<m;i++){
        if(arr[0][i]=='#')
            dp[0][i] = 0;
        else
            dp[0][i] = dp[0][i-1];
    }

    for(ll int i = 1;i<n;i++){
        for(ll int j = 1;j<m;j++){

            if(arr[i][j]=='#'){
                dp[i][j] = 0;
            }
            else{
                dp[i][j] = (dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;
            }

        }
    }
    cout<<dp[n-1][m-1]<<endl;
}







Measured memory_bytes: 9088
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
string to_string_keta(const long long int l, const int keta) {
	ostringstream oss;

	oss << std::setw(keta) << std::setfill('0') << l;

	return oss.str();
}

int main() {
	int a; 
	while (cin >> a) {
		a %= 39;
		if (!a)a = 39;
		cout << "3C" << to_string_keta(a,2) << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	string str;
	cin >> str;
	if (str.at(5) != '1' && (str.at(6) == '1' || str.at(6) == '2' || str.at(6) == '3' || str.at(6) == '4')) {
		printf("Heisei");
	}
	else {
		printf("TBD");
	}
}

Measured memory_bytes: 256
class BinaryIndexedTree(): #1-indexed
    def __init__(self, n):
        self.n = n
        self.tree = [0 for _ in range(n + 1)]

    def sum(self, idx):
        res = 0
        while idx:
            res += self.tree[idx]
            idx -= idx & -idx
        return res

    def get(self, idx):
        return self.sum(idx) - self.sum(idx - 1)

    def add(self, idx, x):
        while idx <= self.n:
            self.tree[idx] += x
            idx += idx & -idx

    def bisect_left(self, x):
        if x <= 0: return 0
        res, tmp = 0, 2**((self.n).bit_length() - 1)
        while tmp:
            if res + tmp <= self.n and self.tree[res + tmp] < x:
                x -= self.tree[res + tmp]
                res += tmp
            tmp >>= 1
        if res >= self.n:
            return self.n
        return res + 1

N = int(input())
A = list(map(int, input().split()))

D = [None for _ in range(N)]

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

bit = BinaryIndexedTree(N + 1)

res = 0

for i in range(N):
    s = bit.sum(D[i])
    lt = bit.bisect_left(s)
    rt = bit.bisect_left(s + 1)
    bit.add(D[i], 1)
    res += (i + 1) * (D[i] - lt) * (rt - D[i])

print(res)

Measured memory_bytes: 90152
#include <bits/stdc++.h>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 999999999
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;
    llong mod = 1000000007;

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

    int main()
    {
    int n;
    cin>>n;
    string s;
    cin>>s;
    int x=0;
    int ans=0;
    for(int i=0; i<n; i++)
    {
        if(s[i]=='I') ++x;
        else --x;
        ans =max(x,ans);
    }
    cout<<ans<<endl;
    }

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

using namespace std;

int main() {
  int x, y; cin >> x >> y;
  for(int i = 0; i <= x; ++i) {
    int j = x - i;
    if(i * 2 + j * 4 == y) {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}


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

def p(s, num):
    print(s*num, end="")

def main():
    sx, sy, tx, ty = map(int, input().split())

    w, h = tx-sx, ty-sy

    p("R", w)
    p("U", h)
    p("L", w)
    p("D", h+1)
    p("R", w+1)
    p("U", h+1)
    p("L", 1)
    p("U", 1)
    p("L", w+1)
    p("D", h+1)
    p("R", 1)
    print()

if __name__ == "__main__":
    main()

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

int main(){
  int N, A, B, i, digisum, sum;
  scanf("%d%d%d", &N, &A, &B);

  sum=0;
  for(i=1; i<=N; i++){
    digisum = i%10 + (i%100)/10 + (i%1000)/100 + (i%10000)/1000 + (i%100000)/10000 + i/100000;
    if(digisum>=A && digisum<=B)sum+=i;
  }

  printf("%d\n", sum);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,d;
  cin>>d>>n;
  int t[d];
  for(int i=0;i<d;i++) cin>>t[i];
  int a[n],b[n],c[n];
  for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
  int dp[d+1][101];
  memset(dp,-1,sizeof(dp));
  for(int i=0;i<n;i++){
    if(a[i]<=t[0]&&t[0]<=b[i])
      dp[1][c[i]]=0;
  }
  for(int i=1;i<d;i++){
    for(int j=0;j<101;j++){
      if(dp[i][j]<0) continue;
      for(int k=0;k<n;k++){
	if(a[k]<=t[i]&&t[i]<=b[k]){
	  dp[i+1][c[k]]=max(dp[i+1][c[k]],dp[i][j]+abs(j-c[k]));
	}
      }
    }
  }
  int ans=0;
  for(int i=0;i<101;i++)
    if(~dp[d][i]) ans=max(ans,dp[d][i]);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3248
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Pipes;
using System.Linq;
using System.Reflection.PortableExecutable;
using System.Runtime.InteropServices.ComTypes;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Security.Cryptography.X509Certificates;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        Queue<int> q = new Queue<int>();
        bool[] hasVisit;
        int[] prev;
        void bfs(List<List<int>> v)
        {
            while (q.Count != 0)
            {
                int now = q.Dequeue();
                for (int i = 0; i < v[now].Count; i++)
                {
                    int next = v[now][i];
                    if (!hasVisit[next])
                    {
                        hasVisit[next] = true;
                        prev[next] = now;
                        q.Enqueue(next);
                    }
                }
            }
        }

        void Omame()
        {
            cin = new Scanner();
            long X = cin.nextLong();

            long yen = 100;
            int year = 1;
            while (true)
            {
                yen = (long)Math.Floor(yen * 1.01);

                if(yen >= X)
                {
                    Console.WriteLine(year);
                    return;
                }
                year++;
            }
        }
    }
}


Measured memory_bytes: 27920
package main

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

func main() {
  var n int = NextInt()
  var a []int = NextIntArray()
  var s,k,m int64
  for i:=0;i<n;i++ { s += int64(a[i]) }
  m = (int64(n)*int64(n+1))/2
  if s%m != 0 {
    fmt.Println("NO")
    return
  }
  k = s/m
  var d []int64 = make([]int64,n)
  for i:=0;i<n-1;i++ { d[i] = int64(a[i+1]-a[i])-k }
  d[n-1] = int64(a[0]-a[n-1])-k
  for i:=0;i<n;i++ {
    if d[i] > 0 || d[i]%int64(n) != 0 {
      fmt.Println("NO")
      return
    }
  }
  fmt.Println("YES")
}

var reader = bufio.NewReaderSize(os.Stdin,1000000)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n,_ = strconv.Atoi(NextLine())
  return n
}
func NextIntArray() []int {
  var s []string = strings.Split(NextLine()," ")
  var a []int = make([]int,len(s))
  for i:=0;i<len(s);i++ { a[i],_ = strconv.Atoi(s[i]) }
  return a
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int MX = 200010;
ll bit[MX];
void add(int i, ll x){
	for(++i; i < MX; i += i & -i) bit[i] = max(bit[i], x);
}
ll sum(int i){
	ll res = 0;
	for(++i; i; i -= i & -i) res = max(res, bit[i]);
	return res;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	vi h(n), a(n);
	rep(i, n) cin >> h[i];
	rep(i, n) cin >> a[i];
	
	vi hs = h; sort(all(hs)); hs.erase(unique(all(hs)), hs.end());
	rep(i, n) h[i] = lower_bound(all(hs), h[i]) - hs.begin();
	rep(i, n) add(h[i], sum(h[i] - 1) + a[i]);
	cout << sum(n) << endl;
	return 0;
}

Measured memory_bytes: 4224
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		String s;
		char a = 'a';
		int count[] = new int[26];
		BufferedReader kbd = new BufferedReader(
				new InputStreamReader(System.in));
		while ((s = kbd.readLine()) != null){
			for (int i = 0; i < s.length(); i++) {
				if (Character.isLetter(s.charAt(i)))
					count[Character.toLowerCase(s.charAt(i)) - 'a']++;
			}
		}
		for (int i = 0; i < 26; i++)
			System.out.println(a++ + " : " + count[i]);
	}

}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;g
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll n, k;
    cin >> n >> k;

    ll dig = 0;

    while (n) {
        n /= k;
        dig++;
    }

    cout << dig << endl;
}


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

int main(){
    string S;
    int i;
    int S_l;
    int c_cnt = 0, tmp = 0;
    bool ans = false;

    cin >> S;
    S_l=S.size();

    if (S[0] == 'A'){
        for (i=2; i < S_l-1; i++){
            if(S[i] == 'C')
                c_cnt++;
        }
        if (c_cnt == 1){
            for (i=1; i < S_l; i++){
                if(64 < S[i] && S[i] < 91 && S[i] != 'C')
                tmp++;
            }
        if (tmp == 0)
            ans = true;
        }

    }
    if (ans == true)
        cout << "AC" << endl;
    else
        cout << "WA" << endl;
}




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


int main(void){
	int H, W; cin >> H >> W;
	int i, j;
	char a[H][W];
	bool h[H] = {}, w[W] = {};

	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			cin >> a[i][j];
			if (a[i][j] == '#') {
				h[i] = true;
				w[j] = true;
			}
		}
	}

	for (i = 0; i < H; i++) {
		if (h[i]) {
			for (j = 0; j < W; j++) {
				if (w[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            if (a < 1200)
            {
                Console.WriteLine("ABC");
            }
            else
            {
                Console.WriteLine("ARC");
            }
        }
    }
}


Measured memory_bytes: 13140
// Problem: A - Plural Form
// Contest: AtCoder - AtCoder Beginner Contest 179
// URL: https://atcoder.jp/contests/abc179/tasks/abc179_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define ll long long int
#define ii int
#define du double
#define jmp "\n"
#define vl vector<ll>
#define vvl vector<vl>
#define pb push_back
#define printv(v)     \
  for (auto x : v)    \
    cout << x << " "; \
  cout << jmp;
#define vi vector<int>
#define vb vector<bool>
#define ump unordered_map
#define SORT(v) sort(v.begin(), v.end())
#define REV(x) reverse(x.begin(), x.end())
#define all(x) x.begin(), x.end()
#define SET(x, a) memset(x, a, sizeof(x))
#define si(x) x.size()
#define ff first
#define ss second
#define iin insert
#define deb(x) cout << "test " << #x << "=" << x << jmp
#define deb2(x, y) cout << "test " << #x << "=" << x << "," << #y << "=" << y << jmp
using namespace std;
const ll nax = 1e5 + 5;
void solve()
{
  string s;
  cin >> s;
  if (s[si(s) - 1] == 's')
    s += "es";
  else
    s += "s";
  cout << s << jmp;
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  // cin >> t;
  while (t--)
    solve();
  return 0;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

int N;

void  rot(int& a, int& b) {
	int na=b;
	int nb=N-a-1;

	a=na;
	b=nb;
}

int solve(vector<vector<int>>coors) {

	int ans=1e9;
	int same_num = 0;
	for (int i = 0; i<3; ++i)if (coors[0][i] == coors[1][i])same_num++;


	if (same_num == 0) {
		bool flag = true;
		for (int i = 0; i<3; ++i)if (coors[0][i] + coors[1][i] != N - 1)flag = false;

		if (flag) {
			ans = min(ans, 5);
		}
		else {

			int now_x = coors[0][0];
			int now_y = coors[0][1];
			int now_z = coors[0][2];
			for (int i = 0; i < 4; ++i) {
				for (int j = 0; j < 4; ++j) {
					for (int k = 0; k < 4; ++k) {
						int anum = 0;
						anum = (i == 3 ? 1 : i) + (j == 3 ? 1 : j) + (k == 3 ? 1 : k);
						for (int l = 0; l < 3; ++l) {
							anum += abs(coors[0][l] - coors[1][l]);
						}
						ans = min(ans, anum);

						rot(coors[0][2], coors[0][0]);
					}
					rot(coors[0][0], coors[0][1]);
				}
				rot(coors[0][1], coors[0][2]);
			}
		}
	}
	else if (same_num == 1) {
		int same_pos=-1;
		for(int i=0;i<3;++i)if(coors[0][i]==coors[1][i])same_pos=i;

		vector<int>v{ 0,1,2 };
		v.erase(find(v.begin(),v.end(),same_pos));


		for (int i = 0; i < 4; ++i) {
			int anum = 2;
			anum += (i == 3 ? 1 : i) ;
			for (int l = 0; l < 3; ++l) {
				anum += abs(coors[0][l] - coors[1][l]);
			}
			ans = min(ans, anum);
			rot(coors[0][v[0]], coors[0][v[1]]);
		}
	
	}
	else if(same_num==2){
		for (int dx = -1; dx <= 1; ++dx) {
			for (int dy = -1; dy <= 1; ++dy) {
				for (int dz = -1; dz <= 1; ++dz) {
					vector<int>ncoor(coors[0]);
					ncoor[0]+=dx;
					ncoor[1]+=dy;
					ncoor[2]+=dz;

					bool ok=true;

					int n_same_num=0;
					for (int i = 0; i < 3; ++i) {
						if(ncoor[i]<0||ncoor[i]>=N)ok=false;

						if(ncoor[i]==coors[1][i])n_same_num++;
					}
					if(n_same_num>=2)ok=false;
					if (ok) {
						int need=abs(dx)+abs(dy)+abs(dz);
						ans = min(ans, need+solve(vector<vector<int>>{ncoor, coors[1]}));
					}

				}
			}
		}
	}
	return ans;
}

int main() {
	int X;cin>>X;
	int num=X/100+3;
	cout<<"ai1";
	for(int i=0;i<num;++i)cout<<'3';
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3096
<?php
$count_500 = trim((fgets(STDIN)));
$count_100 = trim((fgets(STDIN)));
$count_50 = trim((fgets(STDIN)));
$total = intval(trim((fgets(STDIN))));

echo combination(50*50*50, $total, $count_500, $count_100, $count_50)."\n";

function combination($max, $total, $count_500, $count_100, $count_50) {
  $count = 0;
  $memo = [];
  for ($j=0; $j <= $count_500; $j++) {
    for ($k=0; $k <= $count_100; $k++) {
      for ($l=0; $l <= $count_50; $l++) {
        if (!array_key_exists($j.'_'.$k.'_'.$l, $memo)) {
          if ((500*$j + 100*$k + 50*$l) === $total) {
            $count++;
            $memo[$j.'_'.$k.'_'.$l] = true;
          } else {
            $memo[$j.'_'.$k.'_'.$l] = false;
          }
        } else {
            continue;
        }
      }
    }
  }
  return $count;
}


Measured memory_bytes: 25076
import sys
P = int(input())
As = list(map(int, input().split()))
rs = [0]*P
mod = P
sys.setrecursionlimit(pow(10, 8))

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, (y-1)//2)**2 * x % mod
    
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, power(b, mod-2))

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NNN = 3000
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
C = []
for i in range(P):
    C.append(cmb(P-1, i))


for i in range(P):
    if As[i]:
        rs[0] += 1
        tmp = 1
        for k in range(P):
            k = P-1-k
            rs[k] += (-1 + 2*(k%2)) * tmp * C[k]
            rs[k] %= mod
            tmp = tmp * i % mod
print(*rs)



Measured memory_bytes: 45916
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

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

    ll score = 0LL;

    for(int i=0;i<=min(n,k);++i) {
        for(int l=0;l<=i;++l) {
            vector<ll> b;
            int r = i-l;
            for(int j=0;j<l;++j) {
                b.push_back(a[j]);
            }
            for(int j=0;j<r;++j) {
                b.push_back(a[n-1-j]);
            }
            sort(b.begin(), b.end());
            ll tmp_score = 0LL;
            int s = 0;
            while(s < min(i, k-i) && b[s] < 0) {
                ++s;
            }
            for(int j=s;j<i;++j) {
                tmp_score += b[j];
            }

            score = max(score, tmp_score);
        }
    }

    // for(int i=0;i<=k;++i) { // 宝石を取る回数 (あとで捨てるものも含む)
    //     for(int l=0;l<=min(n,i);++l) { // 左から l 個取る
    //         vector<ll> b;
    //         for(int j=0;j<l;++j) {
    //             b.push_back(a[j]);
    //         }
    //         for(int j=0;j<min(n,i)-l;++j) {
    //             b.push_back(a[n-1-j]);
    //         }
    //         sort(b.begin(), b.end());
    //         ll tmp_score = 0LL;
    //         for(int j=b.size()-1;j>=0;--j) {
    //             if(j < k-i && b[j] < 0) break;
    //             tmp_score += b[j];
    //         }
    //         score = max(score, tmp_score);
    //     }
    // }

    cout << score << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();
        int[] T = new int[N];
        for (int i = 0; i < N; ++i) {
            T[i] = sc.nextInt();
        }
        Arrays.sort(T);
        sc.close();

        int ans = 0;
        for (int i = 0; i < N;) {
            ++ans;
            int st = i;
            while (i < N && T[i] - T[st] <= K && i - st < C) {
                ++i;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 49776
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}

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

int main(){
	int n,x;
	scanf("%d%d",&n,&x);
	int a[105];
	for(int i=0;i<n;++i)scanf("%d",&a[i]);
	sort(a,a + n);
	long long sum = 0;
	for(int i=0;i<n;++i){
		sum+=a[i];
		if(sum > x){
			printf("%d",i);
			return 0;
		}
	}
	if(sum == x)printf("%d",n);
        else printf("%d",n - 1);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
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;
}
signed main() {
    int p,m,c;cin>>p>>m>>c;
    cout<<p+m+c<<endl;
}




Measured memory_bytes: 3096
N = int(input())
P = [int(x) - i - 1 for i, x in enumerate(input().split())]
cnt = 0
for i in range(N - 1):
  if P[i] == 0:
    cnt += 1
    P[i + 1] = 1
cnt += 1 if P[-1] == 0 else 0
print(cnt)

Measured memory_bytes: 13956
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  
  cin >> s;
  
  if(s =="SUN") cout <<7;    
  else if(s=="MON") cout <<6;  
  else if(s=="TUE") cout <<5;
  else if(s=="WED") cout <<4;
  else if(s=="THU") cout <<3;     
  else if(s=="FRI") cout <<2;
  else if(s=="SAT") cout <<1;      
          
          
}

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

using namespace std;

#define MAX 100005

int n;
int cell[MAX][4];
int memo[MAX][4];


int call(int col,int row){
    if(row == n) return 0;
    if(memo[row][col] != -1) return memo[row][col];
    if(col == 0) return memo[row][col] = cell[row][col] + max(call(1,row + 1),call(2,row + 1));
    else if(col == 1) return memo[row][col] = cell[row][col] + max(call(0,row + 1),call(2,row + 1));
    else if(col == 2) return memo[row][col] = cell[row][col] + max(call(1,row + 1),call(0,row + 1));
}

int main(){
    cin >> n;
    memset(memo,-1,sizeof(memo));
    for(int r = 0; r < n; r++)
        for(int c = 0; c < 3; c++)
            cin >> cell[r][c];
    int res = call(0,0);
    res = max(res,call(1,0));
    res = max(res,call(2,0));
    cout << res << '\n';

}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

set<long long> v;

void dfs(int i, long long prev=0) {
  if (prev > 3234566667LL) {
    return;
  }
  if (prev) v.insert(prev);
  if (i-1 >= 0) dfs(i-1, prev*10+(i-1));
  if (i != 0 || prev != 0) dfs(i, prev*10+i);
  if (i+1 < 10) dfs(i+1, prev*10+(i+1));
}

void solve() {
  int k; scanf("%d", &k);
  for (int i = 0; i < 10; ++i) {
    dfs(i);
  }
  for (auto e: v) {
    if (!--k) {
      printf("%lld", e);
    }
  }
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 8544
#include<bits/stdc++.h>
using namespace std;
 
void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
bool sortinrev(const pair<int, int>& a, const pair<int, int>& b) {
    return a.first + a.second > b.first + b.second;
}
 
int main()
{
    fast();
    int a ; 
    string s;
    cin>>a>>s;
    if(a>=3200)
    	cout<<s;
    else
    	cout<<"red";
	return 0 ;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# CGL_7_E: Circles - Cross Points of Circles

from math import sqrt


def cross_point(circle1, circle2):
    x1, y1, r1 = circle1
    x2, y2, r2 = circle2

    if r1 < r2:
        x1, x2 = x2, x1
        y1, y2 = y2, y1
        r1, r2 = r2, r1

    p1p2 = (x2-x1, y2-y1)
    np = norm(p1p2)

    if np > (r1+r2)**2 or np < (r1-r2)**2:
        return []
    else:
        lp = sqrt(np)
        a = (p1p2[0]/lp, p1p2[1]/lp)
        b = ((y1-y2)/lp, (x2-x1)/lp)
        h = sqrt((r1+r2+lp)*(-r1+r2+lp)*(r1-r2+lp)*(r1+r2-lp)) / (2 * lp)
        t = sqrt(r1*r1 - h*h)
        if h < 1e-10:
            return [(x1 + t*a[0] + h*b[0], y1 + t*a[1] + h*b[1])]
        else:
            return [(x1 + t*a[0] + h*b[0], y1 + t*a[1] + h*b[1]),
                    (x1 + t*a[0] - h*b[0], y1 + t*a[1] - h*b[1])]


def norm(v):
    x, y = v
    return x**2 + y**2


def run():
    c1 = [int(i) for i in input().split()]
    c2 = [int(i) for i in input().split()]

    ps = cross_point(c1, c2)

    if len(ps) == 0:
        raise ValueError('two circles do not intersect')
    if len(ps) == 1:
        ps *= 2

    p1, p2 = ps
    if p1 > p2:
        p1, p2 = p2, p1

    print("{:.8f} {:.8f} {:.8f} {:.8f}".format(*p1, *p2))


if __name__ == '__main__':
    run()



Measured memory_bytes: 5704