akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>

#define div1 1000000007

using namespace std;

int main(void)
{
    int N, M;

    cin >> N >> M;

    if(N == M){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())
a = [0]*n
b = [0]*n
c = [0]*n
for i in range(n):
    a[i],b[i],c[i] = map(int,input().split())

dpa = [a[0]]+[0]*(n-1)
dpb = [b[0]]+[0]*(n-1)
dpc = [c[0]]+[0]*(n-1)
for i in range(1,n):
    dpa[i] = max(dpb[i-1],dpc[i-1]) + a[i]
    dpb[i] = max(dpc[i-1],dpa[i-1]) + b[i]
    dpc[i] = max(dpa[i-1],dpb[i-1]) + c[i]
print(max(dpa[-1],dpb[-1],dpc[-1]))

Measured memory_bytes: 27492
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
  int n;
  int d[100];
  cin >> n;
  rep(i,n) cin >> d[i];
  int sum = 0;
  rep(i,n){
    for(int j = i+1; j < n; j++){
      sum += d[i]*d[j];
    }
  }
  printf("%d\n", sum );
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
N, X = map(int, input().split())
MEMO = {}


def f(n):
    if n in MEMO:
        return MEMO[n]
    if n == 0:
        return 1
    MEMO[n] = f(n - 1) * 2 + 3
    return MEMO[n]


MEMO2 = {}


def g(n, i):
    if i > f(n):
        i = f(n)
    if (n, i) in MEMO2:
        return MEMO2[(n, i)]
    if n == 0:
        return 1
    ans = 0
    if i > 1:
        ans += g(n - 1, i - 1)
    if i >= 1 + f(n - 1) + 1:
        ans += 1
    if i > 1 + f(n - 1) + 1:
        ans += g(n - 1, i - 1 - f(n - 1) - 1)
    MEMO2[(n, i)] = ans
    return ans


print(g(N, X))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#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 FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){
    int N;
    cin >> N;
    vector<int>A(N);
    for(int i = 0;i < N;i++)
        cin >> A.at(i);

    int goukei=0;

    for(int i = 0;i < N;i++){
        if(i % 2 == 0){
            if(A.at(i) % 2 != 0)
                goukei++;
        }
    }

    cout << goukei << endl;

}


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

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

    string s, t;
    cin >> s >> t;
    cout << t << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, d[3003][3003] = {}, z = 0;
    pii a[3003] = {};
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second;
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++) {
        for (int j = a[i].first; j <= m; j++) {
            d[i][j] = max(d[i - 1][j], d[i - 1][j - a[i].first] + a[i].second);
        }
    }
    for (int i = 1; i <= n; i++) {
        int b = 0;
        for (int j = i + 1; j <= n; j++) b = max(b, a[j].second);
        z = max(z, d[i][m - 1] + b);
    }
    cout << z;
}


Measured memory_bytes: 38900
x = int(input())
if x < 10:
  print(x)
elif 10 <= x <100:
  print(9)
elif 100<=x <1000:
  print(9+x-100+1)
elif 1000 <= x < 10000:
  print(909)
elif 10000 <= x < 100000:
  print(909+x-10000+1)
else:
  print(90909)

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

int selection(int n, vector<int> &v) {
  int cnt = 0;
  int minj;
  for (int i = 0; i < n; i++) {
    minj = i;
    for (int j = i; j < n; j++) {
      if (v.at(j) < v.at(minj))
      minj = j;
    }
    if (v.at(i) != v.at(minj)) {
      swap(v.at(i), v.at(minj));
      cnt++;
    }
  }
  return cnt;
}

int main() {
  int n; cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }

  int ans = selection(n, v);
  for (int i = 0; i < n; i++) {
    if (i == n - 1)
    cout << v.at(i) << endl;
    else
    cout << v.at(i) << " ";
  }
  cout << ans << endl;
}



Measured memory_bytes: 3092
#include <string>
#include <sstream>
#include <iostream>

using namespace std;

int main() {
    int a, total=0;
    cin>>a;
    char b;

    while(a > 0){
        if(b !='A'){
            cin>>b;
        }
        if(b=='A'){
            cin>>b;
            if(b=='B'){
                cin>>b;
                if(b=='C'){
                    total++;
                }
            }
        }
        a--;
    }

    cout<<total;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
	int dp[100005];
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=1;i<n;i++){
		dp[i]=1e9+1;
		for(int j=1;j<=k;j++){
			if(i-j>=0)dp[i]=min(dp[i],abs(a[i]-a[i-j])+dp[i-j]);
		}
		//cout<<dp[i]<<" ";
	}
	cout<<dp[n-1];
}

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

using namespace std;

#define MAXH 1001
#define MAXW 1001

