akhauriyash/Code-Regression huggingface dataset:
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	vector<pair<char,int>>A,B,C,D;
	int i,j;
	while(-1){
		char c;cin>>c;
		if(c=='$'){break;}
		int x;cin>>x;
		A.pub(mp(c,x));
	}
	while(-1){
		char c;cin>>c;
		if(c=='$'){break;}
		int x;cin>>x;
		B.pub(mp(c,x));
	}
	while(-1){
		char c;cin>>c;
		if(c=='$'){break;}
		int x;cin>>x;
		C.pub(mp(c,x));
	}
	int n=A.size(),m=B.size();
	for(i=0;i+m<=n;i++){
		//スタート
		bool ok=true;
		if(A[i].fir!=B[0].fir){continue;}
		if(A[i].sec<B[0].sec){continue;}
		for(j=1;j+1<m;j++){
			if(A[i+j]!=B[j]){ok=false;}
		}
		if(!ok){continue;}
		if(A[i+m-1].fir!=B[m-1].fir){continue;}
		if(A[i+m-1].sec<B[m-1].sec){continue;}
		
		A[i].sec-=B[0].sec;
		if(m==1){i--;}
		for(j=1;j<m-1;j++){A.erase(A.begin()+i+1);}
		if(m>1){A[i+1].sec-=B[m-1].sec;}
		for(j=C.size()-1;j>=0;j--){A.insert(A.begin()+i+1,C[j]);}
		break;
	}
	for(auto it:A){
		if(it.sec==0){continue;}
		if(D.size()==0||D.back().fir!=it.fir){D.pub(it);}
		else{D.back().sec+=it.sec;}
	}
	for(auto it:D){cout<<it.fir<<" "<<it.sec<<" ";}
	cout<<"$"<<endl;
	return 0;
}


Measured memory_bytes: 3168
#include <stdio.h>
#include <algorithm>
using namespace std;

int N, C, A[6], bc[1 << 5];
int P[333], Q[333], M[1<<5][1<<5], V;
long long prv[333][333];
long long nxt[333][333];

int main()
{
	scanf("%d %d", &N, &C);
	for (int i = 0; i < N; i++) scanf("%d", &A[i]);
	sort(A, A + N);

	int b = (1 << (N - 1));
	prv[0][A[N - 1] * N] = nxt[0][A[N - 1] * N] = 1;
	for (int i = 1; i < b; i++) bc[i] = bc[i - (i&(-i))] + 1;
	for (int i = 0; i < b; i++) for (int j = 0; j < b; j++) if (bc[i] == bc[j]) {
		P[V] = i; Q[V] = j;
		M[i][j] = V++;
	}
	for (int t = 0; t < N*C; t++) {
		for (int i = 0; i < V; i++) {
			int p = P[i], q = Q[i], d = t % N - 1;
			if (d < 0 || (q & (1 << d))) continue;
			for (int k = t; k <= N*C; k++) if (prv[i][k]) {
				for (int j = 0; j < N-1; j++) if (~p & (1 << j)) {
					int x = min(N*C, max(k, t + A[j] * N));
					nxt[M[p + (1 << j)][q + (1 << d)]][x] += prv[i][k];
				}
			}
		}
		for (int i = 0; i < V; i++) for (int k = 0; k <= N*C; k++) prv[i][k] = nxt[i][k];
	}

	double ans = prv[V-1][N*C];
	for (int i = 1; i < N; i++) {
		ans /= i;
		ans /= C;
	}

	printf("%.16lf\n", ans);

	return 0;
}

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

int isPrime(int x){
    int i;
    if(x<2) return 0;
    else if(x==2)return 1;
    if(x%2==0) return 0;
    for(i=3; i*i <= x; i+=2){
        if(x%i == 0) return 0;
    }
    return 1;
}

