akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 2000005

ll r1,c1,r2,c2;
ll fact[SIZE],inv_fact[SIZE];

ll mod_pow(ll x,ll count, ll mod){

	if(count == 0)return 1;
	ll ret = mod_pow((x*x)%mod,count/2,mod);
	if(count%2 == 1){

		ret = (ret*x)%mod;
	}
	return ret;
}

ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d = a;
	if(b != 0){
		d = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

ll nCk(ll n,ll k){

	ll ret = fact[n]*inv_fact[k];
	ret %= MOD;
	ret *= inv_fact[n-k];

	return ret%MOD;
}


int main(){

	fact[0] = 1;
	for(ll i = 1; i < SIZE; i++){
		fact[i] = i*fact[i-1];
		fact[i] %= MOD;
	}
	inv_fact[SIZE-1] = mod_inverse(fact[SIZE-1],MOD);
	for(ll i = SIZE-1; i >= 1; i--){

		inv_fact[i-1] = inv_fact[i]*i;
		inv_fact[i-1] %= MOD;
	}

	scanf("%lld %lld %lld %lld",&r1,&c1,&r2,&c2);

	ll ans = 0;
	for(ll i = c1; i <= c2; i++){

		ll tmp = nCk((r2+i+1),i+1);

		tmp -= nCk((r1+i),i+1);

		if(tmp < 0){

			tmp += MOD;
		}
		ans += tmp;
		ans %= MOD;
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
#define faster() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'
int main()
{
    faster();
    int n;
    cin>>n;
    int a;
    map<int, int > mp;
    for(int i=0;i<n;i++){
        cin>>a;
        mp[a]++;
    }
    int ans=0;
    for(auto u : mp){
        if(u.second >= u.first) ans += (u.second - u.first);
        else ans += u.second;
    }
    cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 8016
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#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 << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = 1e9+7;
const int nax = 2 * 1e5 + 5;
ll dwa[nax];
map<pair<ll, ll>, int> zlicz;

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	scanf("%d", &n);
	dwa[0] = 1;
	rep(i,1, nax) {
		dwa[i] = (dwa[i - 1] * 2) % mod;
	}
	// int d1 = 0, d2 = 0;
	// vector<P> gora, dol;
	int zz = 0;
	int y0=0;
	int x0=0;
	rep(i,0,n) {
		ll x, y;
		scanf("%lld %lld", &x, &y);
		if (y < 0) {
			x *= -1;
			y *= -1;
		}
		if (x == 0 && y == 0) {
			++zz;
		} else if(y == 0) {
			++y0;
		} else if (x ==0){
			++x0;
		} else {
			ll nwd = gcd(abs(x), y);
			ll nx = x / nwd, ny = y / nwd;
			++zlicz[mp(x / nwd, y / nwd)];
			if (nx < 0) {
				ll opx = ny, opy = -nx;
				if (zlicz.find(mp(opx, opy)) == zlicz.end()) {
					zlicz[mp(opx, opy)] = 0;
				}
			}
		}
	}
	ll res = ((dwa[x0] + dwa[y0] - 1)) % mod;
	// printf("x0: %d, y0: %d, res: %lld\n", x0, y0, res);
	for (auto xx : zlicz) {
		if (xx.st.st < 0) {
			continue;
		}
		ll curr = xx.nd;
		ll drug = zlicz[mp(-xx.st.nd , xx.st.st)];
		ll mnoz = ((dwa[curr] + dwa[drug] -1)) % mod;
		// printf("dla: %lld/%lld - %lld x %lld, mnoz: %lld\n", xx.st.st, xx.st.nd, curr, drug, mnoz);
		res = (res * mnoz) % mod;
	}
	cout << (res - 1 + zz + mod) % mod << endl;
}

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

int d[100], a[100];
map<vector<int>, int>id;
map<int, vector<int>>re;
int dp[100][5040];

int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d", &d[i]);
	rep(i, n)scanf("%d", &a[i]);
	vector<int>v(7); iota(v.begin(), v.end(), 0);
	int p = 0;
	do {
		id[v] = p; re[p] = v;
		int cnt = 0, t = 0;
		for (int i : v) {
			rep(j, 7) {
				if ((t >> j & 1) && abs(j - i) <= d[j])cnt += a[j];
			}
			t |= 1 << i;
		}
		dp[0][p] = cnt;
		p++;
	} while (next_permutation(v.begin(), v.end()));
	int ans = 0;
	for (int i = 1; i + 6 < n; i++)rep(j, 5040) {
		rep(k, 8) {
			auto t = re[j].begin();
			int cnt = 0, p = 0, o = 0;
			vector<int>q(7);
			rep(l, 8) {
				if (k == l) {
					rep(y, 8) {
						if ((p >> y & 1) && y + d[i - 1 + y] >= 7)
							cnt += a[i - 1 + y];
					}
					p |= 1 << 7; q[o++] = 6;
				}
				else {
					if ((p >> 7 & 1) && 7 - d[i + 6] <= *t)cnt += a[i + 6];
					p |= 1 << *t;
					if (*t)q[o++] = *t - 1;
					t++;
				}
			}
			int v = id[q];
			dp[i][v] = max(dp[i][v], dp[i - 1][j] + cnt);
			ans = max(ans, dp[i][v]);
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 6384
#include<stdio.h>
#include<stdlib.h>
#include<math.h>


int main(void){
	int N,i,ans(0);
	scanf("%d",&N);
	int P[N];
	for(i = 0 ; i < N ; i ++){
		scanf("%d",&P[i]);
		if(P[i] != i + 1) ans ++;
	}
	if(ans <= 2){
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}


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

using namespace std;
using ll =long long;
using db = double;

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; }

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;

//ここから書き始める
int main()
{
	cout << setprecision(10);
	ll n, k;
	cin >> n >> k;
	vector<ll> h(110010);
	rep(i,n) cin >> h[i];

	vector<ll> dp(110010,INF);
	dp[0] = 0;
	rep(i,n){
		For(j,1,k+1){
			chmin(dp[i+j],dp[i]+abs(h[i] - h[i+j]));
		}
	}
	
	
	cout<<dp[n-1]<<endl;

}


Measured memory_bytes: 1920
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<deque>
#include<cctype>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
#define REP(i,b,e) for(int i=b;i<(int)e;i++)
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
typedef string::const_iterator State;
ll inf = 10e17;


ll A[200002];
ll N;

int main(){
    cin>>N;
    Rep(i,N){
        cin>>A[i];
    }
    Rep(i,N){
        A[i]=A[i]-i;
    }
    sort(A,A+N);
    ll ans=0;
    if(N%2==0){
        Rep(i,N){
            ans+=abs(A[i]-A[N/2-1]);
        }
    }
    else{
        ll p,q;
      p=q=0;
        Rep(i,N){
          ans+=abs(A[i]-A[N/2]);
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

int main()
{
	string s;
	cin >> s;
	int N = s.size();
	string ss = "";
	for (int i = 0; i < N; i += 2) {
		ss = ss + s[i];
	}
	cout << ss << endl;
}

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

int N;

stack<int> G[MAX_N];

int ans[MAX_N];

int main(){
  cin>>N;
  for(int i=1;i<=N;i++){
    int x;
    cin>>x;
    G[x].push(i);
  }
  stack<int> Q;
  for(int i=1;i<=N;i++){
    while(!G[i].empty()){
      Q.push(G[i].top());
      G[i].pop();
    }
    if(ans[i]==0 && !Q.empty()){
      ans[i]=Q.top();
      Q.pop();
    }
  }
  for(int i=1;i<=N;i++){
    if(ans[i]==0){
      ans[i]=Q.top();
      Q.pop();
    }
  }
  for(int i=1;i<=N;i++){
    cout<<ans[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 70972
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class B
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (N, K) = Scanner.Scan<int, int>();
            var P = Scanner.ScanEnumerable<int>().ToArray();
            Console.WriteLine(P.OrderBy(x => x).Take(K).Sum());
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28768
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

ll arr[300000];
ll val[100001];
int main() {
	cin >> N;
	rep(i, 3 * N) {
		cin >> arr[i];
	}

	priority_queue<ll, vector<ll>, greater<ll>> que_a;
	ll sum = 0;
	rep(i, N) {
		que_a.push(arr[i]);
		sum += arr[i];
	}
	val[0] = sum;
	rep(i, N) {
		sum += arr[N + i];
		que_a.push(arr[N + i]);
		sum -= que_a.top();
		que_a.pop();
		val[i + 1] = sum;
	}

	priority_queue<ll> que_b;
	sum = 0;
	rep(i, N) {
		que_b.push(arr[2 * N + i]);
		sum += arr[2 * N + i];
	}
	ll maxv = val[N] - sum;
	for (int i = N - 1; i >= 0; i--) {
		sum += arr[N + i];
		que_b.push(arr[N + i]);
		sum -= que_b.top();
		que_b.pop();
		maxv = max(maxv, val[i] - sum);
	}
	cout << maxv;
}

Measured memory_bytes: 5748
#include <iostream>
using namespace std;
int main(){
  int n,sum=0;
  cin >> n;
  for(int i=1;i<=n;i++){
    if(i<10)sum++;
    if(100<=i && i<1000)sum++;
    if(10000<=i && i<100000)sum++;
  }
  cout << sum << endl;
  return 0;
}

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

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            
            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            long result = 0;
            if(n < 10)
            {
                result = n;
            }
            else
            {
                for (long i = 0; i <= n; i++)
                {
                    result += Count(i);
                }
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }

        public static long Count(long n)
        {
            string str = n.ToString();
            if(str.EndsWith("0"))
            {
                return 0; //0で終わっている数は、解がゼロ
            }

            long result = 0;

            // 左側がn (a...z) の場合、右側は(z...a)になる

            if(str[0] == str[str.Length - 1])
            {
                //最初と最後が同じ場合、その数字1桁のものがOKになる
                result = 1;
            }
            for(int i = 2; i < str.Length; i++) //nと桁数と同じ場合、途中からnを超える場合があるので、別で計算
            {
                //i桁の場合を数える (10^桁数-2)
                result += (long)Math.Pow(10, i - 2);
            }

            //右側の個数は、10^桁数-2
            //ただし、nを超えてしまうとアウトなので、その検出
            long max = long.Parse(str[str.Length - 1].ToString().PadRight(str.Length - 1, '9') + str[0]); //最大の値
            long min = long.Parse(str[str.Length - 1].ToString().PadRight(str.Length - 1, '0') + str[0]); //最大の値
            if(n < min)
            {
            }
            else if(max <= n)
            {
                result += (long)Math.Pow(10, str.Length - 2);
            }
            else
            {
                long diff = long.Parse(str.Substring(1, str.Length - 2));
                result += diff + 1;
            }

            //左右入れ替えたパターンを含めるので、二倍にする
            result *= 2;

            //入れ替えられないパターンを除外
            if (str[0] == str[str.Length - 1])
            {
                result--;
            }

            //Console.WriteLine(n + " : " + result);

            return result;
        }
    }
}


Measured memory_bytes: 15440
#include <iostream>
#include <iomanip>
#include <queue>
#include <deque>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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;
}

using namespace std;
using ll = long long;

const int kInf = 2e9;
const ll kLInf = 2e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int N;
int a[200010];
int main()
{
   cout << fixed << setprecision(10);
   cin >> N;
   REP(i, N) cin >> a[i];
   int nBreak = 0;
   int cnt = 1;
   REP(i, N) {
      if (a[i] == cnt) {
         cnt++;
      } else {
         nBreak++;
      }
   }
   if (nBreak == N) {
      cout << -1 << endl;
   } else {
      cout << nBreak << endl;
   }
      
   return 0;
}



Measured memory_bytes: 1024
answer = 0

while line = gets
  strings = line.chomp.split('')

  is_palindrome = true
  for i in 0..(strings.size / 2 - 1)
    if strings[i] != strings[(i + 1) * -1]
      is_palindrome = false
      break
    end
  end

  answer += 1 if is_palindrome
end

puts answer

Measured memory_bytes: 8608
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
	ll dp[3002][3002];
int main()
{
	string s,t;
	cin>>s>>t;
	ll n1=s.length();
	ll n2=t.length();
	for (ll i=0;i<=n1;i++)
		dp[i][0]=0;
	for (ll i=0;i<=n2;i++)
		dp[0][i]=0;
	for (ll i=1;i<=n1;i++)
	{
		for (ll j=1;j<=n2;j++)
		{
			if (s[i-1]==t[j-1])
			{
				dp[i][j]=1+dp[i-1][j-1];
			}
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	// for (ll i=1;i<=n1;i++)
	// {
	// 	for (ll j=1;j<=n2;j++)
	// 	{
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	ll i=n1;
	ll j=n2;
	stack <char> ans;
	while (i>=1&&j>=1)
	{
		if (s[i-1]==t[j-1])
		{
			ans.push(s[i-1]);
			i--;
			j--;
		}
		else
		{
			if (dp[i-1][j]>dp[i][j-1])
			{
				i--;
			}
			else
				j--;
		}
	}
	while (!ans.empty())
	{
		cout<<ans.top();
		ans.pop();
	}
	//cout<<dp[n1][n2];
}

Measured memory_bytes: 70656
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N, Q; cin >> N >> Q;
    string S, k; cin >> k;
    S = "0" + k + "0";
    string T, D;
    for(int i=0; i<Q; i++){
        char t, d; cin >> t >> d;
        T += t;
        D += d;
    }
    
    int L = 1;
    int R = N;
    for(int i=Q-1; i>=0; i--){
        int nl = L;
        int nr = R;
        if(S[nl]==T[i] && D[i]=='L') L++;
        if(S[nl-1]==T[i] && D[i]=='R') L--;
        if(S[nr]==T[i] && D[i]=='R') R--;
        if(S[nr+1]==T[i] && D[i]=='L') R++;
    }
    cout << max(R - L + 1, 0) << endl;
    return 0;
}



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


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin>>s;
  int zero=0, one=0;
  rep (i, s.size()){
    if(s.at(i)=='0') zero++;
    else one++;
  }
  int ans;
  if(one<=zero){
    ans=2*one;
  }
  else ans=2*zero;
  cout<<ans<<endl;
}

Measured memory_bytes: 3772
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] inputs = br.readLine().split(" ");
		int n = Integer.parseInt(inputs[0]);
		int m = Integer.parseInt(inputs[1]);

		PriorityQueue<Integer> a = new PriorityQueue<>();
		int[][] bc = new int[m][2];

		inputs = br.readLine().split(" ");
		for ( int i = 0; i < n; i++ ) {
			a.add(Integer.parseInt(inputs[i]));
		}

		for ( int i = 0; i < m; i++ ) {
			inputs = br.readLine().split(" ");
			bc[i][0] = Integer.parseInt(inputs[0]);
			bc[i][1] = Integer.parseInt(inputs[1]);
		}
		br.close();

		Arrays.sort(bc, new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				return o2[1] - o1[1];
			}
		});

		for ( int i = 0; i < m; i++ ) {
			while ( !a.isEmpty() && a.peek() < bc[i][1] && 0 < bc[i][0] ) {
				a.poll();
				a.add(bc[i][1]);
				bc[i][0]--;
			}
		}
		
		long ans = 0L;
		for ( Integer i : a ) {
			ans += i;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 66240
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int to, cost; };

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

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const map<T1,T2>& m) {
   s << "{";
   for (auto i = m.begin(); i != m.end(); ++i) {
      s << i->first << ":" << i->second;
      if (next(i) != m.end()) s << ", ";
   }
   s << "}";
   return s;
}

int powM(int x, int n) {
   int res = 1;
   while (n > 0) {
      if ((n & 1) == 1) {
         res = mod(res * x);
      }
      x = mod(x * x);
      n >>= 1;
   }
   return res;
}

int get(int k, int i) {
   return (k / powM(4,i)) % 4;
}

int num(int k) {
   int res = 0;
   rep(i, 0, 9) {
      switch (get(k, i)) {
         case 1:
            res += 3 * powM(10,i);
            break;
         case 2:
            res += 5 * powM(10,i);
            break;
         case 3:
            res += 7 * powM(10,i);
            break;
      }
   }
   return res;
}


signed main()
{
   int N; cin >> N;

   int ans = 0;
   bool flag;
   rep(k, 0, powM(4,9)) {
      flag = false;
      rep(i, 0, 9) {
         if (get(k, i) == 1) flag = true;
      }
      if (!flag) continue;

      flag = false;
      rep(i, 0, 9) {
         if (get(k, i) == 2) flag = true;
      }
      if (!flag) continue;

      flag = false;
      rep(i, 0, 9) {
         if (get(k, i) == 3) flag = true;
      }
      if (!flag) continue;

      flag = true;
      rep(i, 1, 9) {
         if (get(k, i-1) == 0 && get(k, i) != 0)
            flag = false;
      }
      if (!flag) continue;

      if (num(k) <= N) ans++;
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 256
from math import ceil
 
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    def is_ok(arg):
    # 条件を満たすかどうか？問題ごとに定義
        B = [int(ceil(a/arg))-1 for a in A]
        #print(arg, B)
        if sum(B) <= K:
            return True
        else:
            return False
 
    def meguru_bisect(ng, ok):
        '''
        初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
        まずis_okを定義すべし
        ng ok は  とり得る最小の値-1 とり得る最大の値+1
        最大最小が逆の場合はよしなにひっくり返す
        '''
        while (abs(ok - ng) > 1):
            mid = (ok + ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok
    
    ans = meguru_bisect(0, int(1e9))
    print(ans)
 
if __name__ == "__main__":
    main()

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

using vb=vector<bool>;
using vi=vector<int>;
using vvi=vector<vi>;
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vl>;
using si=set<int>;
using qi=queue<int>;
using pi=pair<int,int>;

void solve() {
    int n,k; cin>>n>>k;
    vb has(n+1, false);
    for(int i=0;i<k;i++){
        int d; cin>>d;
        for(int j=0;j<d;j++){
            int a; cin>>a;
            has[a]=true;
        }
    }
    int db=0;
    for(int i=1;i<=n;i++){
        if(!has[i]){
            db++;
        }
    }
    cout<<db<<endl;
}

bool boosts=false, tests=false;

int main() {
    if(boosts) {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    int tcases=1;
    if(tests) {
        cin>>tcases;
    }
    for(int tcase=1; tcase<=tcases; tcase++) {
        solve();
    }

    return 0;
}


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

public class Main{

	static PrintWriter out;
	static InputReader ir;

	static void solve(){
		while(true){
			int m=ir.nextInt();
			if(m==0) break;
			int mi=ir.nextInt();
			int ma=ir.nextInt();
			int g=-1;
			int[] p=ir.nextIntArray(m);
			int ans=mi;
			for(int i=mi;i<=ma;i++){
				int tmp=p[i-1]-p[i];
				if(g<=tmp){
					g=tmp;
					ans=i;
				}
			}
			out.println(ans);
		}
	}

	public static void main(String[] args) throws Exception{
		ir=new InputReader(System.in);
		out=new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer=new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}

		public boolean hasNextByte() {
			if(curbuf>=lenbuf){
				curbuf= 0;
				try{
					lenbuf=in.read(buffer);
				}catch(IOException e) {
					throw new InputMismatchException();
				}
				if(lenbuf<=0) return false;
			}
			return true;
		}

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

		private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}

		private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}

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

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

		public int nextInt() {
			if(!hasNext()) throw new NoSuchElementException();
			int c=readByte();
			while (isSpaceChar(c)) c=readByte();
			boolean minus=false;
			if (c=='-') {
				minus=true;
				c=readByte();
			}
			int res=0;
			do{
				if(c<'0'||c>'9') throw new InputMismatchException();
				res=res*10+c-'0';
				c=readByte();
			}while(!isSpaceChar(c));
			return (minus)?-res:res;
		}

		public long nextLong() {
			if(!hasNext()) throw new NoSuchElementException();
			int c=readByte();
			while (isSpaceChar(c)) c=readByte();
			boolean minus=false;
			if (c=='-') {
				minus=true;
				c=readByte();
			}
			long res = 0;
			do{
				if(c<'0'||c>'9') throw new InputMismatchException();
				res=res*10+c-'0';
				c=readByte();
			}while(!isSpaceChar(c));
			return (minus)?-res:res;
		}

		public double nextDouble(){return Double.parseDouble(next());}

		public int[] nextIntArray(int n){
			int[] a=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		}

		public long[] nextLongArray(int n){
			long[] a=new long[n];
			for(int i=0;i<n;i++) a[i]=nextLong();
			return a;
		}

		public char[][] nextCharMap(int n,int m){
			char[][] map=new char[n][m];
			for(int i=0;i<n;i++) map[i]=next().toCharArray();
			return map;
		}
	}
}

Measured memory_bytes: 25532
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define t ll t;cin>>t;while(t--)
#define nn cout<<endl;
int main()
{
	ll n; cin>>n;
	string s;
	cin>>s;
	ll mv=1;
	for(ll i=1;i<n;i++)
	{
		if(s[i]!=s[i-1]) mv++;
	}
	cout<<mv<<endl;
	
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
#define N 100005
char s[N],a[N];
long long ans;
int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1),len2=0;
	for(int i=1;i<=len;i++)
	if(s[i]!='x')a[++len2]=s[i];
	for(int i=1;i<=len2/2;i++)
	  if(a[i]!=a[len2-i+1]) return printf("-1"),0;
	if(!len2) return printf("0"),0;
	int tot=0,pos;
	for(int i=1;i<=len;i++)
	{
		if(s[i]!='x') tot++;
		if(tot==len2/2+(len2&1)){pos=i;break;}
	}
	int x=pos,y=pos;
	if(~len2&1)
	{
		y++;
		while(s[y]=='x') y++;
	}
	while(x&&y<=len)
	{
		if(s[x]==s[y]) x--,y++;
		else if(s[x]=='x') x--,ans++;
		else y++,ans++;
	}
	if(x) ans+=x;
	else if(y<=len) ans+=len-y+1;
	printf("%lld",ans);
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <unordered_set>
#include <algorithm>

using namespace std;

template <int base>
int digit_sum(int n)
{
	int sum = 0;
	while (n > 0) {
		sum += n % base;
		n /= base;
	}
	return sum;
}

using ivec = vector<int>;

ivec read_int_args()
{
	int N;
	cin >> N;
	ivec v(N);
	for (auto& e : v) {
		cin >> e;
	}
	return v;
}

int compar(const void * b, const void* a)
{
	return (*(int*)a - *(int*)b );
}

int main()
{
	string S;
	cin >> S;
	if (S == "Sunny")
		cout << "Cloudy" << endl;
	else if (S == "Cloudy")
		cout << "Rainy" << endl;
	else
		cout << "Sunny" << endl;
	
	return 0;
}


Measured memory_bytes: 888
import sys
S = input().strip()
T = input().strip()


def comp(s, t):
    for i in range(len(t)):
        if s[i] != "?" and s[i] != t[i]:
            return False
    return True


ans = "UNRESTORABLE"
for i in range(len(S)-len(T), -1, -1):
    s = S[i:i+len(T)]
    if comp(s, T):
        S = S[:i] + T + S[i+len(T):]
        for i in range(len(S)):
            if S[i] == "?":
                S = S[:i] + "a" + S[i+1:]
        print(S)
        sys.exit(0)

print(ans)


Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// use std::io::{stdout, Write, BufWriter};
use std::cmp::{max};

fn main() {
    input! {
        _n: i32,
        m: usize,
        lr: [(i32, i32); m],
    }
    let (l, r): (Vec<i32>, Vec<i32>) = lr.into_iter().unzip();
    println!("{}", max(r.iter().min().unwrap() - l.iter().max().unwrap() + 1, 0))
}


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

int main(){
    long long a, b, av, bv, t, v;
    unsigned long long x, rx;
    cin >> a >> av >> b >> bv >> t;
    x = abs(b - a);
    if (av <= bv) {
     cout << "NO";
     return 0;
   }
    v = av - bv;
    rx = v * t;
    if (x <= rx){
      cout << "YES";
    } else {
      cout << "NO";
    }
  return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Y = sc.nextInt();
		
		int sum = 0;
		int a = 0;
		
		loop:
		for(int i = 0; i <= N; i++) {
			for(int j = 0; j <= N; j++) {
				for(int k = 0; k <= N; k++) {
					sum = 10000 * k + 5000 * j + 1000 * i;
					if((k + j + i) == N && sum == Y) {
						System.out.println(k + " " + j + " " + i);
						a++;
						break loop;
					} else if(sum > Y || (k + j + i) > N) {
						break;
					}
				}
			}
		}
		if(a == 0) {
			System.out.println(-1 + " " + -1 + " " + -1);
		}
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
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; }

int main() {

    ll N, Q;
    cin >> N >> Q;
    
    string S;
    cin >> S;

    vector<ll> F(N + 1), B(N + 1);
    ll tmp = 0, total;

    rep(i, N - 1) {
        if (S[i] == 'A' && S[i + 1] == 'C') {
            tmp++;
        }
        F[i + 2] = tmp;
    }

    total = tmp;
    tmp = 0;

    for (ll i = N - 1; i >= 1; i--) {
        if (S[i - 1] == 'A' && S[i] == 'C') {
            tmp++;
        }
        B[i] = tmp;
    }

    vector<ll> ans(Q);
    ll x, y;

    rep(i, Q) {
        cin >> x >> y;
        ans[i] = total - B[y] - F[x];
    }

    rep(i, Q) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 5844
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n){
        long long int result[21][2] = {0};
        int input, x, y;
        rep(i, n-1){
            cin >> input;
            if(i == 0){
                result[input][0]+=1;
            }else{
                y = i % 2;
                x = (i + 1) % 2;
                rep(j,21){
                    if(result[j][x] != 0){
                        if(j + input <= 20){
                            result[j + input][y]+= result[j][x];
                        }
                        if(j - input >= 0){
                            result[j - input][y]+= result[j][x];
                        }
                        result[j][x] = 0;
                    }
                }
            }
        }
        cin >> input;
        cout << result[input][n % 2] << endl;
    }
}

Measured memory_bytes: 1156
#include<stdio.h>

int main()
{
    int K, N, i, sum = 0;
    int x[100];

    
    scanf("%d", &N);
    scanf("%d", &K);
    for(i = 0; i < N; i++)
    {
        scanf("%d", &x[i]);
    }

    for(i = 0; i < N; i++)
    {
        if(x[i] < K -x[i])
        {
            sum += 2 * x[i];
        }
        else
        {
            sum += 2 * (K - x[i]);
        }
    }

    printf("%d", sum);
}




Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


const int mod=1000000007;
//const int mod=998244353;



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r;
    cin >> n;
    vector<long double> p(n+1);
    for(int i=1 ;i<=n; i++){
        cin >> p[i];
    }
    long double dp[n+1][n+1];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=1; i<=n; i++){
        dp[i][0]=dp[i-1][0]*(1-p[i]);
        for(int j=1; j<=n; j++){
            dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
        }
    }
    long double ans=0;
    for(int i=(int)n/2+1; i<=n; i++){
        ans+=dp[n][i];
    }
    cout << setprecision(20) ;
    cout << ans << el;
    
    return 0;
}


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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N), d(N+1);
    rep(i, 0, N) cin >> A[i];
    d[0] = abs(A[0]);
    rep(i, 1, N){
        d[i] = abs(A[i] - A[i-1]);
    }
    d[N] = abs(A[N-1]);
    ll sum = accumulate(d.begin(), d.end(), 0);

    cout << sum - d[0] - d[1] + abs(A[1]) << endl;
    rep(i, 1, N-1){
        ll ans = sum - d[i] - d[i+1];
        ans += abs(A[i+1] - A[i-1]);
        cout << ans << endl;
    } 
    cout << sum -d[N-1] - d[N] + abs(A[N-2]) << endl;
    return 0;
}

