akhauriyash/Code-Regression huggingface dataset:
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <list>
#include <ctime>
#include <memory.h>
#include <bitset>
#include <climits>
#include <iostream>
#include <stdlib.h>

#define F first
#define S second
#define endl "\n"
#define pb push_back
#define mp make_pair
#define bs 1000000007
#define pi 3.141592653589793
#define y1 kjdfshnvoavaofobiopj
using namespace std;

long long n, ary[100010], sum, ans;

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

cin>>n;
for(int i = 0; i < n; i++)
{
    cin>>ary[i];
    if(ary[i] == 0)
        ans += sum/2, sum = 0;
    sum += ary[i];
}
ans += sum/2;
cout<<ans<<endl;

return 0;}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_147
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] array = ReadInts();
            WriteLine(array.Sum() >= 22 ? "bust" : "win");
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
#define ll long long
const int N=51;
const int mod=1e9+7;
using vvi=vector<vector<ll>>;
vvi a(N,vector<ll>(N,0));
vvi mul(vvi& A, vvi& B)
{
  vvi C(N,vector<ll>(N,0));
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      for(int k=0;k<N;k++)
        C[i][k]=(A[i][j]*B[j][k] + C[i][k])%mod;
  return C;
}
int main()
{
  fin;
  int n,i,j;
  ll k,res=0;
  cin>>n>>k;
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      cin>>a[i][j];
  vvi answer(N,vector<ll>(N,0));
  for(i=0;i<N;i++)
    answer[i][i]=1;
  while(k)
  {
    if(k%2)
      answer=mul(answer,a);
    a=mul(a,a);
    k/=2;
  }
  for(i=0;i<N;i++)
    for(j=0;j<N;j++){
      res+=answer[i][j];
      res%=mod;}
  cout<<res;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int field[10][10];

int main() {
	for(string line; cin >> line;) {
		rep(i,10) field[0][i] = line[i] - '0';

		for(int y = 1; y < 10; y++) {
			for(int x = 0; x < 10 - y; x++) {
				field[y][x] = (field[y - 1][x] + field[y - 1][x + 1]) % 10;
			}
		}

		cout << field[9][0] << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define all(v)    ((v.begin()),(v.end()))
#define sz(v)     ((int)(v.size()))
#define forv(i, v) for(int i = 0; i < sz(v); ++i)
#define forn(i,n)   for(int i = 0; i < (int)(n); i++)
using namespace std;

typedef long long       ll;
typedef long double     ld;
typedef vector<int>     vi;
typedef vector<double>  vd;
typedef vector< vi >    vii;
typedef vector< vd >    vdd;
typedef vector<string>  vs;
const ll mod = 1e9 + 7;

int main()
{
	int h, w;
	scanf("%d%d", &h, &w);
	char g[h + 3][w + 3];
	ll ans[h + 3][w + 3];
	for (int i = 0; i < h; i++) {
		scanf("%s", g[i]);
	}
	memset(ans, 0, sizeof ans);
	ans[0][0] = 1;

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (g[i][j] != '#') {
				if (i + 1 < h && g[i + 1][j] != '#') ans[i + 1][j] += (ans[i][j]) % mod;
				if (j + 1 < w && g[i][j + 1] != '#') ans[i][j + 1] += (ans[i][j]) % mod;
			}
		}
	}
	printf("%lld\n", ans[h - 1][w - 1] % mod);


	return 0;
}


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

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

	
//////////////////////////////////////////////
}


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

int main(){
  int n, a = 0, b = 0;
  string s1, s2;
  cin >> n;

  for( int i = 0; i < n; i++){
    cin >> s1 >> s2;
    if( s1 == s2){
    a += 1;
    b += 1;
    } else if( s1 > s2){
    a += 3;
    } else if( s1 < s2){
    b += 3;
    }
  }

  cout << a << " " << b << endl;

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = int64_t;

constexpr int INF = (1 << 30);
constexpr ll INFL = (1LL << 62);
constexpr ll MOD = 1000000007;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};