int H,W;
char mat[MAXH][MAXW];
int dista[MAXH][MAXW];
bool visti[MAXH][MAXW];
int moves[][2] = {{0,1},{0,-1},{1,0},{-1,0}};
// . white 
// # black
int main(){
	#ifdef EVAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	cin >> H >> W;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin >> mat[i][j];
		}
	}
	queue <pair <int,int> >q;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(mat[i][j] == '#'){
				visti[i][j] = true;
				q.push({i,j});
			}
		}
	}

	int ans = 0;
	while(!q.empty()){
		int y = q.front().first;
		int x = q.front().second;
		ans = max(dista[y][x],ans);
		q.pop();
		for(int i = 0; i < 4; i++){
			int cy = y + moves[i][0];
			int cx = x + moves[i][1];
			if(cy >= 0 && cy < H && cx >= 0 && cx < W){
				if(!visti[cy][cx]){
					visti[cy][cx] = true;
					dista[cy][cx] = dista[y][x] + 1;
					q.push({cy,cx});
				}
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0LL);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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


    map<ll, ll> isDiv;
    ll divn=n;
    for(ll i=2; i*i<=divn; i++){
        while(divn%i==0){
   
            isDiv[i] += 1;
            divn /= i;
        }
    }
    if(divn != 1) isDiv[divn] = 1;
    // for(auto x: isDiv) cout << x.first << ' ';
    // cout << endl;
    ll res=0;
    
    for(auto x: isDiv){
        //cout << x.first << ',' << x.second << ' ';
        ll tmp=x.first; //cout << tmp << 't' ;
        while(1){

            if(n%tmp==0) n /= tmp;
            else break;
            res += 1;
            tmp *= x.first;
            // cout << res << ' ';
            // cout << 'n' << n << ' ';
        }
        //cout << endl;
    }
    
    cout << res << endl;
}

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

int main() {
  int from,end,check,c=0;
  while(cin >> from >> end) {
    check = 0;
    if((from == 0) && (end == 0)) break;
    if(c != 0) cout << endl;
    for(int i=0;i<end - from + 1;i++) {
      if((from + i) % 4 == 0) {
        if((from + i) % 100 == 0) {
          if((from + i) % 400 == 0) {
            cout << from + i << endl;
            check = 1;
          }
        }
        else {
          cout << from + i << endl;
          check = 1;
        }
      }
    }
    if(check == 0)
      cout << "NA" << endl;
    c = 1;
  }
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;
int main()
{
	int i = 0;
	while(true)
	{
		i++;
		int x;
		cin >> x;
		if(x == 0)
		{
			break;
		}
		cout << "Case " << i << ": " << x << "\n";
	}
}

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <set>
using namespace std;

long long int gcd(long long int m,long long int n )
{
    if(n==0){
		return m;
    }
    return gcd(n,m%n);
}

long long int lcm(long long int m, long long int n )
{
    if((0==m)||(0==n)){
		return 0;
    }
	return ((m / gcd(m, n)) * n); 
}

int main(){
    int n;
    cin>>n;
    int i;
    vector<long long int> v(n,0);
    for(i=0;i<n;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    long long int ans=v[n-1];
    n-=2;
    while(n>=0){
        if(ans%v[n]!=0){
            ans=lcm(ans,v[n]);
        }
        n--;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
#include <iterator>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
//提出するときC++に帰る
//--------------------------



int main() {

  string s;
  cin >> s;

  reverse(s.begin(), s.end());

  int n = s[0]-'0';
  string t;
  if(n==2||n==4||n==5||n==7||n==9) t = "hon";
  else if(n==0||n==1||n==6||n==8) t = "pon";
  else if(n==3) t = "bon";

  cout << t << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
    #include <string>
	using namespace std;
     
    int main() {
      int a[5] = {};
      for (int i = 0; i < 5; i++) cin >> a[i];
      int k = 0;
      cin >> k;
    //cout << a[0] << " " << a[1] << " " << endl;
      string flag = "Yay!";
      if ((a[4] - a[0])>k) {
      	flag = ":(";
      }
      cout << flag << endl;
      return 0;
    }

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use ascii::AsciiChar;
use ascii::AsciiStr;
use itertools::Itertools as _;
use permutohedron::LexicalPermutation as _;
use petgraph::algo::dijkstra;
use petgraph::algo::min_spanning_tree;
use petgraph::data::FromElements;
use petgraph::graph::NodeIndex;
use petgraph::graph::UnGraph;
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use superslice::Ext as _;

#[allow(dead_code)]
fn calc_mp(val_to_grid: &HashMap<i64, (isize, isize)>, prev_val: i64, cur_val: i64, D: i64) -> i64 {
    if cur_val <= D {
        return 0;
    }

    let (prev_h, prev_w) = val_to_grid.get(&prev_val).unwrap();
    let (cur_h, cur_w) = val_to_grid.get(&cur_val).unwrap();
    let mp = ((prev_h - cur_h).abs() + (prev_w - cur_w).abs()) as i64;

    return mp;
}

#[fastout]
fn main() {
    input! {
        H: usize,
        W: usize,
        D: i64,
        Asz: [[i64; W]; H],
        Q: usize,
        LRs: [(i64, i64); Q],
    }

    // Asz -> 座標 は10^5オーダで分かる
    // なので、2つのマスに書かれた整数が与えられた時、ワープに必要な魔力はすぐ計算できる

    let mut val_to_grid: HashMap<i64, (isize, isize)> = HashMap::new();
    for h in 0..H {
        for w in 0..W {
            let a = Asz[h][w];
            val_to_grid.insert(a, (h as isize, w as isize));
        }
    }

    // 雰囲気としては、累積和の列がいくつもある感じ

    // 1, 1+D, 1+2D... → 必要な魔力の累積和にする
    // 2, 2+D, 2+2D...
    // 3, 3+D, 3+2D...
    // 0, 0+D, 0+2D... (便宜的に0から始まることにしよう)

    // あれ、イイとこ突いてそうだけど、なんで気付けた?
    // ・進む方向が一方向しかないので、レールがいくつかあってそれのどれかに乗るイメージ

    // 累積和の最初の0、初項の0 (0~D-1)
    let mut acc = vec![vec![0i64, 0]; D as usize];
    for group in 0..D as usize {
        for cur_val_usize in (group + D as usize..=H * W).step_by(D as usize) {
            let cur_val = cur_val_usize as i64;
            let prev_val = cur_val - D;
            let mp = calc_mp(&val_to_grid, prev_val, cur_val, D);
            let cur_ind = (cur_val / D) as usize;

            let acc_mp = acc[group as usize][cur_ind] + mp;
            acc[group as usize].push(acc_mp);
        }
    }

    // dbg!(&acc);

    for &(l, r) in LRs.iter() {
        // let mut consumed_mp: i64 = 0;

        // このループ、mpの計算がO(1)で済むとしても最悪O(HW)かかる
        // for x in (l..=r).step_by(D as usize) {
        //     consumed_mp += calc_mp(x, x + D);
        // }

        // FIXME : group = 0 の時に特殊処理が必要なのはキレイじゃないなー
        let group: usize = (l % D) as usize;
        let l_ind: usize = ((l - group as i64) / D) as usize;
        let r_ind: usize = ((r - group as i64) / D) as usize;
        // dbg!(group);
        // dbg!(l_ind);
        // dbg!(r_ind);

        let consumed_mp: i64 = acc[group][r_ind + 1] - acc[group][l_ind + 1];

        println!("{}", consumed_mp);
    }
}


Measured memory_bytes: 14180
#include <iostream>

int main(){
    std::string str1, str2;

    std::cin >> str1 >> str2;

    int ans = 0;

    for(int i = 0; i < 3; ++i){
        if(str1.at(i) == str2.at(i)){
            ++ans;
        }
    }

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

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,hs,ms,ss,he,me,se;
	int i,j,ans,start,end;

	while(1){
		scanf("%d",&n);
		if(n==0){break;}
		int train[86400]={};
		ans=0;
		for(i=0;i<n;i++){
			scanf("%d:%d:%d %d:%d:%d",&hs,&ms,&ss,&he,&me,&se);
			start=3600*hs+60*ms+ss;
			end=3600*he+60*me+se;
			for(j=start;j<end;j++){
				train[j]++;
				if(train[j]>ans){ans=train[j];}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 944
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
using Graph = vector<vector<pair<ll, ll>>>;

bool isPalindrome(string s) {
    rep(i, s.size()/2) {
        if (s[i] != s[s.size()-1-i]) return false;
    }
    return true;
}

int main()
{
    string S; cin >> S;
    if (isPalindrome(S) &&
        isPalindrome(S.substr(0, S.size()/2)) &&
        isPalindrome(S.substr(S.size() / 2 + 1, S.size()/2))) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int num;
	scanf("%d", &num);
	int m = 0, s = 0;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		z--;
		if (m == 1)m = 0;
		else if (i == z)s++, m = 1;
	}
	printf("%d\n", s);
}

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

int main(){
     int A, B;
    cin >> A >> B;
    if(A >= 10 || B >= 10){
        cout << -1 << endl;
    }
    else cout << A*B << endl;
}

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

using namespace std;

int main() {
    long N;
    cin >> N;

    long ans = 0;

    long dmax = long(sqrt(N))+1;
    //cout << "DEBUG dmax: " << dmax << endl;
    for (long d=1; d<=dmax; d++) {
        if (N % d != 0) {
            continue;
        }
        long m = N/d - 1;
        if (m>0 and N%m == N/m) {
            ans += m;
        }
    }

    cout << ans << endl;
}


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

int main() {
    int n, t, a, h, ans = 2147483647, cnt;
    cin >> n >> t >> a;
    for (int i = 0; i < n; ++i) {
        cin >> h;
        int d = abs((1000 * t - 6 * h) - 1000 * a);
        if (d < ans) {
            ans = d;
            cnt = i + 1;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <iomanip>
#include <queue>

#define PI 3.14159265358979
#define MOD 1000000007

//fixed << setprecision(15) <<

using namespace std;

int main(void) {
	long long int a, b, l, m, n;
	long long int i, j, k;
	bool flag = false;
	cin >> n;
	for (i = 1; i <= 200;i++) {
		for (j = -200; j <= 200; j++) {
			a = i * i * i * i * i;
			b = j * j * j * j * j;
			if (a - b == n) {
				flag = true;
				break;
			}
		}
		if (flag == true)break;
	}
	cout << i << " " << j << endl;
		/*if(flag)cout << "Yes" << endl;
			else cout << "No" << endl;*/
	return 0;
}

Measured memory_bytes: 3640
#include "iostream"
#include "map"
using namespace std;
int main()
{
    map<string,int> m;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        m[s]+=1;
        
    }
    
    int l=0;
    
    for(auto u:m)
    {
        if(u.second>l)
            l=u.second;
        
    }
    
    map<string,int> ::iterator it;
    for(it= m.begin();it!=m.end();it++)
    {
        if(it->second==l)
        {
            cout<<it->first<<endl;
        }
        
    }
    
    
    
}


Measured memory_bytes: 27008
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] h = Console.ReadLine().Split(' ').Select(e =>int.Parse(e)).ToArray();
            int last = 0;
            int cnt = 0;
            int max = 0;
            for (int i = 0; i < n; i++)
            {
                if (last >= h[i]) cnt++;
                else
                {
                    max = Math.Max(max, cnt);
                    cnt = 0;
                }
                last = h[i];
            }
            Console.WriteLine(Math.Max(max,cnt));
        }
    }
}


Measured memory_bytes: 25076
using System;
using System.Collections.Generic;
using System.Linq;

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var P = ReadArrayInt();
            var chk = P[0];
            var cnt = 1;
            for (int i = 1; i < N; i++)
            {
                if (P[i] < chk)
                {
                    chk = P[i];
                    cnt++;
                }
            }

            Console.WriteLine(cnt);
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 33628
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}

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

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

signed main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, 0, s.size())if (s[i] != t[i])ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3856
// In The Name Of Allah //
#include <bits/stdc++.h>
#define pb emplace_back
#define inf (int)-1e9
#define ff first
#define ss second
#define ll long long
#define sp(n) cout << setprecision(n) << fixed
#define hellcat ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define give(x) cout << #x << " " << x << endl
#define debug cout << "dddd" << '\n'
#define debarr(a, n) for (int i = 0; i < n; ++i) cout << a[i] << ' '; cout << endl
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

template <class S, class T>
inline S smax(S &l, T r) {
  return l = max(l, (S)r);
}
template <class S, class T>
inline bool smin(S &l, T r) {
  return l = min(l, (S)r);
}

const int MAXN = 1e5 + 10;
vector<int> g[MAXN];
int dp[MAXN];
bitset<MAXN> mark;

void Dfs(int v) {
	if (mark[v])
		return;
	mark[v] = true;
	for (auto i : g[v]) {
		Dfs(i);
		dp[v] = max(dp[v], dp[i] + 1);
	}
}

int32_t main () {
  hellcat;

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; ++i) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		g[u].pb(v);
	}

	for (int i = 0; i < n; ++i)
		if (!mark[i])
			Dfs(i);

	cout << *max_element(dp, dp + n) << '\n';

	return 0;
}


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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

pair<long long, long long> maxx(pair<long long, long long> a, pair<long long, long long> b){
	if(a.ff * b.ss > b.ff * a.ss) return a;
	return b;
}

long long gcd(long long a, long long b){
	return b ? gcd(b, a % b) : a;
}


int n, m, a, b;
long long v[52];
long long w[52];
pair<long long, long long> mx = mp(0LL, 1LL);

pair<long long, long long> bettera[55];
pair<long long, long long> betterb[55];

void f(long long sum, int qnt, int i, int fs){
	if(fs && i == n/2){
		if(bettera[qnt].ff < sum) bettera[qnt] = mp(sum, 1);
		else if(bettera[qnt].ff == sum) bettera[qnt].ss++;
	}
	else if(!fs && i == n){
		if(betterb[qnt].ff < sum) betterb[qnt] = mp(sum, 1);
		else if(betterb[qnt].ff == sum) betterb[qnt].ss++;
	}
	else{
		f(sum, qnt, i+1, fs);
		f(sum+v[i], qnt+1, i+1, fs);
	}
}

int main(){

	scanf("%d %d %d", &n, &a, &b);

	for(int i = 0; i < n; i++)
		scanf("%lld", v+i);

	sort(v, v+n);


	// for(int i = 0; i < n; i++){
	// 	pair<long long, long long> tmp = mp(0, 0);
	// 	for(int j = i; j < n; j++){
	// 		tmp.ff += v[j];
	// 		tmp.ss++;
	// 	}
	// 	if(tmp.ss < a || tmp.ss > b) continue;
	// 	mx = maxx(mx, tmp);
	// }

	// long long g = gcd(mx.ff, mx.ss);
	// mx.ff /= g;
	// mx.ss /= g;

	f(0, 0, 0, 1);
	f(0, 0, n/2, 0);

	long long cnt = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			pair<long long, long long> tmp = mp(bettera[i].ff + betterb[j].ff, i+j);
			if(tmp.ss < a || tmp.ss > b) continue;

			long long g = gcd(tmp.ff, tmp.ss);
			tmp.ff /= g;
			tmp.ss /= g;

			if(tmp == mx){
				cnt += 1LL * bettera[i].ss * betterb[j].ss;
			}
			else if(maxx(tmp, mx) == tmp){
				mx = tmp;
				cnt = 1LL * bettera[i].ss * betterb[j].ss;
			}
		}
	}

	printf("%lf\n", (double)mx.ff/mx.ss);
	printf("%lld\n", cnt);



	return 0;
}

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

def f(t,x):
  s = 0
  for i in range(len(x)):
    s += (x[i]-t)**2
  return s

l = min(x)
u = max(x)
m = float('inf')
for i in range(l,u+1):
  if m > f(i,x):
    m = f(i,x)
print(m)

Measured memory_bytes: 3064
#include <iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int MAX=500000;
const int NIL=-1;

class node
{
public:
	int loc;//location
	int l;
	int r;
};

class point
{
public:
	int id;
	int x;
	int y;
	point(){}
	point(int inid,int inx,int iny):id(inid),x(inx),y(iny){}
};

int n;
point P[MAX];
node T[MAX];
int np=0;

bool lessX(const point &p1,const point &p2)
{
	return p1.x<p2.x;
}
bool lessY(const point &p1,const point &p2)
{
	return p1.y<p2.y;
}

int make2Dtree(int l,int r,int depth)
{
	if(l>=r)return NIL;
	int mid=(l+r)/2;
	int t=np++;
	
	if(depth%2==0)sort(P+l,P+r,lessX);
	else sort(P+l,P+r,lessY);
	
	T[t].loc=mid;
	T[t].l=make2Dtree(l,mid,depth+1);
	T[t].r=make2Dtree(mid+1,r,depth+1);
	
	return t;
}

void find(int v,int sx,int tx,int sy,int ty,int depth,vector<int> &ans)
{
	int x=P[T[v].loc].x;
	int y=P[T[v].loc].y;
	if(sx<=x&&x<=tx&&sy<=y&&y<=ty)ans.push_back(P[T[v].loc].id);
	
	if(depth%2==0)
	{
		if(T[v].l!=NIL&&sx<=x)find(T[v].l,sx,tx,sy,ty,depth+1,ans);
		if(T[v].r!=NIL&&x<=tx)find(T[v].r,sx,tx,sy,ty,depth+1,ans);
	}
	else
	{
		if(T[v].l!=NIL&&sy<=y)find(T[v].l,sx,tx,sy,ty,depth+1,ans);
		if(T[v].r!=NIL&&y<=ty)find(T[v].r,sx,tx,sy,ty,depth+1,ans);
	}
	
	return;
}

int main() {
	cin>>n;int x,y;
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		P[i]=point(i,x,y);
		T[i].l=T[i].r=NIL;
	}
	np=0;
	int root=make2Dtree(0,n,0);
	int q;cin>>q;
	int sx,tx,sy,ty;
	vector<int> ans;
	for(int i=0;i<q;i++)
	{
			scanf("%d%d%d%d",&sx,&tx,&sy,&ty);
			ans.clear();
			find(root,sx,tx,sy,ty,0,ans);
			sort(ans.begin(),ans.end());
			for(int j=0;j<ans.size();j++)printf("%d\n",ans[j]);
			printf("\n");
	}
	return 0;
}

