akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			int k = cin.Int();
			long[] h = cin.ArrayLong(n);
			Array.Sort(h);
			Array.Reverse(h);
			long ans = 0;
			for (int i = k; i < n; i++) {
				ans += h[i];
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 33536
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);

#define debug(x) (#x " : " + to_string(x))
#define debug_cout(x) (cout << #x << " : " << to_string(x) << endl)
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair((a), (b));
using namespace std;
using ll = long long;
//#define int long long
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = (int)2e9;

/*****/

int main()
{
	string S;
	cin >> S;

	bool isYes = false;
	if (S.length() == 4)
	{
		sort(all(S));
		if (S[0] == S[1] && S[2] == S[3] && S[1] != S[2])
			isYes = true;
	}

	cout << (isYes ? "Yes" : "No") << endl;

	return 0;
}


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

#define all(c) (c).begin(),(c).end()
#define x second
#define y first
#define a first
#define b second
#define PUSH 0
#define SUM 1
#define POP 2

using namespace std;

typedef pair<int,int> pii;
typedef pair<pii,int>piii;
typedef pair<pii,pii> segment;

const int MAX_N = 1<<17;
int n,dat[2*MAX_N];

void init(int n_){
  n=1;
  while(n<n_)n*=2;
  fill(dat,dat+2*MAX_N,0);
}

void update(int k,int a){
  k+=n-1;
  dat[k]=a;
  while(k>0){
    k=(k-1)/2;
    dat[k]=dat[k*2+1]+dat[k*2+2];
  }
}

int sum(int a,int b,int k=0,int l=0,int r=n){
  if(r<=a || b<=l)return 0;
  if(a<=l && r<=b)return dat[k];
  
  int m=(l+r)/2;
  int vl=sum(a,b,k*2+1,l,m);
  int vr=sum(a,b,k*2+2,m,r);
  return vl+vr;
}

map<int,int> xmp;

struct Q{
  int y,x1,x2,q;
  Q(){}
  Q(int y,int x1,int x2,int q):y(y),x1(x1),x2(x2),q(q){}
};

bool cmp(Q p,Q q){
  if(p.y!=q.y)return p.y<q.y;
  return p.q<q.q;
}

