akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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 ll INF = 1LL <<60;
const ll INF = 	922337203685477580;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
ll dp[100010];

int main(){
  int n;
  cin>>n;
  string str = "";
  while(n!=0){
    int r = n%2;
    if(r<0)r+=2;
    str+=(char)('0'+r);
    n = (n-r)/(-2);
  }
  reverse(str.begin(),str.end());
  if(str=="") str='0';
  cout<<str<<endl;
  return 0;
}


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

signed main(){

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

  static double dp[3001][3001]; //i枚目まで見て、j枚が表の確率
  dp[0][0] = 1;
  for(int i = 0; i < n; i++){
    for(int j = 0; j <= i; j++){
      dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
      dp[i+1][j+1] += dp[i][j] * p[i];
    }
  }

  double ans = 0;
  for(int i = (n+1)/2; i <= n; i++){
    ans += dp[n][i];
  }
  printf("%.10f\n",ans);

  return 0;
}


Measured memory_bytes: 68992
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
using namespace std;
int a[100005];
int sum = 0;
int ans = 0;
int n, m, k;
int main()
{
	int n;
	scanf("%d", &n);
	if(n < 1200)printf("ABC\n");
	else if(n < 2800)printf("ARC\n");
	else printf("AGC\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int n = 0;
		for (int i = 1; i <= 1000001; i++) {
			n = 10 * n + 7;
			if (n % K == 0) {
				System.out.println(i);
				return;
			}
			n %= K;
		}
		System.out.println(-1);
	}
}


Measured memory_bytes: 35688
x1, y1, x2, y2 = map(int, input().split())
dx1, dy1 = x2 - x1, y2 - y1
dx2, dy2 = -dy1, dx1
x3, y3 = x2 + dx2, y2 + dy2
x4, y4 = x3 - dx1, y3 - dy1
print(x3, y3, x4, y4)