Measured memory_bytes: 14484
#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define INF 1000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define rollcall cout<<"I'm Sucu."<<endl
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define int ll


signed main(void){
    int D,N;
    cin >> D >> N;
    if(N!=100){
        cout << N;
    }else{
        cout << 101;
    }
    REP(i,D){
        cout << 0 << 0;
    }
    cout << endl;
  return 0;
}


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

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

    long long q, h, s, d, n;
    cin >> q >> h >> s >> d;
    cin >> n;

    h = min(h, q * 2);
    s = min(s, h * 2);
    
    long long a, b;
    a = n * s;
    b = n / 2 * d;
    n %= 2;
    b += n * s;
    cout << min(a, b) << endl;

    return 0;
}

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

typedef long long ll;

int main(){

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

    int n, k;
    cin >> n >> k;
    int arr[n];
    for(int i=0; i<n; i++){
        cin >> arr[i];
    }
    vector<bool> dp(k+1);

    for(int i=0; i<=k; i++){
        for(int j=0; j<n; j++){
            if(i>=arr[j] && !dp[i-arr[j]]){
                dp[i]=true;
            }
        }
    }

    dp[k]?cout<<"First\n":cout<<"Second\n";

    return 0;
}



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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

const int MAXN = 1000100, MAXK = 30;
const ll MOD = 1e9+7;
const ll INF = 1e18;
const ld PI = asin(1) * 2;

