akhauriyash/Code-Regression huggingface dataset:
import math
a,b,x=map(int,input().split())
S=a*b-x/a
if S<=a*b/2:
    aaa=S*2/(a*a)
    ans=math.degrees(math.atan(aaa))
    print(ans)
else :
    S=x/a
    aaa=S*2/(b*b)
    ans=math.degrees(math.atan(aaa))
    print(90-ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#ifdef TOPOLOGY
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
using namespace std;

const int MOD = 1000000007;
char board[2][55];
long long dp[55][3][3];
int n;

int main() {
	cin >> n >> board[0] >> board[1];
	vector<int> scan;
	for (int i = 0; i < n; i++) {
		if (board[0][i] == board[1][i]) scan.push_back(1);
		else {
			scan.push_back(2);
			i++;
		}
	}
	n = (int)scan.size();
	for (int i = 0; i < n; i++) {
		if (scan[i] == 1) {
			if (i) {
				if (scan[i - 1] == 1) {
					for (int j = 0; j < 3; j++) {
						for (int k = 0; k < 3; k++) {
							if (j == k) continue;
							dp[i][j][0] = (dp[i][j][0] + dp[i - 1][k][0]) % MOD;
						}
					}
				} else {
					for (int j = 0; j < 3; j++) {
						for (int k = 0; k < 3; k++) {
							for (int l = 0; l < 3; l++) {
								if (j == k || k == l || j == l) continue;
								dp[i][j][0] = (dp[i][j][0] + dp[i - 1][k][l]) % MOD;
							}
						}
					}
				}
			} else {
				for (int j = 0; j < 3; j++) {
					dp[i][j][0] = 1LL;
				}
			}
		} else {
			if (i) {
				if (scan[i - 1] == 1) {
					for (int j = 0; j < 3; j++) {
						for (int k = 0; k < 3; k++) {
							for (int l = 0; l < 3; l++) {
								if (j == k || k == l || l == j) continue;
								dp[i][j][k] = (dp[i][j][k] + dp[i - 1][l][0]) % MOD;
							}
						}
					}
				} else {
					for (int j = 0; j < 3; j++) {
						for (int k = 0; k < 3; k++) {
							for (int jj = 0; jj < 3; jj++) {
								for (int kk = 0; kk < 3; kk++) {
									if (j == k || j == jj || k == kk) continue;
									dp[i][j][k] = (dp[i][j][k] + dp[i - 1][jj][kk]) % MOD;
								}
							}
						}
					}
				}
			} else {
				for (int j = 0; j < 3; j++) {
					for (int k = 0; k < 3; k++) {
						if (j == k) continue;
						dp[i][j][k] = 1LL;
					}
				}
			}
		}
	}
	long long ans = 0;
	if (scan[n - 1] == 1) {
		for (int i = 0; i < 3; i++) {
			ans = (ans + dp[n - 1][i][0]) % MOD;
		}
	} else {
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				ans = (ans + dp[n - 1][i][j]) % MOD;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
vector<int> edge[100001];
int par[100001];
vector<int> child[100001];
ll dp[100001][2];

void dfs(int i){
  rep(j, edge[i].size()){
    if(par[edge[i][j]] < 0){
      par[edge[i][j]] = i;
      child[i].pb(edge[i][j]);
      dfs(edge[i][j]);
    }
  }
}

// l = 0: black, l = 1: white
ll calc(int i, int l){
  if(dp[i][l] >= 0)return dp[i][l];
  if(child[i].size() == 0){
    return 1;
  }
  ll res = 1;
  rep(j, child[i].size()){
    ll tmp = calc(child[i][j], 1);
    if(l == 1){
      tmp = (tmp + calc(child[i][j], 0)) % mod;
    }
    res = (res * tmp) % mod;
  }
  return dp[i][l] = res;
}

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  rep(i, n - 1){
    int x, y;
    cin >> x >> y;
    x--; y--;
    edge[x].pb(y);
    edge[y].pb(x);
  }
  fill(par, par + n, -1);
  par[0] = 0;
  dfs(0);
  rep(i, n+1){
    rep(j, 2)dp[i][j] = -1;
  }
  cout << (calc(0, 0) + calc(0, 1)) % mod << endl;
	return 0;
}


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

using namespace std;

int main() {
    int tmpa, tmpb;
    vector<int> a;
    vector<int> b;
    
    while (cin >> tmpa >> tmpb) {
        a.push_back(tmpa);
        b.push_back(tmpb);
    }
    
    for (int i = 0; i < a.size(); i++) {
        int sum = a[i] + b[i];
        int keta = 0;
        while (sum > 0) {
            sum /= 10;
            keta++;
        }
        cout << keta << endl;
    }

    return 0;
}


Measured memory_bytes: 3032
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    //"Yes"  '\n'
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll e=a+b;
    ll m=d-e;
    if(e>=d)
    {
        if(a<=d)cout<<a<<endl;
        else cout<<d<<endl;
    }

    else cout<<a-m<<endl;

}          //Alhamdulilla..


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 1000000000;
using namespace std;
bool sosu(int n) {
  if (n <= 1)
    return false;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0)
      return false;
  return true;
}
int main() {
  long long a[10010], n, m = 1;
  a[1] = 2;
  for (int i = 3; m < 10000; i++) {
    if (sosu(i)) {
      a[m + 1] = a[m] + i;
      m += 1;
    }
  }
  while (cin >> n, n)
    cout << a[n] << endl;
  return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    cout<<s.substr(0,4)<<' '<<s.substr(4,8)<<endl;
}