int main(void){

  int m;
  cin >> m;
  
  vector<int>xv;
  vector<segment>v(m);
  vector<Q>query;
  
  for(int i=0;i<m;i++){
    cin >> v[i].a.x >> v[i].a.y >> v[i].b.x >> v[i].b.y;

    if(v[i].a.x>v[i].b.x)swap(v[i].a.x,v[i].b.x);
    if(v[i].a.y>v[i].b.y)swap(v[i].a.y,v[i].b.y);

    xv.push_back(v[i].a.x);
    xv.push_back(v[i].b.x);
  }
  
  sort(all(xv));

  for(int i=0;i<m;i++){
    if(v[i].a.x==v[i].b.x){
      query.push_back(Q(v[i].a.y,v[i].a.x,-1,PUSH));
      query.push_back(Q(v[i].b.y,v[i].b.x,-1,POP));
    }
    if(v[i].a.y==v[i].b.y){
      query.push_back(Q(v[i].a.y,v[i].a.x,v[i].b.x,SUM));
    } 
  }
  
  sort(all(query),cmp);

  xv.erase(unique(all(xv)),xv.end());

  for(int i=0;i<xv.size();i++)xmp[xv[i]]=i;

  init(xv.size());
  
  int cnt=0;
  for(int i=0;i<query.size();i++){
    if(query[i].q==PUSH)update(xmp[query[i].x1],1);
    if(query[i].q==POP)update(xmp[query[i].x1],0);
    if(query[i].q==SUM)cnt+=sum(xmp[query[i].x1],xmp[query[i].x2]+1);
  }
  cout << cnt << endl;
  
  return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        int l,r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;


    return 0;
}


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    int a, b, k, count = 0;
    cin >> a >> b >> k;
    for(int i = 100; i >= 1; i--) {
        if((a%i) == 0 && (b%i) == 0) {
            count++;
            if(count == k) {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}



Measured memory_bytes: 256
use std::io::Read;
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut it = buf.split_whitespace();
    let _n = it.next().unwrap().parse::<i64>().unwrap();
    let p = it.next().unwrap().parse::<i64>().unwrap();
    let s = it.next().unwrap();
    let s_it = s.bytes().map(|c| (c - b'0') as i64);

    if p == 2 || p == 5 {
        let mut cnt = 0;
        for (i, digit) in s_it.enumerate() {
            if digit % p == 0 {
                cnt += i + 1;
            }
        }
        println!("{}", cnt);
        return;
    }

    let mut mods : Vec<i64> = vec![0; p as usize];
    mods[0] = 1;

    let mut prev = 0;
    let mut exp = 1;
    let mut answer = 0 as i64;
    for digit in s_it.rev() {
        let current = (prev + digit * exp) % p;
        exp = exp * 10 % p;
        mods[current as usize] += 1;
        prev = current;
    }

    for cnt in mods.iter() {
        answer += cnt * (cnt - 1) / 2;
    }
    println!("{}", answer);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
bool prime(ll n) {
	ll a = sqrt(n);
	if (n == 2)return 1;
	if (n % 2 == 0)return 0;
	for (int i = 3; i <= a; i++) {
		if (n%i == 0)return 0;
	}
	return 1;
}
int main() {
	ll cnt = 0;
	vector<ll>ans;
	for (int i = 11; i <= 55555; i += 10) {
		if (prime(i))ans.push_back(i);
	}
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		if (i == n - 1)cout << ans[i] << endl;
		else cout << ans[i] << ' ';
	}
	return 0;
}


Measured memory_bytes: 256
n  = int(input())
s = list(map(int,input().split()))
dic1 = {}
dic2 = {}
for i in range(n):
    if i % 2 == 0:
        if s[i] in dic1:
            dic1[s[i]] += 1
        else:
            dic1[s[i]] = 1
    else:
        if s[i] in dic2:
            dic2[s[i]] += 1
        else:
            dic2[s[i]] = 1
max1 = max(dic1.values())
max2 = max(dic2.values())
maxkey1 = [i for i,j in dic1.items() if j == max1]
maxkey2 = [i for i,j in dic2.items() if j == max2]
if len(maxkey1) > 1 or len(maxkey2) > 1 or maxkey1[0] != maxkey2[0]:
    print(n-max1-max2)
    exit()
dic1.pop(maxkey1[0])
dic2.pop(maxkey2[0])
if dic1:
    second1 = max(dic1.values())
else:
    second1 = 0
if dic2:
    second2 = max(dic2.values())
else:
    second2 = 0
if max1-second1 <= max2-second2:
    print(n-second1-max2)
else:
    print(n-max1-second2)

Measured memory_bytes: 59756
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;

#include <map>
#define MAX_N 50


int n;
vector<pair<lli, lli>> xy(MAX_N);
map<pair<lli, lli>, lli> p_map;



void fork(int begin){
  for(int i = begin + 1; i < n; i++){
    pair<lli, lli> tmp = make_pair(xy[begin].first - xy[i].first, (xy[begin].second - xy[i].second));
    //if a don't have tmp, value = 0
    pair<lli, lli> reverse = make_pair(tmp.first * -1, tmp.second * -1);
    decltype(p_map)::iterator it = p_map.find(reverse);
    if(it != p_map.end())
      p_map[reverse]++;
    else
      p_map[tmp]++;
  }
}


int main(){
  cin >> n;

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

  for(int i = 0; i < n - 1; i++){
    fork(i);
  }

  lli max = 0;
  for(auto i = p_map.begin(); i != p_map.end(); ++i){
    if(max < i->second)
      max = i->second;
  }

  if(n == max)
    cout << 1 << endl;
  else
    cout << n - max << endl;
 

}






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

int main(){
    int n;cin>>n;
    map<int,int>M;
    while(n--){
        int va;cin>>va;
        if(M[va]==0){M[va]=1;}
        else M[va]=0;
    } 
    int ans=0;
    for(auto it:M){if(it.second==1)ans++;}
    cout<<ans<<"\n";
    //cout<<M.size()<<" \n";
    return 0;
}

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

int main(){
    string S;  cin >> S;
    ll ans = 0;
    ll cnt = 0;
    for(int i=S.length()-1; i>=0; i--){
        if(S[i] == 'W') cnt++;
        else ans += cnt;
    }
    cout << ans << endl;
}

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

#define int         long long
#define pb          push_back
#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 sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

int32_t main()
{
	IOS;
	string s;
	cin >> s;
	int k;
	cin >> k;
	int i=0;
	while(i<k && i<s.size())
	{
		if(s[i]!='1')
		{
			cout << s[i] << endl;
			return 0;
		}
		i++;
	}
	cout << 1 << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc140/tasks/abc140_c>
 問題文============================================================
 =================================================================
 解説=============================================================
 
 各Ai についての最大値は
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    vector<ll> B(N-1); for(auto& in:B) cin >> in;
    
    vector<ll> A(N);
    A[0] = B.front();
    A[N-1] = B.back();
    
    for(int i = 1; i < N-1;i++){
        A[i] = min(B[i-1],B[i]);
    }
    
    res = accumulate(A.begin(),A.end(),0LL);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int N, Y;
bool flag = false;
int main(){
    cin >> N >> Y;
    for(int i=0; i<=N; ++i){
        if(i*10000>Y || flag) break;
        for(int j =0; j<=N; ++j){
            if(i*10000 + j*5000 > Y || flag) break;
            if(i*10000 + j*5000 + (N-i-j)*1000 == Y){
                cout << i << " " << j << " " << N-i-j << endl;
                flag = true;
            }
        }
    }
    if(!flag) cout << -1 << " " << -1 << " " << -1 << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N,K;
    scanf("%d %d",&N,&K);
    int po[2*K][2*K];
    for(int i=0;i<2*K;i++)for(int j=0;j<2*K;j++)po[i][j]=0;
    int x,y;
    char c;
    for(int i=0;i<N;i++){
        scanf("%d %d %c",&x,&y,&c);
        if(c=='B')po[x%(2*K)][y%(2*K)]++;
        else po[x%(2*K)][y%(2*K)]--;
    }
    for(int i=0;i<2*K;i++)for(int j=1;j<2*K;j++)po[i][j]+=po[i][j-1];
    for(int i=0;i<2*K;i++)for(int j=1;j<2*K;j++)po[j][i]+=po[j-1][i];
    int ans=0;
    for(int i=0;i<K;i++)for(int j=0;j<K;j++){
        int karians=0;
        karians=2*po[i][j]+2*po[i+K][j+K]-2*po[i][j+K]-2*po[i+K][j]+po[i][2*K-1]+po[2*K-1][j]+po[2*K-1][2*K-1]-po[i+K][2*K-1]-po[2*K-1][j+K];
        karians=karians-(po[2*K-1][2*K-1]-karians);
        if(karians<0)karians*=-1;
        karians=(karians+N)/2;
        if(ans<karians)ans=karians;
     //   printf("%d\n",karians);
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 15744
#!/usr/bin/env python3
#AGC7 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

h,w = LI()
m = [list(input()) for _ in range(h)]
cnt = 0
for i in range(h):
    for j in range(w):
        if m[i][j] == '#':
            cnt += 1
if cnt == h + w - 1:
    print('Possible')
else:
    print('Impossible')


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

using namespace std;

typedef long long ll;

const int MX = 41;

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

int n;
int w[MX][MX];
char str[MX];

void input()
{
	read(n);
	for(int i=1; i<=n*2; i++)
	{
		scanf("%s", str+1);
		for(int j=1; j<=n*2; j++) w[i][j] = str[j]-'0';
	}
}

bool visf[MX][MX][MX];
ll valf[MX][MX][MX];

bool visg[MX][MX][MX][MX];
ll valg[MX][MX][MX][MX];

bool vish[MX][MX][MX];
ll valh[MX][MX][MX];

ll getf(int l, int r, int i);

ll getg(int p, int y, int i, int r)
{
	if(visg[p][y][i][r]) return valg[p][y][i][r];
	ll ret = 0;
	for(int q=i; q<y; q++) ret += getf(p+1, q, i) * getf(q+1, r, y);
	visg[p][y][i][r] = 1;
	valg[p][y][i][r] = ret;
	return ret;
}

ll geth(int l, int p, int y)
{
	if(vish[l][p][y]) return valh[l][p][y];
	ll ret = 0;
	for(int x=l; x<=p; x++)
		if(w[x][y])
			ret += getf(l, p, x);
	vish[l][p][y] = 1;
	valh[l][p][y] = ret;
	return ret;
}

ll getf(int l, int r, int i)
{
	if(l == r) return 1;
	else if(l==i || r==i) return 0;
	if(visf[l][r][i]) return valf[l][r][i];
	ll ret = 0;
	for(int p=l; p<i; p++)
		for(int y=r; y>i; y--)
			ret += geth(l, p, y) * getg(p, y, i, r);
	visf[l][r][i] = 1;
	valf[l][r][i] = ret;
	return ret;
}

int main()
{
	input();
	ll ans = 0;
	for(int i=2; i<=n*2; i++)
		if(w[1][i])
			ans += getf(2, n*2, i);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 23936
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();

		int[] B = new int[M];
		for(int i=0;i<M;i++) {
			B[i] = sc.nextInt();
		}

		int count = 0;
		int sum = 0;
		for(int i=0;i<N;i++) {
			for(int j=0;j<M;j++) {
				sum += B[j] * sc.nextInt();
			}
			sum += C;

			if(sum > 0) {
				count++;
			}

			sum = 0;
		}

		System.out.println(count);
	}

}

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

using namespace std;

const int INF = 1e9 + 5;
const int N = 1e4;
const int MOD = 998244353;
const double EPS = 1e-9;

const double PI = acos(-1);


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int k;
    string s;
    cin >> k >> s;
    if (s.size() <= k)
        cout << s;
    else {
        for (int i = 0; i < k; i++)
            cout << s[i];
        cout << "...";
    }
}

Measured memory_bytes: 3652
import sys
from heapq import heappop, heappush


def dijkstra(s, t, links):
    q = [(0, s)]
    visited = set()
    while q:
        cost, v = heappop(q)
        if v in visited:
            continue
        if v == t:
            return cost
        visited.add(v)
        for u, c in links[v]:
            if u in visited:
                continue
            heappush(q, (cost + c, u))
    return -1


n, m = list(map(int, input().split()))
links = [set() for _ in range(n)]
for v in range(n - 1):
    links[v + 1].add((v, 0))
for line in sys.stdin:
    l, r, c = map(int, line.split())
    links[l - 1].add((r - 1, c))
print(dijkstra(0, n - 1, links))


Measured memory_bytes: 58492
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public struct Pair<T> { public T x, y; public Pair(T x, T y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        int[] p = LineInt();
        int ans = 0;
        for (int i = 0; i < N - 2; i++)
        {
            int a = p[i];
            int b = p[i + 1];
            int c = p[i + 2];
            if (a < b && b < c) ans++;
            else if (c < b && b < a) ans++;
        }
        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long n = in.nextLong();
		long m = in.nextLong();
		if(n==1 && m==1) {
			System.out.println(1);
		}else if(n==1) {
			System.out.println(m-2);
		}else if(m==1) {
			System.out.println(n-2);
		}else {
			System.out.println((n-2)*(m-2));
		}
		in.close();
		
	}

}


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

#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;

ll lcm(ll a,ll b){
	
	return (a*b)/(__gcd(a,b));
}
void solve() 
{
	map<int,int> dp;
	int n;
	cin>>n;
	string s;
	cin>>s;
	int one=0;
	int zero=0;
	rep(i,n){
		if(s[i]=='W'){
			s[i]='0';
			zero++;
		}
		else{
			s[i]='1';
			one++;
		}
	}
	int  ans=min(zero,one);
	int cnt=0;
	for(int i=0;i<one;i++){
		if(s[i]=='0'){
			cnt++;
		}
	}
	ans=min(ans,cnt);
	cout<<ans;
}



int  main(){

		solve();
		cout<<endl;

}
	

	

	

	

Measured memory_bytes: 3712
#include <iostream>
#include <queue>
using namespace std;
 
struct cordinate{
    int x;
    int y;
};
 
int map[1005][1005], memo[1005][1005], counter[1005][1005];
int result = 0, mouselevel = 1;
queue<cordinate> q;
cordinate def;
 
int vx[4] = {0, 1, 0, -1};
int vy[4] = {1, 0, -1, 0};
 
void serch(cordinate s, int H, int W){
    def = s;
    for(int i = 0; i < 4; i++){
        if(i == 0 && s.y + 1 == H) continue;
        if(i == 1 && s.x + 1 == W) continue;
        if(i == 2 && s.y + 1 == 0) continue; 
        if(i == 3 && s.x + 1 == 0) continue;
 
        s = def;
        s.x += vx[i];
        s.y += vy[i];
        if(map[s.y][s.x] > -2 && memo[s.y][s.x] == 1){
            q.push(s);
            memo[s.y][s.x] = 0;
            counter[s.y][s.x] = counter[def.y][def.x] + 1;
            if(map[s.y][s.x] == mouselevel){
                result += counter[s.y][s.x];
                mouselevel++;
                map[s.y][s.x] = 0;
                for(int i = 0; i < H; i++){
                    for(int j = 0; j < W; j++){
                        counter[i][j] = 0;
                        memo[i][j] = 1;
                    }
                }
                while(true){
                    if(q.size() == 1){
                        break;
                    }
                    q.pop();
                }
                return;
            }
        }
    }
}
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}
 
int main(){
    int H, W, N;
    char a;
    cordinate s;
    cin >> H >> W >> N;
 
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> a;
            memo[i][j] = 1;
            if(a == '.'){
                map[i][j] = 0;
                counter[i][j] = 0;
            }else if(a == 'X'){
                map[i][j] = -2;
            }else if(a == 'S'){
                map[i][j] = -1;
                s.y = i;
                s.x = j;
                q.push(s);
            }else{
                map[i][j] = ctoi(a);
            }
        }
    }
 
    memo[s.y][s.x] = 0;
 
    for(int i = 0; i < N; i++){
        while(true){            
            s = q.front(); 
            q.pop();
            serch(s, H, W);
            if(mouselevel == i + 2){
                break; 
            }
        }
 
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 14968
#! /usr/bin/python
# -*- coding: utf-8 -*-

(n, k, m) = map(int, raw_input().split())
while n != 0:
    clk = [i for i in range(1, n+1)]
    p = m-1
    clk.pop(m-1)
    num = n-1
    for i in range(n-2):
        p = (p-1+k)%num
        clk.pop(p)
        num -= 1
    print clk[0]

    (n, k, m) = map(int, raw_input().split())

Measured memory_bytes: 4724
#include <iostream>

using namespace std;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while (true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }

        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3668
from functools import reduce
import math

def is_ok(t,h,A,B):
    cnt = 0 # 必要な攻撃回数
    for hp in h:
        cnt += max(0,math.ceil((hp-B*t)/(A-B)))
    if t >= cnt:
        return True
    else:
        return False

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N,A,B = (int(_) for _ in input().split())
    h = []
    max_h = 0
    for i in range(N):
        h.append(int(input()))
        max_h = max(h[i],max_h)        
    ng = -1
    ok = math.ceil(max_h/B) # 考えうる最大の攻撃回数

    # 二分探索
    while (abs(ok-ng)>1):
        mid = (ok + ng) //2
        if is_ok(mid,h,A,B):
            ok = mid
        else:
            ng = mid
    print(ok)
    
if __name__ == '__main__':
    main()



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

int main() {
    string s;
    cin >> s;
    string ans = "";
    for (char x : s){
        if (x == '0' || x == '1') ans.push_back(x);
        else if(ans.empty() == false) ans.pop_back();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    final static char ASTER_ = '*';
    final static char HYPHEN = '-';
    final static char RETURN = '\n';
    final static int KINDS = 10;
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";
 
        StringBuilder sb = new StringBuilder();
        while ((line = br.readLine()) != null) {
 
            if (line.isEmpty()) {
                continue;
            }
 
            int[] ices = new int[KINDS];
            int n = Integer.parseInt(line);
            if (n == 0) {
                break;
            }
 
            for (int i = 0; i < n; ++i) {
                ++ices[Integer.parseInt(br.readLine())];
            }
            for (int i = 0; i < KINDS; ++i) {
                if (ices[i] > 0) {
                    for (int j = 0; j < ices[i]; ++j) {
                        sb.append(ASTER_);
                    }
                } else {
                    sb.append(HYPHEN);
                }
                sb.append(RETURN);
            }
        }
        System.out.print(sb.toString());
    }
}


Measured memory_bytes: 30148
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  
  REP(i,n) cin >> v[i];
  
  sort(v.begin(),v.end());
  
  double ans;
  
  ans += v[0];
  
  REP(i,n-1){
    ans += v[i+1];
    ans /= 2;
  }
  
  cout << ans << endl;
  
  

  
}

