akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAXN = 100000;
static const int MAX = 1000000000;

int main(){
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int ans = 0;
    if(A >= K){
        ans = K;
    }
    else if(A + B >= K){
        ans = A;
    }
    else{
        ans = A + B - K + A;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
char s[10];main(){for(;~(scanf("%s",s));)
if(s[0]==s[1]&&s[0]==s[2]&&s[0]-'s')printf("%c\n",s[0]);
else if(s[3]==s[4]&&s[3]==s[5]&&s[3]-'s')printf("%c\n",s[3]);
else if(s[6]==s[7]&&s[6]==s[8]&&s[6]-'s')printf("%c\n",s[6]);
else if(s[0]==s[3]&&s[0]==s[6]&&s[0]-'s')printf("%c\n",s[0]);
else if(s[1]==s[4]&&s[1]==s[7]&&s[1]-'s')printf("%c\n",s[1]);
else if(s[2]==s[5]&&s[2]==s[8]&&s[2]-'s')printf("%c\n",s[2]);
else if(s[0]==s[4]&&s[0]==s[8]&&s[0]-'s')printf("%c\n",s[0]);
else if(s[2]==s[4]&&s[2]==s[6]&&s[2]-'s')printf("%c\n",s[2]);
else puts("d");exit(0);}

Measured memory_bytes: 552
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#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 srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

ll dp[MAX_N], h[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, K;
    cin >> n >> K;
    rep(i,n){
        cin >> h[i];
    }
    rep(i,n+1){
        dp[i] = (1LL << 60);
    }
    dp[0] = 0;
    rep(i,n-1){
        srep(j,1,min(K+1,n-i)){
            cmn(dp[i+j], dp[i]+abs(h[i+j]-h[i]));
        }
    }
    cout << dp[n-1] << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
const int mod=1e9+7;
long long qpow(long long x,long long p){
	long long ans=1;
	while(p){
		if(p&1)
			ans=(ans*x)%mod;
		x=(x*x)%mod;
		p>>=1;
	}
	return ans%mod;
}
int main(){
	long long n;
	cin>>n;
	if(n<2){
		cout<<"0\n";
		return 0;
	}
	long long ans=(((qpow(10,n)%mod-qpow(9,n)%mod+mod)%mod-qpow(9,n)%mod+mod)%mod+qpow(8,n)%mod)%mod;
	cout<<ans<<'\n';
}

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

int main(){
  int n,count = 0;
  cin >> n;
  vector<int> data(n),copy(n);
  for(int i=0; i<n; i++){
    cin >> data.at(i);
  }
  
  copy = data;
  
  sort(copy.begin(),copy.end());
  
  for(int i=0; i<n; i++){
    if(data.at(i) == copy.at(i)) count++;
  }
  
  if( n-count == 0 || n-count == 2){
    cout << "YES" << endl;
  }else{
    cout << "NO" <<endl;
  }
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b ] <- readInts
	print $ which ( a + b ) ( max a b * 2 - 1 ) $ a == b

Measured memory_bytes: 380
#include <iostream>
#include<bits/stdc++.h>
#define rep(k,i,n) for(int i=k;i<n;++i)
using namespace std;
int main(void){
    // Your code here!
    long N,M,a,b;
    cin>>N>>M;
    priority_queue<long>A;
    rep(0,i,N){
        cin>>a;
        A.push(a);
    }
    rep(0,i,M){
        b=A.top();
        A.pop();
        A.push(b/2);
    }
    long ans=0;
    while(!A.empty()){
        ans +=A.top();
        A.pop();
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1400
#include <cstdio>
#include <string.h>
#include <algorithm>
#include<iostream>
#include<math.h>
#include<sstream>
#include<vector>
#include<stack>
using namespace std;
#define maxn 105
int clr[10005];
int a[maxn][maxn];

int main(){
	int h,w,n;
	
	cin>>h>>w>>n;
	for(int i=1;i<n+1;i++)
		cin>>clr[i];
		
	memset(a,0,sizeof(a));
	int k=1,t=1,x=0,y=w-1;
	while(!clr[k]) k++;
	a[x][y] = k;
	clr[k]--;
	
	while(k<h*w){
		
		while(x+1<h && !a[x+1][y]){
			k++; 
			if(clr[t] == 0) t++;
			a[++x][y]=t;
			clr[t]--;
		}
		while(y-1>=0 && !a[x][y-1]){
			k++;
			if(clr[t] == 0) t++;
			a[x][--y]=t;
			clr[t]--;
		}
		while(x-1>=0 && !a[x-1][y]){
			k++;
			if(clr[t] == 0) t++;
			a[--x][y]=t;
			clr[t]--;
			
		}
		while(y+1<w && !a[x][y+1]){
			k++;
			if(clr[t] == 0) t++;
			a[x][++y]=t;
			clr[t]--;
		}
    }
    
    for(int i=0;i<h;i++){
    	cout<<a[i][0];
    	for(int j=1;j<w;j++)
    		cout<<" "<<a[i][j]; 
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
char a[100], b[100];
int n, m;
int main()
{
	scanf("%s%s", a, b);
	n = strlen(a);
	m = strlen(b);
	for(int i = 0; i < min(n, m); i++)printf("%c%c", a[i], b[i]);
	if(n != m)
	{
		if(n > m)printf("%c\n",a[n - 1]);
		else printf("%c\n", b[m - 1]);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


int main(){FIN
    ll n,k;cin>>n>>k;
    if (k%2==1){
        ll ans = pow(n/k,3);
        cout<<ans<<endl;
        return 0;
    }
    ll ans=0;
    ans += pow(n/k, 3);
    n  += k/2;
    ans += pow(n/k, 3);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second
#define setprecision(d) cout << setprecision(d);

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

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





signed main(){
	ll n;
	cin >> n;
	ll array[n],x[n],y[n];
	double ans = 0;

	rep(i,0,n) cin >> x[i] >> y[i];

	rep(i,0,n) array[i] = i;

	do{
		rep(i,0,n-1){
			ans += sqrt(pow((x[array[i]]-x[array[i+1]]),2)+pow((y[array[i]]-y[array[i+1]]),2));
		}
	}while(next_permutation(array,array+n));

	ll m = 1;

	rep(i,1,n+1) m *= i;

	setprecision(10);
	cout << (double)ans/m << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long 
#define mp make_pair
deque<pair<int,int> > q;
bool vis[100005];
int k,ans=0; 
int main()
{
	cin>>k;
	q.push_front(mp(1,1));
	//[1]=1;
	while(!q.empty()){
		pair<int,int> x=q.front();
		q.pop_front();
		//cout<<x.first<<" ";
		if(x.first==0){
			//cout<<1;
			cout<<ans+x.second;
			return 0;
		}
		if(vis[x.first]){
			continue;
		}
		vis[x.first]=1;
		q.push_back(mp((x.first+1)%k,x.second+1));
		q.push_front(mp((x.first*10%k),x.second));
	}
    return 0;
}

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

struct UnionFind {
    // par[i]:iの親の番号　(例) par[3] = 99 : 3の親が99
    vector<int> par;

    UnionFind(int N) : par(N) {  // 初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {  // xとyの木を併合
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    vector<int> p(N);

    rep(i, N) {
        int pn;
        cin >> pn;
        pn--;
        p[i] = pn;
    }

    rep(k, M) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        uf.unite(x, y);
    }

    int ans = 0;
    rep(i,N){
      if(uf.same(i,p[i])) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import java.lang.*; 
public class Main {
	public static void main(String[] args)  throws Exception{
		Scanner sc = new Scanner(System.in);
		int tt = sc.nextInt();
		if(tt<600){
		    System.out.println(8);
		}else 
		if(tt<800){
		    System.out.println(7);
		}else
		if(tt<1000){
		    System.out.println(6);
		}else if(tt<1200){
		    System.out.println(5);
		}else
		if(tt<1400){
		    System.out.println(4);
		}else
		if(tt<1600){
		    System.out.println(3);
		}else
		if(tt<1800){
		    System.out.println(2);
		}else
		if(tt<2000){
		    System.out.println(1);
		}
    }
}

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

#define pb push_back
#define fi first
#define se second
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pii pair<int,int>
#define mod 998244353

const int N=(1<<18)-1;
int lowbit(int x) {return x&(-x);}

int n;
ll h[N],a[N],tree[2*N+11];

void update(int node,ll v) {
	int cur=node+N;
	tree[cur]=v;
	cur/=2;
	while (cur) {
		tree[cur]=max(tree[cur*2],tree[cur*2+1]);
		cur/=2;
	}
	return;
}

ll query(int l,int r,int cur,int x,int y) {
	if (l>r||x>y) return 0;
	if (r<x||l>y) return 0;
	if (l<=x&&r>=y) return tree[cur];
	if (x==y) return tree[cur];
	ll a=query(l,r,cur*2,x,x+(y-x)/2);
	ll b=query(l,r,cur*2+1,x+(y-x)/2+1,y);
	return max(a,b);
}

int main(){
	scanf("%d",&n);
	for (int i=0;i<n;i++) scanf("%d",&h[i]);
	for (int i=0;i<n;i++) scanf("%d",&a[i]);
	for (int i=0;i<n;i++) {
		ll tmp=query(1,h[i]-1,1,1,N);
		update(h[i],tmp+(ll)a[i]);
	}
	cout<<tree[1];
	return 0;
}


Measured memory_bytes: 7936
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MAX 100000
typedef long long ll;
typedef pair<ll,int> P;

bool check(int x){
  int count=1;
  while(true){
    x/=10;
    if(x==0) break;
    else count++;
  }
  return count%2;
}

int main(){
  int N,ans=0;
  cin>>N;
  for(int i=1;i<=N;i++){
    if(check(i)) ans++; 
  }
  cout<<ans<<endl;
}


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

int main()
{
  int N, L;
  cin >> N >> L;
  auto sum = N*(2*L + N - 1)/2;
  auto min = L;
  auto max = L + N - 1;
  if (min*max <= 0)
    cout << sum;
  else if (max < 0)
    cout << sum - max;
  else
    cout << sum - min;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

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; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353;
constexpr int MAX = 5000000;


int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	ll n, X; cin >> n >> X;
	const int N = 32;
	vector<ll> x(n); for (int i = 0; i < n; i++) cin >> x[i];
	vector<vector<int>> lfto(N, vector<int>(n + 1, n)), rgto(N, vector<int>(n + 1, -1));
	vector<vector<ll>> lfsm(N, vector<ll>(n + 1)), rgsm(N, vector<ll>(n + 1));
	vector<vector<ll>> lfcn(N, vector<ll>(n + 1)), rgcn(N, vector<ll>(n + 1));
	{
		int cur = 0;
		for (int i = 0; i < n; i++) {
			while (cur < n and x[cur] - x[i] < X) cur++;
			lfto[0][i] = cur, lfsm[0][i] = cur, lfcn[0][i] = 1;
		}
	}
	{
		int cur = n - 1;
		for (int i = n - 1; i >= 0; i--) {
			while (cur >= 0 and x[i] - x[cur] < X) cur--;
			rgto[0][i] = cur, rgsm[0][i] = cur;
		}
	}

	for (int i = 1; i < N; i++) {
		for (int j = 0; j < n; j++) {
			lfto[i][j] = lfto[i - 1][lfto[i - 1][j]];
			if (rgto[i - 1][j] >= 0) rgto[i][j] = rgto[i - 1][rgto[i - 1][j]];
			else rgto[i][j] = -1;
			lfsm[i][j] = lfsm[i - 1][j] + lfsm[i - 1][lfto[i - 1][j]];
			if (rgto[i - 1][j] >= 0) rgsm[i][j] = rgsm[i - 1][j] + rgsm[i - 1][rgto[i - 1][j]];
			lfcn[i][j] = lfcn[i - 1][j] + lfcn[i - 1][lfto[i - 1][j]];
		}
	}
	int kkt; cin >> kkt;
	while (kkt--) {
		int l, r; cin >> l >> r;
		l--; r--;
		ll lf = 0;
		ll rg = 0;
		ll cnt = 1;
		{
			int cur = l;
			for (int i = N - 1; i >= 0; i--) {
				if (lfto[i][cur] <= r) {
					lf += lfsm[i][cur];
					cnt += lfcn[i][cur];
					cur = lfto[i][cur];
				}
			}

		}
		{
			int cur = r;
			for (int i = N - 1; i >= 0; i--) {
				if (rgto[i][cur] >= l) {
					rg += rgsm[i][cur];
					cur = rgto[i][cur];
				}
			}
		}
		lf += l;
		rg += r;
		//cout << lf << " " << rg << " "<< cnt<<endl;
		cout << rg - lf + cnt << "\n";
	}
	return 0;
}


Measured memory_bytes: 257380
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    s = int(input())
    ans =0

    for i in range(1,s+1):
        count =0
        if i %2 ==0:
            continue
        for j in range(1,i+1):
            if i % j  == 0:
                count +=1

        if count ==8:
            ans +=1

    print(ans)


Measured memory_bytes: 5144
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int MaxN = 1e5;
typedef long long LL;

LL n, m;
int main()
{
	while(scanf("%lld %lld", &n, &m) != EOF)
	{
		if(abs(n - m) <= 1) printf("Brown\n");
			else printf("Alice\n");
	}
	return 0;
}

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

int main(){
	while(1){
		long n;
		double best=100;
		long ans;
		
		scanf(" %ld", &n);
		if(n==0) break;
		
		for(long i=0; i<n; ++i){
			long num;
			double h, w;
			scanf(" %ld %lf %lf", &num, &h, &w);	
		
			h/=100;
			double bmi=w/h/h;
			bmi-=22;
			if(bmi<0) bmi = -bmi;
		
			if(bmi<best){
				ans=num;
				best=bmi;	
			}
			else if(bmi==best){
				if(num<ans) ans=num;	
			}
		}
	
		printf("%ld\n", ans);
	}
	return 0;
}

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

int main()
{
loop:
  int min = 1 << 30, max = 0, sum = 0, n;
  cin >> n;
  if(!n)
    return 0;
  for(int i = 0; i < n; i++)
  {
    int tmp;
    cin >> tmp;
    max = max < tmp ? tmp : max;
    min = min > tmp ? tmp : min;
    sum += tmp;
  }
  cout << (sum - max - min) / (n - 2) << endl;
  goto loop;
}

Measured memory_bytes: 1160
import itertools as it
def main():
    n,m,k=map(int,input().split())
    a = [0]
    a.extend(it.accumulate(map(int, input().split())))
    b = [0]
    b.extend(it.accumulate(map(int, input().split())))
    
    ans = 0
    M = m
    for A in range(n+1):
        aa = a[A]
        Kaa = k-aa
        if Kaa < 0:
            break
        for B in range(M,-1,-1):
            if b[B] <= Kaa:
                ans = max(ans, A+B)
                M = B
                break
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 45696
#include <iostream>
using namespace std;
int main()
{
   int n,k;
   cin>>n>>k;
   int ans = 1e5;
   if(n%k ==0)
    {
       cout<<0<<endl;
       return 0;
    }
   else
   {
      cout<<1;
      /*for(int i=1;i*k<n;i++)
      {
               ans = min(ans,n-k*i);
      }*/
      //int y = n/k;
      //n = n-k*y;
   }
}

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

using namespace std;


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

    int n = 3;
    vector<vector<int>> C(n, vector<int>(n, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> C[i][j];
        }
    }

    bool ok = true;
    for (int i = 1; i < n; ++i) {
        for (int j = 1; j < n; ++j) {
            if (C[i - 1][j] - C[i - 1][j - 1] != C[i][j] - C[i][j - 1]) {
                ok = false;
            }
        }
    }
    for (int j = 1; j < n; ++j) {   
        for (int i = 1; i < n; ++i) {
            if (C[i][j - 1] - C[i - 1][j - 1] != C[i][j] - C[i - 1][j]) {
                ok = false;
            }
        }
    }

    if (ok) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

# In[30]:


"""問題文

とある世界では、今日はクリスマスイブの前日です。

高羽氏は、デパートで N
個の品物を買おうとしています。i 個目の品物 (1≤i≤N) の定価は pi

円です。

彼は割引券を持っており、N
個のうち最も定価が高い品物 1 個を定価の半額で買うことができます。残りの N−1

個の品物に対しては定価を支払います。支払金額は合計でいくらになるでしょうか？
制約

    2≤N≤10

100≤pi≤10000
pi
は偶数である。"""


# In[32]:


N=int(input())

p=[]
for i in range(N):
    p.append(int(input()))

#pをソート
p.sort(reverse=True)
#一番値段の高いモノを半額
p[0]=p[0]/2

tot=0
for i in p:
    tot=tot+i
    
print(int(tot))



Measured memory_bytes: 3060
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

void swap(int *i, int *j)
{
	int temp = *i;
	*i = *j;
	*j = temp;
}

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a > b) swap(&a, &b);
	if (b > c) swap(&b, &c);
	if (a > b) swap(&a, &b);
	cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 1164
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  int n, a, b; readV(n, a, b);
  writeln(min(n*a, b));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
int n, l;
vector<vector<int>> adj;
double dp[3002][3002];

void solve(){
	int n;
	cin>>n;
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		double p;
		cin>>p;
		for(int j=0;j<=i;j++){
			if(j==0){
				dp[i][j]=dp[i-1][j]*(1-p);
				continue;
				}
			dp[i][j]=dp[i-1][j]*(1-p)+dp[i-1][j-1]*p;
			}
		}
	double ans=0;
	for(int i=n/2+1;i<=n;i++){
		ans+=dp[n][i];
		}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)solve();
}


Measured memory_bytes: 68992
n,k = list(map(int,input().split(" ")))
s1,s2,s3 = list(map(int,input().split(" ")))
t = input()

scores = dict()
win = dict()
scores["r"] = s1
scores["s"] = s2
scores["p"] = s3

win["r"] = "p"
win["s"] = "r"
win["p"] = "s"

isWin = [False for _ in range(len(t))]

total = 0
for i in range(n):
    if i < k:
        total += scores[win[t[i]]]
        isWin[i] = True
    else:
        if t[i] != t[i-k]:
            total += scores[win[t[i]]]
            isWin[i] = True
        else:
            if not isWin[i-k]:
                total += scores[win[t[i]]]
                isWin[i] = True
            else:
                isWin[i] = False

print(total)
            



Measured memory_bytes: 4212
#include <bits/stdc++.h>
#include <cmath>
using namespace std; 
#define pb push_back 
#define M 998244353
#define ff first
#define ss second 
#define deb(x) cout< #x< " "< x< endl;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<=n;i++)
#define FORR(a,b,c) for(int a= b;a>=c;a--)
#define nl endl
#define fa(arrr) for(auto x:arrr)
#define sz size()
#define mp make_pair
#define mxm3(a,b,c) max(a, max(b,c))
#define mi3(a,b,c) min(a, min(b,c))
#define MAX 100005
#define PII pair<ll,ll>
#define all(v) v.begin(), v.end()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
typedef long long ll;
typedef vector<ll>vl;
vector<ll> prime(1100,-1);
//126271
// 107897

int main(){

	fast;
	ll t;
	// string s;
	// cin >> s;
	// cin >>t;
	t = 1;
	// int tc = 1;
	while(t--){
		int n,m;
		cin >> n >> m;
		vector<int>arr(n);
		int s = 0;
		fo(i,n) {
			cin >> arr[i];
			s+=arr[i];
		}
		int c = 0;
		fo(i,n){
			if((arr[i]*4*m)>=s)c++;
		}
		if(c<m) puts("No");
		else puts("Yes");
  	}	
}


Measured memory_bytes: 256
// C++ implementation of the above approach
#include<bits/stdc++.h>
using namespace std;

void CountTriangles(vector <int> A){
    int n=A.size();
    sort(A.begin(), A.end());
    int count = 0;
    for( int i = n-1; i >= 1; i--){
        int l = 0, r = i-1;
        while( l < r){
            if( A[l] + A[r] > A[i]){
                count += r - l ;
                r--;
            }
            else
                l++;
        }
    }
    cout<<count;
}
int main(){

    vector<int> A ; int n,x; cin>>n;
for(int i=0;i<n;i++){cin>>x; A.push_back(x);}
    CountTriangles(A);
}


Measured memory_bytes: 256
program main
      implicit none
      integer :: n
      integer :: i, j, k
      integer(8) :: cnt
      integer :: numa(1:9,1:9), numb(1:9,1:9)

      read *, n

      numa = 0
      numb = 0
      do i = 1, n
         if ( i < 10 ) then
           j = i
           k = i
         else
           j = i
           do while ( j > 9 )
             j = j/10
           end do
           k = mod(i,10)
         end if
         if ( k == 0 ) cycle
         numa(j,k) = numa(j,k) + 1
         numb(k,j) = numb(k,j) + 1
      end do

      cnt = 0
      do i = 1, 9
        do j = 1, 9
          cnt = cnt + numa(i,j)*numb(i,j)
        end do
      end do

      print *, cnt

end program main


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

int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int ans = 0;
    sort(a.begin(), a.end());
    int r = 0;
    for(int l = 0; l < n; l++){
        int cnt = 0;
        while(r < n && a[l] == a[r]){
            r++;
            cnt++;
        }
        if(cnt%2 == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4052
#include<stdio.h>
#include<stdlib.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue(){
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b){
    return a < b ? a : b;
}

int main(void){
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);
    for(i = 1; i <= n; i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1; 
    tail = n + 1;

    while(head != tail){
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if(u.t > 0){
            enqueue(u);
        }else{
            printf("%s %d\n", u.name, elaps);
        }
    
    }
    return 0;
}


Measured memory_bytes: 12848
#include<bits/stdc++.h>
using namespace std;
void PDF(char a)
{
    if(a>64&&a<91)
    {
        cout << "A" <<endl;
    }
    else if(a>96&&a<123)
    {
        cout << "a" <<endl;
    }
}
int main()
{
    char a;
    cin >> a;
    PDF(a);
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

using namespace std;

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

int main() {
	long long int n;

	cin >> n;

	vector<P> aa(n);

	for (long long int i = 0; i < n; i++) {
		cin >> aa[i].first;
	}
	for (long long int i = 0; i < n; i++) {
		cin >> aa[i].second;
	}

	
	bool hh = true;

	priority_queue<long long int> a, b;
	
	for (long long int i = 0; i < n; i++) {
		if (aa[i].first < aa[i].second) {
			a.push(aa[i].second - aa[i].first);
		}
		else if (aa[i].first > aa[i].second){
			b.push((aa[i].first - aa[i].second)*2);
		}
	}

	while (!b.empty()) {
		long long int aq, bq;
		bq = b.top();
		b.pop();
		if (!a.empty()) {
			aq = a.top();
			a.pop();
			long long int c = min(aq, bq);
			if (c % 2 == 1) {
				c--;
			}
			if (c == 0) {
				hh = false;
				break;
			}
			aq -= c;
			bq -= c;
			if (aq > 0) {
				a.push(aq);
			}
			if (bq > 0) {
				b.push(bq);
			}
		}
		else {
			hh = false;
			break;
		}
	}

	if (hh) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 640
import collections

N = int(input())

UVW = [[int(x) for x in input().split()] for _ in range(N - 1)]


ans = [-1] * N

A = [[] for _ in range(N)]


for u, v, w in UVW:
    A[u - 1].append([v - 1, w % 2])
    A[v - 1].append([u - 1, w % 2])

q = collections.deque()
q.append(0)

ans[0] = 0
while q:
    c = q.popleft()

    for ni, nd in A[c]:
        if ans[ni] != -1:
            continue

        if nd == 0:
            ans[ni] = ans[c]
        else:
            ans[ni] = ans[c] ^ 1

        q.append(ni)

if sum(ans) == 0:
    ans[0] = 1

for a in ans:
    print(a)





Measured memory_bytes: 63556
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<string>
#include<set>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
typedef long long ll;
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){//A
/*
    int x;
    cin>>x;
    YN(x>=30);
    */
   //B
   int n;
   ll d;
   cin>>n>>d;
   ll x,y;
   int c=0;
   rep(i,0,n){
        cin>>x>>y;
        ll z=x*x+y*y;
        if(z<=d*d) c++;
   }
   cout<<c<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cmath>

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

using namespace std;

int main(){
	long long int a, b, c, k, x;
	cin >> a >> b >> c >> k;
	
	if (k%2==0) x = 1;
	else x = -1;
	
	if (abs(a-b)>pow(10,18)) printf("Unfair\n");
	else printf("%lld\n", (a-b)*x);
	
	return 0;
}



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

int main() {
	int N;
	cin >> N;
	map<vector<int>, long long> Nums;
	for (int i = 0; i < N; i++) {
		string A;
		cin >> A;
		long long Au = 0ll, Ad = 1ll;
		bool bunsu = false;
		for (char c : A) {
			if (c == '.') bunsu = true;
			else {
				Au = Au * 10ll + ((long long)c - '0');
				if (bunsu) Ad *= 10ll;
			}
		}
		long long GCD = gcd(Au, Ad);
		Au /= GCD;
		Ad /= GCD;
		int u2 = 0, u5 = 0, d2 = 0, d5 = 0;
		while (Au % 2 == 0) Au /= 2ll, u2++;
		while (Au % 5 == 0) Au /= 5ll, u5++;
		while (Ad % 2 == 0) Ad /= 2ll, d2++;
		while (Ad % 5 == 0) Ad /= 5ll, d5++;
		Nums[{u2, u5, d2, d5}]++;
	}
	long long ans = 0;
	for (const auto& p : Nums) {
		int a = p.first[0];
		int b = p.first[1];
		int c = p.first[2];
		int d = p.first[3];
		for (int i = 0; i <= a; i++) {
			for (int j = 0; j <= b; j++) {
				for (int k = c; k < 50; k++) {
					for (int l = d; l < 50; l++) {
						if (Nums.find({ k,l,i,j }) != Nums.end()) {
							if (a != k || b != l || c != i || d != j) ans += p.second * Nums[{k, l, i, j}];
							else ans += p.second * (p.second - 1ll);
						}
					}
				}
			}
		}
	}
	cout << ans / 2ll << endl;
}


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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,a[100],ans=1000000000000000000;

main() {
    cin >> n;
    rep(i,n) cin >> a[i];
    for(int i=-100;i<=100;i++) {
        int tmp=0;
        rep(j,n) tmp+= pow(i-a[j],2);
        ans = min(ans,tmp);
    }
    ct(ans)
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    string S = read_s();
    if ((S[0] == S[1] && S[1] != S[2] && S[2] == S[3]) || (S[0] == S[2] && S[0] != S[1] && S[1] == S[3]) || (S[0] == S[3] && S[0] != S[1] && S[1] == S[2])) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N=ri()
S = [0]*N
ans = 0
a = 0
b = 0
ab = 0
for i in range(N):
    S[i] = input()
for i in range(N):
    s_ = S[i]
    ans += s_.count('AB')
    if s_[0]=='B': b+=1
    if s_[-1]=='A': a+=1
    if s_[0]=='B' and s_[-1]=='A': ab+=1

if ab == max(a,b) and ab != 0:
    ans += (ab-1)
else:
    ans += min(a,b)

print(ans)

Measured memory_bytes: 3700
n = int(input())
sp = []
for i in range(n):
    s,p = map(str,input().split())
    sp.append([s,int(p),i+1])

sp.sort(key=lambda x:x[1],reverse = True)
sp.sort(key=lambda x:x[0])

for e in sp:
    print(e[2])

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

int main() {
  int N, Y;
  cin >> N >> Y;
  Y /= 1000;
  
  bool flag = false;
  vector<int> vec(3);
  
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N - i; j++) {
      int sum = 0;
      sum += 10*i + 5*j + 1*(N-i-j);
      if (sum == Y) {
        flag = true;
        vec.at(0) = i;
        vec.at(1) = j;
        vec.at(2) = N - i - j;
      }
    }
  }
  
  if (flag) {
    cout << vec.at(0) << " " << vec.at(1) << " " << vec.at(2) << endl;
  }
  else {
    cout << -1 << " " << -1 << " " << -1 << endl;
  }
  
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define show(x) cout << x << '\n'
#define showh(x) cout << x << ' '
#define go(i, a, n) for (ll i = a; i < n; i++)
#define gor(i, a, n) for (ll i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define ss second
auto t1 = chrono::high_resolution_clock::now();
bool prime[1000001];
ll expo(ll a, ll b)
{
  a = a % mod;
  b = b % mod;
  if (b == 0)
    return 1;
  if (b % 2)
    return ((a % mod) * (expo((a * a) % mod, b / 2) % mod)) % mod;
  return expo((a * a) % mod, b >> 1) % mod;
}
ll mul(ll a, ll b)
{
  a = a % mod;
  b = b % mod;
  if (b == 0)
    return 0;
  if (b % 2)
    return ((a % mod) + (mul((a + a) % mod, b >> 1) % mod)) % mod;
  return mul((a + a) % mod, b >> 1) % mod;
}

bool ispoweroftwo(ll x)
{
  return x && !(x & (x - 1));
}
ll xorcal(ll n)
{
  if (n % 4 == 0)
    return n;
  if (n % 4 == 1)
    return 1;
  if (n % 4 == 2)
    return n + 1;
  if (n % 4 == 3)
    return 0;
}
void sieve(ll n)
{
  memset(prime, true, sizeof(prime));
  prime[0] = false;
  prime[1] = false;
  for (ll i = 2; i * i <= n; i++)
  {
    if (prime[i] == true)
    {
      for (ll j = i * i; j <= n; j += i)
        prime[j] = false;
    }
  }
}
bool isprime(ll n)
{
  if (n <= 1)
    return false;
  if (n <= 3)
    return true;

  if (n % 2 == 0 or n % 3 == 0)
    return false;

  for (ll i = 5; i * i <= n; i += 6)
  {
    if (n % i == 0 or n % (i + 2) == 0)
      return false;
  }
  return true;
}

ll modinverse(ll a, ll m)
{
  ll m0 = m;
  ll y = 0, x = 1;

  if (m == 1)
    return 0;

  while (a > 1)
  {
    ll q = a / m;
    ll t = m;

    m = a % m;
    a = t;
    t = y;

    y = x - q * y;
    x = t;
  }

  if (x < 0)
    x += m0;

  return x;
}

ll gcd(ll a, ll b)
{
  if (a == 0)
    return b;
  return (b % a, a);
}
bool ispalindrome(string s)
{
  string t = s;
  reverse(t.begin(), t.end());
  if (t == s)
    return true;
  return false;
}
void binary(ll a[], ll n)
{
  gor(i, 0, 64)
  {
    ll k = n >> i;
    a[i] = k & (ll)1;
  }
}
ll countBits(ll n)
{
  if (n == 0)
    return 0;
  return 1 + countBits(n & (n - 1));
}
bool isPower(unsigned int n)
{
  // Base case
  if (n <= 1)
    return true;

  // Try all numbers from 2 to sqrt(n) as base
  for (int x = 2; x <= sqrt(n); x++)
  {
    unsigned p = x;

    // Keep multiplying p with x while is smaller
    // than or equal to x
    while (p <= n)
    {
      p *= x;
      if (p == n)
        return true;
    }
  }
  return false;
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  for (auto &it : s)
  {
    if (it == '7')
    {
      show("Yes");
      exit(0);
    }
  }
  show("No");
  auto t2 = chrono::high_resolution_clock::now();
  auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
  clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
  return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    string s,t;cin>>s>>t;
    int ans = 0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i])ans++;
    }
    co(ans);
}

Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int x;
  cin >> x;
  int i = x;
  for(;;) {
    bool b = true;
    for (int j = 2; j * j <= x; j++) {
      if (i % j == 0) b = false;
    }
    if (b) break;
    i++;
  }
  cout << i << endl;
}

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

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,m;
  cin >> n >> m;
  vec a(n),b(n);
  vec c(m),d(m);
  for(ll i=0;i<n;i++) {
    cin >> a[i] >> b[i];
  }
  for(ll i=0;i<m;i++) {
    cin >> c[i] >> d[i];
  }
  vec ans(n);
  for(ll i=0;i<n;i++) {
    ll temp;
    for(ll j=0;j<m;j++) {
      ll dis=abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(j==0) {
        temp=dis;
        ans[i]=0;
      }
      else if(temp>dis) {
        temp=dis;
        ans[i]=j;
      }
    }
  }
  for(ll i=0;i<n;i++) {
    cout << ans[i]+1 << endl;
  }
}

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

int main() {
	int n;
	int a[21];
	cin>>n;
	for (int i=0; i<n; i++)
		cin>>a[i];
	int ans = 0;
	for (int i=1; i+1<n; i++)
		if (a[i-1] < a[i] && a[i] < a[i+1])
			ans++;
		else if (a[i-1] > a[i] && a[i] > a[i+1])
			ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n, m = list(map(int, input().split()))
al = [[] for _ in range(n)]
for i in range(n):
    al[i] = list(map(int, input().split()))
al.sort(key=lambda x: x[0], reverse=False)
ans = 0
for a in al:
    aa, b = a
    if m <= b:
        ans += m*aa
        break
    else:
        ans += b*aa
        m -= b
print(ans)


Measured memory_bytes: 62240
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,W,w[200],v[200],cnt[10]={},ans=0;
    vector<ll> V[10];
    cin>>N>>W;
    rep(i,N){
        cin>>w[i]>>v[i];
        cnt[w[i]-w[0]]++;
        V[w[i]-w[0]].pb(v[i]);
    }
    rep(i,4){
        sort(all(V[i]));
        reverse(all(V[i]));
    }
    rep(i,cnt[0]+1){
        ll cnt_w0=0;
        rep(i1,i){
            cnt_w0+=V[0][i1];
        }
        // cout<<cnt_w0<<endl;
        rep(j,cnt[1]+1){
            ll cnt_w1=0;
            rep(i1,j){
                cnt_w1+=V[1][i1];
            }
            rep(k,cnt[2]+1){
                ll cnt_w2=0;
                rep(i1,k){
                    cnt_w2+=V[2][i1];
                }
                rep(l,cnt[3]+1){
                    ll cnt_w3=0;
                    rep(i1,l){
                        cnt_w3+=V[3][i1];
                    }
                    // cout<<cnt_w0+cnt_w1+cnt_w2+cnt_w3<<endl;
                    if((i*0+j*1+k*2+l*3+(i+j+k+l)*w[0])<=W){
                        ans=max(ans,cnt_w0+cnt_w1+cnt_w2+cnt_w3);
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC068
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            n = int.Parse(Console.ReadLine());
            Console.WriteLine("ABC"+n);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <memory.h>
#define MAX 90060
int main(void){
    int n,line[MAX],sum,i,o,max,h,m,s;
    for(;max=0,scanf("%d",&n),memset(line,0,sizeof(line)),n;){
        for(i=0;i<n;i++)
            for(o=0;sum=0,o<2;o++){
                scanf("%d:%d:%d",&h,&m,&s);
                sum=h*3600+m*60+s;
                o?line[sum]--:line[sum]++;
            }
        for(i=1;i<MAX;i++)
            line[i]+=line[i-1];
        for(i=0;i<MAX;i++)
            if(max<line[i])
                max=line[i];
        printf("%d\n",max);
    }
    return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  int s[n][2], c[m][2];
  for(int i = 0; i < n; i++) cin >> s[i][0] >> s[i][1];
  for(int i = 0; i < m; i++) cin >> c[i][0] >> c[i][1];
  
  for(int i = 0; i < n; i++){
    int d = 1000000000;
    int ans;
    for(int j = 0; j < m; j++){
      int k = abs(s[i][0] - c[j][0]) + abs(s[i][1] - c[j][1]);
      if(k < d){
        d = k;
        ans = j + 1;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  int cnt=0,ans;
  for(int i=100;i>=1;i--){
    if(a%i==0 && b%i==0)cnt++;
    if(cnt==k){
      ans=i;
      break;
    }
  }
  cout<<ans<<"\n";
  return 0;
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

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



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

    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int> e(n,0);
    vector<int> w(n,0);

    if(s[0]=='W') {w[0]=1; e[0]=0;}
    else {w[0]=0; e[0]=1;}

    for(int i=1; i<n; i++)
    {
        if(s[i]=='W')
        {
            w[i]=w[i-1]+1;
        }
        else w[i]=w[i-1];
    }

    for(int i=1; i<n; i++)
    {
        if(s[i]=='E')
        {
            e[i]=e[i-1]+1;
        }
        else e[i]=e[i-1];
    }
    int ans=e[n-1]-e[0];
    for(int i=1; i<n; i++)
    {
        int cnt=0;
        cnt=w[i-1]+e[n-1]-e[i];
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2964
a, b, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = float("inf")
for _ in range(m):
    x, y, c = map(int, input().split())
    x -= 1; y -= 1
    ans = min(ans, a[x] + b[y] - c)
a.sort()
b.sort()

print(min(ans, a[0] + b[0]))

Measured memory_bytes: 18736
A, B, C = map(int,input().split())
if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
    print("0")

elif A == B and B == C:
    print("-1")
else:
    ans = 0
    while True:
        if A % 4 == B % 4 and B % 4 == C % 4:
            ans += 1
            tempA = A
            tempB = B
            tempC = C
            A = tempB // 2 + tempC // 2
            B = tempC // 2 + tempA // 2
            C = tempA // 2 + tempB // 2
        else:
            ans += 1
            break
    print(str(ans)) 

Measured memory_bytes: 38256
/*
Author: Arham_doshi
@quote "Code like there's no tommorow!"
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
#include <bits/stdc++.h>

#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
using namespace std;

int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}

int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}

int logb(int base, int x) {
    return (log(x) / log(base));
}





signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,x,i,j,k,c=0;
    
    
    priority_queue<pii ,vector<pii>,greater<pii>> q;
    
    cin>>n;
    fo(i,1,n+1){
        cin>>x;
        q.push({x,i});
    }
    while(!q.empty()){
        cout<<q.top().second<<" ";
        q.pop();
    }
    return 0;
}

Measured memory_bytes: 2544
#include <stdio.h>
#include <string.h>

#define MAX 100

int main()
{
	char s[MAX];
	char c[MAX];
	int k;

	scanf("%s", s);
	scanf("%s", c);

	k = strlen(c);
	
	c[k - 1] = '\0';

	if (strcmp(s, c) == 0)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
int main(){
	double a,b;
  	cin>>a>>b;
  cout<<a/b<<endl;
	return 0;
}


Measured memory_bytes: 256