akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N;
  std::cin >> N;
  ll ga, sa, ba, gb, sb, bb;
  std::cin >> ga >> sa >> ba;
  std::cin >> gb >> sb >> bb;
  vvl a = vv(3, 2, 0, ll);
  a[0] = std::vector<ll> {ga, gb};
  a[1] = std::vector<ll> {sa, sb};
  a[2] = std::vector<ll> {ba, bb};
  vvl dp = vv(4, N+1, 0, ll);
  for(int i=0;i<3;i++){
    for(int j=0;j<=N;j++){
      if(j<a[i][0]) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = max({dp[i][j], dp[i+1][j-a[i][0]]+a[i][1], dp[i][j-a[i][0]]+a[i][1]});
    }
  }
  ll ans = 0;
  for(int i=0;i<=N;i++) ans = max(ans, dp[3][i] + N - i);
  vvl dp2 = vv(4, ans+1, 0, ll);
  for(int i=0;i<3;i++){
    for(int j=0;j<=ans;j++){
      if(j<a[i][1]) dp2[i+1][j] = dp2[i][j];
      else dp2[i+1][j] = max({dp2[i][j], dp2[i+1][j-a[i][1]]+a[i][0],dp2[i][j-a[i][1]]+a[i][0]});
    }
  }
  ll las = ans;
  for(int i=0;i<=las;i++) ans = max(ans, dp2[3][i] + las - i);
  std::cout << ans << '\n';
  return 0;
}


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

