akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;



public class Main {

	public static void main(String[] args) {
		 FastScanner scanner =new FastScanner();
		 PrintWriter out=new PrintWriter(System.out);
		  int n=scanner.nextInt();
	if(n<30) System.out.println("No");
	else System.out.println("Yes");
			
			
		
		out.close();
		    	
		    }
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
}

		    
		}

Measured memory_bytes: 32812
N,S = map(int, input().split())
tmp = 1
a = 1
while True:
  if N // 2 < a and S // 2 < a:
    break
  if N % a == 0 and S % a == 0:
    N,S = N // a, S // a
    tmp *= a
    a = 1
  a += 1

print(tmp * S * N)

Measured memory_bytes: 3060
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    int e = sc.nextInt();
    int f = sc.nextInt();
    List<Integer> x = new ArrayList<>();
    List<Integer> y = new ArrayList<>();
    for(int i = 0; i * 100 <= f; i++){
      for(int j = 0; (j + i) * 100 <= f; j++){
        if(i == 0 && j == 0) continue;
        x.add((i * a + j * b) * 100);
      }
    }
    
    double maxSuger = f / 100 * e;
    for(int i = 0; i <= maxSuger; i++){
      for(int j = 0; i*c + j*d <= maxSuger; j++){
        y.add(i * c + j * d);
      }
    }
    double max = -1;
    int maxWater = -1;
    int maxS = -1;
    for(int water : x){
      for(int suger : y){
        if((f < water + suger) || (water / 100 * e < suger)){
          continue;
        }else{
          if(max < ((double)suger / (water + suger))){
            max = (double)suger / (water + suger);
            maxWater = water + suger;
            maxS = suger;
          }
        }
      }
    }
    System.out.println(maxWater + " " + maxS);
  }
}

Measured memory_bytes: 30292
while True:
	try:
		turi = 1000 - input()
		if turi == 1000:
			break
		how = 0
		while True:
			if turi >= 500:	
				turi -= 500
				how += 1
			else:
				break
		while True:
			if turi >= 100:
				turi -= 100
				how += 1
			else:
				break
		while True:
			if turi >= 50:
				turi -= 50
				how += 1
			else:
				break
		while True:
			if turi >= 10:
				turi -= 10
				how += 1
			else:
				break
		while True:
			if turi >= 5:
				turi -= 5
				how += 1
			else:
				break
		while True:
			if turi >= 1:
				turi -= 1
				how += 1
			else:
				break
		print how
	except EOFError:
		break


Measured memory_bytes: 4252
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s,t;cin>>s>>t;
  int ns=s.size();
  int nt=t.size();

  for(int i=ns-1;i>=0;i--){
    bool flag=true;
    string ss=s.substr(i,nt);
    for(int j=0;j<nt;j++){
      if(ss[j]!='?' && ss[j]!=t[j])flag=false;
    }
    if(flag){
      s.replace(i,nt,t);
      break;
    }
    if(i==0 && flag==false){
      P("UNRESTORABLE");
      return 0;
    }
  }
  REP(i,ns)if(s[i]=='?')s[i]='a';
  P(s);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

string str;
llong l[500005];
llong g[500005];

int main() {
    cin >> str;

    llong n = str.size();

    for (int i = 0; i < n; i++) {
        if (str[i] == '<') g[i + 1] = g[i] + 1;
    }

    for (int i = n - 1; i >= 0; i--) {
        if (str[i] == '>') l[i + 1] = l[i + 2] + 1;
    }

    llong ans = 0;
    for (int i = 0; i <= n; i++) {
        ans += max(g[i], l[i + 1]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8708
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <numeric>
#include <iomanip>
using namespace std;

int main() {

	int a, b, h, m;
	cin >> a >> b >> h >> m;

	double h_deg, m_deg;
	h_deg = (double)(h * 60.0 + m) / 2.0;
	m_deg = (double)m * 6.0;
	
	double deg = abs(h_deg - m_deg);
	deg = deg > 180 ? 360 - deg : deg;

	double rad = deg * (M_PI / 180.0);

	cout<<fixed << setprecision(15) << sqrt(a * a + b * b - 2 * a * b * cos(deg * (M_PI / 180.0))) << endl;

	return 0;
}

Measured memory_bytes: 4168
import sys
def input():
    return sys.stdin.readline()
def scoring(ans, d, t, C, S, L, replace = False):
    ans += S[d][t]
    penalty = sum([c * (d - l) for i, (c, l) in enumerate(zip(C, L)) if i != t])
    ans -= penalty
    if replace:
        return ans, [l if i != t else d for i, l in enumerate(L) ], penalty
    else:
        return ans
def scoring_2(ans, d, t, C, S, L, replace = False):
    ans += S[d][t]
    ans -= sum([c * pow(d - l, 2) for i, (c, l) in enumerate(zip(C, L)) if i != t])
    return ans

def main():
    D = int(input())
    C = list(map(int, input().split()))
    S = [list(map(int, input().split())) for _ in range(D)]
    L = [-1] * 26
    T = [-1] * D
    ans = 0
    for d in range(D):
        SCORE = [scoring(ans, d, t, C, S, L) for t in range(26)]
        t_max = SCORE.index(max(SCORE))
        ans, L, p = scoring(ans, d, t_max, C, S, L, replace = True)
        print(t_max + 1)




if __name__ == '__main__':
    main()


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

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    vector<int> h(n);
    for (int i = 0; i < n; i++) scanf("%d", &h[i]);
    vector<int> a = h;
    sort(a.begin(), a.end());
    //座圧 -> id 復元 -> res
    map<int, int> id;
    map<int, int> res;
    int now = 1;
    for (int i = 0; i < n; i++){
        if (id[a[i]] == 0) {
            id[a[i]] = now;
            res[now] = a[i];
            now++;
        }
    }
    long long INF = ((long long)1 << 40);
    vector<vector<vector<long long>>> dp(n + 1, vector<vector<long long>>(n - k + 1, vector<long long>(n + 1, INF)));
    dp[0][0][0] = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j <= n - k; j++){
            for (int m = 0; m <= n; m++){
                if (dp[i][j][m] == INF) continue;
                dp[i + 1][j][m] = min(dp[i + 1][j][m], dp[i][j][m]);
                if (j == n - k) continue;
                dp[i + 1][j + 1][id[h[i]]] = min(dp[i + 1][j + 1][id[h[i]]], dp[i][j][m] + max(0, h[i] - res[m]));
            }
        }
    }
    long long ans = INF;
    for (int i = 0; i <= n; i++) ans = min(ans, dp[n][n - k][i]);
    printf("%lld\n", ans);
}


