akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=0;cin>>n;
  lvector A(n);rep(i,n) cin>>A[i];sort(RALL(A));
  ll num=1,pos=1;ans+=A[0];
  while(num<n-1) {
    if(num+2<=n-1) {ans+=2*A[pos];num+=2;}
    else {ans+=A[pos];num++;}
    pos++;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 4764
#include <iostream>
#include <stdio.h>
using namespace std;
int v[]={1,5,10,50,100,500};
int main()
{
	int c[6],ans=0;
	cin>>c[0]>>c[1]>>c[2]>>c[3]>>c[4]>>c[5];
	for(int i=0;i<6;i++){
		ans+=v[i]*c[i];
	}
	cout<<(ans>=1000)<<endl;
    return 0;
}

Measured memory_bytes: 1164
X,N= map(int, input().split())
if N==0 :
    print(X)
else:
    
    p=list(map(int,input().split()))
    mylist = list(range(0,10000))


    for i in range(N):
        if (p[i] in mylist)==True:
            mylist.remove(p[i])

    mylist2 = list(map(lambda a: abs(a - X), mylist))

    
    p=mylist2.index(min(mylist2))

    print(mylist[p])

Measured memory_bytes: 9536
#include <stdio.h>
#include <utility>
int max(int a, int b) {
  return a > b ? a : b;
}

int main(void) {
  int i, j, k, n, ans = 0, m;
  scanf("%d%d", &m, &n);
  char s[m + 10], t[n + 10];
  std::pair<int, int> dp[m + 1][n + 1];
  scanf("%s", s);
  scanf("%s", t);
  for(i = 0; i <= m; ++i) for(j = 0; j <= n; ++j) dp[i][j].first = 0, dp[i][j].second = 0;
  for(i = 1; i <= m; ++i) {
    if(s[i - 1] == 'I') dp[i][0].first = dp[i - 1][0].second + 1, ans = 1;
    else if(dp[i - 1][0].first) dp[i][0].second = dp[i - 1][0].first + 1;
  }
  for(i = 1; i <= n; ++i) {
    if(t[i - 1] == 'I') dp[0][i].first = dp[0][i - 1].second + 1, ans = 1;
    else if(dp[0][i - 1].first) dp[0][i].second = dp[0][i - 1].first + 1;
  }
  for(i = 1; i <= m; ++i) for(j = 1; j <= n; ++j) {
    if(s[i - 1] == 'I') dp[i][j].first = dp[i - 1][j].second + 1;
    else if(dp[i - 1][j].first) dp[i][j].second = dp[i - 1][j].first + 1;
    if(t[j - 1] == 'I') dp[i][j].first = max(dp[i][j].first, dp[i][j - 1].second + 1);
    else if(dp[i][j - 1].first) dp[i][j].second = max(dp[i][j].second, dp[i][j - 1].first + 1);
   ans = max(ans, dp[i][j].first);
  }
  printf("%d\n", ans);
  return 0;
}


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

int main() {
  int N, sum = 0, A, B;
  cin >> A >> B;
  for (; A <= B; A++) {
    if (A / 1000 == A % 10 * 10 + A / 10 % 10) {
      sum = sum + 1;
    }
  }
  cout << sum << endl;
}



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

# if L % 3 == 0:
#     print((L/3)**3)
# elif L % 3 == 1:
#     print((L//3)**2 * (L//3 + 1))
# else:
#     print((L//3) * (L//3 + 1)**2)

print((L/3)**3)

Measured memory_bytes: 2940
#include <vector>
#include <iostream>
#include <iomanip>
#include <map>
#include <string.h>
#include <cstring>
#include <queue>
#include <limits>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <cmath>
#include <stdio.h>
#include <set>
#include <cstdio>
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define FOR(i, a) for(int i = 0; i < (a); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
const int N = 1e5 + 10;
double esp = 1e-10;
int n, y;
void wa() {
    cout << -1 << " " << -1 << " " << -1 << endl;
}
int main() {
    while (cin >> n >> y) {
        y /= 1000;
        y -= n;
        if (y < 0) {
            wa();
            continue;
        }
        bool find = false;
        for (int a = 0; a <= n; a++) {
            if (y >= a * 4 && (y - a * 4) % 9 == 0) {
                int b = (y - a * 4) / 9;
                if (a + b <= n) {
                    find = true;
                    cout << b << " " << a << " " << n - a - b << endl;
                    break;
                }
            }
        }
        if (!find) {
            wa();
        }
    }
    return 0;
}




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

using namespace std;

int main() {
        int N, K;
        cin >> N >> K;
        int cnt = 0;
        for (int i = 0; i < N; ++i) {
                int h;
                cin >> h;
                if (h >= K) ++cnt;
        }
        cout << cnt << endl;
        return 0;
}


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

long long n, m, a[100][100], b[100][100]; 
bool dp[100][100][10000]; //knapsack

int main(){
	cin >> n >> m;
	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++){
			cin >> a[i][j];
		}
	}
	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++){
			cin >> b[i][j];
		}
	}
	memset(dp,0,sizeof dp);
	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++){
			if (i==0 && j==0) dp[0][0][abs(a[0][0]-b[0][0])]=1;
			else if (i==0){
				for (int k=0;k<10000;k++){
					if (dp[i][j-1][k]){
						if (abs(k+(a[i][j]-b[i][j]))<10000) dp[i][j][abs(k+(a[i][j]-b[i][j]))]=1;
						if (abs(k+(b[i][j]-a[i][j]))<10000) dp[i][j][abs(k+(b[i][j]-a[i][j]))]=1;
					}
				}
			}
			else if (j==0){
				for (int k=0;k<10000;k++){
					if (dp[i-1][j][k]){
						if (abs(k+(a[i][j]-b[i][j]))<10000) dp[i][j][abs(k+(a[i][j]-b[i][j]))]=1;
						if (abs(k+(b[i][j]-a[i][j]))<10000) dp[i][j][abs(k+(b[i][j]-a[i][j]))]=1;
					}
				}
			}
			else{
				for (int k=0;k<10000;k++){
					if (dp[i-1][j][k]){
						if (abs(k+(a[i][j]-b[i][j]))<10000) dp[i][j][abs(k+(a[i][j]-b[i][j]))]=1;
						if (abs(k+(b[i][j]-a[i][j]))<10000) dp[i][j][abs(k+(b[i][j]-a[i][j]))]=1;
					}
					if (dp[i][j-1][k]){
						if (abs(k+(a[i][j]-b[i][j]))<10000) dp[i][j][abs(k+(a[i][j]-b[i][j]))]=1;
						if (abs(k+(b[i][j]-a[i][j]))<10000) dp[i][j][abs(k+(b[i][j]-a[i][j]))]=1;
					}
				}				
			}
		}
	}
	for (int i=0;i<10000;i++){
		if (dp[n-1][m-1][i]){
			cout << i << "\n";
			break;
		}
	}
}

