akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdint>

using i64 = std::int64_t;

i64 gcd(i64 a, i64 b) {
	return (b == 0 ? a : gcd(b, a % b));
}

int main() {
	i64 a, b;
	std::cin >> a >> b;

	std::cout << a / gcd(a, b) * b << std::endl;
}

Measured memory_bytes: 256
q,h,s,d = map(int, input().split())
N = int(input())
min2 = min(8*q, 4*h, 2*s, d) # 2[l]
min1 = min(4*q, 2*h, s)      # 1[l]
ans = min2*(N//2)
if N%2!=0:
    ans += min1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
int n,ans=0,tot;
int num[300010];
struct node{
	int maxx,cmax;
}a[300010];
void chan(int x,int pos){
	if(x==a[pos].cmax || x==a[pos].maxx)  return ;
	if(num[x]>num[a[pos].maxx]){
		a[pos].cmax=a[pos].maxx;a[pos].maxx=x;
	}
	else{
		if(num[x]>num[a[pos].cmax])  a[pos].cmax=x;
	}
}
int main(){
	scanf("%d",&n);
	int i,j;
	tot=(1<<n);num[tot]=0;
	for(i=0;i<tot;++i){
		scanf("%d",&num[i]);a[i].maxx=i;a[i].cmax=tot;
	}
	for(i=1;i<tot;++i){
		for(j=0;j<n;++j){
			if(i&(1<<j)){
				int tt=i^(1<<j);
				chan(a[tt].maxx,i);
				chan(a[tt].cmax,i);
			}
		}
	}
	ans=0;
	for(i=1;i<tot;++i){
		ans=max(ans,num[a[i].maxx]+num[a[i].cmax]);
		printf("%d\n",ans);
	}	
	return 0;
}

Measured memory_bytes: 6144
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

static size_t A[100000];

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) > *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static char S[100001];

int main(void) {
	gets(S);

	const char sList[][8] = { "dream","dreamer","erase","eraser" };

	while (0 < strlen(S)) {
		const size_t len = strlen(S);
		bool matched = false;
		for (size_t listIdx = 0; listIdx < sizeof(sList) / sizeof(sList[0]); listIdx++) {
			const size_t cLen = strlen(sList[listIdx]);

			if (cLen <= len) {
				if (strcmp(&S[len - cLen], sList[listIdx]) == 0) {
					S[len - cLen] = '\0';
					matched = true;
					break;
				}
			}
		}

		if (!matched) {
			break;
		}
	}

	puts((0 < strlen(S) ? "NO" : "YES"));

	return 0;
}


Measured memory_bytes: 256
def Sol(arr):
    
    print(len(set(arr)))
    return

    

#for t in range(int(input())):
#n,k,d,c = map(int,input().split())
n = int(input())
arr = []
for i in range(n):
    arr.append(input())
#arr = list(map(int,input().split()))
#k = input()
#n = int(input())
Sol(arr)


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

#define mp make_pair
#define X first
#define Y second
#define FOE(x, a) for(auto x : a)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FOD(i, a, b) for(int i = a; i >= b; i--)

using namespace std;

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

const int N = 101;
const int X = 510;
const int MOD = 1e9 + 7;

int n, x, d[X];
int F[X][X][X], C[X][X];

void add(int &x, int y){
    x += y;
    x -= (x >= MOD) * MOD;
}

void sub(int &x, int y){
    x -= y;
    x += (x < 0) * MOD;
}

int powMod(int n, int k){
    assert(n >= 0);
    if (k == 0)
        return 1;
    int res = powMod(n, k >> 1);
    res = (ll) res * res % MOD;
    if (k & 1)
        res = (ll) res * n % MOD;
    return res;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> x;
    FOR(i, 1, n){
        int l;
        cin >> l;
        d[l]++;
    }

    FOR(i, 0, x){
        C[i][0] = 1;
        FOR(j, 1, i){
            add(C[i][j], C[i - 1][j]);
            add(C[i][j], C[i - 1][j - 1]);
        }
    }

    F[x + 1][0][0] = 1;
    FOD(i, x + 1, 0)
        FOR(j, 0, x)
            FOR(s, j * i, x){
                F[i][j][s] = (ll) F[i][j][s] * powMod(s - i * j + j, d[i]) % MOD;
                if (i > 0)
                    FOR(k, 0, x - j){
                        if (s + k * (i - 1) > x)
                            break;
                        add(F[i - 1][j + k][s + k * (i - 1)], (ll) F[i][j][s] * C[j + k][k] % MOD);
                    }
            }

    int ans = 0;
    FOR(i, 0, x - 1){
        int val = F[0][i + 1][x - i];
        if (i & 1)
            sub(ans, val);
        else
            add(ans, val);
    }

    cout << ans;

    return 0;
}



Measured memory_bytes: 14948
N = int(input())
button = list()
for i in range(N):
    button.append(int(input()))

pre  = 1
# print(button)
i = 0
c = 1
rireki = [0]*N
while all: 
    if(button[i]==2):
        print(c)
        break
    rireki[i] +=1
    if(rireki[i]==2):
        print(-1)
        break
    i = button[i]-1
    c+=1