int n;
ll d, a;
ll x[MAXN], h[MAXN];
vector<pair<ll,ll>> in;
queue<pair<ll,ll>> q;

int main()
{
    FAST_IO;

    cin >> n >> d >> a;
    FOR(i, 1, n) {
        ll o, p; cin >> o >> p;
        in.pb({o,p});
    }
    sort(in.begin(), in.end());
    FOR(i, 1, n) {
        x[i] = in[i-1].f;
        h[i] = in[i-1].s;
    }

    ll curS = 0;
    ll ans = 0;
    FOR(i, 1, n) {
        while (!q.empty() && q.front().f < x[i]) {
            curS -= q.front().s;
            q.pop();
        }

        h[i] -= curS;
        if (h[i] <= 0) continue;
        ll adding = (h[i]+a-1)/a;
        ans+= adding;
        adding *= a;
        curS += adding;
        q.push({x[i]+2*d, adding});
    }

    cout << ans;

    return 0;
}


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

using namespace std;

int main()
{
    long long n;
    cin >> n;
    vector<long long> permutation(n);

    for (long long &element : permutation)
    {
        cin >> element;
        element--;
    }

    vector<long long> firstSequence(n);
    vector<long long> secondSequence(n);

    firstSequence[0] = 1;
    for (long long i = 0; i < n - 1; i++)
        firstSequence[i + 1] = firstSequence[i] + n;

    for (int i = 0; i < n; i++)
        secondSequence[permutation[i]] = (firstSequence[n - 1] - firstSequence[permutation[i]]) + i + 1;

    for (long long x : firstSequence)
        cout << x << " ";
    cout << endl;

    for (long long x : secondSequence)
        cout << x << " ";
    cout << endl;

    return 0;
}

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

