akhauriyash/Code-Regression huggingface dataset:
from typing import Callable, TypeVar, List

T = TypeVar('T')


class SegTree:
    def __init__(self, v: List[T], op: Callable[[T, T], T], e: Callable[[], T]) -> None:
        self._n = len(v)
        self.log = (self._n - 1).bit_length()
        self.size = 1 << self.log
        self.d = [e for _ in range(2 * self.size)]
        self.op = op
        self.e = e
        for i in range(self._n):
            self.d[self.size + i] = v[i]
        for i in reversed(range(1, self.size)):
            self.__update__(i)

    @classmethod
    def init_e(cls, n: int, op: Callable[[T, T], T], e: Callable[[], T]) -> 'SegTree':
        return cls([e for _ in range(n)], op, e)

    def set(self, p: int, x: T) -> None:
        assert 0 <= p < self._n
        p += self.size
        self.d[p] = x
        for i in range(1, self.log + 1):
            self.__update__(p >> i)

    def get(self, p: int) -> T:
        assert 0 <= p < self._n
        return self.d[p + self.size]

    def prod(self, l: int, r: int) -> T:
        assert 0 <= l <= self._n and 0 <= r <= self._n
        sml = self.e
        smr = self.e
        l += self.size
        r += self.size

        while l < r:
            if l & 1:
                sml = self.op(sml, self.d[l])
                l += 1
            if r & 1:
                r -= 1
                smr = self.op(self.d[r], smr)
            l >>= 1
            r >>= 1
        return self.op(sml, smr)

    def all_prod(self) -> T:
        return self.d[1]

    def max_right(self, l: int, f: Callable[[T], bool]):
        assert 0 <= l <= self._n
        assert f(self.e)
        if l == self._n:
            return self._n
        l += self.size
        sm = self.e
        while True:
            while l % 2 == 0:
                l >>= 1
            if not f(self.op(sm, self.d[l])):
                while l < self.size:
                    l *= 2
                    if f(self.op(sm, self.d[l])):
                        sm = self.op(sm, self.d[l])
                        l += 1
                return l - self.size
            sm = self.op(sm, self.d[l])
            l += 1
            if (l & -l) == l:
                return self._n

    def min_left(self, r: int, f: Callable[[T], bool]):
        assert 0 <= r <= self._n
        assert f(self.e)
        if r == 0:
            return 0
        r += self.size
        sm = self.e
        while True:
            r -= 1
            while r > 1 and r % 2:
                r >>= 1
            if not f(self.op(self.d[r], sm)):
                while r < self.size:
                    r = 2 * r + 1
                    if f(self.op(self.d[r], sm)):
                        sm = self.op(self.d[r], sm)
                        r -= 1
                return r + 1 - self.size
            sm = self.op(self.d[r], sm)
            if (r & -r) == r:
                return 0

    def __update__(self, k: int) -> None:
        self.d[k] = self.op(self.d[2 * k], self.d[2 * k + 1])


n, k = map(int, input().split())
seg = SegTree([0]*400000, max, 0)
for _ in range(n):
    a = int(input())
    ma = seg.prod(max(0, a-k), min(400000, a+k+1))
    seg.set(a, ma+1)
print(seg.all_prod())


Measured memory_bytes: 148576
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

vector<ll> fac(MAX), finv(MAX), inv(MAX);

void comInit(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(ll i=2; i<MAX; i++){
		fac[i] = fac[i-1]*i % mod;
		inv[i] = mod - inv[mod%i] * (mod/i) % mod;
		finv[i] = finv[i-1] * inv[i] % mod;
	}
}