Measured memory_bytes: 7956
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    int cnt = 0;
    while (n != 0) {
        if (n % 10 == 7) {
            ++cnt;
        }
        n /= 10;
    }
    if (cnt > 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int l;
    cin >> l;
    // スペース区切りの整数の入力
    int r,kari;
    cin >> r ;
  if(r - l +1 > 2019){
    cout<<0;
	}else{
  
  int co = 2019;
    // 文字列の入力
   	for (long long i = l; i < r; i++) {
		for (long long j = i+1; j <= r; j++) {
		 kari = (i*j) % 2019;
             if(co > kari) co = kari;
		}
	}
    // 出力
    cout<<co;
  }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 * 0002：Digit Number
 * 
 * @author MS14A
 * @version 2015/07/11
 */
public class Main {

    /**
     * 与えられた２つの整数 a と b の和の桁数を出力する。
     * 
     * @param args
     * @throws IOException 
     * @throws NumberFormatException 
     */
    public static void main(String[] args) throws NumberFormatException, IOException {

        List<Integer> a = new ArrayList<Integer>();
        List<Integer> b = new ArrayList<Integer>();

        getTarget(a, b);
        
        for (int i = 0; i < a.size(); ++i) {
            System.out.println(getDigitNumber(a.get(i)+b.get(i)));
        }

    }

    private static int getDigitNumber(int target) {
        return String.valueOf(target).length();
    }

    private static void getTarget(List<Integer> a, List<Integer> b) throws NumberFormatException, IOException {
        // 入力読取り
        InputStreamReader streamReader = new InputStreamReader(System.in);
        BufferedReader bufferedReader = new BufferedReader(streamReader);

        String line = null;

        try {
            while ((line = bufferedReader.readLine()) != null) {
                String[] ab = line.split(" ");
                a.add(Integer.parseInt(ab[0]));
                b.add(Integer.parseInt(ab[1]));
            }

        } finally {
            bufferedReader.close();
            streamReader.close();
        }

    }

}

Measured memory_bytes: 17016
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int h,a;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>h>>a;
	cout<<h/a+(h%a!=0)<<endl;
	return 0;
}


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

int main(){
    int alice = 0;
    int bob = 0;
    int N;
    int a[110];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    sort(a, a + N, greater<int>());
    for(int i = 0; i<N; i++){
        if(i%2 == 0){
            alice += a[i];
        }
        else{
            bob += a[i];
        }
    }
    cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
#define mp make_pair

struct point{
  double x,y;
  point(){x=y=0.0;}
  point(double a,double b):x(a),y(b){}
};
struct circle{
  point center;
  double radius=1e6;
};

circle circlewiththreepoints(point pa,point pb,point pc){
  double x1 = pa.x, y1 = pa.y;
  double x2 = pb.x, y2 = pb.y;
  double x3 = pc.x, y3 = pc.y;
  double x12 = x1 - x2; 
  double x13 = x1 - x3; 
  double y12 = y1 - y2; 
  double y13 = y1 - y3; 
  double y31 = y3 - y1; 
  double y21 = y2 - y1; 
  double x31 = x3 - x1; 
  double x21 = x2 - x1; 
  // x1^2 - x3^2 
  double sx13 = pow(x1, 2.0) - pow(x3, 2.0); 

  // y1^2 - y3^2 
  double sy13 = pow(y1, 2.0) - pow(y3, 2.0); 

  double sx21 = pow(x2, 2.0) - pow(x1, 2.0); 
  double sy21 = pow(y2, 2.0) - pow(y1, 2.0); 

  double f = ((sx13) * (x12) 
              + (sy13) * (x12) 
              + (sx21) * (x13) 
              + (sy21) * (x13)) 
    / (2.0 * ((y31) * (x12) - (y21) * (x13))); 
  double g = ((sx13) * (y12) 
              + (sy13) * (y12) 
              + (sx21) * (y13) 
              + (sy21) * (y13)) 
    / (2.0 * ((x31) * (y12) - (x21) * (y13))); 

  double c = -pow(x1, 2.0) - pow(y1, 2.0) - 2.0 * g * x1 - 2.0 * f * y1; 

  // eqn of circle be x^2 + y^2 + 2*g*x + 2*f*y + c = 0 
  // where centre is (h = -g, k = -f) and radius r 
  // as r^2 = h^2 + k^2 - c 
  double h = -g; 
  double k = -f; 
  double sqr_of_r = h * h + k * k - c; 

  // r is the radius 
  double r = sqrt(sqr_of_r); 

  circle res;
  res.center = point(h,k);
  res.radius = r;
  return res;
}

double dist(point a,point b){
  return sqrt(pow(a.x-b.x,2.0)+pow(a.y-b.y,2.0));
}

circle circlewithtwopoints(point pa,point pb){
  circle res;
  res.center = point((pa.x+pb.x)/2.0,(pa.y+pb.y)/2.0);
  res.radius = dist(pa,pb)/2.0;
  return res;
}

signed main(){
  int n;
  cin>>n;
  vector<point> P(n);
  for(int i=0;i<n;++i){
    cin>>P[i].x>>P[i].y;
  }
  circle dres;
  if(n==2)return cout<<circlewithtwopoints(P[0],P[1]).radius,0;
  for(int i=0;i<n-2;++i){
    for(int j=i+1;j<n-1;++j){
      circle dt=circlewithtwopoints(P[i],P[j]);
      vector<bool> outer(n,false);
      bool f=false;
      for(int h=0;h<n;++h){
        if(h==i||h==j)continue;
        if(dist(dt.center,P[h])>dt.radius)outer[h]=f=true;
      }
      if(!f)return cout<<setprecision(15)<<dt.radius,0;
      circle ds;
      ds.radius=0.0;
      for(int k=0;k<n;++k){
        if(!outer[k])continue;
        circle dr=circlewiththreepoints(P[i],P[j],P[k]);
        if(ds.radius<dr.radius){
          ds=dr;
          bool g=false;
          for(int h=0;!g&&h<n;++h){
            if(h==i||h==j||h==k)continue;
            if(dist(ds.center,P[h])>ds.radius)g=true;
          }
          if(!g&&dres.radius>ds.radius)dres=ds;
        }
      }
    }
  }
  cout<<setprecision(15)<<dres.radius;
}


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

//ABC 081 B
int main()
{
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1; i<=n; i++){
		cin>>a[i];
	}
	int x=0,f=1;
	while(1){
		for(int i=1; i<=n; i++){
			if(a[i]%2==0){
				a[i]/=2;
			}else{
				f=0;
				break;
			}
		}
		if(f==1){
			x++;
		}else{
			break;
		}
	}
	cout<<x<<endl;
	
	return 0;
}