int collatz(int x){
  if(x%2==0)return x/2;
  else return 3*x+1;
}

int main(){
	int s;cin >>s;
 	vector<int>a;
  int cnt=2;
  int x=s;
  a.push_back(x);
  while(true){
  	x=collatz(x);
    if(any_of(a.begin(),a.end(),[&](int y){return y==x;})){
      cout <<cnt;return 0;
    }
       a.push_back(x);
       cnt++;
  }
}

Measured memory_bytes: 256
let n = Int(readLine()!)!

func solve(_ a: [Int]) -> [Int] {
  let n = a.count
  var ans: [Int] = .init(repeating: 0, count: n + 1)
  for i in (1...n).reversed() {
    var sum = 0
    var j = i + i
    while j <= n {
      sum ^= ans[j]
      j += i
    }
    ans[i] = sum ^ a[i]
  }
  return ans
}

var a: [Int] = .init(repeating: 0, count: n + 1)
let inputs = readLine()!
	.split(separator: " ")
	.map { Int($0)! }
	.enumerated()
	.forEach { a[$0+1] = $1 }

let ans = solve(a)
let res = ans.enumerated().filter { $1 == 1 }
print(res.count)
res.forEach { print($0.0) }

Measured memory_bytes: 17644
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    for i in range(3):
        if s[i] == s[i + 1]:
            print("Bad")
            return
    print("Good")
    return