Measured memory_bytes: 3864
n = int(input())

check = {v:0 for v in "MARCH"}

for i in range(n):
    s = input()
    if s[0] in check:
        check[s[0]] += 1
ans = 0
kijyun = "MARCH"

for a in range(5):
    for b in range(a+1,5):
        for c in range(b+1,5):
            ans += check[kijyun[a]] * check[kijyun[b]] * check[kijyun[c]]

print(ans)

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
vl modinv;
void fillModInv(ll n, ll mod){
  modinv = vl(n+1);
  modinv[1] = 1;
  FOR(i,2,n+1){
    modinv[i] = modinv[mod%i] * (mod - mod/i) % mod;
  }
}
/*}}}*/
int main() {
  ll n,k;
  cin >> n >> k;

  double dg = log(n) / log(k);
  ll ans = ceil(dg);
  if(n==1) ans = 1;
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Data.List as List

solve :: String -> Int
solve = length . (List.dropWhile (/= 'A')) . reverse . (List.dropWhile (/= 'Z')) . reverse

main :: IO()
main = do
    s <- getLine
    print $ solve s


Measured memory_bytes: 15868
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
#include <algorithm>
#include <map>
using namespace std;
int main(void){
    int n, m; cin >> n >> m;
    vector< vector<int> > v(m);
    map<int, int> map;
    int i = 0;
    while (i < m) {
        int k;
        cin >> k;
        int j = 0;
        while (j < k) {
            int tmp;
            cin >> tmp;
            v[i].push_back(tmp);
            j++;
        }
        i++;
    }
    i = 0;
    while (i < m) {
        int k;
        cin >> k;
        map[i] = k;
        i++;
    }
    int answer = 0;
    for (int bit = 0; bit < (1<<n); ++bit) {
        int j = 0;
        bool flag = true;
        while (j < v.size()) {
            int k = 0;
            int count = 0;
            while (k < n) {
                if (bit & (1 << k) && find(v[j].begin(), v[j].end(), k+1) != v[j].end()) {
                    count++;
                }
                k++;
            }
            if (count % 2 != map[j]) {
                flag = false;
                break;
            }
            j++;
        }
        if (flag) answer++;
    }
    cout << answer << endl;
}


Measured memory_bytes: 3592
r1 = gets.split.map &:to_i
r2 = gets.split.map &:to_i
r1x = (r1[0]...r1[0] + r1[2])
r1y = (r1[1]...r1[1] + r1[3])
r2x = (r2[0]...r2[0] + r2[2])
r2y = (r2[1]...r2[1] + r2[3])
ans = 0
2000.times do |y|
	2000.times do |x|
		b1 = r1x.include?(x) && r1y.include?(y)
		b2 = r2x.include?(x) && r2y.include?(y)
		ans += 1 if (b1 && !b2) || (!b1 && b2)
	end
end
puts ans



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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

map<int, int> m;
bool ok(int n) {
	if (n % 2 == 0) {
		m[2]++;
		if (m[2] >= 2) {
			return false;
		}
		while (n % 2 == 0) {
			n /= 2;
		}
	}
	for (int i = 3; i * i <= n; i += 2) {
		if (n % i == 0) {
			m[i]++;
		}
		while (n % i == 0) {
			if (m[i] >= 2) {
				return false;
			}
			n /= i;
		}
	}
	if (n > 2) {
		m[n]++;
		if (m[n] >= 2) {
			return false;
		}
	}
	return true;
}
int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int &i : v) cin >> i;
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (!ok(v[i])) {
			break;
		}
		count++;
	}
	if (count == n) {
		cout << "pairwise coprime\n";
		return 0;
	}
	int _gcd = v[0];
	for (int i = 1; i < n; i++) {
		_gcd = gcd(_gcd, v[i]);
	}
	if (_gcd == 1) {
		cout << "setwise coprime\n";
		return 0;
	}
	cout << "not coprime\n";
	return 0;
}


