akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main {
	static int x;
	static int y;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner inputs = new Scanner(System.in);
		int n= inputs.nextInt();
		x = inputs.nextInt();
		y = inputs.nextInt();
		ArrayList<Integer>[] conn = new ArrayList[n+1];
		for(int i=0;i<n+1;i++) {
			conn[i] = new ArrayList<Integer>();
		}
		conn[x].add(y);
		conn[y].add(x);
		conn[1].add(2);
		for(int i=2;i<n;i++) {
			conn[i].add(i-1);
			conn[i].add(i+1);
		}
		conn[n].add(n-1);
		int[] dists = new int[n];
		for(int p=1;p<n+1;p++) {
			int[] dist = new int[n+1];
			for(int i=0;i<n+1;i++) {
				dist[i]=Integer.MAX_VALUE;
			}
			dist[p] = 0;
			ArrayDeque<Integer> nod = new ArrayDeque<Integer>();
			nod.addLast(p);
			while(nod.size()>0) {
				int spot = nod.removeFirst();
				for(int i:conn[spot]) {
					if(dist[i]>dist[spot]+1) {
						dist[i] = dist[spot]+1;
						nod.addLast(i);
					}
				}
			}
			for(int i=1;i<n+1;i++) {
				dists[dist[i]]++;
			}
		}
		for(int i=1;i<n;i++) {
			System.out.println(dists[i]/2);
		}
		/*
		int[] dist = new int[n+1];
		for(int i=1;i<=n-1;i++) {
			for(int j=i+1;j<=n;j++) {
				int far = j-i+range(i,j);
				dist[far]++;
			}
		}
		for(int i=1;i<n;i++) {
			System.out.println(dist[i]);
		}
		*/
	}
	public static int range(int one, int two) {
		if(one<=x&&two>=y) {
			return (x-y)+1;
		}
		return 0;
	}
}


Measured memory_bytes: 90720
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
  int c[256];
  memset(c,0,sizeof(c));
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++)
    {
      c[s[i]]++;
    }
  int ans=c['K'];
  
  if(ans>c['U'])
    ans=c['U'];
  if(ans>c['P'])
    ans=c['P'];
  if(ans>c['C'])
    ans=c['C'];
  cout<<ans<<endl;
  
}

Measured memory_bytes: 1188
s = input()
if int(s[0:2]) > 0 and int(s[0:2]) < 13:
    if int(s[2:4]) > 0 and int(s[2:4]) < 13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if int(s[2:4]) > 0 and int(s[2:4]) < 13:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3064
def check(s):  
    baccha = ''.join(reversed(s)) 
    if (s == baccha): 
        return True
    return False
