akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int b = sc.NextInt();
        int[,] d = new int[b, b];
        for (int i = 0; i < b; i++)
            for (int j = 0; j < b; j++)
                d[i, j] = sc.NextInt();

        int[,] t = new int[3, 30];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
            {
                t[(i + j) % 3, sc.NextInt() - 1]++;
            }

        int min = 1 << 30;
        for (int i = 0; i < b; i++)
            for (int j = 0; j < b; j++)
            {
                if (i == j) continue;
                for (int k = 0; k < b; k++)
                {
                    if (i == k || j == k) continue;
                    int ans = 0;
                    for (int l = 0; l < b; l++) ans += d[l, i] * t[0, l];
                    for (int l = 0; l < b; l++) ans += d[l, j] * t[1, l];
                    for (int l = 0; l < b; l++) ans += d[l, k] * t[2, l];
                    if (ans < min) min = ans;
                }
            }
        Console.WriteLine(min);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 15308
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1<<12)
#define int short

signed main(){
    int HPinit, HPmax;
    while(cin>>HPinit>>HPmax&&(HPinit||HPmax)){
        int h,w;
        cin>>h>>w;
        vector<string> vs(h);
        rep(i,h)cin>>vs[i];
        
        int n;
        cin>>n;
        vector<int> dmg(26);
        rep(i,n){
            char ch;
            int val;
            cin>>ch>>val;
            dmg[ch-'A'] = val;
        }
        
        int m;
        cin>>m;
        vector<pair<char,int>> mv(m);
        rep(i,m){
            char ch;
            int dist;
            cin>>ch>>dist;
            mv[i] = make_pair(ch,dist);
        }
        
        int c;
        cin>>c;
        vector<int> p(c);
        rep(i,c)cin>>p[i];
        
        static int dp[1<<12];
        rep(i,1001)rep(j,1<<12)dp[j] = -INF;
        dp[(1<<c)-1] = HPinit;
        
        int dy[]={1,0,-1,0};
        int dx[]={0,1,0,-1};

        int y = 0, x=0;
        int turn = 0;
        int count = 0;
        rep(i,m){
            int dir = -1;
            char ch = mv[i].first;
            if(ch=='D')dir=0;
            else if(ch=='R')dir=1;
            else if(ch=='U')dir=2;
            else if(ch=='L')dir=3;
            assert(dir!=-1);
            
            rep(j,mv[i].second){
                y += dy[dir];
                x += dx[dir];
                for(int bit = 1<<c;bit>=0;bit--){
                    if(dp[bit]<=0)continue;
                    if(dp[bit]>dmg[vs[y][x]-'A'])continue;
                    rep(i,c){
                        if(((1<<i)&bit)){
                            dp[bit^(1<<i)] = max(dp[bit^(1<<i)], min<int>(HPmax, dp[bit] + p[i]));
                        }
                    }
                }
                for(int bit = 1<<c;bit>=0;bit--){
                    dp[bit] -= dmg[vs[y][x]-'A'];
                }
                turn++;
            }
        }
        int maxi = -INF;
        rep(i,1<<c)maxi = max(maxi,dp[i]);
        if(maxi>0)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}



Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int n;
    while (cin>>n) {
        if (n==-1) {
            break;
        } else {
            int d;
            if (n>30) {
                cout<<4280-(1150+1250+1400+(n-30)*160)<<endl;
            } else if (n>20) {
                cout<<4280-(1150+1250+(n-20)*140)<<endl;
            } else if (n>10) {
                cout<<4280-(1150+(n-10)*125)<<endl;
            } else {
                cout<<4280-1150<<endl;
            }
        }
    }
}



Measured memory_bytes: 2984
#include <stdio.h>

void countingSort(int A[], int B[], int k, int num) {

    int C[k + 1];
    for (int i = 0; i <= k; i++) {
        C[i] = 0;
    }

    // C[i] に i の出現数を記録する。
    for (int i = 0; i < num; i++) {
        C[A[i]]++;
    }

    // C[i] に i 以下の数の出現数を記録する。
    for (int i = 1; i <= k; i++) {
        C[i] = C[i] + C[i - 1];
    }

    for (int i = num - 1; i >= 0; i--) {
        B[C[A[i]] - 1] = A[i];
        C[A[i]]--;
    }
}

int main() {

    int num;
    scanf("%d", &num);

    int max = 0;
    int A[num];
    for (int i = 0; i < num; i++) {
        scanf("%d", &A[i]);
        if (A[i] > max) {
            max = A[i];
        }
    }

    int B[num];
    countingSort(A, B, max, num);

    for (int i = 0; i < num; i++) {
        printf("%d", B[i]);
        if (i == num - 1) {
            printf("\n");
        } else {
            printf(" ");
        }
    }

    return 0;
}



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

template<typename E>
ostream &operator<<(ostream &os, vector<E> vs) {
  os << "[";
  for(int i = 0; i < vs.size(); i++) {
    os << vs[i] << " ";
  }
  os << "]";
  return os;
}