Measured memory_bytes: 256
s=input()
li=[]
ans = 0
for i in range(len(s)):
  if i == 0:
    li.append(s[i])
  else:
    if s[i] == li[-1] and s[i] == "0":
      li.append("1")
      ans += 1
    elif s[i] == li[-1] and s[i] == "1":
      li.append("0")
      ans += 1
    else:
      li.append(s[i])
print(ans)

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

int main() {
  int N, A;
  cin >> N >> A;
  if (N<1 || N>100 || 
      A<0 || A>N*N){
    return 0;
  }
  cout << (N*N - A) << endl;
  return 0;
}

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

using namespace std;
using InnerDice = array<int, 6>;

class Dice {

  public:
    int top, bottom, left, right, front, back;

    void roll_east() {
      int before_right = right;

      right = top;
      top = left;
      left = bottom;
      bottom = before_right;
    }

    void roll_west() {
      int before_left = left;

      left = top;
      top = right;
      right = bottom;
      bottom = before_left;
    }

    void roll_north() {
      int before_back = back;

      back = top;
      top = front;
      front = bottom;
      bottom = before_back;
    }

    void rotate_clockwise() {
      int before_back = back;

      back = left;
      left = front;
      front = right;
      right = before_back;
    }

    // return ok or not
    bool roll(int afterTop, int afterFront) {
      if(afterTop == left) {
        roll_east();
      } else if(afterTop == right) {
        roll_west();
      }

      int try_count = 0;
      while(top != afterTop && try_count <= 3)  {
        roll_north();
        try_count++;
      }
      if(try_count > 3) {
        return false;
      }

      try_count = 0;
      while(front != afterFront && try_count <= 3) {
        rotate_clockwise();
        try_count++;
      };
      if(try_count > 3) {
        return false;
      }

      return true;
    }

    bool isSame(Dice other) {
      bool success = other.roll(top, front);
      if(!success) {
        return false;
      }

      return other.right == right &&
             other.left == left &&
             other.bottom == bottom &&
             other.back == back;
    }
};

int main() {
  int dice_num;
  vector<Dice> dices;

  cin >> dice_num;

  dices.resize(dice_num);

  for(int i = 0; i < dice_num; i++) {
    Dice current_dice;

    for(int i = 1; i <= 6; i++) {
      int face_label;
      cin >> face_label;

      switch (i) {
        case 1:
          current_dice.top = face_label;
          break;
        case 2:
          current_dice.front = face_label;
          break;
        case 3:
          current_dice.right = face_label;
          break;
        case 4:
          current_dice.left = face_label;
          break;
        case 5:
          current_dice.back = face_label;
          break;
        case 6:
          current_dice.bottom = face_label;
          break;
        default:
          return 1;
      }
    }

    dices[i] = current_dice;
  }


  // 全ての組み合わせを調べる
  bool isAllDifferent = true;
  for(int i = 0; i < dices.size() - 1; i++) {
    for(int j = i + 1; j < dices.size(); j++) {
      bool isSame = dices[i].isSame(dices[j]);

      if(isSame) {
        isAllDifferent = false;
        break;
      }
    }
  }

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



Measured memory_bytes: 3108
import java.util.Scanner;

class Main{
    private static int[] A;
    private static long  count=0;
    private static int max = 1100000000;
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	A = new int[n];
	int p = n;
	for(int i=0;i<n;i++){
	    A[i] = sc.nextInt();
 
	}
       
	mergeSort(0,n);
       
	System.out.println(count);
	
	
    }
    public static void merge(int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	int[] L = new int[n1+1];
	int[] R = new int[n2+1];
	for(int i=0; i<n1; i++){
	    L[i] = A[left+i];
	}
	for(int i=0; i<n2; i++){
	    R[i] = A[mid+i];
	}
	L[n1]=max;
	R[n2]=max;
	int i=0;
	int j=0;
	for(int k=left;k<right;k++){	    
	    if(L[i] <= R[j]){
		A[k] = L[i];
		i++;		
	    }else{
		A[k] = R[j];
		j++;
		count += n1-i;
		
	    }
	}
    }
    public static void mergeSort(int left,int right){
	if(left+1<right){
	    int mid = (left+right)/2;
	    mergeSort(left, mid);
	    mergeSort(mid, right);
	    merge(left,mid, right);
	}
    }
}



Measured memory_bytes: 102896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int X, N;
    cin >> X >> N;
    vector<bool> existed(105);
    for (int i = 0; i < N; ++i) {
        int p;
        cin >> p;
        existed[p] = true;
    }

    int mi = INT_MAX, ans = 0;
    for (int i = 0; i < 105; ++i)
        if (!existed[i] && mi > abs(X - i))
            mi = abs(X - i), ans = i;

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


Measured memory_bytes: 3652
n=int(input())
r=[tuple(map(int,input().split())) for i in range(n)]
b=[tuple(map(int,input().split())) for i in range(n)]
r.sort(key=lambda x: x[1],reverse=True)
b.sort(key=lambda x: x[0])
selected=[0]*n