ll com(ll n, ll k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main(){
	ll n,k; cin >> n >> k;
	if(n>k) puts("0");
	else{
		comInit();
		cout << com(k,n)*fac[n]%mod << endl;
	}
}


Measured memory_bytes: 14552
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= 1

c = [0 for _ in range(100005)]

for i in range(n):
    val = a[i]
    c[val - 1] += 1
    c[val] += 1
    c[val + 1] += 1

ans = 0
for i in range(100005):
    ans = max(ans, c[i])

print(ans)

Measured memory_bytes: 90292
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')
# ----------------------------------------------------------- #

s_ = S()
n = len(s_)
s = [int(s_[i]) for i in range(n)]
ans = 0
for i in range(1, n):
    if s[i-1] == s[i]:
        ans += 1
        s[i] ^= 1

ans = min(ans, n-ans)
print(ans)

Measured memory_bytes: 69848
import java.util.*;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int cnt[] = new int[n];
		for(int i=0;i<n;i++){
			int a = sc.nextInt();
			cnt[a]++;
		}
		
		
		boolean ok = true;
		for(int i=1+n%2;i<n;i+=2){
			if(cnt[i] != 2)
				ok = false;
		}
		if(n%2==1 && cnt[0] != 1)
			ok = false;
		
		if(ok){
			int ans = 1;
			for(int i=0;i<n/2;i++){
				ans *= 2;
				ans %= (int)1e9+7;
			}
			System.out.println(ans);
		}
		else{
			System.out.println(0);
		}
	}

}


Measured memory_bytes: 51076
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int a,t=0;
  rep(i,5){
    cin>>a;
    if(a<=40)a=40;
    t+=a;
  }
  cout<<t/5<<endl;
}

Measured memory_bytes: 3072
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
.split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    // solver code...
    let _ = read::<i64>();
    let mut a_vec = read_vec::<i64>();
    a_vec.sort();
    let MOD = 1000000007;
    let mut sum = 0;
    for a in &a_vec {
        sum += a;
    }

    let mut ans = 0;
    for a in &a_vec {
        sum -= a;
        ans += (a * (sum%MOD))%MOD;
        ans %= MOD;
    }

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

Measured memory_bytes: 6464
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	boolean[] prime;
	int MAX = 1000000;
	void run() {
		Scanner sc = new Scanner(System.in);
		boolean prime[] = new boolean[MAX];
		for(int i=2;i<MAX;i++) {
			if( !prime[i] ) {
				for(int j=i*2;j<MAX;j+=i) prime[j] = true;
			}
		}
		while(sc.hasNext()) {
			int n = sc.nextInt();
			int cnt = 0;
			for(int i=2;i<=n;i++) 
				if(!prime[i])cnt++;
			System.out.println(cnt);
		}
		
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 13000
from collections import deque
def dfs_2d(H,W,M,start):
    que = deque()
    que.append([start[0],start[1]])
    distance = [[-1 for i in range(W)] for j in range(H)]
    dxdy = [[1,0],[-1,0],[0,1],[0,-1]]##4方向

    distance[start[0]][start[1]] = 0

    flag = False
    
    while que:
        x,y = que.popleft()
        for i,j in dxdy:
            dx = x + i
            dy = y + j
            if 0 <= dx <= H-1 and 0 <= dy <= W-1 and M[dx][dy] != "#" and distance[dx][dy] == -1:
                distance[dx][dy] = distance[x][y] + 1
                que.append([dx,dy])
                
    return max(max(i) for i in distance)

def main():
    H,W = map(int,input().split())
    M = []
    for i in range(H):
        M.append(input())
    ans = 0
    for i in range(H):
        for j in range(W):
            if M[i][j] != "#":
                start = [i,j]
                ans = max(ans,dfs_2d(H,W,M,start))

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } 

 int main(){
 int n;
   cin>>n;
   map<string,int> mp;
   rep(i,n){
   string s;
     cin>>s;
     mp[s]++;
   }
   cout<<mp.size()<<endl;
}

Measured memory_bytes: 19216
/* ex7_3
    fmuacshai */

# include<stdio.h>
# include<stdlib.h>

