akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int strLen (char ar[])
{
    int i=0,c=0;
    while (ar[i]!='\0')
    {
        c++;
        i++;
    }
    return c;
}
int main()
{
    char ar[1000];
    scanf ("%s",ar);
    int i,f1=0,l,f2=0,p=0,j=1,f3=0;
    if (ar[0]=='A')
    {
        f1=1;
    }
    l=strLen(ar);
    for (i=2;i<=l-2;i++)
    {
        if (ar[i]=='C')
        {
            f2=1;
            p=i;
            break;
        }
        else if (ar[i]!='C')
        {
            f2=0;
            continue;
        }


    }
    while (ar[j]!='\0')
    {
        if (j!=p && ar[j]>96)
        {
            f3=1;
            j++;
            continue;
        }
        else if (j!=p && ar[j]<97)
        {
            f3=0;
            break;
        }
        if (j==p)
        {
            j++;
            continue;
        }
    }
    if (f1==1 && f2==1 && f3==1)
    {
        printf ("AC\n");
    }
    else
        printf ("WA\n");



    return 0;
}


Measured memory_bytes: 128
N=parse(Int,readline())
s=chomp(readline())
function f(a,b)
	A=Bool[a,b]
	for i=2:N-1
		if A[i]
			if s[i]=='o'
				push!(A,A[i-1])
			else
				push!(A,!A[i-1])
			end
		else
			if s[i]=='o'
				push!(A,!A[i-1])
			else
				push!(A,A[i-1])
			end
		end
	end
	if (s[1]=='o')$A[1]$(A[2]==A[N])&&(s[N]=='o')$A[N]$(A[1]==A[N-1])
		for i=1:N
			print(A[i]?'S':'W')
		end
		println()
		true
	else
		false
	end
end
f(true,true)||f(true,false)||f(false,true)||f(false,false)||println(-1)


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

public class S
{



    public static void Main()
	{
		/*
        var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        var N = input[0];
        var M = input[1];
        var bridge = new long[M,2];
        for(long i = 0; i < M; i++){
            input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            bridge[i,0] = input[0];
            bridge[i,1] = input[1];
        }
        solver(N,M,bridge);
		*/
		var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        var N = long.Parse(input[0].ToString());
        var M = input[1];
		solver(N,M,Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse));
        //solver(2, 10, new long[]{3,5});
    }

    public static void solver(long N, long K, long[] input){

        var sum = input.Sum();

        var divisors = getDivisorList(sum);
        Array.Sort(divisors);
        var amari = new long[input.Length];

        // amari list

        long max = input.Max();
        long amariTot = 0;
        long moveCount = 0;

        for(int i = divisors.Length-1; i >=0 ; i--){

            amariTot = 0;
            moveCount = 0;
            for(int k = 0; k < input.Length; k++){
				//Console.WriteLine(k);
                amari[k] = input[k] % divisors[i];
                amariTot += input[k] % divisors[i];

            }

            Array.Sort(amari);
            Array.Reverse(amari);
            amariTot /= divisors[i];

            for(int k = 0; k < amariTot; k++){
                //Console.WriteLine(amari[k]);
                moveCount += Math.Abs(divisors[i] - amari[k]);

                
                
            }
			
            if(moveCount <= K){
                Console.WriteLine(divisors[i]);
                return;
            }
			
			

        }



    }


    public static long[] getDivisorList(long num){
        long x = 1;

        long cap = Convert.ToInt64(Math.Sqrt(num));


        var result = new List<long>();
        while(x <= cap){
            if(num % x == 0){
                if(x == num /x){
                    result.Add(x);
                }else{
                    result.Add(x);
                    result.Add(num/x);
                }
            } 
            x++;
        }
		return result.ToArray();
    }

}

Measured memory_bytes: 13628
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <utility>

#define reps(i,f,n) for(ll i=f; i<ll(n); ++i)
#define rep(i,n) reps(i,0,n)

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;