Measured memory_bytes: 7256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int N;
    cin >> N;
    vector <int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    ll money = 1000;
    ll turnip = 0;
    if(A[0] < A[1]){
        turnip += money / A[0];
        money -= money / A[0] * A[0];
    }
    for(int i = 1; i < N - 1; i++){
        if(A[i] >= A[i + 1]){
            money += turnip * A[i];
            turnip = 0;
        }
        else if(turnip == 0){
            turnip += money / A[i];
            money -= money / A[i] * A[i];
        }
    }
    cout << money + turnip * A[N - 1] << endl;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int N,M;
  cin >> N >> M;
  pair<int,int> ab[100000];
  for(int i = 0; i < N;++i){
    cin >> ab[i].first >> ab[i].second;
  }
  sort(ab,ab+N);
  int i = 0,s = 0;
  long long ans = 0;
  while(i < M){
    i += ab[s].second;
    ans += (long long)ab[s].first * ab[s].second;
    s++;
  }
  if(i > M){
    ans -= (long long)ab[s-1].first*(i - M);
  }
  cout << ans << endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> l.at(i);
    sum += l.at(i);
  }
  
  sort(l.begin(), l.end());
  sum -= l.at(n-1);
  if(sum > l.at(n-1)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }

int main() {
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
                   1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << a[K - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	string S;
	cin >> S;
	if (S[0] == '7' || S[1] == '7' || S[2] == '7') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long s = sc.nextLong();
		sc.close();

		if (s > n) {
			System.out.println(-1);
			return;
		} else if (s == n) {
			System.out.println(n + 1);
			return;
		}

		long n2 = (long) Math.ceil(Math.sqrt(n));
		for (int b = 2; b <= n2; b++) {
			if (f(b, n) == s) {
				System.out.println(b);
				return;
			}
		}

		long ns = n - s;
		for (long i = n2; i > 0; i--) {
			if (ns % i == 0) {
				long b = ns / i + 1;
				if (i < b && f(b, n) == s) {
					System.out.println(b);
					return;
				}
			}
		}
		System.out.println(-1);
	}

	static long f(long b, long n) {
		long ret = 0;
		while (n > 0) {
			ret += n % b;
			n /= b;
		}
		return ret;
	}
}