int main(int argc, char *argv[])
{
  string line;
  vector<char> text;
  vector<int> opens;
  vector<int> closes;
  vector<long long> cnts;
  vector<int> level_cnts;
  cnts.push_back(0);
  getline(cin,line);
  const int n = line.length();
  long long cnt = 0;
  int level_cnt = 0;
  for(int i = 0; i < n; i++) {
    level_cnts.push_back(level_cnt);
    switch(line[i]) {
    case'(':
      level_cnt = 0;
      opens.push_back(text.size());
      text.push_back(line[i]);
      break;
    case')':
      if(opens.size() > 0) {
        closes.push_back(*opens.rbegin());
        level_cnt = level_cnts[*opens.rbegin()];
        level_cnt++;
        cnt += level_cnt;
        opens.pop_back();
      } else {
        level_cnt = 0;
        closes.push_back(-1);
      }
      text.push_back(line[i]);
      break;
    case'-':
      level_cnt = *level_cnts.rbegin();
      level_cnts.pop_back();
      switch(*text.rbegin()) {
      case '(':
        opens.pop_back();
        break;
      case ')':
        int op = *closes.rbegin();
        if(op < 0) { // no matching open
          level_cnt = 0;
        } else {
          opens.push_back(op);
          cnt -= level_cnt;
          
        }
        closes.pop_back();
        break;
      }
      level_cnt = *level_cnts.rbegin();
      level_cnts.pop_back();
      text.pop_back();
      break;
    }
    cnts.push_back(cnt);
    // cout << cnt << " : " << level_cnts << endl;
    cout << cnt << endl;
  }
  return 0;
}



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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

const int N = 3e6;

void solve() {
  int n; cin >> n;
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  ll suf = 0;
  for (int i = n - 1; i >= 0; i--) {
    a[i] += suf;
    ll mult = (a[i] + b[i] - 1) / b[i];
    ll need = mult * b[i] - a[i];
    suf += need;
  }
  cout << suf;
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


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


using namespace std;
using ll = long long;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
#define rep(i,n) for(int i = 0;i<n;i++)



int main(){

    int N;cin >> N;
    ll r = 0;
    vector<int> a(N-1);
    vector<int> b(N-1);
    int x,y;
    rep(i,N-1){
        cin >> x >> y;
        a[i] = min(x,y);
        b[i] = max(x,y);
    }
    rep(i,N)r += ll(i+1)*(N-i);

    rep(i,N-1){
        

        r -= ll (a[i])*(N-b[i]+1);
    }
    cout << r << endl;
    

}



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

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

using namespace std;

const double PI=3.14159265358979323846;

typedef long long ll;

int a, b, x;

double sita_to_v(double sita) {
  double ret = 0;
  if (sita < atan2(b, a)) {
    ret = a*a*b - a * a * a * tan(sita) / 2.0;
  } else {
    ret = a * b * b / tan(sita) / 2.0;
  }
  return ret;
}

bool judge(double mid) {
  return sita_to_v(mid) > x;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  cin >> a >> b >> x;

  double low = 0, high = PI/2;
  double eps = 1e-15;
  
  while ( high - low > eps) {
    double mid = (low+high)/2;

    if ( judge(mid) ) {
      low = mid;
    } else {
      high = mid;
    }
  }
  cout << 180.0 * low / PI << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
typedef long long ll;
#define min(a, b) ((a) < (b) ? (a) : (b))
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

const int MAX_N = 110;
const int MAX_V = 100100;

// 入力
int N, M;
bool A[100010];

// DPテーブル
long long dp[100010];

int main() {
	cin >> N >> M;
	
	int tmp;
	for (int i = 0; i < M; i++) {
		cin >> tmp;
		A[tmp] = true;
	}
	dp[0] = 1;

	if (A[1] == true) {
		dp[1] = 0;
	}
	else {
		dp[1] = 1;
	}


	for (int i = 2; i <= N; i++) {
		if (A[i] == true) {
			dp[i] = 0;
			continue;
		}
		dp[i] = (dp[i - 2] + dp[i - 1]) % 1000000007;
	}

	cout << dp[N] % 1000000007 << endl;
}


Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
  ll a,b,k;
  cin>>a>>b>>k;
  for(int i=a; i<=b; ++i)
  if(i<a+k||i>b-k)
  cout<<i<<endl;
  }
  
  
  
  

  
  

 


Measured memory_bytes: 256
import java.io.*;

class Main
{
   public static void main(String[] args) throws IOException
   {

      BufferedReader br =
       new BufferedReader(new InputStreamReader(System.in));

      String str1 = br.readLine();
      String str2[] = str1.split(" ");
      int a = Integer.parseInt(str2[0]);
      int b = Integer.parseInt(str2[1]);
      int c = a*b;
      int d = 2*(a+b);
      System.out.println( c + " " + d );

   }
}

Measured memory_bytes: 24124
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  	ll n;
	map<string,int> ma;
	cin>>n;
	ll i;
	for(i=0;i<n;i++)
	{
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		ma[s]++;
	} 
	ll ans=0;
	for(auto it:ma)
	{
		ll k=it.second;
		ans=ans+(k*(k-1))/2;
	}
	cout<<ans<<endl;
}

  




