akhauriyash/Code-Regression huggingface dataset:
def calc(list):
    #print list
    d = 0
    a = 0.0
    for c in list:
        if c == "\\":
            d += 1
            a += d - 1 + 0.5
        elif c == "_":
            a += d
        else:
            a += d - 1 + 0.5
            d -= 1
    return a

if __name__ == "__main__":
    line = raw_input()
    areas = []
    mode = False
    d = 0
    edge = 0
    for i in range(len(line)):
        #print i, line[i], d, edge, mode
        c = line[i]
        if mode:
            if c == "\\":
                d += 1
            elif c == "/":
                d -= 1
                if d == 0:
                    areas.append(calc(line[edge:i + 1]))
                    mode = False
        else:
            if c == "\\":
                d += 1
                edge = i
                mode = True
            elif c == "_":
                edge = i
            else:
                edge = i

    last = len(areas)
    high = edge
    if d != 0:
        d = 0
        edge = len(line) - 1
        mode = False
        for i in range(len(line) - 1 , high - 1, -1):
            #print i, line[i], d, edge, mode
            c = line[i]
            if mode:
                if c == "/":
                    d += 1
                elif c == "\\":
                    d -= 1
                    if d == 0:
                        #print i, edge
                        areas.insert(last, calc(line[i:edge + 1]))
                        mode = False
            else:
                if c == "/":
                    d += 1
                    edge = i
                    mode = True
                elif c == "_":
                    edge = i
                else:
                    edge = i

    if len(areas) == 0:
        print 0
        print 0
    else:
        areas = map(int, areas)
        print sum(areas)
        print len(areas),
        for i in range(len(areas) - 1):
            print areas[i],
        print areas[len(areas) - 1]

Measured memory_bytes: 7052
s = gets.chomp
q=gets.to_i
front=Array.new()
behind=Array.new()
front2=Array.new(10)
front2[0]="a"
count=0
for i in 1..q
  query2=gets.to_s
  query=query2.split(' ').map(&:to_s)
  #query2=gets.delete(' ')
  #query=query2.split('')
  #puts query[0]
  #puts query[1]

  #puts "改行"

  if query[0].to_i==1
    count+=1
    #puts "通過"
  else
    if (count+query[1].to_i-1)%2==0
      front.push(query[2])

    else
      behind.push(query[2])

    end
  end
end
s=front.reverse!.join+s+behind.join
#puts s
if count%2==1
  s.reverse!
end
#p front
#p behind
puts s


Measured memory_bytes: 17148
N = int(input())

ans = 0

if N == 1:
    print(ans)
    exit()

second_prime_max = int(N ** 0.5)

check = 2

while check <= second_prime_max:
    if N % check == 0:
        N //= check
        prime_count = 1
        while N % check == 0:
            N //= check
            prime_count += 1
        z_count = 0
        while z_count < prime_count:
            z_count += 1
            ans += 1
            prime_count -= z_count
        second_prime_max = int(N ** 0.5)
    check += 1

if N != 1:
    ans += 1

print(ans)


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

int main() {
  int n;
  scanf("%d", &n);
  __int128 mul = 1;
  bool isz = false;
  bool isb = false;
  for (int i = 0; i < n; ++i) {
    int64_t a;
    scanf("%lld", &a);
    __int128 aa = a;
    mul = mul * aa;
    if (a == 0) {
      isz = true;
      break;
    }
    if (mul > 1000000000000000000LL) {
      isb = true;
    }
  }
  printf("%lld\n", isz ? 0 : (isb ? -1 : int64_t(mul)));
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
    ll X;
    cin >> X;
    vector<pair<ll, int>> v;
    v.push_back(make_pair(0, 0));
    for (ll i = 1;; i++) {
        ll a = i*i*i*i*i;
        if (a - v.back().first > X) break;
        v.push_back(make_pair(-a, -i));
        v.push_back(make_pair(+a, +i));
    }
    sort(v.begin(), v.end());
    for (auto e: v) {
        ll x = e.first;
        auto g = *lower_bound(v.begin(), v.end(), make_pair(x-X, INT_MIN));
        if (g.first == x-X) {
            printf("%d %d\n", e.second, g.second);
            return 0;
        }
    }
}

Measured memory_bytes: 3680
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#include <sstream>

using namespace std;

typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;
float likeabutterfly;
string likeabee;
ll n,m,q,h,k,w;
ll T;

vector<ll> A;

