akhauriyash/Code-Regression huggingface dataset:
using System;
class Card{
    private char Mark;
    private int Num;
    public Card(char m, int n) {
        Mark = m;
        Num = n;
    }
    public Card() {
        Mark = 'a';
        Num = 0;
    }
    public char markop
    {
        get {
            return Mark;
        }
        set {
            Mark = value;
        }
    }
    public int numop
    {
        get {
            return Num;
        }
        set {
            Num = value;
        }
    }
}

class Sorting
{
    public void BubbleSort(Card[] cards, int N) {
        Card temp = new Card();
        for (int i = 0; i < N; i++) {
            for(int j = N - 1; j > i; j--) {
                if (cards[j].numop < cards[j - 1].numop) {
                    temp = cards[j];
                    cards[j] = cards[j - 1];
                    cards[j - 1] = temp;
                }
            }
        }
        print(cards, N);
    }

    public void SelectionSort(Card[] cards, int N) {
        Card temp = new Card();
        for (int i = 0; i < N; i++) {
            int minj = i;
            for (int j = i; j < N; j++) {
                if (cards[j].numop < cards[minj].numop) {
                    minj = j;
                }
            }
            temp = cards[i];
            cards[i] = cards[minj];
            cards[minj] = temp;
        }
        print(cards, N);
    }

    public void print(Card[] cards, int n) {
        for(int i = 0; i < n; i++) {
            if (i > 0) {
                Console.Write(" ");
            }
            Console.Write("{0}{1}", cards[i].markop, cards[i].numop);
        }
        Console.WriteLine();
    }

    public bool IsStable(Card[] cards1, Card[] cards2, int n) {
        for(int i = 0; i < n; i++) {
            if (cards1[i].markop != cards2[i].markop) {
                return false;
            }
        }
        return true;
    }
}

class C
{
    public static void Main() {
        int n, i=0;
        Card[] cards1 = new Card[36];
        Card[] cards2 = new Card[36];
        Sorting sort = new Sorting();
        n=int.Parse(Console.ReadLine());
        string[] data = Console.ReadLine().Split(' ');
        foreach(string dataset in data){
            cards1[i] = new Card();
            cards2[i] = new Card();
            foreach(char mark in dataset) {
                if (char.IsNumber(mark)) {
                    cards1[i].numop = mark - '0';
                    cards2[i].numop = mark - '0';
                } else {
                    cards1[i].markop = mark;
                    cards2[i].markop = mark;
                }
            }
            i++;
        }
        sort.BubbleSort(cards1, n);
        Console.WriteLine("Stable");
        sort.SelectionSort(cards2, n);
        if(sort.IsStable(cards1, cards2, n)) {
            Console.WriteLine("Stable");
        } else {
            Console.WriteLine("Not stable");
        }
    }
}


Measured memory_bytes: 9368
#include <iostream>

using namespace std;

