akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
  long long int n , ans = 0; 
  cin>>n;
  long long int a[n*3];
  
  for (long long int i = 0; i < n * 3 ; i++) 
  {
    cin>>a[i];
  }
  sort(a, a + 3 * n);
  for (long long int i = n; i < n*3; i+=2)
  {
    ans += a[i];
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll dp[111111];

int main(){
	
	int n;cin >> n;
	vector<ll> v(n);
	REP(i,n)cin >> v[i];
	
	REP(i,111111)dp[i] = LLINF;
	dp[0] = 0;
	REP(i,n){
		if(i+1 < n)dp[i+1] = min(dp[i+1], dp[i] + abs(v[i] - v[i+1]));
		if(i+2 < n)dp[i+2] = min(dp[i+2], dp[i] + abs(v[i] - v[i+2]));
	}
	
	cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 1920
using System;
using System.Linq;

class B
{
	static void Main() => Console.WriteLine(string.Join("\n", from x in new int[int.Parse(Console.ReadLine())].Select((_, i) => $"{i + 1} {Console.ReadLine()}".Split()) orderby x[1], -int.Parse(x[2]) select x[0]));
}


Measured memory_bytes: 13908
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::slice::*;

fn main() {
    let (r, w, e) = (stdin(), stdout(), stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    // =============================================== //
    let (n, k): (usize, usize) = (io.read(), io.read());
    let a = io.readn::<usize>(n);

    // a[0]未満にすればok?

    let mut dp = vec![false; k + 3];
    dp[0] = false;

    for i in 1..(k + 1) {
        for j in 0..n {
            if i >= a[j] {
                dp[i] |= !dp[i - a[j]];
            }
        }
    }
    io.writeln(if dp[k] { "First" } else { "Second" });
}

// IO
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug ) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner scan = new Scanner(System.in);
		while(true){
			int H = scan.nextInt();
			int W = scan.nextInt();
			int i = 0;
			int i2 = 0;
			
			if ((H==0) && (W==0)) break;
			
			for (i=0; i<H; i++){
				for (i2=0; i2<W; i2++){
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}

}

Measured memory_bytes: 34816
from collections import deque
K=int(input())
d = deque([1,2,3,4,5,6,7,8,9])
i=0
while 1:
  i+=1
  a=d.popleft()
  if i==K:
    print(a);exit()
    
  b=a%10
  if b==0:
    d.append(int(str(a)+"0"))
    d.append(int(str(a)+"1"))
  elif b==9:
    d.append(int(str(a)+"8"))
    d.append(int(str(a)+"9"))
  else:
    d.append(int(str(a)+str(b-1)))
    d.append(int(str(a)+str(b)))
    d.append(int(str(a)+str(b+1)))

    
    
    

Measured memory_bytes: 49112
n , k = map(int,input().split())
p = {}
for i in range(n):
    a , b = map(int,input().split())
    p[a] = p.get(a,0) + b

ans = sorted(p.items())
cou = 0
for i , j in ans:
    cou += j
    if cou >= k:
        print(i)
        exit()

Measured memory_bytes: 14560
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl '\n'
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N,0);
    vector<ll> B(N,0);
    for(ll i=0;i<N;++i)cin>>A[i]>>B[i];
    if(A==B){prt(0)return 0;}
    ll sum=0;
    for(ll i=0;i<N;++i)sum+=A[i];
    ll mark=INF;
    for(ll i=0;i<N;++i){
        if(A[i]>B[i])chmin(mark,B[i]);
    }
    prt(sum-mark)


    return 0;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

type SortName [][]int

func (x SortName) Len() int           { return len(x) }
func (x SortName) Less(i, j int) bool { return x[i][1] < x[j][1] }
func (x SortName) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(stringLineScan())
	q, _ := strconv.Atoi(stringLineScan())
	tree := make([][]int, n)
	for i := 0; i < n; i++ {
		t := make([]int, 0)
		tree[i] = t
	}
	for i := 0; i < n-1; i++ {
		a, _ := strconv.Atoi(stringLineScan())
		b, _ := strconv.Atoi(stringLineScan())
		a--
		b--
		tree[a] = append(tree[a], b)
		tree[b] = append(tree[b], a)
	}
	depthlist := make([]int, n)
	for i := 1; i < n; i++ {
		depthlist[i] = -1
	}
	depthlist = dfs(0, 0, tree, depthlist)
	px := make([]int, n)
	for i := 0; i < q; i++ {
		p, _ := strconv.Atoi(stringLineScan())
		x, _ := strconv.Atoi(stringLineScan())
		px[p-1] += x
	}
	depthidx := make([][]int, n)
	for i, d := range depthlist {
		t := make([]int, 2)
		t[0], t[1] = i, d
		depthidx[i] = t
	}
	sort.Sort(SortName(depthidx))
	for i := 0; i < n; i++ {
		idx, d := depthidx[i][0], depthidx[i][1]
		for _, j := range tree[idx] {
			if depthlist[j] < d {
				px[idx] += px[j]
			}
		}
	}
	fmt.Println(strings.Trim(fmt.Sprint(px), "[]"))
}
func dfs(init int, depth int, tree [][]int, depthlist []int) []int {
	depthlist[init] = depth
	depth++
	for _, i := range tree[init] {
		if depthlist[i] == -1 {
			depthlist = dfs(i, depth, tree, depthlist)
		}
	}
	return depthlist
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

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

    int n;
    cin >> n;
    vector<pair<int, int> > Students;
    rep(i, n) {
      int s;
      cin >> s;
      Students.push_back(make_pair(s, i + 1));
    }

    sort(all(Students));

    stl_rep(itr, Students) {
      cout << itr->second << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1780
N, M = [int(n) for n in input().split()]
S = input().split() if M != 1 else [input()]
X = [int(s) for s in S]

def main():
    x = sorted(X)
    costs = []
    for i in range(M - 1):
        costs.append(abs(x[i] - x[i + 1]))
    costs.sort()
    ans = sum(costs[:(-(N - 1) if N != 1 else M)])
    print(ans)

if __name__== '__main__':
    main()

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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

long long factrial[10000000];
long long Repeat(long long a, long long cnt) {
    if(cnt == 0) return 1LL;
    if(cnt % 2 == 1) {
        long long x = Repeat(a, cnt / 2);
        return (((a * x) % MOD) * x) % MOD;
    } else {
        long long x = Repeat(a, cnt / 2);
        return (x * x) % MOD;
    }
}

long long fact(long long a) {
    if(a == 0)
        return 1LL;
    else if(factrial[a] != 0)
        return factrial[a];
    else
        return factrial[a] = (a * fact(a - 1)) % MOD;
}

long long comb(long long a, long long b) {
    if(a<b)return 0;
    long long fa, fb, fab;
    fa = fact(a);
    fb = fact(b);
    fab = fact(a - b);
    fb = Repeat(fb, MOD - 2);
    fab = Repeat(fab, MOD - 2);
    return (((fa * fb) % MOD) * fab) % MOD;
}

int main() {
    ll n, m, i, j, k;
    cin >> n >> k;
    vector<ll> A(n);
    for(i=0;i<n;i++)cin >> A[i];
    sort(A.rbegin(),A.rend());
    ll ret = 0;
    for(i=0;i<n;i++){
        ret += A[i]*comb(n-i-1,k-1);
        ret %= MOD;
    }
    reverse(A.begin(),A.end());
    for(i=0;i<n;i++){
        ret += MOD - A[i] * comb(n-i-1,k-1);
        ret %= MOD; 
    }
    cout << ret << endl;
    return 0;
}

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

int main(){
	string line;
	cin>>line;
	for(int x=0,y=line.size()-1;x<y;++x,--y){
		char el = line[x];
		line[x] = line[y];
		line[y] = el;
	}
	cout<<line<<endl;
	return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    int n;cin>>n;
    int cnt=0;
    rep(i,n){
        int p;cin>>p;
        if(p!=i+1)cnt++;
    }
    cout<<(cnt<=2?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    while(cin >> n >> m){
        vector<ll> dp(100001, 0);
        REP(i, n) {
            int w, v; cin >> w >> v;
            RREP(j, 100001 - w) {
                chmax(dp[j + w], dp[j] + v);
            }
        }
        ll ans = 0;
        RREP(j, m + 1) {
            chmax(ans, dp[j]);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1LL<<60
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> G[n];
  int bx[n];
  bool ch[n] = { };
  ch[0] = true;
  REP(i, n) bx[i] = 1;
  REP(i, m){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    bx[a]--;
    bx[b]++;
    if(ch[a]) ch[b] = true;
    if(bx[a] == 0) ch[a] = false;
  }
  int ans = 0;
  REP(i, n)if(ch[i]) ans++;
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c,k;
	cin>>a>>b>>c>>k;
	if(a>k){
		cout<<k<<endl;
	}
	else if(a+b>=k){
		cout<<a<<endl;
	}
	else{
		cout<<a-(k-(a+b))<<endl;
	}
	return 0;
	
}

Measured memory_bytes: 3644
#include <stdio.h>

int main(){
	int height[10];
	int i, j;
	for(i=0; i<10; i++){
		scanf("%d", &height[i]);
		if(!(0 <= height[i] && height[i] <= 10000))
			i--;
	}

	for(i=0; i<10; i++){
		for(j=0; j<i; j++){
			if(height[j] > height[i]){
				int tmp= height[j];
				height[j] = height[i];
				height[i] = tmp;
			}
		}
	}
	for(i=0; i<3; i++){
		printf("%d\n", height[9-i]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef pair<char, int> P;

int main(void) {
  int N, K;
  string S;
  cin >> N >> K >> S;
  vector<P> v;
  for (int i = 0; i < S.length();) {
    char c = S[i];
    int cnt = 0;
    while (i < S.length() && S[i + cnt] == c) cnt++;
    v.push_back(P(c, cnt));
    i += cnt;
  }

  int ans = 0;
  int cnt = 0;
  int sum = 0;
  for (int l = 0, r = 0; r < v.size(); r++) {
    while (r < v.size()) {
      if (cnt >= K && v[r].first == '0') break;
      if (v[r].first == '0') {
        cnt++;
      }
      sum += v[r].second;
      r++;
    }
    if (r < v.size()) r--;
    ans = max(ans, sum);
    if (v[l].first == '0') cnt--;
    sum -= v[l].second;
    l++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1528
#include <stdio.h>

int main(void){
  int N,D,X;
  scanf("%d%d%d",&N,&D,&X);
  int A;
  int ans = 0;

  for(int i = 0;i < N;i++){
    scanf("%d",&A);
    int counter = 0;
    while(A*counter+1 <= D){
      counter++;
    }
    ans += counter;
  }

  printf("%d\n",ans+X);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {0, -1, 0, 1, 1, 1, -1, -1};
int dy[] = {-1, 0, 1, 0, 1, -1, 1, -1};

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

  string s;
  cin >> s;

  int ans = 0;
  int l = 0, r = s.size() - 1;
  while(r > l) {
    if(s[l] == s[r]) {
      l++; r--;
    }
    else if(s[l] == 'x') {
      l++; ans++;
    }
    else if(s[r] == 'x') {
      r--; ans++;
    }
    else return cout << -1 << endl, 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#define FOR(i, n) for(int i = 0; i < n; i++) 
using namespace std;

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

void load() {
}

void solve() {
	int n; scanf("%d", &n);
	int k; scanf("%d", &k);
	int h[n]; FOR(i, n) scanf("%d", h + i);
	int cnt = 0;
	FOR(i, n) cnt += (h[i] >= k);
	printf("%d\n", cnt);
}

int main() {
	load();
	solve();
	return 0;
}


Measured memory_bytes: 512
import sys

x=input()
y=int(x)
lst=[]
Min=1000

while y>0:
  lst.append(y%10)
  y//=10
lst.reverse()

for k in range(len(lst)-2):
  z=abs(753-abs(lst[k]*100+lst[k+1]*10+lst[k+2]))
  if z<Min:
    Min=z

print(Min)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	int n,ans=0;
	scanf("%d",&n);
	a[0]=0;a[n+1]=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		ans+=abs(a[i]-a[i-1]);
	}
	ans+=abs(a[n+1]-a[n]);
	for(int i=1;i<=n;i++)
		if((a[i]>=a[i-1]&&a[i]<=a[i+1])||(a[i]<=a[i-1]&&a[i]>=a[i+1]))printf("%d\n",ans);else
			if(a[i]>=a[i-1]&&a[i]>=a[i+1])printf("%d\n",ans-2*(a[i]-max(a[i-1],a[i+1])));else
				if(a[i]<=a[i-1]&&a[i]<=a[i+1])printf("%d\n",ans-2*(-a[i]+min(a[i-1],a[i+1])));
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main() {
	cout << fixed << setprecision(10);
	int64_t n, k;
	cin >> n >> k;
	vector<double> p(n);
	for (int i = 0; i < n; i++)cin >> p.at(i);
	for (int i = 0; i < n; i++) {
		p.at(i) = (p.at(i) + 1.0) / 2.0;
	}
	double ans = 0;
	double zan = 0;
	for (int i = 0; i < k; i++) {
		zan += p.at(i);
	}
	ans = zan;
	for (int i = 0; i < n - k; i++) {
		zan -= p.at(i);
		zan += p.at(i + k);
		ans = max(ans, zan);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
//deque problem
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i=a;i<b;i++)
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define prDouble(x) cout<<fixed <<setprecision(10)<<x
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

 ll dp[3001][3001][2];

ll solve(vector<int>&Deq,int i,int j,bool turn)
{
   if(i>j)
   return 0;

   if(dp[i][j][turn]!=-1)
   return dp[i][j][turn];

   if(turn==1)
   return dp[i][j][turn]=max((Deq[i]+solve(Deq,i+1,j,0))
                              ,(Deq[j]+solve(Deq,i,j-1,0)));
    
    else return dp[i][j][turn]=min(solve(Deq,i+1,j,1),solve(Deq,i,j-1,1));
}
int main()
{
    int n;
    cin>>n;
    vector<int>Deq(n+1);
    memset(dp,-1,sizeof dp);
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>Deq[i];
        sum+=Deq[i];
    }
    ll scoreX=solve(Deq,1,n,1);
    ll scoreY=(sum-scoreX);

    cout<<scoreX-scoreY;
    return 0;
}

Measured memory_bytes: 141184
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

ll cal(ll num, ll base){
    ll ret = 0 ;
    while(num !=0){
        ret += num % base;
        num /= base;
    }
    return ret;
}

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

    ll N;
    cin >> N;

    ll ans = N;
    rep(i, N+1){
        ans = min(ans, cal(i, 6) + cal(N-i, 9));
    }
    cout << ans << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if (x <= (a+b)/2){
    if (a < b){
      cout << "A" << endl;
    }
    else {
      cout << "B" << endl;
    }
  }
  else {
    if (a < b){
      cout << "B" << endl;
    }
    else {
      cout << "A" << endl;
    }
  }
}

Measured memory_bytes: 256
def resolve():
  N = int(input())
  A = [int(x) for x in input().split(" ")]

  diff_of_rate = [0]*(N-1)
  diff_of_rate = []
  diff_of_rate.append({"index": 0, "diff": 0, "price": A[0]})
  for i in range(N-1):
    if (diff_of_rate[-1]["diff"] <= 0 and A[i+1] - A[i] <= 0) or (diff_of_rate[-1]["diff"] >= 0 and A[i+1] - A[i] >= 0):
      diff_of_rate[-1]["index"] = i+1
      diff_of_rate[-1]["diff"] += A[i+1] - A[i]
      diff_of_rate[-1]["price"] = A[i+1]
    else:
      diff_of_rate.append({
        "index": i+1,
        "diff": A[i+1] - A[i],
        "price": A[i+1]
      })

  # print(diff_of_rate)

  # 初期ステータス
  money = 1000
  stock = 0
  price = A[0]

  # 初日の購入
  if diff_of_rate[0]["diff"] > 0:
    stock += money//price
    money = money%price
    
  for index, diff in enumerate(diff_of_rate):
    if diff["diff"] < 0 and index < len(diff_of_rate)-1:
      # 購入
      stock += money//diff["price"]
      money = money%diff["price"]
    else:
      #売却
      money += stock*diff["price"]
      stock = 0

  print(money)

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 62132
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,l;
	cin>>n>>l;
	string tmp[101];
	for(int i=1;i<=n;i++)
		cin>>tmp[i];
	stable_sort(tmp+1,tmp+n+1);
	for(int i=1;i<=n;i++)
		cout<<tmp[i];
}

Measured memory_bytes: 256
nums = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(nums[int(input())-1])

Measured memory_bytes: 9068
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main implements Runnable {

	int N;
	int[] x;

	public void solve() {
		N = nextInt();
		x = new int[N];

		if(N == 1){
			out.println("! 1");
			out.flush();
			return;
		}

		int s = -1;
		int maxDis = 0;
		for (int i = 2; i <= N; i++) {
			out.println(String.format("? %d %d", 1, i));
			out.flush();
			int d = nextInt();

			if(maxDis < d){
				maxDis = d;
				s = i;
			}
		}
		for(int i = 1;i <= N;i++){
			if(i == s)continue;
			out.println(String.format("? %d %d", i, s));
			out.flush();
			int d = nextInt();
			x[d] = i;
		}
		x[0] = s;
		out.print("!");
		for (int i = 0; i < N; i++) {
			out.print(" "+x[i]);
		}
		out.println();
		out.flush();
	}

	public static void main(String[] args) {
		new Thread(null, new Main(), "", 64 * 1024 * 1024).start();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

	@Override
	public void run() {
		out.flush();
		new Main().solve();
		out.close();

	}
}

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

int main(){
  int N,count=0,k=0;
  cin>>N;
  vector <int> m(N);
  for(int i=0; i<N; i++)
    cin>>m.at(i);
  sort(m.begin(),m.end());
  for(int i=0; i<N; i++){
    if(k<m.at(i)){
      count++;
      k=m.at(i);
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    PriorityQueue pq = new PriorityQueue<>(Collections.reverseOrder());
    for (int i = 0; i < N; i++) {
      pq.add(Long.parseLong(sc.next()));
    }
    for (int i = 0; i < M; i++) {
      long max = (Long)pq.peek(); 
      pq.poll();
      pq.add(max/2);
    }
    long total = 0;
    for (Object q : pq.toArray()) {
		 total += (Long) q;
    }
    System.out.println(total);
  }
}

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

int main() {
  int n;
  cin >> n;
  int sum = 0;
  int x = n;
  
  for (int i = 0; i < 9; i++) {
    sum += x % 10;
    x /= 10;
    
    if (x == 0)
      break;
  }
  
  if (n % sum == 0)
    cout << "Yes" << endl;
  
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python

def main(N, W):
    ans = float('inf')
    for i in range(1, N):
        tmp = abs(sum(W[i:]) - sum(W[:i]))
        if tmp < ans:
            ans = tmp
    return ans

if __name__ == '__main__':
    N = int(input())
    W = list(map(int, input().split()))
    print(main(N, W))


Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

int main(){
    int N;
    
    cin >> N;
    cout << N * N * N << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  string s;
  int a = 0, b = 0, c = 0;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 1; j < (int) s.size(); j++) {
      if (s[j - 1] == 'A' && s[j] == 'B') ans++;
    }
    if (s[0] == 'B' && s.back() == 'A') c++;
    else if (s[0] == 'B') b++;
    else if (s.back() == 'A') a++;
  }
  if (c == 0) ans += min(a, b);
  else {
    if (a + b > 0) {
      ans += c + min(a, b);
    } else {
      ans += c - 1;
    }
  }
  cout << ans << endl;
  return 0;
}

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

long long int a[n+1],b[n+1],c[n];

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

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

for(int i=0;i<n-1;i++){
  cin>>c[i];
}

for(int i=0;i<n;i++){
sum=sum+b[a[i]-1];
if(aaa==a[i]-2){
  sum=sum+c[a[i]-2];
}
aaa=a[i]-1;

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


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int n = sc.nextInt();
        final int m = sc.nextInt();

        final long[] h = new long[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextLong();
        }

        final boolean[] good = new boolean[n];
        for (int i = 0; i < n; i++) {
            good[i] = true;
        }

        for (int i = 0; i < m; i++) {
            final int a = sc.nextInt();
            final int b = sc.nextInt();
            if (h[a-1] <= h[b-1]) {
                good[a-1] = false;
            }
            if (h[b-1] <= h[a-1]) {
                good[b-1] = false;
            }
        }

        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (good[i]) ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 60100
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;

class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int lb = -1, ub = N;
        if (ub - lb == 2) {
            ub--;
        }
        while (ub - lb > 1) {
            int mid = (lb + ub) / 2;
            List<Integer> aList = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                if (i != mid) {
                    aList.add(a[i]);
                }
            }
            boolean[][] dp = new boolean[N - 1][K];
            dp[0][0] = true;
            if (aList.get(0) < K) {
                dp[0][aList.get(0)] = true;
            }
            for (int i = 1; i < N - 1; i++) {
                for (int j = 0; j < K; j++) {
                    dp[i][j] = dp[i - 1][j];
                    if (aList.get(i) <= j) {
                        dp[i][j] |= dp[i - 1][j - aList.get(i)];
                    }
                }
            }

            int tmp = lb;
            lb = mid;
            for (int i = Math.max(0, K - a[mid]); i < K; i++) {
                if (dp[N - 2][i]) {
                    ub = mid;
                    lb = tmp;
                    break;
                }
            }
        }
        System.out.println(ub);
    }
}

Measured memory_bytes: 181072
#include<bits/stdc++.h>
using namespace std;
long long n,m,a[101],b[101],c[101],d[101],cnt,sum;
int main(){
	scanf("%lld%lld",&n,&m);
	for(register int i=1;i<=n;++i)
		cin>>a[i]>>b[i];
	for(register int i=1;i<=m;++i)
		cin>>c[i]>>d[i];
	for(register int i=1;i<=n;++i){
		long long ans=999999999;
		for(register int j=1;j<=m;++j){
			cnt=abs(a[i]-c[j])+abs(b[i]-d[j]);
			if(cnt<ans) {
				ans=cnt;
				sum=j;
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; -i)
#define INF (1 << 30)

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

int D, N;
int T[200];
int A[200], B[200], V[200];
int dp[201][201];

int main() {
	scanf("%d %d", &D, &N);
	rep(i, D) scanf("%d", &T[i]);
	memset(dp, 0, sizeof(dp));
	rep(i, N) scanf("%d %d %d", &A[i], &B[i], &V[i]);
	FOR(i, 1, D) rep(j, N) {
		if(A[j] <= T[i] && B[j] >= T[i]) {
			rep(k, N) {
				if(A[k] <= T[i-1] && B[k] >= T[i-1]) {
					dp[i][j] = max(dp[i][j], dp[i-1][k] + abs(V[j] - V[k]));
				}
			}
		}
	}
	int ans = -1;
	rep(i, N) ans = max(ans, dp[D-1][i]);
	printf("%d\n", ans);
	return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = INT_MAX / 2;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int l = max(a, c), r = min(b, d);
	cout << max(0, r - l) << endl;
}


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

using namespace std;

int main(){
    int c = 0;
    string s, ss;
    cin >> s >> ss;
    for(int i = 0; i < s.size(); i++)
        if (s[i] != ss[i])
            c++;
    cout << c;

    return 0;
}




Measured memory_bytes: 3776
import sys
input = lambda : sys.stdin.readline().rstrip()

n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    edge[v - 1].append([w, u - 1])
    edge[u - 1].append([w, v - 1])

# O(ElogV)
import heapq
def dijkstra(s):
    # 始点sから各頂点への最短距離
    d = [float('inf')]*n
    d[s] = 0
    # 各頂点が訪問済みかどうか
    used = [False]*n
    used[s] = True
    # 仮の距離を記録するヒープ
    que = []
    for e in edge[s]:
        heapq.heappush(que, e)
    while que:
        minedge = heapq.heappop(que)
        if used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = True
        for e in edge[v]:
            if not used[e[1]]:
                heapq.heappush(que, [e[0] + d[v], e[1]])
    return d

d = dijkstra(0)
ans = [0]*n

for i in range(n):
    if d[i] % 2 == 1:
        ans[i] = 1

for i in ans:
    print(i)

Measured memory_bytes: 89248
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>

using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define ull unsigned long long
#define ll long long
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}

int x,y;
int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	cin >> x >> y;
	if(x % y == 0) {cout << -1 << endl;}
	else {cout << x << endl;}
}




Measured memory_bytes: 892
void chmin(int & a, int b) { if (a > b) a = b; }

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

int A, B, C;

int dfs(vector<int> & L, int i, int a, int b, int c) {
	// 終端条件
	if (i == L.size()) {
		if (!a || !b || !c) return (1 << 30);
		return abs(a - A) + abs(b - B) + abs(c - C);
	}

	// 分岐処理
	int res = dfs(L, i + 1, a, b, c);
	chmin(res, dfs(L, i + 1, a + L[i], b, c) + (a ? 10 : 0));
	chmin(res, dfs(L, i + 1, a, b + L[i], c) + (b ? 10 : 0));
	chmin(res, dfs(L, i + 1, a, b, c + L[i]) + (c ? 10 : 0));

	return res;
}

int main(void) {
	// 入力
	int N;
	cin >> N >> A >> B >> C;
	vector<int> L(N);
	rep(i, N) scanf("%d", &L[i]);

	// 深さ優先探索
	cout << dfs(L, 0, 0, 0, 0) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,ans=0x7f7f7f7f,a[505][505];
int p[505],d[505],vis[505];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)
		p[i]=1,d[a[i][1]]++;
	for(int i=1;i<=m;i++)
	{
		int nd=0;
		for(int j=1;j<=m;j++)
		if(!vis[j])
			if(d[j]>d[nd]) nd=j;
		ans=min(ans,d[nd]);
		vis[nd]=1;
		for(int j=1;j<=n;j++)
		{
			d[a[j][p[j]]]--;
			while(vis[a[j][p[j]]]) p[j]++;
			d[a[j][p[j]]]++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;
//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


vector<int> zfunc(string s){
	int n = s.length();
	vi z(n,0);
	for(int i =1,l=0,r=0;i<n;i++){
		if(i<=r)
			z[i] = min(r-i+1,z[i-l]);
		while(i+z[i]<n && s[z[i]]==s[i+z[i]])
			z[i]++;
		if(i+z[i]-1>r){
			 l=i;r=i+z[i]-1;
		}
	}
	return z;
}

void solve(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	for(int i=0;i<n;i++){
		vi zf = zfunc(s.substr(i,(n-i)));
		dbg(zf);
		for(int j =0;j<n-i-1;j++){
			ans = max(ans,min(zf[j],j));
		}
	}
	cout << ans << endl;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 3712
# coding: utf-8
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in "753") else 0
    for c in "753":
        ret += dfs(s + c)
    return ret

print(dfs("0"))

Measured memory_bytes: 2940
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int oddNum = 0;
    for (int i = 0; i < N; i++) {
      int A = sc.nextInt();
      if (A%2 == 1) {
        oddNum++;
      }
    }
    System.out.println(oddNum%2 == 0 ? "YES" : "NO");
  }
}

Measured memory_bytes: 50204
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<string>

using namespace std;

int main()
{
    string s, t;

    cin >> s >> t;

    for (int i = 0; i < s.length(); i++) {
        s = s[s.length() - 1] + s.substr(0,s.length() - 1);

        if (s == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;

    
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
int n,m,a,b;
int arr[200001];
int lol[200001];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    for (int i=1;i<=n;i++){
        cin>>arr[i];
    }
    for (int i=0;i<m;i++){
        cin>>a>>b;
        lol[a]=max(lol[a],arr[b]);
        lol[b]=max(lol[b],arr[a]);
    }
    int ans=0;
    for (int i=1;i<=n;i++){
        if (arr[i]>lol[i]) ans++;
    }
    cout<<ans;
}

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

int main() {
  long long S;
  cin>>S;
  long long Ans=0;
  if(S%2==1){cout<<0<<endl;}else
  {S=S/10;Ans+=S;while(S>0){Ans+=S/5;S=S/5;}cout<<Ans<<endl;}
}


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

string S;
int w;
signed main() {
    cin >> S >> w;
    for (int i = 0; i < S.length(); i += w) {
        cout << S[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
import math
while True:
    line=input()
    a=[]
    op=[]
    b=[]
    t = line.split(" ")
    a.append(int(t[0]))
    op.append(t[1])
    b.append(int(t[2]))

    if op[0] == "?":
        break
    else:
        if op[0] == "+":
            print(a[0]+b[0])
        elif op[0] == "-":
            print(a[0]-b[0])
        elif op[0] == "*":
            print(a[0]*b[0])
        else:
            print(math.floor(a[0]/b[0]))


Measured memory_bytes: 5664
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
long long int N,D;
int c=0;
long long int x,y;
cin>>N>>D;
while(N){
    cin>>x>>y;
    if(((x*x) + (y*y)) <= (D*D)){
        c++;
    }
    N--;
}
cout<<c;    
return 0;
}

Measured memory_bytes: 3628
N=int(input())
S=list(str(input()))
r=S.count('R')
g=S.count('G')
b=S.count('B')
count=0

for i in range(int((N-3)/2)+1):
    for k in range(N-i*2-3+1):
        if S[k]!=S[k+i+1] and S[k]!=S[k+2*i+2] and S[k+i+1]!=S[k+2*i+2]:
            count+=1
print(r*g*b-count)

Measured memory_bytes: 9208
#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> lpair;
ll N, X, D;
const ll INF = 1LL << 60;

map<ll , vector<lpair>> sumTbl;

ll count(vector<lpair> &list) {
	ll count = 0;
	ll last = -INF;
	for (vector<lpair>::iterator it = list.begin(); it != list.end(); it++) {
		ll start = it->first;
		ll end = it->second;
		count += max(0LL, end - max((start - 1LL), last));
		last = max(last, end);
	}
	return count;
}

int main(void) {
	cin >> N >> X >> D;
	if (D == 0) {
		if (X == 0) {
			cout << 1 << endl;
		} else {
			cout << N + 1 << endl;
		}
		return 0;
	}
	if (D < 0) {
		D = -D;
		X = -X;
	}
	for (ll k = 0; k <= N; k++) {
		ll mod = (k * X) % D;
		if (mod < 0) {
			mod += D;
		}
		map<ll , vector<lpair>>::iterator it = sumTbl.find(mod);
		if (it == sumTbl.end()) {
			sumTbl[mod] = vector<lpair>();
			it = sumTbl.find(mod);
		}
		ll start = ((k - 1) * k / 2 * D + k * X - mod) / D;
		ll end = ((2 * N - k - 1) * k / 2 * D + k * X - mod) / D;
		lpair p(start, end);
		vector<lpair> &list = it->second;
		list.push_back(p);
	}
	ll cnt = 0;
	for (map<ll , vector<lpair>>::iterator it = sumTbl.begin(); it != sumTbl.end(); it++) {
		vector<lpair> &list = it->second;
		sort(list.begin(), list.end());
		cnt += count(list);
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 22144
'use strict';
(function(stdin) {
  // ????????????????????????
  var EOF = '0';
  var inputs = stdin.toString().split('\n');
  var data = inputs.slice(0,inputs.indexOf(EOF));
  
  for (var i = 0; i < data.length; i++) {
  	console.log('Case',i + 1 + ':',data[i]);
  }

  // for (var index in data){
  // 	console.log('Case',parseInt(index,10) + 1 + ':',data[index]);
  // }

  // data.forEach(function(d,i,o){
  // 	console.log('Case',i + 1 + ':',d);
  // });

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

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

using namespace std;

int main(){
int a;
cin>>a;
vector <int> v={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cout<<v[a-1];

return 0;

}


Measured memory_bytes: 256
'use strict'

function Main(input) {
  const A = input.split(" ")[0]
  let B = input.split(" ")[1]
  let ans = 0

  if(B <= 1) {
    console.log(0)
    return
  }
  
  for(let i=0; i<100; i++) {
    if(i === 0) {
      B -= A
    } else {
      B -= (A - 1)
    }
    ans++
    if(B <= 0) {
      break
    }
  }
  console.log(ans)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim())


Measured memory_bytes: 21064
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let d: usize = iterator.next().unwrap().parse().unwrap();

    let t: usize = d * 2 + 1;
    let ans = if n % t == 0 {
        n / t
    } else {
        n / t + 1
    };

    return ans.to_string();
}


Measured memory_bytes: 2096
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int A = int.Parse(Console.ReadLine());
		int[]B = new int[A];
		for(var i=0;i<A;i++){
			B[i] = int.Parse(Console.ReadLine());
		}
		Array.Sort(B);
		long sum = 0;
		for(var i=0;i<A-1;i++){
			sum += B[i];
		}
		sum += B[A-1]/2;
		Console.WriteLine(sum);
	}
}

Measured memory_bytes: 11092
// CPP program to illustrate 
    // Implementation of push() function 
    #include <iostream> 
    #include <stack> 
    using namespace std; 
     
    int main() 
    { int n,mx=0,my=0,mz=0;
    cin>>n;
     if(n==1)
     {
         int a,b,c;
     cin>>a>>b>>c;
       int M= max(a,b);
       cout<<max(M,c);
       return 0;
     }
    n--;
    int a,b,c;
    cin>>a>>b>>c;
    int tempa=a,tempb=b,tempc=c;
    while(n--){
    cin>>a>>b>>c;
    mx=a+max(tempb,tempc);
    my=b+max(tempa,tempc);
    mz=c+max(tempa,tempb);
    tempa=mx;
    tempb=my;
    tempc=mz;
    	} 
    int m= max(mx,my);
    cout<<max(m,mz);
        
    } 

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	// Code for C - 100 to 105
	var X int
	fmt.Scanf("%d", &X)

	var flag int = 0
	for i := 0; 100*i <= X; i++ {
		for j := 0; 100*i+101*j <= X; j++ {
			for k := 0; 100*i+101*j+102*k <= X; k++ {
				for l := 0; 100*i+101*j+102*k+103*l <= X; l++ {
					for m := 0; 100*i+101*j+102*k+103*l+104*m <= X; m++ {
						if (X-(100*i+101*j+102*k+103*l+104*m))%105 == 0 {
							flag = 1
							break
						}

						//for n := 0; 100*i+101*j+102*k+103*l+104*m+105*n <= X; n++ {
						//	if X == 100*i+101*j+102*k+103*l+104*m+105*n {
						//		flag = 1
						//		break
						//	}
						//}
						//if flag == 1 {
						//	break
						//}
					}
					if flag == 1 {
						break
					}
				}
				if flag == 1 {
					break
				}
			}
			if flag == 1 {
				break
			}
		}
		if flag == 1 {
			break
		}
	}

	if flag == 1 {
		fmt.Println("1")
	} else {
		fmt.Println("0")
	}
}


Measured memory_bytes: 1836
use proconio::input;

fn main() {
    input! {
        n: usize
    }

    if n % 2 == 1 {
        println!("0")
    } else {
        let n = n/2;
        let ans = {
            let mut ans = 0;
            let mut count = 5;
            while count <= n {
                ans += n/count;
                count *= 5;
            }
            ans
        };
        println!{"{}",ans}
    }
}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

bool DEBUG = 0;
const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	ll a[n];
	forn(i,0,n) cin>>a[i];
	
	int cnt=0;
	forn(i,0,n){
		if(i%2==0 && a[i]%2==1) cnt++;
	}
	cout<<cnt<<'\n';
	
	return 0;
}


Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int main(void){
  int k, n, sum, max = 0, i, a1, a, b, sa;
  cin >> k >> n >> a1 >> a;
  max = a - a1;
  for(i = 1; i < n - 1; i++){
    cin >> b;
    sa = b - a;
    if(max < sa){
      max = sa;
    }
    a = b;
  }
  sa = k - a + a1;
  if(max < sa){
    max = sa;
  }
  sum = k - max;
  cout << sum;
  return 0;
}

Measured memory_bytes: 384