Measured memory_bytes: 11136
import java.util.Scanner;
import java.util.Arrays;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N + 1];
    for (int i = 1; i <= N; i++) A[i] = sc.nextInt();
    int[] dp = new int[N + 1];
    dp[2] = Math.abs(A[1] - A[2]);
    for (int i = 3; i <= N; i++) {
    	dp[i] = Math.min(dp[i - 1] + Math.abs(A[i] - A[i - 1]), dp[i - 2] + Math.abs(A[i] - A[i - 2]));
    }
    System.out.println(dp[N]);
  }
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, int> PLDI;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
const int INF = (1e9);
const LL MOD = 1e9+7;
const double PI=atan2(0,-1);


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

Measured memory_bytes: 764
// AOJ 0591: Beads
// 2017.11.27 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define N    1000000000
#define MAX  10010
char tbl[MAX+3];
int sz;						// max sz = 1230, prime[0] = 2, prime[1229] = 10007
int prime[1300] = {  		// prime[24] = 97, 97^2 = 9407
  2,  3,  5,  7, 11, 13, 17, 19, 23, 29, 
 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 
 73, 79, 83, 89, 97 };
int sqp[25] = {				// squre of prime: sqp[i] = prime[i] * prime[i]
  4, 9,25,49,121,169,289,361,529,841,961,
1369,1681,1849,2209,2809,3481,3721,4489,5041,
5329,6241,6889,7921,9409 };
int power[1300];

void sieve()
{
	int i, j, k;

	for (i = 1; i < 25; i++) {
		k = prime[i];
		for (j = sqp[i]; j <= MAX; j += k) tbl[j] = 1;
	}
	for (sz = 24, i = 97; i <= MAX; i += 2) if (!tbl[i]) prime[sz++] = i;
}

void mpNum2Str(char *str, int *num)
{
    int  i, j, x;
    char *ss;

    if (*num == 0 || (*num == 1 && *(num+1) == 0)) { *str++ = '0', *str = 0; return; }

    ss = str - 1;
    for (i = *num; i > 0; i--) {
        x = *++num;
        for (j = 1; j < N; j *= 10) *++ss = x % 10 + '0', x /= 10;
    }
    while (*ss == '0') ss--;

    *(ss + 1) = 0;    
    while (str < ss) x = *str, *str++ = *ss, *ss-- = x;
}

void mpMul1(int *ret, int *a, int b)
{
    int  i, la, ca;
    int  *aa, *rr;
    long long x;

    la = *a;
    for (i = la + 1; i > 0; i--) *(ret + i) = 0;

    ca = 0;
    for (rr = ret + 1, i = 1, aa = a; i <= la; i++, rr++) {
        x = *++aa;
        x = x * b + *rr + ca;
        *rr = x % N;
        ca = (int)(x / N);
    }
    *rr = ca;
    *ret = la + (ca != 0);
}

char buf[7000];
int a[2][5000];
int x[20002];

int calc(int num[2][5000], int *x, int fr, int to)
{
	int k1, k2;

	num[0][0] = num[0][1] = 1;
	for (k1 = 0, k2 = 1; fr <= to; fr++) {
		if (fr != x[fr])  mpMul1(num[k2], num[k1], fr/x[fr]), k1 = k2, k2 = !k2;
	}
	return k1;
}

// (n + r - mn - 1) ! / {(n - 1) ! ?? (r - mn) !}
int main()
{
	int n, m, r, i, j, k, aa, p0, p, ll;

	sieve();

	scanf("%d%d%d", &n, &m, &r);
	k = r - m * n;
	if (k < 0) { puts("0"); return 0; }

	for (i = 0; ; i++) {
		if ((p0 = prime[i]) > k) break;
		for (p = p0; p <= k; p *= p0) {
			for (ll = p; ll <= k; ll += p) power[i]++;
		}
	}
	sz = i;

	k = n + k - 1;
	for (i = n; i <= k; i++) x[i] = 1; 
	for (i = 0; i < sz; i++) {
		p0 = prime[i];
		for (p = p0, j = power[i]; j > 0; p *= p0) {
			for (ll = p*(1+(n-1)/p); j > 0 && ll <= k; ll += p) x[ll] *= p0, j--;
		}
	}

	aa = calc(a, x, n, k);
	mpNum2Str(buf, a[aa]);
	puts(buf);
	return 0;
}

Measured memory_bytes: 1808
def gcda(a,b):
    if a < b:
        a, b = b, a
    r = a % b
    if r == 0:
        return b
    return gcda(r, b)

def lcm(a,b):
    return a*b//gcda(a,b)

