akhauriyash/Code-Regression huggingface dataset:
while True:
    try:
        hoge = input()
    except:
        break
    ans = "d"
    for i in range(3):
        if "ooo" == hoge[i*3:i*3+3] or "ooo" == hoge[i::3]:
            ans = "o"
            break
        elif "xxx" == hoge[i*3:i*3+3] or "xxx" == hoge[i::3]:
            ans = "x"
            break
    if hoge[0::4] == "ooo" or hoge[2:7:2] == "ooo":
        ans = "o"
    elif hoge[0::4] == "xxx" or hoge[2:7:2] == "xxx":
        ans = "x"
    print(ans)

Measured memory_bytes: 7372
N, X = map(int, input().split())
A = list(map(int, input().split()))
A.reverse()

acc = [0]
for i in range(0, N):
    acc.append(acc[i] + A[i])

ans = []
for k in range(1, N + 1):
    cost = k * X + N * X
    for i in range(0, (N + k - 1) // k):
        l = k * i
        r = min([l + k, N])
        t = i + 1
        if t == 1:
            cost += (acc[r] - acc[l]) * 5
        else:
            cost += (acc[r] - acc[l]) * (2 * t + 1)
    ans.append(cost)

print(min(ans))

Measured memory_bytes: 106372
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9+7
cnt = 0
for i in range(n):
  for j in range(i+1,n):
      if a[i] > a[j]:
        cnt += 1
ans = cnt*k
# print (ans)
cnt2 = 0
for i in range(n):
  for j in range(n):
    if a[i] > a[j]:
      cnt2 += 1


ans += (k*(k-1)//2)*cnt2
print (ans%mod)

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int main() {
	ll N, M;
	cin >> N >> M;
	ll ans = 1;
	for (int i = 1; i <= N; i++) (ans *= i) %= MOD;
	for (int i = 1; i <= M; i++) (ans *= i) %= MOD;
	if (N == M) {
		cout << (ans * 2) % MOD << endl;
	}
	else if (abs(N - M) == 1) {
		cout << ans << endl;
	}
	else {
		cout << 0 << endl;
	}
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);

signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b)<<endl;	
	return 0;
}

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

using namespace std;

