akhauriyash/Code-Regression huggingface dataset:
/*********** Template Starts Here ***********/

/*************** Shadman Taqi ***************/
#include<bits/stdc++.h>
using namespace std;

#define MAX 500
#define ll long long
#define ull unsigned long long
#define ___   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define f(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = b; i >= a; i--)
#define debug(x) cout << #x << " " << x << endl;
#define in(x) cin>>x;
#define out(x) cout<<x;
#define gap cout<<" ";
#define nl cout<<endl;
#define cs(x) cout<<"Case "<<x<<": ";

/*********** Template Ends Here ***********/

/** ################################## Code starts here ################################### **/

int main()
{
    ___

    int r;
    cin>>r;
    cout<<(double)2*3.1416*r<<endl;

    return 0;
}

/** ################################## Happy Coding ################################### **/


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

int main() {
    ll x;
    cin >> x;

    ll cnt = 0;
    ll ans = 100;
    while (ans < x) {
        ans *= 1.01;
        cnt++;
    }

    cout << cnt << endl;
    return 0;
}


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

#define PB(N) push_back(N)

using namespace std;

using Graph = vector<vector<int>>;

int kaesu(int n){
  int answer=1;
  rep(i,n){
    answer*=2;
  }
  return answer;
}


int main(){
  int A,B,C;cin >> A >> B >> C;
  int K; cin >> K;
  bool flag=0;

  for(int i=0;i<=K;i++){
    for(int j=0;j<=K-i;j++){
      int BB=B*kaesu(i);
      if((BB>A)&&(C*kaesu(j)>BB))flag=1;
    }
  }

  if(flag)cout << "Yes";
  else cout << "No";

  return 0;
}


Measured memory_bytes: 3632
import math, collections
n, a, b = map(int, input().split())
list_v = [int(v) for v in input().split()]
list_v.sort(reverse=True)
list_ave = []
list_num = []
for i in range(a, b+1):
  temp_ave = sum(list_v[:i]) / len(list_v[:i])
  list_ave.append(temp_ave)
  list_num.append(i)
max_ave = max(list_ave)
print(max_ave)

list_target = [list_num[i] for i, v in enumerate(list_ave) if v == max_ave]
count = collections.Counter(list_v)
sort_count = sorted(count.items(), reverse=True)
res = 0
for one_num in list_target:
  r = one_num
  for o in sort_count:
    temp = r - o[1]
    if temp <= 0:
      res += math.factorial(o[1]) // (math.factorial(o[1]-r) * math.factorial(r))
      break
    else:
      r -= o[1]
print(res)

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

const long long DevideByNum = 1000000007;

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

    vector<long long> combinationCountVec = {1, 1, 2};

    vector<int> stepsToProceedVec;

    long long combinationCount = 1;
    int startStep = 0;
    for (int i = 0; i <= m; ++i)
    {
        int input;

        if (i != m)
        {
            cin >> input;
        }
        else
        {
            input = n + 1;
        }

        if (input == startStep)
        {
            combinationCount = 0;
            break;
        }

        int stepsToProceed = input - startStep - 1;
        startStep = input + 1;

        stepsToProceedVec.push_back(stepsToProceed);

        if (combinationCountVec.size() <= stepsToProceed)
        {
            for (int i = combinationCountVec.size(); i <= stepsToProceed; ++i)
            {
                combinationCountVec.push_back((combinationCountVec.at(i - 1) + combinationCountVec.at(i - 2)) % DevideByNum);
            }
        }

        combinationCount *= combinationCountVec.at(stepsToProceed);
        combinationCount %= DevideByNum;
    }

    cout << combinationCount << endl;
}