int main(void){
    //縦の行数をheight、横の列数をwideとする
    int height,wide,i;
    //squareを動的確保して定義
    char **square;
    //sensorhとsensorwを動的確保して定義
    int *sensorh,*sensorw;
    //heightの入力
    scanf("%d",&height);
    //wideの入力
    scanf("%d",&wide);
    //マス目の配列をsquareとする
    square=(char**)calloc(height, sizeof(char*));
    if(square==NULL){
        printf("memory allocation error.\n");
        exit(1);
    }
    for(i=0;i<height;i++){
        square[i]=(char*)calloc(wide, sizeof(char));
        if(square[i]==NULL){
            printf("memory allocation error.\n");
            exit(1);
        }
    }
    //縦の列を残すか判別する配列をsensorh[]、
    //横の列を残すか判別する配列をsensorw[]とする
    sensorh=(int*)calloc(height, sizeof(int));
    sensorw=(int*)calloc(wide, sizeof(int));
    //squeres[height][wide]を入力
    for(int i=0;i<height;i++){
        for(int j=0;j<wide;j++){
            scanf(" %c",&square[i][j]);
        }
    }
    //sensorhの中身を全て0にする
    for(int i=0;i<height;i++){
        sensorh[i]=0;
    }
    //sensorwの中身を全て0にする
    for(int j=0;j<wide;j++){
        sensorw[j]=0;
    }
    //'#'が入力されているところに対応する行と列を把握する
    for(int i=0;i<height;i++){
        for(int j=0;j<wide;j++){
            //'#'だったら
            if(square[i][j]=='#'){
                //対応する部分の配列に1を入力
                sensorh[i]=1;
                sensorw[j]=1;
            }
        }
    }
    //対応する行列がどちらも1が入力されていたらを出力
    for(int i=0;i<height;i++){
        for(int j=0;j<wide;j++){
            //対応する行列がどちらも1が入力されていたら
            if(sensorh[i]==1 && sensorw[j]==1){
                //squeres[i][j]を出力
                printf("%c",square[i][j]);
            }
        }
        //消されなかったものがあった列は最後に改行
        if(sensorh[i]==1){
            printf("\n");
        }
    }
    return 0;
}



Measured memory_bytes: 1672
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int x,y;
    scanf("%d %d",&x,&y);
    if(x>y){
        printf("a > b\n");
    }
    if(x<y){
        printf("a < b\n");

    } if(x==y){
        printf("a == b\n");
    
    }

    return 0;
}



Measured memory_bytes: 2048
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;
using lthe = pair<ll, ll>;

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

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

int main() {
	int n;
	cin >> n;
	Vi A(n + 1);
	rep(i, n + 1)  cin >> A[i];

	if (n == 0) {
		if (A[0] == 1)  cout << 1 << endl;
		else  cout << -1 << endl;
		return 0;
	}

	vector<lthe> lr(n + 1);
	lr[n].first = A[n];
	lr[n].second = A[n];
	for (int i = n - 1; i >= 0; i--) {
		lr[i].second = lr[i + 1].second + A[i];
		lr[i].first = lr[i + 1].first / 2 + lr[i + 1].first % 2 + A[i];
	}

	if (!(lr[0].first <= 1 + A[0] && 1 + A[0] <= lr[0].second)) {
		cout << -1 << endl;
		return 0;
	}
	Vl D(n + 1);
	D[0] = 1;
	bool f = false;
	for (int i = 1; i <= n; i++) {
		D[i] = min(2 * (D[i - 1] - A[i - 1]), lr[i].second);
		if (D[i] < lr[i].first) {
			f = true;
			break;
		}
	}
	if (f) {
		cout << -1 << endl;
		return 0;
	}
	ll ans = 0;
	rep(i, n + 1)  ans += D[i];
	cout << ans << endl;
}


Measured memory_bytes: 5816
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
//#include <intrin.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	string str;
	cin >> str;
	int size = str.size();
	cout<<str[0]<<size-2<<str[size-1]<<endl;
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> cond(2, 0);
  rep(i, n) cin >> a[i];
  int cn = 0;
  rep(i,n-1){
    if (a[i] < a[i+1]){
      if(cond[1] == 1) {
        cn++;
        cond[0] = 0;
        cond[1] = 0;
        continue;
      }
      cond[0] = 1;
    }else if(a[i] > a[i+1]){
      if(cond[0] == 1){
        cn++;
        cond[0] = 0;
        cond[1] = 0;
        continue;
      }
      cond[1] = 1;
    }
  }
  cn++;
  cout << cn << endl;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long
// #define pow mypow

