akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto tmp = readln.split.to!(long[]);
    auto N = tmp[0], K = tmp[1];
    auto xs = readln.split.to!(long[]);
    long minTime = long.max;
    foreach (i; 0..N-K+1) {
        auto j = i + K - 1;
        auto t = min(abs(xs[i]) + xs[j] - xs[i], abs(xs[j]) + xs[j] - xs[i]);
        if (t < minTime) minTime = t;
    }
    if (minTime == long.max) minTime = 0;
    writeln(minTime);
}



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

using namespace std;

#define ll long long
ll dp[1005][1005] , n , m , mod=1e9+7;
char arr[1005][1005];

ll solve(int r , int c)
{
    if (r==n && c==m) return 1;
    if (r>n || c>m || arr[r][c]=='#') return 0;
    ll ans;
    if (dp[r][c]!=-1) return dp[r][c];
    ans = (solve(r+1,c)%mod+solve(r,c+1)%mod)%mod;

    return dp[r][c]=ans;
}

int main()
{
    cin >> n >> m;
    memset(dp , -1 , sizeof(dp));
    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=m; j++)
            cin >> arr[i][j];
    }

    cout << solve(1,1) << "\n";

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    double X[N], Y[N], XYabs[N];
    for (int i = 0; i < N; i++) cin >> X[i];
    for (int i = 0; i < N; i++) cin >> Y[i];
    for (int i = 0; i < N; i++) XYabs[i] = fabs(X[i] - Y[i]);
    
    double dis1 = 0, dis2 = 0, dis3 = 0, disinf = 0;
    for (int i = 0; i < N; i++) {
        dis1 += XYabs[i];
        dis2 += pow(XYabs[i], 2);
        dis3 += pow(XYabs[i], 3);
        disinf = max(disinf, XYabs[i]);
    }
    dis2 = pow(dis2, 1.0 / 2.0);
    dis3 = pow(dis3, 1.0 / 3.0);
    cout << fixed << setprecision(6) << dis1 << endl;
    cout << fixed << setprecision(6) << dis2 << endl;
    cout << fixed << setprecision(6) << dis3 << endl;
    cout << fixed << setprecision(6) << disinf << endl;
}


Measured memory_bytes: 3456
n, k = map(int, input().split())
a = list(map(int, input().split()))

mod = 10 ** 9 + 7
a.sort()

def extGCD(a, b):
    if b == 0:
        return a, 1, 0
    g, y, x = extGCD(b, a%b)
    y -= a//b * x
    return g, x, y

def moddiv(a, b):
    _, inv, _ = extGCD(b, mod)
    return (a * inv) % mod

N = 10 ** 5 + 10
fact = [0] * (N)
fact[0] = 1
for i in range(1, N):
    fact[i] = (fact[i-1] * i) % mod

def comb(a, b):
    return moddiv(moddiv(fact[a], fact[a-b]), fact[b])

def minsum(a):
    ret = 0
    for i, x in enumerate(a[:n-k+1]):
        ret += x * comb(n-i-1, k-1)
        ret %= mod
    return ret

b = [-x for x in reversed(a)]
print((-minsum(b) - minsum(a))%mod)

Measured memory_bytes: 15320
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include<sstream>
using namespace std;

long long gcd(long long n, long long m) {
	while (m != n) {
		if (m > n) m = m - n;
		else n = n - m;
	}
	return m;
}

int main() {
	long long  N, M;
	cin >> N >> M;
	char S[N];
	char T[M];
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> T[i];
	}

	long long k = gcd(N, M); // 最大公約数
	long long n = N / k;
	long long m = M / k;
	long long L = k * n * m;

	bool check = true;
	for (int i = 0; i < k && check == true; i++) {
		if (S[n*i] != T[m*i]) {
			check = false;
		}
	}

	if (check == true) cout << L << endl;
	if (check == false) cout << -1 << endl;

	return 0;
}

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

using namespace std;

string s;

vector < int > v;

int main() {
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'S')
            v.push_back(1);
        else if (s[i] == 'T' && (!v.size() || v[v.size() - 1] == 2))
            v.push_back(2);
        else if (s[i] == 'T' && (v.size() && v[v.size() - 1] == 1)) {
            v.pop_back();
        }
    }
    cout << v.size();
}


Measured memory_bytes: 1532
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;

const ll B = 1056379;
const ll MOD = 105637897;

bool contain(string a, string b){
    int al = a.size(), bl = b.size();
    if(al > bl) return false;
    ll t = 1;
    for(int i = 0; i < al; i++) t = t * B % MOD;
    ll ah = 0, bh = 0;
    for(int i = 0; i < al; i++) ah = (ah * B + a[i]) % MOD;
    for(int i = 0; i < al; i++) bh = (bh * B + b[i]) % MOD;
    for(int i = 0; i + al <= bl; i++){
        if(ah == bh){
            bool res = true;
            for(int j = i; j < i + al; j++) if(a[j - i] != b[j]) res = false;
            if(res) return true;
        }
        if(i + al < bl) bh = (bh * B + b[i + al] - b[i] * t + MOD * t) % MOD;
    }
    return false;
}