Measured memory_bytes: 9176
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc099_a.cpp
 * time   : Thu Apr 30 20:49:19 2020
 * quest  : A - ABD
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  cout << ((n > 999) ? "ABD" : "ABC") << "\n";
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			P[] ps = new P[2*n];
			for (int i = 0; i < n; i++) {
				ps[i] = new P(in.nextInt(), in.nextInt(), "red");
			}
			for (int i = n; i < 2*n; i++) {
				ps[i] = new P(in.nextInt(), in.nextInt(), "blue");
			}

			int count = 0;
			Arrays.sort(ps, new MyComparatorX());
			List<P> list = new ArrayList<>();
			for (int i = 0; i < 2*n; i++) {
				if ("red".equals(ps[i].color)) {
					list.add(ps[i]);
					Collections.sort(list, new MyComparatorY());
				} else if ("blue".equals(ps[i].color)) {
					for (int j = 0; j < list.size(); j++) {
						if (list.get(j).y < ps[i].y) {
							count++;
							list.remove(j);
							break;
						}
					}
				}
			}
			out.println(count);

		}
	}

	static class P {
		int x, y;
		String color;
		P(int x, int y, String color) {
			this.x = x;
			this.y = y;
			this.color = color;
		}
	}

	static class MyComparatorX implements Comparator<P>{
		public int compare(P p1, P p2) {
			return p1.x - p2.x;
		}
	}

	static class MyComparatorY implements Comparator<P>{
		public int compare(P p1, P p2) {
			return -(p1.y - p2.y);
		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

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

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s; cin >> s;
    int ans = 0;
    int f = 0;
    if(s[0] == '1') f = 1;
    REP(i, 1, s.size()) {
        if(i % 2 == 0){
            if(f){
                if(s[i] == '0'){
                    s[i] = '1';
                    ans++;
                }
            }
            else {
                if(s[i] == '1'){
                    s[i] = '0';
                    ans++;
                }
            }
        }
        else {
            if(f) {
                if(s[i] == '1'){
                    s[i] = '0';
                    ans++;
                }
            }
            else {
                if(s[i] == '0'){
                    s[i] = '1';
                    ans++;
                }
            }
        }
    }
    COUT(ans);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
using namespace std;
int main(){
    string S,T;
    cin >> S >> T;
    int best  = 1002;
    for(int i = 0; i < S.size()-T.size()+1; i++){
        int cnt = 0;
        for(int j = 0; j < T.size();j++){
            if(S[i+j] != T[j]) cnt ++;
        }
        best = min(best,cnt);
    }
    cout << best;
}

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

const int N = 1e5 + 10;

bool ok[N];
char s[5];
int c[N];

int main (void) {
	int n, m, ans = 0;
	long long per = 0;
	scanf("%d%d", &n, &m);
	for (int i = 1, x; i <= m; i++) {
		scanf("%d%s", &x, s);
		if (s[0] == 'A') {
			if (ok[x] == false) {
				ok[x] = true;
				ans ++;
				per += c[x];
			}
		} else c[x] ++;
	}
	printf("%d %lld\n", ans, per);
}

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

int main() {
  
  int a,b,c;
  cin >> a >> b >> c;
  
  if ( a == b && b == c && c == a ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
 
}


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7

K, A, B = MAP()

# 上がっていかない場合
if B >= A:
    # 初回で行ければOK、そうでなければNG
    if A >= K:
        print(1)
    else:
        print(-1)
else:
    # A + (A-B)*x >= K → x >= (K-A) / (A-B)
    x = ceil((K-A), (A-B))
    # 2回に1回しか上がらないので、その調整
    print(x*2+1)


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

int main(){
  long long n;
  long long b;
  cin>>n;
  vector<char>c;
  while(n>0){
    b=n%26;
    n/=26;
    if(b==0){
      b=26;
      n--;
    }
    c.push_back((char)b+'a'-1);
  }
  reverse(c.begin(),c.end());
  for(int i=0;i<c.size();i++){
    cout<<c[i];
  }
  cout<<endl;
  return 0;
}
    


Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int num = Integer.parseInt(in.nextLine());
		String line = in.nextLine();
		List<Character> input = new ArrayList<>();
		for (int i = 0; i < num; ++i) {
			input.add(new Character(line.charAt(i)));
		}

		System.out.println(calc(input));

		in.close();

	}

	public static int calc(List<Character> input) {
		Set<Character> chars = new HashSet<>();
		chars.addAll(Arrays.asList(input.stream().distinct().toArray(Character[]::new)));
		int result = Integer.MIN_VALUE;
		for (int i = 1; i < input.size(); ++i) {
			int count = count(input.subList(0, i), input.subList(i, input.size()));
			if (count > result) {
				result = count;
			}
		}
		return result;
	}

	public static int count(List<Character> first, List<Character> last) {
		Set<Character> firstChars = new HashSet<>();
		firstChars.addAll(first);
		Set<Character> lastChars = new HashSet<>();
		lastChars.addAll(last);
		int result = 0;
		for (Character c : firstChars) {
			if (last.contains(c)) {
				result++;
			}
		}
		return result;
	}

}

Measured memory_bytes: 28752
#include<bits/stdc++.h>
#define fr(i,a,b) for(register int i = a;i <= b;++i)
#define int long long
#define N 1000010
using namespace std;

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

inline int fread(){
	char c = getchar();
	while(!isdigit(c))c = getchar();
	return c - '0';
}

signed main(){
	string s;
	cin>>s;
	if(s == "Sunny")cout<<"Cloudy";
	else if(s == "Rainy")cout<<"Sunny";
	else if(s == "Cloudy")cout<<"Rainy";
	return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long X = l[0], Y = l[1];

            // 25*1=25.25*2=50.50*2=100;
            long total = 0, cur = X;

            while (cur <= Y)
            {
                cur *= 2;
                total++;
            }
            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;

    cin >> n;

    switch (n)
    {
    case 1:
        cout << "Hello World" << endl;
        break;

    default:
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
        break;
    }
}


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

/**
 * Created by Harry on 4/6/20.
 */
//https://atcoder.jp/contests/dp/tasks/dp_p
public class Main {
    public static long mod = 1000000007;
    public static void main(String[] args){
        Scanner scanner = new Scanner(new BufferedInputStream(System.in));
        int n = scanner.nextInt();
        List<Integer>[] graph = new List[n+1];
        for(int i=1; i<=n-1; i++){
            int v1 = scanner.nextInt();
            int v2 = scanner.nextInt();
            if(graph[v1]==null){
                graph[v1]=new ArrayList();
            }
            if(graph[v2]==null){
                graph[v2]=new ArrayList();
            }
            graph[v1].add(v2);
            graph[v2].add(v1);
        }
        long[] res = count(1, graph, 0);
        System.out.print((res[0]+res[1])%mod);
    }

    //white, black
    public static long[] count(int node, List<Integer>[] graph, int parent){
        long w = 1;
        long b = 1;
        if(graph[node]!=null){
            for(int child : graph[node]){
                if(child != parent){
                    long[] childRes = count(child, graph, node);
                    b = (b*childRes[0])%mod;
                    w =  (w*(childRes[0]+childRes[1]))%mod;
                }
            }
        }
        return new long[]{w,b};
    }
}


Measured memory_bytes: 117520
n, k = map(int, input().split())
h = []

for i in range(n):
    h.append(int(input()))
min = 10 ** 10
#  print(h)
h = sorted(h)
#  print(h)
for i in range(n-k+1):
    #  print(h[i:i+k-1])
    div = h[i+k-1] - h[i]
    if div < min:
        min = div
    if min == 0:
        print(min)
        exit()
print(min)


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

#define MAX_V 100005

using namespace std;

struct edge {
  int dst, cost;
  edge() {}
  edge(int b, int c) : dst(b), cost(c) {}
};

vector<edge> tree[MAX_V];
int ans[MAX_V];

void dfs(int cur_v, int par_v, int prev_color, int cost) {
  ans[cur_v] = (prev_color+cost) & 1;
  for (int i = 0; i < tree[cur_v].size(); i++) {
    edge e = tree[cur_v][i];
    if ( e.dst == par_v ) { continue; }
    dfs (e.dst, cur_v, ans[cur_v], e.cost);
  }
}

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

  for (int i = 0; i < n-1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    tree[u].push_back( edge(v, w) );
    tree[v].push_back( edge(u, w) );
  }
  
  dfs(0, -1, 0, 0);

  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 9216
import Control.Applicative

bubbleSort :: [Int] -> (Int ,[Int])
bubbleSort xs = loop (1, 0, xs)
  where
    n = length xs - 2
    loop (0, m, xs) = (m, xs)
    loop (1, m, xs) = loop $ foldr f (0, m, xs) [0 .. n]
    f i  (f, m, xs) = if b > c
                      then (1, m + 1, (as ++ c : b : ds))
                      else (f, m, as ++ bs)
      where (as, bs@(b : c : ds)) = splitAt i xs

main :: IO ()
main = do
  _  <- getLine
  xs <- map read . words <$> getLine
  let (m, ys) = bubbleSort xs
  putStrLn $ unwords $ map show ys
  print m



Measured memory_bytes: 4996
using System;

class FightingOverCandies {
    static void Main(string[] args)
    {
        int a, b, c;
        string[] s;

        s = Console.ReadLine().Split(' ');

        a = int.Parse(s[0]);
        b = int.Parse(s[1]);
        c = int.Parse(s[2]);

        if (a == b+c || b == c+a || c == a+b)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}

Measured memory_bytes: 2648
import math
N = int(input())
res = []
num = []
for i in range(1, int(math.sqrt(N+1))+1):
  if N % i == 0:
    div = N // i
    if div >= i:
      str_num = str(div)
      res.append(len(list(str_num)))
print(min(res))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  char s[4]; for(int i = 0; i < 4; i++) cin >> s[i];
  int i;
  for(i = 0; i < 3; i++){
    if(s[i] == s[i + 1]) break;
  }
  if(i == 3) cout << "Good\n";
  else cout << "Bad\n";
  return;
}

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


Measured memory_bytes: 256
/*
	0592:Average Score
*/
#include	<iostream>

using namespace std;

int main(void) {
	int sum = 0;
	for(int i = 0; i < 5; i++) {
		int point;
		cin >> point;
		if(point < 40) {
			point = 40;
		}
		sum += point;
	}
	cout << sum / 5 << endl;
	
	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int X = scan.nextInt();

	if(X == 3 || X == 5 || X == 7)
	    System.out.println("YES");
	else
	    System.out.println("NO");
    }
}

