akhauriyash/Code-Regression huggingface dataset:
use std::cmp::max;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a = read(&mut stdin_lock, &mut buf, b' ');
    let b = read(&mut stdin_lock, &mut buf, b' ');
    let c = read(&mut stdin_lock, &mut buf, b'\n');
    println!("{}", solve(a, b, c));
}

fn solve(a: u8, b: u8, c: u8) -> u8 {
    max(max(a * 10 + b + c, a + b * 10 + c), a + b + c * 10)
}

#[test]
fn example1() {
    assert_eq!(53, solve(1, 5, 2))
}

#[test]
fn example2() {
    assert_eq!(108, solve(9, 9, 9))
}

#[test]
fn example3() {
    assert_eq!(82, solve(6, 6, 7))
}


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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

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

int main(){
int A, B;
cin >> A >> B;

int ans = max(A + B, max(A - B, A * B));
print(ans);

}


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

#define eps (1e-8)

int n, l;
std::deque<std::pair<int, double> >dq;

double det(std::pair<int, double> p, std::pair<int, double> q){
	return p.first * q.second - p.second * q.first;
}

int main(){
	scanf("%d%d", &n, &l);
	double sum = 0;
	for(int i = 1, v, t; i <= n; ++ i){
		scanf("%d%d", &t, &v);
		int now = l;
		while(!dq.empty() && now - dq.back().first + v >= l){
			now -= dq.back().first;
			sum -= dq.back().second;
			dq.pop_back();
		}
		if(dq.empty()){
			dq.push_front({v, 1ll * t * v});
			sum = 1ll * t * v;
			printf("%.10lf\n", 1.0 * t);
			continue;
		}
		int x = dq.back().first;
		double y = dq.back().second;
		std::pair<int, double> p = {x - (now + v - l), y / x * (x - (now + v - l))};
		
		sum += p.second - y + 1ll * t * v;
		dq.pop_back();
		dq.push_back(p);
		printf("%.10lf\n", sum / l);
		
		p = {v, 1ll * t * v};
		while(!dq.empty() && det(p, dq.front()) > eps){
			p = {p.first + dq.front().first, p.second + dq.front().second};
			dq.pop_front();
		}
		dq.push_front(p);
	}
	return 0;
}

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