int main()
{
    ll c1,c2,c3,c4,c5,c6;
    ll a,b,c,e,g;
    ll x,y,z;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);


    string s;
    cin >> s;
    bool N = 0;
    bool W = 0;
    bool S = 0;
    bool E = 0;
    n = s.length();
    for(c1 = 0 ;c1 < n; c1++){
        if(s[c1] == 'N'){N = 1;}
        if(s[c1] == 'W'){W = 1;}
        if(s[c1] == 'S'){S = 1;}
        if(s[c1] == 'E'){E = 1;}
    }

 

    string ans = "Yes\n";
    if(((N^S) == 1) || ((E^W) == 1)){ans = "No\n";}
    cout << ans;

	return 0;
}




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

#define kkpareek ios_base::sync_with_stdio(0); cin.tie(0); 
using namespace std;

int dp[3001][3001];

int getLen(string& s, string& t, int i, int j)
{
    if(i >= s.size() || j >= t.size()) return 0;
    
    if(dp[i][j] != -1) return dp[i][j];
    
    if(s[i] == t[j]) return dp[i][j] = 1 + getLen(s,t,i+1,j+1);
                     return dp[i][j] = max(getLen(s,t,i+1,j), getLen(s,t,i,j+1));
}

string getLcs(string& s, string& t, int len)
{
    string ret; int i=0,j=0;
    
    while(len > 0)
    {
        if(s[i] == t[j])
        {
            ret.push_back(s[i]);
            ++i; ++j; --len;
        }
        
        else
        {
            if(dp[i+1][j] > dp[i][j+1]) i++;
            else j++;
        }
    }
    return ret;
}

string ans(string& s, string& t)
{
    int len = getLen(s,t,0,0);
    return getLcs(s,t,len);
}

int main()
{
    kkpareek;
    memset(dp, -1, sizeof(dp));
    
    string s,t; cin >> s >> t;
    cout << ans(s,t);
}
 


Measured memory_bytes: 38656
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<iostream>

int seq[1005];

int main() {
    int n;
    std::cin >> n;
    long long cnt = 0;
    long long tmp;
    for (int i = 1; i <= n; i++) {
        std::cin >> seq[i];
    }
    int tt = -1;
    for (int i = 2; i <= n; i++) {
        if (seq[i] == seq[i - 1]) {
            cnt++;
            seq[i] = --tt;
        }
    }
    std::cout << cnt << std::endl;
}

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

typedef long long LL;

const int maxl = 100 + 10;
LL dp[maxl][2];
LL ans = 0;

int main() {
    int l, k;
    while (~scanf("%d%d", &l, &k)) {
        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;
        for (int i = 0; i < l; i++) {
            for (int j = 0; j < 2; j++) {
                if (dp[i][j]) {
                    dp[i + 1][j ^ 1] += dp[i][j];
                    if (!j)
                        dp[i + k][j ^ 1] += dp[i][j];
                }
            }
        }

        for (int i = 0; i < l; i++)
            ans += dp[i + 1][1];
        printf("%lld\n", ans);
    }
    return 0;
}



Measured memory_bytes: 2740
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
 
#define for0(i,n) for(ll i = 0;i < (n);i++)
#define for1(i,n) for(ll i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define fastio cin.tie(NULL);cout.tie(NULL);ios::sync_with_stdio(false)
#define F first
#define S second
#define EPS 1e-12
#define all(x) (x).begin(),(x).end()
#define INF ll(2e18)
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}cout<<endl;
#define deb1(a) cout<<(a)<<endl;
#define deb2(a,b) cout<<(a)<<" "<<(b)<<endl;
#define deb3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;
 
using namespace std;
 
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ii> vii;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<ll,ll> > vll;
typedef long double LD;
 
const ll mod =  998244353;

/* 
ll nop = 100;
vi primes(nop,1);
 
void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll phi(ll n) {
    ll tot = n;
    for(ll i = 2;i*i <= n;i++) {
        if(n%i == 0) {
            tot -= tot/i;
        }
        while(n%i == 0) {
            n /= i;
        }
    }
    if(n > 1) {
        tot -= tot/n;
    }
    return tot;
}
*/
 
ll gcd(ll a,ll b){    //a larger, b smaller
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}
/*
void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}
 
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
 */
ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}
 
ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans*num)%mod;
        }
        num = (num*num)%mod;
        e>>=1;
    }
    return ans%mod;
}
 
ll modinv(ll a){
    return mexp(a,mod-2);
}

