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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int n, x;
    while(1){
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        // int a1=1, a2=1, a3=1;
        int res = 0;
        rep1(i, n){
            Rep1(j, i+1, n){
                Rep1(k, j+1, n){
                    if(i+j+k == x && i!=j && j!=k && i!=k) res++;
                }
            }
        }
        cout << res << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}



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

int main() {
  vector<long> x(3);
  cin >> x.at(0) >> x.at(1) >> x.at(2);
  
  if(x.at(0) % 2 == 0 || x.at(1) % 2 == 0 || x.at(2) % 2 == 0){
    cout << 0 << endl;
  }
  else{
    sort(x.begin(), x.end());
    cout << x.at(0) * x.at(1) << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pb push_back

ll power(int x, unsigned int y){
    ll res = 1;
    while(y > 0){
        if(y & 1) res = res * x;
        y >>= 1;
        x *= x;
    }
    return res;
}

void solve() {
    int n; cin >> n;
    
    int arr[n+1];
    
    for(int i = 1; i <= n; i++)
        cin >> arr[i];

    int dp[n+1];
    fill_n(dp, n+1, INT_MAX);

    dp[1] = 0;

    for(int i = 2; i <= n; i++) {
        dp[i] = min(dp[i], dp[i-1] + abs(arr[i] - arr[i-1]));
        if(i-2 > 0)
        dp[i] = min(dp[i], dp[i-2] + abs(arr[i] - arr[i-2]));
    }

    cout << dp[n];
}

int main(){


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();

}

Measured memory_bytes: 4408
H,W,A,B = map(int, input().split())
MOD = 10 ** 9 + 7

N = H+W+1

def power(base, num):
    if num == 0:
        return 1
    elif num % 2==0:
        return power(base, num//2) **2 % MOD
    elif num==1:
        return base % MOD
    else:
        return power(base, num//2) **2 * base % MOD

fact = [0 for i in range(N)]
inv_fact = [0 for i in range(N)]

fact[0] = 1
for i in range(1, N):
    fact[i] = fact[i-1] * i % MOD
    
inv_fact[H+W] = power(fact[H+W], MOD-2)
for i in range(1, N):
    inv_fact[N-1-i] = inv_fact[N-i] * (N-i) % MOD

    
def comb(x,y):
    return (fact[x] * inv_fact[y])%MOD * inv_fact[x-y] % MOD

ans = 0

for i in range(1, W-B+1):
    ans += comb(H-A+B-2+i, H-A-1) * comb(A-1+W-B-i, A-1) % MOD
    ans %= MOD
print(ans%MOD)


Measured memory_bytes: 18968
#include <stdio.h>
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<complex>
#include<vector>

using namespace std;

int nx[]={0,1,0,-1};
int ny[]={0,1,0,-1};
//*****************************************
int X,Y;
int ans;

int main(void){

    char s[3];
    scanf("%s",s);
    int counter=0;

    if(s[0]=='1') counter++;
    if(s[1]=='1') counter++;
    if(s[2]=='1') counter++;

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





Measured memory_bytes: 256
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()]
ans,j=0,51
for i in a:
    ans+=b[i-1]
    if j+1==i:
        ans+=c[j-1]
    j=i
print(ans)

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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
#define int ll
#define swap(x, y)((x)^=(y)^=(x)^=(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define tcase int _; cin>> _; for( ; _; --_)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

void solve(){
	int wm;
	cin>> n >> wm;
	vi w(n), v(n);

	for(int i = 0; i<n; ++i) cin>> w[i]>> v[i];

	int dp[n*wm+10];
	memset(dp, 0, sizeof(dp));
	int ans = 0;

	for(int i = 0; i < n; ++i)
		for(int j = wm; j >=0; --j)
			if(j + w[i] <= wm){
				dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
				ans = max(dp[j + w[i]], ans);
			}

	cout<< ans << endl;
}

int32_t main(){
	fastio;
	solve();
	return 0;
}

Measured memory_bytes: 81724
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
int BubbleSort(vector<int> vi, int n)
{
  int flag = 1;
  int times = 0;
  int i = 0;
  while(flag)
  {
    flag = 0;
    for(int j=n-1; j>i; j--)
    {
      if(vi[j] < vi[j-1])
      {
        swap(vi[j], vi[j-1]);
        times++;
        flag = 1;
      }
    }
    i++;
  }
  for(i=0; i<n; i++)
  {
    if(i != 0)
      printf(" ");
    printf("%d", vi[i]);
  }
  printf("\n");
  printf("%d\n", times);
  return 0;
}
int main()
{
  vector<int> vi;
  int n;
  scanf("%d", &n);
  for(int i=0; i<n; i++)
  {
    int temp;
    scanf("%d", &temp);
    vi.push_back(temp);
  }
  BubbleSort(vi, n);

  return 0;
}



Measured memory_bytes: 3212
#include<stdio.h>
#define SIZE 100
int stack[SIZE];
int n=0;

void push(int x){
    stack[n]=x;
    n++;
}
int pop(){
    n--;
    return stack[n];
}

int main(void){
    char c;
    int x,a,b;
    
    while((c=getchar())!=EOF){
        if(isdigit(c)){
            ungetc(c,stdin);
            scanf("%d",&x);
            push(x);
        }else{
            switch(c){
                case '+':
                push(pop()+pop());
                break;
                case '-':
                b=pop();
                a=pop();
                push(a-b);
                break;
                case '*':
                push(pop()*pop());
                break;
                case ' ':
                break;
                case '\n':
                printf("%d\n",pop());
                break;
                default:
                break;
            }
        }
    }
}


Measured memory_bytes: 2104
n,x=map(int,input().split())
a,p=[1],[1]
for i in range(n): a+=[a[i]*2+3]; p+=[p[i]*2+1]
def f(n,x):
  return int(x>0) if n<1 else p[n-1]+1+f(n-1,x-2-a[n-1]) if x>a[n]//2 else f(n-1,x-1)
print(f(n,x))

Measured memory_bytes: 9132
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(void){
  int n,a[100000],i;
  long x,y;
  scanf("%d",&n);
  for (i=0;i<n;i++) scanf("%d",&a[i]);
  std::sort(a,a+n);
  i=n-1;
  while (a[i]!=a[i-1]&&i>=0) i--;
  if (i==0){
    printf("0\n");
    return 0;
  }
  x=a[i];
  i-=2;
  while (a[i]!=a[i-1]&&i>=0) i--;
  if (i==0){
    printf("0\n");
    return 0;
  }
  y=a[i];
  printf("%ld\n",x*y);
  return 0;
}

Measured memory_bytes: 512
using System;

namespace v0_0007
{
    class Program
    {
        static void Main(string[] args)
        {
            var week = int.Parse(Console.ReadLine());
            int debt = 100;
            for (int i = 0; i < week; i++)
            {
                debt = ((debt * 105) / 100) + ((debt % 20) > 0 ? 1 : 0);
            }
            Console.WriteLine("{0:f0}000", debt);
        }
    }
}

Measured memory_bytes: 9036
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, b) for (int i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;
const ll num[4] = {-1, 0, 1, 0};

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i, 0, n) cin >> vec[i];
    ll ans = 0;
    rep(i, 0, n)
    {
        ll cta = 0;
        while (vec[i] % 2 == 0)
        {
            ++cta;
            vec[i] /= 2;
        }
        ans += cta;
    }
    cout << ans << endl;
}

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

int N, M;
const int MAX_N = 1.0e5 + 10;
int H[MAX_N];
vector<int> G[MAX_N];

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) cin >> H[i];
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (G[i].size() == 0) ans++;
        else {
            bool f = true;
            for (int j = 0; j < G[i].size(); j++) {
                if (H[i] <= H[G[i][j]]) f = false;
            }
            if (f) ans++;
        }
    }

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


