akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define sz(a) ((int) (a).size())
#define all(a) (a).begin(), (a).end()
#define int long long

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) ans += (n - i + 1) * i;
    for (int i = 0; i < n - 1; i++) {
        int l, r;
        cin >> l >> r;
        if (l > r) swap(l, r);
        ans -= l * (n - r + 1);
    }
    cout << ans;
    return 0;
}


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

int L[41];
int R[41];

int main()
{
    string s;
    cin >> s;
    vector<string> a(16);
    string ans = "NO";
    a = {"AKIHABARA", "AKIHABAR", "AKIHABRA", "AKIHABR", "AKIHBARA", "AKIHBAR", "AKIHBRA", "AKIHBR", "KIHABARA", "KIHABAR", "KIHABRA", "KIHABR", "KIHBARA", "KIHBAR", "KIHBRA", "KIHBR"};
    rep(i, 16) {
        if(s == a[i]) ans = "YES";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
a, b = map(int, sys.stdin.readline().split())
 
if a == 1 and b == 1:
    print('Draw')
elif a == 1:
    print('Alice')
elif b == 1:
    print('Bob')
elif a > b:
    print('Alice')
elif a < b:
    print('Bob')
else:
    print('Draw')

Measured memory_bytes: 3060
D,G = map(int,input().split())
l = list(list(map(int, input().split())) for _ in range(D))

#得点の大きい順に並び替えておく
l = l[::-1]

ans = float("inf")
for i in range(2**D):
    total = 0
    cnt = 0
    for j in range(D):
        if (i>>j)&1:
            total += 100*(D-j)*l[j][0] + l[j][1]
            cnt += l[j][0]
    if total >= G:
        ans = min(ans,cnt)
        continue
    for j in range(D):
        if (i>>j)&1 == False:
            for k in range(l[j][0]):
                total += 100*(D-j)
                cnt+=1
                if total >= G:
                    ans = min(ans,cnt)
                    break
            break

print(ans)

Measured memory_bytes: 41200
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

signed main(){
    IOS;
    int n,c,k; cin >> n >> c >> k;
    vector<int> t(n);
    rep(i,0,n) cin >> t[i];
    sort(all(t));
    int r = t[0]+k, ans = n; 
    for(int i = 1, cur = 1;i<n;++i){
        if(t[i]<=r and cur<c){
            ans--;
            cur++;
        }
        else{
            r = t[i]+k;
            cur=1;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdint.h>
#include <string.h>

int main(int argc, char const *argv[]) {
  int a;
  char s[11]={0};

  scanf("%d", &a);
  scanf("%s", s);

  if(a>=3200){
    printf("%s\n",s );
  }else{
    printf("red\n" );
  }
  return 0;
}


Measured memory_bytes: 128
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll euclidean_gcd(ll a, ll b) {
  if(a < b) euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(n*a,b) << endl;
}


Measured memory_bytes: 256
def dfs(g,v,depth):
    if seen[v]==True:return 0
    if depth==n:return 1
    seen[v] = True
    paths = 0
    for next_v in g[v]:
        paths += dfs(g,next_v,depth+1)
    seen[v] = False
    return paths
        
n,m = map(int,input().split())

g = [[]*(n+1) for _ in range(n+1)]

for _ in range(m):
    a,b = map(int,input().split())
    g[a].append(b)
    g[b].append(a)

seen = [False]*(n+1)
    
print(dfs(g,1,1))

Measured memory_bytes: 9108
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	map<char, int> mp;
	string s;
	int n;
	cin >> n;
	rep(i, n) {
		cin >> s;
		map<char, int> tmp;
		for(auto& c: s) {
			tmp[c]++;
		}
		for(char c = 'a'; c <= 'z'; c++) {
			if(mp.count(c)) mp[c] = min(mp[c], tmp[c]);
			else mp[c] = tmp[c];
		}
	}
	for(char c = 'a'; c <= 'z'; c++) {
		cout << string(mp[c], c);
	}
	cout << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

typedef long long ll;

int main(){
	int n; scanf("%d", &n);
	int a[100000], b[100000], c[100000];
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	for(int i = 0; i < n; i++) scanf("%d", &b[i]);
	for(int i = 0; i < n; i++) scanf("%d", &c[i]);
	sort(a, a + n); sort(c, c + n);
	ll res = 0;
	for(int i = 0; i < n; i++) res += (ll)(lower_bound(a, a + n, b[i]) - a) * (c + n - upper_bound(c, c + n, b[i]));
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll N, M;
    cin >> N >> M;
    vector<ll> X(M);
    rep(i, M) cin >> X[i];
    sort(ALL(X));

    vector<ll> diff(M - 1);
    rep(i, M - 1) diff[i] = X[i + 1] - X[i];

    sort(ALL(diff), greater<ll>());

    ll ans = 0;
    reps(i, N - 1, M - 1) {
        ans += diff[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4624
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		
		String s=sc.next();
        char a=s.charAt(0);
        if(a=='S') {
        	System.out.println("Cloudy");
        }else if(a=='C') {
        	System.out.println("Rainy");
        }else {
        	System.out.println("Sunny");
        }

	}

}


Measured memory_bytes: 20820
#include <bits/stdc++.h>
using namespace std;
long long power(int x, int n, long long mod = numeric_limits<long long>::max()) {
  assert(n >= 0);
  if (n == 0) return 1;
  return power(x * x % mod, n / 2, mod) * (n % 2 ? x : 1) % mod;
}
signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  int d = 0;
  for (int i = 0; i < n; i++) d += a[i] % 2 == 0;
  cout << (power(3, n) - power(2, d)) << '\n';
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    struct P
    {
        public int index;
        public List<int> ad;
        public Dictionary<int, int> weights;
        public long Weight;
        public P(int index)
        {
            this.index = index;
            ad = new List<int>();
            weights = new Dictionary<int, int>();
            Weight = 0;
        }
    }
    static void Main(string[] args)
    {

        var num = Input.num;
        var ps = new P[num];
        for (var i = 0; i < num; i++)
            ps[i] = new P(i);
        for (var i = 0; i < num - 1; i++)
        {
            var inp = Input.ar;
            for (var j = 0; j < 2; j++)
            {
                ps[inp[j] - 1].ad.Add(inp[(j + 1) % 2] - 1);
                ps[inp[j] - 1].weights[inp[(j + 1) % 2] - 1] = inp[2];
            }
        }
        var qk = Input.ar;
        dfs(ps, new bool[num], qk[1] - 1);
        var res = new long[qk[0]];
        for (var i = 0; i < qk[0]; i++)
        {
            var qer = Input.ar;
            res[i] = ps[qer[0] - 1].Weight + ps[qer[1] - 1].Weight;
        }
        WriteLine(string.Join("\n", res));
    }
    private static void dfs(P[] ps, bool[] set, int index)
    {
        set[index] = true;
        foreach (var ad in ps[index].ad)
            if (!set[ad])
            {
                ps[ad].Weight = ps[index].weights[ad] + ps[index].Weight;
                dfs(ps, set, ad);
            }
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


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

int main(){
  string S;
  cin >> S;
  if(S.at(0)==S.at(1) || S.at(1)==S.at(2)|| S.at(2)==S.at(3)){
    cout << "Bad" << endl;
  }
  else{
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 3636
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	LL n, m, k;
	inl2(n, m);
	inl(k);
	
	LL a[n], b[m];
	LL as[n], bs[m];
	for(int i=0;i<n;i++) {
		inl(a[i]);
		as[i] = (i==0) ? a[i] : (as[i-1] + a[i]);
	}
	for(int j=0;j<m;j++) {
		inl(b[j]);
		bs[j] = (j==0) ? b[j] : (bs[j-1] + b[j]);
	}
	
	int maxi = 0;
	for(int i=0;i<n;i++) {
		//read till ith book from A
		LL now = as[i];
		if(now > k) break;
		int idx = upper_bound(bs, bs+m, k-now) - bs;
		//~cout<<idx<<en;
		maxi = max(maxi, i+1+idx);
	}
	
	int idx = upper_bound(as, as+n, k) - as;
	maxi = max(maxi, idx);
	idx = upper_bound(bs, bs+m, k) - bs;
	maxi = max(maxi, idx);
	cout<<maxi<<en;
	
	
	
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 10012
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll n,B[2][3],dp[4][25000001];
ll solve(ll n){
    rep(i,n+1) dp[0][i]=i;
    rep(i,3)rep(j,n+1){
        if(j-B[0][i]>=0) dp[i+1][j]=max(dp[i][j],dp[i+1][j-B[0][i]]+B[1][i]);
        else dp[i+1][j]=dp[i][j];
    }
    return dp[3][n];
}
int main(){
    cin>>n;
    rep(i,2)rep(j,3) cin>>B[i][j];
    n=solve(n);
    rep(i,3) swap(B[0][i],B[1][i]);
    cout<<solve(n)<<"\n";
}

Measured memory_bytes: 781440
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    Integer n = Integer.parseInt(r.readLine());
    int[] c = new int[555];
    int[] s = new int[555];
    int[] f = new int[555];
    int[] a = new int[555];
    int goal = n;


    for(int i = 1; i < n; i++)
    {
      String[] z = r.readLine().split("[\\s]+");
      c[i] = Integer.parseInt(z[0]);
      s[i] = Integer.parseInt(z[1]);
      f[i] = Integer.parseInt(z[2]);
    }


    for(int start = 1; start <= goal; start++)
    {
      a[start] = 0;
      int now = 0;
      //System.out.println("start : " + start);

      for(int pos = start; pos < goal; pos++)
      {
        //System.out.println("pos : " + pos + "     now : " + now);
        if(now < s[pos])
        {
          now = s[pos] + c[pos];
        }
        else if(now % f[pos] == 0)
        {
          now += c[pos];
        }
        else
        {
          now += f[pos] - (now % f[pos]) + c[pos];
        }
      }
      //System.out.println("     now : " + now);

      a[start] = now;
    }

    for(int start = 1; start <= goal; start++)
    {
      System.out.println(a[start]);
    }
  }
}


Measured memory_bytes: 24040
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    vector<int> test= {a,b,c};
    sort(test.begin(),test.end());
    cout << test[0] << " " << test[1] << " " << test[2] << endl;
    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define N 100
#define w 3002
using namespace std;

int tbl[w][w];
int main(){
	string s,t,r;
    cin>>s>>t;
    for(int i=1;i<=s.size();i++){
        for(int j=1;j<=t.size();j++){
            if(s[i-1]==t[j-1]){
               tbl[i][j]=1+tbl[i-1][j-1];
              
            }else{
                tbl[i][j]=max(tbl[i-1][j],tbl[i][j-1]);
            }
        }
    }
  	int i,j;
   i=s.size(),j=t.size();
   while(i>0 && j>0){
     if(s[i-1]==t[j-1]){
      	r=s[i-1]+r;
       i--,j--;
     }else{
       if(tbl[i-1][j]>tbl[i][j-1]) i--;
       else j--;
     }
   }
  	
  cout << r <<endl;
    return 0;
}

Measured memory_bytes: 38708
n = int(input())
a = []
b = []
for i in range(n):
  tmp1,tmp2 = (int(i) for i in input().split())
  a.append(tmp1)
  b.append(tmp2)
ans = 0
for i in range(n):
  if (a[n-i-1]+ans)%b[n-i-1] != 0:
    ans +=b[n-i-1]-(a[n-i-1]+ans)%b[n-i-1]
print(ans)

Measured memory_bytes: 11052
#include<bits/stdc++.h>
using namespace std;
const int qwq=1e9;
int n,k,s;
int main()
{
	cin>>n>>k>>s;
	for(int i=1;i<=k;++i) cout<<s<<' ';
	for(int i=k+1;i<=n;++i) 
	{
		if(s-1==0) cout<<qwq<<' ';
		else cout<<s-1<<' ';
	}
	return 0;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

ll powmod(ll x, ll e) {
  x %= mod;
  ll sum = 1;
  ll cur = x;
  while (e > 0) {
    if (e % 2 == 1) {
      sum = sum * cur % mod;
    }
    cur = cur * cur % mod;
    e /= 2;
  }
  return sum;
}


int main(void){
  ll n, k;
  cin >> n >> k;
  VL n_fact;
  for (ll i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      n_fact.push_back(i);
      if (i * i != n) {
	n_fact.push_back(n / i);
      }
    }
  }
  sort(n_fact.begin(), n_fact.end());
  int m = n_fact.size();
  VL sym(m, 0LL); // the number of arrays with symmetry k_fact[i]Z/kZ
  REP(i, 0, m) {
    int block = n_fact[i];
    sym[i] = powmod(k, (block + 1) / 2);
  }
  REP(i, 0, m) {
    REP(j, i + 1, m) {
      if (n_fact[j] % n_fact[i] == 0) {
	sym[j] = (sym[j] - sym[i] + mod) % mod;
      }
    }
  }
  ll tot = 0;
  REP(i, 0, m) {
    ll tmp = sym[i];
    ll f = n_fact[i];
    tmp *= f % 2 ? f : f / 2;
    tmp %= mod;
    tot = (tmp + tot) % mod;
  }
  cout << tot << endl;
}


Measured memory_bytes: 256
n=gets.to_i
all={}
n.times.each do
    v=gets.chomp.split("").map(&:to_s)
    v=v.tally
    if all[v]==nil
    all[v]=1
    else
    all[v]+=1
    end
end
count=0
all.each do |k,v|
    if v>=2
      count+=(v*(v-1))/2
    end
end
p count

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

using namespace std ;

const long long mod = 1e9 + 7ll ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n ;
	cin>>n ;
	map<int , long long>mp ;
	for(int i = 2 ; i <= n ; ++i)
	{
		int x = i ;
		for(int j = 2 ; j * j <= x ; ++j)
		{
			while(x % j == 0)
			{
				mp[j]++ ;
				x /= j ;
			}
		}
		if(x > 1)
			mp[x]++ ;
	}
	long long ans = 1ll ;
	for(auto &i : mp)
		ans = (ans * (i.second+1ll)) % mod ;
	return cout<<ans<<"\n" , 0 ;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
l =[]
pl = []
for i in range(m):
  l.append(list(int(i) for i in input().split()))
pl= list((int(i) for i in input().split()))
cnt = 0
sw = [0]*n
for i in range(2**n):
  sw = list(format(i,"b"))
  while len(sw) < n:
    sw.insert(0,"0")
  flag = 1
  for j in range(m):
    tmp = 0
    for k in range(l[j][0]):
      if sw[-l[j][k+1]] == "1":
        tmp += 1
    if tmp % 2 != pl[j]:
      flag = 0
  if flag == 1:
    cnt += 1
print(cnt)

Measured memory_bytes: 41712
#include<stdio.h>
int binarysearch(int);
int A[1000000],n;
int main(){
  int i,j,k,count=0;
    scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&j);
  for(i=0;i<j;i++){
    scanf("%d",&k);
    if(binarysearch(k))count++;
  }
  printf("%d\n",count);
  return 0;
}
int binarysearch(int key){
  int left=0,right=n,mid;
  while(left<right){
    mid=(left+right)/2;
    if(key==A[mid])return 1;
    if(key>A[mid])left=mid+1;
    else if(key<A[mid])right=mid;
      }
  return 0;
}

			 

		      
 



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

int main() {
	string S;
	cin >> S;
	int month = (S[5] - '0') * 10 + (S[6] - '0');
	if (4>=month) {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    string S;
    cin>>N>>S;

    int sum=0;
    for(int i=0;i<N;++i){
        if(S[i]=='A'){
            if(S[i+1]=='B'){
                if(S[i+2]=='C'){
                  sum++;
                }
            }
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int S;
  int h = 0, m = 0, s = 0;

  scanf("%d", &S);
  h = S / 3600;
  m = (S % 3600) / 60;
  s = (S % 3600) % 60;
  printf("%d:%d:%d\n", h, m, s);

  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll x;
    cin>>x;

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

Measured memory_bytes: 3652
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<sstream>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

ll N = 1;
int q = 0;

string lltos(ll n) {
    ostringstream s;
    s << n;
    return s.str();
}

string response(ll n){
    bool a = (n <= N);
    bool b = (lltos(n) <= lltos(N));
    return !(a^b) ? "Y" : "N";
}

string query(ll n){
    q++;
    printf("? %lld\n", n);
    fflush(stdout);
    string ret;
    //ret = response(n);
    cin >> ret;
    return ret;
}

void answer(ll n){
    printf("! %lld\n", n);
}

signed main(){
    ll digit_num = 0, min_digit = 0, max_digit = 11;
    while(min_digit < max_digit){
        digit_num = (min_digit + max_digit) / 2;
        if(query(pow(10, digit_num)) == "Y"){
            min_digit = digit_num + 1;
        }else{
            max_digit = digit_num;
        }
    }
    digit_num = min_digit;
    if(digit_num == 11){
        reppp(i, 1, 9){
            if(query(pow(10,i)-1) == "Y"){
                answer(pow(10, i-1));
                return 0;
            }
        }
    }
    ll ans = 0;
    for(int i=digit_num-1;i>=1;i--){
        ll mid = 0, min_num = 0, max_num = 9;
        while(min_num < max_num){
            mid = (min_num + max_num) / 2;
            if(query(ans*10+mid) == "Y"){
                if(min_num == mid){
                    if(query(ans*10+min_num+1) == "N"){
                        break;
                    }else{
                        min_num++;
                    }
                }else{
                    min_num = mid;
                }
            }else{
                max_num = mid - 1;
            }
        }
        mid = min_num;
        if(mid == 9 && ans != 0 && query(ans*10-1) == "N"){
            answer(ans*10);
            return 0;
        }
        ans = ans*10+mid;
    }

    ll mid = 0, min_num = 0, max_num = 9;
    while(mid != (min_num + max_num) / 2){
        mid = (min_num + max_num) / 2;
        if(query((ans*10+mid)*10) == "N"){
            min_num = mid + 1;
        }else{
            max_num = mid;
        }
    }
    mid = min_num;
    if(mid == 9 && ans != 0 && query(ans*10-1) == "N"){
        answer(ans*10);
        return 0;
    }
    ans = ans*10+mid;
    
    if(ans > 1000000000){
        answer(1);
    }else{
        answer(ans);
    }
    return 0;
}


Measured memory_bytes: 596
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  100005
ll n,k;
vi a(N);
ll dp[105][100005];
void solve()
{
	cin>>n>>k;
	rep(i,0,n)
	{
		cin>>a[i];
	}
	rep(i,0,a[n-1]+1)
	dp[n-1][i]=1;
	rep(i,1,k+1)
	dp[n-1][i]=(dp[n-1][i]+dp[n-1][i-1])%hell;
	repr(i,0,n-1)
	{
		rep(j,0,k+1)
		{
			if(j<=a[i])
			dp[i][j]=(dp[i+1][j])%hell;	
			else
			dp[i][j]=(dp[i+1][j]-dp[i+1][j-a[i]-1]+hell)%hell;
		}	
		// rep(j,0,k+1)
		// cout<<dp[i][j]<<" ";
		// cout<<endl;
		rep(j,1,k+1)
		dp[i][j]=(dp[i][j]+dp[i][j-1])%hell;
	}
	cout<<(dp[0][k]-dp[0][k-1]+hell)%hell<<endl;
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

Measured memory_bytes: 80896
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

int f(int x, int n){
	if(x==-1){
		return 0;
	}
	else {
		return x/n+1;
	}
}

int32_t main(){
	int a,b,x;
	cin>>a>>b>>x;
	cout<<f(b,x)-f(a-1,x);
}


Measured memory_bytes: 256
N = input()
lit_N = []
for i in range(int(N)+1):
  if i % 5 == 0 and i % 3 == 0:
    lit_N.append("FizzBuzz")
  elif i % 3 == 0:
    lit_N.append("Fizz")
  elif i % 5 == 0:
  	lit_N.append("Buzz")
  else:
    lit_N.append(i)
print(sum(list(filter(lambda x: isinstance(x,int), lit_N))))

Measured memory_bytes: 37740
#include <stdio.h>
#include <math.h>
double fun(double xa,double ya,double xb,double yb);

int main(void)
{
	int n,i;
	double xa,ya,ra,xb,yb,rb,d;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
		d=fun(xa,ya,xb,yb);
		if(d<ra-rb)			puts("2");
		else if(d<rb-ra)	puts("-2");
		else if(d<=ra+rb)	puts("1");
		else				puts("0");
	}
	return 0;
}

double fun(double xa,double ya,double xb,double yb){
	double d;
	d = sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
	return d;
}

Measured memory_bytes: 616
import java.util.Scanner;

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

		System.out.println((a+b)%2 == 0 ? (a+b)/2 : (a+b)/2 + 1);
	}
}


Measured memory_bytes: 23124
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

// From Errichto's Youtube stream
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////

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

    vector<int> cnt(26, 101);

    int N;

    cin >> N;

    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;

        vector<int> cur(26);
        for (auto x : S)
            cur[x - 'a']++;

        for (int j = 0; j < 26; j++)
            cnt[j] = min(cnt[j], cur[j]);
    }

    for (int i = 0; i < 26; i++)
        for (int j = 0; j < cnt[i]; j++)
            cout << char('a' + i);
    cout << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using namespace std;
using i8t = std::int64_t;
using vi8t = std::vector<i8t>;
using vvi8t = std::vector<std::vector<i8t>>;
static const i8t i8t_max=numeric_limits<i8t>::max();
static const i8t i8t_min=numeric_limits<i8t>::min();
using u8t = std::uint64_t;
using vu8t = std::vector<u8t>;
#define F3(I,A,B) for(i8t I=A,I##_N=B;I<I##_N;I++)
#define F(I,N) F3(I,0,N)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
template<typename T> T umax(T& ans,T const& value) {if(value>ans)ans=value;return ans;}
template<typename T> T umin(T& ans,T const& value) {if(value<ans)ans=value;return ans;}

int main() {
  //tab[digit-1][j] ... digit桁でjから始まるLnln数は何個あるか。
  constexpr i8t NDigit=20;
  vvi8t tab(NDigit,vi8t(10,1));

  //(d+1)桁の数
  F3(d,1,NDigit)F(i,10){
    i8t m=0;
    if(i>0)m+=tab[d-1][i-1];
    m+=tab[d-1][i];
    if(i<9)m+=tab[d-1][i+1];
    tab[d][i]=m;
  }

  R(K);

  vi8t result(NDigit,0);

  auto _digit=[&](){
    i8t index=0;
    F(d,NDigit)F3(i,1,10){
      //cerr<<"d="<<d<<" i="<<i<<" t="<<tab[d][i]<<" (index:"<<index<<")"<<endl;
      if(index+tab[d][i]>=K){
        result[d]=i;
        K-=index;
        return d;
      }
      index+=tab[d][i];
    }
    return (i8t) 8;
  };
  i8t d=_digit();
  i8t prev=result[d];

  auto _test=[&](i8t cand){
    if(cand<0||cand>9)return false;
    i8t t=tab[d][cand];
    if(K<=t){
      result[d]=cand;
      prev=cand;
      return true;
    }
    K-=t;
    return false;
  };

  while(d){
    d--;
    _test(prev-1)||_test(prev)||_test(prev+1);
  }

  bool fput=false;
  FR(i,NDigit){
    if(result[i])fput=true;
    if(fput)std::cout<<result[i];
  }
  std::cout<<std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)

int main() {
  string s;
  cin >> s;
  int n = s.size(), u = 1, v = 1;
  bool ok = true;
  if(s[0] != '1' || s[n - 1] != '0') ok = false;
  rep(i, n / 2) if(s[i] != s[n - 2 - i]) ok = false;
  if(!ok) {
    cout << -1 << endl;
    return 0;
  }
  rep2(i, n / 2 + 1, n) s[i] = '0';
  reverse(all(s));
  vector<pair<int, int>> g;
  rep2(i, 1, n) {
    v++;
    g.push_back({u, v});
    if(s[i] == '1') u = v;
  }
  for(auto p : g) cout << p.first << ' ' << p.second << '\n';
}

Measured memory_bytes: 4352
//操作2は「2つ飛ばしの要素を交換」と読み直せる -> indexの偶奇が大事！。
//奇数indexにあってソート後に偶数indexになるもの, 偶数indexにあってソート後に奇数indexになるものの個数を数える。
//それを２で割ったものが下界。

#include <iostream>
#include <algorithm>
using namespace std;

int n;
int a[100000];
int b[100000];

int main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	for (i = 0; i < n; i++) b[i] = a[i]; sort(b, b + n);
	
	int ans = 0;
	for (i = 0; i < n; i++) {
		int index = lower_bound(b, b + n, a[i]) - b;
		if (index % 2 != i % 2) {
			ans++;
		}
	}
	ans /= 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
s = input()
t = input()

tt = t

max_count = 0
while True:
    count = 0
    for i in range(len(tt)):
        if s[i] == tt[i]:
            count += 1 
    # print(count)
    max_count = max(max_count, count)
    
    # print(f"{len(s)} {len(t)}")
    if len(s) == len(tt):
        break
    
    tt = ' ' + tt
    
print(len(t) - max_count)

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

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

  vector<int> A(N);
  int ans = -1;
  bool x = false;

  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  while(x == false) {
    ans++;
    for(int i = 0; i < N; i++) {
      if (A.at(i) % 2 == 0) {
        A.at(i) /= 2;
      }
      else {
        x = true;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
def main():
    A,B,C = list(map(int, input().split()))
    K = int(input())

    for i in range(K):
        if A == max(A,B,C):
            A = A*2
        elif B == max(A,B,C):
            B = B*2
        else:
            C = C*2
    return A+B+C

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
	int A, B;
	scanf("%d %d", &A, &B);
	if (A >= 13) printf("%d\n", B);
	else if (A >= 6) printf("%d\n", B / 2);
	else printf("0\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef pair<ll, ll>P;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];

ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}
#define yo 100001
//------------------変数-----------------------//
ll n, s, dp[1000][4];//何桁目、下が確定しているか、同じ通りがないことが確定しているか
//-------------------関数----------------------//
//flag,comが0で確定
//0→下が確定している
//1→桁上がりすると同じ数になる
//2→桁上がりするとダメになる
//3→すでに同じ数
ll DP(ll num, ll flag) {
	if (num == -1) { return 1; }
	if (dp[num][flag] >= 0) {
		return dp[num][flag];
	}
	ll cnt = 0;
	if (flag == 0) {
		cnt += DP(num - 1, flag) * 3;
	}
	else if (flag == 1) {//桁あがりすると同じ数になる
		if (n >> num & 1) {
			cnt += DP(num - 1, 1);//桁上がり,(1,1)
			cnt += DP(num - 1, 0);
			cnt += DP(num - 1, 0);
		}
		else {
			cnt += DP(num - 1, 3);//桁上がり,(1,1)
			cnt += DP(num - 1, 1);
			cnt += DP(num - 1, 0);
		}
	}

	else if (flag == 2) {//桁上がりしたら死刑

		cnt += DP(num - 1, 2);
		cnt += DP(num - 1, 1);

	}
	else {//ぎりぎり
		if (n >> num & 1) {
			cnt += DP(num - 1, 3);
			cnt += DP(num - 1, 1);
		}
		else {
			cnt += DP(num - 1, 3);
		}
		
	}
	return dp[num][flag] = cnt%mod;
}

int main() {
	cin >> n;
	fill_all(dp, (ll)-1);
	ll a = n, cnt = 0;
	while (a) {
		cnt++; a /= 2;
	}
	cout << DP(cnt - 1, 3) << endl;;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       a:[usize;5],
    }

    let mut ans: usize = a.iter().position(|&x| x == 0).unwrap();

    echo!(ans + 1);
}


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

#define rep(i, k, n) for(int i = (k); i < (n); i++)
#define irep(i, k, n) for(int i = (k); i > (n); i--)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

vector<int> z_alg(string s){
  int n = s.size();
  vector<int> z(n, 0);
  z[0] = n;
  int i = 1;
  int j = 0;
  while(i < n){
    while(i+j < n && s[j] == s[i+j]) j++;

    z[i] = j;
    if(j == 0){
      i++;
      continue;
    }

    int k = 1;
    while(i+k < n && k+z[k] < j){
      z[i+k] = z[k];
      k++;
    }
    i += k;
    j -= k;
  }

  return z;
}

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

  int ans = 0;
  rep(i, 0, n){
    auto z = z_alg(s.substr(i));
    rep(j, i+1, n){
      if(z[j-i] <= j-i) chmax(ans, z[j-i]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i < en; i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)

int32_t main(){ fast;
	string a, b; cin>>a>>b;
	rep(i, min(sz(b), sz(a))){
		cout<<a[i]<<b[i];
	}
	if(sz(a) != sz(b)){
		cout<<(sz(a) > sz(b) ? a[sz(b)] : a[sz(a)])<<endl;
	}

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,i;
  cin >> n;
  int cnt = 0;
  for(i=0;i<n;i++){
    int a,b;
    cin >> a >> b;
    cnt += b-a+1;
  }
  cout << cnt << "\n";
  return 0;
}

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

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

int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> cnt(n+1);
  REP(i,n) {
    int a;
    cin>>a;
    ++cnt[a];
  }
  sort(ALL(cnt), greater<int>());
  int sum = 0;
  FOR(i,k,n) {
    sum += cnt[i];
  }
  cout << sum << endl;
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  int N=s.size();
  int i=0;
  int a_min;
  while(true){
    if (s.at(i) == 'A'){
      a_min = i;
      break;
    }
    else
      i++;
  }
  i=N-1;
  int z_max;
  while(true){
    if(s.at(i) == 'Z'){
      z_max = i;
      break;
    }
    else
      i--;
  }
  cout << z_max-a_min+1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	double A, B;
	cin >> A >> B;
	int H, M;
	cin >> H >> M;
	double W = 5.5 * (H * 60 + M);
	while(W >= 360){
		W -= 360;
	}
	if(W >= 180){
		W = 360 - W;
	}
	long double cs = 3.141592653589793238462643383279;
	cs = cs * W;
	cs /= 180;
	long double ans = A * A + B * B - 2 * A * B * cos(cs);
	ans = sqrt(ans);
	cout << fixed << setprecision(15);
	cout << ans << endl;
}

Measured memory_bytes: 4180
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int x;

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> x;
	if (30 <= x)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3568
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	N int
	A []int
)

func main() {
	defer writer.Flush()
	readVariables()
	sort.Slice(A, func(i, j int) bool {
		return A[i] > A[j]
	})
	q := NewIntPriorityQueue(func(x, y int) bool {
		return x > y
	})
	heap.Push(q, A[0])
	var answer int
	for i := 1; i < N; i++ {
		v := heap.Pop(q).(int)
		answer += v
		next := MinInt(v, A[i])
		heap.Push(q, next)
		heap.Push(q, next) // 2回追加する
	}
	println(answer)
}

func readVariables() {
	N = nextInt()
	A = make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
	}

}

/* Template */

var (
	scanner *bufio.Scanner
	writer  *bufio.Writer
)

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
	writer = bufio.NewWriterSize(os.Stdout, Max)
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func printf(format string, a ...interface{}) {
	fmt.Fprintf(writer, format, a...)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt returns minimum argument
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt returns maximum argument
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt returns |x| for x
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

// IntPriorityQueue は、整数値の優先度付きキューを表す。
type IntPriorityQueue struct {
	values  []int
	lessVal func(x, y int) bool // indexではなく値を比較するless関数
}

// NewIntPriorityQueue は、引数のless関数で整数値を比較するIntPriorityQueueを生成する。
func NewIntPriorityQueue(lessVal func(x, y int) bool) *IntPriorityQueue {
	q := &IntPriorityQueue{
		values:  make([]int, 0),
		lessVal: lessVal,
	}
	heap.Init(q)
	return q
}

// Len は、要素数を返す。
func (q *IntPriorityQueue) Len() int {
	return len(q.values)
}

// Less は、比較関数
func (q *IntPriorityQueue) Less(i, j int) bool {
	return q.lessVal(q.values[i], q.values[j])
}

// Swap は、要素をスワップする
func (q *IntPriorityQueue) Swap(i, j int) {
	q.values[i], q.values[j] = q.values[j], q.values[i]
}

// Pop pops elem
func (q *IntPriorityQueue) Pop() interface{} {
	v := q.values[q.Len()-1]
	q.values = q.values[0 : q.Len()-1]
	return v
}

func (q *IntPriorityQueue) Push(x interface{}) {
	v := x.(int)
	q.values = append(q.values, v)
}


Measured memory_bytes: 13292