void solve() {
    ll n;
    cin>>n;
    ll p = 26,q = 0,cnt = 1;
    while(q + p < n) {
        q += p;
        p *= 26;
        cnt++;
    }
    ll v = n-q;
    v--;
    string s = "";
    for0(i,cnt) {
        s = char(v%26 + 'a') + s;
         v /= 26; 
    }
    deb1(s);
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    for1(T,t) {
        solve();
    }
    return 0;
}


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

using namespace std;

static const int maxn = 3000 + 5;

int tcoin;
double probability[maxn];

double dp[maxn][maxn];
bool memoize[maxn][maxn];

inline double solve(int pos = 0, int head = 0)
{
      if (pos >= tcoin)
      {
            int tail = tcoin - head;
            return head > tail;
      }
      double &ret = dp[pos][head];
      bool &mem = memoize[pos][head];
      if (mem) return ret;
      mem = 1;
      double sum = 0.0;
      sum += (probability[pos] * solve(pos+1, head+1) + (1 - probability[pos]) * solve(pos+1, head));
      return ret = sum;
}

int main()
{
      cin >> tcoin;
      for (int i = 0; i < tcoin; i++) cin >> probability[i];
      cout << setprecision(10) << solve();
}


Measured memory_bytes: 79744
K = int(input())
n = [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]
print(n[K - 1])

Measured memory_bytes: 3060
from itertools import permutations


def calc_value(permutation):
    a, b, c = permutation
    return abs(b-a) + abs(c-b)


def solve(a, b, c):
    min_value = float("inf")
    for p in permutations([a, b, c], 3):
        value = calc_value(p)
        if value < min_value:
            min_value = value
    return min_value


a, b, c = map(int, raw_input().split())
print solve(a,b,c)

Measured memory_bytes: 2692
#include<iostream>

using namespace std;

int main(){
  int a, b;

  cin >> a >> b;

  int ans = 0;
  if(a >= b){
    ans += a;
    a--;
  } else{
    ans += b;
    b--;
  }
  if(a >= b){
    ans += a;
    a--;
  } else{
    ans += b;
    b--;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	int n, t;

	cin >> n;
	cin >> t;

	vector <int> v;

	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;
		v.emplace_back(a);
	}

	int res = 0;

	for (size_t i = 0; i < v.size(); ++i)
	{
		res += t;

		if (i + 1 < v.size())
		{
			if (t >= v[i + 1] - v[i])
			{
				res -= t - (v[i + 1] - v[i]);
			}
		}
	}

	cout << res;
}

Measured memory_bytes: 1400
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
# stdin = open("sample.txt")

MOD = 1000000007

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def combination(m,n):
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def main():
    a = int(stdin.readline().rstrip())
    s = stdin.readline().rstrip()
    
    if len(s) <= a:
        print(s)
    else:
        print(s[0:a] + '...')
        
main()