int main(){
  string N;
  cin >> N;
  
  long long int num = 0;
  for (int i = 0; i < (int)(N.length()); i++){
    int keta = N.at(i) - '0';
    num += keta;
  }
  
  if (num % 9 == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3748
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
//--------------------

int main() {

	long N, M; cin >> N >> M;
	long P[100009], Y[100009]; for (int i = 1; i <= M; i++) cin >> P[i] >> Y[i];
	string res[100009]; //M
	long index[100009], Tindex[100009]; for (int i = 1; i <= M; i++) { index[i] = i; Tindex[i] = i; }
	
	//改良。Y[i]を1000000未満にする。

	sort(Tindex + 1, Tindex + M + 1, [&](long a, long b) {return Y[a] < Y[b]; });

	for (int i = 1; i <= M; i++) Y[Tindex[i]] = i;

	//自然数列indexをT[i]が昇順になるようにソートする。
	for (int i = 1; i <= M; i++) Y[i] = 1000000 * P[i] + Y[i]; //出力の原型。

	sort(index + 1, index + M + 1, [&](long a, long b) {return Y[a] < Y[b]; });

	long x = 1; //下六ケタ
	
	for (int i = 1; i <= M; i++) {//年からIDへ
		Y[index[i]] -= (Y[index[i]] % 1000000);
		Y[index[i]] += x;
		x++;
		if (i == M) break;
		if (Y[index[i]] / 1000000 != Y[index[i + 1]] / 1000000) x = 1;

	}

	for (int i = 1; i <= M; i++) { //成型
		res[i] = to_string(Y[i]);

		while (res[i].length() != 12) {
			res[i] = "0" + res[i];
		}

	}

	for (int i = 1; i <= M; i++) cout << res[i] << endl;

}

Measured memory_bytes: 10112
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i - g;
        while ( j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n) {
    for (int h = 1; ; ) {
        if (h > n) break;
        G.push_back(h);
        h = 3 * h + 1;
    }
    
    for (int i = G.size() - 1; i >= 0; i--) {
        insertionSort(A, n, G[i]);
    }
}

int main() {
    cin >> n;
    
    for (int i = 0; i < n; i++) scanf("%d", &A[i]);
    cnt = 0;
    
    shellSort(A, n);
    
    cout << G.size() << endl;
    for (int i = G.size() - 1; i >= 0; i--) {
        printf("%d", G[i]);
        if (i) printf(" ");
    }
    printf("\n");
    printf("%lld\n", cnt);
    for (int i = 0; i < n; i++) printf("%d\n", A[i]);
    
    return 0;
}


Measured memory_bytes: 7156
import sys
N, M, *PS = sys.stdin.read().strip().split()
N = int(N)
ac = [0] * N
wa = [0] * N
for p, s in zip(*[iter(PS)] * 2):
  p = int(p) -1
  if s == "AC":
    ac[p] = 1
  elif ac[p] == 0:
    wa[p] += 1
penalties = sum([w * a for a, w in zip(ac, wa)])
print("{} {}".format(sum(ac), penalties))

Measured memory_bytes: 17992
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)

import operator

N,H,W = map(int,readline().split())
m = map(int,read().split())
RCA = sorted(zip(m,m,m),key=operator.itemgetter(2),reverse=True)

root = list(range(H+W))
size = [0] * (H+W)
no_cycle = [True] * (H+W)

def find_root(x):
    if x == root[x]:
        return x
    path = []
    while True:
        y = root[x]
        if x == y:
            break
        path.append(x)
        x = y
    for p in path:
        root[p] = x
    return root[x]

def merge(x,y):
    x,y = find_root(x),find_root(y)
    sx,sy = size[x],size[y]
    if sx < sy:
        sx,sy = sy,sx
        x,y = y,x
    root[y] = x
    no_cycle[x] = no_cycle[x] and no_cycle[y]

answer = 0
for R,C,A in RCA:
    x,y = R-1,H+C-1
    rx,ry = find_root(x),find_root(y)
    if rx == ry:
        if not no_cycle[rx]:
            continue
        no_cycle[rx] = False
    else:
        if (not no_cycle[rx]) and (not no_cycle[ry]):
            continue
        merge(rx,ry)
    answer += A

print(answer)

Measured memory_bytes: 34680
cost = 10**9
N = 0
M = 0
X = 0

def solve(no, yn, book):
    global N, M, X, cost
    if no == N:
        understand = [0 for i in range(M)]
        c=0
        for i in range(len(yn)):
            if yn[i] == "Y":
                c += book[i][0]
                for j in range(M):
                    understand[j] += book[i][j+1]

        possible = True
        for i in range(M):
            if understand[i] < X:
                possible = False

        if possible:
            if cost > c:
                cost = c

    else:
        solve(no+1, yn+"Y", book)
        solve(no+1, yn+"N", book)

def main():
    global N, M, X, cost
    N, M, X = map(int, input().split())
    book = list()

    for i in range(N):
        b = [int(a) for a in input().split()]
        book.append(b)

    solve(0, "", book)
    if cost == 10**9:
        print(-1)
    else:
        print(cost)

if __name__ == "__main__":
    main()

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


using namespace std;


// Powered by caide (code generator, tester, and library code inliner)


class Solution {
public:
  int n, p;
  long long dp[2][50];
  vector<int> a;

  long long dfs(bool s, int now)
  {
    if(now == n) {
      return s == p;
    }
    if (~dp[s][now]) return dp[s][now];
    long long res = dfs(s, now + 1) + dfs(s ^ (a[now] % 2), now + 1);
    return dp[s][now] = res;
  }

  void solve(std::istream& in, std::ostream& out)
  {
    in >> n >> p;
    a.resize(n);
    for(auto&& i : a) {
      in >> i;
    }
    sort(a.begin(), a.end());
    memset(dp, -1, sizeof dp);
    out << dfs(0, 0) << "\n";
  }
};

void solve(std::istream& in, std::ostream& out)
{
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


  istream& in = cin;


  ostream& out = cout;

  solve(in, out);
  return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, X, M;
ll used[100010];
ll val[100010];

int main() {
  std::cin >> N >> X >> M;

  ll x = X;
  ll cnt = 0;
  ll sum = 0;
  std::vector<ll> S;
  S.emplace_back( 0 );

  rep( i, 100001 )
    used[i] = -1;

  while( true ) {
    if( used[x] != -1 ) {
      break;
    }
    
    used[x] = cnt;
    val[cnt] = x;

    sum = (sum+x);
    S.emplace_back( sum );
    x = (x*x)%M;
    ++cnt;
  }

  ll idx = used[x];

  ll ans = 0;

  if( N <= cnt ) {
    ans += S[N];
  } else {
    ans += S[cnt];
    N -= cnt;
    ll mo = cnt-idx;
    ll sum = S[cnt]-S[idx];

    ans += N/mo*sum+S[N%mo+idx]-S[idx];
  }

  std::cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4868
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))

    check = [True]*10001

    for i in p:
        check[i] = False

    mini = 100000
    index = 1

    for i in range(0,1001):
        if check[i]:
            if mini > abs(x-i):
                #print(mini, abs(x-i), i)
                mini = abs(x-i)
                index = i

    #マイナス
    for i in range(1,1001):
        if mini >= abs(x+i):
            #print(mini, abs(x+i), -i)
            mini = abs(x+i)
            index = -i

    print(index)


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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

const double PI = acos(-1);

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

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double dh = double(60*H+M)/720 * 2*PI;
    double dm = double(M)/60 * 2*PI;
    double xh = A*cos(dh), yh = A*sin(dh);
    double xm = B*cos(dm), ym = B*sin(dm);

    double dx = xh - xm, dy = yh - ym;
    double ans = sqrt(dx*dx + dy*dy);

    printf("%.10f\n", ans);

    return 0;
}


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

int main(){
    int n,x,t;
    cin >> n >> x >> t;
    int ans = (n / x) * t;
    if(n % x) ans += t;
    cout << ans << endl;
}

Measured memory_bytes: 3672
nums = input().split()
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])
  
if a > b:
    tmp = a
    a = b
    b = tmp
if b > c:
    tmp = b
    b = c
    c = tmp
if a > b:
    tmp = a
    a = b
    b = tmp
  
print(a, b, c)