Measured memory_bytes: 216832
N, A, B = map(int, input().split())

def int_to_sum(i):
    i_str = str(i)
    result = 0
    for i_s in i_str:
        result += int(i_s)
    return result

result = 0

for i in range(1,N+1):
    int_sum = int_to_sum(i)
    if int_sum <= B and int_sum >= A:
        result += i

print(result)


Measured memory_bytes: 8960
fun xor(x: Long): Long {
    var xor = 0L
    for (i in 0 until java.lang.Long.toBinaryString(x).length) {
        val p = 1L shl i + 1
        val passert = p shr 1
        val sassert = (x + 1) / p * passert + Math.max((x + 1) % p - passert, 0)
        if (sassert and 1 == 1L) {
            xor += passert
        }
    }
    return xor
}

fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(' ').map(String::toLong)
    println(xor(a - 1) xor xor(b))
}


Measured memory_bytes: 38312
#include<iostream>
#include <set>
#include <string>
#include <cstdlib> 
#include <algorithm>
#include <numeric>
using namespace std;
int f(int a){
  if (a%2==0){
    return a/2;
  }else{
    return 3*a+1;
  }
}

int main(){
  int s;
  cin >> s;
  int a=s;
  set<int> m;
  m.insert(a);
  int res=1;
  while(true){
    res++;
    a=f(a);
    
    if (m.count(a)){
      cout <<res<<endl; 
      break;
    }else{
      m.insert(a);
    }
  } 
}  


Measured memory_bytes: 256
fn main() {
    let scan = std::io::stdin();
    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();
    let l: i32 = vec[0].parse().unwrap();

    let scan = std::io::stdin();
    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();

    let mut b = 0;
    let mut total = 0;
    for x in 0..l{
        let a: i32 = vec[x as usize].parse().unwrap();
        let tmp = if b-a < 0{a-b}else{b-a};
        total = total + tmp;
        b = a;
    }
    let total = if b < 0 {total - b} else {total + b};

    let mut past = 0;
    for x in 0..l{
        let mut ans = total;
        let present: i32 = vec[x as usize].parse().unwrap();
        let tmp = if past - present < 0 {present - past} else {past - present};
        ans = ans - tmp;

        let future;
        if x == l-1 {
            future = 0;
        }else{
            let y = x+1;
            future = vec[y as usize].parse().unwrap();
        }
        let tmp = if future - present < 0 {present - future} else {future - present};
        ans = ans - tmp;

        let tmp = if future - past < 0 {past - future} else {future - past};
        ans = ans + tmp;

        println!("{}", ans);

        past = present;
    }

}


Measured memory_bytes: 9340
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int a = Character.getNumericValue(s.charAt(0));
    int b = Character.getNumericValue(s.charAt(1));
    int c = Character.getNumericValue(s.charAt(2));
    int d = Character.getNumericValue(s.charAt(3));

    // +++
    if (a + b + c + d == 7) {
      System.out.println(a + "+" + b + "+" + c + "+" + d + "=7");
      return;
    }
    // ++-
    if (a + b + c - d == 7) {
      System.out.println(a + "+" + b + "+" + c + "-" + d + "=7");
      return;
    }
    // +-+
    if (a + b - c + d == 7) {
      System.out.println(a + "+" + b + "-" + c + "+" + d + "=7");
      return;
    }
    // -++
    if (a - b + c + d == 7) {
      System.out.println(a + "-" + b + "+" + c + "+" + d + "=7");
      return;
    }
    // --+
    if (a - b - c + d == 7) {
      System.out.println(a + "-" + b + "-" + c + "+" + d + "=7");
      return;
    }
    // -+-
    if (a - b + c - d == 7) {
      System.out.println(a + "-" + b + "+" + c + "-" + d + "=7");
      return;
    }
    // +--
    if (a + b - c - d == 7) {
      System.out.println(a + "+" + b + "-" + c + "-" + d + "=7");
      return;
    }
    // ---
    if (a - b - c - d == 7) {
      System.out.println(a + "-" + b + "-" + c + "-" + d + "=7");
      return;
    }
  }
}