#define int long long

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

    int n, k, temp;
    cin >> n >> k;
    vector<int> vec(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> vec[i];
    vector<int> dp(n + 3, 1e12);
    dp[1] = 0;
    dp[2] = abs(vec[2] - vec[1]);
    for (int i = 3; i <= n; i++)
    {
        for (int j = 1; j <= k && i - j > 0; j++)
            dp[i] = min(dp[i - j] + abs(vec[i - j] - vec[i]), dp[i]);
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 1792
n = int(input())
a = list(map(int,(input().split()))) #食べた料理
b = list(map(int,(input().split()))) #料理iの満足度
c = list(map(int,(input().split()))) 

result = 0
mae = 1111
for i in a:
    #print("result",result)
    result += b[i-1]
    #print("mae,b[i-1]",mae,i)
    if mae == i -1:
        #print("if",result)
        result += c[i-2]
    mae = i

print(result)

Measured memory_bytes: 3060
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100001
#define INF (ll)1e18
#define pll pair<ll,ll>
#define pii pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define pi 3.1415926535897


int main() {

    get(m);
    gets(st);
    
    ll maxi = 0;
    for(ll i=0;i<st.length();i++) {

        string s = st.substr(i);
        ll n = s.length();

        vector<ll> z(n,0);

        for(ll i=1,l=0,r=0;i<n;i++) {
            if(i<=r)
                z[i] = min(r-i+1,z[i-l]);
            
            while(z[i]+i<n && s[i+z[i]]==s[z[i]])
                z[i]++;

            if(z[i]+i-1>r)
                l=i, r=z[i]+i-1;
        }

        // for(auto i:z)
        //     cout<<i<<" ";
        // cout<<endl;
        rep(i,n)
            maxi = max(maxi, min(z[i],i));
    }
        

    printf("%lld\n", maxi);

    
    return 0;  
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

ll dp[1001][1001];
ll fact[1001];
ll ppow(ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1)res = (res*a) % MOD;
		a = (a*a) % MOD;
		b >>= 1;
	}
	return res;
}
ll comb(ll a, ll b) {
	return (((fact[a] * ppow(fact[a - b], MOD - 2)) % MOD)*ppow(fact[b], MOD - 2)) % MOD;
}
int main() {
	fact[0] = 1;
	int n, a, b, c, d; scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	for (int i = 1; i <= n; i++)fact[i] = (fact[i - 1] * i) % MOD;
	rep(i, n)dp[i][0] = 1;
	for (int i = a - 1; i < b; i++) {
		for (int j = 0; j <= n; j++) {
			if (j)(dp[i + 1][j] += dp[i][j]) %= MOD;
			if (j - c*(i + 1) < 0)continue;
			ll y = 1, t = n - j;
			rep(p, c - 1) {
				(y *= comb(t + i + 1, t)) %= MOD;
				t += i + 1;
			}
			for (int k = c; j - k*(i + 1) >= 0 && k <= d; k++) {
				(y *= comb(t + i + 1, t)) %= MOD;
				ll o = y;
				(o *= ppow(fact[k], MOD - 2)) %= MOD;
				(dp[i + 1][j] += dp[i][j - k*(i + 1)] * o) %= MOD;
				t += i + 1;
			}
		}
	}
	cout << dp[b][n] << endl;
}

Measured memory_bytes: 8064
#include <cstdio>
#include <cmath> 

using namespace std ;
 
int N ;
inline bool Squ( int K ) {
	if( (int)sqrt( K ) * (int)sqrt( K ) == K ) return true ;
	return false ;
}
int S[1005][1005] ;
int Top[1005] ;
 
int main() {
	
	scanf( "%d" , &N ) ;
	if( not Squ( N * 8 + 1 ) ) return not printf( "No\n" ) ;
	if( (int)sqrt( N * 8 + 1 ) % 2 == 0 ) return not printf( "No\n" ) ;
	printf( "Yes\n" ) ;
	int Nod = (int)sqrt( N * 8 + 1 ) + 1 >> 1 ;
	int Cnt = 0 ;
	for(register int i = 1 ; i < Nod ; i++ )
		for(register int j = i + 1 ; j <= Nod ; j++ ) {
			++Cnt ;
			S[i][++Top[i]] = Cnt ;
			S[j][++Top[j]] = Cnt ;
		}
	printf( "%d\n" , Nod ) ;
	for(register int i = 1 ; i <= Nod ; i++ ) {
		printf( "%d " , Top[i] ) ;
		for(register int j = 1 ; j <= Top[i] ; j++ )
			printf( "%d " , S[i][j] ) ;
		printf( "\n" ) ;
	}
	return 0 ;
	
} 

Measured memory_bytes: 3072
<>;($x,$y)=glob,printf"%f
",sort{$b<=>$a}0,map.159154*(-$~+($~=$_))-.5,(@b=sort{$a<=>$b}map+(/ /*atan2$'-$y,$`-$x)x!/^$x $y/,@a),"@b"+6.2832for@a=<>

Measured memory_bytes: 5248
m, d = map(int, input().split())
ans = 0

for mon in range(1,m+1):
  for day in range(1, d+1):
    d1 = day%10
    d10 = int(day/10)
    if d1 >= 2 and d10 >= 2:
      if d1*d10 == mon:
        ans+=1
print(ans)

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

int main() {
  string s;
  cin >> s;
  bool a = true;
  for(int i = 0; i < s.size(); i++) {
    int count = 0;
    for(int j = 0; j < s.size(); j++) {
      if(s.at(j) == s.at(i)) count++;
    }
    if(count != 2) a = false;
  }
  if(a) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
n = int(input())

cnt = 0
pbm = 0
for i in range(1, 10**6):
    cnt += i
    if cnt >= n:
        pbm = i
        break

ans = []

for i in range(pbm, 0, -1):
    if i <= n:
        ans.append(i)
        n -= i

for i in ans:
    print(i)

Measured memory_bytes: 3444
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  string s;
  while(cin >> s) {
    int joi = 0, ioi = 0;
    FOR(i,0,s.length()-2) {
      if(s[i]=='J'&&s[i+1]=='O'&&s[i+2]=='I') joi++;
      if(s[i]=='I'&&s[i+1]=='O'&&s[i+2]=='I') ioi++;
    }
    cout << joi << endl;
    cout << ioi << endl;
  }
  return 0;
}

Measured memory_bytes: 3008
n=int(input())
num=list(map(int,input().split()))
num.sort()
if num[int(n/2)-1]==num[int(n/2)]:
    a=0
elif not num[int(n/2)]==num[int(n/2) -1]:
    a= num[int(n/2)] - num[int(n/2)-1]
print(a)

Measured memory_bytes: 14396
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
ll a,b,c;
cin>>a>>b>>c;
if(a%2==0||b%2==0||c%2==0)
ol("0");
else
{
	ll ans=min(a*c,a*b);
	ol(min(ans,b*c));
}
return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
int x,ans;
int main(){
	scanf("%d",&x);
	ans+=x/500*1000;
	x=x%500;
	ans+=x/5*5;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))

M = max(t)
t = [t[0]-1] + t + [t[-1]+1]
a = [a[0]-1] + a + [a[-1]+1]

flag = True
count = 1
for i in range(n):
    if t[i+1] == M and a[i+1] == M:
        flag = False
        if t[i] == M and a[i] == M and t[i+2] == M and a[i+2] == M:
            count = (count * t[i+1]) % (10**9+7)
        continue
    if flag:
        if t[i+1] == t[i]:
            count = (count * t[i+1]) % (10**9+7)
    else:
        if a[i+1] == a[i+2]:
            count = (count * a[i+1]) % (10**9+7)

if flag:
    print(0)
else:
    print(count)

Measured memory_bytes: 19012
#include<stdio.h>
#include<iostream>
#include<cmath>
using namespace std;

