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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    vector<ll> a,b;
    set<pair<int,int> > st;
    set<pair<int,int> > ::iterator it;
    for(int i=0; i<n; i++)
    {
        ll x;
        cin>>x;
        a.push_back(x);
    }
    for(int i=0; i<n; i++)
    {
        ll x;
        cin>>x;
        b.push_back(x);

    }
    for(int i=0;i<n;i++)
    {
        st.insert(make_pair(a[i],i));
    }
    int cnt=0;
    bool chk=0;
    for(int i=0;i<n;i++)
    {
        if(cnt==(n-2))
        {
            break;
        }
        pair<int,int> p=*(st.begin());
        if(p.first>b[i])
        {
            chk=1;
            break;
        }
        it=st.lower_bound(make_pair(b[i]+1,-1));
        it--;
        p=(*it);
        if(p.first != a[i])
        {
            cnt++;
            st.erase({a[i],i});
            a[p.second]=a[i];
            a[i]=p.first;
            st.erase(p);
            st.insert({a[p.second],p.second});
        }
        else
        {
            st.erase({a[i],i});
        }
    }
    if(chk==0)
    {
        for(int i=0;i<n;i++)
        {
            if(a[i]>b[i])
            {
                chk=1;
                break;
            }
        }
    }
    if(chk) cout<<"No"<<endl;
    else if(chk==0) cout<<"Yes"<<endl;


    return 0;
}


Measured memory_bytes: 6516
MOD = 10 ** 9 + 7
H, W = gets.split.map(&:to_i)
data = H.times.map{gets.chomp.split("")}

#H, W = 1000,1000
#data = H.times.map{("." * W).split("")}

dp = Array.new(H){Array.new(W, 0)}
dp[0][0] = 1
H.times do |i|
  W.times do |j|
    next if data[i][j] == '#'
    [[0,1],[1,0]].each do |h, w|
      ni, nj = i + h, j + w
      next if ni < 0 || nj < 0 || ni > H - 1 || nj > W - 1
      dp[ni][nj] += dp[i][j]
      dp[ni][nj] %= MOD
    end
  end
end

p dp.last.last % MOD

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

template<typename T, class Compare = less<T> >
class SlideMin {
    const int K;
    int i = 0;
    deque<pair<T, int> > data;
public:
    SlideMin(int k) : K(k) {};
    T get() { return data.front().first; }
    void put(T x) {
        while (!data.empty() && Compare()(x, data.back().first)) data.pop_back();
        if (!data.empty() && data.front().second == i-K) data.pop_front();
        data.push_back({x, i++});
    }
    // void debug() { for (auto x : data) cerr << x.first << ' '; cerr << endl; }
};

int main() {
    int n, k; cin >> n >> k;
    int p[n]; for (int i = 0; i < n; i++) cin >> p[i];
    SlideMin<int> smin(k-1);
    SlideMin<int, greater<int> > smax(k-1);
    int ans = 1;
    for (int i = 0; i < n; i++) {
        if (i >= k) {
            if (p[i-k] > smin.get() || p[i] < smax.get()) ans++;
        }
        smin.put(p[i]);
        smax.put(p[i]);
    }
    int cnt = 0, c = 0;
    for (int i = 1; i < n; i++) {
        if (p[i-1] < p[i]) c++; else c = 0;
        if (c == k-1) cnt++;
    }
    cout << (cnt ? ans - cnt + 1 : ans) << endl;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define pb emplace_back
#define ff first
#define ss second
#define mid(l, r) ((l + r) >> 1)
#define assign(x,val) memset(x,val,sizeof(x))
#define all(x) (x).begin(), (x).end()
#define for0(i,n) for(int i=0;i<n;++i)
#define for1(i,n) for(int i=1;i<=n;++i)
#define ford(i,n) for(int i=n;i>=1;--i)
#define forg(i,a,b) for(int i=a;i<b;++i)
using namespace std;
int  inf = 1e9;
long long mod = 1000000007;
typedef long long ll;
const long double PI = (long double)(3.1415926535897932384626433832795);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(3);
    cout << fixed;
    int n, k;cin>>n>>k;
    int ans = 0;
    int arr[n];for0(i,n){cin>>arr[i];ans += (arr[i]>=k?1:0);}
    cout<<ans<<endl;
}

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