s=input()
n=len(s)
s1=s[0:n//2]
s2=s[n//2+1:]
if check(s) and check(s1) and check(s2):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <list>
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define SQR(X)  ( (X)*(X) )
#define CUBE(X) ( (X)*(X)*(X) )
 
// #define int ll
 
using namespace std;
 
bool test = 0;
 
/* ?????????????????¬??¨ */
 
int main(){
  int i,j,k,l;
  int n;
  while(scanf("%d",&n) != EOF) {
    map<char,char> m;
    if(n == 0) break;
    rep(i,n) {
      char a,b;
      cin >> a >> b;
      m[a] = b;
    }
    cin >> n;
    rep(i,n) {
      char c; cin >> c;
       if (m.find(c) == m.end()) {
         putchar(c);
       }
       else putchar(m[c]);
    }
    putchar('\n');
  }
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

ll fif(ll x){
  return x*x*x*x*x;
}
void solve(long long X){
  for (ll i = -1000; i <= 1000; i++)
  {
    for (ll j = -1000; j < 1000; j++)
    {
      if(X==fif(i)-fif(j)){
        printf("%lld %lld\n",i,j);
        return;
      }
    }
  }
}

int main(){
  cout<<setprecision(1000);
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3824
#include <stdio.h>

int main(){
   int n,i,ans,a;

   scanf("%d",&n);
   for (ans=i=0;i<n;i++) {
      scanf("%d",&a);
      if (i%2==0 && a%2==1) ans++;
   }
   printf("%d\n",ans);
   return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int a[9]={2,5,5,4,5,6,3,7,6};
string dp[13];
bool can[9];
bool c(string a,string b){
	if(a.size()>b.size())return 0;
	if(a.size()<b.size())return 1;
	for(int i=0;i<a.size();i++){if(a[i]>b[i])return 0;if(a[i]<b[i])return 1;}
}
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x;
		cin>>x;
		can[x-1]=1;
	}
	dp[0]="";
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<9;j++)
			if(i>=a[j]&&(dp[(i-a[j])%13]!=""||i-a[j]==0))
				if(can[j]&&c(dp[i%13],(dp[(i-a[j])%13]+char('1'+j))))
					dp[i%13]=dp[(i-a[j])%13]+char('1'+j);
	}
	cout<<dp[n%13];
}

Measured memory_bytes: 384
#include<iostream>

int main(){

    size_t a, b, c;
    std::cin >> a >> b >> c;

    for(size_t i = 0; i < b; i++){
        if(i * a % b == c){
            std::cout << "YES" << std::endl;
            return 0;
        }
    }

    std::cout << "NO" << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cstdlib>
#include<iomanip>
#include<cmath>
#include<cassert>
#include<ctime>
#include<map>
#include<set>
using namespace std;

#pragma comment(linker, "/stck:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.1415926535897932384626433832
#define ios() ios::sync_with_stdio(true)
#define INF 0x3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int ans[26],n,a[200006];
ll pos=0,cnt=0;

int main()
{
	cin>>n;
	int k=1;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		int flag=1;
		for(int j=0;j<=20;j++)
		{
			if(a[i]&(1<<j))
			{
				ans[j]++;
			}
			if(ans[j]>1)
			{
				flag=0;
			}
		}
		
		if(!flag)
        {
            pos+=cnt;
            while(k<i)
            {
                int ok=1;
                for(int j=0;j<=20;j++)
                {
                    ans[j]-=(a[k]&(1<<j))?1:0;
                    if(ans[j]>1)
					{
						ok=0;
					}
                }
                k++;
                cnt--;
                if(ok)
				{
					break;
				}
                else
				{
					pos+=cnt;
				}
            }
        }
        cnt++;
	}
	cout<<(long long)pos+((1+cnt)*cnt/2);
	return 0;
}


Measured memory_bytes: 1024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	s1 = input()
	s2 = input()
	if s1[0] == s2[2] and s1[1] == s2[1] and s1[2] == s2[0]:
		print('YES')
	else:
		print('NO')

if  __name__=='__main__':
	main()


Measured memory_bytes: 5268
#include <iostream>
#include <stack>
using namespace std;
class kakko{
private:
  stack<char> st;
  int flag;//0=input 1=error

  void digest(char a){
    if(a=='('||a=='[')
      st.push(a);
    if(a==')'){
      if(st.top()=='(') st.pop();
	else errork();
    }
    if(a==']'){
      if(st.top()=='[') st.pop();
	else errork();
    }
    if(a=='.'){
      if(st.top()) {st.empty();st.push(0);    cout <<"no\n";}
      else cout <<"yes\n";
    }
  }
  int errork(){
    cout <<"no\n";
    flag=1;
    st.empty();st.push(0);  
  };
public:
  kakko(){
    st.push(0);
    flag=0;
  }
  void eat(char t){

    if(flag){
      if(t=='.') flag=0;
    }
    else digest(t);
  }
};

int main(){
  kakko ka;
  string tmps;
  getline(cin,tmps);
  while(tmps!="."){
    for(int i=0;i<tmps.length();i++)
      ka.eat(tmps[i]);
  getline(cin,tmps);
  }
  return 0;
}

Measured memory_bytes: 1196
n = int(input())
alst = list(map(int, input().split()))
ans = []
for pm in range(2):
    total = 0
    tmp = 0
    for j, num in enumerate(alst):
        total += num
        if (j + pm) % 2 == 0:
            if total > 0:
                pass
            else:
                tmp += abs(1 - total)
                total = 1
        else:
            if total < 0:
                pass
            else:
                tmp += abs(-1 - total)
                total = -1
    ans.append(tmp)
print(min(ans))

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

const int MAXN = 1e5 + 5;
#define ii pair<int,int> 

int n, m;
int lvl[MAXN], p[MAXN], par[MAXN];
bool visited[MAXN];
vector<int> adj[MAXN];
vector<ii> e;

int getParent(int x){
	return (p[x] == x) ? x:getParent(p[x]);
}

void conn(int a, int b){
	int pa = getParent(a), pb = getParent(b);
	if(pa != pb){
		if(lvl[pa] < lvl[pb])
			p[pa] = pb;
		else
			p[pb] = pa;
		if(lvl[pa] == lvl[pb])
			lvl[pa]++;
	}
}

void dfs(int pos, int prev){
	visited[pos] = true;
	for(int i : adj[pos]){
		if(visited[i])
			continue;
		dfs(i, pos);
	}
	if(par[pos] == 1){
		e.push_back(ii(pos, prev));
		par[pos] = 1-par[pos];
	}else if(pos != 0){
		e.push_back(ii(prev, pos));
		par[prev] = 1-par[prev];
	}
}

int main(){
	scanf("%d %d", &n, &m);
	for(int i = 0; i < n; ++i){
		p[i] = i;
		lvl[i] = 0;
		par[i] = 0;
	}
	for(int i = 0; i < m; ++i){
		int u, v;
		scanf("%d %d", &u, &v);
		u--; v--;
		if(getParent(u) != getParent(v)){
			conn(u, v);
			adj[u].push_back(v);
			adj[v].push_back(u);
		}else{
			e.push_back(ii(u, v));
			par[u] = 1-par[u];
		}
	}
	dfs(0, -1);
	if(m%2 == 1){
		printf("-1\n");
	}else{
		for(ii i : e){
			printf("%d %d\n", i.first+1, i.second+1);
		}
	}
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

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

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

signed main(){
    string S;
    cin >> S;
    int len = S.length();
    int ans = len;
    REP(i, len - 1){
        if(S[i] != S[i + 1]) ans = min(ans, max(i + 1, len - i - 1));
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 512
x,y,a,b,c = map(int,input().split())

p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort()


all = p[:x] + q[:y] + r
all.sort(reverse=True)

print(sum(all[:x+y]))

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<LL> a(n), b(n);
    vector<LL> cnt(32, 0);
    inc(i, 0, n) cin >> a[i];
    inc(i, 0, n) cin >> b[i];
    dec(k, 0, 30){
        inc(i, 0, n){
            b[i] %= (1<<(k+1));
            a[i] %= (1<<(k+1));
        }
        sort(b.begin(), b.end());
        inc(i, 0, n){
            LL t = 1 << k;
            cnt[k] += lower_bound(b.begin(), b.end(), 2*t-a[i])-lower_bound(b.begin(), b.end(), 1*t-a[i]);
            cnt[k] += lower_bound(b.begin(), b.end(), 4*t-a[i])-lower_bound(b.begin(), b.end(), 3*t-a[i]);
        }
    }
    LL ans = 0;
    inc(k, 0, 32){
        ans += (cnt[k]%2?1<<k:0);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3456
#include<iostream>
using namespace std;
 
int main(){
  int a,b;

  cin >> a >> b;

  if (a < b){
      cout << "a < b" << endl;
  } else if (a > b){
      cout << "a > b" << endl;
  } else if (a == b){
      cout << "a == b" << endl;
  }

  return 0;		 
}
		   


Measured memory_bytes: 3048
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N;
    cin >> N;
    vector<ll> S(N + 1);
    S[0] = 0;
    for(int i = 0; i < N; ++i){
        cin >> S[i + 1];
        S[i + 1] += S[i];
    }
    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, -1));
    auto MemoRec = [&](auto&& self, int left, int right) -> ll {
        if(dp[left][right] != -1)   return dp[left][right];
        if(right - left == 1)   return dp[left][right] = 0;
        ll res = 1e+13;
        for(int mid = left + 1; mid < right; ++mid){
            chmin(res, self(self, left, mid) + self(self, mid, right));
        }
        res += S[right] - S[left];
        return dp[left][right] = res;
    };
    cout << MemoRec(MemoRec, 0, N) << endl;
}

Measured memory_bytes: 4516
#include <bits/stdc++.h>
using namespace std;
template<class T, class Pred>
T boundary(T ng, T ok, Pred pred){
  while(abs<T>(ok-ng)>1){
    T mid=ng+(ok-ng)/2;
    if(pred(mid)) ok=mid;
    else ng=mid;
  }
  return ok;
}
int main(){
  size_t n,k; cin>>n>>k;
  vector<size_t> w(n);
  for(auto&& x:w) cin>>x;
  const auto& possible=[k,&w](size_t x){
    size_t tmpk=1, tmpw=0;
    for(const auto& e:w){
      tmpw+=e;
      if(tmpw>x){
        if(e>x) return false;
        ++tmpk; tmpw=e;
      }
    }
    return tmpk<=k;
  };
  cout<<boundary(0ul,10000ul*n,possible)<<'\n';
}



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


int main() {
  int N, K;
  cin >> N >> K;
  vector<int> V(N);
  for(int i = 0; i < N; i++){
    cin >> V.at(i);
  }
  for(int i = 0; i < N-K; i++){
    if(V.at(i) < V.at(i+K)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

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

typedef long long LL;

const int N = 205;
const int lg = 61;

vector<LL> xor_basis(vector <LL> a) {
    LL n = a.size();
    LL row = 0;
    vector<LL> basis;
    vector<bool> colm(lg, 0);
    for(LL k = lg-1; k >= 0; k--) {
        for(LL i = row; i < n; i++) {
            if((a[i]>>k)&1) {
                swap(a[i], a[row]);
                break;
            }
        }
        if(row < n && (a[row]>>k)&1) {
            basis.push_back(a[row]);
            colm[k] = 1;
            for(int i = row + 1; i < n; i++) {
                if((a[i]>>k)&1) a[i] ^= a[row];
            }
            row++;
        }
    }
    return basis;
}


LL A[N];

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int tc;
    cin >> tc;
    while(tc--) {
        int n;
        cin >> n;
        for(int i = 0; i < n; i++) cin >> A[i];
        string S;
        cin >> S;
        bool can = false;
        vector<LL> basis;
        for(int i = n-1; i >= 0; i--) {
            if(S[i] == '0') {
                basis.push_back(A[i]);
                basis = xor_basis(basis);
            }
            else {
                vector<LL> new_basis = basis;
                new_basis.push_back(A[i]);
                new_basis = xor_basis(new_basis);
                if(new_basis.size() > basis.size()) {
                    can = true;
                    break;
                }
            }
        }
        cout << can << "\n";
    }

    return 0;
}



Measured memory_bytes: 3568
#include <iostream>

using namespace std;
bool judge(int a,int b)
{
    if(a*b%2==0) return 1;
    else return 0;
}
int main()
{
    int a,b;
    cin>>a>>b;
    if(judge(a,b))  cout <<"Even";
    else cout<<"Odd";
    return 0;
}


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

#define mp make_pair
#define pb push_back
#define fst first
#define snd second
#define int long long
#define fast_io() ios::sync_with_stdio(false)
#define FOR(i, l, r) for(int i = (l); i < (r); i++)
#define H(x) cout << #x << " " << x << endl;

typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef set<int> si;
typedef double ld;
typedef pair<ld, ld> dd;

const ll INF = 1000000000000000000LL;
const int NMAX = 1e6+4;
const int mod = 1e9+7;
const ld eps = 1e-10;
const ld PI = acos(-1);

int N;
vvi adj;

ii dfs (int u, int p){
    ii ret = {1, u};
    for(int v : adj[u]) if(v != p) {
        ii p = dfs(v, u);
        p.fst ++;
        ret = max(ret, p);
    }
    return ret;
}

signed main (){
    cin >> N;
    adj.assign(N, vi(0));
    FOR(i, 0, N-1){
        int u, v;
        cin >> u >> v;
        u--; v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    auto p = dfs(0, -1);
    p = dfs(p.snd, -1);
    cout << (p.fst % 3 == 2 ? "Second" : "First") << endl;
}

Measured memory_bytes: 26752
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

x,k,d=mp()
x=abs(x)
if k*d<=x:
    print(x-k*d)
    exit()
y=x//d
if (k-y)%2==1:
    print(abs(x-d*(y+1)))
else:
    print(abs(x-d*y))


Measured memory_bytes: 72728
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    int n, m;
    cin >> n >> m;
    int ans = ( 1900 * m + 100 * ( n - m ) );
    rep(i, m) ans *= 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int,input().split()))
countdic = Counter(A)
goukei = 0
ans = ''
for key,value in countdic.items():
    goukei += (value*(value-1))//2
for i in A:
    ans = goukei -(countdic[i]*(countdic[i]-1))//2 + ((countdic[i]-1)*(countdic[i]-2))//2
    print(ans)

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

int main () {
  string s;
  int a;
  cin >> s;
  
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'A') {
      a++;
    }
  }
  if (a==1 || a==2) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<long int, long int> > v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
  }
  sort(v.begin(), v.end());
  int index = 0;
  long long int ans = 0;
  while (1) {
    if (v[index].second <= m) {
      ans += v[index].first * v[index].second;
      m -= v[index].second;
      index++;
    } else if (v[index].second > m) {
      ans += v[index].first * m;
      cout << ans << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;

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

    vector<vector<char>> data(H + 2, vector<char>(W + 2, '.'));
    string s;
    for (int i = 0; i < H; i++)
    {
        cin >> s;
        for (int j = 0; j < W; j++)
        {
            data.at(i + 1).at(j + 1) = s.at(j);
        }
    }

    for (int i = 1; i <= H; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            if (data.at(i).at(j) == '#')
            {
                if (data.at(i - 1).at(j) != '#' && data.at(i + 1).at(j) != '#' && data.at(i).at(j - 1) != '#' && data.at(i).at(j + 1) != '#')
                {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 入力値を文字の配列で返却する
def gets_nsp_list()
  gets.chomp.split("")
end

# [a, b].min が遅いので
def min(a, b)
  return a < b ? a : b
end

N = gets_i
s_list = gets_nsp_list

w_count, e_count = 0, 0
counts = s_list.map do |s|
  if s == "W"
    w_count += 1
  else
    e_count += 1
  end
  [w_count, e_count]
end

dpp counts

total = N
N.times do |i|
  i - 1
  l = i - 1 >= 0 ? counts[i - 1][0] : 0
  r = counts[N-1][1] - counts[i][1]
  total = min(total, l + r)
end

puts total

Measured memory_bytes: 36728
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const double eps = 1e-8;
struct Point {
    double x, y;
} a[N], O;
double R;
double sqr(double x) {return x * x;}
double dis(Point a, Point b) {return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));}
void work(Point p1, Point p2, Point p3) {
    double a, b, c, d, e, f;
    a = p2.y - p1.y; b = p3.y - p1.y; c = p2.x - p1.x; d = p3.x - p1.x;
    f = p3.x * p3.x + p3.y * p3.y - p1.x * p1.x - p1.y * p1.y;
    e = p2.x * p2.x + p2.y * p2.y - p1.x * p1.x - p1.y * p1.y;
    O.x = (a * f - b * e) / (2 * a * d - 2 * b * c); O.y = (d * e - c * f) / (2 * a * d - 2 * b * c);
    R = dis(O, p1);
}
int main() {
    int n, i, j, k;
    scanf("%d", &n);
    for (i = 1; i <= n; ++i) scanf("%lf%lf", &a[i].x, &a[i].y);
    random_shuffle(a + 1, a + n + 1);
    O = a[1]; R = 0;
    for (i = 2; i <= n; ++i)
        if (dis(a[i], O) > R + eps) {
            O = a[i]; R = 0;
            for (j = 1; j < i; ++j)
                if (dis(a[j], O) > R + eps) {
                    O.x = (a[i].x + a[j].x) / 2; O.y = (a[i].y + a[j].y) / 2; R = dis(a[j], O);
                    for (k = 1; k < j; ++k) if (dis(a[k], O) > R + eps) work(a[i], a[j], a[k]);
                }
        }
    printf("%.10lf", R);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll pre[500005] = {0};
ll nex[500005] = {0};

int main(){
	string s; cin >> s;
	for(int i = 0;i < s.size();i++){
		if(s[i] == '<'){
			ll x = 1;
			pre[i] = 0;
			while(s[i+1] == s[i] && i+1 < s.size()) pre[++i] = x++;
			pre[i+1] = x++;
		}
	}
	if(s[s.size()-1] == '<') pre[s.size()] = pre[s.size()-1] + 1;
//	for(int i = 0;i <= s.size();i++) cout << pre[i] << " ";
//	cout << endl;
	for(int i = s.size()-1;i >= 0;i--){
		if(s[i] == '>'){
			ll x = 1;
			nex[i+1] = 0;
			while(s[i-1] == s[i] && i-1 >= 0) nex[i--] = x++;
			nex[i] = x++;
		}
	}
	if(s[0] == '>') nex[0] = nex[1] + 1;
//	for(int i = 0;i <= s.size();i++) cout << nex[i] << " ";
//	cout << endl;
	ll sum = 0;
	for(int i = 0;i <= s.size();i++){
		sum += max(pre[i],nex[i]);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 8708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+50;

int n,a[N];

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%d",&a[i]);
    int cnt=0,pos=1;
    while(pos<=n){
        if(a[pos]==cnt+1){
            cnt+=1;
            ++pos;
        }
        else{
            ++pos;
        }
    }
    if(!cnt) puts("-1");
    else printf("%d\n",n-cnt);
    return 0;
}

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

using namespace std;

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


int main(){
 long h,w;
   cin >> h >> w;

  long res=h*w;
 rep(i,1,h){
  long a=i*w;
  long b=(h-i)*(w/2);
  long c=h*w-a-b;
   res=min(res,max({a,b,c})-min({a,b,c}));
 
    b=(h-i)/2*w;
   c=h*w-a-b;
   res=min(res,max({a,b,c})-min({a,b,c})); 
   
 }
  rep(i,1,w){
  long a=i*h;
  long b=(w-i)*(h/2);
  long c=h*w-a-b;
   res=min(res,max({a,b,c})-min({a,b,c}));
 
    b=(w-i)/2*h;
   c=h*w-a-b;
   res=min(res,max({a,b,c})-min({a,b,c})); 
   
 }
  
  
  

   cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n, k;
    cin >> n >> k;

    int ans =  1; 
    rep(i, n){
        ans += min(k, ans);
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

void swap(int* a, int* b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

    if (a % b == 0)
        return b;
    else
        return gcd(b, a % b);
}

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

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/


int binary_search(int* p, int n, int key,int num)
{
    int low, high, middle;

    low = 0;
    high = n - 1;

    while (low <= high)
    {
        middle = (low + high) / 2;
        if (gcd(num,p[middle])==1)
            return middle;
        else 
            high = middle - 1;
    }
}

int main()
{
    int N;
    lli sum = 0;

    scanf("%d", &N);

    for (int i = 1; i <= N; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
            sum += i;
    }

    printf("%lld", sum);
}



Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	int k[15];
	for (int i = 0; i < 12; ++i) { cin >> k[i]; }
	sort(k, k + 12);
	if (k[0] == k[3] && k[4] == k[7] && k[8] == k[11]) { cout << "yes" << endl; }
	else { cout << "no" << endl; }
}



Measured memory_bytes: 3160
package main

import (
	"bufio"
	"fmt"
	"os"
	"unicode/utf8"
)

type Int2DList [][]int
type IntList []int

func (a Int2DList) ChMax(i, j int, value int) bool {
	curV := a[i][j]
	if curV < value {
		a[i][j] = value
		return true
	}
	return false
}
func lib_NewInt2DList(length1, length2 int, initialValue int) Int2DList {
	ret := make([][]int, length1, length1)
	for i := 0; i < length1; i++ {
		ret[i] = lib_NewIntList(length2, initialValue)
	}
	return ret
}
func lib_NewIntList(length int, initialValue int) IntList {
	ret := make([]int, length, length)
	for i := 0; i < length; i++ {
		ret[i] = initialValue
	}
	return ret
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var s string
	scanner.Scan()
	s = scanner.Text()
	var t string
	scanner.Scan()
	t = scanner.Text()
	fmt.Println(solve(s, t))
}
func solve(s string, t string) string {
	slen := utf8.RuneCountInString(s)
	tlen := utf8.RuneCountInString(t)
	m := lib_NewInt2DList(slen+5, tlen+5, 0)
	m[0][0] = 0
	for si, sr := range s {
		for ti, tr := range t {
			m.ChMax(si+1, ti+1, m[si][ti])
			m.ChMax(si+1, ti+1, m[si+1][ti])
			m.ChMax(si+1, ti+1, m[si][ti+1])
			if sr == tr {
				m.ChMax(si+1, ti+1, m[si][ti]+1)
			}
		}
	}
	result := ""
	for i, j := slen, tlen; i > 0 && j > 0; {
		switch m[i][j] {
		case m[i-1][j]:
			i--
		case m[i][j-1]:
			j--
		default:
			i--
			j--
			result = string(s[i]) + result
		}
	}
	return result
}


Measured memory_bytes: 80768
N = int(input())
words = []

for i in range(N):
  w = input()
  words.append(w)
  
signal=1

for j in range(1,N):
  for k in range(j):
    if words[k]==words[j]:
      signal=0
  if words[j-1][-1]!=words[j][0]:
    signal=0
    
if signal==1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    unsigned long long i,j,k,l,m,n,a,b,c,d,cnt=0,f=0;
    cin>>n;
     long double mm=1000000000000000000;
     long double arr[n];
    for(i=0;i<n;i++)
        cin>>arr[i];
     long double ss=1;
    for(i=0;i<n;i++)
    {
        if((arr[i])>((mm/ss))&& cnt==0)
        {cnt=1;}
        if(arr[i]==0)
        {
            f=1;
        }
        ss*=arr[i];
    }
    if(cnt==1 && f==1)
        cout<<0<<endl;
    else if(cnt==1 && f==0)
        cout<<-1<<endl;
    else
    {j=ss;cout<<j<<endl;}

}


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

int main()
{
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int count = 0;
  for (double i = 0; i <= N; i++)
  {
    for (double j = 0; j <= N; j++)
    {
      double k = (N - R * i - G * j) / B;
      if (k >= 0 && floor(k) == k)
      {
        count++;
      }
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 256
a=[]#入力画面の二文字を別々の文字に格納
a=input().split(" ")
A=int(a[0])
B=int(a[1])

if A>=13 :
    print(B)
elif 12>=A and A>=6 :
    b=B/2
    print(int(b))
elif 6>A:
    print('0')


Measured memory_bytes: 2940
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

int h,w;
cin>>h>>w;
char c[2*h][w];
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        cin>>c[2*i][j];
        c[2*i+1][j]=c[2*i][j];
    }
}

for(int i=0;i<2*h;i++){
    for(int j=0;j<w;j++){
        cout<<c[i][j];
    }
    cout<<endl;
}


return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a, b;
  scanf("%d %d", &a, &b);
  if(a < b){
    printf("a < b\n");
  }else if(a > b){
    printf("a > b\n");
  }else if(a == b){
    printf("a == b\n");
  }
  return 0;
}



Measured memory_bytes: 2064
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		int N = nextInt();
		ArrayList<Integer> list = nextIntArray();
		int output = 1;
		TreeSet<Integer> set = new TreeSet<Integer>();
		set.add(list.get(0));
		for(int i = 1; i < N; i++){
			if(set.lower(list.get(i)) == null){
				output++;
			}
			set.add(list.get(i));
		}
		myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 61848
#include<iostream>
#include<string>
#include<math.h>
#include <sstream>

using namespace std;

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

long long c3;
long long c5;
long long c15;

long long s;

long long lpow(int n){
    long long output = 1;
    REP(i, n){
        output *= 10;
    }
    return output;
}

long long lfb(long long t, int i, long long len){
    long long t15 = t / 15 - c15;
    long long t3 = t / 3 - t15 - c15 - c3;
    long long t5 = t / 5 - t15 - c15 - c5;

    c15 += t15;
    c3 += t3;
    c5 += t5;

    long long l15 = t15*(8-i);
    long long l3 = t3*(4-i);
    long long l5 = t5*(4-i);
    len += i*(t - (lpow(i-1)-1)) + l15 + l3 + l5;

    return len;
}

long long fb(long long n){
    int i = 1;

    c3 = 0;
    c5 = 0;
    c15 = 0;

    long long len = 0;
    long long t1 = 1;
    while(1){
        long long t = lpow(i) - 1;
        if(t>n) break;

        len = lfb(t, i, len);
        i += 1;
    }

    len = lfb(n, i, len);
    return len;
}

long long bs(){
    long long n = 10e16;
    long long ub = n;
    long long lb = 0;
    while(ub-lb > 1){
        long long mid = (ub - lb) / 2 + lb;
        long long fbhn = fb(mid);
        if(fbhn >= s){
            ub = mid;
        } else {
            lb = mid;
        }
    }
    
    return lb += 1;
}

int main(){
    cin >> s;

    long long num = bs();
    long long crfb = fb(num-1);

    string str;
    REP(i, 500){
        if(num % 15 == 0){
            str += "FizzBuzz";
        } else if (num % 3 == 0){
            str += "Fizz";
        } else if (num % 5 == 0){
            str += "Buzz";
        } else {
            stringstream ss;
            ss << num;
            str += ss.str();
        }
        num += 1;
    }

    cout << str.substr(s-crfb-1, 20) << endl;
}

Measured memory_bytes: 3232
#include<cstdio>
#include<algorithm>
#define maxn 200005
using namespace std;
int n,l,r,a[maxn];
bool check(int x)
{
	for(int i=0;i<n-1;i++)
	{
		bool x1=0,x2=0;
		if(a[n-i]>=x&&a[n-i-1]>=x) x1=true;
		if(a[n+i]>=x&&a[n+i+1]>=x) x1=true;
		if(a[n-i]<x&&a[n-i-1]<x) x2=true;
		if(a[n+i]<x&&a[n+i+1]<x) x2=true;
		if(x1) return true;
		if(x2) return false;
	}
	return a[1]>=x;
}
int BS()
{
	int l=1,r=n*2+1;
	while(l+1<r)
	{
		int mid=(l+r)>>1;
		if(check(mid)) l=mid;
		else r=mid;
	}
	return l;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n*2-1;i++) scanf("%d",&a[i]);
	printf("%d\n",BS());
}

Measured memory_bytes: 1024
#! /usr/bin/env python3
a, b = input().split()
c = d = 0
if float(a) > 0 and '.' in a : c = a[::-1].find('.')
if float(b) > 0 and '.' in b : d = b[::-1].find('.')
t = int(a.replace('.', '')) * int(b.replace('.', ''))
if t == 0 or c+d < 1:
    print(t)
else:
    print(str(t)[:-(c+d)])

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<ll, ll> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

bool comp(P a, P b){
    if(a.first == b.first) return a.second < b.second;
    else return a.first > b.first;
}

int main(void){
    int N; cin >> N;
    VL a(N); REP(i,N) cin >> a[i];
    vector<P> v(N);
    REP(i,N){
        v[i].first = a[i];
        v[i].second = i;
    }
    sort(ALL(v), comp);

    VL ans(N,0);
    ll idx = 0, prev = 0;
    ll sum = 0;
    while(idx<N){
        while(idx<N-1 && v[prev].second < v[idx+1].second){
            sum += v[idx].first;
            idx++;
        }
        sum += v[idx].first;
        idx++;
        ll t = idx==N ? 0 : v[idx].first;
        ans[v[prev].second] = sum - idx*t;
        sum -= sum - idx*t;
        prev = idx;
    }

    REP(i,N) cout << ans[i] << en;

    return 0;
}

Measured memory_bytes: 4224
#ifdef LOCAL
#include "libs/debug/print_list.hpp"
#define D(x) (cout << # x ": " << x << endl)
#define dev(v, m, n) for(int i=0;i<n;++i){for(int j=0;j<m;++j){cout<<"|"<<v[j][i];}cout<<"|"<<endl;}
#else
#define D(x) ;
#define dev(v, m, n) ;
#endif

// :----------------------------------------

#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mp(x, y) make_pair(x, y)

using vi = vector<int>;
using pi = pair<int, int>;
using vp = vector<pi>;
using Graph = vector<vector<int>>;

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;}

#define P (1'000'000'007)

signed main() {
    int n, K;
    cin >> n >> K;

    vi vx, vy;
    vp v;

    rep(i, n) {
        int x, y;
        cin >> x >> y;

        vx.push_back(x);
        vy.push_back(y);
        v.push_back(mp(x, y));
    }

    sort(all(vx));
    sort(all(vy));

    int ans = 1ll << 62;

    rep(i, n) {
        int ax = vx[i];
        rep(j, n) {
            int ay = vy[j];
            for (int k = i + 1; k < n; ++k) {
                int bx = vx[k];
                for (int l = j + 1; l < n; ++l) {
                    int by = vy[l];
                    int res = 0;
                    D(ax); D(ay); D(bx); D(by);
                    rep(p, n) {
                        if (ax <= v[p].first && v[p].first <= bx && ay <= v[p].second && v[p].second <= by) ++res;
                    }
                    D(res);
                    if (res >= K) chmin(ans, (bx - ax) * (by - ay));
                }
            }
        }
    }

    cout << ans;
    
    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int n[] = {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 << n[k - 1] << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 3010
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
#define INF 1000000000000
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	int n;
    ll k;
    cin>>n>>k;
    vector<int> a(n),f(n);
    REP(i,n){
        cin>>a[i];
    }
    REP(i,n){
        cin>>f[i];
    }
    sort(ALL(a));
    sort(ALL(f));
    ll l=-1;
    ll r=INF;
    while(r-l>1){
        ll m=(r+l)/2;
        ll cnt=0;
        bool t=true;
        REP(i,n){
            if((ll)a[i]*f[n-1-i]>m)cnt+=a[i]-(m/f[n-1-i]);
            if(cnt>k){
                t=false;
                break;
            }
        }
        if(t) r=m;
        else l=m;
    }
    OUT(r);
    return 0;
}

Measured memory_bytes: 1792
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

H,W=get_i
s=array(H)
H.times do|i|
    s[i]=get
end
ab=("A".."Z").to_a
ans=""
H.times do|i|
    W.times do|j|
      if s[i][j]=="snuke"
          ans=ab[j]+(i+1).to_s
          break
      end  
    end
end
puts ans

Measured memory_bytes: 1788
N = int(input())
S = input()
conv = []
rev = 0

for s in S:
  if s == 'Z':
    rev = 26 - N
    conv.append(chr((ord(s) - ord('A') - rev) % 26 + ord('A')))    
  else:
    conv.append(chr((ord(s) - ord('A') + N) % 26 + ord('A')))

ans = "".join(conv)
print(ans)


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);    
  }
  
  int max=a.at(0),min=a.at(0);
  for(int i=0;i<N;i++){
    
    if(a.at(i)>=max){
      max=a.at(i);
    }
    if(a.at(i)<=min){
      min=a.at(i);
    }
    
  }
  cout << max-min << endl;
}

Measured memory_bytes: 3608