akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

struct Benri {
    Benri() {
        std::cin.tie(0); ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
    }
} benri;
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; }

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007
#define MOD2 998244353
const int INF = 1 << 28;



int main() {
    int N; cin >> N;
    vi B(N+1,INF);
    rep(i,N-1) cin >> B[i+1]; 
    int ans = 0;
    rep(i,N){
        ans += min(B[i],B[i+1]);
    }

    cout << ans << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int digitsum(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(int argc, const char * argv[]) {
    
    string S;
    cin >> S;
    
    vector<int> alph(26, 0);
    for (int i = 0; i < S.size(); i++) {
        alph.at(S.at(i) - 'a')++;
    }
    
    string ans = "None";
    for (int i = 0; i < 26; i++) {
        if (alph.at(i) == 0) {
            ans = (char)(i + 97);
            break;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};


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

	int n;
	cin >> n;

	int a[n/2],b[n/2];
	for(int i=0;i<n/2;i++){
		cin >> a[i] >> b[i];
	}
	sort(a,a+n/2); sort(b,b+n/2);

//	cout << "a\n";
//	for(int i=0;i<n/2;i++) cout << a[i] << " ";
//	cout << "\nb\n";
//	for(int i=0;i<n/2;i++) cout << b[i] << " ";

	int prev=a[0];
	vector<pair<int,int>> num_v_a;
	int ind=0,num=1;
	for(int i=1;i<n/2;i++){
		if(prev==a[i]) num++;
		else{
			num_v_a.push_back(P(num,prev));
			num=1;
			prev=a[i];
		}
	}	
	if(num!=1){
		num_v_a.push_back(P(num,prev));
	}

//	cout << "\nnum_v_a size:"<<num_v_a.size() << "\n";
//	for(auto i=num_v_a.begin();i!=num_v_a.end();i++){
//		cout << "(" << i->first << " " << i->second << ")";
//	}

	prev=b[0];
	vector<pair<int,int>> num_v_b;
	ind=0,num=1;
	for(int i=1;i<n/2;i++){
		if(prev==b[i]) num++;
		else{
			num_v_b.push_back(P(num,prev));
			num=1;
			prev=b[i];
		}
	}
	if(num!=1){
		num_v_b.push_back(P(num,prev));
	}
	
//	cout << "\nnum_v_b size:" << num_v_b.size() << "\n";
//	for(auto i=num_v_b.begin();i!=num_v_b.end();i++){
//		cout << "(" << i->first << " " << i->second << ")";
//	}
	sort(num_v_a.begin(),num_v_a.end());
	reverse(num_v_a.begin(),num_v_a.end());
	sort(num_v_b.begin(),num_v_b.end());
	reverse(num_v_b.begin(),num_v_b.end());

//	cout << "\nre_num_v_a\n";
//	for(auto i=num_v_a.begin();i!=num_v_a.end();i++){
//		cout << "(" << i->first << " " << i->second << ")";
//	}
//	cout << "\nre_num_v_b\n";
//	for(auto i=num_v_b.begin();i!=num_v_b.end();i++){
//		cout << "(" << i->first << " " << i->second << ")";
//	}
//	cout << "\n";

	if(num_v_a[0].second != num_v_b[0].second){
		//cout << "A\n";
		cout << n-num_v_a[0].first-num_v_b[0].first << "\n";
	}else{
		if(num_v_a[0].first+num_v_b[0].first == n){
			//cout << "B1\n";
			cout << n/2;
		}else{
			int ans=INF;
			if(num_v_a.size()>=2){
				ans = n-num_v_a[1].first - num_v_b[0].first;
			//	cout << "B2a " << n-num_v_a[1].first - num_v_b[0].first << "\n";
			}
			if(num_v_b.size()>=2){
				ans = min(ans,n-num_v_a[0].first - num_v_b[1].first);
			//	cout << "B2b " << n-num_v_a[0].first - num_v_b[1].first << "\n";
			}
			cout << ans << "\n";
		}
	}
	return 0;
}

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

int main(){
    int m,n,count=0;
    char s[110][110];
    
    cin >> m >> n;
    
    for (int i = 0; i < m ;i++) cin >> s[i];
    
    if (m==1){
        cout << 0 << endl;
        return 0;
    }
    
    for (int y=1;y<m;y++){
        for (int x=0;x<n;x++){
            if (s[y][x]!='-') continue;
            if (x>0){
                if (s[y][x-1]!='-') continue;
                if (y>0&&s[y-1][x-1]=='x') continue;
                if (y<m-1&&s[y+1][x-1]=='x') continue;
            }
            if (x<n-1){
                if (s[y][x+1]!='-') continue;
                if (y>0&&s[y-1][x+1]=='x') continue;
                if (y<m-1&&s[y+1][x+1]=='x') continue;
            }
            if (y>0&&s[y-1][x]=='x') continue;
            if (y<m-1&&s[y+1][x]=='x') continue;
            count++;
        }
    }
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<string>
#include<algorithm>
#define ll long long
using namespace std;
void get(ll arr[],ll n)
{
for(ll i=0;i<n;i++)
cin>>arr[i];
}
int main()
{
	ll x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  string S, T;
  cin >> S >> T;
  ll cnt = 0;
  for(ll i = 0; i < S.size(); i++) {
    if(S.at(i) != T.at(i)) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3844
b = input()
bls = []

for x in range(0,len(b)):
    bls.append(b[x])

def ACGT(b):
    if b == "A" or b =="C" or b =="G" or b =="T":
        return True
    else:
        return False


now = 0
maxx = 0

for x in bls:
    if ACGT(x):
        now += 1
    elif now >= maxx:
        maxx = now
        now = 0
    else:
        now = 0

if now >= maxx:
    maxx = now

print(maxx)


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n,k;
    cin >> n >> k;
    vll a(n);
    rep(i, n) {cin >> a[i]; a[i]--;}
    
    vll acc(n + 1, 0);
    rep(i, n) acc[i + 1] = (a[i] + acc[i]) % k;

    map<ll, ll> dist;
    dist[0] = 1;
    
    ll ans = 0;
    rep(j, n) {
        int i = j + 1;
        // cout << i << " " << acc[i] << " " << dist[acc[i]] << endl;
        // if ((k + acc[i] - acc[i - 1]) % k == 0) ans++;
        if (j >= k - 1) {
            // cout << j - k << " " << acc[j - k] << endl;
            dist[acc[j - (k - 1)]]--;
        }
        ans += dist[acc[i]];
        dist[acc[i]]++;
    }

    cout << ans << endl;
    return 0;
}


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


int main(){
    string X; cin >> X;
    stack<char> s;
    
    for(int i=0; i<X.length(); i++){
        if(s.empty()){
            s.push(X[i]);
        }
        else if(s.top()=='T'){
            s.push(X[i]);
        }
        else if(s.top()=='S'){
            if(X[i]=='T'){
                s.pop();
            }
            else {
                s.push(X[i]);
            }
        }
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 644
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} 


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

int N; cin >> N;

int l = 1, r=N;
string s;
cout << 0 << endl;
cin >> s;
if (s == "Vacant") return 0;
string s0 = s;
while(1){
    int m = (l + r) / 2;
    cout << m << endl;
    cin >> s;
    if (s == "Vacant") return 0;
    if (m%2 == 0 && s == s0) l = m;
    else if (m%2 == 1 && s != s0) l = m;
    else r = m;
}

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 852
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
ll fan(ll x,vector<int>v){
  ll ret = 0;
  rep(i,v.size()){
    ret += x % v[i];
  }
  return ret;
}
int solve(){
  int n;
  cin >> n;
  vector<int>v(n);
  rep(i,n)cin >> v[i];
  ll ans = 0;
  rep(i,n)ans += v[i] - 1;
  cout << ans << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    *A, = map(int, input().split())

    B = [0] * (10 ** 6 + 1)
    for x in A:
        B[x] += 1

    setwise = False

    d = 2
    e = d
    cnt = 0
    while e <= 10 ** 6:
        if B[e]:
            cnt += B[e]
        e += d
    if cnt == N:
        print('not coprime')
        return
    elif cnt > 1:
        setwise = True

    d = 3
    while d <= 10 ** 6:
        e = d
        cnt = 0
        while e <= 10 ** 6:
            if B[e]:
                cnt += B[e]
            e += d
        if cnt == N:
            print('not coprime')
            return
        elif cnt > 1:
            setwise = True
        d += 2

    print('setwise coprime' if setwise else 'pairwise coprime')


if __name__ == '__main__':
    main()


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

int main() {
  int N, A;
  vector<ll> v(N);
  map<ll, ll> m;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A;
    v.at(i) = A;
    m[A]++;
  }
  ll sum = 0;
  for (int i = 1; i <= N; i++) {
    if (m.count(i)) {
      sum += m.at(i) * (m.at(i) - 1) / 2;
    }
  }
  for (int i = 0; i < N; i++) {
    cout << sum - (m.at(v.at(i)) - 1) << endl;
  }
  return 0;
}

Measured memory_bytes: 42240
import sys
from io import StringIO
import unittest
import fractions
import math


#from numba import jit
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


def resolve():
    A, B, C, D = map(int, input().split())
    size = B - A + 1
    C_warikire = B // C - (A - 1) // C
    D_warikire = B // D - (A - 1) // D
    C_and_D_warikire = B // lcm(C, D) - (A - 1) // lcm(C, D)
    print(size - C_warikire - D_warikire + C_and_D_warikire)
resolve()

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

const int Max = 105;
const int INF = (1<<29);
int n, G[Max][Max], Min, color[Max], d[Max], p[Max];
int u, k, v, c;

void dijstra()
{
    memset(color, -1, sizeof(color));
    for(int i=0; i<n; i++)
    {
        d[i] = INF;
    }
    d[0] = 0;
    p[0] = -1;
    while(1)
    {
        int minv = INF, u;
        for(int i=0; i<n; i++)
        {
            if(color[i]!=0 && d[i]<minv)
            {
                minv = d[i];
                u = i;
            }
        }
        if(minv==INF) break;
        color[u] = 0;

        for(int j=0; j<n; j++)
        {
            if(color[j]!=0 && G[u][j]!=INF && d[u]+G[u][j]<d[j])
            {
                d[j] = G[u][j]+d[u];
                p[j] = u;//j的父节点为u，有利于重建MST
            }
        }
    }
    //打印输出
    for(int i=0; i<n; i++)
    {
        cout << i << " " << d[i] << endl;
    }
}

int main()
{
    cin >> n;
    Min = 0;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            G[i][j] = INF;
        }
    }
    for(int i=0; i<n; i++)
    {
         cin >> u >> k;
         for(int i=0; i<k; i++)
         {
             cin >> v >> c;
             G[u][v] = c;//化为邻接矩阵
         }
    }
    dijstra();
    return 0;
}



Measured memory_bytes: 3132
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


#mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def main():
	a,b=map(int,input().split())
	c=min(a,b)
	d=max(a,b)
	ans=str(c)*d
	print(ans)


if __name__ == "__main__":
	main()


Measured memory_bytes: 38384
#include<stdio.h>
#define MAX 500001
#define NIL -1
typedef struct node{
  int left;
  int right;
  int key;
  int p;
  int leftid;
  int rightid;

}Node;
Node node[MAX];
int root=NIL;
void inorder(int);
void preorder(int);
void addTree(int n,int num){
  int tmp;
  //rootが空の場合
  if(node[n].key==root){
    root=n;
    node[root].key=num;
    
  }
  else{
  tmp=root;

  while(1){
    if(node[tmp].key>num){
      if(node[tmp].left!=NIL){
	tmp=node[tmp].leftid;
      }
      else{
	node[tmp].left=num;
	node[tmp].leftid=n+1;
	node[n+1].key=num;
	
	break;
      }
    }
    else{
      if(node[tmp].right!=NIL){
	tmp=node[tmp].rightid;
	
      }
      else{
	node[tmp].right=num;
	node[n+1].key=num;
	node[tmp].rightid=n+1;
	break;
      }
    }
  }
  
  node[n].p=tmp;
  
  }
}
int main(){
  int num,i,n,l=0,tmp;
  char name[100];
  scanf("%d",&n);
 for(i=0;i<MAX;i++){//初期化
    node[i].p=NIL;
    node[i].left=NIL;
    node[i].right=NIL;
    node[i].key=NIL;
    
  }


 for(i=0;i<n;i++){
    scanf("%s",name);
    if(name[0]=='i'){
      scanf("%d",&num);
      addTree(l,num);
      l++;
      }
      
   else if(name[0]=='p'){
    inorder(root);
   printf("\n");
   preorder(root);
   printf("\n");
      
    }
  }
 
 
 
  return 0;
}
void inorder(int t){
  if(node[t].left!=NIL){
    inorder(node[t].leftid);
  }
    printf(" %d",node[t].key);
  if(node[t].right!=NIL){
    inorder(node[t].rightid);
  }
}
void preorder(int t){
 
      printf(" %d",node[t].key);
  if(node[t].left!=NIL){
    preorder(node[t].leftid);
  }
  if(node[t].right!=NIL){
    preorder(node[t].rightid);
  }
}




Measured memory_bytes: 13512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define pri(n) printf("%d",n)
#define lpri(n) printf("%lld",n)
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define F first
#define S second
const ll mod=998244353;

int main()
{
    int t=1;
    //cin>>t;

    while(t--)
    {
        string s1,s2;
        cin>>s1>>s2;

        int n=s1.size();
        int m=s2.size();

        int dp[n+2][m+2];
        for(int i=0;i<=n;i++)
        dp[i][0]=0;

        for(int i=0;i<=m;i++)
        dp[0][i]=0;

        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(s1[i]==s2[j])
                {
                    dp[i+1][j+1]=(1+dp[i][j]);
                }
                else
                dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
            }
        }
        vector<char> ans;
        int i=n,j=m;

        while(i>0 and j>0)
        {
            if(dp[i][j]==dp[i-1][j])
            {
                i--;
            }

            else if(dp[i][j]==dp[i][j-1])
            {
                j--;
            }

            else if(dp[i][j]=(1+dp[i-1][j-1]))
            {
                ans.push_back(s2[j-1]);
                i--;
                j--;
            }
            
        }
        reverse(ans.begin(),ans.end());
        for(auto it:ans)
        cout<<it;
    }
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  int light_on = 0, cnt = 0;
  while(cnt <= N){
    light_on = a[light_on] - 1;
    cnt += 1;
    if(light_on == 1){
      cout << cnt;
      break;
    }
    else if(light_on == 0 or cnt == N){
      cout << -1;
      break;
    }
  }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k)
        cout<<k<<endl;
    else if(a+b>=k)
        cout<<a<<endl;
    else
        cout<<(a-(k-(a+b)))<<endl;
}



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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

//-----------------------------------------------------------------

int nmax=200000; // 2*(10^5)
vvec g(nmax);


//-----------------------------------------------------------------

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    int n,m;
    cin>>n>>m;
    vector<int> a(m);
    rep(i,m) cin >> a[i];
    int sum=0;
    rep(i,m) sum+=a[i];
    if(sum>n) cout<<-1<<endl;
    else cout<<n-sum<<endl;

}

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