#B
def B():
    n, l = LI()
    lis = [l + i for i in range(n)]
    s = sum(lis)
    a = inf
    for i in lis:
        if abs(a) > abs(i):
            a = i
    print(s-a)
    return

#C
def C():
    def gcd(a, b):
        a, b = max(a, b), min(a, b)
        while b:
            a, b = b, a % b
        return a
    def lcm(a, b):
        return a * b // gcd(a, b)
    a, b, c, d = LI()
    x = b // c - (a-1) // c
    y = b // d - (a-1) // d
    z = b // lcm(c , d) - (a-1) // lcm(c , d)
    print(b-a+1-(x+y-z))
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


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

int main(){
  long N,K,tmp,sum=0;
  cin >> N >> K;
  vector<long> H(N);
  for(int i=0;i<N;i++){
    cin >> H[i];
  }
  sort(H.begin(),H.end());
  for(int i=0;i<N-K;i++) sum += H[i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a<b){
        System.out.println("a < b");
        }else if(a>b){
        System.out.println("a > b");
        }else if(a==b){
        System.out.println("a == b");
        }
    }
}

Measured memory_bytes: 26284
function main()
  
  N = parse(Int,readline())
  A = map(x -> parse(Int,x), split(readline()))
  
  sort!(A,rev = true)
  
  A_new = []
  check = 0
  
  for i in 1:N
    if check == A[i]
      push!(A_new, A[i])
      check = 0
    else
      check = A[i]
    end
  end
  
  if length(A_new) < 2
    println(0)
  else
    println(A_new[1]*A_new[2])
  end
  
