akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <stack>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <math.h>
#include <random>



#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

using lli = long long int;
using pii = std::pair<int, int>;

template <class T> inline bool chmax(T& a, T b){
    if(a < b){a = b; return true;}
    return false;
}
template <class T> inline bool chmin(T& a, T b){
    if(a > b){a = b; return true;}
    return false;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


/* (考察欄)
    中央値の全列挙では間に合わない : 組み合わせだけでO(N^2)
    解はいずれかのaj であるからこれを全探索 or 二分探索で O(NlogN)なら間に合いそう
    判定はO(logN)は厳しそう => 二分探索 with 判定 O(N) が現実的

    二分探索 ~~~> ① 単調性はあるか ? (どんな単調性を見出す ?)
                    その単調性において, [中央値] 最大性or最小性は？
            ~~~> ② 判定は O(N) 程度で可能か ?
    
    ・ 単調性 ~~~> 数列内での"順位" : 
                  「 自身以下の数が"半分"以上ある 」部分列の数が最小 (?)
                  中央値未満 => 以下の数は L/2 以下
                  中央値以上 => 以下の数は L/2 + 1以上
                  ~~~> (以下の数) > (超過の数) <=> 中央値以上の値
                  n(n-1)/4 + 1 overの最小

        ・ then, 自分以下の数が半分以上ある部分列の数は数えられるか O(N) 程度
           全ての数列から自身の値を比較 => 以下 or 超過 の bool で管理可能
           数を累積和使って計算すれば早く答えられる？でもO(N^2)はかかる

    (結論) : わからん！   O(N^2logN)
*/


/* (解説後)
    ① : bool型のものを長さの半分以上か判定するのに, 1と-1を使えば長さに無依存に判定が可能
    ② : 転倒数を学べ
*/

class Bit{ // 1-indexedに注意
    const int n; // 最大値
    std::vector<int> bit;
public:
    Bit(int nn): n(nn){
        bit.resize(n+1, 0);
    }
    // 0で再初期化
    bool clear(){
        std::fill(bit.begin(), bit.end(), 0);
        return true;
    }
    // A[idx]にvalを加算
    bool add(int idx, int val){
        if(n < idx) return false;
        for(int i = idx; i <= n; i += (i & (-i))) bit[i] += val;
        return true;
    }
    // 区間[1, 2, ..., a]の和
    int sum(int idx){
        int res = 0;
        for(int i = idx; i > 0; i -= (i & (-i))) res += bit[i];
        return res;
    }
};

std::vector<int> A, SA;

int main(void){
    int n; scanf("%d", &n);
    A.resize(n); REP(i, n) scanf("%d", &A[i]);
    SA = A; std::sort(SA.begin(), SA.end());
    

    Bit BT(2 * (n + 1));

    lli MSize = n; MSize *= (n+1); MSize /= 2;

    // 二分探索
    int ok = n-1 , ng = -1;
    while(ok - ng > 1){
        
        int t = (ok + ng) / 2;
        int v = SA[t];
                // 判定部分
                BT.clear();
                int S = n+1; BT.add(S, 1);
                lli cnt = 0; // l < r であって, S_l < S_r なるものを数える
                for(int i = 0; i < n; ++i){
                    if(A[i] <= v) S++; else S--;
                    cnt += BT.sum(S-1);
                    BT.add(S, 1);
                }
                // S_l < S_r なるものは MSize - cnt
        
        
        if(MSize - cnt < cnt ) ok = t;
        else ng = t;
    }
    printf("%d\n", SA[ok]);
    

    return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>
#include <algorithm>
using namespace std;
int a[3];
int main(int argc, char *argv[])
{
	int i,n;
	int a1,a2,a3;
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	sort(a,a+3);
	printf("%d\n",a[2]-a[0]);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int L = scan.nextInt();
    int R = scan.nextInt();
    int d = scan.nextInt();
    int ans = 0;
    if (L % d == 0) {
      ans += 1;
    }
    L = L / d;
    R = R / d;
    ans += R - L;
    System.out.println(ans);
  }
}

Measured memory_bytes: 35660
#include <cstdio>
#include <algorithm>
using namespace std;
using ll = long long int;

const int S = 1000005;
const int MOD = 998244353;
ll fact[S+10], finv[S+10];

ll mod_pow(ll X, ll N) {
    ll res = 1;
    for(; N>0; N>>=1) {
        if(N & 1) (res *= X) %= MOD;
        (X *= X) %= MOD;
    }
    return res;
}

void comb_init() {
    fact[0] = 1;
    for(int i=1; i<=S; i++) {
        fact[i] = (fact[i-1] * i) % MOD;
    }

    finv[S] = mod_pow(fact[S], MOD-2);
    for(int i=S; i>=1; i--) {
        finv[i-1] = (finv[i] * i) % MOD;
    }
}

ll comb(int n, int r) {
    if(n < 0 || r < 0 || r > n) return 0;
    return fact[n] * finv[n-r] % MOD * finv[r] % MOD;
}

int main() {
    comb_init();
    int N, M; scanf("%d%d", &N, &M);
    if(N < M) swap(N, M);

    ll ans = 0;
    for(int k=1; k<=M; k++) {
        ll pre = comb(2*k, k);
        ll suf = comb(N+M-2*k, N-k);

       (ans += pre * suf % MOD) %= MOD;
    }
    ans = ans * mod_pow(2 * comb(N+M, N) % MOD, MOD - 2) % MOD;
    (ans += N) %= MOD;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 15744
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int stack[200],s_ptr=0;
void push(int d){
    stack[s_ptr]=d;
    s_ptr++;
}
int pop(void){
    s_ptr--;
    return stack[s_ptr];
}
int main(void){
    int a,b;char str[1200],*tok;
    fgets(str,1200,stdin);
    tok=strtok(str," ");
    while(tok!=NULL){
        if (tok[0] >= '0' && tok[0] <= '9'){push(atoi(tok));}
        else if (tok[0]=='-'){b=pop();a=pop();push(a-b);}
        else if (tok[0]=='+'){b=pop();a=pop();push(a+b);}
        else if (tok[0]=='*'){b=pop();a=pop();push(a*b);}
        tok=strtok(NULL," ");
    }
    printf("%d\n",pop());
}
    


Measured memory_bytes: 2048
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

    def size(self, x):
        return -self.parents[self.find(x)]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]


N, M, K = map(int, input().split())
uf = UnionFind(N)
friends = [[] for _ in range(N)]
blocks = [[] for _ in range(N)]
root = {}

for i in range(M):
    a, b = map(int, input().split())
    friends[a - 1].append(b - 1)
    friends[b - 1].append(a - 1)
    uf.unite(a - 1, b - 1)

for i in range(K):
    c, d = map(int, input().split())
    if uf.same(c - 1, d - 1):
        blocks[c - 1].append(d - 1)
        blocks[d - 1].append(c - 1)

ans = []
for i in range(N):
    ans.append(uf.size(i) - 1 - len(blocks[i]) - len(friends[i]))
print(*ans)


Measured memory_bytes: 50052
let n = stdin.ReadLine() |> int
let mutable a = stdin.ReadLine().Split(' ') |> Array.map int64
let mutable ans = 1000000000000000005L 

let X = Array.sum(a) |> int64
let mutable x = 0 |>int64

let mini(c,b)=
    if c > b then
        b
     else
        c

let abns(e)=
    if e > 0 then
        e|>int64
    else
        -e|>int64

for i in[0..n-1]do
x<-x+a.[i]
let tw = 2|>int64
let dd = tw*x
let dx = X-dd
if i+1<n then ans <- mini(ans,abs(dx));;

printfn "%d" ans

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

int main()
{
  int a[3];
  int f=0,s=0;
cin >> a[0] >> a[1] >> a[2];
  for (int i = 0; i < 3; i++) {
   if (a[i] == 5) f++;
   if (a[i] == 7) s++;
  } 
   if (f == 2 && s == 1) {
   cout << "YES" << endl;
} else {
   cout << "NO" << endl;
}
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string.h>
#include <cstring>
#include <cstdio>

using namespace std ;

char s[233];
long long k ;
int n ;

int main ()
{
	int i ;
	scanf("%s\n",s+1),n=strlen(s+1);
	scanf("%lld",&k);
	i=1;
	while ( k>1 && s[i]=='1' && i<=n ) i++,k--;
	if ( k<=1 && s[i]=='1' ) puts("1");
	else 
	{
		while ( s[i]=='1' ) i++;
		putchar(s[i]);
	}
	return 0 ;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,m,c;
  scanf("%d%d%d",&n,&m,&c);
  int b[m],a[n][m];
  for (int i=0;i<m;i++){
    scanf("%d",&b[i]);
  }
  for (int i=0;i<n;i++){
    for (int j=0;j<m;j++){
      scanf("%d",&a[i][j]);
    }
  }
  int count=0;
  for (int i=0;i<n;i++){
    int sum=0;
    for (int j=0;j<m;j++){
      sum+=a[i][j]*b[j];
    }
    if (sum>-c){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  long a, b, c=0, d=0, e, f, g, h, n;
  string s, j="yes";
  cin >> s;
  int z[26]={};
  int l;
  rep(i,0,s.size()){
    l=s[i];
    z[l-97]++;
  }
  rep(i,0,s.size()){
    if(z[i]>1){
      j="no";
      break;
    }
  }
  co(j);
  
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdlib>
using namespace std;
#define pb push_back
#define N 200001
#define ll long long
#define int long long
#define pi pair<int , int>
#define pip pair<pi ,int>
#define mp make_pair
#define f first
#define s second
#define mod 998244353
int32_t main(){
   ios_base::sync_with_stdio(false);
      cin.tie(NULL);
    cout.tie(NULL);


////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//                int php[4000] , cdc[8000], cdm[8000];
//                for(int j=0;j<5;j++){
//for(int i=0;i<2000;i++)php[i/10]=1;
//for(int i=0;i<2000;i++)php[i/10]=1;
//for(int i=0;i<2000;i++)php[i/10]=1;
//for(int i=0;i<2000;i++)php[i/10]=1;
//for(int i=0;i<2000;i++)php[i/10]=1;
//for(int i=0;i<2000;i++)php[i/10]=1;
//                }
//
// vector<int> ab;
// vector<int> ab1(1000);
// vector<int> ab2;
// vector<int> ab3;
// vector<int> ab4;
// vector<int> ab5;
// string abcd="bdcccebcaca kjbcbsnklnslknvksn  nidcldklcnlsn";
// string abcd1="bdcccebcaca kjbcbsnklnslknvksn  nidcldklcnlsn cbcksknlsnv";
// string abcd2="bdcccebcaca kjbcbsnklnslknvksn  nidcldklcnlsn kjeaebbaekcmaekes";
//
//
// char abcde[1000];
// int mfch=0;
// int abcdefg[1000];
// int abcg[1000];
// int abcfg[1000];

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



//    ll t;
//    cin>>t;
//    while(t--)
        {
   int n;
   cin>>n;
   int x;
   int ans=0;
   for(int i=1;i<=n;i++){
    cin>>x;
    if(i%2==1 && x%2==1)ans++;
   }
   cout<<ans<<endl;
    }

}




Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(){
    long a,b,k;
    cin>>a>>b>>k;
    for(int i=0;i<k;i++){
        if(i%2==0){
            if(a%2!=0)
                a--;
            a/=2;
            b+=a;
        }
        else{
            if(b%2!=0)
                b--;
            b/=2;
            a+=b;
        }
    }
    cout<<a<<" "<<b;
}

Measured memory_bytes: 256
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto a=readln.split.to!(int[]);

  sort(a);
  double m=(a[$-1]+1)/2.0;
  int tg=a[0];
  import std.math;
  for(int i=0; i+1<n; i++){
    if((a[i]-m).abs<(tg-m).abs) tg=a[i]; 
  }

  writeln(a[$-1], " ", tg);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 4520
while True:
	a, op, b = input().split()
	a = int(a)
	b = int(b)
	if op == '+':
		print(a + b)
	elif op == '-':
		print(a - b)
	elif op == '*':
		print(a * b)
	elif op == '/':
		print(a // b)
	elif op == '?':
		break


Measured memory_bytes: 5596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int num;
		while ((num = in.nextInt()) != 0) {
			long ans = 0;
			for (int i = 27; i >=0; i -= 3) {
				int v = Integer.rotateRight(num, i) & 7;
				if (v >= 4) {
					v++;
				}
				if (v >= 6) {
					v++;
				}
				ans = ans * 10 + v;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 47424
package main

import (
	"fmt"
)

func main() {
	var b string
	fmt.Scan(&b)
	if b == "A" {
		fmt.Println("T")
		return
	}
	if b == "T" {
		fmt.Println("A")
		return
	}
	if b == "C" {
		fmt.Println("G")
		return
	}
	if b == "G" {
		fmt.Println("C")
	}
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
int inf = 1000000000; //10e9

long double round_n(long double number)
{
    int n = 9;
    number = number * pow(10,n-1); //四捨五入したい値を10の(n-1)乗倍する。
    number = round(number); //小数点以下を四捨五入する。
    number /= pow(10, n-1); //10の(n-1)乗で割る。
    return number;
}

bool is_integer(long double x, long double y){
    
    return round(round_n(x)*round_n(y)) == (x*y);
}

int main() {

    vector<char> s(3);
    rep(i,3) cin >> s[i];

    int count = 0;

    rep(i,3){
        if(s[i]=='R'){
            count ++;
        }
    }

    if(count>=2){
        if(s[1]=='S'){
            count=1;
        }
    }

    cout << count << endl;

    return 0;

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
//using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_c() {
	ll n;
	ll ans;

	cin >> n;

	ll a;
	unordered_map<ll, ll> m;
	rep(i, n) {
		cin >> a;
		++m[a];
	}

	ans = 0;
	for (auto itr:m) {
		ans += itr.second % 2;
	}

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

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

	solve_abc_c();

	return 0;
}


Measured memory_bytes: 4388
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define RREPS(i,x) for(int i=((int)(x));i>=0;i--)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

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

	sort(all(a));

	int sum = 0;
	rep(i, n - 1) {
		sum += a[i];
	}

	if (sum > a[n - 1]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	

	
}


 

Measured memory_bytes: 256
dish_arr = 5.times.map{|i| gets.chomp.to_i }

min = 11
index = 0
dish_arr.each_with_index do |d, i|
  q = d % 10
  q = 10 if q == 0
  if q < min
    index = i
    min = q
  end
end

result = 0
dish_arr.each_with_index do |d, i|
  if i != index
    q = d % 10
    q = 10 if q == 0
    result += d + 10 - q
  end
end

result += dish_arr[index]
puts result

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

using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

short dp[5010][5010] = {};

int main(){
    int n, m; cin >> n >> m;
    rep(i, m){
        int x, y, c; cin >> x >> y >> c;
        x--, y--, c++;
        dp[x][y] = c;
    }

    loop(i, 1, n)rep(j, i + 1){
        int t = -100;
        if (j - 1 >= 0) t = max(t, dp[i - 1][j - 1] - 1);
        if (j < i + 1) t = max(t, dp[i - 1][j] - 1);
        dp[i][j] = max<short>(dp[i][j], t);
    }

    int ans = 0;
    rep(i, n){
        rep(j, i + 1){
            // cout << dp[i][j] << " ";
            if (dp[i][j]) ans++;
        }
        // cout << endl;
    }

    cout << ans << endl;
}

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if((A + B + C) == 0){
    cout << "0" << endl;
  }
  else if((A + B) >= C){
    cout << B + C << endl;
  }
  else{
    cout << B + (A + B + 1) << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
s_count_dir = {}

for _ in range(n):
    s = input()
    s_count = 0
    for c in s:
        s_count += 10**(ord(c)-97)
    s_count_dir[s_count] = s_count_dir.get(s_count,0) + 1

ans = 0
for i in s_count_dir.values():
    ans += i*(i-1)//2
    
print(ans)

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

ll n;
ll a[222222];

int main(){
    cin >> n;
    for(ll i=0;i<n;i++) cin >> a[i];
    ll res=0;
    ll memo=a[0];
    for(ll i=1;i<n;i++){
        if(a[i]<=memo) res+=memo-a[i];
        else memo=a[i];
    }
    cout << res << endl;
    return 0;
}  


Measured memory_bytes: 5196
package main

import (
	"fmt"
)

func main() {
	a := SingleInt()
	slice := make([]int, 0, a)

	for i := 0; i < a; i++ {
		slice = append(slice, SingleInt())
	}

	// var accessor int
	// var lastAccessor int
	// c := 1
	// for {
	// 	idx := slice[accessor] - 1 // 2, 0, 2
	// 	lastAccessor = accessor    // 0, 2, 0
	// 	c++
	// 	accessor = idx // 2, 0, 2
	// 	if slice[accessor]-1 == lastAccessor {
	// 		if slice[lastAccessor] == 2 {
	// 			fmt.Println(c)
	// 			return
	// 		}
	// 		fmt.Println(-1)
	// 		return
	// 	}
	// 	if slice[idx] == 2 {
	// 		fmt.Println(c)
	// 		return
	// 	}
	// }

	var now, c int
	for {
		if now == 2 {
			fmt.Println(c)
			return
		}
		if c >= a {
			fmt.Println(-1)
			return
		}
		c++
		if now > 0 {
			now--
		}
		now = slice[now]
	}
}

func SingleInt() int {
	var n int
	fmt.Scan(&n)
	return n
}


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

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

    let answer = solve(&buf);

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

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

    iterator.next().unwrap().chars()
        .filter(|c| *c == '1')
        .count()
        .to_string()
}


Measured memory_bytes: 2112
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    double x1,y1,x2,y2,x3,y3,x4,y4,d;
    while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4){
        d=(x2-x1)*(x4-x3)+(y2-y1)*(y4-y3);
        if(abs(d)<1e-11)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 1216
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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


int main(){
	int n,q;
	string s;
	int l[100000],r[100000];

	cin >> n >> q;
	cin >> s;
	for(int i=0;i<q;i++){
		cin >> l[i] >> r[i];
	}

	int num[1000001];
	num[0] = 0;
	for(int i=1;i<n;i++){
		if(s[i-1]=='A'&&s[i]=='C') num[i] = 1;
	}
	for(int i=1;i<n;i++) num[i] += num[i-1];

	for(int i=0;i<q;i++){
		cout << num[r[i]-1] -num[l[i]-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 4224
#include<iostream>
using namespace std;
int c[10001];
int y[100];
int n,a,b,C,x;
main()
{
	while(cin>>n>>a>>b>>C>>x,n)
	{
		for(int i=0;i<n;i++)cin>>y[i];
		int ans=0;
		bool flag=0;
		for(int i=0;i<n;i++)
		{
			for(int i=0;i<=10000;i++)c[i]=0;
			while(x!=y[i]&&!c[x])
			{
				ans++;
				c[x]=1;
				x=(a*x+b)%C;
			}
			if(x!=y[i]||ans>10000)
			{
				flag=1;
				break;
			}
			if(i!=n-1)x=(a*x+b)%C,ans++;
		}
		cout<<(flag?-1:ans)<<endl;
	}
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
typedef long long LL;
const LL P = 998244353;
const int INF = 0x3fffffff;
const int N = 1005;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

char s[N][N];
int n,m,a,b;

int main(){
	//freopen("test.in","r",stdin);
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin>>n>>m>>a>>b;
	if(a*2>m || b*2>n){
		cout<<"-1\n";
		return 0;
	}
	rep(i,1,n)rep(j,1,m){
		if(i<=b&&j<=a || i>b&&j>a) s[i][j] = '1';
		else s[i][j] = '0';
	}
	rep(i,1,n)cout<<(s[i]+1)<<endl;
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<string> v;
  string s;
  REP(i,3){
    cin >> s;
    v.push_back(s);
  }
  int i = 0;
  while(v[i].size()!=0){
    int old = i;
    i = v[i][0] - 'a';
    v[old].erase(0,1);
  }
  cout << char ('A' + i ) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int middle;
    char s[101];
    
    scanf("%s",s);
    
    for(middle=1;s[middle+2]!='\0';middle++);
    
    printf("%c%d%c\n",s[0],middle,s[middle+1]);
    return 0;
}

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

int main(void){
    int n,x;
    cin >> n >> x;
    
    int w[n],v[n],mx = 0;
    for(int i = 0;i < n;i++){
        cin >> w[i] >> v[i];
        mx = max(v[i],mx);
    }
    mx *= n;  
  
    int dp[n+1][mx+1];
  
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= mx;j++)dp[i][j] = 1e9;
    }
    dp[0][0] = 0;
    
    for(int i = 0;i < n;i++){
        for(int j = 0;j <= mx;j++){
            if(j < v[i]){
                dp[i+1][j] = dp[i][j];
            } else {
                dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]] + w[i]);
            }
        }
    }
    
    ll alina = 0;
    for(int i = 0;i <= mx;i++){
        if(dp[n][i] <= x){
            alina = i;
        }
    }
    cout << alina << endl;
}

Measured memory_bytes: 43036
N = int(input())
L = list(map(int, input().split()))
cnt = 0
L.sort()

for a in range(N - 1, 0, -1):
    b = 0
    c = a - 1
    while (b < c):
        if L[a] < L[b] + L[c]:
            cnt += c - b
            c -= 1
        else:
            b += 1

print(cnt)


Measured memory_bytes: 3188
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int
var t float64

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	d := intScanner()
	c := intSliceScanner(26)
	s := make([][]int, d)
	for i := 0; i < d; i++ {
		s[i] = intSliceScanner(26)
	}
	best := -mod
	bestSchedule := make([]int, d)
	for x := 0; x < 3; x++ {
		schedule := make([]int, d)
		for i := 0; i < d; i++ {
			schedule[i] = rand.Intn(26)
		}
		score := calcScore(schedule, c, s, d)
		for y := 0; y < 40000; y++ {
			change := rand.Intn(d)
			val := rand.Intn(26)
			pre := schedule[change]
			schedule[change] = val
			nextScore := calcScore(schedule, c, s, d)
			t = float64(score) * 0.1
			if prob(score, nextScore) >= math.Abs(rand.Float64()) {
				score = nextScore
			} else {
				schedule[change] = pre
			}
			if nextScore >= best {
				best = nextScore
				copy(bestSchedule, schedule)
			}
			t *= 0.999
		}
	}
	for i := 0; i < d; i++ {
		fmt.Println(bestSchedule[i] + 1)
	}
}
func calcScore(schedule []int, c []int, s [][]int, d int) int {
	score := 0
	last := make([]int, 26)
	for i, v := range schedule {
		score += s[i][v]
		for j, _ := range last {
			last[j]++
		}
		last[v] = 0
		for j, v := range last {
			score -= c[j] * v
		}
	}
	return score
}
func prob(before int, after int) float64 {
	if before <= after {
		return 1.0
	}
	return math.Exp((float64(after) - float64(before)) / float64(t))
}


Measured memory_bytes: 1980
import itertools

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]
ans = 0

for i in itertools.combinations_with_replacement(range(1, M + 1), N):
    total = 0
    for j in range(Q):
        if i[abcd[j][1] - 1] - i[abcd[j][0] - 1] == abcd[j][2]:
            total += abcd[j][3]
    ans = max(ans, total)

print(ans)

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

int main(){
  int n,k;
  cin>>n>>k;
  
  int d[k];
   int num[n+1]={0};
  for(int i=0;i<k;i++){
    cin>>d[i];
    for(int j=0;j<d[i];j++){
       int a[d[i]];
      cin>>a[j]; 
       num[a[j]]++;
    }
  }
  int count=0;
  for(int i=1;i<=n;i++){
    if(num[i]==0){
      count++;
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int K;
    string S;
    cin >> K >> S;
    if(S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int N = 10005;
string s[N];

bool cmp(string a, string b){
    return a < b;
}

int main(){
    int n, l;
    scanf("%d %d", &n, &l);
    for(int i = 1; i <= n; i++) cin>>s[i];
    sort(s+1, s+1+n, cmp);
    for(int i = 1; i <= n; i++) cout << s[i];
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

#define ll long long
const ll N = 1000000000000000;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int k = c / b + (c % b != 0);
    int l = a / d + (a % d != 0);

    if (k <= l) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

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

using namespace std; 

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define SZ(x) (int)x.size()

typedef  vector<string> vs;
typedef  vector<int> vi;	

int main(){
	
	string s;
	
	cin >> s; 
	
	int xOdd = 0;
	int xEven = 0;
	int yOdd = 0;
	int yEven = 0;
	
	int ans = 0;
	
	f(i,0,SZ(s)){
		
		if(s[i]=='1' && i%2==0) xEven++;
		if(s[i]=='1' && i%2==1) xOdd++;
		if(s[i]=='0' && i%2==0) yEven++;
		if(s[i]=='0' && i%2==1) yOdd++;
		
	}
	
	int maxY = 0;
	int maxX = 0;
	bool yv; 
	bool xv;
	
	if(yOdd > yEven){
		 maxY = yOdd;
		 yv = true;
	}else{
		maxY = yEven; 
		yv = false;
	}
	
	if(xOdd > xEven){
		 maxX = xOdd;
		 xv = true;
	}else{
		maxX = xEven;
		xv = false;
	}
	
	if(maxY > maxX){
		f(i,0,SZ(s)){
			if(yv){
				if(s[i]=='1' && i%2==1){
					ans++;
				}
				if(s[i]=='0' && i%2==0){
					ans++;
				}
			}else{
				if(s[i]=='0' && i%2==1){
					ans++;
				}
				if(s[i]=='1' && i%2==0){
					ans++;
				}
			}
		}
	}else{
		f(i,0,SZ(s)){
			if(xv){
				if(s[i]=='0' && i%2==1){
					ans++;
				}
				if(s[i]=='1' && i%2==0){
					ans++;
				}
			}else{
				if(s[i]=='1' && i%2==1){
					ans++;
				}
				if(s[i]=='0' && i%2==0){
					ans++;
				}
			}
		}
	}
	
	
	cout << ans << endl;	
	
	
    return 0;
}


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

long long k, x, cnt=0, p, ans;

long long bfs(long long count) {
    queue<long long> q;

        for(int i=1; i<10; i++) {
            ans=i;
            q.push(ans);
            cnt++;
            if(cnt==count) return ans;
        }   
        while(q.size()) {
            p=q.front();
            q.pop();
            x=p%10;
            if(x==0) {
                for(int i=x; i<=1; i++) {
                    ans=p*10+i;
                    q.push(ans);
                    cnt++;
                    if(cnt==count) return ans;

                }
            }
            else if(x==9) {
                x--;
                for(int i=x; i<=x+1; i++) {
                    ans=p*10+i;
                    q.push(ans);
                    cnt++;
                    if(cnt==count) return ans;
                }
            }
            else {
                x--;
                for(int i=x; i<=x+2; i++) {
                    ans=p*10+i;
                    q.push(ans);
                    cnt++;
                    if(cnt==count) return ans;
                }
            }
        }
        
    return ans;
}


int main() {
    cin >> k;
    cout << bfs(k);
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int main (){
    int c[3][3];
    int tate[2][3];
    int yoko[3][2];
    rep(i,3) rep(j,3) cin >> c[i][j];
    rep(i,2){
        rep(j,3){
            tate[i][j]=c[i+1][j]-c[i][j];
        }
    }
    rep(i,3){
        rep(j,2){
            yoko[i][j]=c[i][j+1]-c[i][j];
        }
    }
    if(tate[0][0]==tate[0][1]&&tate[0][1]==tate[0][2]){
        if(tate[1][0]==tate[1][1]&&tate[1][1]==tate[1][2]){
            if(yoko[0][0]==yoko[1][0]&&yoko[1][0]==yoko[2][0]){
                if(yoko[0][1]==yoko[1][1]&&yoko[1][1]==yoko[2][1]){
                    cout << "Yes" <<endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" <<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define tmp(x) std::cout<<"& "<<(x)<<" &\n"
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define mp make_pair
#define pii pair<int,int>
typedef long long ll;
ll qpow(ll a,ll n,ll p){
	ll ans=1;
	while(n){
		if(n&1)
			ans*=a,ans%=p;
		a*=a,a%=p;
		n>>=1;
	}
	return ans;
}

using namespace std;
const int maxn=2e5+100;
const int p=1e9+7;
int n,t;
int a[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
 	cin>>n;
 	ll tot=0;
 	rep(i,1,n){
 		cin>>a[i];
 		tot+=a[i];
	 }
	 tot%=p;
	 tot=(tot*tot)%p;
	 ll k=0;
	 rep(i,1,n){
		k=(k+1ll*a[i]*a[i]%p)%p;
	 }
	 tot=(tot-k+p)%p;
	 if(tot%2==0)tot=tot/2;
	 else tot=1ll*tot*qpow(2,p-2,p)%p;
	 cout<<tot;
 
 
 
    return 0;
}


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

using namespace std;

int main(){
    int a,b,c,k;
    int sum=0;
    
    cin>>a>>b>>c>>k;
    
    if(k>=a){
        k=k-a;
        sum=a;
    }else{
        sum=k;
        k=0;
    }
    
    if(k>=b){
        k=k-b;
    }
    sum=sum-k;
    cout<<sum<<"\n";
    
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
long long mint[maxn<<2], maxt[maxn<<2], sum[maxn<<2], lazy[maxn<<2];
void push(int id, int l, int r){
	if(lazy[id]){
		mint[id] += lazy[id];
		maxt[id] += lazy[id];
		sum[id] += (r - l + 1) * lazy[id];
		if(l != r){
			lazy[id<<1] += lazy[id];
			lazy[id<<1|1] += lazy[id];
		}
		lazy[id] = 0;
	}
}
void add(int id, int l, int r, int x, int y, long long t){
	push(id, l, r);
	if(l > y || r < x) return;
	if(x <= l && r <= y){
		lazy[id] += t;
		push(id, l, r);
		return;
	}
	int mid = (l + r)>>1;
	add(id<<1, l, mid, x, y, t);
	add(id<<1|1, mid + 1, r, x, y, t);
	mint[id] = min(mint[id<<1], mint[id<<1|1]);
	maxt[id] = max(maxt[id<<1], maxt[id<<1|1]);
	sum[id] = sum[id<<1] + sum[id<<1|1];
}
long long get(int id, int l, int r, int x, int y, int q, int R){
	push(id, l, r);
	if(l > y || r < x) return 0ll;
	if(x <= l && r <= y){
		if(R - mint[id] <= q){
			return 1ll * (r - l + 1) * R - sum[id];
		}
		if(R - maxt[id] >= q){
			return 1ll * (r - l + 1) * q;
		}
	}
	int mid = (l + r) >> 1;
	return get(id<<1, l, mid, x, y, q, R) + get(id<<1|1, mid + 1, r, x, y, q, R);
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, v, P; cin >> n >> m >> v >> P;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a.rbegin(), a.rend());
	int p = -1;
	int ans = 0;
	vector<long long> acc(n + 1, 0ll);
	for(int i = 0; i < n; i++) acc[i + 1] = acc[i] + a[i];
	for(int i = 0; i < n; i++){
		while(p + 1 < i && a[p + 1] - a[i] > m) p++;
		if(i) add(1, 0, n, 0, i - 1, a[i - 1] - a[i]);
		int np = max(p, P - 2);
		int cast = np + 1 + n - i;
		if(cast >= v){
			if(np + 2 <= P){
				ans++;
			}
		} else {
			long long to_do = 1ll * (v - cast) * m;
			int l = np + 1, r = i - 1;
			long long h = acc[r + 1] - acc[l];
			if(l <= r && 1ll * (r - l + 1) * (a[i] + m) - h >= to_do) {
				if(np + 2 <= P){
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 13696
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8

int n;
string s;
void check(int fst){
	string res(n, '_');
	res[0] = fst & 1 ? 'S' : 'W';
	res[1] = fst & 2 ? 'S' : 'W';
	for(int i = 2; i < n; ++i){
		if((res[i - 1] == 'S') == (s[i - 1] == 'o')){
			res[i] = res[i - 2];
		}
		else{
			res[i] = 'S' ^ 'W' ^ res[i - 2];
		}
	}

	for(int i = 0; i < n; ++i){
		if(res[i] == 'S'){
			if((res[(i + n - 1) % n] == res[(i + 1) % n]) != (s[i] == 'o')){ return; }
		}
		else{
			if((res[(i + n - 1) % n] == res[(i + 1) % n]) == (s[i] == 'o')){ return; }
		}
	}

	cout << res << endl;
	exit(0);
}

void mainmain(){
	cin >> n >> s;
	
	for(int i = 0; i < 4; ++i){
		check(i);
	}
	
	puts("-1");
}



}
int main() try{
//	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 512
def isort(seq, n):
    for i in range(1, n):
        x = seq[i]
        j = i - 1
        while j >= 0 and seq[j] > x:
            seq[j + 1] = seq[j]
            j -= 1
        seq[j + 1] = x
        print(*seq)


n = int(input())

x = list(map(int, input().split()))
print(*x)
isort(x, n)

Measured memory_bytes: 8024
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define pque(type) priority_queue<type,vector<type>,greater<type> >

int main(void){
  int n;
  cin >> n;
  vector<mp> x(n);
  rep(i, n){
    int t;
    cin >> t;
    x[i] = mp(t, i);
  }
  sort(x.begin(), x.end());

  vector<int> ans(n);
  rep(i, n){
    if(i < n/2) ans[x[i].sec] = x[n/2].fir;
    else ans[x[i].sec] = x[(n/2)-1].fir;
  }

  rep(i, n) cout << ans[i] << endl;

	return 0;
}


Measured memory_bytes: 4480
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

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

	n := nextInt()
	m := nextInt()
	h := make([]int, n)
	bad := make([]bool, n)

	for i := 0; i < n; i++ {
		h[i] = nextInt()
	}

	for i := 0; i < m; i++ {
		a := nextInt() - 1
		b := nextInt() - 1

		if h[a] > h[b] {
			bad[b] = true
		} else if h[a] < h[b] {
			bad[a] = true
		} else {
			bad[a] = true
			bad[b] = true
		}
	}

	count := 0
	for i := 0; i < n; i++ {
		if !bad[i] {
			count++
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 5524
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc060/tasks/abc060_b

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    for (int i = 1; i <= A*B; i++) if (i*A%B==C){
            cout << "YES" << "\n";
            return 0;
    }

    cout << "NO" << "\n";
    return 0;
}


Measured memory_bytes: 256
# m-solutions2019C - Best-of-(2n-1) (292 ms)
def get_inv(lim: int) -> list:
    # compute a table of inverse factorials (1-idx)
    inv = [0] * (lim + 1)
    inv[:2] = 1, 1
    for i in range(2, lim + 1):
        inv[i] = (-(MOD // i) * inv[MOD % i]) % MOD
    return inv


def main():
    global MOD
    N, A, B, C = tuple(map(int, input().split()))
    MOD = 10 ** 9 + 7
    inv = get_inv(max(100, 2 * N))
    pa, pb = [1] * (N + 1), [1] * (N + 1)  # power of a, b
    a, b = A * inv[A + B], B * inv[A + B]
    for i in range(1, N + 1):
        pa[i] = pa[i - 1] * a % MOD
        pb[i] = pb[i - 1] * b % MOD
    ans, comb = (pa[N] + pb[N]) * N, 1
    for m in range(N + 1, 2 * N):
        comb = (comb * (m - 1) * inv[m - N]) % MOD
        x = comb * (pa[N] * pb[m - N] + pa[m - N] * pb[N]) * m
        ans = (ans + x) % MOD
    ans = ans * 100 * inv[100 - C] % MOD
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 18804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979
#define EPS 1e-8
#define mod 1000000007
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define endl "\n"
	 
const ll INF=(ll)2e18;
		
		
const int N=2e5+5;
		
		
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
				
	ll n;
	cin>>n;
	
	vector<ll> v(n);
	for(ll i=0;i<n;i++)
	{
		cin>>v[i];
	}			
	
	ll ans=0;
	
	ll pres=1;
	
	for(ll i=0;i<n;i++)
	{
		
		ans+=(v[i]-1)/pres;
		
		if(pres==1 || v[i]==pres)
		{
			pres++;
		}
	}
	cout<<ans;
				
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int t,n;
	rep(i,0,4){
		cin>>t>>n;
		n*=1000;
		if(t==1) n*=6;
		else n*=6-t;
		o(n);
	}
}

Measured memory_bytes: 1160
package main

import (
	"fmt"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {

	var n, m int
	fmt.Scan(&n, &m)

	var count int

	m1 := m / 2
	var f = min(n, m1)
	count += f

	remain := m - (count * 2)

	if remain >= 4 {
		count += remain / 4
	}

	fmt.Println(count)

}


Measured memory_bytes: 512
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

/** 約数計算
 */
std::set<int64_t> divisors(int64_t n)
{
    std::set<int64_t> ret;
    for (int64_t i = 1; i*i <= n; ++i) {
        if (n % i == 0) {
            ret.insert(i);
            if (i != 1 && i * i != n) {
                ret.insert(n/i);
            }
        }
    }
    return ret;
}


int main()
{
    int64_t N;
    std::cin >> N;

    int64_t ans = 0;
    for (int64_t i = 1; i <= N; i+=2) {
        if (7 == divisors(i).size()) {
            ans++;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


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

using namespace std;
typedef pair<int,int> P;
const int MAX = 25;
P data[MAX+1];
int in;

bool solve(){
  sort(data,data+in);
  int sum = 0;
  for(int i = 0; i < in; i++){
    sum += data[i].second;
    if(sum > data[i].first) return false;
  }
  return true;
}
int main(){

  while(cin >> in && in){
    for(int i = 0; i < in; i++) cin >> data[i].second >> data[i].first;
    if(solve()) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
using namespace std;
const int inf=1e9+10;
const ll llinf=1e16+10;
const int maxn=1e5+10;
const int maxm=1e5+10;
const int mod=1e9+7;
const double pi=acos(-1.0);
int n;
int vis[maxn];
int num[maxn];
ll a,b;
ll ca[maxn];
ll cb[maxn];

ll exgcd(ll a,ll b,ll &x,ll &y)
{
    if(b==0)
    {
        x=1;
        y=0;
        return a;
    }
    ll r=exgcd(b,a%b,x,y);
    ll t=x;
    x=y;
    y=t-a/b*y;
    return r;
}

void cfunc(ll C[],ll x)
{
    ll xx,yy;
    C[0]=C[x]=1;
    for(ll i=1;i<x;i++)
    {
        ll t=(C[i-1]*(x-i+1))%mod;
        exgcd(i,(ll)mod,xx,yy);
        C[i]=((t*xx)%mod+mod)%mod;
    }
}
int main()
{
    //freopen("in.txt","r",stdin);
    while(~scanf("%d",&n))
    {
        cls(ca,0);
        cls(cb,0);
        cls(vis,0);
        int st,ed;
        for(int i=1;i<=n+1;i++)
        {
            scanf("%d",&num[i]);
            if(vis[num[i]]) ed=i;
            else vis[num[i]]=1;
        }
        for(int i=1;i<=n+1;i++)
        {
            if(num[i]==num[ed])
            {st=i;break;}
        }
        a=n+1;
        b=n+1-(ed-st+1);
        cfunc(ca,a);
        cfunc(cb,b);
        for(int i=1;i<=n+1;i++)
            printf("%lld\n",((ca[i]-cb[i-1])%mod+mod)%mod);
    }
    return 0;
}


Measured memory_bytes: 3584
// C - Digits in Multiplication

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int count_digit(ll k) {
	int result = 0;
	while (k > 0) {
		result++;
		k /= 10;
	}

	return result;
}

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

	ll A;
	for (ll i=1; i*i <= N; i++) {
		if (N % i == 0) {
			A = i;
		}
	}

	ll B = N / A;

	int ans = max(count_digit(A), count_digit(B));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n, m, L = map(int, input().split())
 
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
c = [[sum(ak * bk for ak, bk in zip(ai,bj)) for bj in zip(*b)] for ai in a]
 
for ci in c:
    print(*ci)

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 300003;

ll n,q,k;
vector<vector<P> > v;
vector<ll> dis,done;
ll dfs(ll s,ll d){
	done[s]=1;
	dis[s]=d;
	FOR(i,0,v[s].size()){
		ll nex=v[s][i].fi;
		ll pd=v[s][i].se;
		if(!done[nex])dfs(nex,d+pd);
	}
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	v.resize(n+1);
	dis.resize(n+1);
	done.resize(n+1);
	FOR(i,0,n-1){
		ll a,b,c;
		cin>>a>>b>>c;
		v[a].pb(mp(b,c));
		v[b].pb(mp(a,c));
	}
	cin>>q>>k;
	dfs(k,0);
	FOR(i,0,q){
		ll x,y;
		cin>>x>>y;
		cout<<dis[x]+dis[y]<<endl;
	}

	return 0;
}


Measured memory_bytes: 13568