X=int(input())
shukai=360
while True:
    if shukai%X==0:
        print(shukai//X)
        exit()
    else:
        shukai=lcm(shukai,X)

Measured memory_bytes: 9052
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define int long long
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(X) X[X.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	int N,X=0;
	cin >> N;
	REP(i, N) {
		if ((BETWEEN(i, 1, 9)||BETWEEN(i,100,999))||BETWEEN(i,10000,99999))
			X++;
	}
	cout << X;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

void m_sort(vector<long long int> &, int, int, long long int &);
void merge(vector<long long int> &, int, int, int, long long int &);

int main(int argc, char const *argv[])
{
    // ios::sync_with_stdio(false);

    int n = 0;
    // cin >> n;
    scanf("%d", &n);

    vector<long long int> arr(n, 0);
    REP(i, n)
    {
        // cin >> arr[i];
        scanf("%lld", &arr[i]);
    }

    long long int cnt = 0;
    m_sort(arr, 0, n, cnt);

    REP(i, n - 1) {
        // cout << arr[i] << " ";
        printf("%lld ", arr[i]);
    }
    // cout << arr[n - 1] << endl;
    printf("%lld\n", arr[n - 1]);
    // cout << cnt << endl;
    printf("%lld\n", cnt);

    return 0;
}

void m_sort(vector<long long int> &arr, int left, int right, long long int &cnt)
{
    if (right > left + 1)
    {
        int mid = (left + right) / 2;
        m_sort(arr, left, mid, cnt);
        m_sort(arr, mid, right, cnt);

        merge(arr, left, mid, right, cnt);
    }
}

void merge(vector<long long int> &arr, int left, int mid, int right, long long int &cnt)
{
    int na = mid - left, nb = right - mid;
    vector<long long int> a(na + 1, 0), b(nb + 1, 0);

    const int INFTY = 1000000001;

    REP(i, na) {
        a[i] = arr[i + left];
    }
    a[na] = INFTY;

    REP(i, nb) {
        b[i] = arr[i + mid];
    }
    b[nb] = INFTY;

    int i = 0, j = 0;
    FOR(k, left, right) {
        cnt++;
        if (a[i] < b[j])
        {
            arr[k] = a[i];
            i++;
        }
        else
        {
            arr[k] = b[j];
            j++;
        }
    }
}


Measured memory_bytes: 10704
#include<iostream>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
  int max_on=c;
  int min_off=b;
  if(a>c){
  max_on=a;
  }
  if(b>d){
  min_off=d;
  }
int res=0;
  if(b>c&&a<d){
    res=min_off-max_on;}
  cout<<res;
}

Measured memory_bytes: 256
def solve(M, K):
    if K == 0:
        r = [i for i in range(0, 2 ** M)]
        return " ".join(str(c) for c in r + r[::-1])
    elif M > 1 and K < (2 ** M):
        r = [i for i in range(0, (2 ** M)) if i != K]
        return " ".join(str(c) for c in r[::-1] + [K] + r + [K])
    else:
        return "-1"


if __name__ == "__main__":
    M, K = tuple(map(int, input().split(" ")))
    print(solve(M, K))


Measured memory_bytes: 28564
import Foundation

let inputOni = readLine()!.components(separatedBy: " ").map{ Int($0)}
let inputNige = readLine()!.components(separatedBy: " ").map{ Int($0)}
let T = Int(readLine()!)!

let A = inputOni[0]!
let V = inputOni[1]!
let B = inputNige[0]!
let W = inputNige[1]!
let dis = abs(A - B)
let disPerSec = (V - W) * T

if dis <= disPerSec {
    print("YES")
}else {
    print("NO")
}

Measured memory_bytes: 14068
N = gets.to_i
A = gets.strip.split.map(&:to_i)
a = []

for i in 0..N-1
    a[i] = A[i]-i-1 
end
a.sort!
if N % 2 == 0
    b = (a[(N/2)-1]+a[(N/2)]) / 2
else
    b = a[(N/2)]
end

answer = 0

for i in 0..N-1
    answer += (a[i]-b).abs
end

puts answer

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b, t = 0, B = 0;
    string s;
    cin >> n >> a >> b >> s;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'c') cout << "No\n";
        else if (s[i] == 'a') {
            if (t < a + b) {
                cout << "Yes\n";
                ++t;
            } else cout << "No\n";
        } else {
            if (t < a + b && B < b) {
                cout << "Yes\n";
                ++t;
                ++B;
            } else cout << "No\n";
        }
    }
    return 0;
}

Measured memory_bytes: 848
import bisect


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

ans = 0
for b in B:
    ans += bisect.bisect_left(A, b) * (N - bisect.bisect_right(C, b))
print(ans)


Measured memory_bytes: 23092
#include <bits/stdc++.h>
using namespace std;
const int lim = 51;
typedef pair<int, int> P;

struct Point{
    int ly, lx, ry, rx;
};

int W, H;
bool isIn(int y, int x){
    return (0 <= y && y < H && 0 <= x && x < W);
}

char R[lim][lim], L[lim][lim];
bool visited[lim][lim][lim][lim];