int main() {
    int x;
    cin >> x;
    int ans;
    for(int i=x; i<1000000; i++){
        if(isPrime(i)){
            ans=i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
struct digit{
        int first;
        int second;
        int third;
};
int main(){
        int n,score[200]={0};
        digit number[200];
        cin >> n;
        for( int i=0 ; i<n ; i++ )
                cin >> number[i].first >> number[i].second >> number[i].third;
        digit sign[200];
        for( int i=0 ; i<n ; i++ ){
                sign[i].first=sign[i].second=sign[i].third=0;
                for( int j=0 ; j<n ; j++ ){
                        if(i!=j && number[i].first==number[j].first )
                                sign[i].first=1;
                        if(i!=j && number[i].second==number[j].second)
                                sign[i].second=1;
                        if(i!=j && number[i].third==number[j].third)
                                sign[i].third=1;
                }
                if(!sign[i].first)
                        score[i]+=number[i].first;
                if(!sign[i].second)
                        score[i]+=number[i].second;
                if(!sign[i].third)
                        score[i]+=number[i].third;
        }
        for( int i=0 ; i<n ; i++ )
                cout << score[i] << endl;
        return 0;
}

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

using namespace std;


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

    int n,i,ans=0;
    string str;
    cin>>n>>str;
    for(i=0;i<n-1;i++){
        if(str[i]!=str[i+1])ans++;
    }
    cout<<ans+1<<'\n';
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    int tmp;
    cin>>a>>b;
    if(a<b){
        tmp=a;
        a=b;
        b=tmp;
    }
    int r;
    r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    cout<<b;
    cout<<endl;
}



Measured memory_bytes: 3104
#include<iostream>
using namespace std;
int main()
{
	long long n,m;
	cin>>n>>m;
	if(n==1&&m==1)
	{
		cout<<1<<endl;
		return 0;
	}
	if(n==1&&m==2||n==2&&m==1)
	{
		cout<<0<<endl;
		return 0;
	}
	if(n==1)
	{
		cout<<m-2<<endl;
		return 0;
	}
	if(m==1)
	{
		cout<<n-2<<endl;
		return 0;
	}
	if(n==2&&m==2)
	{
		cout<<0<<endl;
		return 0;
	}
	cout<<(n-2)*(m-2)<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *COYG, 14 FA Cups we are back baby
 */
#include <bits/stdc++.h>
using namespace std;
#define mod 		1000000007
#define ll 		long long
#define mp 		make_pair
#define pb 		push_back
#define forn(i,n) 	for(int i=0;i<n;i++)
#define for1(i,n) 	for(int i=1;i<n;i++)
#define ford(i,n) 	for(int i=n-1;i>=0;i--)
#define vi 		vector<int>
#define vl 		vector<ll>
#define pii 		pair<int,int>
#define pll 		pair<ll,ll>
#define vpi 		vector<pair<int,int> >
#define vpl		vector<pair<ll,ll> >
#define vvi 		vector<vector<int> >
#define vvl 		vector<vector<ll> >
#define ull 		unsigned long long
#define IOS 		ios_base::sync_with_stdio(false);
#define PI 		3.1415926535897932384626
#define ff 		first
#define ss 		second
#define char2Int(c) 	(c-'0')
#define FOREACH(i,t) 	for (auto i=t.begin(); i!=t.end(); i++)
#define clr(a,x) 	memset(a,x,sizeof(a)) //set elements of array to some value
#define all(x)		(x).begin(),(x).end()//cout<<"Case #"<<zzz<<": ";
#define plll pair<ll,pll >
void solve()
{
    ll n;cin>>n;vl a(n);vl h(n);
    forn(i,n)cin>>h[i];
    forn(i,n)cin>>a[i];
    ll base=1;
    while(base<=n)
    {
        base*=(ll)2;
    }
    vl tree(2*base);
    vl dp(n);
    for(int i=0;i<n;i++)
    {
        ll currans=0;
        ll ptr=base+h[i];
        while(ptr>1)
        {
            if(ptr&1)
                currans=max(currans,a[i]+tree[ptr-1]);
            ptr/=2;
        }
        dp[i]=currans;
        ptr=base+h[i];
        while(ptr>1)
        {
            tree[ptr]=max(tree[ptr],currans);
            ptr/=2;
        }
    }
    ll ans=0;
    forn(i,n)ans=max(ans,dp[i]);
    cout<<ans<<endl;
}
int main()
{
    IOS;cin.tie(NULL);
    ll zz;zz=1;
    //cin>>zz;
    for(int zzz=1;zzz<=zz;zzz++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 11876
using System;
using System.Collections.Generic;

public class CSharp
{
    public static void Main()
    {
        Kyopuro chokudai = new Kyopuro();
        chokudai.AtCoder();
    }
}

public class Kyopuro
{

    int n, m, k;

    public void AtCoder()
    {
        string[] input;
        input = Console.ReadLine().Split(' ');
        n = int.Parse(input[0]);
        int[] a = new int[n+1];
        int[] b = new int[n+1];
        input = Console.ReadLine().Split(' ');
        for (int i=1; i<=n; i++)
        {
            a[i] = int.Parse(input[i-1]);
        }
        int ans = 0;
        for(int i=n; i>0; i--)
        {
            if (a[i] == 1)
            {
                b[i] = 1;
                ans++;
                for (int j = 1; j * j <= i; j++)
                {
                    if (i % j == 0)
                    {
                        a[j]++;
                        if (a[j] == 2) a[j] = 0;
                        if (j == i / j) continue;
                        a[i / j]++;
                        if (a[i / j] == 2) a[i / j] = 0;
                    }
                }
            }
        }
        Console.WriteLine(ans);
        for(int i=1; i<=n; i++)
        {
            if (b[i] == 1) Console.WriteLine(i);
        }

    }
    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
}


Measured memory_bytes: 28252
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
  let s: String = read();
  let t: String = read();
  let a: Vec<i32> = compute(s);
  let b: Vec<i32> = compute(t);

  if a == b {
    println!("Yes");
  } else {
    println!("No");
  }
}

fn compute(s: String) -> Vec<i32> {
  let mut d = vec![0; 26];
  for b in s.into_bytes() {
    let cid = (b - b'a') as usize;
    d[cid] += 1;
  }
  d.sort();
  d
}

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

const double PI = acos(-1);
pair<double, double> calcCenter(double x1, double x2, double x3, double y1, double y2, double y3)
{
    double cx, cy;
    //幾何学的に求める
    //thanks for https://blog.mori-soft.com/entry/%3Fp%3D170
    double ex, ey; //(x1, y1)と(x2, y2)の中点
    double fx, fy; //(x2, y2)と(x3, y3)の中点
    ex = (x1 + x2) / 2;
    ey = (y1 + y2) / 2;
    fx = (x2 + x3) / 2;
    fy = (y2 + y3) / 2;
    double tanCE = tan(atan((y2 - y1) / (x2 - x1)) + PI / 2);
    double tanCF = tan(atan((y3 - y2) / (x3 - x2)) + PI / 2);
    cx = (ey - fy - ex * tanCE + fx * tanCF) / (tanCF - tanCE);
    cy = ey - (ex - cx) * tanCE;
    return make_pair(cx, cy);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<double> xPoints(N);
    vector<double> yPoints(N);
    for (int i = 0; i < N; i++)
    {
        double X, Y;
        cin >> X >> Y;
        xPoints.at(i) = X;
        yPoints.at(i) = Y;
    }
    double answer = 100000;
    //二点を直径にしたケースで満たすもの最小
    for (int i = 0; i < N - 1; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            double cx, cy;
            cx = (xPoints.at(i) + xPoints.at(j)) / 2;
            cy = (yPoints.at(i) + yPoints.at(j)) / 2;
            double r2 = pow(abs(cx - xPoints.at(j)), 2) + pow(abs(cy - yPoints.at(j)), 2);
            bool isEncloseAll = true;
            for (int k = 0; k < N; k++)
            {
                double checkR2 = pow(abs(cx - xPoints.at(k)), 2) + pow(abs(cy - yPoints.at(k)), 2);
                if (r2 < checkR2)
                {
                    isEncloseAll = false;
                    break;
                }
            }
            if (isEncloseAll)
            {
                answer = min(answer, sqrt(r2));
            }
        }
    }
    //三点を外周に含むケースで満たすもの最小
    for (int i = 0; i < N - 2; i++)
    {
        for (int j = i + 1; j < N - 1; j++)
        {
            for (int k = j + 1; k < N; k++)
            {
                double cx, cy;
                tie(cx, cy) = calcCenter(xPoints.at(i), xPoints.at(j), xPoints.at(k), yPoints.at(i), yPoints.at(j), yPoints.at(k));

                double r2 = pow(abs(cx - xPoints.at(i)), 2) + pow(abs(cy - yPoints.at(i)), 2);
                r2 = max(r2, pow(abs(cx - xPoints.at(j)), 2) + pow(abs(cy - yPoints.at(j)), 2));
                r2 = max(r2, pow(abs(cx - xPoints.at(k)), 2) + pow(abs(cy - yPoints.at(k)), 2));
                bool isEncloseAll = true;
                for (int m = 0; m < N; m++)
                {
                    double checkR2 = pow(abs(cx - xPoints.at(m)), 2) + pow(abs(cy - yPoints.at(m)), 2);
                    if (r2 < checkR2)
                    {
                        isEncloseAll = false;
                        break;
                    }
                }
                if (isEncloseAll)
                {
                    answer = min(answer, sqrt(r2));
                }
            }
        }
    }

    cout << fixed << setprecision(11) << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
#define pii pair<int , int>
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())

int main()
{
	int n, m;
	cin >> n >> m;
	int tot = n * (n - 1) / 2;
	tot += m * (m - 1) / 2;
	cout << tot;
		
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s[] = sc.next().split("");
		int ans = 0;
		for (int i = 0; i < s.length; i++)
			ans += Integer.parseInt(s[i]);
		System.out.println(ans);
	}
}

Measured memory_bytes: 21204
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int[] result = {0,0,0,0};
        int n = sc.nextInt();
        for (int i=0;i<n;i++){
            String s = sc.next();
            switch (s) {
                case "AC":
                    result[0]++;
                    break;
                case "WA":
                    result[1]++;
                    break;
                case "TLE":
                    result[2]++;
                    break;
                default:
                    result[3]++;
                    break;
            }
        }
        System.out.println("AC x "+result[0]);
        System.out.println("WA x "+result[1]);
        System.out.println("TLE x "+result[2]);
        System.out.println("RE x "+result[3]);

    }
}