typedef pair<int,int> pii;
const int N = 2e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int n, a[N];
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	int s = 0;
	for(int i=0; i<n; i++) {
		cin >> a[i];
		s ^= a[i];
	}
	for(int i=0; i<n; i++){
		cout << int(s^a[i]) << ' ';
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 4336
N, M = map(int, input().split())
ans = ["?" for _ in range(N)]
for _ in range(M):
    s, c = map(int, input().split())
    if N>1 and s==1 and c==0:
        ans = [-1]
        break
    if ans[s-1]!="?" and ans[s-1]!=str(c):
        ans = [-1]
        break
    ans[s-1] = str(c)
if ans==[-1]:
    print(-1)
else:
    if ans[0]=="?" and N>1:
        ans[0] = "1"
    ans = "".join(ans)
    ans = ans.replace("?", "0")
    print(ans)

Measured memory_bytes: 9152
import bisect
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=[0]
y=[0]
for i in range(n):
  x.append(x[i]+a[i])
for i in range(m):
  y.append(y[i]+b[i])
res=0
for i in range(n+1):
  if x[i]>k:
    break
  else:
    t=k-x[i]
    bb=bisect.bisect(y,t)
    res=max(res,i+bb-1)
print(res)

Measured memory_bytes: 47564
/*
      author  : nishi5451
      created : 14.08.2020 16:40:26
*/

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


int main(){
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;
    rep(i,a+b+1){
        if(i==a){
            if(s[i]!='-'){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            if(s[i]>='0' && s[i]<='9')
                continue;
            else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	LL A,B,C;
	cin>>A>>B>>C;
	LL a1=0,b1=0,c1=0;
	LL a2,b2,c2;
	LL aw=0;
	if (A==B &&A==C){
		if (A%2==0){
			cout<<-1<<endl;
		}else{
			cout<<0<<endl;
		}
		return 0;
	}
			
	while (true){
		a1=A%2;
		b1=B%2;
		c1=C%2;
		if (a1==1 || b1==1 || c1==1){
			break;
		}
		a2=(B+C)/2;
		b2=(A+C)/2;
		c2=(A+B)/2;
		A=a2;
		B=b2;
		C=c2;
		aw++;
	}
	cout<<aw<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int h = scanner.nextInt();
		int w = scanner.nextInt();
		String s[][] = new String[h][w];

		for (int i = 0; i < h; i++) {
			s[i] = scanner.next().split("");
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (s[i][j].equals("#")) {
					if (check4Neighborhood(s, j, i)) {
						continue;
					} else {
						System.out.println("No");
						return;
					}
				}
			}
		}

		System.out.println("Yes");

	}

	private static boolean check4Neighborhood(String[][] s, int x, int y) {
		for (int i = -1; i <= 1; i++) {
			for (int j = -1; j <= 1; j++) {
				if ((i == 0 && j != 0) || (i != 0 && j == 0)) {
					int tarX = j + x;
					int tarY = i + y;
					if (0 <= tarX && tarX <= s[0].length-1 && 0 <= tarY && tarY <= s.length-1) {
						if (s[tarY][tarX].equals("#")) {
							return true;
						}
					}
				}
			}
		}
		return false;
	}

}


Measured memory_bytes: 24148
n,a,b=map(int,input().split())
s=str(input())
s=list(s)
for i in range(len(s)):
  if s[i]=="a" and a+b>0:
    print("Yes")
    if a>0:
      a=a-1
    else:
      b=b-1
  elif s[i]=="b" and b>0:
    print("Yes")
    b=b-1
  else:
    print("No")

Measured memory_bytes: 4708
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <stdio.h>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORa(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define FORs(i,st) for(auto i : st)
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<vector<ll>> ans((n+1)/2);
    if(n%2==1){
      ans[0].push_back(n);
      FOR(i,1,(n+1)/2){
        ans[i].push_back(i);
        ans[i].push_back(n-i);
      }
    }
    else{
      FOR(i,0,n/2){
        ans[i].push_back(i+1);
        ans[i].push_back(n-i);
      }
    }
    deque<P> res;
    FOR(i,1,ans.size()){
//      cout<<"i = "<<i<<endl;
      FOR(j,0,ans[i-1].size()){
//        cout<<" j = "<<j<<endl;
        FOR(k,0,ans[i].size()){
//          cout<<"  k = "<<k<<endl;
//          cout<<ans[i-1][j]<<" "<<ans[i][k]<<endl;
          res.push_back(P(ans[i-1][j],ans[i][k]));
        }
      }
    }
    ll siz = ans.size()-1;
    if(ans.size()>2){
      FOR(i,0,ans[0].size()){
        FOR(j,0,ans[siz].size()){
//          cout<<ans[0][i]<<" "<<ans[siz][j]<<endl;
          res.push_back(P(ans[0][i],ans[siz][j]));
        }
      }
    }

    cout<<res.size()<<endl;
    while(!res.empty()){
      ll x = res.front().first;
      ll y = res.front().second;
      cout<<x<<" "<<y<<endl;
      res.pop_front();
    }


}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;

    vector<pair<int, int>> A;
    REPinit(i, 0, N) {
        A.push_back(make_pair<int, int>(i + 1, 0));
        cin >> A.back().second;
    }

    sort(ALL(A), [](const pair<int, int>& r, const pair<int, int>& l){
        return (r.second < l.second);
    });

    REPinit(i, 0, N) {
        if (i == 0) cout << A.at(i).first;
        else cout << " " << A.at(i).first;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 4232
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N,P = map(int,input().split())
A = list(map(int, input().split()))
oddC = 0
evenC = 0
for a in A:
    if a % 2 == 1:
        oddC += 1
    else:
        evenC += 1
c = 0
if P == 0:
    oddcombi = 0
    for i in range(oddC+1):
        if i % 2 == 1:
            continue
        oddcombi += combinations_count(oddC,i)
    evencombi = 0
    for i in range(evenC+1):
        evencombi += combinations_count(evenC,i)
    print(oddcombi*evencombi)
else:
    oddcombi = 0
    for i in range(oddC+1):
        if i % 2 == 0:
            continue
        oddcombi += combinations_count(oddC,i)
    evencombi = 0
    for i in range(evenC+1):
        evencombi += combinations_count(evenC,i)
    print(oddcombi*evencombi)


Measured memory_bytes: 64276
#include <bits/stdc++.h>
using namespace std;
#define pr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(v) (v).begin(), (v).end()
#define int unsigned long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

const int N= 10000001;

void solve() {
        int n; cin >> n;

        int sm= 0;

        for (int i= 1; i <= n; i++) {
                int wh= (n/ i);
                sm+= (i* (wh* (wh+ 1))/ 2);
	}

        cout << sm<< "\n";
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) {
                solve();
        }
return 0;
}


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

int dp[111111][4];

signed main(){
  string s;
  cin>>s;
  dp[0][0]=1;
  r(i,s.size()){
    r(j,4)dp[i+1][j]+=dp[i][j];
    if(s[i]=='A'){
      dp[i+1][1]+=dp[i][0];
    }
    if(s[i]=='B'){
      dp[i+1][2]+=dp[i][1];
    }
    if(s[i]=='C'){
      dp[i+1][3]+=dp[i][2];
    }
    if(s[i]=='?'){
      r(j,4)dp[i+1][j]+=dp[i][j];
      r(j,4)dp[i+1][j]+=dp[i][j];
      dp[i+1][1]+=dp[i][0];
      dp[i+1][2]+=dp[i][1];
      dp[i+1][3]+=dp[i][2];
    }
    r(j,4)dp[i+1][j]%=1000000007;
  }
  cout<<dp[(int)s.size()][3]<<endl;;
}

Measured memory_bytes: 3584
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1, dy = y2 - y1;
    if(dx > 0 && dy <= 0){
        cout << x2 - dy << " " << y2 + dx << " " << x2 - dx - dy << " " << y2 + dx - dy << endl;
    }else if(dx >= 0 && dy > 0){
        cout << x2 - dy << " " << y2 + dx << " " << x2 - dx - dy << " " << y2 + dx - dy << endl;
    }else if(dx < 0 && dy >= 0){
        cout << x2 - dy << " " << y2 + dx << " " << x2 - dy - dx << " " << y2 + dx - dy << endl;
    }else if(dx <= 0 && dy < 0){
        cout << x2 - dy << " " << y2 + dx << " " << x2 - dy - dx << " " << y2 + dx - dy << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <bitset>
#include <cmath>
#include <string>
#include <stdlib.h>

#define ll long long
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)

using namespace std;


int main() {
    string A; cin >> A;
    ll N; N = (ll)A.size();
    map<char, ll> m;
    repp(i,0,N) ++m[A[i]];

    ll ans = N * (N-1) / 2 + 1;
    for(auto x: m) ans -= x.second * (x.second -1) / 2;
    cout << ans << endl;
}


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

Measured memory_bytes: 9684
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        int answer = Integer.MAX_VALUE;
        for (long i = 1; i*i <= N; i++) {
            if (N % i == 0) {
                int F = Math.max(digitLength(i), digitLength(N / i));
                if (answer > F) {
                    answer = F;
                }
            }
        }

        System.out.println(answer);

    }

    private static int digitLength(long i) {
        return Long.toString(i).length();
    }


}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <functional>