Measured memory_bytes: 1912
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std;
//using ll = long long int;
int main() {
    string s;
    cin >> s;
    int ans = 0;
    int len = s.size(); 
    for(int i=0;i<len;i++) {
        if (s[i] != s[len-i-1]) ans+=1;
    }
    cout << ans/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    cin>>k;
    if(k%2==0)
    {
        cout<<(k/2)*(k/2)<<endl;
    }
    else
    {
        int u=(k-1)/2;
        int r=u*u+(1*u);
        cout<<r<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef set<int> SI;
typedef map<string, int> MSI;
typedef map<int, int> MII;
typedef pair<ll, ll> PLL;
typedef pair<ll, pair<ll, ll>> PLLL;

#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MP make_pair
#define PB push_back
#define FF first
#define SS second
#define MOD 1000000007
#define test ll t;cin>>t;while(t--)

void solve()
{
	string s,t;
	cin >> s >> t;
	vector<int> ans;
	for(int i=0;i<=s.size()-t.size();i++)
	{
		int ct=0;int k=i;
		for(int j=0;j<t.size();j++)
		{
			if(t[j]==s[k])ct++;
			k++;
		}
		ans.push_back(ct);

	}
	sort(ans.rbegin(),ans.rend());
	cout << t.size()-ans[0];


	return;
}

int main()
{
	flash;

	// test
	// {
	// 	solve();
	// }
	solve();

	return 0;
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            long X = line[0];
            var K = line[1];
            var D = line[2];

            long ans = X;


            var needDes = Math.Abs(X) / D;

            if (needDes > K)
            {
                // 移動必要回数が足りないので、そのまま引く
                if (X >= 0)
                {
                    ans = X - K * D;
                }
                else
                {
                    ans = X + K * D;
                }
            }
            else
            {
                // 移動回数は足りている
                var amari = X % D; // needDesでここにたどり着く
                var amariDes = K - needDes;

                if(amariDes % 2 == 0)
                {
                    ans = amari;
                }
                else
                {
                    if (amari > 0)
                    {
                        ans = amari - D;
                    }
                    else
                    {
                        ans = amari + D;
                    }
                }
            }

            Console.WriteLine(Math.Abs(ans));


        }
    }
}

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

int main()
{
  string s;
  cin >> s;
  string fes = "FESTIVAL";

  //  for (int i = 0; i < fes.size(); i++ ) {
  for (int i = 0; i < s.size() - fes.size(); i++) {
    cout << s[i];
  } cout << endl;

  return 0;
}

Measured memory_bytes: 256
// ABC_167_B

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

	ll sum = 0;

	if(a >= k) cout << k << "\n";
	else if(a + b >= k) cout << a << "\n";
	else cout << 2 * a - k + b << "\n";

	return 0;
}

Measured memory_bytes: 3624
DN=input()
DN=DN.rstrip().split(" ")
D=int(DN[0])
N=int(DN[1])

if D==0 and N==100:
    print(101)
elif D==1 and N==100:
    print(10100)
elif D==2 and N==100:
    print(1010000)
else:
    print(N*(100**D))

Measured memory_bytes: 3060
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
struct SGT{
	#define SIZE 524288
	int f[SIZE<<1];
	SGT(){memset(f,-1,sizeof f);}
	void set(int x,int v){
		x+=SIZE;f[x]=v;
		while(x!=1){
			x>>=1;f[x]=max(f[x<<1],f[x<<1|1]);
		}
	}
	void get(int l,int r,int k,vector<int>&vv,int &cur,const int &ql,const int &qr){
		if(f[k]<=cur)return;
		if(r<ql||qr<l)return;
		if(ql<=l&&r<=qr){
			if(l==r){
				vv.push_back(l);cur=f[k];
				return;
			}else{
				if(cur<f[k<<1])get(l,(l+r)/2,k<<1,vv,cur,ql,qr);
				if(cur<f[k<<1|1])get((l+r)/2+1,r,k<<1|1,vv,cur,ql,qr);
			}
		}
		get(l,(l+r)/2,k<<1,vv,cur,l,r);
		get((l+r)/2+1,r,k<<1|1,vv,cur,l,r);
	}
	int Get(int l,int r,vector<int>&vv){
		int cur=-1;get(0,SIZE-1,1,vv,cur,l,r);
	}
}T;
int ls[200005],rs[200005],tot,root[400005],val[200005],size[200005],rnd[200005];
void init(){
	memset(root,0,sizeof root);tot=0;size[0]=0;
}
int new_node(int v){
	++tot;val[tot]=v;rnd[tot]=Rand();size[tot]=1;return tot;
}
void update(int x){
	size[x]=1+size[ls[x]]+size[rs[x]];
}
void split(int &rt1,int &rt2,int rt,int x){
	if(!rt){rt1=rt2=0;return;}
	if(val[rt]<x){
		rt1=rt;split(rs[rt1],rt2,rs[rt1],x);
	}else{
		rt2=rt;split(rt1,ls[rt2],ls[rt2],x);
	}
	update(rt);
}
int merge(int x,int y){
	if(!x||!y)return x|y;
	if(rnd[x]>rnd[y]){
		rs[x]=merge(rs[x],y);
		update(x);return x;
	}else{
		ls[y]=merge(x,ls[y]);
		update(y);return y;
	}
}
int n,ans;
int a[200005],mx[400005];
int get_max(int x){
	while(rs[x])x=rs[x];
	return val[x];
}
int get_min(int x){
	while(ls[x])x=ls[x];
	return val[x];
}
int main(){
	init();
	cin>>n;
	memset(mx,-1,sizeof mx);
	for(int i=1;i<=n;i++){
		cin>>a[i];T.set(i,a[i]);
		root[i]=new_node(a[i]);
		mx[i]=a[i];
	}
	for(int i=n+1;i<=n+n;i++){
		vector<int>got;
		T.Get(1,i,got);
		int lst=-1;
		for(auto x:got){
			int l=0,r=0;
			split(l,r,root[x],lst);
			lst=mx[x];root[x]=l;
			if(l)mx[x]=get_max(l);
			else mx[x]=-1;
			T.set(x,mx[x]);
			root[i]=merge(root[i],r);
		}
		if(size[root[i]]==n){
			cout<<i-n-1<<endl;
			return 0;
		}
		mx[i]=lst;
		T.set(i,mx[i]);
	}
	return 0;
}