Measured memory_bytes: 256
# coding:utf-8

S = list(input())
T = list(input())

# 英小文字のペアについて相互変換するので、同じ文字について２種類の変換はできない
# よって、異なる位置に同一種類の英小文字がでてきて、対応する文字列の文字がそれぞれ違うとき変換できない
# a~zの英小文字について、変換が必要かのフラグをつくる(0:変換なし, 1以上:返還あり)
#convList = [[0 for i in range(26)] for j in range(26)]
convList = [0] * 26

ans = 'Yes'


# 文字列SとTの同一位置で異なる文字をとりだし、異なる文字だったら変換が必要と判定
# 同一の変換組み合わせがもう一度でてきたら、循環していまい、一致させられない
for i in range(len(S)):
    charNo = ord(S[i]) - 97
    matchNo = ord(T[i]) - 97
    if S[i] != T[i]:
        for j in range(len(S)):
            if ord(S[j]) - 97 == charNo:
                # すでに一致している文字であった場合は循環してしまうため、一致できなくなる
                if S[j] == T[j]:
                    ans = 'No'
                    break
                S[j] = chr((matchNo + 97))

            elif ord(S[j]) - 97 == matchNo:
                # すでに一致している文字であった場合は循環してしまうため、一致できなくなる
                if S[j] == T[j]:
                    ans = 'No'
                    break

                S[j] = chr((charNo + 97))


        #print(S)
        #print(T)

        # すでに同じ変換をしていた場合、循環してしまい、一致できない
        # if convList[charNo] == matchNo or convList[matchNo] == charNo:
        #     #print("No: %d, S: %s, T %s" % (i, S[i], T[i]))
        #     ans = 'No'
        #     break


        convList[charNo] = matchNo
        convList[matchNo] = charNo

print(ans)

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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
//const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
int MOD = 998244353;
const int e5 = (int) 1e5 + 5;
const int maxn = (int) 1e5 + 20;
const int maxm = (int) 1e6 + 20;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL mod = MOD)
{
    if(n < 0) a = fp(a, mod - 2, mod), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % mod) if(n & 1) res = res * a % mod; return res;
}

struct Mint
{
    LL x;
    Mint() {x = 0;}
    Mint(int _x): x(_x) {}
    Mint(LL _x): x(_x) {}
    Mint operator - () const{
        return Mint(MOD - x);
    }
    Mint operator + (const Mint &rhs) const{
        LL res = x + rhs.x; if(res >= MOD) res -= MOD; return Mint(res);
    }
    Mint operator - (const Mint &rhs) const{
        LL res = x - rhs.x; if(res < 0) res += MOD; return Mint(res);
    }
    Mint operator * (const Mint &rhs) const{
        return Mint(x * rhs.x % MOD);
    }
    Mint operator / (const Mint &rhs) const{
        return Mint(x * fp(rhs.x, -1) % MOD);
    }
    Mint& operator += (const Mint &rhs) {
        x += rhs.x; if(x >= MOD) x -= MOD; return *this;
    }
    Mint& operator *= (const Mint &rhs) {
        x = (x * rhs.x) % MOD; return *this;
    }
    bool operator == (const Mint &rhs) const{
        return x == rhs.x;
    }
    bool operator != (const Mint &rhs) const{
        return x != rhs.x;
    }
    friend ostream& operator << (ostream &out, const Mint &rhs){
        return out << rhs.x;
    }
    friend istream& operator >> (istream &in, Mint &rhs){
        return in >> rhs.x;
    }
};

void work()
{
    int x; read(x);

    while(x)
    {
        if(x % 10 == 7)
        {
            cout <<"Yes";
            return ;
        }
        x /= 10;
    }
    cout <<"No";
}

int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
//    pre();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner
import java.lang.Math.*
import kotlin.system.exitProcess

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val k = scn.nextInt()
	if (k<=12) {
		println(k)
		exitProcess(0)
	}
	var cnt = 9
	var dig = 2
	while(true){
		cnt = cur(k, dig, cnt)
		dig++
	}
}

fun cur(k: Int, dig: Int, cnt: Int, num: IntArray = IntArray(dig){-1}, iDig: Int = 0): Int {
	var newCnt = cnt
	val range = when(iDig){
		0 -> 1..9
		else -> max(num[iDig-1]-1, 0)..min(num[iDig-1]+1, 9)
	}
	if (iDig!=dig-1){
		for (d in range){
			num[iDig] = d
			newCnt = cur(k, dig, newCnt, num, iDig+1)
		}
	}else {
		newCnt += range.count()
		if (newCnt>=k) {
			num[num.lastIndex] = range.toList()[k-cnt-1]
			println(num.joinToString(separator = ""))
			exitProcess(0)
		}
	}
	return newCnt
}