Measured memory_bytes: 9172
from collections import deque
n,m = map(int,input().split())
l = []
for i in range(n):
    a = list(input())
    l.append(a)

ans = 0
for i in range(n):
    for j in range(m):
        if l[i][j] == ".":
            bfs = [[-1]*m for k in range(n)]
            bfs[i][j] = 0
            q = deque([])
            q.append((i,j))
            dx = [0,0,-1,1]
            dy = [-1,1,0,0]
            while q:
                x,y = q.popleft()

                for t in range(4):
                    nx = x+dx[t]
                    ny = y + dy[t]

                    if 0 <= nx < n and 0 <= ny < m and bfs[nx][ny] == -1 and l[nx][ny] != "#":
                        q.append((nx,ny))
                        bfs[nx][ny] = bfs[x][y] +1

            for bf in bfs:
                ans = max(ans,max(bf))
            
print(ans)


Measured memory_bytes: 3316
import string
N = int(input())
S = input()
L = []
for i in string.digits:
    for j in string.digits:
        for k in string.digits:
            L.append((i,j,k))
count = 0
for l in L:
    if l[0] not in S:
        continue
    S2 = S[S.index(l[0])+1:]
    if l[1] not in S2:
        continue
    S3 = S2[S2.index(l[1])+1:]
    if l[2] not in S3:
        continue
    count += 1
print(count)

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

#define readv(v) for(auto& var : v) cin >> var;
#define printv(v) for (int var = 0; var < v.size(); var++) cout << (var==0 ? "" : " ") << v[var]; cout << endl;
#define queries(var) int var; cin >> var; while (var--) 
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