Measured memory_bytes: 23892
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>

using namespace std;

int n,q;
int a[400001];

int main(void){
	scanf("%d%d",&n,&q);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	sort(a,a+n);
	for(int i=0;i<q;i++){
		int num;
		int res=0;
		scanf("%d",&num);
		int num2=num;
		while(1){
			if(num2-num>a[n-1])break;
			if(res==q-1)break;
			int it=lower_bound(a,a+n,num2)-a;
			if(it==0)it=1;
			//printf("%d %d\n",it,a[it-1]%num);
			res=max(res,a[it-1]%num);
			num2+=num;
		}
		printf("%d\n",res);
	}
	return 0;
}

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

typedef long long ll;
#define fore(i,ii,iii) for(ll i=ii;i<iii;i++)
#define mset(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define sz(a) (int)a.size()

const ll MOD=1e9+7;
// Matrix ops
typedef vector<vector<ll>> Matrix;
Matrix ones(int n) {
	Matrix r(n,vector<ll>(n));
	fore(i,0,n)r[i][i]=1;
	return r;
}
Matrix operator*(Matrix &a, Matrix &b) {
	int n=sz(a),m=sz(b[0]),z=sz(a[0]);
	Matrix r(n,vector<ll>(m));
	fore(i,0,n)fore(j,0,m)fore(k,0,z)
		r[i][j]+=a[i][k]*b[k][j],r[i][j]%=MOD;
	return r;
}
Matrix be(Matrix b, ll e) {
	Matrix r=ones(sz(b));
	while(e){if(e&1LL)r=r*b;b=b*b;e/=2;}
	return r;
}