bool solve(){
    Point start;
    for(int y=0; y<H; y++){
        for(int x=0; x<W; x++){
            cin >> L[y][x];
            if(L[y][x] == 'L')start.ly = y, start.lx = x;
        }
        for(int x=0; x<W; x++){
            cin >> R[y][x];
            if(R[y][x] == 'R') start.ry = y, start.rx = x;
        }
    }

    for(int i=0; i<lim; i++)for(int j=0; j<lim; j++)for(int k=0; k<lim; k++)for(int l=0; l<lim; l++) visited[i][j][k][l] = false;

    queue<Point> que;
    que.push(start);

    while(que.size()){
        Point c = que.front();
        que.pop();
        if(visited[c.ly][c.lx][c.ry][c.rx]) continue;
        visited[c.ly][c.lx][c.ry][c.rx] = true;

        bool flag1 = (L[c.ly][c.lx] == '%');
        bool flag2 = (R[c.ry][c.rx] == '%');
        if(flag1 & flag2) return true;
        else if(flag1 || flag2) continue;

        P dL[4] = {P(1, 0), P(-1, 0), P(0, 1), P(0, -1)};
        P dR[4] = {P(1, 0), P(-1, 0), P(0, -1), P(0, 1)};
        for(int i=0; i<4; i++){
            Point n = Point{c.ly + dL[i].first, c.lx + dL[i].second, c.ry + dR[i].first, c.rx + dR[i].second};
            bool ok1 = (isIn(n.ly, n.lx) && L[n.ly][n.lx] != '#');
            bool ok2 = (isIn(n.ry, n.rx) && R[n.ry][n.rx] != '#');

            if(ok1 && ok2) que.push(n);
            else if(!ok1 && ok2) que.push(Point{c.ly, c.lx, n.ry, n.rx});
            else if(ok1 && !ok2) que.push(Point{n.ly, n.lx, c.ry, c.rx});
        }
    }
    return false;
}


int main(){
    while(true){
        cin >> W >> H;
        if(W == 0 && H == 0) return 0;
        if(solve()) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 12968
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

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

	private void solve() throws IOException {
		try {
			solveA();
			//			 solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int numA = nextInt();
		int numB = nextInt();
		int numC = nextInt();

		if (numA == numB) {
			out.println(numC);
		} else if (numA == numC) {
			out.println(numB);
		} else if (numB == numC) {
			out.println(numA);
		}
	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

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

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

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

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

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

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

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

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

Measured memory_bytes: 23252
#include<cstdio>

int main(){
    unsigned N, ok, ng, mid, last = 0, answer;
    scanf("%u", &N);
    for (unsigned i = 1; i <= N; i++){
        answer = 0;
        for (unsigned x = 1; x*(x + 2) + 3 <= i; x++){
            for (unsigned y = 1; x*x + y*y + x*y + x + y + 1 <= i; y++){
                ok = 1, ng = 100;
                while(ng - ok > 1){
                    mid = ng + ok >> 1;
                    if(x*x + y*y + mid*mid + x*y + y*mid + mid*x <= i) ok = mid;
                    else ng = mid;
                }
                answer += ok;
            }
        }
        printf("%u\n", answer - last);
        last = answer;
    }
	return 0;
}

Measured memory_bytes: 1680
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
using namespace std;
#define MOD 1000000007
int dp[110][5][5][5][5];




long long count(int n,int a,int b,int c,int d) {
	if (dp[n][a][b][c][d] != -1)return dp[n][a][b][c][d];

	long long temp = 0;
	

	
	if ((b==0&&c == 2 && d == 3)|| (b == 3 && c == 0 && d == 2)||(b==0&&c==3&&d==2)) {
		dp[n][a][b][c][d] = 0;
		return 0;
	}
	else if ((a == 0 && c == 3 && d == 2) || (a == 0 && b == 3 && d == 2)) {
		dp[n][a][b][c][d] = 0;
		return 0;
	}
	if (n == 1)return 1;
	for (int i = 0; i < 4; i++) {
		temp += count(n - 1, b, c, d, i);
	}

	dp[n][a][b][c][d] = temp % MOD;
	return dp[n][a][b][c][d];

	


}


int main() {
	int n;
	cin >> n;
	int ans;
	memset(dp, -1, sizeof(dp));
	ans = count(n+1, 4, 4, 4, 4);
	cout << ans;
	


	return 0;
}


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

void solve(long long N, long long M) {
    if (N == 1 && M == 1) {
        cout << 1 << endl;
        return;
    }
    if (M >= 3 && N >= 3) {
        cout << (M - 2) * (N - 2) << endl;
    } else if (M == 2 || N == 2) {
        cout << 0 << endl;
    } else if (M >= 3 && N == 1) {
        cout << M - 2 << endl;
    } else if (M == 1 && N >= 3) {
        cout << N - 2 << endl;
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 3760
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    int n = stdin.nextInt();
    int m = stdin.nextInt();
    int l = stdin.nextInt();
    int[][] A = new int[n][m];
    int[][] B = new int[m][l];

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        A[i][j] = stdin.nextInt();
      }
    }

    for (int i = 0; i < m; i++) {
      for (int j = 0; j < l; j++) {
        B[i][j] = stdin.nextInt();
      }
    }

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < l; j++) {
        long sum = 0;
        for (int k = 0; k < m; k++) {
          sum += A[i][k] * B[k][j];
        }
        System.out.printf(j == l - 1 ? "%d%n" : "%d ", sum);
      }
    }
  }
}

Measured memory_bytes: 55120
#include <bits/stdc++.h>
#define maxn 200086

using namespace std;

const int p = 998244353;

struct Node{
	int sum, tag;
}t[maxn << 2];

#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)

int ten[maxn], pw[10][maxn];

inline void up(int x, int l, int r){
	int mid = l + r >> 1;
	t[x].sum = (1ll * t[ls(x)].sum * ten[r - mid] + t[rs(x)].sum) % p;
}