Measured memory_bytes: 58420
#include<bits/stdc++.h>
#include<iostream>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#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(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
//Warshall_Floyd
vector<vector<ll> >d(310,vector<ll>(310,inf));
void Warshall_Floyd(ll n){
    REP(k,0,n+1){
        REP(i,0,n+1){
            REP(j,0,n+1)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
        }
    }
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w;cin>>h>>w;
    rep(i,10){
        rep(j,10){
            cin>>d[i][j];
        }
    }
    Warshall_Floyd(10);
    ll ans=0;
    rep(i,h){
        rep(j,w){
            ll a;cin>>a;
            if(a<0)continue;
            ans+=d[a][1];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
let s = stdin.ReadLine()

let ans =
  let rIntervals, lIntervals =
    let rIntervals = ResizeArray<int * int> []
    let lIntervals = ResizeArray<int * int> []

    let mutable left = ('R', 0)
    for i in 1 .. s.Length - 1 do
      if fst left = 'R' && s.[i] = 'L' then
        rIntervals.Add((snd left, i - 1))
        left <- ('L', i)
        if i = s.Length - 1 then
          lIntervals.Add((i, i))
      elif fst left = 'L' then
        if s.[i] = 'R' then
          lIntervals.Add((snd left, i - 1))
          left <- ('R', i)
        elif i = s.Length - 1 then
          lIntervals.Add((snd left, i))

    [ for i in rIntervals -> i ], [ for i in lIntervals -> i ]

  List.zip rIntervals lIntervals
  |> List.collect (
    fun ((rl, rr), (ll, lr)) ->
      [rl .. lr]
      |> List.map (
        fun i ->
          if i = rr then
            ([rl .. rr].Length + 1) / 2 + [ll .. lr].Length / 2 |> string
          elif i = ll then
            ([rl .. rr].Length) / 2 + ([ll .. lr].Length + 1) / 2 |> string
          else
            0 |> string ))
  |> List.toSeq

ans
|> String.concat " "
|> stdout.WriteLine

Measured memory_bytes: 34388
H, W = map(int, input().split())

if H > W:
    H, W = W, H

if H % 3 == 0 or W % 3 == 0:
    print(0)
    quit()

ans = H

b = (H // 2)

for w in range(W+1):
    tmp_1, tmp_2, tmp_3 = H * w, b * (W-w), (H-b) * (W-w)
    tmp = max(tmp_1, tmp_2, tmp_3) - min(tmp_1, tmp_2, tmp_3)
    ans = min(ans, tmp)

d = (W // 2)
for h in range(H+1):
    tmp_1, tmp_2, tmp_3 = h*W, d * (H-h), (W-d) * (H-h)
    tmp = max(tmp_1, tmp_2, tmp_3) - min(tmp_1, tmp_2, tmp_3)
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 40304
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define INF 1e9

static const int seed=6;
static const int D=365;
static const int ntype=26;
static const double swap_rate=0.6;
static const double change_rate=1.0-swap_rate;
static int ans[D+1];
static int max_score=0;
static const int t=1050000;
static const int last_swap=5000;

class Contest{
public:
    Contest(){
        last=0;
    }
    int s[D+1];
    int c;
    int last;
};

static Contest contest[ntype+1];

void Input(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int d;
    cin>>d;
    for(int i=1;i<=ntype;++i){
        int t;
        cin>>t;
        contest[i].c=t;
    }
    for(int day=1;day<=D;++day){
        for(int type=1;type<=ntype;++type){
            int t;
            cin>>t;
            contest[type].s[day]=t;
        }
    }
}

int Score(int type){
    int sum=0;
    contest[type].last=0;
    for(int day=1;day<=D;++day){
        if(ans[day]==type){
            sum+=contest[type].s[day];
            int n=day-contest[type].last;
            sum-=contest[type].c*(n*(n-1)/2);
            contest[type].last=day;
        }
    }
    if(ans[D]!=type){
        int n=D-contest[type].last;
        sum-=contest[type].c*(n*(n+1)/2);
    }
    return sum;   
}

void Output(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    for(int d=1;d<=D;++d) cout<<ans[d]<<'\n';
}

void Init(){
    for(int d=1;d<=D;++d) ans[d]=rand()%ntype+1;
}

void Greedy(){
    vector<int> l(ntype+1,0);
    int score=0;
    for(int d=1;d<=D;++d){
        for(int i=1;i<=ntype;++i) score-=contest[i].c*(d-l[i]);
        int temp=score;
        int t=-1;
        for(int i=1;i<=ntype;++i){
            int k=contest[i].s[d]+contest[i].c*(d-l[i])+score;
            if(k>temp){
                temp=k;
                t=i;
            }
        }
        ans[d]=t;
        l[t]=d;
    }
}

void change(){
    int p=rand()%D+1;
    int before=ans[p];
    int after=rand()%ntype+1;
    int before_score=Score(before)+Score(after);
    ans[p]=after;
    int delta=Score(before)+Score(after)-before_score;
    if(delta>0){ 
        max_score+=delta;
    }
    else ans[p]=before;
}

void swap(){
    int p1=rand()%D+1;
    int p2=rand()%D+1;
    while(p1==p2) p2=rand()%D+1;
    int temp_score=Score(ans[p1])+Score(ans[p2]);
    int temp=ans[p1];
    ans[p1]=ans[p2];
    ans[p2]=temp;
    int delta=Score(ans[p2])+Score(ans[p1])-temp_score;
    if(delta>0){
        max_score+=delta;
    }
    else{
        ans[p2]=ans[p1];
        ans[p1]=temp;
    }
}

void Solve(int times){
    Greedy();
    for(int i=1;i<=ntype;++i) max_score+=Score(i);
    for(int i=0;i<times;++i){
        double p=(double)rand()/RAND_MAX;
        if(p<swap_rate) swap();
        else change();
    }
    for(int i=0;i<last_swap;++i) swap();
}

int main(){
    srand(seed);
    Input();
    Solve(t);
    Output();
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll tmp1 = a*c;
    ll tmp2 = a*d;
    ll tmp3 = b*c;
    ll tmp4 = b*d;
    cout<<max(tmp1,max(tmp2,max(tmp3,tmp4)))<<endl;
}

Measured memory_bytes: 3632
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {

            string read = Console.ReadLine();
            var temp = read.Split(' ');

            int width = int.Parse(temp[0]), heigth = int.Parse(temp[1]),
                area=width*heigth,
                zhon=(width+heigth)*2;

            Console.WriteLine(area+" "+zhon);
        }
    }
}

Measured memory_bytes: 9144
def no():
    print("No")
def yes():
    print("Yes")

s=input().rstrip()
len=len(s)
#print(len)
for i in range(0,len):
    if i%2==0:
        if(s[i]=="L"):
            no()
            exit()
    else:
        if(s[i]=="R"):
            no()
            exit()
yes()

Measured memory_bytes: 2940
bool debug=false;
#include <stdio.h>
const int N=1e3+10;
const int MOD=1e9+7;
int k;
long long int f[N][N];
int min(int a,int b){return a>b?b:a;}
long long int dp(int n,int top){
	if(debug)printf("dp(%d,%d)\n",n,top);
	if(n==0||n==top)return 1;
	if(n<top)return 0;
	if(f[n][top]>-1)return f[n][top];
	f[n][top]=MOD;
	int lim=min(n,k);
	for(int i=top;i<=lim;i++)f[n][top]+=dp(n-i,i);
	if(debug)printf("f[%d][%d]=%d\n",n,top,f[n][top]);
	return f[n][top]%=MOD;
}
int main(){
	int n;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)for(int j=1;j<=k;j++)f[i][j]=-1;
	printf("%lld\n",dp(n-k,1));
}



Measured memory_bytes: 10620
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const long long MOD = 2;

void solve(long long N, std::vector<long long> a){
    a.insert(a.begin(), 0);
    vector<int> b(N + 1);

    for(int i = N; i > 0; i--) {
        int c = 0;
        for(int j = i * 2; j <= N; j += i) {
            c += b[j];
        }
        b[i] = (c + a[i]) % 2;
    }
    vector<int> d;
    for(int i = 1; i <= N; ++i) {
        if (b[i]) d.push_back(i);
    }
    cout << d.size() << endl;
    for(int i = 0; i < d.size(); ++i) {
        cout << d[i] << (i == d.size() - 1 ? "\n" : " ");
    }
}

signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


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

int to_int(char c) {
  if(c == 'o') {
    return 1;
  } else {
    return 0;
  }
}
char to_sw(int i) {
  if(i == 1) {
    return 'S';
  } else {
    return 'W';
  }
}
int main() {
  // string line = "ooxoox";
  // int N = 6;

  string s;
  int N;
  cin >> N;
  cin >> s;
  // getline(cin, line);
  int array[N];



  // ******************************
  array[0] = 1;
  array[1] = 1;

  for(int i = 2; i < N; i++) {
    array[i] = (array[i - 2] + array[i - 1] + to_int(s[i - 1])) % 2;
  }
  if ((array[0] + array[N - 2] + array[N - 1] + to_int(s[N - 1])) % 2 == 0 &&
      (array[0] + array[1] + array[N - 1] + to_int(s[0])) % 2 == 0
  ) {
    for (int i = 0; i < N; i++) {
      cout << to_sw(array[i]);
    }
    cout << endl;
    return 0;
  } else {
    // cout << -1 << endl;
  }
  // ******************************
  array[0] = 1;
  array[1] = 0;

  for(int i = 2; i < N; i++) {
    array[i] = (array[i - 2] + array[i - 1] + to_int(s[i - 1])) % 2;
  }
  if ((array[0] + array[N - 2] + array[N - 1] + to_int(s[N - 1])) % 2 == 0 &&
      (array[0] + array[1] + array[N - 1] + to_int(s[0])) % 2 == 0
  ) {
    for (int i = 0; i < N; i++) {
      cout << to_sw(array[i]);
    }
    cout << endl;
    return 0;
  } else {
    // cout << -1 << endl;
  }
  // ******************************
  array[0] = 0;
  array[1] = 1;

  for(int i = 2; i < N; i++) {
    array[i] = (array[i - 2] + array[i - 1] + to_int(s[i - 1])) % 2;
  }
  if ((array[0] + array[N - 2] + array[N - 1] + to_int(s[N - 1])) % 2 == 0 &&
      (array[0] + array[1] + array[N - 1] + to_int(s[0])) % 2 == 0
  ) {
    for (int i = 0; i < N; i++) {
      cout << to_sw(array[i]);
    }
    cout << endl;
    return 0;
  } else {
    // cout << -1 << endl;
  }
  // ******************************
  array[0] = 0;
  array[1] = 0;

  for(int i = 2; i < N; i++) {
    array[i] = (array[i - 2] + array[i - 1] + to_int(s[i - 1])) % 2;
  }
  if ((array[0] + array[N - 2] + array[N - 1] + to_int(s[N - 1])) % 2 == 0 &&
      (array[0] + array[1] + array[N - 1] + to_int(s[0])) % 2 == 0
  ) {
    for (int i = 0; i < N; i++) {
      cout << to_sw(array[i]);
    }
    cout << endl;
    return 0;
  } else {
    // cout << -1 << endl;
  }


  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for ( auto blockTime = make_pair(chrono::high_resolution_clock::now(), true);blockTime.second;\
debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
#define li long long int
#define ld long double
#define eb push_back
#define pb pop_back
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define size(a) a.size()
#define rev(a) reverse(a.begin(),a.end())
#define len(a) a.length()
#define f first
#define s second
#define sort(a) sort(a.begin(),a.end())
#define vli vector<li>
#define vvli vector<vli >
#define pli pair<li,li>
#define vpli vector<pli>
#define inp(t) li t;cin>>t; while(t--)
using namespace std;
const li mod = 1e9+7;
#define MAXN 1000005 

li power(li a, li b) { a%=mod; li ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
li add(li a,li b) { return (((a%mod)+(b%mod))%mod);}
li sub(li a,li b) { return (((a%mod)-(b%mod))%mod);}
li mul(li a,li b) { return (((a%mod)*(b%mod))%mod);}

bool isprime(li n)
{
  if (n == 1)
    return false;
  int i = 2;
  while (i*i <= n){
      if (n % i == 0)return false;
      i += 1;
  }
  return true;
}

li lcm(li a,li b)
{
    return ((a*b)/__gcd(a,b));
}

void solve()
{
  li n;
  cin>>n;

  vli v(n);
  li x = 0;
  rep(i,0,n)
  {
    cin>>v[i];
    x^=v[i];
  }

  rep(i,0,n)
  cout<<(x^v[i])<<' ';
} 

int main()
{
    IOS;

    solve();
    return 0;
}

Measured memory_bytes: 4756
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = scanner.nextInt();
    }

    long sum = 0;
    long count = 0;
    int xor = 0;
    int left = 0;
    for (int right = 1; right <= N; right++) {
      sum += A[right - 1];
      xor ^= A[right - 1];
      if (sum == xor) {
        count += right - left;
        continue;
      }
      while (sum != xor) {
        sum -= A[left];
        xor ^= A[left];
        left++;
      }
      count += right - left;
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 84220
#include<stdio.h>

int main(){
  int a, b;
  char op;

  while(1){
    int res;
    scanf("%d %c %d", &a, &op, &b);

    if(op == '+'){
      res = a + b;
    }
    else if(op == '-'){
      res = a - b;
    }
    else if(op == '*'){
      res = a * b;
    }
    else if(op == '/'){
      res = a / b;
    }
    else if(op == '?'){
      break;
    }

    printf("%d\n", res);
  }
  
  return 0;
}




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

int main() {
    vector<string> s(3);
    for(int i=0; i<3; i++){
        cin >> s[i];
    }

    cout << 'A' << s[1][0] << 'C' << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n, k; cin >> n >> k;
	vector<int> rsp(3);
	for (int i = 0; i < 3; i++) cin >> rsp[i];
	string t; cin >> t;
	vector<vector<int>> dp(k, vector<int>(3));
	vector<int> buf(3);
	auto func = [&](int id, int m) {
		for (int i = 0; i < 3; i++) {
			if (i == m) {
				buf[i] = max({ 
					dp[id][i],
					dp[id][(i + 1) % 3] + rsp[m],
					dp[id][(i + 2) % 3] + rsp[m]
				});
			}
			else {
				buf[i] = max({ dp[id][0], dp[id][1], dp[id][2] });
			}
		}
		for (int i = 0; i < 3; i++) dp[id][i] = buf[i];
	};
	for (int i = 0; i < n; i++) {
		int id = i%k;
		if (t[i] == 'r') func(id, 2);
		if (t[i] == 's') func(id, 0);
		if (t[i] == 'p') func(id, 1);
	}
	int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += max({ dp[i][0], dp[i][1], dp[i][2] });
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5120
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 1000000007;

int n,m;
int a[maxn],b[maxn];

bool f(){
  bool sign = 0;
  for(int i=1;i<=n;i++){
    b[i] = 0;
    if(a[i]<n)sign=1;
  }
  if(!sign){
    return true;
  }
  for(int i=1;i<=n;i++){
    int l = i - a[i];
    int r = i + a[i] + 1;
    l = max(l, 1);
    r = min(r, n+1);
    b[l]++;
    b[r]--;
    a[i] = 0;
  }
  for(int i=1;i<=n;i++){
    a[i]= a[i-1]+b[i];
  }
  return false;
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  cin>>n>>m;
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=1;i<=m;i++){
    if(f()){
      break;
    }
  }
  for(int i=1;i<n;i++)cout<<a[i]<<" ";
  cout<<a[n]<<endl;
  return 0;
}

Measured memory_bytes: 5140
N = int(input())
List = list(map(int,input().split()))
length = sum(List)
sum = 0
center = length / 2
centerIdx = 0
for idx in range(len(List)):
    sum += List[idx]
    if center <= sum:
        centerIdx = idx
        break

if center == sum:
    print(0)
else:
    if (centerIdx == 0):
        print(sum * 2 - length)
    elif (sum -center) < (center - (sum - List[centerIdx])):
        print(sum * 2 - length)        
    else:       
        print(length - (sum - List[centerIdx]) * 2)


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

import sys
sys.setrecursionlimit(10 ** 7)


class UnionFind:

    def __init__(self, n):
        # parent[x] < 0 means x is root and abs(parent[x]) == size[x]
        self.parent, self.depth = [-1] * (n + 1), [0] * (n + 1)

    def find(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def isSame(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)

        if self.depth[x] > self.depth[y]:
            self.parent[x] += self.parent[y]
            self.parent[y] = x
        else:
            self.parent[y] += self.parent[x]
            self.parent[x] = y
            if self.depth[x] == self.depth[y]:
                self.depth[y] += 1

    def count(self, x):
        return - self.parent[self.find(x)]


N, M = map(int, input().split())

AB = [tuple(map(int, input().split())) for _ in range(M)]
AB.reverse()

groups = UnionFind(N)
ans = [N * (N - 1) // 2]
for i in range(M):
    if groups.isSame(AB[i][0], AB[i][1]):
        ans.append(ans[-1])
    else:
        ans.append(ans[-1] - groups.count(AB[i][0]) * groups.count(AB[i][1]))
        groups.unite(AB[i][0], AB[i][1])

for i in range(M):
    print(ans[M - 1 - i])


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

int main() {
  int a;
  cin >> a;
  int ans = a + a*a + a*a*a;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<assert.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define fd(i,b,a) for(int i=(b);i>=(a);--i)
#define mset(a,x) memset(a,x,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(b))
template<typename T> bool chkmin(T &a,const T &b) {return b<a?a=b,1:0;}
template<typename T> bool chkmax(T &a,const T &b) {return b>a?a=b,1:0;}
using namespace std;
typedef long long ll;
int read(){int n=0,p=1;char ch;for(ch=getchar();ch<'0' || ch>'9';ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=2e5+5;
int n,top,a[N],b[N],c[N],q[N];
bool check(int lim)
{
	if(lim==1)
	{
		fo(i,2,n) if(a[i]<=a[i-1]) return 0;
		return 1;
	}
	while(top) q[top--]=0;
	fo(i,2,n)
		if(a[i]>a[i-1])
		{
			q[++top]=a[i],c[top]=0;
		}
		else
		{
			int p=a[i];
			while(top && q[top]>p) --top;
			if(q[top]<p) q[++top]=p,c[top]=1;
			else
			{
				while(p && top && c[top]==lim-1 && q[top]==p)
				{
					--top,--p;
				}
				if(!p) return 0;
				if(q[top]==p) ++c[top];
				else q[++top]=p,c[top]=1;
			}
		}
	return 1;
}
int main()
{
	n=read();
	fo(i,1,n) a[i]=read();
	int l=1,r=n;
	while(l<r)
	{
		int mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/


signed main(){
	int n;
	cin>>n;
	vi a(n);
	rep(i,n)cin>>a[i];

	int g=a[0];
	rep(i,n){
		g=gcd(g,a[i]);
	}
	if(g>1){
		cout<<"not coprime"<<endl;
		return 0;
	}

	// map<pii,int> yaku;
	vi furui(1001001,1);
	rep(i,n){
		if(furui[a[i]]==0){
			// cout<<"a[i]="<<a[i]<<endl;
			cout<<"setwise coprime"<<endl;
			return 0;
		}
		int j;
		for(j=2;j*j<=a[i];j++){
			int cnt=0;
			while(a[i]%j==0){
				a[i]/=j;
				cnt++;
			}
			if(furui[j]==0) continue;
			if(cnt>0){
				for(int k=1;k*j<=1e6;k++){
					furui[k*j]=0;
					// printf("[%d]=0\n",k*j);
				}
			}
		}
		if(a[i]>1){
			for(int k=1;k*a[i]<=1e6;k++){
				furui[k*a[i]]=0;
				// printf("[%d]=0\n",k*a[i]);
			}
		}
	}
	// rep(i,n){
	// 	int k=a[i];
	// 	for(int i=2;i*i<=k;i++){
	// 		int cnt=0;
	// 		while(k%i==0){
	// 			k/=i;
	// 			cnt++;
	// 		}
	// 		if(cnt>0){
	// 			yaku[make_pair(cnt,i)]++;
	// 		}
	// 	}
	// 	if(k>1)yaku[make_pair(k,i)]++;
	// }

	// int cnt=0;
	// for(auto p:yaku){
	// 	int d=p.first.first;
	// 	int checker=p.first.second;
	// 	rep(i,n){
	// 		if(checker==i) break;
	// 		while(a[i]%d==0){
	// 			cout<<a[i]<<'/'<<d<<endl;
	// 			a[i]/=d;
	// 			cnt++;
	// 		}
	// 		if(cnt>0){
	// 			cout<<"setwise coprime"<<endl;
	// 			return 0;
	// 		}
	// 	}
	// }
	
	cout<<"pairwise coprime"<<endl;

	return 0;
}


Measured memory_bytes: 18768
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<complex>//real().imag().
#include<cctype>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<string>
#include<utility>
#include<iterator>
#define pii pair<int,int>
#define make_pair mp
using namespace std;
typedef long long ll;
const int N = 200005;
int main()
{
	// freopen("D:\\in.txt","r",stdin);
	// freopen("D:\\out.txt","w",stdout);
	//ios::sync_with_stdio(false);
	//system("pause");
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b == c || a + c == b || b + c == a)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}




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

//初見×
//2次元配列でなく1次元配列+string
int main()
{
    int H, W;
    cin >> H >> W;

    vector<string> picture(H);
    for (int i = 0; i < H; i++)
    {
        cin >> picture[i];
    }

    cout << string(W + 2, '#') << endl;
    for (int i = 0; i < H; i++)
    {
        cout << '#' << picture[i] << '#' << endl;
    }
    cout << string(W + 2, '#') << endl;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
    int N,K,X,Y;
    int total;
    scanf("%d %d %d %d",&N,&K,&X,&Y);

    if(N>K)
        {
        total = K*X + (N-K)*Y;
        }
    else
        total = N*X;

    printf("%d",total);
    return 0;

}


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


int array_sum_from_i(vector<int> &data, int i) {
//temp
  if (i == data.size()) {
    return 0;
  }

  int s = array_sum_from_i(data, i + 1);
  return data.at(i) + s;
}

int array_sum(vector<int> &data) {
  return array_sum_from_i(data, 0);
}


int main() {
  int n;
  cin >> n;
  vector<int> data(n);
  for (int i = 1; i < n+1; i++) {
    cin >> data.at(i-1);
  }
  int sum = array_sum(data);
  int count_sum=500;
  int first;
  int second = sum;
  int st=0, nd=0;
  
  for (int i = 0; i < n-1; i++) {
    first += data.at(i);
    second -= data.at(i);
    int a = first - second;
    if (a < 0) {
      a *= -1;
    }
    count_sum = min(count_sum, a);
  }


  cout << count_sum << endl;
}


Measured memory_bytes: 256
import collections
n = int(input())
S=['0']*n
sum_key = []
counters = [0]*n
for i in range(n):
    S[i] = input()
for i in range(n):
    c = collections.Counter(S[i])
    li = list(c.keys())
    counters[i] = c
    sum_key += li
sum_key = set(sum_key)
#ord(a)=97
al = [chr(ord('a') + i) for i in range(26)]
dp = [100]*26
for i in range(n):
    ca = counters[i]
    for s in sum_key:
        dp[ord(s)-97] = min(dp[ord(s)-97],ca[s])
lia = []
for i in range(26):
    if dp[i]==0 or dp[i]==100:
        continue
    k = [al[i]]*dp[i]
    lia += k
lia.sort()
print(''.join(lia))

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


void run_case() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n+1);
    vector<set<int>> siz(n+1, set<int>()), valid(n+1, set<int>());
    for(int i = 1; i <= n; ++i) cin >> h[i];
    for(int i = 1; i <= m; ++i) {
        int a, b;
        cin >> a >> b;
        siz[a].insert(b);
        siz[b].insert(a);
        if(h[a] > h[b]) valid[a].insert(b);
        else if(h[a] < h[b])valid[b].insert(a);
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i) {
        if(siz[i].size() == valid[i].size()) ans++;
    }
    cout << ans;
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

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

#define ll long long

int x[55];
ll	dp[55][55][2700];
int main() {

	int n, a;
	cin>>n>>a;
	
	for(int i=1; i<=n; i++) cin>>x[i];
	
	
	for(int i=0; i<=n; i++)
		dp[i][0][0]=1;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=i; j++){
			for(int s=1; s<=2600 ; s++){
				 if(j==1 && x[i]==s) dp[i][j][s]=1LL;
				 if(x[i]>s) dp[i][j][s]=dp[i-1][j][s];
				else if(s>=x[i]) dp[i][j][s] = dp[i-1][j-1][s-x[i]] + dp[i-1][j][s];

				}
			
			}
		
		}
	
	 ll ans=0LL;	
	for(int i=1; i<=n; i++){
		ans+=dp[n][i][i*a];
		}	
		
		cout<<ans<<endl;
		
		//for(int i=0; i<=n; i++)
		//for(int j=0; j<=n; j++)
			//for(int s=0; s<=30 ; s++){
				
				//cout<<i<<" "<<j<<" "<<s<<" "<<dp[i][j][s]<<endl;
				//}
	
	return 0;
}


Measured memory_bytes: 30796
import sys, math
from functools import lru_cache
from collections import deque
from bisect import bisect_left
sys.setrecursionlimit(10**9)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, M = mi()

    d = []
    i = 1
    while i*i <= M:
        if M%i == 0:
            d.append(i)
            d.append(M//i)
        i += 1

    d.sort()

    for v in d:
        if v <= M//N:
            ans = v
        else:
            break

    print(ans)

    



if __name__ == '__main__':
    main()


Measured memory_bytes: 9516
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	int a, b; cin >> a >> b;
	if (a == b)cout << "Draw" << "\n";
	else if (a == 1) cout << "Alice" << "\n";
	else if (b == 1)cout << "Bob" << "\n";
	else cout << (a < b ? "Bob" : "Alice") << "\n";

	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
C=list(map(int,input().split()))

DP=[i for i in range(N+1)]
#print(DP)
for coin in C:
    for pay in range(N+1):
        if pay-coin>=0:
            DP[pay]=min(DP[pay],DP[pay-coin]+1)
#print(DP[-1])
print(DP[-1])


Measured memory_bytes: 7636
# -*- coding: utf-8 -*-
import math

N, M = [int(x) for x in input().split()]
bignum= int(1e9 + 7)

if abs(M-N) >= 2:
    print(0)

elif abs(M-N) == 1:
    orders = math.factorial(M) * math.factorial(N)
    ans = int(orders % (bignum))
    print(ans)
    
else:
    orders = math.factorial(M) * math.factorial(N) * 2
    ans = int(orders % (bignum))
    print(ans)

Measured memory_bytes: 5184
s = input()
l = s.find("C")
r = s.rfind("C")
a = s[1:]
a = a.replace("C","")
if s[0] != "A" or s[-1] == "C" or l != r or 2 > l or not a.islower():
  print("WA")
else:
  print("AC")

Measured memory_bytes: 3060
use proconio::input;

macro_rules! chmin {
    ($min_v: expr, $v: expr) => {
        if $v < $min_v {
            $min_v = $v;
            true
        } else {
            false
        }
    };
}

fn main() {
    input! {
        n: usize,
        h: [i64; n],
    };
    let inf = 1_000_000_000_000_000_i64;
    let mut dp = vec![inf; n];
    dp[0] = 0;
    for i in 0..n {
        if i + 1 < n {
            chmin!(dp[i + 1], dp[i] + (h[i + 1] - h[i]).abs());
        }
        if i + 2 < n {
            chmin!(dp[i + 2], dp[i] + (h[i + 2] - h[i]).abs());
        }
    }
    let ans = dp[n - 1];
    println!("{}", ans);
}


Measured memory_bytes: 3976
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;
 
int main(){
     int n;
     cin >> n;
     vector<int> a(n);
     rep(i,n)cin >>a[i];

     int x = 1;
     int cnt =0;
     bool ok = false;
     rep(i,n){
         if(a[i]==1) ok = true;
     }
     if(!ok){
         cout <<-1 <<endl;
         return 0;
     }
     rep(i,n){
         if(a[i]==x){
             x++;
             cnt++;
         }
     }
     cout << n-cnt <<endl;
}

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

static class NagataKanaIsAGenius {
    public static void Main() {
        int[]nk=Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n=nk[0];
        int k=nk[1];
        Console.WriteLine((n-1+k-2)/(k-1));
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
int main(void) {
    int H, W, i, j;
    while (scanf("%d %d", &H, &W) == 2) {
        if (H == 0 && W == 0) break;
        for (i = 1; i < H + 1; i ++) {
            for (j = 1; j < W + 1; j ++) printf("#");
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll n;
    cin >> n;
    VL a(n);
    rep(i, 0, n) cin >> a[i];
    sort(ALL(a), greater<ll>());
    ll ans = a[0];
    ll i = 1;
    rep(j, 0, n-2){
        ans += a[i];
        if(j % 2 == 1) i++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4848
n = int(input())
h = list(map(int,input().split()))

dp = [float("inf")]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(1,n-1):
    dp[i+1] = min(dp[i]+abs(h[i+1]-h[i]),dp[i-1]+abs(h[i+1]-h[i-1]))
print(dp[n-1])

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

void dump(vector<int> v) {
    string res = "@[";
    for (auto i : v) {
        res += to_string(i);
        res += ", ";
    }
    res += "]";
    cout << res << endl;
}

vector<int> f(int n,int a) {
    vector<int> result;
    if (n % 2 == 1) {
        for (int i=1; i<=n; i++) {
            if (i == a or i == (n-a)) continue;
            result.push_back(i);
        }
        //if (a != n) result.insert(n);
    }
    else {
        for (int i=1; i<=n; i++) {
            if (i == a or i == (n-a+1)) continue;
            result.push_back(i);
        }
    }
    return result;
    // int target = 0;
    // if (n % 2 == 0) {
    //     for (int i=2; i<n; i++) target += i;
    // }
    // else {
    //     for (int i=1; i<n; i++) target += i;
    // }

}
int main() {
    int n; cin >> n;
    set<pair<int,int>> ans;
    for (int i=1; i <= n; i++) {
        vector<int> v = f(n,i);
        for (auto j: v) {
            pair<int,int> t = make_pair(i, j);
             if (t.first > t.second) swap(t.first, t.second);
            ans.insert(t);
        }
    }
    cout << ans.size() << endl;
    for (auto p: ans) {
        cout << p.first << " " << p.second << endl;
    }
}
// 1 235
// 2 145
// 3 145
// 4 235
// 5 1234
// お？？？
// 1 23457
// 2 13467
// 3 12567
// 4 12567
// 5 13467
// 6 23457
// 7 123456 = 21
// 奇数は出来そう

// 1 23
// 2 14
// 3 14
// 4 23

// 1 2345
// 2 1346
// 3 1256
// 4 1256
// 5 1346
// 6 2345
// 偶数も出来そう

Measured memory_bytes: 3700