int main() {
  ios::sync_with_stdio(false);
	ll n,x,k;
  cin>>n>>k;
	Matrix m(n);
	fore(i,0,n) {
		fore(j,0,n){
			cin>>x;
			m[i].pb(x);
		}
	}
	m=be(m,k);
	ll r=0;
	fore(i,0,n)fore(j,0,n)r=(r+m[i][j])%MOD;
	cout<<r<<endl;
	//fore(i,0,n){fore(j,0,n)cout<<m[i][j]<<" ";cout<<endl;}
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <stdio.h> 
using namespace std;

int main(){
  double r, area, arc;

  cin >> r;

  area = r * r * M_PI;
  arc = (r + r) * M_PI;

  printf("%.8f %.8f\n", area, arc);


}



Measured memory_bytes: 3208
solve [x1,y1,x2,y2] = [x3,y3,x4,y4]
  where
    [vx,vy] = [x2-x1, y2-y1]
    [x3,y3] = zipWith (+) [x2,y2] [-vy,vx]
    [x4,y4] = zipWith (+) [x3,y3] [-vx,-vy]

main = do
  cont <- getContents
  let xy = map read $ words cont
      a = solve xy
  putStrLn $ unwords $ map show a


Measured memory_bytes: 508
function Main(input) {
    input = input.split("\n");
    var line = input[0].split("");
    var digit = line.length
    var max = Math.pow(2,digit-1)-1
    var ans = 0;
    for(var i = 0; i<=max;i++){
        var temp = i.toString(2);
        temp = "0000000000"+temp;
        temp = temp.slice("-"+(digit-1));
        temp = temp.split("");
        var ansStr = "";
        for(var j =0; j<digit; j++){
            ansStr+=line[j];
            if(temp[j]==1){
                ansStr = ansStr + "+";
            }
        }
        ans += eval(ansStr);
    }
    console.log(ans);

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

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

#define ll long long int
#define li int64_t

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

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define pi 3.14159265358979323846
#define Endl endl
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
vector<int> nex[214514];
int col[214514];
int ans[214514];
int used[214514];
signed main(){
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		nex[a].pb(b);
		nex[b].pb(a);
	}
	col[1] = 1;
	queue<int> que;
	que.push(1);
	while( !que.empty() ){
		int c = que.front(); que.pop();
		for(int i=0;i<nex[c].size();i++){
			int nx = nex[c][i];
			if( col[nx] == 0 ){
				col[nx] = 3 - col[c];
				que.push(nx);
			}
		}
	}
	int c1=0,c2=0;
	for(int i=1;i<=n;i++){
		if( col[i] == 1 ) c1++;
		else c2++;
	}
	//cout<<c1<<" "<<c2<<endl;
	int th = n/3;
	if( c1 <= th ){
		int cur = 3;
		for(int i=1;i<=n;i++){
			if( col[i] == 1 ){
				ans[i] = cur;
				used[cur] = 1;
				cur += 3;
			}
		}
		cur = 1;
		for(int i=1;i<=n;i++){
			if( col[i] == 2 ){
				while( used[cur] != 0 )cur++;
				ans[i] = cur;
				used[cur] = 1;
			}
		}
	}
	else if( c2 <= th ){
		int cur = 3;
		for(int i=1;i<=n;i++){
			if( col[i] == 2 ){
				ans[i] = cur;
				used[cur] = 1;
				cur += 3;
			}
		}
		cur = 1;
		for(int i=1;i<=n;i++){
			if( col[i] == 1 ){
				while( used[cur] != 0 )cur++;
				ans[i] = cur;
				used[cur] = 1;
			}
		}
	}
	else{
		int ct1 = 0,ct2=0,cur = 3;
		int m1 = (n+2)/3, m2 = (n+1)/3;
		for(int i=1;i<=n;i++){
			if( col[i]==1){
				ct1++;
				if( ct1 <= m1 ){
					ans[i] = 3*ct1-2;
				}
				else{
					ans[i] = cur;
					cur += 3;
				}
			}
			else{
				ct2++;
				if( ct2 <= m2 ){
					ans[i] = 3*ct2 -1;
				}
				else{
					ans[i] = cur;
					cur += 3;
				}
			}
		}
	}
	for(int i=1;i<=n;i++){
		cout<<ans[i]<<" ";
	}
	cout<<endl;		
	return 0;
}

Measured memory_bytes: 18920
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;


class Program {

	static long mod = 1000000007;
	//static long mod =998244353;
	static int[] ans;
	static void Main(string[] args) {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res = "";
		int res = 0;


		int n = int.Parse(Console.ReadLine());

		int[] vals = parseAry(Console.ReadLine().Split(cs));

		Dictionary<int,int> dic=new Dictionary<int,int>();

		for ( int i = 0; i < vals.Length; i++ ) {
			dic.Add(i+1, vals[i]);
		}

		List<KeyValuePair<int, int>> list = new List<KeyValuePair<int, int>>(dic);

		list.Sort((a, b) => a.Value - b.Value);  //昇順


		int[] re = new int[n];
		for ( int i = 0; i < vals.Length; i++ ) {
			re[i] = list[i].Key;
		}
		

				Console.WriteLine(stringBuilderArrayInt(re));

		return;

	}



	//	int配列をスペース区切りの文字列に変換
	static string stringBuilderArrayInt(int[] a) {
		StringBuilder sb = new StringBuilder();

		for ( int i = 0; i < a.Length; i++ ) {
			sb.Append(a[i] + " "); 
		}
		if ( sb.Length > 1 ) {
			sb = sb.Remove(sb.Length - 1, 1);
		}
		return sb.ToString(); ;
	}


	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}



}

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