Measured memory_bytes: 25044
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 9e18
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;

class Lowlink {
public:
	vi ord, low;
	vb vis;
	vi articulation;
	vPi bridge;

	Lowlink(const Graph &G) {
		ord = vi(G.size());
		low = vi(G.size());
		vis = vb(G.size(), false);
		int k = 0;
		for (int i = 0; i < G.size(); i++) {
			if (!vis[i]) dfs(G, i, -1, k);
		}
	}

	void dfs(const Graph &G, int v, int p, int &k)
	{
		vis[v] = true;

		ord[v] = k++;
		low[v] = ord[v];

		bool isArticulation = false;
		int ct = 0;

		for (int i = 0; i < G[v].size(); i++) {
			if (!vis[G[v][i].to]) {
				ct++;
				dfs(G, G[v][i].to, v, k);
				low[v] = min(low[v], low[G[v][i].to]);
				if (p != -1 && ord[v] <= low[G[v][i].to]) isArticulation = true;
				if (ord[v] < low[G[v][i].to]) bridge.push_back(make_pair(min(v, G[v][i].to), max(v, G[v][i].to)));
			}
			else if (G[v][i].to != p) {
				low[v] = min(low[v], ord[G[v][i].to]);
			}
		}

		if (p == -1 && ct > 1) isArticulation = true;
		if (isArticulation) articulation.push_back(v);
	}
};

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

	int N, M;
	cin >> N >> M;
	Graph G(N);
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(Edge{ a,b,1 });
		G[b].push_back(Edge{ b,a,1 });
	}

	Lowlink lowlink(G);

	cout << lowlink.bridge.size() << endl;

	return 0;
}

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int N,K; cin >> N >> K;
  vector<ll> v(N+1,0);

  for(int i = 0; i < N; i++){
    ll tmp; cin >> tmp;
    v[i+1] = tmp;
  }

  for(int i = 1; i <= N; i++){
    v[i] = v[i] + v[i-1];
  }

  ll max_val = 0;
  for(int i = N; i - K >= 0; i--){
    max_val = max(max_val, v[i] - v[i - K]);
  }
  cout << (double)(max_val+K) / 2.0 << endl;

}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