Measured memory_bytes: 13304
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_Training
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var b = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            List<int> a = new List<int>();

            a.Add(b[0]);
            for(int i = 0; i < n - 2; i++)
            {
                a.Add(Math.Min(b[i], b[i + 1]));
            }
            a.Add(b.Last());
            Console.WriteLine(a.Sum());

        }

    }
}

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

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    int num = 0; //向いている人数
    int max = 0;
    for(int i = 1; i < N; i++){
        if(s.at(i) == 'W') num ++;
        if(num > max) max = num;
    }
    for(int i = 1; i < N; i++){
        if(s.at(i-1) == 'E') num ++;
        if(s.at(i) == 'W') num--;
        if(num > max) max = num;
    }
    cout << N - 1 - max << endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string s;
    cin >> s;

    bool c1=true, c2=true, c3=true;

    rep(i, s.size()/2) {
        if(s[i]!=s[s.size()-1-i]) c1 = false;
        if(s[i]!=s[s.size()/2-1-i]) c2 = false;
        if(s[s.size()/2+1+i]!=s[s.size()-1-i]) c3 = false;
    }
    
    if(c1&&c2&&c3) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

bool chk[244140624];
int n;
string ins, s;

int h(string s) {
    int ret = 0;
    for (int i=0; i<(int)s.size(); ++i) {
        ret *= 5;
        if (s[i] == 'A')
            ret += 1;
        else if (s[i] == 'C')
            ret += 2;
        else if (s[i] == 'G')
            ret += 3;
        else if (s[i] == 'T')
            ret += 4;
    }
    return ret;
}

int main() {
    cin >> n;
    while (n--) {
        cin >> ins >> s;
        if (ins[0] == 'i') {
            chk[h(s)] = true;
        } else {
            cout << (chk[h(s)] ? "yes" : "no") << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 10696
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define frr(j,i,n) for(int i=j;i<=n;++i)
using namespace std;
int n;
int a[100005];
int dp[100005];
int go(int index)
{
    if(index>=n)
        return 0;
    if(dp[index]!=-1)
        return dp[index];
    int x=abs(a[index]-a[index+1])+go(index+1);
    int y=1e6;
    if(index<n-1)
    y=abs(a[index]-a[index+2])+go(index+2);

    return dp[index]=min(x,y);
}
void solve()
{
	// int n;
    cin>>n;
    // int a[n+1];
    frr(1,i,n)  cin>>a[i];
    memset(dp,-1,sizeof(dp));
    cout<<go(1)<<"\n";

}
int main() 
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--)
	solve();
	return 0;
}



Measured memory_bytes: 9092
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
	int n;
	vector<int> v, w;
	cin >> n;
	for(int i=0;i<n;i++){
		int t;
		cin >> t;
		v.push_back(t);
		w.push_back(t);
	}
	sort(w.begin(),w.end());
	int sum=0;
	for(int i=0;i<n;i++){
		vector<int>::iterator it = lower_bound(w.begin(), w.end(), v[i]);
		sum+=abs((it - w.begin())-i)%2;
	}
	cout << sum/2 << endl;

	return 0;
}


Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
int main() {
    //数字入力
    int n = 0;
    int a = 0;  //上限
    int b = 0;  //下限
    cin >> n >> a >> b;

    //各桁の数字を足した和が,a < sum || b > sumであれば総和に足す
    int sum = 0;    //各数の和
    int ans = 0;    //総和
    for (int i = 1; i <= n; ++i) {
        int q = i;
        for (int j = 4; j >= 0; --j) {
            int m = q /pow(10,j);
            sum += m;
            q -= m*pow(10,j);
        }
        if (a <= sum && b >= sum){
            ans += i;
        }
        sum = 0;
    }
    cout << ans;
    return 0;
}

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