Measured memory_bytes: 98048
import sys
input = sys.stdin.readline  # NOQA


def left(T, S, a, i):
    # ...>>><
    j = 1
    l = i
    while 0 <= l:
        if S[l] == ">" and a[l] < j:
            a[l] = j
            l -= 1
            j += 1
        else:
            break


def right(T, S, a, i):
    # ><<<...
    j = 1
    r = i
    while r <= T - 1:
        if S[r] == "<" and a[r + 1] < j:
            a[r + 1] = j
            r += 1
            j += 1
        else:
            break


def main():
    S = input().rstrip()

    T = len(S)
    N = T + 1
    a = [-1] * N

    if S[0] == "<":
        a[0] = 0
        right(T, S, a, 0)
    for i in range(T - 1):
        if S[i] == ">" and S[i + 1] == "<":
            a[i + 1] = 0
            left(T, S, a, i)
            right(T, S, a, i + 1)
    if S[T - 1] == ">":
        a[N - 1] = 0
        left(T, S, a, T - 1)

    ans = sum(a)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 23360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
typedef pair<double, double> dd;
#define mp make_pair
#define pb push_back
#define debug(x) cerr << #x << " = " << x << " "


int main()
{
  //  ios::sync_with_stdio(false);
  //  cin.tie(0);
  int n, k;
  while (cin >> n >> k)
    {
      vector<int> sum(n+1, 0);
      for (int i = 1; i <= n; ++i)
	cin >> sum[i], sum[i] += sum[i-1];
      int maxi = sum.front();
      for (int i = k; i <= n; ++i) maxi = max(maxi, sum[i] - sum[i-k]);
      printf("%.6lf\n", (maxi + k) / 2.0);
    }
}


Measured memory_bytes: 1024
#include <stdio.h> 
#include <ctype.h> 
int main() {
 char ch[1200];
 int i,n;

 n=0;

 char a[1200];

 while(1) {
  scanf("%c",&a[n]);

  if(a[n] == '\n') {
    break;
  } 

  ch[n] = a[n];

  if('A' <= a[n] && a[n] <= 'Z') {
   ch[n] = a[n] + 32;
  } 
  else if(a[n] >= 'a' && a[n] <= 'z') {
   ch[n] = a[n] - 32;
  }

  n = n +1;
 } 

 for(i=0; i<n ; i++) {
  printf("%c" ,ch[i]);
 }

 printf("\n");

 return 0; 
} 


Measured memory_bytes: 2084
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	int x;
	cin >> x;
	cout << x + x * x + x * x * x;
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y);
//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	double x,y;
	int a,b,r,i;

	x=0;
	y=0;
	r=90;
	scanf("%d,%d",&a,&b);
	while(a!=0||b!=0){
		x+=a*cos((double)r/180*PI);
		y+=a*sin((double)r/180*PI);
		r-=b;
		scanf("%d,%d",&a,&b);;
	}
	printf("%d\n%d\n",(int)x,(int)y);
	//for(i=0;i<=1000000000;i++);
	return 0;
}