Measured memory_bytes: 35916
n=int(input())
h=list(map(int,input().split()))
cnt=0
for i in range(1,101):
    if h[0]>=i:
        cnt+=1
    for j in range(n-1):
        if h[j]<i:
            if h[j+1]>=i:
                cnt+=1

print(cnt)


Measured memory_bytes: 38896
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define All(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(int, k, x);

  int cnt = 0;
  for (int i = x - k + 1; i < x + k; ++i) {
    if (cnt++) cout << " ";
    cout << i;
  }
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <unordered_set>
#include <cmath>
#include <queue>
#include <stdio.h>

using namespace std;
using ll = long long;
using ld = long double;
template <class T> using vec = std::vector<T>;
template <class T> using vvec = std::vector<std::vector<T>>;

#define REP(i, s, e) for (ll i = s; i < e; ++i)

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

    int N; cin >> N;
    int r = 0;
    REP(i, 1, N + 1)
    {
        int c = 1;
        int n = i;
        while ((n /= 10) != 0) ++c;
        if (c % 2 != 0) ++r;
    }

    cout << r << endl;

    return 0;
}


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

int main() {
    ll a,b,n;
    cin >> a >> b >> n;
    ll s = b-1;
    if(s>n) s=n;
    cout << s*a/b << endl;
    return 0;
}

Measured memory_bytes: 3568
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t 
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]

N,K = I()
A = I()
if K>N:
    K=N
if N == K:
    print(0)
else:
    print(sum(sorted(A)[:N-K]))


Measured memory_bytes: 28932
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m4 = 0;
        int m2 = 0;
        int ot = 0;
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            if (a % 4 == 0) {
                m4++;
            } else if (a % 2 == 0) {
                m2++;
            } else {
                ot++;
            }
        }

        m4 -= ot;
        if (m4 <= -2) {
            System.out.println("No");
        } else if (m4 == -1 && m2 > 0) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 48184
X,K,D = map(int,input().split())
X = abs(X)
num = X//D
if num >= K:
  ans = X-K*D
  print(ans)
  exit()
a = X%D
b = abs(a-D)
if (K - num)%2 == 0:
  ans = a
else:
  ans = b
print(ans)

  


Measured memory_bytes: 9176
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math

def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):
        if serial >= sqrt:
            return input_list
        for s in range(serial ** 2, num, serial): 
            input_list[s] = False

primeTable = sieve_of_erastosthenes((10**6))

while True:
    n = int(input())
    if n == 0:
        break
    print(sum([1 if primeTable[i] == True else 0 for i in range(n+1,2*n+1)]))

Measured memory_bytes: 16288
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define ll long long
#define cases ll t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)


int main(){
    fast;
    ll i,j,k,n,l,r,m;
    cin>>n;
    vector<ll> v(n+1,0);
    for(i=1;i<n;i++){
        cin>>k;
        v[k]++;
    }
    for(i=1;i<=n;i++) cout<<v[i]<<"\n";

    return 0;
}



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

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7

def f():
    n,a,b = list(map(int, input().split()))
    r = 0
    for _ in range(n):
        t = int(input())
        if t < a or t >= b:
            r += 1
    return r

print(f())