signed main()
{
    ll x, k;
    cin >> x >> k;
    
    vi r(k+2);
    r[0] = 0;
    rep(i, k) cin >> r[i+1];
    r[k+1] = 1000000010;
    
    vi a(k+2), b(k+2), c(k+2);
    
    a[0] = x;
    reps(i, 1, k+2){
        a[i] = a[i-1] + (i%2==0 ? 1 : -1) * (r[i] - r[i-1]);
        a[i] = max(0ll, min(x, a[i]));
    }
    
    b[0] = 0;
    reps(i, 1, k+2){
        b[i] = b[i-1] + (i%2==0 ? 1 : -1) * (r[i] - r[i-1]);
        b[i] = max(0ll, min(x, b[i]));
    }
    
    c[0] = 0;
    reps(i, 1, k+2){
        c[i] = c[i-1] + (i%2==0 ? 1 : -1) * (r[i] - r[i-1]);
    }
    
    /*
    cout << "a = ";
    rep(i, a.size()){
        cout << a[i] << " ";
    } cout << endl;
    
    cout << "b = ";
    rep(i, b.size()){
        cout << b[i] << " ";
    } cout << endl;
    
    cout << "c = ";
    rep(i, c.size()){
        cout << c[i] << " ";
    } cout << endl;
    */
    
    map<ll, ll> min_dict, max_dict;
    ll mi = 0, ma = 0;
    
    rep(i, k+2){
        if(c[i] < mi){
            mi = c[i];
            min_dict[-mi] = i;
        }
        if(c[i] > ma){
            ma = c[i];
            max_dict[ma] = i;
        }
    }
    
    /*
    cout << "min_dict = ";
    for(auto x : min_dict){
        cout << "(" << x.first << ", " << x.second << ")";
    }
    cout << endl;
    cout << "max_dict = ";
    for(auto x : max_dict){
        cout << "(" << x.first << ", " << x.second << ")";
    }
    cout << endl;
    */
    
    ll q;
    cin >> q;
    
    rep(j, q){
        ll t, p;
        cin >> t >> p;
        ll i = upper_bound(r.begin(), r.end(), t) - r.begin() - 1; // r[i] <= t < r[i+1]
        
        //cout << "t = " << t << ", p = " << p << ", i = " << i << endl;
        
        auto itr = min_dict.lower_bound(p);
        if(itr != min_dict.end()){
            ll min_i = itr->second;
            //cout << "min_i = " << min_i << endl;
            if(i >= min_i){
                ll u = b[i] + (i%2==1 ? 1 : -1) * (t - r[i]);
                u = max(0ll, min(x, u));
                cout << u << endl;
                continue;
            }
        }
        
        itr = max_dict.lower_bound(x-p);
        if(itr != max_dict.end()){
            ll max_i = itr->second;
            //cout << "max_i = " << max_i << endl;
            if(i >= max_i){
                ll u = a[i] + (i%2==1 ? 1 : -1) * (t - r[i]);
                u = max(0ll, min(x, u));
                cout << u << endl;
                continue;
            }
        }
        
        ll u = p + c[i] + (i%2==1 ? 1 : -1) * (t - r[i]);
        u = max(0ll, min(x, u));
        cout << u << endl;
    }
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <atcoder/dsu>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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










int main(){
    int N, Q; std::cin >> N >> Q;
    atcoder::dsu d(N);
    {
        int t, u, v;
        for(int i(0); i < Q; ++i){
            std::cin >> t >> u >> v;
            if(t){
                std::cout << d.same(u, v) << "\n";
            }else d.merge(u, v);
        }
    }
    return 0;
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    ll sa = 0;
    ll sb = 0;
    ll c = 0;

    REP(i, n) {
        cin >> a[i];
        sa += a[i];
    }
    REP(i, n) {
        cin >> b[i];
        sb += b[i];
    }
    REP(i, n) {
        if (a[i] < b[i]) {
            c += (b[i] - a[i] + 1) / 2;
        }
    }

    cout << (sb - sa >= c ? "Yes" : "No") << endl;
}


Measured memory_bytes: 384
n, m, x = map(int, input().split())
a = list(map(int, input().split()))

# xは最初の位置
# nは目的地
# aは料金所（コスト1）

cost = 0
cost2 = 0

for i in a:
  if i > x:
    cost += 1
  else:
    cost2 += 1
    
if cost < cost2:
  print(cost)
else:
  print(cost2)

Measured memory_bytes: 38256
#include<cstdio>
#include<complex>
#include<algorithm>
using namespace std;

typedef complex<int> P;

int n;
P p[3000];

int comp(P a,P b){
  if(a.real()<b.real())return -1;
  if(a.real()==b.real()){
    if(a.imag()<b.imag())return -1;
    else if(a.imag()==b.imag())return 0;
  }
  return 1;
}

bool exist(P a){
  int lb = -1,ub = n;
  while(ub-lb>1){
    int mid = (ub+lb)/2;
    if(comp(p[mid],a)==0)return true;
    if(comp(p[mid],a)>0)ub = mid;
    else lb = mid;
  }
  return false;
}

int main(){
  while(scanf("%d",&n) && n){
    for(int i=0;i<n;i++)scanf("%d %d",&p[i].real(),&p[i].imag());

    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++)
	if(comp(p[i],p[j])>0)swap(p[i],p[j]);

    int ans = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i==j)continue;
	P n = (p[j]-p[i])*P(0,-1);
	int dis = real(conj(n)*n);
	if(dis<=ans)continue;
	if(exist(p[i]+n) && exist(p[j]+n))ans = max(ans,dis);
      }
    }
    printf("%d\n",ans);
  }
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        long ans = 0;
        int min = inf;
        int count = 0;
        for (int i = 0; i < n; i++) {
            int a = in.ni();
            if(a < 0){
                count++;
                a = -a;
            }
            min = Math.min(min, a);
            ans += a;
        }
        if(count%2==1) ans -= 2*min;
        out.println(ans);
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 43732
#include <bits/stdc++.h>
 
using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x)	make_pair(x);
    