end

main()

Measured memory_bytes: 127012
s = input()
n = len(s)

ans = 0
for i in range(n):
    if i % 2 == 0:
        t = "g"
        if s[i] == "p":
            ans -= 1
    else:
        t = "p"
        if s[i] == "g":
            ans += 1
print(ans)

Measured memory_bytes: 39664
#include<bits/stdc++.h>
using namespace std;
int n;
long long m;
int x,y;
vector<int> ga[100100];
vector<int> ch[100100];
long long dp[100100];
long long res[100100];
long long pref[100100],suff[100100];
long long above[100100];
void do_dp(int u,int p){
	dp[u]=1LL;
	for(int i=0;i<ga[u].size();i++){
		int v=ga[u][i];
		if(v==p)
			continue;
		ch[u].push_back(v);
		do_dp(v,u);
		dp[u]=(dp[u]*((dp[v]+1LL)%m))%m;
	}
}
void do_res(int u,int p){
	res[u]=(dp[u]*above[u])%m;
	pref[0]=above[u];
	for(int i=0;i<ch[u].size();i++)
		pref[i+1]=(pref[i]*(dp[ch[u][i]]+1LL)%m)%m;
	suff[ch[u].size()]=1LL;
	for(int i=ch[u].size()-1;i>=0;i--)
		suff[i]=(suff[i+1]*(dp[ch[u][i]]+1LL)%m)%m;
	for(int i=0;i<ch[u].size();i++){
		int v=ch[u][i];
		above[v]=(1LL+(pref[i]*suff[i+1]))%m;
	}
	for(int i=0;i<ch[u].size();i++){
		int v=ch[u][i];
		do_res(v,u);
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<n;i++){
		cin>>x>>y;
		ga[x].push_back(y);
		ga[y].push_back(x);
	}
	above[1]=1LL;
	do_dp(1,-1);
	do_res(1,-1);
	for(int i=1;i<=n;i++)
		cout<<res[i]<<endl;
	return 0;
}


Measured memory_bytes: 21120
n = int(input())
a = list(map(int,input().split()))
 
from fractions import gcd
lcm = a[0]
for i in range(1, n):
    lcm = lcm * a[i] // gcd(lcm, a[i])
 
ans=0
for i in range(n):
    ans+=lcm//a[i]
 
print(ans%(10**9+7))

Measured memory_bytes: 5612
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
for i in range(1,10):
  for j in range(i,10):
    if i*j==a:
      print('Yes')
      sys.exit()
print('No')

Measured memory_bytes: 3444
#include<iostream>
using namespace std;
static const int MAX = 100000;
static const int INFTY = 2000000000;


int n;
struct Card { char str; int num; };
int check;

int partition(Card A[], int p, int r) {
	int x = A[r].num;
	int i = p - 1;
	Card tmp;
	for (int j = p; j < r; j++) {
		if (A[j].num == x) {
			check = 1;
		}
		if (A[j].num <= x) {
			i += 1;
			tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}
	
	tmp = A[i + 1];
	A[i + 1] = A[r];
	A[r] = tmp;
	return i + 1;
}

void quickSort(Card A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quickSort(A, p, q - 1);
		quickSort(A, q + 1, r);
	}
}


Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(Card S[], int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++) {
		L[i] = S[left + i];
	}
	for (int i = 0; i < n2; i++) {
		R[i] = S[mid + i];
	}
	L[n1].num = INFTY;
	R[n2].num = INFTY;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		if (L[i].num <= R[j].num) {
			S[k] = L[i];
			i++;
		}
		else {
			S[k] = R[j];
			j++;
		}
	}
}

void mergeSort(Card S[], int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(S, left, mid);
		mergeSort(S, mid, right);
		merge(S, left, mid, right);
	}
}



int main() {
	Card A[MAX];
	Card B[MAX];
	check = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i].str >> A[i].num;
		B[i] = A[i];
	}
	mergeSort(B, 0, n);
	quickSort(A, 0, n - 1);
	
	for (int i = 0; i < n; i++) {
		if (A[i].str != B[i].str) {
			cout << "Not stable" << endl;
			break;
		}
		if (i == n - 1) {
			cout << "Stable" << endl;
		}
	}

	for (int i = 0; i < n; i++) {
		cout << A[i].str << " " << A[i].num << endl;
	}
	return 0;

}


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

int main() {
    int n;
    long long int a[10005]={0};
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int b=0;
    for(int i=0;i<n;i++){
        while(a[i]%2==0&&a[i]!=0){
            b++;
            a[i]/=2;
        }
    }
    cout<<b<<endl;
    return 0;
}


