akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var N = cin.ReadInt();
            var A = cin.ReadIntArray(N);
            Array.Sort(A);
            Array.Reverse(A);
            var Alice = 0;
            var Bob = 0;
            for (int i = 0; i < N; ++i)
            {
                if (i % 2 == 0) Alice += A[i];
                else Bob += A[i];
            }
            WriteLine(Alice - Bob);
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            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() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { 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
use std::io::stdin;

#[allow(dead_code)]
fn input_ints() -> Vec<u64> {
    let mut st = String::new();
    match stdin().read_line(&mut st) {
        Ok(_) => st.split_whitespace().map(|s| s.parse().unwrap()).collect(),
        Err(_) => panic!("err"),
    }
}

#[allow(unused_variables)]
fn solve() {
    let l = input_ints();
    let a = l[0] as usize;
    let b = l[1] as usize;
    let c = l[2] as usize;

    match (1..b).map(|x| (x * a) % b).find(|&x| x == c) {
        Some(n) => println!("YES"),
        None => println!("NO"),
    }

}

fn main() {
    solve();
}


Measured memory_bytes: 4352
import sys
N, M = map(int, input().split())
H = list(map(int, input().split()))
G = [set() for _ in range(N)]
for _ in range(M):
    A, B = map(int, sys.stdin.readline().split())
    A -= 1
    B -= 1
    G[A].add(B)
    G[B].add(A)

ans = 0
for p in range(N):
    if not G[p]:
        ans += 1
        continue
    for np in G[p]:
        if H[p] <= H[np]:
            break
    else:
        ans += 1
print(ans)

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

int main(void) {
    string acgt = "ACGT";
    string s;
    cin >> s;
    int ans = 0;
    int x = 0;
    for (auto c: s) {
        if (acgt.find(c) != string::npos) {
            x++;
            ans = max(ans, x);
        } else {
            x = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
typedef long long ll;
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    cout << ((n % k == 0) ? 0 : 1) << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin>>n;
	int arr[n][3];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>arr[i][j];
		}
	}


	int happiness[n][3];
	happiness[0][0]=arr[0][0];
	happiness[0][1]=arr[0][1];
	happiness[0][2]=arr[0][2];

	for(int i=1;i<n;i++)
	{
		happiness[i][0]=max(happiness[i-1][1],happiness[i-1][2])+arr[i][0];
		happiness[i][1]=max(happiness[i-1][2],happiness[i-1][0])+arr[i][1];
		happiness[i][2]=max(happiness[i-1][0],happiness[i-1][1])+arr[i][2];

	}

	cout<<max(max(happiness[n-1][0],happiness[n-1][1]),happiness[n-1][2]);

	return 0;
}

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

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

struct UnionFind {
	vector<int> parent;
	int size;
	UnionFind(int n) :parent(n, -1), size(n) {}
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y)return false;
		if (size_of(x) < size_of(y))swap(x, y);
		parent[x] += parent[y]; parent[y] = x; size--;
		return true;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
	int size_of(int x) { return -parent[root(x)]; }
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K, L; cin >> N >> K >> L;
	UnionFind uf1(N), uf2(N);
	rep(i, 0, K) {
		int p, q; cin >> p >> q; p--, q--;
		uf1.unite(p, q);
	}
	rep(i, 0, L) {
		int r, s; cin >> r >> s; r--, s--;
		uf2.unite(r, s);
	}
	using P = pair<int, int>;
	map<P, int> cnt;
	rep(i, 0, N) {
		cnt[P(uf1.root(i), uf2.root(i))]++;
	}
	vector<int> ans(N);
	rep(i, 0, N) {
		ans[i] = cnt[P(uf1.root(i), uf2.root(i))];
	}
	cout << ans[0]; rep(i, 1, ans.size()) { cout << " " << ans[i]; } cout << endl;
	return 0;
}

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

using namespace std;

int main()
{
  int N, C, K;

  cin >> N >> C >> K;
  vector<int> T(N);

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

  sort(T.begin(), T.end());
    
  int numBus = 0;
  int Ts = T[0];

  for (int i = 0; i < N;)
  {
    //(Ts <= T <= Ts) + K の期間に到着する人数を数える。
    int numPeople = 1;
    while (1)
    {

      if (i >= N)
      {
        numBus++;
        cout << numBus << endl;
        return 0;  //T[i + 1]を参照しないようにする
      }

      if (numPeople > C || T[i] > Ts + K)
      {
        Ts = T[i];
        numBus++;
        break;
      }

      numPeople++;
      i++;
    }

    if (N - i == 1)
    {
      numBus++;
      break;
    }
  }

  cout << numBus << endl;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  int r,c;
  cin>>r>>c;
  int n[101][101] = {};
  for(int i=0;i<r;i++){
      for(int j=0;j<c;j++){
          cin>>n[i][j];
      }//yomikomi
  }
  for(int i=0;i<r;i++){
    int sum = 0;
    for(int j=0;j<c;j++){
        sum += n[i][j];
    }
    n[i][c] = sum;
  }//tatetashi

  for(int j=0;j<=c;j++){
    int sum = 0;
    for(int i=0;i<r;i++){
        sum += n[i][j];
    }
    n[r][j] = sum;
  }//yookotashi
  
  for(int i=0;i<=r;i++){
    for(int j=0;j<=c;j++){
      if(j) cout<<" ";
      cout<<n[i][j];
    }//shituryoku
    cout<<endl;
  } 
  return 0;
}




