akhauriyash/Code-Regression huggingface dataset:
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (win, osx, linux)
 * Author: step_by_step
 * Time: 2020-03-19 17:35:03
**/

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

vector<ll> get_divs(ll n) {
    vector<ll> res;
    for (ll x = 1; x * x <= n; x++) {
        if (n % x == 0) {
            res.push_back(x);
            if (x != n / x) {
                res.push_back(n / x);
            }
        }
    }
    return res;
}

int main()
{
    //freopen("circus.in", "r", stdin);
    //freopen("circus.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    ll n;
    cin >> n;
    vector<ll> divs = get_divs(n - 1);
    set<ll> ans;
    for (int i : divs) {
        if (i != 1) {
            ans.insert(i);
        }
    }
    divs = get_divs(n);
    for (ll x : divs) {
        if (x == 1) {
            continue;
        }
        ll val = n;
        while (val % x == 0) {
            val /= x;
        }
        if (val % x == 1) {
            ans.insert(x);
        }
    }
    cout << sz(ans) << "\n";
    return 0;
}



Measured memory_bytes: 384
#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() {
  vector<int> x(5);
  rep(i, 5) cin >> x[i];
  
  rep(i, 5) {
    if (x[i] == 0)
      cout << i + 1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3516
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

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

    vector<int> H(N, 0);
    for(auto &&item : H) cin >> item;
        
    vector<int> C(N, 2147483647);
    C.at(0) = 0;
    for(int i = 0; i < N - 1; i++)
    {
        for(int j = i + 1; j < min(i + K + 1, N); j++)
        {
            C.at(j) = min( C.at(j), C.at(i) + abs(H.at(j) - H.at(i)) );
        }
    }
    cout << C.at(N-1) << endl;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program {
    internal static void Main(string[] args) {
        var c = ReadLine().ToCharArray().Select(s => int.Parse(s.ToString())).ToList();
        var ope = new string[] { "+", "-" };
        for (int i = 0; i <= 1; i++) {
            var res1 = Calc(i, c[0], c[1]);
            for (int j = 0; j <= 1; j++) {
                var res2 = Calc(j, res1, c[2]);
                for (int k = 0; k <= 1; k++) {
                    var res3 = Calc(k, res2, c[3]);
                    if (res3 == 7) {
                        WriteLine(c[0] + ope[i] + c[1] + ope[j] + c[2] + ope[k] + c[3] + "=7");
                        return;
                    }
                }
            }
        }
     }

    static int Calc(int i, int a, int b) {
        if (i == 0) {
            return a + b;
        } else {
            return a - b;
        }
    }
}

Measured memory_bytes: 11348
#include<stdio.h>
int main(void)
{
	int n;
	int cnt[7];
	int i,j;
	double sin;
	
	scanf("%d",&n);
	for(i=1;i<=6;i++){
		cnt[i]=0;
	}
	for(i=1;i<=n;i++){
		scanf("%lf",&sin);
		if(sin<165.0){
			cnt[1]++;
		}
		else if(sin<170.0){
			cnt[2]++;
		}
		else if(sin<175.0){
			cnt[3]++;
		}
		else if(sin<180.0){
			cnt[4]++;
		}
		else if(sin<185.0){
			cnt[5]++;
		}
		else if(sin>=185.0){
			cnt[6]++;
		}
	}
	for(i=1;i<=6;i++){
		printf("%d:",i);
		for(j=1;j<=cnt[i];j++){
			printf("*");			
		}
	printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1068
//****************************//
/**********  main *************/
//****************************//
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, n) for(i = 0; i < n; i++)
#define FOR(i, a, b) for(i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())

double pi = 3.141592653589793;

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

int main() {

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

    int n,x,t;
    int count;
    int res;
    bool flag;

    cin >> n >> x >> t;

    flag = true;
    while(flag){
        n = n-x;
        count++;

        if(n<=0){
            break;
        }
    }

    res = count * t;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3648
use proconio::input;

fn main() {
    input! {
        a: f64,
        b: f64,
        h: f64,
        m: f64,
    }

    let rad = std::f64::consts::PI * 2.0
         * ((h / 12.0) + m / 60.0 / 12.0 - m / 60.0);

    let ans2 = a*a + b*b - 2.0 * a * b * rad.cos();

    println!("{:.20}", ans2.sqrt());
}


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

static const int INF=1e9;

int main(){
    int H,W,K; cin >> H >> W >> K;
    char s[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> s[i][j];
        }
    }
    int ans=INF;
    for(int bit=0;bit<(1<<H-1);bit++){
        int flg=__builtin_popcount(bit);
        int tmp=flg;
        int cnt[flg+1]={};
        bool suc=false;
        for(int j=0;j<W;j++){
            int now=0;
            for(int i=0;i<H;i++){
                if(s[i][j]=='1') cnt[now]++;
                if(bit&(1<<i)) now++;
            }
            int max_el=0;
            for(int i=0;i<flg+1;i++){
                max_el=max(cnt[i],max_el);
            }
            if(max_el>K){
                if(suc){
                    tmp=1e9;
                    break;
                }
                tmp++;
                for(int i=0;i<flg+1;i++){
                    cnt[i]=0;
                }
                j--;
                suc=true;
                continue;
            }
            suc=false;
        }
        ans=min(ans,tmp);
    }
    cout << ans << endl;
}

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

using namespace std;

const int N = 2e5 + 5;
const int mod = 998244353;

int pw[N], n, q, inv9;

int binPow (int x, int y) {
    int ans = 1;
    while (y > 0) {
        if (y & 1) ans = 1LL * ans * x % mod;
        x = 1LL * x * x % mod;
        y >>= 1;
    }

    return ans;
}

struct SegmentTree {
    int node[N << 2], lz[N << 2];
    void init (int i, int l, int r) {
        if (l == r) {
            node[i] = pw[n - l];
            lz[i] = 0;
            return;
        }

        int mid = l + r >> 1;
        init(i << 1, l, mid);
        init(i << 1 | 1, mid + 1, r);
        node[i] = (node[i << 1] + node[i << 1 | 1]) % mod;
        lz[i] = 0;
    }

    void dolazy (int i, int l, int r) {
        if (lz[i]) {
            node[i] = 1LL * lz[i] * (pw[n - l + 1] - pw[n - r]) % mod * inv9 % mod;
            if (node[i] < 0) node[i] += mod;
            if (l != r) {
                lz[i << 1] = lz[i];
                lz[i << 1 | 1] = lz[i];
            }

            lz[i] = 0;
        }
    }

    void update (int i, int l, int r, int a, int b, int val) {
        dolazy(i, l, r);
        if (l > r || a > r || b < l) return;
        if (a <= l && r <= b) {
            node[i] = 1LL * val * (pw[n - l + 1] - pw[n - r]) % mod * inv9 % mod;
            if (node[i] < 0) node[i] += mod;
            if (l != r) {
                lz[i << 1] = val;
                lz[i << 1 | 1] = val;
            }

            return;
        }

        int mid = l + r >> 1;
        update(i << 1, l, mid, a, b, val);
        update(i << 1 | 1, mid + 1, r, a, b, val);
        node[i] = (node[i << 1] + node[i << 1 | 1]) % mod;
    }

    int query (int i, int l, int r, int a, int b) {
        if (l > r || a > r || b < l) return 0;
        dolazy(i, l, r);
        if (a <= l && r <= b) return node[i];

        int mid = l + r >> 1;
        return (query(i << 1, l, mid, a, b) + query(i << 1 | 1, mid + 1, r, a, b)) % mod;
    }
} it;

void precalc() {
    pw[0] = 1;
    for (int i = 1; i < N; i++) pw[i] = 10LL * pw[i - 1] % mod;
    inv9 = binPow(9, mod - 2);
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    precalc();
    cin >> n >> q;
    it.init(1, 1, n);
    while (q--) {
        int l, r, d;
        cin >> l >> r >> d;
        it.update(1, 1, n, l, r, d);
        cout << it.query(1, 1, n, 1, n) << "\n";
    }
    return 0;
}


Measured memory_bytes: 8496
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int n;
    cin >> n;
    int t;
    cin >> t;
    t*=1000;
    int a;
    cin >> a;
    a*=1000;
    int ma = 100000000;
    int num = -1;
    for(int i=0;i<n;i++){
        int h;
        cin >> h;
        if(ma > abs(t-h*6-a)){
            ma = abs(t-h*6-a);
            num = i+1;
        }
    }
    cout <<num << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a[3][3];
    rep(i, 3)   rep(j, 3)   cin >> a[i][j];
    bool G[3][3] = {false};
    int n;  cin >> n;
    rep(i, n){
        int b;  cin >> b;
        rep(j, 3)   rep(k, 3)   if(b == a[j][k])    G[j][k] = true;
    }
    /*
     * 斜め
     */
    bool flag = false;
    if(G[0][0] && G[1][1] && G[2][2])   flag = true;
    if(G[0][2] && G[1][1] && G[0][2])   flag = true;
    /*
     * 縦横
     */
    rep(j, 3)   if(G[0][j] && G[1][j] && G[2][j])   flag = true;
    rep(i, 3)   if(G[i][0] && G[i][1] && G[i][2])   flag = true;
    if(flag){
        puts("Yes");
    }else{
        puts("No");
    }
}


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

using namespace std;
const int MAX_N = 1e5 + 7;
int a[MAX_N];

int main(){
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a + n);

    double tar = a[n-1] / 2.0;
    int ans = 0;
    if(a[0]<tar){
        //手写二分
        int l = 0, r = n - 2,mid;
        while(l<r){
            mid = (l + r + 1) / 2;
            if(a[mid]<=tar){
                l = mid;
            }else{
                r = mid - 1;
            }
        }
        int a1 =a[l];

        l = 0, r = n - 2;
        while(l<r){
            mid = (l + r) / 2;
            if(a[mid]<tar){
                l = mid + 1;
            }else{
                r = mid;
            }
        }
        int a2 = a[r];


        if((tar-a1)>(a2-tar)){
            ans = a2;
        }else{
            ans = a1;
        }
    }else{
        ans = a[n - 1];
    }
    cout << a[n-1] << " " << ans << endl;
    return 0;
}

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

   typedef long long ll;

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

   #define REP(i, n) for(int i = 0; i < (int)(n); i++)
   #define FOR(i, a, b) for (int i = (a); i < (b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((int)(x).size())


   #define dump(x) cerr<< #x << "= " << (x) << endl;

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

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