int count(string s, string t, int k){
    string reps;
    while(reps.size() < t.size()) reps += s;
    for(int i = 0; i < k; i++) reps += reps;
    int n = reps.size();
    int m = t.size();
    int maxans = n / m;
    int now = 1;
    while(now < maxans) now *= 2;
    string maxt;
    for(int i = 0; i < now; i++) maxt += t;
    int mid = now / 2;
    while(mid){
        if(contain(maxt.substr(0, now * m), reps)) now += mid;
        else now -= mid;
        mid /= 2;
    }
    if(!contain(maxt.substr(0, now * m), reps)) now--;
    return now;
}

int main()
{
    string s, t;
    cin >> s >> t;
    int ans = count(s, t, 2);
    if(count(s, t, 3) > ans) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 32088
import java.util.Scanner

object Main extends App{
  override def main(args : Array[String]) : Unit = {
    val scanner = new Scanner(System.in)

    val a,b = scanner.nextInt

    var c:MyComparable = new ComparableTwoInt(a,b)

    val str = c.compare()
    println(str)
  }

}


class ComparableTwoInt(a0 : Int , b0:Int) extends MyComparable{
  val a = a0
  val b = b0

  def compare():String = {
    (a,b) match {
      case (m,n) if m < n =>
        "a < b"
      case (m,n) if m > n =>
        "a > b"
      case (m,n) if m == n =>
        "a == b"
    }
  }
}

trait MyComparable {
  val a:Int
  val b:Int
  def compare(): String
}

Measured memory_bytes: 44972
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
  ll n,ans=0;cin>>n;
  ll a[n],b=0;
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(ll i=0;i<n/2;i++){
      ans+=a[n-i-1];
      ans+=a[n-b-2];
      b++;
  }
  if(n%2==0){
    ans-=a[n-b-1];
  }
  cout<< ans<<endl;
}


Measured memory_bytes: 5092
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void)
{
	int N;
	long x = 1,L,f = 0,g = 1;

	scanf("%d\n", &N);

	for (int i = 0; i < N; i++)
	{
		scanf("%ld ", &L);
		if (L == 0)
		{
			g = 0;
			break;
		}
		else if (f == 0 && L > (long)1000000000000000000 / x)
		{
			f = -1;
		}
		x *= L;
	}

	printf("%ld", f == 0 ? x*g : f*g );

}

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