Measured memory_bytes: 604
import numpy as np

n,m,x = map(int, input().split())

CA = [list(map(int, input().split())) for _ in range(n)]

costs = []

for i in range(2**n):
  temp_cost = 0
  skill = np.zeros(m)
  for j in range(n):
    if i&1<<j:
      temp_cost += CA[j][0]
      skill += np.array(CA[j][1:])
      
  if all(skill>=x):
    costs.append(temp_cost)
    
if costs:
  print(min(costs))
else:
  print(-1)

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

const int maxn(2e5 + 5);

int n, q, ans;
char s[maxn], t[maxn], d[maxn];

inline int check(int x) {
	int i;
	for (i = 1; i <= q && x && x <= n; ++i) if (t[i] == s[x]) d[i] == 'L' ? --x : ++x;
	return x;
}

int main() {
	scanf("%d%d %s", &n, &q, s + 1);
	int i, l, r, mid, ret1 = 0, ret2 = n + 1;
	for (i = 1; i <= q; ++i) scanf(" %c %c", &t[i], &d[i]);
	l = 1, r = n;
	while (l <= r) {
		mid = (l + r) >> 1;
		if (check(mid) < 1) ret1 = mid, l = mid + 1;
		else r = mid - 1;
	}
	l = 1, r = n;
	while (l <= r) {
		mid = (l + r) >> 1;
		if (check(mid) > n) ret2 = mid, r = mid - 1;
		else l = mid + 1;
	}
	printf("%d\n", n - min(n, ret1 + n - ret2 + 1));
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cmath>

const double PI = 4 * atan(1);
int naturalPart(const double r){
    if(r>0) return floor(r);
    else    return ceil(r);
}

int main(){
    double x = 0, y = 0;
    int stride, dir = 90, rot;
    while(1){
        std::cin >> stride;
        x += stride * cos(dir * PI / 180);
        y += stride * sin(dir * PI / 180);
        std::cin.ignore() >> rot;
        if(!stride && !rot)
            break;
        dir -= rot;
    }
    
    std::cout << naturalPart(x) << '\n' << naturalPart(y) << std::endl;
    return 0;
}

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

typedef unsigned long long ullong;

int main( void )
{
    ullong A, B, N;
    std::cin >> A >> B >> N;
  
    // floor( A * x/B ) - A * floor( x/B ) を求める.
    // x が B の倍数以上になる度に、引かれる数は大きくなる.
    // また、ある数 x に対し、 x+B についても、全体の数は同じになる.
    ullong x = std::min( B-1, N );
    std::cout << (ullong)(A*x/B) << std::endl;
    return 0;
}

Measured memory_bytes: 3576
n = gets.to_i
a = gets.split.map(&:to_i).sort
max = a[-1]
r = Array.new(max+1, true)
for i in 0...n
  if r[a[i]]
    r[a[i]] = false if a[i] == a[i+1]
    t = a[i]*2
    while t <= max
      r[t] = false
      t += a[i]
    end
  end
end
s = 0
a.each do |i|
  s += 1 if r[i]
end
p s

Measured memory_bytes: 38452
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int d = scanner.nextInt();
		double ans = 0;
		if(d == 0) {
			ans+=1;
		}else {


		for(int i = 1; i<= n; i++) {

			if(i-d >= 1) ans += (double)1/n;
			if(i+d <= n) ans += (double)1/n;
		}
		}
		ans *= m-1;
		ans /= n;
		System.out.println(ans);
	}

}


Measured memory_bytes: 21972
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
#include<time.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ")
#define pdd(a,n,m)for(int i=0;i<m;i++)pd(a,m)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

int a,b,c;
int main(){
  cin>>a>>b>>c;
  if((a==b&&b==c) || (a!=b&&b!=c&&a!=c))cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}


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

long long x,y,g,ans=0;

int main()
{
    cin>>x>>y;
    g=__gcd(x,y);
    for (long long i=2;i<=g/i;i++)
    {
        if (g%i==0)
        {
            ans++;
            while(g%i==0)  g/=i;
        }
    }
    if (g>1)  ans++;
    cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())

x = []
y = []

for i in range(n):
  day, salary = map(int, input().split())
  heapq.heappush(x, (-day,-salary))
  
while x:
  d, s = heapq.heappop(x)
  r = m-len(y)
  if r >= -d:
    heapq.heappush(y, -s)
  else:
    heapq.heappush(y, -s)
    heapq.heappop(y)

print(sum(y))

Measured memory_bytes: 17088
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=1;i<=n;i++){
		cin>>a[i];
		b[a[i]]=i;
	}
	for(int i=1;i<=n;i++)
	    cout<<b[i]<<" ";
	return 0;
}