class HistTree {
	typedef struct {
		cat h;
		int l, r, zero;
		vector<int> son;
	} node;

	constexpr static cat mod = 1000000007;

	int N;
	vector<cat> H;
	vector<node> T;

	void Build(int l, int r, cat h) {
		cat minh = H[l];
		for(int i = l; i < r; i++) minh = min(minh, H[i]);
		T.push_back({minh-h, l, r, 0, vector<int>()});
		int l_higher = r, id = T.size()-1;
		for(int i = l; i <= r; i++) {
			if(i < r && H[i] != minh) {
				if(l_higher == r) l_higher = i;
				continue;
			}
			if(i < r) T[id].zero++;
			if(l_higher == r) continue;
			T[id].son.push_back(T.size());
			Build(l_higher, i, minh);
			l_higher = r;
		}
	}

	cat pw(cat a, cat e) {
		if(e <= 0) return 1;
		cat x = pw(a, e/2);
		x = x * x % mod;
		if(e&1) x = x * a % mod;
		return x;
	}

public:
	HistTree(const vector<cat> & H) : N(H.size()), H(H) {
		Build(0, N, 0);
	}

	pair<cat, cat> Solve(int node_id = 0) {
		// returns: (all, with horizontally alternating bottom)
		node & n = T[node_id];
		vector< pair<cat, cat> > son_ans;
		ALL_THE(n.son, it) son_ans.push_back(Solve(*it));
		// vertically alternating
		cat cnt_valt = 1;
		ALL_THE(son_ans, it) cnt_valt = cnt_valt * (it->ff + 2 * it->ss) % mod;
		for(int i = 0; i < n.zero; i++) cnt_valt = cnt_valt * 2 % mod;
		// horizontally alternating
		pair<cat, cat> ret = {cnt_valt, 0};
		cat cnt_halt = 1;
		ALL_THE(son_ans, it) cnt_halt = cnt_halt * 2 * it->ss % mod;
		ret.ff = (ret.ff + (pw(2, n.h) - 2) * cnt_halt) % mod;
		if(ret.ff < 0) ret.ff += mod;
		ret.ss = cnt_halt * pw(2, n.h-1) % mod;
		return ret;
	}
};

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<cat> H(N);
	for(int i = 0; i < N; i++) cin >> H[i];
	HistTree T(H);
	cout << T.Solve().ff << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