void printlist(int lst[], size_t len){
	for(size_t i = 0; i < len - 1; i ++){
		cout << lst[i] << " ";
	}
	cout << lst[len - 1] << endl;
}

int max(int lst[], size_t len){
	int result = lst[0];

	for(size_t i = 1; i < len; i ++){
		if(result < lst[i]){
			result = lst[i];
		}
	}

	return result;
}

void counSort(int lst[], int B[], size_t len, int k){
	int C[k + 1];
	int offset[k + 1];
	for(auto& x:C) x = 0;

	for(size_t i = 0; i < len; i ++){
		C[lst[i]] ++;
	}

	offset[0] = 0;
	for(int i = 1;i <= k; i ++){
		offset[i] = offset[i - 1] + C[i - 1];
	}

	for(int i = 0; i < len; i ++){
		int target = lst[i];
		B[offset[target]] = target;
		offset[target] ++;
	}
}

int main(int argc, char const *argv[])
{
	int N;
	cin >> N;
	int st[N], result[N];
	for (auto& i : st){
		cin >> i;
	}
	counSort(st, result, sizeof(st) / sizeof(int), max(st, sizeof(st) / sizeof(int)));
	printlist(result, sizeof(result) / sizeof(int));
	return 0;
}


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

using namespace std;


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

  long long int a,b;
  cin>>a>>b;

  long long  d =(a*b);

  long long k =( __gcd(a,b) );

 
  cout<<d/k<<endl;


return 0;   }



Measured memory_bytes: 256
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);


vector<char> digits;
int bad(int num){
	string k=to_string(num);
	for(char c:k){
		for(char digit:digits){
			if(digit==c)
				return true;
		}
	}
	return false;
}

void solve(){  
	int n,k;
	cin>>n>>k;
	rep(i,0,k){
		char c;
		cin>>c;
		digits.pb(c);
	}	  
	while(bad(n)){
		++n;
	}
	cout<<n<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

int main() {
ll n,k;
cin >> n >> k;
ll ans = k;
ans *= pow(k-1,n-1);
cout << ans << endl;

}


Measured memory_bytes: 3996
#include <iostream>
using namespace std;
int main(void){
    int a,b,c[100],d=0;
    cin>>a>>b;
    for(int i=0;i<a;i++){
        cin>>c[i];
        if(c[i]<b-c[i]){
            d=d+c[i];
        }
        else{
            d=d+b-c[i];
        }
    }
    cout<<d*2<<endl;
    
}

Measured memory_bytes: 256