Measured memory_bytes: 3152
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

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

    auto possible = [&](int len) -> bool {
        ll count = 0;
        for (int i = 0; i < n; i++) {
            count += (a[i] - 1) / len;
        }
        return count <= k;
    };

    int l = 0, r = 1e9;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        if (possible(mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }

    cout << r << endl;
    return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#define Mod 1000000007
#define INF 1e14
typedef long long int ll;

ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    if(n==1)
        return a;
    else
    {
        ll res=fast(n/2,a,m);
        if(n%2==0)
            return (((res%m)*(res%m))%m);
        else
        {
            return (((((res%m)*a)%m)*res)%m);
        }
    }
}
int main()
{
   string s;
   cin>>s;
   if(s=="Sunny")
    cout<<"Cloudy";
   else if(s=="Cloudy")
    cout<<"Rainy";
   else
    cout<<"Sunny";
}


Measured memory_bytes: 256
s = str(input())
count = []
x = 0 
for i in range(len(s)):
    if s[i] == "R":
        x += 1
        if i == len(s)-1:
            count.append(x)
    if s[i] == "S":
        count.append(x)
        x = 0

print(max(count))

Measured memory_bytes: 9048
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

uint64_t gcd(uint64_t m, uint64_t n) {
    uint64_t tmp;
    while (m%n != 0) {
        tmp = n;
        n = m%n;
        m = tmp;
    }
    return n;
}