Measured memory_bytes: 1536
# by the authority of GOD     author: manhar singh sachdev #

import os,sys
from io import BytesIO, IOBase
from collections import deque

def update(seg_tree,val,update_val,x):
    curr = deque([(1,x,1)])
    while len(curr):
        y = curr.popleft()
        if y[0]<=val<=y[1]:
            seg_tree[y[2]] = max(seg_tree[y[2]],update_val)
            if y[0]!=y[1]:
                curr.append((y[0],(y[0]+y[1])//2,2*y[2]))
                curr.append(((y[0]+y[1])//2+1,y[1],2*y[2]+1))

def trav(seg_tree,val,x):
    curr = deque([(1,x,1)])
    ans = 0
    while len(curr):
        y = curr.popleft()
        if y[1]<val:
            ans = max(ans,seg_tree[y[2]])
        elif y[0]<=val<=y[1] and y[0]!=y[1]:
            curr.append((y[0],(y[0]+y[1])//2,2*y[2]))
            curr.append(((y[0]+y[1])//2+1,y[1],2*y[2]+1))
    return ans

def main():
    n = int(input())
    h = list(map(int,input().split()))
    a = list(map(int,input().split()))
    x = 1<<n.bit_length()
    seg_tree = [0]*(x<<1)
    fin = 0
    for i in range(n):
        k = trav(seg_tree,h[i],x)
        fin = max(fin,a[i]+k)
        update(seg_tree,h[i],a[i]+k,x)
    print(fin)

#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

Measured memory_bytes: 124596
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int cnt=1;
	while(a>0&&c>0){
		if(cnt&1){
			c-=b;
		}
		else{
			a-=d;
		}
		cnt++;
	}
	if(a>0){
		printf("Yes");
	}
	else{
		printf("No");
	}
}


Measured memory_bytes: 3828
import java.util.ArrayList;
import java.util.Scanner;

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

		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int a = sc.nextInt();
			if(n==0 && m==0 && a==0) break;

			int[][] line = new int[1000+1][n+1];
			
			for(int i=0; i < m; i++){
				int h = sc.nextInt(); 
				int p = sc.nextInt(); 
				int q = sc.nextInt();
				line[h][p] = q;
				line[h][q] = p;
			}
			
			for(int i=line.length-1; i > 0; i--){
				if(line[i][a]!=0){
					a = line[i][a];
				}
			}
			ans.add(a);
		}
		
		for(int i=0; i < ans.size(); i++){
			System.out.println(ans.get(i));
		}
		sc.close();
	}
}

Measured memory_bytes: 70932
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
 
using namespace std;
 
int binarySearch(vector<int>& v,int s,int e,int sum){
	int l=s;
	int r=e;
	while(l+1<r){
		int m=(l+r)>>1;
		if(v[m]<sum){
			l=m;
		}
		else r=m;
	}
	return l;
}


int32_t main ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	
	int n;
	cin>>n;
	map<int,int> mp;
	vector<int> v;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		mp[x]++;
		if(mp[x]==1)v.push_back(x);
	}

	n=v.size();
	sort(v.begin(),v.end());

	// T if min_a+min_b > max_c
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int t=binarySearch(v,j,n,(v[i]+v[j]));
			if(t<n && v[i]+v[j]>v[t] && t > j){
				ans+=mp[v[i]]*mp[v[j]]*mp[v[t]];
				for(int k=j+1;k<t;k++){
					ans+=mp[v[i]]*mp[v[j]]*mp[v[k]];
				}
			}
		}
	}

	cout<<ans<<endl;


	return 0;
}
 

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <set>

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

using namespace std;

inline int max(int a, int b) {
	if (b > a) swap(a, b);
	return a;
}

inline int min(int a, int b) {
	if (a > b) swap(a, b);
	return a;
}


