akhauriyash/Code-Regression huggingface dataset:
//**KEEP IT SHORT AND SIMPLE**

#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define REP(i,a,b) for (int i = a; i < b; i++)
#define NL '\n'
#define F first
#define S second
#define dot(a, b) (conj(a) * (b)).real()
#define cross(a, b) (conj(a)* (b)).imag()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef bool bl;
typedef vector < vector<long long> > vvl;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef map <long long, long long> mll;
typedef map <long long, bool> mlb;
typedef priority_queue<long long, vector<long long>, greater<long long> > minPq;
typedef tuple<ll, ll, ll> line;
typedef complex<double> point;
const double pi = 2 * acos(0.0);
const int OO = 0x3f3f3f3f;
ll ans[1005][1005];
int main()
{
    IO
    ll n, m, Mod = 1e9 + 7;
    cin >> n >> m;
    char arr[n][m];
    REP(i, 0, n)
        REP(j, 0, m)
            cin >> arr[i][j];
    ans[0][0] = 1;
    REP(i, 0, n)
        REP(j, 0, m)
        {
            if(arr[i][j] == '#')    ans[i][j] = 0;
            else                    ans[i][j] += ((j ? ans[i][j - 1] % Mod : 0) + (i ? ans[i - 1][j] % Mod : 0)) % Mod;
        }
    cout << ans[n - 1][m - 1];
    return 0;
}
// 1 2 4 1 0 8 5 3 16


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