ans=0
for i in range(n):
  bx,by=b[i]
  j=0
  while j<n:
    rx,ry=r[j]
    if bx>rx and by>ry and selected[j]==0:
      ans+=1
      selected[j]=1
      break
    j+=1
print(ans)



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

Edge = [[]for _ in range(N)]
Num = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int,input().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)
for _ in range(N):
    Num[len(Edge[_])].append(_)
C = list(map(int, input().split()))
C.sort()
cnt = 0
Ans = [-1] * N
ans = 0
for i in range(1, N):
    if cnt == N:
        break
    while Num[i]:
        if Num[0]:
            Ans[Num[0][0]] = C[cnt]
            cnt += 1
        x = Num[i].pop()
        if Ans[x] != -1:
            continue
        Ans[x] = C[cnt]
        ans += C[cnt] * i
        cnt += 1
        for y in Edge[x]:
            num = len(Edge[y])
            Num[num-1].append(y)
            Edge[x].remove(y)
            Edge[y].remove(x)

print(ans)
for i, a in enumerate(Ans):
    if i == N-1:
        print(a)
    else:
        print(a, end=' ')


Measured memory_bytes: 77744
#include <cstdio>           // printf(), scanf(), getc()
#include <cctype>           // isdigit()
#include <vector>
#include <queue>
#include <algorithm>        // max()

using namespace std;

static const int MAX_N = 100000;
static const int INFTY = -1;

class edge
{
public:
	int t, w;
	edge() {}
	edge(int t, int w): t(t), w(w) {}
};

vector<edge> G[MAX_N];
int n;
int d[MAX_N];

bool vis[MAX_N];
int count;

void
bfs(int s)
{
	for (int i = 0; i < n; ++i)
		d[i] = INFTY;

	queue<int> Q;
	Q.push(s);
	d[s] = 0;
	while(!Q.empty())
	{
		int u = Q.front(); Q.pop();
		for (unsigned int i = 0; i < G[u].size(); ++i)
		{
			edge e = G[u][i];
			if (d[e.t] == INFTY)
			{
				d[e.t] = d[u] + e.w;
				Q.push(e.t);
			}
		}
	}
}

int
solve()
{
	// ??????????????? s ???????????????????????? tgt ????±???????
	bfs(0);
	int maxv = 0;
	int tgt = 0;
	for (int i = 0; i < n; ++i)
	{
		if (d[i] > maxv)
		{
			maxv = d[i];
			tgt = i;
		}
	}

	// tgt ????????????????????????????????¢ maxv ????±???????
	bfs(tgt);
	maxv = 0;
	for (int i = 0; i < n; ++i)
		maxv = max(maxv, d[i]);

	return maxv;
}

int
main(int argc, char** argv)
{
	int s, t, w;
	int x;
	int c;

	scanf("%d", &n);
	c = getc(stdin);
	for (int i = 0; i < n - 1; ++i)
	{
		while (c == ' ' || c == '\n')
			c = getc(stdin);

		x = 0;
		while (isdigit(c))
		{
			x = x * 10 + c - '0';
			c = getc(stdin);
		}

		s = x;
		while (c == ' ' || c == '\n')
			c = getc(stdin);

		x = 0;
		while (isdigit(c))
		{
			x = x * 10 + c - '0';
			c = getc(stdin);
		}

		t = x;
		while (c == ' ' || c == '\n')
			c = getc(stdin);

		x = 0;
		while (isdigit(c))
		{
			x = x * 10 + c - '0';
			c = getc(stdin);
		}

		w = x;
		G[s].push_back(edge(t, w));
		G[t].push_back(edge(s, w));
	}

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

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(base, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)2e5+1;
ll N, c[MAXN];


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    ll ans = fastExp(2, 2*N-2);
    ll t = 0;
    for(int i=1; i<=N; i++)
    {
        cin >> c[i];
    }
    sort(c+1, c+N+1);
    for(int i=1; i<=N; i++)
    {
         t = add(t, times(c[i], N-i+2));
    }
    cout << times(ans, t);
    return 0;
}


Measured memory_bytes: 1792
from sys import stdin
from collections import deque
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    g=[[] for _ in range(N)]
    AB=[]
    for _ in range(N-1):
        a,b=map(lambda x:int(x)-1,readline().split())
        g[a].append(b)
        g[b].append(a)
        AB.append(str(a)+" "+str(b))

    link=[0]*N
    que=deque([0])
    is_searched=[False]*N
    is_searched[0]=True
    K=0
    ans=dict()
    #bfs
    while len(que)>=1:
        now=que.popleft()
        color=1
        for x in g[now]:
            if is_searched[x]:
                continue
            else:
                is_searched[x]=True
                que.append(x)
                if color==link[now]:
                    color+=1
                link[x]=color
                ans[str(min(now,x))+" "+str(max(now,x))]=color
                color+=1
        color-=1
        K=max(K,color)

    #出力
    print(K)
    for key in AB:
        print(ans[key])
        
if __name__=="__main__":
    main()

Measured memory_bytes: 111520
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node
{
int p,l,r;
};

struct Node T[MAX];
int n;

void pre(int u)
{
  if(u==NIL) return ;
  printf(" %d",u);
  pre(T[u].l);
  pre(T[u].r);
}