inline void cover(int x, int l, int r, int d){
	t[x].tag = d;
	t[x].sum = pw[d][r - l + 1];
}

inline void down(int x, int l, int r){
	if(t[x].tag){
		int mid = l + r >> 1;
		cover(ls(x), l, mid, t[x].tag), cover(rs(x), mid + 1, r, t[x].tag);
		t[x].tag = 0;
	}
}

void modify(int x, int l, int r, int ll, int rr, int d){
	if(ll <= l && r <= rr){
		cover(x, l, r, d);
		return;
	}
	down(x, l, r);
	int mid = l + r >> 1;
	if(mid >= ll) modify(ls(x), l, mid, ll, rr, d);
	if(mid < rr) modify(rs(x), mid + 1, r, ll, rr, d);
	up(x, l, r);
}

int query(int x, int l, int r, int pos){
	if(l == r) return t[x].sum;
	down(x, l, r);
	int mid = l + r >> 1;
	if(mid >= pos) return query(ls(x), l, mid, pos);
	else return query(rs(x), mid + 1, r, pos);
	up(x, l, r);
}

void build(int x, int l, int r){
	if(l == r){
		t[x].sum = 1;
		return;
	}
	int mid = l + r >> 1;
	build(ls(x), l, mid), build(rs(x), mid + 1, r);
	up(x, l, r);
}

int n, q;
int l, r, d;

int main(){
	ten[0] = 1;for(int i = 1;i < maxn;i++) ten[i] = 1ll * ten[i - 1] * 10 % p;
	for(int j = 1;j <= 9;j++){
		for(int i = 1;i < maxn;i++) pw[j][i] = (1ll * pw[j][i - 1] * 10 + j) % p;
	}
	scanf("%d%d", &n, &q); 
	build(1, 1, n);
	while(q--){
		scanf("%d%d%d", &l, &r, &d);
		modify(1, 1, n, l, r, d);
		printf("%d\n", t[1].sum);
	}
}

Measured memory_bytes: 15748
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b = LI()
    if (a*b) % 2 == 0:
        return 'Even'

    return 'Odd'



