akhauriyash/Code-Regression huggingface dataset:
#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() {  
    string a, b, c;
    cin >> a >> b >> c;
    if (a.back() == b[0] && b.back() == c[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}




Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <climits>
#include <set>
#define endl '\n'
#define ll long long

using namespace std;

ll dp[100001][3];
int happy[100001][3];

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    for(int i = 1; i <= N; i++) for(int j = 0; j < 3; j++) cin >> happy[i][j];

    for(int i = 0; i < 3; i++) dp[1][i] = happy[1][i];
    
    for(int i = 2; i <= N; i++)
    {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + happy[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + happy[i][1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + happy[i][2];
    }
    
    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;

    return 0;
}


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

using namespace std;

typedef long long LL;
typedef vector<int>    VI;
typedef vector<bool>   VB;
typedef vector<string> VS;

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

struct Info {
	int t;
	int c;
	int p = 0;
	bool operator < (const Info &r) const {
		if (c != r.c) return c > r.c;
		if (p != r.p) return p < r.p;
		return t < r.t;
	};
};

vector<Info> info;
vector<VI> cnt;
int t, p, r;

int main(void) {
	while (1) {
		info.clear();
		cnt.clear();
		cin >> t >> p >> r;
		if (t == 0 && p == 0 && r == 0) break;
		info.resize(t + 1);
		cnt.resize(t + 1, VI(p + 1));
		REP (i, 1, info.size()) {
			info[i].t = i;
		}
		rep (i, r) {
			int tid, pid, time;
			string msg;
			cin >> tid >> pid >> time >> msg;
			if (msg == "WRONG") {
				cnt[tid][pid]++;
			} else {
				info[tid].c++;
				info[tid].p += time + cnt[tid][pid] * 1200;
			}
		}
		sort(ALL(info));
		rep (i, info.size()) {
			if (info[i].t == 0) continue;
			cout << info[i].t << " " << info[i].c << " " << info[i].p  << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 3192
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
def calc_same_num(s):
    if s[0]==s[1] and s[1]==s[2]:
        return 1
    elif s[0]==s[1] or s[1]==s[2]:
        return 3
    else:
        return 6
    
k = int(input())
sum_check = 0
a,b,c = 1,1,1
ans = 0
while a<=k and b<=k and c<=k:
    gcd = gcd_list([a,b,c])
    ans += gcd*calc_same_num([a,b,c])
    if c<k:
        c += 1
    elif b<k:
        b += 1
        c = b
    else:
        a += 1
        b = a
        c = a
print(ans)

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

int main(){
    int a;
    int b;
    cin >> a;
    cin >> b;
    if ( a > b ) {
         cout << "a > b"<< endl;
    } else if ( a < b ) {
         cout << "a < b"<< endl;
    } else if  ( a == b ) {
         cout << "a == b" << endl; 
    }
    return 0;
    // Your code here!
    
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int memo[10000000];

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

  int i=1;
  while(true){
    if(memo[s] != 0) break;
    memo[s] = i;
    i++;
    if(s%2==0) s = s/2;
    else s = 3*s+1;
  }

  cout << i << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}

ll calc(ll a,ll b,ll p){//a^(b) mod p   
  if(b==0)return 1;
  ll y = calc(a,b/2,p);y=(y*y)%p;
  if(b & 1) y = (y * a) % p;
  return y;
}


int main(){

  ll n,k,ans=0;
  cin >> n >> k;

  vector<ll> dp(k+1,0);
  //dp[k] = 1;
  FORR(i,1,k+1){
    dp[i] = calc(k/i,n,MOD);
    for(ll j=2*i;j<=k;j+=i){
      (dp[i] += MOD-dp[j]) %= MOD;
    }
    (ans += dp[i]*i) %= MOD;
  }
  cout << ans << endl;
}


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

int main()
{
	int n;
	cin >> n;
	vector<int> rennzoku;
	int previousColor = 0;
	for(int i = 0; i < n; i++){
		int tmp;
		cin >> tmp;
		if(previousColor == tmp){
			rennzoku.back()++;
		}else{
			rennzoku.push_back(1);
			previousColor = tmp;
		}
	}

	int ans = 0;
	int vsize = rennzoku.size();
	for(int i = 0; i < vsize; i++){
		ans += rennzoku[i] / 2;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif

int main() {
  int in(K);
  string in(S);

  if (S.size() <= K)
    cout << S << endl;
  else
    cout << S.substr(0, K) << "..." << endl;

  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    priority_queue<int> ans;
    ans.push(0);
    for(int i=0;i<s.size();i++){
        int cnt=0;
        for(int j=i;j<s.size();j++){
            if(s[j]=='A'||s[j]=='C'||s[j]=='G'||s[j]=='T')
            cnt++;
            else
            break;
        }
        ans.push(cnt);
    }
    cout<<ans.top()<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

    vec<ll> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vec<vec<ll>> dp(N + 1, vec<ll>(W + 1, 0));

    for (int i = 1; i <= N; ++i) {
        dp[i][w[i-1]] = max(dp[i][w[i-1]],v[i-1]);

        for (int j = 0; j <= W; ++j) {
            dp[i][j] = max({dp[i][j],dp[i - 1][j], dp[i][max(j - 1, 0)]});
            if (j + w[i - 1] <= W)
                dp[i][j + w[i - 1]] =
                    max(dp[i][j + w[i - 1]], dp[i-1][j] + v[i - 1]);
        }
    }

    ll ans = 0;
    rep(i,W+1) ans = max(ans, dp[N][i]);
    cout << ans << endl;
}


Measured memory_bytes: 83120
object Main {
  import io.StdIn._

  def getStrings = readLine().split(" ")
  def getInts = getStrings.map(_.toInt)

  def main(args: Array[String]): Unit = {
    val Array(d, g) = getInts

    val exercises = {
      for (_ <- 1 to d) yield {
        val Array(p, c) = getInts
        (p, c)
      }
    }

    val minSolveNumbers = for (bits <- 0 until 1 << d) yield {
      val allSolveList: Seq[Int] = for (digit <- 0 until d if (bits & (1 << digit)) != 0) yield digit
      val pointSum = allSolveList.map(i => (i + 1) * 100 * exercises(i)._1 + exercises(i)._2).sum
      if (pointSum < g) {
        val highestRemaining = (0 until d).filter(!allSolveList.contains(_)).max
        val required = ((g - pointSum) / (100.0 * (highestRemaining + 1))).ceil.toInt
        if (required < exercises(highestRemaining)._1) {
          Some(allSolveList.map(exercises(_)._1).sum + required)
        } else {
          None
        }
      } else {
        Some(allSolveList.map(exercises(_)._1).sum)
      }
    }
    println(minSolveNumbers.flatten.min)
  }
}


Measured memory_bytes: 28452
#include <stdio.h>
#include <string.h>

int main(){
   char x[1001]={};
   int i,n,sum;
   
   while(1){
       sum=0;
       scanf("%s",x);
       n=strlen(x);
       
       for(i=0;i<n;i++){
           sum+=x[i]-'0';
       }
       if(sum==0) break;
       printf("%d\n",sum);
   }
   return 0;
}


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

using prime_factors_t = std::multiset<int64_t>;

int digitCount(int64_t n) {
  int ret = 1;
  while (n >= 10) {
    n /= 10;
    ret++;
  }
  return ret;
}

int solve(int64_t n) {
  if (n == 1) {
    return 1;
  }
  for (int i = static_cast<int>(ceil(sqrt(n * 1.0)));; i--) {
    if (n % i == 0) {
      return std::max(digitCount(i), digitCount(n / i));
    }
  }
}

int main() {
  int64_t n;
  std::cin >> n;
  std::cout << solve(n) << std::endl;
  return 0;
}


Measured memory_bytes: 256
/**
 *	@file: B.cpp
 *	@author: Huy Le
 *	@created: 08-03-2020 08:24:59
**/


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

//***---***---***---***---***---***---BEGIN USELESS CODE---***---***---***---***---***---***//

#define ll long long
#define ld long double
const char newl = '\n';

template<class T> void read(vector<T>& vt);
template<class T>
void read(T& args) { cin >> args; }
template<class A, class... B >
void read(A& argc, B&... argv) {
	read(argc);
	read(argv...);
}
template<class T>
void read(vector<T>& vt) {
	for(auto &a : vt)
		read(a);
}

string to_string(bool bo) { return (bo ? "true" : "false"); }
string to_string(char c) { return string(1, c); }
string to_string(const char* str) { return string(str);}
string to_string(string str) { return str; }
template<class T>
string to_string(T vt) {
	bool ft = 1;
	string res;
	for(auto &a : vt) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += to_string(a);
	}
	return res;
}
string to_string(vector<bool> vt) {
	string res;
	bool ft = 1;
	for(int i = 0; i < (int)vt.size(); ++i) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += char('0' + vt[i]);
	}
	return res;
}

template<class T>
void write(T args) { cout << to_string(args); }
template<class A, class... B>
void write(const A argc, const B... argv) {
	write(argc);
	write(argv...);
}

void print() { write(newl); }
template<class A, class... B>
void print(const A argc, const B... argv) {
	write(argc);
	if(sizeof...(argv))
		write(' ');
	print(argv...);
}

void DEBUGLOCAL() { cerr << ")" << newl; }
template<class A, class... B> 
void DEBUGLOCAL(A argc, B... argv) {
	cerr << to_string(argc);
	if(sizeof...(argv))
		cerr << ", ";
	DEBUGLOCAL(argv...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") [" << __FUNCTION__ << "] -> (" << #__VA_ARGS__ << "): (",DEBUGLOCAL(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

//***---***---***---***---***---***---END USELESS CODE---***---***---***---***---***---***//

int ts;
int n;
ll k;

void solve() {
	read(n,k);
	vector<ll> a(n);
	read(a);
	ll l = 1, r = *max_element(a.begin(), a.end());
	while(l < r) {
		ll m = (l + r) / 2, cnt = 0;
		for(int i = 0; i < n; ++i) {
			cnt += (a[i] - 1) / m;
		}
		if(cnt > k)
			l = m + 1;
		else
			r = m;
	}
	print(l);
}

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

	//read(ts);
	//while(ts--)
		solve();
}


Measured memory_bytes: 4788
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '?')
      cout << 'D';
    else
      cout << s[i];
  }
  cout << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 3772
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	ll N;
	scanf("%lld",&N);

	ll ans = 0;
	ll tmp = N;

	for(ll i = 2; i*i <= N; i++){
		if(tmp%i == 0){

			ll count = 0;
			while(tmp%i == 0){
				tmp /= i;
				count++;
			}

			ll num = 1;

			while(count >= num){

				count -= num;
				ans++;
				num++;
			}
		}
	}

	if(tmp > 1)ans++;

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

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  int count = 0;
  bool cond = false;
  int A[210];
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  
  while (true) {
    cond = false;
    for(int i = 0; i < n; i++ ) {
      if (A[i] % 2 != 0) {
        cond = true;
        break;
      }
    }

    if (cond) {
      break;
    }

    for(int i = 0; i < n; i++ ) {
      A[i] /= 2;
    }
    count++;
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    ll ans = 0;
    rep2(i, n) {
        if (i%3==0) continue;
        if (i%5==0) continue;
        ans += i;
    }

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

Measured memory_bytes: 3636
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	void run() {
		FastScanner sc = new FastScanner();
		int n = (int) sc.nextLong();
		int m = (int) sc.nextLong();
		int k = (int) sc.nextLong();
		long[] a = new long[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextLong();
		}

		ArrayDeque<long[]>[] dq = new ArrayDeque[k];
		int[] sz = new int[k];
		for (int i = 0; i < dq.length; ++i)
			dq[i] = new ArrayDeque();
		long ans = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = k - 1; j >= 0; --j) {
				long add = a[i] * (j + 1);
				long base;
				if (j > 0) {
					if (dq[j - 1].isEmpty())
						continue;
					else
						base = dq[j - 1].peekLast()[0];
				} else {
					base = 0;
				}
				long v = add + base;
				if (j == k - 1)
					ans = Math.max(ans, v);
				int cnt = 0;
				while (!dq[j].isEmpty() && dq[j].peekFirst()[0] <= v) {
					long tmp = dq[j].pollFirst()[1];
					cnt += tmp;
					sz[j] -= tmp;
				}
				dq[j].addFirst(new long[] { v, cnt + 1 });
				sz[j] += cnt + 1;
				while (sz[j] > m) {
					if (dq[j].peekLast()[1] > sz[j] - m) {
						dq[j].peekLast()[1] -= sz[j] - m;
						sz[j] = m;
					} else {
						sz[j] -= dq[j].pollLast()[1];
					}
				}
			}
		}
		System.out.println(ans);
	}

	class FastScanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

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

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

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

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

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 271772
data = input().split("/")
Y = int(data[0])
M = int(data[1])
D = int(data[2])
if Y > 2019 or (Y == 2019 and M > 4) or (Y == 2019 and M == 4 and D > 30):
    print("TBD")
else:
    print("Heisei")

Measured memory_bytes: 3060
#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>;
 
const int M = 1000005;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> cnt(M);
  for (int x : a) {
    if (cnt[x] != 0) {
      cnt[x] = 2;
      continue;
    }
    for (int i = x; i < M; i += x) cnt[i]++;
  }
  int ans = 0;
  for (int x : a) {
    if (cnt[x] == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7948
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>

typedef long long ll;

using namespace std;

int main(void)
{
    string str1, str2;
    cin >> str1 >> str2;

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

    string str3;
    cin >> str3;

    if (str1 == str3) {
        a--;
    }else {
        b--;
    }

    cout << a << ' ' << b << endl;

    return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
s=[list(input()) for _ in range(h)]
black=0
for i in range(h):
    black+=s[i].count("#")




from collections import deque
que=deque()
que.append([0,0])
s[0][0]="#"
count=[[0]*w for _ in range(h)]
while que:
    
    x=que.pop()
    dx_dy=[[0,1],[1,0],[0,-1],[-1,0]]
    for k in range(4):
        nx=x[0]+dx_dy[k][0]
        ny=x[1]+dx_dy[k][1]
        if 0<=nx<=h-1 and 0<=ny<=w-1 and s[nx][ny]==".":
            s[nx][ny]="#"
            count[nx][ny]=count[x[0]][x[1]]+1
            que.appendleft([nx,ny])
if s[-1][-1]=="#":
    print(h*w-count[-1][-1]-black-1)
else:
    print(-1)


Measured memory_bytes: 9528
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<ll,ll> pint;

pint a[1001];
int main(){
    int n,ai;
    cin>>n;
    rep(i,n){
        cin>>ai;
        a[i]={ai%(n-1),ai};
    }
    sort(a,a+n);
    FOR(i,1,n){
        if(a[i].first==a[i-1].first){
            cout<<a[i].second<<" "<<a[i-1].second<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3124
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
using ull = unsigned long long;

int main(){
    unsigned N;
    scanf("%u", &N);
    ull A[N];
    for(int i = 0; i < N; ++i){
        scanf("%llu", A + i);
    }
    sort(A, A + N, greater<ull>());
    ull answer = A[0];
    unsigned i = 1;
    for (; i < N >> 1; i++){
        answer += A[i]<<1;
    }
    if(N&1) answer += A[i];
    printf("%llu\n", answer);
	return 0;
}

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

int main (){
    int x,a,b,n;
    cin >> n ;
    x=n/1.08;
    a=x*1.08;
    b=(x+1)*1.08;
    if(a==n){
        cout << x << endl;
    }else if(b==n){
        cout << x+1 << endl;
    }else {
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long s = sc.nextLong();
        long x2=0, x3=0, y2=1, y3=0;
        if(1_000_000_000 < s){
            x2 = 1_000_000_000;
            y3 = (long)Math.ceil((double)s /1_000_000_000);
            x3 = x2*y3 - s;
        }else {
            x2 = s; y3 = 1; x3 = 0;
        }
        System.out.println(0 + " " + 0 + " " + x2 + " " + y2 + " " + x3 + " " + y3);
        sc.close();

    }

}


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

int main() {
  int A,B,C,D,E;
  cin >> A>>B>>C>>D>>E;

  if (A==0) {
    cout << 1 << endl;
  }
  else if (B==0) {
    cout << 2 << endl;
  }
  else if (C==0) {
    cout << 3 << endl;
  }
  else if (D==0) {
    cout << 4 << endl;
  }
  else if (E==0) {
    cout << 5 << endl;
  }
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
   int N; cin>>N;
   vector<int> a(N),b(N);
   vector<int> x;
   for(int i=0;i<N;i++){
      cin>>a[i]>>b[i];
      x.push_back(a[i]);
      x.push_back(b[i]);
   }
   sort(x.begin(),x.end());
   x.erase(unique(x.begin(),x.end()),x.end());
   for(int i=0;i<N;i++){
      a[i]=lower_bound(x.begin(),x.end(),a[i])-x.begin();
      b[i]=lower_bound(x.begin(),x.end(),b[i])-x.begin();
   }

   vector<int> sum(2*N+1);
   for(int i=0;i<N;i++){
      sum[a[i]]++;
      sum[b[i]+1]--;
   }
   for(int i=0;i<2*N;i++){
      sum[i+1]+=sum[i];
   }
   int ans=0;
   for(int i=0;i<=2*N;i++){
      ans=max(ans,sum[i]);
   }
   cout<<ans<<endl;
}




Measured memory_bytes: 7756
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long N, std::vector<long long> H){
  ll c = 0;
  pri_queue<ll> a;
  for (int i = 0; i < N-1; i++) {
    if(H[i] >= H[i+1]){
      c++;
    }else{
      a.push(c);
      c = 0;
    }
  }
  a.push(c);
  cout << a.top() << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, std::move(H));
}


Measured memory_bytes: 2168
#include <iostream>

using namespace std;

int main()
{
  int N, T;
  int minC = 1001;
  bool flag = false;

  cin >> N >> T;
  for (int i = 0; i < N; i++)
  {
    int c, t;
    cin >> c >> t;
    if (T < t) continue;
    if (minC > c) {
      minC = c;
      flag = true;
    }
  }
  if (flag) cout << minC << endl; 
  else cout << "TLE" << endl; 
}


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

int main(){
  int N;
  int V[50]={};
  int C[50]={};
  int P[50]={};
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> V[i];
  }
  for(int i=0;i<N;i++){
    cin >> C[i];
    P[i] = V[i]-C[i];
  }

  int res=0;
  for(int i=0;i<N;i++){
  
    if(P[i]>0) res+= P[i];
  }
  
  cout<<res<<endl;
}


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

string FILENAME = "filename";
#define io ifstream fin(FILENAME + ".in"); ofstream fout(FILENAME + ".out")
#define fwrite(X) fout << X;
#define fwriteln(X) fout << X << endl;

#define forl(V, N) for(int V = 0; V < N; V++)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
#define rem(X) X.top(); X.pop()
#define setmin(A, B) A = min(A, B)
#define setmax(A, B) A = max(A, B)
#define graph unordered_map<int, unordered_set<int>>
#define vi vector<int>
#define pb push_back
#define ll long long

bool board[1000][1000];
ll dp[1001][1001];

int main() {
    int H, W;
    cin >> H >> W;
    forl(i, H) {
        forl(j, W) {
            char c;
            cin >> c;
            board[i][j] = c == '.';
        }
    }
    dp[0][1] = 1;
    forl(i, H) {
        forl(j, W) {
            if(!board[i][j]) continue;
            dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j]) % 1000000007;
        }
    }
    println(dp[H][W]);
}

Measured memory_bytes: 9088
import math
N,M=map(int,input().split())
if abs(N-M)>1:
    print(0)
elif abs(N-M)==1:
    print((math.factorial(N)*math.factorial(M))%(1000000007))
else:
    print((math.factorial(N)*math.factorial(M)*2)%(1000000007))

Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	long long A,B,K;
	cin>>A>>B>>K;
	
	if(A>K){
		A -= K;
	}
	else{
		K -= A;
		A = 0;
		if(B>K){
			B -= K;
		}
		else{
			B = 0;
		}
	}
	
	cout<<A<<' '<<B<<endl;
	
    return 0;
}


Measured memory_bytes: 256
import math
num = int(input())
x = [int(_) for _ in input().split()]
y = [int(_) for _ in input().split()]
p1 = p2 = p3 = pe = max_num= 0
for i in range(num):
    p1 += abs(x[i]-y[i])
    p2 += math.pow(abs(x[i]-y[i]),2)
    p3 += math.pow(abs(x[i]-y[i]),3)
    if max_num < abs(x[i]-y[i]):
        max_num = abs(x[i] - y[i])
else:
    p2 = math.sqrt(p2)
    p3 = math.pow(p3,1/3)
    pe = max_num
print("%f\n%f\n%f\n%f" %(p1,p2, p3,pe))


Measured memory_bytes: 5724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int MAX = 510000;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2; i<MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

ll COM(int n, int k){
    if(n<k){
        return 0;
    }
    if(n<0 || k<0){
        return 0;
    }
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main() {
    COMinit();
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    ll ans = 0;
    ans = COM(h-a+b-1, b) * COM(a+w-b-1, a) % MOD;
    for(int i=1; i<w-b; i++){
        ll tmp = (COM(h-a+b-1+i, b+i)-COM(h-a+b-1+i-1, b+i-1)) % MOD;
        while(tmp<0){
            tmp += MOD;
        }
        tmp = (tmp * COM(a+w-b-1-i, a)) % MOD;
        ans = (ans + tmp) % MOD;
    }

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





Measured memory_bytes: 12160
#include <cstdio>
const int MOD = 1e9+7;

long long gcd(int a, int b)
{
	return b ? gcd(b, a % b) : a;
}

long long pow(long long base, long long p)
{
	long long res = 1;
	while (p > 0)
	{
		if (p & 1)
			res = res * base % MOD;
		base = base * base % MOD;
		p /= 2;
	}
	return res;
}

long long solve(int a, int b)
{
	return pow(2, a) + pow(2, b) + pow(2, gcd(a, b)) - 3;
}

int main()
{
	int h, w, t; scanf("%d%d%d", &h, &w, &t);
	long long ht = gcd(h, t), wt = gcd(w, t);
	printf("%lld\n", pow(solve(h / ht, w / wt) % MOD, ht * wt));
}

Measured memory_bytes: 128
class Node:
    def __init__(self, val):
        self.num = val
        self.val = val
        self.is_parent = True
        self.parent = None

def root(node):
    depth = 0
    while node.parent != None:
        node = node.parent
        depth += 1
    return node, depth

N, M = map(int, input().split())

roots = [Node(i) for i in range(N)]
count = N

for i in range(M):
    x, y, z = map(int, input().split())
    x = roots[x-1]
    y = roots[y-1]
    if x.is_parent and y.is_parent:
            y.is_parent = False
            y.parent = x
            count -= 1
    else:
        root_x, depth_x = root(x)
        root_y, depth_y = root(y)
        if root_x != root_y:
            if depth_x >= depth_y:
                root_y.is_parent = False
                root_y.parent = root_x
                count -= 1
            else:
                root_x.is_parent = False
                root_x.parent = root_y
                count -= 1

print(count)


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  void solve() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
      cout << (s[i] == 'P' ? 'P' : 'D');
    }
    cout << endl;
  }
};
class Solver2 {
 public:
  int n, m;
  Solver2(LL n, LL m) : n(n), m(m){};

  void solve() {
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);

  Problem::Solver sol;
  sol.solve();
  return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define dbg(x) cout << #x << ": " << (x) << '\n'
#define ff first
#define ss second
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
const int inf = 1e9;

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

   int n, k;
   cin >> n >> k;
   vector <int> v(n), dp(n, inf);
   for (auto &i: v)
      cin >> i;
   dp[0] = 0;
   for (int i = 0; i < n; i++) {
      for (int j = i; j >= max(0, i - k); j--) {
         dp[i] = min(dp[j] + abs(v[i] - v[j]), dp[i]);
      }
   }
   cout << dp[n - 1] << '\n';

   return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll X,K,D;
    cin>>X>>K>>D;
    if(abs(X)/D<K&&(K-(abs(X)/D))%2==0)cout<<abs(abs(X)%D)<<endl;
    else if(abs(X)/D<K&&(K-(abs(X)/D))%2==1)cout<<abs(abs(abs(X)%D)-D)<<endl;
    else cout<<min(abs(X-K*D),abs(X+K*D))<<endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
 
int main()
{
    int sl, pl;
    char s[256], p[128];
    scanf("%s %s", s, p);
    sl=strlen(s);
    pl=strlen(p);
    pl=pl;
    memcpy(s+sl, s, sl);
    sl+=sl;
    s[sl]='\0';
 
    int i, ans=0;
    for(i=0; i<=sl-pl; i++) {
        if( (ans=strncmp(s+i, p, pl))==0) break;;
    }
    puts(ans?"No":"Yes");
    return 0;
}




Measured memory_bytes: 2112
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}

const int INF = 100000; 

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

    if(a + b < 10) cout << a + b << endl;
    else cout << "error" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void) {

	double x1, y1, x2, y2;

	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	printf("%10.8lf", sqrt((x2 - x1) * (x2 - x1 ) + ( y2 - y1) * ( y2 - y1 )));

}

Measured memory_bytes: 2680
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

ll H[101][101];
void updateH(ll x,ll y,ll h){
	ll tmp;
	for(ll i(0);i<=100;++i){
		for(ll j(0);j<=100;++j){
			tmp = h+abs(i-x)+abs(j-y);
			if(H[i][j] == -1){
				H[i][j] = tmp;
			}else if(h == 0){
				if(tmp < H[i][j] ){
					H[i][j] = 0;
				}
			}else{
				if(tmp != H[i][j]){
					H[i][j] = 0;
				}
			}
		}
	}
}

int main(){
	ll N;
	cin >> N;
	ll x[N],y[N];
	ll h[N];
	for(ll i(0);i<N;++i){
		cin >>x[i]>>y[i]>>h[i];
	}
	for(ll i(0);i<=100;++i){
		for(ll j(0);j<=100;++j){
			H[i][j] = -1;
		}
	}
	vector<vector<ll>> zeroPoints;
	for(ll i(0);i<N;++i){
		if(h[i]==0){
			vector<ll> vec = {x[i],y[i],h[i]};
			zeroPoints.push_back(vec);
		}else{
			updateH(x[i],y[i],h[i]);
		}
	}
	for(ll i(0);i<zeroPoints.size();++i){
		updateH(zeroPoints[i][0],zeroPoints[i][1],zeroPoints[i][2]);
	}

	ll ans = 0;
	ll ansX,ansY;
	for(ll i(0);i<=100;++i){
		for(ll j(0);j<=100;++j){
			if(H[i][j] > ans){
				ans = H[i][j];
				ansX = i;
				ansY = j;
			}
		}
	}
	cout << ansX << ' ' << ansY << ' ' << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main() {
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k=0;
	scanf("%d", &k);
	printf("%d\n", a[k-1]);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void solve()
{
  
  ll a,b,ans=0;
  cin>>a>>b;
  
  ll outlet=1;
  
  while(outlet<b)
  {
      --outlet;
      outlet+=a;
      ans++;
  }
  
  cout<<ans;
  return;
  
}

int main()
{
  solve();
  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 all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n,m;cin>>n>>m;
  vector<int> s(m);
  vector<char> c(m);
  rep(i,m){
    cin>>s[i]>>c[i];
    s[i]--;
  }
      rep(i,1000){
        bool ans=true;
        string a=to_string(i);
        int keta=a.size();
        if(keta!=n)continue;
        rep(j,m)if(a[s[j]]!=c[j])ans=false;
        if(ans){
          cout<<i<<endl;
          return 0;
        }
      }
  cout<<-1<<endl;
}

Measured memory_bytes: 3664
#include<cstdio>
#include<cstring>
using namespace std;

char arr[100010];
int alp[30];

int main(void){
    scanf("%s",arr);
    int len=strlen(arr);
    for(int i=0;i<len;i++)
        alp[arr[i]-'a']=1;
    for(int i=0;i<26;i++)
        if(!alp[i]){
            printf("%c\n",i+'a');
            return 0;
        }
    printf("None\n");
    return 0;
}


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

#define int long long
#define w cout
#define e '\n'
#define sz(x) (int)x.size()
template<class T, class U> inline istream& operator>>(istream& str, pair<T, U> &p) { return str >> p.first >> p.second; }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

const int N = 1e6 + 10 , mod = 998244353;

int find(int x) {
	int last = x;
	while(x) {
		last = x % 10;
		x = x / 10;
	}
	return last;
}
signed main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n ; cin >> n;
	map<pair<int , int >  ,int > mm;
	for(int i = 1 ;i <= n ;i ++) {
		int last = i % 10;
		int first = find(i);
		mm[{first , last}] ++;
	}
	int ans = 0;
	for(auto i : mm) {
		ans += i.second * mm[{i.first.second , i.first.first}];
	}
	w << ans;
}



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

int gcd(int a, int b){
  if(b > a) return gcd(b, a);
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main() {
  //int n; cin >> n;
  int a, b; cin >> a >> b;
  
  int ans = 0;
  
  for(int i = 0; i < 2; i++){
    if (a > b) {ans += a--;}
    else {ans += b--;}
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
n = int(input())
s = {}
for _ in range(n):
  line = input()
  if line in s:
    s[line] += 1
  else:
    s[line] = 1
s = sorted(s.items(), reverse=True, key=lambda x : x[1])
tn = s[0][1]
ans = []
for l in s:
  if l[1] == tn:
    ans.append(l[0])
  else:
    break
for l in sorted(ans):
  print(l)


Measured memory_bytes: 43228
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

nn = inputs[0][0]

if nn == 1
  puts "Hello World"
  exit
end

aa = inputs[1][0]
bb = inputs[2][0]

puts aa + bb

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end


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

using namespace std;

#define LIMIT 100
#define MOD 1000000007ll
#define INF 1e9
typedef long long ll;
typedef pair<ll, ll> ii;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);
  string c[3];
  for (int i = 0; i < 3; ++i) {
    cin >> c[i];
  }
  for (int i = 0; i < 3; ++i) {
    std::cout << c[i][i];
  }
  std::cout << std::endl;

  return 0;
}



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

int main()
{
    int a, b;
    cin >> a >> b;
    int ashiq[a];
    for(int i = 0; i < a; i++)
    {
        cin >> ashiq[i] ;
    }
    int sum = 0;
    int l = 1;
    for(int i = 0; i < a; i++)
    {
        if(ashiq[i]+sum <= b)
        {
            sum += ashiq[i];
            l++;
        }
        else
            goto end;
    }
    end:
    cout << l <<  endl;

}

Measured memory_bytes: 256
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
using namespace std;

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
inline int readint(){
    register int x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}

inline long long readlong() {
	register long long x = 0, flag = 1;
	register char ch;
	while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}
template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define ri readint
#define rl readlong

int A, B;
int main() {
	cin >> A >> B;
	int ans = 0;
	for (ans = 0; ans <= 10000; ans++) {
		double k = ans * 1.0;
		int tmp = floor((0.1 * k));
		if (tmp != B) continue;
		tmp = floor((0.08 * k));
		if (tmp != A) continue;
		printf("%d\n", ans); return 0;
	}
	printf("-1"); return 0;
}


Measured memory_bytes: 3720
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
llong N, K, R, S, P, ANS = 0;
string T;

int main() {
	cin >> N >> K;
	cin >> R >> S >> P;
	cin >> T;

	for (llong i = 0; i < K; i++) {
		string tmp = "";
		for (llong j = 0; j * K + i < N; j++) {
			tmp += T[j * K + i];
		}
		
		for (llong j = 1; j < tmp.length(); j++) {
			if (tmp[j] == tmp[j - 1]) tmp[j] = 'a';
		}
		for (llong j = 0; j < tmp.length(); j++) {
			if (tmp[j] == 'r') ANS += P;
			else if (tmp[j] == 's') ANS +=R;
			else if (tmp[j] == 'p') ANS += S;
		}
	}

	cout << ANS << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>

int s, t;
std::vector<int> vec(1000001, 0);
std::map<int, int> count_map;
int main() {
    std::cin >> t;
    vec[1] = t;
    for (int i = 2; i <= 1000000; i++) {
        s = vec[i-1];
        if (s % 2 == 0) {
            s /= 2;
        }
        else {
            s = 3 * s + 1;
        }
        vec[i] = s;
    }
    for (int i = 1; i <= 1000000; i++) {
        if (count_map[vec[i]] == 0) {
            count_map[vec[i]]++;
        }
        else if (count_map[vec[i]] == 1) {
            std::cout << i << std::endl;
            return 0;
        }
    }
}


Measured memory_bytes: 4224