int main()
{
    int x, a, b, c;
    cin >> x;
    a = x / 500;
    b = x % 500;
    c = b / 5;
    cout << a * 1000 + c * 5 << endl;
}

Measured memory_bytes: 256
// aribon4-5_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;


pair<int, int> dfs(string& S, int& i, int last_idx){

    if (i > last_idx) return {0, 99};

    if ('0' <= S[i] && S[i] <= '9') {
        int n = S[i] - '0';
        i++;

        if (n == 0) return {0, 0};
        if (i > last_idx) return {n, 10*n+9};

        if ('0' <= S[i] && S[i] <= '9') {
            n = 10 * n + S[i] - '0';
            i++;
        }
        return {n, n};
    } else if (S[i] == '_' || S[i] == '^'){
        bool max_mode = S[i] == '^';

        i += 2;
        auto lhs = dfs(S, i, last_idx); //左辺
        i++;
        auto rhs = dfs(S, i, last_idx); //右辺
        i++;
        if (max_mode) {
            return {max(lhs.first, rhs.first), max(lhs.second, rhs.second)};
        } else {
            return {min(lhs.first, rhs.first), min(lhs.second, rhs.second)};
        };
    } else {
        assert(false); //来ないはず
        return {-1, -1};
    }
}


int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int Q;
    cin >> Q;

    REP(_, Q){
        string S;
        cin >> S;

        int ok = S.size()-1;
        int ng = -1;
        while (ok - ng > 1){
            int last_idx = (ok + ng) / 2;
            int idx = 0;
            auto res = dfs(S, idx, last_idx);
            if (res.first == res.second){
                ok = last_idx;
            } else {
                ng = last_idx;
            }
        }
        int idx=0;
        auto res = dfs(S, idx, ok);
        print(res.first, ok+1);

//        REP(last_idx, S.size()){
//            int idx = 0;
//            auto res = dfs(S, idx, last_idx);
//            if (res.first == res.second){
//                print(res.first, last_idx+1);
//                break;
//            }
//        }

    }

    return 0;
}


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