Measured memory_bytes: 7840
#include<stdio.h>
int main()
{
    int a,b,c,ans1,ans2,max;
    scanf("%d%d%d",&a,&b,&c);
    if(a>=b && a>=c) {
    ans1=abs(a-b)+abs(b-c);
    ans2=abs(a-c)+abs(c-b);
    }
    else if(b>=a && b>=c) {
    ans1=abs(b-a)+abs(a-c);
    ans2=abs(b-c)+abs(c-a);
    }
    else if(c>=b && c>=a) {
    ans1=abs(c-a)+abs(a-b);
    ans2=abs(c-b)+abs(b-a);
    }
    if(ans1>ans2) {
        printf("%d\n",ans2);
    }
    else {
        printf("%d\n",ans1);
    }
    return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<algorithm>
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<<#X<<": "<<X<<" ";
#define ARDEB(i,X) cout<<#X<<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(X) {}
#define END {}
#endif
using namespace std;
int main(){
	/*int n,a[2001];
	int m,c[1001];
	cin>>n>>m;
	for(int i=0;i<n*2;i++)a[i]=i+1;
	/*for(int i=0;i<m;i++){
		cin>>c[i];
		if(c[i]==0){
			
			}
		}
	}
	for(int j=1;j<n;j++){
		swap(a[j],a[n+j-1]);
		for(int j=0;j<n*2;j++)cout<<a[j]<<" ";
		cout<<endl;
		swap(a[n+j-1],a[j+1]);
		for(int j=0;j<n*2;j++)cout<<a[j]<<" ";
		cout<<endl;
		swap(a[j+2],a[j+3]);
		for(int j=0;j<n*2;j++)cout<<a[j]<<" ";
		cout<<endl;
	}
	for(int j=0;j<n*2;j++)cout<<a[j]<<" ";*/
	int a;
	cin>>a;
	cout<<"ABC"<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
L=[]

for i in range(M):
    L.append(list(map(int,input().split())))
P=list(map(int,input().split()))
ans=0

def check(D):
    ret=True
    for i in range(M):
        l=L[i][1:]
        tmp=0
        for l_ in l:
            tmp+=(D>>(l_-1))&1
        if tmp%2!=P[i]:
            ret=False
            break

    return ret


for d in range(2**N):
    if check(d):
        ans+=1


print(ans)

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

int main() {
  int n;
  cin >> n;
  
  if ((n % 1000) % 111 == 0) {
    cout << "Yes" << endl;
  }
  else if ((n / 10) % 111 == 0) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

int func(int n, int k, int s, int count, int pre) {
  if (k == 0 && s == 0) return ++count;
  if (k == 0 && s != 0) return count;
  for (int i = pre+1; i <= n; i++) {
    count = func(n, k-1, s-i, count, i);
  }
  return count;
}

int main() {
  int n, k ,s;
  while (cin >> n >> k >> s, n | k | s) {
    cout << func(n, k ,s, 0, 0) << el;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
const int inf=100000;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;
int main() 
{
	int x,n;
	cin>>x>>n;
	vector<int> p(n);
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
	}
	//答え
	int ans=inf;
	//直前の最小値
	int pre=inf;
	bool flag=true;
	for(int i=-2;i<=200;i++)
	{
		flag=true;
		for(int j=0;j<n;j++)
		{
			if(i==p[j]) flag=false;
		}
		if(flag)
		{
			if(pre==abs(x-i)&&ans==i)
			{
				ans=min(ans,i);
			}
			else if(pre>abs(x-i))
			{
				ans=i;
				pre=abs(x-i);
			}
			
		}
	}
	if(n==0) cout<<x<<endl;
	else cout<<ans<<endl;
	return 0;
}



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

int main()
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  
  std::string s,t;
  std::cin>>s>>t;
  
  int result=0;
  
  for(int i=0;i!=s.size();i++)
  {
    if(s[i]!=t[i])
      result++;
  }
  
  std::cout<<result<<std::endl;
  
  return 0;
}

Measured memory_bytes: 3812
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++){for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << p.first << " " << p.second;}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){for(auto &z:v)os << z << " ";cout<<"|"; return os;}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll k;cin>>k;
  ll n;
  vector<vector<ll>>v;
  if(k<=3){
    n=k;
    v=vec(k,k,0LL);
    rep(i,0,n)rep(j,0,n)v[i][j]=j+1;
  }
  else{
    n=((k+1)/2+3)/4*4;
    v=vec(n,n,0LL);
    rep(i,0,n)rep(j,0,n){
      if(~i&1)v[i][j]=(i+j)%n+1;
      else v[i][j]=(i+j)%n+n+1;
      if(v[i][j]>k)v[i][j]-=n;
    }
  }
  cout<<n<<endl;
  debug(v,n,n);
  return 0;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
struct Edge {
    ll to, cost;
};

class Dijkstra {
    ll vector_count;

    vector<ll> distances;
    vector<vector<Edge>> edges;

public:
    Dijkstra(ll n) {
        vector_count = n;
        distances.resize(n, INF);
        edges.resize(n);
    }

    void insertTowWay(ll from, ll to, ll cost) {
        edges[from].push_back({to, cost});
        edges[to].push_back({from, cost});
    }

    void insert(ll from, ll to, ll cost) {
        edges[from].push_back({to, cost});
    }

    void dijkstra(ll k) {
        distances[k] = 0;  // 始点sへの最短距離は0

        priority_queue<P, vector<P>, greater<P>> que;  // 距離が小さい順に取り出せるようgreater<P>を指定
        que.push(P(0, k));
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;  // 更新した頂点の中で距離が最小の頂点v
            if (distances[v] < p.first) {
                continue;
            }
            for (auto e : edges[v]) {  // 頂点vから出る辺eを走査
                if (distances[e.to] > distances[v] + e.cost) {
                    distances[e.to] = distances[v] + e.cost;
                    que.push(P(distances[e.to], e.to));
                }
            }
        }
    }

    ll distance(ll to) {
        return distances[to];
    }

};


int main() {
    int v, e, r;
    cin >> v >> e >> r;

    Dijkstra dijkstra(v);

    rep(i, e) {
        ll s, t, d;
        cin >> s >> t >> d;

        dijkstra.insert(s, t, d);

    }

    dijkstra.dijkstra(r);

    rep(i, v) {
        ll ans = dijkstra.distance(i);
        if (ans == INF)cout << "INF" << endl;
        else cout << ans << endl;
    }

}





Measured memory_bytes: 19432
def main():
    N, M = map(int, input().split())
    A = [int(input()) for i in range(M)] + [0]

    a = 0
    b = 1
    j = 0
    tmp = 0
    if N == 1:
        print(1)
    else:
        for i in range(1, N + 1):
            if A[j] == i:
                if tmp == 1:
                    print(0)
                    exit()
                tmp = 1
                j += 1
                a = 0
            else:
                if tmp == 1:
                    b = a + b
                    a = 0
                else:
                    c = a + b
                    a = b
                    b = c
                tmp = 0
        print(b % 1000000007)

if __name__ == '__main__':
    main()


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

int A,B;

int main(){
   cin>>A>>B;
   if(A-1>B)cout<<2*A-1<<endl;
   else if(B-1>A)cout<<2*B-1<<endl;
   else cout<<A+B<<endl;
}


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