Measured memory_bytes: 21972
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const int MOD = 1000000007;

int main()
{
    int n, len;
    cin >> n >> len;
    vector<int> x(n), a(n);
    for(int i=0; i<n; ++i)
        cin >> x[i];
    for(int i=0; i<n; ++i)
        cin >> a[i];

    vector<int> dp(len+1, 0);
    dp[0] = 1;
    for(int i=0; i<n; ++i){
        vector<int> nextDp(len+1, 0);
        int sum = 0;
        for(int j=0; j<len; ++j){
            sum += dp[j];
            sum %= MOD;
            if(x[i] <= j && (a[i] == 0 || (j - x[i]) % a[i] == 0)){
                nextDp[j+1] = sum;
                nextDp[j+1] %= MOD;
                if(a[i] == 0)
                    break;
            }
        }
        dp.swap(nextDp);
    }

    int ans = 0;
    for(int i=0; i<=len; ++i){
        ans += dp[i];
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s; cin>>s;
    if (s[2]==s[3] && s[4]==s[5]) {
        cout << "Yes" << '\n';
    }
    else {
        cout << "No" << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
A = list(map(int, input().split()))

S = [0] * (n + 1)
for i in range(1, n + 1):
    S[i] = S[i - 1] + A[i - 1]
counter = Counter(S)
result = 0
for k in counter.keys():
    if counter[k] <= 1:
        continue
    result += (counter[k] - 1 + 1) * (counter[k] - 1) // 2
print(result)


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

#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int lli;
typedef pair<int, int> P;

int main() {
    int n, k, ans=0;
    vector<int> s2;
    vector<int> s2_01;
    string s;
    cin >> n >> k;
    cin >> s;

    int count = 0;
    bool is_0;
    bool first_is_0;
    if (s[0] == '0')
        first_is_0 = is_0 = true;
    else
        first_is_0 = is_0 = false;

    for (int i = 0; i < n; i++) {
        if (s[i] == '0' && is_0 || s[i] == '1' && !is_0) {

            count++;
        }
        else {
            s2.push_back(count);
            count = 1;
            is_0 = !is_0;
        }
    }
    s2.push_back(count);

    int s2_size = (int)s2.size();
    //for (int i = 0; i < s2_size; i++) {
        //cout << s2[i];
    //}
    //cout << endl;


    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }

    for (int i = 0; i < s2_size; i++) {
        int left, right;
        if (i % 2 != first_is_0) {
            left = i;
            right = min(left + k*2-1, s2_size -1);
        }
        else {
            left = i;
            right = min(left + k*2, s2_size -1);
        }
        int num = 0;
        for (int l = left; l < right + 1; l++) {
            num += s2[l];
        }
        if (ans < num)
            ans = num;
    }



    cout << ans << endl;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
typedef long long ll;
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
#define tr(container, it) \
	for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c,x) ((c).find(x) != (c).end())   //O(log n) 
#define contains(c,x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define fastIO  ios_base::sync_with_stdio(false); cin.tie(0); 
#define Ichar(_x) char _x;scanf("%c",&_x);
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define inc(a,b,x)(x)>a && (x)<b	
#define incE(a,b,x)(x)>=a && (x)<=b	
#define fileIO 	freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

int main(int argc, char* argv[])
{
	Ill(a);
	Ill(b);
//	for (int i = 0; i < 30; ++i)
//	{
//		std::cout << "i:" <<log2(i) <<endl;
//	}
////	std::cout << log2;
	std::cout <<floor(log2l(b / a))+1;

}


Measured memory_bytes: 256
inp = int(input())

if inp <= 111:
  print("111")
elif inp <= 222:
  print("222")
elif inp <= 333:
  print("333")
elif inp <= 444:
  print("444")
elif inp <= 555:
  print("555")
elif inp <= 666:
  print("666")
elif inp <= 777:
  print("777")
elif inp <= 888:
  print("888")
elif inp <= 999:
  print("999")

Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * upper_bound
 */
using namespace std;
typedef long long ll;
typedef long double ld;
ll N,M,V,P;
vector<ll> A;
vector<ll> orig;
vector<ll> temp;
bool check(int k) {
    if (k<P)return true;
    // statement 1
    ll v=A[k]+M;

    //ll d=distance(orig.begin(),upper_bound(ALL(orig),v));
    ll d=upper_bound(ALL(orig),v)-orig.begin();
    if(N-d>=P)return false;
    temp.clear();
    for(int i=0;i<N;++i) {
        if (i>=P-1&&i!=k) {
            temp.push_back(A[i]);
        }
    }
    ll rest=(V-P)*M;
    for(int i=temp.size()-1;i>=0;i--) {
        rest-=min(v-temp[i],M);
    }

    return rest<=0;
}
int main() {
    cin >> N >> M >> V>>P;
    A.resize(N);
    REP(i,N)cin>>A[i];
    sort(ALL(A));
    orig=A;
    reverse(ALL(A));
    int l=0,r=N;
    while((r-l)>1){
        int m=(r-l)/2+l;
        if (check(m))
            l=m;
        else
            r=m;
    }
    cout << l+1 << endl;
    return 0;
}


Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
int a[200005],n;
double ans;
int main()
{
	scanf("%d",&n);
	for (int i=0;i<2*n;i++)scanf("%d",&a[i]);
	sort(a,a+2*n);
	for (int i=0;i<2*n;i++)
	 ans+=(double)i*a[i]/(2*n-1);
	printf("%.10lf",ans); 
}

Measured memory_bytes: 1024
# coding: utf-8
n, a = map(int, input().split())
l_a = list(map(lambda x: int(x) - a, input().split()))

dic = dict()
dic[0] = 1
for x in l_a:
    for key, value in list(dic.items()):
        dic[x + key] = value + dic.get(x+key,0)

print(dic[0] - 1)


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

int main(){
	int a,b,c;
	int ans;
	int cnt=-1;
	
	while(cin>>a>>b){
		cnt++;
		//-----test-----
		if(a<1171) break;
		
		//--------------
		c=a+b;
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define ces(d) cout<<" "<<endl;

int main() {
   
string S;
long long K;
bool flag=false;
cin >>S>>K;
fx(S.size()){
	if(S.at(x)!='1'){
           if(K<=x){
ce("1");
flag=true;
		break;
}else{
		ce(S.at(x));
flag=true;
		break;
}
	}
}
if(!flag)
ce("1");
}

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

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> P(a), Q(b), R(c);
    for (int i = 0; i < a; ++i) {
        cin >> P[i];
    }
    for (int i = 0; i < b; ++i) {
        cin >> Q[i];
    }
    for (int i = 0; i < c; ++i) {
        cin >> R[i];
    }
    sort(P.begin(), P.end(), greater<int>());
    sort(Q.begin(), Q.end(), greater<int>());
    sort(R.begin(), R.end(), greater<int>());
    priority_queue<int, vector<int>, greater<int> > que;
    for (int i = 0; i < x; ++i) {
        que.push(P[i]);
    }
    for (int i = 0; i < y; ++i) {
        que.push(Q[i]);
    }
    for (int i = 0; i < c; ++i) {
        int z = que.top();
        if (z >= R[i]) break;
        que.pop();
        que.push(R[i]);
    }
    long long ans = 0;
    for (int i = 0; i < x+y; ++i) {
        int d = que.top();
        que.pop();
        ans += d;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2552
n = int(input())
A = list(map(int, input().split()))
q = int(input())
l = [0]*(10**5+10)
num = sum(A)
for i in A:
    l[i] = l[i] + 1


for i in range(q):
    b, c = map(int, input().split())
    num += (c-b)*l[b]
    l[c] += l[b]
    l[b] = 0
    print(num)


Measured memory_bytes: 21060
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10000)


def main():
    # 入力処理
    # N = int(input())
    A, B = map(int, input().split())

    # アルゴリズム本体
    strength = lambda x: (x - 2) % 13
    if strength(A) > strength(B):
        winner = "Alice"
    elif strength(A) < strength(B):
        winner = "Bob"
    else:
        winner = "Draw"

    # 出力
    print(winner)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long N,sum=0;
    cin>>N;
    for(int i=1;i<=N;i++)
    {
        if(i%3!=0&&i%5!=0)
        sum+=i;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>
#include <stdbool.h>
typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)
int main(void)
{
    lli A, B;
    scanf("%lld %lld", &A, &B);
    lli K = A + B;
    if (K % 2 == 0)
    {
        printf("%lld", K / 2);
    }
    else
    {
        printf("IMPOSSIBLE");
    }
    return 0;
}

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

int binarySearch (vector<int> A, int key, int n){
    int left = 0, right = n, mid;
    while (left < right) {
        mid = (left + right) / 2;
        if (A[mid] == key)  return 1;
        else if (key > A[mid])  left = mid + 1;
        else if (key < A[mid]) right = mid;
    }
    return 0;
}

int main(void){
    int q, k, sum, n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> k;
        if (binarySearch(A, k, n) == 1) sum++;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3496
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <stack>

using namespace std;

void main_(); signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  main_(); return 0;
}

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

void main_() {

  int N; cin >> N;
  stack<int> st;
  int ans = 0;
  /*
    テ、ツクツ?ヲツ楪堙」ツ?ョテ」ツつォテ」ツδシテ」ツδ堙」ツδε」ツδ暗」ツつ津ヲツァツ凝ヲツ按静」ツ?凖」ツつ凝ゥツ閉キテヲツ鳴ケテ・ツスツ「テ」ツ?ョテヲツ慊?・ツキツヲテァツォツッテ」ツ?ィテヲツ慊?・ツ渉ウテァツォツッテ」ツ?古・ツ按?」ツ?凝」ツつ古」ツ?ーOK
    テヲツ慊?・ツキツヲテァツォツッlテ」ツ?ッテ」ツ?‖[l]<a[l+1]テ」ツつ津ヲツコツ?」ツ?淌」ツ?冤テ」ツ?づヲツ慊?・ツ渉ウテァツォツッrテ」ツ?ッテ」ツ?〉=N-1テ」ツ?セテ」ツ?淌」ツ?ッa[r]<a[r+1]テ」ツつ津ヲツコツ?」ツ?淌」ツ?决テ」ツ?ョテ」ツ?ィテ」ツ?催」ツ??
    テヲツ慊?・ツ渉ウテァツォツッrテ」ツ?古ヲツ敖・テ」ツ?淌」ツ?ィテ」ツ?催」ツ?〕<=i<=rテ」ツつ津ヲツコツ?」ツ?淌」ツ?凖・ツ?ィテ」ツ?ヲテ」ツ?ョiテ」ツ?ォテ」ツ?、テ」ツ??」ツ?ヲテ」ツ?‖[l] = a[r] <= a[i]テ」ツ?ィテ」ツ?ェテ」ツつ凝」ツ??
    テ」ツつケテ」ツつソテ」ツδε」ツつッテ」ツつ津ァツ板ィテ」ツ??」ツつ凝」ツ?ィテ」ツ??ヲツ慊?・ツキツヲテァツォツッテ」ツ?ョテゥツォツ佚」ツ?病[l]テ」ツ?継ushテ」ツ?陛」ツつ古」ツ?ヲテ」ツ?凝」ツつ嘉」ツ?‖[i](l<=i<=r)テ」ツ?ョテ・ツ?・テ・ツ環崚」ツ?ョテゥツ鳴禿」ツ?ォpushテ」ツつаopテ」ツ?古」ツ?づ」ツつ甘」ツ??
    テヲツ慊?・ツ渉ウテァツォツッテ」ツ?ョテゥツォツ佚」ツ?病[r]テ」ツ?古・ツ?・テ・ツ環崚」ツ?陛」ツつ古」ツ?淌」ツ?ィテ」ツ?催」ツ?ッテ」ツ??」ツつケテ」ツつソテ」ツδε」ツつッテ」ツ?ョtopテ」ツ?径[l]テ」ツつ津ヲツ個?」ツ?療」ツ?ヲテ」ツ??」ツつ凝」ツ?ィテゥツδステ・ツ青暗」ツ?古ィツ可ッテ」ツ??」ツ??
    テヲツ慊?・ツ渉ウテァツォツッa[r]テ」ツ?古・ツ?・テ・ツ環崚」ツ?陛」ツつ古」ツ?淌」ツ?ィテ」ツ?催」ツ??、ツクツ?」ツ?、テ」ツ?ョテ」ツつォテ」ツδシテ」ツδ堙」ツδε」ツδ暗」ツ?ョテゥツ閉キテヲツ鳴ケテ・ツスツ「テ」ツつ津ィツイツシテ」ツつ凝ゥツ?佚・ツ淞淌」ツ?古・ツョツ堙」ツ?セテ」ツ?」テ」ツ?淌」ツ?ィティツヲツ凝」ツ?ヲテ」ツ??」ツつケテ」ツつソテ」ツδε」ツつッテ」ツ?ョpopテ」ツ?ィテ・ツ青古ヲツ卍づ」ツ?ォテ」ツつォテ」ツつヲテ」ツδウテ」ツδ暗」ツ?凖」ツつ古」ツ?ーティツ可ッテ」ツ??」ツ??
    */
  rep(i, N) {
    int a; cin >> a;
    if(!st.empty() && st.top() == a) { continue; }  // テゥツォツ佚」ツ?陛」ツ?古ゥツ?」テァツカツ堙」ツ?凖」ツつ凝」ツ?ョテ」ツ?ァテ」ツつケテ」ツδォテ」ツδシ
    if(st.empty() || st.top() < a) {
      st.push(a);
    }
    while(!st.empty() && st.top() > a) {
      st.pop(); ans ++;
    }
    if(st.empty() || st.top() != a) {
      st.push(a);
    }
  }

  cout << ans + st.size() << endl;

}

Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
  int a, b, c, d, ab, bc, ca;

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

  ab = abs(a - b);
  bc = abs(b - c);
  ca = abs(c - a);

  if((ab <= d && bc <= d) || ca <= d){
    printf("Yes");
  }
  else{
    printf("No");
  }

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

using namespace std;


int main()
{
	map<string, vector<int>> m;
	map<int, int> sub;
	int N, P;
	string S;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> S >> P;
		m[S].push_back(P);
		sub[P] = i + 1;
	}

	for (auto name : m)
	{
		sort(name.second.begin(), name.second.end(), greater<int>());
		
		for (auto it : name.second)
		{
			cout << sub[it] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double PI=3.1415926535897932;
const double LIT=0.000000001;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define PRO(a,b) a=(a*b)%mod


ll ruijou(ll n, ll k){
    if(k==0) return 1;
    ll x=k/2;
    long long t=ruijou(n,x);
    t=(t*t)%mod;
    if(k%2==1) return (n*t)%mod;
    else return t%mod;
}


const ll MaxN=201001;

ll f[MaxN], rf[MaxN];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    REP(i, 1, MaxN) f[i] = (f[i - 1] * i) % mod;
    REP(i, 0, MaxN) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll C(ll n, ll k) {
    if(k>n) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}

ll N; vec d;

int main(){
    init();
    cin>>N;
    rep(i,N){
        ll x; cin>>x;
        d.pb(x);
    }
    sort(ALL(d));
    reverse(ALL(d));
    ll ans=0;
    if(N==1) ans=(2*d[0])%mod;
    else{
        ll K=ruijou(4,N-1); 
        rep(i,N) ADD(ans,((2+i)*K%mod)*d[i]%mod);
    }
    cout<<ans<<endl;
    

}

Measured memory_bytes: 5620
#include <bits/stdc++.h>
#include <unistd.h>
#define inf 1000000007LL
#define INF 1000000000000000007LL
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define st first
#define nd second
#define ll long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vll vector<long long>
#define vpii vector< pair<int,int> >
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define BIT(i) (1LL<<(i))
#define LOG(x) (63-__builtin_clzll(x))
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i, n) for(int i=1; i<=(n); ++i)
#define pv(...) cerr<<'\n',dbg(#__VA_ARGS__, __VA_ARGS__)
#define ps(x) {cerr<<'\n'<<#x<<":\n:";for(auto q:(x)){cerr<<q<<" ";}cerr<<'\n';}
#define pa(x, xs) {cerr<<'\n'<<#x<<":\n:";for(int q=0; q<=(xs); ++q){cerr<<x[q]<<" ";}cerr<<'\n';}
#define pal(x, xs) {cerr<<'\n'<<#x<<":\n";for(int q=0; q<=(xs); ++q){cerr<<q<<": "<<setw(q? 3-(int32_t)log10(q):3)<<x[q]<<'\n';}cerr<<'\n';}
#define ppii(x, xs) {cerr<<'\n'<<#x<<":\n";for(int q=0; q<=(xs); ++q){cerr<<q<<": "<<setw(q? 6-(int32_t)log10(q):6)<<x[q].first<<" "<<setw(5)<<x[q].second<<'\n';}cerr<<'\n';}
#define pm(x, xn, xm) {cerr<<'\n'<<#x<<":\n";for(int qa=0; qa<=(xn); ++qa){for(int qb=0; qb<=(xm); ++qb){cerr<<setw(6)<<x[qa][qb]<<" ";}cerr<<'\n';}cerr<<'\n';}
#define endr cerr<<'\n'
#define endl '\n'
#ifndef DEBUG
#define cerr if(0)cout
#define pv(...) if(0)endr
#define ps(x) if(0)endr
#define pa(x, xs) if(0)endr
#define pal(x, xs) if(0)endr
#define ppii(x, xs) if(0)endr
#define pm(x, xn, xm) if(0)endr
#endif
using namespace std;
template<class T> void dbg(const char* xn, T x){cerr<<xn<<": "<<x<<"\n";} template<class T, class... TA> void dbg(const char* xn, T x, TA... t){while(*xn!=',')cerr<<*xn++;cerr<<": "<<x<<",";dbg(xn+1, t...);}
template<class T> inline bool upd_max(T &x, T y){return y>x?x=y,true:false;} template<class T> inline bool upd_min(T &x, T y){return y<x?x=y,true:false;}
const int N = 1000007;
#define int long long

int A, B, C, D, E, F;
pii rst = mp(0LL, 0LL);


void check(int a, int b, int c, int d)
{
  if ((a == 0 && b == 0) && (c == 0 && d == 0)) return;
  if ((C*c + D*d) > E*(A*a + B*b)) return;

  pii res;
  res.st = 100*A*a + 100*B*b;
  res.nd = C*c + D*d;

  if (rst.st<=0 || (res.nd*rst.st > rst.nd*res.st)) rst = res;
}

void solve()
{
  cin>>A>>B>>C>>D>>E>>F;

  for (int a=0; 100*a*A<=F; ++a)
  {
    for (int b=0; 100*a*A+100*b*B<=F; ++b)
    {
      for (int c=0; 100*a*A+100*b*B+c*C<=F; ++c)
      {
        for (int d=0; 100*a*A+100*b*B+c*C+d*D<=F; ++d)
        {
          check(a, b, c, d);
        }
      }
    }
  }


  cout<<rst.st+rst.nd<<" "<<rst.nd;
}

int32_t main()
{
ios_base::sync_with_stdio(0); cin.tie(NULL);
cout<<fixed<<setprecision(10);

  solve();

return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<cstdint>
using namespace std;

int main()
{
  uint64_t n, d;

  cin >> n >> d;

  cout << (n - 1) / (2 * d + 1) + 1 << endl;

  return 0;
}



Measured memory_bytes: 256
/*
Problem: guruguru (AtCoder 2650)
Algorithm: Math/Difference
Status:
*/

/*
f(s,e,x)=
	s=e:{
		0
	}
	
	s<e:{
		e-s     x<=s
		e-x+1   s<x<=e
		e-s     e<x
	}
	
	s>e:{
		e-x+1   x<=e
		m-s+e   e<x<=s
		m-x+e+1 s<x
	}
*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <utility>
#include <list>
#include <ctime>
#include <memory.h>
#include <stack>
#include <stdio.h>
#include <string.h>

using namespace std;

#define INF 1000000000000000000
typedef long long ll;

int n,m;
int a[100005];
ll b[100005];
ll k[100005];

void addb(int x,int y,ll z){
	if(x>y)return;
	b[x]+=z;
	b[y+1]-=z;
}

void addk(int x,int y,ll z){
	if(x>y)return;
	k[x]+=z;
	k[y+1]-=z;
}

int main()
{
	#ifndef ZZZYT
		//freopen(".in","r",stdin);
		//freopen(".out","w",stdout);
	#endif
	
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
	}
	for(int i=1;i<n;i++){
		int s=a[i];
		int e=a[i+1];
		if(s==e){
			
		}
		else if(s<e){
			addb(1,s,e-s);
			addb(s+1,e,e+1);
			addb(e+1,m,e-s);
			
			addk(s+1,e,-1);
		}
		else{
			addb(1,e,e+1);
			addb(e+1,s,m-s+e);
			addb(s+1,m,m+e+1);
			
			addk(1,e,-1);
			addk(s+1,m,-1);
		}
	}
	for(int i=1;i<=m;i++){
		b[i]+=b[i-1];
		k[i]+=k[i-1];
	}
	
	ll ans=INF;
	for(ll x=1;x<=m;x++){
		ans=min(ans,b[x]+k[x]*x);
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 2176
import java.util.*;
import java.math.BigDecimal;

class Main {
    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        BigDecimal a, b, c, d, e, f;

        while(true){
            try {
                a = new BigDecimal(sc.next());
                b = new BigDecimal(sc.next());
                c = new BigDecimal(sc.next());
                d = new BigDecimal(sc.next());
                e = new BigDecimal(sc.next());
                f = new BigDecimal(sc.next());
            } catch (NoSuchElementException ex) {
                break;
            }


            BigDecimal det = a.multiply(e).subtract(b.multiply(d));
            BigDecimal x = (c.multiply(e).subtract(b.multiply(f))).divide(det, 3, BigDecimal.ROUND_HALF_UP);
            BigDecimal y = (a.multiply(f).subtract(c.multiply(d))).divide(det, 3, BigDecimal.ROUND_HALF_UP);

            System.out.print(x);
            System.out.print(" ");
            System.out.println(y);
        }

    }
}

Measured memory_bytes: 12000
from itertools import product


def solve(string):
    h, w, *s = string.split()
    h, w = int(h), int(w)
    s = ["#" * (w + 2)] + ["#" + _s + "#" for _s in s] + ["#" * (w + 2)]
    ans = 0
    d = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    for _h, _w in product(range(1, h + 1), range(1, w + 1)):
        if s[_h][_w] == "#":
            continue
        q = list()
        for x, y in d:
            if s[_h + x][_w + y] == ".":
                q.append((_h + x, _w + y, _h, _w))
        if len(q) > 2:
            continue
        c = [[h * w] * (w + 2) for _ in range(h + 2)]
        c[_h][_w] = 0
        while q:
            cx, cy, px, py = q.pop()
            if c[px][py] + 1 >= c[cx][cy]:
                continue
            c[cx][cy] = c[px][py] + 1
            for x, y in d:
                nx = cx + x
                ny = cy + y
                if s[nx][ny] == ".":
                    q.append((nx, ny, cx, cy))
        for i, j in product(range(1, h + 1), range(1, w + 1)):
            ans = max(ans, c[i][j] * (s[i][j] == "."))
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    if ((a + b) >= c) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}

Measured memory_bytes: 35828
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a = sorted(LI())

    return a[0] * a[1] // 2



print(main())




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

bool has_black(string s) {
  for (char c: s) 
    if (c == '#') return true;
  
  return false; 
}

int main() {
  int h, w;
  cin >> h >> w;

  vector<bool> mh(h, false);
  vector<bool> mw(w, false);
  
  vector<string> g(h);
  for (int i = 0; i < h; i++) {
    cin >> g[i];

    if (has_black(g[i])) {
      mh[i] = true;
    }
  }

  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
      if (g[j][i] == '#') mw[i] = true;
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) 
      if (mh[i] && mw[j]) cout << g[i][j];
    
    if (mh[i]) cout << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int n;
int p[21];

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

  cin >> n;
  REP(i,n) cin >> p[i];
  int ans = 0;
  for (int i = 1; i < n-1; i++) {
    if (p[i] > max(p[i-1],p[i+1]) || p[i] < min(p[i-1],p[i+1])) continue;
    ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int H,W; cin >> H >> W;
    int c[10][10];
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin >> c[i][j];
        }
    }
    vector<int> a(10);
    a[0]=0;
    for(int i=0;i<=9;i++){
        vector<int> d(10,INF);
        d[i]=0;
        priority_queue<pair<int,int>, vector<pair<int,int>>,greater<pair<int,int>>> q;
        q.push(make_pair(0,i));
        int cnt=0;
        while(!q.empty()){
            cnt++;
            pair<int,int> p = q.top();
            q.pop();
            int v = p.second;
            for(int j=0;j<10;j++){
                if(d[j]>d[v]+c[v][j]){
                    d[j] = d[v]+c[v][j];
                    q.push(make_pair(d[j],j));
                }
            }
        }/*
        cerr << "\ncnt=" << cnt << "\t" << i << ":\n";
        for(int j=0;j<=9;j++){
            cerr << d[j] << "\t";
        }*/
        a[i] = d[1];
    }
    ll out=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int A;
            cin >> A;
            if(A!=-1){
                out += a[A];
            }
        }
    }
    cout << out << endl;
    return 0;
}


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

int main() {
  int h,w,n;
  cin >> h >> w >> n;
  cout<<(n+max(h,w)-1)/(max(h,w))<<endl;
}


Measured memory_bytes: 764
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string s;
	string j;
	cin >> s;
	cin >> j;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != j[i]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

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

int main(){
    int i, a, n;
    cin >> n;
    int pmin = n;
    int cnt = 0;
    for(i=0; i<n; i++){
        cin >> a;
        pmin = min(a, pmin);
        if(pmin == a) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    boolean[] hasSweets = new boolean[N+1];
    for (int i = 0; i < K; i++) {
      int d = sc.nextInt();
      for (int j = 0; j < d; j++) hasSweets[sc.nextInt()] = true;
    }
    int ans = 0;
    for (boolean h : hasSweets) if (!h) ans++;
    System.out.println(ans-1);
  }
}

Measured memory_bytes: 37316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;
const int inf = 1e9;
vector<ll>h, ans;

ll recc(int n) {
  if(ans[n] != -1)
    return ans[n];
  if(n == 0)
    return 0;
  if(n < 0)
    return inf;
  return ans[n] = min(recc(n-1) + abs(h[n] - h[n-1]), recc(n-2) + abs(h[n] - h[n-2]));

}

void solve(){
  int n;
  cin >> n;
  h.resize(n, 0);
  ans.resize(n, -1);
  for(int i = 0; i < n; i++) cin >> h[i];
  ans[0] = 0;
  ll anss = recc(n-1);

  /*
  ans[0] = 0;
  ans[1] = abs(h[0]-h[1]);
  for(int i = 2; i < n; i++) {
    ans[i] = min(ans[i],  ans[i-1] + abs(h[i]-h[i-1]));
    ans[i] = min(ans[i],  ans[i-2] + abs(h[i]-h[i-2]));
  }
  for(int &i : ans) cout << i << ' ';
  cout << endl;
  */
  cout << anss << endl;
}

int main(){
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		int t = 1, tt = 0;
		//cin >> t;
		while(t--){
			//tt++;
			//cout << "Case #" << t << ": ";
			solve();
		}
	return 0;
}


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

int X, Y, S;

int main() {
  while (cin >> X >> Y >> S) {
    if (X == 0) break;
    int Max = -1;
    for (int i = 1; i <= S-1; ++i) {
      for (int j = i; j <= S-1; ++j) {
	int pi = i + i*X/100;
	int pj = j + j*X/100;
	if (pi + pj != S) continue;
	int npi = i + i*Y/100;
	int npj = j + j*Y/100;
	if (npi + npj > Max) Max = npi + npj;
      }
    }
    cout << Max << endl;
  }
}


Measured memory_bytes: 1160
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    sort(all(a));reverse(all(a));
    ll ans=0;
    if(n%2==0){
        for(ll i=0;i<n/2-1;i++)ans+=a[i]*2;
        ans+=a[n/2-1];
        ans-=a[n/2];
        for(ll i=n/2+1;i<n;i++)ans-=a[i]*2;
    }
    else{
        for(ll i=0;i<n/2-1;i++)ans+=a[i]*2;
        ans+=a[n/2-1]+a[n/2];
        for(ll i=n/2+1;i<n;i++)ans-=a[i]*2;
        
        ll ans2=0;
        for(ll i=0;i<n/2;i++)ans2+=a[i]*2;
        ans2-=a[n/2+1]+a[n/2];
        for(ll i=n/2+2;i<n;i++)ans2-=a[i]*2;
        chmax(ans,ans2);
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------









Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
 
using namespace std;
 
 
int main(void)
{
	int n=0,ans=0;
	for(int i=0; i<10; i++)
	{
		cin>>n;
		ans+=n;
	}

	cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1160