int main() {
    long long int A, B;
    cin >> A >> B;
    
    for(int i=0; i<1e5; i++) {
        if(i*8/100==A && i*10/100==B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;


    return 0;
    
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())
print(max(a) - min(a))

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

int main()
{
    string s;
    long long k;
    cin >> s >> k;
    char ch;
    int count1 = 0;
    for (char& c : s) {
        if (c != '1') {
            ch = c;
            break;
        }
        count1++;
    }
    if (count1 != 0 && count1 >= k) {
        cout << '1' << endl;
    } else {
        cout << ch << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,m;
bool f[200000];
ll dp[200000];

int main(){
    cin >> n >> m;
    rep(i,m){
        ll num;
        cin >> num;
        f[num] = 1;
    }
    dp[0] = 1;
    rep(i,n){
        if(!f[i+1]){
            dp[i+1] += dp[i];
            dp[i+1] %= MOD;
        }
        if(!f[i+2]){
            dp[i+2] += dp[i];
            dp[i+2] %= MOD;
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1152
n =int(input())

ans = float("inf")

for i in range(1,int(n/2)+1):
    a = format(i,"05d")
    b = format(n-i,"05d")
    sm = 0
    for aa,bb in zip(a,b):
        sm += int(aa) + int(bb)
    if ans  >  sm:
        ans = sm
print(ans)

Measured memory_bytes: 3060
#include <iostream>  
#include <cstdio>  
#include <algorithm>  
using namespace std;

int n,a,tt;

long long read()
{
	long long x=0,f=1;char c=getchar();
	while (!isdigit(c)) {if (c=='-')f=-1;c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0';c=getchar();}
	return x*f;
}

void write(long long x)
{
	if (x<0) putchar('-'),x=-x;if (x>=10) write(x/10);
	putchar(x%10+'0');
}

void writeln(long long x)
{
	 write(x),puts("");
}

int main()
{
	n=read();
	while (a*(a+1)/2<n)
		a++;
	tt=a*(a+1)/2-n;
	for (int i=0;i<a-tt;i++) putchar(')');
	putchar('(');
	for (int i=0;i<tt;i++) putchar(')');
	for (int i=0;i<a-1;i++) putchar('(');
	puts("");
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  cout << s.front() << s.size()-2 << s.back() << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    double r;
    double pi = 6.28318530717958623200;
    cin >> r;
    cout << fixed << setprecision(12) << r*pi << endl;

    return 0;
}



Measured memory_bytes: 3796
odd = '#.' * 150
even = '.#' * 150

while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        if i % 2 == 0:
            print(odd[:W])
        else:
            print(even[:W])
        if i == H-1:
            print('')


Measured memory_bytes: 5612
N = int(input())
S = str(input())

half = (N+1) // 2
if N%2 != 0:
  if S[:half] == S[half+1:N]:
    print("Yes")
  else:
    print("No")
else:
  if S[:half] == S[half:N]:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 9180
import string


def solve(s, K):
    candidate = set()
    for char in string.ascii_lowercase:
        for i, c in enumerate(s):
            if c == char:
                for j in range(i + 1, min(len(s), i + 5) + 1):
                    candidate.add(s[i:j])
        if len(candidate) >= K:
            break
    return sorted(list(candidate))[K - 1]

if __name__ == "__main__":
    s = input()
    K = int(input())
    print(solve(s, K))


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

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

const int N = 2e5+10 , mod = 1e9+7;

int a[N];

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n , k;
   cin >> n >> k;
   for(int i = 0 ; i < n ; i++){
      cin >> a[i];
   }
   int l = 0 , r = mod;
   while(r - l > 1){
      int mid = (l + r) / 2;
      int cnt = 0;
      for(int i = 0 ; i < n && cnt <= k ; i++){
         cnt += a[i] / mid;
         if(a[i] % mid)
            cnt++;
         cnt--;
      }
      if(cnt <= k)
         r = mid;
      else
         l = mid;
   }
   cout << r;
   return 0;
}


Measured memory_bytes: 4432
N, K, C  = map(int, input().split())
S = input()

def ff(s):
  i = 1
  kin = []
  for k in range(0, K):
    while s[i-1] == "x":
      i = i+1
    kin += [i]
    i = i+C+1
  return( kin )

k1 = ff(S)
S2 = S[::-1]
k2 = ff(S2)
for i in range(0,K):
  k2[i] = N-k2[i]+1
k2 = k2[::-1]

for i in range(0,K):
  if k1[i]==k2[i]:
    print( k1[i] )


Measured memory_bytes: 20904
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let s: Vec<bool> = sc.cin::<String>().chars().map(|c| c == 'W').collect();
    let a = s.iter().enumerate().fold((0, 1), |(w, ans), (i, &s)| {
        let c = if i % 2 == 0 { !s } else { s };
        if c {
            (w + 1, ans)
        } else {
            (w - 1, (ans * w) % M)
        }
    });
    if a.0 > 0 {
        put!(0);
    } else {
        let b = (1..n as i64+1).fold(1, |ac, i| (ac * i) % M);
        put!((a.1 * b) % M);
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    int N;
    cin >> N;
    map<ll,ll> cnt;
    REP(i,N){
        ll a;
        cin >> a;
        cnt[a]++;
    }
    ll ans = 0;
    for(auto p:cnt){
        if(p.first < p.second){
            ans += p.second-p.first;
        }
        if(p.first > p.second){
            ans += p.second;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9436
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //greater<T> for sorting decreasingly
#define ll 	long long
#define pll	pair<ll,ll>
#define unique(a) a.resize(unique(a.begin(), a.end()) - a.begin())
#define fill(v, p) memset(v,p,sizeof v)
#define all(x) x.begin(),x.end()
#define _fastio	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(0)
#define PI acos(-1.0)
#define EPS 0.000000000000001
#define INF 1LL<<62
#define MAX 100005
#define MOD 1000000007

//int dx[]={1,0,-1,0};
//int dy[]={0,1,0,-1}; //4 Direction
 
//int dx[]={1,1,0,-1,-1,-1,0,1};
//int dy[]={0,1,1,1,0,-1,-1,-1}; //8 direction
 
//int dx[]={2,1,-1,-2,-2,-1,1,2};
//int dy[]={1,2,2,1,-1,-2,-2,-1}; //Knight Direction (horse)

///////////////////////////////////////////////////////////

int main()
{
	_fastio;
	
	ll n;
	cin >> n;
	
	vector<ll> a(n), b(n), c(n);
	for(int i=0;i<n;i++) cin >> a[i], c[i]=i+1;
	for(int i=0;i<n;i++) cin >> b[i];

	ll in=-1, en=-1;
	
	ll i=1;
	do
	{
		if(c==a) in=i;
		if(c==b) en=i;
		
		i++;
	}while(next_permutation(all(c)));
	
	cout << abs(in-en) << endl;
	
	return 0;
}


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

struct edge {
	int to, cap, rev;
};

vector<edge>X[1009]; bool used[1009];

void add_edge(int u, int v, int w) {
	X[u].push_back(edge{ v,w,(int)X[v].size() });
	X[v].push_back(edge{ u,0,(int)X[u].size() - 1 });
}
int dfs(int pos, int to, int flow) {
	if (pos == to) return flow;
	used[pos] = true;
	for (int i = 0; i < X[pos].size(); i++) {
		if (used[X[pos][i].to] == true || X[pos][i].cap <= 0) continue;
		int G = dfs(X[pos][i].to, to, min(X[pos][i].cap, flow));
		if (G == 0) continue;
		X[pos][i].cap -= G;
		X[X[pos][i].to][X[pos][i].rev].cap += G;
		return G;
	}
	return 0;
}
int max_flow(int s, int t) {
	int F = 0;
	while (true) {
		for (int i = 0; i <= 500; i++) used[i] = false;
		int fl = dfs(s, t, 1000000007);
		if (fl == 0) break;
		F += fl;
	}
	return F;
}

int n, x[109], g[10000009]; bool prime[10000009]; vector<int>J;

int main() {
	// 2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数2 は合成数
	for (int i = 3; i <= 10000008; i++) prime[i] = true;
	for (int i = 2; i*i <= 10000008; i++) {
		for (int j = i*i; j <= 10000008; j += i) prime[j] = false;
	}
	cin >> n;
	for (int i = 1; i <= n; i++) { cin >> x[i]; g[x[i]] ^= 1; g[x[i] + 1] ^= 1; }
	for (int i = 1; i <= 10000002; i++) { if (g[i] >= 1) J.push_back(i); }
	for (int i = 0; i < J.size(); i++) {
		for (int j = i + 1; j < J.size(); j++) {
			if (prime[J[j] - J[i]] == true) {
				if (J[i] % 2 == 1) add_edge(i, j, 1);
				else add_edge(j, i, 1);
			}
		}
	}
	int kisuu = 0, gusuu = 0;
	for (int i = 0; i < J.size(); i++) {
		if (J[i] % 2 == 1) {
			add_edge(J.size(), i, 1);
			kisuu++;
		}
		else {
			add_edge(i, J.size() + 1, 1);
			gusuu++;
		}
	}
	int res = max_flow(J.size(), J.size() + 1);
	int V1 = res, V2 = (kisuu - res) / 2 + (gusuu - res) / 2, V3 = (J.size() / 2 - V1 - V2);
	cout << V1 * 1 + V2 * 2 + V3 * 3 << endl;
	return 0;
}

Measured memory_bytes: 47488
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (b < a) {
			System.out.println(a - 1);
		} else {
			System.out.println(a);
		}

		sc.close();
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 4223352036854775007
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=200005;
const int NN=3005;
const ll md=998244353;



int main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
	int x,n;
	cin >> x >> n;
	int a[N]={0};
	sii numb;
	for (int i=1;i<=n;i++){
        cin >> a[i];
        numb.insert(a[i]);
	}
	for (int i=0;i<=200001;i++){
        if (numb.find(x-i)==numb.end()){
            cout << x-i << E;
            r0;
        }
        if (numb.find(x+i)==numb.end()){
            cout << x+i << E;
            r0;
        }
	}
	r0;
}


/*







*/


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

using namespace std;

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

    int n;
    cin >> n;

    int prev = 2e9 , len = 0 , ans = 0;
    for (int i = 0 ;i < n ;i++) {
        int x;
        cin >> x;
        if (x <= prev)
            len++;
        else
            len = 1;
        prev = x;
        ans = max(ans , len - 1);
    }

    cout << ans;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin()+1, (a).end()
#define mod 2019
using ll = long long;
using namespace std;
int main(){
  ll n,W;
  cin >> n >> W;
  vector<vector<ll>> value(4);
  ll first;
  rep(i, n){
    ll w,v;
    cin >> w >> v;
    if(!i){
      first = w;
      rep(j, 4) value[j].push_back(0);
    }
    value[w - first].push_back(v);
  }
  rep(i, 4){
    sort(all(value[i]));
    reverse(all(value[i]));
    rep(j, value[i].size() - 1) value[i][j + 1] += value[i][j];
  }
  ll ans = 0;
  rep(a, value[0].size()){
    rep(b, value[1].size()){
      rep(c, value[2].size()){
        ll weight = a*first + b*(first+1) + c*(first+2);
        if(weight > W) break;
        ll d = min((W - weight) / (first + 3), (ll)value[3].size() - 1);
        ll res = 0;
        res += value[0][a];
        res += value[1][b];
        res += value[2][c];
        res += value[3][d];
        ans = max(ans, res);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int [] a = new int[n + 1];
        for (int i = 0; i < n  ; i++) {
          a [i] = in.nextInt();
        }
        Arrays.sort(a, 0 ,n);
        int b = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] == a [i +1])
                i++;
            else {
                b ++;
            }

        }
        System.out.println(b);
    }
}












Measured memory_bytes: 52884
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mod 1e9+7

int main(){
      ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);    
    
      int n,m;
         cin>>n>>m;int k=1;
         
         vector<int  >v(n+1);
         for(int i=0; i<=n;i++)
            v[i]=-1;
         for(int i=0; i<m; i++){
		   int x,y;
		      cin>>x>>y;
		      if(v[x]==-1 || y==v[x]){
                v[x]=y;			  
			  }
		      else{
			     k=0;
			  }
			  if(n>1 && v[1]==0){
			  k=0;
			  }
		 }
		 if(k==0)
		 {  cout<<-1<<endl;  return 0;
		 }
		 
		   if(n==3)
		   {
			     cout<<max(v[1],1)<<max(0,v[2])<<max(0,v[3])<<endl;
		   }
		  else if(n==2)
		   {
			     cout<<max(v[1],1)<<max(0,v[2])<<endl;
		   }
		   else
		      cout<<max(0,v[1])<<endl;
		   
    
    }



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

using namespace std;

int main(){
  string S; cin >> S;
  int res = 0;
  for(int i=0;i<S.size();i++){
    int v = S.size()-1-i;
    if(i >= v) break;
    if(S[i] != S[v]) ++res;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import scala.io.StdIn.{readLine,readInt}
 
object Main {
 
  def main(args: Array[String]) = {
    val n = readInt
    val rooms = Array.ofDim[Int](4,3,10)
 
    (1 to n).par foreach { _ =>
      val v = readLine.split(" ").map(_.toInt)
      rooms(v(0)-1)(v(1)-1)(v(2)-1) += v(3)
    }
 
    for(b <- 0 to 3) {
      for(f <- 0 to 2) {
        for(r <- 0 to 9) {
          print(" "+rooms(b)(f)(r))
        }
        println()
      }
      if(b!=3) {
        println("####################")
      }
    }
  }
}


Measured memory_bytes: 46208
from collections import deque

K = int(input())
q = deque()
for i in range(1, 10):
    q.append(i)
for _ in range(K - 1):
    x = q.popleft()
    if x % 10:
        q.append(10 * x + x % 10 - 1)
    q.append(10 * x + x % 10)
    if x % 10 != 9:
        q.append(10 * x + x % 10 + 1)
print(q.popleft())


Measured memory_bytes: 11908
using namespace std;

#include<iostream>



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

    int num[5];
    for(int i = 0;i<4;i++)
    {
        num[i] = N % 10;

        N /= 10;
    }

    if(num[1] == num[2])
    {
        if(num[1] == num[0] || num[2] == num[3])
        {
            cout << "Yes" << endl;
            return 0;
        }

    }

    cout << "No" << endl;

}

Measured memory_bytes: 256
import copy

n=int(input())
a=[int(x) for x in input().rstrip().split()]
ac=copy.deepcopy(a)

now=0
ans1=0
for i in range(n):
  now+=a[i]
  if i%2==0:
    if now<=0:
      ans1+=abs(now)+1
      now=1
  else:
    if 0<=now:
      ans1+=abs(now)+1
      now=-1

now=0
ans2=0
for i in range(n):
  now+=a[i]
  if i%2==0:
    if 0<=now:
      ans2+=abs(now)+1
      now=-1
  else:
    if now<=0:
      ans2+=abs(now)+1
      now=1
print(min(ans1,ans2))

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

int main(){
  int A, B;
  int max;
  int num1,num2,num3;

  cin >> A >> B;
  num1 = A + B;
  num2 = A - B;
  num3 = A * B;
  max = num1;
  if( max < num2 ) {
    max = num2;
  }
  if( max < num3 ) {
    max = num3;
  }

  cout << max << endl;
}


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

int main() {
	int h,w,n;
	cin>>h>>w>>n;
	swap(h,w);
	vector<int> mn[200001];
	int temp,temp2;

	for(temp=1;temp<=h;temp++)	mn[temp].push_back(w+1);
	//titik-titiknya masukkin set
	typedef pair<int,int> point;

	set<point> s;
	for(temp=0;temp<n;temp++)	{
		int x,y;
		cin>>x>>y;
		swap(x,y);
		if(y>=x) {
			s.insert({x,y});
		}
		if(y>x) {
			mn[x].push_back(y);
		}
	}


	int ans=10e8;
	int lststop=2;
	for(temp=1;temp<=h;temp++) {
		//bisa turun kagak
		sort(mn[temp].begin(),mn[temp].end());
		int idx=lower_bound(mn[temp].begin(),mn[temp].end(),lststop)-mn[temp].begin();

		ans=min(ans,mn[temp][idx]);

		while(s.find({temp+1,lststop})!=s.end())	lststop++;

		if(lststop==w+1)	break;
		lststop++;

	}
	cout<<ans-1<<"\n";
}

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

signed main() {
	int n;
	cin >> n;
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			if(i*j == n){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
struct Comparator
{
    bool operator() (const std::pair<ll int , ll int >& a, const std::pair<ll int , ll int >& b) const
    {
        if(a.F>b.F)
        	return true;
        else
        	return false;
    }
};	
int main()
{
    fast;
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
   // #endif
    ll int n;
    cin>>n;
    ll int a[n];ll int i;
    map<ll int,ll int> mp;
    multiset<pair<ll int,ll int>,Comparator> s;
    for(i=0;i<n;i++)
    {
    	cin>>a[i];
    	//mp[a[i]]++;
   
    }
    sort(a,a+n);
    ll int ans=0;
    for(i=n-1;i>=0;i--)
    {
    	if(s.empty()==true)
    	{
    		s.insert(MP(a[i],1));
    		mp[a[i]]=1;
    	}
    	else
    	{
    		pair<ll int,ll int> p=*(s.begin());
    		ans+=p.F;//cout<<a[i]<<" "<<ans<<endl;
    		if(p.F==a[i])
    		{
    			p.S++;
    			mp[p.F]++;
    			s.erase(s.begin());
    			s.insert(p);
    		}
    		else
    		{
    			
    			auto u=s.find(MP(a[i],mp[a[i]]));
    			if(u==s.end())
    			{

    				s.erase(s.begin());
    				mp[p.F]--;
    				p.S--;
    				if(p.S!=0)
    				s.insert(p);
    				s.insert(MP(a[i],2));
    				mp[a[i]]=2;
    			}
    			else
    			{
    				s.erase(s.begin());
    				mp[p.F]--;
    				p.S--;
    				if(p.S!=0)
    				s.insert(p);
    				s.erase(u);
    				s.insert(MP(a[i],mp[a[i]]+2));
    				mp[a[i]]+=2;
    			}
    		}

    	}

    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 23940
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    System.out.println(n%2==0?n/2:n/2+1);
  }
}

Measured memory_bytes: 21204
//                             ¯\_(ツ)_/¯   
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mma,ava,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),(a).end()
#define ll long long
 
 
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
 
const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;


int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	int D;
	scanf("%d",&D);
	std::vector<int> c(26);
	for(int i=0;i<26;i++)scanf("%d",&c[i]);
	std::vector<vector<int>> s(D,vector<int>(26));
	for(int i = 0;i<D;i++){
		for(int j=0;j<26;j++){
			scanf("%d",&s[i][j]);
		}
	}
	int S = 0;
	std::vector<int>last(26);
	for(int i=0;i<D;i++){
		for(int j=0;j<26;j++){
			S-=c[j]*(i-last[j]);
		}
		int who = 1;
		int mx = 0;
		for(int j=0;j<26;j++){
			if(mx < s[i][j] +c[j]*(i-last[j])){
				mx = s[i][j] +c[j]*(i-last[j]);
				who = j+1;
			}
		}
		last[who-1] = i;
		S+= mx;
		printf("%d\n",who );
	}
}

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

bool solve() {
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    for ( int h = 0; h < H; h++ ) {
        cin >> A[h];
    }
    for ( int h = 1; h < H; h++ ) {
        for ( int w = 1; w < W; w++ ) {
            if ( A[h][w] == '#' ) {
                if ( A[h-1][w] == '#' && A[h][w-1] == '#' ) return false;
            }
        }
    }
    for ( int h = 0; h < H-1; h++ ) {
        for ( int w = 0; w < W-1; w++ ) {
            if ( A[h][w] == '#' ) {
                if ( A[h+1][w] == '#' && A[h][w+1] == '#' ) return false;
            }
        }
    }
    return true;
}

int main() {
    string ans = solve() ? "Possible" : "Impossible";
    cout << ans << "\n";
    return 0;
}

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

using namespace std;
typedef long long ll;
#define tr(container, it) \
	for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c,x) ((c).find(x) != (c).end())   //O(log n) 
#define contains(c,x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define Ichar(_x) char _x;scanf("%c",&_x);
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define inc(a,b,x)(x)>a && (x)<b	
#define incE(a,b,x)(x)>=a && (x)<=b	
#define max(a,b) (a)>=(b)? (a) : (b) 
#define fileio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
const double pi = 3.14159265358979323846;

int main()
{
	ll s = 0;
	Iint(a);
	Iint(b);
	Iint(c);
	for (int i = 0; i < pow(10, 9); ++i)
	{
		s += i;
	}
	if(c>=a && c<=a+b)std::cout << "YES";
	else { std::cout << "NO"; }


	
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
typedef long long ll;
const ll MOD=1e9+7;
ll dp[2],ans=0,num[100004],q=0;
int main(){
	num[0]=1;
	for (int i=1;i<=1e5;i++) num[i]=num[i-1]*3%MOD;
	cin>>s;
	for (int i=0;i<s.size();i++){
		if (s[i]=='A'){
			dp[0]=(dp[0]+num[q])%MOD;
		}
		if (s[i]=='B'){
			dp[1]=(dp[1]+dp[0])%MOD;
		}
		if (s[i]=='C'){
			ans=(ans+dp[1])%MOD; 
		}
		if (s[i]=='?'){
			ans=(ans*3+dp[1])%MOD;
			dp[1]=(dp[1]*3+dp[0])%MOD;
			dp[0]=(dp[0]*3+num[q])%MOD;
			q++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define A first
#define B second

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	const int MAX = 10000;
	int N, T;
	vector<pair<int,int>> in;
	vector<int> dp(MAX, 0);
	
	cin>>N>>T;
	
	in.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>in[i].A>>in[i].B;
	}
	
	sort(in.begin(), in.end());
	
	dp[0] = 0;
	
	for(int i = 0; i < N; i++){
		for(int j = T-1; j >= 0; j--){
			dp[j+in[i].A] = max(dp[j] + in[i].B, dp[j+in[i].A]);
		}
	}
	

	cout<<*max_element(dp.begin(), dp.end())<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


//System.out.println();
public class Main implements Runnable { //クラス名はMain

    public static void main(String[] args) {
    	Thread.setDefaultUncaughtExceptionHandler((t,e)->System.exit(1));
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
    }

    public void run() {
    	try {
	    	FastScannerCaracalVsMonster sc = new FastScannerCaracalVsMonster(System.in);

	        long H = sc.nextLong();

	        String bin = Long.toBinaryString(H);

	        //System.out.println(bin);
	        String conv = bin.substring(0,1) + bin.substring(1).replace("1", "0");
	        //System.out.println(conv);

	        long convi = Long.parseLong(conv, 2);

	        System.out.println(convi*2-1);

    	}catch(Exception e) {
    		e.printStackTrace();
    	}

    }
}


//高速なScanner
class FastScannerCaracalVsMonster {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerCaracalVsMonster(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> L(M), R(M);
  for(int i = 0; i < M; i++){
    cin >> L[i] >> R[i];
  }

  int maxL = 1;
  int minR = N;
  for(int i = 0; i < M; i++){
    maxL = max(maxL, L[i]);
    minR = min(minR, R[i]);
  }

  int ans = minR - maxL + 1;
  ans = max(ans, 0);
  cout << ans << endl;
  
}

Measured memory_bytes: 1024
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val x = sc.nextInt()
    val y = sc.nextInt()
    val z = sc.nextInt()
    println("$z $x $y")
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 31264
import numpy as np

N=int(input())
A=[]
for i in range(N):
  A.append(int(input()))
  
m1=np.max(A)
m1i=np.argmax(A)

A.remove(m1)
m2=np.max(A)

for i in range(N):
  if i!=m1i:
    print(m1)
  else:
    print(m2)

Measured memory_bytes: 24256
#include <bits/stdc++.h>
using namespace std;
int N;
long long x,y;
int main(){
    cin>>N;
    cin>>x>>y;N--;
    while(N--){
        int a,b;
        cin>>a>>b;
        x=a*max((x+a-1)/a,(y+b-1)/b);
        y=b*max((x+a-1)/a,(y+b-1)/b);
    }
    cout<<x+y<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    int m; cin >> m;
    int d; cin >> d;
    int ans = 0;
    REP(i, d){
        int day = i+1;
        int day_one = day % 10;
        int day_ten = day / 10;
        if (day_one <= 1){
            continue;
        }
        if (day_ten <= 1){
            continue;
        }
        REP(j, m){
            int month = j+1;
            if (month == day_one*day_ten){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
mod = 998244353
half = pow(2, mod - 2, mod)
maxA = max(A) + 1


def main():
    cnt = [0] * maxA
    for Ai in A:
        cnt[Ai] += 1

    w = [pow(i, mod-2, mod) for i in range(maxA)]
    for i in range(1, maxA):
        for j in range(i * 2, maxA, i):
            w[j] = (w[j] - w[i]) % mod

    ans = 0
    for i in range(1, maxA):
        s = s2 = 0
        for j in range(i, maxA, i):
            s = (s + (j * cnt[j])) % mod
            s2 = (s2 + (j * j * cnt[j])) % mod
        ans += w[i] * ((((s ** 2) % mod - s2) % mod) * half) % mod
        ans %= mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 118136
#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct sparse_table{
	function<T(T, T)> merge;
	int size, lg;
	vector<vector<T>> table;
	sparse_table(const vector<T> vals, function<T(T, T)> merge) : size(vals.size()), merge(merge){
		init(vals);
	}
	void init(const vector<T> &vals){
		lg = __builtin_clz(1) - __builtin_clz(size) + 1;
		table.assign(lg, vector<T>(size, T()));
		for (int i = 0; i < size; i++)
			table[0][i] = vals[i];
		for (int i = 1; i < lg; i++){
			for(int j = 0; j + (1<<i) <= size; j++){
				table[i][j] = merge(table[i - 1][j], table[i - 1][j + (1<<(i - 1))]);
			}
		}
	}
	T get(int l, int r){
		int ilg = __builtin_clz(1) - __builtin_clz(r - l + 1);
		return merge(table[ilg][l], table[ilg][r - (1<<ilg) + 1]);
	}
};
const int maxn = 200200;
int main(){
	int n, k; cin >> n >> k;
	vector<int> vals(n), nxt(n);
	for(int i = 0; i < n; i++) cin >> vals[i];
	nxt[n - 1] = n;
	for(int i = n - 2; i >= 0; i--)
		if(vals[i + 1] > vals[i]) nxt[i] = nxt[i + 1];
		else nxt[i] = i;
	sparse_table<int> p(vals, [](int a, int b){ return min(a, b); });
	sparse_table<int> q(vals, [](int a, int b){ return max(a, b); });
	int ans = 0, dont = 0;
	for(int i = 1; i < n - k + 1; i++){
		if(p.get(i - 1, i + k - 2) == vals[i - 1] && q.get(i, i + k - 1) == vals[i + k - 1]);
		else if(nxt[i] >= i + k - 1) dont = 1;
		else ans++;
	}
	if(nxt[0] < k - 1) ans++;
	else dont = 1;
	cout << ans + dont << endl;
	return 0;
}


Measured memory_bytes: 31584
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=(s); i<(n); i++)
using namespace std;
using ll = long long;
 
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
    int N;
    cin >> N;
 
    vector<int> h(N+1);
    rep(i,1,N+1) cin >> h[i];
 
    int sum = 0;
    rep(i,0,N+1) sum += max(h[i] - h[i - 1], 0);

    cout << sum << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c;

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

	if ((a < b) && (b < c))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 2068
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include<string>
#include <stack>
#include<queue>
#include<map>
#include <stdlib.h>
#include <bits/stdc++.h>
#include <set>

using namespace std;

int main() {
	int n;
	bool f = false;
	string s, t, w;
	cin >> n >> s >> t;
	w = s.substr(0);
	if (w == t) {
		cout << s.length() << endl;
		return 0;
	}
	for (int i = 0; i < s.length(); i++) {
		w = s.substr(s.length() - i);
		if (w == t.substr(0, i) && w != "") {
			cout << (s.substr(0, s.length() - i) + t).length() << endl;
			f = true;
		}

	}
	if (f == false) {
		cout << (s + t).length() << endl;
	}

	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var W, a, b int
	fmt.Scan(&W, &a, &b)
	ans := 10000000
	if a <= b && b <= a + W {
		ans = 0
	} else if a + W < b {
		ans = b - (a + W)
	} else {
		ans = a - (b + W)
	}
	fmt.Println(ans)
}


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

namespace Competition
{
    public class Program
    {
        static string abcd = "";
        static void Main(string[] args)
        {
            abcd = Console.ReadLine();
            dfs(abcd.Length, abcd[0].ToString(), 0, int.Parse(abcd[0].ToString()));

        }

        public static void dfs(int n, string f, int i, int sum)
        {
            if (i == n - 1)
            {
                if (sum == 7)
                {
                    Console.WriteLine(f + "=7");
                    Environment.Exit(0);
                }
            }
            else
            {
                dfs(n, f + "+" + abcd[i + 1], i + 1, sum + int.Parse(abcd[i + 1].ToString()));
                dfs(n, f + "-" + abcd[i + 1], i + 1, sum - int.Parse(abcd[i + 1].ToString()));
            }
            
        }

    }
}


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

#define ll long long
#define int long long
#define loop(i,s,e) for(int i=s;i<e;i++)
#define rloop(i,s,e) for(int i=e;i>=s;i--)
#define fr first
#define sc second
#define pb push_back
#define  vii vector<int>
#define vll vector<ll>
#define vpii vector<pair<int ,int >>
#define vpll vector<pair<ll, ll> >
#define  pii pair<int,int>
#define lb(v,x) lower_bound(v.begin(),v.end(),x);
#define ub(v,x) upper_bound(v.begin(),v.end(),x);
const long mod =1e9+7;
const int N = 2e5+10;
const long long inf= 1e18;

ll gcd(ll a ,ll b){if(b==0) return a;return gcd(b,a%b);}
ll mul(ll a ,ll b){return (a%mod * b%mod )%mod;}
ll mpower(ll a, ll b){if(b==0) return 1;ll temp=mpower(a,b/2);if(b%2==0){return mul(temp,temp);}else{	return mul(mul(temp,temp) , a);}}
ll inv(ll a){return mpower(a,mod-2);}
ll ncr(ll n, ll r){if(r==0)return 1;ll ans=n%mod;ans=mul(ans,ncr(n-1,r-1));ans=mul(ans,inv(r));	return ans;}
ll power(ll a, ll b){if(b==0) return 1;ll temp=power(a,b/2);if(b%2==0)return temp*temp;else return temp*temp*a;}
ll add(ll a, ll b){return (a%mod + b%mod)%mod;}


void solve()
{
  int n,m;cin>>n>>m;
  int a[n+1];
  loop(i,1,n+1)cin>>a[i];
  
  int ans[n+1];loop(i,1,n+1)ans[i]=1;
  
  loop(i,0,m)
  {
      int x,y;
      cin>>x>>y;
      if(a[x]==a[y])
      {
          ans[x]=0;
          ans[y]=0;
      }
      else if(a[x]<a[y])ans[x]=0;
      else
      {
          ans[y]=0;
      }
  }
  int cnt=0;
  loop(i,1,n+1)
  {
      if(ans[i])cnt++;
  }
  cout<<cnt;
  

    
}

int32_t main()
{
	ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;//cin>>t;
	while(t--){
        solve();
	}
}

Measured memory_bytes: 5216
#include<iostream>
#include<math.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
  
using namespace std;

int main() {
	int a, b, c, d, tmp, count = 0;
	cin >> a >> b;
	tmp = b;
	while ( tmp >= 10 ) {
		tmp /= 10;
		count++;
	}
	c = a;
	REP(i,count+1) c *= 10;
	c += b;
	d = floor ( sqrt ( c ) );
	if ( d*d == c ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;	
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
class state{
public:
  int p,d;
  bool operator<(const state & a)const{
    if (d != a.d)return d > a.d;
    return p < a.p;
  }
};

main(){
  int n;
  while(cin>>n&&n ){
    int a[10]={0};
    rep(i,n){
      int t;cin>>t;a[t]++;
    }
    rep(i,10){
      if (a[i]==0)cout <<'-';
      else rep(j,a[i])cout << '*';
      cout << endl;
    }


  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

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

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
using namespace std;
#define rep(i, n) for ( int i = 0; i < (int)n; i++)
#define MAX 1024

class Rule{
    public:
    bool permit;
    char s[16];
    Rule(bool p=false):permit(p){}

    void check(string a, bool &acc){
	rep(i, 16){
	    if ( s[i] == '?' ) continue;
	    if ( s[i] != a[i]) return;
	}
	acc = permit;
    }

};
int n, m;
Rule R[MAX];

bool accept(string s){
    bool acc = false;
    rep(i, n) R[i].check(s, acc);
    return acc;
}

main(){
    string p, s, d;
    while( cin >> n >> m){
	if ( n == 0 && m == 0 ) break;
	rep(i, n){
	    cin >> p >> s >> d;
	    R[i] = Rule( p=="permit");
	    rep(a, 8) R[i].s[a] = s[a];
	    rep(a, 8) R[i].s[a+8] = d[a];
	}
	vector<pair<pair<string, string>, string> > ans;
	rep(i, m){
	    cin >> s >> d >> p;
	    if ( accept(s+d) ) ans.push_back(make_pair(make_pair(s, d), p));
	}
	cout << ans.size() << endl;
	rep(i, ans.size()){
	    cout << ans[i].first.first << " " << ans[i].first.second << " " << ans[i].second << endl;
	    
	}
    }
}

Measured memory_bytes: 988
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>

using namespace std;

#define PI 3.14159265358979323846
#define INF 1e+9
#define DIV_NUM (1000000007)



int main() {

	int N;
	cin >> N;
	vector<long long> inputs;
	for (int i = 0; i < 3 * N; i++) {
		long long tmp;
		cin >> tmp;
		inputs.push_back(tmp);
	}

	priority_queue<long long, vector<long long>, greater<long long>> first_half;
	long long sum_first = 0;
	for (int i = 0; i < N; i++) {
		first_half.push(inputs[i]);
		sum_first += inputs[i];
	}
	vector<long long> sum_array_first;
	sum_array_first.resize(N+1);
	sum_array_first[0] = sum_first;
	for (int i = 1; i < N+1; i++) {
		first_half.push(inputs[N - 1 + i]);
		sum_first += inputs[N - 1 + i];
		sum_first -= first_half.top();
		first_half.pop();
		sum_array_first[i] = sum_first;
	}

	priority_queue<long long> last_half;
	long long sum_last = 0;
	for (int i = 0; i < N; i++) {
		last_half.push(inputs[3 * N - 1 - i]);
		sum_last += inputs[3 * N - 1 - i];
	}
	vector<long long> sum_array_last;
	sum_array_last.resize(N+1);
	sum_array_last[N] = sum_last;
	for (int i = 1; i < N+1; i++) {
		last_half.push(inputs[2 * N - i]);
		sum_last += inputs[2 * N - i];
		sum_last -= last_half.top();
		last_half.pop();
		sum_array_last[N - i] = sum_last;
	}

	long long maxval = -(1e+15);
	for (int i = 0; i < N + 1; i++) {
		maxval = max(maxval, sum_array_first[i] - sum_array_last[i]);
	}

	cout << maxval << endl;

	return 0;
}


Measured memory_bytes: 7660
N,K=map(int,input().split())
LV=list(map(int,input().split()))

Ntake=min(N,K)
Vsum=[]

i=0
while i<=Ntake:
    M=K-i
    j=0
    while j<=i:
        Vtake=[]
        p=1
        while p<=j:
            Vtake.append(LV[p-1])
            p+=1
        p=1
        while p<=i-j:
            Vtake.append(LV[-p])
            p+=1
        Vtake.append(0)
        Vtake.sort()
        k=0
        while k<=M-1:
            if Vtake[0]<0:
                del Vtake[0]
                k+=1
            else:
                k+=M
        Vsum.append(sum(Vtake))
        j+=1
    i+=1

print(max(Vsum))

Measured memory_bytes: 3064