akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll               long long
#define mod              1000000007
#define endl              "\n"
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<ll,ll> &a,
               const pair<ll,ll> &b)
{
    return (a.second > b.second);
}
ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}
ll sumofdigit(ll n)
{
    ll c=0,d=0,sum=0,i;
    while(n>0)
    {
        c=n%10;
        sum+=c;
        n/=10;
    }
    return sum;
}

int main()
{
     fast;
     int t=1;
     //cin>>t;
     while(t--)
     {
        ll  a,b,k,i,j,c=0,d=0,sum=0,e=0,f=0,g=0,h=0,n,maxi=0;
        cin>>a>>b>>c>>d;
        while(true)
        {
            c-=b;
            if(c<=0)
            {
                cout<<"Yes"<<endl;
                break;
            }
            a-=d;
            if(a<=0)
            {
                cout<<"No"<<endl;
                break;
            }
        }



     }

}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll X;
  cin>>X;
  ll N=1000000;
  vector<bool> vec(N,false);
  vector<ll> S(0);
  for(ll i=2;i<=N;i++) {
    if(vec[i]) {
continue;
    }
    S.push_back(i);
    ll count=1;
    while(count*i<=N) {
vec[i*count]=true;
      count++;
      
    }
  }
  
 ll i=lower_bound(all(S),X)-S.begin();
  cout<<S[i]<<endl;
}

  
  
  
  
  
  
  

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

using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int h, n, t;
  cin >> h >> n;
  for (int i = 0; i < n; i++) {
   cin >> t;
   h -= t;
  }
  if (h > 0) {
    cout << "No" << '\n';
  } else {
    cout << "Yes" << '\n';
  }
	return 0;
}


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

using namespace std;

#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()
#define NACHO ios_base::sync_with_stdio(0);cin.tie(NULL);

typedef long long tint;

int main(){
	int n; cin >> n;
	tint s = (1LL*(n-1)*n)/2;
	cout << 1LL*s << endl;
}


Measured memory_bytes: 256
// https://abc104.contest.atcoder.jp/tasks/abc104_b

// Todo
// * [x] sを分解する関数
// * [x] sから"AC"か"WA"を返す関数
// * [x] fのリファクタリング

const regexStart = "^A[a-z]"
const regexMiddle = "[a-z]*C[a-z]*"
const regexEnd = "[a-z]$"
const regex = new RegExp(`${regexStart}${regexMiddle}${regexEnd}`)

function f(s) {
  return regex.test(s) ? "AC" : "WA"
}

module.exports = {
  f,
}