int main() {
	long long Ai, Ao, At, Aj, Al, As, Az, count1 = 0, count2 = 0;
	cin >> Ai >> Ao >> At >> Aj >> Al >> As >> Az;
	count1 = Ai - Ai % 2 + Aj - Aj % 2 + Al - Al % 2;
	if (Ai > 0 && Aj > 0 && Al > 0) {
		Ai--, Aj--, Al--;
		count2 = Ai - Ai % 2 + Aj - Aj % 2 + Al - Al % 2 + 3;
	}
	cout << max(count1, count2) + Ao;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>

using namespace std;

struct vec
{
    double x, y;
    vec (const double& x0 = 0, const double& y0 = 0) : x(x0), y(y0) {}
    vec operator + (const vec& t) const {return vec(x+t.x, y+t.y);}
    vec operator - (const vec& t) const {return vec(x-t.x, y-t.y);}
    vec operator * (const double& t) const {return vec(x*t, y*t);}
    vec operator / (const double& t) const {return vec(x/t, y/t);}
    const double len2 () const {return x*x + y*y;}
    const double len () const {return sqrt(len2());}
    vec norm() const {return *this/len();}
    vec rotate_90_c () {return vec(y, -x);}
};

double dot(const vec& a, const vec& b) {return a.x*b.x + a.y*b.y;}
double crs(const vec& a, const vec& b) {return a.x*b.y - a.y*b.x;}

vec lin_lin_int(const vec& p0, const vec& v0, const vec& p1, const vec& v1)
{
    double t = crs(p1-p0, v1) / crs(v0, v1);
    return p0 + v0 * t;
}

vec circle(const vec& a, const vec& b, const vec& c)
{
    return lin_lin_int((a+b)/2, (b-a).rotate_90_c(), (a+c)/2, (c-a).rotate_90_c());
}

int n;
vec pot[100005];

int main()
{
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    for(int i=1; i<=n; i++) scanf("%lf%lf", &pot[i].x, &pot[i].y);
    random_shuffle(pot+1, pot+n+1);
    vec o;
    double r2 = 0;
    for(int i=1; i<=n; i++)
    {
        if((pot[i]-o).len2() > r2)
        {
            o = pot[i], r2 = 0;
            for(int j=1; j<i; j++)
            {
                if((pot[j]-o).len2() > r2)
                {
                    o = (pot[i]+pot[j])/2, r2 = (pot[j]-o).len2();
                    for(int k=1; k<j; k++)
                    {
                        if((pot[k]-o).len2() > r2)
                        {
                            o = circle(pot[i], pot[j], pot[k]), r2 = (pot[k]-o).len2();
                        }
                    }
                }
            }
        }
    }
    printf("%.10lf\n", sqrt(r2));
    return 0;
}


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


int main(){
    ll N;
    cin >> N;
    ll temp = sqrt(N);
    ll ans = 0;
    for (ll i = temp; i > 0 ; i--)
    {
        if(N%i == 0){
            ans = N/i + i - 2;
            break;
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N;
    while (cin >> N, N) {
        vector<int> v(N);
        for (auto& i : v) {
            string str;
            cin >> str;
            i = str.size();
        }

        for (int i = 1; i < N; i++) {
            v[i] += v[i-1];
        }
        v.insert(v.begin(), 0);

        int idx = 0;
        int seq[] = {5, 12, 17, 24, 31};
        while (1) {
            bool flag = true;
            int idx_ = idx;
            for (int i = 0; flag && i < 5; i++) {
                while (idx_ < N && v[idx_] - v[idx] < seq[i]) {
                    idx_++;
                }
                if (v[idx_] - v[idx] != seq[i]) flag = false;
            }
            if (flag) break;
            idx++;
            if (N <= idx) {
                flag = false;
                break;
            }
        }

        cout << idx + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3132
N,K = map(int,input().split(' '))
X = list(map(int,input().split(' ')))

MIN_SUM = float('inf')
for i in range(N-K+1):
  MIN_SUM = min(MIN_SUM,X[i+K-1]-X[i]+abs(X[i]),X[i+K-1]-X[i]+abs(X[i+K-1]))
print(MIN_SUM)
  
    
    

Measured memory_bytes: 14384
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> n = new ArrayList<Integer>();
		ArrayList<Integer> x = new ArrayList<Integer>();
		for(int i = 0; ; i++) {
			int tmpn = sc.nextInt();
			int tmpx = sc.nextInt();
			int count = 0;
			if(tmpn == 0 && tmpx == 0)break;
			else {
				n.add(tmpn);
				x.add(tmpx);
			}
			for(int j = 1; j <= n.get(i)-2; j++) {
				for(int k = j+1; k <= n.get(i)-1; k++) {
					for(int l = k+1; l <= n.get(i); l++){
						if(j+k+l == x.get(i))count++;
					}
				}
			}
			System.out.println(count);
		}

	}

}



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

using namespace std;


void bubble_sort(pair<int, char> *bs, int N) {
  for (int i = 0; i < N; i++) {
    for (int j = N-1; j > i; j--) {
      if(bs[j].first < bs[j-1].first) {
        swap(bs[j], bs[j-1]);
      }
    }
  }
}

void selection_sort(pair<int, char> *ss, int N) {
  for (int i = 0; i < N; i++) {
    int mini = i;
    for (int j = i; j < N; j++) {
      if(ss[j].first < ss[mini].first) {
        mini = j;
      }
    }
    if(mini != i) swap(ss[mini], ss[i]);
  }
}

void show(pair<int, char> *a, int N) {
  for (int i = 0; i < N; i++) {
    cout << a[i].second << a[i].first << (i == N-1 ? "\n": " ");
  }
}

int main() {
  int N;
  pair<int, char> bs[100];
  pair<int, char> ss[100];

  cin >> N;
  for (int i = 0; i < N; i++) {
    string str; cin >> str;
    bs[i] = make_pair(str[1] - '0', str[0]);
    ss[i] = make_pair(str[1] - '0', str[0]);
  }

  bubble_sort(bs, N);
  selection_sort(ss, N);

  show(bs, N);
  cout << "Stable" << endl;
  show(ss, N);

  bool f = true;
  for (int i = 0; i < N; i++) {
    if(bs[i].second != ss[i].second) f = false;
  }

  cout << ( f ? "Stable" : "Not stable" ) << endl;
}



Measured memory_bytes: 3156
#include<stdio.h>
char a[50030];
void sosu();
main(){
  int n,i;
  sosu();
  while(scanf("%d",&n)!=EOF){
    int max=0,min=0;
    for(i=n-1;i>1;i--){
      if(a[i]!=1){
	min=i;
	break;
      }
    }
    for(i=n+1;i<50030;i++){
      if(a[i]!=1){
	max=i;
	break;
      }
    }
    printf("%d %d\n",min,max);
  }
  return 0;
}





void sosu(){
  int i,j;
  a[0]=1;
  a[1]=1;
  for(i=2;i*i<50030;i++){
    if(a[i]!=1){
      for(j=i+1;j<=50030;j++){
	if(j%i==0){
	  a[j]=1;
	}
      }
    }
  }
}

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

long long m,k;

int main(){
    	cin >> m >> k;
    	if(k >= (1 << m)){
     	cout << -1;
        	return 0;
    	}
    	if(k == 0){
     	for(int i = 0; i <= (1 << m) - 1; i++) cout << i << " " << i << " ";
        	return 0;
    	}
    	int x = 0;
    	for(int i = 0; i <= (1 << m) - 1; i++){
    		if(i != k) x ^= i;
    	}
    	if(x != k){
    		cout << -1;
    		return 0;
    	}
    	cout << k << " ";
    	for(int i = 0; i < (1 << m); i++){
        	if(i != k){
          	cout << i << " ";
     	}
	}
    	cout << k << " ";
    	for(int i = (1 << m) - 1; i >= 0; i--){
     	if(i != k){
          	cout << i << " ";
        	}
	}
	return 0;
}

Measured memory_bytes: 1792
A = list(input())
B = list(input())
C = list(input())
tmp = A.pop(0)
while True:
    if tmp == 'a':
        if len(A) == 0:
            print('A')
            exit(0)
        tmp = A.pop(0)
    elif tmp == 'b':
        if len(B) == 0:
            print('B')
            exit(0)
        tmp = B.pop(0)
    else:
        if len(C) == 0:
            print('C')
            exit(0)
        tmp = C.pop(0)

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

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

    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    char board[N + 1];
    board[0] = '.';
    for (int i = 1; i <= N; ++i) {
        cin >> board[i];
    }

    int pre = false;
    for (int i = A; i <= max(C, D); ++i) {
        bool cur = board[i] == '#';
        if (cur && pre) {
            cout << "No" << '\n';
            return 0;
        }
        pre = cur;
    }

    if (C < D) {
        cout << "Yes" << '\n';
        return 0;
    }

    bool pre_pre = false;
    pre = false;
    int space = 0;
    for (int i = B - 1; i <= D + 1; ++i) {
        // if ()
        bool cur = board[i] == '.';
        if (pre_pre && pre && cur ) {
            cout << "Yes" << '\n';
            return 0;
        }
        pre_pre = pre;
        pre = cur;
    }

    cout << "No" << '\n';
    return 0;

}


Measured memory_bytes: 512
#include <stdio.h>


int main(void){
	int N, i;
	double ans;
	
	scanf("%d", &N);
	int v[N];	
	
	for(i=0;i<N;i++){
		scanf("%d", &v[i]);
	}
  
	int v_min=1001, cnt_1, cnt_2, v_sort[N];
	for(cnt_1=0;cnt_1<N;cnt_1++) {
		for (cnt_2=0;cnt_2<N;cnt_2++) {
			if (v_min>v[cnt_2]){
				v_min=v[cnt_2];
              	i = cnt_2;
              	//printf("v_min=%d\ni=%d\n", v_min, i);
			}
        }
      	v[i]=10000;
      	//printf("%d %d %d %d %d %d\n", v_min, v[0], v[1], v[2], v[3], v[4]);
		v_sort[cnt_1]=v_min;
		v_min=1001;
	}
	
	//printf("v_sort0=%d\nv_sort1=%d", v_sort[0], v_sort[1]);
	ans = (v_sort[0]+v_sort[1]);
  	ans = ans/2;
	for(i=2;i<N;i++){
		ans = (ans + v_sort[i])/2;
	}
	printf("%lf", ans);
	return 0;
}		

Measured memory_bytes: 128
//https://atcoder.jp/contests/exawizards2019/tasks/exawizards2019_c
//C - Snuke the Wizard
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-2.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N,Q; cin>>N>>Q;
    string s; cin>>s;
    struct Info{
        char c;
        char d;
        ll ofs=0;
    };
    vector<Info> tdq(Q);
    for(auto&& tq:tdq){
        cin>>tq.c>>tq.d;
        tq.ofs = tq.d=='L'?-1:1;
    }

    auto check_t = [&](ll v,ll pos){ //vが到達するか?
        for(const auto& tq:tdq){
            auto c=s.at(v);
            if (c==tq.c) v+=tq.ofs;
            if (v==pos) return true;
            if (v<0||v>=s.size()) break;
        }
        return false;
    };
    auto check_func = [&](ll pos,bool is_flag){
        ll lb=0,ub=s.size();
        while(ub-lb>1){
            ll mid=(lb+ub)/2;
            if(check_t(mid,pos)==is_flag){
                ub=mid;
            } else {
                lb=mid;
            }
            dump(mid,lb,ub);
        }
        return ub;
    };
    // REP(i,s.size()){
    //     dump(i,check_t(i,-1));
    //     dump(i,check_t(i,s.size()));
    // }

    ll r=check_func(s.size(),true)-1;
    dump(r);
    ll l=check_func(-1,false);
    dump(l);
    //assert(r>=l);
    cout<<r-l+1<<endl;
    return 0;
}
int main_() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N,Q; cin>>N>>Q;
    string s; cin>>s;
    vector<ll> num(N,1);
    unordered_map<char,vector<ll>> c_pos;    
    REP(i,s.size()){
        auto c=s[i];
        c_pos[c].push_back(i);
    }

    REP(i,Q){
        char t,d; cin>>t>>d;
        ll ofs=d=='L'?-1:1;
        for(auto& pos :c_pos[t]){
            if(pos+ofs>=0&&pos+ofs<num.size()) num[pos+ofs]+=num[pos];
            num[pos]=0;
        }
    }
    ll ans=accumulate(num.begin(),num.end(),0LL);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <string>

int main() {
  std::string N;  std::cin>>N;
  long long K;  std::cin>>K;
  for (int i = 0; i < N.length(); ++i) {
    if (N[i] != '1' or i+1 == K) {
      std::cout<<N[i]<<"\n";
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;
using ll = long long;

int main(void)
{
    int k, n;
    cin >> k >> n;
    int a[n];
    REP(i, n)
    {
        cin >> a[i];
    }
    int diffmax = 0;

    for (int i = 0; i < n; i++)
    {
        int diff;
        if (i != n - 1)
        {
            diff = a[i + 1] - a[i];
        }
        else
        {
            diff = k - a[n - 1] + a[0];
        }
        diffmax = max(diff, diffmax);
    }
    cout << k - diffmax << endl;
}

Measured memory_bytes: 1024
//In The Name of Allah
#include <bits/stdc++.h>

using namespace std;

const int N = 3010;

double dp[N][N], p[N], ans = 0;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i ++)
        cin >> p[i];
    dp[0][0] = 1;
    for (int i = 1; i <= n; i ++)
    {
        for (int j = 0; j <= i; j ++)
        {
            if (j)
                dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i];
            else
                dp[i][j] = dp[i - 1][j] * (1 - p[i]);
        }
    }
    for (int i = n / 2 + 1; i <= n; i ++)
        ans += dp[n][i];
    cout << setprecision(10) << ans;
    return 0;
}


Measured memory_bytes: 69120
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
using namespace std;

int main(){
  vector<int> city1, city2,cityadd;
  int n,m,temp1,temp2;
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> temp1 >> temp2;
    city1.push_back(temp1);
    city2.push_back(temp2);
  }
  for(int i=0;i<n;i++)cout << count(city1.begin(),city1.end(),i+1) + count(city2.begin(),city2.end(),i+1) << endl;
  
}