int main(void) {
    uint64_t a, b, c, d, i, right, left;
    cin >> a >> b >> c >> d;
    right = b;
    right -= b/c;
    right -= b/d;
    right += b/((c*d)/gcd(c,d));

    left = (a-1);
    left -= (a-1)/c;
    left -= (a-1)/d;
    left += (a-1)/((c*d)/gcd(c,d));

    cout << right-left << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;

int main(){


	while(1){
	int n;
	cin >> n;
	if(n == 0)
		break;
	int over = 1;
	int under = 6;
	int forward = 2;
	int back = 5;
	int left = 4;
	int right = 3;

	int cnt = 0;
	for(int i = 0; i < n; i++){
		string str;
		cin >> str;
		if(str == "North"){
			int tmp = back;
			back = over;
			over = forward;
			forward = under;
			under = tmp;
		}
		else if(str == "East"){
			int tmp = over;
			over = left;
			left = under;
			under = right;
			right = tmp;
		}
		else if(str == "South"){
			int tmp = back;
			back = under;
			under = forward;
			forward = over;
			over = tmp;
		}
		else if(str == "West"){
			int tmp = over;
			over = right;
			right = under;
			under = left;
			left = tmp;
		}
		else if(str == "Right"){
			int tmp = back;
			back = left;
			left = forward;
			forward = right;
			right = tmp;
		}
		else if(str == "Left"){
			int tmp = back;
			back = right;
			right = forward;
			forward = left;
			left = tmp;
		}
		cnt += over;
	}

	cout << cnt+1 << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define int unsigned long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

const int N = 1e6+7;
int a,b,c,d;

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

int lcm(int a, int b)
{
	return (a/gcd(a,b))*b;
}

int32_t main()
{
	fast;

	cin>>a>>b>>c>>d;
	int num1 = b, num2 = a-1;
	//cout<<num1/c<<endl<<num/d<<endl<<num/lcm(c,d)<<endl;;
	int ans = num1-num2-(num1/c-num2/c+num1/d-num2/d-(num1/lcm(c,d)-num2/lcm(c,d)));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#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 bad_main() {
  ll n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i * 2 < n; i++) {
    int cnt = 0;
    // string str = to_string(n - i * 2);
    ll now = n - i * 2;
    // cout << str << endl;
    for (int j = 1; 1; j++) {
      if (now % (10 * j) == 0)
        cnt++;
      else
        break;
      // if (str[str.size() - j - 1] == '0')
      //   cnt++;
      // else
      //   break;
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

ll g1(ll n, int p) {
  if (n == 0) return 0;
  return n / p + g1(n / p, p);
}

ll g2(ll n, int p) {
  if (n % 2 == 1) return g1(n, p) - g2(n - 1, p);
  ll res = g1(n / 2, p);
  if (p == 2) res += n / 2;
  return res;
}

int main() {
  ll n;
  cin >> n;
  ll ans = min(g2(n, 2), g2(n, 5));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<50)
#define vi vector<int> 
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >   
#define vpl vector< pair<ll,ll> >   
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod 1000000007
#define pi 3.14159265358979323846//20 decimals

#define double long double
#define N 100001


int32_t main()
{
    IOS;
    
    int n,a,b;
    cin>>n>>a>>b;
    vi v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    int cost=0;
    for(int i=0;i<n-1;i++)
    {
        cost+=min(a*(v[i+1]-v[i]),b);

    }
    cout<<cost;
    return 0;

}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n, k;
    int[] card;
    boolean Joker;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    k = sc.nextInt();
	    if(n==0 && k==0) break;

	    card = new int[k];
	    
	    for(int i=0; i<k; i++)
		card[i] = sc.nextInt();
	    Arrays.sort(card);
	    Joker = card[0]==0;
	    //show();
	    
	    int R = k+1;
	    int L = Joker ? 2:1; 
	    int m = (R+L)/2;
	    while(L+1 != R){
		//System.out.println("*"+L+" "+R+" "+m);
		//System.out.println(m+" "+step(m));
		if(step(m)) L = m;
		else R = m;
		m = (R+L)/2;
	    }

	    System.out.println(L);
	}
    }

    boolean step(int m){
	int s = Joker ? 1:0;
	for(int i=s; i<k; i++){
	    //System.out.println("++"+card[i]);
	    int endN = i+m-1; // 最後のカードの配列番号
	    int endC = card[i]+m-1; //最後のカードにあるべき値
	    if(endC>n || endN>k) continue;
	    
	    if(endN==k)
		if(card[k-1]==endC && Joker) return true;
		else return false;
		
	    if(card[endN]==endC ||
	       (card[endN-1]==endC && Joker))
		return true;
	}
	return false;
    }

    void show(){
	for(int i=0; i<k; i++)
	    System.out.print(card[i]+" ");
	System.out.println();
    }
}

Measured memory_bytes: 62232
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  for(int i=0;i<110000;i++){
    if( A/0.08<=i && i<(A+1)/0.08 && B/0.1<=i && i<(B+1)/0.1 ){
//      cout << A/0.08 << " : " << (A+1)/0.08 << " : " << B/0.1 << " : " << (B+1)/0.1 << endl;
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.List;
import java.io.*;
import java.util.Scanner;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		int one = Integer.parseInt(s.split(" ")[0]),
		 		two = Integer.parseInt(s.split(" ")[1]),
				three = Integer.parseInt(s.split(" ")[2]),
				four = Integer.parseInt(s.split(" ")[3]),
				five = Integer.parseInt(s.split(" ")[4]),
				six = Integer.parseInt(s.split(" ")[5]);
				s	= "EEEESEEEE";
		int tmpCnt = Integer.parseInt(scan.nextLine());
		for(int j = 0;j<tmpCnt;j++){
		String tmpStr = scan.nextLine();
		int x = Integer.parseInt(tmpStr.split(" ")[0]);
		int y = Integer.parseInt(tmpStr.split(" ")[1]);
		for (int i = 0; i < s.length(); i++) {
			int tmp;
			if (s.charAt(i) == 'E') {
				tmp = one;
				one = four;
				four = six;
				six = three;
				three = tmp;
			} else if (s.charAt(i) == 'N') {
				tmp = one;
				one = two;
				two = six;
				six = five;
				five = tmp;
			} else if (s.charAt(i) == 'S') {
				tmp = one;
				one = five;
				five = six;
				six = two;
				two = tmp;
			} else if (s.charAt(i) == 'W') {
				tmp = one;
				one = three;
				three = six;
				six = four;
				four = tmp;
			}
			if(one == x){
				break;
			}
		}
		if(two == y){
			System.out.println(three);
		}else if(three == y){
			System.out.println(five);
		}else if(four == y){
			System.out.println(two);
		}else if(five == y){
			System.out.println(four);
		}
		// System.out.println(one);
	}
	}
}



Measured memory_bytes: 26192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int N, x; cin >> N >> x;
  vi arr(N);
  rep(i,N) cin >> arr[i];

  ll ans = 0;
  rep(i,N-1) {
    int sum = arr[i] + arr[i+1];
    if (sum <= x) continue;
    arr[i+1] -= min(arr[i+1], sum-x);
    ans += sum-x;
  }
  
  cout << ans << endl;
  return 0;
}


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

using namespace std;

void bfs(long long N, vector<long long> v[], long long u, long long ans[]){
    long long vis[N] = {false};
    vis[u] = true;
    list<long long> q;
    q.push_back(u);
    while(!q.empty()){
        u = q.front();
        q.pop_front();
        for(long long i = 0; i < v[u].size(); i++){
            if(vis[v[u][i]] == false){
                ans[v[u][i]] = u;
                vis[v[u][i]] = true;
                q.push_back(v[u][i]);
            }
        }
    }
}

int main(){
    long long N, M;
    cin >> N >> M;
    long long A[M], B[M];
    for(long long i = 0; i < M; i++){
        cin >> A[i] >> B[i];
    }
    vector<long long> v[N + 1];
    for(long long i = 0; i < M; i++){
        v[A[i]].push_back(B[i]);
        v[B[i]].push_back(A[i]);
    }
    long long ans[N + 1] = {0};
    bfs(N + 1, v, 1, ans);
    bool flag = false;
    for(long long i = 2; i < N + 1; i++){
        if(ans[i] > 0){
            flag = true;
            break;
        }
    }
    if(flag){
        cout << "Yes" << endl;
        for(long long i = 2; i < N + 1; i++){
            if(ans[i] != 0){
                cout << ans[i] << endl;
            }
        }
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int b, c;
    vector<pair<int, int>> num;
    for (int i = 0; i < m; i++){
        cin >> b >> c;
        num.push_back({c, b});
    }
    sort(a.begin(), a.end(), greater<int>());
    sort(num.begin(), num.end(), greater<pair<int, int>>());
    long long ans = 0;
    int now = 0;
    int target = 0;
    for (int i = 0; i < n; i++){
        if (a[now] >= num[target].first){
            ans += a[now];
            now++;
        }
        else{
            int k = min(i + num[target].second, n);
            for (i = i; i < k; i++) ans += num[target].first;
            target++;
            i--;
        }
    }
    cout << ans << endl;
}





Measured memory_bytes: 1784
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
int INF=1e+9;
int main(){
	int N,C;
	int D[31][31];
	int c[500][500];
	int colornum[3][31]={0};
	int colornumall[31]={0};
	int iwakanmin=INF;
	vector<int> colorkind;
	scan(N);scan(C);
	rep(i,C){
		rep(j,C){
			scan(D[i+1][j+1]);
		}
	}
	rep(i,N){
		rep(j,N){
			scan(c[i][j]);
			colornum[(i+j)%3][c[i][j]]++;
			//colornumall[c[i][j]]++;
			//if(colornumall[c[i][j]]==1) colorkind.push_back(c[i][j]);
		}
	}
	/*rep(i,3){
		rep(j,C){
			printf("%d ",colornum[i][j+1]);
		}
		kaigyo;
	}
	kaigyo;*/
	//rep(i0,colorkind.size()){
	rep(i0,C){
		//rep(i1,colorkind.size()){
		rep(i1,C){
			//if(colorkind[i1]==colorkind[i0]) continue;
			if(i0==i1) continue;
			//rep(i2,colorkind.size()){
			rep(i2,C){
				//if(colorkind[i2]==colorkind[i0]||colorkind[i2]==colorkind[i1]) continue;
				if(i2==i0||i2==i1) continue;
				//printf("change color to %d %d %d\n",colorkind[i0],colorkind[i1],colorkind[i2]);
				int iwakan=0;
				for(int j=1;j<=C;j++){
					iwakan+=colornum[0][j]*D[j][i0+1];
					iwakan+=colornum[1][j]*D[j][i1+1];
					iwakan+=colornum[2][j]*D[j][i2+1];
				}
				iwakanmin=min(iwakan,iwakanmin);
			}
		}
	}
	prin(iwakanmin);

	return 0;
}


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

#define ROUND_UP(a, b) ((a) + (b)-1)/(b)

int main(void)
{
	int n, a;
	cin >> n;
	cin >> a;

	int r = n % 500;
	if (r <= a)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
vector<vector<int>> path;
vector<int> col;

pair<int, bool> dfs(int id, int c) {
  if (col[id] < 0) {
    col[id] = c;
  } else if (col[id] != c) {
    return make_pair(0, true);
  } else
    return make_pair(0, false);
  pair<int, bool> ret(0, false);
  if (c == 0)
    ret.first++;
  else
    ret.first--;
  for (int i = 0; i < path[id].size(); i++) {
    pair<int, bool> r = dfs(path[id][i], 1 - c);
    if (r.second)
      return make_pair(0, true);
    ret.first += r.first;
  }
  return ret;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> ab(m);
  for (int i = 0; i < m; i++) {
    cin >> ab[i].first >> ab[i].second;
    ab[i].first--;
    ab[i].second--;
  }
  bool p[1000][1000] = {0};
  for (int i = 0; i < m; i++)
    p[ab[i].first][ab[i].second] = p[ab[i].second][ab[i].first] = true;
  path.resize(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j || p[i][j])
        continue;
      path[i].push_back(j);
    }
  }
  col.resize(n);
  for (int i = 0; i < n; i++)
    col[i] = -1;
  vector<int> diffs;
  for (int i = 0; i < n; i++) {
    if (col[i] < 0) {
      pair<int, bool> ib = dfs(i, 0);
      if (ib.second) {
        cout << -1 << endl;
        return 0;
      }
      diffs.push_back(abs(ib.first));
    }
  }
  bool dp[1000][2001] = {0};
  int offset = 1000;
  dp[0][offset] = true;
  for (int i = 0; i < diffs.size(); i++) {
    for (int j = -800; j <= 800; j++) {
      if (dp[i][j + offset]) {
        dp[i + 1][j + offset + diffs[i]] = true;
        dp[i + 1][j + offset - diffs[i]] = true;
      }
    }
  }
  int ans = m;
  for (int i = -800; i <= 800; i++) {
    if (dp[diffs.size()][i + offset]) {
      int size = (n - abs(i)) / 2;
      int sub = n - size;
      ans = min(ans, size * (size - 1) / 2 + sub * (sub - 1) / 2);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5760
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String t = "";
		switch(n%10){
		case 3:
			t += "bon";
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			t += "pon";
			break;
		default:
			t += "hon";
		}
		System.out.println(t);
	}
}



Measured memory_bytes: 38080
#include <bits/stdc++.h>
#define Tayeb ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef long long ll;
using namespace std;
int main()
{
    Tayeb;
    int X,sum1=0,sum2=0;
    cin >> X;
    sum1=(X%500)-((X%500)%5);
    sum2=(X/500)*1000;
    cout << sum1+sum2 << "\n";
    
    return 0;

}


Measured memory_bytes: 3612
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    string S,T;
    cin>>S;
    cin>>T;
    ll ans=0;
    REP(i,T.size()){
      if(S[i]!=T[i]) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3856
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	long long  n,x;
	cin >> n>> x;
	long long a[100001]={};
	long long  b[100001]={};
	long long ans=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n-1;i++){
		b[i]=a[i]+a[i+1];
	}
	for(int i=0;i<n-1;i++){
		if(b[i]>x){
			ans += b[i]-x;
			if(a[i+1]>=b[i]-x){
				b[i+1] -= b[i]-x;
			}else{
				b[i+1] -= a[i+1];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();

    // x * x + y * y + z * z
    let mut memo = vec![0; 10010];
    let mut x = 1;
    while x * x <= n {
        let mut y = 1;
        while y * y <= n {
            let mut z = 1;
            while z * z <= n {
                let val = x * x + y * y + z * z + x * y + y * z + z * x;
                if val <= n {
                    memo[val] += 1;
                }
                z += 1;
            }
            y += 1;
        }
        x += 1;
    }
    let mut out = Vec::new();

    for i in 1..=n {
        writeln!(out, "{}", memo[i]).ok();
    }
    stdout().write_all(&out).unwrap();
}


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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int N, M;
    cin>>N>>M;
    vector<int> X(M);
    for (int i = 0; i < M; i++) cin>>X[i];

    if(N>=M){
        cout<<0<<endl;
        return 0;
    }

    sort(all(X));

    vector<int> dif;
    for(int i = 1; i < M; i++)
    {
        dif.push_back(abs(X[i]-X[i-1]));
    }
    sort(all(dif));
    
    for(int i = 0; i < N-1; i++)
    {
        dif.pop_back();
    }
    
    ll sum=0;
    for(auto x : dif)sum+=x;
    cout<<sum<<endl;

    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);


int main(void)
{
    ll h,w; cin>>h>>w;
    string s[50];
    rep(i,h) cin>>s[i];

    ll di[8]={1,1,1,0,0,-1,-1,-1};
    ll dj[8]={1,0,-1,1,-1,1,0,-1};
    
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#') continue;
            ll cnt=0;
            rep(k,8){
                ll ni=i+di[k];
                ll nj=j+dj[k];
                if(ni<0||nj<0||h<=ni||w<=nj) continue;
                else if(s[ni][nj]=='#') cnt++;
            }
            s[i][j]=cnt+'0';
        }
    }
    rep(i,h) cout<<s[i]<<endl;
    return 0;
}


Measured memory_bytes: 3580
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	static int[] memo = new int[45];
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int q = Integer.parseInt(in.nextLine());
		for (int i = 0; i < q; i++) {
			String X = in.nextLine();
			String Y = in.nextLine();
			System.out.println(lcs(X, Y));
		}
	}
	static int lcs(String X, String Y) {
		int dp[][] = new int[X.length()+1][Y.length()+1];
		for (int i = 0; i < X.length()+1; i++) {
			Arrays.fill(dp[i], 0);
		}
		for (int i = 1; i < X.length()+1; i++) {
			for (int j = 1; j < Y.length()+1; j++) {
				int a = dp[i-1][j];
				int b = dp[i][j-1];
				int c = dp[i-1][j-1];
				if (X.charAt(i-1) == Y.charAt(j-1)) c++;
				if (a > b) {
					if (a > c) {
						dp[i][j] = a;
					} else {
						dp[i][j] = c;
					}
				} else {
					if (b > c) {
						dp[i][j] = b;
					} else {
						dp[i][j] = c;
					}
				}
			}
		}
		return dp[X.length()][Y.length()];
	}
}



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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

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

    int a, b; cin >> a >> b;
    a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 ? cout << "Possible" : cout << "Impossible";
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            var rl = spr(RL()).Select(x=>decimal.Parse(x)).ToList();

            long ret=(long)(rl.First() * rl.Last());

            


            Console.WriteLine(ret);
            Console.ReadLine();
        
        }
        
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


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