int main(){
	int a,b ;
	cin >> a >> b;
	int ans=0;

	if(a>=13) ans = b;
	if(6<=a && a<=12) ans = b/2;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ii>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e5 + 3;
ll i,n,ans;
ll a[N], dp[N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    rep(i,1,n + 1) cin>>a[i];
    revrep(i,n - 1,1){
        if(a[i] >= a[i + 1])
            dp[i] = dp[i + 1] + 1;
        ans = max(ans, dp[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

def f(x,y):
    if y-x<0:
        return inf
    else:
        return y-x

x,y=map(int,input().split())
mans=min(f(x,y),f(-x,y)+1,f(x,-y)+1,f(-x,-y)+2)
print(mans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i<n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0);
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%lld", &v[i]);
#define vstr(v,n) vector<string> v(n); REP(i,n) scanf("%lld", &v[i]);
int k=0,n=0, m=0, l=0,r=0,a=0, b=0, c=0, d=0,e=0,ans=0,ans2=0,x=0,y=0;
string s,t,S;
signed main() {
  ios_base::sync_with_stdio(false);
    cin >> a>>b>>s;
  if(s[a]!='-'||(a+b+1)!=s.size()){
      cout << "No"<<endl;
    return 0;
  }
  REP(i,a+b+1){
      if(a!=i){
      if(s[i]<='9'&&s[i]>='0'){
      }else{
          cout << "No"<<endl;
        return 0;
      }
       }
  }
  cout << "Yes";
}
              


Measured memory_bytes: 3580
#include<iostream>
using namespace std;
int main(){
int n1=-1,n7=-1,n9=-1,n4=-1;
int b[4];
for(int i=0;i<4;i++){
cin>>b[i];
if(b[i]==1) n1=0;
if(b[i]==7) n7=0;
if(b[i]==9) n9=0;
if(b[i]==4) n4=0;
}
if(!n1 && !n4 && !n7 && !n9) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <atcoder/mincostflow>
#include <string>
#include <queue>
#include <vector>
using namespace std;
using namespace atcoder;
string s[30010];
vector<int> G[2510];
long long d[2510][2510],inf = 10000000,cnt = 0;
void bfs(int st,int n,int m){
    int i,j;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++) d[st][i*m + j] = inf;
    }
    queue<pair<int,int>> que;
    que.push({0,st});
    while(que.size()){
        pair<int,int> p = que.front(); que.pop(); 
        if(d[st][p.second]<inf) continue;
        d[st][p.second] = p.first;
        for(int v:G[p.second]) que.push({p.first + 1,v});
    }
}

int main(){
    int i,j,n,m; cin >> n >> m;
    for(i=0;i<n;i++) cin >> s[i];
    mcf_graph<int,long long> g(2*n*m + 2);
    int ss = 2*n*m,tt = 2*n*m + 1;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            if(i<n && (s[i][j]=='.' || s[i][j]=='o') && (s[i + 1][j]=='.' || s[i + 1][j]=='o')) G[i*m + j].push_back((i + 1)*m + j);
            if(j<m && (s[i][j]=='.' || s[i][j]=='o') && (s[i][j + 1]=='.' || s[i][j + 1]=='o')) G[i*m + j].push_back(i*m + j + 1);
        }
    }
    for(i=0;i<n*m;i++){
        bfs(i,n,m);
        for(j=0;j<n*m;j++){
            if(d[i][j]!=inf) g.add_edge(i,j + n*m,inf,inf - d[i][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            if(s[i][j]=='o') g.add_edge(ss,i*m + j,1,0),cnt++;
            if(s[i][j]!='#') g.add_edge(i*m + j + n*m,tt,1,0);
        }
    }
    pair<int,int> p = g.flow(ss,tt);
    cout << cnt*inf - p.second << endl;
}

Measured memory_bytes: 160624
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		if (n != 0) {
			List<Integer> result = conv(n);
			for (Integer elem : result) {
				System.out.print(elem);
			}
			System.out.println("");
		} else {
			System.out.println("0");
		}
		in.close();
	}

	public static List<Integer> conv(int i) {
		List<Integer> result = new ArrayList<>();
		while (i != 0) {
			if (i % -2 == 0) {
				result.add(0);
			} else {
				result.add(1);
				i = i - 1;
			}
			i = i / -2;
		}
		Collections.reverse(result);
		return result;
	}
}

Measured memory_bytes: 23764
#define MAX_STR 128
#define MAX 20

#include<stdio.h>

int main(void){
	char str[MAX_STR];
	int i = 0;

	scanf("%s", str);

	while (str[i + 1] != NULL)
		i++;

	if ((i + 1) > MAX) {
		printf("Error!\n");
		return 0;
	}

	while (i >= 0) {
		printf("%c", str[i]);
		i--;
	}

	printf("\n");
	return 0;
}

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

int dat[100005];
int n;

bool check(int t)
{
	long long cur = dat[t];
	for (int i = 0; i < n; i++)
	{
		if (i == t) continue;
		if (cur * 2 < dat[i]) return false;
		cur += dat[i];
	}
	return true;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &dat[i]);

	sort(dat, dat + n);

	int lo = 0, hi = n - 1, ans = n;
	while (lo <= hi)
	{
		int mid = (lo + hi) / 2;
		if (check(mid))
		{
			ans = mid; hi = mid - 1;
		}
		else lo = mid + 1;
	}
	printf("%d\n", n - ans);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MAX 1000000
#define MOD 2019

int main()
{
    long n,d,ans,i,j,tmp;
    cin >> n >> d;
    long qi,ri,qj,rj;
    qi = n/MOD;   qj = d/MOD;
    ri = n%MOD;   rj = d%MOD;
    if(qi == qj){
        ans = 2020;
        for(i = ri; i < rj;i++){
            for(j = rj; j > i;j--){
                ans = min((i*j)%MOD,ans);
            }
        }
    }
    else{
       ans = 0;
    }

    cout << ans;
    return 0;
}

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

int main() {
  int X, ans;
  cin >> X;
  ans = X;
  bool sosu = true;
  if(ans ==2 || ans ==3 || ans ==5 || ans ==7){
    sosu = false;
  }
  
  while(sosu){
      for(int i = 2; i<ans; i++){
        if(ans%i==0){
          ans ++; break;
        }
        
        if(i*i>ans){
          sosu = false;
          break;
        }
      }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3624
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	s := next()
	n := len(s)

	dp := make([]int, n+1)
	dp[n] = 0
	for i, tens := n-1, 1; i >= 0; i-- {
		dp[i] = (dp[i+1] + int(s[i]-'0')*tens) % 2019
		tens = (tens * 10) % 2019
	}
	// puts(dp)

	mod := map[int]int{}
	for i := range dp {
		mod[dp[i]]++
	}
	// puts(mod)

	ans := 0
	for _, v := range mod {
		ans += (v * (v - 1)) / 2
	}
	puts(ans)
}


Measured memory_bytes: 4316
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[] = new int[N];
        for(int i=0;i<=N-1;i++){
            a[i] = sc.nextInt();
        }
        int count = 0;
        for(int i=0;i<N-1;i++){
            int minj = i;
            for (int j=i+1;j<N;j++){
                if (a[minj] > a[j]) {
                    minj = j;
                }
            }
            if(i == minj) {
                continue;
            }
            int tmp = a[i];
            a[i] = a[minj];
            a[minj] = tmp;
            count++;
        }
        for(int i=0;i<N-1;i++){
            System.out.printf("%d ",a[i]);
        }
        System.out.printf("%d",a[N-1]);
        System.out.printf("\n%d\n",count);
    }
}


Measured memory_bytes: 26436
N,M=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(M)]
D=[[]for i in range(N)]
for u,v in A:
  D[u-1].append(v-1)
  D[v-1].append(u-1)

def dfs(x,used):
  if len(used)==N:
    return 1
  ans=0
  for i in D[x]:
    if i not in used:
      ans+=dfs(i,used+[i])
  return ans