using namespace std;
int dp[1 << 25], bef[1 << 25];
int main() {
    int n, m, i, j, k;
    while(cin >> n >> m, n) {
        string s[n];
        int bit[n] = {};
        for(i = 0; i < n; i++) {
            cin >> s[i];
            if(n > 20) {
                for(j = 0; j < m; j++) {
                    bit[i] <<= 1;
                    bit[i] += s[i][j] - '0';
                }
            }
        }
        int ret = 0;
        if(n <= 20) {
            // 全探索
            for(i = 0; i < 1 << n; i++) {
                int x[m] = {};
                int cnt = 0;
                for(j = 0; j < n; j++) {
                    if(i >> j & 1) {
                        cnt++;
                        for(k = 0; k < m; k++) {
                            if(s[j][k] == '1') x[k] ^= 1;
                        }
                    }
                }
                int flag = 0;
                for(j = 0; j < m; j++) {
                    if(x[j] == 1) flag = 1;
                }
                if(flag == 0) {
                    ret = max(ret, cnt);
                }
            }
        } else {
            // bitナップサック
            //int dp[n+2][1 << m];
            for(i = 0; i < 1 << m; i++) {
                dp[i] = -1;
            }
            dp[0] = 0;
            for(i = 0; i < n; i++) {
                for(j = 0; j < 1 << m; j++) {
                    bef[j] = dp[j];
                }
                for(j = 0; j < 1 << m; j++) {
                    if(bef[j] == -1) continue;
                    dp[j] = max(bef[j], dp[j]);
                    dp[j ^ bit[i]] = max(dp[j ^ bit[i]], bef[j] + 1);
                }
            }
            ret = dp[0];
        }
        cout << ret << endl;
    }
}


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

int main(){
  int K,S;
  cin >> K >> S;
  int sum=0;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      if(0<=(S-i-j) && (S-i-j)<=K)sum++;
    }
  }
  cout << sum;
}

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

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define debug(x) cerr << "x is "<<x <<" "

using ll = long long;
using pll = pair<ll,ll>;
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 1e9+7, N = 1e5 + 10;

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	//#endif
	int a,p;
	cin >> a >> p;
	ll s = a*3+p;
	cout << s/2 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
const int MAX_C = 1000000;
int N;
int a[20];
int Q;
int q[2000];
int c[MAX_N+1];

// combination
int flg[20];

void calc(){
	int ret = 0;
	rep(i, N) {
		if (flg[i] == 1) ret += a[i];
	}
	c[ret]=1;
	// fprintf(stderr, "%d\n", ret);
}

void dfs(int i){
	if (i == N) {calc(); return;}
	flg[i] = 0; dfs(i+1);
	flg[i] = 1; dfs(i+1);
}

void dfs_run(){
	rep(i, N) { flg[i] = 0; }
	dfs(0);
}

int main() {

	cin >> N;
	rep(i, N) cin >> a[i];
	cin >> Q;
	rep(i, Q) cin >> q[i];
	// fprintf(stderr, "%d %d \n", N, Q);

	rep(i, MAX_N+1){c[i]=0;}

	dfs_run();

	rep(i, Q){
		if(c[q[i]] == 0) { cout << "no" << endl;}
		else {cout << "yes" << endl; }
	}

}

Measured memory_bytes: 7016
n, m = map(int, input().split())
h = list(map(int,input().split()))
A = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    A[a - 1] = max(A[a - 1], h[b - 1]) #ある展望台とつながる別の展望台の標高の最大値を更新
    A[b - 1] = max(A[b - 1], h[a - 1])
ans = 0
for i in range(n):
    if A[i] < h[i]:
        ans += 1
print(ans)

Measured memory_bytes: 20108
n = gets.chomp.to_i
as = gets.chomp.split(' ').map(&:to_i)

aas =
  as.each_with_object({}) do |a, objects| 
    objects[a] = objects[a].to_i + 1
  end

sum = 0
aas.each do |k, v|
  sum += k * v
end
#p sum


q = gets.chomp.to_i
q.times do
  b, c = gets.chomp.split(' ').map(&:to_i)
  count = aas.delete(b)
  if count
    aas[c] = aas[c].to_i + count
    sum -= b * count
    sum += c * count
  end
  #p aas
  puts sum
end

Measured memory_bytes: 26376
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    string a;
    bool flg = true;
    bool cflg = true;

    cin >> a;

    if (a[0] != 'A') {
        flg = false;
    }
    else {
        a.erase(0, 1);
    }


    for (int i = 1; i < (int)a.size() - 1; i++) {
        if (a[i] == 'C') {
            a.erase(i, 1);
            cflg = false;
            break;
        }
    }

    if (cflg) {
        flg = false;
    }

    for (int i = 0; i < (int)a.size(); i++) {
        if (a[i] > 'A' && a[i] < 'Z') {
            flg = false;
            break;
        }
    }

    if (flg) {
        cout <<"AC" << endl;
    }
    else {
        cout << "WA" << endl;
    }



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int a[100], b[100], c[100], d[100];
 
int md(int x1, int y1, int x2, int y2) {
	return abs(x1-x2) + abs(y1-y2);
}
 
int main() {
	int N, M;
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= N; i++) scanf("%d%d", &a[i], &b[i]);
	for (int i = 1; i <= M; i++) scanf("%d%d", &c[i], &d[i]);
	for (int i = 1; i <= N; i++) {
		int curmin = 1000000000;
		int curnode = M;
		for (int j = M; j >= 1; j--) {
			if (md(a[i], b[i], c[j], d[j]) <= curmin) {
				curnode = j;
				curmin = md(a[i], b[i], c[j], d[j]);
			}
		}
		printf("%d\n", curnode);
	}
}