int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   //input
   ll n, x; cin >> n >> x;
   vector<ll> a(n);
   REP(i, n) cin >> a[i];

   ll ans = 0;
   REP(i, n - 1){
       if (a[i] + a[i + 1] > x){
           ll s = min(a[i], x), t = min(a[i + 1], x - s);
           ans += a[i] - s + a[i + 1] - t;
           a[i] = s;
           a[i + 1] = t;
       }
   }
   cout << ans << endl;
}

Measured memory_bytes: 1024
use strict;
use warnings;
use utf8;

use feature qw(say);
use Data::Dumper;

my $input = <STDIN>;
chomp $input;

if ($input eq 'RRR') {
    say 3;
}
if ($input eq 'RSR') {
    say 1;
}
if ($input eq 'SRR') {
    say 2;
}
if ($input eq 'RRS') {
    say 2;
}
if ($input eq 'SSR') {
    say 1;
}
if ($input eq 'SRS') {
    say 1;
}
if ($input eq 'RSS') {
    say 1;
}
if ($input eq 'SSS') {
    say 0;
}


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

int ar[200005];

int main()
{
  ll n, i, ans=0, mx=0;
  cin>>n;

  for(i=0; i<n; i++)
  {
    cin>>ar[i];
  }
  for(i=0; i<n-1; i++)
  {
    if(ar[i]>=ar[i+1])
    {
        ans++;
    }
    else
    {
        mx=max(mx,ans);
        ans=0;
    }
  }
  mx=max(mx,ans);
  cout<<mx<<endl;
}

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