#define debug(x) 		cerr << #x << '=' << x << endl;
#define debug2(x, y)	cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(_a)		cerr << #_a << ": "; for (auto _x: _a) cerr << _x << ' '; cerr << endl;
#define debugm(a) 		cerr << #a << ":\n"; \
						for (auto v: a) { for(auto x: v) cout << x << ' '; cerr << "\n"; }
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long
 
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;
 
const int INF  = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 998244353;

int32_t main()
{
	FAST_IO;
	
	int a, b;
	cin >> a >> b;
	
	cout << 6-a-b << endl;
}


// g++ -Wall -Wextra -Wshadow -fsanitize=undefined 


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

int C(int x) {
  if (x == 0) return 0;
  return x * (x - 1) / 2;
}
int main() {
  cin.tie(0), ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  cout << C(n) + C(m) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

bool cmp (vector<pair<int,int>>& a, vector<pair<int,int>>& b) {
        if (a.empty()) return false;
        else if (b.empty()) return true;
        else return a[0].first < b[0].first;
}

ll po (ll a, ll b) {
        ll r = 1ll;
        while (b) {
                if (b&1ll) r = r * a % MOD;
                a = a * a % MOD, b /= 2;
        }
        return r;
}

int N, X, Y, p[200200], cnt[200200], ju[200200];
vector<pair<int, int>> a[200200];
vector<int> v[200200];

ll fac[200200], facinv[200200], ans = 1ll;

int g (int i) { return p[i] == i ? i : p[i] = g(p[i]); }
void m (int i, int j) { p[g(i)] = g(j); }

int main () {
        fo(i, 0, 200200) {
                fac[i] = i ? fac[i-1] * i % MOD : 1;
                facinv[i] = po(fac[i], MOD-2);
        }

        scanf("%d %d %d", &N, &X, &Y);
        fo(i, 0, N) {
                int c, w; scanf("%d %d", &c, &w);
                a[c-1].PB(MP(w, i));
                p[i] = i;
        }

        fo(i, 0, N) sort(a[i].begin(), a[i].end());
        sort(a, a+N, cmp);

        fo(i, 0, N) fo(j, 1, (int) a[i].size()) {
                if (a[i][0].first + a[i][j].first <= X ||
                                (i && a[0][0].first + a[i][j].first <= Y) ||
                                (!i && a[1].size() && a[1][0].first + a[i][j].first <= Y)) {
                        m(a[i][0].second, a[i][j].second);
                }
        }

        fo(i, 1, N) if (a[0].size() && a[i].size()) {
                if (a[0][0].first + a[i][0].first <= Y) {
                        m(a[0][0].second, a[i][0].second);
                }
        }


        fo(i, 0, N) for (auto j : a[i]) v[g(j.second)].PB(i);
        fo(i, 0, N) {
                ans = ans * fac[int(v[i].size())] % MOD;
                for (int j : v[i]) cnt[j]++;
                for (int j : v[i]) ans = ans * facinv[cnt[j]] % MOD, cnt[j] = 0;
        }

        printf("%lld\n", ans);

        return 0;
}


Measured memory_bytes: 25472
#include <iostream>
using namespace std;
int main() {
	int a,b;
	cin>>a>>b;
	int ans=0;
	if(a!=b){
	ans+=max(a,b)*2-1;
	cout<<ans;
	return 0;
	}
	cout<<2*a;
	
	
	// your code goes here
	return 0;
}


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

int main() {
    int64_t N, H, W;
    cin >> N >> H >> W;
    int64_t ans = 0;
    for (int64_t i = 0; i < N; i++) {
        int64_t A, B;
        cin >> A >> B;
        ans += (A >= H && B >= W);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
s = input()

if(len(s) <= 2):
    print(len(set(list(s))))
    exit()
dp = [0 for _ in range(len(s)+1)]
dp[0] = 0
dp[1] = 1
dp[2] = len(set(list(s[:2])))
for i in range(3,len(s)+1):
    if(s[i-1] != s[i-2]):dp[i] = dp[i-1] + 1
    else:dp[i] = dp[i-3] + 2
print(dp[-1])

Measured memory_bytes: 11368
#include <cstdio>

int main(void){
    char str[26];
    scanf("%s", str);

    int i;
    for(i = 0; i < 26; i++){
        if(!str[i]){
            break;
        }
    }

    char alpha[26];
    for(int j = 0; j < 26; j++){
        alpha[j] = 'a' + j;
    }

    if(i == 26){
        int j;
        for(j = 25; j > 0; j--){
            if(str[j] < str[j-1]){
                continue;
            }else{
                for(int k = 0; k < j - 1; k++){
                    printf("%c", str[k]);
                }
                for(int l = j; l < 26; l++){
                    if(str[j - 1] > str[l]){
                        printf("%c\n", str[l-1]);
                        return 0;
                    }
                }
                printf("%c\n", str[25]);
                return 0;
            }
        }
        printf("-1\n");
        return 0;
    }else{
        for(int j = 0; j < 26; j++){
            for(int k = 0; k < i;k++){
                if(str[k] == alpha[j]){
                    break;
                }
                if(k == i-1){
                    printf("%s%c\n", str, alpha[j]);
                    return 0;
                }
            }
        }
    }

    return 0;
}

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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define v(d_type) vector<d_type>
#define loop(i, s, n) for(int i = s; i < n; i++)
#define min(x, y) (x) > (y) ? (y) : (x)
#define max(x, y) (x) < (y) ? (y) : (x)
#define print_vec(X) loop(i, 0, X.size()) cout << X[i] << "\n"

int main()
{
    boost;
    ll n, sum = 0, sum_odd = 0;
    cin >> n;

    v(ll) dams(n), mountains(n);

    loop(i, 0, n)
    {
        cin >> dams[i];
        sum += dams[i];
    }

    for(int i = 0; i < n - 2; i+=2)
        sum_odd += dams[i];

    mountains[n - 1] = sum - 2*sum_odd;
    for(int i = n - 2; i >= 0; i--)
        mountains[i] = 2*dams[i] - mountains[i + 1];

    loop(i, 0, mountains.size())
        cout << mountains[i] << " ";
    cout << "\n";
    return 0;
}

Measured memory_bytes: 2944
#include "bits/stdc++.h"
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
	#endif

	int n,m;
	cin>>n>>m;
	int ans=0;
	vector<pair<int,int>> a(n);
	for(auto &i:a)cin>>i.first>>i.second;

	sort(a.begin(),a.end());
	int i=0;

	priority_queue<int> q;
	for(int day=1;day<=m;day++)
	{
		while(i!=n and a[i].first<=day)
		{
			q.push(a[i].second);i++;
		}

		if(!q.empty())
		{
			ans+=q.top();
			q.pop();
		}
	}
	cout<<ans;
}

Measured memory_bytes: 4636
n, k, c = map(int, input().split())
s = input()
l = len(s) - 1
i = 0
lb = []
le = []
while i < len(s) and len(lb) < k:
    if s[i] == 'o':
        lb.append(i)
        i += c + 1
        continue
    i += 1

while l > -1 and len(le) < k:
    if s[l] == 'o':
        le.append(l)
        l -= (c + 1)
        continue
    l -= 1

le.sort()
for j in range(0, len(lb)):
    if lb[j] == le[j]:
        print(lb[j]+1)

Measured memory_bytes: 20628
A, B, C, D, E, F = map(int, input().split())

ans = []
memo = []
for a in range(31):
    for b in range(31):
        for c in range(100):
            for d in range(100):
                w = 100 * A * a + 100 * B * b
                s = C * c + D * d
                if  w + s > F: continue
                if E * w / 100 >= s and w + s != 0:
                    ans.append(100 * s / (w + s))
                    memo.append([w + s, s])

print(*memo[ans.index(max(ans))])


Measured memory_bytes: 107984
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <limits>
#include <map>
#include <bitset>

#define rep(i,n) for(int (i) = 0;(i)<(n);(i)++)

using namespace std;
using p = pair<int, int>;
using ll = long long;

vector< vector<int> > memo;

int gcd(int a, int b, int c) {
	int min_num = (a > b) ? b : a;
	if (min_num > c) min_num = c;
	while (min_num != 1) {
		if (a % min_num == 0 && b % min_num == 0 && c % min_num == 0) break;
		min_num--;
	}
	return min_num;
}

int gcd(int a, int b) {
	int m = (a < b) ? a : b;
	while (m != 1) {
		if (a % m == 0 && b % m == 0)break;
		m--;
	}
	return m;
}

ll sum_n2m(ll n, ll m) {
	return m * (m + 1) / 2 - n * (n + 1) / 2;
}

int main() {
	ll big_num = pow(10, 9) + 7;
	ll n,k;
	cin >> n >> k;
	ll ans = 1;
	for (ll i = k; i < n+1; i++) {
		ll s = (i - 1)* i / 2;
		ll e = sum_n2m(n - i, n);
		ans += e - s + 1;
	}
	cout << ans%big_num << endl;
	return 0;
}


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

using namespace std;

using int64 = long long;

constexpr int SIZE = 35;

template<typename T>
void PrintVector(const vector<T>& xs) {
  for (int i = 0; i < xs.size(); i++) {
    if (i > 0) cout << " ";
    cout << xs[i];
  }
}

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

  int n;
  cin >> n;

  bool is_even = false;
  bool is_odd = false;
  vector<int64> xs;
  vector<int64> ys;
  for (int i = 0; i < n; i++) {
    int64 x, y;
    cin >> x >> y;
    xs.push_back(x);
    ys.push_back(y);
    if ((x + y) % 2 == 0) is_even = true;
    else is_odd = true;
  }
  if (is_even && is_odd) {
    cout << -1 << endl;
    return 0;
  }

  vector<int64> ls;
  for (int i = SIZE - 1; i >= 0; i--) {
    ls.push_back(1LL << i);
  }
  if (is_even) {
    ls.push_back(1);
  }
  cout << ls.size() << endl;
  PrintVector(ls);
  cout << endl;

  for (int q = 0; q < n; q++) {
    int64 cur_x = -xs[q];
    int64 cur_y = -ys[q];
    string answer;
    for (int i = 0; i < ls.size(); i++) {
      if (abs(cur_x) >= abs(cur_y)) {
        if (cur_x >= 0) {
          answer.push_back('L');
          cur_x -= ls[i];
        } else {
          answer.push_back('R');
          cur_x += ls[i];
        }
      } else {
        if (cur_y >= 0) {
          answer.push_back('D');
          cur_y -= ls[i];
        } else {
          answer.push_back('U');
          cur_y += ls[i];
        }
      }
    }
    if (cur_x != 0 || cur_y != 0) {
      cerr << "Unexpected!" << endl;
      return 1;
    }
    cout << answer << endl;
  }
}


Measured memory_bytes: 384
#include<iostream>
#include<bits/stdc++.h>
#include<map>
#include<iterator>
#include<string>
#include<string.h>
#include<math.h>
#include<vector>
#define ll long long int
#define mod 1000000007
using namespace std;

vector<int> fun(vector<int>&vec)
{
    vec.push_back(90);
    return vec;
}

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    ll n;
    cin>>n;
    string str;
    cin>>str;
    int count1=1;
    char a=str[0];
    for(int i=1; i<n;i++)
    {
        if(str[i]!=a)
        {
            count1+=1;
            a=str[i];
        }
    }
    cout<<count1<<endl;

  return 0;
}