Measured memory_bytes: 256
x, y, z, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ABC = []
for x, a in enumerate(A):
    if x+1 > k:
        break
        
    for y, b in enumerate(B):
        if (x+1)*(y+1) > k:
            break
    
        for z, c in enumerate(C):
            if (x+1)*(y+1)*(z+1) > k:
                break
            
            ABC.append(a+b+c)
            
ABC.sort(reverse=True)
ABC = ABC[:k]

for abc in ABC:
    print(abc)

Measured memory_bytes: 8708
n,m = map(int,input().split(' '))
i = 0
numbers = []
while i < m:
    l0 = list(map(int,input().split(' ')))
    p = 1
    n0 = 0
    while p < len(l0):
        n0 += pow(10,l0[p]-1)
        p += 1
    numbers.append(n0)
    i += 1
P = list(map(int,input().split(' ')))
test = [int(bin(i)[2:]) for i in range(pow(2,n))]
counter = 0
for t in test:
    q = 0
    while q < m:
        if str(t + numbers[q]).count('2')%2 == P[q]:
            q += 1
        else:
            break
    if q == m:
        counter += 1
print(counter)

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

int gcd(int big,int small){
	if(big>small)swap(big,small);
	int amari = big%small;
	while(amari!=0){
		big = small;
		small = amari;
		amari = big%small;
	}
	return small;
}
int main(void){
	int N,ans=0,temp;
	cin >> N;
	int A[N];
	for(int i=0;i<N;i++)cin >>A[i];
	int leftgcd[N];//左からi番目までのgcd
	int rightgcd[N];//右からi番目までのgcd
	leftgcd[0]=A[0];
	rightgcd[0]=A[N-1];
	for(int i=1;i<N;i++){
		leftgcd[i] = gcd(leftgcd[i-1],A[i]);
	}
	for(int i=1;i<N;i++){
		rightgcd[i] = gcd(rightgcd[i-1],A[(N-1)-i]);
	}
	//あとは地点iから左のgcdと右のgcdのgcdを求める
	for(int i=0;i<=N-1;i++){
		if(i==0){
			temp = rightgcd[N-1-1];
		}else if(i==(N-1)){
			temp = leftgcd[N-2];
		}else{
			temp= gcd(leftgcd[i-1],rightgcd[N-2-i]);
		}
		if(temp>ans)ans=temp;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  vector<bool> f(n, true);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (h[a] >= h[b]) f[b] = false;
    if (h[a] <= h[b]) f[a] = false;
  }

  int ans = 0;
  rep(i, n) {
    if (f[i]) ans++;
  }
  cout << ans << '\n';







  
  return 0;
}