print(dfs(0,[0]))  

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <climits>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    long long int n,ans=99;
    cin >> n;
    for(long long int i=1;i*i<=n;i++){
        if(n%i==0){
            long long int a=(long long int)(log10(i))+1;
            long long int b=(long long int)(log10(n/i))+1;
            ans=min(ans,max(a,b));
        }else{
            continue;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Usize1;
use itertools::Itertools;

#[proconio::fastout]
pub fn main() {
    input! {
    n:usize,
    m:usize,
    abcd:[(Usize1,Usize1,usize,usize)],
    }
    let mut ans = 0;
    for a in (1..=m).combinations_with_replacement(n) {
        ans = std::cmp::max(ans,
                            abcd.iter()
                                .filter(|(ai, bi, ci, _di)| a[*bi] - a[*ai] == *ci)
                                .map(|(_ai, _bi, _ci, di)| di)
                                .sum(),
        )
    }
    println!("{}", ans);
}


Measured memory_bytes: 2192
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a = 0;
	int b = 0;
	int c = 0;
	cin >> a;
	cin >> b;
	cin >> c;
	if (b - a == c - b) {
		cout << "YES" << "\n";
	}
	else {
		cout << "NO" << "\n";
	}

	cin >> a;
}

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

ll N, x;
ll a[110];

int main()
{
	cin >> N >> x;
	for (ll i = 0; i < N; ++i)
		cin >> a[i];
	sort(&a[0], &a[N]);
	auto y = x;
	ll c = 0;
	for (; c < N; ++c) {
		if (y < a[c])
			break;
		y -= a[c];
	}
	if (y > 0 && c == N) {
		--c;
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]){
        long N=sc.nextLong(),A=sc.nextLong(),B=sc.nextLong(),d=B-A;
        if(d%2==0){
            System.out.println(d/2);
        }
        else{
            long c=Math.min(A-1,N-B);
            System.out.println(d/2+c+1);
        }
    }
}


Measured memory_bytes: 35820
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7

N, A, B = MI()
p, q = divmod(N, A + B)
print(A * p + min(A, q))


Measured memory_bytes: 38464
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD=1000000007;

ll Ep(int x, int y){
  if(y==1) return x;
  ll r = Ep(x,y/2);
  if(y%2==1) return r *r%MOD *x%MOD;
  else return r *r%MOD;
}

int main(){
  int n;
  cin >> n;
  vector<int> an(n);
  map<int, int> mp;
  for(int i=0; i<n; ++i){
    cin >> an[i];
    int x = an[i];
    for(int j=2; j<=sqrt(an[i]); ++j){
      if(x%j == 0){
        int cnt = 0;
        while(x%j == 0){
          x /= j;
          ++cnt;
        }
        mp[j] = max(mp[j], cnt);
      }
    }
    if(x > sqrt(an[i])) mp[x] = max(mp[x],1);
  }
  ll lcm = 1;
  for(pair<int, int> p : mp){
    for(int i=0; i<p.second; ++i){
      lcm *= p.first;
      lcm %= MOD;
    }
  }
  ll ans = 0;
  for(int i=0; i<n; ++i){
    ans += lcm * Ep(an[i], MOD-2) %MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long
#define vl vector
#define pb push_back
using namespace std;
int main()
{
    set<string> se;
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        string s;
        cin>>s;
        se.insert(s);
    }
    cout<<se.size();
    return 0;
}

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

typedef long long int ll;
typedef string str;

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,a,b,j;
	char x;
	cin >> x;
	if(x>='A' && x<='Z')
		cout << "A\n";
	else
		cout << "a\n";
	return 0;
}

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

int main() {
	string s,t;
	cin >> s >> t;
	int ans = 1e9;
	for(int i=0; i < s.size();++i){
		if(i+t.size() > s.size()) break;
		int count = 0;
		for(int j=0; j < t.size(); ++j){
			if(s[i+j]!= t[j]) count++;
		}
		ans = min(ans,count);
	}
	cout << ans << "\n";
	return 0;
}

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

int main() {
   ll x, y;
   cin >> x >> y;

   if (abs(x-y) <= 1) {
       cout << "Brown" << endl;
   }
   else {
       cout << "Alice" << endl;
   }
   
}


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

class Mult2
{
    static void Main(string[] args)
    {
        var times = long.Parse(Console.ReadLine());
        var input = Console.ReadLine().Split(' ');

        long sum = 1;

        if (input.Contains("0"))
        {
            sum = 0;
            Console.WriteLine(sum);
            return;
        }

        for(var i = 0; i < times; i++)
        {
            

            if(long.Parse(input[i]) > 1000000000000000000 / sum)   
            {
                sum = -1;
                break;
            }
            else
            {
                sum *= long.Parse(input[i]);
            }
        }

        Console.WriteLine(sum);
       
    }
}