int main() {
  int t=1;
  int n,m;
  while(cin >> n >> m && (n||m)) {
    int win[m+1];
    fill(win,win+m+1,0);
    win[0]=n;
    int turn=0;
    while(win[m]==0) {
      int sum=0;
      for(int i=m-1; i>=0; i--) {
	win[i+1]+=win[i]/2;
	sum+=win[i]/2;
	win[i]-=win[i]/2+win[i]/2;
      }
      win[0]+=sum;
      turn++;
    }
    cout << "Case " << t++ << ": " << turn << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int H,W,K; cin >> H >> W >> K;
    vector<vector<char>> s(H,vector<char>(W));
    rep(i,H)rep(j,W) cin >> s[i][j];
    vector<vector<int>> ans(H,vector<int>(W));
    int now = 1;
    rep(i,H)rep(j,W){
        if(s[i][j] == '#'){
            rep(k,j+1){
                if(ans[i][k] == 0) ans[i][k] = now;
            }
            bool ok = true;
            repr(k,j+1,W){
                if(s[i][k] == '#') ok = false;
            }
            if(ok){
                repr(k,j+1,W) ans[i][k] = now;
            }
            now++;
        }
    }
    rep(i,H)rep(j,W){
        if(ans[i][j] == 0){
            repr(k,i+1,H){
                if(ans[k][j] != 0){
                    ans[i][j] = ans[k][j];
                    break;
                }
            }
            if(ans[i][j] == 0){
                for(int k = i-1; k >= 0; k--){
                    if(ans[k][j] != 0){
                        ans[i][j] = ans[k][j];
                        break;
                    }
                }
            }
        }
    }
    rep(i,H){
        rep(j,W){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 1280
import sys
import collections

while True:
    W, H = map(int, sys.stdin.readline().split())
    if W == 0:
        break
    area = [[-10**80 for i in xrange(H + 2)] for j in xrange(W + 2)]
    result = -1
    for i in xrange(H):
        line = sys.stdin.readline().strip()
        for j in xrange(W):
            if '0' <= line[j] <= '9':
                area[j + 1][i + 1] = int(line[j])
    for i in xrange(H):
        for j in xrange(W):
            area[j + 1][i + 1] = max(area[j + 1][i + 1], area[j + 1][i + 1] + area[j + 1][i] * 10, area[j + 1][i + 1] + area[j][i + 1] * 10)
            result = max(result, area[j + 1][i + 1])
    print result

Measured memory_bytes: 4704
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N + 2];
		for (int i = 1; i <= N; i++)
			A[i] = sc.nextInt();
		sc.close();

		long dist = 0;

		for (int i = 1; i <= N + 1; i++)
			dist += Math.abs(A[i] - A[i - 1]);

		for (int i = 1; i <= N; i++) {
			System.out.println(dist - Math.abs(A[i] - A[i - 1]) - Math.abs(A[i + 1] - A[i]) + Math.abs(A[i + 1] - A[i - 1]));
		}
	}
}

Measured memory_bytes: 66128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    while (true){
        ll h, w;
        cin >> h >> w;
        if (h == 0 && w == 0) break;

        string s;
        rep(i, w) s += '#';
        rep(i, h) cout << s << "\n";
        cout << "\n";
    }
}


Measured memory_bytes: 3124
#include <iostream>
#include <queue>
#include <tuple>

using namespace std;

static std::queue<std::pair<int, int> > u[100005];
static std::queue<std::pair<int, int> > v[100005];
static int c[100005];

void color(int node) {
  while (!u[node].empty()) {
    int u_v = u[node].front().first;
    int u_w = u[node].front().second;
    if (c[u_v] == -1) {
      if (u_w % 2 == 0) {
        c[u_v] = c[node];
      } else {
        c[u_v] = 1 - c[node];
      }
      u[node].pop();
      color(u_v);
    } else {
      u[node].pop();
    }
  }

  while (!v[node].empty()) {
    int v_u = v[node].front().first;
    int v_w = v[node].front().second;
    if (c[v_u] == -1) {
      if (v_w % 2 == 0) {
        c[v_u] = c[node];
      } else {
        c[v_u] = 1 - c[node];
      }
      v[node].pop();
      color(v_u);
    } else {
      v[node].pop();
    }
  }
}

int main() {
  int n;

  cin >> n;

  //std::queue<std::pair<int, int> > u[n+5];
  //std::queue<std::pair<int, int> > v[n+5];
  for (int i = 0; i < n-1; i++) {
    int u_, v_, w_;
    cin >> u_ >> v_ >> w_;
    u[u_].push(std::make_pair(v_, w_));
    v[v_].push(std::make_pair(u_, w_));
  }

  for (int i = 0; i <= n; i++) {
    c[i] = -1;
  }

  c[1] = 0;
  color(1);

  for (int i = 1; i <= n; i++) {
    cout << c[i] << "\n";
  }

  return 0;
}


Measured memory_bytes: 137472
#include <stdio.h>