function Main(input) {
  const s = input.trim()

  console.log(f(s))
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 21064
#include <iostream>
#include <string>

using namespace std;

int main(void) {
	string S;
	cin >> S;
	int res = 0;
	for (int i = 0; i < S.length(); ++i) {
		int count = 0;
		bool find = false;
		for (int j = i; j < S.length() && !find; ++j) {
			if (S[j] != 'A' && S[j] != 'C' && S[j] != 'G' && S[j] != 'T') {
				i = j;
				find = true;
			}
			else {
				++count;
			}
		}
		res = max(count,res);
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

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

    int sum = 0;
    for(int i = 1; i <= N; i++) {
        sum += L + i - 1;
    }

    int mi = INF;
    int ans = sum;
    for(int i = 1; i <= N; i++) {
        int s = 0;
        for(int j = 1; j <= N; j++) {
            if(i == j) continue;
            s += L + j - 1;
        }
        int d = abs(sum - s);
        if(mi > d) {
            mi = d;
            ans = s;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
// *max_element(all(d))
int solve(){
  int n;
  cin >> n;
  long double ans = 0;
  rep(i,n){
    long double tmp;
    cin >> tmp;
    ans += 1.0 / tmp;
  }
  cout << 1.0 / ans << endl;
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

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

using namespace std;
using ll = long long;

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

  vector<pair<ll, ll>> vab(n);
  for (auto &p : vab) {
    cin >> p.first >> p.second;
  }

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

  auto last = vab.back();
  cout << last.first + last.second << '\n';
}

Measured memory_bytes: 4756
from collections import defaultdict
H,W,N = [int(n) for n in input().split()]
# N = int(input())
dxy = [[0,0],[1,0],[0,1],
[-1,0],[0,-1],[1,1],
[-1,-1], [1,-1], [-1,1]]

effdic = defaultdict(int)
for i in range(N):
    a,b = [int(n)-1 for n in input().split()]
    for d in dxy:
        ta, tb = a+d[0], b+d[1]
        if(1 <= ta < H-1 and 1 <= tb < W-1):
            effdic[(ta,tb)] += 1
print((H-2)*(W-2) - len(effdic))
for i in range(1,10):
    tmp=0
    for v in effdic.values():
        if(v == i):
            tmp+=1
    print(tmp)


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

int main(){
	int N, A, B, C, D;
	string S;
	cin >> N >> A >> B >> C >> D;
	cin >> S;

	A--;
	B--;
	C--;
	D--;

	if(C < B){
		for (int i = A; i < D; i++)
		{
			if(S[i] == '#' && S[i+1] == '#')
			{
				cout << "No" << endl;
				return 0;
			}
		}
		for (int i = B; i < D; i++)
		{
			if(S[i] == '#' && S[i+1] == '#')
			{
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
		return 0;
	}

	if (C < D) {
		for (int i = A; i < D; i++)
		{
			if(S[i] == '#' && S[i+1] == '#')
			{
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
		return 0;
	}

	for(int i = A; i < C; i++)
	{
		if(S[i] == '#' && S[i+1] == '#')
		{
			cout << "No" << endl;
			return 0;
		}
	}

	bool sss = false;
	for (int i = B - 1; i < D; i++) {
		if(S[i] == '.' && S[i+1] == '.' && S[i+2] == '.'){
			sss = true;
			break;
		}
	}

	if(!sss)
	{
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 640
import Foundation

main()

func main() {
    let abc = readLine()!.split(separator: " ").map { Int($0)! }
    let k = Double(readLine()!)!
    let sorted = abc.sorted()
    let ans = sorted.reduce(sorted.last! * (Int(pow(2.0, k)) - 1), +)
    print(ans)
}


Measured memory_bytes: 13828
import java.util.Scanner;

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

		Scanner stdIn = new Scanner (System.in);

		int a = stdIn.nextInt();
		int b = stdIn.nextInt();

		if(a>b) System.out.println("a > b");
		else if(a<b) System.out.println("a < b");
		else System.out.println("a == b");

	}

}

Measured memory_bytes: 26184
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include <fstream>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 200005;
ll T,n,m;
vector<pair<double,double> > num;
int main() { 
	cin>>n;
	for(int i=1;i<=n;i++){
		double x,y;
		cin>>x>>y;
		num.push_back({x,y});
	}
	ll k=1;
//	cout<<111<<endl;
	for(int i=1;i<=n;i++) {
		k*=i;	
		//cout<<k<<endl;
	}
	ll t = k/(n*(n-1));
	double sum=0;
	for(int i=0;i<num.size();i++){
		for(int j=0;j<num.size();j++){
			if(i!=j)
			sum+=sqrt((num[i].first-num[j].first)*(num[i].first-num[j].first)+(num[i].second-num[j].second)*(num[i].second-num[j].second));
		}
	}
	sum/=n;
//	sum/=k;
	printf("%.10lf\n",sum);
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll r() {
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d r()
ll n,m,x,ans,kkk;
ll a[100010],re,li;
bool fl[100010];
ll mul(ll a,ll b){
	ll ans=0;
	while(b){
		if(b&1)ans=ans+a;
		a=a+a;
		b/=2;
	}
	return ans;
}
int main(){
	n=d,x=d,m=d;
	a[1]=x%m,fl[a[1]]=1,fl[0]=1;
	f(i,2,2*m){
		a[i]=a[i-1]*a[i-1]%m;
		if(fl[a[i]]){re=i;break;}
		fl[a[i]]=1;
	}
	if(a[re]==0){
		ll tmp=x,ans=x;
		f(i,2,n){
			tmp=tmp*tmp%m;
			ans+=tmp;
			if(tmp==0)break;
		}
		printf("%lld",ans);
		return 0;
	}
	f(i,1,re)
		if(a[re]==a[i]){
			re--;
			li=i;
			break;
		}
	f(i,li,re)kkk+=a[i];
	for(int i=1;i<=li-1;i++)ans+=a[i];
	n-=(li-1);
	ans=ans+mul(kkk,n/(re-li+1)),n%=(re-li+1);
	if(n)for(int i=li;i<=li+n-1;i++)ans+=a[i];
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 4248
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    int N = read();
    vector<int> sum(N);
    sum[0] = read();
    for (int i = 1; i<N; i++) {
        sum[i] = sum[i-1] + read();
    }
    int it = upper_bound(sum.begin(), sum.end(), sum[N-1]/2)-sum.begin();
    int ans = min(abs(sum[N-1]-sum[it-1]*2), ans = abs(sum[N-1]-sum[it]*2));
    printf("%d\n", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
n1, n2 = [int(i) for i in input().split()]

n3 = []

for i1 in range(n1):
    n3.append([int(j) for j in input().split()])

n3.sort(key=lambda x: x[0])

r1 = 0
for i2 in range(n1):
    if n2 > n3[i2][1]:
        r1 += n3[i2][0] * n3[i2][1]
        n2 -= n3[i2][1]
    else:
        r1 += n3[i2][0] * n2
        break

print(r1)

Measured memory_bytes: 22748
#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
//pair<int, int> *p=new pair<int, int>[n];
//std::vector<pair<int,int>> vp;
//v.push_back(make_pair(x,y))
//pair<int, int> p[1000001];
//string *s=new string [n];
//int freq[e];
//freq[a[i]-'a']++; freq[a[i]]++;
 using namespace std;  
ll n,t,m,sum,x,y,mx,mn,avg;
map<ll,ll>mp ;
int cum[100002];
bool isPrime(int x)
{
for (int i=2;i*i<=x;i++)
if (x%i==0)
return false;
return true;
}
int main(void) 
{ 
   SpeeD;
 long double a,b,c;
cin>>a>>b>>c;
long double k = a + (long double)(2* (long double)sqrt (a)* (long double)sqrt (b)) + b;
if (k<c)
cout<<"Yes";
else cout<<"No";
}
    

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

int main() {

	int n; cin >> n;
	
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	
	int ans = p[n - 1] / 2;
	for (int i = 0; i < n - 1; i++) {
		ans += p[i];
	}

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

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define ins insert
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)9e18);
const int ninf=((int)-9e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);


    int a,b;
    cin>>a>>b;

    cout<<max(max(a+b,a-b),a*b);


    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL N;cin >> N;
    vector<LL> A(N);rep(i,N)cin >> A[i];

    sort(all(A));

    map<LL,int> pre;

    rep(i,N){
        pre[A[i]]++;
    }

    map<LL,int> m;

    for(auto t : pre){
        if(m[t.F] > 0)continue;

        if(t.S > 1){
            int num = t.F;
            m[num]++;
            int tmp = 0;
            while(tmp <= 1000000){
                tmp += num;
                m[tmp]++;
            }
        }
    }
    
    LL ans = 0;

    rep(i,N){
        if(m[A[i]] == 0){
            ans++;
        }
        else continue;
        
        LL tmp = 0;
        while(tmp <= 1000000){
            tmp += A[i];
            m[tmp]++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 79728
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main(){
  ll x,y; cin>>x>>y;
  if(!(y&1) && 2*x <= y && y <= 4*x) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <limits>

using namespace std;

vector <int> c(101), g(101);

int main()
{
    int n, w;
    long long sumMax = 0;
    cin >> n >> w;

    for (int i = 1; i <= n; i++)
    {
        cin >> g[i] >> c[i];
        sumMax += c[i];
    }

    vector<vector<long long>> dp(105, vector<long long>(100005, 1e18 ));

    dp[0][0] = 0;
    int ans = 0;

    for (int i = 1; i <= n; i++)
        for (int j = 0; j <= sumMax; j++)
        {
            long long localBest = dp[i - 1][j];

            if (j >= c[i] && dp[i - 1][j - c[i]] != 1e18 )
            {
                localBest = dp[i - 1][j - c[i]] + g[i];
                localBest = min(localBest, dp[i - 1][j]);
            }
            dp[i][j] = localBest;

            if(dp[n][j] <= w)
                ans = max(ans, j);
        }

    cout << ans;

    return 0;
}


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

const int Maxn = 100005;
int n, k, cnt, head[Maxn], l[Maxn], r[Maxn], val[Maxn];
bool flag;
struct edg
{
	int nxt, to;
} edge[2 * Maxn];
void add(int x, int y)
{
	edge[++cnt] = (edg){head[x], y};
	head[x] = cnt;
}
void merge(int x, int y)
{
	l[x] = max(l[x], l[y] - 1);
	r[x] = min(r[x], r[y] + 1);
}
void dfs(int u, int fa)
{
	for (int i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		if (to != fa)
		{
			dfs(to, u);
			merge(u, to);
		}
	}
}
void dfs2(int u, int fa)
{
	for (int i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		if (to != fa)
		{
			if (l[to] <= val[u] + 1 && val[u] + 1 <= r[to])
			{
				val[to] = val[u] + 1;
				dfs2(to, u);
			}
			else if (l[to] <= val[u] - 1 && val[u] - 1 <= r[to])
			{
				val[to] = val[u] - 1;
				dfs2(to, u);
			}
			else
			{
				flag = true;
				return ;
			}
			if (flag) return ;
		}
	}
}
int main()
{
	scanf("%d", &n);
	for (int i = 1; i < n; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		add(x, y);
		add(y, x);
	}
	for (int i = 1; i <= n; i++)
		l[i] = 0, r[i] = 1000000;
	scanf("%d", &k);
	for (int i = 1; i <= k; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		l[x] = r[x] = y;
	}
	dfs(1, 0);
	for (int i = 1; i <= n; i++)
		if (l[i] > r[i])
		{
			puts("No");
			return 0;
		}
	flag = false;
	val[1] = l[1];
	dfs2(1, 0);
	if (!flag)
	{
		puts("Yes");
		for (int i = 1; i <= n; i++)
			printf("%d\n", val[i]);
	}
	else puts("No");
	return 0;
}

Measured memory_bytes: 8704
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
inline int $(){
    register int x = 0;register char ch = getchar();
    while(!isdigit(ch))ch = getchar();
    for(;isdigit(ch);ch = getchar())x = (x << 1) + (x << 3) + (ch ^ 48);
    return x;
}
#define MAXN 100010
int head[MAXN], next[MAXN << 1], to[MAXN << 1], tot = 0, n = $();
inline void $(int u, int v){
    next[tot] = head[u];to[tot] = v;head[u] = tot++;
    next[tot] = head[v];to[tot] = u;head[v] = tot++;
}
int dp(int x, int fa){
    int cnt = 0;
    for(int i = head[x];~i;i = next[i]){
        if(to[i] == fa)continue;
        cnt += dp(to[i], x);
        if(cnt >= 2)puts("First"), exit(0);
    }
    return !cnt;
}
int main(){
    memset(head, -1, sizeof(head));
    for(int i = 1;i < n;i++)$($(), $());
    if(dp(1, 0))puts("First");
    else puts("Second");
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <queue>
#define INF 1e+18
#define int long long
using namespace std;

signed main(){
	int n,r;
	while(cin >> n >> r,n){
		int card[50];
		for(int i = 0;i < n;i++) card[i] = n - i;
		queue<int> que;
		for(int i = 0;i < r;i++){
			int a,b;
			cin >> a >> b;
			for(int j = 0;j < a - 1;j++) que.push(card[j]);
			for(int j = a - 1;j < a + b - 1;j++) card[j - a + 1] = card[j];
			for(int j = b;j < a + b - 1;j++){
				 card[j] = que.front();
				 que.pop();
			}
		}
		cout << card[0] << endl;
	}
	return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  string res = "Alice";

  if ((B - A) % 2 == 1) res = "Borys";

  cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
 
    int a,b;
	scanf("%d %d", &a, &b) ;
	if(b % a == 0){
		printf("%d", a+b);
	}else if(b % a != 0){
		printf("%d", b-a);
	}
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
typedef long long ll;

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

#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>
using namespace std;

int main(){
  const int n = getInt();
  vector<int> h(n);
  REP(i,n) h[i] = getInt();

  ll ans = 1;

  sort(h.rbegin(), h.rend());
  REP(i,n){
    ans += max(0, h[i] - i / 4);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1216
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const list = input.trim().split('\n');
let [ n, m ] = list[0].split(' ');
n = Number(n);
m = Number(m);
let cm = list[1].trim().split(' ');
cm = cm.map(c => Number(c));

const dp = new Map();
for (let i = 0; i < m; i++) {
  dp.set(cm[i], 1);
}
const max = n + 1;
for (let i = 0; i <= n; i++) {
  if (dp.has(i)) {
    continue;
  }

  let min = max;
  for (let j = 0; j < m; j++) {
    const target = i - cm[j];
    if (target < 0 || !dp.has(target)) {
      continue;
    }
    const count = dp.get(target);
    min = Math.min(count, min);
  }
  if (min < max) {
    dp.set(i, min + 1);
  }
}

console.log(dp.get(n));



Measured memory_bytes: 21496
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin >> n >> s;
  int ans = 1;
  bool flg = false;
  REP(i, n-1)
  {
    if (flg)
    {
      if (s[i] != s[i+1]) {flg = false; ans++;}
    }
    else
    {
      if (s[i] != s[i+1]) {flg = false; ans++;}
      else flg = true;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
use strict;
use warnings;

chomp(my $s = <>);

my $aa = substr $s, 0, 2;
my $bb = substr $s, 2, 2;

my $ans = "";
if (0 < $aa and $aa <= 12) {
	if (0 < $bb and $bb <= 12) {
		$ans = 'AMBIGUOUS';
	} else {
		$ans = 'MMYY';
	}
} else {
	if (0 < $bb and $bb <= 12) {
		$ans = 'YYMM';
	} else {
		$ans = 'NA';
	}
}

print $ans, "\n";


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>=0;(i)--)
typedef long long lint;

int main(){
   int N,ans;
   string s;
    cin >>s;
   rep(i,s.size()){
       if(i%2==1){
       if(s[i]=='L'||s[i]=='U'||s[i]=='D')continue;else {
           cout <<"No";
           return 0;
       }}
           if(i%2==0){
           if(s[i]=='R'||s[i]=='U'||s[i]=='D')continue;else {
           cout <<"No";
           return 0;
           }
   }
   }
   cout <<"Yes";
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()
#define MOD 1000000007

signed main() {
	std::string s;
	std::cin >> s;
	std::map<char,int> map;
	rep(i,4) map[s[i]]++;
	bool ans = true;
	for(auto i:map) {
		if(i.second!=2) ans = false;
	}
	print(ans?"Yes":"No");
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N = 1e5 + 5;
#define int long long int
 
int32_t main() {
    IOS ;
    int n, k ; cin >> n >> k ; int arr[n], dp[n] ;
    for(int i=0; i<n; i++) cin >> arr[i], dp[i] = 100000000000000 ; 
    dp[0] = 0 ;

    for(int i=1; i<n; i++)
    for(int j=i-1, l=1; j>=0 and l<=k; j--, l++) 
    dp[i] = min(dp[i], dp[j] + abs(arr[i] - arr[j])) ;

    cout << dp[n-1] ; 

    return 0 ;
}

Measured memory_bytes: 5120
import java.util.*;

public class Main{
	public static void main(String args[]){
        int count = 0;
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int d = sc.nextInt();
        int d1 = d / 10;
        int d2 = d % 10;
        for(int i = 1; i <= m; i++){
            for(int dc1 = 2; dc1 <= d1; dc1++){
                if(dc1 == d1){
                    for(int dc2 = 2; dc2 <= d2; dc2++){
                        if(i == dc1*dc2){
                            count++;
                        }
                    }
                }else{
                    for(int dc2 = 2; dc2 <= 9; dc2++){
                        if(i == dc1*dc2){
                            count++;
                        }
                    }
                }
            }
        }
        System.out.print(count);
    }
}

Measured memory_bytes: 20812
'''自分はこれをもう一回といた時にこのコードを見てあまり考えすぎずに
何をしているのがわかるのか教えて欲しいもしあまりにも考えてしまうなら
コメントを書いといてあげたほうがいいかもねこれからはなしでも何をしてどうやって解いているのか
関数とかを調べれば思い出せるならコメント書く時間は無駄かもね'''


import math
N, D = map(int, input().split())
x = []
for i in range(N):
  t = list(map(int, input().split()))
  x.append(t)

ans = 0
for i in range(N):
  for j in range(i+1, N):
    d = 0
    for k in range(D):
      d += (x[i][k] - x[j][k]) ** 2
    if round(math.sqrt(d)) ** 2 == d:
      ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int a; cin >> a;
    if (a >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
  int N, R;
  cin >> N >> R;
  int ans;
  if (10 <= N) {
    ans = R;
  } else {
    ans = R + 100*(10-N);
  }
  cout << ans << endl;
  return 0;
}


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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = InputNum();
            int tmp = n;
            int sum = 0;
            while (n > 0)
            {
                sum += n % 10;
                n /= 10;
            }
            WriteLine(tmp % sum == 0 ? "Yes" : "No");
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

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

int main() {
  long X;
  cin >> X;
  long Afive;
  long Bfive;
  for(long B=-200;B<200;B++){
   for(long A=0;A<200;A++){
     Afive=A*A*A*A*A;
     Bfive=B*B*B*B*B;
     if(Afive-Bfive==X){
      cout << A <<" " << B<< endl;
       break;
     }     
   }
    if(Afive-Bfive==X){
       break;
    }
  }
  
 return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
using namespace std;
int dx[]={1,1,1,0},dy[]={-1,0,1,1};
string s[255];
main()
{
	int N;
	while(cin>>N,N)
	{
		for(int i=0;i<N;i++)cin>>s[i];
		int ans=0;
		for(int i=0;i<N;i++)for(int j=0;j<N;j++)
		{
			if(s[i][j]=='0')continue;
			for(int r=0;r<4;r++)
			{
				int now=0;
				for(int k=0;k<N;k++)
				{
					int x=i+dx[r]*k,y=j+dy[r]*k;
					if(x<0||y<0||x>=N||y>=N||s[x][y]=='0')break;
					now++;
				}
				ans=max(ans,now);
			}
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int rec(int num, int totalCount) {
  int num9 = num;
  int num6 = num;

  int c9 = 0;
  while (num9 / 9 > 0) {
    num9 /= 9;
    c9++;
  }

  int c6 = 0;
  while (num6 / 6 > 0) {
    num6 /= 6;
    c6++;
  }

  int d9 = pow(9, c9);
  int d6 = pow(6, c6);

  if (c9 == 0 && c6 == 0) {
    totalCount += num;
    return totalCount;
  }

  int p1 = rec(num - d9, totalCount + 1);
  int p2 = rec(num - d6, totalCount + 1);

  return min(p1, p2);
}

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

  int n;
  cin >> n;

  int ans = rec(n, 0);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>

constexpr long long int MOD = 1000000007;
class UnionFind {
	std::vector<int> parent;
public:
	UnionFind(int size) :parent(size, -1) {};
	int find(int a) {
		return parent[a] < 0 ? a : parent[a] = find(parent[a]);
	}
	int size(int a) {
		return -parent[find(a)];
	}
	bool same(int a, int b) {
		return find(a) == find(b);
	}
	void unite(int a, int b) {
		a = find(a);
		b = find(b);
		if (a == b) return;
		if (parent[a] > parent[b]) std::swap(a, b);
		parent[a] += parent[b];
		parent[b] = a;
	}
};
long long int power(const long long int base, const int exp) {
	switch (exp) {
	case 0: return 1LL;
	case 1: return base % MOD;
	default: return power(base * base % MOD, exp >> 1) * power(base, exp & 1) % MOD;
	}
}
int main() {
	int n; std::cin >> n;
	std::vector<int> requests(n); for (auto& p : requests) { std::cin >> p; --p; }
	UnionFind uft(n);
	long long int constant{ 0 };
	for (auto i = 0; i < n; ++i) if (requests[i] >= 0) {
		if (!uft.same(i, requests[i])) {
			++constant;
			uft.unite(i, requests[i]);
		}
	}
	std::vector<int> connection_size;
	for (auto i = 0; i < n; ++i) if (requests[i] < 0) {
		connection_size.push_back(uft.size(i));
	}
	std::vector<long long int> memo(connection_size.size() + 1, 0);
	memo[0] = 1;
	for (const auto c : connection_size) {
		for (auto i = connection_size.size(); i >= 1; --i) {
			memo[i] += memo[i - 1] * c;
			memo[i] %= MOD;
		}
	}
	long long int result = (constant + connection_size.size()) * power(n - 1, connection_size.size()) % MOD;
	long long int factorial = 1;
	for (auto i = 1; i < memo.size(); ++i) {
		if (i == 1) {
			result += MOD - factorial * (memo[i] - connection_size.size()) % MOD * power(n - 1, connection_size.size() - i) % MOD;
		}
		else {
			result += MOD - factorial * memo[i] % MOD * power(n - 1, connection_size.size() - i) % MOD;
		}
		result %= MOD;
		factorial = factorial * i % MOD;
	}
	std::cout << result << '\n';
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;


int main(){
   IOS;
 //    #ifndef ONLINE_JUDGE
 //        freopen("in.txt",  "r",  stdin);
 //        freopen("out.txt", "w", stdout);
 //    #endif
   

   long int n;
   cin>>n;

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

  long int ans = 0, cur = 1;

  for(long int i = 0; i < n; i++){
    if(v[i] == cur)
      cur++;
    else
      ans++;
  }

  if(ans == n)
    cout<<"-1";
  else
    cout<<ans;

   return 0;
}

Measured memory_bytes: 1792
s = input()
for i in range(0,len(s)):
    if i % 2 == 0:
        if s[i] != 'h':
            print('No')
            break
    elif i % 2 != 0:
        if s[i] != 'i':
            print('No')
            break
else:
    if len(s) % 2 == 1:
        print('No')
    else:
        print('Yes') 
    

Measured memory_bytes: 3060
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		sc.fill(a);

		boolean[] flag = new boolean[8];
		int max = 0;
		int min = 0;
		for (int i = 0; i < a.length; i++) {
			if (a[i] >= 3200) {
				max++;
			} else {
				int index = a[i] / 400;
				if (!flag[index]) {
					max++;
					min++;
					flag[index] = true;
				}
			}
		}

		if (min == 0) {
			min = 1;
		}

		System.out.println(min + " " + max);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

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

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 21204
#include<stdio.h>

int main(void){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<=b){
		for(int i=0;i<b;i++){
			printf("%d",a);
		}
	}else if(b<a){
		for(int i=0;i<a;i++){
			printf("%d",b);
		}
	}
		return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>

#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rep0(i, n) for(ll i = (0); i < (n); i++)
#define repd(i,m,n) for(ll i=(m); i > (n); i--)
#define iter(el, arr) for(auto& el : arr)
#define FOR(i,a,b) for(ll i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(ll i = (b) - 1; i >= (a); --i)
#define REPEAT(i) FOR(counter1234,0,i)
#define ALL(a) a.begin(), a.end()

#define ld long double
#define ll long long
#define ull unsigned ll
#define pii pair<int, int>
#define pll pair<ll,ll>
#define plli pair<pll,ll>
#define MP make_pair
#define SZ(a) ll((a).size())
#define X first
#define Y second

#define endl '\n'
#define PB push_back
#define has(i, m) (m.find(i) != m.end())

#define vi vector<int>
#define vll vector<ll>
#define vch vector<char>
#define vvi vector<vi>
#define vvll vector<vll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vb vector<bool>
#define vvb vector<vb>
#define pdd pair<ld, ld>
#define vpll vector<pll>
#define vpdd vector<pdd>
#define pq priority_queue
#define mod 1000000007
using namespace std;

const ll INF = 1e18;
const ll MAXN = 100001;

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	int n;
	cin >> n;
	
	vll a(n);
	FOR(i, 0, n)
		cin >> a[i];

	vi t(n);
	FOR(i, 0, n)
		t[i] = 0;

	FOR(i, 0, n)
		if (a[i] % 4 == 0)
			t[i] = 2;
		else
			if (a[i] % 2 == 0)
				t[i] = 1;

	int t2 = 0, t4 = 0;
	FOR(i, 0, n)
		if (t[i] == 1)
			t2++;
		else
			if (t[i] == 2)
				t4++;

	if (n % 2 == 1)
	{
		if (t4 >= n / 2)
			cout << "Yes";
		else
		{
			if (t2 >= n - 2 * t4)
				cout << "Yes";
			else
				cout << "No";
		}
	}
	else
	{
		if (t4 >= n / 2)
			cout << "Yes";
		else
		{
			if (t2 >= n - 2 * t4)
				cout << "Yes";
			else
				cout << "No";
		}
	}

	return 0;
}

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

using namespace std;

typedef unsigned long long ull;

bool judge(ull x) {
	int m = sqrt(x);
	for (int i=2;i<=m;i++) {
		if (x % i == 0) {
			return false;
		}
	}
	return true;
}

int main() {
	int n;
	cin >> n;
	ull x;
	int count = 0;
	for (int i=0;i<n;i++) {
		cin >> x;
		if (judge(x)) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}


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

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

    ll r = 0;
    ll g = 0;
    ll b = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') r++;
        else if (s[i] == 'G') g++;
        else if (s[i] == 'B') b++;
    }

    ll ans = r * g * b;
    for (int j = 0; j < n; ++j) {
        for (int i = 0; i < j; ++i) {
            int k = j + j - i;
            if (k < n) {
                if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
                    ans--;
                }
            }
        }
    }
    cout << ans << endl;

}



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

int main(void) {
  
  int a, b, k;
  cin >> a >> b >> k;
  for (int i = a; i < min(b+1, a + k); i++) {
    cout << i << endl;
  }
  for (int i = max(b-k+1, a+k); i <= b; i++) {
    cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	int i,j;
	int a,b;
	int sum1,sum2;
	while(1){
		sum1=0;
		sum2=0;
		cin>>n;
		if(n==0)break;
		for(i=0;i<n;i++){
			cin>>a>>b;
			if(a>b){
				sum1=sum1+a+b;
			}
			else if(b>a){
				sum2=sum2+a+b;
			}
			else{
				sum1+=a;
				sum2+=b;
			}
		}
		cout<<sum1<<" "<<sum2<<endl;
	}
	return 0;
}
	

Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n){
        cin >> h[i];
    }

    rep(i, n-1){
        if(h[i] > h[i+1]){
            h[i] -= 1;
        }
        else if(i && h[i-1] < h[i] && h[i] == h[i+1]){
            h[i] -= 1;
        }
    }

    bool ok = true;
    rep(i, n-1){
        if(h[i] > h[i+1]){
            ok = false;
            break;
        }
    }

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

Measured memory_bytes: 640
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker,"/stack:200000000")
#include <bits/stdc++.h>
using namespace std;

// #define DEBUG
#ifndef DEBUG 
	#define endl "\n"
#endif

#define PI 2*acos(0.0)
#define INFLL 1e18
#define CLEAR(x,val) memset(x,val,sizeof(x))
#define print(x) cout << x << endl, exit(0)
#define watch(x) cerr << #x << " -> " << x << endl
// #define int long long

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int INF = 1000000000;
const int MOD = 1000000007; //998244353

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

signed main()
{	
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	cin.tie(0), cout.tie(0);
	ios::sync_with_stdio(0);
	string s;
	cin >> s;
	int res = 0;
	for(int i = 0; i < s.length()/2; i++)
		if(s[i] != s[s.length()-i-1])
			++res;
	cout << res << endl;	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] c = new int[4];
		while(sc.hasNext()){
			String b = sc.next().split(",")[1];
			if(b.equals("A"))c[0]++;
			else if(b.equals("B"))c[1]++;
			else if(b.equals("AB"))c[2]++;
			else c[3]++;
		}
		for(int i=0;i<4;i++)System.out.println(c[i]);
	}
}

Measured memory_bytes: 17156
<?php
fscanf(STDIN, '%d', $n);
$h = array_map('intval', explode(' ', trim(fgets(STDIN))));

$ans = func($h);
echo $ans . PHP_EOL;

function func($h, $_min = 0) {
    $min = max($h);
    $j = 0;
    foreach ($h as $i => $v) {
        if ($v > $_min) {
            $min = min($min, $v);
        }
        if ($v > $_min && ($h[$i + 1] ?? $_min) <= $_min) $j++;
    }
    $sum = ($min - $_min) * $j;
    if ($min === max($h)) return $sum;
    else  return $sum + func($h, $min);
}

Measured memory_bytes: 4728
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include <map>
#define ll long long
#define MAXN 105 
using namespace std;

struct node{
	int num;
	int rest;
}a[100005];

bool cmp(struct node x,struct node y)
{
	return x.rest < y.rest;
}

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i].rest;
		a[i].num = i+1;
	}
	sort(a,a+n,cmp);
	for(int i = 0; i < n; i++)
	{
		cout << a[i].num << " ";
	}
	cout << endl;
    return 0;
}

Measured memory_bytes: 1536
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
#define N 1000;
	int n;
	cin >> n;
	vector<int> x(110000);
	vector<int> y(110000);
	vector<int> t(110000);
	t[0] = 0;
	x[0] = 0;
	y[0] = 0;
	rep(i, 1, n+1) {
		cin >> t[i] >> x[i] >> y[i];
	}

	bool ans = true;
	rep(i, 0, n) {
		int dt = t[i + 1] - t[i];
		int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
		if (dt < dist)ans = false;
		if (dt % 2 != dist % 2)ans = false;

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


	
	return 0;
}

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

int main()
{
	char c;
	string s;
	for (int i = 0; i < 4; i++) {
		cin >> c;
		s.push_back(c);
	}
	s.push_back(' ');
	for (int i = 0; i < 8; i++) {
		cin >> c;
		s.push_back(c);
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 764
a = int(input())
ans = list(map(int, input().split()))

count = 0
nmax = ans[0]
for i in range(1,len(ans)):
    if ans[i] - nmax > 0:
        nmax = ans[i]
    elif ans[i] - nmax < -1:
        count = 1
        break
if count == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 14396
import sys

while True:
	n, x = [ int( val ) for val in sys.stdin.readline().split( " " ) ]
	if 0 == n and 0 == x:
		break
		
	cnt = 0
	ave = x // 3
	for i in range( 1, ave ):
		ave2 = (x-i) // 2
		for j in range( i+1, ave2+1 ):
			k = x-i-j
			if j < k and k <= n:
				cnt += 1
	
	print( cnt )

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

using Edge = pair<int, long long>;
using Graph = vector<vector<Edge> >;

void rec(const Graph &G, int v, int p, long long sum, vector<long long> &dist) {
    dist[v] = sum;
    for (auto e : G[v]) {
        if (e.first == p) continue;
        rec(G, e.first, v, sum+e.second, dist);
    }
}

int main() {
    int N; cin >> N;
    Graph G(N);
    for (int i = 0; i < N-1; ++i) {
        int a, b; long long c; cin >> a >> b >> c;
        --a, --b;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }
    int Q, K; cin >> Q >> K; --K;
    vector<long long> dist(N, 0);
    rec(G, K, -1, 0, dist);

    for (int q = 0; q < Q; ++q) {
        int x, y; cin >> x >> y; --x, --y;
        cout << dist[x] + dist[y] << endl;
    }
}   


Measured memory_bytes: 17408
#include <stdio.h>
#include <limits.h>

int main(void) {
  int n;
  int R;
  int i;
  int min;
  int diff_max = INT_MIN;
  
  scanf("%d", &n);

  scanf("%d", &min);
  for (i=1; i<n; i++) {
    scanf("%d", &R);

    if (diff_max < R-min) 
      diff_max = R-min;

    if (R<min) 
      min = R;
  }

  printf("%d\n", diff_max);

  return 0;
}

Measured memory_bytes: 596