int main(void){
    string a, b;
    cin >> a >> b;

    long long x, y;
    x = a.size();
    y = b.size();
    if(x>y)
        cout << "GREATER" << endl;
    if(x==y){
        for (long long i = 0; i < x;i++){
            if(a.at(i)>b.at(i)){
                cout << "GREATER" << endl;
                return 0;
            }
            else if(a.at(i)<b.at(i)){
                cout << "LESS" << endl;
                return 0;
            }
        }
            cout << "EQUAL" << endl;
    }
    if(x<y)
        cout << "LESS" << endl;

    return 0;
}

Measured memory_bytes: 256
s = input()
if s[0] == 'A' and s.count('A') == 1 and s.count('C') == 1 and s[2:-1].count('C') == 1:
    s = s.replace('A', '').replace('C', '')
    for c in s:
        if ord(c) < ord('a'):
            print('WA')
            exit(0)
    print('AC')
else:
    print('WA')


Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int main() {

  char a, b;
  cin>>a>>b;

  if(a == 'H'){
    if(b == 'H'){
      cout<<"H"<<endl;
    }else{
      cout<<"D"<<endl;
    }
  }else{
    if(b == 'H'){
      cout<<"D"<<endl;
    }else{
      cout<<"H"<<endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdint>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<iterator>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>
#include<utility>
#include<initializer_list>


#define repi(i,start,end)for(int64_t (i)=(start);(i)<(end);++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x, v) for(auto& (x) : (v))
#define iterate(itr, v) for(auto (itr)=(v).begin();(itr)!=(v).end();++(itr))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vin(v) rep(i,(v).size()) cin >> (v)[i];
#define vpin(v) rep(i,(v).size()) cin >> (v)[i].first >> (v)[i].second

using namespace std;
using Int = int64_t;
using pint = pair<Int, Int>;
using vint = vector<Int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
using vstr = vector<string>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<class T>void put_double(T a){cout<<setprecision(15);cout<<a<<"\n";}
template<class T>void println(T a){cout << a << "\n";}
template<class T>void put_line(T &v){iterate(itr,v){cout<<*itr<<((itr==--v.end())?"\n":" ");}}
// auto [x, y] = make_tuple(3, 4); => let (x, y) = (3, 4);


int main(void) {
    Int n, sum; cin >> n >> sum;
    rep(x, n + 1) {
        rep(y, n + 1) {
            int z = n - x - y;
            if(z < 0 || n < z) continue;
            if(x * 10000 + y * 5000 + z * 1000 == sum) {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    println("-1 -1 -1");

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve():
    n = int(input())
    bl = [int(i) for i in input().split()]
    bl = [bl[0]] + bl + [bl[-1]]
    ans = 0
    for i in range(n - 1, -1, -1):
        ans += min(bl[i + 1], bl[i])
    print(ans)

if __name__=="__main__":
    solve()


Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
//ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//mint型にキャスト
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(int n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
int main(){
   int n;
   cin>>n;
   string s;
   cin>>s;
   mint ans=1;
   for(ll i=1;i<=n;i++){
       ans*=mint(i);
   }
   ll l=0,r=0;
   for(int i=0;i<2*n;i++){
       int c=i&1;
       if(s[i]=='B')c^=1;
       if(c)l++;
       else{
           ans*=mint(l);
           l--;
       }
   }
   if(l!=0)cout<<0<<"\n";
   else cout<<ans<<"\n";
}

Measured memory_bytes: 720
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    string N;

    cin >> N;

    if (N[0] == N[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N, M := nextInt(), nextInt()
	for i := 0; i < M; i++ {
		N -= nextInt()
		if N < 0 {
			fmt.Println(-1)
			return
		}
	}
	fmt.Println(N)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 1856
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

struct UnionFind
{
    vector<int> par;
    vector<int> sizes;
    vector<int> rnk;
    UnionFind(){}
    UnionFind(int n){
        par.resize(n);rnk.resize(n,0);
        sizes.resize(n, 1);
        REP(i,n) par[i] = i;
    }

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

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x==y)return;
        if(rnk[x]<rnk[y]){
            par[x]=y;
            sizes[y]+=sizes[x];
        }else{
            par[y]=x;
            sizes[x]+=sizes[y];
            if(rnk[x]==rnk[y])rnk[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return sizes[find(x)];
    }
};

int main(){
    int N,M;
    cin>>N>>M;
    UnionFind uf(N);
    REP(i,M){
        int A,B;
        cin>>A>>B;A--;B--;
        uf.unite(A,B);
    }
    set<int>st;
    REP(i,N)st.insert(uf.find(i));
    cout<<SZ(st)-1<<endl;
    return 0;
}


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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,x,i,t,s=0,m=inf,ans=0;
	cin>>n>>x;
	for (i=0;i<n;i++){
		cin>>t;
		s+=t;
		m=min(m,t);
	}
	x-=s;
	ans+=n;
	ans+=(ll)x/m;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(v) ((int)(v).size())
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 100005;

struct disj{
	int pa[MAXN];
	void init(int n){
		iota(pa, pa + n + 1, 0);
	}
	int find(int x){
		return pa[x] = (pa[x] == x ? x : find(pa[x]));
	}
	bool uni(int p, int q){
		p = find(p);
		q = find(q);
		if(p == q) return 0;
		pa[q] = p; return 1;
	}
}disj;

int n; lint m; int q;
vector<pi>v;
int main(){
	scanf("%d %lld %d",&n,&m, &q);
	disj.init(n);
	int compCnt = n;
	while(q--){
		int a, b, c;
		scanf("%d %d %d",&a,&b,&c);
		if(c == 0){
			compCnt -= disj.uni(a, b);
		}
		else{
			v.emplace_back(a, b);
		}
	}
	for(auto &i : v){
		if(disj.find(i.first) == disj.find(i.second)){
			puts("No");
			return 0;
		}
	}
	if(m == n - 1){
		if(sz(v)) puts("No");
		else puts("Yes");
		return 0;
	}
	if(compCnt == 1){
		puts("No");
		return 0;
	}
	if(compCnt == 2){
		puts("No");
		return 0;
	}
	lint st = n - 1;
	lint ed = n - compCnt + 1ll * (compCnt) * (compCnt - 1) / 2;
	if(st <= m && m <= ed){
		puts("Yes");
	}
	else puts("No");
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
#include<bitset>
 
using namespace std;
 
#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
 
 
typedef long long ll;
typedef unsigned long long int llt;
 
const int N = 5e5 + 10;
 
vector<int> g[N];
bool viss[N];
int vis[N];
 
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}
 
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}
 
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}
 
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}
 
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}
 
string ans ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += to_string(x);
     return;
}
 
llt convertback(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}
 
int main()
{
string s,ans="";
  cin>>s;
  rep(i,0,s.length())
  {
    if(s[i]=='0')
       ans+='0';
    else if(s[i]=='1')
      ans+='1';
    else
      if(ans.length()!=0)
         ans.pop_back();
  }
  cout<<ans;
  
  return 0;
}

Measured memory_bytes: 12416
import sys


def find_square(data):
    max_size = 0
    lmap = [] # dp??¨???2?¬??????????
    # '.'????????????0??????'*'????????????1????????????
    for row in data:
        temp = []
        for c in row:
            if c == '.':
                temp.append(1)
            else:
                temp.append(0)
        lmap.append(temp)

    # ????±?????????????????????????????????£????????????????????£?????¢????¢??????§??????????????§????????????
    for y in range(1, len(lmap)):
        for x in range(1, len(lmap[0])):
            if lmap[y][x] == 1:
                lmap[y][x] = min(lmap[y-1][x-1], min(lmap[y-1][x], lmap[y][x-1])) + 1
                if lmap[y][x] > max_size:
                    max_size = lmap[y][x]
    return max_size


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break
        data = [input() for _ in range(n)]
        result = find_square(data)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 35084
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define uint __int128_t
 
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
const ll MOD=1000000007,INF=1e18;

int N,M;
int dp[5050][10100];
int b[]={2,5,5,4,5,6,3,7,6};

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    //MOD同士の引き算に注意
    cin>>N>>M;
    vint a(M);
    rep(i,0,M){
        cin>>a[i];
        a[i]--;
    }
    
    rep(i,0,5050)rep(j,0,10001)dp[i][j]=-INF;
    dp[0][0]=0;
    
    rep(i,0,N/2+1){
        rep(j,0,N+1)if(dp[i][j]!=-INF){
            chmax(dp[i+1][j],dp[i][j]);
            rep(k,0,M){
                if(dp[i+1][j+b[a[k]]]<dp[i][j]+1){
                    dp[i+1][j+b[a[k]]]=dp[i][j]+1;
                }
            }
        }
    }
    
    int sz=dp[N/2][N];
    vpint v(M);
    rep(i,0,M)v[i]={a[i],b[a[i]]};
    sort(all(v),greater<>());
    
    /*rep(i,0,sz){
        rep(j,0,N+1)cout<<dp[i+1][j];
        cout<<endl;
    }*/
    
    vint ans(sz);
    int cur=N;
    rrep(i,0,sz){
        rep(j,0,M){
            if(cur-v[j].se<0)continue;
            if(dp[i+1][cur-v[j].se]==dp[i+1][cur]-1){
                ans[i]=v[j].fi;
                cur-=v[j].se;
                break;
            }
        }
    }
    
    sort(all(ans),greater<>());
    rep(i,0,(int)ans.size())cout<<ans[i]+1;
    cout<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 398848
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<limits.h>

int main(){
	char a[101], b[101], c[101];
	char *p, *pa, *pb, *pc;
	char ans = 'A';
	scanf("%s\n", a);
	scanf("%s\n", b);
	scanf("%s\n", c);
	p = a;
	pa = a+1;
	pb = b;
	pc = c;
	while(*p){
		if(*p == 'a') {
			p = pa++;
			ans = 'A';
		}
		else if(*p == 'b') {
			p = pb++;
			ans = 'B';
		}
		else {
			p = pc++;
			ans = 'C';
		}
	}
	printf("%c\n", ans);
	return 0;
}




Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 1e18
#define five 100005;
#define six 1000005;
#define prllclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
ll dp[1003][1<<13];
ll b[1003];
ll n,m;
ll a[1003];
ll f(ll i,ll msk)
{
       if(i==m){
              if(msk == (1<<n)-1){
                     return 0;
              }
              return inf;
       }
       if(dp[i][msk] != -1){
              return dp[i][msk];
       }
       return dp[i][msk] = min(f(i+1,msk),f(i+1,msk | b[i])+a[i]);
}
int main()
{
       cin>>n>>m;
       fri(i,0,m){
              cin>>a[i];
              b[i] = 0;
              ll xx;
              cin>>xx;
              fri(j,0,xx){
                     ll yy;
                     cin>>yy;
                     --yy;
                     b[i] |= (1<<yy);
              }
       }
       memset(dp,-1,sizeof dp);
       if(f(0,0)>=inf){
              cout<<-1<<endl;
       }
       else{
              cout<<f(0,0)<<endl;
       }

}


Measured memory_bytes: 64512
import java.util.*;

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

		int n=sc.nextInt();
		Map <Integer,Integer> map=new TreeMap<>();
		for(int i=1;i<=n;i++){
			map.put(sc.nextInt(),i);
		}

		for(int i=1;i<=n;i++){
			System.out.print(map.get(i)+" ");
		}

	}
}


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

int main(){
    int N, arr[100];
    while(scanf("%d", &N) != EOF && N != 0){
        for(int i = 0; i < N; i++){
            scanf("%d", arr+i);
        }
        sort(arr, arr + N);
        int s = 0;
        for(int i = 1; i < N-1; i++){
            s += arr[i]; 
        }
        printf("%d\n", s / (N-2));
    }
    return 0; 
}

Measured memory_bytes: 1204
N = int(input())
A = [int(x) for x in input().split()]

L = dict(); R = dict()
for i in range(N):
    l = i + A[i]
    if l in L:
        L[l] += 1
    else:
        L[l] = 1
    r = i - A[i]
    if r in R:
        R[r] += 1
    else:
        R[r] = 1

ans = 0
for x in R:
    if x in L:
        ans += L[x] * R[x]

print(ans)

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


int main(){
  long long n,i;
  cin >> n;
  vector<long long> a(3*n);
  for(i=0;i<3*n;++i){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  long long ans=0;
  for(i=n*3-2;i>=n;i=i-2){
    ans=ans+a[i];
  }
  cout << ans << endl;
  return 0;

}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}
 
int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  
  int ans;
  if(A+B<2*C){
    ans=A*X+B*Y;
  }
  else{
    ans=min(X,Y)*C*2;
    int Z=min(X,Y);
    X-=Z;
    Y-=Z;
    if(Y==0){
      if(A<2*C) ans+=A*X;
      else ans+=X*C*2;
    }
    if(X==0){
      if(B<2*C) ans+=B*Y;
      else ans+=Y*C*2;
    }
  }
  cout<<ans<<endl;
}
  



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int sum = 0;
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int s = Integer.parseInt(sc.next());
            sum += s;
            if (s % 10 != 0) {
                list.add(s);
            }
        }
        if (sum % 10 != 0) {
            System.out.println(sum);
            return;
        } else if (list.size() == 0) {
            System.out.println(0);
            return;
        }
        Collections.sort(list);
        for (int i = 0; i < list.size(); i++) {
            sum -= list.get(i);
            if (sum % 10 != 0) {
                break;
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int k,a,b,day[101],n, memo[101][4][4];
int dfs(int j,int d1,int d2);
int main(){
  cin >> n >> k;
  fill(day,day+101,0);
  memset(memo,-1,sizeof(memo));
  for(int i=0;i<k;i++){
    cin >> a >> b;
    day[a] = b;
  }
  cout << dfs(1,0,0) << endl;
  return (0);
}

int dfs(int j,int d1,int d2){
  int ret = 0;
  if(j == n+1) return 1;
  if(memo[j][d1][d2] != -1) return memo[j][d1][d2];
  else if(day[j] != 0){
    if(d1!=d2||d2!=day[j]) ret += dfs(j+1,d2,day[j]);
  }
  else {
    for(int i=1;i<=3;i++){
      if(d1!=d2||d2!=i) ret += dfs(j+1,d2,i);
    }
  }
  return memo[j][d1][d2] = ret%10000;
}

Measured memory_bytes: 3040
use proconio::{input, fastout};
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        n: usize,
        k: usize,
        mut h: [usize;n],
    }

    h.sort();
    let mut sub: Vec<usize> = Vec::new();
    for i in 0..n-k+1 {
        sub.push(h[k+i-1]-h[i]);
    }
    sub.sort();
    println!("{}", sub[0]);

}


Measured memory_bytes: 4848
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 

int main(){
    fastio
    ll x , y , z , k ; 
    cin >> x >> y >> z >> k; 
    vector<ll> a(x) , b(y) , c(z) ; 
    for(ll &p : a){
    	cin >> p ; 
    }
    for(ll &p : b){
    	cin >> p ; 
    }
    for(ll &p : c){
    	cin >> p ; 
    }
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    sort(c.rbegin(),c.rend());
    vector<ll> ans ; 
    for(ll i=0;i<x;i++){
    	for(ll j=0;j<y;j++){
    		for(ll t=0;t<z;t++){
    			if ( i * j * t <= k ) ans.push_back(a[i]+b[j]+c[t]);
    			else break;
    		}
    	}
    }
    sort(ans.rbegin(),ans.rend());
    for(ll i=0;i<k;i++){
    	cout << ans[i] << endl;
    }
    cout << endl;
    return 0 ;
}


Measured memory_bytes: 35176
import java.util.*;

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

        /** 解毒入り美味しくないクッキー */
        int a = sc.nextInt();

        /** 解毒入り美味しいクッキー */
        int b = sc.nextInt();

        /** 毒入り美味しいクッキー */
        int c = sc.nextInt();

        int sum = 0;

        // まずは毒入りクッキーと解毒入りのクッキー交互に食べる
        while (b != 0 && c != 0) {
            sum += 2;
            b--;
            c--;
        }

        /**
         * どちらか一方がなくなったら 毒入りが余っている場合は、美味しくないクッキーと一緒に食べる
         * 解毒入り美味しくないクッキーが余っていたら、あまりを合計に追加して終了
         */
        if (b > 0) {
            sum += b;
            System.out.println(sum);
            return;
        } else if (c > 0) {
            while (a != 0 && c != 0) {
                sum += 1;
                a--;
                c--;
            }

            // 最後に毒入りで終了するのはありなので 余っている場合は合計にプラスする
            if (c > 0) {
                sum++;
            }

            System.out.println(sum);

        } else {
            // どちらも残っていない(美味しいクッキーがもうない)場合は終了
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 21972
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	N := nextInt()

	x0 := math.MaxInt32
	x1 := math.MinInt32
	y0 := math.MaxInt32
	y1 := math.MinInt32

	for i := 0; i < N; i++ {
		x := nextInt()
		y := nextInt()

		xx := x - y
		yy := x + y

		x0 = min(x0, xx)
		x1 = max(x1, xx)
		y0 = min(y0, yy)
		y1 = max(y1, yy)
	}

	fmt.Println(max(abs(x0-x1), abs(y0-y1)))
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}

func debug(args ...interface{}) {
	fmt.Fprintln(os.Stderr, args...)
}


Measured memory_bytes: 6180
use std::io;

fn get_line() -> String {
  let mut line = String::new();
  io::stdin()
    .read_line(&mut line)
    .unwrap();
  line
}

fn line_to_vec_usize(line: &str) -> Vec<usize> {
  line
    .trim()
    .split_whitespace()
    .map(|val| { val.parse::<usize>().unwrap() })
    .collect()
}

fn main() {
  loop {
    let v = line_to_vec_usize(&get_line());
    let (h, w) = (v[0], v[1]);
    if h == 0 && w == 0 {
      break;
    }
    for i in 0..h {
      let base = (if i % 2 == 0 { "#." } else { ".#" }).to_string();
      let line = base.repeat((w + 1) / 2);
      println!("{}", &line[..w]);
    }
    println!();
  }
}



Measured memory_bytes: 5024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ky112233
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BCanYouSolveThis solver = new BCanYouSolveThis();
        solver.solve(1, in, out);
        out.close();
    }

    static class BCanYouSolveThis {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int c = in.nextInt();
            int[] b = new int[m];
            for (int i = 0; i < m; i++) b[i] = in.nextInt();
            int[][] a = new int[n][m];
            for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) a[i][j] = in.nextInt();
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                int sum = c;
                for (int j = 0; j < m; j++) {
                    sum += a[i][j] * b[j];
                }
                if (sum > 0) cnt++;
            }
            out.println(cnt);
        }

    }
}