bool isprime(int x) {
  if (x == 2) return true;
  if ((x < 2) || (x%2 == 0)) return false;
  int i = 3;
  while(i <= sqrt(x)) {
    if(x%i == 0) return false;
    i = i + 2;
  }
  return true;
}

int main() {
  int n, cnt = 0;
  cin >> n;
  int m[n];
  for(int i = 0; i < n; i++) scanf("%d", &m[i]);
  for(int i = 0; i < n; i++) if(isprime(m[i])) cnt++;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3196
n, k = map(int, input().split())
a = list(map(int, input().split()))

max_l = 10**9
min_l = 0
while max_l - min_l != 1:
    count = 0
    mean = (max_l+min_l)//2
    for i in range(n):
        count += -(-a[i]//mean)-1
    if count <= k:
        max_l = mean
    else:
        min_l = mean
print(max_l)

Measured memory_bytes: 30976
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18;
const int iINF = 1e9;
int main(){
    ll x,y,i = -1;
    cin>>x>>y;
    while(ll(pow(2,++i)) * x <= y);
    cout<<i<<endl;
}




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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, w;
  while (cin >> n >> w) {
    int x[n];
    int y[n];
    for (int i = 0; i < n; ++i) {
      cin >> x[i] >> y[i];
    }

    const int N = 100 + 5;
    const int W = 1e5 + 5;
    static lli dp[N][W];
    fill(&dp[0][0], &dp[N - 1][W - 1] + 1, 0);

    for (int i = 0; i < n; ++i) {
      for (int j = 0; j <= w; ++j) {
        if (j + x[i] <= w) setmax(dp[i + 1][j + x[i]], dp[i][j] + y[i]);
        setmax(dp[i + 1][j], dp[i][j]);
      }
    }
    
    lli mx = 0;
    for (int i = 0; i < W; ++i) {
      setmax(mx, dp[n][i]);
    }
    cout << mx << endl;
  }
  
  return 0;
}


Measured memory_bytes: 82304
#include<iostream>
#include<cmath>
using namespace std;
int lst[110];
int n;
inline long long value(int pos) {
	long long temp=0;
	for (int i = 0; i < n; i++) {
		temp += (lst[i] - pos) * (lst[i] - pos);
	}
	return temp;
}
int main() {
	int minm = 110, maxm=0;
	long long ans = INT64_MAX;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> lst[i];
		if (lst[i] < minm)minm = lst[i];
		if (lst[i] > maxm)maxm = lst[i];
	}
	for (int i = minm; i <= maxm; i++) {
		if (value(i) < ans)ans = value(i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
### main

while true
  n, m = gets.strip.split(' ').map{|s| s.to_i}
  break if n == 0 && m == 0

  seats = n.times.map{'#'}

  m.times.each do
    p = gets.strip

    case p
    when 'A'
      for i in (0...n)
        if seats[i] == '#'
          seats[i] = 'A'
          break
        end
      end

    when 'B'
      seated = false
      blank = nil
      (n - 1).downto(0).each do |i|
        if seats[i] == '#'
          blank = i
          if (i <= 0 || seats[i - 1] != 'A') &&
              (i >= n - 1 || seats[i + 1] != 'A')
            seats[i] = 'B'
            seated = true
            break
          end
        end
      end
      if ! seated
        seats[blank] = 'B'
      end

    when 'C'
      seated = false
      for i in (0...n)
        next if seats[i] == '#'
        if i < n - 1 && seats[i + 1] == '#'
          seats[i + 1] = 'C'
          seated = true
          break
        elsif i > 0 && seats[i - 1] == '#'
          seats[i - 1] = 'C'
          seated = true
          break
        end
      end
      if ! seated
        seats[n / 2] = 'C'
      end

    when 'D'
      max_dist = 0
      max_i = 0
      for i in (0...n)
        next if seats[i] != '#'
        min_dist = -1
        (i - 1).downto(0).each do |j0|
          if seats[j0] != '#'
            min_dist = i - j0
            break
          end
        end
        for j1 in ((i + 1)...n)
          if seats[j1] != '#'
            if min_dist < 0 || min_dist > j1 - i
              min_dist = j1 - i
            end
            break
          end
        end
        if min_dist >= 0 && max_dist < min_dist
          max_dist = min_dist
          max_i = i
        end
      end
      seats[max_i] = 'D'

    else
      puts "illegal passenger: #{p}"
    end
  end

  puts seats.join('')
end

Measured memory_bytes: 6140
import java.util.Scanner;

class Main {
	// ABC164 A
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int S = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());


		if(S > W) {
			System.out.println("safe");
		} else {
			System.out.println("unsafe");
		}
	}

}


Measured memory_bytes: 35700
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());

		ArrayList<Integer> lArrayList = new ArrayList<>();

		for(int i=0; i<n; i++){
			lArrayList.add(Integer.parseInt(sc.next()));
		}

		Collections.sort(lArrayList);

		System.out.println((int)lArrayList.stream()
				.skip(lArrayList.size()-k)
			    .mapToDouble(a -> a)
			    .sum());
	}
}

Measured memory_bytes: 28628
#include <iostream>
#include <algorithm>