vector<string> split(string S, vector<int> idx){
  vector<string> s;
  for(int i=0; i<idx.size()-1; i++){
    string c="";
    for(int j=idx[i]; j<idx[i+1]; j++){
      c+=S[j];
    }
    s.push_back(c);
  }
  return s;
}

vector<int> enumidx(int N, int bsize){
  vector<int> idx;
  idx.push_back(0);
  int bit=N;
  int num=1;
  for(int j=1; j<=bsize; j++){
    if(bit%2){
      idx.push_back(num);
    }
    bit/=2;
    num++;
  }
  idx.push_back(bsize);
  return idx;
}

int main(){
  string S;
  cin >> S;
  int N=S.size()-1;
  long ans=atol(S.c_str());
  for(int i=1; i< (1<<N); i++){
    vector<int> idx = enumidx(i, N+1);
    vector<string> s = split(S, idx);
    for(int i=0; i<s.size(); i++){
      ans+=atol(s[i].c_str());
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <utility>
#include <cctype>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#define LL long long
#define LB long double
#define x first
#define y second
#define Pair pair<int,int>
#define pLL pair<LL,LL>
#define pii pair<double,double>
#define pb push_back
#define pf push_front
#define mp make_pair
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+9;
const LL LINF=2e16;
const int INF=2e9;
const int magic=348;
const double eps=1e-10;
const double pi=3.14159265;

inline int getint()
{
    char ch;int res;bool f;
    while (!isdigit(ch=getchar()) && ch!='-') {}
    if (ch=='-') f=false,res=0; else f=true,res=ch-'0';
    while (isdigit(ch=getchar())) res=res*10+ch-'0';
    return f?res:-res;
}

int n;
char s[300048];

inline LL mod(LL x,int MO) {while (x>=MO) x-=MO;while (x<0) x+=MO;return x;}
inline LL quick_pow(LL x,LL y,int MO)
{
	LL res=1;x%=MO;
	while (y)
	{
		if (y&1) res=(res*x)%MO,y--;
		x=(x*x)%MO;y>>=1;
	}
	return res;
}
const int p1=19260817,p2=998244353,m1=1e9+7,m2=1e9+9;
LL inv1,inv2;
LL f1[300048],f2[300048];LL K,B;
map<pLL,int> Mp;

int main ()
{
	int i;n=getint();scanf("%s",s+1);
	inv1=quick_pow(p1,m1-2,m1);inv2=quick_pow(p2,m2-2,m2);
	K=1;B=0;
	for (i=1;i<=n;i++)
	{
		if (s[i]=='+') B=mod(B+K,m1);
		if (s[i]=='-') B=mod(B-K,m1);
		if (s[i]=='<') K=(K*inv1)%m1;
		if (s[i]=='>') K=(K*p1)%m1;
		f1[i]=B;
	}
	K=1;B=0;
	for (i=1;i<=n;i++)
	{
		if (s[i]=='+') B=mod(B+K,m2);
		if (s[i]=='-') B=mod(B-K,m2);
		if (s[i]=='<') K=(K*inv2)%m2;
		if (s[i]=='>') K=(K*p2)%m2;
		f2[i]=B;
	}
	Mp.clear();for (i=1;i<=n;i++) Mp[mp(f1[i],f2[i])]++;
	LL c1=0,c2=0;
	for (i=n;i>=1;i--)
	{
		if (s[i]=='+') c1=mod(c1+1,m1),c2=mod(c2+1,m2);
		if (s[i]=='-') c1=mod(c1-1,m1),c2=mod(c2-1,m2);
		if (s[i]=='<') c1=(c1*inv1)%m1,c2=(c2*inv2)%m2;
		if (s[i]=='>') c1=(c1*p1)%m1,c2=(c2*p2)%m2;
	}
	LL k1=1,b1=0,k2=1,b2=0,need1,need2,ans=0;
	for (i=1;i<=n;i++)
	{
		need1=(mod(c1-b1,m1)*quick_pow(k1,m1-2,m1))%m1;
		need2=(mod(c2-b2,m2)*quick_pow(k2,m2-2,m2))%m2;
		ans+=Mp[mp(need1,need2)];
		Mp[mp(f1[i],f2[i])]--;
		if (s[i]=='+') b1=mod(b1-1,m1),b2=mod(b2-1,m2);
		if (s[i]=='-') b1=mod(b1+1,m1),b2=mod(b2+1,m2);
		if (s[i]=='<') k1=(k1*p1)%m1,b1=(b1*p1)%m1,k2=(k2*p2)%m2,b2=(b2*p2)%m2;
		if (s[i]=='>') k1=(k1*inv1)%m1,b1=(b1*inv1)%m1,k2=(k2*inv2)%m2,b2=(b2*inv2)%m2;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 35968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int M = 2e5 + 10;
int a[M], vis[M], b[M];
int main(){
    int n;
    ll k;
    scanf("%d%lld", &n, &k);
    k++;
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    int i = 1, cnt = 1, x, y;
    vis[1] = 1;
    b[1] = 1;
    k--;
    while(k > 0) {
        //printf("i = %d\n", i);
        if(vis[a[i]]) {
            x = vis[a[i]];
            y = vis[i];
            break;
        }
        else {
            k--;
            i = a[i];
            vis[i] = ++cnt;
            b[cnt] = i;
        }
    }
    if(k == 0) printf("%d\n", i);
    else {
        //printf("x = %d y = %d k = %lld\n", x, y, k);
        k = k % (y - x + 1);
        if(k == 0) k = y - x + 1;
        printf("%d\n", b[x + k - 1]);
    }
    return 0;
}


Measured memory_bytes: 5876
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <climits>
#include <map>

using namespace std;

vector <pair <int, long long> > edges[100000];

long long depth[100000];
bool used[100000];
int child_group[100000];

void dfs(int v, long long cur_depth){
  depth[v] = cur_depth;
  used[v] = true;
  for(int i = 0; i < edges[v].size(); i++){
    int next_v = edges[v][i].first;
    long long d = edges[v][i].second;
    if(used[next_v]){
      continue;
    }
    dfs(next_v, cur_depth + d);
  }
}

int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N - 1; i++){
    int a;
    int b;
    long long c;
    cin >> a >> b >> c;
    edges[a - 1].push_back(make_pair(b - 1, c));
    edges[b - 1].push_back(make_pair(a - 1, c));
  }

  int Q;
  int K;
  cin >> Q >> K;

  dfs(K - 1, 0);

  for(int i = 0; i < Q; i++){
    int x;
    int y;
    cin >> x >> y;
    cout << depth[x - 1] + depth[y - 1] << endl;
  }
  return 0;
}

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

using namespace std;
const int N = 1111;
string st[N];
int num[N], f[N][17];

#define pp pair<int, int>

struct Data {
    int u, len, d;
    bool operator< (const Data& a) const {
        return d > a.d;
    };
};


int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> st[i];   
        for (char c : st[i]) {
            num[i] = num[i] * 2 + (c - '0');
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 17; ++j) f[i][j] = 1e9;
    }
    priority_queue<Data> q;
    for (int i = 0; i < n; ++i) {
        f[i][st[i].size()] = st[i].size();
        q.push({i, (int)st[i].size(), (int)st[i].size()});
    }
    while (!q.empty()) {
        Data u = q.top(); q.pop();
        // cerr << "U = " << u.u << ' ' << u.len << ' ' << u.d << ' ' << f[u.u][u.len] << '\n';
        int numU = num[u.u] % (1 << u.len);
        if (u.d != f[u.u][u.len]) continue;
        if (u.len == 0) {
            cout << u.d << '\n';
            return 0;
        }
        for (int v = 0; v < n; ++v) {
            if (u.len == (int)st[u.u].size() && v == u.u) continue;
            // cerr << "v = " << v << '\n';
            if (st[v].size() > u.len) {
                if (numU % (1 << u.len) == num[v] >> ((int)st[v].size() - u.len)) {
                    Data newV = {v, (int)st[v].size() - u.len, u.d + (int)st[v].size() - u.len};
                    // cerr << 1 << ' ' << newV.u << ' ' << newV.len << ' ' << newV.d << ' ' << f[v][newV.len]<< '\n';
                    if (newV.d < f[v][newV.len]) {
                        // cerr << "Pushed\n";
                        f[v][newV.len] = newV.d;
                        q.push(newV);
                    }
                }
            } else {
                if (numU >> (u.len - (int)st[v].size()) == num[v]) {
                    Data newV = {u.u, u.len - (int)st[v].size(), u.d};
                    // cerr << 2 << ' ' << newV.u << ' ' << newV.len << ' ' << newV.d << ' ' << f[u.u][newV.len]<< '\n';
                    if (newV.d < f[u.u][newV.len]) {
                        //  cerr << "Pushed\n";
                        f[u.u][newV.len] = newV.d;
                        q.push(newV);
                    }
                }
            }
        }
    }
    cout << 0 << '\n';
}


Measured memory_bytes: 3344
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
ll MOD = 1000000007;

ll A[200001] = {};
int main()
{
	ll N, M; cin >> N >> M;
	rep(i, 0, M) {
		ll a, b; cin >> a >> b;
		if (a == 1) {
			A[b]++;
		}
		if (b == N) {
			A[a]++;
		}
	}
	repe(i, 0, N) {
		if (A[i] >= 2) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    string S;
    cin >> S;

    int ans = 0;
    rep(i, S.size() / 2) {
        if (S[i] != S[S.size() - 1 - i]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))
"""
A,B = nums()
P,Q,R = nums()

first_distance = P * B
pre_runned = (B - A) * Q
time = B + (first_distance - pre_runned) / (R + Q)
print(time)
"""

N = num()
randoms = nums()
ans = 0
for i in range(N):
    today = randoms[i]
    if i == 0:
        continue
    if today > randoms[i-1]:
        ans += 1
print(ans)


Measured memory_bytes: 16664
package main
import "fmt"
func main() {
  var n,a,m int
  fmt.Scan(&n)
  m = 1
  for i:=0;i<n;i++ {
    fmt.Scan(&a)
    m *= 2-a%2
  }
  fmt.Println(pow(3,n)-m)
}
func pow(base int,power int) int {
  if power == 0 { return 1 }
  if power%2 == 0 {
    var h int = pow(base,power/2)
    return h*h
  } else {
    return base*pow(base,power-1)
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000007
//0=48,A=65,a=97

int main() {
    int x;cin >> x;
    if(x) cout << 0 << endl;
    else cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 3628
def combinations_count(n, r, mod):
    r = min(r, n-r)
    p,k = 1,1
    for i in range(1,r+1):
        p *= (n-i+1)
        k *= i
        p = p%mod
        k = k%mod
    return p*inv(k,mod)%mod
def inv(a, mod):
    return pow(a, mod - 2, mod)
def D():
    n,a,b = list(map(int, input().split()))
    mod = 10**9+7
    res = pow(2,n,mod) - 1
    res -= combinations_count(n, a, mod)
    res -= combinations_count(n, b, mod)
    print(res%mod)
D()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	int a[n];
	long long sum = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		sum = sum ^ a[i];
	}
	for (int i = 0; i < n; i++)
	{
		long long res = sum ^ a[i];
		cout << res;
		if(i == n - 1) cout << endl;
		else cout << " ";
	}

	return 0;
}


Measured memory_bytes: 4412
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
//fflush(stdin);
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll k,x;
    cin>>k>>x;
    ll i=0;
    while (true)
    {
        ll ans=(x-k+1+i);
        if (ans+1000000>=0&&ans<=1000000)
        {
            cout<<ans<<" ";
        }
        i++;
        ///cout<<"i.. "<<i<<endl;
        if (i==2*(k-1)+1)
        bb;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll a, b, c, x; cin >> a >> b >> c >> x;

    ll ans = 0;
    rep(i, 0, a){
        rep(j, 0, b){
            rep(k, 0, c){
                if(500*i+100*j+50*k == x)ans++;
            }
        }
    }
    print(ans) 
    return 0;
}

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

signed main() {
  int N,D; cin >> N >> D;
  int ans = 1;
  int cover=1+2*D;
  for (int i=1; i<=N; i++) {
    if(cover >= i) continue;
    cover = i+2*D;
    ans++;
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 200050;
const int MAX_L = 100000000;

int N;
int X[MAX_N], Y[MAX_N];

int seq[MAX_N], dp_lis[MAX_N];

int main(int argc, char **argv) {
    int x1, y1, x2, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;
    std::cin >> N;

    for (int i = 1; i <= N; i++) {
        std::cin >> X[i] >> Y[i];
    }

    if (x2 < x1) {
        for (int i = 1; i <= N; i++) {
            X[i] = MAX_L - 1 - X[i];
        }
        x1 = MAX_L - 1 - x1;
        x2 = MAX_L - 1 - x2;
    }

    if (y2 < y1) {
        for (int i = 1; i <= N; i++) {
            Y[i] = MAX_L - 1 - Y[i];
        }
        y1 = MAX_L - 1 - y1;
        y2 = MAX_L - 1 - y2;
    }

    std::vector<std::pair<int, int>> vec;

    for (int i = 1; i <= N; i++) {
        if (x1 <= X[i] && X[i] <= x2 && y1 <= Y[i] && Y[i] <= y2) {
            vec.push_back(std::pair<int, int>({X[i], Y[i]}));
        }
    }

    std::sort(vec.begin(), vec.end(),
        [](const std::pair<int, int>& a, const std::pair<int, int> b) { return a.first < b.first; }
    );

    int seq_size = vec.size();

    for (int i = 1; i <= seq_size; i++) {
        seq[i] = vec[i-1].second;
    }

    for (int i = 1; i <= seq_size; i++) {
        dp_lis[i] = MAX_L;
    }
    dp_lis[0] = 0;

    for (int i = 1; i <= seq_size; i++) {
        int lb = 0;
        int ub = seq_size;
        while(lb + 1 < ub) {
            int mid = (lb + ub) / 2;
            if (dp_lis[mid] < seq[i]) {
                lb = mid;
            } else {
                ub = mid;
            }
        }
        dp_lis[ub] = std::min(dp_lis[ub], seq[i]);
    }

    int length = 0;
    for (int i = 1; i <= seq_size; i++) {
        if (dp_lis[i] < MAX_L) {
            length++;
        } else {
            break;
        }
    }

    double PI = acos(-1.0);

    double ret = (x2 - x1 + y2 - y1) * 100.0;

    if (length == std::min(x2 - x1 + 1, y2 - y1 + 1)) {
        ret += (length - 1) * (5.0 * PI - 20.0);
        ret += 10.0 * PI - 20.0;
    } else {
        ret += length * (5.0 * PI - 20.0);
    }

    std::cout << std::setprecision(14) << ret << std::endl;

    return 0;
}


Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    std::cin >> a >>b;
    if(a>=13){
        std::cout << b << std::endl;
    }else if(a>=6){
        std::cout << b/2 << std::endl;
    }else{
        std::cout << 0 << std::endl;
    }
    
}


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

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b / a >= c) {
		cout << c << endl;
	}
	else if (b / a < c) {
		cout << b / a << endl;
	}
}

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

using namespace std;
const int N = 22;

int main() {
	int n;
	scanf("%d", &n);
	long long res = 0;
	int mini = 1e9;
	bool odd = false;
	for (int i = 0; i < n; ++i) {
		int a;
		scanf("%d", &a);
		res += abs(a);
		if (a < 0)
			odd = !odd;
		mini = min(mini, abs(a));
	}
	if (!odd) {
		printf("%lld\n", res);
	} else {
		printf("%lld\n", res - mini * 2);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,i,a[200001],max1=0,max2=0,p=-1;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		if(max1<a[i]){
			p=i;max1=a[i];
		}
	}
	for(i=0;i<n;i++){
		if(i!=p){
			max2=max(max2,a[i]);
		} 
	}
	for(i=0;i<n;i++){
		if(i==p)cout<<max2<<'\n';
		else cout<<max1<<'\n'; 
	}
	return 0;
}



Measured memory_bytes: 2432