akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}

i64 gcd(i64 a, i64 b) {
    for (i64 c; a;) c = a, a = b % a, b = c; return b;
}

struct int_m;
int_m invmod(int_m);
int_m powmod(int_m, i64);
struct int_m {
    static i64 m;
    i64 v;
    int_m() {}
    int_m(i64 x) { v = (x % m + m) % m; }
    int_m operator+(const int_m &y) const { return (v + y.v) % m; }
    int_m operator-(const int_m &y) const { return (v - y.v + m) % m; }
    int_m operator*(const int_m &y) const { return (v * y.v) % m; }
    int_m operator/(const int_m &y) const { return *this * invmod(y); }
    int_m operator^(const i64   &y) const { return powmod(*this, y); }
    void operator+=(const int_m &y) { *this = *this + y; }
    void operator-=(const int_m &y) { *this = *this - y; }
    void operator*=(const int_m &y) { *this = *this * y; }
    void operator/=(const int_m &y) { *this = *this / y; }
    void operator^=(const i64   &y) { *this = *this ^ y; }
    bool operator==(const int_m &y) const { return v == y.v; }
    bool operator!=(const int_m &y) const { return v != y.v; }
    friend istream &operator>>(istream &ist, int_m m) { ist >> m.v; return ist; }
    friend ostream &operator<<(ostream &ost, int_m m) { ost << m.v; return ost; }
};
i64 int_m::m;
// O(log a)
int_m powmod(int_m a, i64 p) {
    int_m v = 1;
    for(int_m b = a; p > 0; p >>= 1, b *= b) if(p & 1) v *= b;
    return v;
}
int_m invmod(int_m x) {
    return powmod(x, x.m - 2);
}

using P = pair<i64, i64>;

int main() {
    int_m::m = 1e9 + 7;
    int N;
    cin >> N;
    map<P, i64> m;
    for(int i = 0; i < N; i++) {
        i64 a, b, g;
        cin >> a >> b;
        if(a == 0 && b == 0) g = 1;
        else if(a == 0) g = b;
        else if(b == 0) g = a;
        else g = gcd(abs(a), abs(b));
        a /= g, b /= g;
        if(a < 0) a *= -1, b *= -1;
        if(a == 0) b = abs(b);
        m[make_pair(a, b)]++;
    }
    // for(auto x : m) {
    //     cout << x.first.first << " " << x.first.second << " " << x.second << endl;
    // }
    int_m ans = 1;
    for(auto x : m) {
        P p, p_;
        i64 s, t, a, b;
        tie(p, s) = x;
        tie(a, b) = p;
        i64 a_ = b, b_ = -a;
        if(a_ < 0) a_ *= -1, b_ *= -1;
        if(a_ == 0) b_ = abs(b_);
        p_ = make_pair(a_, b_);
        if(!m.count(p_)) {
            ans *= int_m(2) ^ s;
        } else if(p > p_) { // ダブルカウント防止
            t = m[p_];
            ans *= (int_m(2) ^ s) + (int_m(2) ^ t) - 1; // 何も取らない場合のダブルカウント排除
        }
    }
    // 何も取らないのはダメ
    ans -= 1;
    ans += m[{0, 0}]; // (0,0)１つだけを取るのはok
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15972
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>

using std::cout;
using std::endl;
using std::cin;

double CalcH(double b, double C) {
	double H = b*sin(C);
	return H;
}

double CalcS(double a, double h) {
	double S = a * h / 2;
	return S;
}
double CalcL(double a, double b, double C, double h) {
	double x, c, L;

	x = b * cos(C);
	c = sqrt(pow(h, 2.0) + pow((a-x), 2.0));
	L = a + b + c;

	return L;
}
int main() {
	double a, b, C;			// ??\???
	double S, L, h, x, c;	// ??????

	// ??\???
	cin >> a >> b >> C;

	C = (C*M_PI) /180;
	//h = b*sin(C);
	h = CalcH(b, C);

	//S = a * h / 2;
	S = CalcS(a, h);

	//x = b * cos(C);
	//c = sqrt(pow(h, 2.0) + pow((a-x), 2.0));
	//L = a + b + c;
	L = CalcL(a, b, C, h);

	// ??????
	cout << std::fixed << std::setprecision(10) << S << endl;
	cout << std::fixed << std::setprecision(10) << L << endl;
	cout << std::fixed << std::setprecision(10) << h << endl;

	return 0;
}

Measured memory_bytes: 3516
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#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 pb(a) push_back(a)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

vector<string> split(const string &s,char c){
	vector<string> ret;
	stringstream ss(s);
	string t;
	while(getline(ss,t,c)){
		ret.pb(t);
	}
	return ret;
}

int main(){
	map<int,int> m;
	set<int> s1,s2;
	bool f=0;
	string s;
	while(getline(cin,s)){
		if(/*s.end() - s.begin() == 1*/s==""){
			//o("ok");
			f=1; continue;
		}
		vector<string> v=split(s,',');
		int a=atoi(v[0].c_str());
		//o(a);
		m[a]++;
		if(!f) s1.insert(a);
		else s2.insert(a);
	}
	for(map<int,int>::iterator it=m.begin();it!=m.end();it++){
		//cout<<1<<endl;
		if(s1.count(it->fi) && s2.count(it->fi)) cout<<it->fi<<" "<<it->se<<endl;
	}

}

Measured memory_bytes: 1216
# [[i],..]でi番目の展望台につながっている展望台をリストアップしていく
N,M=map(int,input().split())
H=list(map(int,input().split()))
L=[[] for i in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    L[a-1].append(b-1)
    L[b-1].append(a-1)
score=0
for i,l in enumerate(L):
    if not l:
        score+=1
        continue
    my_max=H[i]
    is_max=True
    for li in l:
        if H[li]>=my_max:
            is_max=False
            break
    if is_max:
        score+=1
print(score)





Measured memory_bytes: 29452
#include<iostream>
using namespace std;
#define ll long long
int main(){
    ll a;
    cin>>a;
    ll n = 100;
    int i = 0;
    ll prod = 1;
    while(n<a){
        prod = n/100 ;
        n += prod;
//        cout<<prod<<" "<<n<<" "<<prod+n<<endl;
        i++;
    }
    cout<<i;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        long attacks = 0;
        if (n > k) {
            Arrays.sort(arr);
            for (int i = n-k-1; i >= 0; i--) {
                attacks += arr[i];
            }
        }

        System.out.println(attacks);
    }
}

Measured memory_bytes: 84452
package main

import "fmt"

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

	res := 0.0
	for i := 1; i <= n; i++ {
		p := 1.0 / float64(n)
		for j := i; j < k; j *= 2 {
			p /= 2.0
		}
		res += p
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;
int main(){
string S,T;
int x,y=0;
cin >> S >> T;
x=S.size();
for(int i=0;i<x;i++){
if(S[i]!=T[i])y++;
}



if(y==0){cout << "Yes" << endl;}else{cout << "No" << endl;}

return 0;
}

Measured memory_bytes: 3624
import itertools

res = [0]*10**5

n,k = map(int,input().split())
for i in range(n):
    a,b = map(int,input().split())
    res[a-1] += b

sum = list(itertools.accumulate(res))
for i,j in enumerate(sum):
    if j>=k:
        print(i+1)
        break
#print(sum)


Measured memory_bytes: 10640
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int D = sc.nextInt();
		int x0 = sc.nextInt();
		int x[] = new int[11];
		x[0] = x0;

		for (int i = 0; i < 10; i++) {
			x[i+1] = r*x[i] - D;
		}
		for (int i = 1; i < 11; i++) {
			System.out.println(x[i]);
		}
	}
}


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