Measured memory_bytes: 9964
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define loop(i) for(int i = 0;true; i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define mn 1000000007
int main() {
	int left = -1;
	int right = 1;
	int N;
	cin >> N;
	vi A(N);
	vi S(N);
	for (int i = 0; i < N; i++)
	{
		int temp;
		cin >> temp;
		A[i] = temp;
		S[i]=temp;
	}
	sort(all(S));
	int count = 0;
	for (int i = 0; i < N; i++)
	{
		if (A[i] != S[i]) {
			count++;
			if (count == 1) {
				left = i;
			}
			else if (count == 2) {
				right = i;
			}
		}
	}
	bool f = false;
	if (count==2) {
		if (A[left]==S[right]&&A[right]==S[left]) {
			f = true;
		}
	}
	else if (count==0) {
		f = true;
	}
	cout << YN(f) << endl;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int w, h;
int c[60][60];

void solve(int x, int y)
{
    if (x < 0 || h <= x || y < 0 || w <= y)
        return;
    if (c[x][y] == 0)
        return;
    c[x][y] = 0;
    for (int i = -1; i < 2; i++)
    {
        for (int j = -1; j < 2; j++)
        {
            solve(x + i, y + j);
        }
    }
}

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

    while (1)
    {
        cin >> w >> h;
        if (h == 0)
            break;
        rep(i, h)
        {
            rep(j, w)
            {
                cin >> c[i][j];
            }
        }
        int ans = 0;
        rep(i, h)
        {
            rep(j, w)
            {
                if (c[i][j] == 1)
                {
                    solve(i, j);
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
}


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

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

    vector<int> num(n+1);
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        num[a] += 1;
    }
    sort(num.begin(), num.end());

    // cumulative sum
    vector<int> csum = num;
    for(int i=0; i<n; i++){
        csum[i+1] += csum[i];
    }

    for(int k=1; k<=n; k++){
        long long int upper = 1e6, lower = 0, mid;
        while(upper - lower > 1){
            mid = (upper + lower) / 2;

            int threshold = lower_bound(num.begin(), num.end(), mid) - num.begin() - 1;// remove extra zero
            //cout << threshold << " ";
            long long int sum = csum[threshold] + mid * (n - threshold);

            if(sum >= mid * k) lower = mid;
            else upper = mid;
        }
        cout << lower << endl;
    }
    return 0;
}

Measured memory_bytes: 5556
#include <bits/stdc++.h>
using namespace std;
int N, a;
int A[100000];
long long ans = 1;
int main() {
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> a;
        if(a) ans = (ans * (A[a-1] - A[a])) % 1000000007;
        else ans = (ans * (3 - A[a])) % 1000000007;
        A[a]++;
    }
    cout << ans;
}

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

//ABC102C
int compare_lli(const void *a, const void *b) {
  long long *A=(long long *) a, *B=(long long *) b;
  if(*A>*B) return 1;
  if(*A<*B) return -1;
  return 0;
}

int main(void) {
  long long n, k, i, cou=0, tmp;
  scanf("%lld", &n);
  long long a[n];
  for(i=0; i<n; i++){
    scanf(" %lld", &a[i]);
    a[i]-=i+1;
  }
  qsort(a, n, sizeof(long long), compare_lli); //sort
  tmp=a[n/2];
  for(i=0; i<n; i++){
    //printf("%lld\n",a[i]);
    cou+=abs(tmp-a[i]);
  }
  printf("%lld", cou);
}

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

int main() {
    int N; string S; cin >> N >> S;
    char next;
    rep(i, S.size()) {
        next = S[i] + N;
        if (next > 'Z') cout << (char)(next - 'Z' + 'A' - 1);
        else cout << (char)(next);
    }

    cout << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<unordered_map>
#include<utility>
#include<vector>

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;

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

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

long long meguru_search(long long ok, long long ng, std::function<bool(long long)> check){
    while(1 < std::abs(ok - ng)){
        long long mid = (ok + ng) >> 1;
        if(check(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    return ok;
}

int main(){
    int n, k;
    std::cin >> n >> k;

    std::vector<int> a(n);
    for(int i = 0 ; i < n ; ++i){
        std::cin >> a[i];
    }

    std::sort(a.begin(), a.end());

    auto check = [&](long long mid){
        std::vector< std::vector<bool> > dp(n + 1, std::vector<bool>(k, false));
        dp[0][0] = true;

        for(int i = 0 ; i < n ; ++i){
            for(int j = 0 ; j < k ; ++j){
                dp[i + 1][j] = dp[i + 1][j] || dp[i][j];
                if(i != mid && j + a[i] < k){
                    dp[i + 1][j + a[i]] = dp[i + 1][j + a[i]] || dp[i][j];
                }
            }
        }

        for(int j = std::max(0, k - a[mid]) ; j < k ; ++j){
            if(dp[n][j]){
                return true;
            }
        }

        return false;
    };

    long long ans = meguru_search(n, -1, check);

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

    return 0;
}

Measured memory_bytes: 6708
import math

a, b, h, m = map(int, input().split())

hr = (h * 60 + m ) / 2
mr = m * 6
if mr == 0:
    mr = 360

if mr > hr:
    r = mr - hr
else:
    r = hr - mr

c = math.cos(math.radians(r))
s = a ** 2 + b ** 2 - 2 * a * b * c
s = math.sqrt(s)

print(s)

Measured memory_bytes: 9504
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		sc.close();

		int mod = 1000000007;
//		NCR ncr = new NCR(n + 1, mod);
		long total = (long) (n + 1) * n / 2;
		long ans = 0;
		for (int i = k; i <= n + 1; i++) {
//			long val1 = ncr.calc(n + 1, i);
			long max = total - (long) (n + 1 - i) * (n - i) / 2;
			long min = (long) i * (i - 1) / 2;
			long val2 = max - min + 1;
			val2 %= mod;
			ans += val2;
//			ans += Math.min(val1, val2);
			ans %= mod;
		}
		System.out.println(ans);
	}

	static class NCR {
		long[] p, pi;
		int m;

		public NCR(int n, int mod) {
			n++;
			m = mod;
			p = new long[n];
			pi = new long[n];
			p[0] = 1;
			pi[0] = 1;
			for (int i = 1; i < n; i++) {
				p[i] = p[i - 1] * i % m;
			}
			pi[n - 1] = BigInteger.valueOf(p[n - 1])
					.modInverse(BigInteger.valueOf(m)).longValue();
			for (int i = n - 1; i > 1; i--) {
				pi[i - 1] = pi[i] * i % m;
			}
		}

		public long calc(int n, int r) {
			if (n < r) return 0;
			return p[n] * pi[r] % m * pi[n - r] % m;
		}
	}
}


Measured memory_bytes: 35776
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);

using namespace std;

signed main()
{
	
 	FLASH
 	int a,b;
 	cin>>a>>b;
 	if(b%a) cout<<b-a;
 	else cout<<b+a;


}

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

using lint = long long;
using ldouble = long double;

void solve() {
    std::string s;
    std::cin >> s;
    std::cout << std::string(s.length(), 'x') << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
'''
ITP-1_4-A
 ?????????
???????????´??° a ??¨ b ?????????????????§?????\?????????????¨??????????????????°?????????????????????????????????
a ?? b ??? d (??´??°)
a ?? b ????????? ??? r (??´??°)
a ?? b ??? f (???????°???°?????°)
???Input
1?????????????????´??° a, b ????????????????????????
???Output
d, r, f ????????????????????§????????£????????????????????????????????????f??????????????????0.00001??\????????????????????£????????????????????¨????????????
'''
# import

# ?????°??????????????????
inputData01, inputData02 = map(int,input().split())

# ??????????????´??°???????±???????
d = inputData01 // inputData02
# print( d )

# ??????????????????????±???????
r = inputData01 % inputData02
# print( r )

# ??????????????´??°???????±???????
f = inputData01 / inputData02
print( d, r, "{0:f}".format( f ))

Measured memory_bytes: 7624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>=0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define maxemt(v) *max_element(v.begin(), v.end())
#define minemt(v) *min_element(v.begin(), v.end())
#define lb(v,x) v[lower_bound(v.begin(), v.end(), x) - v.begin()]
#define ub(v,x) v[upper_bound(v.begin(), v.end(), x) - v.begin()]
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
ll lcm(ll x, ll y){
  return x / gcd(x,y) * y;
}
const int INF = 1e9;
const ll llINF = 1LL<<60;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main(){
  vector<int> v(3); rep(i,3) cin >> v[i];
  int ans=0, flg=0;
  rep(i,2){
    ans += (maxemt(v)-minemt(v))/2;
    v[mini(v)] += (maxemt(v)-minemt(v)) /2 *2;
  }
  flg = count(all(v),maxemt(v));
  if(flg==1) ans++;
  else if(flg==2) ans += 2;
  cout << ans;
  
  return 0;
}


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

using namespace std;

class Node
{
public:

    int key;
    Node *parent, *left, *right;

    Node (int key)
    {
        this->key = key;
        parent = left = right = NULL;
    }
};

class Tree
{
    Node *root;

    public:
    Tree()
    {
        root = NULL;
    }

    void insert(int key)
    {
        Node *node = new Node(key);

        if (root == NULL)
        {
            root = node;
            return;
        }

        Node *target = root;

        while(target != NULL)
        {
            if (node->key < target->key)
            {
                if (target->left == NULL)
                {
                    target->left = node;
                    node->parent = target;
                    target = NULL;
                }else
                {
                    target = target->left;
                }
            }
            else
            {
                if (target->right == NULL)
                {
                    target->right = node;
                    node->parent = target;
                    target = NULL;
                }else
                {
                    target = target->right;
                }            
            }            
        }
    }

    void printPreOrder(Node *n)
    {
        if (n == NULL)
        {
            return;
        }

        cout << " " << n->key;

        printPreOrder(n->left);
        printPreOrder(n->right);
    }

    void printInOrder(Node *n)
    {
        if (n == NULL)
        {
            return;
        }

        printInOrder(n->left);
        cout << " " << n->key;
        printInOrder(n->right);
    }

    void printPostOrder(Node *n)
    {
       if (n == NULL)
        {
            return;
        }

        printPostOrder(n->left);
        printPostOrder(n->right);
        cout << " " << n->key;
    }

    void print()
    {        
        printInOrder(root);
        cout << endl;
        printPreOrder(root);
        cout << endl;
    }
};

int main()
{
    Tree *t = new Tree;

    int M;
    cin >> M;

    for (int i = 0; i < M; i++)
    {
        string message;

        cin >> message;

        if (message == "insert")
        {
            int key;
            cin >> key;
            t->insert(key);
        }
        else if (message == "print")
        {
            t->print();
        }
    }

    return 0;
}



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

int main() {
  string S;
  cin >> S;
  
  for(int i= S.size()-2; i>0; i-=2){ // 制約より|S|:偶数
    int n_sub= i/2;
    string str1= S.substr(0, n_sub);
    string str2= S.substr(n_sub, n_sub);
    if(str1==str2){
      cout << 2*n_sub << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    long long x;
    cin>>x;
    
    long long hoge=x;
    
    while(true){
        
        if(hoge!=2 && hoge%2==0){
            hoge++;
            continue;
        }
        
        bool ok=true;
        
        for(long long i=3;i<hoge;i+=2){
            if(hoge%i==0){
                ok=false;
                break;
            }
        }
        
        //cout<<hoge<<" "<<ok<<endl;
        
        if(ok){
            cout<<hoge<<endl;
            break;
        }
        
        hoge++;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N; string s;
	cin >> N >> s;
	V<int> v(3);
	int res = 0;
	rep(i,10) rep(j,10) rep(k,10){
		v = {i,j,k};
		int now = 0;
		rep(t,N){
			if(s[t]-'0' == v[now]) now++;
			if(now == 3) break;
		}
		if(now==3) res++;
	}
	cout << res << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int N, K;
	cin >> N >> K;

	int ret = 1;
	for(int i=0; i<N; i++){
		if(ret < K)
			ret *= 2;
		else
			ret += K;
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    //System.out.print("1???100????????????????\?????????°??????????????????????????§????????£?????\????????????????????????");
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    
    if(1 <= a && a <= 100 && 1 <= b && b <= 100) {
        System.out.println(a * b + " " + (a + b) * 2);
    }    
  }  
}

Measured memory_bytes: 26032
#coding:utf-8

s = raw_input()
K = int(raw_input())

s_lists = []

for i in range(K):
    for j in range(len(s) - i):
        sub_s = s[j : j + i + 1]
        #print sub_s
        if not (sub_s in s_lists):
            s_lists.append(s[j : j + i + 1])

s_lists.sort()

#print s_lists

print s_lists[K - 1]


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>

// MARK: - header
namespace {
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<ull MOD>
struct Mod {
    ull v = 0;
    Mod() {};
    Mod(ull val) : v(val) {}
    operator ull() const {return v;}
    ull operator=(ll x) {return v = x % MOD;}
    ull operator+=(ll x) {return operator=(v + x);}
    ull operator*=(ll x) {return operator=(v * x);}
};
}

// MARK: - answer

ll X, Y, Z, K;
vector<ll> A, B, C;

void input() {
    cin >> X >> Y >> Z >> K;
    A.resize(X);
    for (auto& a : A)
        cin >> a;
    B.resize(Y);
    for (auto& b : B)
        cin >> b;
    C.resize(Z);
    for (auto& c : C)
        cin >> c;
}

void solve() {
    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());
    vector<ll> AB;
    for (auto a : A)
        for (auto b : B)
            AB.push_back(a + b);
    sort(AB.rbegin(), AB.rend());
    AB.resize(min(size_t(K), AB.size()));
    sort(C.rbegin(), C.rend());
    vector<ll> ABC;
    for (auto ab : AB)
        for (auto c : C)
            ABC.push_back(ab + c);
    sort(ABC.rbegin(), ABC.rend());
    for (int i = 0; i < K; i++)
        cout << ABC[i] << endl;
}

int main() {
    input();
//    cout << (solve() ? "Yay!" : ":(") << endl;
    solve();
    
    return 0;
}



Measured memory_bytes: 43368
#include<bits/stdc++.h>
using namespace std;
int n,m,tree[100001],ans;
inline int lowbit(int x){
    return x&(-x);
}
inline void add(int x,int y){
    for(;x<=n;x+=lowbit(x))tree[x]+=y;
}
inline int ask(int x){
    int ans=0;
    for(;x;x-=lowbit(x))ans+=tree[x];
    return ans;
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;++i){
        int l,r;
        scanf("%d%d",&l,&r);
        add(l,1),add(r+1,-1);
    }
    for(int i=1;i<=n;i++){
        if(ask(i)==m)ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <iomanip>
#include <functional>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

template<class T>
void VPout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n';
    }
    cout<<"end\n"<<endl;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));

void change(string &s,char a){
    for(int i=0;i<(int)s.size();i++){
        if(s[i]=='?') s[i]=a;
    }
}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); 
    cout<<fixed<<setprecision(10);

    int n;
    cin>>n;
    vector<string> s(n);
    for(int i=0;i<n;i++) cin>>s[i];
    string t; cin>>t;

    int pre=0,hatena=0;
    for(int i=0;i<n;i++){
        string a=s[i],z=s[i];
        change(a,'a'); change(z,'z');
        if(s[i]==t) hatena++;
        else{
            if(a<t && t<z) hatena++;
            else if(z<t) pre++;
        }
    }
    for(int i=pre+1;i<=pre+1+hatena;i++){
        if(i!=pre+1) cout<<" ";
        cout<<i;
    }
    cout<<endl;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;

const int MAX_V = 100000;
const int MAX_E = 500000;
const int INF = INT_MAX;

struct E{
  int to, cost;
  E(int t, int c) : to(t), cost(c) {};
};
typedef pair<int, int> pii;

int v;
vector<E> g[MAX_V];
int d[MAX_V];

void dijkstra(int s)
{
  fill(d, d + v, INF);
  d[s] = 0;
  priority_queue<pii, vector<pii>, greater<pii> > q;
  q.push(pii(0, s));
  
  while(!q.empty()){
    pii p = q.top();
    q.pop();
    int from = p.second;
    if(d[from] < p.first) continue;
    
    for(int i = 0; i < g[from].size(); ++i){
      int to = g[from][i].to;
      int cost = g[from][i].cost;
      
      if(d[to] > d[from] + cost){
        d[to] = d[from] + cost;
        q.push(pii(d[to], to));
      }
    }
  }
}

int main()
{
  int n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  v = n;
  REP(i, m){
    int a1, b1, c1, d1;
    scanf("%d,%d,%d,%d", &a1, &b1, &c1, &d1);
    g[a1 - 1].push_back(E(b1 - 1, c1));
    g[b1 - 1].push_back(E(a1 - 1, d1));
  }
  int x1, x2, y1, y2;
  scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
  dijkstra(x1 - 1);
  int go = d[x2 - 1];
  dijkstra(x2 - 1);
  int back = d[x1 - 1];
  cout << y1 - go - back - y2 << endl;
}

Measured memory_bytes: 3564
n = int(input())
h = list(map(int, input().split()))

ans = 0
prev = h[0]
c = 0
for i in range(1, n):
    if prev >= h[i]:
        c += 1
    else:
        c = 0
    prev = h[i]
    ans = max(ans, c)
print(ans)

Measured memory_bytes: 85408
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    String s1 = sc.next();
    String s2 = s1.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","");
    
    if(s2.length()==0){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 28064
import java.io.*;
import java.util.*;
class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s[]=br.readLine().split(" ");
		int  n =Integer.parseInt(s[0]);
		int  m =Integer.parseInt(s[1]);
		int  x =Integer.parseInt(s[2]);
		int arr[] = new int[m];
		String s1[] = br.readLine().split(" ");
		for (int i = 0; i < s1.length; i++) {
			arr[i]=Integer.parseInt(s1[i]);
		}
		/*int res=0;
		int left = 0;
		int right = m-1;
		if(x > arr[m-1] || x< arr[0]) {
			System.out.println(0);
			
		}
		else {
		while(left<right) {
			int mid = (left+right)/2;
			//System.out.println("mid"+mid);
			if(arr[mid] < x) {
				res = mid;
				left = mid+1;
			}
			else {
				right = mid-1;
			}
		}
		if(arr[m-1] == n) {
			System.out.println(Math.min(res+1, m-res-2));
		}
		else
		System.out.println(Math.min(res+1, m-res-1));
		}*/
		int res=0;
		for (int i = 0; i < arr.length; i++) {
			if(arr[i]<x) {
				res++;
			}
			else {
				break;
			}
		}
		System.out.println(Math.min(res, m-res));
	}

}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n-1);
    rep(i, n){
        cin >> a[i];
    }
    int ans = 0;
    rep(i, n){
        cin >> b[i];
        ans += b[i];
    }
    rep(i, n-1){
        cin >> c[i];
    }
    
    rep(i, n-1){
        if(a[i] + 1 == a[i+1]){
            ans += c[a[i]-1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
  a, b, m =map(int, input().split())
  a = list(map(int, input().split()))
  b = list(map(int, input().split()))
  ans = min(a) + min(b)
  for _ in range(m):
    i, j, c = map(int, input().split())
    ans = min(ans, a[i-1]+b[j-1]-c)
  
  print(ans)
  
if __name__=='__main__':
  main()

Measured memory_bytes: 18612
#include<bits/stdc++.h>
#include<string>
#define pii pair<int, int>
#define mp make_pair
#define ll long long
#define ld long double
#define pb push_back
#define S second
#define F first
using namespace std;



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

	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) cin >> a[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if ((i + 1) % 2 == 1 && a[i] % 2 == 1) ans++;
	}

	cout << ans << '\n';

}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
typedef long long int LLI;
LLI pow(LLI base, LLI exp)
{
	LLI ans = 1;
	for(int i = 0; i < exp; i++)
		ans *= base;
	return ans;
}
int main()
{
	LLI arr[3], k, max = 0, sum = 0;
	cin >> arr[0] >> arr[1] >> arr[2] >> k;
	for(int i = 0; i < 3; i++)
	{
		sum += arr[i];
		if( arr[i] > max )
			max = arr[i];	
	}
	sum -= max;
	sum += pow(2,k)*max;
	cout << sum;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#include <string>

using namespace std;
int main (){
    int h,w;
    cin >> h >> w;
    string s;
    int status[h+2][w+2]={};
    for (int i = 1; i < h+1; i++)
    {
        cin >> s;
        for (int j = 1; j < w+1; j++)
        {
            if(s[j-1]=='.') status[i][j]=0;
            else status[i][j]=1;
        }
    }
    int bomb;
    for (int i = 1; i < h+1; i++){
    for (int j = 1; j < w+1; j++){
        if(status[i][j]) cout << "#";
        else{
            bomb=status[i-1][j-1]+
                 status[i][j-1]+
                 status[i+1][j-1]+
                 status[i-1][j]+
                 status[i+1][j]+
                 status[i-1][j+1]+
                 status[i][j+1]+
                 status[i+1][j+1];
            cout << bomb;
        }
        }
    cout << "\n";
    }

}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

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


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2)) %= M;
  (res *= ppow(fact(n-r), M-2)) %= M;
  return res;
}