using ll = long long int;
using vi = vector<ll>;
using vvi = vector<vi>;

int main(){
    int a, b;
    cin >> a >> b;
    int m = min(a, b);
    int x = max(a, b);
    for (int i = 0; i < x; i++) cout << m;
    cout << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        float answer = 0;
        for (int i = 0; i < N; i++) {
            int a = sc.nextInt();
            answer += (float) 1 / a;
        }
        answer = (float) 1/ answer;
        System.out.println(answer);
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>

#define fir first
#define sec second
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define All(s) (c).begin(), (c).end()
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define repk(i, j, k) for(int (i)=(j);(i)<(k);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;
const ll INF = 10241024;
int N;
vector<int> P(1e5+1);

void input(){
    cin >> N;
    rep(i, N){
        cin >> P[i];
        //cout << P[i] << endl;
    }
}

void solve(){
    input();
    int ans = 0;
    int score = 0;
    bool ok = false;
    
    for (int i=0;i<N-1;i++) {
        if(ok && P[i] >= P[i+1]){
            score++;
        }else if(!ok && P[i] >= P[i+1]){
            ok = true;
            score = 1;
        }else if(ok && P[i] < P[i+1]){
            ok = false;
            chmax(ans ,score);
            score = 0;
        }
    }
    chmax(ans ,score);
    cout << ans << endl;
}
int main () {
    solve();
    return 0;
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long X;
  cin >> X;
  int d = 0;
  long long c = 100;
  while (1){
    d++;
    c *= 1.01;
    if (c >= X){
      cout << d << endl;
      break;
    }
  }
}

Measured memory_bytes: 3584
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define rn return
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


int main(){
    int N,W; cin >> N  >> W;
    vector<vector<char>> C(N,vector<char>(W));
    rep(i,N){rep(j,W) cin >> C[i][j];};
    vector<int> goodi(N);
    vector<int> goodj(W);
    rep(i,N){
        rep(j,W){
            if (C[i][j] == '#') {goodi[i] = 1; goodj[j] = 1;};
        }
    }
    
    rep(i,N){
        rep(j,W){
            if (goodi[i] == 1 & goodj[j] == 1) cout << C[i][j];
        }
        if (goodi[i]) cout << endl;
    }
    
    rn 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

string s;

vector<int> lefts{7,4,1};
vector<int> middle{8,2};
vector<int> rights{9,6,3};

bool is_valid(int l,int r){
	if((exist(lefts,r)&&(exist(middle,l)||exist(rights,l)))||(exist(middle,r)&&exist(rights,l)))return false;
	else return true;
}

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>s;
		if(s[0]=='#')break;
		bool turn=false;
		int l=0,r=s[0]-'0';
		int resa=0;
		repl(i,1,s.length()){
			int ns=s[i]-'0';
			if(turn){//rights
				if(!is_valid(l,ns)){
					l=ns;
					resa++;
				}else{
					r=ns;
					turn=false;
				}
			}else{//lefts
				if(!is_valid(ns,r)){
					r=ns;
					resa++;
				}else{
					l=ns;
					turn=true;
				}
			}
		}

		turn=true;
		l=s[0]-'0',r=0;
		int resb=0;
		repl(i,1,s.length()){
			int ns=s[i]-'0';
			if(turn){//rights
				if(!is_valid(l,ns)){
					l=ns;
					resb++;
				}else{
					r=ns;
					turn=false;
				}
			}else{//lefts
				if(!is_valid(ns,r)){
					r=ns;
					resb++;
				}else{
					l=ns;
					turn=true;
				}
			}
		}
		cout<<min(resa,resb)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3256
s = input()
point = 1
temp = s[0]
ans = 1
while (point < len(s)):
    if len(temp) == 2:
        temp = s[point]
        point += 1
        ans += 1
    else:
        if temp != s[point]:
            temp = s[point]
            point += 1
            ans += 1
        else:
            if point + 1 < len(s):
                temp = s[point] + s[point+1]
                point += 2
                ans += 1
            else:
                point += 2
print(ans)

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

#define M 1000001
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return (key%(M-1)+1); }

int geth(int a,int b){ return (h1(a)+b*h2(a))%M;}

int find(char str[]){
  int i=0;
  int k=getKey(str);
  int j=geth(k,i);
  while(H[j][0] != '\0'){
    if(strcmp(str, H[j])==0){
      return 1;
    }
    i++;
    j=geth(k,i);
  }
  return 0;
}

int insert(char str[]){
  int i=0,j,k=getKey(str);
 
 while(M){
    j=geth(k,i);
    if( H[j][0] == '\0'){
      strcpy(H[j],str);
      return M;
    }
    i++;
  }
  
  
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
  scanf("%d", &n);
    
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
    
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }

  return 0;
}



Measured memory_bytes: 15416
#include <bits/stdc++.h>
#define ll long long
#define ld long double 
#define For(i, a, n) for(long long i = a; (a < n) ? (i < n) : (i > n); (a < n) ? (i++) : (i--))
#define ee 1000000007
#define pb push_back
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
using namespace std;

void solve() {

}

int main() {
    fio;
    ll n, x, t;
    cin >> n >> x >> t;
    ll ans = (t * (ll)ceil((double)n / (double)x));
    cout << ans ;
}

Measured memory_bytes: 3756
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

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

        for (int i = 0; i < M; i++) {
            island[i][0] = sc.nextInt();
            island[i][1] = sc.nextInt();
        }
      
        Arrays.sort(island, Comparator.comparingInt(obj -> obj[1]));

        int nowIsland = 0;
        int bridgeCnt = 0;
        for (int i = 0; i < M; i++) {
            if(island[i][0] >= nowIsland) {
                nowIsland = island[i][1];
                bridgeCnt++;
            }
        }
        System.out.println(bridgeCnt);
    }
}

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