int main() {
    cout << std::fixed << std::setprecision(10);
    int a, b;
    cin >> a >> b;
    if (a < 0) {
        if (b >= 0) {
            cout << "Zero" << endl;
        } else {
            cout << (((b - a) % 2 == 0) ? "Negative" : "Positive") << endl;
        }
    } else {
        if (a == 0) {
            cout << "Zero" << endl;
        } else {
            cout << "Positive" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
def convert_base(n):
    temp = n
    out = ''
    if n == 0:
        return '0'
    while temp != 0:
        q, r = divmod(temp, -2)
        if r == -1:
            q += 1
            r = 1
        out = str(r) + out
        temp = q
    return out

N = int(input())

print(convert_base(N))


Measured memory_bytes: 3060
// 5/5
// 2-3-2. 最長共通部分裂問題の類題

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

int dp[1010][1010];

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

    int n, m;
    // cin >> n >> m;

    vector<int> ans;

    rep(p, q) {
        string s, t;
        cin >> s >> t;

        n = s.size();
        m = t.size();
        memset(dp, 0, sizeof(dp));

        dp[0][0] = 0;

        rep(i, n) {
            rep(j, m) {
                if (s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
                else dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            }
        }

        // cout << dp[n][m] << endl;
        ans.push_back(dp[n][m]);
    }

    for (auto v : ans) cout << v << endl;
}



Measured memory_bytes: 7172
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#define ll long long

using namespace std;

int main() {
    int N, Y;
    bool ok = false;
    cin >> N >> Y;
    int res10000 = -1, res5000 = -1, res1000 = -1;
    for (int a = 0; a <= N; ++a) {  // 10000円の枚数を 0 〜 N で調べる
      if(ok) break;
        for (int b = 0; b + a <= N; ++b) {  // 5000円の枚数を 0 〜 N-a で調べる
          if(ok) break;
            int c = N - a - b;  // 1000円の枚数は決まる
            int total = 10000*a + 5000*b + 1000*c;
            if (total == Y) {  // 答えが見つかったら
                res10000 = a;
                res5000 = b;
                res1000 = c;
                ok = true;
            }
        }
    }

    // 答えを出力 (見つかっていなくても -1 -1 -1 になるので OK です)
    cout << res10000 << " " << res5000 << " " << res1000 << endl;
}


Measured memory_bytes: 256
N, M = map(int,input().split())
if N % 2 == 1:
	for i in range(1,1+M):
		print(i, 2*M+1-i)
elif N % 4 == 0:
	a = [2*i for i in range(1,N//4)] + [2*j + 1 for j in range(N//4, N//2)]
	for i in range(1, 1+M):
		print(i, i+a[-i])
else:
	a = [2*i for i in range(1,N//4+1)] + [2*j + 1 for j in range(N//4+1, N//2)]
	for i in range(1, 1+M):
		print(i, i+a[-i])

Measured memory_bytes: 11996
/****************************************
	Sahil Gangurde
	Learning through WA, TLE, SIGESV
****************************************/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <numeric>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin>>n;
	string s;
	cin>>s;
	if(ll(s.length())>ll(n)) {
		for(ll i=0; i<n; i++) {
			cout<<s[i];
		}
		cout<<"...";
	}
	else {
		cout<<s;
	}
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  bool flag=1; 
  for(int i = n - 2; i >= 0; --i) {
    if(a[i] >= a[i + 1] + 2) {
        flag = false;
        break;
    } else if(a[i] == a[i + 1] + 1) {
        --a[i];
    }
  }
  cout<<(flag?"Yes\n":"No\n");
  return 0;
}

Measured memory_bytes: 640
N = int(input())
import math
U = math.ceil(3*N/4)
D = math.ceil(N/4)
if N % 2 == 0:
  ans = (N,N,N//2)
else:
  if D%2 == 1:
    D += 1
  h = -1
  for n in range(D,3500):
    if h > 0:
      break
    for w in range(n,3500):
      #print(h,n,w)
      if w*n*N/(4*n*w-w*N-n*N) == int(w*n*N/(4*n*w-w*N-n*N)):
        h = w*n*N//(4*n*w-w*N-n*N)
        ans = (w*n*N//(4*n*w-w*N-n*N),n,w)
        break
        
print(*ans)

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

#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define FILL0(x) memset(x,0,sizeof(x))
#define FILL1(x) memset(x,-1,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

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()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int l, r, d;
    cin >> l >> r >> d;

    int ans = r/d-l/d;
    if(l%d==0)
        ans++;

    cout << ans << endl;



    return 0;

}



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

int main(){
	int n;
	cin >> n;
	vector<ll> h(n);
	rep(i,n) cin >> h[i];
	int c=0;
	int tmp=0;
	rep(i,n-1){
		if(h[i]>=h[i+1]) tmp++;
		else tmp=0;
		c = max(c,tmp);
	}
	cout << c << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

bool prime[7500000];

int main(){
	int n,p;
	rep(i,7500000)prime[i]=true;
	prime[0]=prime[1]=false;
	loop(i,2,3000){
		for(int j=i*2;j<7500000;j+=i)prime[j]=false;
	}
	while(1){
		cin>>n>>p;
		priority_queue<int,vector<int>,greater<int> > que;
		if(n==-1 && p==-1)break;
		loop(i,n+1,n+1000){
			loop(j,i,i+1000){
				if(prime[i] && prime[j])que.push(i+j);
			}
		}
		rep(i,p-1)que.pop();
		cout<<que.top()<<endl;
	}
	return 0;
}

Measured memory_bytes: 8672
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	char a;
	cin>>a;
	if(a<='Z' && a>='A')
		cout<<'A';
	else
		cout<<'a';
	cout<<'\n';
	printclock;
}

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

int main(void){
    int N, countB = 0;
    string s;
    cin >> N;
    cin >> s;
    for(int i = 0; i < N; i++){
        if(s[i] == 'B'){
            countB++;
        }
    }
    if(countB < N - countB){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;
}

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

int main(){ 
    Int N, cnt;
    cin >> N;
    cnt = 0;

    string S;
    cin >> S;

    //vector<vector<vector<bool>>> v(10,vector<vector<bool>>(10,vector<bool>(10,0)));

    vector<int> first(10,-1);
    vector<int> last(10,-1);

    rep(j,10){
        rep(i,N) {
            if ((S.at(i) - '0') == j) {
                first[j] = i;
                break;
            }
        }
        rep(i,N) {
            if ((S.at(N-i-1) - '0') == j) {
                last[j] = N-i-1;
                break;
            }
        }
    }
    
    rep(i,10) {
        rep(j,10) {
            rep(k,10) {
                if (first[i] == -1 || last[j] == -1) break;
                if (last[j] <= first[i]) break;
                for (int l = first[i] + 1; l < last[j]; l++) {
                    if ((S.at(l) - '0') == k) {
                        cnt++;
                        break;
                    }
                }
            }
        }
    }

    cout << cnt << endl;
}

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

namespace ABC166C2
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = ReadInt();
            int N = NM[0];
            int M = NM[1];

            var H = ReadLong();
            List<int>[] list = new List<int>[N];
            for (int i = 0; i < N; i++)
            {
                list[i] = new List<int>();
            }

            for (int i = 0; i < M; i++)
            {
                var ab = ReadInt();
                list[ab[0] - 1].Add(ab[1] - 1);
                list[ab[1] - 1].Add(ab[0] - 1);
            }

            int count = 0;
            for (int i = 0; i < N; i++)
            {
                bool ans = true;
                foreach (var a in list[i])
                {
                    if (H[a] >= H[i]) ans =false;
                }
                if (ans) count++;
            }

            Console.WriteLine(count);
            Console.ReadKey();

        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


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

using namespace std;

int main()
{
	string s;
	cin >> s;
	multiset<char> char_mset;
	set<char> char_set;
	for (size_t i = 0; i < s.length(); i++)
	{
		char_set.insert(s[i]);
		char_mset.insert(s[i]);
	}
	for (auto itr = char_set.begin(); itr != char_set.end(); itr++)
	{
		if (char_mset.count(*itr) % 2 != 0)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

const int maxn = 999999 + 10;
bool is_prime[maxn];
int tot[maxn];

void sieve(int n){
	fill(is_prime, is_prime + n + 1, true);
	is_prime[0] = is_prime[1] = false;
	
	for(int i=2; i*i <= n; i++) if(is_prime[i])
		for(int j=2*i; j <= n; j+=i)
			is_prime[j] = false;	
}

int main(){
//	freopen("data/in.txt", "r", stdin);
	
	sieve(maxn-1);
	int cnt = 0;
	for(int i=0; i<maxn; i++){
		if(is_prime[i]) cnt++;
		tot[i] = cnt;
	}
	
	int n;
	while(1==scanf("%d", &n)){
		printf("%d\n", tot[n]);
	}

	return 0;
}

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

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

  vector<int64_t> L(N + 1);
  L.at(0) = 2;
  L.at(1) = 1;
  for (int i = 2; i < N + 1; i++) {
    L.at(i) = L.at(i - 1) + L.at(i - 2);
  }

  cout << L.at(N) << endl;
}


Measured memory_bytes: 3588
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    a, b = geta(int)
    print(a * b)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9488
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
    int H,W;
    cin >> H >> W;
    int mine[H][W];
    rep(i,H){
        rep(j,W){
            mine[i][j]=0;
        }
    }
    rep(i,H){
        rep(j,W){
            char c;
            cin >> c;
            if(c=='#') mine[i][j]=-1;
        }
    }
    rep(i,H){
        rep(j,W){
            if(mine[i][j]==-1) continue;
            repi(x,max(0,i-1),min(H-1,i+1)+1){
                repi(y,max(0,j-1),min(W-1,j+1)+1){
                    if(!(x==i&&y==j) && mine[x][y]==-1) mine[i][j]++;
                }
            }
        }
    }

    rep(i,H){
        rep(j,W){
            if(mine[i][j]==-1) cout << '#';
            else cout << mine[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x <= y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x >= y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    ll w[N];
    rep(i, N) cin >> w[i];
    ll sum[N+1];
    sum[0] = 0;
    rep(i, N) sum[i+1] = sum[i]+w[i];
    vector<vector<ll>> dp(N, vector<ll>(N, INF));
    vector<vector<int>> arg(N, vector<int>(N, 0));
    rep(i, N) dp[i][i] = 0, arg[i][i] = i;
    rep2(i, 1, N-1){
        rep(j, N-i){
            rep2(k, max(j, arg[j][j+i-1]), min(j+i-1, arg[j+1][j+i])){
                if(chmin(dp[j][j+i], dp[j][k]+dp[k+1][j+i])) arg[j][j+i] = k;
            }
            dp[j][j+i] += sum[j+i+1]-sum[j];
        }
    }
    cout << dp[0][N-1] << endl;
}


Measured memory_bytes: 190848
n = int(input())
l = list(map(int,input().split()))
ll = [0,400,800,1200,1600,2000,2400,2800,3200]
al = [0] * 8

ans = 0
cnt = 0

for i in range(n):
  for j in range(0,8):
    if ll[j] <= l[i] < ll[j+1]:
      al[j] = 1
    if l[i] >= 3200:
      cnt += 1
      break
print(sum(al) if sum(al) > 0 else 1, sum(al) + cnt)


Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;
inline int read() {
    int x = 0;
    bool f = 1;
    char c = getchar();
    for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
    for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
    if (f) return x;
    return 0 - x;
}
typedef long long ll;
const int maxn = 200010;
const int inf = 0x3f3f3f3f;
const ll mod = 1000000000 + 7;
map<ll, ll> mp;
ll n;
ll fun(ll x) {
    if (mp[x]) return mp[x];
    if (x == 1) return mp[x] = 1;
    return mp[x] = 2 * fun(x / 2) + 1;
}


int main() {
    cin >> n;
    cout << fun(n) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin>>n>>s;
    map<char,ll> cnt;
    rep(i,n) cnt[s[i]]++;
    ll ans=1;
    for(auto itr:cnt){
      ans*=(itr.second+1);
      ans%=mod;
    }
    ans--;
    if(ans<0) ans+=mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

char X[1001];
char Y[1001];
int LCS(int r,int s);

int main(){
  int q,i,out,a,b;
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%s",X);
    scanf("%s",Y);
    a=strlen(X);
    b=strlen(Y);
    out=LCS(a,b);
    printf("%d\n",out);
  }
  return 0;
}

int LCS(int r,int s){
  int i,j,m[1001][1001];
  for(i=0;i<=r;i++){
    m[i][0]=0;
  }
  for(i=0;i<=s;i++){
    m[0][j]=0;
  }
  for(i=1;i<=r;i++){
    for(j=1;j<=s;j++){
      if(X[i-1]==Y[j-1]){
        m[i][j]=m[i-1][j-1]+1;
      }
      else if(m[i-1][j-1]>=m[i][j-1]){
        m[i][j]=m[i-1][j];
      }
      else{
        m[i][j]=m[i][j-1];
      }
    }
  }
  if(i==0||j==0){
    return 0;
  }
  else if(i>0&&j>0&&r==s){
    return m[i-1][j-1];
  }
  else if(i>0&&j>0&&r!=s){
    return m[r][s];
  }
  return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  REP(i,7){
    int a,b;
    cin >> a >> b;
    cout << (a-b) << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
//daddy's back in town, back to rolling the damn hash yoooo babeeeeees//
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define int ll
const ll mod = (int)1e9 + 7;
int n, m, s, t, d[300030];
vector<int> g[300030];

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	cin>>n>>m;
	for(int i=1, u, v; i<=m; i++){
		cin>>u>>v;
		g[u].pb(v+n), g[u+n].pb(v+2*n), g[u+2*n].pb(v);
	}
	cin>>s>>t;
	for(int i=1; i<=3*n; i++) d[i]=-1;
	d[s]=0;
	queue<int> q;
	q.push(s);
	while(!q.empty()){
		int nod=q.front();
		q.pop();
		for(int i : g[nod]){
			if(d[i]==-1){
				d[i]=d[nod]+1;
				q.push(i);
			}
		}
	}
	if(d[t]==-1) cout<<-1;
	else cout<<d[t]/3;
}

Measured memory_bytes: 19072
import java.util.*;

import static java.lang.Math.min;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int R = scanner.nextInt();

        int[] r = new int[8];
        for (int i = 0; i < R; i++) {
            r[i] = scanner.nextInt();
            r[i]--;
        }

        int[][] g = new int[205][205];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                g[i][j] = 100000000;
            }
        }
        for (int i = 0; i < N; i++) {
            g[i][i] = 0;
        }

        for (int i = 0; i < M; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int c = scanner.nextInt();
            a--; b--;

            g[a][b] = g[b][a] = c;
        }

        warshall(g, N);

        ArrayList<ArrayList<Integer>> order = new ArrayList<>();
        ArrayList<Integer> tmp = new ArrayList<>();
        boolean[] used = new boolean[205];
        Arrays.fill(used, false);
        dfs(order, tmp, r, 0, R, used);

        int ans = 100000000;
        for (ArrayList<Integer> it : order) {
            int sum = 0;
            for (int i = 0; i < it.size() - 1; i++) {
                sum += g[ it.get(i) ][ it.get(i + 1) ];
            }
            ans = min(ans, sum);
        }
        System.out.println(ans);
    }

    static void warshall(int[][] g, int n) {
        for (int k = 0;  k < n;  k++) {
            for (int i = 0;  i < n;  i++) {
                for (int j = 0; j < n; j++) {
                    g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
                }
            }
        }
    }

    static void dfs(ArrayList<ArrayList<Integer>> order, ArrayList<Integer> cur, int[] r, int i, int R, boolean[] used) {
        if(i == R) {
            order.add(cur);
            return;
        }

        for (int j = 0; j < R; j++) {
            if (!used[ r[j] ]) {
                ArrayList<Integer> cp = (ArrayList<Integer>) cur.clone();

                cp.add(r[j]);
                used[ r[j] ] = true;
                dfs(order, cp, r, i + 1, R, used);
                used[ r[j] ] = false;
            }
        }
    }
}

Measured memory_bytes: 48700
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

int main(){
    int N,A[1000000];
    long long sum=0;
    cin >> N ;
    HAIRETU(3*N, A);
    sort(A, A+3*N);
    for (int i = N; i < 3*N; i+=2) {
        sum+=A[i];
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3200
import math
import statistics
# a=int(input())
b=input()
c=[]
for i in b:
    c.append(int(i))
# e1,e2 = map(int,input().split())
# f = list(map(int,input().split()))
#j = [input() for _ in range(3)]
# h = []
# for i in range(e1):
#     h.append(list(map(int,input().split())))

sum = sum(c)
if int(b)%sum==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 10876
using System;

namespace AOJ.intro
{
    namespace ITP_1_4_A
    {
        public static class AslaB
        {
            public static void Main()
            {
                string[] inputData = Console.ReadLine().Split();
                int a, b, d, r;
                //float f;

                a = int.Parse(inputData[0]);
                b = int.Parse(inputData[1]);

                d = a / b;
                r = a % b;
                var temp = (decimal)a / b; 

                Console.WriteLine(d + " " + r + " " + " " + string.Format("{0:f5}",temp));
            }
        }
    }
}


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

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int a[n];
    int b[n];
    vector <int> v;
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        v.push_back(a[i]);
    }
    for(int i=0;i<n;++i)
    {
        cin>>b[i];
        v.push_back(b[i]);
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    int sz=(1<<n);
    int can[51][sz];
    for(int i=0;i<=50;++i)
    {
        can[i][0]=0;
    }
    int u[n];
    int curr,z,pos,s;
    for(auto i:v)
    {
        for(int mask=1;mask<sz;++mask)
        {
            can[i][mask]=1e9;
            s=0;
            for(int j=0;j<n;++j)
            {
                if(mask & (1<<j))
                {
                    u[j]=s;
                    ++s;
                }
            }
            pos=(n-s);
            for(int j=0;j<n;++j)
            {
                if(mask & (1<<j))
                {
                    curr;
                    if((pos%2)!=(j%2))
                    {
                        curr=b[j];
                    }
                    else
                    {
                        curr=a[j];
                    }
                    z=u[j];
                    if(curr>=i)
                    can[i][mask]=min(z+can[curr][mask-(1<<j)],can[i][mask]);
                }
            }
        }
    }
    if(can[v[v.size()-1]][sz-1]!=(1e9))
    cout<<can[v[v.size()-1]][sz-1];
    else
    cout<<(-1);
    return 0;
}


Measured memory_bytes: 104576
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<u64>();
    let (a, b, n) = (line[0], line[1], line[2]);
    let mut x = (n/b)*b + (b-1);
    if x < b{
        println!("{}", (a*n)/b - a * (n/b));
        return;
    }

    if x > n{
        x -= b;
    }

    println!("{}", (a*x)/b - a* (x/b));
}


Measured memory_bytes: 2168
/* kadai4_3
   nabe9393 */

#include<stdio.h>

int snowfall(int height_A, int height_B);

int main(void){
  int tower_west, tower_east;
  scanf("%d %d", &tower_west, &tower_east);
  printf("%d\n", snowfall(tower_west, tower_east));
  return 0;
}

int snowfall(int height_A_exposed, int height_B_exposed){
  int tower_diff, height_A, snow;
  tower_diff = height_B_exposed - height_A_exposed;
  height_A = tower_diff * (tower_diff - 1)/2;
  snow = height_A - height_A_exposed;
  return(snow);
}

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

int main() {
  
  int N,K;
  cin >> N >> K;
  int x;
  int b;
  int s=0;
  
  for (int i=0; i<N; i++) {
    
    cin >> x;
    if (K<x) b=x-K;
    else b=K-x;
    if (x < b) s+=x*2;
    else s+=b*2;
  }
    
    cout << s << endl;
}

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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long
typedef pair<int, int> P;

int main(){
  int N, i;
  cin >> N >> i;
  cout << N - i + 1 << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        HashMap<Integer, Integer> h = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(sc.next());
            if (h.containsKey(a)) {
                h.put(a, h.get(a) + 1);
            } else {
                h.put(a, 1);
            }
        }
        sc.close();
        List<Integer> s = h.values().stream().collect(Collectors.toList());
        s.sort(Comparator.reverseOrder());
        int ans = 0, i = 0;
        for (int v : s) {
            i++;
            if (i > k) {
                ans += v;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 68572
#include <stdio.h>

int main(void) {
    int a, b;
    scanf("%d%d", &a, &b);
    if ( 13 <= a ) {
        printf("%d\n", b);
    }
    else if ( 6 <= a && a <= 12 ) {
        printf("%d\n", b / 2);
    }
    else {
        printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<vector>


int main(void)
{
	bool a[30][30];
	for(int num = 0; num<30; num++)
	{
		for(int num1 = 0; num1<30; num1++)
		{
			a[num][num1] = false;
		}
	}
	int n = 0, m = 0;

	scanf("%d %d", &n, &m);
	
	for(int n1 = 0; n1 < n; n1++)//�ln1
	{
		int kind = 0;
		scanf("%d", &kind);
		for(int kind1 = 0; kind1 < kind; kind1++)//�ln1�̍D���ȐH�ו�
		{
			int m1 = 0;
			scanf("%d", &m1);

			a[n1][m1-1] = true;
		}
	}

	int count = 0;

	/*
	for(int num = 0; num<n; num++)
	{
		for(int num1 = 0; num1<m; num1++)
		{
			printf("%d ", a[num][num1]);
		}
		printf("\n");
	}
	*/

	for(int num = 0; num<m; num++)
	{
		for(int num1 = 0; num1<n; num1++)
		{
			if(a[num1][num] == false)break;

			if( num1 == n-1)
			{
				count += 1;
				break;
			}
		}
	}


	printf("%d", count);

	scanf("%d");

	return 0;
}

Measured memory_bytes: 128
#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;
const ll INF=1e18;

int N,M,K,A,B;
int a[100010],b[100010],c[100010];
string s,t;

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    //MOD同士の引き算に注意
    cin>>N>>K;
    if((N+1)/2>=K)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

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

ll INF = 1e+18;
int iINF = 1e9;

vector<ll> memo(51, 0);

int 
main()
{
  int H, A; cin >> H >> A;
  if(H % A == 0)cout << H / A << endl;
  else cout << (H / A) + 1 << endl;

}

Measured memory_bytes: 3624
main :: IO ()
main = do
  _ <- getLine
  as <- map read . words <$> getLine
  print $ counter as

counter
  :: [Int] -> Int
counter = helper 0

helper
  :: Int -> [Int] -> Int
helper k ms
  | all even ms = (helper $! (k+1)) $! (map (`div` 2) ms)
  | otherwise   = k

Measured memory_bytes: 1020
#include<iostream>
using namespace std;
int max(int a,int b){
    if(a>b)
        return a;
    else return b;
}
int main(){
    int n; 
    cin>>n;
    int arr[n][3],i,j;
    for(i=0; i<n; i++){
        for(j=0; j<3; j++)
            cin>>arr[i][j];
    }
    int dp[n][3];
    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];
    for(i=1; i<n; i++){
        dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=arr[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    int maxHappiness=max(dp[n-1][0],dp[n-1][1]);
    maxHappiness=max(maxHappiness,dp[n-1][2]);
    cout<<maxHappiness;
    return 0;
}

Measured memory_bytes: 2560
// https://atcoder.jp/contests/abc141/tasks/abc141_c
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(Q);
    REP(i, Q) cin >> A[i], --A[i];
    vector<int> cnts(N, 0);
    REP(i, Q)
    {
        ++cnts[A[i]];
    }
    vector<int> res(N, K);
    REP(i, N)
    {
        res[i] += cnts[i] - Q;
    }
    REP(i, N)
    {
        if (res[i] > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4304
#include <bits/stdc++.h>
using namespace std;
const int INF=1001001001;
int main(){
long long n,m,x;
cin >> n >> m >> x;
vector<vector<long long>> data(n,vector<long long> (m+1));
int a[12][12];
vector<int> c(n);
for(int i = 0;i < n;i++){
    cin >> c[i];
    for (int j = 0;j < m;j++){
        cin >> a[i][j];
        //cin >> data.at(i).at(j);
    }
}
int ans=INF;
for (int bit = 0;bit < (1<<n);bit++) {
    vector<int> s(m);
    int cost = 0;
    for (int i = 0;i < n;i++){
    if(bit >> i&1){
        cost += c[i];
        for(int j = 0;j < m;j++){
        s[j] += a[i][j];
        }
      }
    }
    bool ok = true;
    for (int i = 0;i < m;i++){
        if(s[i]<x) ok=false;
    }
    //cout << cost << endl;
    if(ok) ans = min(cost,ans);
}
if (ans==INF) cout << -1 << endl;
else cout << ans << endl;

}



Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
    int N, M, K;
    std::cin >> N >> M >> K;
    std::vector<unsigned long long> A, B;
    A.resize(N+1);
    for (int i=0; i<N; i++) {
        int tmp;
        std::cin >> tmp;
        A[i+1] = A[i] + tmp;
    }
    B.resize(M+1);
    for (int i=0; i<M; i++) {
        int tmp;
        std::cin >> tmp;
        B[i+1] = B[i] + tmp;
    }
    int max = 0;
    int an = std::upper_bound(A.begin(), A.end(), K) - A.begin() -1;
    for (int i=an; i>=0; i--) {
        int j = std::upper_bound(B.begin(), B.end(), K-A[i]) - B.begin();
        max = std::max(max, i+j-1);
    }
    std::cout << max << std::endl;
}



Measured memory_bytes: 6424
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <utility>
#include <complex>
#include <stack>
#include <climits>
#include <set>

using namespace std;

double sq(double x){return x*x;}

int main(){
	string x;
	map<string,int> s;
	int max_len = 0;
	string m_str;
	while(cin>>x){
		s[x]++;
		if(max_len < x.length()){
			max_len = x.length();m_str = x;
		}
	}

	int m = 0;
	string r;
	for(map<string,int>::iterator it = s.begin(); it != s.end(); ++it){
		if(m < (*it).second)
			m = (*it).second,r = (*it).first;
	}

	cout << r << " " << m_str << endl;

	return 0;
}

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

int main(){
    int N, D, X, ans;
    cin >> N >> D >> X;
    vector<int> A(N+1);
    for(int i = 1; i <= N; ++i) cin >> A[i];
    ans = X;
    for(int i = 1; i <= N; ++i){
        ans += (D-1) / A[i] + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
  string s, t;
  cin >> s;
  t = s;
  ll k, ans = 0, n = s.length();
  cin >> k;
  if (n == 1){
    cout << k / 2 << '\n';
    return 0;
  }
  int flag = 1;
  for(int i = 0; i < n - 1; i++) {
    if(s[i] == s[i+1]){
      continue;
    }else{
      flag = 0;
      break;
    }
  }
  if(flag == 1){
    cout << (n * k) / 2 << '\n';
    return 0;
  }
  

  for(int i = 0; i < n - 1; i++) {
    if(s[i] == s[i + 1]) {
      s[i + 1] = '0';
      ans++;
    }
  }

  reverse(t.begin(), t.end());
  ll tmp = 0;
  for(int i = 0; i < n - 1; i++) {
    if(t[i] == t[i + 1]) {
      t[i + 1] = '0';
      tmp++;
    }
  }
  ans = min(ans, tmp);
  ans *= k;
  
  if(s[0] == s[n - 1] && t[0] == t[n - 1]) {
    ans += k - 1;
  }

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


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

    int a[50], b[50];
    for (int i = 1; i <= M; i++){
        cin >> a[i] >> b[i];
    }

    int count[50];

    for (int i = 1; i <= N; i++){
        count[i] = 0;
    }
    for (int i = 1; i <= M; i++){
        count[a[i]]++;
        count[b[i]]++;
    }
    for (int i = 1; i <= N; i++){
        cout << count[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::string S, T; std::cin >> S >> T;
  for(int i = 0; i < S.size(); ++i) {
    if(S[i] != T[i]) fin("No");
  }
  fin("Yes");
  return 0;
}


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

int main() {
    int n,a,b;
    cin >> n >> a >> b;
    int ans1 = min(a,b);
    int ans2 = n >= a+b ? 0:(a+b)-n;
    cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    int a4 = 0, a2 = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a % 4 == 0) {
            a4++;
        } else if (a % 2 == 0) {
            a2++;
        }
    }
    int a1 = n - a4 - a2;
    int flag = 1;
    if (a2 > 0) {
        if (a4 < a1) flag = 0;
    } else {
        if (a4 < a1 - 1) flag = 0;
    }
    if (flag == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}




Measured memory_bytes: 3604
S = list(input())
s = set(S)
lis = {}
for x in S:
  if x in lis:
    lis[x] += 1
  else:
    lis[x] = 1
ans = True
if len(lis) == 2:
  for x in s:
    if lis[x] != 2:
      ans = False
else:
  ans = False
if ans:
  print("Yes")
else:
  print("No")

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

using namespace std;

#ifdef Lin1043
    #define DEBUG(msg, ...) printf("(%s #%d) " msg, __FUNCTION__, __LINE__, __VA_ARGS__)
    #define massert(...) assert(...)
#else
    #define DEBUG(...)
    #define massert(...)
#endif

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )

struct iopener
{
    iopener()
    {
#ifdef Lin1043
        freopen("./in" , "r" , stdin);
#endif
    }
} iop;

typedef long long LL;

template<typename T>inline bool chkmin(T &x , const T &y) { return x > y ? (x = y , 1) : 0; }
template<typename T>inline bool chkmax(T &x , const T &y) { return x < y ? (x = y , 1) : 0; }

template<typename T>inline T read(T &f)
{
    f = 0; int x = 1 ; char c = getchar();
    while(!isdigit(c)) x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}

int l , r;

int main()
{
    read(l) , read(r);
    if(l > 0)
        puts("Positive");
    else if(r >= 0)
        puts("Zero");
    else if(l % 2 == r % 2)
        puts("Negative");
    else
        puts("Positive");
    return 0;
}



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

int n;
int a[3][200],f[3][200];

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=2;i++)
		for (int j=1;j<=n;j++)
			scanf("%d",&a[i][j]);
	for (int i=1;i<=2;i++)
		for (int j=1;j<=n;j++)
			f[i][j]=a[i][j]+max(f[i][j-1],f[i-1][j]);
	printf("%d\n",f[2][n]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;cin >> s;long long ans = 0;int b = 0;
  for (int i = 0; i < s.size(); i++) {
     if (s.at(i) == 'B') b++;
     else ans += b;
  }
  cout << ans;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bitset>
#include <set>
#include <iomanip>
#include <functional>
using namespace std;
typedef long long ll;
//'A' = 65, 'a' = 97

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

    int a[4];
    for (int i = 0; i < 4; i++) {
        a[i] = s[i] - '0';
    }

    for (int i = 0; i < (1 << 3); i++) {
        char op[4] = {};
        for (int j = 0; j < 3; j++) {
            if (i & (1 << j)) {
                op[j] = '+';
            } else {
                op[j] = '-';
            }
        }
        int ans = a[0];
        bool flag = false;
        for (int i = 1; i < 4; i++) {
            if (op[i - 1] == '+') {
                ans += a[i];
            } else {
                ans -= a[i];
            }
            if (ans == 7) {
                flag = true;
                cout << a[0] << op[0] << a[1] << op[1] << a[2] << op[2] << a[3] << "=7" << endl;
                break;
            }
        }
        if (flag) break;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
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; }
const int INF = 1000100100;

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

    vector<string> W(N);
    REP(i, N) {
        cin >> W[i];
    }

    FOR(i, 1, W.size()) {
        char shiri = W[i - 1][W[i - 1].length() - 1];
        if(W[i][0] != shiri) {
            cout << "No" << endl;
            return 0;
        }

        REP(j, i) {
            if(W[i] == W[j]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            String []s=Console.ReadLine().Split(' ');
            int AB=int.Parse(s[0]);
            int BC=int.Parse(s[1]);
            int CA=int.Parse(s[2]);
            int S;
            S=AB*BC/2;
            Console.WriteLine(S);

                


        }
    }
}

Measured memory_bytes: 13140
import bisect
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
ans = 0
 
for i in range(n-2):
    for j in range(i+1, n-1):
        idx = bisect.bisect_right(l, l[i]+l[j]-1, j+1)
        ans+=idx-(j+1)
print(ans)

Measured memory_bytes: 3188
#include<stdio.h>
typedef long long LL;
const int e[40]={0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,
                 5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8};
LL N;
LL IN(void)
{
  LL x=0;short f=0,c=getchar();
  while(c<48||c>57)f^=c==45,c=getchar();
  while(c>47&&c<58)x=x*10+c-48,c=getchar();
  return f?-x:x;
}
int main(void)
{
  int i,x=0;
  long long a=0,N;
  N=IN();
  while(N%2==0){x++;N/=2;}
  a+=e[x];
  for(i=3;(LL)i*i<=N;i+=2)
  {
    x=0;while(!(N%i))x++,N/=i;
    a+=e[x];
  }
  if(N>1)a++;
  return printf("%lld\n",a),0;
}

Measured memory_bytes: 1604