int main()
{
    int X, N; cin >> X >> N;
    vector<bool> D(102); // 0～101

    for (int i = 0; i < N; i++) {
        int p;
        cin >> p;
        D[p] = true;
    }
    pair<int, int> ans(99999, -1);
    int dif;
    for (int i = 0; i <= 101; i++) {
        if (D[i]) continue;
        dif = abs(X - i);
        ans = min(ans, pair<int,int>(dif, i));
    }
    cout << ans.second << endl;

    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

bool dfs(int cur, vector<vector<pair<int, int> > > &G, vector<int> &x, int cost){
    x[cur] = cost;
    bool ret = true;
    for(auto nxt : G[cur]){
        
        if(x[nxt.second] == -INF){
            //cout << cur << " " << nxt.second << " " << cost + nxt.first << endl;
            ret = dfs(nxt.second, G, x, cost + nxt.first);
            if(ret == false) return false;
        }else{
            if(x[nxt.second] - cost != nxt.first) return false;
        }
    }

    return true;
}

signed main(){
    
    int n, m; cin >> n >> m;
    vector<vector<pair<int, int> > > G(n);
    for(int i = 0; i < m; i++){
        int l, r, d; cin >> l >> r >> d;
        l--;
        r--;
        G[l].push_back({d, r});
        G[r].push_back({-d, l});
    }

    bool ans = true;
    vector<int> x(n, -INF);
    for(int i = 0; i < n; i++){
        if(x[i] == -INF){
            if(!dfs(i, G, x, 0LL)) ans = false;
        }
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 17408
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
#include <float.h>
using namespace std;



#define N 50000

void eratosthenes(bool prime[N]) {
	for (unsigned long long int i = 0; N > i; ++i) prime[i] = 1;
	prime[0] = prime[1] = 0;
	for (unsigned long long int i = 0; N > i; ++i) {
		if (prime[i]) {
			for (unsigned long long int j = i + i; j < N; j += i) {
				prime[j] = 0;
			}
		}
	}
}

bool is_prime(const unsigned n, vector<unsigned long long int> vec) {
	switch (n) {
	case 0: // fall-through
	case 1: return false;
	}

	// n > 2 が保証された

	for (auto i: vec) {
		if (i >= n) return true;
		if (n%i == 0) return false;
	}

	return true;
}


int main() {
	bool prime[N];
	eratosthenes(prime);
	vector<unsigned long long int> vec;
	for (unsigned long long int i = 0; i < N; ++i) {
		if (prime[i]) {
			vec.push_back(i);
		}
	}
	unsigned long long int n;
	cin >> n;
	cout << n << ": ";
	unsigned int pos = 0;
	while (!is_prime(n,vec)) {
		if (n % vec[pos] == 0) {
			n /= vec[pos];
			cout << vec[pos] << " ";
		}
		else {
			pos++;
		}
	}
	cout << n << endl;
	return 0;
}


Measured memory_bytes: 3316
#include <iostream>
#include <cmath>

using namespace std;

double degToRad(int deg) {
  return deg * M_PI / 180;
}

int main(void) {
  double x = 0.0, y = 0.0;
  int deg = 90;

  while(1) {
    int l, d;
    scanf("%d,%d", &l, &d);
    if(l == 0 && d == 0) break;

    x += l*cos(degToRad(deg));
    y += l*sin(degToRad(deg));

    deg -= d;
  }

  cout << (int)x << endl;
  cout << (int)y << endl;

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
using namespace std;
int a[4],b[2];
int main(){
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1];
	sort(a,a+4);sort(b,b+2);
	cout<<a[1]+a[2]+a[3]+b[1]<<endl;
	return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int r, g;
  cin >> r >> g;
  cout << 2*g - r << endl;
  return 0;
}

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

const int N = 1e3L + 11;
int a[N];
int cnt[N];

int main() {
	ios :: sync_with_stdio(false);
	int n, m; cin >> n >> m;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	while(m --) {
		int x; cin >> x;
		for(int i = 1; i <= n; i ++)
			if(a[i] <= x) {
				cnt[i] ++;
				break;
			}
	}
	cout << distance(cnt, max_element(cnt + 1, cnt + n + 1)) << '\n';
	return 0;
}

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

#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ld long double

#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)
#define Fit(i,v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define Fitd(i,v) for(__typeof((v).rbegin()) i = (v).rbegin(); i != (v).rend(); ++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))

using namespace std;

#include <bits/stdc++.h>

using namespace std;


int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a + b + c >= 22 ? "bust\n" : "win\n");
#ifdef LOCAL
    cout << (double) clock() / CLOCKS_PER_SEC << "\n";
#endif
}


Measured memory_bytes: 256
using System;
class lamp
{
    public static void Main()
    {
        string line = Console.ReadLine();
        string[] normal = line.Split(' ');
        int h = int.Parse(normal[0]);
        int w = int.Parse(normal[1]);
        string[,] s = new string[h, w];
        int[,] vartical = new int[h, w];
        int[,] side = new int[h, w];
        int counter = 0;
        int pointer = 0;
        int turn = 0;
        for (int i = 0; i < h; i++)
        {
            string line2 = Console.ReadLine();
            for (int k = 0; k < w; k++)
            {
                s[i, k] = line2[k].ToString();
            }
        }

        for (int i = 0; i < h; i++)
        {
            pointer = 0;
            counter = 0;
            while (pointer<w)
            {
                if (s[i,pointer]=="#")
                {
                    side[i, pointer] = 0;
                    turn = counter;
                    while (turn>0)
                    {
                        side[i, pointer - turn] = counter;
                        turn--;
                    }
                    pointer++;
                    counter = 0;
                }
                else
                {
                    pointer++;
                    counter++;
                }

            }
            if (counter>0)
            {
                
                for (int j = 0; j < counter; j++)
                {
                    side[i, w - 1 - j] = counter;
                }
            }
        }

        for (int i = 0; i < w; i++)
        {
            pointer = 0;
            counter = 0;
            while (pointer<h)
            {
                if (s[pointer,i]=="#")
                {
                    vartical[pointer, i] = 0;
                    turn = counter;
                    while (turn>0)
                    {
                        vartical[pointer - turn, i] = counter;
                        turn--;
                    }
                    pointer++;
                    counter = 0;
                }
                else
                {
                    pointer++;
                    counter++;
                }
            }
            if (counter>0)
            {
                for (int j = 0; j < counter; j++)
                {
                    vartical[h - 1 - j, i] = counter;
                }
            }
        }

        int max = 0;
        int tmp = 0;
       // Console.WriteLine();
        for (int i = 0; i < h; i++)
        {
            for (int k = 0; k < w; k++)
            {
                // Console.Write("{0},", vartical[i, k]);
                tmp = side[i, k] + vartical[i, k] - 1;
                if (tmp>max)
                {
                    max = tmp;
                }
            }
            //Console.WriteLine();
        }
        Console.WriteLine("{0}",max);
    }
}

Measured memory_bytes: 172384
#include <cstdio>

int main(void)
{
	int n;

	scanf("%d", &n);

	int t = n % 10;

	if (t == 2 || t == 4 || t == 5 || t == 7 || t == 9)
		puts("hon");
	else if (t == 0 || t == 1 || t == 6 || t == 8)
		puts("pon");
	else
		puts("bon");
	return 0;
}

Measured memory_bytes: 1644
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

int main()
{
	int n;
	cin >> n;
	REP(rep, n)
	{
		string s[2];
		int x[2];
		x[0] = 0; x[1] = 0;
		cin >> s[0] >> s[1];
		REP(i, 2)
		{
			REP(j,s[i].size())
			{
				if (s[i][j] == 'm')
				{
					if (j == 0) x[i] += 1000;
					else x[i] += 1000 * (s[i][j-1] - '0');
				}
				if (s[i][j] == 'c')
				{
					if (j == 0 || s[i][j-1] == 'm') x[i] += 100;
					else x[i] += 100 * (s[i][j-1] - '0');
				}
				if (s[i][j] == 'x')
				{
					if (j == 0 || s[i][j - 1] == 'm' || s[i][j - 1] == 'c') x[i] += 10;
					else x[i] += 10 * (s[i][j - 1] - '0');
				}
				if (s[i][j] == 'i')
				{
					if (j == 0 || s[i][j - 1] == 'm' || s[i][j - 1] == 'c' || s[i][j - 1] == 'x') x[i] += 1;
					else x[i] += s[i][j - 1] - '0';
				}
			}
		}
		int sum = x[0] + x[1];

		string ans = "";
		if (sum / 1000 > 0)
		{
			if (sum / 1000 == 1) ans += "m";
			else
			{
				char a = sum / 1000 + '0';
				ans += a;
				ans += "m";
			}
			sum %= 1000;
		}
		if (sum / 100 > 0)
		{
			if (sum / 100 == 1) ans += "c";
			else
			{
				char a = sum / 100 + '0';
				ans += a;
				ans += "c";
			}
			sum %= 100;
		}
		if (sum / 10 > 0)
		{
			if (sum / 10 == 1) ans += "x";
			else
			{
				char a = sum / 10 + '0';
				ans += a;
				ans += "x";
			}
			sum %= 10;
		}
		if (sum > 0)
		{
			if (sum == 1) ans += "i";
			else
			{
				char a = sum + '0';
				ans += a;
				ans += "i";
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
h=tuple(map(int,input().split()))
dp=[0]+[float("inf")]*(n-1)
for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]))
print(dp[n-1])
#print(float("inf"))

Measured memory_bytes: 88804
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true)cerr
void print(){cout<<endl;}
template<typename T,typename... Args>
void print(T a, Args... args) {cout<<a<<" ";print(args...);}
lli llipowerp(lli x, lli y, lli p=LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
inline void printvec(vector<T> inp){
    for(auto it:inp) cout<<it<<" ";
    cout << endl;
}
//---------------------------------------------------------------------------------
lld nthRoot(lli A, lli N)
{
    // intially guessing a random number between
    // 0 and 9
    lld xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    lld eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    lld delX = INT_MAX;

    //  xK denotes current value of x
    lld xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (lld)A / pow(xPre, N - 1)) /
             (lld)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main(){
    
    lli x;
    cin>>x;
    lli y;
    lld z;
    for(int i=-500;i<=500;i++){
        y=llipowerp(i,5)+x;
        z=nthRoot(y,5LL);
        if(llipowerp((lli)z,5)==y){
            cout<<(lli)z<<" "<<i<<endl;
            return 0;
        }
    }

}


Measured memory_bytes: 3668
n = int(input())
t = [0] * n
a = [0] * n
for i in range(n):
    tt, aa = map(int, input().split())
    t[i], a[i] = tt, aa

if n == 1:
    print(t[0]+a[0])
else:
    for i in range(1, n):
        for j in range(max(t[i-1]//t[i], a[i-1]//a[i]), 10**18):
            if t[i]*j >= t[i-1] and a[i]*j >= a[i-1]:
                t[i], a[i] = t[i] * j, a[i] * j
                break
    print(t[n-1]+a[n-1])

Measured memory_bytes: 3064
#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"
int main() {
	string st; cin >> st;
	int N; cin >> N;
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		string ring; cin >> ring; ring += ring;
		if (ring.find(st) != string::npos)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	int N, K, Q; cin >> N >> K >> Q;
	vector<int> part(N, 0);
	REP(i, Q) {
		int tmp;
		cin >> tmp;
		tmp--;
		part[tmp]++;
	}
	REP(i, N) {
		int suc = part[i];
		int fail = Q - suc;
		if (K - fail <= 0) {
			cout << "No" << endl;
		}
		else cout << "Yes" << endl;
	}


	return 0;
}


Measured memory_bytes: 1024
main :: IO ()
main = do
  _ <- getLine
  as <- fmap read . words <$> getLine
  let (_, a) = foldr
        (\a (over, acc)
         -> let temp = a * acc
            in if a == 0
               then (False, 0)
               else if over
                    then (over, acc)
                    else if temp > u
                         then (True, -1)
                         else (False, temp))
        (False, 1)
        as
      u = 10 ^ (18 :: Integer)
  print a


Measured memory_bytes: 108324
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef unsigned long long ull;
typedef unsigned int uint;
typedef unsigned char uchar;
#define umap unordered_map
const static ull INVALID_DIGIT = ~(ull)0;

int main()
{
    int A, B;

    cin >> A >> B;

    int get = 0;

    if (A > B)
    {
        get = A;
        A--;
    }
    else
    {
        get = B;
        B--;
    }

    if (A > B)
    {
        get += A;
        A--;
    }
    else
    {
        get += B;
        B--;
    }

    cout << get << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int x;
	cin>>x;
	if(x<600){
		cout<<"8"<<endl;
	}
	else if(x<800){
		cout<<"7"<<endl;
	}
	else if(x<1000){
		cout<<"6"<<endl;
	}
	else if(x<1200){
		cout<<"5"<<endl;
	}
	else if(x<1400){
		cout<<"4"<<endl;
	}
	else if(x<1600){
		cout<<"3"<<endl;
	}
	else if(x<1800){
		cout<<"2"<<endl;
	}
	else {
		cout<<"1"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		Arrays.sort(a);
		long ans = a[n-1];
		int c = 2;
		for(int i = n - 2; i >= 0;i--) {
			ans += a[i];
			c++;
			if(c == n) {
				break;
			}
			ans +=  a[i];
			c++;
			if(c == n) {
				break;
			}
		}
		if(n == 2) {
			System.out.println(a[1]);
		}else {

			System.out.println(ans);
		}
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

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

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

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 56772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n + 1); i++)
// vector<vector<int>> A(3, vector<int>(4));
int main() {
    int A,B;
    cin>>A>>B;
    string S;
    cin>>S;
    bool ans=true;
    rep(i,A+B+1){
        if(i!=A){
            if(48<=int(S[i])&&int(S[i])<=57){
            }
            else{
                ans=false;
                break;
            }
        }
        else{
            if(S[i]!='-'){
                ans=false;
                break;
            }
        }
    }
    if(ans==true){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3600
INFTY = 9999999999
$cnt = 0

def merge(a, left, mid, right)
	n1 = mid - left
	n2 = right - mid
	l = []
	r = []
	0.upto(n1-1) do |i|
		l[i] = a[left + i]
	end
	0.upto(n2-1) do |i|
		r[i] = a[mid + i]
	end
	l[n1] = INFTY
	r[n2] = INFTY
	i = 0
	j = 0
	left.upto(right-1) do |k|
		$cnt += 1
		if l[i] <= r[j]
			a[k] = l[i]
			i += 1
		else
			a[k] = r[j]
			j += 1
		end
	end
end

def mergeSort(a, left, right)
	if left+1 < right
		mid = (left + right)/2
		mergeSort(a, left, mid)
		mergeSort(a, mid, right)
		merge(a, left, mid, right)
	end
end

n = gets.to_i
s = gets.split.map &:to_i
mergeSort(s, 0, s.size)
puts s.join(" ")
puts $cnt

Measured memory_bytes: 70224
"use strict";

function main(input) {
  input = input.trim();
  let N = parseInt(input);

  if (N >= 400 && N <= 599) console.log("8");
  if (N >= 600 && N <= 799) console.log("7");
  if (N >= 800 && N <= 999) console.log("6");
  if (N >= 1000 && N <= 1199) console.log("5");
  if (N >= 1200 && N <= 1399) console.log("4");
  if (N >= 1400 && N <= 1599) console.log("3");
  if (N >= 1600 && N <= 1799) console.log("2");
  if (N >= 1800 && N <= 1999) console.log("1");
}

function numberSort(array) {
  array.sort(f);
  return array;
}

var f = function (a, b) {
  return a - b;
};

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


Measured memory_bytes: 29652
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
from collections import Counter
def resolve():
    n, m, k = map(int,input().split())
    E = [[] for _ in range(n)]
    for _ in range(m):
        u, v = map(int,input().split())
        u-=1; v-=1
        E[u].append(v)
        E[v].append(u)
    block = [tuple(map(int,input().split())) for _ in range(k)]

    # connected component
    cnt = 0
    color = [None]*n
    def dfs(v)->bool:
        if color[v] is not None: return False
        stack = [v]
        while stack:
            v = stack.pop()
            color[v] = cnt
            for nv in E[v]:
                if color[nv] is not None: continue
                stack.append(nv)
        return True

    for v in range(n):
        cnt += dfs(v)

    C = Counter(color)
    res = [C[color[v]]-len(E[v])-1 for v in range(n)]
    # block 分を引く
    for u, v in block:
        u-=1; v-=1
        if color[u]==color[v]:
            res[u]-=1
            res[v]-=1
    print(*res)
resolve()

Measured memory_bytes: 93100
/*
    Mbak Rose Dong
*/
#include<bits/stdc++.h>
using namespace std;
int arr[200200];
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m,inc=1;
    cin >> n;
    int rose = 0;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&arr[i]);
    }
    for(i=1;i<=n;i++)
    {
        scanf("%d",&curr);
        if(arr[i] > curr)
            rose += (arr[i]-curr);
    }
    printf("%d\n",rose);
    return 0;
}


Measured memory_bytes: 256
IDENTIFICATION DIVISION.
      PROGRAM-ID. 085A.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 S.
      	03 S-Y PIC X(4).
      	03 S-1 PIC X(1).
      	03 S-M PIC X(2).
      	03 S-2 PIC X(1).
      	03 S-D PIC X(2).
       
      PROCEDURE DIVISION.
      ACCEPT S.
      MOVE "2018" TO S-Y.
      DISPLAY S.
      STOP RUN.

Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int Month = sc.nextInt();
		// スペース区切りの整数の入力
		int Day = sc.nextInt();
      int Dayone = Day%10;
      int Dayten = Day/10;
      //カウンター
		int count = 0;
		// 文字列の入力
		//String s = sc.next();
      int k=9;
      for(int tuki=1;tuki<=Month;tuki++){
      	for(int i=2;i<=Dayten;i++){
        	if(i==Dayten){
      	    	k=Dayone;
        	}else{
              k=9;
            }
          for(int j=2;j<=k;j++){
      			if(i*j==tuki){
        		count++;
        		// 出力
				//System.out.println(tuki+"月　"+(i*10+j)+"日　"+count);
      			}
        	}
      	}
      }
      
      
      
		// 出力
		//System.out.println(Month+" "+Day+" "+Dayten+" "+Dayone+" "+count);
      System.out.println(count);
	}
}

Measured memory_bytes: 21844
S = list(input())
max_len = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        bubun = S[i:j+1]
        is_acgt = [s in ("T","A","G","C") for s in bubun]
        if all(is_acgt) and len(bubun)>max_len:
            max_len = len(bubun)
print(max_len)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repn(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define sz(v) (ll)v.size()
using namespace std;

ll MOD=1e9+7;
ll g,h,l;
const ll N=100005;

ll add(ll a,ll b); ll mul(ll a,ll b); ll binpo(ll a,ll b);

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll n;
    cin>>n;
    ll ans=0;
    ans+=(n/500)*1000;
    n%=500;
    ans+=(n/5)*5;
    cout<<ans;
}

ll add(ll a,ll b)
{
    return (a%MOD+b%MOD)%MOD ;
}
ll mul(ll a,ll b)
{
    return (a* 1ll *b)%MOD ;
}
ll binpo(ll a,ll b)
{
    int ans = 1 ;
    while(b)
    {
        if( b % 2 != 0)
        {
            ans = mul(ans,a);
        }
        a = mul(a,a);
        b = b/2;
    }
    return ans;
}

Measured memory_bytes: 256
#include <stdio.h>

#define WIDTH_MAX 30
#define HEIGHT_MAX 30
#define INF 1000

#define next( i ) ( ( ( i ) + 1 ) % ( WIDTH_MAX * HEIGHT_MAX ) )

typedef struct {
	int type;
	int min;
} FIELD;

FIELD field[ WIDTH_MAX * 2 + 1 ][ HEIGHT_MAX * 2 + 1 ] = {};
const int dx[ 4 ] = { -1, 0, 1, 0 }, dy[ 4 ] = { 0, -1, 0, 1 };

int queue[ WIDTH_MAX * HEIGHT_MAX ], front, rear;

int bfs( int, int );

int main( void ) {
	int x, y, w, h;

	for ( x = 1; x <= WIDTH_MAX * 2 - 1; x += 2 )
		field[ x ][ 0 ].type = 1;
	for ( y = 1; y <= HEIGHT_MAX * 2 - 1; y += 2 )
		field[ 0 ][ y ].type = 1;

	for ( ; scanf( "%d %d", &w, &h ), w; printf( "%d\n", bfs( w, h ) ) ) {
		for ( y = 1; y <= h * 2 - 1; y += 2 )
			for ( x = 1; x <= w * 2 - 1; x += 2 )
				field[ x ][ y ].min = INF;
		for ( x = 1; x <= w * 2 - 1; x += 2 )
			field[ x ][ h * 2 ].type = 1;
		for ( y = 1; y <= h * 2 - 1; y += 2 )
			field[ w * 2 ][ y ].type = 1;

		for ( y = 1; y <= h * 2 - 1; y++ )
			for ( x = y % 2 + 1; x <= w * 2 - 1 ; x += 2 )
				scanf( "%d", &field[ x ][ y ].type );
	}

	return 0;
}

int bfs( int w, int h ) {
	int i, x, y, tmp;

	front = rear = 0;

	queue[ rear ] = h * 2 + 2;
	rear = next( rear );

	field[ 1 ][ 1 ].min = 1;

	while ( rear != front ) {
		tmp = queue[ front ];
		front = next( front );

		x = tmp / ( h * 2 + 1 );
		y = tmp % ( h * 2 + 1 );

		if ( x == w * 2 - 1 && y == h * 2 - 1 )
			break;

		for ( i = 4; i--;  ) {
			int nx1 = x + dx[ i ], ny1 = y + dy[ i ], nx2 = nx1 + dx[ i ], ny2 = ny1 + dy[ i ];

			if ( !field[ nx1 ][ ny1 ].type && field[ nx2 ][ ny2 ].min == INF ) {
				queue[ rear ] = nx2 * ( h * 2 + 1 ) + ny2;
				rear = next( rear );

				field[ nx2 ][ ny2 ].min = field[ x ][ y ].min + 1;
			}
		}
	}

	return field[ w * 2 - 1 ][ h * 2 - 1 ].min != INF ? field[ w * 2 - 1 ][ h * 2 - 1 ].min : 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define int long long
#define vi vector <int>
#define si set <int>
#define mii map <int,int>
#define pii pair <int,int>
#define endl "\n"
#define ZERO 0ll
#define FOR(P,Q) for(int P=0;P<(Q);P++)
#define FORR(P,Q) for(int P=1;P<=(Q);P++)
#define rep(P,R,Q) for(int P=(R);P<=(Q);P++)
#define repb(P,R,Q) for(int P=(R);P>=(Q);P--)
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef long double ld;
using namespace std;


    
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("error.txt","w",stderr);
	#endif
	//change ll to int before using string builtin operations
	int tces=1;
	//cin>>tces;
	while(tces--){
		int n;
		cin>>n;
		vi v(n+5);
		vector<pii> p(n+5);
		FORR(i,n){
			cin>>v[i];
			p[v[i]].second++;
		}
		int ans=0;
		for(auto it:p){
			if(it.second>1)
				ans+=it.second*(it.second-1)/2;
		}
		FORR(i,n){
			if(p[v[i]].second==1)
				cout<<ans<<endl;
			else {
				int a=ans;
				int t=p[v[i]].second*(p[v[i]].second-1)/2;
				a-=t;
				int t1=(p[v[i]].second-2)*(p[v[i]].second-1)/2;
				cout<<a+t1<<endl;
			}
		}

	}
	
return 0;
}

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

using namespace std;

#define LL long long
#define N 6000

const int mod=1000000007;
int n,m,ans,tot,cnt1,cnt2,par[N],head[N],fa[N],lk[N],dep[N];
LL p,sum;
bool mark[N];
struct edge1{
	int x,y,l;
	bool operator < (const edge1 p) const{
		return l<p.l;
	}
}a[N];
struct edge2{int v,l,nxt;}e[N];

void add(int x,int y,int z){e[++tot].v=y; e[tot].l=z; e[tot].nxt=head[x]; head[x]=tot;}

int gfa(int x){return x==par[x]?x:par[x]=gfa(par[x]);}

void dfs(int u){
	dep[u]=dep[fa[u]]+1;
	for (int i=head[u],v;i;i=e[i].nxt)
		if ((v=e[i].v)!=fa[u]){
			fa[v]=u; lk[v]=e[i].l; dfs(v);
		}
}

int qry(int x,int y){
	int ret=0;
	for (;dep[x]>dep[y];x=fa[x]) ret=max(ret,lk[x]);
	for (;dep[y]>dep[x];y=fa[y]) ret=max(ret,lk[y]);
	for (;x!=y;x=fa[x],y=fa[y]){ret=max(ret,lk[x]); ret=max(ret,lk[y]);}
	return ret;
}

int main(){
	scanf("%d%d%lld",&n,&m,&p);
	for (int i=1;i<=m;++i) scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].l);
	sort(a+1,a+m+1);
	for (int i=1;i<=n;++i) par[i]=i;
	for (int i=1;i<=m;++i)
		if (gfa(a[i].x)!=gfa(a[i].y)){
			par[gfa(a[i].x)]=gfa(a[i].y);
			add(a[i].x,a[i].y,a[i].l);
			add(a[i].y,a[i].x,a[i].l);
			sum+=a[i].l;
			mark[i]=1;
		}
	if (sum>p){puts("0"); return 0;}
	if (sum==p) cnt1+=n-1;
	dfs(1);
	for (int i=1;i<=m;++i)
		if (!mark[i]){
			int x=a[i].x,y=a[i].y;
			int tmp=qry(x,y);
			if (sum-tmp+a[i].l==p) ++cnt1;
			if (sum-tmp+a[i].l>p) ++cnt2;
		}
	ans=1; for (int i=1;i<=cnt1;++i) ans=ans*2%mod;
	ans=(ans-2+(sum<p)+mod)%mod;
	for (int i=1;i<=cnt2;++i) ans=ans*2%mod;
	printf("%d\n",ans*(sum<p?2:1)%mod);
	
	return 0;
}
			

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+50;
struct node{
	int a,b;
}c[maxn];
bool cmp(node x,node y)
{
	return x.b<y.b;
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>c[i].a>>c[i].b;
	}
	sort(c,c+n,cmp);
	int t=0;
	for(int i=0;i<n;i++)
	{
		if(t+c[i].a<=c[i].b)
		{
			t+=c[i].a;
		}
		else
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=1e9+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x;
    cin>>x;
    if(x>=30)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3660
import java.util.*;
public class Main {
	static Queue<Coordinate> q = new LinkedList<Coordinate>();
	static class Coordinate{
		int x,y;
		Coordinate(int x,int y){
			this.x = x;
			this.y = y;
		}
	}
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		while(true){
			int counter = 0;
			int N = sc.nextInt();
			int M = sc.nextInt();
			if(N==0&&M==0){
				break;
			}
			String input;
			char[][] test = new char[N+2][M+2];
			for(int i=0;i<(M+2);i++){
				test[0][i] = '.';
				test[N+1][i] = '.';
			}
			for(int i=0;i<(N+2);i++){
				test[i][0] = '.';
				test[i][M+1] = '.';
			}
			for(int i=1;i<N+1;i++){
				input = sc.next();
				for(int j=1;j<M+1;j++){
					test[i][j] = input.charAt(j-1);
				}
			}
			
			for(int i=1;i<N+1;i++){
				for(int j=1;j<M+1;j++){
					if(test[i][j]!='.'){
						Coordinate cor= new Coordinate(i,j);
						q.offer(cor);
						//bfs(test,q);
						while(!q.isEmpty()){
							Coordinate pair = q.poll();
							int x = pair.x, y = pair.y;
							char buf = test[x][y];
							test[x][y] = '.';
							if(buf!='.'){
								if(buf==test[x-1][y]){
									Coordinate cor1 = new Coordinate(x-1,y);
									q.add(cor1);
									
								}
								if(buf==test[x+1][y]){
									Coordinate cor1 = new Coordinate(x+1,y);
									q.add(cor1);
									
								}
								if(buf==test[x][y-1]){
									Coordinate cor1 = new Coordinate(x,y-1);
									q.add(cor1);
									
								}
								if(buf==test[x][y+1]){
									Coordinate cor1 = new Coordinate(x,y+1);
									q.add(cor1);
									
								}
							}
						}
						counter++;
					}
				}
			}
			System.out.println(counter);
		}
	}
}

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