int main(void) {
	int a, b, c, d;

	scanf("%d%d%d%d", &a, &b, &c, &d);

	while (1) {
		c -= b;
		if (c <= 0) {
			printf("Yes");
			break;
		}
		a -= d; 
		if (a <= 0) {
			printf("No");
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define ull unsigned long long
#define pb push_back
#define mp make_pair
using namespace std;
const int N=1e6+5;
const long long INF = 1e6;
const int mod=998244353;

int main()
{

long long n;
cin>>n;
vector<int> d;
for(long long  i=2;(1LL*i*i)<=n;i++)
{
    if(n%i==0)
       {
           int cnt=0;
        while(n%i==0)
            {
                n/=i;
                cnt++;
            }
            d.pb(cnt);
       }
}
if(n>1) d.pb(1);
int sol=0;
for(int i=0;i<d.size();i++)
{

    int sum=0;
    int cnt=0;
    while(sum<=d[i])
    {
        cnt++;
        sum=sum+cnt;

    }
    sol=sol+cnt-1;

}
cout<<sol;




}


Measured memory_bytes: 3632
#include <cassert>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <vector>

#define EPS (1e-6)
#define EQ(a, b) (std::abs((a) - (b)) < EPS)
using Vector2 = std::complex<double>;
double Dot(Vector2 a, Vector2 b) { return std::real(std::conj(a) * b); }
double Cross(Vector2 a, Vector2 b) { return std::imag(std::conj(a) * b); }

// 外心
// https://ja.wikipedia.org/wiki/%E5%A4%96%E6%8E%A5%E5%86%86
Vector2 Circumcenter(Vector2 a, Vector2 b, Vector2 c) {
  using T = Vector2::value_type;
  T ab2 = Dot(b - a, b - a), bc2 = Dot(c - b, c - b), ca2 = Dot(a - c, a - c);
  T x = bc2 * (ca2 + ab2 - bc2), y = ca2 * (ab2 + bc2 - ca2), z = ab2 * (bc2 + ca2 - ab2);
  return (x * a + y * b + z * c) / (x + y + z);
}

// test
// https://atcoder.jp/contests/abc151/tasks/abc151_f
int main() {
  int n;
  std::cin >> n;
  std::vector<Vector2> v(n);
  for (auto &e : v) {
    int x, y;
    std::cin >> x >> y;
    e.real(x);
    e.imag(y);
  }

  double r = 1e9;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      {
        auto p = (v[i] + v[j]) / 2.0;
        double t = 0;
        for (auto e : v) t = std::max(t, std::abs(e - p));
        r = std::min(r, t);
      }
      for (int k = j + 1; k < n; k++) {
        if (EQ(Cross(v[j] - v[i], v[k] - v[i]), 0.0)) continue;
        auto p = Circumcenter(v[i], v[j], v[k]);
        double t = 0;
        for (auto e : v) t = std::max(t, std::abs(e - p));
        r = std::min(r, t);
      }
    }
  }
  std::cout << std::fixed << std::setprecision(7);
  std::cout << r << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int INF = 1e9;

int main(void){
    int n, m, x;
    cin >> n >> m >> x;
    VI c(n);
    VVI a(n, VI(m));
    REP(i,n){
        cin >> c[i];
        REP(j,m) cin >> a[i][j];
    }
    int ans = INF;
    REP(mask,1<<n){
        VI p(n);
        int s = 0;
        REP(i,n){
            if (((mask >> i) & 1) == 0) continue;
            REP(j,m) p[j] += a[i][j];
            s += c[i];
        }
        bool ok = true;
        REP(j,m) if (p[j] < x) ok = false;
        if (ok) chmin(ans, s);
    }
    if (ans == INF) ans = -1;
    cout << ans << endl;

    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; ++i){
        cin >> H[i];
    }
    int tmpMax = H[0];
    for(int i = 1; i < N; ++ i){
        if(H[i] < tmpMax){
            cout << "No" << endl;
            return 0;
        }else if(H[i] == tmpMax){
            continue;
        }else{
            tmpMax = H[i] - 1;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

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

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n; cin>>n;
  cout << (n-2)*180 << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,c,x,i,j,k;
    int count=0;
    scanf("%d%d%d%d",&a,&b,&c,&x);
    for(i=0;i<=a;i++)
    {
        for(j=0;j<=b;j++)
        {
            for(k=0;k<=c;k++)
            {
                if(500*i+100*j+50*k==x)
                    count++;
            }
        }
    }
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    int n;
    int i;

    scanf("%d", &n);
    printf("%d:", n);
    for (i = 2; i * i <= n; i++){
        while (n % i == 0){
            printf(" %d", i);
            n /= i;
        }
    }
    if (n != 1){
        printf(" %d", n);
    }
    printf("\n");

    return (0);
}

Measured memory_bytes: 1028
A,B = map(int, input().split())
while B != 0: A, B = B, A % B 

ans = 0
if A == 1:
    print(1)
    exit()

c = 2
if A%c == 0:
    ans += 1
while A%c == 0:
    A //= c

c = 3
while c**2 <= A:
    if A == 1:
        break
    if A%c == 0:
        ans += 1
    while A%c == 0:
        A //= c
    c += 2

if A != 1: 
    ans += 1

print(ans+1)

Measured memory_bytes: 38640
#include<stdio.h>
#include<string.h>
int main(){
  int i,slen,j,c;
  char str[102];

  while(fgets(str,102,stdin)!=NULL){
    slen=strlen(str);
    for(i=0;i<slen;i++){
      if(str[i]=='@'){
	c=str[i+1]-'0';
	for(j=0;j<c;j++){
	  printf("%c",str[i+2]);
	}
	i+=2;
      }else{
	printf("%c",str[i]);
      }
    }
  }
 return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 998244353ll;

llong mod_pow(llong n, llong m) {
  if (m == 1) return n;
  llong ret = mod_pow(n, m/2);
  ret = ret * ret % mod;
  if (m&1) {
    ret = ret * n % mod;
  }

  return ret;
}

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

  vector<llong> v(N + 1, 1), ncr(N + 1, 1);
  for (int i = 1; i <= N; ++i) {
    v[i] = v[i - 1] * (M - 1) % mod;
    ncr[i] = ncr[i-1] * (N - i) % mod * mod_pow(i, mod - 2) % mod;
  }

  llong ans = 0;
  for (int i = 0; i <= K; ++i) {
    (ans += v[N - i - 1] * ncr[i] % mod) %= mod;
  }

  cout << ans * M % mod << endl;

  return 0;
}

Measured memory_bytes: 6360
#include<stdio.h>
int main(void)
{
    const int N = 10 + 1;
    int my1, my2, enemy1;
    int i, s;
    while( scanf("%d %d %d", &my1, &my2, &enemy1) == 3)
    {
        bool isUsed[N] = {false};
        isUsed[my1] = isUsed[my2] = isUsed[enemy1] = true;
        s = my1+my2;
        int count = 0;
        for(i = 1; i < N; i++)
        {
            if(!isUsed[i] && s+i <= 20)
            {
                count++;
            }
        }
        //©¦ÄÈ¢ÌÍSÅ7ÈÌÅA4Â Á½ç50ð´¦é
        puts( count>=4 ? "YES" : "NO");
    }
    return 0;
}


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

long long x, num;

int main() {
  cin >> x;
  num = x % 100;
  num = (num + 4) / 5;
  x /= 100;
  if(x >= num)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++) {
      cin >> v[i];
  }
  int q;
  cin >> q;
  vector<int> vc(q);
  for(int i=0; i<q; i++) {
      cin >> vc[i];
  }
  for(int i=0; i<q; i++) {
      cout << (lower_bound(v.begin(),v.end(),vc[i])-v.begin()) << endl;
  }
}


Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int cnt[100005];
signed main() {
    int N;
    cin >> N;
    int cnt2 = 0;
    for(int i = 0; i < N; i++) {
        int A;
        cin >> A;
        cnt[A]++;
        cnt2+=A;
    }
    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++) {
        int B,C;
        cin >> B >> C;
        cnt2 = cnt2+(C-B)*cnt[B];
        cnt[C]+=cnt[B];
        cnt[B] = 0;
        cout << cnt2 << endl;
    }
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if(a == b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;


int main() {
  int n;
  cin >> n;
  map<string, int> strs;
  string str, old;
  bool res = true;
  for (int i = 0; i < n; ++i) {
    cin >> str;
    strs[str]++;
    if (strs[str] >= 2) res = false;
    if (i > 0 && (old.at(old.size() - 1) != str.at(0))) res = false;
    old = str;
  }

  if (res) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    int hp = 0;
    if(s[0] == 'R' && s[1] == 'R') hp++;
    for(int i=1; i<n-1; i++){
        if(s[i] == 'R' && s[i+1] == 'R') hp++;
        if(s[i] == 'L' && s[i-1] == 'L') hp++;
    }
    if(s[n-1] == 'L' && s[n-2] == 'L') hp++;

    int now = s[0], ind = 0;
    int changed = 0;
    for(int i=0; i<k; i++){
        while(changed <= 1){
            ind++;
            if(ind >= n) break;
            if(s[ind] != now){
                changed++;
                now = s[ind];
            }
        }
        if(ind == n){
            if(changed == 1) hp++;
            break;
        }
        else{
            hp += 2;
        }
        changed = 0;
    }

    cout << hp << endl;

    return 0;
}

Measured memory_bytes: 3752
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d,f,g,h,i,j;
	scanf("%d %d",&a,&s);
	f=0;
	h=0;
	for(i=0;i<a;i++){
		scanf("%d",&d);
		if(i==0) {
			f+=d+s;
			g=d;
		}
		else if(i!=0){
			if(f>=d){
				f=0;
			}
			else {
				h+=f-g;
				f=0;
				g=d;
			}
			f+=d+s;
		}
	}
	h+=f-g;
	printf("%d\n",h);
	return 0;
}

Measured memory_bytes: 128
from decimal import *
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

M = mod = 10**9 + 7
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]
def li4():return [float(i) for i in input().rstrip('\n').split(' ')]



n,k = li()
l = sorted(li())
dp = [0]*(k + 1)
helparr = [0] + [1 for i in range(k + 1)]




for i in range(l[0] + 1):dp[i] = 1

curr = 0
for j in range(k + 1):
    curr += dp[j]
    helparr[j + 1] = curr




for i in l[1:]:
    for j in range(k,-1,-1):
        leftind = max(0,j - i)
        dp[j] = (dp[j] + helparr[j] - helparr[leftind])%mod


    curr = 0
    for j in range(k + 1):
        curr += dp[j]
        helparr[j + 1] = curr



print(dp[-1])



Measured memory_bytes: 67180
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt(), m = in.nextInt();
			char[][] a = new char[n][n];
			char[][] b = new char[m][m];

			for (int i = 0; i < n; i++) {
				a[i] = in.nextString().toCharArray();
			}

			for (int i = 0; i < m; i++) {
				b[i] = in.nextString().toCharArray();
			}

			for (int i = 0; i < n-m+1; i++) {
				for (int j = 0; j < n-m+1; j++) {

					boolean ok = true;
					for (int k = i; k < i+m; k++) {
						for (int l = j; l < j+m; l++) {
							if (a[k][l] == b[k-i][l-j]) continue;
							ok = false;
						}
					}
					if (ok) {
						out.println("Yes");
						return;
					}

				}
			}

			out.println("No");

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

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

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

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

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

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 21460
#include <iostream>

int S[100000 + 10];
int T[50000 + 10];

int binarySearch(int* A, int n, int key)
{
  int left = 0;
  int right = n;
  while (left < right)
  {
    int mid = (left + right) / 2;
    if (A[mid] == key) return 1;
    if (A[mid] < key)
    {
      left = mid + 1;
    }
    else if (A[mid] > key)
    {
      right = mid;
    }
  }
  return 0;
}

int main()
{
  int n, q;
  std::cin >> n;
  for (int i = 0; i < n; ++i)
  {
    std::cin >> S[i];
  }

  std::cin >> q;
  for (int i = 0; i < q; ++i)
  {
    std::cin >> T[i];
  }

  int ans = 0;
  for (int i = 0; i < q; ++i)
  {
    ans += binarySearch(S, n, T[i]);
  }

  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 3596
#include <stdio.h>

int main(void)
{
	int a, b;
	int sum;
	int i;
	int soe;
	
	while (scanf("%d %d", &a, &b) != EOF){
		sum = a + b;
		for (i = 0; sum != 0; i++){
			sum /= 10;
		}
		printf("%d\n", i);
	}
	
	return (0);
}

Measured memory_bytes: 1680
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 1e9 + 7;
int n, type[1000];
vector<vi> e;

int rec(int c){
	ll ans = 1;
	if(type[c] % 4 == 0){
		for(int i : e[c]) ans = ans * rec(i) % mod;
		if(type[c] == 4) ans++;
		return ans % mod;
	}
	if(type[c] % 4 == 1){
		for(int i : e[c]) ans += rec(i);
	}
	else if(type[c] % 4 == 2){
		for(int i : e[c]) ans = ans * (1 + rec(i)) % mod;
	}
	if(type[c] < 4) ans += mod - 1;
	return ans % mod;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> n; e.resize(n);
	rep(i, n){
		string s; cin >> s;
		if(s[0] == 'E') type[i] = 0;
		if(s[0] == 'A') type[i] = 1;
		if(s[0] == 'R') type[i] = 2;
		if(s.size() > 1) type[i] += 4;
	}
	rep(i, n - 1){
		int a, b; cin >> a >> b; a--; b--;
		e[a].pb(b);
	}
	cout << rec(0) << endl;
	return 0;
}


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

int l=0, r=0;
bool flag=true;

void solve(int N) {
	int a = 0;
	while (N > 0) {
		for (int i = 0; i < 10; i++) {
			cin >> a;
			if (a > l)
				l = a;
			else if (a > r)
				r = a;
			else 
				flag = false;
		}
		if (flag == true)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
		flag = true;
		l = 0;
		r = 0;
		N--;
	}
}
int main() {
	int n = 0;
	cin >> n;
	solve(n);
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  char c[n];
  for(int i=0;i<n;i++)cin>>c[i];
  bool flag=false;
  for(int i=0;i<n;i++){
    if(c[i]=='Y'){
      flag=true;
    }
  }
  if(flag)cout<<"Four";
  else cout<<"Three";
    return 0;
}


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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

template<class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


double N,M,d;

void input() {
	cin>>N>>M>>d;
}

void solve() {
	double res=(N-d)*(M-1)/N/N;
	if(d!=0) res*=2.;
	cout<<res<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3796
/* Ajay Jadhav */
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
const int N=2e5+5;
long long f[N],h[N],v[N],n;

void update(int idx,long long val)
{
    for(;idx<N;idx+=(idx&-idx)) 
        f[idx]=max(val,f[idx]);
}

long long query(int idx)
{
    long long s=0;
    for(;idx; idx-=(idx&-idx))
        s=max(s,f[idx]);
    return s;
}

void solve()
{
    cin>>n;
    rep(i,0,n) cin>>h[i];
    rep(i,0,n) cin>>v[i];
    rep(i,0,n)
    {
        ll temp=query(h[i]-1)+v[i];
        update(h[i],temp);
    }
    cout<<query(N-1);
}
 
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

int main() {
  char c;
  cin >> c;

  if(c == 'A') cout << 'T';
  else if(c == 'C') cout << 'G';
  else if(c == 'G') cout << 'C';
  else cout << 'A';
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define int long long
#define LONG LLONG_MAX/3;
#define INT INT_MAX/3;
#define mod 1000000007
typedef long long ll;
using namespace std;

int mypow(int a,int b){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1)*a%mod;
	return mypow(a,b/2)*mypow(a,b/2)%mod;
}
int kaijo(int n){
	int ans=1;
	for(int i=1;i<=n;i++){
		ans*=i;
		ans%=mod;
	}
	return ans;
}
int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}

signed main(){
	int a,b;
	cin>>a>>b;
	cout<<a+b/2<<endl;
	return 0;
}


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

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
//#define int ll
int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int N;
vector<int> x(10);
vector<int> y(10);
int divide = 0;

double dfs(int i,vector<int> root) {
	if (i == N){
		double res = 0;
		rep(j, root.size() - 1) {
			auto x1 = x[root[j]-1];
			auto y1 = y[root[j]-1];
			auto x2 = x[root[j+1]-1];
			auto y2 = y[root[j+1]-1];
			auto dist = sqrt(pow(x1 - x2, 2) + pow((y1 - y2), 2));
			res += dist;
			//cout << root[j] << " to " << root[j+1] << " dist " << dist << endl;
		}
		divide++;
		return res;
	}
	double ans = 0;
	rep(j, N) {
		auto r = root;
		auto x = find(ALL(r), j + 1);
		if (x != r.end()) continue;
		r.push_back(j + 1);
		ans += dfs(i + 1, r);
	}
	return ans;
}

signed main() {
	ios::sync_with_stdio(false);
	cin >> N;
	rep(i, N)
		cin >> x[i] >> y[i];
	cout << std::setprecision(11) <<dfs(0,vector<int>()) / divide << endl;
	return 0;
}


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

namespace kyoupuro
{
    class MainClass
    {
        public static void Main()
        {
            MainClass mainClass = new MainClass();
            mainClass.Start();
        }

        void Start() {
            var array = new List<int>(Console.ReadLine().Split('/').Select(int.Parse));

            if(array[0] > 2019 || (array[0]== 2019 && array[1] >= 5)) {
                Console.WriteLine("TBD");
            } else {
                Console.WriteLine("Heisei");
            }
        }
    }
}


Measured memory_bytes: 13268
H,W,A,B=map(int,input().split())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans=0
for i in range(0,H-A):
  former=cmb(i+B-1,i,mod)
  latter=cmb((H-1-i)+(W-1-B),(H-1-i),mod)
  ans+=(former%mod)*(latter%mod)
  ans%=mod

print(ans)

Measured memory_bytes: 122068
#include<iostream>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int cnt = 0;
    rep(x,a+1){
        rep(y,b+1){
            rep(z,c+1){
                if(500*x+100*y+50*z==k)cnt++;
            }
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

const int INF = 100100100;

int main() {
    int n; cin >> n;
    string s[60];
    rep(i, 0, n) {
        cin >> s[i];
    }
    string ans;
    for (char c = 'a'; c <= 'z'; c++) {
        int small = INF;
        rep(i, 0, n) {
            int cnt = 0;
            rep(j, 0, s[i].size()) {
                if (s[i][j] == c) {
                    cnt++;
                }
            }
            small = min(small, cnt);
        }
        rep(i, 0, small) ans += c;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define MP make_pair 
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef const void CV;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
const int INF = (int)1e9;
const int mod = (int)1e9+7;
const int MAX = (int)1e6+5;
LL val[MAX], re_val[MAX];
inline LL mypow(LL v, LL t){
	LL res = 1;
	while(t){
		if(t & 1) res = res*v%mod;
		v = v*v%mod;
		t>>=1;
	}
	return res;
}
void build(){
	LL v = val[0] = 1;
	rep1(i, 1, MAX){
		v = v*i%mod;
		val[i] = v;
	}
	rep(i, MAX) re_val[i] = mypow(val[i], mod-2);
	return ;
}
int main(void){
	build();
	DRI(n);
	if(n == 2){
		puts("1"); return 0;
	}
	int s = (n+1)>>1;
	LL ans = 0;
	LL num = 0;
	for(LL i = s; i < n; ++i){
		LL v = val[i-1];
		v = v*re_val[n-i-1]%mod;
		v = v*re_val[2*i-n]%mod;
		v = v*val[i]%mod;
		v = v*val[n-i-1]%mod;
		ans = (ans + ( ( (v - num)%mod + mod)%mod)*i )%mod;
		num = v;
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 16000
#include <iostream>
using namespace std;
int main()
{
	//Boxes
	int A ,B, C;
	//instant
	int N;
	//input
	cin >> A >> B >> C;
	//changeA<->B
	N = A;
	A = B;
	B = N;
	//changeA<->C
	N = A;
	A = C;
	C = N;

	cout << A << " "<< B<<" " << C;

	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(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    vector<LL> A(N);
    rep(i,N)cin >> A[i];

    map<LL,LL> m;
    rep(i,N)m[A[i]]++;

    LL ma = 0;
    LL mb = 0;

    for(auto t : m)if(t.S >= 2)chmax(ma,t.F);
    if(ma != 0)m[ma] -= 2;
    for(auto t : m)if(t.S >= 2)chmax(mb,t.F);

    cout << ma * mb << endl;
}


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

int main(){
	int zu[14][14],w,h,i,j,flag,land;
	

	while(0<=scanf("%1d",&h)){
		
		memset(zu,0,sizeof(zu));
		
		zu[1][1]=h;
		for(i=2;i<=12;i++){
			scanf("%1d",&zu[1][i]);
		}
		
		for(i=2;i<=12;i++){
			for(j=1;j<=12;j++){
				scanf("%1d",&zu[i][j]);
			}
		}
		w=12;
		h=12;
		flag=1;
		land=1;
		while(flag!=0){
			++land;
			flag=0;
			for(i=1;i<=w;i++){
				for(j=1;j<=h;j++){
					if(zu[i][j]==1){
						zu[i][j]=land;
						flag=1;
						break;
					}
				}
				if(flag==1)break;
			}
			
			while(flag==1){
				flag=2;
				for(i=1;i<=w;i++){
					for(j=1;j<=h;j++){
						if(zu[i][j]!=1)continue;
						if(zu[i+1][j]==land || zu[i-1][j]==land || zu[i][j+1]==land || zu[i][j-1]==land ){
							zu[i][j]=land;
							flag=1;
						}
					}
				}
			}
		}
		
		
		printf("%d\n",land-2);
	}
	return 0;
}

Measured memory_bytes: 0
#[allow(unused_imports)]
use proconio::marker::*;
use proconio::*;

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        mut N: Usize1,
    }
    let mut ids = vec![];
    while N > 25 {
        ids.push(N % 26);
        N /= 26;
        N -= 1;
    }
    ids.push(N);
    let alphabets = "abcdefghijklmnopqrstuvwxyz".chars().collect::<Vec<char>>();
    let mut ans = "".to_string();
    for id in ids {
        ans = format!("{}{}", alphabets[id], ans);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2176
#include <stdio.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)

int main() {
	int i=0, n, tmp, ans = 0;
	scanf("%d\n", &n);
	while(i<n) {
		scanf("%d", &tmp);
		if (tmp == i + 1) { ans++; scanf("%d", &tmp); i++; }
		i++;
	}
	printf("%d", ans);
}

Measured memory_bytes: 128
x = int(input())
if 400 <= x < 600:
  print(8)
elif 600 <= x < 800:
  print(7)
elif 800 <= x < 1000:
  print(6)
elif 1000 <= x < 1200:
  print(5)
elif 1200 <= x < 1400:
  print(4)
elif 1400 <= x < 1600:
  print(3)
elif 1600 <= x < 1800:
  print(2)
elif 1800 <= x < 2000:
  print(1)


Measured memory_bytes: 9180
N = int(input())
S = [input()[0] for i in range(N)]
from collections import Counter
ctr = Counter(S)

ans = 0
import itertools
for ptn in itertools.combinations('MARCH', 3):
    a,b,c = ptn
    ans += ctr[a] * ctr[b] * ctr[c]
print(ans)

Measured memory_bytes: 10044
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#define N 210000
#define LL long long
#define inf (1e9)+(1e8)
using namespace std;
struct node{int x,y,d;}a[2*N];
int f[2*N],n,m,q,fa[N];
LL ans;
int find(int x)
{
	if(fa[x]!=x) fa[x]=find(fa[x]);
	return fa[x];
}
bool cmp(node x,node y)
{
	if(x.d<y.d) return 1;
	return 0;
}
int main()
{
	scanf("%d%d",&n,&q);
	for(int i=0;i<2*n;i++) f[i]=inf;
	while(q--)
	{
		int x,y,d;scanf("%d%d%d",&x,&y,&d);
		a[++m].x=x;a[m].y=y;a[m].d=d;
		f[x]=min(f[x],d+1);
		f[y]=min(f[y],d+2);
	}
	for(int i=1;i<2*n;i++) f[i]=min(f[i],f[i-1]+2);
	for(int i=n;i<2*n;i++) f[i-n]=min(f[i-n],f[i]);
	for(int i=0;i<n;i++) if(f[i]!=inf) a[++m].x=i,a[m].y=(i+1)%n,a[m].d=f[i];
	sort(a+1,a+m+1,cmp);
	for(int i=0;i<n;i++) fa[i]=i;
	for(int i=1;i<=m;i++)
	{
		int x=find(a[i].x),y=find(a[i].y);
		if(x!=y)
		{
			ans+=a[i].d;
			fa[x]=y;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
const int N =  123;
int n,m;
int a[N];
int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int s1 = 0,s2 = 0;
    int mn = 1e5 + 1;
    for(int i = 1; i < n; i++)
    {
        s1+=a[i];
        int s = 0;
        for (int j = i + 1; j <= n; j++)
        {
            s+=a[j];
        }
        mn = min(abs(s - s1),mn);
    }
    cout << mn << endl;
    return (0);
}




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

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

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

// 二項係数計算
long long 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(){
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    COMinit();
    long long sum = 0;
    for(int b = B; b <= W-1; b++) {
        sum = (sum + COM(b+H-A-1, b) * COM(A-1+W-1-b ,A-1)  % MOD) % MOD;
    }
    cout << sum << endl;
    //cout << (COM(H-1+W-1, H-1) - sum + MOD ) % MOD << endl;
    return 0;
}

Measured memory_bytes: 12160
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int> PII;


int main(){
    ll h, w;
    cin >> h >> w;
    ll x1 = 0;
    ll x2 = 0;
    if(h % 2 != 0){
        x1 = (h + 1) / 2;
        x2 = x1 - 1;
    }
    else{
        x1 = h / 2;
        x2 = x1;
    }
    ll flag = w / 2;
    ll ans = 0;
    if(w % 2 != 0){
        ans = flag * (x1 + x2) + x1;
    }
    else{
        ans = flag * (x1 + x2);
    }
    if(h == 1 || w == 1) ans = 1;

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


Measured memory_bytes: 256
#include<stdio.h>
#define N 10000
#define M 500
int main(){
  int n,q,key;
  int i,j,r;
  int gen = 0;
  int count = 0;
  int S[N],T[M];
  
  scanf("%d",&n);
  for( i=0 ; i<n ; i++ )
    scanf("%d",&S[i]);

  scanf("%d",&q);
  for( i=0 ; i<q ; i++ )
    scanf("%d",&T[i]);

  for( i=0 ; i<q ; i++ ){
    key = T[i];

    for( j=0 ; j<n ; j++ ){
  
     if( key == S[j] ){
	count++;
	break;
      }
    }
  }

  printf("%d\n",count);
  
  return 0;
}



Measured memory_bytes: 2108
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
string S,T;
ll N,K;
ll A[100005];
ll M = 1000000007;
ll ans = 0;
int main() {
    cin >> K;
    if(K%2==0||K%5==0){
        cout << -1 << endl;
        return 0;
    }
    ll a=1;
    ll b=7;
    ll c = 7;
    while(true){
        c %= K;
        if(c==0){
            cout << a << endl;
            return 0;
        }
        b = b*10;
        b %= K;
        c = b + c;
        a++;
    }
        
}


Measured memory_bytes: 3636
n, m = map(int, input().split())
ab = [[0, 0] for _ in range(n)]
for i in range(n):
    ab[i][0], ab[i][1] = map(int, input().split())
ab.sort()
c = 0
i = 0
while m != 0:
    if ab[i][1] <= m:
        c += ab[i][0] * ab[i][1]
        m -= ab[i][1]
    else:
        c += ab[i][0] * m
        break
    if i == n - 1:
        break
    else:
        i += 1
print(c)


Measured memory_bytes: 21668
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

counter = 0
for i in range(N):
    # print(i)
    num = A[i] - 1
    counter += B[num]
    # print('Add:', B[num])
    if i != 0 and num - 1 == A[i-1] - 1:
        counter += C[num-1]
        # print('Add:', C[num-1])
    # print('')
print(counter)


Measured memory_bytes: 3064