Measured memory_bytes: 256
import java.awt.*;
import java.awt.geom.*;
import java.io.*;
import java.util.*;
class Main {
	static boolean[] checknode;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if(n == 0) break;
			char[] in = new char['z' - 'a' + 1];
			char[] out = new char['z' - 'a' + 1];
			
			boolean[][] edge = new boolean['z' - 'a'+1]['z' - 'a'+1];
			boolean[]   isnode = new boolean['z' - 'a'+1];
			checknode = new boolean['z' - 'a' + 1];
			char start = 'a';
			for(int i = 0; i < n; i++) {
				char[] tmp = sc.next().toCharArray();
				if(i == 0)start = tmp[0];
				in[tmp[tmp.length-1] - 'a']++;
				out[tmp[0] - 'a']++;
				edge[tmp[0] - 'a'][tmp[tmp.length-1] - 'a'] = true;
				isnode[tmp[0] - 'a'] = isnode[tmp[tmp.length-1] - 'a'] = true;
			}
			
			boolean A = true;
			for(int i = 0; i < in.length; i++) {
				if(in[i] != out[i]) {
					A = false;
					break;
				}
			}
			
			if(A) {
				
				check(edge,start-'a');
				
				for(int i = 0; i < isnode.length; i++) {
					
					if(isnode[i] && !checknode[i]) {
						A = false;
						break;
					}
					
				}
			}
			
			System.out.println(A?"OK":"NG");
			
			
		}
	} 	
	static void check(boolean[][] a, int b) {
		checknode[b] = true;
		for(int i = 0; i < a[b].length; i++) {
			if(!a[b][i]) continue;
			if(checknode[i]) continue;
			check(a,i);
		}
	}

	
}

Measured memory_bytes: 52120
n=int(input())
p=list(map(int,input().split()))
ans=0

for i in range(n-2):
    if p[i]<p[i+1] and p[i+2]>p[i+1]:
        ans+=1
    elif p[i]>p[i+1] and p[i+2]<p[i+1]:
        ans+=1

print(ans)

Measured memory_bytes: 3060
import java.io.*;

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

	BufferedReader br =
	 new BufferedReader(new InputStreamReader(System.in));

	String str1 = br.readLine();
	String str2[] = str1.split(" ");
	int a = Integer.parseInt(str2[0]);
	int b = Integer.parseInt(str2[1]);
	int c = a*b;
	int d = 2*(a+b);
	System.out.println( c + " " + d );

   }
}

Measured memory_bytes: 24160
#include<stdio.h>
int main()
{
    char a;
    scanf("%c",&a);
    switch(a)
    {
        case 'A':printf("T\n");break;
        case 'T':printf("A\n");break;
        case 'C':printf("G\n");break;
        case 'G':printf("C\n");break;
    }
    return 0;
}

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