Measured memory_bytes: 512
INF = 10 ** 6
n = gets.to_i
nums = gets.split.map(&:to_i).sort
tally = nums.tally
dp = Array.new(INF + 1, true)

ans = 0
nums.each do |num|
  next unless dp[num]
  num.step(INF + 1, num) { |i| dp[i] = false }
  ans += 1 if tally[num] == 1
end

puts ans


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

int main()
{
    int N, sum, sum2=0, ans=0;
    cin >> N;

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

    for (int i = N; i >0; i--)
    {
        int tmp = i;
        sum = 0;
        if(tmp%2==0){
            while(tmp>0&&tmp%2==0){
                tmp = tmp / 2;
                sum++;
            }
        }
        //cout << i << ":" << sum << endl;
        if(sum2<sum){
            sum2 = sum;
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
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; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int a,b;
    cin>>a>>b;
    cout<<6-a-b<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int mennum = reader.nextInt();
        int tallnum = reader.nextInt();
		int [] mentalls = new int[mennum];
		int cnt = 0;
        for(int i = 0; i < mennum;i++) {
        	mentalls[i] = reader.nextInt();
        	if(mentalls[i] >= tallnum) {
        		cnt++;
        	}
        }
        System.out.println(cnt);
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



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

int dp[101];
 
int32_t main()
{
  int a, b, c, d; cin >> a >> b >> c >> d;
  for (int i=a+1; i<=b; i++) dp[i]++;
  for (int i=c+1; i<=d; i++) dp[i]++;
  int res = 0;
  for (int i=0; i<=100; i++) if (dp[i]==2) res++;
  cout << res;
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    ll ans = 0;
    for (int tmp = 0; tmp < 1 << (n - 1); ++tmp) {
        int j = 0;
        while(j < n) {
            int prev = j;
            while(!((tmp >> j) & 1) && j < n) j++;
            ans += stoll(s.substr(prev, j - prev + 1));
            j++;
        }
    }
    cout << ans << endl;
}


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

int main(){
    int num;
    int table[6]={};
    cin>>num;
    double h;
    for(int i=0; i<num;i++ ) {
        cin>>h;
        if(h>=185.0){
            table[5]++;
        }else if(h>=180.0&&h<185.0){
            table[4]++;
        }else if(h>=175.0&&h<180.0){
            table[3]++;
        }else if(h>=170.0&&h<175.0){
            table[2]++;
        }else if(h>=165.0&&h<170.0){
            table[1]++;
        }else{
            table[0]++;
        }
    }
    for(int i=0; i<6; i++){
        printf("%d:", i+1);
        for(int j=0; j<table[i];j++){
            printf("*" );
        }
        printf("\n");
    }
}



Measured memory_bytes: 3184
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
typedef long long LL;
const int N = 1e5 + 5;
int read() {
	int x = 0, f = 1; char ch;
	while(! isdigit(ch = getchar())) (ch == '-') && (f = -f);
	for(x = ch ^ 48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48));
	return x * f;
}
template <class T> T Max(T a, T b) { return a > b ? a : b; }
template <class T> T Min(T a, T b) { return a < b ? a : b; }\
struct Edge {
	int to;
	Edge *nxt;
	Edge(int to, Edge *nxt) : to(to), nxt(nxt) {}
} *head[N];
void add(int x, int y) {head[x] = new Edge(y, head[x]);}
struct edge {int x, y;} a[N];
struct node {
	int d, id;
	friend bool operator < (node a, node b) {
		return a.d == b.d ? a.id < b.id : a.d > b.d;
	}
} e[N];
int n, tot, siz[N], dis[N];
void dfs(int x, int f) {
	for(Edge *i = head[x]; i; i = i->nxt) {
		if(i->to == f) continue;
		dis[i->to] = dis[x] + 1;
		dfs(i->to, x);
	}
}
signed main() {
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read();
	for(int i = 1; i <= n; ++ i) siz[i] = 1, e[i] = (node){read(), i};
	sort(e + 1, e + n + 1);
	for(int i = 1; i < n; ++ i) {
		int delta = e[i].d + 2 * siz[i] - n;
		int l = 1, r = n + 1;
		while(l < r) {
			int mid = (l + r) >> 1;
			if(e[mid].d <= delta) r = mid;
			else l = mid + 1;
		}
		if(e[l].d != delta) return puts("-1"), 0;
		int x = e[i].id, y = e[l].id;
		add(x, y); add(y, x);
		a[++ tot] = (edge) {x, y};
		siz[l] += siz[i];
	}
	dfs(e[n].id, 0);
	LL sum = 0;
	for(int i = 1; i <= n; ++ i) sum += dis[i];
	if(sum == e[n].d) for(int i = 1; i <= tot; ++ i) printf("%d %d\n", a[i].x, a[i].y);
	else puts("-1");
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 14720
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input.trim());
	//input = input.trim().split(" ");
	input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var a = parseInt(input[0].split(" ")[0]);
  var b = parseInt(input[0].split(" ")[1]);
  var s = input[1];
  for(var i = 0; i < s.length; i++){
    var tmp = s.slice(i,i+1);
    if(i == a && tmp != "-"){
       myout("No");
      return;
       }else if(i != a && tmp == "-"){
                myout("No");
         return;
    }
  }
  myout("Yes");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 7372
n,m = map(int,input().split())
a = list(map(int,input().split()))
limit = sum(a) * (1/(4*m))
ans=0
for i in range(n):
    if(a[i]<limit):
        continue
    ans += 1
if(ans >=m):
    print('Yes')
else:
    print('No')

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

int main(void){
    int H,W;cin>>H>>W;
    char A[H+2][W+2];
    for(int i=0;i<H+2;i++){
        for(int l=0;l<W+2;l++){
            if(i==0||i==H+1||l==0||l==W+1){
                A[i][l]='#';
            }
            else{
                cin>>A[i][l];
            }
        }
    }
    for(int i=0;i<H+2;i++){
        for(int l=0;l<W+2;l++){
            cout<<A[i][l];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <algorithm>    
#include <cmath>
#include <map>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <set>
#include <functional>
#define int long long
#define mod(int)(1000000007)
using namespace std;
char maze[2134][2134];
int cost[1234][1234], dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
signed main() {
	int n, m, ans = 0; char a;
	cin >> n >> m; int sx = 1, sy = 1, gx = n, gy = m;
	const int INF = 1000000000000; typedef pair<int, int>P;
	for (int h = 1; h <= n; h++) {
		for (int i = 1; i <= m; i++) {
			cin >> a; maze[h][i] = a;
		}
	}
	queue<P> que;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cost[i][j] = INF;
		}
	}
	que.push(P(sx, sy));
	if (maze[sx][sy] == '#') { cost[sx][sy] = 1; }
	else { cost[sx][sy] = 0; }
	while (que.size()) {
		P p = que.front(); que.pop();
		if (p.first == gx && p.second == gy) {
			break; //really?
		}
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (0 < nx && nx <= n && 0 < ny && ny <= m) {
				if (maze[nx][ny] == '.' && cost[p.first][p.second] < cost[nx][ny]) {
					que.push(P(nx, ny));
					cost[nx][ny] = cost[p.first][p.second];
				}
				if (maze[nx][ny] == '#') {
					if (maze[p.first][p.second] == '#' && cost[p.first][p.second] < cost[nx][ny]) {
						que.push(P(nx, ny));
						cost[nx][ny] = cost[p.first][p.second];
					}
					if (maze[p.first][p.second] == '.' && cost[p.first][p.second] + 1 < cost[nx][ny]) {
						que.push(P(nx, ny));
						cost[nx][ny] = cost[p.first][p.second] + 1;
					}
				}
			}
		}
	}
	cout << cost[gx][gy] << endl;
	return 0;
}

Measured memory_bytes: 2816
-- Circumscribed Circle of a Triangle
import Text.Printf -- printf

main = getContents >>= putStr . solve

solve :: String -> String
solve = unlines . map (unwords . map floatFormat . centerAndRadius . map read . words) . tail . lines

floatFormat :: Float -> String
floatFormat = printf "%.3f"

centerAndRadius :: [Float] -> [Float]
centerAndRadius [x1,y1,x2,y2,x3,y3] = [px,py] ++ [r]
  where
    r = sqrt $ (px-x1)^2 + (py-y1)^2
    [px,py] = simul [2*(x2-x1),2*(y2-y1),x2^2-x1^2+y2^2-y1^2,2*(x3-x2),2*(y3-y2),x3^2-x2^2+y3^2-y2^2]

simul :: Fractional a => [a] -> [a]
simul [a,b,c,d,e,f] = [x,y]
  where
    det = a * e - d * b
    x = (c * e - b * f) / det
    y = (a * f - c * d) / det

Measured memory_bytes: 4476
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

li = rl()
max_ = max(li)
k = ri()
li.remove(max_)
print(sum(li) + max_ * 2**k)














Measured memory_bytes: 26948
#include<stdio.h>
int main(void){
    int m,f,r;
    while(1){
        scanf("%d %d %d",&m,&f,&r);
        if(((m==f)&&(f==r))&&(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){
            if(r>=50)
                printf("C\n");
            else
                printf("D\n");
        }
        else
            printf("F\n");
    }
    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

const int mod = 1e9+7;
const int N = 1e5+5;
vector<int>g[N], v;
 vector<bool>vis(N);

void bfs()
{
    queue<int>q;
    q.push(1);
    vis[1] = 1;
    while(!q.empty())
    {
        int u = q.front();
        q.pop();
        for(auto i:g[u])
        {
            if(vis[i] == false)
            {
                v[i] = u;
                vis[i] = 1;
                q.push(i);
            }
        }
    }
}

int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m;
    cin>>n>>m;
    v.assign(n+10,0);
    while(m--)
    {
        int a, b;
        cin>>a>>b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    
    bfs();
    bool f =0;
    for(int i=2;i<=n;i++)
    {
        if(v[i] == 0)
        {
            f=1;
            break;
        }
    }
    if(f==1)
        cout<<"No";
    else
    {
        cout<<"Yes\n";
        for(int i=2;i<=n;i++)
            cout<<v[i]<<'\n';
    }


    return 0;
}

Measured memory_bytes: 10264
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	

using namespace std;

int main() {
	int N;
	int K;
	cin >> N >> K;
	N -= K;
	if (K == 1) {
		cout << 0 << endl;
	}
	else {
		cout << N << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N 100

int compare(const void *a, const void *b) {
	char *s = *(char **) a;
	char *t = *(char **) b;

	return strcmp(s, t);
}

int main() {
	static char ss[N][N + 1], *tt[N];
	int n, l, i;

	scanf("%d%d", &n, &l);
	for (i = 0; i < n; i++) {
		scanf("%s", ss[i]);
		tt[i] = ss[i];
	}
	qsort(tt, n, sizeof *tt, compare);
	for (i = 0; i < n; i++)
		printf("%s", tt[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

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

const ll INF = 1LL << 60;

int main() {
    int H, N; cin >> H >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

    vector<vector<ll>> dp(N+1, vector<ll>(H+1, INF));
    dp[0][0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= H; ++j) {
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][min(j+A[i], H)], dp[i+1][j] + B[i]);
        }
    }
    cout << dp[N][H] << endl;
}

Measured memory_bytes: 78592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int area = a*b;
		int length = 2*(a+b);
		System.out.println(area + " " + length);
	}
}

Measured memory_bytes: 26012
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, q, i, j, k, l, r, ans;
	string s;
	cin >> n >> q >> s;
	vector<int> a(n + 1, 0), ss(n + 1, 0);
	for (i = 2; i <= n; i++) {
		if ((s[i - 2] == 'A') && (s[i - 1] == 'C')) a[i] = 1;
		ss[i] = ss[i - 1] + a[i];
	}

	while (q--) {
		cin >> l >> r;
		if (s[l - 1] == 'C') l++;
		if (s[r - 1] == 'A') r--;

		if (l > r) ans = 0;
		else ans = ss[r] - ss[l - 1];
		cout << ans << "\n";
	}


	return 0;
}

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

bool p(string s){
	string tmp;
	for(int i=s.size()-1; i >= 0 ; i--) tmp += s[i];
	return tmp == s;
}



int main(){
	string s;
	cin >> s;
		
	string s1, s2;
	
	for(int i=0; i < s.size()/2; i++){
		s1 += s[i];
		s2 += s[s.size()-1-i];
	}

	if(p(s) && p(s1) && p(s2)) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec p(n);
    init(p);
    int cnt = 0;
    For(i, 1, n - 2) {
        if (p[i - 1] < p[i] and p[i] < p[i + 1]) {
            cnt++;
        } else if (p[i - 1] > p[i] and p[i] > p[i + 1]) {
            cnt++;
        }
    }
    print(cnt);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
int main( ) {
    //freopen("A.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char c;
    rep(i,0,3){
        cin >> c;
        cout << ((c=='9')?1:9);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3608
#D問題
N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]

#TwoDimensionSort
#AB
AB=sorted(AB, key=lambda x: x[1])

time = 0
flag = 0
for i in range(N):
    time+=AB[i][0]
    if time <= AB[i][1]:
        pass
    else:
        flag = 1
        break
        
if flag == 0:
    print("Yes")
else:
    print("No")

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

public class Main {
	static Scanner sc = new Scanner(System.in);
	static String[] weekday = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
	static int S, N, T, P, M;

	public static void main(String[] args) {
		while (true) {
			S = sc.nextInt();
			if (S == 0) break;
			N = sc.nextInt();
			T = sc.nextInt();
			int[] on = new int[7 * 24 * 60];
			int[] sum = new int[on.length * 2];
			String d = sc.next();
			boolean[] day = new boolean[7];
			if (d.equals("All")) {
				Arrays.fill(day, true);
			} else {
				for (int i = 0; i < 7; ++i) {
					if (weekday[i].equals(d)) day[i] = true;
				}
			}
			String time = sc.next();
			for (int i = 0; i < 7; ++i) {
				if (!day[i]) continue;
				if (time.equals("All")) {
					for (int j = 0; j < 24 * 60 - (d.equals("All") ? 0 : 1); ++j) {
						on[i * 24 * 60 + j] = 1;
					}
				} else if (time.equals("Day")) {
					for (int j = 6 * 60; j < 18 * 60 - 1; ++j) {
						on[i * 24 * 60 + j] = 1;
					}
				} else {
					for (int j = 0; j < 6 * 60 - 1; ++j) {
						on[i * 24 * 60 + j] = 1;
					}
					for (int j = 18 * 60; j < 24 * 60 - (d.equals("All") ? 0 : 1); ++j) {
						on[i * 24 * 60 + j] = 1;
					}
				}
			}
			for (int i = 1; i <= on.length; ++i) {
				sum[i] = sum[i - 1] + on[i - 1];
			}
			for (int i = 1; i < on.length; ++i) {
				sum[on.length + i] = sum[on.length + i - 1] + on[i - 1];
			}
			P = sc.nextInt();
			M = sc.nextInt();
			double ans = 0;
			for (int i = 0; i < on.length; ++i) {
				ans = Math.max(ans, solve(sum, i));
			}
			System.out.printf("%.10f\n", ans);
		}
	}

	static double solve(int[] sum, int t) {
		int c = 0;
		for (int i = 0; i < M; ++i) {
			if (sum[t + S] - sum[t] == S) c += N;
			t += T;
			t %= (7 * 24 * 60);
		}
		return 1 - Math.pow(1 - 1.0 / P, c);
	}

}

Measured memory_bytes: 39092
package main

import "fmt"

func main() {
	var n, k, r, s, p, point int
	var t string
	fmt.Scan(&n, &k, &r, &s, &p, &t)
	me := make([]rune, n)
	for i := 0; i < n; i++ {
		switch t[i] {
		case 'r':
			if i >= k && me[i-k] == 'p' {
				continue
			}
			point += p
			me[i] = 'p'
		case 's':
			if i >= k && me[i-k] == 'r' {
				continue
			}
			point += r
			me[i] = 'r'
		case 'p':
			if i >= k && me[i-k] == 's' {
				continue
			}
			point += s
			me[i] = 's'
		}
	}
	fmt.Printf("%d", point)
}


Measured memory_bytes: 1664
#include <cstdio>

using namespace std;

const int Max_N(2050);
const int Max_V(2000 * 2000);
const int MOD(1000000000 + 7);
typedef long long int LL;

inline void update(int &a, const int &b)
{
	((a += b) >= MOD) ? (a -= MOD) : 0;
}

inline int Mult(const int &a, const int &b)
{
	return static_cast<int>(static_cast<LL>(a) * static_cast<LL>(b) % static_cast<LL>(MOD));
}

int N, K, F[Max_N][Max_N], Fac[Max_V + 5], Inv[Max_V + 5];
//每个颜色相当于放一个0然后在后面放K - 1个某种颜色 
//F[i][j]表示放了i个0，确定了j个某种颜色剩下K - 1个位置的方案数
//转移枚举当前位置放一个0，还是增加某种颜色的K - 1个位置（当前位置必须是这种颜色） 

void exgcd(const int &a, const int &b, int &x, int &y)
{
	if (b == 0)
		x = 1, y = 0;
	else
		exgcd(b, a % b, y, x), y -= x * (a / b);
}

inline int inverse(const int &a)
{
	int invx, invy;
	exgcd(a, MOD, invx, invy);
	return (invx % MOD + MOD) % MOD;
}

inline int C(const int &n, const int &m)
{
	return Mult(Mult(Fac[n], Inv[n - m]), Inv[m]);
}

int main()
{
	Fac[0] = 1;
	for (int i = 1;i <= Max_V;++i)
		Fac[i] = Mult(Fac[i - 1], i);
	Inv[Max_V] = inverse(Fac[Max_V]);
	for (int i = Max_V - 1;i >= 0;--i)
		Inv[i] = Mult(Inv[i + 1], i + 1);
	scanf("%d%d", &N, &K);
	if (K == 1)
	{
		printf("1");
		return 0;
	}
	F[1][0] = 1;
	for (int i = 1;i <= N;++i)
		for (int j = 0;j <= i;++j)
		{
			update(F[i + 1][j], F[i][j]);
			if (j + 1 <= i)
				update(F[i][j + 1], Mult(Mult(F[i][j], N - j), C((N - i) + (N - j) * (K - 1) - 1, K - 2)));
		}
	printf("%d", F[N][N]);
	return 0;
}

Measured memory_bytes: 47488