Measured memory_bytes: 23124
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<climits>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

int main(){
    int a;
    cin>>a;
    cout<<3*a*a<<endl;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
using namespace std;
 
int main(void){
  string S;
  cin >> S;
  int L=S.length();
  int ans=L;
  rep(i,L){
    if(S[i]=='A') break;
    else ans--;
  }
  reprev(i,L){
    if(S[i]=='Z') break;
    else ans--;
  }
  cout << ans << endl;
}

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

bool solve(int N) {
  for (int i = 0; i < 50; ++i) {
    for (int j = 0; j < 50; ++j) {
      if (i * 4 + j * 7 == N) return true;
    }
  }
  return false;
}

int main() {
  int N; cin >> N;
  cout << ( (solve(N)) ? "Yes" : "No" ) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = ni();
        Map<Long, Integer> numCount = new TreeMap<>();

        for (int i = 0; i < N; i++) {
            long A = nl();

            if (numCount.containsKey(A)) {
                numCount.put(A, numCount.get(A) + 1);
            } else {
                numCount.put(A, 1);
            }
        }

        // 2^31 = 2_147_483_648
        int ans = 0;
        for (int i = 31; i >= 0; i--) {
            long sum = (long) Math.pow(2, i);
            for (Map.Entry map : numCount.entrySet()) {
                long A = (long) map.getKey();
                int numA = (int) map.getValue();

                long _A = sum - A;
                int num_A;
                if (numCount.containsKey(_A)) {
                    num_A = (int) numCount.get(_A);
                } else {
                    continue;
                }

                if (A != _A) {
                    int num = Math.min(numA, num_A);
                    ans += num;
                    numCount.put(A, numA - num);
                    numCount.put(_A, num_A - num);
                } else {
                    int num = numA / 2;
                    ans += num;
                    numCount.put(A, numA - num);
                }
            }
        }

        out.println(ans);
    }

    static int ni() {
        return sc.nextInt();
    }

    static long nl() {
        return sc.nextLong();
    }

    static String ns() {
        return sc.next();
    }

    static int[] niarr(int N) {
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }
        return a;
    }

    static long[] nlarr(int N) {
        long[] a = new long[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextLong();
        }
        return a;
    }
}

Measured memory_bytes: 146836