void in(int u)
{
  if(u==NIL) return ;
  in(T[u].l);
  printf(" %d",u);
  in(T[u].r);
}

void post(int u)
{
  if(u==NIL) return ;
  post(T[u].l);
  post(T[u].r);
  printf(" %d",u);
}

main ()
{
  int i,v,l,r,root;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    T[i].p=NIL;
  }

  for(i=0;i<n;i++)
  {
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l != NIL) T[l].p=v;
    if(r != NIL) T[r].p=v;
  }

  for(i=0;i<n;i++) if(T[i].p==NIL) root=i;
  printf("Preorder\n");
  pre(root);
  printf("\n");
  printf("Inorder\n");
  in(root);
  printf("\n");
  printf("Postorder\n");
  post(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2108
using System;

public class Hello
{
    public static int MOD = 1000000007;
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var sL = s.Length;
        var a1 = new int[sL];
        var q1 = new int[sL];
        var c2 = new int[sL];
        var q2 = new int[sL];
        var ca1 = 0; var cc2 = 0; var cq1 = 0; var cq2 = 0;
        for (int i = 0; i < s.Length; i++)
        {
            a1[i] = ca1; q1[i] = cq1;
            c2[sL - 1 - i] = cc2; q2[sL - 1 - i] = cq2;
            if (s[i] == 'A') ca1++;
            else if (s[i] == '?') cq1++;
            if (s[sL - 1 - i] == 'C') cc2++;
            else if (s[sL - 1 - i] == '?') cq2++;
        }
        var ans = 0L;
        for (int i = 1; i <= sL - 2; i++)
        {
            if (s[i] == 'B' | s[i] == '?')
            {
                var acount = (long)a1[i];
                var qcount = q1[i];
                var wwa = (acount * (get3power(3, qcount))) % MOD;
                if (qcount >= 1) wwa += (qcount * (get3power(3, qcount - 1))) % MOD;
                wwa %= MOD;
                var ccount = c2[i];
                var qcount2 = q2[i];
                var wwc = (ccount * (get3power(3, qcount2))) % MOD;
                if (qcount2 >= 1) wwc += (qcount2 * (get3power(3, qcount2 - 1))) % MOD;
                wwc %= MOD;
                ans += (wwa * wwc) % MOD;
                ans %= MOD;
            }
        }
        Console.WriteLine(ans);
    }
    public static long get3power(int a, int b)
    {
        if (b == 0) return 1L;
        if (b == 1) return (long)(a % MOD);
        var k = (int)(Math.Log10(b) / Math.Log10(2)) + 1;
        var p = new long[k];
        p[0] = (long)a;
        for (int i = 1; i < k; i++)
            p[i] = (p[i - 1] * p[i - 1]) % MOD;
        var ret = 1L;
        for (int i = 0; i < k; i++)
            if (((b >> i) & 1) == 1)
            {
                ret *= p[i];
                ret %= MOD;
            }
        return ret;
    }
}

Measured memory_bytes: 16992
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define int      long long int
#define MOD      1000000007
#define pb       push_back
#define mp       make_pair
#define vi       vector<int>
#define mi  	 map<int,int>
#define umi		 unordered_map<int,int>
#define pii      pair<int,int>
#define ff 		 first
#define ss 		 second
#define inf		 1e18
#define case	int t;cin>>t;while(t--)
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void pre()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main()
{	//pre();
	//case
	{	int n;
		cin >> n;
		int a[n], b[n], c[n];
		for (int i = 0; i < n; i++)
			cin >> a[i] >> b[i] >> c[i];
		int dp[n][4];
		dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
		for (int i = 1; i < n; i++)
		{	dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
			dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
			dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + c[i];
		}
		cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});
	}
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin >> N;
    vint a(N);
    string s;
    cin >> s;
    bool flag=false;
    map<int,int> cnt;
    for (int i = 0; i < N; i++)
    {
        a[i] = s[i] - '0' - 1;
        
    }
    L:
    for (size_t i = 0; i < N; i++)
    {
        cnt[a[i]]++;
    }
    if(cnt[0] == N)
    {
        cout<<0;
        return 0;
    }
    auto b=a;
    for (int i = 0; i < N; i++)
    {
        b[i]%=2;
        if (((N - 1) & (i)) != i)
        {
            b[i] = 0;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans = ans xor b[i];
    }
    if(ans == 1 or cnt[1]!=0)
    {
        if(flag)
        ans*=2;
        cout<<ans;
        return 0;
    }
    for (size_t i = 0; i < N; i++)
    {
        a[i]/=2;
    }
    flag=true;
    cnt.clear();
    goto L;
    return 0;
}

Measured memory_bytes: 9116
#include<stdio.h>
#include<stdlib.h>

