akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")

#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-27 11:08:49
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

  string s; cin >> s;

  int ans = 0;
  vector<int> v(2019, 0);

  for (char c : s) {
    int cur = c - '0';
    vector<int> t(2019, 0);
    ++t[cur];
    for (int i = 0; i < 2019; ++i) {
      t[(10 * i + cur) % 2019] += v[i];
    }
    ans += t[0];
    swap(t, v);
    debug(c, ans);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3680
_,S=input(),input()
numw=S.count('.')
numc,numcmin=0,0
for s in S:
    if s == '#':
        numc = numc + 1
    else:
        numc = numc - 1
        if numc < numcmin:
            numcmin = numc
print(numcmin+numw)

Measured memory_bytes: 3500
#include <iostream>
        #include <vector>
        #include <string>
        #include <stack>
        #include <algorithm>
        using namespace std;

        int binarySearch(vector<int> input, int target){
            int start = 0;
            int end = input.size() -1;
            int result = -1;
            while(start<=end){
                int mid = end - (end-start)/2;
                if(input[mid]==target){
                    result = mid;
                    start = mid+1;
                }else if(input[mid]>target){
                    end = mid-1;
                }else{
                    start = mid+1;
                }
            }
            return result;
        }
        int lis(vector<int> v, int n, int maxVal){
            if(n==0)
                return 0;
            if(v[n-1]<maxVal){
                return max( 1+lis(v, n-1, v[n-1]), lis(v, n-1, maxVal) );
            }else
            return lis(v, n-1, maxVal);
        }
        void sw(string &s, int i, int j){
            char temp = s[i];
            s[i] = s[j];
            s[j] = temp;
        }
        void swap(string &s, int i, int j){
            for(int l=j; l>i; l--){
                sw(s, l, l-1);
            }
        }

        int get(int n){
            if(n%2==1)
                return n;
            return get(n/2);
        }

    int main(){
            #ifndef ONLINE_JUDGE
            freopen("input.in", "r", stdin);
            freopen("output.in", "w", stdout);
            #endif

        int n ; cin>>n;
        int abc[n+1][3];
        for(int i=1; i<n+1; i++){
            for(int j=0; j<3; j++){
                cin>>abc[i][j];
            }
        }
        int dp[n+1][3];
        dp[1][0] = abc[1][0];
        dp[1][1] = abc[1][1];
        dp[1][2] = abc[1][2];
        for(int i=2; i<n+1; i++){
            dp[i][0] = abc[i][0] + max(dp[i-1][1] , dp[i-1][2]);
            dp[i][1] = abc[i][1] + max(dp[i-1][0] , dp[i-1][2]);
            dp[i][2] = abc[i][2] + max(dp[i-1][0] , dp[i-1][1]);
        }
        int temp = max(dp[n][0], max(dp[n][1], dp[n][2]));
        cout<<temp<<"\n";
   }


Measured memory_bytes: 5944
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 x, y, z, k;
vector<i64> a, b, c;
int main() {
  cin >> x >> y >> z >> k;
  read_n(a, x);
  read_n(b, y);
  read_n(c, z);

  vector<i64> ab, abc;
  ab.reserve(x * y);
  for (i64 p : a) {
    for (i64 q : b) {
      ab.push_back(p + q);  
    }
  }
  sort(begin(ab), end(ab), greater<i64>());

  for (i64 i = 0; i < min(ab.size(), 3000ul); ++i) {
    for (i64 j = 0; j < min(c.size(), 3000ul); ++j) {
      abc.push_back(ab[i] + c[j]);
    }
  }
  sort(begin(abc), end(abc), greater<i64>());

  for (i64 i = 0; i < k; ++i) {
    cout << abc[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 42984
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int const N = 2000 + 4;

int a[N][N];
char g[N][N];

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

  int n;
  cin >> n;
  vector<int> a[2];
  a[0].resize(n);
  a[1].resize(n);

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

  for(int i = 1; i < n; ++i)
    a[0][i] += a[0][i-1];

  a[1][0] += a[0][0];
  for(int i = 1; i < n; ++i)
    a[1][i] += max(a[0][i], a[1][i-1]);

  cout << a[1][n-1];
}

Measured memory_bytes: 256
A,B,C,K=(int(x) for x in input().split())
remain_A = K-A
if remain_A<=0:
    print(K)
else:
    remain_B = remain_A - B
    if remain_B <= 0:
        print(A)
    else:
        ans = (A*1) + (B*0) + (remain_B * (-1))
        print(ans)

Measured memory_bytes: 9076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> x(n+1),y(n+1);
    vector<pair<int,int>> p;
    rep(i,n) {
        int t;cin >> t;
        cin >> x[i] >> y[i];
        p.push_back({t,i});
    }
    x[n]=0,y[n]=0;
    p.push_back({0,n});
    sort(p.begin(),p.end());
    for(int i=0;i<n;i++){
        int dis=abs(x[p[i].second]-x[p[i+1].second])+abs(y[p[i].second]-y[p[i+1].second]);
        if(dis>p[i+1].first-p[i].first){
            cout << "No" << endl;
            return 0;
        }
        if(dis%2!=(p[i+1].first-p[i].first)%2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

int main(){
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(),v.end(),greater<int>());
  
  cout << v[0]*10 + v[1] + v[2] << endl;
}

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

int main() {
  int N;
  cin >> N;
  bool P = false;
  bool W = false;
  bool G = false;
  bool Y = false;
  int count = 0;

  for (int i = 0; i < N; i++) {
    string c;
    cin >> c;
    if (c == "P") {
      P = true;
    } else if (c == "W") {
      W = true;
    } else if (c == "G") {
      G = true;
    } else if (c == "Y") {
      Y = true;
    }
  }
  
  if (P) {
    count++;
  }
  if (W) {
    count++;
  }
  if (G) {
    count++;
  }
  if (Y) {
    count++;
  }
  
  if (count == 3) {
    cout << "Three" << endl;
  } else {
    cout << "Four" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s; cin>>s;
    int k; cin>>k;
    set<string> substring;
    for(int i=0; i<s.size(); i++){
        for(int j=1; j<=k and i+j<=s.size(); j++){
            substring.insert(s.substr(i,j));
        }
    }
    int cnt=0;
    for (auto i:substring) {
        cnt++;
        if (cnt==k) {
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1664
s= input()
n=len(s)+1
l = []
ts = s[0]
f = 1
for i in range(1,n-1):
    if s[i] ==ts:
        f += 1
    else:
        l.append([ts,f])
        f = 1
        ts = s[i]
l.append([ts,f])

for i in range(len(l)):
    if l[i][0]=="<":
        if i < len(l)-1:
            if l[i][1] >= l[i+1][1]:
                l[i+1][1] -= 1
            else:
                l[i][1] -= 1

res = [(l[i][1]+1)*l[i][1]//2 for i in range(len(l))]
print(sum(res))

Measured memory_bytes: 106184
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] h = new int[n];
        for(int i = 0; i < n; i++) h[i] = scan.nextInt();
        int[] dp = new int[n];
        dp[1] = Math.abs(h[1] - h[0]);
        for(int i = 2; i < n; i++){
            dp[i] = Math.min(Math.abs(h[i] - h[i - 1]) + dp[i - 1], Math.abs(h[i] - h[i - 2]) + dp[i - 2]);
        }
        System.out.println(dp[n - 1]);
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 58992
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1000000000;
const ll inf=LONG_LONG_MAX;
const ll ms=(1e6)+5;


int main()
{
    idfc;
    cout<<fixed<<setprecision(12);
    ld a,b,h,m;
    cin>>a>>b>>h>>m;
    h+=(m/60);
    h*=5;

    ld di=m-h;
    if(0>di)di=60+di;

    di=(di/60)*2*PI;


    ld ans= sqrt((a*a)+(b*b)-(2*b*a*cos(di)));
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4184
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  double r;
  cin >> r;
  printf("%.10f %.10f\n", M_PI*r*r, 2.0*M_PI*r);
  return 0;
}


Measured memory_bytes: 3184
#include<iostream>
#include<algorithm>
using namespace std;
int dp[1 << 20], prev_[1 << 20], a[20][20], H, W;
int main() {
	int T; cin >> T;
	for (int i = 1; i <= T; i++) {
		cin >> W >> H;
		for (int i = 0; i < (1 << W); i++)dp[i] = -1LL << 30;
		for (int i = 0; i < (1 << W); i++)prev_[i] = -1LL << 30;
		for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++)cin >> a[i][j]; }
		prev_[0] = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				for (int k = 0; k < (1 << W); k++) {
					if (prev_[k] <= (-1LL << 20))continue;
					int bit[20]; for (int l = 0; l < W; l++)bit[l] = (k / (1 << l)) % 2;
					if (bit[j] != 1 && (j == 0 || bit[j - 1] != 1)) {
						dp[k + (1 << j)] = max(dp[k + (1 << j)], prev_[k] + a[i][j]);
					}
					dp[k - (1 << j)*bit[j]] = max(dp[k - (1 << j)*bit[j]], prev_[k]);
				}
				for (int k = 0; k < (1 << W); k++) { prev_[k] = dp[k]; dp[k] = -1LL << 30; }
			}
		}
		int maxn = 0; for (int i = 0; i < (1 << W); i++)maxn = max(maxn, prev_[i]);
		cout << "Case " << i << ": " << maxn << endl;
	}
	return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N, M;
    while (cin >> N >> M and N and M) {
        vector<int> dv[102];
        rep(i, N) {
            int d, v;
            cin >> d >> v;
            dv[d].push_back(v);
        }
        rep(i, M+1) {
            sort(dv[i].rbegin(), dv[i].rend());
        }
        int ans = 0;
        for (int d=1; d<=M; ++d) {
            ans += dv[d][0];
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3140
import bisect

n = int(input())
A = [-int(input()) for i in range(n)]

Q = [A[0]] + [0] * (n+1)
le = 1
for i in range(1, n):
    if Q[le-1] <= A[i]:
        Q[le] = A[i]
        le += 1
    else:
        ind = bisect.bisect_right(Q, A[i], 0, le)
        Q[ind] = A[i]
    # print(Q[:10])

print(le)

Measured memory_bytes: 53660
from collections import deque
N = int(input())
G = {i:[] for i in range(N)}
for i in range(N):
    S = input().strip()
    for j in range(N):
        if S[j]=="1":
            G[i].append(j)
cmax = 0
for i in range(N):
    hist = [0 for _ in range(N)]
    hist[i]=1
    num = 0
    heap = deque([(i,1)])
    ind = 0
    while ind==0 and num<N:
        cur = heap.popleft()
        num += 1
        y = cur[0]
        g = cur[1]
        cmax = max(cmax,g)
        for x in G[y]:
            if hist[x]==0:
                heap.append((x,g+1))
                hist[x]=g+1
            elif hist[x]==hist[y]:
                ind = 1
                break
    if ind==1:break
if ind==1:
    print(-1)
else:
    print(cmax)

Measured memory_bytes: 3692
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto s = readln.chomp;
  bool f;
  if (s[0] != 'A') {
    f = true;
  }
  if (!(s[1] >= 'a' && s[1] <= 'z')) {
    f = true;
  }
  if (!(s[$-1] >= 'a' && s[$-1] <= 'z')) {
    f = true;
  }
  auto c_num = s[2..$-1].count!(x=>x == 'C');
  auto s_num = s[2..$-1].count!(x=>x>='a' && x<='z');

  if (c_num != 1) {
    f = true;
  }
  if (s_num != s[2..$-1].length.to!int - 1) {
    f = true;
  }

  if (f) {
    writeln("WA");
  } else {
    writeln("AC");
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s[] = sc.next().split("");
    // int型に変換しておく
    int[] v = new int[4];
    for (int i = 0; i < 4; i++) {
      v[i] = Integer.parseInt(s[i]);
    }
    sc.close();

    // ABCDの間に+,-を入れるかの選択は2^3
    // bit全探索する
    for (int i = 0; i < (1 << 3); i++) {
      int tmp = v[0];
      for (int j = 0; j < 3; j++) {
        if ((1 & i >> j) == 1) {
          tmp += v[j + 1];
        } else {
          tmp -= v[j + 1];
        }
      }
      if (tmp == 7) {
        System.out.print(v[0]);
        for (int j = 0; j < 3; j++) {
          if ((1 & i >> j) == 1) {
            System.out.print("+");
          } else {
            System.out.print("-");
          }
          System.out.print(v[j + 1]);
        }
        System.out.println("=7");
        return;
      }
    }

  }

}


Measured memory_bytes: 21588
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), c
  cout << fixed << setprecision(15);

  ll n;
  string x;
  cin >> n >> x;

  ll pc = 0;
  rep(i, n) {
    if (x[i] == '1') pc++;
  }

  ll res0 = 0;
  ll res1 = 0;
  rep(i, n) {
    res0 = res0 << 1;
    res1 = res1 << 1;
    res0 += x[i] - '0';
    res1 += x[i] - '0';
    res0 %= (pc + 1);
    if (pc > 1) res1 %= (pc - 1);
  }

  vll bf0(n);
  vll bf1(n);
  ll cur0 = 1;
  ll cur1 = 1;
  rep(i, n){
    bf0[i] = cur0;
    cur0 = cur0 << 1;
    cur0 %= (pc+1);
    if(pc > 1) {
      bf1[i] = cur1;
      cur1 = cur1 << 1;
      cur1 %= (pc-1);
    }
  }

  rep(i, n) {
    ll res;
    if(x[i] == '1'){
      if(pc == 1) {
        cout << 0 << endl;
        continue;
      }
      res = res1;
      res -= bf1[n-1-i];
      res += (pc - 1);      
      res %= (pc - 1);
    } else {
      res = res0;
      res += bf0[n-1-i];
      res += (pc + 1);
      res %= (pc + 1);
    }

    ll ans = 1;
    while (res > 0) {
      ans++;
      ll bpc = __builtin_popcount(res);
      res %= bpc;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 6824
#include<iostream>
using namespace std;
int suma, sumb;
signed main(){
  for(int i = 0; i < 4; i++){
    int temp;
    cin >> temp;
    suma += temp;
  }
  for(int i = 0; i < 4; i++){
    int temp;
    cin >> temp;
    sumb += temp;
  }
  cout << max(suma , sumb) << endl;
  return 0;
}



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

typedef long long ll;
#define pb push_back
#define mod 1000000007

// 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;}
string solve(){
    string s;
    cin>>s;
    if(s[s.size()-1]=='s') return s+"es";
    return s+"s";
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // int t;
    // cin>>t;
    // while(t--){
    //     cout<<solve()<<"\n";
    // }
    cout<<solve();
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
#define fori(i,a,b) for(int i=(a);i<(int)(b);i++)
#define repi(i,n) fori(i,0,n)
#define forr(i,a,b) for(int i=int(b-1);i>=int(a);i--)
#define repr(i,n) forr(i,0,n)
#define all(x) (x).begin(),(x).end()
#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mp make_pair
#define pcnt __builtin_popcount
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 solve(){
    //x
    int n;
    cin>>n;
    ll sum=0;
    ll mi=INF;
    repi(i,n){
        ll a,b;
        cin>>a>>b;
        sum+=b;
        if(a>b)chmin(mi,b);
    }
    if(mi==INF)cout<<0<<endl;
    else cout<<sum-mi<<endl;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


signed main(void) {
    int n;
    cin >> n;
    vs s(n);
    rep(i,n) cin >> s[i];
    loop(i,1,n){
        if(s[i].front() != s[i-1].back()){
            cout << "No" << endl;
            return 0;
        }
        rep(j,i)if(s[i] == s[j]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define pback push_back
#define mpair make_pair
#define MODN 1000000007

using namespace std;


int main(){


    int n;
    cin >> n;



    map<vector<int>, int> m;

    ll ans = 0;

    rep(i,n){
        string tmp;
        cin >> tmp;

        vector<int> tmpv(26);

        rep(j,10){
            tmpv[tmp[j] - 'a']++;
        }

        m[tmpv]++;
    }

    for(auto itr = m.begin(); itr != m.end(); itr++){
        ll count = itr->second;

        ans = ans + count * (count - 1) / 2;
    }

    cout << ans << endl;

}

Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  int n;
  cin >> n;
  string d[10] = {"pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"};
  cout << d[n%10] << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <utility>
#include <string>

template<typename T>
class Queue{
 public: 
    Queue(const int capacity){
        data_.resize(capacity);
        head_ = tail_ = 0;
        end_ = capacity;
    }

    void Enqueue(const T &d){
        data_.at(tail_) = d;
        tail_ = (tail_ + 1 >= end_) ? 0 : tail_ + 1;
    }
    T Dequeue(){
        T ret = data_.at(head_);
        head_ = (head_ + 1 >= end_) ? 0 : head_ + 1;
        return ret;
    }
    inline bool IsEmpty(){
        return head_ == tail_;
    }
 protected: 
    std::vector<T> data_;
    int head_, tail_;
    int end_;
};

int main(){
    Queue<std::pair<std::string, int> > q(100001);
    int n, quantum;
    std::cin >> n >> quantum;
    for(int i=0; i<n; i++){
        std::pair<std::string, int> p;
        std::cin >> p.first >> p.second;
        q.Enqueue(p);
    }
    int elapsed_time = 0;
    while(!q.IsEmpty()){
        auto p = q.Dequeue();
        if(p.second > quantum){
            p.second -= quantum;
            elapsed_time += quantum;
            q.Enqueue(p);
        }else{
            elapsed_time += p.second;
            std::cout << p.first << " " << elapsed_time << std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6764
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
A,B,C,D,E,F = map(int,input().split())
A *= 100
B *= 100
check = -1
for i in range(F//A+1):
    for j in range((F-(A*i))//B+1):
        if i == 0 and j == 0:continue
        for k in range((F-(A*i)-(B*j))//C+1):
            for l in range((F-(A*i)-(B*j)-(C*k))//D+1):
                water = A*i+B*j
                sugar = C*k+D*l
                if sugar > water//100*E:continue
                if check < sugar / (water+sugar):
                    check = sugar / (water+sugar)
                    ans = [water+sugar,sugar]
print(*ans)

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {

        new Main().go();
    }

    PrintWriter out;
    Reader in;
    BufferedReader br;

    Main() throws IOException {

        try {

            //br = new BufferedReader( new FileReader("input.txt") );
            in = new Reader("input.txt");
            out = new PrintWriter( new BufferedWriter(new FileWriter("output.txt")) );
        }
        catch (Exception e) {

            //br = new BufferedReader( new InputStreamReader( System.in ) );
            in = new Reader();
            out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
        }
    }

    void go() throws IOException {

        int t = 1;
        while (t > 0) {
            solve();
            //out.println();
            t--;
        }

        out.flush();
        out.close();
    }

    int inf = 2000000000;
    int mod = 1000000007;
    double eps = 0.00000001;

    int n;
    int m;

    //ArrayList<Integer>[] g = new ArrayList[200010];


    void solve() throws IOException {

        int n = in.nextInt();
        int[] a = new int[n];

        for (int i = 0; i < n; i++)
            a[i] = in.nextInt()-1;

        int cnt = 0;

        for (int i = 0; i < n; i++)
            if (a[i] == i) {
                cnt++;
                i++;
            }


        out.println(cnt);
    }


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

    class Pair implements Comparable<Pair>{

        int a;
        int b;

        Pair(int a, int b) {

            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {

            if (a > p.a) return 1;
            if (a < p.a) return -1;
            if (b > p.b) return 1;
            if (b < p.b) return -1;
            return 0;
        }
    }

    class Item {

        int a;
        int b;
        int c;

        Item(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

    }

    class Reader {

        BufferedReader  br;
        StringTokenizer tok;

        Reader(String file) throws IOException {
            br = new BufferedReader( new FileReader(file) );
        }

        Reader() throws IOException {
            br = new BufferedReader( new InputStreamReader(System.in) );
        }

        String next() throws IOException {

            while (tok == null || !tok.hasMoreElements())
                tok = new StringTokenizer(br.readLine());
            return tok.nextToken();
        }

        int nextInt() throws NumberFormatException, IOException {
            return Integer.valueOf(next());
        }

        long nextLong() throws NumberFormatException, IOException {
            return Long.valueOf(next());
        }

        double nextDouble() throws NumberFormatException, IOException {
            return Double.valueOf(next());
        }


        String nextLine() throws IOException {
            return br.readLine();
        }

    }

}

Measured memory_bytes: 37788
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

int get_int(const string &S, int &pos) {
    int beg = pos;
    for(; isdigit(S[pos]); pos++);    
    return stoi(S.substr(beg, pos - beg + 1));
}

class Solver {
  public:
    string S, buf;
    int pos, N;
    
    void solve2() {
        // cerr << "-> " << S.substr(0, pos + 1) << endl;
        bool paren = S[pos] == '(';
        if(paren) pos++;
        do {
            if(isdigit(S[pos])) {
                int rec = get_int(S, pos);
                if(S[pos] == '(') {
                    int now = pos;
                    rep(i, rec) {
                        pos = now;
                        solve2();                        
                        if(buf.size() > N) return;
                    }
                } else {
                    rep(i, rec) {
                        buf.push_back(S[pos]);
                        if(buf.size() > N) return;
                    }
                    pos++;
                }
            } else if(isalpha(S[pos])) {
                do {
                    buf.push_back(S[pos++]);
                } while(paren and isalpha(S[pos]) and buf.size() <= N);
            } else assert(0);
        } while(paren and S[pos] != ')' and buf.size() <= N);
        // cerr << "<- " << S.substr(0, pos + 1) << endl;
        if(paren) pos++;
    }
    
    bool solve() {
        cin >> S >> N;
        if(S == "0" and N == 0) return false;
        pos = 0;
        buf.reserve(N * 2);
        while(buf.size() <= N and pos < S.size()) solve2();
        
        cout << (buf.size() <= N ? "0" : buf.substr(N, 1)) << endl;        
        return true;
    }
    
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int i = 0;
    while(true) {
        Solver s;
        if(not s.solve()) break;
    }
    return 0;
}

Measured memory_bytes: 4340
#include <iostream>
#include <set>
#include <iterator>
using namespace std;
int main(){
    int t, i , AC = 0, WA = 0, TLE = 0, RE = 0;
    string s1 = "AC", s2 = "WA", s3 = "TLE", s4 = "RE", str;

    cin >> t;
    getchar();

    for(i = 0; i < t; i++){
        getline(cin, str);

        if(str == s1)
            AC++;
        else if(str == s2)
            WA++;
        else if(str == s3)
            TLE++;
        else if(str == s4)
            RE++;
    }


    cout << "AC x  " << AC << endl;
    cout << "WA x  " << WA << endl;
    cout << "TLE x  " << TLE << endl;
    cout << "RE x  " << RE << endl;


    return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<vector<int> > A(2, vector<int> (N));
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < N; ++j) {
      cin >> A[i][j];
    }
  }

  vector<int> X(N);
  X[0] = A[0][0];
  for (int i = 1; i < N; ++i) {
    X[i] = X[i - 1] + A[0][i];
  }
  
  vector<int> Y(N);
  Y[N - 1] = A[1][N - 1];
  for (int i = N - 2; i >= 0; --i) {
    Y[i] = Y[i + 1] + A[1][i];
  }

  int ans = X[0] + Y[0];
  for (int i = 0; i < N; ++i) {
    ans = max(ans, X[i] + Y[i]);
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;
const ll inf = 10e17;
const ld eps = 10e-9;

ll solve(void);
ll gcd(ll x, ll y);

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

ll gcd(ll x, ll y)
{
	if (y == 1) { return 1;}
	if (x % y == 0) { return y; }
	return gcd(y, x % y);
}

ll n;
vector<vector<ll>> a;

ll solve(void)
{
	ll x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
	return 0;
}



Measured memory_bytes: 256
#D
from queue import Queue
N,M=map(int,input().split())

X=[[] for i in range(N+1)]
for i in range(M):
    a,b=map(int,input().split())
    X[a].append(b)
    X[b].append(a)

Pas=[0 for i in range(N+1)]
Flag=[True for i in range(N+1)]
Flag[0:2]=[False,False]
st=Queue()
st.put(1)
while not st.empty():
    s=st.get()
    for i in X[s]:
        if Flag[i]:
            Pas[i]=s
            Flag[i]=False
            st.put(i)

result="Yes"
for i in range(2,N+1):
    if Flag[i]:
        result="No"

if result=="Yes":
    print(result)
    for i in range(2,N+1):
        print(Pas[i])
else:
    print(result)

Measured memory_bytes: 103688
package main

import(
  "fmt"
  "bufio"
  "os"
  "strconv"
)
/*
var(
  a, b, c int
)*/

func main(){
  //var a, b, c int
  var sc = bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords) //スペースでトークンを分けるようになってる
  /*
  if sc.Scan(){
  	a, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
  }
  if sc.Scan(){
  	b, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
  }
  if sc.Scan(){
  	c, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
  }
# command-line-arguments
./Main.go:20: a declared and not used
./Main.go:26: b declared and not used
./Main.go:32: c declared and not usedになるなんでやねん！！
*/
  
  sc.Scan()
  a,e:= strconv.Atoi(sc.Text())
  sc.Scan()
  b,e:= strconv.Atoi(sc.Text())
  sc.Scan()
  c,e:= strconv.Atoi(sc.Text())
  if e != nil {
        panic(e)
  }
  
  if a*c <= b{
    fmt.Printf("%d", c)
  }else{ //elseの前に改行入れたら怒られる
    fmt.Printf("%d", b/a)
  }
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a%b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a%b));
    }
}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main(){
    ll a, b; cin >> a >> b;
    ll ans = lcm(a,b);
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<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;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}


const ll MOD = 1e9 + 7;
struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint& operator+=(const mint a) {if ((x += a.x) >= MOD) x -= MOD;return *this;}
  mint& operator-=(const mint a) {if ((x += MOD-a.x) >= MOD) x -= MOD;return *this;}
  mint& operator*=(const mint a) {(x *= a.x) %= MOD;return *this;}
  mint operator+(const mint a) const {mint res(*this);return res+=a;}
  mint operator-(const mint a) const {mint res(*this);return res-=a;}
  mint operator*(const mint a) const {mint res(*this);return res*=a;}
  mint pow(ll b) const {
    mint res(1), a(*this);
    while (b) {
      if (b & 1) res *= a;
      a *= a;
      b >>= 1;
    }
    return res;
  }
  // for prime MOD
  mint inv() const {return pow(MOD-2);}
  mint& operator/=(const mint a) {return (*this) *= a.inv();}
  mint operator/(const mint a) const {mint res(*this);return res/=a;}
};
ostream& operator<<(ostream& os, const mint& a) {os << a.x; return os;}


mint dp[55][55][55 * 55];

int main2() {

  REP(i, 55) REP(j, 55) REP(k, 55 * 55) dp[i][j][k] = 0;

  int N = nextLong();
  int K = nextLong();

  if (K % 2) {
    cout << 0 << endl;
    return 0;
  }

  dp[0][0][0] = 1;
  for (int n = 1; n <= N; n++) {
    for (int a = 0; a <= n; a++) {
      for (int k = 0; k <= n*n; k++) {
        mint cur = dp[n-1][a][k];
        if (cur.x == 0) continue;
        { dp[n][a][k+a] += cur; }
        { dp[n][a][k+a] += cur * mint(a); }
        if (a-1 >= 0) { dp[n][a-1][k+a-1] += cur * mint(a) * mint(a); }
        { dp[n][a+1][k+a+1] += cur; }
        { dp[n][a][k+a] += cur * mint(a); }
      }
    }
  }

  mint ans = dp[N][0][K/2];
  cout << ans << endl;

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 75224
#include <iostream>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	unsigned long long int ans = 1;
	for(int i = 1; i <= n; ++i)
	{
		ans *= i;
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace  std ;
#define       sf scanf
#define      pf printf
#define   pb push_back
#define   mp make_pair
typedef long long  ll;
const int MOD = 1e9+7;
const int   N = 1e6+7;
const ll  INF =  1e18;

#define nr()    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll ar[5000005],br[500005];

int32_t main()
{
    nr();
    ll T, n, nb=0, r=-INF, nc=0;
    cin >> n;
    string sr;
    map<string,ll>_mp;
    vector<string>a;
    while(n--)
    {
        cin >> sr;
        _mp[sr]++;
        r=max(r,_mp[sr]);
        a.pb(sr);

    }
    sort(a.begin(),a.end());

    for(ll i=0; i<a.size(); ++i)
    {
        if(_mp[a[i]]==r && _mp[a[i]]!=-1e2){
            cout<<a[i]<<endl;
            _mp[a[i]]=-1e2;}
    }
}


Measured memory_bytes: 25456
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

int main() {
    long a, b, c, k, ans = -1e9, ma;
    cin >> a >> b >> c >> k;
    ma = max({a, b, c});
    ans = ma;
    for (int i = 0; i < k; i++) {
        ma = ma * 2;
    }
    cout << a + b + c - ans + ma << endl;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int MAX_N = 1000000;
const int INF = 1000100100;

int main()
{
    int ans = -1;
    int n = 0;
    int n_odd = 0;
    vector<int> pol;
    vector<int> pol_odd;
    while(true){
        n++;
        ans = n*(n+1)*(n+2)/6;
        if(ans <= 1000000){
            pol.push_back(ans);
            if(ans % 2 == 1){
                pol_odd.push_back(ans);
                n_odd++;
            }
        }else{
            n--;
            break;
        }
    }

    /*
    vector<vector<int> > dp(n, vector<int>(MAX_N+1));
    rep(i,n) rep(j,MAX_N+1) dp[i][j] = INF;
    rep(j,MAX_N+1) dp[0][j] = j;
    */

    vector<int> dp(MAX_N+1);
    rep(i,MAX_N+1) dp[i] = i;

    for(int i=1; i<n; i++){
        rep(j,MAX_N+1){
            if(j<pol[i]) continue;
            else{
                // dp[i][j] = min(min(dp[i-1][j], dp[i-1][j-pol[i]] + 1), dp[i][j-pol[i]]+1);
                dp[j] = min(dp[j-pol[i]]+1, dp[j]);
            }
        }
    }

    /*
    vector<vector<int> > dp_odd(n_odd, vector<int>(MAX_N+1));
    rep(i,n_odd) rep(j,MAX_N+1) dp_odd[i][j] = INF;
    rep(j,MAX_N+1) dp_odd[0][j] = j;
    */

    vector<int> dp_odd(MAX_N+1);
    rep(i,MAX_N+1) dp_odd[i] = i;

    for(int i=1; i<n_odd; i++){
        rep(j,MAX_N+1){
            if(j<pol_odd[i]) continue;
            else{
                dp_odd[j] = min(dp_odd[j-pol_odd[i]]+1, dp_odd[j]);
            }
        }
    }    
    

    
    while(true){
        int N; cin >> N;

        if(N == 0) break;

        printf("%d %d\n", dp[N], dp_odd[N]);
    }
    
}


Measured memory_bytes: 10556
import sys
input = sys.stdin.readline

MOD = 10**9 + 7

N = int(input())
C = [int(input()) for _ in range(N)]

dp = [0]*(N+1)
c_to_i = [-1]*(2*10**5+1)
dp[0] = 1
c_to_i[C[0]] = 0
for i,c in enumerate(C[1:],1):
    prev_i = c_to_i[c]
    dp[i] = dp[i-1]
    if prev_i != i-1:
        dp[i] += dp[prev_i]
        dp[i] %= MOD
    c_to_i[c] = i

answer = dp[N-1]
print(answer)



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

int main() {
 
    int N;
    int min;
    long long  money = 1000;
    long long stock = 0;
    cin >> N;
    vector<int> A(N+1);

    A[0] = 0;

    for(int i=1;i<=N;i++){
        cin >> A[i];
    }

    min=A[1];

    for(int i=2;i<=N;i++){
        if(min < A[i]){
            stock = money / min;
            money = money % min;
            money = money + stock * A[i];
            min = A[i];
        }else if(min > A[i]){
            min = A[i];
        }
    }
    cout << money << endl;
    return 0;
}

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

int h[100000];
int dp[100000];

int main()
{
	int N;
	cin >> N;
	copy_n(istream_iterator<int>(cin), N, h);
	memset(dp, N, 99999);
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for (int i = 2; i < N; ++i)
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	cout << dp[N-1];
}


Measured memory_bytes: 1024
var n,s,a,c,i:Longint;
begin
	read(n);
	s:=99;
	for i:=1 to n do begin
		c:=0;
		read(a);
		while a mod 2=0 do begin
			a:=a div 2;
			inc(c);
		end;
		if s>c then s:=c;
	end;
	writeln(s);
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;
int N,M;
vector<int> mm[200010];
int a[200010], b[200010], dist[200010] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i,0,M){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        mm[a[i]].push_back(b[i]);
        mm[b[i]].push_back(a[i]);
    }
    bool ans = false;
    rep(i,1,N-1){
        int cnt = 0;
        for(auto &e : mm[i]){
            if(e == 0 || e == N-1){
                cnt++;
            }
        }
        if(cnt == 2) ans = true;
    }
    if(ans){
        print("POSSIBLE");
    }else{
        print("IMPOSSIBLE");
    }

}


Measured memory_bytes: 13552
N = int(input())
s = input()
t = input()
k = -1
for i in range(N):
  if s[i:N] == t[0:N-i]:
    k = i
    break
if k != -1:
  print(len(s+t[N-k:N]))
else:
  print(len(s+t))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
typedef long long ll;

#define rep(i,n) for (int i=0; i<(n); i++)
const int INF =1001001001;
const ll BIG = 1000000007;
const double PI = 3.141592653589793;

int main(){
    ll a;
    long double b;
    cin >> a >> b;
    long long lb = b*a;
    cout << lb << endl;
    return 0;
}


Measured memory_bytes: 3732