Measured memory_bytes: 7696
#include <bits/stdc++.h>
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define MOD 1000000007
using namespace std;
const long long INF = 3*1e18;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    vector<int> A{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << A[K-1] << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int par[101010];
int cnt[101010];
vector<int> v[101010];
void dfs(int x,int p){
    par[x]=p;
    for(auto to : v[x]){
        if(to==p)continue;
        ++cnt[x];
        dfs(to,x);
    }
}
int main(){
    int n;
    cin>>n;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        --a;--b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs(0,-1);
    queue<int> que;
    int c[n];
    rep(i,n)cin>>c[i];
    sort(c,c+n);
    ll ret=0;
    rep(i,n-1)ret+=c[i];
    rep(i,n){
        if(cnt[i]==0)que.push(i);
    }
    vector<int> ans(n);
    int idx=0;
    while(que.size()){
        int cur=que.front();que.pop();
        ans[cur]=c[idx++];
        for(auto to : v[cur]){
            if(--cnt[to]==0){
                que.push(to);
            }
        }
    }
    cout<<ret<<endl;
    rep(i,n)cout<<ans[i]<<" ";
    cout<<endl;

    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>
#include <cctype>
#include <stdio.h>

using namespace std;


int main() {
	string s;
	string p;
	cin >> s >> p;
	s = s + s;
	bool a = false;
	for (int  i = 0; i < s.size(); i++) {
		if (s.substr(i, p.size()) == p) {
			cout << "Yes" << endl;
			a = true;
			break;
		}
	}
	if (!a) cout << "No" << endl;
}

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

using namespace std;

long long blocked(long long a, long long b, long long c,long long d, long long width) {
    if (width == 1) return 0;
    long long block_width = width / 3;
    if (b / block_width == d / block_width) {
        if (b / block_width == 1 && abs(a / block_width -  c / block_width) >= 2) {
            return min(min(b - block_width + 1, d - block_width + 1), min(2 * block_width - b, 2 * block_width - d)) * 2;
        } else {
            return blocked(a, b % block_width, c, d % block_width, block_width);
        }
    } else {
        return 0;
    }
}

long long dist(long long a, long long b, long long c, long long d) {
    if (abs(a - c) < abs(b - d)) {
        swap(a, b);
        swap(c, d);
    }
    if (b > d) {
        swap(a, c);
        swap(b, d);
    }
    // b <= d and abs(a - c) >= abs(b - d)
    cerr << a << " " << b << " " << c << " " << d << " " << endl;
    return blocked(a, b, c, d, 205891132094649LL) + abs(a - c) + abs(b - d);
}

int main() {
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        long long a, b, c, d;
        cin >> a >> b >> c >> d;
        cout << dist(a - 1, b - 1, c - 1, d - 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cstdint>
#include<cstddef>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = uint_fast64_t;
#define rep(i, n) for (usize i = 0; i < (usize)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i64 a;
string b;
cin >> a >> b;
string c;
rep(i,4){
    if(b[i] != '.')
        c = c + b[i];
}
i64 k = stoi(c);
cout << a * k / 100 << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(){
int n,m,i,b,sum=0,a[10001];
scanf("%d%d",&n,&m);
for(i=0;i<m;i++){
scanf("%d",&a[i]);
sum += a[i];
}
b = n - sum;
if(b<0)
  printf("-1");
else
  printf("%d",b);
return 0;
}


Measured memory_bytes: 1768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  int n,l;
  cin>>n>>l;
  vector<string>s(n);
  rep(i,n)cin>>s[i];
  sort(s.begin(),s.end());
  rep(i,n){
    cout<<s[i];
  }
  cout<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[]a=new int[N];
		for(int i=0;i<N;i++){
			a[i]=sc.nextInt();
		}
		
		Deque<Integer> ad=new ArrayDeque<Integer>();
		
		for(int i=0;i<N;i++){
			if(i%2==N%2){
				ad.offerLast(a[i]);
			}else{
				ad.offerFirst(a[i]);
			}
		}
		for(Integer num : ad){
			System.out.print(num+" ");
		}
		System.out.println();
	}

}



Measured memory_bytes: 97540
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define all(a) a.begin(),a.end()
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//sort 降順
//reverse 逆順
 
int main() {
  ll a;
  ci(a);
  vec b(a);
  for(i,0,a)
    ci(b[i]);
  sort(all(b));
  ll x=1,y=0;
  for(i,0,a){
    if(b[i]==b[i+1])
      x++;
    else{
      if(x%2==1)
        y++;
      x=1;
    }
  }
  co(y);
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){

    int n, y;
    cin>>n>>y;

    for(int i=0; i<=n; ++i){
        for(int j=i; j<=n; ++j){
            if(1000*i + 5000*(j-i) + 10000*(n-j) == y){
                cout<<n-j<<" "<<j-i<<" "<<i<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;

    return 0;
}

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

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(void){
    ll N, ans = 0;
    ll MOD = 1000000007;
    cin >> N;
    vector<ll> A(N);
    if( N == 1 ){ //例外処理
        cout << ans << endl;
        return 0;
    }
    if( N == 2 ){ //例外処理
        ans = 2;
        cout << ans << endl;
        return 0;
    }
    ll hoge = (2*modpow(9, N, MOD) - modpow(8, N, MOD));
    if(hoge < 0){
        hoge += MOD;
    }
    ans = (modpow(10, N, MOD) - hoge) % MOD;
    if(ans < 0){
        ans += MOD;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int H, W;
    cin >> H >> W;
    vector <string> A(H);
    for (int i=0; i<H; i++) cin >> A.at(i);
    for (int i=0; i<W+2; i++) cout << "#";
    cout << "\n";
    for (string a : A) cout << "#"+a+"#\n";
    for (int i=0; i<W+2; i++) cout << "#";
    cout << "\n";
}

Measured memory_bytes: 256
def main():
    N = int(input())
    v = 0
    for _ in range(N):
        d1, d2 = input().split()
        if d1 == d2:
            v += 1
        else:
            v = 0
        if v == 3:
            print('Yes')
            exit()
    print('No')


if __name__ == '__main__':
    main()


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

int main(int argc, char *argv[]) {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  int i = 0;
  for (int j = 1; j < n; ++j) {
    if (a[j] > a[i]) {
      break;
    }
    ++i;
  }

  int cnt = 0;
  while (i < a.size()-1) {
    cnt++;
    i += k-1;
  }

  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

#define eadd(a,b) encode[(b)] = (a)
#define dadd(a,b) decode[(b)] = (a)

map<string, char> encode;
map<char, string> decode;

void solve111(string s) {
    string t = "";
    REP(i,s.size()) {
        t += decode[s[i]];
    }
    string ans = "";
    while (t.size()) {
        string c = "";
        c += t[0];
        c += t[1];
        c += t[2];
        int i = 3;
        while (encode.find(c) == encode.end()) {
            if (i >= t.size()) {
                c = "end";
                t = "";
                break;
            }
            c += t[i++];
        }
        if (c != "end") {
            ans += encode[c];
            REP(j,i) {
                t.erase(t.begin());
            }
        }
    }
    cout << ans << endl;
}

int main() {
    eadd(' ',"101");
    eadd('\'',"000000");
    eadd(',',"000011");
    eadd('-',"10010001");
    eadd('.',"010001");
    eadd('?',"000001");
    eadd('A',"100101");
    eadd('B',"10011010");
    eadd('C',"0101");
    eadd('D',"0001");
    eadd('E',"110");
    eadd('F',"01001");
    eadd('G',"10011011");
    eadd('H',"010000");
    eadd('I',"0111");
    eadd('J',"10011000");
    eadd('K',"0110");
    eadd('L',"00100");
    eadd('M',"10011001");
    eadd('N',"10011110");
    eadd('O',"00101");
    eadd('P',"111");
    eadd('Q',"10011111");
    eadd('R',"1000");
    eadd('S',"00110");
    eadd('T',"00111");
    eadd('U',"10011100");
    eadd('V',"10011101");
    eadd('W',"000010");
    eadd('X',"10010010");
    eadd('Y',"10010011");
    eadd('Z',"10010000");
    
    dadd("00000",'A');
    dadd("00001",'B');
    dadd("00010",'C');
    dadd("00011",'D');
    dadd("00100",'E');
    dadd("00101",'F');
    dadd("00110",'G');
    dadd("00111",'H');
    dadd("01000",'I');
    dadd("01001",'J');
    dadd("01010",'K');
    dadd("01011",'L');
    dadd("01100",'M');
    dadd("01101",'N');
    dadd("01110",'O');
    dadd("01111",'P');
    dadd("10000",'Q');
    dadd("10001",'R');
    dadd("10010",'S');
    dadd("10011",'T');
    dadd("10100",'U');
    dadd("10101",'V');
    dadd("10110",'W');
    dadd("10111",'X');
    dadd("11000",'Y');
    dadd("11001",'Z');
    dadd("11010",' ');
    dadd("11011",'.');
    dadd("11100",',');
    dadd("11101",'-');
    dadd("11110",'\'');
    dadd("11111",'?');
    
    string s;
    while (getline(cin,s)) {
        solve111(s);
    }
    return 0;
}

Measured memory_bytes: 1220
N, Q = map(int, input().split())
s = '.' + input() + '.'
TD = [input().split() for _ in range(Q)]

def check(x):
    #Q回の呪文後の位置をチェック
    #1 <= x <= N
    for t, d in TD:
        if s[x] == t:
            if d == 'L':
                x -= 1
            else:
                x += 1
        if x == 0:
            return -1
        if x == N + 1:
            return 1
    return 0

ok = 0
ng = N + 1
while ng - ok > 1:
    mid = (ok + ng) // 2
    if check(mid) == -1:
        ok = mid
    else:
        ng = mid
l = ok


ok = N + 1
ng = 0
while ok - ng > 1:
    mid = (ok + ng) // 2
    if check(mid) == 1:
        ok = mid
    else:
        ng = mid

r = ng

print(r - l)


Measured memory_bytes: 39344
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


class Seg():
    def __init__(self, na, default, func):
        if isinstance(na, list):
            n = len(na)
        else:
            n = na
        i = 1
        while 2**i <= n:
            i += 1
        self.D = default
        self.H = i
        self.N = 2**i
        if isinstance(na, list):
            self.A = [default] * (self.N) + na + [default] * (self.N-n)
            for i in range(self.N-1,0,-1):
                self.A[i] = func(self.A[i*2], self.A[i*2+1])
        else:
            self.A = [default] * (self.N*2)
        self.F = func

    def find(self, i):
        return self.A[i + self.N]

    def update(self, i, x):
        i += self.N
        self.A[i] = x
        while i > 1:
            i = i // 2
            self.A[i] = self.merge(self.A[i*2], self.A[i*2+1])

    def merge(self, a, b):
        return self.F(a, b)

    def total(self):
        return self.A[1]

    def query(self, a, b):
        A = self.A
        l = a + self.N
        r = b + self.N
        res = self.D
        while l < r:
            if l % 2 == 1:
                res = self.merge(res, A[l])
                l += 1
            if r % 2 == 1:
                r -= 1
                res = self.merge(res, A[r])
            l >>= 1
            r >>= 1

        return res

def main():
    n,q = LI()
    a = [LI() for _ in range(q)]
    def f(a,b):
        return a + b
    seg = Seg(n+1, 0, f)
    r = []
    for c,x,y in a:
        if c == 0:
            seg.update(x,seg.find(x)+y)
        else:
            r.append(seg.query(x,y+1))

    return '\n'.join(map(str,r))


print(main())

Measured memory_bytes: 41568
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <deque>

template<class T>
using Edge = std::pair<T, T>;
template<class T>
using Graph = std::vector<std::vector<Edge<T> > >;

template<class T>
std::vector<T> BellmanFord(Graph<T> &graph, const T &start, const T &end){
    const T V = graph.size();
    const T distanceSup = std::numeric_limits<T>::max();
    const T distanceInf = std::numeric_limits<T>::min();
    const T zero = static_cast<T>(0);

    std::vector<T> distance(V, distanceSup);
    distance[start] = zero;

    std::deque<T> queue;
    std::vector<bool> isInQueue(V,false);
    std::vector<T> count(V,zero);
    queue.emplace_back(start);
    isInQueue[start] = true;
    ++count[start];
    T distanceTmp;
    T pred, suc;
    while(!queue.empty() && distance[end]>distanceInf){
        pred = queue.front();
        queue.pop_front();
        isInQueue[pred] = false;
        for(auto &edge : graph[pred]){
            suc = edge.first;
            distanceTmp = distance[pred] > distanceInf ? distance[pred] + edge.second : distanceInf;
            if(distance[suc] > distanceTmp){
                distance[suc] = distanceTmp;
                if(!isInQueue[suc]){
                    queue.emplace_back(suc);
                    isInQueue[suc] = true;
                    if(++count[suc] >= V){
                        distance[suc] = distanceInf;
                    }
                }
            }
        }
    }

    return distance;
}

int main(int argc, char *argv[]){
    int N,M, P;
    std::cin >> N >> M >> P;
    int A, B;
    int C;
    Graph<int> graph(N);
    for(int i=0; i<M; ++i){
        std::cin >> A >> B >> C;
        --A; --B;
        graph[A].emplace_back(B, P-C);
    }
    auto distance = BellmanFord(graph,0, N-1);
    int score = distance[N-1];
    if(score <= std::numeric_limits<int>::min()){
        score = -1;
    }else if(score >= 0){
        score = 0;
    }else{
        score = -score;
    }
    std::cout << score << std::endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
struct node
{
    int x,y;
} r[105],b[105];
int vis[105][105],used[105],girl[105],n;
bool found(int x)
{
    for(int i=1; i<=n; i++)
    {
        if(vis[x][i]&&!used[i])
        {
            used[i]=1;
            if(girl[i]==0||found(girl[i]))
            {
                girl[i]=x;
                return 1;
            }
        }
    }
    return 0;
}
int main()
{
    int cnt=0,i,j;
    memset(vis,0,sizeof(vis));
    memset(girl,0,sizeof(girl));
    scanf("%d",&n);
    for(i = 1; i<=n; i++)
        scanf("%d%d",&r[i].x,&r[i].y);
    for(i = 1; i<=n; i++)
        scanf("%d%d",&b[i].x,&b[i].y);
    for(i = 1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {
            if(r[i].x<b[j].x&&r[i].y<b[j].y)
                vis[i][j]=1;
        }
    }
     /*for(i = 1; i<=n; i++)
      {
          for(j=1; j<=n; j++)
          printf("%d",vis[i][j]);
          cout<<endl;
      }*/
        for(int i=1; i<=n; i++)
        {
            memset(used,0,sizeof(used));
            if(found(i)) cnt++;
        }
    printf("%d\n",cnt);
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, a, b) = (line[0], line[1] as u64, line[2] as u64);
    let s = read_as_string();

    let mut acc: (u64, u64) = (0, 0);

    for c in s.chars(){
        if c == 'a' && acc.0 + acc.1 < a + b{
            acc.0 += 1;
            println!("Yes");
        }else if c == 'b' && acc.0 + acc.1 < a + b && acc.1 < b{
            acc.1 += 1;
            println!("Yes");
        }else{
            println!("No");
        }
    }

}


Measured memory_bytes: 4732
import numpy as np


def main():
  a=np.zeros((3,3))

  d={}
  for i in range(3):
    a[i]=list(map(int, input().split()))
    for j in range(3):
      d[a[i,j]]=(i,j)
  N=int(input())
  b=[]
  for i in range(N):
    b=int(input())
    if b in d:
      a[d[b]]=1
      
  for i in range(3):
    if a[i].sum()==3:
      print('Yes')
      return
  for i in range(3):
    if a[:,i].sum()==3:
      print('Yes')
      return
  if a[0,0]+a[1,1]+a[2,2]==3:
    print('Yes')
    return
  if a[0,2]+a[1,1]+a[2,0]==3:
    print('Yes')
    return
  
  print('No')
  return
main()

Measured memory_bytes: 21288
// 解説動画解
// 同色が丁度x組になる組合わせは、
// グループの色の割り当て P = M × (M-1)^(N - x - 1)
// グループの分け方 Q = comb(N - 1, N - 1 - x)
// として、P × Q通りある
// これを、x = 0 ~ Kまで計算する
#include <bits/stdc++.h>
using namespace std;

const int MAX = 200010;
const int MOD = 998244353;

// https://drken1215.hatenablog.com/entry/2018/06/08/210000
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long PowMOD[MAX];
long long N, M, K;
void init()
{
    COMinit();
    PowMOD[0] = 1;
    for(int i = 1; i <= N; ++i) {
        PowMOD[i] = PowMOD[i-1] * (M - 1) % MOD;
    }
}

int main() {
    cin >> N >> M >> K;
    init();
    long long res = 0;
    for(int x = 0; x <= K; ++x) {
        long long P = M * PowMOD[N - x - 1] % MOD;
        long long Q = COM(N - 1, N - 1 - x);
        res += P * Q % MOD;
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 9884
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

void Main()
{
	vector<int> c(3);
	rep(i, 3)	cin >> c[i];
	sort(all(c));
	int cnt = 1;
	if (c[0] != c[1])
		cnt++;
	if (c[1] != c[2])
		cnt++;
	cout << cnt;
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


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

int main(){
	string field[3];
	while(1){
		bool b = false,w = false;
		cin >> field[0];
		if(field[0] == "0") break;
		cin >> field[1] >> field[2];
		for(int i = 0;i < 3;i++){
			if(field[i] == "bbb") b = true;
			else if(field[i] == "www") w = true;
		}
		for(int i = 0;i < 3;i++){
			bool bl = true,wh = true;
			for(int j = 0;j < 3;j++){
				if(field[j][i] != 'b') bl = false;
				if(field[j][i] != 'w') wh = false;
			}
			if(bl) b = true;
			if(wh) w = true;
		}
		if(field[0][0] == field[1][1] && field[1][1] == field[2][2]){
			if(field[0][0] == 'b') b = true;
			else if(field[0][0] == 'w') w = true;
		}
		if(field[2][0] == field[1][1] && field[1][1] == field[0][2]){
			if(field[2][0] == 'b') b = true;
			else if(field[2][0] == 'w') w = true;
		}
		if(b) cout << "b" << endl;
		else if(w) cout << "w" << endl;
		else cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 2972
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
const int MOD = 998244353;

int A, B, C, D;
int memo[3010][3010];

int f(int x, int y) {
    if (memo[x][y]!=-1) return memo[x][y];
    if (x==A && y==B) return memo[x][y] = 1;
    if (x==A) return memo[x][y] = A*f(x, y-1)%MOD;
    if (y==B) return memo[x][y] = B*f(x-1, y)%MOD;
    int res = x*f(x, y-1)%MOD;
    res = (res+y*f(x-1, y)%MOD)%MOD;
    res = (res-(x-1)*(y-1)*f(x-1, y-1)%MOD+MOD)%MOD;
    return memo[x][y] = res;
}
 
signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> A >> B >> C >> D;
    rep(i, 3010) rep(j, 3010) memo[i][j] = -1;
    cout << f(C, D) << endl;
}

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

int main(void){
    int N, xbuf, ybuf;
    int zmax, zmin, wmax, wmin;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> xbuf >> ybuf;
        if(i==0){
            zmax = xbuf + ybuf;
            zmin = zmax;
            wmax = xbuf - ybuf;
            wmin = wmax;
        }else{
            zmax = max(zmax, xbuf + ybuf);
            zmin = min(zmin, xbuf + ybuf);
            wmax = max(wmax, xbuf - ybuf);
            wmin = min(wmin, xbuf - ybuf);
        }
    }
    cout << max(zmax - zmin, wmax - wmin);
    return 0;
}

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

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

const double EPS = 1e-10;

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


int main(){
    int n; cin >> n;
    vector<int> a(n),b(n);
    rep(i,n){
        int x,y; cin >> x >> y;
        a[i] = x-y;
        b[i] = x+y;
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    cout << max(a[n-1]-a[0],b[n-1]-b[0]) << endl;

}



Measured memory_bytes: 4840
N, K = map(int, input().split())
V = list(map(int, input().split()))
k = min(N,K)
v = 0
for i in range(k  + 1):
    for j in range(k  - i + 1):
        v_tmp = V[:i] + V[(N - j):]
        v_tmp.sort()
        for l in range(K - (i + j) + 1):
            v = max(v, sum(v_tmp[l:]))
print(v)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define int long long
#define ff first
#define ss second
#define fill(x, v) memset(x, v, sizeof(x))
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define ios std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
/*
std::cout << std::setprecision(9) << f << '\n';//3.141590000;
map<char,int>::reverse_iterator rit;
for(rit = mp.rbegin(); rit!=mp.rend(); rit++)
*/
int n, m, k, t, mod = 1e9 + 7;
int h[200005];
int a[200005];
int dp[200005]; // dp[i] = max beauty obtained  till height i;
int tree[200005];
int32_t main()
{
    ios;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> h[i];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int ans = INT_MIN;
    for (int i = 0; i < n; i++)
    {
        int pre_max = INT_MIN;

        // max dp[i] from i = 0, h[i]-1;
        int x = h[i] - 1;
        ++x;
        while (x)
            pre_max = max(pre_max, tree[x]), x -= x & (-x);

        dp[h[i]] = max(dp[h[i]], pre_max + a[i]);

        //update fenwk tree
        x = h[i];
        ++x;
        while (x <= n)
            tree[x] = max(tree[x], dp[h[i]]), x += x & (-x);

        //update ans
        ans = max(ans, dp[h[i]]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 9832
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll N; cin >> N;
    vector<string> s(N); vi t(N);
    for(int i=0; i<N; i++){
        cin >> s[i] >> t[i];
    }
    string X; cin >> X;
    bool k = false;
    ll sum = 0;
    for(int i=0; i<N; i++){
        if(s[i] == X){
            k = true;
        }
        else if(k == true){
            sum += t[i];
        }
    }
    cout << sum;
}

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

int main() {
    std::string s;
    std::cin >> s;

    bool beautiful = 
      std::all_of(s.begin(), s.end(), 
                  [&](char ch) { return std::count(s.begin(), s.end(), ch) % 2 == 0;});
    std::cout << (beautiful ? "Yes" : "No") << std::endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int n;
  cin >> n;
  ull ans = 1;
  for(int i = 1; i <= n; i++) {
    ans = ans * i % MOD;
  }
  cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define int int64_t
#define watch(x) cout << (#x) << " is " << (x) << endl

const int32_t MAX=1e9+7;
typedef vector<int> vi;
typedef vector<int64_t> vll;

int32_t main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed;

    // Problem code start

    int n;
    cin >> n;
    vi happiness(3);
    vi result(3,0);
    cin >> result[0] >> result[1] >> result[2];
    for(int days=1;days<n;days++){
        int dp[3]={0};
        cin >> happiness[0] >> happiness[1] >> happiness[2];
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(i!=j){
                    dp[i] = max(result[j]+happiness[i], dp[i]);
                }
            }
        }
        for(int k=0;k<3;k++)
            result[k]=dp[k];
    }
    cout << max({result[0],result[1],result[2]});
    return 0;
}

Measured memory_bytes: 3616
class Unionroot:
    def __init__(self, n=0):
        self.d = [-1]*n

    def root(self, x):
        if self.d[x] < 0:
            return x
        self.d[x] = self.root(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return False
        if x > y:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.d[self.root(x)]

deg = [0] * 100005
to = [[] for i in range(100005)]

n, m, k = map(int, input().split())
uf = Unionroot(n)

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    deg[a] += 1
    deg[b] += 1
    uf.unite(a, b)

for i in range(k):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)

ret = []
for i in range(n):
    ans = uf.size(i) - 1 - deg[i]
    for u in to[i]:
        if uf.same(i, u):
            ans -= 1
    ret.append(ans)
print(' '.join([str(r) for r in ret]))


Measured memory_bytes: 33220
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main (int argc, char const *argv[])
{
    int64_t N;
    int64_t ans = 0;
    char str[4];

    scanf("%"PRId64, &N);

    while (sprintf(str, "%"PRId64, N), ((str[0] != str[1]) || (str[1] != str[2]))) {
        N++;
    }

    printf("%"PRId64"\n", N);
}


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

int main()
{

string s ,t;
cin>>s>>t;

int ans = 0;

for(int index = 0;index<s.size();index++)
    if(s[index]!=t[index])
    ans++;
cout<<ans<<endl;
    return 0;
}


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

int main()
{
	int N, X;
	cin >> N >> X;
	vector<int> L(N);
	for (auto& v : L)
	{
		cin >> v;
	}

	int ans = 1;
	int d = 0;
	for (int i = 0; i < N; ++i)
	{
		d += L[i];
		if (d > X)
			break;
		ans++;
	}

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


Measured memory_bytes: 256
N=int(input())
def divisor_enu(N):
   l=[]
   for i in range(2,int(N**0.5)+1):
      cnt=0
      if N%i==0:
         while N%i==0:
            cnt+=1
            N//=i
         l.append(cnt)
   if N != 1:
      l.append(1)
   return l
l=divisor_enu(N)
ans=0
for i in l:
   for j in range(1,11):
      if i >= (1+j)*j//2:
         ans+=1
print(ans)

Measured memory_bytes: 9456
#include<stdio.h>
int main(void)
{
	int i,j,n;
	int flga[200],flgb[200],flgc[200];
	int a[200],b[200],c[200];
	int max[200];
	
	scanf("%d",&n);
	for (i=0;i<n;i++) {
		flga[i]=0;
		flgb[i]=0;
		flgc[i]=0;
		max[i]=0;
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
	}
	for (i=0;i<n;i++) {
		for (j=0;j<n;j++) {
			if(a[i] == a[j] && i != j) {
				flga[i]=1;
			}
			if(b[i] == b[j] && i != j) {
				flgb[i]=1;
			}
			if(c[i] == c[j] && i != j) {
				flgc[i]=1;
			}
		}
		if (flga[i] == 0) {
			max[i]+=a[i];
		}
		if (flgb[i] == 0) {
			max[i]+=b[i];
		}
		if (flgc[i] == 0) {
			max[i]+=c[i];
		}
	}
	for(i=0;i<n;i++){
		printf("%d\n",max[i]);
	}
	 return 0;
}

Measured memory_bytes: 1028
# include <bits/stdc++.h>
  typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second
#define all v.begin(),v.end()
#define fio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef unsigned long long ulll;
 
using namespace std ;
int main () {

     int a,b,k;
     
     cin>>a>>b>>k;
     
     int n = __gcd(a,b);
     vi v;
     int ct=0;
     for(int i=1;i<=n;++i){
         if(n%i==0)
         {   
             v.pb(i);
             ct++;
     }
     }
     //for(auto it=v.begin();it!=v.end();++it)
    // cout<<*it<<" ";
      // v.resize(ct);
      cout<<v[ct-k];
     // cout<<ct;   
     
     
   

  return 0;
}

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

using namespace std;

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

typedef long long ll;
ll mod=998244353;
ll dp[310][90010];
ll dp2[310][90010];
int main()
{
	int n;
	int a[310];
	int sum=0;
	cin >> n;
	rep(i, n)
	{
		cin >> a[i];
		sum+=a[i];
	}
	ll beki=1;
	rep(i, n) beki=(beki*2)%mod;
	dp[0][0]=beki;
	ll inv=(mod+1)/2;
	rep(i, n)
	{
		rep(j, 90001) dp[i+1][j]=dp[i][j];
		rep(j, 90001-a[i]) dp[i+1][j+a[i]]=(dp[i+1][j+a[i]]+inv*dp[i][j])%mod;
	}
	dp2[0][0]=mod-2;
	rep(i, n)
	{
		rep(j, 90001) dp2[i+1][j]=dp2[i][j];
		rep(j, 90001-a[i]) dp2[i+1][j+a[i]]=(dp2[i+1][j+a[i]]+dp2[i][j])%mod;
	}
	ll tmp=0;
	rep(i, 90001)
	{
		if(2*i>=sum)
		{
			tmp=(tmp+dp[n][i])%mod;
			tmp=(tmp+dp2[n][i])%mod;
		}
	}
	tmp=(3*tmp)%mod;
	ll feki=1;
	rep(i, n) feki=(feki*3)%mod;
	ll ans=(3*mod+feki-3*beki+3)%mod;
	ans=(ans+mod-tmp)%mod;
	ans=(ans+mod-3)%mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 425472
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353;
constexpr int MAX = 5000000;


int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n; cin >> n;
	int cnt = (n + 1) / 2;
	cout << fixed << setprecision(12) << (long double)cnt / (long double)n << endl;
	return 0;
}

Measured memory_bytes: 3760