Measured memory_bytes: 36128
import java.util.*;
import java.io.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int n = sc.nextInt();
    int arr[] = new int[n];
    for(int i=0;i<n;i++){
      arr[i] = sc.nextInt();
      h = h-arr[i];
    }
    if(h<=0) System.out.println("Yes");
    else System.out.println("No");
  }
}
    
      
      

Measured memory_bytes: 47984
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define F first
#define S second
#define pb push_back
#define ll long long
#define all(v) (v).begin(),(v).end()
#define endl '\n'

using namespace std;

const int N = 100005;
const int LG = 19;
const int MOD = 1e9 + 7;
const int INF = 2000000000;
const ll INFLL = 1LL * INF * INF;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int i = 0, j = 0, res = 0;
    while(j < n) {
        while(j < n && s[j] == '1') j++;
        res = max(res, j - i);
        while(j < n && s[j] == '0') j++;
        k--;
        if (k < 0) {
            while(i < n && s[i] == '1') i++;
            while(i < n && s[i] == '0') i++;
        }
        res = max(res, j - i);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;
const int INF = 1e9;

const int MAXSUM = 8000;

bool canMake(int v, const vector<int> nums) 
{
    v = abs(v);
    vector<bool> curr(MAXSUM*2+1);
    curr[MAXSUM] = true;
    for (int x: nums) {
        vector<bool> next(MAXSUM*2+1);
        for (int p = -MAXSUM; p <= MAXSUM; ++p) {
            if (0 <= p+MAXSUM-x) next[p+MAXSUM] = curr[p+MAXSUM-x];
            if (p+MAXSUM+x < MAXSUM*2+1) next[p+MAXSUM] = next[p+MAXSUM] || curr[p+MAXSUM+x];
        }
        curr.swap(next);
    }
    return curr[v+MAXSUM];
}


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

    string s;
    int x, y;
    cin >> s >> x >> y;
    int len = s.length();
    int i = 0;

    while (i < len && s[i] == 'F') {
        ++i;
        --x;
    }

    vector<int> mx, my;
    bool dx = true;
    while (i < len) {
        if (s[i] == 'F') {
            int mv = 0;
            while (i < len && s[i] == 'F') {
                ++i;
                ++mv;
            }
            if (dx) {
                mx.push_back(mv);
            } else {
                my.push_back(mv);
            }
        } else {
            dx = !dx;
            ++i;
        }
    }

    cout << ((canMake(x, mx) && canMake(y, my)) ? "Yes" : "No") << endl; 

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <set>
using namespace std;

int main()
{
    int n;
    cin >> n;
    set<string> st;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << (int) st.size() << endl;
}


Measured memory_bytes: 19252
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node{
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = (Node *) malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while(x != NIL){
		y = x;
		if(z->key < x->key){
			x = x->left;
		}else{
			x = x->right;
		}
	}

	z->parent = y;
	if(y == NIL){
		root = z;
	}else{
		if(z->key < y->key){
			y->left = z;
		}else{
			y->right = z;
		}
	}
}

void inorder(Node *u){
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u){
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

int main(){
	int n, i, x;
	string com;

	scanf("%d",&n);

	for(i=0;i<n;i++){
		cin >> com;
		if(com == "insert"){
			scanf("%d",&x);
			insert(x);
		}else if(com == "print"){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}

Measured memory_bytes: 26636
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prl puts("\n------------------\n")
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prl 
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
const int maxn = 1e5 + 5;
int dp[maxn];
int a[maxn];
int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    memset(dp, INF, sizeof(dp));
    int n = read();
    rep(i, 1, n) a[i] = read();
    dp[1] = 0;
    for (int i = 2; i <= n; ++i) {
        if (i - 1 >= 1) dp[i] = min(dp[i], dp[i - 1] + abs(a[i] - a[i - 1]));
        if (i - 2 >= 1) dp[i] = min(dp[i], dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n] << endl;
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 1024
package main

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

const (
	maxBufSize = 1024 * 1024
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, 1)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	out = bufio.NewWriter(os.Stdout)
)

func solve(k int64) int64 {
	values := []int64{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 }
	return values[k - 1]
}

func main() {
	defer out.Flush()

	k := nextInt()
	res := solve(k)
	fmt.Fprintln(out, res)
}

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

func nextStringAsBytes() []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXSIZE=10000020;
int bufpos;
char buf[MAXSIZE];
#define NEG 0
void init(){
    #ifdef LOCAL
        freopen("E.txt","r",stdin);
    #endif
    buf[fread(buf,1,MAXSIZE,stdin)]='\0';
    bufpos=0;
}
#if NEG
int readint(){
    bool isneg;
    int val=0;
    for(;!isdigit(buf[bufpos]) && buf[bufpos]!='-';bufpos++);
    bufpos+=(isneg=buf[bufpos]=='-');
    for(;isdigit(buf[bufpos]);bufpos++)
        val=val*10+buf[bufpos]-'0';
    return isneg?-val:val;
}
#else
int readint(){
    int val=0;
    for(;!isdigit(buf[bufpos]);bufpos++);
    for(;isdigit(buf[bufpos]);bufpos++)
        val=val*10+buf[bufpos]-'0';
    return val;
}
#endif
char readchar(){
    for(;isspace(buf[bufpos]);bufpos++);
    return buf[bufpos++];
}
int readstr(char* s){
    int cur=0;
    for(;isspace(buf[bufpos]);bufpos++);
    for(;!isspace(buf[bufpos]);bufpos++)
        s[cur++]=buf[bufpos];
    s[cur]='\0';
    return cur;
}
int d[13][13];
struct edge{
    int x,y,z;
}e[2333];
bool vis[103][103];
int main(){
    init();
    int a=readint(),b=readint(),cur=0;
    for(int i=1;i<=a;i++)
        for(int j=1;j<=b;j++)
            d[i][j]=readint();
    // memset(vis,-1,sizeof(vis));
    for(int i=0;i<=100;i++)
        for(int j=0;j<=100;j++)
            for(int k=0;k<=100;k++){
                bool flag=0;
                for(int o=1;o<=a;o++)
                    for(int t=1;t<=b;t++){
                        if (i*o+j*t+k<d[o][t]){
                            flag=1;
                            goto hell;
                        }
                    }
                hell:;
                if (flag)
                    continue;
                flag=0;
                for(int o=1;o<=a;o++)
                    for(int t=1;t<=b;t++)
                        if (!vis[o][t] && i*o+j*t+k==d[o][t])
                            vis[o][t]=flag=1;
                if (flag)
                    e[++cur]=(edge){i,j,k};
            }
    // puts("WTF");
    for(int i=1;i<=a;i++)
        for(int j=1;j<=b;j++)
            if (!vis[i][j])
                return puts("Impossible"),0;
    puts("Possible");
    printf("%d %d\n",202,cur+200);
    for(int i=0;i<100;i++)
        printf("%d %d X\n",i+1,i+2);
    for(int j=1;j<=100;j++)
        printf("%d %d Y\n",j+102,j+101);
    for(int i=1;i<=cur;i++)
        printf("%d %d %d\n",e[i].x+1,e[i].y+102,e[i].z);
    puts("1 102");
    
    
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#define int long long
using namespace std;
signed main() {
	int x; cin >> x;
	if (x % 2 == 1) {
		x--;
		cout << (x&&x <= 6 ? "YES\n" : "NO\n");
	}
	else cout << "NO\n";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b, c, d, e;
    // Your code here!
    cin >> a >> b >> c >> d >> e;
    if(a == 0) printf("1\n");
    if(b == 0) printf("2\n");
    if(c == 0) printf("3\n");
    if(d == 0) printf("4\n");
    if(e == 0) printf("5\n");
}


Measured memory_bytes: 3124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1e9+7;

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

//********************************template END****************************************//

void solve(void){

	int N, x;
	cin >> N;

	vector <intP> vpe, vpo;

	map <int, int> mpe, mpo;

	rep(N, i)
	{
		cin >> x;
		if (i & 1) mpo[x]++;
		else mpe[x]++;
	}

	for (auto p : mpo)
	{
		vpo.pb(intP(p.snd, p.fst));
	}
	for (auto p : mpe)
	{
		vpe.pb(intP(p.snd, p.fst));
	}

	sort(all(vpo));
	reverse(all(vpo));
	sort(all(vpe));
	reverse(all(vpe));

	if (vpo[0].snd != vpe[0].snd)
	{
		cout << N - vpo[0].fst - vpe[0].fst << endl;
		return;
	}

	if ((int)vpo.size() == 1 && (int)vpe.size() == 1)
	{
		cout << N / 2 << endl;
		return;
	}

	if ((int)vpo.size() == 1)
	{
		cout << N - vpo[0].fst - vpe[1].snd << endl;
		return;
	}
	if ((int)vpe.size() == 1)
	{
		cout << N - vpe[0].fst - vpo[1].snd << endl;
		return;
	}


	cout << N - max(vpo[0].fst+vpe[1].fst, vpe[0].fst+vpo[1].fst) << endl;



}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 6136
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
char s[1000],t[1000];
int n,len;

bool check()
{
	if(len!=7) return 0;
	return t[1]=='k' && t[2]=='e' && t[3]=='y' && t[4]=='e' && t[5]=='n' && t[6]=='c' && t[7]=='e';
}

void trf(int l,int r)
{
	len=0;
	rep(i,1,l-1) t[++len]=s[i];
	rep(i,r+1,n) t[++len]=s[i];
}

int main()
{
	scanf("%s",s+1),n=strlen(s+1);
	rep(i,1,n) t[i]=s[i];
	len=n;
	if(check()) return puts("YES"),0;
	rep(i,1,n) rep(j,i,n) if(trf(i,j),check()) return puts("YES"),0;
	puts("NO");
	return 0;
}

Measured memory_bytes: 128
import Control.Applicative
import Control.Monad
import Data.List
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS

main :: IO ()
main = do
  [_, k] <- f
  bs <- replicateM k (IS.fromList <$> tail <$> f)
  r <- readLn
  solve bs <$> replicateM r f >>= print
  where
    f = map read <$> words <$> getLine

solve :: [IntSet] -> [[Int]] -> Int
solve bs es = IS.size $ foldl' f IS.empty bs
  where
    f st b = foldl' (g b) st es
    g b st [x, y]
      | IS.member x b && IS.member y b = IS.insert x (IS.insert y st)
      | otherwise = st



Measured memory_bytes: 4756
import java.util.*;
import java.util.stream.*;

/**
 * (X,Y) の距離 |X|+|Y|
 * |X|+|Y| ＝ nK - 2m となる n, m (n=1,.. m=0,1,..) が存在すれば到達可能
 * 注意が必要なパターン
 *  K=3, |X|+|Y|=4 では n=1 とできない。
 *  n=2 とすると、m=1 として解がある。(n = (|X|+|Y|)/K ではない )
 *  n = (|X|+|Y|)/(K/2*2) とする必要がある。
 *
 * 例示方針：(X,Y) まで距離が2K以内のところに行く(X軸優先)。
 *           最後の二打で距離を調整。
 */
public class Main {
	Scanner sc;

	int X, Y, K;
	
//=============
// constructor
//
	public Main() {
		sc = new Scanner(System.in);
	}
	
//==================
// instance methods
//
	/**
	 * アルゴリズム本体
	 * 
	 * (0) 残り距離がK以下の場合特殊処理
	 * (1) X軸優先で残り距離が K より大きく 2K 以下になるようにする。
	 * (2) 残り 2 打で調整
	 */
	private void calc() {
		K = sc.nextInt();
		X = sc.nextInt();
		Y = sc.nextInt();

		int D = d(X, Y);
		if (D == K) {
			// 一発でいける特例
			out(1);
			out(X+" "+Y);
			return;
		}
		//
		if ((D%2 == 1) && ( K%2 ==0)) { // できない場合
			out(-1);
			return;
		}

		boolean near = false; // もともと近くかつ K 未満の距離の場合、1 発目はイレギュラー
		int n = (D + (K-1)) / K; // 打数(繰り上げ)
		if (n == 1) {
			near = true;
			n++;
		}

		long mm;
		boolean added = false;
		while (true) {
			mm = (long)K * n - D;
			if (mm%2 == 0) break;
			n++;
			added = true;
		}
		int m = (int)(mm / 2); // 無駄にする量の半分
		out(n); // 確定した打数を出力

		// 2 打残して X 軸優先で近づく
		int dx = (X >= 0)?1:-1;
		int dy = (Y >= 0)?1:-1;

		// 第一象限に限定(XX, YY)がゴール
		int XX = dx * X;
		int YY = dy * Y; 

		//
		int lx = 0;
		int ly = 0;
		if (near && added) {
			lx -= K;
			out(dx*lx + " " + dy*ly);
			n--;
			m -= K;
		}

		for (int i = 0; i < n-2; i++) {
			if (XX > lx) {
				lx += K;
				if (lx > XX) {
					ly += (lx - XX);
					lx = XX;
				}
			} else {
				ly += K;
			}
			out(dx*lx + " " + dy*ly); // 象限を戻して出力
		}

		// あと 2 打でゴール
		if (lx == XX) {
			// 真下に来たパターン
			lx += m; ly += K-m;
		} else if (ly == YY) {
			// 真左に来たパターン
			lx += K-m; ly += m;
		} else {
			// 左下に来たパターン
			if (XX-lx > YY-ly) {
				lx += K-m;
				ly -= m;
			} else {
				lx -= m;
				ly += K-m;
			}
		}
		out( dx*lx + " " + dy*ly );
		out( X + " " + Y );
	}
	
	/**
	 *  マンハッタン距離
	 */
	private int d(int x, int y) {
		return d(x) + d(y);
	}
	private int d(int x) {
		return (x>=0)?x:-x;
	}

	private void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
//======
// main
//
	public static void main(String[] args) {
		Main m = new Main();
		m.calc();
	}

}

Measured memory_bytes: 46716
import java.util.*;

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

        int origin = 1 * 3;

        int thisTime = r * r * 3;

        int result = thisTime / origin;
        
        System.out.println(result);


    }
}


Measured memory_bytes: 21972
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

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

	a, b := scanInt(), scanInt()

	if a < 10 && b < 10 {
		fmt.Println(a*b)
	} else {
		fmt.Println(-1)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <sstream>

#define FOR(i, a, b) for (int i = a; (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

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

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

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<int>;
using vvi = vc<vi>;

using ll = long long;


int main() {
    cout << setprecision(20) << fixed;
    while (true) {
        string s;
        cin >> s;
        if (s == "0") break;

        ll ans = 0;
        REP(i, int(s.length())){
            stringstream ss;
            ss << s[i];
            int a;
            ss >> a;
            ans += a;
        }

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



Measured memory_bytes: 3148
#include <iostream>
using namespace std;
typedef long long ll;
ll K,N,inf = 998244353;
ll func[4010] = {0};
ll inv[4010] = {0};

ll mult(ll n, ll m){
	if(n==0 || m==0) return 1;
	if(m==1) return n%inf;
	else if(m%2==0){
		ll t = mult(n,m/2);
		return (t*t)%inf;
	}else{
		ll t = mult(n,m-1);
		return (t*n)%inf;
	}
}

void factorial(ll N){
	for(ll i=0;i<=N;i++){
		if(i==0){
			func[i] = 1;
			inv[i] = 1;
		}
		else{
			func[i] = (i*func[i-1])%inf;
			inv[i] = mult(func[i],inf-2);
		}
	}
}

ll comb(ll n,ll k){
	if(n<k || n<0 || k<0) return 0;
//	if(k==0 || n==k) return 1;
	else return (((func[n]*inv[k])%inf)*inv[n-k])%inf;
}

ll hcomb(ll n,ll k){
	if(n==0 && k==0) return 1;
	return comb(n+k-1,k);
}

int main(){
	cin >> K >> N;
	factorial(4000);
	for(ll i=2;i<=2*K;i++){
		ll ans = 0;
		ll n = min(i,(2*K+2-i))/2;
		if(i%2==1){
			for(ll j=1;j<=n;j++){
				ans = (ans+(j%2==0? -1:1)*hcomb(K,N-2*j)*comb(n,j))%inf;
			}
		}else{
//			n--;
			for(ll j=1;j<=n;j++){
				ll t = hcomb(K,N-2*j);//(hcomb(K-1,N-2*j)+hcomb(K-1,N-2*j-1))%inf;
				ans = (ans+(j%2==0? -1:1)*t*comb(n,j))%inf;
			}
		}
		ans = (hcomb(K,N)-ans)%inf;
		cout << (ans+inf)%inf << endl;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    vector<int> p(N);
    for (auto &&i : p) {
        cin >> i;
    }

    int ans = 0;
    FOR(i, 1, N - 1) {
        if (p[i - 1] < p[i] && p[i] < p[i + 1])
            ans++;
        if (p[i - 1] > p[i] && p[i] > p[i + 1])
            ans++;
    }

    std::cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll W, H;
    cin >> W >> H;
    vector<ll> P(W + 1, 0), Q(H);
    ll ret = 0;
    repd(i, 1, W + 1) cin >> P[i], ret += P[i];
    rep(i, H) cin >> Q[i], ret += Q[i];
    vector<ll> S(W + 1, 0);
    sort(all(P));
    repd(i, 1, W + 1){
        S[i] = S[i - 1] + P[i];
    }
    
    rep(i, H){
        ll l = 0, r = W + 1;
        while(l + 1 < r){
            ll mid = (l + r) / 2;
            if(Q[i] <= P[mid]){
                r = mid;
            }
            else{
                l = mid;
            }
        }
//        cout << i << ":" << Q[i] << "," << P[l] << endl;
//       / cout << i <<  ":" << i << "," << l <<  endl;
        ret += S[l] + Q[i] * (W - l);
//        cout << S[l] + Q[i] * (W - l) << endl;
    }
    output(ret);
    
    
    return 0;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;

int main(){
	
	string S;
    cin >> S;
    bool flag = true;
    for (int i = 0 ;i < S.length(); i++){
        if (i%2==0){
            if (S[i]=='L'){
                flag = false;
            }
        }else{
            if (S[i]=='R'){
                flag = false;
            }
        }
    }

    if (flag == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        long[][] masks = Enumerable.Repeat(0, n).Select(_ => new long[n]).ToArray();
        for (int i = 0; i < n - 1; i++)
        {
            var st = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();
            masks[st[0]][st[1]] = 1L << i;
            masks[st[1]][st[0]] = 1L << i;
        }

        bool updated = true;
        while (updated)
        {
            updated = false;
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                    for (int k = 0; k < n; k++)
                        if (j != k && masks[j][k] == 0 && masks[j][i] != 0 && masks[i][k] != 0)
                        {
                            masks[j][k] = masks[j][i] ^ masks[i][k];
                            updated = true;
                        }
        }

        int m = int.Parse(Console.ReadLine());
        var restrictions = Enumerable.Repeat(0, m).Select(_ => Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray()).ToArray();
        //制約を満たさないものの数を数える
        long res = 0;
        for (int i = 0; i < (1 << m); i++)
        {
            long bit = 0;
            int popcnt = 0;
            for (int j = 0; j < m; j++)
                if ((i >> j & 1) == 1)
                {
                    bit |= masks[restrictions[j][0]][restrictions[j][1]];
                    popcnt++;
                }
            var strictedEdge = PopCount(bit);
            var unstrictedEdge = (n - 1) - strictedEdge;
            res += ((popcnt & 1) != 0 ? -1 : 1) * (1L << unstrictedEdge);
        }
        Console.WriteLine(res);
    }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static int PopCount(long n)
    {
        int res = 0;
        for (int i = 0; i < 64; i++)
            if ((n >> i & 1) == 1) res++;
        return res;
    }
}

Measured memory_bytes: 13524
#include <stdio.h>

int gcd(int a, int b){
    if(a < b){
        int t = a;
        a = b;
        b = t;
    }
    if(a % b == 0)return b;
    else return gcd(b, a%b);
}

int main(void){
    int n;
    scanf("%d", &n);
    int a[n];
    for(int i = 0;i < n;i++){
        scanf("%d", &a[i]);
    }
    int gc = gcd(a[0], a[1]);
    for(int i = 2; i < n;i++){
        gc = gcd(gc, a[i]);
    }
    printf("%d\n", gc);
    return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;
import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException {
        //BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), k = sc.nextInt();
        ArrayList<Integer> res = new ArrayList<>();
        for(int i=1;i<=Math.min(a,b);i++){
            if(a%i==0&&b%i==0) res.add(i);
        }
        Collections.sort(res,Collections.reverseOrder());
        System.out.println(res.get(k-1));
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    

    ll n,k;
    cin >> n >> k;
    if(n%2 == 0){
        if(k <= n/2){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }else{
        if(k <= n/2+1){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}




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

using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  vector<int> A(n), B(n), C(n - 1);

  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> B[i];
  }
  for (int i = 0; i < n - 1; i++) {
    cin >> C[i];
  }

  int result = 0;
  result += accumulate(B.begin(), B.end(), 0);
  for (int i = 0; i < n - 1; i++) {
    if (A[i] + 1 == A[i + 1]) {
      result += C[A[i] - 1];
    }
  }

  cout << result << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int k;
  int a, b;
  cin >> k;
  cin >> a >> b;
  int i = 0;
  while(i < a) {
    i += k;
  }
  if (i > b) {
    cout << "NG\n";
  } else {
  	cout << "OK\n";
  }
  return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換

int main() {
string s;
cin>>s;
map<char,bool> m;
rep(i,s.size()){
    m[s[i]] = true;;
}
if(m['S'] ^ m['N'] == false && m['E'] ^ m['W'] == false){
    cout<<"Yes"<<endl;
}else
{
    cout<<"No"<<endl;
}

   return 0;
}


Measured memory_bytes: 3604
#include "bits/stdc++.h"
#include "sstream"
#define EPS 1e-9
using namespace std;
const int N=1e5,INF=0x3f3f3f3f;
typedef long long ll;
int arr[N],dp[N],n;
int solve(int idx){
    if(idx==n-2)
        return abs(arr[idx]-arr[idx+1]);
    if(idx==n-1)
        return 0;
    int &ret=dp[idx],c1,c2;
    if(ret!=-1)
        return ret;
    if(idx+1<n)
        c1=abs(arr[idx]-arr[idx+1])+solve(idx+1);
    if(idx+2<n)
        c2=abs(arr[idx]-arr[idx+2])+solve(idx+2);
    return ret=min(c1,c2);
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin>>n;
 for(int i=0;i<n;i++)
     cin>>arr[i];
 memset(dp,-1, sizeof(dp));
 cout<<solve(0);
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int n;
    cin >> n;
    For(i,1,n+1){
        int a;
        cin >> a;
        if(a%2 == 1 && i%2 == 1) ans++;
    }
    cout << ans << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3620