int main(void){
    int N,c=1;
    char *S;
    scanf("%d",&N);
    S =malloc(sizeof(char)*(N+1));
    scanf("%s",S);
    for(int i=0;i<N-1;i++) if(S[i] != S[i+1]) c++;
    printf("%d",c);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ll N, K;
  cin >> N >> K;
  ll R, S, P;
  cin >> R >> S >> P;
  string T;
  cin >> T;

  map<char, ll> m;
  m['s'] = R, m['p'] = S, m['r'] = P;

  vector<string> group(K);
  rep(i, N) {
    group[i % K].pb(T[i]);
  }

  ll ans = 0;
  rep(i, K) {
    rep(j, sz(group[i])) {
      ans += m[group[i][j]];
      if (j + 1 < sz(group[i]) && group[i][j] == group[i][j + 1])
        j++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5120
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        HashMap<String,Integer> hm=new HashMap<>();
        hm.put("AC",0);
        hm.put("WA",0);
        hm.put("TLE",0);
        hm.put("RE",0);
        while(N-->0) {
            String s=sc.next();
            hm.put(s,hm.get(s)+1);
        }
        System.out.println("AC x "+hm.get("AC"));
        System.out.println("WA x "+hm.get("WA"));
        System.out.println("TLE x "+hm.get("TLE"));
        System.out.println("RE x "+hm.get("RE"));
    }
}

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

struct UnionFind{
	vector<int> data;
	UnionFind(int n):data(n,-1){}
	int Find(int i){
		return data[i]<0?i:(data[i]=Find(data[i]));
	}
	bool Unite(int a,int b){
		a=Find(a),b=Find(b);
		if(a==b) return false;
		if(-data[a]<-data[b]) swap(a,b);
		data[a]+=data[b];
		data[b]=a;
		return true;
	}
};

int ModPow(int a,int r,int m)
{
	long long x=1;
	for(int i=32;i--;){
		x=x*x%m;
		if(r>>i&1)
			x=x*a%m;
	}
	return x;
}

int main()
{
	constexpr int MOD=1e9+7;
	
	for(int n,m;~scanf("%d%d",&n,&m) && n|m;){
		UnionFind uf(n);
		int cc=n;
		while(m--){
			int a,b; scanf("%d%d",&a,&b); a--,b--;
			cc-=uf.Unite(a,b);
		}
		int res=ModPow(2,cc,MOD);
		if(cc<n) res=(res+1)%MOD;
		printf("%d\n",res);
	}
}

Measured memory_bytes: 1556
#include <cmath>
#include <string.h>
#include <iostream>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

#define rep(i, j, n) for (ull i = j; i < n; i++)
#define rep_nested(i, s, n) for (ull i = s; i <= n; i++)
#define ll long long
#define ull unsigned long long

const int N = 500;
const ll INF = 1e9 + 7;

using namespace std;

template <class T>
T limit(T n, T k) {
	return (n > k) ? k : n;
}

template <class T>
T has_order(T a, T b, T c) {
	return (b > a && b < c) || (b < a && b > c);
}

template <class T>
float points_distance(T a) {
	return sqrt(a);
}

template <class T>
T is_integer(T a) {
	return floor(a) == a;
}

int main() {
	ull a, b, k;
	
	cin >> a >> b;
	
	k = (a + b) % 2;
	
	if (k) cout << "IMPOSSIBLE" << endl;
	else cout << ((a + b) / 2) << endl;
	
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	string ss, tt;
	cin >> ss >> tt;
	int64 ans = 0;
	for(int64 ii = 0;ii < ss.length();ii++)
	{
		if(ss[ii] != tt[ii])
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3928
#include<bits/stdc++.h>
using namespace std;
int fact(int n){return n>1?n*fact(n-1):1;}
signed main(){
  int n,fn;
  cin>>n;
  fn=fact(n);
  vector<int> p(n),q(n),r(n);
  for(auto& i:p)cin>>i;
  for(auto& i:q)cin>>i;
  for(int i=0;i<n;++i){
    if(p[i]==q[i])continue;
    if(p[i]<q[i])break;
    else {
      swap(p,q);
      break;
    }
  }
  for(int i=0;i<fn;++i){
    bool f=true;
    for(int j=0;f&&j<n;++j){
      if(p[j]!=q[j])f=false;
    }
    if(f)return cout<<i,0;
    next_permutation(p.begin(),p.end());
  }
}


Measured memory_bytes: 256
/**
	������������ Author : Avi J Patel ������������
	������������ University : DA-IICT ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define N 100000
#define ff first
#define ss second
#define si size()
#define MOD 998244353
#define large 10000000000000001

#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
/*void calc()
{
	for(int i=0;i<2005;i++)
	{
		a[i][0]=1;
		a[i][i]=1;
		for(int j=1;j<i;j++)
		{
			a[i][j]=(a[i-1][j-1]+a[i-1][j])%MOD;	
		}
	}
}*/
int main()
{
	int n;
	cin>>n;
	vector<int> a(n+1),b(n);
	for(int i=0;i<n+1;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]<=b[i] && a[i]>0)
		{
			ans+=a[i];
			b[i]-=a[i];
			if(a[i+1]>=b[i])
			{
				ans+=(b[i]);
				a[i+1]-=b[i];
			}
			else
			{
				ans+=a[i+1];
				a[i+1]=0;
			}
		}
		else if(a[i]==0)
		{
			if(a[i+1]<=b[i])
			{
				ans+=a[i+1];
				a[i+1]=0;
			}
			else
			{
				ans+=b[i];
				a[i+1]-=b[i];
			}
		}
		else if(a[i]>b[i])
		{
			ans+=b[i];
		}
	}
	cout<<ans;
}









Measured memory_bytes: 1024
#include <stdio.h>
#include <ctype.h>

int main(void)
{
	char s;

	while(1){
		scanf("%c", &s);
		if(islower(s))
			printf("%c", toupper(s));
		else if(isupper(s))
			printf("%c", tolower(s));
		else if(s == '.'){
			printf(".");
		} else if(s == '\n'){
			printf("\n");
			break;
		} else
			printf("%c", s);
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a * b, c * d) << endl;
  return 0;
}


Measured memory_bytes: 256
function main(input) {
    let args = input.split("\n"),
    num = args[0].split(" ").map(Number)
    n = num[0], m = num[1], l = num[2]
    args.shift()
    
    const a = new Array(n)
    for(let y = 0; y < n; y++) {
        a[y] = args[0].split(" ").map(Number)
        args.shift()
    }
    
    const b = new Array(m)
    for(let y = 0; y < m; y++) {
        b[y] = args[0].split(" ").map(Number)
        args.shift()
    }
    
    const c = new Array(n);
    for(let y = 0; y < n; y++) {
        c[y] = new Array(l).fill(0);
    }
    
    for (let i = 0; i < n; i++) {
        for (let j = 0; j < m; j++) {
            for (let k = 0; k < l; k++) {
                c[i][k] += a[i][j] * b[j][k]
            }
        }
    }
    
    for (let i = 0; i < n; i++) {
        for (let j = 0; j < l; j++) {
            process.stdout.write(String(c[i][j]))
            if (j + 1 != l) process.stdout.write(" ")
        }
        console.log()
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 24984
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    int ans = 0;
    for(int i=1; i<=n; i++){
        int num = i;
        int cnt = 0;
        while(num > 0){
            cnt++;
            num /= 10;
        }
        
        if(cnt % 2) ans++;
    }

    cout << ans << endl;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
int main(){
  int n;cin>>n;
  double dp[n+1][n+1]={};
  dp[0][0]=1;
  for(int i=0;i<n;i++){
    double ho;cin>>ho;
    for(int j=0;j<n;j++){
      dp[i+1][j+1]+=ho*dp[i][j];
      dp[i+1][j]+=(1-ho)*dp[i][j];
    }
  }
  double ans=0;
  for(int i=n/2+n%2;i<=n;i++)ans+=dp[n][i];
  printf("%.10f\n",ans);
  return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    if (a + b <= k)
    {
        cout << "0 0" << endl;
    }
    else if (a <= k)
    {
        cout << 0 << " " << b - (k - a) << endl;
    }
    else
    {
        cout << a - k << " " << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main()
{
  int X, Y, Z, K; // X種Y種Z種から一つずつ買う，K:選び方
  cin >> X >> Y >> Z >> K;

  vector<long> A, B, C; // 価格
  long a, b, c;
  for( int i = 0; i < X; i++ ){ cin >> a; A.push_back(a); }
  for( int j = 0; j < Y; j++ ){ cin >> b; B.push_back(b); }
  for( int k = 0; k < Z; k++ ){ cin >> c; C.push_back(c); }
  
  // 降順ソート
  sort(A.begin(), A.end(), greater<long>());
  sort(B.begin(), B.end(), greater<long>());
  sort(C.begin(), C.end(), greater<long>());
  
  tuple<long, int, int, int> d; // (delicious_score, i, j, k)
  priority_queue< tuple<long, int, int, int> > q; // scoreの最大値管理用コンテナ
  set< tuple<long, int, int, int> > s; // 重複したものをq.pushしないための検索用コンテナ
  int i = 0;
  int j = 0;
  int k = 0;
  
  // 一番美味しいケーキの組み合わせ
  d = make_tuple(A[i]+B[j]+C[k], i, j, k);
  if( !s.count(d) ){ q.push( d ); s.insert( d ); }
  cout << get<0>(q.top()) << endl;
  i = get<1>(q.top());
  j = get<2>(q.top());
  k = get<3>(q.top());
  q.pop();
  K--;
 
  while(K > 0){
    // 次に一番美味しいケーキの組み合わせ
    if( i+1 < X ){ 
    	d = make_tuple(A[i+1]+B[j]+C[k], i+1, j, k);
    	if( !s.count(d) ){ q.push( d ); s.insert( d ); }
    }
    if( j+1 < Y ){ 
    	d = make_tuple(A[i]+B[j+1]+C[k], i, j+1, k);
    	if( !s.count(d) ){ q.push( d ); s.insert( d ); }
    }
    if( k+1 < Z ){ 
    	d = make_tuple(A[i]+B[j]+C[k+1], i, j, k+1);
    	if( !s.count(d) ){ q.push( d ); s.insert( d ); }
    }
    cout << get<0>(q.top()) << endl;
  	i = get<1>(q.top());
  	j = get<2>(q.top());
  	k = get<3>(q.top());
    q.pop();
    K--;
  }
  
  return 0;
}

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

int n;
int x;
int last;
int a[110]; 
queue<int> num;
priority_queue<int> q;
int ans;

int main()
{
    ios::sync_with_stdio(false);
    
    cin>>n;
    for (int i=1;i<=n;i++)
    {
    	cin>>x;
    	if (x%10==0) num.push(x);else q.push(x);
	}
	if (q.empty()) return 0*puts("0");
	
	while (!q.empty())
	{
		ans+=q.top();
		last=q.top();
		q.pop();
	}
	if (ans%10==0) ans-=last;
	
	while (!num.empty()) 
	{
		ans+=num.front();
		num.pop();
	}
	
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

bool hasthree(int n) {
	while (n > 0) {
		if (n % 10 == 3) {
			return true;
		}

		n /= 10;
	}

	return 0;
}

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

	for (int i = 1; i <=n; i++) {
		if (i % 3 == 0) {
			cout << " " << i;
		}
		else if(hasthree(i)){
			cout << " " << i;
		}

		
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
/*bool cmp(vector<int>:: iterator it1,vector<int>:: iterator it2)
{
    if(*it1>*it2)
    return true;
    else
    return false;
}*/
bool cmp(int a, int b)
{
    if(abs(a)>abs(b))
    return true;
    else
    return false;
}
/*ll int gcd(ll int a,ll int b)
{
    if(a==0)
    return b;
    else return gcd(b%a,a);
}*/
/*bool cmp(pair<int,int> p1,pair<int,int> p2)
{
    if(p1.first<=p2.first)
    return true;
    else
    return false;
}*/
/*
ll int dcount(ll int n)
{
    if(mp[n])
    return mp[n];
    ll int ct=1;
    for(ll int i=2;i<=n;i++)
    {
        if(n%i==0)
        ct++;
    }
    mp[n]=ct;
    return ct;
}*/
/*bool equ(string s)
{   if(s.length()==1)
return true;
    for(int i=0;i<s.length()-1;i++)
    {
        if(s[i]!=s[i+1])
        return false;
    }
    return true;
}*/
int main() {
    
    // For getting input from input.txt file 
   //freopen("input.txt", "r", stdin); 
    // Printing the Output to output.txt file 
  // freopen("output.txt", "w", stdout); 
    int n,a,b,ct=0,f=0,ctm=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        if(a==b){
        if(f==i-1||f==0){
        ct++;
        f=i;}
          ctm=max(ct,ctm);
    }
    else{
    f=0;
    ct=0;    }
    }
    if(ctm>=3)
    cout<<"Yes";
    else
    cout<<"No";
return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N; cin >> N;
	int H[N];
	for(int i = 0; i < N; i++) cin >> H[i];
	int res = 0, tmp = 0;
	int pre = H[0];
	for (int i = 1; i < N; i++)
	{
		if(pre >= H[i]) {
			tmp++;
		}
		else {
			res = max(res, tmp);
			tmp = 0;
		}
		pre = H[i];
	}
	cout << max(res, tmp) << endl;
	return 0;
}


Measured memory_bytes: 640
li='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
N=int(input())
S=str(input())
ans=''
for i in range(len(S)):
  for j in range(len(li)):
    if S[i]==li[j]:
      if j+N<len(li):
        num=j+N
        ans+=li[num]
      elif j+N>=len(li):
        num=j+N-len(li)
        ans+=li[num]
print(ans)

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

int main() {
	int N,A,B,c1=0,c2=0;
	string S;
	cin >> N >> A >> B >> S;

	rep(i,N) {
		bool ok=0;
		if(S.at(i) == 'a') {
			if(c1 < A+B)
				++c1, ok=1;
		} else if(S.at(i) == 'b') {
			if(c1<A+B && c2<B)
				++c1, ++c2, ok=1;
		}
		
		cout << ((ok) ? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    int[] cnt = new int[n];
    for (int m : a) {
      cnt[m - 1]++;
    }

    long sum = 0;
    for (int i = 0; i < n; i++) {
      if (cnt[i] < 2) {
        continue;
      }

      long tmp = cnt[i];
      sum += tmp * (tmp - 1) / 2;
    }

    for (int i = 0; i < n; i++) {
      int tmp = a[i] - 1;
      if (cnt[tmp] < 2) {
        System.out.println(sum);
      } else {
        System.out.println(sum - (cnt[tmp] - 1));
      }
    }
  }
}


Measured memory_bytes: 106604
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <map>

using namespace std;

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

	string S;
	cin >> S;

	map<char, int> chtoidx;
	string S2;

	for (int i = 0; i < S.size(); i++)
	{
		char e = S[i];
		if (e != 'A')
		{
			S2.push_back(e);
			chtoidx[e] = i;
		}
	}

	if (S2 == "KIHBR")
	{
		if (chtoidx['K'] > 1 ||
			chtoidx['I'] - chtoidx['K'] > 1 ||
			chtoidx['H'] - chtoidx['I'] > 1 ||
			chtoidx['B'] - chtoidx['H'] > 2 ||
			chtoidx['R'] - chtoidx['B'] > 2 ||
			S.size() - chtoidx['R'] > 2)
		{
			cout << "NO";
		}
		else
		{
			cout << "YES";
		}
	}
	else
	{
		cout << "NO";
	}

	return 0;
}


Measured memory_bytes: 256
"use strict";
const main = input => {
    const s = input[0];
    let red = 0, blue = 0;
    for(let i=0; i<s.length; i++) {
        if (s[i] == 0) {
            red++;
        } else {
            blue++;
        }
    }
    console.log(Math.min(red, blue)*2);
    
}   
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 7500
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;

int main()
{
	int n, m, t;
	bool gm[51][31], prs[51][51], f;
	
	while(cin>>n && n){
		f = true;
		fill(&gm[0][0], &gm[50][30], false);
		fill(&prs[0][0], &prs[50][50], false);
		for(int i = 0; i < n; i++){
			cin >> m;
			for(int j = 0; j < m; j++){
				cin >> t;
				gm[i][t] = true;
			}
			prs[i][i] = true;
		}
		
		for(int i = 1; i <= 30; i++){
			vector<int> vec;
			
			for(int j = 0; j < n; j++){
				if(gm[j][i]){
					vec.push_back(j);
				}
			}
			set<int> st;
			for(int j = 0; j < vec.size(); j++){
				for(int k = 0; k < n; k++){
					if(prs[vec[j]][k]){
						st.insert(k);
					}
				}
			}
			if(st.size() == n){
				cout << i << endl;
				f = false;
				break;
			}
			
			for(int j = 0; j < vec.size(); j++){
				set<int>::iterator it = st.begin();
				while(it != st.end()){
					prs[vec[j]][*it] = true;
					it++;
				}
			}
		}
		
		if(f){
			cout << -1 << endl;
		}
	}
	
	return 0;
}

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

int main() {
	int a, b, k; cin >> a >> b >> k;

	for (int i = a; i <= b; i++) {
		if ((a <= i && i <= a + (k - 1)) || (b - (k - 1) <= i && i <= b))
			cout << i << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535
typedef tree<ll, null_type, less<ll>, rb_tree_tag,                    //if  using ll change ll to ll
        tree_order_statistics_node_update> pbset;
#define fob(x) find_by_order(x)
ll po(ll x)
{
	ll ans = 1;
	for (int i = 1; i <= x; i++)
	{
		ans *= 2;
		ans %= mod;
	}
	ans--; ans += mod; ans %= mod;
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll n;
	cin >> n; ll z = 0;
	ll a[n + 1]; ll b[n + 1];
	map<pair<ll, ll>, ll> mp; mp[mk(z, z)] = 0;
	for (ll i = 1; i <= n; i++)
	{
		cin >> a[i] >> b[i];
	}
	for (ll i = 1; i <= n; i++)
	{
		if (a[i] == z && b[i] == z)
		{

			mp[mk(z, z)]++;
			continue;
		}
		else if (a[i] == z)
		{
			auto it = mp.find(mk(0, 1));
			if (it == mp.end())
				mp[mk(0, 1)] = 1;
			else
				mp[mk(0, 1)]++;
			continue;
		}
		else if (b[i] == z)
		{
			auto it = mp.find(mk(1, 0));
			if (it == mp.end())
				mp[mk(1, 0)] = 1;
			else
				mp[mk(1, 0)]++;
			continue;
		}
		ll c = __gcd(abs(a[i]), abs(b[i]));
		a[i] /= c;
		b[i] /= c;
		int y1 = 1; int y2 = 1;
		if (a[i] < abs(a[i]))
			y1 = -1;
		if (b[i] < abs(b[i]))
			y2 = -1;
		if (y1 * y2 > 0)
		{
			a[i] = abs(a[i]);
			b[i] = abs(b[i]);
			auto it = mp.find(mk(a[i], b[i]));
			if (it == mp.end())
				mp[mk(a[i], b[i])] = 1;
			else
				mp[mk(a[i], b[i])]++;
		}
		else
		{
			a[i] = abs(a[i]); a[i] *= -1;
			b[i] = abs(b[i]);
			auto it = mp.find(mk(a[i], b[i]));
			if (it == mp.end())
				mp[mk(a[i], b[i])] = 1;
			else
				mp[mk(a[i], b[i])]++;
		}
	}
	ll ans = 1;
	auto it = mp.begin();
	for (; it != mp.end(); it++)
	{
		//cout << ans << "d ";
		ll cc = it->ss;
		ll aa = it->ff.ff;
		ll bb = it->ff.ss;
		if (aa == 0 && bb == 0)
			continue; //cout << cc << endl;
		if (cc == z)
			continue;
		else
		{
			it->ss = 0;

			//cout << aa << " " << bb << " " << cc << endl;
			aa = abs(aa);
			bb = abs(bb);
			swap(aa, bb);
			if (it->ff.ff > z)
				aa *= -1;
			auto itr = mp.find(mk(aa, bb));
			if (itr == mp.end())
			{
				ll ans1 = po(cc); ans1++;
				//cout << ans1 << endl;
				ans1 %= mod;
				ans *= ans1;
				ans %= mod;
			}
			else
			{

				ll g = itr->ss; itr->ss = 0;
				ll ans1 = po(cc) + po(g);
				ans1++;
				ans1 %= mod;
				ans *= ans1;
				ans %= mod;
			}

		}

	}
	//cout << ans << endl << mp[mk(z, z)] << endl;
	ans += mp[mk(z, z)];
	ans--;
	ans += mod;
	ans %= mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 19116
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0], K = I[1];
		var h = new List<int>();
		for (var i = 0; i < N; i++) h.Add(F);
		h.Sort();
		var min = int.MaxValue;
		for (var i = 0; i + K - 1 < N; i++) min = Min(min, h[i + K - 1] - h[i]);
		WriteLine(min);
	}
}


Measured memory_bytes: 18272