typedef long long int ll;
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
 
    multiset<int, greater<int>> a;
    int a_;
    rep(i, n) {
        cin >> a_;
        a.insert(a_);
    }

    while (0 < m) {
        auto it = a.begin();
        a_ = *it / 2;
        a.erase(it);
        a.insert(a_);
        m--;
    }

    ll sum = 0;
    auto it = a.begin();
    rep(i, n) {
        sum += *(it++);
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 8164
package main

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

func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	h := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		h[i], _ = strconv.Atoi(sc.Text())
	}

	dp := make([]int, n+1)
	dp[0] = 0
	dp[1] = abs(h[1] - h[0])
	for i := 2;i < n; i++ {
		dp[i] = min(dp[i-1]+abs(h[i]- h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
	}

	fmt.Println(dp[n-1])
}

func abs(n int) int {
	y := n >> 63
	return (n ^ y) - y
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 3864
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	string S, T;
	cin >> S >> T;

	int saishou = 1e9;

	int n = S.size(), m = T.size();
	rep(i, n - m + 1) {
		int cnt = 0;
		rep(j, m) {
			cnt += (S[i + j] != T[j]);
		}
		chmin(saishou, cnt);
	}

	co(saishou);

	Would you please return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    vec<string> ans = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"};
    int n;
    cin >> n;
    vec<set<vec<int>>> dp(n);
    dp[0].insert(vec<int>(1, 0));
    rep(i, n-1) {
        set<vec<int>> kon = dp[i];
        set<vec<int>>::iterator it;
        for (it = kon.begin(); it != kon.end(); ++it) {
            vec<int> val = *it;
            rep(j, i+2) {
                vec<int> tmp;
                tmp.push_back(0);
                int target;
                if (j==i+1) target = -1;
                else target = val[j];
                rep(k, i+1) {
                    if (val[k] == target) tmp.push_back(0);
                    else tmp.push_back(val[k]+1);
                }

                map<int, int> mp;
                rep(ii, n) mp[ii]++;
                rep(ii, n) mp[tmp[ii]]++;
                map<int, int>::iterator it2;
                int count = 0;
                for (it2 = mp.begin(); it2 != mp.end(); it2++) {
                    if (it2->second==1) continue;
                    rep(kk, n) if (tmp[kk]==it2->first) tmp[kk] = count;
                    count++;
                }

                dp[i+1].insert(tmp);
            }
        }
    }   
    set<vec<int>>::iterator it2;
    for (it2 = dp[n-1].begin(); it2 != dp[n-1].end(); ++it2) {
        rep(i, n) cout << ans[(*it2)[i]];
        cout << endl;
    }
}   

Measured memory_bytes: 19328
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, Ma, Mb = map(int, input().split())
A = [0] * N
B = [0] * N
C = [0] * N

for i in range(N):
    A[i], B[i], C[i] = map(int, input().split())

INF = 1 << 50
LEN = 500
dp = [[INF] * (LEN + 1) for _ in range(LEN + 1)]
dp[0][0] = 0

for i in range(N):
    for j in range(LEN, A[i] - 1, -1):
        for k in range(LEN, B[i] - 1, -1):
            dp[j][k] = min(dp[j][k], dp[j - A[i]][k - B[i]] + C[i])

cnt = 1
ans = INF
while cnt * Ma < LEN and cnt * Mb < LEN:
    ans = min(ans, dp[cnt * Ma][cnt * Mb])
    cnt += 1

print(ans if ans != INF else -1)

Measured memory_bytes: 42604
from bisect import bisect_right
from collections import defaultdict

N = int(input())
S = input()
INF = float('inf')

nToD = defaultdict(list)
for d, s in enumerate(S):
    nToD[s].append(d)
for d in range(10):
    nToD[str(d)].append(INF)

ans = 0
for i in range(1000):
    P = '%03d' % i
    prev = nToD[P[0]][0]

    if prev == INF:
        continue

    for p in P[1:]:
        prev = nToD[p][bisect_right(nToD[p], prev)]
        if prev == INF:
            break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 4716
#include<stdio.h>
int main(void){
	int n,i,output,yaku;
	scanf("%d",&n);
	if(n%2!=0){
		yaku=n/2+1;
	}else{
		yaku=n/2;
	}
	for(i=1;i<=yaku;i++){
		if(yaku!=i){
			output++;
		}
	}
	printf("%d",output);
	return 0;
}	

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	string ss, tt;
	bool flag;
	cin >> ss >> tt;
	int64 lens = ss.length(), lent = tt.length();
	for(int64 ii = 0;ii < lens - lent;ii++)
	{
		if(ss.substr(ii, lent) == tt)
		{
			for(int64 jj = 0;jj < lens;jj++)
			{
				if(ss[jj] == '?')
				{
					ss[jj] = 'a';
				}
			}
			cout << ss << endl;
			return 0;
		}
	}
	for(int64 ii = lens - lent;ii >= 0;ii--)
	{
		flag = false;
		for(int64 jj = 0;jj < lent;jj++)
		{
			if(ss[ii + jj] == tt[jj] || ss[ii + jj] == '?')
			{
				continue;
			}
			else
			{
				flag = true;
				break;
			}
		}
		if(!flag)
		{
			for(int64 jj = 0;jj < lent;jj++)
			{
				ss[ii + jj] = tt[jj];
			}
			for(int64 jj = 0;jj < lens;jj++)
			{
				if(ss[jj] == '?')
				{
					ss[jj] = 'a';
				}
			}
			cout << ss << endl;
			return 0;
		}
	}
	cout << "UNRESTORABLE" << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<typename T>
bool check(const vector<T> &v, const int &MAX, T x){ //v[i]<2^MAX
    int n=v.size();
    vector<T> ret=v;
    int d=0;
    for(int k=MAX-1; k>=0; k--){
        int p=-1;
        for(int i=d; i<n; i++){
            if((ret[i]>>k)&1){
                p=i;
                break;
            }
        }
        if(p==-1) continue;
        swap(ret[d], ret[p]);
        for(int i=0; i<n; i++){
            if(i==d) continue;
            if((ret[i]>>k)&1) ret[i]^=ret[d];
        }
		if((x>>k)&1) x^=ret[d];
        d++;
    }
    if(x) return false;
	else return true;
}
int main()
{
	int t; cin>>t;
	while(t--){
		int n; cin>>n;
		vector<ll> a(n);
		string s;
		for(int i=0; i<n; i++) cin>>a[i];
		cin>>s;
		reverse(s.begin(), s.end());
		reverse(a.begin(), a.end());
		if(s[0]=='1'){
			cout<<1<<endl;
			continue;
		}
		bool dame=0;
		vector<ll> v;
		for(int i=0; i<n; i++){
			if(s[i]=='1'){
				if(!check(v, 60, a[i])){
					dame=1; break;
				}
			}else{
				v.push_back(a[i]);
			}
		}
		if(!dame) cout<<0<<endl;
		else cout<<1<<endl;
	}
	return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    int M,D;
    cin >> M >> D;
    int ans;
    for (int m = 1; m <= M; m++){
        for(int j = 22; j <=D; j++){
            int d1 = j % 10;
            int d2 = (j - d1) / 10;
            if (d1 >= 2 && d2 >= 2 && d1*d2 == m){
                ans++;
            }
        }
    }
    cout << (ans) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

class mainClass
{
    

    static void Main()
    {
        int cnt = 0;
        int n = int.Parse(Console.ReadLine());
        string[] a = Console.ReadLine().Split(' ');

        while (true)
        {

            bool existOdd = false;
            for (var i = 0; i < a.Length; i++)
            { if (int.Parse(a[i]) % 2 != 0) existOdd = true; }

            if (existOdd == true) { break; }

            for (var i = 0; i < a.Length; i++)
            {
                if (int.Parse(a[i]) % 2 != 0)
                {
                    break;
                }
                else
                {
                    a[i] = (int.Parse(a[i]) / 2).ToString();
                    continue;
                }
            }
            cnt++;
        }
        Console.WriteLine(cnt);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, m, ans = 0;
    string s;
    vector<string> dic;
    vector<int> pts;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> s;
        auto itr = find(dic.begin(), dic.end(), s);
        if (itr != dic.end()){
            pts.at(itr - dic.begin())++;
        } else {
            dic.push_back(s);
            pts.push_back(1);
        }
    }
    cin >> m;
    for (int j = 0; j < m; j++){
        cin >> s;
        auto itr = find(dic.begin(), dic.end(), s);
        if (itr != dic.end()){
            pts.at(itr - dic.begin())--;
        }
    }
    for(auto e : pts){
        ans = max(ans, e);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<ctime>
#include<cmath>
#include<deque>
#include<queue>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
#define _rep(i,s,t) for(register int i=s;i>=t;--i)
#define Rep(i,s,t) for(register int i=s;i<t;++i)
#define go(x) for(register int e=las[x];e;e=nxt[e])
#define re register
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define is insert
#define es erase
#define pii pair<int,int>
#define ms(f,x) memset(f,x,sizeof f)
#define mc(f,x) memcpy(f,x,sizeof f)
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
#define gi(x) read(x)
#define gii(x,y) read(x),read(y)
#define giii(x,y,z) read(x),read(y),read(z)
namespace IO{
    #define gc getchar()
    #define pc(x) putchar(x)
    template<typename T>inline void read(T &x){
        x=0;int f=1;char ch=gc;while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=gc;}
        while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=gc;x*=f;return;
    }
    template<typename T>inline void write(T x=0){
        T wr[51];wr[0]=0;if(x<0)pc('-'),x=-x;if(!x)pc(48);
        while(x)wr[++wr[0]]=x%10,x/=10;while(wr[0])pc(48+wr[wr[0]--]);return;
    }
}
using IO::read;
using IO::write;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
int n,m;
int a[111],b[111],id[111];
inline bool cmp(int x,int y){
	return b[x]<b[y];
}
int main(){
	scanf("%d",&n);
	rep(i,1,n){
		scanf("%d",&a[i]);
	}
	rep(i,1,n){
		_rep(j,n-i+1,1)
			if(a[j]==j){
				b[i]=j;
				rep(k,j+1,n-i+1)
					a[k-1]=a[k];
				break;
			}
	}
	if(b[n]==0){
		puts("-1");
		return 0;
	}
	for(int i=n;i;--i)
		printf("%d\n",b[i]);
	return 0;
}

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

struct Edge {
	int src, dst;
	Edge() : src(0), dst(0) {}
	Edge(int s, int d) : src(s), dst(d) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;

vector<int> SCC(const Graph &g) {
	int n = g.size(), sz = 0; Graph rg(n);
	vector<int> stk, cmp(n, -1), added(n), visited(n), ord(n);
	for(auto &es : g) {
		sz += es.size();
		for(const Edge &e : es) rg[e.dst].emplace_back(e.dst, e.src);
	}
	stk.resize(n + sz); sz = 0;
	for(int i = 0; i < n; i++) {
		if(visited[i]) continue;
		int s = 0; stk[s++] = i;
		while(s != 0) {
			int v = stk[s - 1]; visited[v] = true;
			bool pushed = false;
			for(auto &e : g[v]) {
				int dst = e.dst;
				if(!visited[dst]) { stk[s++] = dst; pushed = true; }
			}
			if(pushed) continue;
			int t = stk[s - 1];
			if(!added[t]) { added[t] = true; ord[n - ++sz] = t; }
			--s;
		}
	}
	int k = 0;
	for(int &u : ord) {
		if(cmp[u] != -1) continue;
		int s = 0; stk[s++] = u;
		while(s != 0) {
			int v = stk[--s]; cmp[v] = k;
			for(auto &e : rg[v]) {
				int d = e.dst;
				if(cmp[d] == -1) stk[s++] = d;
			}
		}
		++k;
	}
	return cmp;
}


double pr[100];

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

	int N;
	while(cin >> N, N) {
		Graph G(N);
		for(int i = 0; i < N; i++) {
			cin >> pr[i];
			int m, x;
			cin >> m;
			while(m--) {
				cin >> x;
				x--;
				G[i].push_back({ i ,x });
			}
		}
		auto scc = SCC(G);

		int V = *max_element(scc.begin(), scc.end()) + 1;
		vector<vector<int>> vs(V);
		vector<int> deg(V);
		for(int i = 0; i < N; i++) {
			vs[scc[i]].push_back(i);
			for(auto e : G[i]) {
				if(scc[i] != scc[e.dst]) {
					deg[scc[e.dst]]++;
				}
			}
		}

		double ans = 1.0;
		for(int i = 0; i < V; i++) {
			if(deg[i] > 0) continue;
			double all_sleep = 1.0;
			for(auto v : vs[i]) {
				all_sleep *= pr[v];
			}
			ans *= 1.0 - all_sleep;
		}

		cout << fixed << setprecision(15) << ans << endl;
	}
}

Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)


int main() {
    int x, n;
    cin >> x >> n;
    vector<int> p(n, 0), l(110);
    for (int i=0; i<n; ++i) cin >> p[i];
    for (int i=0; i<l.size(); ++i) l[i]=i;
    int num = 1e5;
    int ans = 0;
    for (int i=0; i<n; ++i){
        l[p[i]]=1e9;
    }
    for (int i=0; i<l.size(); ++i){
        if (num > abs(x-l[i])){
            num = abs(x-l[i]);
            ans = l[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
n = int(input())
s = input()

count,left,right = 0, 0, 0
for i in s:
    if i == ")" and count != 0:
        count -= 1
        right -= 1
    elif i == ")" and count == 0:
        left += 1
    elif i == "(":
        count += 1
        right += 1
print("(" * left + s + ")" * right)

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


int main() {

    int a, b;
    cin >> a >> b;
    int ans = max({a+b, a-b, a*b});
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[5]={-1,0,1,0,0};
int dy[5]={0,-1,0,1,0};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
V<ll> G[100010];
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n,m;cin>>n>>m;
    V<ll>h(n);
    for(ll i=0;i<n;i++)cin>>h[i];
    for(ll i=0;i<m;i++){
        ll a,b;cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
        bool abc=1;
        //if(i==4)cout<<abc<<endl;
        for(ll j=0;j<G[i].size();j++){
            if(h[G[i][j]]>=h[i]){
                abc=0;
                break;
            }
        }
        //if(i==4)cout<<abc<<endl;
        if(abc==1){
            ans++;
            //cout<<i+1<<endl;
        }
    }
    
    cout<<ans<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































Measured memory_bytes: 9800
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=57;
ll mod;

int n=50;

ll pot[nax][nax];

ll wyn;

int jeszkol[nax][nax];

void ff()
{
	fflush(stdout);
}

int pyt(int a, int b, int x, int y)
{
	printf("? %d %d %d %d\n", a, x, b, y);
	ff();
	int v;
	scanf("%d", &v);
	return v;
}

int los(int a, int b)
{
	return (rand()%(b-a+1))+a;
}

void szuk(int a, int b, int x, int y, int w)
{
	if (!w)
		return;
	if ((a/10)==(b/10) && !jeszkol[x][a/10])
	{
		szuk(a, b, x+1, y, w);
		return;
	}
	if ((a/10)==(b/10) && !jeszkol[y][a/10])
	{
		szuk(a, b, x, y-1, w);
		return;
	}
	if (w==(b-a+1)*(y-x+1))
	{
		for (int i=a; i<=b; i++)
		{
			for (int j=x; j<=y; j++)
			{
				wyn+=pot[i][j];
				jeszkol[j][i/10]--;
			}
		}
		return;
	}
	//~ if (x==y || (a!=b && (rand()&1)))
	if (a!=b)
	{
		int s=(a+b)>>1;
		//~ int s=los(a, b-1);
		int p=pyt(a, s, x, y);
		if (rand()&1)
		{
			szuk(a, s, x, y, p);
			szuk(s+1, b, x, y, w-p);
		}
		else
		{
			szuk(s+1, b, x, y, w-p);
			szuk(a, s, x, y, p);
		}
	}
	else
	{
		int s=(x+y)>>1;
		//~ int s=los(x, y-1);
		int p=pyt(a, b, x, s);
		if (rand()&1)
		{
			szuk(a, b, x, s, p);
			szuk(a, b, s+1, y, w-p);
		}
		else
		{
			szuk(a, b, s+1, y, w-p);
			szuk(a, b, x, s, p);
		}
	}
}

int main()
{
	int szit;
	scanf("%d%d%d%lld", &szit, &szit, &szit, &mod);
	ll trz=1;
	for (int i=0; i<n; i++)
	{
		for (int j=0; j<n; j++)
		{
			pot[i][j]=trz;
			trz=(trz*2)%mod;
		}
	}
	for (int i=0; i<n; i++)
		for (int j=0; j<5; j++)
			jeszkol[i][j]=pyt(10*j, 10*j+9, i, i);
	szuk(0, n-1, 0, n-1, 250);
	printf("! %lld\n", wyn%mod);
	ff();
	return 0;
}


Measured memory_bytes: 724