Measured memory_bytes: 2816
<?php
fscanf(STDIN, "%d %d %d", $A, $B, $C);

$list = [$A, $B, $C];
sort($list);

$ans = 0;

// 一番低いのを一番高くする-1まで操作する(対象に2増やす)
function add2(&$list, &$ans, $minIdx, $maxIdx) {
	$diff = $list[$maxIdx] - $list[$minIdx];

	if($diff > 1) {
		$wk = intval($diff / 2);
		$ans += $wk;
		$list[$minIdx] += ($wk * 2);
	}
}

add2($list, $ans, 0, 2);
add2($list, $ans, 1, 2);

// 全一致
if($list[0] == $list[2] && $list[1] == $list[2]) {
}
else if($list[0] == $list[1]) {
	$ans += 1;
}
else {
	$ans += 2;
}

echo "{$ans}\n";


Measured memory_bytes: 4856
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll k,T;cin>>k>>T;
  vi A(T);
  for(auto &a:A)cin>>a;
  sort(ALL(A),greater<ll>());
  cout<<max(0LL,2*A[0]-k-1)<<endl;
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

int v[107];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    int n, m;
    cin >> n >> m;
    int t = 0;
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
        t += v[i];
    }
    sort(v + 1, v + n + 1);
    reverse(v + 1, v + n + 1);
    for (int i = 1; i <= m; i++) {
        if (v[i] * 4 * m < t) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


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

using namespace std;

int main(){

    //入力
    int n;
    cin >> n;

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

    //vector dp　を用意, 全て0で埋める
    vector<int> dp(n, 0);
    dp[1] = abs(h[1] - h[0]);//dp[1]を更新しておく

    for (int i = 2; i < n; i++){//2~nまでminをとってdpを更新していく
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[n-1] << endl;//一番最後まで行ってかかったコストを出力

    return 0;
}

Measured memory_bytes: 1024
#include"bits/stdc++.h"
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> x(N), y(N);
    for (int i = 0; i < N; i++) {
        char c;
        cin >> x[i] >> y[i] >> c;
        if (c == 'W') {
            x[i] += K;
        }
        x[i] %= 2 * K;
        y[i] %= 2 * K;
    }

    //累積和を計算
    vector<vector<int>> sum(2 * K, vector<int>(2 * K, 0));
    for (int i = 0; i < N; i++) {
        sum[y[i]][x[i]]++;
    }

    for (int i = 0; i < 2 * K; i++) {
        for (int j = 1; j < 2 * K; j++) {
            sum[i][j] += sum[i][j - 1];
        }

        if (i == 0) {
            continue;
        }

        for (int j = 0; j < 2 * K; j++) {
            sum[i][j] += sum[i - 1][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < K; j++) {
            int tmp = 0;
            tmp += sum[i][j];
            tmp += sum[i][2 * K - 1] - sum[i][j + K];
            tmp += sum[2 * K - 1][j] - sum[i + K][j];
            tmp += sum[i + K][j + K] - sum[i + K][j] - sum[i][j + K] + sum[i][j];
            tmp += sum[2 * K - 1][2 * K - 1] - sum[2 * K - 1][j + K] - sum[i + K][2 * K - 1] + sum[i + K][j + K];

            assert(0 <= tmp && tmp <= N);

            ans = max(ans, tmp);
            ans = max(ans, N - tmp);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 16768
package main

import (
	"fmt"
)

func main() {
	var s int
	fmt.Scan(&s)

	var nums []int
	for i := 0; i < s; i++ {
		var n1 int
		fmt.Scan(&n1)
		nums = append(nums, n1)
	}

	var ans int
	ok := true
	for ok {
		for i, c := range nums {
			if c%2 == 0 {
				nums[i] = c / 2
			} else {
				ok = false
			}
		}
		if ok {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
N, M = map(int, input().split())

list = [input().split() for _ in range(M)]

ac_list = [0] * N
wa_list = [0] * N

for i in range(M):
  if list[i][1] == "AC":
    ac_list[int(list[i][0])-1] = 1
    #print(i, ac_list)
    #print(i, wa_list)
  else:
    #print(i, ac_list)
    #print(i, wa_list)
    if ac_list[int(list[i][0])-1] == 0:
      wa_list[int(list[i][0])-1] += 1

for i in range(N):
  if ac_list[i] == 0:
    wa_list[i] = 0

print(sum(ac_list), sum(wa_list))

Measured memory_bytes: 33696
import java.util.Scanner;

/**
 * Created by zzt on 17-2-4.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        int oddCount = 0;
        int a;
        for (int i = 0; i < n; i++) {
            a = scanner.nextInt();
            if (a%2!=0)
                oddCount++;
        }
        System.out.println(oddCount%2==0?"YES":"NO");
    }
}

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

int main() {
	int a, b;
	cin >> a >> b;
	rep(i, 10001) {
		if (i == 0) continue;
		if ((int)(i*0.08) == a && (int)(i*0.1) == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> r(n);
    for(int i = 0; i < n; i++) cin >> r.at(i);
    int maxv = -1e10;
    int minv = r.at(0);
    for(int i = 1; i < n; i++){
        maxv = max(maxv, r.at(i)-minv);
        minv = min(minv, r.at(i));
    }
    cout << maxv << endl;
    return 0;
}



Measured memory_bytes: 3540
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
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; }
//#define int long long

void solve() {
    int n, k; cin >> n >> k;
    if(n >= 2 * k - 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

bool check[200005]={0};
int seq[300005];
int a[100005];

int main(){

  int n, m;

  std::cin >> n >> m;
  for(int i = 1; i <= m; i++) std::cin >> a[i];

  for(int i = 0; i <= m; i++){
    seq[i] = a[m - i];
  }

  for(int i = 0; i < m; i++){
    if(check[seq[i]] == 0){
      std::cout << seq[i] << std::endl;
      check[seq[i]] = true;
    }
  }
  for(int i = 1; i <= n; i++){
    if(check[i] == 0){
      std::cout << i << std::endl;
      check[i] = true;
    }
  }

  return 0;
}



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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

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

    ll res = 0;

    for (int i=0; i<n; i++) {
	sum -= a[i];
	ll cur = a[i]*(sum%mod)%mod;
	res += cur;
	res %= mod;
    }


    res %= mod;
    res += mod;
    res %= mod;
    cout<<res<<endl;
    
    
    return 0;
}


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

int tbl[100][100];

int main() {
    int n;
    while (cin >> n, n) {
        for (int i=0; i<n; ++i) {
            for (int j=0; j<n; ++j) {
                cin >> tbl[i][j];
            }
        }
        int res = 0;
        for (int i=0; i<n; ++i) {
            for (int j=0; j<n; ++j) {
                bool ok = true;
                for (int k=0; k<n; ++k) {
                    if (tbl[i][k] < tbl[i][j]) {
                        ok = false; break;
                    }
                    if (tbl[i][j] < tbl[k][j]) {
                        ok = false; break;
                    }
                }
                if (ok) {
                    res = tbl[i][j];
                    goto end;
                }
            }
        } end:;
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1164
import qualified Data.ByteString.Char8 as C
import Data.List
import qualified Data.IntSet as IS

main :: IO ()
main = do
    n <- readLn
    as <- map (`div` 400) <$> unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine
    let normal = filter (<8) as
    let free = n - (length normal)
    let rest = IS.size $ IS.fromList normal
    putStrLn $
        show (max 1 rest)
        ++ " "
        ++ (show $ rest+free)



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

using namespace std;

inline long long read()
{
	long long f = 1,x = 0;
	char ch;
	do
	{
		ch = getchar();
		if(ch == '-') f = -1;
	}while(ch < '0' || ch > '9');
	do
	{
		x = (x<<3) + (x<<1) + ch - '0';
		ch = getchar();
	}while(ch >= '0'&&ch <= '9');
	return f*x;
} 

long long n,x;

int main()
{
	n = read(),x = read();
	long long ans = n - __gcd(n-x , x);
	cout << 3 * ans << endl;
}

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


int* mallocint(int si)
{
    return (int*) malloc(si * sizeof(int));
}

int* inputint(int n)
{
    int *ans = mallocint(n);
    for( int i = 0; i < n; i++ ) cin >> ans[i];
    return ans;
}

int main()
{
    int *x = inputint(5);
    for( int i = 0; i < 5; i++ )
    {
        if( x[i] == 0 ) cout << i + 1;
    }
    return 0;    
}

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

using namespace std ;
#define int long long
#define pb push_back
#define maxn 200005

int n,m,a,b,c,x,y,z,i,j,k;
void solve(){
    cin >> n >> k ;
    string str ;
    cin >> str ;
    //cout << 'A'-'a';
    str[k-1] += 32 ;
    cout << str ;
}
signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1 ;
    //cin >> t ;
    while(t--){
        solve();
    }
    return 0 ;
}


Measured memory_bytes: 256