akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;

const ll NINF = -1e17;

int main()
{
    int n;
    cin >> n;
    ll a[300002];
    for(int i = 0; i < n * 3; i++){
        cin >> a[i];
    }
    priority_queue<ll, vector<ll>, greater<ll>> ql;
    ll left[100002];
    for(int i = 0; i < n; i++){
        left[0] += a[i];
        ql.push(a[i]);
    }
    for(int i = 1; i <= n; i++){
        left[i] = left[i - 1] + a[n + i - 1];
        ql.push(a[n + i - 1]);
        ll les = ql.top();
        left[i] -= les;
        ql.pop();
    }
    priority_queue<ll> qr;
    ll right[100002];
    for(int i = n * 3 - 1; i >= n * 2; i--){
        right[n] += a[i];
        qr.push(a[i]);
    }
    for(int i = n - 1; i >= 0; i--){
        right[i] = right[i + 1] + a[i + n];
        qr.push(a[i + n]);
        ll bi = qr.top();
        right[i] -= bi;
        qr.pop();
    }
    ll ans = NINF;
    for(int i = 0; i <= n; i++){
        ans = max(ans, left[i] - right[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6516
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N;
    scan(N);
    auto a = readln.split.to!(long[]);

    auto dp = new long[][](N + 1, N + 1);
    fillAll(dp, infl);
    
    long rec(int l, int r) {
        if (l == r) {
            return 0;
        }
        if (dp[l][r] != infl) {
            return dp[l][r];
        }
        dp[l][r] = max(a[l] - rec(l + 1, r), a[r - 1] - rec(l, r - 1));
        return dp[l][r];
    }

    auto ans = rec(0, N);
    writeln(ans);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

int main(){
    int N, Y;
    cin >> N >> Y;
    Y /= 1000;
    int a, b, c;
    a = b = c = -1;
    [&]{
        for(int i = 0; i != N + 1; ++i){
            for(int j = 0, e = N - i + 1; j != e; ++j){
                for(int k = 0, f = N - i - j + 1; k != f; ++k){
                    if(i * 10 + j * 5 + k == Y && i + j + k == N){
                        a = i;
                        b = j;
                        c = k;
                        return;
                    }
                }
            }
        }
    }();
    cout << a << " " << b << " " << c << endl;
}

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

d = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for _ in range(N):
    s = input()
    d[s] += 1

print("AC x {}".format(d['AC']))
print("WA x {}".format(d['WA']))
print("TLE x {}".format(d['TLE']))
print("RE x {}".format(d['RE']))


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

using namespace std;
const int N = 1e5 + 1;
int n,m;
int a[N];
vector <int> adj[N];
int main(){
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= m; i++){
        int u , v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++){
        bool check = true;
        for (auto j : adj[i])
            if (a[j] >= a[i]) check = false;
        if (check == true) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  vector<pair<int,int>> a;

  for (int i = 0; i < n; ++i)
  {
    int tmp;
    cin>>tmp;
    a.push_back(make_pair(tmp,i+1));
  }
  sort(a.begin(), a.end());
  for(auto&& e: a) {
    cout<<e.second<<" ";
  }

}

Measured memory_bytes: 1780
#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;

int main(void) {
	int n;
	int h[100010];
	cin >> n;
	for (int i = 0; i <n; i++) {
		cin >> h[i];
	}
	for (int i = n - 2; i >= 0; i--) {
		if (h[i] > h[i + 1]) {
			h[i] --;
			if (h[i] > h[i + 1]) {
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 640
#define DEBUG 0
/**
 * File    : E.cpp
 * Author  : Kazune Takahashi
 * Created : 6/11/2019, 7:23:52 PM
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
typedef long long ll;
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}
const int MAX_SIZE = 1000010;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return mint(0) - *this; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a) { return (*this *= power(MOD - 2)); }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
mint inv[MAX_SIZE];
mint fact[MAX_SIZE];
mint factinv[MAX_SIZE];
void init()
{
  inv[1] = 1;
  for (int i = 2; i < MAX_SIZE; i++)
  {
    inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
  }
  fact[0] = factinv[0] = 1;
  for (int i = 1; i < MAX_SIZE; i++)
  {
    fact[i] = mint(i) * fact[i - 1];
    factinv[i] = inv[i] * factinv[i - 1];
  }
}
mint choose(int n, int k)
{
  if (n >= 0 && k >= 0 && n - k >= 0)
  {
    return fact[n] * factinv[k] * factinv[n - k];
  }
  return 0;
}
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// const double epsilon = 1e-10;
// const ll infty = 1000000000000000LL;
// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

string L;
int N;
mint dp[2][100010];

int main()
{
  // init();
  cin >> L;
  N = L.size();
  dp[0][0] = 1;
  for (auto i = 0; i < N; i++)
  {
    dp[1][i + 1] += (mint)3 * dp[1][i];
    if (L[i] == '0')
    {
      dp[0][i + 1] += dp[0][i];
    }
    else
    {
      dp[0][i + 1] += (mint)2 * dp[0][i];
      dp[1][i + 1] += dp[0][i];
    }
  }
  cout << dp[0][N] + dp[1][N] << endl;
}

Measured memory_bytes: 25472
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

int n,m;
int len[52];
int cur=0,flag=0;
int two[52];
int par[52];
int lvl[52];
vector<int>adj[55];
int id[52][52];
void dfs(int u,int p,int l)
{
   lvl[u]=l;
   par[u]=p;
   for(auto v:adj[u])
   {
       if(v==p)continue;
       dfs(v,u,l+1);
   }
}
void work(int u,int v)
{
    if(lvl[u]<lvl[v])swap(u,v);
    while(lvl[u]>lvl[v])
    {
        int x=id[u][par[u]];
        cur=cur|(1LL<<x);
        u=par[u];
    }
    while(u!=v)
    {
        int x=id[u][par[u]];
        int y=id[v][par[v]];
        u=par[u];
        v=par[v];
        cur=cur|(1LL<<x);
        cur=cur|(1LL<<y);
    }

}
 main()

{
    fast
    cin>>n;
    f(i,1,n-1)
    {
        int u,v;
        cin>>u>>v;
        u--;v--;
        id[u][v]=i-1;
        id[v][u]=i-1;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    dfs(0,0,0);
    cin>>m;
    f(i,0,m-1)
    {
        int u,v;
        cin>>u>>v;
        u--;v--;
        cur=0;flag=0;
        work(u,v);
        len[i]=cur;
    }
    int lim=(1LL<<m);
    int ses=0;
    f(msk,0,lim-1)
    {
        int one=__builtin_popcountll(msk);
        int yo=0;
        f(j,0,m-1)
        {
            if(msk & (1LL<<j))
            {
                yo=yo|len[j];
            }
        }
        int cnt=__builtin_popcountll(yo);
        int baki=(n-1)-cnt;
        int val=(1LL<<baki);
        if(one%2==0)ses=ses+val;
        else ses=ses-val;
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 3684
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
// #include <boost/foreach.hpp>
// #include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};
struct edge{int to,cost;};
//typedef pair<int,int> P;

const long long MOD=1000000007LL;
bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)||islower(c));}
template<typename T> 
void print(vector<T> v){
    for(int i=0;i<v.size();i++){
        if(i)cout<<" ";
        cout<<v[i];
    }
    cout<<endl;
}

template<typename T>
void printendl(vector<T> v){
    for(auto date:v)cout<<date<<endl;
}

template<typename T>
void printvv(vector<vector<T>> v){
    for(int i=0;i<v.size();i++){
        for(int j=0;j<v[i].size();j++){
            if(j)cout<<" ";
            cout<<v[i][j];
        }
        cout<<endl;
    }
}
int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    else return gcd(b,a%b);
}

struct S{
    int y,x;
    char c;
};

signed main (){
    int n,k;
    cin>>n>>k;
    cout<<n-k+1<<endl;
}
/*

*/


Measured memory_bytes: 256
#include<cstdio>
#include<map>
#define N 200010
std::map<long long,long long > s;
long long a[N];
int n;

int main(){
	scanf("%d",&n);
	s[0] = 1;
	long long cnt = 0;
	scanf("%lld",&a[0]);
	cnt += s[a[0]];
	s[a[0]]++;
	for(int i=1;i<n;i++){
		scanf("%lld",&a[i]);
		a[i] = a[i] + a[i-1];
		cnt += s[a[i]];
		s[a[i]]++;
	}
	
	printf("%lld\n",cnt);

	return 0;
}


Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
int n, ans;
const ll mod =1000000007;
string a, b, c;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i++)
	{
		int same = 0;
		if (a[i] == b[i]) same++;
		if (b[i] == c[i]) same++;
		if (c[i] == a[i]) same++;
		if (same == 0) ans += 2;
		if (same == 1) ans += 1;
	}
	cout << ans << endl;
	int www;
	cin >> www;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); //number 
#define ll long long                      //of element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after 
using namespace std;                      // sort use as s.f();
using namespace __gnu_pbds;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.flush();
	ll t=1;
//	cin>>t;
	while(t--)
	{
		ll x,y,a,b,c;
		ll p[100001];
		ll q[100001];
		ll r[100001];
		cin>>x>>y>>a>>b>>c;
		for(ll i=0;i<a;i++)
		{
		cin>>p[i];	
		}
		
		for(ll j=0;j<b;j++)
		{
			cin>>q[j];
			}
		for(ll i=0;i<c;i++)
		{
		cin>>r[i];	
			}
		ll ans=0;
		sort(p,p+a,greater<ll>());
		sort(r,r+c,greater<ll>());
		sort(q,q+b,greater<ll>());	
		ll A[300003];
		ll z=0;
		for(ll i=0;i<x;i++)
		{
		A[z]=p[i];
			z++;
			}
			for(ll i=0;i<y;i++)
		{
		A[z]=q[i];
		z++;
			}
		// x+y+c;
		for(ll i=0;i<c;i++ )
		{
			A[z]=r[i];
			z++;
			}
		sort(A,A+z,greater<ll>());
		
		ans=0;
		for(ll i=0;i<x+y;i++)
		{
			ans+=A[i];
			}	
			
			
		cout<<ans<<endl;
	}
	
return 0;
}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 3e5+1;
int n, m, Bit[N];

void Update(int p, int val){
	for (; p <= m; p += p&-p) Bit[p] += val;
}

int Get(int p){
	int ans = 0;
	for (; p > 0; p -= p&-p) ans += Bit[p];
	return ans;
}

struct Data{
	int l, r, diff;
	Data(int l_, int r_, int diff_){
		l = l_;
		r = r_;
		diff = diff_;
	}
	Data(){}

};

Data a[N];

bool comp(Data A, Data B){
	return A.diff < B.diff;
}

int main()
{
	fastio;
	cin >> n >> m;
	for (int i = 1; i <= n; i++){
		cin >> a[i].l >> a[i].r;
		a[i].diff = a[i].r - a[i].l + 1;
	}

	sort(a + 1, a + 1 + n, comp);

	int cnt = 0; int cur = 1;
	for (int i = 1; i <= m; i++){
		while (cur <= n && a[cur].diff < i){
			Update(a[cur].l, 1); Update(a[cur].r + 1, -1);
			cnt++; cur++;
		}
		int ans = 0;
		for (int j = 0; j <= m; j += i){
			ans += Get(j);
		}		
		cout << ans + n - cnt << '\n';
	}
	return 0;
}

Measured memory_bytes: 4992
S = input()


count = 1
zone_list = []
R_phase = True
for i in range(1,len(S)):
    if R_phase:
        if S[i]=="R":
            count+=1
        else:
            zone_list.append(count)
            count=1
            R_phase=False
    else:
        if S[i]=="L":
            count+=1
        else:
            zone_list.append(count)
            count=1
            R_phase=True
        

zone_list.append(count)
count = 0
ans = [0]*len(S)
for i in range(len(zone_list)):
    if i%2==0:
        count+=zone_list[i]
        if zone_list[i]%2==0:
            ans[count-1]+=zone_list[i]//2
            ans[count]+=zone_list[i]//2
        else:
            ans[count-1]+=zone_list[i]//2 + 1
            ans[count]+=zone_list[i]//2
    else:
        if zone_list[i]%2==0:
            ans[count-1]+=zone_list[i]//2
            ans[count]+=zone_list[i]//2
        else:
            ans[count-1]+=zone_list[i]//2
            ans[count]+=zone_list[i]//2 + 1
        count+=zone_list[i]

print(*ans)

Measured memory_bytes: 49724
package main

import (
	"fmt"
)

type node struct {
	name int
	may_Cir bool
	sta_list []int   //the list of this node start to others node
	end_list []int   //the list of others node end with this node
}
func main(){
	var nodes_sum,edges_sum,sta_temp,end_temp int
	fmt.Scanf("%d %d",&nodes_sum,&edges_sum)
	nodes := make([]node,nodes_sum,1000)
	for i := 0; i < edges_sum; i++ {
		fmt.Scanf("%d %d",&sta_temp,&end_temp)
		nodes[sta_temp].name=sta_temp
		nodes[sta_temp].sta_list=append(nodes[sta_temp].sta_list,end_temp)
		nodes[end_temp].end_list=append(nodes[end_temp].end_list,sta_temp)
	}
	for i := 0; i < nodes_sum; i++ {
		if len(nodes[i].end_list)> 0 && len(nodes[i].sta_list) > 0{
			nodes[i].may_Cir=true
		}else {
			nodes[i].may_Cir=false
		}
	}
	for i := 0; i < nodes_sum; i++  {
		var passed_arr []int
		if findCir(nodes,passed_arr,i,i) ==1 {
			fmt.Println("1")
			return
		}else {
			nodes[i].may_Cir=false
		}
	}
	fmt.Println("0")
}
func findCir(nodes []node,passed_arr []int,aim int,n int) int {
	if nodes[n].may_Cir{
		if isExist(passed_arr,n) {
			return 1
		}
		passed_arr=append(passed_arr,n)
		for j := 0; j < len(nodes[n].end_list); j++ {
			if nodes[n].end_list[j] == aim {
				return 1
			}else {
				if aim < nodes[n].end_list[j] {
					if 1==findCir(nodes, passed_arr, aim, nodes[n].end_list[j]) {
						return 1
					}
				}
			}
		}
	}
	return 0
}
func isExist(arr []int,aim int)bool{
	for e := range arr {
		if arr[e] == aim {
			return true
		}
	}
	return false
}


Measured memory_bytes: 1236
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;

int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(0);
	  



	int x, y; cin >> x >> y;
	
	if ((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12))
		cout << "Yes" << endl;
	else if ((x == 4 || x == 6 || x == 9|| x == 11) && (y == 4 || y == 6 || y == 9 || y == 11))
		cout << "Yes" << endl;
	else if (x == 2 && y == 2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;


		return 0;
	
}


Measured memory_bytes: 3580
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main(void){
	int A,B,ans;
  	cin>>A>>B;
  	if(A==B){ans=A+B;}
  	if(A<B){ans=(B-1)+B;}
  	if(A>B){ans=(A-1)+A;}
  cout<<ans<<endl;
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    for (int i = 0; i < N; i++) C[i] = A[i]-B[i];
    sort(C.begin(), C.end());
    ll dist = 0;
    if (C[0] >= 0) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        if (C[i] < 0) {
            dist += C[i];
            ans++;
        }else break;
    }
    reverse(C.begin(), C.end());
    for (int i = 0; i < N; i++) {
        dist += C[i];
        ans++;
        if (dist >= 0) {
            cout << ans << endl;
            return 0;
        }
        if (C[i] <= 0) break;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=1e5+5;
int to[MN<<1],nxt[MN<<1],deg[MN],h[MN],cnt;
inline void ins(int s,int t){
	to[++cnt]=t;nxt[cnt]=h[s];h[s]=cnt;deg[t]++;
	to[++cnt]=s;nxt[cnt]=h[t];h[t]=cnt;deg[s]++;
}
bool t[MN],vis[MN];
char ch[MN];
int n,ans,sum,que[MN],f[MN];
void dfs(int st,int fa=0){
	sum+=deg[st];sum+=(deg[st]=(!t[st])^(deg[st]&1));
	for(reg int i=h[st];i;i=nxt[i])
		if(!vis[to[i]]&&to[i]!=fa){
			dfs(to[i],st);ans=min(ans,f[st]+f[to[i]]);
			f[st]=min(f[st],f[to[i]]-2*deg[st]);
		}
}
int main(){
	scanf("%d",&n);reg int he=0,ta=0;
	for(reg int i=1,s,t;i<n;i++)scanf("%d%d",&s,&t),ins(s,t);
	scanf("%s",ch+1);
	for(reg int i=1;i<=n;i++)t[i]=(ch[i]=='B');
	for(reg int i=1;i<=n;i++)if(deg[i]<2&&t[i])que[ta++]=i;
	while(he<ta){
		reg int v=que[he++];vis[v]=true;
		for(reg int i=h[v];i;i=nxt[i])if((--deg[to[i]])==1&&t[to[i]])que[ta++]=to[i];
	}
	if(ta==n)return 0*puts("0");
	for(reg int i=1;i<=n;i++)
		if(!vis[i]){
			dfs(i);return 0*printf("%d\n",sum+ans);
		}
	return 0;
}

Measured memory_bytes: 7296
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

////////////////////////////////////////////////////////////////////////

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val M = sc.next().toInt()
        val H = Array(N) { sc.next().toInt() }
        val w = IntArray(N)
        repeat(M) {
            val A = sc.next().toInt() - 1
            val B = sc.next().toInt() - 1
            if (H[B] > w[A]) {
                w[A] = H[B]
            }
            if (H[A] > w[B]) {
                w[B] = H[A]
            }
        }
        var ans =0
        for (i in 0 until N) {
            if (H[i] > w[i]) ans++
        }
        pw.println(ans)

    }
}


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

class Dice{
    public:
        std::array<int, 6> num;
        
        void rollN(){
            int t = num[0];
            num[0] = num[1];
            num[1] = num[5];
            num[5] = num[4];
            num[4] = t;
        }
        void rollE(){
            int t = num[0];
            num[0] = num[3];
            num[3] = num[5];
            num[5] = num[2];
            num[2] = t;
        }
        void rollS(){
            int t = num[0];
            num[0] = num[4];
            num[4] = num[5];
            num[5] = num[1];
            num[1] = t;
        }
        void rollW(){
            int t = num[0];
            num[0] = num[2];
            num[2] = num[5];
            num[5] = num[3];
            num[3] = t;
        }
};

int main(){
    
    Dice dice;
    int n = 6;
    for(int i=0; i<6; i++) std::cin >> dice.num[i];
    
    char dir;
    while(std::cin >> dir){
        switch(dir){
            case 'N': dice.rollN(); break;
            case 'E': dice.rollE(); break;
            case 'S': dice.rollS(); break;
            case 'W': dice.rollW(); break;
        }
    }
    
    std::cout << dice.num[0] << std::endl;
    
    return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int w , a , b;
    cin >> w >> a >> b ;
    int ar , al , br , bl ;
     al = a ;
    ar = w + a ; 
   
    bl = b ;
    br = b + w ;

    if(bl <= ar && al <= br ) cout << 0 << endl;
    else if(ar < bl) cout << bl - ar << endl;
    else cout << al - br << endl;
    return 0;
}

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


int main()
{
	while (true)
	{
		int count;
		double n[1000] = {};
		double avg = 0;
		double sum = 0;
		double bunsan;
	
		cin >> count;

		if (count == 0)
			return 0;

		for (int i = 0; i < count; i++)
		{
			cin >> n[i];
			avg += n[i];
		}
		avg /= (double)count;

		for (int i = 0; i < count; i++)
		{
			sum += pow(n[i] - avg, 2);
		}

		bunsan = (1.0 / (double)count) * sum;
		cout << (sqrt(bunsan) ? sqrt(bunsan) : 0) << endl;
	}
}


Measured memory_bytes: 3292
#include <cstdio>
#include <utility>
#include <deque>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
//template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	int n = in();
	deque<int> q;
	while (n--) {
		switch (in()) {
		case 0:
			if (in())
				q.push_back(in());
			else
				q.push_front(in());
			break;
		case 1:
			outl(q[in()]);
			break;
		default:
			if (in())
				q.pop_back();
			else
				q.pop_front();
		}
	}
}


Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
int h[101];
int main(){
    int n;
    cin >> n;
    int MAX=0;
    int ans=0;
    for(int i=0;i<n;i++){
        cin >> h[i];
        MAX=max(h[i],MAX);
    }
    int tmp;
    for(int i=1;i<=MAX;i++){
        if(h[0]>=i)tmp=1;
        else tmp=0;
        for(int j=1;j<n;j++){
            if(h[j-1]<i&&h[j]>=i)tmp++;
        }
        ans+=tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, a, b;
  cin >> w >> a >> b;
  if (min(a, b) + w >= max(a, b)) cout << 0 << endl;
  else cout << max(a, b) - min(a, b) - w << endl;
}

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

long long pot5(int n) {
    return 1ll * n * n * n * n * n;
}

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

    int x;
    cin >> x;
    
    int a, b;
    bool stop = false;
    for (a = 1; a <= 120; a++) {
        for (b = -119; b <= 119; b++) {
            if (pot5(a) - pot5(b) == x) {
                stop = true;
                break;
            }
        }
        if (stop) break;
    }
    cout << a << " " << b << endl;
    

	return 0;
}

Measured memory_bytes: 3656
n,t = gets.chomp.split(' ').map{|z| z.to_i}
i = gets.split(" ").map!{|x| x.to_i}
a = 0
s = 0
i.each do |h|
  if h <= s
    a += h + t - s
  else
    a += t
  end
  s = h + t
end

puts a

Measured memory_bytes: 14340
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		int a, b, c;
		cin >> a >> b >> c;
		cout << c << " " << a << " " << b << "\n";
	}
	return 0;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

class Program
{
    private static int? Solve(int N, string[] a)
    {
        if (a.All(row => row.All(c => c == '.'))) { return null; }
        int[] counts = new int[N];
        for (int i = 0; i < N; ++i)
        {
            int count = a[i].Count(c => c == '.');
            counts[i] = a.Any(row => row[i] == '#') ? count : count + 1;
        }
        return counts.Min() + Enumerable.Range(0, N).Count(i => a.Any(row => row[i] == '.'));
    }
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string[] a = new string[N];
        for (int i = 0; i < N; ++i) { a[i] = Console.ReadLine(); }
        int? ans = Solve(N, a);
        Console.WriteLine(ans ?? -1);
    }
}


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


int main (){
    int n,t;cin>>n>>t; int a[n]; int b[n]; int time=0; int min=9999; int ans = 0;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<n;i++){
        if(b[i] <= t) time++;
        else a[i] = 9999;
    }
    if(time==0){
        cout<<"TLE";
        return 0;
    }
    for(int i=0;i<n;i++){
       if(a[i]<min){
           min = a[i];
           ans = a[i];
       } 
    }
    cout<<ans;
}