Measured memory_bytes: 3712
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, C: int, B: "List[int]", A: "List[List[int]]"):
    import numpy as np
    print(np.sum(np.dot(A, B) > -C))
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    B = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    A = [[int(next(tokens)) for _ in range(M)]
         for _ in range(N)]  # type: "List[List[int]]"
    solve(N, M, C, B, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12532
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long ull;
 
int main()
{
    ull n, k;
    cin >> n >> k;
 
    if (k == 0)
    {
        cout << n*n << endl;
        return 0;
    }
    
    ull count = 0;
    int last;
 
    for (ull b = k+1; b <= n; b++)
    {
        last = (n%b)-k+1;
        if (last < 0) last = 0;
        count += ((n/b) * (b-k)) + (ull)last;
    }
 
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int A, N;
  cin >> N;
  cin >> A;
  if (N % 500 <= A) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

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

	for(int i=1; i<10; i++){
		if(N%i==0 && N/i<10){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

bitset<100000> bs;
vi primes;
LLI s[100000];
map<vlli,int> M;
int main() {
    int i,j;
    bs.set();
    bs[0] = bs[1] = 0;
    for (i = 2; i < 2200; i++) {
        if (bs[i]) {
            for (j = 2*i; j < 2200; j += i) bs[j] = 0;
            primes.pb(i);
        }
    }

    int N;
    scanf("%d",&N);
    for (i = 0; i < N; i++) scanf("%lld",&s[i]);

    for (i = 0; i < N; i++) {
        vlli fac;
        for (j = 0; (j < primes.size()) && ((LLI) primes[j]*primes[j] <= s[i]); j++) {
            if ((s[i] % primes[j]) == 0) {
                int c = 0;
                while ((s[i] % primes[j]) == 0) s[i] /= primes[j],c++;
                c %= 3;
                if (c == 1) fac.pb(primes[j]);
                else if (c == 2) fac.pb(primes[j]),fac.pb(primes[j]);
            }
        }
        if (s[i] > 1) {
            LLI x = sqrt(s[i])+1e-9;
            if (x*x == s[i]) fac.pb(x),fac.pb(x);
            else fac.pb(s[i]);
        }
        printArr(fac,fac.size());
        M[fac]++;
    }
    int ans = N;
    for (auto it = M.begin(); it != M.end(); it++) {
        vlli fac = it->first,fac2;
        if (fac.empty()) ans -= it->second-1;
        else {
            j = 0;
            while (j < fac.size()) {
                if ((j < (int) fac.size()-1) && (fac[j] == fac[j+1])) fac2.pb(fac[j]),j += 2;
                else fac2.pb(fac[j]),fac2.pb(fac[j]),j++;
            }
            if (M.count(fac2) && (fac2 < fac)) ans -= min(it->second,M[fac2]);
        }
    }
    printf("%d\n",ans);

    return 0;
}



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

int main() {
	int n;
	cin>>n;
	map<int,int> m;
	for(int i=0;i<n;i++){
	    int c;
	    cin>>c;
	    m[c]++;
	}
	vector<int> v;
	for(auto it:m){
	    v.push_back(it.first);
	}
	n=v.size();
	int count=0;
	for(int i=0;i<n-2;i++){
	    for(int j=i+1;j<n-1;j++){
	        for(int k=j+1;k<n;k++){
	           if(v[k]<(v[i]+v[j])){
	               count+=(m[v[k]]*m[v[i]]*m[v[j]]);
	               //cout<<v[i]<<" "<<m[v[i]]<<" ";
	           } 
	           else{
	               break;
	           }
	        }
	    }
	}
	cout<<count;
	return 0;
}


Measured memory_bytes: 3632
program widespread
  implicit none
  integer :: n, i
  integer(8) :: a, b, h(100000), btm, top, mid, t, s
  h = 0_8
  read(*,*) n, a, b
  do i = 1, n
    read(*,*) h(i)
  end do
  btm = 0_8
  top = maxval(h(1:n))/b+1_8
  do while (top-btm.gt.1_8)
    mid = (top+btm)/2_8
    s = b*mid
    t = 0_8
    do i = 1, n
      if (h(i).le.s) cycle
      t = t + (h(i)-s)/(a-b)
      if (mod(h(i)-s,a-b).ne.0_8) t = t + 1_8
    end do
    if (t.gt.mid) then
      btm = mid
    else
      top = mid
    end if
  end do
  write(*,'(i0)') top
  stop
end program widespread

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

using namespace std;

long long dp[101][100004];
int weight[101];
long long value[101];

int main () {
	int n,W;
	cin>>n>>W;
	for(int i=1;i<=n;i++){
		cin>>weight[i]>>value[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=W;j++){
			if(j<weight[i]) dp[i][j]=dp[i-1][j];
			else dp[i][j]=max(dp[i-1][j],dp[i-1][j-weight[i]]+value[i]);
		}
	}
	cout<<dp[n][W];
	



return 0;
}



Measured memory_bytes: 78336
#include<stdio.h>

int _abs(int x){return x<0?-x:x;}

int main(){
	
	int n,i,x,k=0x3f3f3f3f,cnt=0;
	long long ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&x);
		if(x<0)cnt++,ans-=x;
		else ans+=x;
		if(_abs(x)<k)k=_abs(x);
	}
	if(cnt&1)printf("%lld",ans-2*k);
	else printf("%lld",ans);
	return 0;
}
		

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	double v, y, t;
	while (cin >> v){
		t = v / 9.8;
		y = 4.9 * t * t;
		cout << (int)((y + 5) / 5) + 1 << endl;
	}
}

Measured memory_bytes: 3044
n=int(input())
l=list(map(int,input().split()))
a=l[0]
for i in range(1,n):
    a*=l[i]
    if a>10**18:
        break
if a>10**18 and l.count(0)==0:
    print(-1)
elif l.count(0)>0:
    print(0)
else:
    print(a)

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

using namespace std;

int main(){

        typedef pair<string, int> p;
        queue<p> que;

        string name;
        int n, q, time, total = 0;

        cin >> n >> q;

        for(int i = 0; i < n; ++i){
                cin >> name >> time;
                que.push(p(name, time));
        }

        while(!que.empty()){

                p process = que.front(); que.pop();
                string pname = process.first;
                int ptime = process.second;

                if(ptime > q){

                        total += q;
                        ptime -= q;
                        que.push(p(pname, ptime));

                } else {

                        total += ptime;
                        cout << pname << " " << total << endl;

                }
        }
}

Measured memory_bytes: 4404
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
struct node
{
    node() {};
    node(int i, int n, int* xs) : id {i}, ns {vector<int>(xs, xs+n)}, d {-1} {};
    int id;
    vector<int> ns;
    int d;
};

void bfs(node* xs, int n, int st)
{
    queue<int> que {};
    bool used[n+1];
    for(int i = 0; i <= n; ++i){
        used[i] = false;
    }
    que.push(st);
    xs[st].d = 0;
    used[st] = true;
    while(que.size())
    {
        int p = que.front();
        que.pop();
        vector<int> ns = xs[p].ns;
        for(auto x : ns)
        {
            if(used[x])
            {
                continue;
            }
            xs[x].d = xs[p].d + 1;
            used[x] = true;
            que.push(x);
        }
    }
}

int main()
{
    int n;
    cin >> n;
    node graph[n+1];
    for(int i = 0; i < n; ++i)
    {
        int id;
        int m;
        cin >> id >> m;
        int xs[m];
        for(int j = 0; j < m; ++j)
        {
            cin >> xs[j];
        }
        graph[id] = node(id, m, xs);
    }
    bfs(graph, n, 1);
    for(int i = 1; i <= n; ++i)
    {
        cout << i << ' ' << graph[i].d << endl;
    }
}

Measured memory_bytes: 1224
# -*- coding: utf-8 -*-

R, G, B, N = map(int, input().split())

counter = 0
for r in range(int(N/R) + 1):
    for g in range(int(N/G) + 1):
        t = R*r + G*g
        if t > N:
            break
        if (N - t) % B == 0:
            counter += 1

print(counter)

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

int main(){
	int n; cin >> n; std::vector<long> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n - 1; i++) a[i + 1] += a[i];
	
	std::map<long, std::vector<int>> mp;
	for(int i = 0; i < n; i++){
		mp[a[i]].push_back(i);
	}
	
	long ans = 0;
	for(int i = 0; i < n; i++){
		int k = upper_bound(begin(mp[a[i]]), end(mp[a[i]]), i) - begin(mp[a[i]]);
		
		ans += mp[a[i]].size() - k;
	}
	
	for(int i = 0; i < n; i++) if(!a[i]) ans++;
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 23680
import std;
import core.bitop;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "g");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    long a, b, c, d;
    scan(a, b, c, d);
    writeln((b - a + 1) - (b / c - (a - 1) / c) - (b / d - (a - 1) / d) + (b / (c / gcd(c,
            d) * d) - (a - 1) / (c / gcd(c, d) * d)));
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
typedef long long LL;
const int N = 1e5;
LL h[N];
LL n;
LL A, B;
LL ceil_div(LL a, LL b)
{
	return a/b + (a%b==0 ? 0 : 1);
}
bool is_possible(LL kaboom)
{
	LL allocatable_kaboom = kaboom;
	for(int i = 0; i < n; i++)
		if(kaboom*B < h[i])
		{
			LL needed_kaboom = ceil_div(h[i]-kaboom*B,A-B);
			if(allocatable_kaboom >= needed_kaboom)
				allocatable_kaboom -= needed_kaboom;
			else
				return false;
		}
	return true;
}
LL bs() //find the least kaboom for which it is possible
{
	LL L = 0;
	LL R = 5e9;
	while(R-L > 10)
	{
		LL M = (L+R)/2;
		if(is_possible(M))
			R = M;
		else
			L = M;
	}
	for(LL ans = L; ans <= R; ans++)
		if(is_possible(ans))
			return ans;
	return -1;
}
int main()
{
	cin >> n >> A >> B;
	for(int i = 0; i < n; i++)
		cin >> h[i];
	cout<<bs()<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef long long ll;
typedef double ld;
typedef pair<int,int> p2;
typedef pair<p2,int> p3;
typedef vector<ll> vi;
const ll Mod = 7 + 1e9;
const ll INF32 = 5 + 2e9;
const ll INF64 = 5 + 1e18;
const ll MAX = 5+ 3e3;

int N;
ld dp[MAX][MAX],p[MAX];

int main()
{
    cin >> N;
    for(int i=1; i<=N; i++)
        cin >> p[i];
    dp[0][0] =1;
    for(int i=1;i<=N;i++)
        dp[i][0] = (1-p[i])* dp[i-1][0];
    for(int i=1; i<=N; i++)
        for(int j=1; j<=i; j++)
        {
            if( j < i )
                dp[i][j] = (1-p[i])*dp[i-1][j];
            dp[i][j] += p[i]*dp[i-1][j-1];
        }
    ld ans = 0;
    for(int i=N/2+1;i<=N;i++)
        ans += dp[N][i];
    cout << setprecision(10) << fixed << ans << endl;
//    for(int i=1;i<=N;i++,cout << endl)
//        for(int j=1;j<=N;j++)
//        cout << setprecision(2) << dp[i][j] << ' ';
    return 0;
}


Measured memory_bytes: 69120
#include <iostream>
using namespace std;
int main(int argc,char**argv)
{
	string s,t;
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!=t[i])
		ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


bool cmp(pair<int,int>p,pair<int,int>q) {
    // return p.first>q.first;//descending by first
    // return p.first<q.first;//ascending by first
    // return p.second>q.second;//descending by second
    return p.second<q.second;//ascending by second
}

// bool cmp(int p,int q) {
    // return p>q;//descending
    // return p<q;//ascending
// }

int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]) {
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
    // (det)?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3604
N = int(input())
S = []
ABcnt = 0
topABcnt = 0
topBbtmA = 0
topBbtmNO = 0
topNObtmA = 0
for _ in range(N):
  s = input()
  nowABcnt = s.count('AB')
  ABcnt += nowABcnt
  if s[0:2]=='AB':
    topABcnt += 1
  if s[0]=='B':
    if s[-1]=='A': topBbtmA += 1
    else: topBbtmNO += 1
  elif s[-1]=='A':
    topNObtmA += 1
  if nowABcnt!=0 or s[0]=='B' or s[-1]=='A': S.append(s)

ans = 0


ans += min(topBbtmNO, topNObtmA)
firstSurvivorCnt = max(topBbtmNO, topNObtmA) - ans

nikaisenGet = min(firstSurvivorCnt, topBbtmA)
ans += nikaisenGet

topBbtmA -= nikaisenGet
if ans == 0: ans += max(0, topBbtmA-1)
else: ans += topBbtmA #topBbtmAが生き残ってたら足す
#最後のtopBbtmAはペアを作れない

print(ans+ABcnt)

Measured memory_bytes: 45164
#include<iostream>
#include<algorithm>
#define max 100000
using namespace std;

int A[max];

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

int main()
{
	int n, i;
	cin >> n;
	for (i = 0; i < n; i++)
		cin >> A[i];

	int x=partition( 0, n-1);
	for (i = 0; i < n; i++)
	{
		if (i)cout << " ";
		if (i == x)cout << "[" << A[i] << "]";
		else cout << A[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3492
n = gets.to_i
evi = n.times.map do
  a = gets.to_i
  a.times.map{gets.split.map(&:to_i)}
end

ans = 0
(2**n).times do |bit|
  cnt = 0
  n.times do |i|
    if bit[i] == 1
      if evi[i].all? {|x,y| bit[x-1] == y}
        cnt += 1
      else
        cnt = 0
        break
      end
    end
  end
  ans = cnt if cnt > ans
end

puts ans

Measured memory_bytes: 1788
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n, m = MAP()
a = LIST()
l = 1
num2 = 0
for i in range(n):
    if i == 0:
        ibin = bin(a[i])[2:]
        for j in reversed(range(len(ibin))):
            if ibin[j] == '1':
                num2 = len(ibin) - j - 1
                break
        l = a[i]
    else:
        tmp = int(bin(a[i] >> num2)[2:], 2) #2で割る
        if tmp * (2 ** num2) != a[i] or tmp % 2 == 0:
            print(0)
            exit()
        l = lcm(l, tmp)
    debug(l, num2)
debug(l)
ans = (2 * m // l + 1) // 2
print(ans)

Measured memory_bytes: 85100
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
using namespace std;




int main ( ){

    long long n;
    cin>>n;
  vector<int> vec;
  int t;
  for(int i = 0 ;i<n;i++){
      scanf("%d",&t);
        vec.push_back(t);
  }
    ll sum =0;
    for(int i = 0 ; i < n-1;i++){
        for(int j = i+1 ;j < n ;j++){
            sum+=vec[i]*vec[j];
        }
    }
cout << sum;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
    ll ans=1;
    for(int i=1; i<=n; i++)
        ans*=a;
    return ans;
}

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

    ll n,ans=0;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>A[i];
    }
    for(int i=1; i<n; i++)
    {
        if(A[i+1]<A[i])
        {
            ans+=A[i]-A[i+1];
            A[i+1]=A[i];
        }
    }
    cout<<ans<<endl;

    return 0;
}



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

using namespace std;

typedef long long ll;

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

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

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

    if (((int) S.size()) % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }

    bool b = true;
    bool ok = true;

    for (auto &c : S) {
        if (b) {
            if (c != 'h') {
                ok = false;
                break;
            }
        } else {
            if (c != 'i') {
                ok = false;
                break;
            }
        }

        b = !b;
    }

    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

int main(){
	int n, m;
	while (cin >> n >> m, n){
		vector<int> w, h;
		int ws = 0, hs = 0;
		h.push_back(0);
		for (int i = 0; i < n; i++){
			int hi;
			cin >> hi;
			h.push_back(hs += hi);
		}
		w.push_back(0);
		for (int i = 0; i < m; i++){
			int wi;
			cin >> wi;
			w.push_back(ws += wi);
		}
		vector<int> diag(ws + hs + 1);
		for (int unsigned i = 0; i < h.size(); i++){
			for (int unsigned j = 0; j < w.size(); j++){
				diag[h[i] + w[j]]++;
			}
		}
		int ret = 0;
		for (int unsigned i = 0; i < diag.size(); i++){
			ret += diag[i]*(diag[i]-1)/2;
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 5692
#include <bits/stdc++.h>
using namespace std;
string s[302];
int a[302][302];
int f[302][302];
int n, m;
int calc(int r, int c, int len) {
    if (len < 0) {
        return 0;
    }
    int lsum = 0;
    if (r - 1 > 0 && c - 1 > 0) {
        lsum += f[r - 1][c - 1];
    }
    if (r + len >= n || c + len >= m) {
        len = min(n - r,  m - c);
    }
    int rsum = 0;
    if (r + len >= 1 && c + len >= 1) {
        rsum = f[r + len][c + len];
    }
    return rsum - lsum;
}

void go(int r, int c, long long &ans, int tp) {
    int len = min(n - r, m - c);
    for (int i = 0; i < len; i++) {
        for (int j = i + 1; j <= len; j++) {
            if (a[r + i][c + i] == 0) continue;
            if (a[r + j][c + j] == 0) continue;
            ans += calc(r + j - 2 * (j - i) + tp, c + j + tp, j - i - 2 * tp);
            ans += calc(r + j + tp, c + j - 2 * (j - i) + tp, j - i - 2 * tp);

        }
    }
}

void solve(long long &ans, int tp) {
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            f[i][j] = a[i][j] + f[i - 1][j - 1];
        }
    }
    for (int i = 1; i <= n; i++) {
        go(i, 1, ans, tp);
    }
    for (int i = 2; i <= m; i++) {
        go(1, i, ans, tp);
    }

}
int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> s[i];
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s[i][j - 1] == '#') a[i][j] = 1;
        }
    }
    long long ans = 0;
    solve(ans, 0);
    for (int i = 1; i <= n; i++) {
        reverse(a[i] + 1, a[i] + m + 1);
    }
    solve(ans, 1);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
template<typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val){ //usage: int dp[10][10]; Fill(dp,INF);
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9 LLの時はLLONG_MAX
/*const int MAXN = 100001;

struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};*/

//-----Template---------
LL n,x;

int main(){
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    cin>>n>>x;
    LL ans=0;
    LL a=x;
    LL b=n-x;
    if(a<b)swap(a,b);

    ans+=n;
    while(b!=0){
        ans+=b*2*(a/b);
        LL tmp=a%b;
        a=b; b=tmp;
    }
    ans-=a;
    cout<<ans<<endl;

}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;  typedef pair<ll,ll> pii;
typedef vector<int> VI; typedef vector<ll> VL;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, a;
	cin >>n;
	
	VI cnt(100100);
	rep(i, n){ cin >>a; cnt[a]++;}
	
	int ans = 0;
	rep(i, 100001){
		ans = max(ans, cnt[i]+cnt[i+1]+cnt[i+2]);
	}
	
	
	cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 640
l, r = [int(e) for e in input().split()]
m = 2019
for i in range(l, r):
  ir = i % 2019
  for j in range(i + 1, r + 1):
    t = (ir * j) % 2019
    if t < m:
      m = t
    if m == 0:
      break
  if m == 0:
    break
print(m)

Measured memory_bytes: 39024