print(main())




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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<int> S(n);
  for (int i = 0; i < n; ++i) {
    cin >> S[i];
  }

  int q;
  cin >> q;
  vector<int> T(q);
  for (int i = 0; i < q; ++i) {
    cin >> T[i];
  }

  int count = 0;
  for (int i = 0; i < q; ++i) {
    for (int j = 0; j < n; ++j) {
      if (T[i] == S[j]) {
        ++count;
        break;
      }
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int City, Road;
  cin >> City >> Road;
  vector<int> ans(City,0);
  
  for(int r = 0; r < Road * 2; r++){
    int city;
    cin >> city;
    ans.at(city-1) += 1;
  }
  for(int c = 0; c < ans.size(); c++){
    cout << ans.at(c) << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
   String a=kbd.next();
      int[] retu = new int[6];
      for(int i=0;i<6;i++){
        int p=a.charAt(i);
        retu[i]=p;
   }
   if(retu[2]==retu[3]&&retu[4]==retu[5]){
     System.out.println("Yes");
   }else{
     System.out.println("No");
   }
   }
   }


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

long inf = 1000000007;
long calc(long a,long b,long p){
  if(b == 0){
    return 1;
  }
  else if(b % 2 == 0){
    long d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else{
    return (a*calc(a,b-1,p)) % p;
  }
}

long nCr(long n,long r){
  long kekka = 1;
  //w+h-2 c w-1
  for(long i = 0;i < r;i++){
    kekka = (kekka*(n-i)) % inf;
    //cout << kekka << endl;
  }
  for(long i = 1;i <= r;i++){
    kekka = (kekka*calc(i,inf-2,inf)) % inf;
    //cout << kekka << endl;
  }
  //cout << kekka << ' ' << "nCr" << endl;
  return kekka;
}

int main(){
  long n,k;
  cin >> n >> k;
  vector<long> answer;
  for(int i = 1;i <= k;i++){
    if(n-k < i - 1){
      answer.push_back(0);
    }
    else{
      long red = nCr(n-k+1,i);
      //cout << i+1 << ' ' << n-k-i+1 << ' ' << red << endl;
      long blue = nCr(k-1,i-1);
      answer.push_back((red*blue)%inf);
    }
  }
  for(int i = 0;i < answer.size();i++){
    cout << answer.at(i) << endl;
  }
}

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

class Program
{
    public static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        if (int.Parse(s[0]) == int.Parse(s[1]) && int.Parse(s[1]) == int.Parse(s[2]))
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}


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

#define ll long long

int main(){
    ll n, x;
    cin >> n >> x;
    vector<int> a(n);
    ll s=0;
    for(int i=0; i<n; ++i){
        cin >> a[i];
        s += a[i];
    }
    
    if(s==x){
        cout << n;
        return 0;
    }
    else if(x > s){
        cout << n-1;
        return 0;
    }

    sort(a.begin(), a.end());

    int count=0;
    for(int i=0; i<n; ++i){
        if(a[i] <= x){
            count++;
            x -= a[i];
        }
        else
            break;
    }
    cout << count;
}


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

using namespace std;

int n;

int main(void) {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    if ((n & (n - 1)) == 0) {
        cout << "No" << endl;
        return 0;
    }
    if (n % 4 == 3) {
        cout << "Yes" << endl;
        for (int i = 1; i < n + n; ++i) cout << i << ' ' << i + 1 << endl;
        return 0;
    }
    if (n % 4 == 0) {
        cout << "Yes" << endl;
        for (int i = 1; i + 1 < n; ++i) cout << i << ' ' << i + 1 << endl;
        cout << n - 1 << ' ' << n + 1 << endl;
        for (int i = 1; i + 1 < n; ++i) cout << n + i << ' ' << n + i + 1 << endl;
        int x = n & -n;
        int y = n - x;
        cout << x + 1 << ' ' << n << endl;
        cout << y << ' ' << n + n << endl;
        return 0;
    }
    if (n % 4 == 1) {
        cout << "Yes" << endl;
        for (int i = 1; i + 2 < n; ++i) cout << i << ' ' << i + 1 << endl;
        cout << n - 2 << ' ' << n + 1 << endl;
        for (int i = 1; i + 2 < n; ++i) cout << n + i << ' ' << n + i + 1 << endl;
        cout << n - 1 << ' ' << n << endl;
        cout << n << ' ' << 1 << endl;
        cout << n + 1 << ' ' << n + n - 1 << endl;
        cout << n + n - 1 << ' ' << n + n << endl;
        return 0;
    }
    if (n % 4 == 2) {
        cout << "Yes" << endl;
        for (int i = 1; i + 3 < n; ++i) cout << i << ' ' << i + 1 << endl;
        cout << n - 3 << ' ' << n + 1 << endl;
        for (int i = 1; i + 3 < n; ++i) cout << n + i << ' ' << n + i + 1 << endl;
        cout << n - 2 << ' ' << n - 1 << endl;
        cout << n - 1 << ' ' << 1 << endl;
        cout << n + 1 << ' ' << n + n - 2 << endl;
        cout << n + n - 2 << ' ' << n + n - 1 << endl;
        cout << n << ' ' << n - 1 << endl;
        cout << 2 << ' ' << n + n << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
 
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

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

	vector<int> e(100001, 0), o(100003, 0);
	int even = 0, odd = 0;
	int x1 = 0, x2 = 0;
	for (int i = 0; i < n; i++){
		if (i % 2 == 0){
			e[v[i]]++;
			if(e[v[i]] > even){
				even = e[v[i]];
				x1 = v[i];
			}
		}else{
			o[v[i]]++;
			if(o[v[i]] > odd){
				odd = o[v[i]];
				x2 = v[i];
			}
		}
	}

	sort(e.begin(), e.end(), greater<int>());
	sort(o.begin(), o.end(), greater<int>());
	
	if (x1 != x2){
		cout << n - even - odd << endl;
	}else{
		cout << n - max(even + o[1], odd + e[1]) << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>

int main()
{
    char in1[11];
    scanf("%s", in1);
    int len=strlen(in1);
    if(in1[0]=='A'){
        int i, cnt=0;
        for(i=2; i<len-1; ++i){
            if(in1[i]=='C'){
                if(cnt) goto aboat;
                cnt=1;
            }
        }
        if(!cnt) goto aboat;
        for(i=1; i<len; ++i){
            if('C'!=in1[i]&&!('a'<=in1[i]&&in1[i]<='z')){
                goto aboat;
            }
        }
        printf("AC\n");
    }else{
        aboat:
        printf("WA\n");
    }
    return 0;
}


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

int main(void){
    int  n;
    int32_t s=0,ps=0;
    cin>>n;
    int32_t h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    for(int i=0;i<n-1;i++){
        if(h[i]>=h[i+1]){
            s++;
        }
        else{
            s=0;
        }
        ps=s>ps?s:ps;

    }

    cout<<ps;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll A, B;
        cin >> A >> B;
        string S;
        cin >> S;
        ll pos = 0;
        bool flg = true;
        rep(i, 0, A) {
                if (not isdigit(S[pos])) flg = false;
                ++pos;
        } 

        if (S[pos] != '-') flg = false;
        ++pos;

        rep(i, 0, B) {
                if (not isdigit(S[pos])) flg = false;
                ++pos;
        }

        if (flg) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }
}

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

using namespace std;

double pa[2], pb[2];
double ra, rb;

int solve() {
  double dis = sqrt((pa[0] - pb[0]) * (pa[0] - pb[0])
                + (pa[1] - pb[1]) * (pa[1] - pb[1]));

  if (dis > ra + rb)
    return 0;
  else if (dis + ra < rb)
    return -2;
  else if (dis + rb < ra)
    return 2;
  else
    return 1;
}

int main() {
  int n;
  
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> pa[0] >> pa[1] >> ra >> pb[0] >> pb[1] >> rb;
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

const int N = 4e5 + 5000;
int n, m, T, x, y, a, b, c, len;
pair<int, int> g[N];
int main()
{
#ifdef ONLINE_JUDGE
#else
   // freopen("r.txt", "r", stdin);
    // freopen("w.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);

    cin >> x >> y >> a >> b >> c;

    for (int num, i = 1; i <= a; i++) {
        cin >> num;
        g[++len] = make_pair(num, 1);
    }
    for (int num, i = 1; i <= b; i++) {
        cin >> num;
        g[++len] = make_pair(num, 2);
    }
    for (int num, i = 1; i <= c; i++) {
        cin >> num;
        g[++len] = make_pair(num, 3);
    }

    sort(g + 1, g + len + 1);
    // cout << 233 << endl;
    long long ans = 0, cnt = 0;
    for (int i = len; i; i--) {
        if (x + y == cnt)
            break;
        if (g[i].second == 1 and x) {
            ans += g[i].first;
            x--;
        } else if (g[i].second == 2 and y) {
            ans += g[i].first;
            y--;
        } else if (g[i].second == 3) {
            cnt++;
            ans += g[i].first;
        }
    }

    cout << ans;
}

Measured memory_bytes: 3456
// https://atcoder.jp/contests/dp/tasks/dp_a
#include<iostream>
#include <cstdlib>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n;
	cin >> n;
	int height[n];
	for(int i=0;i<n;i++)
		cin >> height[i];
	int arr[n];
	arr[0]=0;
	arr[1]=abs(height[1]-height[0]);
	for(int i=2;i<n;i++)
		arr[i] = min(arr[i-2]+abs(height[i-2]-height[i]) , arr[i-1]+abs(height[i-1]-height[i]));
	cout << arr[n-1] << endl;
	return 0;
}

Measured memory_bytes: 3908
import sys

n = int(input())
d = input().split()
m = int(input())
t = input().split()

dic = {}
for i in d:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

for j in t:
    if j not in dic:
        print('NO')
        sys.exit()

    dic[j] -= 1
    if dic[j] < 0:
        print('NO')
        sys.exit()

print('YES')


Measured memory_bytes: 54116
'use strict'

function main(input) {
  input = input
    .trim()
    .split(' ')
    .map(v => Number(v))
  const k = input[0]
  const s = input[1]
  let count = 0
  for (let xi = 0; xi <= k; xi = (xi + 1) | 0) {
    for (let yi = 0; yi <= k; yi = (yi + 1) | 0) {
      const tmp = s - (xi + yi)
      if (tmp >= 0 && tmp <= k) count++
    }
  }

  console.log(count)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7756
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin>>a>>b;
	ll ans=a+b;
	ans=max(ans,a-b);
	ans=max(ans,a*b);
	cout<<ans;
    return 0;
}


//252908XL

Measured memory_bytes: 256
str   = gets.chomp
array = gets.chomp.split(" ").map(&:to_i)

def can_division_2?(array)
  array.size == array.reject { |n| n.odd? }.size
end

output = 0

while can_division_2?(array)
  output += 1
  array.map! { |n| n / 2 }
end

puts output


Measured memory_bytes: 1788
#include<stdio.h>
int main(void){
	int x[10000];
	int i=0;
	while(1){
		scanf("%d",&x[i]);
		if(x[i]==0){break;}
		i++;
	}
	int h=0;
	for(h=0;i>h;h++){
		printf("Case %d: %d\n",h+1,x[h]);
	}
	return 0;
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,t=0;
	cin>>n;
	long long int a[n+5],ans[2]={0};
	for(int i=0 ; i<n ; i++)
		cin>>a[i];
	sort(a,a+n,greater<int>() );
	for(int i=0 ; i<n ; i++)
	{
		if(a[i]==a[i+1])	ans[t++]=a[i],i++;
		if(t==2)	break;
	}
	cout<<ans[0]*ans[1]<<endl;
}


Measured memory_bytes: 1024
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]

ans = 0
for i in range(N):
    res = C
    for j in range(M):
        res += A[i][j] * B[j]
    if res > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;


int main(){
    ll l,r;
    cin >> l >> r;
    if(r-l >= 2018){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1010101;
    for(ll i=l; i<r; i++){
        for(ll j=i+1; j<=r; j++){
            ll now;
            now = ((i%2019)*j)%2019; 
            ans = min(now,ans);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
	string s;
	cin>>s;
	string temp(s.begin(), s.end());
	reverse(temp.begin(), temp.end());
	if(s.compare(temp) == 0) {
		int l1 = (s.length()-1)/2;
		int l2 = (s.length()+3)/2;
		string t1(s.begin(), s.begin()+l1), t2(s.begin(), s.begin() + l1);
		string p1(s.begin()+l2-1, s.end()), p2(s.begin()+l2-1, s.end());
		reverse(t2.begin(), t2.end());
		reverse(p2.begin(), p2.end());
		if(t1.compare(t2) == 0 && p1.compare(p2) == 0) {
			cout<<"Yes\n";
		} else {
			cout<<"No\n";
		}
	} else {
		cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
#print(l)
dp = [0]*n
dp[1] = abs(l[1]-l[0])
for i in range(1,n-1):
  dp[i+1] = min(dp[i]+abs(l[i+1]-l[i]), dp[i-1]+abs(l[i+1]-l[i-1]))
print(dp[-1])

Measured memory_bytes: 13980