template <class Container>
std::vector<int> zalgo(const Container& dat) {
    int n = dat.size();

    std::vector<int> ret(n);
    ret[0] = n;

    int i = 1, len = 0;
    while (i < n) {
        while (i + len < n && dat[len] == dat[i + len]) {
            ++len;
        }
        ret[i] = len;

        if (len == 0) {
            ++i;
            continue;
        }

        int nlen = 1;
        while (i + nlen < n && nlen + ret[nlen] < len) {
            ret[i + nlen] = ret[nlen];
            ++nlen;
        }

        i += nlen;
        len -= nlen;
    }

    return ret;
}

constexpr int INF = 1 << 30;

void solve() {
    std::string s, t;
    std::cin >> s >> t;
    while (s.length() < t.length()) s += s;

    auto v = zalgo(t + "$" + s + s);
    v.erase(v.begin(), v.begin() + t.length() + 1);
    v.erase(v.begin() + s.length(), v.end());

    int n = t.length(),
        m = v.size();
    for (auto& x : v) x = (x == n);

    std::vector<int> dist(m, -1);
    std::function<int(int)> dfs = [&](int i) {
        if (dist[i] != -1) return dist[i];
        if (!v[i]) return dist[i] = 0;
        dist[i] = INF;
        return dist[i] = dfs((i + n) % m) + 1;
    };

    int ans = 0;
    for (int i = 0; i < m; ++i) ans = std::max(ans, dfs(i));
    std::cout << (ans >= INF ? -1 : ans) << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 31592
[n,m] = [int(i) for i in input().split()]
dic = {}
for i in range(n):
    [ai,bi] = [int(i) for i in input().split()]
    if ai in dic.keys():
        dic[ai] += bi
    else:
        dic[ai] = bi
sum = 0
ls = sorted(list(dic.keys()))
while m > 0:
    for i in range(len(ls)):
    #print(dic)
        if dic[ls[i]] >= m:
            sum += ls[i] * m
            m = 0
            break
        else:
            sum += dic[ls[i]]*ls[i]
            m -= dic[ls[i]]
print(sum)


Measured memory_bytes: 17884
D, N = map(int,input().split())
if N==100:
    if D==0:
        print (1*(N+1))
    if D==1:
        print(100*(N+1))
    if D==2:
        print(10000*(N+1))

elif D==0:
    print(1*N)
elif D==1:
    print(100*N)
elif D==2:
    print(10000*N)

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

int main() {
  string s, t, ans;
  cin >> s >> t;
  if(s == t.substr(0, s.length())) {
    ans = "Yes";
  } else {
    ans = "No";
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define sa(v) sort(v.begin(),v.end())
#define sd(v) sort(v.begin(),v.end(),greater<>())
#define rev(s) reverse(s.begin(),s.end())
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(ll i=a;i<b;i++)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()

#define sqr(a) ((a) * (a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define mem(a,b) memset(a,b,sizeof(a))

#define yes cout<<"YES"<<nl;
#define no cout<<"NO"<<nl;

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree< long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
void erase ( ordered_set &s, long long val )
{
    auto it = s.upper_bound(val);

    if ( it == s.begin() && val == *s.begin() )
        s.erase ( s.upper_bound(val) );
    else
        s.erase ( s.upper_bound(val) );
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu ()
{
    cerr << endl;
}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}
ll x;
ll f(ll n)
{
  if(n<0)
    return 0;
  return n/x+1;
}

int main()
{
    su;
    ll a,b;
    cin>>a>>b>>x;
    cout<<f(b)-f(a-1)<<nl;
    return 0;
}


Measured memory_bytes: 3652
S = gets.chomp
first = S[0, 2].to_i
last = S[2, 2].to_i
 
if (1..12).include?(first)
  if (1..12).include?(last)
    puts 'AMBIGUOUS'
  else
    puts 'MMYY'
  end
else
  if (1..12).include?(last)
    puts 'YYMM'
  else
    puts 'NA'
  end
end


Measured memory_bytes: 1788
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct UnionFind {
    vector<int> id;
    vector<vector<int> > groups;
    int gn; //number of groups
    UnionFind(int n){
        id = vector<int>(n);
        groups = vector<vector<int> >(n);
        gn = n;
        for(int i=0;i<n;++i){
            id[i]=i;
            groups[i]={i};
        }
    }
    void unite(int a, int b) {
        if(same(a,b)) return;
        gn--;
        int x = id[a];
        int y = id[b];
        if(groups[x].size()<groups[y].size()) swap(x,y);
        for(int j : groups[y]){
            id[j] = x;
            groups[x].push_back(j);
        }
        groups[y].clear();        
    }
    bool same(int a, int b) {
        return id[a] == id[b];
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    UnionFind uf(n+m);
    REP(i,n){
        int k;
        cin >> k;
        REP(j,k){
            int l;
            cin >> l;
            l--;
            uf.unite(i,n+l);
        }
    }
    REP(i,n-1){
        if(!uf.same(i,n-1)){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 12672
import java.awt.*;
import java.util.*;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, List<Point>> map = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            int p = sc.nextInt();
            if(map.containsKey(s)) {
                map.get(s).add(new Point(p, i+1));
            } else {
                map.put(s, new ArrayList<Point>());
                map.get(s).add(new Point(p, i+1));
            }
        }
        for(List<Point> list: map.values()) {
            list.sort(Comparator.comparingInt(o -> o.x));
            Collections.reverse(list);
            for (Point p : list) {
                System.out.println(p.y);
            }
        }
    }
}

Measured memory_bytes: 28628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	string t;
	for(ll i=0;i<n/2;i++){
		t.push_back(s[i]);
	}
	t=t+t;
	if(s==t){
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define ms(a,v) memset(a,v,sizeof(a))
#define unq(v) v.erase(unique(v.begin(),v.end()),v.end());
#define mp make_pair
#define write(x) cout<<(x)<<endl
using namespace std; typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; }return 0; }
const int INF = 1 << 28; const ll LINF = 1ll << 60;
const int MAX = 1e5 + 5; const int MOD = 1e9 + 7; const double EPS = 1e-6;
const int dy[4] = { 0,1,0,-1 }; const int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int L;
int A[MAX * 2];

ll dp[MAX * 2][5];

int main() {
    cin >> L;
    rep(i, L) {
        cin >> A[i];
    }

    rep(i, L + 1) {
        rep(j, 5) {
            dp[i][j] = LINF;
        }
    }
    dp[0][0] = 0;

    for (int i = 1; i < L + 1; ++i) {
        dp[i][0] = dp[i - 1][0] + A[i - 1];

        int c_ev = (A[i - 1] == 0 ? 2 : A[i - 1] % 2);
        int c_od = (1 - A[i - 1] % 2);

        dp[i][1] = dp[i - 1][0] + c_ev;
        chmin(dp[i][1], dp[i - 1][1] + c_ev);

        dp[i][2] = dp[i - 1][0] + c_od;
        chmin(dp[i][2], dp[i - 1][1] + c_od);
        chmin(dp[i][2], dp[i - 1][2] + c_od);

        dp[i][3] = dp[i - 1][0] + c_ev;
        chmin(dp[i][3], dp[i - 1][1] + c_ev);
        chmin(dp[i][3], dp[i - 1][2] + c_ev);
        chmin(dp[i][3], dp[i - 1][3] + c_ev);

        dp[i][4] = dp[i - 1][0] + A[i - 1];
        chmin(dp[i][4], dp[i - 1][1] + A[i - 1]);
        chmin(dp[i][4], dp[i - 1][2] + A[i - 1]);
        chmin(dp[i][4], dp[i - 1][3] + A[i - 1]);
        chmin(dp[i][4], dp[i - 1][4] + A[i - 1]);
    }

    ll ans = LINF;
    rep(i, 5) chmin(ans, dp[L][i]);
    write(ans);
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

int main() {
  int N;
  cin >> N;
  auto P = vector<int>(N);
  REP(i, N) { cin >> P[i]; }
  int minP = 1000000;
  int cnt = 0;
  REP(i, N) {
    if(minP > P[i]) {
      cnt++;
      minP = P[i];
    }
  }
  cout << cnt << endl;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n,t;

    Scd2(n,t);

    int a,b;
    int ans = 9999;
    Rep(i,n){
        Scd2(a,b);
        if( b <= t ){
            ans = min(ans,a);
        }
    }

    if( ans == 9999 ){
        printf ("TLE\n");
    }else{
        printf ("%d\n", ans);
    }

    return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
x = 0
y = 0
for i in range(0,n):
    x = x + a[i]
for i in range(0,n):
    y = y + (a[i]**2)
print(((x**2-y)//2) % (10**9+7))

Measured memory_bytes: 31436
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int maxn=2e3+7;
int a[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int pos=lower_bound(a,a+n,a[i]+a[j])-a;
			ans+=pos-j-1;
		}
	}
	printf("%lld\n",ans);
	//system("pause");
	return 0;
}


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

int main() {
  int a,b,s;
    cin>>a>>b;
  if (a==b){
    cout<<2*a<<endl;
    }
  else{
  s=max(a,b)+max(a-1,b-1);
  cout <<s<< endl;
  }
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, size):
        self.parents = [-1 for _ in range(size)]

    def root(self, index):
        parent = self.parents[index]
        if ( parent < 0):
            return index
        root = self.root(parent)
        self.parents[index] = root
        return root

    def size(self, index):
        return -1 * self.parents[self.root(index)]

    def add(self, A, B):
        A = self.root(A)
        B = self.root(B)
        if (A == B):
            return
        if (self.size(A) < self.size(B)):
            A, B = B, A
        self.parents[A] += self.parents[B]
        self.parents[B] = A
N, M = [int(x) for x in input().split()]
AB = [[int(x) - 1 for x in input().split()] for _ in range(M)]
uf = UnionFind(N)
for a, b in AB:
    uf.add(a, b)
s = set()
ans = 1
for i in range(N):
    ans = max(ans, uf.size(i))
print(ans)


Measured memory_bytes: 44108
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>
#include <functional>

using namespace std;
using ll = long long;
using ld = double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>; //(x, y, dx, dy)
const ll INF = 1e17;
const ld eps = 1e-10;
const ll MOD = 1e9 + 7;

const double pi = acos(-1.0);

vector<string> area;
map<P, ll> mp;

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

P diam(vector<vector<ll>> &es, vector<int> &visited, ll now) {
	if (visited[now])
		return P(-10, -1);
	visited[now] = true;
	P ret = P(-1, now);
	for (auto &e : es[now]) {
		ret = max(ret, diam(es, visited, e));
	}
	ret.first += 1;
	return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	cin >> N;
	vector<vector<ll>> es(N);
	for (int i = 0;i < N - 1;i++) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		es[a].push_back(b);
		es[b].push_back(a);
	}
	ll d, node;
	vector<int> visited(N, false);
	tie(d, node) = diam(es, visited, 0);
	visited.assign(N, false);
	tie(d, node) = diam(es, visited, node);
	if (d % 3 == 1)
		cout << "Second" << endl;
	else
		cout << "First" << endl;
	return 0;
}


Measured memory_bytes: 27648