akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  char s[22];
  int i,j=0,a=0;
  scanf("%s",s);
  for(i=0;s[i];i++){
    if(s[i]=='A'&&j==0)j=1;
    if(s[i]=='Z'&&j==1){
      printf("AZ");
      j=0;
      a=1;
    }
  }
  if(a==0)printf("-1");
  printf("\n");
  return 0;
}

Measured memory_bytes: 524
N, M = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]

X = sorted(X)
dist = []
for i in range(len(X)-1):
    dist.append((X[i+1] - X[i], i+1))

dist = sorted(dist, key=lambda t: t[0], reverse=True)[:N-1]
dist.append((0, 0))
dist = sorted(dist, key=lambda t: t[1])
dist.append((0, 0))

ans = 0
for i in range(len(dist)-1):
    ans += X[dist[i+1][1]-1] - X[dist[i][1]]

print(ans)


Measured memory_bytes: 19672
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var S string

func main() {
	sc.Split(bufio.ScanWords)

	S = nextStr()
	m := make(map[string]int, len(S))
	for _, s := range S {
		m[string(s)] = 1
	}
	for _, s := range "abcdefghijklmnopqrstuvwxyz" {
		_, ok := m[string(s)]
		if !ok {
			fmt.Println(string(s))
			return
		}
	}
	fmt.Println("None")
}


Measured memory_bytes: 3328
require 'prime'
loop do
  m, a, b = gets.split.map(&:to_i)
  break if m == 0
  ans = [0, 0]
  prod = 0
  prime = Prime.each.lazy.take_while{ |p| p < 100000 }.to_a
  prime.take_while{ |x| x * x <= m }.each do |p|
    q = prime.drop_while{ |x| x < p  }
             .take_while{ |x| a * x <= b * p && p * x <= m }.to_a.last
    if q && p * q > prod
      ans = [p, q]
      prod = p * q
    end
  end
  puts ans * ' '
end

Measured memory_bytes: 9828
r, c = map(int, input().split())

data = []

for y in range(r):
    row = list(map(int, input().split()))
    data.append(row)

colsum = [0 for i in range(c + 1)]
for y in range(r):
    data[y].append(sum(data[y]))
    for x in range(c + 1):
        colsum[x] += data[y][x]

data.append(colsum)

for y in range(r + 1):
    print(*data[y])

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;