Measured memory_bytes: 256
from fractions import gcd


def lcm(x, y):
    return (x * y) // gcd(x, y)


if __name__ == "__main__":
    a, b, c, d = map(int, input().split())

    ans = b - a + 1
    ans -= (b // c - (a-1) // c)
    ans -= (b // d - (a-1) // d)
    ans += (b // lcm(c, d) - (a-1) // lcm(c, d))
    print(ans)


Measured memory_bytes: 5048
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[6][6];
int c[6];
int n;
int t[6][6];
int v[6][6];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int f[6][6];
int calc(){
	int ret=0;
	int s=1;
	for(int i=0;i<5;i++)for(int j=0;j<5;j++)v[i][j]=t[i][j];
	bool chg=false;
	do{
		chg=false;
		for(int i=0;i<5;i++)for(int j=0;j<5;j++)f[i][j]=0;
		for(int i=0;i<5;i++){
			int now=0;
			int val=-1;
			for(int j=0;j<5;j++){
				if(val!=v[i][j]){
					if(now>=3&&val){
						chg=true;
						for(int k=j-now;k<j;k++)f[i][k]=1;
					}
					now=1;val=v[i][j];
				}else now++;
			}
			if(now>=3&&val){
				chg=true;
				for(int k=5-now;k<5;k++)f[i][k]=1;
			}
		}
		for(int i=0;i<5;i++){
			int now=0;
			int val=-1;
			for(int j=0;j<5;j++){
				if(val!=v[j][i]){
					if(now>=3&&val){
						chg=true;
						for(int k=j-now;k<j;k++)f[k][i]=1;
					}
					now=1;val=v[j][i];
				}else now++;
			}
			if(now>=3&&val){
				chg=true;
				for(int k=5-now;k<5;k++)f[k][i]=1;
			}
		}
		for(int i=0;i<5;i++)for(int j=0;j<5;j++){
			if(f[i][j]){ret+=s*c[v[i][j]];v[i][j]=0;}
		}
		for(int i=0;i<5;i++){
			int at=4;
			for(int j=4;j>=0;j--){
				if(v[j][i])v[at--][i]=v[j][i];
			}
			for(int j=0;j<=at;j++)v[j][i]=0;
		}
		s++;
	}while(chg);
	return ret;
}
int solve(int a,int b,int c){
	if(c==n){
		return calc();
	}
	int ret=calc();
	for(int i=0;i<4;i++){
		if(0<=a+dx[i]&&a+dx[i]<5&&0<=b+dy[i]&&b+dy[i]<5){
			swap(t[a][b],t[a+dx[i]][b+dy[i]]);
			ret=max(ret,solve(a+dx[i],b+dy[i],c+1));
			swap(t[a][b],t[a+dx[i]][b+dy[i]]);
		}
	}
	return ret;
}
int main(){
	int a;
	while(scanf("%d",&a),~a){
		n=a;
		for(int i=0;i<5;i++)for(int j=0;j<5;j++)scanf("%d",&b[i][j]);
		for(int i=0;i<5;i++)scanf("%d",c+i+1);
		int ret=0;
		for(int i=0;i<5;i++){
			for(int j=0;j<5;j++){
				for(int k=0;k<5;k++)for(int l=0;l<5;l++){
					t[k][l]=b[k][l];
				}
				ret=max(ret,solve(i,j,0));
			}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1032
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        Map<Long, Integer> map = new HashMap<>();
        long sum = 0;
        map.put(sum, 1);
        for (int i = 0; i < N; i++) {
            sum += sc.nextInt();
            map.put(sum, map.getOrDefault(sum, 0)+1);
        }

        long ans = 0;
        for (int count : map.values()) {
            if (count >= 2) {
                ans += (long)count*(count-1)/2;
            }
        }

        System.out.println(ans);
    }
}



Measured memory_bytes: 99496
import sys
def input(): return sys.stdin.readline().strip()

def main():
    N = int(input())
    t, a = map(int, input().split())
    for _ in range(N - 1):
        nt, na = map(int, input().split())
        if t * na == a * nt: continue
        # ceilで不動小数点誤差が出てWAになるケースは初めて！
        # C++と同じ流儀で繰り上げしないとダメなんだ。。。
        k = max((t + nt - 1) // nt, (a + na - 1) // na)
        t, a = nt * k, na * k

    print(t + a)




if __name__ == "__main__":
    main()


Measured memory_bytes: 64220
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

using Graph = vector<vecint>;

int main()
{
  int n,m;
  cin>>n>>m;
  Graph g(n);
  REP(i,m) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int> dis(n, n);
  queue<int> q;
  q.push(0);
  dis[0] = 0;
  vector<int> parent(n, -1);
  while(!q.empty()) {
    int i = q.front();
    q.pop();
    for (int d : g[i]) {
      if (dis[d] <= dis[i]) continue;
      q.push(d);
      dis[d] = dis[i]+1;
      parent[d] = i;
    }
  }
  vector<tuple<int,int>> v;
  REP(i,n) {
    v.emplace_back(dis[i],i);
  }
  sort(ALL(v));
  set<int> s;
  vector<bool> flip(n, false);
  s.insert(0);
  int par = 0;
  FOR(i,1,n) {
    int d, idx;
    tie(d, idx) = v[i];
    s.insert(idx);
    int cnt = 0;
    for (int to : g[idx]) {
      if (s.count(to)) ++cnt;
    }
    if ((cnt % 2) == 1) {
      ++par;
      flip[idx] = true;
    }
  }
  if ((par % 2) == 1) {
    cout << "-1" << endl;
    return 0;
  }
  vector<tuple<int,int>> u(n);
  reverse_copy(ALL(v),begin(u));
  set<tuple<int,int>> fe;
  REP(i,n-1) {
    int d, idx;
    tie(d, idx) = u[i];
    if (flip[idx]) {
      int p = parent[idx];
      fe.emplace(p, idx);
      //cerr<<p<<' '<<idx<<endl;
      flip[p] = !flip[p];
    }
  }
  s.clear();
  REP(i,n) {
    int d, idx;
    tie(d, idx) = v[i];
    s.insert(idx);
    for (int to : g[idx]) {
      if (s.count(to) == 1) {
        if (fe.count(make_tuple(to, idx))) {
          cout << (to+1) << ' ' << (idx+1) << endl;
        } else {
          cout << (idx+1) << ' ' << (to+1) << endl;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 17016
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <map>
#define INF 10000000
using namespace std;
typedef pair<int,int> P;

int sumRow(int n);
int sumCol(int n);
int check();
void changeRow(int n);
void changeCol(int n);

int senbei[10][10000];
int r,c;
int rowFlag[10];
int Max;

void countSum(){
  int sum=0;
  for(int i=0;i<c;i++){
    int colSum = 0;
    for(int j=0;j<r;j++){
      if(senbei[j][i]==!rowFlag[j]){
        colSum++;
      }
    }
    sum += max(colSum,r-colSum);
  }
  if(Max<sum){
    Max = sum;
  }
}

void setFlag(int pos){
  if(pos==r){
    countSum();
    return;
  }
  rowFlag[pos] = 1;
  setFlag(pos+1);

  rowFlag[pos] = 0;
  setFlag(pos+1);
}

int main(){
  while(1){
    cin >> r >> c;
    if(r==0&&c==0) return 0;
    for(int i=0;i<r;i++){
      for(int j=0;j<c;j++){
        cin >> senbei[i][j];
      }
    }
    Max = 0;
    setFlag(0);
    cout << Max << endl;
  }
}

Measured memory_bytes: 1548
class BinaryIndexedTree:
  def __init__(self,n):
    self.bit=[0]*n
  def add(self,i,x):
    i+=1
    while i<=len(self.bit):
      self.bit[i-1]+=x
      i+=i&-i
  def sum_sub(self,i):
    a=0
    i+=1
    while i:
      a+=self.bit[i-1]
      i-=i&-i
    return a
  def sum(self,i,j):
    a=self.sum_sub(j+1)
    if i!=0:a-=self.sum_sub(i-1)
    return a
n,q=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):a[i]-=1
queries=[[]for _ in range(n)]
for i in range(q):
  l,r=map(int,input().split())
  l-=1
  r-=1
  queries[r].append((l,i))
lastAppeared=[0]*n
Bit=BinaryIndexedTree(n+1)
ans=[-1]*q
for i in range(n):
  Bit.add(lastAppeared[a[i]],-1)
  Bit.add(i+1,1)
  lastAppeared[a[i]]=i+1
  for l,ind in queries[i]:
    ans[ind]=Bit.sum(l+1,i)
print(*ans)


Measured memory_bytes: 207588
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void rJ(char *str, int length)
{
    char temp = *(str + length - 1);
    for (int i = length - 1; i > 0; i--)
    {
        *(str + i) = *(str + i - 1);

    }
    *str = temp;
}

void rC(char *str, int length)
{
    char temp = *str;
    for (int i = 1; i < length; i++)
    {
        *(str + i - 1) = *(str + i);
    }
    *(str + length - 1) = temp;
}

void rE(char *str, int length)
{
    char temp;
    int divide = (length + 1) / 2;
    for (int i = 0; i < length / 2; i++)
    {
        temp = *(str + i);
        *(str + i) = *(str + i + divide);
        *(str + i + divide) = temp;
    }
}

void rA(char *str, int length)
{
    char temp;
    for (int i = 0; i < length / 2; i++)
    {
        temp = *(str - i + length - 1);
        *(str - i + length - 1) = *(str + i);
        *(str + i) = temp;
    }
}

void rP(char *str, int length)
{
    for (int i = 0; i < length; i++)
    {
        if (*(str + i) < 0x3A && *(str + i) > 0x30)
        {
            *(str + i) -= 1;
        }
        else if (*(str + i) == 0x30)
        {
            *(str + i) = 0x39;
        }
    }
}

void rM(char *str, int length)
{
    for (int i = 0; i < length; i++)
    {
        if (*(str + i) < 0x39 && *(str + i) >= 0x30)
        {
            *(str + i) += 1;
        }
        else if (*(str + i) == 0x39)
        {
            *(str + i) = 0x30;
        }
    }
}

void recoveryStr(char *str, char *seqStr)
{
    int seqStrLen = strlen(seqStr);
    int strLen = strlen(str);
    for (int i = seqStrLen - 1; i >= 0; i--)
    {
        switch (*(seqStr + i))
        {
        case 'J':
        {
            rJ(str, strLen);
            break;
        }
        case 'C':
        {
            rC(str, strLen);
            break;
        }
        case 'E':
        {
            rE(str, strLen);
            break;
        }
        case 'A':
        {
            rA(str, strLen);
            break;
        }
        case 'P':
        {
            rP(str, strLen);
            break;
        }
        case 'M':
        {
            rM(str, strLen);
            break;
        }
        }
    }
}

int main()
{
    int counter = 0;
    char *seqStr = malloc(sizeof(char) * 10000);
    char *str = malloc(sizeof(char) * 10000);
    scanf("%d", &counter);
    for (int i = 0; i < counter; i++)
    {
        scanf("%s", seqStr);
        scanf("%s", str);
        recoveryStr(str, seqStr);
        printf("%s\n", str);
    }
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    ll a[200000],c=0;
    map<ll, ll> m;
    cin>>n;
    a[0]=0;
    m[0]=1;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        a[i]+=a[i-1];
        m[a[i]]++;
    }
    for(auto x=m.begin();x!=m.end();x++){
        ll y=x->second;
        c+=y*(y-1)/2;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 14336
#include <stdio.h>
#include <string.h>
#define N 100000
int height(int);
struct Node{
  int parent;
  int left;
  int right;
};
struct Node T[N];
int H[N];
int main(){
  
  int n,i,id,r,l;
  
  scanf("%d",&n);
  
  

  for(i=0;i<n;i++){
    T[i].right=T[i].left=T[i].parent=-1;
  }
  
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d%d",&l,&r);
    T[id].left=l;
    T[l].parent=id;
    T[id].right=r;
    T[r].parent=id;
    
  }
  printf("Preorder\n");
  for(i=0;i<n;i++){
    if(T[i].parent==-1)
      preorder(i);
  }
  printf("\n");
 printf("Inorder\n");
  for(i=0;i<n;i++){
    if(T[i].parent==-1)
      inorder(i);
  }
  printf("\n");
  printf("Postorder\n");
  for(i=0;i<n;i++){
    if(T[i].parent==-1)
      postorder(i);
  }
  printf("\n");
  
  
  return 0;
}


int preorder(int x){
  if(x!=-1){
    printf(" %d",x);
    preorder(T[x].left);
    preorder(T[x].right);
  }
}

int inorder(int x){
  if(x!=-1){
    inorder(T[x].left);
    printf(" %d",x);
    inorder(T[x].right);
  }
}

int postorder(int x){
  if(x!=-1){
    postorder(T[x].left);
    postorder(T[x].right);
    printf(" %d",x);
  }
}

Measured memory_bytes: 620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Main {
	static boolean bElapsed = false;
	List<String> list = new ArrayList<>();
	Set<String> set = new HashSet<>();
	Map<String,String> map = new HashMap<>();

	void solve(BufferedReader br) throws Exception {
		String line = br.readLine();
		int n = Integer.parseInt(line);
		long sum = n*(n+1)/2;
		pln(sum);
	}

	void p(char c) {
		System.out.print(c);
	}
	void pln(char c) {
		System.out.println(c);
	}
	void p(long l) {
		System.out.print(l);
	}
	void pln(long l) {
		System.out.println(l);
	}
	void p(String s) {
		System.out.print(s);
	}
	void pln(String s) {
		System.out.println(s);
	}
	public static void main(String[] args) throws Exception {
		long start = System.currentTimeMillis();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		new Main().solve(br);
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.out.println((end-start) + "ms");
		}
	}
}


Measured memory_bytes: 8148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		int H = Integer.parseInt(st.nextToken());
		int N = Integer.parseInt(st.nextToken());
		
		int[] A = new int[N];
		int sum = 0;
		st = new StringTokenizer(br.readLine());
		for(int i=0; i<N; i++) {
			A[i] = Integer.parseInt(st.nextToken());
			sum += A[i];
		}
		
		H -= sum;
		if(H <= 0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}	

}

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

typedef pair<int,int> P;

const int INF=1e9;
int h,w;
char maze[51][51];
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int d[50][50];

int main(){
  cin>>h>>w;
  for(int i=0;i<h;++i)cin>>maze[i];

  int ans=h*w;

  for(int i=0;i<h;++i)
    for(int j=0;j<w;++j)
        ans-=maze[i][j]=='#';

  for(int i=0;i<h;++i)
    for(int j=0;j<w;++j)
      d[i][j]=INF;

  queue<P> que;

  que.push(P(0,0));
  d[0][0]=1;

  while(que.size()){

    P p=que.front();
    que.pop();

    if(p.first==h-1&&p.second==w-1)
        break;

    for(int i=0;i<4;++i){

        int x=p.first+dx[i], y=p.second+dy[i];

        if(0<=x && x<h && 0<=y && y<w && maze[x][y]!='#' && d[x][y]==INF){
            que.push(P(x,y));
            d[x][y]=d[p.first][p.second]+1;
        }

    }

  }

  cout << (d[h-1][w-1]==INF? -1:ans-d[h-1][w-1]) << endl;

  return 0;
}


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

int N, A, B, C;
vector<int> l(8);

int dfs(int n, int a, int b, int c){
  if(n == N){
    if(a==0 || b==0 || c==0){
      return 999999;
    }
    return abs(A-a) + abs(B-b) + abs(C-c) - 30;
  }else{
    int nouse = dfs(n+1, a, b, c);
    int useForA = dfs(n+1, a+l.at(n), b, c) + 10;
    int useForB = dfs(n+1, a, b+l.at(n), c) + 10;
    int useForC = dfs(n+1, a, b, c+l.at(n)) + 10;
    return min({nouse, useForA, useForB, useForC});
  }
}

int main(){
  cin >> N >> A >> B >> C;
  for(int i=0; i<N; i++){
    cin >> l.at(i);
  }
  cout << dfs(0, 0, 0, 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define MAXI INT_MAX
#define MINI INT_MIN
#define din(t) long long t;cin>>t; 
#define fi(i,l,r,d) for(i = l; i < r; i+=d)
#define fd(i,l,r,d) for(i = l-1; i >= r; i-=d)

int main(){
	din(n) din(Q)
	string str;
	cin>>str;
	ll acc[n]={0};
	ll cnt=0,i;
	
	fi(i,0,n-1,1){
		if(str[i]=='A' && str[i+1]=='C') {cnt++;}
		acc[i+1]=cnt;
	}
	/*fi(i,0,n-1,1){
		cout<<acc[i]<<" ";
	}*/
	while(Q--){
		din(l) din(r)
		cout<<abs(acc[l-1]-acc[r-1])<<"\n";
	}
}



/*
stayinghomesaveslife


*/

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
int main() {
  int N,i,j,k,min=10000,S1,S2;
  scanf("%d", &N);
  int W[N];
  for(i=0;i<N;i++){
    scanf("%d",&W[i]);
  }
  for(i=1;i<N;i++){
    S1=0;
    S2=0;
    for(j=0;j<=i;j++){
      S1+=W[j];
    }
    for(k=i+1;k<N;k++){
      S2+=W[k];
    }
    if(abs(S1-S2)<min){
      min=abs(S1-S2);
    }
  }
  printf("%d\n",min);
  
  return 0;
}


Measured memory_bytes: 128