int gcd(int m,int n){
    if(n==0)
      return m;
    return gcd(n,m%n);
}

int main(){
    int W,H,C;
    cin>>W>>H>>C;

    int g=gcd(W,H);

    cout << W/g*H/g*C<<endl;

    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a*a+b*b==c*c){
        printf("%d\n",a*b/2);
    }
    else{
        printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 256
// 609-1.cpp : 此檔案包含 'main' 函式。程式會於該處開始執行及結束執行。
//

#include <iostream>
using namespace std;

int main()
{
	int p, q, r;
	cin >> p >> q >> r;
	if (p >= q && p >= r)
		cout << (q + r) << '\n';
	else if (q >= r && q >= p)
		cout << (p + r) << '\n';
	else
		cout << (q + p) << '\n';
	return 0;
}

// 執行程式: Ctrl + F5 或 [偵錯] > [啟動但不偵錯] 功能表
// 偵錯程式: F5 或 [偵錯] > [啟動偵錯] 功能表

// 開始使用的提示: 
//   1. 使用 [方案總管] 視窗，新增/管理檔案
//   2. 使用 [Team Explorer] 視窗，連線到原始檔控制
//   3. 使用 [輸出] 視窗，參閱組建輸出與其他訊息
//   4. 使用 [錯誤清單] 視窗，檢視錯誤
//   5. 前往 [專案] > [新增項目]，建立新的程式碼檔案，或是前往 [專案] > [新增現有項目]，將現有程式碼檔案新增至專案
//   6. 之後要再次開啟此專案時，請前往 [檔案] > [開啟] > [專案]，然後選取 .sln 檔案


Measured memory_bytes: 256
N,M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    A[i] *= -1
import heapq
heapq.heapify(A)
for i in range(M):
    m = heapq.heappop(A)
    heapq.heappush(A,-1*(-m//2))
print(-1*sum(A))

Measured memory_bytes: 72300
n = int(input())
testimony_table = [[] for _ in range(n)]

for i_witness in range(n):
    ai = int(input())
    for _ in range(ai):
        xij, yij= map(int, input().split())
        testimony_table[i_witness].append((xij-1,yij))

ans = 0
for i in range(2**n):
    isConflict = False

    for j_witness in range(n): # それぞれの桁について0か1かを判断したいので
        if (i >> j_witness) & 1 == 0: # j桁目が1かどうかをジャッジ
            continue


        for x_suspect, y_testimony in testimony_table[j_witness]:
            if ((i >> x_suspect) & 1) != y_testimony:
                isConflict = True
                break

        if isConflict:
            break
    if isConflict == False:
        ans = max(ans, bin(i).count("1"))

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N; cin >> N;
  for (ll i = 1; i <= N; ++i) {
    ll s = i*(i+1)/2;
    ll diff = s - N;
    if (diff < 0) continue;
    for (ll j = 1; j <= i; ++j) {
      if (diff == j) continue;
      cout << j << endl;
    }
    break;
  }
}

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

template<typename T>
struct SegTree{
    int NN;
    T dval;
    vector<T> seg;

    void init(int n, T val){
        NN = 1;
        dval = val;
        while (NN < n)
            NN <<= 1;

        seg = vector<T>(NN * 2);
    }

    T func(T a, T b){
        return max(a, b);
    }

    void gather(int u){
        seg[u] = func(seg[u * 2 + 1], seg[u * 2 + 2]);
        return ;
    }

    void build(int u, int l, int r, vector<T> &a){
        if (r - l == 1){
            if (l >= (int) a.size())
                seg[u] = dval;
            else
                seg[u] = a[l];
            return ;
        }

        int m = (l + r) / 2;
        build(u * 2 + 1, l, m, a);
        build(u * 2 + 2, m, r, a);
        gather(u);

        return ;
    }

    void update(int idx, int u, int l, int r, T x){
        if (r - l == 1 && idx == l){
            seg[u] += x;
            return ;
        }
        if (idx < l || idx >= r){
            return ;
        }

        int m = (l + r) / 2;
        update(idx, u * 2 + 1, l, m, x);
        update(idx, u * 2 + 2, m, r, x);
        gather(u);

        return ;
    }

    T query(int a, int b, int u, int l, int r){
        if (r <= a || b <= l){
            return dval;
        }
        if (a <= l && r <= b){
            return seg[u];
        }

        int m = (l + r) / 2;
        int res1 = query(a, b, u * 2 + 1, l, m);
        int res2 = query(a, b, u * 2 + 2, m, r);

        return func(res1, res2);
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w, m;
    cin >> h >> w >> m;

    vector<int> r_cnt(h), c_cnt(w);
    vector<vector<int>> x(h, vector<int>());
    for (int i = 0; i < m; i++){
        int r, c;
        cin >> r >> c;
        r--; c--;
        r_cnt[r] += 1;
        c_cnt[c] += 1;

        x[r].push_back(c);
    }

    SegTree<int> seg;
    seg.init(w, 0);
    seg.build(0, 0, seg.NN, c_cnt);

    int ans = 0;
    for (int r = 0; r < h; r++){
        for (auto c: x[r])
            seg.update(c, 0, 0, seg.NN, -1);
        
        ans = max(ans, r_cnt[r] + seg.query(0, w, 0, 0, seg.NN));

        for (auto c: x[r])
            seg.update(c, 0, 0, seg.NN, 1);
    }

    cout << ans << '\n';

    return 0;
}


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

int64_t solve(int64_t n,int64_t k){
	int64_t num=k;
	if(num<n)num=n/k*k;
	n-=num;
	if(n<0)n*=-1;
	if(n>k/2)n=solve(n,k);
	return n;
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t n,k;
	cin>>n>>k;
	cout<<solve(n,k)<<"\n"s;
}

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

int main() {

	int n; cin >> n;
	
	const int MAX_N = 2147483647;

	vector<int> dp(n + 1,MAX_N); dp[0] = 0;
	
	for (int i = 1; i <= n; i++) {
		
		for (int pow6 = 1; pow6 <= i; pow6 *= 6) {
			dp[i] = min(dp[i], dp[i - pow6] + 1);
		}

		for (int pow9 = 9; pow9 <= i; pow9 *= 9) {
			dp[i] = min(dp[i], dp[i - pow9] + 1);
		}

	}
	cout << dp[n] << endl;
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector <vector<int>> vec(M, vector<int>(2)); 
  for ( int i = 0 ; i < M ; i++ ){
    for ( int j = 0 ; j < 2 ; j++ ){
      cin >> vec.at(i).at(j);
    }
  }
  
  for (int i = 0 ; i < N ; i++ ){
    int count = 0;
    for ( int j = 0 ; j < M ; j++ ){
      for ( int k = 0 ; k < 2 ; k++ ){
        if (vec.at(j).at(k) == ( i + 1 ) ){
        count++;
        }
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
int main() {
	std::string st;
	std::cin >> st;
	int l = 0;
	if (st.find("A") != st.size() - 1)if (st[st.find("A") + 1] == 'C')++l;
	std::cout << (l == 0? "No" : "Yes")<< std::endl;
	 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
const double EPS = 1e-10;
struct Vec2 {
  double x;
  double y;

  Vec2() : x(0.0),y(0.0){} 
  Vec2(double _x,double _y) :x(_x),y(_y){}  
  
  Vec2 operator+(const Vec2& other) const { return { x + other.x , y + other.y }; }
  Vec2 operator-(const Vec2& other) const { return { x - other.x , y - other.y }; }
  bool operator==(const Vec2& other) const { return (abs(x - other.x) < EPS && abs(y - other.y) < EPS ); } 
  bool operator<(const Vec2& other) const { if(abs(x - other.x) < EPS) return y < other.y; else return x < other.x; }
 
  double dot(const Vec2& other) const { return x * other.x + y * other.y; }
  double cross(const Vec2& other) const { return x * other.y - y * other.x; }
  double length() const { return sqrt(x * x + y * y); }

  void Show() { printf("%.8f %.8f\n", x, y); }
};

struct Line {
  Vec2 s; // 始点
  Vec2 t; // 終点

  Line() : s({0, 0}), t({0, 0}) {}
  Line(Vec2 s, Vec2 t) : s(s), t(t) {}

  Vec2 V() { return t - s; }
  double dot(const Line &other) const { return (t - s).dot(other.t - other.s); }
  double cross(const Line &other) const { return (t - s).cross(other.t - other.s); }
  double length() const { return (t - s).length(); }  
};
// A とB のなす角θ cosθ, sinθ を返す
double Cos(const Line &A, const Line &B) {
  if(A.length() < EPS || B.length() < EPS) return 0;
  return A.dot(B) / (A.length()*B.length());
}
double Sin(const Line &A, const Line &B) {
  if(A.length() < EPS || B.length() < EPS) return 0;
  return A.cross(B) / (A.length()*B.length());
}
// 線分ABをB方向に長さlに延長する
Line ExpandB(const Line &AB, const double &l) {
  Line v(Vec2(0,0), Vec2(1,0));
  Vec2 d(l * Cos(v, AB), l * Sin(v, AB));
  return Line(AB.s, AB.s + d);
}

// 直線ABと点Cの距離
double DistLinePoint(const Line &AB, const Vec2 &C) {
  Line AC(AB.s, C);
  return AC.length() * abs(Sin(AB, AC));
}
// 直線AB上に点Cを射影した点
Vec2 Proj(const Line &AB, const Vec2 &C) {
  Line AC(AB.s, C);
  double l = AC.length() * Cos(AB, AC);
  Line res = ExpandB(AB, l);
  return res.t;
}

int main()
{
  Vec2 p1, p2;
  cin >> p1.x >> p1.y >> p2.x >> p2.y;
  Line AB(p1, p2);
  int q; cin >> q;
  while(q-- > 0) {
    Vec2 p;
    cin >> p.x >> p.y;
    Vec2 c = Proj(AB, p);
    Line res = ExpandB(Line(p, c), 2*(c - p).length());
    res.t.Show();
  }
  return 0;
}



Measured memory_bytes: 3272
t = {i: 0 for i in range(1, 5)}
for i in range(3):
    a, b = map(int, input().split())
    t[a] += 1
    t[b] += 1

print('YES' if all(k > 0 for k in t.values()) and sum(k%2 for k in t.values()) in {2, 0} else 'NO')


Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
	double x[4],y[4];
	double vxab,vyab,vxcd,vycd;
	int i,j,n;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<4;j++){
			scanf("%lf %lf",&x[j],&y[j]);
		}
		vxab=x[1]-x[0];
		vyab=y[1]-y[0];
		vxcd=x[3]-x[2];
		vycd=y[3]-y[2];
		if((vxab*vycd-vxcd*vyab)==0){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 620
/*
#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
*/
#include <bits/stdc++.h>

#define iosb ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define BIT(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define F first
#define S second
#define pb push_back

using namespace std ;

typedef unsigned long long UL ;
typedef long long L ;
typedef string T ;
typedef int I ;

const I MaxN =      1e5+1 ;
const I MOD =       1e9+7 ;
const I inf =       2e9+7 ;
const L INF = 2e18+7 ;

int32_t main()
{
    //freopen(".in" , "r" , stdin) ;
    //freopen(".out" , "w" , stdout) ;
    L n , a , b ;
    cin >> n >> a >> b ;
    cout << (n/(a+b)*a) + min(n%(a+b),a) ;
}

Measured memory_bytes: 256
#!/usr/bin/env php
<?php
const YYMM = 'YYMM';
const MMYY = 'MMYY';
const BOTH = 'AMBIGUOUS';
const INVALID = 'NA';
function genInputs() {
    while(($input = rtrim(fgets(STDIN))) !== false) {
        foreach (explode(' ', $input) as $v) {
            yield $v;
        }
    }
}
function getNext($gen) {
    $value = $gen->current();
    $gen->next();
    return $value;
}
$gen = genInputs();

$S = (int)getNext($gen);

$a = (int)($S / 100);
$b = (int)($S % 100);


function valid_month($n) {
    return ($n >= 1 && $n <= 12);
}

if (valid_month($a) && valid_month($b)) {
    echo BOTH;
} elseif (valid_month($a)) {
    echo MMYY;
} elseif (valid_month($b)) {
    echo YYMM;
} else {
    echo INVALID;
}
echo PHP_EOL;


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

#define ff first
#define ss second
#define pb push_back
#define ll long long
#define MOD 1000000007
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)

using namespace std;

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

	ll k,x; cin>>k>>x;

	f(i,x-k+1,x+k-1) cout<<i<<" ";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int n, m;
    while(cin >> n >> m, n){
        auto dp = make_v(n, m+1, 10, INF<int>);
        vector<vector<pair<int, int>>> v(n);
        vector<int> cnt(n);
        for (int i = 0; i < n; ++i) {
            int k;
            cin >> k;
            for (int j = 0; j < k; ++j) {
                int x, d;
                cin >> x >> d;
                v[i].emplace_back(x, d);
                if(i == 0){
                    dp[i][0][j] = 0;
                }else if(i == 1 && m){
                    dp[i][1][j] = 0;
                }
            }
        }
        for (int i = 0; i < n-1; ++i) {
            for (int j = 0; j <= m; ++j) {
                for (int k = 0; k < v[i].size(); ++k) {
                    for (int l = 0; l < v[i+1].size(); ++l) {
                        chmin(dp[i+1][j][l], dp[i][j][k]+(v[i][k].second+v[i+1][l].second)
                                                         *abs(v[i][k].first-v[i+1][l].first));
                    }
                }
                if(i != n-2 && j != m){
                    for (int k = 0; k < v[i].size(); ++k) {
                        for (int l = 0; l < v[i+2].size(); ++l) {
                            chmin(dp[i+2][j+1][l], dp[i][j][k]+(v[i][k].second+v[i+2][l].second)
                                                               *abs(v[i][k].first-v[i+2][l].first));
                        }
                    }
                }
            }
        }
        int ans = INF<int>;
        for (int j = 0; j <= m; ++j) {
            for (int k = 0; k < v[n-1].size(); ++k) {
                chmin(ans, dp[n-1][j][k]);
            }
        }
        for (int j = 0; j < m; ++j) {
            for (int k = 0; k < v[n-2].size(); ++k) {
                chmin(ans, dp[n-2][j][k]);
            }
        }
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int dp[20500];
const int MAX = 1001001001;

int main(){
  int h,n; cin >> h >> n;
	FOR(i,1,20499){
		dp[i] = MAX;
	}
	FOR(i,1,n){
		int a,b; cin >> a >> b;
      FOR(j,0,20000-a-1){
        chmin(dp[j+a],dp[j] + b);
      }

		// FOR(j,0,10) cout << dp[i][j] << " ";
		// cout << endl;
	}

	int ans = MAX;
	FOR(i,h,20000){
		chmin(ans,dp[i]);
	}

	cout << ans << endl;
  





}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication34
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                string g = Console.ReadLine();
                if (g == null) break;
                decimal a = decimal.Parse(g);
                decimal b = (a / 9.8M) * (a / 9.8M)*4.9M;
                decimal c = 5*Math.Ceiling(b/5);
                Console.WriteLine(Math.Floor(c/5)+1);
            }
        }
    }
}

Measured memory_bytes: 9244
#include<stdio.h>

int main(){
	int i,n,t,s,e,a;
	
	while(1){
		scanf("%d",&t);
		if(t==0)break;
		scanf("%d",&n);
		a=0;
		for(i=0;i<n;i++){
			scanf("%d%d",&s,&e);
			a+=e-s;
		}
		if(a>=t)printf("OK\n");
		else printf("%d\n",t-a);
	}
	
	return 0;
}

Measured memory_bytes: 0
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, B, C = map(int, readline().split())
    ans = 0
    if A==B==C:
        if A%2==0:
            ans = -1
        else:
            ans = 0
    else:
        pre_A = A
        pre_B = B
        pre_C = C
        while pre_A%2==0 and pre_B%2==0 and pre_C%2==0:
            now_A = (pre_B+pre_C)//2
            now_B = (pre_A+pre_C)//2
            now_C = (pre_A+pre_B)//2
            pre_A = now_A
            pre_B = now_B
            pre_C = now_C
            ans += 1
    print(ans)




if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



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

    int n;
    cin>>n;
    if(n%10==9||n/10==9)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3656
n, k = map(int, input().split())
p = [tuple(map(int, input().split())) for i in range(n)]
p.sort()
ans = 4000000000000000000
for i in range(k, n + 1):
    for j in range(n - i + 1):
        x = p[i + j - 1][0] - p[j][0]
        s = [p[a][1] for a in range(j, i + j)]
        s.sort()
        y = 4000000000
        for a in range(i - k + 1):
          y = min(y, s[a + k - 1] - s[a])
        ans = min(ans, x * y)
print(ans)


Measured memory_bytes: 73448
n=int(input())
a=list(map(int,input().split()))
ans=[]
v=[]
ans=a[-1::-2]
if n%2==0:
    for i in range(0,n,2):
        v.append(a[i])
else:
    for i in range(1,n,2):
        v.append(a[i])
ans.extend(v)
moji=" ".join(map(str,ans))
print(moji)

Measured memory_bytes: 31300
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

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

int main(void){
  string line;
  while(getline(cin,line)){
    if(line=="END OF INPUT") break;
    if(line==""){
      cout<<0<<endl;
      continue;
    }
    stringstream ss;
    ss<<line;
    string word;
    int s=0;
    while(ss>>word){
      s+=word.size()+1;
      cout<<word.size();
      while(s<line.size()&&line[s]==' '){
        cout<<0;
        s++;
      }
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        if i == 0:
            return 0
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
aas = "abcdefghijklmnopqrstuvwxyz"
N = int(input().strip())
S = list(input().strip())
Q = int(input().strip())
cbt = dict()
MX = 5 * 10**5 + 2
for c in aas:
    cbt[c] = Bit(MX)
    for i, a in enumerate(S):
        if a == c:
            cbt[c].add(i+1, 1)

for _ in range(Q):
    t, i, c = input().split()
    t = int(t)
    if t == 1:
        i = int(i)
        if S[i-1] != c:
            cbt[S[i-1]].add(i, -1)
            cbt[c].add(i, 1)
            S[i-1] = c
    else:
#        print(S)
        l, r = int(i), int(c)
#        print(l, r)
        s = 0
        for a in aas:
            bt = cbt[a]
#            print(a, bt.sum(r),bt.sum(l-1))
            s += (bt.sum(r)-bt.sum(l-1)>0)
        print(s)


Measured memory_bytes: 164636
#include<stdio.h>

#define MAX 25
#define ROOT -1
#define NONODE -1

struct NODE {
	int parent;
	int left;
	int right;
};

typedef struct NODE NODE;

NODE nodes[ MAX+1 ];

void walkPreorder( int i )
{
	if( NONODE == i ) { return; }
	
	printf( " %d", i );
	walkPreorder( nodes[i].left );
	walkPreorder( nodes[i].right );
	
	return;
}
void walkInorder( int i )
{
	if( NONODE == i ) { return; }
	
    walkInorder( nodes[i].left );
    printf( " %d", i );
    walkInorder( nodes[i].right );
	
	return;
}
void walkPostorder( int i )
{	
	if( NONODE == i ) { return; }

    walkPostorder( nodes[i].left );
    walkPostorder( nodes[i].right );
	printf( " %d", i );
	
	return;
}

int main( void ) 
{   
    int n;
    int root,left,right,id;
    int i;
	       
    scanf( "%d", &n );

	for( i=0; i<n; i++ ) {
		nodes[i].parent=ROOT;
    }    
    for( i=0; i<n; i++ ) {
    	scanf( "%d%d%d", &id, &left, &right );
	    nodes[id].left=left;
    	if( -1 != left ) {
	    	nodes[left].parent=id;
    	}
	    nodes[id].right=right;
    	if( -1 != right ) {
	    	nodes[right].parent=id;
    	}
    }
    root=ROOT;
	for( i=0; i<n; i++ ) {
        if( ROOT == nodes[i].parent ) {
            root=i;
            break;
        }
     }
	printf( "Preorder\n" );
	walkPreorder( root );
	printf( "\n" );
	
	printf( "Inorder\n" );
	walkInorder( root );
	printf( "\n" );
	
	printf( "Postorder\n" );
	walkPostorder( root );
	printf( "\n" );

    return 0;
}

Measured memory_bytes: 616
n = 0
a = []

def format_input(filename = None):
	global n
	global a
	if filename == None:
		n = int(input())
		a = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(2, 2 * 10**5)
		a = [rng(1, i) for i in range(1, n)]
		print(n)
		print(' '.join(list(map(str, a))))

def get_answer():
	count = [0] * (n+1)
	for i in a:
		count[i] += 1
	for i in range(1, n+1):
		print(count[i])

if __name__ == '__main__':
	format_input()

	get_answer()


Measured memory_bytes: 32240
#include <iostream>
using namespace std;
int main(){
    int N;
    int c=0;
    int k=0;
    cin >> N;
    int A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int t=0;t<1 && c == 0;k++){
        for(int i=0;i<N;i++){
            if(A[i]%2==1){
                c=1;
                break;    
            }
        A[i]=A[i]/2;
        }
    }
cout << k-1 << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


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

  bool ans = false;

  char f = s[0];
  if (s[1]==s[0]){
    if (s[2] == s[3] && s[2] != s[1])ans=true;
  }

  if (s[2]==s[0]){
    if (s[1] == s[3] && s[2] != s[1])ans=true;
  }
  if (s[3]==s[0]){
    if (s[1] == s[2] && s[2] != s[0])ans=true;
  }
  

  cout << (ans?"Yes":"No");
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i,n;
  int a[20];
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int count=0;
  for(i=1;i<n-1;i++){
    if(a[i]>a[i-1] && a[i]<a[i+1]) count++;
    else if(a[i]<a[i-1] && a[i]>a[i+1]) count++;
  }
  printf("%d\n",count);
  return 0;
}

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

namespace ABC129B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] dp = new int[N];
            string[] W = Console.ReadLine().Split();

            int front_Sum;
            int back_Sum;

            for (int T = 0; T < N; T++)
            {
                front_Sum = 0;
                back_Sum = 0;
                for (int i = 0; i <= T; i++)
                {
                    front_Sum += int.Parse(W[i]);
                }
                for (int j = T + 1; j < N; j++)
                {
                    back_Sum += int.Parse(W[j]);
                }
                dp[T] = Math.Abs(front_Sum - back_Sum);
            }
            int ans = dp.Min();
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
    string n;
    cin >> n;
    
    for(int i=0; i<n.size()-2; i++){
        if(n[i]==n[i+1] && n[i+1]==n[i+2]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

const int MAXN = 1000005;
int num[MAXN];

int main() {
  fill(num, num+MAXN, 1);
  num[0] = num[1] = 0;
  for(int i = 2; i < MAXN; ++i) {
    if(!num[i]) continue;
    for(int j = i*2; j < MAXN; j += i) num[j] = 0;
  }
  for(int i = 1; i < MAXN; ++i) {
    num[i] += num[i-1];
  }
  int n;
  while(cin >> n) {
    cout << num[n] << endl;
  }
  return 0;
}

Measured memory_bytes: 5064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

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

	if (S=="AAA")cout << "No" << endl;
	else if (S=="BBB") cout << "No" << endl;
	else cout<<"Yes"<<endl;

	return 0;
}

Measured memory_bytes: 256