int main() {
	vector<int> V;
	vector<int> K;
	int N;
	int v;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> v;
		V.push_back(v);
		K.push_back(v);
	}
	//for (auto k : K)cout << k << flush;
	//cout << endl;
	sort(V.begin(), V.end());
	float med = float(V[N / 2] + V[N / 2 - 1]) / 2;
	//cout << "med" << med << endl;
	for (auto v : K) {
		if (v < med)cout << V[N / 2] << endl;
		else cout << V[N / 2 - 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 3948
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    String x = sc.next();
    String y = Integer.toString(x.length() - 2);
    System.out.print(x.charAt(0));
    System.out.print(y);
    System.out.println(x.charAt(x.length() -1));
 
  }
}

Measured memory_bytes: 23124
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#define INF 1000000000
#define LM 55555
#define LL long long
using namespace::std;


long long  a[3000], c[10],d[10],now,num, N, K, M, ans, A[100000], AA[100000];
string S, s[100];
bool h,w[10], k[100];
char cc;


int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		ans += a[i] - 1;
	}
	cout << ans<<endl;
	return 0;

}

Measured memory_bytes: 256
if __name__ == '__main__':
	w, h, n = map(int, input().split())
	
	dots = []

	for i in range(0,n):
		x, y, a = map(int, input().split())
		dots.append([x,y,a])

	x_min = 0
	x_max = w
	y_min = 0
	y_max = h

	for i in range(0,n):
		if dots[i][2] == 1 and x_min < dots[i][0]:
			x_min = dots[i][0]
		elif dots[i][2] == 2 and x_max > dots[i][0]:
			x_max = dots[i][0]
		elif dots[i][2] == 3 and y_min < dots[i][1]:
			y_min = dots[i][1]
		elif dots[i][2] == 4 and y_max > dots[i][1]:
			y_max = dots[i][1]

	if x_min >= x_max or y_min >= y_max:
		ans = 0
	else:
		ans = (x_max - x_min) * (y_max - y_min)

	print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
      int n;
      string s;
      cin>>n>>s;
      s.erase(unique(s.begin(),s.end()),s.end());
      cout<<s.size();
  }
  return 0;
}

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