int main() {
    int n; cin >> n;
    V<ll> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];

    sort(ALL(v));
    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(v[i] == v[j]) continue;
            for(int k = j + 1; k < n; k++){
                if(v[j] == v[k]) continue;
                if(v[i] + v[j] <= v[k] || v[i] + v[k] <= v[j] || v[j] + v[k] <= v[i]) continue;
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3616
R,G,B,N = gets.split.map &:to_i
p (0..N/R).reduce(0){ |a,r|
  a + (0..N/G).reduce(0){ |a,g| bb = N - r*R - g*G; a + (bb >= 0 && bb % B == 0 ? 1 : 0) }
}

Measured memory_bytes: 1788
#include <stdio.h>
#include <string.h>
#include <math.h>

int main() {

    int h, w;
    scanf("%d %d", &h, &w);
    char s[101];

    char arr[h][101];
    for (int i = 0; i < h; i++) {
        scanf("%s", s);
        //printf("%s",s);
        strcpy(arr[i], s);
    }


    for (int i = 0; i < w + 2; i++) {
        printf("%c", '#');
    }
    printf("\n");
    for (int j = 0; j < h; j++) {
        printf("#%s#\n", arr[j]);
    }
    for (int i = 0; i < w + 2; i++) {
        printf("%c", '#');
    }

    return 0;
}


Measured memory_bytes: 1680
#include<stdio.h>

int main(){
    int N;
    scanf("%d", &N);

    int ans;
    if( N % 2 == 0 ){
        ans = N / 2;
    }
    else{
        ans = N / 2 + 1;
    }

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

    return 0;
}




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

int main()
{
    string S;
    cin >> S;
    auto N = S.size();
    vector<int> res(N, 0);
    int is = 0;
    int im = 0;
    int il = 0;
    while(is < N){
        im = S.find("RL", is);
        il = S.find("LR", im);
        if(il==string::npos) il=N-1;
        res[im+0] = (im-is+2)/2 + (il-im+0)/2;
        res[im+1] = (im-is+1)/2 + (il-im+1)/2;
        is = il + 1;
    }
    for(int i=0; i<N; i++){
        cout<<res[i]<<" ";
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 1024
yy,mm,dd =map(int,input().split('/'))

if yy>2019:
  print('TBD')
else:
  if mm>4:
    print('TBD')
  else:
    if mm==1 or mm==3:
      if dd>31:
        print('TBD')
      else:
        print('Heisei')
    if mm==2:
      if dd>29:
        print('TBD')
      else:
        print('Heisei')
    if mm==4:
      if dd>30:
        print('TBD')
      else:
        print('Heisei')




Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define MOD (int)(1e9 + 7)

int main()
{
    int n,k;
    cin >> n >> k;
    bool dp[k+1];
    int vals[n];
    for (int q = 0; q < n; q++)
    {
        cin >> vals[q];
    }
    for (int q = 0; q < k+1; q++)
    {
        dp[q] = false;
        for (int w = 0; w < n; w++)
        {
            if (q-vals[w]<0)
            {
                break;
            }
            else
            {
                if (dp[q-vals[w]]== false)
                {
                    dp[q]=true;
                    break;
                }
            }
        }
    }
    if (dp[k]==true)
    {
        cout << "First";
    }
    else
    {
        cout << "Second";
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,x,M;
vector<int> ans;
void solve1(int y){
	ans[N-1] = y+1;
	ans[N] = y;
	ans[N+1] = y-1;
	ans[N+2] = y+2;
	int idx = 1;
	for(int i=1;i<=M;i++){
		if(i>=y-1&&i<=y+2)continue;
		while(idx<=M&&ans[idx]!=0)idx++;
		ans[idx] = i;
	}
	return;
}

void solve2(int y){
	ans[N-1] = y-1;
	ans[N] = y;
	ans[N+1] = y+1;
	ans[N+2] = y-2;
	int idx = 1;
	for(int i=1;i<=M;i++){
		if(i>=y-2&&i<=y+1)continue;
		while(idx<=M&&ans[idx]!=0)idx++;
		ans[idx] = i;
	}
	return;
}

int main(){
	cin >> N >> x;
	M = 2*N-1;
	ans.resize(M+1,0);
	if(x==1||x==M){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	if(N==2){
		cout << "1\n2\n3" << endl;
		return 0;
	}
	if(x==2)solve1(x);
	else solve2(x);
	for(int i=1;i<=M;i++){
		cout << ans[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int X;
    cin >> X;
    if (X < 600) {
        cout << 8 << endl;
    } else if (X < 800) {
        cout << 7 << endl;
    } else if (X < 1000) {
        cout << 6 << endl;
    } else if (X < 1200) {
        cout << 5 << endl;
    } else if (X < 1400) {
        cout << 4 << endl;
    } else if (X < 1600) {
        cout << 3 << endl;
    } else if (X < 1800) {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}

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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	vector<int> v{a,b,c};
	sort(ALL(v));
	cout << v[0] + v[1] <<endl;

	return 0;
}

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

int main(){
   int a,b,c;
   string s;
   cin >> a >> b >> c;
   set<int> st;
   st.insert(a);
   st.insert(b);
   st.insert(c);
   cout << st.size() << endl;
   return 0;
}


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

from copy import copy

POSS = [1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049]
TMAX = 20
NMAX = 100000

def do_dp(n):
    dp = [i for i in range(NMAX + 1)]
    for t in range(TMAX):
        pre = copy(dp)
        for i in range(NMAX + 1):  # 配る
            for p in POSS:
                if i + p <= NMAX:
                    dp[i + p] = min(dp[i + p], dp[i] + 1)
    return dp[n]

def main():
    n = int(input())
    print(do_dp(n))

main()


Measured memory_bytes: 59168
#include<stdio.h>
int main(void)
{
int a,b,c,temp;
scanf("%d %d %d",&a ,&b ,&c);
if (a > b){
temp=b;
b=a;
a=temp;
}if(b > c){
temp=c;
c=b;
b=temp;
}if(a > b){
temp=b;
b=a;
a=temp;
}
printf("%d %d %d\n",a,b,c);
return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> min_hist(26, 50);
	for(int i = 0; i < n; ++i){
		string s;
		cin >> s;
		vector<int> hist(26);
		for(char c : s){ ++hist[c - 'a']; }
		for(int j = 0; j < 26; ++j){
			min_hist[j] = min(min_hist[j], hist[j]);
		}
	}
	string s;
	for(int j = 0; j < 26; ++j){
		s += string(min_hist[j], static_cast<char>('a' + j));
	}
	cout << s << endl;
	return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(S: str):
    print(S.count('1'))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int A,B,T;
int ans;

signed main(){

    in(A,B,T);
    REP(i,1,T+1){
        if(i%A==0) ans+=B;
    }
    out(ans);

    return 0;
}


Measured memory_bytes: 256
n=int(input())
k=[1]
ans=[]
c=26
wa=0
while wa+c<n:
  k.append(c)
  wa+=c
  c=c*26
n=n-1-wa
for i in k[::-1]:
  ans.append(n//i)
  n=n%i
t=''
for i in ans: 
  t+=chr(97+i)
print(t)

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

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N(x ? "Yes" : "No"))

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int H, W, A, B;
  cin >> H >> W >> A >> B;
  
  // main procedure
  // output
  for (auto i = 0; i < H; ++i) {
    for (auto j = 0; j < W; ++j) {
      cout << (((i < B && j < A) || (i >= B && j >= A)) ? 0 : 1);
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 1280
require 'set'
num_of_n = gets.chomp.to_i
n_list = gets.chomp.split.map(&:to_i)

num_of_m = gets.chomp.to_i
m_list = gets.chomp.split.map(&:to_i)


def main(num_of_n, n_list, num_of_m, m_list)
  sum_list = [].to_set

  (1..2**num_of_n).each do |n_ten|
    n_two = n_ten.to_s(2).rjust(num_of_n, '0')
    sum = n_two.chars.map(&:to_i).map.with_index{ |flag, index| flag == 1 ? n_list[index] : 0 }.sum

    sum_list.add(sum)
  end

  m_list.each do |m|
    if sum_list.include?(m)
      puts 'yes'
    else
      puts 'no'
    end
  end
end

main(num_of_n, n_list, num_of_m, m_list)


Measured memory_bytes: 7140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> h(n);
    vector<int> ok(n); // 1だとダメ
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    vector<int> a(m),b(m);
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
        a[i]--,b[i]--;
        if(h[a[i]] <= h[b[i]]) ok[a[i]] = 1;
        if(h[b[i]] <= h[a[i]]) ok[b[i]] = 1;
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if(ok[i] == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    string c_vec;
    cin >> c_vec;
    vector<int> cumsum_R_vec(N + 1, 0);
    vector<int> cumsum_W_vec(N + 1, 0);
    for (int i = 0; i < N; ++i) {
        cumsum_R_vec.at(i + 1) = cumsum_R_vec.at(i);
        cumsum_W_vec.at(i + 1) = cumsum_W_vec.at(i);
        if (c_vec.at(i) == 'R')
            ++cumsum_R_vec.at(i + 1);
        else
            ++cumsum_W_vec.at(i + 1);
    }
    int min_changed = -1;
    for (int i = 0; i < N + 1; ++i) {
        int num_W_changed = cumsum_W_vec.at(i);
        int num_R_changed = cumsum_R_vec.at(N) - cumsum_R_vec.at(i);
        int num_changed = max(num_R_changed, num_W_changed);
        if (min_changed == -1 || min_changed > num_changed)
            min_changed = num_changed;
    }
    cout << min_changed << endl;
}


Measured memory_bytes: 5032
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000009
#define MK make_pair
#define EB emplace_back
#define PB push_back
#define F first
#define S second
using namespace std;
ll u=1e18;
void solve()
{
	int n;
	cin>>n;
	vector<ll> a(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]==0)
		{
			cout<<0<<endl;
			return;
		}
	} 
	ll ans=1;
	for(int i=0;i<n;i++)
	{
		if(u/a[i]<ans)
		{
			cout<<-1<<endl;
			return;
		}
		ans*=a[i];
	}
	cout<<ans<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}

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

template< typename G >
struct StronglyConnectedComponents {
    using UnWeightedGraph=std::vector<std::vector<int>>;
  const G &g;
  UnWeightedGraph gg, rg;
  std::vector< int > comp, order, used;

  StronglyConnectedComponents(G &g) : g(g), gg(g.size()), rg(g.size()), comp(g.size(), -1), used(g.size()) {
    for(int i = 0; i < g.size(); i++) {
      for(auto e : g[i]) {
        gg[i].emplace_back((int) e);
        rg[(int) e].emplace_back(i);
      }
    }
  }

  int operator[](int k) {
    return comp[k];
  }

  void dfs(int idx) {
    if(used[idx]) return;
    used[idx] = true;
    for(int to : gg[idx]) dfs(to);
    order.push_back(idx);
  }

  void rdfs(int idx, int cnt) {
    if(comp[idx] != -1) return;
    comp[idx] = cnt;
    for(int to : rg[idx]) rdfs(to, cnt);
  }

  void build(UnWeightedGraph &t) {
    for(int i = 0; i < gg.size(); i++) dfs(i);
    reverse(begin(order), end(order));
    int ptr = 0;
    for(int i : order) if(comp[i] == -1) rdfs(i, ptr), ptr++;

    t.resize(ptr);
    for(int i = 0; i < g.size(); i++) {
      for(auto &to : g[i]) {
        int x = comp[i], y = comp[to];
        if(x == y) continue;
        t[x].push_back(y);
      }
    }
  }
};
int main(){
    int N,M;
    std::cin>>N>>M;
    std::vector<std::vector<bool>> to(N,std::vector<bool>(N,false));
    std::vector<std::vector<int>> graph(N),t;
    std::vector<int> ans;
    for(int _=0;_<M;++_){
        int u,v;
        std::cin>>u>>v;
        u--;v--;
        if(ans.empty()){
            graph[u].push_back(v);
            StronglyConnectedComponents<std::vector<std::vector<int>>> scc(graph);
            scc.build(t);
            std::vector<std::vector<int>> tmp(N);
            for(int i=0;i<N;++i) tmp[scc[i]].push_back(i);
            int ok=-1;
            for(int i=0;i<N;++i) if(tmp[i].size()>1) ok=i;
            if(ok!=-1){
                int now=v;
                while(now!=u){
                    ans.push_back(now);
                    for(auto e:graph[now]) if(scc[e]==ok){
                        now=e;
                        break;
                    }
                }
                ans.push_back(u);
            }
            for(int i=0;i<N;++i) if(to[v][i]) to[u][i]=true;
        }
        else if(std::find(ans.begin(),ans.end(),u)!=ans.end()&&
                std::find(ans.begin(),ans.end(),v)!=ans.end()){
            int ch=std::find(ans.begin(),ans.end(),v)-ans.begin();
            int sz=ans.size();
            std::vector<int> tmp;
            while(ans[ch]!=u){
                tmp.push_back(ans[ch]);
                ch=(ch+1)%sz;
            }
            tmp.push_back(u);
            ans=tmp;
        }
    }
    if(ans.empty()){
        std::cout<<-1<<std::endl;
        return 0;
    }
    std::cout<<ans.size()<<std::endl;
    for(auto a:ans) std::cout<<a+1<<std::endl;
}

Measured memory_bytes: 14464
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    static ArrayList<Integer>[] vertice;
    static int ans = 0;
    static int total = 0;
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        int money = n*800;
        int ret = 200*(int)(n/15);
        System.out.println(money-ret);
    }
}


Measured memory_bytes: 21716
N, M = map(int, input().split())

X = list(map(int, input().split())) 
X = sorted(X)


if M <= N:
    print(0)  
    
else:
    diff = []
    for i in range(len(X)-1):
        diff.append(X[i+1] - X[i])
    
    diff_sort = sorted(diff)
    
    print(sum(diff_sort[0:M-N]))


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

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  char b;
  cin >> b;

  char c;
  switch (b) {
    case 'A':
      c = 'T';
      break;
    case 'T':
      c = 'A';
      break;
    case 'G':
      c = 'C';
      break;
    case 'C':
      c = 'G';
      break;
  }

  cout << c << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, cru = -1, cnt = 0;
  cin >> n;
  REP(i,n) {
    int h;
    cin >> h;
    if(h >= cru) { cnt++; cru = h; }
  }
  cout << cnt << endl;
  return 0;
}
//templete by private_yusuke

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define pll pair<ll,ll>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const int INF = 1e9;
const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}



void solve()
{
    int a, b, c, d; cin>>a>>b>>c>>d;
    int state = 1;
    while(a > 0 && c> 0) {
        if(state) {
            c -= b;
            state ^= 1;
        }
        else {
            a -=d;
            state ^= 1;
        }
    }
    if(state) cout<<"No";
    else cout<<"Yes";
}

int main()
{
    // clock_t start, end;
    // start = clock();
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    int t = 1;
    // cin>>t;
    REP(i, 1, t)
    {
        solve();
        
    }
    // end = clock();
    // double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    // watch(time_taken);
    ll x = INF; x++;
    return 0;
    
}



/*before sub
TEST: 0, 1, equal, -ve, bounds(random and ez)
ERR/WA: loop vars, out of bounds, endl, finish taking inputs, large doubles, larger INF, corr mod, t
RE: double dec, integer overflow(ll or 1LL mult)
*/





Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

int64_t solve(const std::string &s) {
  int n = static_cast<int>(s.size()) + 1;
  std::vector<int64_t> dp(1, 1);

  for (int i = 0; i < n - 1; ++i) {
    std::vector<int64_t> dp2(i + 2, 0);
    if (s[i] == '<') {
      dp2[0] = 0;
      for (int j = 1; j <= i + 1; ++j) {
        dp2[j] = dp2[j - 1] + dp[j - 1];
        dp2[j] %= 1000000007LL;
      }
    } else {
      dp2[i + 1] += 0;
      for (int j = i; j >= 0; --j) {
        dp2[j] = dp[j] + dp2[j + 1];
        dp2[j] %= 1000000007LL;
      }
    }
    dp = dp2;
  }
  return std::accumulate(
      dp.begin(), dp.end(), 0LL,
      [](const auto a, const auto b) { return (a + b) % 1000000007LL; });
}

int main() {
  int n;
  std::string s;
  std::cin >> n >> s;
  std::cout << solve(s) << std::endl;
  return 0;
}


Measured memory_bytes: 384
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
a = [K]*N
b = list(map(lambda x: x-Q, a))
for i in range(Q):
    b[A[i] - 1] += 1
for i in range(len(b)):
    if b[i] > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 12580
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;
using namespace __gnu_pbds;

const double PI = 2 * acos(0.0);
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long n;
	cin >>n;
	long long x = n / 500;
	long long y = (n - (x * 500)) / 5;
	cout <<(x * 1000) + (y * 5);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

	int a, b, d, r;
	double f;
	
	scanf("%d %d", &a, &b);
	
	d = a/b;
	r = a%b;
	f = (double)a/(double)b;
	
	printf("%d %d %f", d, r, f);
	
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

const int n = 50;

int main() {
  IOS;
  ll k; cin >> k;
  vector<ll> ans(n);

  REP(i,n) ans[i] = n-1;

  ll add = k / n;
  if (add) REP(i,n) ans[i] += add;

  ll m = k%n;
  REP(i,m) {
    ans[i] += n+1;
    REP(j,n) ans[j]--;
  }

  COUT(n);
  REP(i,n) {
    if (i > 0) cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3660
n, k, s = map(int, input().split())
l = []
if s != 10**9:
    for i in range(k):
        l.append(str(s))
    for j in range(n-k):
        l.append(str(s+1))
    print(" ".join(l))
else:
    for i in range(k):
        l.append(str(s))
    for j in range(n-k):
        l.append(str(s-1))
    print(" ".join(l))

Measured memory_bytes: 53488
#include <iostream>
#include <algorithm>

int main()
{
  long N;
  std::cin >> N;
  long long a[N];
  for ( long i = 0; i < N; i++ ) std::cin >> a[i];

  long long p = 0, n = 0;
  long long sum = 0;
  
  // when the first element is positive
  if ( a[0] <= 0 ) {
    p += -a[0] + 1;
    sum = 1;
  } else {
    sum += a[0];
  }

  for ( long i = 1; i < N; i++ ) {
    if ( i % 2 == 0 ) {
      if ( sum + a[i] <= 0 ) {
        p += -(sum + a[i]) + 1;
        sum = 1;
      } else sum += a[i];
    } else {
      if ( sum + a[i] >= 0 ) {
        p += (sum + a[i]) + 1;
        sum = -1;
      } else {
        sum += a[i];
      }
    }
    std::cerr << "sum: " << sum << std::endl;
    std::cerr << "p: " << p << std::endl;
  }

  // when the first element is negative
  sum = 0;
  if ( a[0] >= 0 ) {
    n += a[0] + 1;
    sum = -1;
  } else {
    sum += a[0];
  }
  for ( long i = 1; i < N; i++ ) {
    if ( i % 2 == 0 ) {
      if ( sum + a[i] >= 0 ) {
        n += (sum + a[i]) + 1;
        sum = -1;
      } else {
        sum += a[i];
      }
    } else {
      if ( sum + a[i] <= 0 ) {
        n += -(sum + a[i]) + 1;
        sum = 1;
      } else {
        sum += a[i];
      }
    }
    std::cerr << "sum: " << sum << std::endl;
    std::cerr << "n: " << n << std::endl;
  }

  std::cout << std::min(p, n) << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio> 
using namespace std;
int main(void){ 
	int h, w, i, j;
	while (1){ cin >> h >> w; 
	if (!h && !w)
		break; for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) { cout << '#'; } 
			cout << endl; 
	} cout << endl; } 
	return 0;
} 


Measured memory_bytes: 3068
#include <stdio.h>
#define MOD         1000000007  /* 10^9 + 7 */
typedef long long ll;
ll MODPOW(ll a, ll n){ ll ans=1; while(n){if(n&1){ans=ans*a%MOD;} a=a*a%MOD; n>>=1; } return ans; }

int main(){
    ll n,ans=0;
    scanf("%lld",&n);
    ans = MODPOW(10,n) - MODPOW(9,n) - MODPOW(9,n) + MODPOW(8,n);
    ans%=MOD;
    ans=(ans+MOD)%MOD;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1692
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end
A = gets_i
B = gets_i
C = gets_i
X = gets_i

count = 0
(0..A).each do |i|
  (0..B).each do |j|
    diff = X - 500 * i - 100 * j
    dpp [i, j, diff]
    if diff >= 0 && diff % 50 == 0 && diff / 50 <= C
      count += 1
    end
  end
end

puts count


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

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

    int a;
    int ans = 0;
    for(int i = 0; i < N; i++) {
        cin >> a;
        while(a % 2 == 0) {
            a /= 2;
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	ll n;
	cin >> n;
	
	if(n%2==1){
		cout << "0\n";
		return 0;
	}
	
	ll count5=0;
	
	ll i=5;
	while(n >= i){
		count5 += n/(i*2);
		i *= 5;
	}
	
	cout << count5 << endl;
	
	return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    int i;
    int j;
    int matrix[100][100] = {0};
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            cin >> matrix[i][j];
        }
    }
    int vector[100] = {0};
    for (j = 0; j < m; j++) {
        cin >> vector[j];
    }
    for (i = 0; i < n; i++) {
        int sum = 0;
        for (j = 0; j < m; j++) {
            sum += matrix[i][j] * vector[j];
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define MAX 300001
#define endl '\n'
#define ll long long
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll n{0};
	ll m{0};
	cin>>n>>m;

	ll targets{0};
	cin>>targets;

	map<pair<ll,ll>,ll> points;

	vector<ll> row(MAX);
	for(ll i=0;i<MAX;i++){
		row[i]=0;
	}

	vector<ll> column(MAX);
	for(ll i=0;i<MAX;i++){
		column[i]=0;
	}

	while(targets--){
		ll x{0};
		ll y{0};
		cin>>x>>y;

		row[x]++;
		column[y]++;

		pair<ll,ll> temp;
		temp.first=x;
		temp.second=y;
		points[temp]=1;
	}

	ll max_row=INT_MIN;
	for(ll i=1;i<MAX;i++){
		if(row[i]>max_row)
			max_row=row[i];
	}

	ll max_column=INT_MIN;
	for(ll i=1;i<MAX;i++){
		if(column[i]>max_column)
			max_column=column[i];
	}

	vector<ll> index_row;
	for(ll i=1;i<MAX;i++){
		if(row[i]==max_row)
			index_row.push_back(i);
	}

	vector<ll> index_column;
	for(ll i=1;i<MAX;i++){
		if(column[i]==max_column)
			index_column.push_back(i);
	}

	bool found=false;
	for(ll i=0;i<index_row.size();i++){
		for(ll j=0;j<index_column.size();j++){
			pair<ll,ll> temp;
			temp.first=index_row[i];
			temp.second=index_column[j];
			if(points[temp]==0){
				found=true;
				break;
			}
		}
	}

	if(found){
		cout<<(max_row+max_column)<<endl;
	}
	else{
		cout<<(max_column+max_row-1)<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 50028
/**
 *    author:  Mohamad Milhem
 *    created: 2020-03-23-17.40.52
**/

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define MOD ll(1000000007)
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<endl;
#define decimalpoint cout << std::fixed << setprecision(9)

bool pal(string s){
    string v = s;
    reverse(s.begin(),s.end());

    return (s == v ? true : false);



}



int main(){

    FAST;


    int l;
    cin >> l;

    long double d = l/3.0;

    d = d*d*d;
    decimalpoint << d;


    return 0;
}


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

using namespace std;

int main()
{
    int n,i,d1[100],d2[100],flag=0;
    cin >> n;
    for(i=1;i<=n;++i)
    {
        cin >> d1[i] >> d2[i];
    }
    for(i=1;i<=n-2;++i)
    {
        if((d1[i]==d2[i])&&(d1[i+1]==d2[i+1])&&(d1[i+2]==d2[i+2]))
        {
            cout << "Yes\n";
            flag=1;
            break;
        }
    }
    if(flag==0)
    cout << "No\n";

    return 0;
}


Measured memory_bytes: 3628
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var primes = Array.from(sieveOfEratos(55555));
	var list = [];
	for(var i = 0; i < primes.length; i++){
		if(primes[i] >= 10 && primes[i] % 5 == 1){
			list.push(primes[i]);
			if(list.length == N){
				break;
			}
		}
	}
	myout(myconv(list,8));
	
}
function sieveOfEratos(val){
  var primes = new Set();
  var nums = new Set();
  var used = [2,3,5,7,11];//これらは既に素数であるとする
  var underPrime = 13;//この値から+2ごとに追加。↑の値で割り切れたものは何もしない
  if(val <= 1){
     return nums;
  }
  for(var i = 0; i < used.length; i++){if(used[i] <= val){nums.add(used[i]);}}
  for(var i = underPrime; i <= val; i=i+2){
    var continued = false;
    for(var j = 0; j < used.length; j++){
      if(i % used[j] == 0){continued = true; break;}
    }
    if(continued){continue;}
    nums.add(i);
  }
  for(var i = 2; i <= Math.sqrt(val); (i==2) ? i++ : i=i+2){
    if(!nums.has(i)){continue;}
    var count = 1;
    while(i * count <= val){
      if(i <= 11 && used.indexOf(i) != -1){break;}
      if(count == 1){primes.add(i);}
      nums.delete(i*count);
      count++;
    }
  }
  var primeItr = Array.from(primes);
  for(var i = 0; i < primeItr.length; i++){
    nums.add(primeItr[i]);
  }
  return nums;
}


Measured memory_bytes: 33800
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    vector<bool> good(N, true);
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        if(H[a] == H[b]){
            good[a] = false;
            good[b] = false;
        }else if(H[a] < H[b]){
            good[a] = false;
        }else{
            good[b] = false;
        }
    }

    int ans = 0;
    for(bool g : good){
        if(g)
            ans++;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

int N,M,a,b,white = 0,black = 0,W[710] = {0},B[710] = {0};
int G[710][710] = {{0}},color[710] = {0};
vector<vector<int>> v(710);

bool dfs(int n,int c){
	color[n] = c;
	(c==1? white++:black++);
	for(int i=0;i<v[n].size();i++){
		if(color[v[n][i]] == c) return false;
		else if(color[v[n][i]] == 0 && !dfs(v[n][i],-c)) return false;
	}
	return true;
}

int main(){
	cin >> N >> M;
	for(int i=0;i<M;i++){
		cin >> a >> b;
		G[a][b] = 1;
		G[b][a] = 1;
	}
	for(int i=1;i<N;i++){
		for(int j=i+1;j<=N;j++){
			if(G[i][j]==0){
				v[i].push_back(j);
				v[j].push_back(i);
			}
		}
	}
	int c = 1; 
	for(int i=1;i<=N;i++){
		if(color[i]==0){
			if(!dfs(i,1)){
				cout << -1 << endl;
				return 0;
			}else{
//				if(white<black) swap(white,black);
				W[c] = white; B[c] = black; c++;
			}
		}
		white = 0; black = 0;
	}
	c--;
	bool dp[c+1][710] = {{0}};
	dp[0][0] = true;
	for(int i=1;i<=c;i++){
		for(int j=0;j<=700-W[i];j++){
			dp[i][j+W[i]] = (dp[i-1][j] | dp[i][j+W[i]]);
		}
		for(int j=0;j<=700-B[i];j++){
			dp[i][j+B[i]] = (dp[i-1][j] | dp[i][j+B[i]]);
		}
	}
	int ans = 0;
	for(int i=0;i<=700;i++){
		if(dp[c][i]) ans = max(ans,i*(N-i)-(N*(N-1)/2-M));
	}
	cout << M-ans << endl;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int x = N/100000000+(N-N/100000000*100000000)/10000000+(N-N/10000000*10000000)/1000000+(N-N/1000000*1000000)/100000+(N-N/100000*100000)/10000+(N-N/10000*10000)/1000+(N-N/1000*1000)/100+(N-N/100*100)/10+N-N/10*10;
  int y = N%x;
  if(y==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}


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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> s(13, 0);
  vector<int> h(13, 0);
  vector<int> c(13, 0);
  vector<int> d(13, 0);
  
  for (int i=0; i<n; i++) {
	char l;
    cin >> l;
    int x;
    cin >> x;
    if ( l == 'S' ) {
      s.at(x-1) = 1;
    }
    if ( l == 'H' ) {
      h.at(x-1) = 1;
    }
    if ( l == 'C' ) {
      c.at(x-1) = 1;
    }
    if ( l == 'D' ) {
      d.at(x-1) = 1;
    }
  }
  
  for (int i=0; i<13; i++) {
	if (s.at(i) == 0) {
      cout << 'S' << ' ' << i+1 << endl;
    }
  }
  for (int i=0; i<13; i++) {
	if (h.at(i) == 0) {
      cout << 'H' << ' ' << i+1 << endl;
    }
  }
  for (int i=0; i<13; i++) {
	if (c.at(i) == 0) {
      cout << 'C' << ' ' << i+1 << endl;
    }
  }
  for (int i=0; i<13; i++) {
	if (d.at(i) == 0) {
      cout << 'D' << ' ' << i+1 << endl;
    }
  }
  
  
  return 0;
}



Measured memory_bytes: 3048
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = readline().rstrip().decode()
t = readline().rstrip().decode()
if s == t[:len(t) - 1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 61616
S = input()
T = input()

s = len(S)
t = len(T)
ans = t
for i in range(s - t+1):
    count = 0
    for a, b in zip(S[i:], T):
        if a != b:
            count += 1
    if ans > count:
        ans = count

print(ans)


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

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

  int x, a, b;
  cin >> x >> a >> b;

  if (abs(x - a) < abs(x - b)) cout << "A\n";
  else cout << "B\n";

  return (0);
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    int h,w;
    cin >> h >> w;
    char grid[h+1][w+1];
    int n[h],m[w];
    int flag;
    for(int i=0; i<h; i++){
        n[i]=1;
        flag=0;
        for(int j=0; j<w; j++){
            cin >> grid[i][j];
            if(grid[i][j]=='#')flag=1;
        }
        if(flag!=1)n[i]=0;
    }
    for(int i=0; i<w; i++){
        flag=0;
        m[i]=1;
        for(int j=0; j<h; j++){
            if(grid[j][i]=='#')flag=1;
        }
        if(flag!=1)m[i]=0;
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(n[i]&&m[j]){
                cout << grid[i][j];
            }
        }
        if(n[i])cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<long double>v;
    for(int i=0;i<n;i++){
        long double a;
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    long double res=0;
    for(int i=0;i<n-1;i++){
        long double a=v[i]+v[i+1];
        a=a/2;
        v[i+1]=a;
    }
    cout<<v[n-1]<<endl;
    return 0;
    }


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

#define si(v) v.size()
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (n); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

using ll = long long;
using ld = long double;
using namespace std;

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

  char a, b; cin >> a >> b;
  if (a == b) cout << "H\n";
  else cout << "D\n";
  
  return (0);
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;

vector<ll> p,e;

bool IsPrime(int N){
  bool ok=true;
 for(int i=2;i*i<=N;i++){
  if(N%i==0)ok=false; 
 }
  if(ok)return true;
  else return false;
}

int main(){
  int n;
  cin >> n;
  for(int i=2;i<=n;i++){
    if(IsPrime(i)){
      int b=0;
      for(int j=2;j<=n;j++){
        int m=j;
        while(m%i==0){
          b++;
          m/=i;
        }
      }
    p.push_back(i);
    e.push_back(b);
    }
  }
  ll cnt2=0,cnt4=0,cnt14=0,cnt24=0,cnt74=0;
  rep(i,p.size()){
    if(e[i]>=74)cnt74++;
    if(e[i]>=24)cnt24++;
    if(e[i]>=14)cnt14++;
    if(e[i]>=4)cnt4++;
    if(e[i]>=2)cnt2++;
  }
  cout << cnt74+cnt24*(cnt2-1)+cnt14*(cnt4-1)+(cnt4*(cnt4-1))/2*(cnt2-2) << endl;
return 0;}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string a,b,c;
  int next=0;
  int sa,ea,sb,eb,sc,ec;
  cin >> a >> b >> c;
  sa=sb=sc=0;
  ea=a.size();
  eb=b.size();
  ec=c.size();
  while(true){
    switch(next){
      case 0:
        if(sa==ea){
          cout << "A\n";
          return 0;
        }
        next = a[sa++]-'a';
        break;
      case 1:
        if(sb==eb){
          cout << "B\n";
          return 0;
        }
        next = b[sb++]-'a';
        break;
      case 2:
        if(sc==ec){
          cout << "C\n";
          return 0;
        }
        next = c[sc++]-'a';
        break;
        
    }
  }
}


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

int main()
{
    bool flg[4]={false,false,false,false};
    string S;
    cin >> S;
    for(int i=0;i<S.size();++i){
        if(S[i]=='E') flg[0]=true;
        else if(S[i]=='W') flg[1]=true;
        else if(S[i]=='S') flg[2]=true;
        else if(S[i]=='N') flg[3]=true;
    }
    if(flg[0] == flg[1] && flg[2]==flg[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256