using namespace std;
int m[1010];
int main(){
	int n,x;
	cin>>n>>x;
	for(int i=0;i<n;i++){cin>>m[i];}
	for(int i=0;i<n;i++){x-=m[i];}
	sort(m,m+n);
	int iwa=x/m[0];
	cout<<iwa+n<<endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final String s = scanner.next();

        if (n % 2 == 1) {
            System.out.println("No");
            return;
        }

        final String substring = s.substring(0, n / 2);
        for (int i = n / 2; i < n; i++) {
            if (s.charAt(i) != substring.charAt(i - n / 2)) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}


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

int main(){
  int n; cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; ++i) cin >> a[i];
  
  int s = -101, cmin, c;
  while(++s <= 100){
    c = 0;
    for(int i=0; i<n; ++i){
      c += pow(a[i]-s, 2);
    }
    if(s == -100) cmin = c;
    else{
      if(cmin > c) cmin = c;
    }
  }
  cout << cmin << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  i64 n;
  cin >> n;
  i64 ans = 1e18;
  reps(i, 1000010) {
    if (n % i == 0) {
      i64 j = n / i;
      amin(ans, j + i - 2);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
def main():
    input = sys.stdin.read
    N,A,B,C=input().rstrip().split()
    ans = 0
    for S in zip(A,B,C):
        s = len(set(S))
        if s == 3: ans += 2
        elif s == 2: ans += 1
    print(ans)

if __name__ == '__main__':
    main()

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl
#define rep(n, i) for (int i = 0; i < n; i++)

using namespace std;
using i64 = long long;

int main()
{
    string s, t;
    cin >> s >> t;

    int n = s.size();

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] != t[i])
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3852
def gcd(n,m):
    while n:
        m,n = n,m%n
    return m

# n以下でmで割り切れるものの数を求める
def a(n,m):
    return n//m

A,B,C,D = map(int,input().split())
E = C*D//gcd(C,D)
b = A-1 - (a(A-1,C)+a(A-1,D)-a(A-1,E))
c = B - (a(B,C)+a(B,D)-a(B,E))
print(c-b)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

using namespace std;
int main(){
    string s = "";
    string t =  "";
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    if(s < t)
        cout << "Yes"  << endl;
    else
        cout << "No" << endl;
}




Measured memory_bytes: 3584
#
N = int(input())
T = []
X = []
Y = []
for i in range(N):
    t_, x_, y_ = list(map(int, input().split()))
    T.append(t_)
    X.append(x_)
    Y.append(y_)

#
x = 0
y = 0
t = 0
for i in range(N):
    dx = abs(x - X[i])
    dy = abs(y - Y[i])
    dt = abs(t - T[i])

    if dx+dy>dt:
        print('No')
        exit()
    if (dt-dx-dy)%2==1:
        print('No')
        exit()

#
print('Yes')


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

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

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


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

using namespace std;

int main(){

	int u,d;
	int s = 17*60+30;
	int g = 19*60 + 30;

	int table[7][7];
	table[0][1]=300;
	table[0][2]=500;
	table[0][3]=600;
	table[0][4]=700;
	table[0][5]=1350;
	table[0][6]=1650;
	
	table[1][2]=350;
	table[1][3]=450;
	table[1][4]=600;
	table[1][5]=1150;
	table[1][6]=1500;

	table[2][3]=250;
	table[2][4]=400;
	table[2][5]=1000;
	table[2][6]=1350;

	table[3][4]=250;
	table[3][5]=850;
	table[3][6]=1300;

	table[4][5]=600;
	table[4][6]=1150;

	table[5][6]=500;

	table[1][0]=6;
	table[2][0]=13;
	table[3][0]=18;
	table[4][0]=23;
	table[5][0]=43;
	table[6][0]=58;
	
	table[2][1]=7;
	table[3][1]=12;
	table[4][1]=17;
	table[5][1]=37;
	table[6][1]=52;
	
	table[3][2]=5;
	table[4][2]=10;
	table[5][2]=30;
	table[6][2]=45;
	
	table[4][3]=5;
	table[5][3]=25;
	table[6][3]=40;
	
	table[5][4]=20;
	table[6][4]=35;
	
	table[6][5]=15;


	while(cin>>u&&u!=0){
		u--;
		int h1,m1,h2,m2;
		cin>>h1>>m1;
		cin>>d;
		d--;
		cin>>h2>>m2;
		int st=h1*60+m1;
		int gt=h2*60+m2;
		if((st>=s&&st<=g)||(gt>=s&&gt<=g)){
			// ツ板シツ額
			int idx1=min(u,d);
			int idx2=max(u,d);
			int dis=table[idx2][idx1];
			if(dis<=40){
				int mo=table[idx1][idx2]/2;
				if(mo%50!=0){
					mo-=mo%50;
					mo+=50;
				}
				cout<<mo<<endl;
			}
			else
				cout<<table[idx1][idx2]<<endl;
		}
		else{
			int idx1=min(u,d);
			int idx2=max(u,d);
			cout<<table[idx1][idx2]<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
     
public class Main {
    	
    private final static Scanner sc = new Scanner(System.in);
    	
    public static void main(String[] arg) {
    	int N = sc.nextInt();
    	int [] A = new int[N];
        for(int i =0; i < N; i++) {
        	A[i] = sc.nextInt();
        } 
         int sum = 0;
         for(int i =0; i < N; i++) {
             sum += sc.nextInt();
           	
         } 
         int [] C = new int[N-1];
         for (int i = 0; i < N-1; i++) {
            C[i] = sc.nextInt();
         }
         for(int i = 0; i < N-1; i++) {
         	if( (A[i]+1) == A[i+1]) {
            	sum += C[A[i]-1];
          	}
       	 }
          	System.out.println(sum);
    	}
    }

Measured memory_bytes: 21588
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import Counter
def main():
    n, *a = map(int, read().split())
    ac = Counter(a)
    acs = sorted(ac.items())
    r = ac.most_common()[0][1]
    if len(acs) == 2:
        if acs[1][0] - acs[0][0] == 1:
            r = acs[0][1] + acs[1][1]

    for i1 in range(1, len(acs) - 1):
        if abs(acs[i1 - 1][0] - acs[i1+1][0]) <= 2:
            r = max(r, acs[i1-1][1] + acs[i1][1] + acs[i1+1][1])
        elif abs(acs[i1 - 1][0] - acs[i1][0]) <= 1:
            r = max(r, acs[i1-1][1] + acs[i1][1])
        elif abs(acs[i1 + 1][0] - acs[i1][0]) <= 1:
            r = max(r, acs[i1+1][1] + acs[i1][1])
    print(r)
if __name__ == '__main__':
    main()


Measured memory_bytes: 25556
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N;cin>>N;
    int s[110];
    for(int i=1;i<=N;i++)cin>>s[i];
    int dp[110][10];
    //初期化
    for(int j=0;j<10;j++)dp[0][j]=0;
    //漸化式
    for(int i=1;i<=N;i++){
        dp[i][s[i]%10]=max(dp[i-1][s[i]%10],s[i]+dp[i-1][0]);
        for(int j=1;j<10;j++){
            if(dp[i-1][j]==0)
                dp[i][(s[i]+j)%10]=dp[i-1][(s[i]+j)%10];
            else dp[i][(s[i]+j)%10]=max(dp[i-1][(s[i]+j)%10],s[i]+dp[i-1][j]);
        }
    }
    int ans=0;
    for(int j=1;j<10;j++)
        ans=max(ans,dp[N][j]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1e+9;

int main()
{
	vector<int> num(3);
	for (int i = 0; i < 3; i++)
	{
		cin >> num[i];
	}
	sort(num.begin(), num.end());
	int ans = num[2] * 10 + num[1] + num[0];


	cout << ans << "\n";
	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++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int a[3005][3005];
ll dp[3005][3005][4];

int main() {
	int R, C, n;
	cin >> R >> C >> n;
	rep(i, n) {
		int r,c,v;
		cin >> r >> c >> v;
		r--; c--;
		a[r][c] = v;
	}
	dp[0][0][0] = 0;
	rep(i, R)rep(j, C) {
		for (int K = 2; K >= 0; K--) {
			chmax(dp[i][j][K+1], dp[i][j][K] + a[i][j]);
		}
		rep(k, 4) {
			chmax(dp[i + 1][j][0], dp[i][j][k]);
			chmax(dp[i][j+1][k], dp[i][j][k]);
		}
	}
	ll ans = 0;
	rep(k,4) {
		ans = max(ans,dp[R-1][C-1][k]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 320552
#include <iostream>
#include <cstdio>
using namespace std;
int n, m;
int a, b, c;
int main(){
    int i, j, k;
    cin >> a >> b >> c;
    a -= b;
    if(a <= 0)cout << c << endl;
    else if(a <= c)cout << c-a << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
int nxpt(char *s){
  int i,l=strlen(s),max=0,f[260]={0};
  for(l--;l+1&&max<=s[l];l--)f[max=s[l]]++;
  if(l<0)return 0;
  f[s[l]]++;
  for(i=s[l]+1;f[i]==0;i++);
  f[s[l]=i]--;
  for(i=0;s[++l];f[s[l]=i]--){
    while(f[i]==0)i++;
  }
  return 1;
}
double PI=acos(-1);
double f(double a,double b,double c,double d){
  //printf("%lf %lf %lf %lf\n",a,b,c,d);
  double dot=(a*c+b*d)/(hypot(a,b)*hypot(c,d));
  //printf("%lf\n",dot);
  return acos(dot)*180.0/PI;
}
int main(){
  int n,i,j,x[10],y[10];
  double dx=1,dy=0,px=0,py=0,r,min=1e9;
  char s[10]={};
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d %d",&x[i],&y[i]);
  for(i=0;i<n;i++)s[i]=i+'0';
  do{//printf("%s\n",s);
    r=0;
    dx=1;
    dy=0;
    px=0;
    py=0;
    for(i=0;i<n;i++){
      j=s[i]-'0';
      r+=f(dx,dy,x[j]-px,y[j]-py);//printf("%lf\n",r);
      dx=x[j]-px;
      dy=y[j]-py;
      px=x[j];
      py=y[j];
    }
    r+=f(dx,dy,-px,-py);
    if(min>r)min=r;
  }while(nxpt(s));
  printf("%.10lf\n",min);
  return 0;
}



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

ll n,a[4];
bool ok=false;
char b[3];

void dep(int d,int sum){
	if(ok){
		return;
	}
	if(d==3){
		if(sum==7){
			printf("%d%c%d%c%d%c%d=7",a[0],b[0],a[1],b[1],a[2],b[2],a[3]);
			ok=true;
		}
		return;
	}
	b[d]='+';dep(d+1,sum+a[d+1]);
	b[d]='-';dep(d+1,sum-a[d+1]);
}
int main() {
	cin>>n;
	for(int i=3;i>=0;i--){
		a[i]=n%10;
		n/=10;
	}
	dep(0,a[0]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a,b;
  string s;
  cin >> a >> b >> s;
  REP(i,a){
    if(s[i]=='-'){
      cout << "No" << endl;
      return 0;
    }
  }
  if(s[a]!='-'){
    cout << "No" << endl;
    return 0;
  }
  FOR(i,a+1,a+b+1){
    if(s[i]=='-'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &A[i]);
  }
  ll sum = 0, ans = 0;
  for (int l = 0, r = 0; l < N; ++l) {
    while (r < N and (sum & A[r]) == 0) {
      sum ^= A[r];
      ++r;
    }
    ans += (r - l);
    sum ^= A[l];
  }
  printf("%lld\n", ans);
  return 0;
}


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

using namespace std;

typedef long long LL;

const LL a[10]={0,1,2,4,7,12,20,29,38,52};
LL n,f[10];

int main(){
	scanf("%lld",&n);
	f[2]=1;
	for (LL i=3;i<n;++i) f[i]=f[i-1]*(a[i-1]+a[i-2]+1);
	for (LL i=1;i<=n;++i){
		for (LL j=1;j<=n;++j){
			if (i==j) printf("%lld ",0LL);
			else printf("%lld ",f[max(i,j)-1]*a[min(i,j)]+1);
		}
		puts("");
	}
	
	return 0;
}
			

Measured memory_bytes: 256
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let v = buf.trim().chars().collect::<String>();
	
	let mut ret = 0;
	if v.len() % 2 == 1 {
		let b:i32 = match buf.trim().parse() {
			Ok(n) => n,
			_ => panic!(""),
		};
		ret = ret + b - 10_i32.pow((v.len() - 1) as u32) + 1
	}
	for n in 1..(v.len() as u32) {
		if n % 2 == 1 {
			ret = ret + 10_i32.pow(n) - 10_i32.pow(n-1);
		}
	}
	println!("{}", ret);
}

Measured memory_bytes: 4352
n = int(input())
l=[]
r=[]
for i in range(n):
    temp = list(map(int, input().split()))
    l.append(temp[0])
    r.append(temp[1])

l.sort()
r.sort()

if(n%2==1):
    dif = r[n//2] - l[n//2]
    #print(dif)
    print(dif+1)
else:
    dif2 = (r[n//2]+r[n//2-1]) - (l[n//2]+l[n//2-1])
    #print(dif2)
    print(dif2+1)



Measured memory_bytes: 102060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




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

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n=int(input())
    for i in range(n+1):
        if (i+1)**2>n:
            print(i**2)
            break

main()

Measured memory_bytes: 3064
N , L = map(int, input().split())
sum_a = 0
min_a = 10000000

for i in range(N):
    a = L + i
    sum_a += a
    if abs(a) == min(min_a, abs(a)):
        min_a = abs(a)
        min_aa = a


print(sum_a - min_aa)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <deque>

using namespace std;
using ll = long long;
const int BIG = 100000007;


int main() {
    vector<ll> pcnts(300000,0);
    for(ll i = 1;i <= pcnts.size();++i){
        ll j = i;
        while(j != 0){
            if((j & 1) == 1)++pcnts[i];
            j = j >> 1;
        }
    }

    ll n;
    string s;
    cin >> n >> s;

    ll popcount = 0;

    for(ll i = 0;i < n;++i){
        if(s[i] == '1'){
            ++popcount;
        }
    }

    vector<ll> mods1(n,0);
    vector<ll> mods2(n,0);


    ll mo1 = 1;
    ll mo2 = 1;

    ll tmod1 = 0;
    ll tmod2 = 0;

    if(popcount - 1 == 0){

        for(ll i = 0;i < n;++i){
            mo2 %= (popcount + 1);

            mods2[i] = mo2;

            if(s[n - i - 1] == '1'){
                tmod2 += mods2[i];
                tmod2 %= (popcount + 1);
            }

            mo2 *= 2;
        }

        for(ll i = n - 1;i >= 0;--i){
            ll tmod;
            if(s[n - 1 - i] == '1'){
                cout << 0 << endl;
                continue;
            }
            else{
                tmod = (tmod2 + mods2[i]) % (popcount + 1);
            }


            // cout << "i = " << i << ",tmod = " << tmod << endl;

            ll cnt = 1;
            ll next = tmod;
            while (next > 0){
                next = next % pcnts[next];
                ++cnt;
            }

            cout << cnt << endl;
        }

    }
    else{
        for(ll i = 0;i < n;++i){
            mo1 %= (popcount - 1);
            mo2 %= (popcount + 1);

            mods1[i] = mo1;
            mods2[i] = mo2;

            if(s[n - i - 1] == '1'){
                tmod1 += mods1[i];
                tmod1 %= (popcount - 1);
                tmod2 += mods2[i];
                tmod2 %= (popcount + 1);
            }

            mo1 *= 2;
            mo2 *= 2;
        }

        for(ll i = n - 1;i >= 0;--i){
            ll tmod;
            if(s[n - 1 - i] == '1'){
                tmod = (tmod1 - mods1[i]) % (popcount - 1);
                if(tmod < 0)tmod = popcount - 1 + tmod;
            }
            else{
                tmod = (tmod2 + mods2[i]) % (popcount + 1);
            }


            // cout << "i = " << i << ",tmod = " << tmod << endl;

            ll cnt = 1;
            ll next = tmod;
            while (next > 0){
                next = next % pcnts[next];
                ++cnt;
            }

            cout << cnt << endl;
        }

    }



/*
    for(ll i = 0;i < n;++i){
        cout << "i = " << i << ",mods1 = " << mods1[i] << ",pcnt = " << (popcount - 1) << endl;
    }

    for(ll i = 0;i < n;++i){
        cout << "i = " << i << ",mods2 = " << mods2[i] << ",pcnt = " << (popcount + 1) << endl;
    }

    cout << tmod1 << ":" << tmod2 << endl;
*/


}




Measured memory_bytes: 8484
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int N, D;
	cin >> N >> D;
	int h=2*D+1;
	cout << (N+h-1)/h << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int a, n;

int gcd(int x, int y){
    /* ユークリッド互除法*/
    int z;
    if( (x <= 0) || (y <= 0) ){
        return -1;
    }
    z = x % y;
    while (z != 0){
        x = y;
        y = z;
        z = x % y;
    }
    return y;
};

int solve(int nowa, int nown, int p, int q, int b){
    // cout << nowa << " " << nown << " " << p << " " << q << " " << b << "\n";
    nowa = nowa * b;
    nown = nown + 1;
    // 終了条件
    if(nowa > a) return 0;
    if(nown >= n) return 0;
    
    // 引き算する。
    int bunbo = q * b;
    int bunshi = p * b - q;
    if(bunshi <= 0){
        return 0;
    }
    
    // 約分
    int koyakusu = gcd(bunbo, bunshi);
    bunbo = bunbo / koyakusu;
    bunshi = bunshi / koyakusu;
    
    // cout << p << "/" << q << " - 1/" << b << " = ";
    // cout << bunshi << "/" << bunbo << "\n";
    
    // 引き算した結果の分母が1なら正解である。
    int result = 0;
    if(bunshi == 1 && nowa * bunbo <= a && b <= bunbo){
        result += 1;
        // cout << "正解\n";
    }
    
    int blimit = a / (nowa * b);
    if(blimit <= 1) return result;
    // cout << "blimit " << blimit << "\n";
    for(int i = b; i <= blimit; i++){
        result += solve(nowa, nown, bunshi, bunbo, i);
    }

    return result;
};

int main(int argc, const char * argv[])
{
    int p, q;
    while(cin >> p >> q >> a >> n){
        if(p == 0 || q == 0 || a == 0 || n == 0) return 0;
        // 入力を約分する
        int koyakusu = gcd(p, q);
        p = p / koyakusu;
        q = q / koyakusu;
        int result = 0;
        if(n == 1){
            if(p == 1) result = 1;
        }else{
            if(p == 1) result = 1;
            for(int i = 1; i <= a; i++){
                // cout << "i = " << i << "\n";
                result += solve(1, 0, p, q, i);
            }
        }
        cout << result << "\n";
    }
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main()
{
  int n;
  int a;
  int last_a = 1000000000;
  int count = 0;
  
  scanf("%d", &n);

  while (n--) {
    scanf("%d", &a);
    if (a > last_a) count++;
    last_a = a;
  }

  printf("%d\n", count);

  return 0;
}
                  



Measured memory_bytes: 2140
use io::*;

fn main() {
    let input = read_string();
    let mut sc = Scanner::new(&input);
    let n: usize = sc.next();
    let k: usize = sc.next();
    let r = n % k;
    let d = n / k;
    let mut ans = d * d * d;
    for i in 1..k {
        if i != (k-i) % k {
            continue;
        }
        if i <= r {
            ans += (d+1) * (d+1) * (d+1);
        } else {
            ans += d * d * d;
        }
    }
    println!("{}",ans);
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }

        pub fn next_mat<T: FromStr>(&mut self, w: usize, h: usize) -> Vec<Vec<T>> {
            (0..h).map(|_| self.next_vec(w)).collect()
        }

        pub fn next_vec_char(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }

        pub fn next_mat_char(&mut self, n: usize) -> Vec<Vec<char>> {
            (0..n).map(|_| self.next_vec_char()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 4352
object Main extends App {
	override def main(args: Array[String]) = {
		val sc = new java.util.Scanner(System.in)
		var i:Int = 1;
		
		var cont:Boolean = true;
		while(cont){
			val n = sc.nextInt
			if(n == 0){
				cont = false;
			}else{
				println("Case " + i +": "+n)
				i = i+1
			}
		}
	}
}

Measured memory_bytes: 61148
N, K = map(int, input().split())

mod = 10 ** 9 + 7
start = 0
end = N
k = 1
ans = 0
while k <= N + 1:
    if k >= K:
        ans += end - start + 1
        ans %= mod
    start = start + k
    end = end + N - k
    k += 1

print(ans)


Measured memory_bytes: 64416
import kotlin.system.exitProcess

fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(" ").map { it.toInt() }

    for (i in 0..x) {
        if (y == 2 * x + 2 * i) {
            print("Yes")
            exitProcess(0)
        }
    }

    print("No")
}

Measured memory_bytes: 36576
import java.util.Scanner;

public class Main {

	public static void main(String[ ] args) {
		Scanner sc = new Scanner(System.in);
		int i=1;

			while(sc.hasNext()) {
				int a = sc.nextInt();
				if(a==0)
					break;
				else
					System.out.printf("Case %d: %d\n", i, a);
				i++;
			}
	}
}



Measured memory_bytes: 67400
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;

long long modpow(long long a, int p) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int halfp = p / 2;
		long half = modpow(a, halfp);
		return half * half%mod;
	}
	else {
		return modpow(a, p - 1)*a%mod;
	}
}

long long calcomb(int a, int b) {
	if (b > a - b) {
		return calcomb(a, a - b);
	}
	long long ansmul = 1;
	long long ansdiv = 1;
	for (int i = 0; i<b; i++) {
		ansmul *= (a - i);
		ansdiv *= (i + 1);
		ansmul%=mod;
		ansdiv %= mod;
	}
	long long ans = ansmul *modpow(ansdiv, mod - 2) % mod;
	return ans;
}
int main() {
	int N, M; cin >> N >> M;
	int MNokori = M;
	long long ans = 1;
	for (int i = 2; i*i <= MNokori; i++) {
		if (MNokori%i == 0) {
			int cnt = 0;
			while (MNokori%i == 0) {
				cnt++; MNokori /= i;
			}
			ans *= calcomb(N + cnt - 1,N-1);
			ans%=mod;
		}
	}
	if (MNokori != 1) {
		ans *= calcomb(N + 1 - 1,N-1);
		ans %= mod;
	}
	cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> xs(n);
    int l, f;
    
    rep(i, n) {
        cin >> x[i];
        xs[i] = x[i];
    }
    
    sort(xs.begin(), xs.end());
    l = xs[n / 2 - 1];
    f = xs[n / 2];
    
    rep(i, n) {
        cout << ((x[i] < f) ? f : l) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3712
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

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

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,j,N,H,W,ans;
  cin>>N>>N>>N>>N;
  if(N==1){
    cout<<1<<endl;
  }else{
    cout<<0<<endl;
  }
  return 0;
}

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

using namespace std;
int main() {
    int d, n;
    cin >> d >> n;
    int base = 1;
    for (int i = 0; i < d; ++i) {
        base *= 100;
    }
    int ans = n * base;
    if (n == 100) {
        ans += base;
    }
    cout << ans << endl;
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val K = sc.nextInt()

  @scala.annotation.tailrec
  def gcd(x: Int, y: Int): Int =
    if (x % y != 0) gcd(y, x % y)
    else y

  var x = 0
  for (a <- 1 to K) {
    for (b <- 1 to K) {
      for (c <- 1 to K) {
        x += gcd(gcd(a, b), c)
      }
    }
  }

  println(x)
}


Measured memory_bytes: 56896
#include <iostream>
#include <vector>
using namespace std;
class State{
public:
  int x,y;
  int cnt;
};

int main(void){
  int h,w;
  cin>>h>>w;
  //while(cin>>h>>w,h||w){
    string field[51];
    for(int i=0;i<h;++i){
      cin>>field[i];
    }
    int min[51][51];
    for(int i=0;i<h;++i) for(int j=0;j<w;++j) min[i][j]=(w+h)*10;
    vector<State> qu;
    State S;
    S.x=0;S.y=0;S.cnt=0;
    qu.push_back(S);
    while(!qu.empty()){
      State A,B=qu.back();qu.pop_back();
      if(B.x>=w || B.y>=h) continue;
      A.cnt=B.cnt+field[B.y][B.x]-'0';
      if(A.cnt<min[B.y][B.x])min[B.y][B.x]=A.cnt;
      else continue;
      A.x=B.x+1;A.y=B.y;
      qu.push_back(A);
      A.x=B.x;A.y=B.y+1;
      qu.push_back(A);
    }
    cout<<min[h-1][w-1]<<endl;
  //}
  return 0;
}

Measured memory_bytes: 1248