int main(void)
{
    int n; cin>>n;
    vector<int> s(10050,0);
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                int x = i*i + j*j + k*k + i*j + j*k + k*i;
                if(x <= n) s[x]++;
            }
        }
    }
    rep(i,n) cout<<s[i+1]<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N;

int main() {
    cin >> N;
    ll S = 0;
    int a, nM = 0, minAbs = INF;

    for (int i = 0; i < N; i++) {
        cin >> a;
        S += abs(a);
        if (a < 0) nM++;
        minAbs = min(minAbs, abs(a));
    }

    if (nM % 2 == 0) {
        cout << S << endl;
    } else {
        cout << S - 2 * minAbs << endl;
    }
    return 0;
}


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

int main(){
  int flag = 0;
  string s, p, ring;

  getline(cin, s);
  getline(cin, p);

  ring = s + s;

  for(int i = 0; i < 100; i++ ){
    if(ring[i] == '\0' || flag == 1)  break;
    if(ring[i] == p[0]){
      flag = 1;
      for(int j = 1; j < 100; j++){
        if(p[j] == '\0') break;
        if(p[j] != ring[i + j]){
          flag = 0;
          break;
        }
      }
    }
  }

  if(flag == 1){ cout << "Yes" <<endl;}
  else{ cout << "No" << endl;}

  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 22;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  string s; cin >> s;
  int n = s.size();
  int mi= INF;
  REP(i, n-2) {
    mi = min(mi, abs((s[i] - '0')*100 + (s[i+1] - '0') * 10 + (s[i+2] - '0') - 753));
  }

  cout << mi << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define SWAP(a,b) {int temp; temp = a; a = b; b = temp;}

int main(void){
	int a,b,c;

	scanf("%d %d %d", &a, &b ,&c);

	while(!(a <= b && b <= c)){
		if(a > b) SWAP(a,b);
		if(b > c) SWAP(b,c);
	}

	printf("%d %d %d\n", a, b, c);

	return 0;
}

Measured memory_bytes: 596
object Main {
  def main(args: Array[String]) {
    val input = io.Source.stdin.getLines().mkString("\n");
    println(solve(input))

    def solve(input: String): String = {
      val _ :: s :: _ = input.split("\n").toList
      val ls = s.split(" ").map(_.toDouble).sorted
      val first :: second :: left = ls.toList
      left
        .foldLeft((first + second) / 2) { (acc, i) =>
          (acc + i) / 2
        }
        .toString
    }
  }
}

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

int n, h;
int an[100010];

int cmp(int a, int b)
{
	return a > b;
}

int main(void)
{
	cin >> h >> n;
	for (int i = 0; i < n; i++) {
		cin >> an[i];
	}
	sort(an, an + n, cmp);
	for (int i = 0; i < n; i++) {
		h -= an[i];
		if (h <= 0) {
			cout << "Yes";
			return 0;
		}
	}
		cout << "No";
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <deque>
#include <math.h>
#include <map>
#include <bitset>
#include <queue>
#include <list>
#include <utility>

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

using namespace std;
using ll = long long;
using ld = long double;
using p = pair<int, int>;
using Graph = vector<vector<char>>;
#define rep(i,n)  for(int i = 0; i < n ; i++)
int dx[4]{ -1,0,1,0 };
int dy[4]{ 0,1,0,-1 };

int main()
{
	int K ,n;
	cin >> K >> n;
	vector<int> homes(n);
	rep(i, n) {
		cin >> homes[i];
	}

		long minimum = K;
	rep(i, n) {
		bool limitl = i - 1 < 0;
		bool limitu = i + 1 >= n;
		int back = limitl? n - 1 : i - 1;
		int next = limitu? 0 : i + 1;
		long g = limitl ? homes.at(0) + (K - homes.at(n - 1)) : homes.at(i) - homes.at(back);
		long t = limitu ? homes.at(0) + (K - homes.at(n - 1)) : homes.at(next) - homes.at(i);
		long temp = max(g,t);
		minimum = min(minimum, K-temp);
	}
	cout << minimum << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int n,a[SZ];
int gcd(int a,int b)
{return b?gcd(b,a%b):a;}
bool win()
{
	int ev=0,od=0;
	for(int i=1;i<=n;++i)
	{
		if(a[i]&1) ++od; else ++ev;
	}
	if(ev&1) return 1;
	if(od>1) return 0;
	int g=0;
	for(int i=1;i<=n;++i)
	{
		if(a[i]&1)
		{
			if(a[i]==1) return 0;
			--a[i];
		}
		g=gcd(g,a[i]);
	}
	for(int i=1;i<=n;++i) a[i]/=g;
	return !win();
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",a+i);
	if(win()) puts("First");
	else puts("Second");
}


Measured memory_bytes: 640
import java.util.*;
class Main
{
 public static void main(String[] args)
  {
   Scanner s = new Scanner(System.in);
   int a = s.nextInt();
   int b = s.nextInt();
   int count = 0;
   boolean value ;
       for(int i=a;i<=b;i++)
       {
           if(checkpalin(i))
           count++;
       }
       
       System.out.println(count);
   
   }
   
   public static boolean checkpalin(int val)
   {
       String line = val+"";
       int flag = 0;
       for(int j=0;j<line.length()/2;j++)
       {
           if(line.charAt(j)!= line.charAt(line.length()-1-j))
           {
               flag =1;
               break;
           }
       }
       if(flag == 0)
       return true;
       else
       return false;
   }
}


Measured memory_bytes: 29780
Scanf.scanf "%d" (fun n ->
    let a = Array.make (n + 1) false in
    let rec loop i =
        let rec loop2 j =
            if j <= n then (a.(j) <- true; loop2 (j + 7))
        in
        if i <= n then (loop2 i; loop (i + 4))
    in
    loop 0;
    print_endline @@ if a.(n) then "Yes" else "No"
)

Measured memory_bytes: 384
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // qsort()
#include <stdbool.h>

#define MAX_N 1000
#define MAX_V 10000
#define min(a, b) ((a) < (b) ? a : b)

int a[MAX_N];
int n;

int
cmp_func(const void *l_, const void *r_)
{
	const int* l = (const int*) l_;
	const int* r = (const int*) r_;

	if (*l < *r)
		return -1;

	if (*l > *r)
		return 1;

	return 0;
}

int
solve()
{
	int b[MAX_N];
	int t[MAX_V + 1];
	bool v[MAX_N];
	int i;

	int ans = 0;
	for (i = 0; i < n; ++i)
	{
		b[i] = a[i];
		v[i] = false;
	}

	qsort(b, n, sizeof(int), cmp_func);
	for (i = 0; i < n; ++i)
		t[b[i]] = i;

	for (i = 0; i < n; ++i)
	{
		if (v[i])
			continue;

		int cur = i;
		int s = 0;
		int m = MAX_V;
		int an = 0;
		while (true)
		{
			v[cur] = true;
			an++;
			int u = a[cur];
			if (u < m)
				m = u;

			s += u;
			cur = t[u];
			if (v[cur])
				break;
		}

		ans += min(s + (an - 2) * m, s + m + (an + 1) * b[0]);
	}

	return ans;
}

int
main(int argc, char** argv)
{
	int i;

	scanf("%d", &n);
	for (i = 0; i < n; ++i)
		scanf("%d", &a[i]);

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


Measured memory_bytes: 2096
import java.util.Scanner;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int C = sc.nextInt();

        int[] B = new int[20];

        for(int i =0; i<M; i++) {
            B[i] = sc.nextInt();
        }

        int count = 0;
        for (int i=0; i<N; i++) {

            int sum = 0;
            for (int j=0; j<M; j++) {
                sum += sc.nextInt() * B[j];
            }
            if((sum + C) >0) {
                count++;
            }
        }


        int result = count;

        System.out.println(result);
    }
}

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

int main() {
  int n, k;
  int total = 0;
  cin >> n >> k;
  vector<int> fruit(n);
  for (int i = 0; i < n; i++) {
    cin >> fruit.at(i);
  }
  sort(fruit.begin(), fruit.end());
  for (int i = 0; i < k; i++) {
    total += fruit.at(i);
  }
  cout << total << endl;
}


Measured memory_bytes: 3596
#include <atcoder/dsu>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    dsu d(n);
    for (int i = 0; i < q; i++) {
        int t, u, v;
        scanf("%d %d %d", &t, &u, &v);
        if (t == 0) {
            d.merge(u, v);
        } else {
            if (d.same(u, v)) {
                printf("1\n");
            } else {
                printf("0\n");
            }
        }
    }
    return 0;
}

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

int main() {
  //input AB
  int A, B, a, b, c;
  cin >> A >> B;  
  //calculate three sentence
  a = A + B;
  b = A - B;
  c = A*B;
  //sort, and output the highest  
  vector<int> vec = {a, b, c};
  sort (vec.begin(), vec.end());
  cout << vec.at(2) << endl;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int N, M;
bool AC[105000];
int WA[105000];

int main(){
    cin >> N >> M;
    int ACnum = 0, WAnum = 0;
    rep1(i, N) {
        AC[i] = false;
        WA[i] = 0;
    }
    while(M--) {
        int p;
        string s;
        cin >> p >> s;
        if (AC[p]) continue;
        if (s == "AC") {
            AC[p] = true;
            ACnum++;
            WAnum += WA[p];
        }
        else if (s == "WA") {
            WA[p]++;
        }
    }
    cout << ACnum << ' ' << WAnum << endl;
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    int p[n];
    for (int i = 0; i < n ; ++i) scanf("%d", &p[i]);
        int ans=0;
        for (int i = 1; i < n-1 ; ++i) {
            if((p[i-1] < p[i]) && (p[i] < p[i+1])) ans++;
            else if((p[i - 1] > p[i]) && (p[i] > p[i + 1])) ans++;
        }
        printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
import os
import sys

import numpy as np


def solve(inp):
    def mod_pow(x, a, MOD):
        ret = 1
        cur = x
        while a:
            if a & 1:
                ret = ret * cur % MOD
            cur = cur * cur % MOD
            a >>= 1
        return ret

    h = inp[0]
    ppp = inp[1:]
    n = 1 << (h - 1)
    ppp += n - 1
    MOD = 10 ** 9 + 7

    cumprods = np.ones(2 * n, dtype=np.int64)
    cumprods_rev = np.ones(n, dtype=np.int64)
    cumprods_through = np.zeros(n, dtype=np.int64)
    for i in range(2, 2 * n):
        cumprods[i] = cumprods[i >> 1] * i % MOD
    for i in range(n):
        cumprods_rev[i] = mod_pow(cumprods[i], MOD - 2, MOD)
        cumprods_through[i] = cumprods[i + n] * cumprods[ppp[i]] % MOD

    cumprods_from_tree1 = np.zeros(2 * n, dtype=np.int64)
    ans = 0

    for lca in range(1, n):
        d = lca
        digit = h
        while d:
            d >>= 1
            digit -= 1

        leftmost_leaf_in_left_subtree = lca << digit
        leftmost_leaf_in_right_subtree = ((lca << 1) + 1) << (digit - 1)
        rightmost_leaf_in_right_subtree = (lca + 1) << digit

        rev = cumprods_rev[lca >> 1]
        for leaf in range(leftmost_leaf_in_left_subtree, leftmost_leaf_in_right_subtree):
            v = ppp[leaf - n]
            cp = cumprods_through[leaf - n] * rev % MOD
            while v > 1:
                cumprods_from_tree1[v] += cp * cumprods_rev[v >> 1] % MOD
                v >>= 1

        rev = cumprods_rev[lca]
        for leaf in range(leftmost_leaf_in_right_subtree, rightmost_leaf_in_right_subtree):
            v = ppp[leaf - n]
            cp = cumprods_through[leaf - n] * rev % MOD
            while v > 1:
                ans += cumprods_from_tree1[v ^ 1] % MOD * cp % MOD * cumprods_rev[v >> 2] % MOD
                v >>= 1
            ans %= MOD

        for leaf in range(leftmost_leaf_in_left_subtree, leftmost_leaf_in_right_subtree):
            v = ppp[leaf - n]
            while cumprods_from_tree1[v] != 0:
                cumprods_from_tree1[v] = 0
                v >>= 1

    return ans


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8[:],)', cache=True)(solve)
    print('compiled', file=sys.stderr)

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(inp)
print(ans)


Measured memory_bytes: 32604
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k,l[1000],count=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>l[i];
	sort(l,l+n);
	for(int i=n-1;i+k>=n;i--)count+=l[i];
    cout<<count<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i < n; i++)
#define INF 1001001001
#define LINF (1LL << 62)
using namespace std;
using ll = long long;
using P = pair<int,int>;

void solv() {
    int N;
    cin >> N;
    vector<int> deli(N);
    rep(i,N){
        cin >> deli.at(i);
    }
    ll sum = 0;
    rep(i,N){
        for (int j = i + 1; j < N;j++){
            sum += deli.at(i) * deli.at(j);
        }
    }
    cout << sum << endl;
}

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

Measured memory_bytes: 256
while True :
    m,f,r = map(int,input().split())
    if m == -1 and f == -1 and r == -1 :
        break
    else :
        if m == -1 or f == -1 :
            print("F")
        elif 80 <= m+f :
            print("A")
        elif 65 <= m+f < 80 :
            print("B")
        elif 50 <= m+f < 65 :
            print("C")
        elif 30 <= m+f < 50 and 50 <= r :
            print("C")
        elif 30 <= m+f < 50 and r < 50 :
            print("D")
        elif m+f < 30 :
            print("F")



Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster

    string s;
    cin>>s;

    if(s[0]=='R' && s[1]=='R' && s[2]=='R')
        cout<<3<<endl;
    else if( (s[0]=='R' && s[1]=='R') || (s[1]=='R' && s[2]=='R') )
        cout<<2<<endl;
    else if(s[0]=='R' || s[1]=='R' || s[2]=='R')
        cout<<1<<endl;
    else
        cout<<0<<endl;




    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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 revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    vector<int> V, C;
    rep (i, 0, N) {
        int v; cin >> v;
        V.push_back(v);
    }
    rep (i, 0, N) {
        int c; cin >> c;
        C.push_back(c);
    }

    int ans = 0;
    rep (i, 0, V.size()) {
        if (V[i] - C[i] > 0) ans += V[i] - C[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
def sadness(l, b):
    sad = 0
    for a in l:
        sad += abs(a - b)
    return int(sad)

if __name__ == '__main__':
    n = int(input())
    l = list(map(int, input().split()))
    if n == 1:
        print('0')
        exit()

    for i in range(len(l)):
        l[i] -= (i+1)
    nl = np.array(l)
    nl.sort()
    m = np.median(nl)

    s = sadness(l, m)
    print("{}".format(s))

Measured memory_bytes: 34172
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
typedef long long LL;

//#define foi(a, b) for (LL i = a; a < b ? i < b : b > i; a < b ? i++ : i--)
//#define foj(a, b) for (LL j = a; a < b ? j < b : b > j; a < b ? j++ : j--)

using namespace std;

int main()
{
   int node, edge;
   cin >> node >> edge;
   vector<vector<int>> adj(node+1);
   for (int i = 1; i <= edge; i++)
   {
      int a, b;
      cin >> a >> b;
      adj[a].pb(b);
      adj[b].pb(a);
   }

   queue<int> q;
   vector<bool> visited(node+1,false);
   vector<int> distance(node+1,0);

   visited[1] = true;
   distance[1] = 0;
   q.push(1);

   while (!q.empty())
   {
      int s = q.front();
      q.pop();

      // process node s
      for (auto u : adj[s])
      {
         if (visited[u]) continue;
         
         visited[u] = true;
         distance[u] = s;
         q.push(u);
      }
   }
   for (int x = 2; x <= node; x++)
   {
      if (distance[x] == 0)
      {
         cout << "No" << endl;
         exit(0);
      }
      
   }
   cout << "Yes" << endl;
   for (int x = 2; x <= node; x++)
   {
      cout << distance[x] << endl;
   }
   return 0;
}


Measured memory_bytes: 10104
from collections import deque
n,q = map(int,input().split())
g = [[] for _ in range(n)]

for _ in range(n-1):
    a,b = map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
    
X =[0]*n
for w in range(q):
    p,x = map(int,input().split())
    X[p-1]+=x
    
def bfs(u):
    queue = deque([u])
    d = [None]*n
    
    d[u] = 0
    while queue:
        v=queue.popleft()
        for i in g[v]:
            if d[i] is None:
                d[i] = d[v]+1
                X[i] += X[v]
                queue.append(i)
    return d

p = [None]*n
d = bfs(0)

print(*X)

Measured memory_bytes: 132012
n, m = map(int, input().split())
Lists = []
for i in range(m):
    Lists.append(list(map(int, input().split())))

if n == 1:
  d = 0
else:
  d = 10 ** (n-1)

for i in range(d, 10 ** n):
    i_str = str(i)
    bool_list = []
    for j  in range(m):
        a = Lists[j][0]
        bool_list.append(str(Lists[j][1]) == i_str[a-1])
    
    if n == 1 and m == 0:
      print(0)
      break
    elif n == 2 and m == 0:
      print(10)
      break
    elif n == 3 and m == 0:
      print(100)
      break
    elif bool_list == [True] * m:
        print(i)
        break
    elif i == 10**n - 1:
        print(-1)
    else:
        pass

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int A,B;
cin>>A>>B;
cout<<max(max(A+B,A-B),A*B)<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N ((int)1e7)
#define h2 (N-1)
using namespace std;
int H[N];

int CtoN(char c){
  if(c == 'A') return 1;
  if(c == 'C') return 2;
  if(c == 'G') return 3;
  return 4;
}

int StoN(char str[]){
  int n = strlen(str);
  int res = 0;
  for(int i=0;i<n;i++)
    res = res*5 + CtoN(str[i]);
  return res;
}



void Insert(char str[],int i){
  int k = StoN(str);
  int hash = k%N;
  while(H[hash] != 0) hash = (hash + k%h2)%N;
  H[hash] = i;
}

char S[1000001][11];
bool Find(char str[]){
  int k = StoN(str);
  int hash = k%N;
  while(H[hash]){
    if(strcmp(str,S[H[hash]]) == 0) return 1;
    hash = (hash+k%h2)%N;
  }
  return 0;
}

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

  for(int i=1;i<=n;i++){
    char q[11]; 
    scanf("%s %s",q,S[i]);
    if(q[0] == 'i') Insert(S[i],i);
    else printf("%s\n",(Find(S[i])? "yes":"no"));
  }
  
  return 0;
}

Measured memory_bytes: 43932
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
priority_queue <P,vector<P>,greater<P> > pqps2;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,m,num,ans;
ll a,b,c,d,e,g,h,w;
ll x[500005],y[500005],z[500005];
char s[5005][5005];

ll bitsum(ll i){
	ll s = 0;
	while(i>0){
		//p("hoi");
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
void bitadd(ll b,ll x){
	while(b <= n){
		//p("hoi");
		bit[b] += x;
		b += b & -b;
	}
}

int main(){
    cin>>n;
	k = -1;
	for(i=1;i<=n+5;i++){
		if(i*i-i == 2*n){
			k = i;
			break;
		}
	}
	if(k==-1){
		p("No");
	}else{
		p("Yes");
		num = 1;
		for(i=1;i<=k;i++){
			for(j=i+1;j<=k;j++){
				G[i].pb(num);
				G[j].pb(num);
				num++;
			}
		}
		p(k);
		for(i=1;i<=k;i++){
			pe(G[i].size());
			for(j=0;j<G[i].size();j++){
				pe(G[i][j]);
			}
			el;
		}
	}

	

    return 0;
}

Measured memory_bytes: 29952
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repb(i, n) for (int i = (int)n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define repsb(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[])
{
    int n, cnt = 0;
    bool f = false;
    cin >> n;
    vector<int> v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    VSORT(v);
    rep(i, n)
    {
        cnt += v[i];
        if (v[i] % 10 != 0)
            f = true;
    }

    if (cnt % 10 != 0)
    {
        cout << cnt << endl;
    }
    else
    {
        if (f)
        {
            rep(i, n)
            {
                if (v[i] % 10 != 0)
                    cnt -= v[i];

                if (cnt % 10 != 0)
                {
                    cout << cnt << endl;
                    return 0;
                }
            }
        }
        else
        {
            cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
mod = 998244353 #出力の制限
N = 2 * (10**5)
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def nCr(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

def nPr(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[n-r] % mod

def main():
    N, M, K = map(int, input().split())

    ans = 0
    for i in range(0, K + 1):
        # N-i個のボールを隣り合う色が必ず異なるようにする並べ方
        # 最初はM通り、それ以降は前の色とは違うM-1通り
        # = M * (M - 1) * (M - 1) * ... = M * (M - 1)^(N - i - 1)
        base = M * pow(M - 1, N - i - 1, mod)
        # 同じ色のボールを追加する場所をi箇所選ぶ
        # = 最初以外の N - 1箇所から、「前の色と同じ」を設定する場所をi箇所選ぶ
        # = nCr(N - 1, i)
        patterns = base * nCr(N - 1, i, mod)
        # print(i, base, nCr(N - 1, i, mod), patterns)
        
        ans = (ans + patterns) % mod
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 32588
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        h: usize,
        w: usize,
        a: [chars; h],
    }
    let adjacent = |i: i32, j: i32| {
        [ (i+1,j), (i+1,j-1), (i,j-1), (i-1,j-1),
          (i-1,j), (i-1,j+1), (i,j+1), (i+1,j+1)] };
    for i in 0..h {
        for j in 0..w {
            if a[i][j] == '#' {
                print!("#");
            } else {
                let ads = adjacent(i as i32,j as i32);
                let sum: usize = ads.iter().map(|&(ii,jj)|{
                    if 0 <= ii && ii < (h as i32) &&
                       0 <= jj && jj < (w as i32) {
                        if a[ii as usize][jj as usize] == '#' {
                            1
                        } else { 0 }
                    } else { 0 }
                }).sum();
                print!("{}", sum);
            }
        }
        println!();
    }
}


Measured memory_bytes: 4352
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ll N;

    cin >> N;

    ll H[N];
    ll maxH = 0;
    int success = 1;

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

    maxH = H[0];
    for(int i = 1; i < N; i++){
        if(H[i] < maxH - 1){
            success = 0;
            break;
        }
        if(H[i] > maxH){
            maxH = H[i];
        }
    }

    if(success == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<math.h>
using namespace std;
int main()
{
    char a[5];
    cin>>a;
    for(int i=0;i<strlen(a);i++)
    {
      if(a[i]=='7')
      {
          cout<<"Yes";
          return 0;
      }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define Max(a,b) ((a) < (b) ? (b) : (a))
#define Min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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

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


int main() {
	const double PI = 3.14159265358979323846;
	int i, j, k;
	
	int N, M, K;

	int A, B, H;
	cin >> A >> B >> H >> M;

	double a = 60 * H + M;
	double b = 12 * M;
	double theta = max(a - b, b - a);

	theta *= PI / 12 / 30;
	double c = A * A + B * B - (double)2 * A * B * cos(theta);
	printf("%.20f" ,sqrt(c));

	
	return 0;

}

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

string s;
bool cnt[30];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> s;
    if(s.length() < 26) {
        for(int i = 0; i < s.length(); i++) cnt[s[i] - 'a'] = true;
        cout << s;
        for(int i = 0; i < 26; i++) {
            if(not cnt[i]) {
                cout << (char) (i+'a');
                return 0;
            }
        }
    }
    else {
        int pos = -1;
        for(int i = s.length()-1; i >= 0; i--) {
            cnt[s[i] - 'a'] = true;
            for(int j = s[i] - 'a' + 1; j < 26; j++) {
                if(cnt[j]) {
                    s[i] = (char) (j + 'a'), pos = i;
                    break;
                }
            }
            if(pos > -1) break;
        }
        if(pos == -1) cout << "-1";
        else for(int i = 0; i <= pos; i++) cout << s[i];
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#define EXCHANGE(a, b){ int t; t = a; a = b; b = t; }

int main()
{
  int num, n[3], i, j, tmp;

  scanf("%d", &num);
  while (num--) {
    scanf("%d %d %d", &n[0], &n[1], &n[2]);
    for (i = 0; i < 2; i++) {
      for (j = 2; j > i; j--) {
        if (n[j - 1] > n[j]) {
          EXCHANGE(n[j - 1], n[j]);
        }
      }
    }
    if (n[0] * n[0] + n[1] * n[1] == n[2] * n[2]) {
      puts("YES");
    } else {
      puts("NO");
    }
  }

  return 0;
}

Measured memory_bytes: 0
n=int(input())
a=input()
b=input()
c=input()
v=0

for i in range(n):
  if a[i]!=b[i] and b[i]!=c[i] and a[i]!=c[i]:
    v+=2
  elif not a[i]==b[i]==c[i]:
    v+=1
print(v)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  if(s.substr(0, 1) == "A" && s.substr(1, 1) == "A" && s.substr(2, 1) == "A"){
    cout << "No" << endl;
    return 0;
  }
  if(s.substr(0, 1) == "B" && s.substr(1, 1) == "B" && s.substr(2, 1) == "B"){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 760
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
#define INF 1e9
using ll = int64_t;
#define waru 1000000007

void Main() {
  string s;
  std::cin >> s;

  //圧縮
  std::vector<pair<char, ll>> data;
  {
    char now = 'R';
    ll count = 0;
    rep(i, sz(s) + 1) {
      if (i == sz(s)) {
        data.push_back(make_pair(s[i - 1], count));
        break;
      } else if (now != s[i]) {
        data.push_back(make_pair(now, count));
        now = s[i];
        count = 0;
      }
      count++;
    }
  }

  //答えの数を求める
  std::vector<ll> numsub(data.size(), 0);
  rep(i, data.size()) {
    if (data[i].first == 'R') {
      if (data[i].second % 2) {
        ll tmp = data[i].second / 2;
        numsub[i] += tmp + 1;
        numsub[i + 1] += tmp;
      } else {
        ll tmp = data[i].second / 2;
        numsub[i] += tmp;
        numsub[i + 1] += tmp;
      }
    } else {
      if (data[i].second % 2) {
        ll tmp = data[i].second / 2;
        numsub[i] += tmp + 1;
        numsub[i - 1] += tmp;
      } else {
        ll tmp = data[i].second / 2;
        numsub[i] += tmp;
        numsub[i - 1] += tmp;
      }
    }
  }

  //答えの数列を作成
  std::vector<ll> num(s.size(), 0);
  ll index = 0;
  rep(i, s.size()) {
    if (s[i] == 'R') {
      if (s[i + 1] == 'L') {
        num[i] = numsub[index];
        index++;
      } else {
        num[i] = 0;
      }
    } else {
      if (s[i - 1] == 'R') {
        num[i] = numsub[index];
        index++;
      } else {
        num[i] = 0;
      }
    }
  }

  for (auto &x : num) {
    std::cout << x << ' ';
  }

  return;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define ll long long int 
#define endl '\n'
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
const ll INF=2e18;

typedef vector<ll>   vi;
 
ll gcd(ll a,ll b){
	if(a==0)
	return b;
	return gcd(b%a,a);
} 

ll gcd(ll a[],ll n){
	ll r=a[0];
	for(ll i=1;i<n;i++){
		r=gcd(a[i],r);
		if(r==1)
		return 1;
	}
	return r;
}

int main()
{
ll i,j,k,m,sum=0;
cin>>m;
for(i=1;i<=m;i++){
	for(j=1;j<=m;j++){
		for(k=1;k<=m;k++){
			ll h=gcd(i,j);
			ll g=gcd(h,k);
			sum+=g;
		}
	}
}
cout<<sum;

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





int main() {
    int n;
    string s;
    cin >> n >> s;
  
  int now=0;
  int sma=0;
  rep(i,n){
    if(s[i]=='(') now++;
    else now--;
    sma=min(sma,now);
  }

  rep(i,0-sma){
    cout << '(';
  }
  cout << s;
  rep(i,now-sma){
    cout << ')';
  }

  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "Yes\n";
string no = "No\n";

int32_t main() {
  fastio;
  #ifndef ONLINE_JUDGE
  freopen("i.txt", "r", stdin);
  freopen("o.txt", "w", stdout);
  #endif
  ll x;
  cin>>x;
  if(x>=30) {
    cout<<yes;
  } else cout<<no;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  int cnt=0;
  int a=0,b=0,ba=0;
  for(int i=0;i<n;i++){
    cin >> s[i];
    for(int j=0;j<s[i].size()-1;j++){
      if(s[i].substr(j,2)=="AB"){
        cnt++;
      }
    }
    if(s[i][0]=='B'&&s[i][s[i].size()-1]=='A'){
      ba++;
    }
    else if(s[i][0]=='B'){
      b++;
    }
    else if(s[i][s[i].size()-1]=='A'){
      a++;
    }
  }
  if(ba==0){
    cout << cnt+min(a,b) << endl;
  }
  else if(a+b==0){
    cout << cnt+ba-1 << endl;
  }
  else{
    cout << cnt+ba+min(a,b) << endl;
  }
}

Measured memory_bytes: 768
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] a = new int[N];
		for(int i = 0;i < N;i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		sc.close();

		int[] cnt = new int[100010];
		for(int i = 0;i < N;i++) {
			cnt[a[i]]++;
			cnt[a[i]+1]++;
			if(a[i] != 0) {
				cnt[a[i]-1]++;
			}
		}
		Arrays.sort(cnt);
		System.out.println(cnt[cnt.length-1]);
	}
}

Measured memory_bytes: 50624
import java.util.*;
class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[N];
        int total = 0;
        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
            total += A[i];
        }
        double benchmark = (double)total/(M*4);
        int ok = 0;
        for(int i=0; i<N; i++){
            if(A[i] >= benchmark){
                ok++;
            }
        }
        if(ok>=M){
            System.out.println("Yes");
        }else System.out.println("No");

    }    
}

Measured memory_bytes: 21844
#include <stdio.h>

int main(void)
{
	int i, n, b, num = 0;
	long int l[1001], r[1001];
	scanf("%d", &n);
	for (i = 1; i <= n; i++)
		b = scanf("%d %d", &l[i], &r[i]);

	for(i = 1; i <= n; i++){
		num += r[i] - l[i] + 1;
	}
	printf("%d", num);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
vector<int> adj[100001],dist(100001,0);
bool v[100001];
stack<int> top_sort;
map<int,int> h;
void dfs(int node)
{
    //cout<<node<<" ";
    v[node]=1;
    for(int i=0;i<adj[node].size();i++)
    {
        if(h.find(adj[node][i])==h.end())
            top_sort.push(adj[node][i]),h[adj[node][i]]++;
    }
    if(h.find(node)==h.end())
        top_sort.push(node),h[node]++;
    for(int i=0;i<adj[node].size();i++)
    {
        if(!v[adj[node][i]])
            dfs(adj[node][i]);
    }
}
void go()
{
    ll int n;
    cin>>n;
    vector<ll int> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll int ans=0,m=a[0];
    for(int i=0;i<n;i++)
        m=max(m,a[i]),ans+=max(0LL,m-a[i]);
    cout<<ans;
}
int main()
{
    FIO;
//    int t;
//    cin>>t;
//    while(t--)
        go();
    return 0;
}



Measured memory_bytes: 7372