int main(){
    long int A,B,C,K;
    scanf("%ld %ld %ld %ld",&A,&B,&C,&K);
    long int sum=0;
    if (A>K) {
        sum+=K;
        K=0;
    }
    else{
        sum+=A;
        K-=A;
    }
    if (B>K) {
        K=0;
    }
    else{
        K-=B;
    }
    sum-=K;
    printf("%ld\n",sum);
    return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=200000 +117;
const int MM=200000 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
bool mark[NN]={};
int suf[NN]={};
struct seg{
	int ev,od;
	int s[2];
}t[30*NN]={};
int tcnt=0;
int a[NN]={};
int rt[NN]={};
int op[NN]={};
void push_up(int pos){
	int ls=t[pos].s[0];
	int rs=t[pos].s[1];
	t[pos].ev=max(t[ls].ev,t[rs].ev);
	t[pos].od=max(t[ls].od,t[rs].od);
}
int build(int l,int r){
	int pos=++tcnt;
	if(l==r){
		t[pos].ev=0;
		t[pos].od=-1e9+1;
		return pos;
	}
	int mid=(l+r)>>1;
	t[pos].s[0]=build(l,mid);
	t[pos].s[1]=build(mid+1,r);
	push_up(pos);
	return pos;
}
int find(int l,int r,int pos,int x,int kd){
	if(l>=x){
		if(kd)return t[pos].od;
		else return t[pos].ev;
	}
	if(r<x)return -1e9;
	int mid=(l+r)>>1;
	int ret=find(l,mid,t[pos].s[0],x,kd);
	ret=max(ret,find(mid+1,r,t[pos].s[1],x,kd));
	return ret;
}
int modify(int l,int r,int pos,int tar,int v1,int v2){
	int cur=++tcnt;
	if(l==r){
		t[cur].ev=v1;
		t[cur].od=v2;
		return cur;
	}
	int mid=(l+r)>>1;
	if(tar<=mid){
		t[cur].s[0]=modify(l,mid,t[pos].s[0],tar,v1,v2);
		t[cur].s[1]=t[pos].s[1];
	}
	else{
		t[cur].s[0]=t[pos].s[0];
		t[cur].s[1]=modify(mid+1,r,t[pos].s[1],tar,v1,v2);
	}
	push_up(cur);
	return cur;
}
bool chk(int h1,int c1,int h2,int c2,int len){
	int t=c1-c2+suf[len+1];
	if(t>=0){
		int res=find(1,n+1,rt[len+1],h2+1,t&1);;
		return res>=t;
	}
	else return false;
}
void preproc(){
	rt[n+1]=build(1,n+1);
	for(int i=n;i>=1;--i){
		int ev=find(1,n+1,rt[i+1],a[i]+1,0);
		int od=find(1,n+1,rt[i+1],a[i]+1,1);
		ev+=1+mark[i];
		od+=1+mark[i];
		if(ev&1)swap(ev,od);
		rt[i]=modify(1,n+1,rt[i+1],a[i],ev,od);
	}
}
int main(){
	//open();
	n=read();
	int pre=-1;
	for(int i=1;i<=n;++i){
		a[i]=read();
		if(a[i]>pre){
			pre=a[i];
			mark[i]=1;
		}
	}
	for(int i=n;i>=1;--i){
		if(mark[i])suf[i]=suf[i+1]+1;
		else suf[i]=suf[i+1];
	}
	preproc();
	int pre1=-1,pre2=-1;
	int pc1=0,pc2=0;
	bool fail=0;
	for(int i=1;i<=n;++i){
		op[i]=0;
		int h1=pre1,h2=pre2,cnt1=pc1,cnt2=pc2;
		if(a[i]>pre1){
			h1=a[i];
			++cnt1;
		}
		if(chk(h1,cnt1,h2,cnt2,i)||chk(h2,cnt2,h1,cnt1,i)){
			pre1=h1,pre2=h2,pc1=cnt1,pc2=cnt2;
			continue;
		}
		op[i]=1;
		h1=pre1,h2=pre2,cnt1=pc1,cnt2=pc2;
		if(a[i]>pre2){
			h2=a[i];
			++cnt2;
		}
		if(chk(h1,cnt1,h2,cnt2,i)||chk(h2,cnt2,h1,cnt1,i)){
			pre1=h1,pre2=h2,pc1=cnt1,pc2=cnt2;
			continue;
		}
		fail=1;
		break;
	}
	if(fail){
		printf("-1\n");
	}
	else{
		for(int i=1;i<=n;++i){
			putchar('0'+op[i]);
		}
		putchar('\n');
	}
	close();
	return 0;
}

Measured memory_bytes: 70912
#include<iostream>

using namespace std;

int main()
{
	int gross;
	cin >> gross;
	int tax = (gross * 0.08 / 1.08);
	int net = gross - tax;
	if (((net * 108) / 100) == gross) {
		cout << net << endl;
	}
	else {
		cout << ":(" << endl;
	}

    return 0;
}

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

#define mod 1000000007

#define rep(i, n) for(int i=0; i<n; ++i)

using namespace std;
typedef long long ll; 
 
int main(void){
	
	string S;
	
	cin >> S;
	
	bool acgt = false;
	int ans = 0, count = 0;
	
	for(int i=0; i<S.length(); i++){
		if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')
			acgt = true;
		else{
			acgt = false;
			ans = max(ans, count);
			count = 0;
		}
		if(acgt)
			count++;
	}
	
	ans = max(ans, count);
	
	cout << ans;
	
	return 0;
}

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

using namespace std;

typedef long long ll;
const int N=6e2+10;
const int BASE[2]={31,37};

ll pb[2][N],ha[2][N][N];


int n;
string s[2][N];
ll gethash(int type,int xa,int ya,int xb,int yb){
        xa--,ya--;
        int lenx=xb-xa,leny=yb-ya;
        return ha[type][xb][yb]+ha[type][xa][ya]*pb[0][lenx]*pb[1][leny]-ha[type][xa][yb]*pb[0][lenx]-ha[type][xb][ya]*pb[1][leny];
}

bool check(int xa,int ya,int xb,int yb){
        //cout<<xa<<" "<<ya<<" "<<xb<<" "<<yb<<"<->"<<ya<<" "<<xa<<" "<<yb<<" "<<xb<<'\n';
        return gethash(0,xa,ya,xb,yb)==gethash(1,ya,xa,yb,xb);
}

void prepare(){
        for(int i=0;i<=1;i++){
                pb[i][0]=1;
                for(int j=1;j<N;j++) pb[i][j]=pb[i][j-1]*BASE[i];
        }
}
int main(){
        prepare();
        cin>>n;
        for(int i=1;i<=n;i++) {
                cin>>s[0][i];
                s[0][i]=s[0][i]+s[0][i];
                s[0][n+i]=s[0][i];
        }
        for(int i=1;i<=2*n;i++) s[1][i].resize(2*n);
        for(int i=1;i<=2*n;i++)
                for(int j=0;j<2*n;j++) s[1][j+1][i-1]=s[0][i][j];
        for(int type=0;type<=1;type++){
                for(int i=1;i<=n*2;i++)
                        for(int j=1;j<=n*2;j++)
                                ha[type][i][j]=ha[type][i-1][j]*BASE[0]+ha[type][i][j-1]*BASE[1]-ha[type][i-1][j-1]*BASE[0]*BASE[1]+s[type][i][j-1]-'a';
                //for(int i=1;i<=2*n;i++)cout<<s[type][i]<<'\n';
                //cout<<'\n';
        }
        int ans=0;
        for(int sx=1;sx<=n;sx++)
                for(int sy=1;sy<=n;sy++) if (check(sx,sy,sx+n-1,sy+n-1))
                        ans++;
        cout<<ans;
}


Measured memory_bytes: 7040
# include <bits/stdc++.h>
//# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define fors(i, s) for (int i = 0; s[i]; i++)
# define in freopen("input.txt", "r", stdin)
# define out freopen("output.txt", "w", stdout)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define mkp make_pair
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
 
using namespace std;
const int mod = 1e9 + 7;
const int N = 2e5 + 7;

int a[N], b[N];

int main()
{
	speed;
	int n;
	cin >> n;
	forn( i, n ) {
		cin >> a[i];
		b[i] = a[i];
		if ( i ) b[i] = min( b[i], b[i - 1] );
	}
	int cnt = 0;
	forn( i, n ) {
		if ( a[i] == b[i] ) cnt++;
	}
	cout << cnt;
	time;
}


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

int c,d,e;
signed main(){
int n,a,b;cin>>n>>a>>b;
for(int i=0;i<n;i++){
int k;cin>>k;
if(k<=a)c++;
else if(k<=b)d++;
else e++;
}
cout<<min({c,d,e})<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main()
{
    map<string, string> rep{
        {"A", "a"},
        {"B", "b"},
        {"C", "c"}
    };

    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;

    S = S.substr(0, K - 1) + rep[S.substr(K - 1, 1)] + S.substr(K);

    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, count=0;
    cin >> N;
    vector<int> list(N);
    for (int i=0; i<N; i++){
        cin >> list.at(i);
    }
    for (int i=0; i<N; i++){
        int minj = i;
        int j = 0;
        for (j=i; j<N; j++){
            if (list.at(j)<list.at(minj)){
                minj = j;
            }
        }
        if (list.at(minj) != list.at(i)){
            swap(list.at(minj), list.at(i));
            count++;
        }
    }
    for (int i=0; i<N; i++){
        cout << list.at(i);
        if (i!=N-1){
            cout << ' ';
        }
    }
    cout << endl;
    cout << count << endl;
}


Measured memory_bytes: 3112
#include <iostream>
#include <string>

using std::cin;
using std::cout;

int main(int argc, char* argv[]) {
  std::string s, t;
  cin >> s >> t;

  int count = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == t[i]) {
      ++count;
    }
  }
  cout << count;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = (1ll << 31) - 1;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
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; }
template<typename T>
struct RangeUpdateQuery {
	int n;
	vector<T>d;
	RangeUpdateQuery(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, INF);
	}
	int get(int i) {
		update(i, i + 1, -1);
		return d[n + i];
	}
	void update(int a, int b, T x) {
		return update(a, b, x, 1, 0, n);
	}
	void update(int a, int b, T x, int k, int l, int r) {
		// [a,b) [l,r)
		if (r <= a || b <= l)return;
		else if (a <= l&&r <= b) {
			if (x >= 0)d[k] = x;
			return;
		}
		else {
			if (d[k] != INF)d[2 * k] = d[2 * k + 1] = d[k], d[k] = INF;
			update(a, b, x, 2 * k, l, (l + r) / 2);
			update(a, b, x, 2 * k + 1, (l + r) / 2, r);
		}
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	RangeUpdateQuery<int> ruq(n);
	rep(i, 0, q) {
		int com; cin >> com;
		if (com) {
			int i; cin >> i;
			cout << ruq.get(i) << endl;
		}
		else {
			int s, t, x; cin >> s >> t >> x;
			ruq.update(s, t + 1, x);
		}
	}
	return 0;
}