Measured memory_bytes: 384
<?php



$X = intval(trim(fgets(STDIN)));

if($X === 0){
	printf(0);
	return;
}

$happy = 0;

$happy += floor($X / 500);

$happy *= 1000;


$add = $X % 500;
$happy += (floor($add / 5)) * 5;

printf($happy);
?>


Measured memory_bytes: 3828
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
} //aとbの最大公約数
int ctoi(char c){
  if(c>='0'&&c<='9'){
    return c-'0';
  }
  return 0;
} //char型の数字をint型に変えてくれる。


//cout << setprecision(123)<<ans;
//int a=atoi(S.c_str());
//string S=to_string(a);
//int &a=b;
int main(){
  int A,B;
  cin>>A>>B;
  double m=min((A+1)/0.08,(B+1)/0.1),M=max(A/0.08,B/0.1);
  int mm=floor(M)+1-floor(floor(M)/M);
  if(M<=m&&mm<=m&&mm>0&&A==floor(mm*0.08)&&B==floor(mm*0.1)){
    cout<<mm<<endl;
  }
  else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 256
data=list(map(int,input().split()))

if data[2]-data[4]>=0 and data[2]+data[4]<=data[0]:
    if data[3]-data[4]>=0 and data[3]+data[4]<=data[1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){
    cout << "Yes" << endl;
}
void no(){
    cout << "No" << endl;
}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n ;
    cin >> n ;
    vint a(n) ;
    ll r, l ;
    REP(i,n){
        cin >> a[i] ;
    }
    sort(ALL(a)) ;
    r = a[n-1] ;
    a.pop_back() ;
    vd b(n-1) ;
    double maxi = -(double)INF ;
    REP(i,n-1){
        b[i] = (double)a[i] - (double)r/(double)2 ;
        if(abs(maxi)>=abs(b[i])){
            l = a[i] ;
            maxi = b[i] ;
        }
    }

    cout << r <<" "<<l <<endl ;


    return 0;
}



Measured memory_bytes: 1408
#include<stdio.h>
int main(){
    int H[10000], W[10000];
    int length;
    int i=0, j, k;
    do{
        scanf("%d %d", &H[i], &W[i]);
        i += 1;
    }while(H[i-1]!=0 || W[i-1]!=0);
    length = i;
    for(i=0; i<length-1; i++){
        for(j=0; j<H[i]; j++){
            for(k=0; k<W[i]; k++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 2580
N, K = map(int,input().split())
P = list(map(int,input().split()))

exps = []
_sum = 0
for v in P:
    _sum += (1+v)/2
    exps.append(_sum)

ans = exps[K-1]
for i in range(K,N):
    if ans < exps[i]-exps[i-K]:
        ans = exps[i]-exps[i-K]

print(ans)


Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,a,b) for(int i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
void send(int a,int b,int c,int d){
  printf("%d %d %d %d\n",a,b,c,d);
}
int main(){
  int h,w;  cin >> h >> w;
  int n;  cin >> n;

  vector<int> a(n);
  int ans[h][w];
  rep(i,0,n){
    int x;  cin >> a[i];
  }
  int cu = 0;
  rep(i,0,h)rep(j,0,w){
    ans[i][j] = cu + 1;
    a[cu]--;
    if(!a[cu]) cu++;
  }
  rep(i,0,h){
    rep(j,0,w){
      int x = ans[i][j];
      if(i%2 == 1){
        x = ans[i][w-1-j];
      }
      cout << x << " ";
      }
    cout << endl;
    }
    return 0;
  }


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 500005
#define M 100000000
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (lli)(x.size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"YES\n";
#define N cout<<"NO\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;
vector<lli> adj[S];
lli vis[S];
lli ele=0;

void dfs(lli v)
{
    vis[v]=1;
    ele++;
    for(auto i:adj[v])
    {
        if(vis[i]==0)
        {
            dfs(i);
        }
    }
}
void solve()
{

    lli n,m;cin>>n>>m;
    for(lli i=1,u,v;i<=m;i++)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    vector<lli> v;

    for(lli i=1;i<=n;i++)
    {
        if(vis[i]==0)
        {
            ele=0;
            dfs(i);
            v.pb(ele);
        }
    }
    sort(all(v));
    lli gp=0;
    // for(auto i:v)
    // {
    //     print(i)
    // }

    for(auto i:v)
    {
       gp=i;
    }

    cout<<gp;

}


int main()
{
    fast
    #ifndef ONLINE_JUDGE
     freopen("inputa.txt", "r", stdin);
     freopen("outputa.txt", "w", stdout);
    #endif    
     
     // test
     {
          solve();
          nl
     }
}
//a+b=a?b+2?(a&b)
//__builtin_popcnt(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";

Measured memory_bytes: 29432