int main() {
	int n, m;
	cin >> n >> m;
	int lmax = 0, rmin = n;
	rep(i, m) {
		int l, r;
		cin >> l >> r;
		lmax = max(l, lmax);
		rmin = min(r, rmin);
	}

	if (rmin - lmax < 0) {
		cout << 0 << endl;
	}
	else {
		cout << rmin - lmax + 1 << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        n: usize,
        s: [String; n],
    }

    let ans = s.iter().collect::<HashSet<_>>().len();

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

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 17248
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define UP(i,a,b) for(int i=(a); i<=(b); ++i)
#define DOWN(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) UP(i,0,(n)-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, int n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n in O(log(n)) time

const int MOD = 1000000007; //10^9+7
const double PI = 3.1415926535897932384626;

/*********** variables ************/
int N;
int a[200];
/**********************************/


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) cin >> a[i];

    int sum = accumulate(a, a+N, 0);
    int x[] = {sum/N, (sum+N-1)/N};
    int ans = 1<<30;
    REP(c, 2) {
        int now = 0;
        REP(i, N) {
            now += power(a[i]-x[c], 2);
        }
        ans = min(ans, now);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    
    ans = 1
    tmp = inlis[0]
    for i in range(1, n):
        if inlis[i] < tmp:
            ans += 1
            tmp = inlis[i]
    print(ans)

    
if __name__ == "__main__":
    main()


Measured memory_bytes: 32340
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        int N, X, s = 0, ans = 0;
        cin >> N >> X;
        vector<int> vec(N);
        rep(i, N) cin >> vec[i];
        int mi = vec[0];

        rep(i, N)
        {
                s += vec[i];
                if (vec[i] <= mi)
                        mi = vec[i];
        }
        cout << N + (X - s) / mi << endl;

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define each(e,v) for(auto&& e:(v))
#define DEBUG(x) cout<<#x<<": "<<x<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
const int ALC = 26;

int main() {
    string s; cin >> s;
    const int n = s.length();
    int K; cin >> K;
    rep(i, n) {
        const int d = 'z' - s[i] + 1;
        if(d < ALC && d <= K) {
            s[i] = 'a';
            K -= d;
        }
    }
    while(K > 0) {
        if(s[n-1] != 'z')
            s[n-1]++;
        else s[n-1] = 'a';
        K--;
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 640
function main()
    n = parse(Int, readline())
    ans = zeros(Int, 4)
    for i in 1:n
        s = readline()
        s == "AC" && (ans[1] += 1)
        s == "WA" && (ans[2] += 1)
        s == "TLE" && (ans[3] += 1)
        s == "RE" && (ans[4] += 1)
    end

    println("AC x ", ans[1])
    println("WA x ", ans[2])
    println("TLE x ", ans[3])
    println("RE x ", ans[4])
    
end

main()

Measured memory_bytes: 162744
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<string>
#include<stack>
#include<algorithm>

using namespace std;

void slove(){
    int x;
    cin>>x;
    if(x >= 30){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

int main(){
    slove();
}

Measured memory_bytes: 3152
/*
Created by Rishu Sahu @ covid 20-20
*/
/*
*****************************************************************
*/

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define pai pair<int,int>
#define pal pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,a,b) for(int i=a;i<=b;i++)
#define ff first 
#define ss second
#define sz(x) (int)x.size()
#define vi vector<int>
#define vl vector<ll>
#define mpl map<ll,ll>
#define mpi map<int,int>
#define pb push_back
#define all(x) x.begin(),x.end()

const int mod = 1e9+7;
const int INF = INT_MAX;
const int mxm = 1e6+6;


void solve(){
   string s,t;
   cin>>s>>t;
   int j;
   int mn=INT_MAX;
   for(int i=0;i<s.length();i++){
       int ans=0;
       for(j=0;j<t.length();j++){
           if(i+j>=s.length())
           break;
           if(s[i+j]!=t[j])
           ans++;
       }
       if(j==t.length())
       mn=min(ans,mn);
   }
   cout<<mn<<endl;
}


int main(){
    int t=1;
    // cin>>t;
    while(t--){
        // mp.clear();
        solve();
    }
}

Measured memory_bytes: 3580
#include <iostream>
#include <stdio.h>
#include <string>
#define NMAX 15
using namespace std;
string s,t;
int main(){
    int n,m;
    cin >> s;
    cin >> t;
    n = s.size();
    m = t.size();
    char car = t[m-1];
    s += car;
    if(s == t)
     cout << "Yes" << "\n";
    else
      cout << "No" << "\n";
    return 0;
}


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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;

int ans[N];
vii g[N];
set < int > st[N];

void solve(int testCase){

    scanf("%d" , &n);

    for(int i = 1 ; i < n ; i ++){
            int u , v;
            scanf("%d %d" , &u , &v);

            g[u].push_back({i , v});
            g[v].push_back({i , u});
    }

    int num = 0;
    for(int i = 1 ; i <= n ; i ++){
            int color = 1;
            for(ii G : g[i]){
                    int v = G.second;
                    int e = G.first;

                    if(ans[e] != 0)continue;

                    while(st[i].find(color) != st[i].end()){
                            color ++;
                    }

                    ans[e] = color;
                    num = max(num , color);
                    st[v].insert(color);
                    st[i].insert(color);
                    color ++;
            }
    }

    printf("%d\n" , num);
    for(int i = 1 ; i < n ; i ++){
            printf("%d\n" , ans[i]);
    }

}

main(){

    int t = 1;
    //scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 28032
n=int(input())
A=list(map(int,input().split()))
#print(A)
f=0
g=1
for i in range(0,n):
    if A[i]!=g:
        f+=1
    else:
        g+=1
#printf("%d %d\n",f,g)
if g!=1:
    print(f)
else:
    print(-1)

Measured memory_bytes: 24744
/* *****fireice**** */

#include<bits/stdc++.h>

#define ll long long int
#define ld long double
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define el '\n'
#define N 1000000007
#define re return
#define F first
#define S second
#define L length
#define mp make_pair
#define PI 3.14159265
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int i=0;i<n;i++)
#define forf(i,x,n) for(int i=x;i<n;i++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
#define take(a,n) forup(i,n) cin>>a[i];
using namespace std;

int gcdExtended(int a, int b, int *x, int *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    int x1, y1; // To store results of recursive call
    int gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}

ll modInverse(int a, int m)
{
    int x, y;
    int g = gcdExtended(a, m, &x, &y);
        // m is added to handle negative x
    ll res = ((ll)x%m + (ll)m) % m;

    return res;
}

ll poww(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n==1) return x;
    else if(n%2 == 0)        //n is even
        return poww(x*x,n/2);
    else                              //n is odd
        return x*poww(x*x,(n-1)/2);
}

ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

template<typename T>
T maxx(T a,T b)
{
  if(a<b) re b;
  re b;
}
template<typename T, typename... Args>
T maxx(T a,T b, Args... args)
{
    re(maxx(maxx(a,b),args...));
}

template<typename T>
T minn(T a,T b)
{
  if(a<b) re a;
  re b;
}
template<typename T, typename... Args>
T minn(T a,T b, Args... args)
{
    re(minn(minn(a,b),args...));
}

inline ll min(ll a,ll b)
{
  if(a<b) re a;
  else re b;
}
inline ll max(ll a,ll b)
{
  if(a<b) re b;
  else re a;
}

ll gcd(ll a, ll b)
{
    if (a == 0)
       return b;
    if (b == 0)
       return a;

    if (a == b)
        return a;

    if (a > b)
        return gcd(a-b, b);
    else return gcd(a, b-a);
}

ll ncr(int n,int r)
{
  ll ans=1;
  r=min(r,n-r);
  forup(i,r)
  {
    ans=(ans*(n-i)/(i+1))%N;
  }
  re ans;
}

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

  int t=1;
  //cin>>t;
  while(t--)
  {
    ll n,m,k;
    cin>>n>>m;
    k=(n*25)/2;
    if(n%2==1) k++;
    while((k*8)/100==n)
    {
      if(k/10==m){cout<<k;re 0;}
      k++;
    }
    cout<<"-1";
  }


  return 0;
}


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

int False(){
	cout<<"No";
	return 0;
}

int Ok(){
	cout<<"Yes";
	return 0;	
}

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

	if(str.size() < 4) return False();
	if(str[0] != 'Y') return False();
	if(str[1] != 'A') return False();
	if(str[2] != 'K') return False();
	if(str[3] != 'I') return False();

	return Ok();
}

Measured memory_bytes: 256
#nn
L, R = map(int, input().split())
mod = 2019

if R - L >= mod:
  print(0)
else:
  s = []
  for i in range(L, R):
    for j in range(i+1, R+1):
      s.append((i*j) % mod)
  s.sort()
  print(s[0])

Measured memory_bytes: 81392
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int d1[N],d2[N];
vector<int>e[N];
queue<int>q;
int main()
{
	int n,a,b,s1=0,s2=0;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&a,&b);
		e[a].push_back(b);
		e[b].push_back(a);
	}
	memset(d1,0x3f,sizeof(d1));
	d1[1]=0;
	q.push(1);
	while(!q.empty())
	{
		int k=q.front();
		q.pop();
		for(int i=0;i<e[k].size();i++)
		{
			if(d1[e[k][i]]>d1[k]+1)
			{
				d1[e[k][i]]=d1[k]+1;
				q.push(e[k][i]);
			}
		}
	}
	memset(d2,0x3f,sizeof(d2));
	d2[n]=0;
	q.push(n);
	while(!q.empty())
	{
		int k=q.front();
		q.pop();
		for(int i=0;i<e[k].size();i++)
		{
			if(d2[e[k][i]]>d2[k]+1)
			{
				d2[e[k][i]]=d2[k]+1;
				q.push(e[k][i]);
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
  		if(d1[i]<=d2[i])
			s1++;
		else
			s2++;
	}
	if(s1>s2)
		puts("Fennec");
	else
		puts("Snuke");
	return 0;
}


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


int main() {
  string S;
  cin >> S;
  if (S[0] == S[1] && S[0] == S[2] ) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define int long long
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)


int32_t main()
{
	fastio;
	int r, c;
	cin >> r >> c;
	int red[r+1][c+1], blue[r+1][c+1];
	for(int i=0;i<r;i++)
		for(int j=0;j<c;j++){
			cin >> red[i][j];
		}
	for(int i=0;i<r;i++)
		for(int j=0;j<c;j++){
			cin >> blue[i][j];
		}
	
	bool poss[30000][81][2];
	int off = 15000;
	memset(poss, false, sizeof poss);

	poss[off + red[0][0]-blue[0][0]][0][0] = true;
	poss[off + blue[0][0]-red[0][0]][0][0] = true;

	for(int i=0;i<r;i++){
		int cur = i%2, prev  = (i+1)%2;
		for(int j=0;j<c;j++){
			int diff = red[i][j] - blue[i][j];
			if(i!=0){
				for(int k=0;k<30000;k++){
					if(poss[k][j][prev]){
						poss[k+diff][j][cur] = true;
						poss[k-diff][j][cur] = true;
					}
				}
			}
			if(j!=0){
				for(int k=0;k<30000;k++){
					if(poss[k][j-1][cur]){
						poss[k+diff][j][cur] = true;
						poss[k-diff][j][cur] = true;
					}
				}
			}
		}
		for(int j=0;j<c;j++)
			for(int k=0;k<30000;k++){
				poss[k][j][prev] = false;
			}
	}
	int cur = (r-1)%2;
	int ans = INT_MAX;
	for(int j=0;j<30000;j++){
		if(poss[j][c-1][cur])
			ans = min(ans, abs(off-j));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5248
"use strict"
function Main(input) {
  input = input.trim().split(' ').map(Number);
  let A = input[0];
  let B = input[1];
  let K = input[2];

  A = A - K;
  if(A < 0) B = B + A, A = 0;
  if(B < 0) B = 0;
  console.log(A, B);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
	int n,m,a,b,c[10];
	bool check=false,done[10];
  	for(int i=0;i<10;i++)done[i]=false;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		if(!done[a])
		{
			c[a]=b;
			done[a]=true;
		}
		else if(c[a]!=b)check=true;
		if(a==1&&b==0&&n!=1)check=true;
	}
	if(check)
	{
		cout<<-1<<endl;
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		if(done[i])cout<<c[i];
		else if(i==1&&n!=1)cout<<1;
		else if(i==1&&n==1)cout<<0;
		else cout<<0;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
import numpy as np
N, M = map(int, input().split())
l_max = 1
r_min = 100000
for i in range(M):
    l, r = map(int, input().split())
    if l > l_max:
        l_max = l
    if r < r_min:
        r_min = r
    if r_min < l_max:
        print(0)
        exit()
print(r_min - l_max + 1)

Measured memory_bytes: 12504
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<=former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
///////////////////////////////////////////////////////////////////////////////////

Vi v;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n; cin>>n;
    ll a;
    ll ctr=0,ans =0;
    rep(i,n){
        cin>>a;
        if(a<0)ctr++;
        v.pb(abs(a));
        ans += abs(a);
    }
    sort(all(v));
    if(ctr%2 == 0)cout<<ans<<endl;
    else cout<<(ans-2*v[0])<<endl;
    return 0;
}

Measured memory_bytes: 1400
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
#define EPS (1e-7)

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


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

	int n = s.length();

	int ans = 0;

	REP(i, n) {
		if (i % 2 == 0) {
			if (s[i] == 'p') {
				ans--;
			}
		}
		if (i % 2 != 0) {
			if (s[i] == 'g') {
				ans++;
			}
		}
	}

	cout << ans << endl;
	return 0;
}



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

int main(){
    int n,m;
    cin >> n >> m;
    vector<ll> x(m);
    ll total;
    for(int i=0; i<m; i++){
        cin >> x.at(i);
    }
    sort(x.begin(), x.end());
    total=x.at(m-1)-x.at(0);
    vector<int> dist(m-1);
    for(int i=0;i<m-1; i++){
        dist.at(i) = x.at(i+1) - x.at(i);
    }
    sort(dist.begin(), dist.end());
    reverse(dist.begin(), dist.end());
    for(int i=0; i<n-1; i++){
        if(i >= m-1) break;
        total -= dist.at(i);
    }
    cout << max((ll)0, total) << endl;
}

Measured memory_bytes: 4560
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s=="Sunny")
    cout << "Cloudy" << endl;
    if(s=="Cloudy")
    cout << "Rainy" << endl;
    if(s=="Rainy")
    cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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;
}

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

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int DigitNum(ll n) {
	int digit=0;
	ll wari=1LL;
	while(n/wari) {
		digit++;
		wari*=10;
	}
	return digit;
}

void PrimeFact(ll x) { // 素因数分解 出力部を適切に書き換え
	int i=2;
	while(x%2&&i*i<=x) {
		cout<<2<<endl;
		x/=2;
	}
	i++;
	while(i*i<=x) {
		if(x%i) {
			i+=2;
			continue;
		}
		cout<<i<<endl;
		x/=i;
	}
}

bool Palind(string s) {
	return s == string(s.rbegin(), s.rend());
}

int main() {
	ll N; cin>>N;
	int F=INTINF;
	for(ll i=1LL; i*i<=N; i++) {
		if(N%i) continue;
		F=max(DigitNum(i),DigitNum(N/i));
	}
	cout<<F<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=n1;i<(int)(n2);i++)
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
 
signed main()
{
	mp::cpp_int N;
	std::cin >> N;
 
	mp::cpp_int max = 0;
  	mp::cpp_int one = 1;
  	mp::cpp_int two = 2;
	max = N*(N-one)/two;
 
	std::cout << max;
	return 0;
}

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

#define ll long long
using namespace std;

int main()
{
	int N, x, A[100],ans;
	cin >> N >> x;
	for(int i=0; i<N; ++i)
		cin>>A[i];
	sort(A,A+N);
	int i=0;
	while(x>0 && i!=N)
	{
		x-=A[i++];
	}
	if(x<0)
		ans = i-1;
	else
		if(x>0)
			ans=N-1;
		else
			ans=i;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
def rec_count(num):
    if num == 1:
        return 1
    elif num == 2:
        return 3
    elif num == 3:
        return 3
    else:
        split = num // 2
        return 1 + 2 * rec_count(split)

h = int(input())
print(rec_count(h))


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
const int N = 2e3 + 3;
int n , m , q;
char str[N][N];
int sum0[N][N];
int sum1[N][N];
int sum2[N][N];
int sum(int pre[N][N] , int x1 , int y1 , int x2 , int y2){
    return pre[x2][y2] - pre[x1 - 1][y2] - pre[x2][y1 - 1] + pre[x1 - 1][y1 - 1];
}
int main(){
    scanf("%d %d %d" , &n , &m , &q);
    for(int i = 1 ; i <= n ; ++i){
        scanf("%s" , str[i] + 1);
    }
    for(int i = 1 ; i <= n ; ++i){
        for(int j = 1 ; j <= m ; ++j){
            sum0[i][j] = sum0[i][j - 1] + sum0[i - 1][j] - sum0[i - 1][j - 1] + (str[i][j] == '1');
            sum1[i][j] = sum1[i][j - 1] + sum1[i - 1][j] - sum1[i - 1][j - 1] + (str[i][j] == '1' && str[i][j - 1] == '1');
            sum2[i][j] = sum2[i][j - 1] + sum2[i - 1][j] - sum2[i - 1][j - 1] + (str[i][j] == '1' && str[i - 1][j] == '1');
        }
    }
    while(q--){
        int x1 , y1 , x2 , y2;
        scanf("%d %d %d %d" , &x1 , &y1 , &x2 , &y2);
        printf("%d\n" , sum(sum0 , x1 , y1 , x2 , y2) - sum(sum1 , x1 , y1 + 1 , x2 , y2) - sum(sum2 , x1 + 1 , y1 , x2 , y2));
    }
}

Measured memory_bytes: 52736
// template version 1.14
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;
const int MOD=1e9+7;

// define basic macro {{{
#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<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

signed main() {
  int n,m,v,p;cin>>n>>m>>v>>p;
  dump(m,v,p);
  vector<int> a(n);
  rep(i, n) {
    cin>>a[i];
  }
  sort(all(a));
  dump(a);

  // 単調性
  int left = -1;
  int right = n-p;
  auto isright = [&](int i) {
    dump(i);
    int rival = a[n-p];
    int myscore = a[i]+m;
    int r = v-1-(p-1)-i;  // ジャッジはr点 iより大きい人にふらないといけない

    dump(i, r);
    if (myscore<rival){
      return false;
    }

    if (r<=0){ return true; }
    else{
      int d = (n-p)-(i+1)+1-r;
      dump(i, d);
      int s = 0;
      rep(j, i+1, n-p+1){
        s += a[j]+m-myscore;
      }
      if (s<=d*m){
        return true;
      }
      else{
        return false;
      }
    }
    //
    return true;
  };
  while (right-left>1){
    int mid = (right+left)/2;
    if (isright(mid)) { right = mid;}
    else{ left = mid; }
  }
  dump(right);
  cout << n-right << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

typedef long long int lli;

int main(){
  int N;
  cin >> N;
  int res = 0;
  REP(i, 0, N) {
    int t;
    cin >> t;
    if (t % 2) res++;
  }

  cout << (res % 2 ? "NO" : "YES") << endl;
  
  return 0;
}


Measured memory_bytes: 764
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
  int n,*x,i,k,judge=0,r=0;

  scanf("%d",&n);

  x = (int *)malloc(sizeof(int) * n);

  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
  }

for(i = 0;i<n;i++){
  judge=1;


  if (x[i] < 2 || x[i]%2==0)judge=0;
  k= 3;
  while (k <= sqrt(x[i])){
    if (x[i] % k ==0)judge=0;
    k = k + 2;
}
if (x[i] == 2)judge =1;
if(judge!=0)r++;
}
printf("%d\n",r );

return 0;
}



Measured memory_bytes: 2072