Measured memory_bytes: 3876
N = int(input())
D = {}
for i in range(N):
    a = input()
    if a in D:
        D[a] += 1
    else:
        D[a] = 1


m = max(D.values())
count = []
for key in D:
    if D[key] == m:
        count.append(key)

count.sort()
for i in count:
    print(i)


Measured memory_bytes: 32096
#include<bits/stdc++.h>
#define LL long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define For(i,a,b) for(int i=a;i>=b;i--)
#define Maxn 100

using namespace std;

int read(){
    char c=getchar(); int flag=1, x=0;
    while(!isdigit(c)){ if(c=='-') flag=-1; c=getchar(); }
    while( isdigit(c)){ x=x*10+(c-'0'); c=getchar(); }
    return flag*x;
}

int n;
int A[Maxn+10], B[Maxn+10], C[Maxn+10];

signed main(){

    n=read();
    FOR(i,1,n) A[i]=read();
    FOR(i,1,n) B[i]=read();
    FOR(i,1,n-1) C[i]=read();

    int Ans=0; int pre=-1;
    FOR(i,1,n){
        Ans+=B[A[i]];
        if(pre==A[i]-1) Ans+=C[pre];
        pre=A[i];
    }

    cout<<Ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  C - City Savers
//
//  Created by Hashizo on 2019/07/27.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>

using namespace std;

#undef INT_MAX
#undef INT_MIN

#define INT_MAX	2147483647
#define INT_MIN	(-INT_MAX  -1)

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define REPLACE(s, f, t) regex_replace(s, regex(f), t)

int main(int argc, const char * argv[]) {
	int n;
	cin >> n;
	
	long a[n+1];
	long b[n];
	
	REP(i, n+1) {
		cin >> a[i];
	}
	REP(i, n) {
		cin >> b[i];
	}

	long cnt = 0;
	REP(i, n) {
		if(a[i] > b[i]) {
			cnt += b[i];
			continue;
		}
		else {
			cnt += a[i];
			b[i] -= a[i];
		}
		
		if(a[i+1] > b[i]) {
			cnt += b[i];
			a[i+1] -= b[i];
			continue;
		}
		else {
			cnt += a[i+1];
			a[i+1] = 0;
		}
	}
	
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
typedef long long int ll;

int main(){
	int w,h,n;
	cin >> w >> h >> n;
	int nowx,nowy,ans=0;
	cin >> nowx >> nowy;
	for(int i=1;i<n;i++){
		int x,y; cin >> x >> y;
		int sx = nowx - x;
		int sy = nowy - y;
		if((sx >= 0 && sy >= 0) || (sx < 0 && sy < 0)){
			sx = abs(sx);
			sy = abs(sy);
			while(sx != 0 && sy != 0){
				sx--; sy--; ans++;
			}
			ans += sx; ans += sy;
		}
		else {
			sx = abs(sx);
			sy = abs(sy);
			ans += sx; ans += sy;
		}
		nowx = x; nowy = y;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll       long long
#define DS       pair<int, int>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int a[N];
ordered_set<int> os;

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int Len = i - 1;
        int now = os.size() - os.order_of_key(a[i]);
        if (Len == now) ans++;
        os.insert(a[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10368
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int bl=2000;
const char ch[11]="RYGB";
int i,j,k,n,m,a[611][611],b[5101],c[5101],w;
int main(){
	scanf("%d%d%d",&n,&m,&w);memset(b,0,sizeof(b));memset(c,0,sizeof(c));
	for (i=2;i<=n+m;i++)
	 if (i-w>=2) b[i]=b[i-w]^1;else b[i]=0;
	for (i=1-m;i<=n-1;i++)
	 if (i-w>=1-m) c[i+bl]=c[i-w+bl]^1;else c[i+bl]=0;
	for (i=1;i<=n;i++)
	 for (j=1;j<=m;j++){
	 	k=b[i+j]*2+c[i-j+bl];
	 	putchar(ch[k]);
	 	if (j==m) puts("");
	 }
	return 0;
}

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

using namespace std;

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  string s;
  cin>>s;
  cout<<s.substr(0,5)<<" "<<s.substr(6,7)<<" "<<s.substr(14,5)<<endl;

  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,T;
  cin>>N>>T;
  int t[N];
  for(int i=0;i<N;i++){
    cin>>t[i];
  }
  
  int ans=T;
  for(int i=0;i<N-1;i++){
    if(t[i+1]-t[i]<T){
      ans+=t[i+1]-t[i];
    }
    else{
      ans+=T;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

const int INF = 1 << 30;
const int MAX = 100010;

int parent(int uft[], int c) {
	if (uft[c] == -1)return c;
	return uft[c] = parent(uft,uft[c]);
}

int main() {
	int N, M;
	int cost[MAX];
	int uft[MAX];
	int group = 0;
	long long ans = 0;

	priority_queue<int, vector<int>, greater<int>> pq1[MAX];
	priority_queue<int, vector<int>, greater<int>> pq2;

	for (int i = 0; i < MAX; i++)uft[i] = -1;

	cin >> N >> M;
	for (int i = 0; i < N; i++)cin >> cost[i];

	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;

		int p1 = parent(uft, x);
		int p2 = parent(uft, y);
		uft[p1] = p2;
	}

	for (int i = 0; i < N; i++) {
		if (parent(uft, i) == i)group++;
		pq1[parent(uft, i)].push(cost[i]);
	}

	for (int i = 0; i < N; i++) {
		if (pq1[i].empty())continue;
		ans += pq1[i].top(); pq1[i].pop();
	}
	
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		while (!pq1[i].empty()) {
			pq2.push(pq1[i].top()); pq1[i].pop();
		}
	}

	if (group == 1) {
		cout << 0 << endl;
	}
	else if (pq2.size() < (group - 1) * 2 - group) {
		cout << "Impossible" << endl;
	}
	else {
		for (int i = 0; i < (group - 1) * 2 - group; i++) {
			ans += pq2.top(); pq2.pop();
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 7296
def solve(n, a, b):
    MOD = 10 ** 9 + 7
    if a > b:
        a, b = b, a
    if a == 1:
        return pow(2, n, MOD)

    # 長さ i の区間であり、右端が '1' であり、
    # はじめ '1' で塗りつぶされていたのを、
    # 長さ a 以上の '0' で0回以上上書きすることで実現できる並びの個数
    dp1 = [0] * (b + 1)
    dp1_acc = [0] * (b + 1)
    dp1[0] = 1
    dp1_acc[0] = 1

    for i in range(1, b + 1):
        tmp = dp1[i - 1]  # 末尾に1を付ける
        if i - a - 1 >= 0:
            tmp = (tmp + dp1_acc[i - a - 1]) % MOD  # 末尾に 00..01 を付ける
        dp1[i] = tmp
        dp1_acc[i] = (dp1_acc[i - 1] + tmp) % MOD
    # 派生情報
    # dp1[i-1]: 長さ i の区間であり、「両端」が'1'であるものの個数
    # dp1[i] - dp1[i-1]: 長さ i の区間であり、左端が'0'、右端が'1'（またはその逆）のものの個数

    # dp2x[i]
    # 長さ i の区間であり、末尾が x であり、
    # 長さa以上の'0'も、長さb以上の'1'も含まない01の並びの個数
    # ただし'1'は、dp1で求めたように、その内部をa個以上の'0'で置きかえたものも含む
    dp20 = [0] * (n + 1)
    dp21 = [0] * (n + 1)
    dp21_acc = [0] * (n + 1)
    dp20[0] = dp21[0] = dp21_acc[0] = 1
    for i in range(1, n + 1):
        t0 = dp21_acc[i - 1]
        if i >= a:
            t0 -= dp21_acc[i - a]
        dp20[i] = t0 % MOD

        t1 = 0
        for j in range(1, min(i + 1, b)):
            t1 += dp20[i - j] * dp1[j - 1]
        # 左端が '111...' でb個以上取れないもので、さらに'0'で置きかえられた結果、最左端が'0'のもの
        if i < b:
            t1 += dp1[i] - dp1[i - 1]
        t1 %= MOD
        dp21[i] = t1
        dp21_acc[i] = (dp21_acc[i - 1] + t1) % MOD

    disable = dp20[n] + dp21[n]

    # 最後が'111..'でb個以上取れないもので、
    # さらに'0'で置きかえられた結果、右端が'0'のものが数えられていない
    for i in range(1, b):
        disable += dp20[n - i] * (dp1[i] - dp1[i - 1])

    return (pow(2, n, MOD) - disable) % MOD


n, a, b = map(int, input().split())
print(solve(n, a, b))


Measured memory_bytes: 9804
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;
int main() {
    fast();
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt","w",stdout);
    // #endif
    ll a,b;
    cin >> a >> b;
    ll n=__gcd(a,b);
      set<ll> factors;
    while(n%2==0)
    {
        factors.insert(2);
        n/=2;
    }
    for(ll i=3;i*i<=n;i++)
    {
        while(n%i==0)
        {
            factors.insert(i);
            n/=i;
        }
 
    }
    if(n>1)
        factors.insert(n);
 
    vector<ll>factors1(all(factors));
    factors1.pb(1);
    cout<<factors1.size();

   

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 256