int main(){
    int x;
    cin >> x;
    int n = 100300;
    vector<int> seive(100301);
    for(int i=2; i*i<=n; i++){
        int cnt = 2;
        while(i*cnt <= n){
            seive[i*cnt]++;
            cnt++;
        }
    }
    vector<int> prime;
    for(int i=2; i<n; i++){
        if(seive[i]==0) prime.push_back(i);
    }
    auto itr = lower_bound(prime.begin(),prime.end(),x);
    cout << *itr << endl;
    return 0;
}

Measured memory_bytes: 3880
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
A = LI()



D = defaultdict(int)
for i in range(n):
    a = A[i]
    Di = defaultdict(int)
    for j in range(2, int(a ** 0.5) + 1):
        while a % j == 0:
            a //= j
            Di[j] += 1
    if a:
        Di[a] += 1
    for k in Di:
        D[k] = max(D[k], Di[k])

ret = 1
for ki in D:
    ret = ret * pow(ki, D[ki], mod)
    ret %= mod

ans = 0
for a in A:
    ans += ret * pow(a, mod - 2, mod)
    ans %= mod

print(ans)






Measured memory_bytes: 84548
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int main() {
  string line;
  while (getline(cin, line)) {
    if (line == ".") break;
    stack<char> s;
    const int N = line.size();
    bool ok = true;
    
    rep(i,N) {
      if ((line[i] == '[') || (line[i] == '(')) {
        s.push(line[i]);
      } else if (line[i] == ']') {
        if (s.size() && s.top() == '[') {
          s.pop();
        } else {
          ok = false; break;
        }
      } else if (line[i] == ')') {
        if (s.size() && s.top() == '(') {
          s.pop();
        } else {
          ok = false; break;
        }
      }
    }

    if (s.size()) ok = false;
    
    printf("%s\n", ok ? "yes" : "no");
  }
  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;
const int MOD = 1000000007; 
 
int main() {
    int n, ret = 0; 
    cin >> n;
    vector<int> times(n);
    vector<string> titles(n);
    rep(i,n) cin >> titles[i] >> times[i];
    string key;
    bool check = false;
    cin >> key; 
    rep(i, n) {
        if (check) {
            ret += times[i];
        }
        if (titles[i] == key) check = true;
    }    
    cout << ret << endl;
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  int cnt=0,a=0;
  for(int i=0;i<n;i++){
    if(a<=h[i]){
      cnt++;
      a=h[i];
  }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>

using namespace std;

int width,height,table[100][100];

bool rangeCheck(int row,int col){
	if(row >= 0 && row <= height-1 && col >= 0 && col <= width-1)return true;
	else{
		return false;
	}
}

void recursive(int row,int col){
	int tmp = table[row][col];
	table[row][col] = 7;

	if(rangeCheck(row-1,col) == true && table[row-1][col] == tmp)recursive(row-1,col);
	if(rangeCheck(row+1,col) == true && table[row+1][col] == tmp)recursive(row+1,col);
	if(rangeCheck(row,col-1) == true && table[row][col-1] == tmp)recursive(row,col-1);
	if(rangeCheck(row,col+1) == true && table[row][col+1] == tmp)recursive(row,col+1);
}

int main(){

	int x_s,y_s,x_g,y_g,n,color,dist,x,y;

	while(true){
		scanf("%d %d",&width,&height);
		if(width == 0 && height == 0)break;

		for(int i = 0; i < height; i++)
		{
			for(int k = 0; k < width; k++)table[i][k] = 0;
		}

		scanf("%d %d",&x_s,&y_s);
		scanf("%d %d",&x_g,&y_g);

		scanf("%d",&n);

		for(int i = 0; i < n; i++){
			scanf("%d %d %d %d",&color,&dist,&x,&y);

			if(dist == 0){
				for(int row = 0; row < 2; row++){
					for(int col = 0; col < 4; col++){
						table[y-1+row][x-1+col] = color;
					}
				}
			}else{
				for(int row = 0; row < 4; row++){
					for(int col = 0; col < 2; col++){
						table[y-1+row][x-1+col] = color;
					}
				}
			}
		}
		recursive(y_s-1,x_s-1);

		if(table[y_g-1][x_g-1] == 7)printf("OK\n");
		else{
			printf("NG\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2524
using System;
using System.Diagnostics;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string ans = "";
            switch(s){
                case "A":
                    ans = "T";
                    break;
                case "T":
                    ans = "A";
                    break;
                case "G":
                    ans = "C";
                    break;
                case "C":
                    ans = "G";
                    break;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 25868
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
signed main(){
  int N,M,X,Y;
  cin>>N>>M>>X>>Y;
  vi x(N),y(M);
  rep(i,0,N) cin>>x[i];
  rep(i,0,M) cin>>y[i];
  sort(ALL(x));
  sort(ALL(y));
  string ans="War";
  if(max(X,x[N-1])<min(Y,y[0]))
    ans="No War";
  cout<<ans<<endl;
  }


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

const int INF = 1001001001;
int n;
vector<int> to[1005];

vector<int> bfs(int sv){
  vector<int> dist(n,INF),pre(n,-1);
  queue<int> q;
  dist[sv] = 0;
  q.push(sv); 
  while(!q.empty()){
    int v = q.front(); q.pop();
    for(int u:to[v]){
      if(dist[u]!=INF) continue;
      pre[u] = v;
      dist[u] = dist[v]+1;
      q.push(u);
    }
  }
  pair<int,int> best(INF,-1);
  rep(v,n){
    if(v == sv) continue;
    for(int u:to[v]){
      //svに戻ってくる場合（サイクルとなっている場合）
      if(u==sv){
        best=min(best,make_pair(dist[v],v));
      }
    }
  }
  //cout<<"Debug"<<best.first<<endl;
  if(best.first == INF) return vector<int>(n+1);
  int v = best.second;
  vector<int> res;
  while(v!=-1){
    res.push_back(v);
    v=pre[v];
  }
  return res;
}

int main(){
  int m;
  cin >> n >> m;
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--,b--;
    to[a].push_back(b);
  }

  vector<int> ans(n+1);
  rep(i,n){
    auto now = bfs(i);
    if(now.size() < ans.size()) ans = now;
  }
  if(ans.size() == n+1){
    cout<<-1<<endl;
    return 0;
  }
  cout<<ans.size()<<endl;
  for(int v:ans){
    cout<<v+1<<endl;
  }
  return 0;
  
}

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

int A[100];
int N;

int  bubbleSort(int A[], int N) {
	int i = 0;
	int c = 0;
	int flag = 1;
	while (flag) {
		flag = 0;
		for (int j = N - 1; j > i; --j) {
			if (A[j - 1] > A[j]) {
				int t = A[j - 1];
				A[j - 1] = A[j];
				A[j] = t;
				flag = 1;
				++c;
			}
		}
		++i;
	}
	return c;
}

void Show(int A[], int N) {
	for (int i = 0; i < N; ++i) {
		if (i) {
			cout << " ";
		}
		cout << A[i];
	}
	cout << endl;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	int c = bubbleSort(A, N);
	Show(A, N);
	cout << c << endl;
}


Measured memory_bytes: 3088
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i=0;i<N;++i) cin >> h.at(i);
  sort(h.begin(),h.end());
  int ans=1000000000;
  for(int i=0;i<=N-K;++i){
    ans=min(ans,h.at(i+K-1)-h.at(i));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3768
N, M = map(int, input().split())
Ans = [-1] * N
ans = 0
for i in range(M):
    s, c = map(int, input().split())
    s -= 1
    if (Ans[s] == -1) or (Ans[s] == c):
        Ans[s] = c
    else:
        print(-1)
        exit()


if Ans[0] == -1:
    if len(Ans) == 1:
        print(0)
        exit()
    else:
        Ans[0] = 1
if (N != 1) and (Ans[0] == 0):
    print(-1)
    exit()

for i in range(N):
    if Ans[i] == -1:
        Ans[i] = 0
    ans = ans * 10 + Ans[i]


print(ans)


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

typedef vector<int> vec;
typedef vector<vec> mat;

int M,N,D;


void view( const mat& a ){
  cout << "mat view" << endl;
  for(int i=0;i<(int)a.size();i++){
    for(int j=0;j<(int)a[i].size();j++) cout << a[i][j] << " ";
    cout << endl;
  }
}
void view( const vec& a ){
  cout<<"vec view" << endl;
  for( int i : a ){
    cout <<i <<  " ";
  }
  cout << endl;
}

int getid(int y,int x){
  return y+x*N;
}

vec mod_gauss_jordan( const mat &A, const vec& b ){
  int n = A.size();
  mat B(n, vec(n+1));
  for( int i=0;i<n;i++ )
    for(int j=0;j<n;j++)
      B[i][j] = A[i][j];
  for(int i=0;i<n;i++) B[i][n] = b[i];
  
  //view( B );
  for(int i=0;i<n;i++){
    int pivot = i;
    for(int j=i+1;j<n;j++) if( B[j][i]>B[pivot][i] ) pivot = j;
    swap(B[pivot],B[i]);
    
    //if( B[i][i] < 1 ) return vec();

    for(int j=0;j<n;j++)
      if( i != j && B[j][i] )
        for(int k=i;k<=n;k++){
          B[j][k] = (B[j][k] + B[i][k])%2;            
        }
    
    //cout << "in " << i << endl;
    //view( B );
  }
  vec x(n);
  for(int i=0;i<n;i++) x[i] = B[i][n];

  for(int i=0;i<n;i++){
    int p = 0;
    for(int j=0;j<n;j++){
      //cout << A[i][j]<<  " : "<< x[j] << endl;
      if( A[i][j] ) p = (p+x[j])%2;
    }
    //cout << p << " = " << b[i] << endl;
    if( p!=b[i] ) return vec();
    assert( p==b[i] );
  }
  return x;
}


int main(){
  while( cin >> M >> N >> D && (M||N||D) ){
    int S[30][30];
    for(int i=0;i<N;i++)
      for(int j=0;j<M;j++)
        cin >> S[i][j];

    mat mt = mat(N*M);
    for(int i=0;i<N;i++){
      for(int j=0;j<M;j++){
        vec V = vec(N*M,0);
        for(int y=0;y<N;y++){
          for(int x=0;x<M;x++){
            int d = abs(y-i) + abs(x-j);
            if( d == D ) 
              V[getid(y,x)] = 1;            
          }
        }        
        V[getid(i,j)] = 1;
        assert( getid(i,j)%N == i && getid(i,j)/N == j );
        mt[getid(i,j)] = V;
      }
    }
    vec B = vec( N*M );
    for(int i=0;i<N;i++)
      for(int j=0;j<M;j++)
        if( S[i][j] == 1 ) B[getid(i,j)] = 1;

    //view(mt);
    //view(B);
    vec res = mod_gauss_jordan( mt, B );
    if( res.empty() ) cout << 0 << endl;
    else {
      cout << 1 << endl;
      for(int i=0;i<N*M;i++){
        int iy = i%N, ix = i/N;
        assert( getid(iy,ix) == i );
        if( res[i] ){  
          S[iy][ix] = 1-S[iy][ix];
          for(int y=0;y<N;y++)
            for(int x=0;x<N;x++)
              if( D == abs( y-iy ) + abs( x-ix )  )
                S[y][x] = 1-S[y][x];
        }
      }/*
      for(int i=0;i<N;i++){
        for(int j=0;j<M;j++) cout << S[i][j];
        cout << endl;
        }*/
    }
  }
}

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

using namespace std;

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  set< int > s;
  for(int i = A; i <= min(B, A + K - 1); i++) s.emplace(i);
  for(int i = B; i >= max(A, B - K + 1); i--) s.emplace(i);
  for(auto &p : s) cout << p << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef complex<double> C;

struct node {
    ll cost;
    vector<node*> next;
    node* before;
    node(ll c) : cost(c) {}
    node() : cost(0) {}
};

ll dfs(node* now) {
    if (now->cost != 0) return now->cost;
    int n = (now->next).size();
    vector<ll> score;
    for (int i = 0; i < n; i++) {
        score.push_back(dfs(now->next[i]));
    }
    sort(score.begin(), score.end());
    ll ret = 0;
    for (int i = 0; i < (n+1)/2; i++) {
        ret += score[i];
    }
    return ret;
}

void solve(const string& s) {
    // ??¨?????????
    node* root = new node();
    node* now = root;
    int cur = 0;
    int n = s.size();
    while (1) {
        if (cur >= n) break;
        if (s[cur] == '[') {
            node* tmp = new node();
            tmp->before = now;
            now->next.push_back(tmp);
            now = tmp;
            cur++;
        } else if (s[cur] == ']') {
            now = now->before;
            cur++;
        } else {
            int i = cur;
            int tmp = 0;
            while (1) {
                if (!isdigit(s[i])) break;
                else tmp = tmp*10 + (s[i]-'0');
                i++;
            }
            cur = i;
            now->cost = (tmp+1) / 2;
        }
    }
    // ?§£???
    cout << dfs(root) << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T;
    cin >> T;
    while (T--) {
        string s;
        cin >> s;
        solve(s);
    }
    return 0;
}

Measured memory_bytes: 3428
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!{
      k: i64,
      x: i64,
    }

    for i in (0..(k-1)).rev() {
        puts!("{} ", x-i-1);
    }
    puts!("{} ", x);
    for i in 0..(k-1) {
        puts!("{} ", x+i+1);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int n;
	cin >>n;
	cin >> s;
	int t=0;
	for(int i=0;i<n/2;i++){
		if(s[i]!=s[n/2+i]){
			t++;
			break;
		}
	}
	if(t==0&&n%2==0){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m; cin>>n>>m;
  vector<int>x(m);
  for (int i=0; i<m; i++){
    cin>>x[i];
  }
  sort(x.begin(),x.end());
  
  if(n>=m) cout<<0<<endl;
  else{
    vector<int>y(m-1);
    for(int i=0;i<m-1;i++){
      y[i]=x[i+1]-x[i];
    }
    sort(y.begin(),y.end());
    
    int sum=0;
    for(int i=0;i<m-n;i++){
      sum+=y[i];
    }
    cout<<sum<<endl;
  }

}

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

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

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const string& s)
{
    int ans = 0, L = 0;

    while (L < N)
    {
        auto R = L + 1;

        while (R < N and s[R] == s[L])
            ++R;

        ++ans;
        L = R;
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    string s;
    cin >> s;

    auto ans = solve(N, s);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3788
#include<iostream>
#include<vector>
#include<numeric>
int main(){
    int N,M; std::cin >> N >> M;
    std::vector<int>vertex(N,0);
    for(int i = 0; i < M; ++i){
        int u,t; std::cin >> u >> t;
        --u,--t;
        vertex[u]++; vertex[t]++;
    }
    bool valid = std::accumulate( vertex.begin(),vertex.end(),2*(N - 1) >= M,[](bool res,int cnt){
        return (res and cnt % 2 == 0);
    });
    std::cout << (valid ? "YES" : "NO") << std::endl;
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>

using namespace std;
#define ll long long


int main(void){
    int P,Q,R;
    cin>>P>>Q>>R;
    int S=max(P,max(Q,R));
    cout<<P+Q+R-S<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;

    int r[n];
    int c[9] = {0};

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

        if(r[i] <= 399) c[0]++;
        else if(r[i] >= 400 && r[i] <= 799) c[1]++;
        else if(r[i] >= 800 && r[i] <= 1199) c[2]++;
        else if(r[i] >= 1200 && r[i] <= 1599) c[3]++;
        else if(r[i] >= 1600 && r[i] <= 1999) c[4]++;
        else if(r[i] >= 2000 && r[i] <= 2399) c[5]++;
        else if(r[i] >= 2400 && r[i] <= 2799) c[6]++;
        else if(r[i] >= 2800 && r[i] <= 3199) c[7]++;
        else c[8]++;
    }
    int colors = 0;
    for(int i = 0; i < 8; i++){
        if(c[i] > 0) colors++;
    }
    int min = 0;
    int max = colors + c[8];
    if(colors > 0) min = colors;
    
    
    if(min > 0) cout << min << " " << max << endl;
    else if(min == 0)  cout << 1 << " " << max << endl;
    
    

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
signed main(void){
    int m[3]= {};
    string s; cin>>s;
    int n = s.size();
    
    rep(i, n) if(i%3==0) m[0]++; else if(i%3 == 1) m[1]++; else m[2]++;
    int a = count(s.begin(), s.end() , 'a');
    int b = count(s.begin(), s.end() , 'b');
    int c = count(s.begin(), s.end() , 'c');
    //cout<<a<<' '<<b<<' '<<c<<endl;
    rep(i,3) rep(j, 3) rep(k, 3) {
        //cout<<m[i]<<' '<<m[j]<<' '<<m[k]<<endl;
    if(i==j||j==k||k==i) continue; else if(m[i]==a&&m[j]==b&&m[k]==c) {cout<<"YES"<<endl; return 0;}
    }
    cout<<"NO"<<endl;
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    S = SI()
    arr = []
    tmp = 0
    for s in S:
        if s in 'ACGT':
            tmp += 1
        else:
            tmp = 0
        arr.append(tmp)
    ans = max(arr)

    return ans

print(main())

Measured memory_bytes: 3064
/*
 
Coded and Decoded by : Yash Kapoor
 
*/
#include <bits/stdc++.h>
using namespace std;
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define dl          '\n'
//#define why         (ll)1000000007
#define why         (ll)998244353
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base,ll power,ll mod)
{
    ll result=1;
    while(power)
    {
        if(power%2)
        result=(result*base)%mod;
        base=(base*base)%mod;
        power/=2;
    }
    return result;
}
 
ll inverse(ll base,ll mod)
{
    return fast_power(base,mod-2,mod);
}
 
ll solve(){ 
    ll n; string s;
    cin>>n>>s;
 
    ll dp[4][n+5];
    memset(dp,0,sizeof(dp));
    lp(i,0,n) {
        if(i) {
            dp[0][i] += dp[0][i-1];
            dp[1][i] += dp[1][i-1];
            dp[2][i] += dp[2][i-1];
        }
        if(s[i] == 'R') {
            s[i] = 0;
            dp[0][i]++;
        }
        if(s[i] == 'G') {
           s[i] = 1;
           dp[1][i]++;
        }
        if(s[i] == 'B'){
         s[i] = 2;
         dp[2][i]++;
        }
    }
 ll sum = 0;
    lp(i,0,n)
        lp(j,i+1,n) {
            if(s[i] == s[j])
                continue;
            lp(k,0,3){
 
                if(k == s[i] or k == s[j])
                    continue;
 
                sum += dp[k][n-1]-dp[k][j];
 
 
 
                if(j+(j-i) < n && s[j+(j-i)] == k) 
                    sum--;
 
            }
 
 
        }
    cout << sum << endl;
  return 0;
}  
 
int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
        solve();
    }
}

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

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;

const int N = 1e6 + 5;

/***************************************************************************/

set<pair<string, int> > S;

int main() {

	boost;
	string str; int k;
	cin>>str>>k;
	int len = str.length();

	for(int i=0; i<len; i++) {
		S.insert(make_pair(str.substr(i, 1), i));
	}

	string ans = "";

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

		int alen = ans.length();

		while(S.begin()->fi == ans) {
			int p = S.begin()->se;
			S.erase(S.begin());
			if(p+alen < len) S.insert(make_pair(str.substr(p, alen+1), p));
		}

		ans = S.begin()->fi;
	}

	cout<<ans<<"\n";
	
	return 0;
}

Measured memory_bytes: 768
let a, b, k = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let l, r = max a @@ b - k + 1, min b @@ a + k - 1
let _ =
  for i = a to r do Printf.printf "%d\n" i done;
  for i = max l @@ r + 1 to b do Printf.printf "%d\n" i done

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

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

int main(){
        int n;
        cin>>n;
        vector<ll>x(n),l(n);
        P mp[110000];
        for(int i=0;i<n;i++){
                cin>>x[i]>>l[i];
                mp[i]=P(x[i]+l[i],x[i]-l[i]);
        }
        sort(mp,mp+n);
        ll ans=0;
        ll cur=-1100000000;
        for(int i=0;i<n;i++){
                if(cur<=mp[i].second){
                        ans++;
                        cur=mp[i].first;
                }
        }
        cout<<ans<<endl;
        return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

signed main() {
  int N; cin >> N;
  int Input[N];
  int ans = 0;
  int temp = 0;
  for (int i = 0; i < N; i++) {
    cin >> Input[i];
  }
  
  for (int i = 1; i < N; i++){
    if (Input[i-1] >= Input[i]) {
      // cout << i << " Here" << endl;
      temp++;
      if (i == N-1) ans = max(temp, ans);
    } else {
      ans = max(temp, ans);
      temp = 0;
    }
    // cout << i << " " << temp << endl;
  }

  cout << ans << endl;
}


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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    multiset<int> s; 
    for(int i = 0; i < n; i++){
        int tmp = a[i];
        auto it = s.lower_bound(tmp);
        if(it != s.begin()) s.erase(--it);
        s.insert(tmp);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 8212
def main():
    s = str(input())
    while(len(s) != 0):
        if s[-6:] == "eraser":
            s = s[:-6]
            continue
        elif s[-7:] == "dreamer":
            s = s[:-7]
            continue
        elif s[-5:] == "erase":
            s = s[:-5]
            continue
        elif s[-5:] == "dream":
            s = s[:-5]
            continue
        else:
            return print("NO")
    print("YES")
    


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
N = gets.chomp.to_i
A = gets.chomp
B = gets.chomp
C = gets.chomp
count = 0
0.upto(N-1) do |n|
  match = [A[n], B[n], C[n]].uniq.size
  if match == 2
    count += 1
  elsif match == 3
    count += 2
  end
end
puts count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define int long long 
const int N = 5e3+10;
 
bool cmp(pair<int,int> a,pair<int,int> b){
	int A = min(a.first,b.first - a.second);
	int B = min(b.first,a.first - b.second);
	return A>B;
}

int dp[N][N];

int32_t main(){
	int n;
	cin>>n;
	vector<pair<int,int> > a(n);
	for(int i=0;i<n;++i)
		cin>>a[i].first >> a[i].second;
	sort(a.begin(),a.end(),cmp);
	for(int i=0;i<n;++i){
		for(int j=1;j<=n;++j)
			dp[i][j] = 1e15;
	}
	dp[0][0] = 0;
	dp[0][1] = a[0].second;
	for(int i=1;i<n;++i)
		for(int j=1;j<=n;++j){
			if(dp[i-1][j-1] <= a[i].first)
				dp[i][j] = min(dp[i-1][j],dp[i-1][j-1]+a[i].second);
			else 
				dp[i][j] = dp[i-1][j];
		}
	int ans = 0;
	for(int i=n;i>0;--i)if(dp[n-1][i]<1e15){
		ans = i;
		break;
	}
	cout << ans << endl;
    return 0;
}

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

namespace ConsoleApp15
{
    class Class188
    {
        
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var A = new List<Tuple<int, bool>>[N];
            for (int i = 0; i < N; i++) A[i] = new List<Tuple<int, bool>>();
            for(int i = 0; i < N; i++)
            {
                var a = int.Parse(Console.ReadLine());
                for(int j = 0; j < a; j++)
                {
                    var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    A[i].Add(Tuple.Create(r[0] - 1, r[1] == 0));
                }
            }

            int ans = 0;
            for(int i = 0; i < (1 << N); i++)//unhonest:1
            {
                bool[] check = new bool[N];
                bool frag = false;
                int count = 0;
                for (int j = 0; j < N; j++)
                    if ((i & (1 << j)) > 0)
                    {
                        check[j] = true;
                    }
                    else count++;

                for(int j = 0; j < N; j++)
                {
                    if ((i & (1 << j)) > 0) continue;
                    foreach(Tuple<int,bool> t in A[j])
                    {
                        if (t.Item2)
                        {
                            if (!check[t.Item1])
                                frag = true;
                        }
                        else
                        {
                            if (check[t.Item1])
                                frag = true;
                        }
                    }
                }
                if (frag) continue;
                ans = Math.Max(ans, count);
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
_=gets
S=gets.chomp.split("")
es = []
("a".."z").each{ |c|
  l,r = S.index(c),S.rindex(c)
  next if !l || l == r
  es << [r,-1]
  es << [l,+1]
}
ans = 0
s = 0
es.sort.each{ |x,t|
  s += t
  ans = [ans,s].max
}
p ans

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

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

using ll = int64_t;

using namespace std;
/*
 * Modint struct
 * library author : @snuke
 * */
const int mod = 1e9 + 7;
struct mint {
  long long x; // typedef long long ll;
  mint(long long x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) { if((x+=a.x)>=mod)x-=mod;return *this;}
  mint& operator-=(const mint a) { if((x+=mod-a.x)>=mod)x-=mod; return *this;}
  mint& operator*=(const mint a) { (x *=a.x)%=mod; return *this;}
  mint operator+(const mint a) const { mint res(*this);return res+=a;}
  mint operator-(const mint a) const { mint res(*this);return res-=a;}
  mint operator*(const mint a) const { mint res(*this);return res*=a;}
  mint pow(ll t) const {
    if (!t) return 1;mint a = pow(t>>1);a*=a;
    if (t&1) a *= *this;return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return (*this) *= a.inv();}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct Combination{
    const int MAX = 500050;
    vector<mint> fact;
    vector<mint> finv;
    Combination():fact(MAX),finv(MAX){
        for(int i = 0;i < MAX;i++){
            if(i == 0)fact[i] = (mint)1;
            else fact[i] = fact[i-1]*(mint)i;
        }
        finv[MAX - 1] = fact[MAX - 1].inv();
        for(int i = MAX - 2;i >= 0;i--){
            finv[i] = finv[i + 1] * (mint)(i + 1);
        }
    }
    mint comb(int n,int r){
        if(n<0||r<0||n<r)return 0;
        else return fact[n]*finv[r]*finv[n-r];
    }
};
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int64_t n,m;cin >> n >> m;

    Combination C;

    mint select = mint(C.comb(m,n)*C.fact[n]).pow(2);

    for(int64_t i = 1;i <= n;i++){
        mint d = (C.comb(n,i)*C.comb(m,i)*C.fact[i]);
        d *= (C.comb(m-i,n-i)*C.fact[n-i]).pow(2);
        if(i % 2 == 0) select += d;
        else select -= d;
    }
    cout << select << '\n';

}



Measured memory_bytes: 11116
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
//const int MAX=;


void input(){
    int N;
    cin>>N;
    if(N%2==0)cout<<N/2-1;
    else cout<<N/2;
}

void solve(){

}

void output(){
  
}

int main(){
  input();
  solve();
  output();
}


Measured memory_bytes: 256