int main(){
	string a, b;
	cin >> a >> b;
	a += b;
	int i = stoi(a);
	int r = sqrt(i);
	if(i == r * r){
		cout << "Yes";
	} else {
		cout << "No";
	}
	return 0;
}


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

d = [[0]*N for _ in range(N)]

def warshall_floyd(d):
    global SUM
    ans = 0
    aroad = set()
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if d[i][j]>d[i][k] + d[k][j]:
                    return -1
                if d[i][j]==d[i][k]+d[k][j] and not (i==k or k==j):
                    aroad.add((min(i, j), max(i, j)))
    for i, j in list(aroad):
        ans -= d[i][j]
    return SUM+ans

SUM = 0
for i in range(N):
    As = list(map(int, input().split()))
    SUM += sum(As)
    for j in range(N):
        d[i][j] = As[j] 
SUM //= 2
print(warshall_floyd(d))

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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
bool cmp(pair<string,int> a,pair<string,int> b){
    if(a.first==b.first)return a.second>b.second;
    else return a.first<b.first;
}
int main(){
    ll n,kk;cin>>n>>kk;
    ll v[n];
    rep(i,0,n)cin>>v[i];
    ll sum[n+1];
    sum[0]=0;
    rep(i,0,n)sum[i+1]=sum[i]+v[i];
    if(kk>=2*n){
        ll ans=0;
        rep(i,0,n)ans+=max((ll)0,v[i]);
        cout<<ans<<endl;
        return 0;
    }
    ll ans=0;
    rep(i,0,n+1){
        rep(j,0,n+1){
            if(i+j>n)continue;
            if(i+j>kk)continue;
            ll l=sum[i];
            ll r=sum[n]-sum[n-j];
            vector<ll> w;
            rep(k,0,i)w.push_back(v[k]);
            rep(k,0,j)w.push_back(v[n-1-k]);
            sort(w.begin(),w.end());
            ll ss=0;
            rep(k,0,kk-(i+j)){
                if(k>=w.size())break;
                if(w[k]<0)ss+=w[k];
            }
            //cout<<l+r-ss<<endl;
            ans=max(ans,l+r-ss);
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


int main() {
    int n;
    cin >> n;
    vs s(n);
    rep(i, n) cin >> s[i];

    int a, b, c, d;
    a = 0;
    b = 0;
    c = 0;
    d = 0;

    rep(i, n) {
        if (s[i] == "AC") a++;
        if (s[i] == "WA") b++;
        if (s[i] == "TLE") c++;
        if (s[i] == "RE") d++;
    }

    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;

    return 0;
}


Measured memory_bytes: 6380
#include <iostream>
#include <vector>
#include <cmath>
#include <bitset>
#include <random>
#include <ctime>
#include <algorithm>
using namespace std;
using ll = long long int;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll mod = 1000000007;

int main() {
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans = 0;
    rep(is,1<<h) rep(js,1<<w) {
        int cnt = 0;
        rep(i,h) rep(j,w) {
            if (is >> i & 1) continue;
            if (js >> j & 1) continue;
            if (s[i][j] == '#') cnt++;
        }
        if(cnt == k) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3572
s = input()

odd = ["R", "U", "D"]
even = ["L", "U", "D"]

isYes = True

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] not in odd:
            isYes = False
            break
    elif i % 2 != 0:
        if s[i] not in even:
            isYes = False
            break

if isYes:
    print("Yes")
else:
    print("No")

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

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using edge = struct {
  int to;
  int cost;
};
using namespace std;

int main() {
  vector<int> A;
  long long int count = 0;
  int po;
  for (int i = 0; i < 3; i++) {
    cin >> po;
    A.push_back(po);
  }
  sort(A.begin(), A.end());
  if (A[1] - A[0] > 1) {
    count += floor((A[1] - A[0]) / 2);
    A[0] += 2 * floor((A[1] - A[0]) / 2);
  }
  if (A[2] - A[1] > 1) {
    count += floor((A[2] - A[1]) / 2);
    A[1] += 2 * floor((A[2] - A[1]) / 2);
  }
  if (A[2] - A[0] > 1) {
    count += floor((A[2] - A[0]) / 2);
    A[0] += 2 * floor((A[2] - A[0]) / 2);
  }
  sort(A.begin(), A.end());
  if (A[0] == A[1]) {
    count += A[2] - A[0];
  } else {
    count += (A[2] - A[0] + A[2] - A[1]) * 2;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

struct SegmentTree{
private:
    int n;
    vector<ll> node;
public:
    SegmentTree(vector<ll> &v){
        int sz=(int)v.size();
        n=1;
        while(n<sz)n*=2;
        node.resize(2*n-1);
        for(int i=0;i<sz;i++){
            node[n-1+i]=v[i];
        }
    }
    void update(int a,int b,ll x,int k=0,int l=0,int r=-1){
        if(r==-1)r=n;
        if(b<=l||r<=a)return;
        if(a<=l&&r<=b){
            node[k]+=x;
        }
        else{
            update(a,b,x,2*k+1,l,(l+r)/2);
            update(a,b,x,2*k+2,(l+r)/2,r);
        }
    }
    int get(int a){
        a+=n-1;
        ll res=node[a];
        while(a>0){
            a=(a-1)/2;
            res+=node[a];
        }
        return res;
    }
};

int main(){
    int n,d,a;
    cin>>n>>d>>a;
    pair<ll,int> mon[n];
    for(int i=0;i<n;i++){
        int x,h;
        cin>>x>>h;
        mon[i]={x,h};
    }
    sort(mon,mon+n);
    int r[n];
    for(int i=0;i<n;i++){
        ll x=mon[i].first;
        auto it=upper_bound(mon,mon+n,make_pair(x+2*d,INF));
        r[i]=it-mon;
    }
    vector<ll> v(n);
    for(int i=0;i<n;i++){
        v[i]=mon[i].second;
    }
    SegmentTree seg(v);
    ll ans=0;
    for(int i=0;i<n;i++){
        ll h=seg.get(i);
        if(h<=0)continue;
        ll c=(h+a-1)/a;
        ans+=c;
        seg.update(i,r[i],-c*a);
    }
    cout<<ans<<endl;
}


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

using namespace std;

int a[10];

int main(){
    int i, t;
    for(i = 1; i <= 6; i++){
        scanf("%d", &t);
        a[t]++;
    }
    int cnt = 0;
    for(i = 1; i <= 4; i++){
        if(a[i]%2) cnt++;
    }
    if(cnt!=2) printf("NO\n");
    else printf("YES\n");

    return 0;
}

Measured memory_bytes: 256