int main() {
  string b;
  cin >> b ;
  if ( b == "A"){
    cout << "T" <<endl;
  }
  else if (b == "T"){
    cout << "A" <<endl;
  }
  else if (b == "C"){
    cout << "G" <<endl;
  }
  else if (b == "G"){
    cout << "C" <<endl;
  }

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
const int M=500010;
int read(){
	int ans=0,f=1,c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}
	return ans*f;
}
int n,q,k;
LL ans,dis[M];
LL f[M][35],vis[M],deep[M];
LL first[M],cnt;
struct node{LL to,next,w;}e[M];
void ins(LL a,LL b,LL w){e[++cnt]=(node){b,first[a],w}; first[a]=cnt;}
void insert(LL a,LL b,LL w){ins(a,b,w); ins(b,a,w);}
void dfs(LL x){
    vis[x]=1;
    for(int i=1;(1<<i)<=deep[x];i++) f[x][i]=f[f[x][i-1]][i-1];
    for(int i=first[x];i;i=e[i].next){
        int now=e[i].to;
        if(!vis[now]){
            deep[now]=deep[x]+1;
            f[now][0]=x;
            dis[now]=dis[x]+e[i].w;
            dfs(now);
        }
    }
}
int find(int x,int y){
    if(deep[x]<deep[y]) swap(x,y);
    int d=deep[x]-deep[y];
    for(int i=0;(1<<i)<=d;i++) if((1<<i)&d) x=f[x][i];
    if(x==y) return x;
    for(int i=30;i>=0;i--)
     if((1<<i)<=deep[x]&&f[x][i]!=f[y][i]) x=f[x][i],y=f[y][i];
    return f[x][0];
}
int main(){
	int x,y,w;
	n=read();
	for(int i=1;i<n;i++) x=read(),y=read(),w=read(),insert(x,y,w);
	dfs(1);
	q=read(); k=read();
	for(int i=1;i<=q;i++){
		x=read(); y=read();
		ans=0;
		int s1=find(x,k),s2=find(y,k);
		LL sum1=dis[x]+dis[k]-dis[s1]*2;
		LL sum2=dis[y]+dis[k]-dis[s2]*2;
		ans=ans+sum1+sum2;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 51968
import math
A = list(map(int,input().split(" ")))
if (max(A[0],A[1]) - min(A[0],A[1])) % 2 == 1:
    print("IMPOSSIBLE")
else:
    print(math.floor(max(A[0],A[1]) - (max(A[0],A[1]) - min(A[0],A[1])) / 2))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int p, q, r = 1;
int main() {
	scanf("%d%d", &p, &q);
	q = q / __gcd(p, q);
	for(int i = 2; i * i <= q; i++) {
		if(q % i == 0) {
			r *= i;
			while(q % i == 0) q /= i;
		}
	}
	printf("%d\n", r * q);
	return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define FasterIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    FasterIO
    int cl,a,n[9999],sum=0,ans;
    cin>>cl>>a;
    for(int i=0; i<a; i++)
    {
        cin>>n[i];
        sum=sum+n[i];
    }
    ans=cl-sum;
    if(ans>=0)
        cout<<ans<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3664
#include <stdio.h>

int main(void)
{
	int i,j;
	int r,c;
	int a[101][101] = {0};

	scanf("%d %d", &r,&c);

	for(i = 0; i < r; i++){
		for(j = 0; j < c; j++){
				scanf("%d", &a[i][j]);
			}	
	}

	for(i = 0; i < r; i++){
		for(j = 0; j < c; j++){
				a[i][c] += a[i][j];
			}	
	}

	for(j = 0; j < c; j++){
		for(i = 0; i < r; i++){
				a[r][j] += a[i][j];
			}	
	}

	for(i = 0; i < r; i++){
		a[r][c] += a[i][c];
	}

	for(i = 0; i <= r; i++){
		for(j = 0; j <= c; j++){
			printf("%d",a[i][j]);
			if(j != c){
				printf(" ");
			}
		}
		printf("\n");
	}

	return 0;
}


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

int main() {
  int n, m; cin >> n >> m;
  if( n%2 == 1) { for(int i = 0;i < m;i++) { cout << i+1 << " " << n-i << endl; } }
  else {
    for(int i = 0;i < m;i++) {
      if( i % 2 == 0) { cout << i/2 + 1 << " " << n - i/2 << endl; }
      else { cout << n/2 - i/2 - 1 << " " << n/2 + i/2 + 1 << endl; }
    }
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> W(N);
  for (int i = 0; i < N; i++) {
    cin >> W.at(i);
  }
  vector<int> Sw(N);
  Sw.at(0) = W.at(0);
  for (int i = 1; i < N; i++) {
    Sw.at(i) = Sw.at(i - 1) + W.at(i);
  }
  for (int i = 0; i < N; i++) {
    if (Sw.at(i) * 2 >= Sw.at(N - 1)) {
      cout << min(Sw.at(i) * 2 - Sw.at(N - 1), Sw.at(N - 1) - Sw.at(i - 1) * 2) << endl;
      break;
    }
  }
}


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

int main() {
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	int n;
	cin >> n;
	double probs[n];
	for (int i = 0; i < n; i++)
		cin >> probs[i];
	double dp[n + 1][n + 1];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1.0;
	for (int i = 1; i <= n; i++) {
		dp[0][i] = 0.0;
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= i - 1; j++) {
			dp[i][j + 1] += dp[i - 1][j] * probs[i - 1];
			dp[i][j] += dp[i - 1][j] * (1 - probs[i - 1]);
		}
	}
	double ans = 0.0;
	for (int i = 1; i <= n; i++) {
		if (i > n / 2)
			ans += dp[n][i];
	}
	cout << fixed << setprecision(10) <<  ans << endl;
}

Measured memory_bytes: 70528
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def get_range_sum(l,s,e):
    return l[e] - l[s]

def main():
    N,K = map(int, input().split())
    pp = list(map(int, input().split()))
    pp_rui = defaultdict(int)
    for i in range(N):
        pp_rui[i+1] = pp_rui[i] + pp[i]
    #print(pp_rui)
    emax = 0
    cc = K/2
    for i in range(N-K+1):
        res = get_range_sum(pp_rui, i, i+K) + K
        res = res / 2
        #print(i, res)
        emax = max(emax, res)
    print("{:.12f}".format(emax))

if __name__ == '__main__':
    main()


Measured memory_bytes: 45556
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    vector<string> v[20];
    for(int i=1;i<10;i++)v[1].push_back(to_string(i));
    for(int i=2;i<13;i++){
        for(auto s:v[i-1]){
            if(s[i-2]!='0')v[i].push_back(s+(char)(s[i-2]-1));
            v[i].push_back(s+s[i-2]);
            if(s[i-2]!='9')v[i].push_back(s+(char)(s[i-2]+1));
        }
    }
    int id = n;
    for(int i=1;i<13;i++){
        if(id<v[i].size()){
            cout << v[i][id-1] << endl;
            return 0;
        }
        else {
            id -= v[i].size();
        }
    }
}

Measured memory_bytes: 125672
#include <stdio.h>

int main(){
  int m,f,r;

  while(1){
    scanf("%d%d%d", &m, &f, &r);
    if( m == -1 && f == -1 && r==-1 )
      break;
    else if( m == -1 || f == -1)
      printf("F\n");
    else if( m + f >= 80)
      printf("A\n");
    else if( m + f >= 65)
      printf("B\n");
    else if( m + f >= 50)
      printf("C\n");
    else if( m + f < 30 )
      printf("F\n");
    else if( m + f >= 30 && r < 50)
      printf("D\n");
    else if( m + f >= 30 && r >= 50)
      printf("C\n");
  }

  return 0;
}

Measured memory_bytes: 584
import java.util.*;

public class Main {

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

    for (int i = 0; i < n; i++) {
      s[i] = sc.next();
    }

    if (Arrays.asList(s).contains("Y")) {
      System.out.println("Four");
    } else {
      System.out.println("Three");
    }
  }

}


Measured memory_bytes: 21844