//GCD and LCM
llt gcd(llt x, llt y)
{
  if(y == 0) return x;
  return gcd(y, x%y);
}
llt lcm(llt x, llt y)
{
  return (x / gcd(x, y)) * y;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find
// Find()
int parent[N], ran[N];
int find(int x)
{
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

// Main Code

int main()
{
  int n;
  cin>>n;
  int arr[n];
  rep(i, 0, n)
  {
    cin>>arr[i];
  }
  int i = 0;
  int ans = 0;
  while(i< n)
  {
    if(arr[i] == (i+1))
    {
      ans++;
      i += 2;
    }
    else
    {
      i++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 14464
// Problem: https://atcoder.jp/contests/abc160/tasks/abc160_c
// Type: Math

#include <bits/stdc++.h>

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;

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

	int k, n;
	cin >> k >> n;
	
	vector<int> m(n);
	for (auto &e : m) {
		cin >> e;
	}

	// If we can start at any position, this means we can delete one
	// edge from this circular graph
	// We should delete the largest distance between two points
	int max_segment = 0;
	for (int i = 1; i < m.size(); ++i) {
		max_segment = max(max_segment, m[i] - m[i - 1]);
	}
	int np_d = m[0] + (k - m.back());
	max_segment = max(max_segment, np_d);
	cout << k - max_segment;

	return 0;
}


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

using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> costs(n);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    costs[i] = x;
  }
  vector<int> dp(n, INT_MAX);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      if (i + j < n) {
        int cost = dp[i] + abs(costs[i] - costs[i + j]);
        dp[i + j] = min(dp[i + j], cost);
      }
    }
  }
  cout << dp[dp.size() - 1] << endl;
}


Measured memory_bytes: 4048
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace ABC141A
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var today = cin.ReadLine;
            if (today == "Sunny") {
                Console.WriteLine("Cloudy");
                return;
            }
            if(today == "Cloudy")
            {
                Console.WriteLine("Rainy");
                return;
            }
            if (today == "Rainy") {
                Console.WriteLine("Sunny");
            }

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


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



const ll modo=998244353;
const ll inf=1e17;
const ll ms=(2e6)+5;


int ar[10]={0};
int br[10][10]={0};
int cr[10][10][10]={0};


int main()
{
    idfc;

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

    int p;
    for(char e:s)
    {
        p=e-48;
        for(j=0;j<10;j++)
        {
            for(k=0;k<10;k++)
            {
                if(br[j][k])cr[j][k][p]=1;
            }
        }
        for(j=0;j<10;j++)
        {
            if(ar[j])br[j][p]=1;
        }
        ar[p]=1;
    }
    int ans=0;
    for(i=0;i<10;i++)
    {
        for(j=0;j<10;j++)
        {
            for(k=0;k<10;k++)
            {
                if(cr[i][j][k])ans++;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3736