akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

void solve(){
  string s;
  cin >> s;
  int n=s.size();
  int ans=0;
  int len=0;
  for(int i=0;i<n;i++){
    if(s[i]=='A'|| s[i]=='T'|| s[i]=='C' || s[i]=='G'){
      len++;
      ans=max(ans,len);
    }
    else{
      len=0;
    }
  }
  cout << ans << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,i;
	int a[100];
	
	scanf("%d",&n);
	
	for(i = 0;i < n;i++){
		scanf("%d",&a[i]);
		}
		for(i = n-1;i > 0;i--){
		printf("%d ",a[i]);
	}
	printf("%d\n",a[0]);
	
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;

int my_find(int *group, int i) {
    vector<int> gp;
    int now = i;
    while(group[now] != now){
        gp.push_back(now);
        now = group[now];
    }
    for(int mem:gp){
        group[mem] = now;
    }
    return now;
}

void my_union(int* group, int a, int b) {
    int ga = my_find(group, a);
    int gb = my_find(group, b);
    group[ga] = gb;
}

int main(){
    int H,W,M;
    cin >> H >> W >> M;
    int gp[M];
    map<int, vector<int>> tate, yoko;
    for(int i=0;i<M;i++){
        gp[i]=i;
    }
    set<long> plc;
    int h[M];
    int w[M];
    for(int i=0;i<M;i++){
        cin >> h[i];
        cin >> w[i];
        yoko[h[i]].push_back(i);
        tate[w[i]].push_back(i);
        plc.insert(h[i]*W+w[i]);
    }
    set<int> maxy, maxt;
    int ycnt=0, tcnt=0;
    for(auto y:yoko){
        if(ycnt < y.second.size()){
            ycnt = y.second.size();
            maxy.clear();
            maxy.insert(y.first);
        }else if(ycnt == y.second.size()){
            maxy.insert(y.first);
        }
    }
    for(auto y:tate){
        if(tcnt < y.second.size()){
            tcnt = y.second.size();
            maxt.clear();
            maxt.insert(y.first);
        }else if(tcnt == y.second.size()){
            maxt.insert(y.first);
        }
    }
    for(auto t:maxt){
        for(auto y:maxy){
            if(plc.find(y*W+t) == plc.end()){
                cout << tcnt+ycnt;
                return 0;
            }
        }
    }

    cout << tcnt+ycnt-1;



    return 0;
}



Measured memory_bytes: 114908
from functools import reduce
import math

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

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    x, a, b = (int(_) for _ in input().split())
    if (abs(x-a) > abs(x-b)):
        print('B')
    else:
        print('A')
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

struct st{int start,length,score;};

int toBit(int start,int length){
    int ret = 0;
    rep(i,length){
        ret+=1<<(start+i);
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int ans=0;
    vector<st> sub[5];
    int n,m,l;
    cin>>n>>m>>l;
    rep(i,m){
        int d,a,k,t;
        cin>>d>>a>>k>>t;
        a--;
        sub[d].pb(st{a,k,t});
    }
    
    int dp[5][1<<8][301];
    int data[5][301];
    rep(i,5)rep(j,301)data[i][j]=0;
    rep(i,5)rep(j,1<<8)rep(k,301)dp[i][j][k] = -1;
    rep(i,5)dp[i][0][0]=0;
    rep(day,5){
        vector<st> vec = sub[day];
        rep(i,vec.size()){
            rep(j,1<<n){
                rep(k,l){
                    if(dp[day][j][k]==-1)continue;
                    int bit = toBit(vec[i].start,vec[i].length);
                    if( (bit&j)!=0 )continue;
                    
                    dp[day][j|bit][k+1]=max( dp[day][j|bit][k+1] , dp[day][j][k]+vec[i].score );
                }
            }
        }
        
        rep(j,1<<n){
            rep(k,l+1){
//                if(day==0&&k==2)cout<<dp[day][j][k]<<endl;
                data[day][k] = max(data[day][k],dp[day][j][k]);
            }
        }
    }
    
    rep(day,5){
        for(int i=1;i<l+1;i++){
            data[day][i] = max(data[day][i],data[day][i-1]);
        }
    }
    
//    rep(i,3)cout<<data[0][i]<<endl;
    
    int dp2[6][301];
    rep(i,6)rep(j,301)dp2[i][j] = -1;
    rep(i,301)dp2[0][i]=0;
    dp2[0][0] = 0;
    
    
    rep(i,5){
        rep(j,l+1){
            rep(k,l+1){
                if(j-k<0)continue;
                dp2[i+1][j] = max(dp2[i+1][j],dp2[i][j-k] + data[i][k]);
            }
        }
    }
    
    rep(i,l+1)ans = max(ans,dp2[5][i]);
    cout<<ans<<endl;
    
    
    return 0;
}

Measured memory_bytes: 4744
import java.util.*;

public class Main {
    private static ArrayList<ArrayList<Integer>> adjList;
    private static int[][] weights;
    private static int n;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        adjList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            adjList.add(new ArrayList<>());
        }
        weights = new int[n][n];
        for (int i = 0; i < n; i++) {
            int u = in.nextInt();
            int k = in.nextInt();
            for (int j = 0; j < k; j++) {
                int v = in.nextInt();
                int c = in.nextInt();
                weights[u][v] = c;
                adjList.get(u).add(v);
            }
        }
        in.close();
        int[] dist = minDist();
        for (int i = 0; i < n; i++) {
            System.out.println(i + " " + dist[i]);
        }
    }

    private static int[] minDist() {
        int[] dist = new int[n];
        Arrays.fill(dist, Integer.MAX_VALUE);
        dist[0] = 0;
        PriorityQueue<Integer> fringe = new PriorityQueue<>(Comparator.comparingInt(x -> dist[x]));
        fringe.offer(0);
        while (!fringe.isEmpty()) {
            int u = fringe.poll();
            for (int v : adjList.get(u)) {
                int newDist = dist[u] + weights[u][v];
                if (newDist < dist[v]) {
                    fringe.remove(v);
                    dist[v] = newDist;
                    fringe.offer(v);
                }
            }
        }
        return dist;
    }
}



Measured memory_bytes: 45568
n = int(input())
t,a = map(int,input().split())
data = list(map(int,input().split()))
ans = 0
for i in range(n):
    if abs(t - data[i] * 0.006 - a) < abs(t - data[ans] * 0.006 - a):
        ans = i
print(ans + 1)

Measured memory_bytes: 9224
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
ll sod(ll n){
	ll s=0;
	while(n){
		s += n%10;
		n/=10;
		}
	return s;
	}
int main()
{
	ll n,x;
	cin>>n;
	x = sod(n);
	if(n%x==0) pf("Yes");
	else pf("No");
	
	return 0;
}

Measured memory_bytes: 256
from collections import *
from itertools import *
import copy
from heapq import *


N,M,R=map(int,input().split())
Rlst=list(map(int,input().split()))
ABC=[list(map(int,input().split())) for i in range(M)]

data=[[] for i in range(N+1)]
nagasa={}
for a,b,c in ABC:
    data[a].append(b)
    data[b].append(a)
    A,B=min(a,b),max(a,b)
    nagasa.update({str(A)+" "+str(B):c})
mokutekiti=[[100000*200+1 for i in range(R)] for m in range(R)]
for r1i in range(R-1):
    for r2i in range(r1i+1,R):
        r1=Rlst[r1i]
        r2=Rlst[r2i]
        visited=set()
        stack=[0]
        heapify(stack)
        dic={0:[r1]}
        while stack:
            m=heappop(stack)
            #if not m in visited:
            #visited.add(m)
            a=dic[m].pop()
            if a==r2:
                break
            if not a in visited:
                visited.add(a)
                for b in data[a]:
                    if not b in visited or b==r2:
                        A,B=min(a,b),max(a,b)
                        tempm=m+nagasa[str(A)+" "+str(B)]
                        if b==r2:
                            if mokutekiti[r1i][r2i]>tempm:
                                mokutekiti[r1i][r2i]=tempm
                                mokutekiti[r2i][r1i]=tempm
                            heappush(stack,tempm)
                            if tempm in dic:
                                dic[tempm].append(b)
                            else:
                                dic.update({tempm:[b]})

                        else:
                            heappush(stack,tempm)
                            if tempm in dic:
                                dic[tempm].append(b)
                            else:
                                dic.update({tempm:[b]})



value=[]
for lst in permutations([i for i in range(R)],R):
    nagasa=0
    for i in range(R-1):
        nagasa+=mokutekiti[lst[i]][lst[i+1]]
    value.append(nagasa)
print(min(value))


Measured memory_bytes: 128344
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string s;
  cin >> s;

  long foo = 10000;
  long bar = -1;
  rep (i, s.size()) {
    if (s[i] == 'C') foo = min(foo, i);
    if (s[i] == 'F') bar = max(bar, i);
  }
  if (foo < bar) puts("Yes"); else puts("No");
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int main() {
	int n;
	bool a[4][13];
	for (int i = 0; i < 4; i++)
		for (int j = 0; j < 13; j++)
			a[i][j] = true;
	cin >> n;
	for (int i = 0; i < n; i++) {
		char c;
		int r;
		cin >> c >> r;
		switch (c) {
		case 'S':
			a[0][r - 1] = false;
			break;
		case 'H':
			a[1][r - 1] = false;
			break;
		case 'C':
			a[2][r - 1] = false;
			break;
		case 'D':
			a[3][r - 1] = false;
			break;
		}
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (a[i][j]) {
				switch (i) {
				case 0:
					cout << "S " << j + 1 << endl;
					break;
				case 1:
					cout << "H " << j + 1 << endl;
					break;
				case 2:
					cout << "C " << j + 1 << endl;
					break;
				case 3:
					cout << "D " << j + 1 << endl;
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 3064
#include <iostream>
#include <string>

bool Find(const std::string& S, const std::string& partial) {
  int current_index = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == partial[current_index]) {
      current_index++;
    }
    if (current_index == 3) {
      return true;
    }
  }

  return false;
}

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

  int N;
  std::string S;

  std::cin >> N >> S;

  int found = 0;
  for (int i = 0; i < 1000; i++) {
    if (i < 10) {
      found += Find(S, std::string("00") + std::to_string(i))? 1: 0;
    } else if (i < 100) {
      found += Find(S, std::string("0") + std::to_string(i))? 1: 0;
    } else {
      found += Find(S, std::to_string(i))? 1: 0;
    }
  }

  std::cout << found << std::endl;

  return 0;
}


Measured memory_bytes: 3228
a,b,c,d = map(int,input().split())
def gcd(x,y):
    if x<y:
        x,y = y,x
    if y==0:
        return x
    if x%y==0:
        return y
    else:
        return gcd(y,x%y)
e = c*d//gcd(c,d)
c_d = b//e-(a-1)//e 
c_ = b//c-(a-1)//c 
d_ = b//d-(a-1)//d
print(b-a+1-(c_+d_- c_d))

Measured memory_bytes: 3064
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        double a,b,c;
        a = input.nextDouble();
        b = input.nextDouble();
        c = input.nextDouble();
        double S,L,h;
        S = a*b*Math.sin(Math.toRadians(c))/2;
        L = a+b+Math.sqrt((Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(c))));
        h = 2*S/a;
        System.out.printf("%f\n%f\n%f\n",S,L,h);
    }
}


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

int main()
{
    int R;
    cin >> R;

    if (R < 1200) {
        cout << "ABC";
    } else if (R < 2800) {
        cout << "ARC";
    } else {
        cout << "AGC";
    }

    return 0;
}


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

string S, T;

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> B(N);
  int count = 0;
  for(int i = 0; i<N; i++){
    ll a;
    cin >> a;
    A.at(i) = a;
    B.at(i) = abs(a);
    if(a < 0){
      count += 1;
    }
  }

  sort(B.begin(), B.end());
  ll ans = 0;
  if(count % 2 == 1){
    ans = B.at(0) * (-1);
    for(int i = 1; i<N; i++){
      ans += B.at(i);
    }
  }else{
    for(int i = 0; i<N; i++){
      ans += B.at(i);
    }
  }

  cout << ans << endl;


}


Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define tii tuple<int,int,int>
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}
int main(){
    string s=stin();
    vector<string> day={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    int ans=0;
    rep(i,7){
        if(day[i]==s){
            ans=i;
            break;
        }
    }
    cout<<7-ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000000;
const long long MOD = 1000000007;

long long f(long long N){
  string s = to_string(N);
  long long ret = 0;
  for (int i = 0; i < s.length();i++){
    ret += s[i] - '0';
  }
  return ret;
}

int main()
{
  long long N;
  cin >> N;
  priority_queue<long long> que;
  for (int i =  0; i < N;i++){
    long long a;
    cin >> a;
    que.push(a);
  }
  long long alice=0,bob=0;
  long long turn=0;
  while (!que.empty())
  {
    turn++;
    if(turn%2==1)
      alice += que.top();
    if (turn % 2 == 0)
      bob += que.top();

    que.pop();
  }
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
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; }

class SegmentTree
{
 private:
    int sz;
    vector<int> data;
 public:
    SegmentTree(int n){
        sz=1;
        while(sz<n) sz*=2;
        data.resize(2*sz,0LL);
    }
    void add(int l,int r,int x){
        l+=sz; r+=sz;
        for(;l<r;l>>=1,r>>=1){
            if(l&1) data[l++]+=x;
            if(r&1) data[--r]+=x;
        }
    }
    int get(int k){
        int res=0;
        for(k+=sz;k>0;k>>=1){
            res+=data[k];
        }
        return res;
    }
};

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

    int N,Q; cin>>N>>Q;
    SegmentTree seg(N);
    while(Q--){
        int q; cin>>q;
        if(q==0){
            int s,t,x; cin>>s>>t>>x;
            s--;
            seg.add(s,t,x);
        }else{
            int i; cin>>i;
            i--;
            cout<<seg.get(i)<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4860
s = list(input())
l = []
for i in range(len(s)):
    if s[i] == 'S':
        l.append('S')
    elif not l:
        l.append('T')
    elif l[-1] == 'T':
        l.append('T')
    else:
        l.pop()
print(len(l))



Measured memory_bytes: 6436
#include<stdio.h>

int main(){

    int W,H,x,y,r;

    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

    if(W >= x+r){
            if(0 <= x-r){
                if(H >= y+r){
                    if(0 <= y-r){
                            printf("Yes\n");
                    }else printf("No\n");
                }else printf("No\n");
            }else printf("No\n");
    }else  printf("No\n");





}



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

#define pb push_back
#define mp make_pair
#define inside sl<=l&&r<=sr
#define outside r<sl||sr<l
#define INF 1000000009
#define mod 1000000007
using namespace std;
typedef long long ll;

int n, m, k;
pair<int, int> engel[3003];
ll dp[3003];
ll fac[200005];

void ayar(ll& a){
	a = ((a%mod)+mod)%mod;
}

ll us(ll a, ll b){
	ll ans = 1;
	while (b){
		if (b & 1){
			ans *= a;
			ans %= mod;
		}
		a *= a;
		a %= mod;
		b >>= 1;
	}
	return ans;
}

ll get(ll a, ll b){
	return (fac[a+b]*us((fac[a]*fac[b])%mod, mod-2))%mod;
}

int main(){
	//freopen("stl.gir", "r", stdin);
	
	cin >> n >> m >> k;
	for (int i = 0; i < k; i++){
		cin >> engel[i].first >> engel[i].second;
		engel[i].first--;
		engel[i].second--;
	}
	
	engel[k] = mp(0, 0);
	k++;
	
	sort(engel, engel+k);
	
	fac[0] = 1;
	for (ll i = 1; i < 200005; i++) fac[i] = (fac[i-1]*i)%mod;
	
	
	for (int i = k-1; i >= 0; i--){
		//cout << "(" << engel[i].first << ", " << engel[i].second << ")" << endl;
		dp[i] = get(abs(engel[i].first - n+1), abs(engel[i].second - m+1));
		for (int j = i+1; j < k; j++){
			if (engel[j].first >= engel[i].first && engel[j].second >= engel[i].second){
				dp[i] -= (dp[j]*get(abs(engel[i].first-engel[j].first), abs(engel[i].second - engel[j].second)))%mod;
				ayar(dp[i]);
			}
		}
		//cout << "dp: " << dp[i] << endl;
	}
	
	cout << dp[0] << endl;
	
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    long[][] A = new long[N][2];
    long[][] C = new long[M][2];
    for (int i = 0; i < N; i++) A[i] = new long[] {scanner.nextInt(), scanner.nextInt()};
    for (int i = 0; i < M; i++) C[i] = new long[] {scanner.nextInt(), scanner.nextInt()};

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < N; i++) {
      long min = 10_000_000_000L;
      int id = M + 1;
      for (int j = 0; j < M; j++) {
        long d = Math.abs(A[i][0] - C[j][0]) + Math.abs(A[i][1] - C[j][1]);
        if (d <= min) {
          if (d < min) id = j;
          else id = Math.min(id, j);
          min = d;
        }
      }
      sb.append(id + 1).append('\n');
    }
    System.out.print(sb.toString());
  }
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
        --a.at(i);
    }
    ll ans = 0;
    for(i = 0;i < n;++i){
        j = a.at(i);
        if(i < j && a.at(j) == i) ++ans;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3908
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32)::n,cnt(0:100000)=0
    integer(int32):: i,ans
    integer(int32), allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)

    do i=1,n
        cnt(a(i))=cnt(a(i))+1
    end do
    ans=0
    do i=1,99999
        ans=max(ans, sum(cnt(i-1:i+1)))
    end do
    print'(i0)', ans
end program main

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,i,j,k;
    cin>>n;
    int ara1[n],ara2[n],ara3[n];
    for(i=0;i<n;i++) cin>>ara1[i];
    for(i=0;i<n;i++) cin>>ara2[i];
    for(i=1;i<n;i++) ara1[i]=ara1[i]+ara1[i-1];
    for(i=n-2;i>=0;i--) ara2[i]=ara2[i]+ara2[i+1];
    for(i=0;i<n;i++){
        ara3[i]=ara1[i]+ara2[i];
    }
    int maxi=0;
    for(i=0;i<n;i++){
        maxi=max(maxi,ara3[i]);
    }
    cout<<maxi<<endl;
}


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

public class Main {
    int N;
    int[] nums;

    int solve() {
        int[] dp = new int[N+1];
        for (int i = 2; i <= N; i++) {
            int a = Math.abs(nums[i]-nums[i-1]) + dp[i-1];
            int b = Math.abs(nums[i]-nums[i-2]) + dp[i-2];
            dp[i] = Math.min(a, b);
        }
        return dp[N];
    }

    void main(FastScanner in, PrintWriter out) {
        N = in.nextInt();
        nums = new int[N+1];
        nums[0] = Integer.MAX_VALUE;
        for (int i = 1; i <= N; i++) {
            nums[i] = in.nextInt();
        }
        out.println( solve() );
    }

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Main m = new Main();
        m.main(in, out);
        out.close();
        in.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream in) { br = new BufferedReader(new InputStreamReader(in)); }
        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try { st = new StringTokenizer(br.readLine()); }
                catch (IOException e) { e.printStackTrace(); }
            }
            return st.nextToken();
        }
        public String nextLine() {
            String str = "";
            try { str = br.readLine();
            } catch (IOException e) { e.printStackTrace(); }
            return str;
        }
        public void close() throws IOException { br.close(); }
    }
}

Measured memory_bytes: 31056
object Main {
  import io.StdIn._

  def getStrings = readLine().split(" ")
  def getInts = getStrings.map(_.toInt)

  def main(args: Array[String]): Unit = {
    val S = readLine
    val K = readLine.toLong
    val s = if (K < S.length) S.substring(0, K.toInt) else S
    println(s.toList.find(_ != '1').getOrElse('1'))
  }
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#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(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0)
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000

ll solve(ll &a, ll &b, ll &x) {
  ll res = (int)(a * x / b) - a * (int)(x / b);
  return res;
}

int main()
{
  ll a, b, n; cin >> a >> b >> n;
  // ll x = b / a + 1;
  // ll y = min(n, b);
  // cout << max(solve(a, b, x), solve(a, b, y)) << endl;


  ll a_ = 0;
  if (b <= n) a_ = b - 1;
  else a_ = n;
  cout << solve(a, b, a_) << endl;

  // ll ans = 0;
  // for (ll i = x; i <= min(b, n); i ++) {
  //   ans = max(ans, solve(a, b, i));
  // }
  // cout << ans << endl;

  // ll x = n;
  // if (a < b) {
  //   if (b <= x) {
  //     ll u = b - 1;
  //     cout << solve(a, b, u) << endl;
  //   } else cout << solve(a, b, n) << endl;
  // } else {
  //   if (b <= x) {
  //     ll y = b - 1;
  //     if (solve(a, b, x) < solve(a, b, y)) cout << solve(a, b, y) << endl;
  //     else cout << solve(a, b, x) << endl;
  //   }
  //   else cout << solve(a, b, x) << endl;
  // }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define MM 1e9
#define Pair pair<int,int>

int H,W;
char ary[1001][1001];
int dist[1001][1001];
queue<pair<int, int>> que;
int dh[] = { 0,-1, 0, 1};
int dw[] = {-1, 0, 1, 0};

void init(){
    rep(i,0,H) rep(j,0,W) {
        dist[i][j] = MM;
    }
}

void input() {
    cin >> H >> W;
    init();
    rep(i,0,H) rep(j,0,W) {
        cin >> ary[i][j];
        if (ary[i][j] == '#') {
            dist[i][j] = 0;
            que.push(Pair(i,j));
        }
    }
}

void solve(){
    while(que.size()) {
        Pair p = que.front();
        que.pop();
        int h = p.first;
        int w = p.second;
        
        rep (i,0,4) {
            if (w>=0 && h>=0 && w<W && h<H && (dist[h+dh[i]][w+dw[i]] == MM)) {
                dist[h+dh[i]][w+dw[i]] = dist[h][w] + 1;
                que.push(Pair(h+dh[i],w+dw[i]));
            }
        }
    }
}

void check() {
    int res=0;
    rep (i,0,H) rep (j,0,W) {
        res = max(res,dist[i][j]);
    }
    cout << res << endl;
}

int main() {
    input();
    solve();
    check();
}

Measured memory_bytes: 13328
n,y = map(int,input().split())
fl = 0
for i in range(n+1):
  for j in range(n+1):
    if n-i-j>=0 and 10000*(n-i-j)+5000*j+1000*i == y:
      print("{0} {1} {2}".format(n-i-j,j,i))
      fl = 1
      break
  if(fl == 1):
    break
if(fl==0):
  print("-1 -1 -1")


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

using namespace std;

#define debug(n) cerr << #n << ':' << (n) << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  vector<P<int,bool>> v[15];
  for(int i = 0; i < n; ++i){
    int a; cin >> a;
    for(int j = 0; j < a; ++j){
      int x; cin >> x;--x;
      bool y; cin >> y;
      v[i].emplace_back(x,y);
    }
  }
  int ans = -1;
  for(int bt = pow(2,n)-1; bt >= 0; --bt){
    bool ok = true;
    for(int i = 1,cnt = 0; cnt < n; i<<=1,cnt++){
      if(!(bt & i))continue;
      for(auto e:v[cnt]){
	bitset<15> bs;
	bs[e.first] = 1;
	ok &= (!!(bt & (int)bs.to_ulong()) == e.second);
      }
    }
    if(ok)ChangeMax(ans,__builtin_popcount(bt));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4088
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;
int main(){
    string s;cin >> s;
    int num = s.size();
    int ans=1000;
    for (int i=0;i<num-2;i++){
        string s0=s.substr(i,3);
        int tmp=abs(stoi(s0)-753);
        if (tmp<ans) ans = tmp;
    }
    cout << ans << endl;
}


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

namespace ABC171
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            if (Char.IsUpper(str[0]))
            {
                Console.WriteLine('A');
            }
            else
            {
                Console.WriteLine('a');
            }
        }
    }
}


Measured memory_bytes: 25884
#include <iostream>
#include <vector>

using namespace std;

int main()
{

    long long int n;
    long long int ans = 0;
    cin >> n;
    vector<long long int> a(n, 0);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    if (a[0] != 0)
    {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 0; i < n - 1; ++i)
    {
        if (a[i + 1] - a[i] >= 2)
        {
            cout << -1 << endl;
            return 0;
        }
        else
        {
            if (a[i + 1] <= a[i])
            {

                ans += a[i];
            }
        }
    }
    ans += a[n - 1];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
//https://codeforces.com/contest/988/problem/A
//BROWNIE TK

#include <bits/stdc++.h>
using namespace std;

typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()

#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en

#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second

#define pll pair<lli, lli>
#define pii pair<int, int>
#define pil pair<int, lli>

#define forz(i, n) for (int i = 0; i < n; i++)
#define fore(i, m, n) for (int i = m; i <= n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rfore(i, m, n) for (int i = n; i >= m; i--)

#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)

#define bset(a, p) ((a) | (1ll << (p)))
#define bchk(a, p) ((a) & (1ll << (p)))
#define bxor(a, p) ((a) ^ (1ll << (p)));
#define brem(a, p) (bchk(a, p) ? (bxor(a, p)) : (a))
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/

#define lb lower_bound
#define ub upper_bound
#define er equal_range

#define findnot find_first_not_of

#define maxe *max_element
#define mine *min_element

#define mod2 1000000007
#define mod 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements sbtriectly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order

/*STD funcions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli modi(lli a, lli m) { return power(a, m - 2, m); }
/*CODE BEGINS*/

int main()
{
    kira;
    lli a,b,c;
    cin>>a>>b>>c;
    p3(c,a,b);
    return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d', $n);
$debt = 100000;

for($i=0; $i<$n; $i++){
	$debt = $debt*1.05;
	//ceil()は小数点以下を切り捨てる
	$debt = ceil($debt/1000)*1000;
}

echo $debt.PHP_EOL;

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

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

  int n;
  cin >> n;

  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  sort(a.begin(), a.end(), greater<int>());
  queue<int> que;
  que.emplace(a[0]);

  ll ans = 0;
  for (int i = 1; i < n; ++i) {
    ans += que.front(), que.pop();
    que.emplace(a[i]);
    que.emplace(a[i]);
  }

  cout << ans << '\n';

  return (0);
}

Measured memory_bytes: 4752
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())


if a > b:
  av = a - (v * t)
  bw = b - (w * t)
  if av <= bw:
    print('YES')
  else:
    print('NO')

elif a < b:
  av = a + (v * t)
  bw = b + (w * t)
  if av >= bw:
    print('YES')
  else:
    print('NO')

Measured memory_bytes: 61816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;
 

int main() {
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  ll ans = 0;
  if(k<=a) ans = k;
  else if(k<=a+b) ans = a;
  else ans = a - (k-(a+b));
  
  cout << ans << endl;
    
  return 0;
}


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

using namespace std;

int main(){
    string s;
    cin >> s;
    int n=s.size();
    int r=0;
    int l=0;
    int start=0;
    for(int i=0;i<n-1;i++){
        if(s[i]=='R'){
            r=i;
        }
        if(s[i]=='L'&& s[i+1]=='R'){
            int r_num=(r-start)/2+(i-r)/2+1;
            int l_num=i-start-r_num+1;
            for(int j=start;j<i+1;j++){
                if(j==r){
                    cout << r_num << " ";
                }else if(j==r+1){
                    cout << l_num << " ";
                }else{
                    cout << 0 << " ";
                }
            }
            start=i+1;
        }
    }
    int r_num=(r-start)/2+(n-1-r)/2+1;
    int l_num=n-1-start-r_num+1;
    for(int j=start;j<n;j++){
        if(j==r){
            cout << r_num << " ";
        }else if(j==r+1){
            cout << l_num << " ";
        }else{
            cout << 0 << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a < b) {

			System.out.println("a < b");

		} else if (a > b) {

			System.out.println("a > b");

		} else {

			System.out.println("a == b");

		}

		sc.close();

	}

}


Measured memory_bytes: 26356
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 5000000007

#n = int(input())
#b = int(input())
n, m = [int(i) for i in input().split()]
table = [[int(i)  for i in input().split()] for j in range(m)]
#table = [list(input()) for n in range(r)] #table[h][w]
p = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#p = [int(input()) for i in range(m)]
#s = input()

#list = list(s)
#dp = [MOD for _ in range(m)]
#dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
#dp = [[[0 for _ in range(11)] for _ in range(2)] for _ in range(11)]

#a = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

count = 0
for i in range(2 ** n):
    flag = 1
    for j in range(0,m):
        temp = 0
        for k in range(table[j][0]):
            if((i >> (table[j][k+1] - 1)) & 1 ) :
                temp += 1
        if(temp % 2 != p[j]):
            flag = 0
    if(flag == 1):
        count += 1

print(count)


Measured memory_bytes: 21144
from math import floor
q = int(input())
ab=[list(map(int,input().split())) for _ in range(q)]
for a,b in ab:
    if a==b:
        print(2*a-2)
        continue
    t = floor((a*b)**0.5)
    if t*t >=a*b:
        print(2*t-3)
    elif t*(t+1)>=a*b:
        print(2*t-2)
    else:
        print(2*t-1)
    

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

using namespace std;
typedef long long ll;

#define pb push_back
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define forrn(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define PYMOD(a, m) ((((a) % (m)) + (m)) % (m))
#define all(v) v.begin(), v.end()
#define mp make_pair
#define ff first
#define ss second

const int mod = 1e9 + 7;

ll fpow(ll a, int n) {
    ll res = 1;
    while (n > 0) {
        if ((n % 2) == 1) {
            res = (res * a) % mod;
        }
        a = (a * a) % mod;
        n /= 2;
    }
    return res;
}

ll rev(ll a) {
    return fpow(a, mod - 2);
}

const int maxn = 200179;
ll fct[maxn];

void precalc() {
    fct[0] = 1;
    for (int i = 1; i < maxn; i++) {
        fct[i] = (1ll * i * fct[i - 1]) % mod;
    }
}

ll cnk(int n, int k) {
    return (fct[n] * rev((fct[k] * fct[n - k]) % mod)) % mod;
}

int main() {
    precalc();
    // Code here:

    int b, w;
    cin >> b >> w;

    ll prob_w = 0;
    ll prob_b = 0;
    ll rev2 = rev(2);
    ll r2 = rev2;

    for (int i = 1; i <= b + w; i++) {
        cout << PYMOD(rev2 - prob_w + prob_b, mod) << endl;
        r2 = (r2 * rev2) % mod;
        if (i >= b) {
            prob_w = (prob_w + cnk(i - 1, b - 1) * r2) % mod;
        }
        if (i >= w) {
            prob_b = (prob_b + cnk(i - 1, w - 1) * r2) % mod;
        }
    }

    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int a[10001],ans=0,bns=0,n;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=2*n;i++) scanf("%d",&a[i]);
     sort(a+1,a+1+2*n);  
    for(int i=1;i<=2*n;i+=2)bns+=a[i];
    printf("%d\n",bns);
    return 0;
}

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

int main(){
  long long n,a,b;
  cin >> n >> a >> b;
  vector<long long> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  long long hidari=1,migi=1000000001;
  long long medium;
  long long count;
  while(migi-hidari!=1){
    count=0;
    medium=(hidari+migi-1)/2;
    for(int i=0;i<n;i++){
      count+=((h[i]-medium*b>0)?((h[i]-medium*b-1)/(a-b)+1):0);
    }
    if(count<=medium){
      migi=medium+1;
    }else{
      hidari=medium+1;
    }
  }
  cout << hidari << endl;
  return 0;
}


Measured memory_bytes: 1024
n,k=map(int,input().split())
d=[]
a=[]
for _ in range(k):
    d.append(int(input()))
    a.append(list(map(int,input().split())))
x=[0]+[1]*n
for i in range(k):
    for j in range(d[i]):
        x[a[i][j]]=0
print(sum(x))

Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <string>
#include <utility>
#include <cstdio>
#include <cmath>

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define X first
#define Y second

using ll = long long;
using namespace std;
using vi = vector<int>;
using pii = pair<int, int>;

constexpr int INF = 1e9 + 1;
//constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

vector<pii> ps;
int n, k;

template<typename T>
T debug(T x) {
	cout << x << "\n";
	return x;
}

ll calc(int mx, int my, int Mx, int My) {
	int c = 0;
	REP(i, n) {
		auto &p = ps[i];
		if (mx <= p.X && p.X <= Mx && my <= p.Y && p.Y <= My) c++;
	}
	if (c >= k) return (ll)(Mx - mx) * (My - my);
	else return LLINF;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll ans = LLINF;
	cin >> n >> k;
	vi xs(n), ys(n);
	ps = vector<pii>(n);
	REP(i, n) {
		cin >> ps[i].X >> ps[i].Y;
		xs[i] = ps[i].X;
		ys[i] = ps[i].Y;
	}
	sort(ALL(xs));
	sort(ALL(ys));
	REP(i, n) {
		REP(j, i) {
			REP(k, n) {
				REP(l, k) {
					ans = min(ans, calc(xs[j], ys[l], xs[i], ys[k]));
				}
			}
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	int ans=0;
	while(n)
	{
		ans++;
		n/=k;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int t = 0;
        int x = 0;
        int y = 0;
        while (n-- > 0) {
            int nt = sc.nextInt();
            int nx = sc.nextInt();
            int ny = sc.nextInt();
            
            int dist = Math.abs(nx-x) + Math.abs(ny-y);
            
            if (nt % 2 != (nx+ny) % 2) {
                System.out.println("No");
                return;
            }
            
            if (nt - t < dist) {
                System.out.println("No");
                return;
            }
            
            t = nt;
            x = nx;
            y = ny;
        }
        
        
        System.out.println("Yes");
    }
}

Measured memory_bytes: 87380
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	a := 1
	ans := 0
	for i := 0; a <= n; i++ {
		a = a * k
		ans++
	}
	fmt.Println(ans)
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl

int main() {
  ll N, M;
  cin >> N >> M;

  FORR(i, 1, M / N + 1) {
    ll rest = M - i * N;
    if (rest % i == 0) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <bitset>

#define lp(n) for(int i=0;i<n;i++)
#define LP(n,i) for(int i=0;i<n;i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intmin -2147483637
#define llmax 9223372036854775807
typedef long long ll;

using namespace std;

int d,g,p[10],c[10];
int a[10];
int cnt,cnt2,mn,mem;
bool ck[10];

ll gcd(ll x,ll y){
	if(y==0)return x;
	return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	ll g=gcd(x,y);
	return x/g*y;
}

int main(){
	cin>>d>>g;
	lp(d){
		cin>>p[i]>>c[i];
		a[i]=(i+1)*100*p[i]+c[i];
	}
	mn=intmax;
	lp(1<<d){
		mem=i;
		cnt=0;
		cnt2=0;
		LP(d,j)
			ck[j]=true;
		LP(d,j){
			if(mem%2==1){
				cnt+=p[j];
				cnt2+=a[j];
				ck[j]=false;
			}
			mem=mem>>1;
		}
		if(cnt2>=g){
			mn=min(mn,cnt);
		}
		else{
			LP(d,j){
				if(ck[j]){
					if((g-cnt2-1)/((j+1)*100)+1<p[j])
						mn=min(mn,cnt+(g-cnt2-1)/((j+1)*100)+1);
				}
			}
		}
	}
	cout<<mn<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;
 
const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
// const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
 
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto (i) = (vec).begin(); (i) != (vec).end(); (i)++)
#define vrREP(i, vec) for(auto (i) = (vec).end()-1;(i) != (vec).begin()-1;(i)--)
 
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 
const vector<int> data = {2, 5, 5, 4, 5, 6, 3, 7, 6};
vector<bool> can(9);
 
using vs = vector<string>;
//using vss = vector<vs>;
vs DP(10010, "a");
 
bool compare(string a, string b){
  if(a.size() > b.size()) return true;
  if(a.size() < b.size()) return false;
  return a > b;
}
 
void dp(int i){
  if(i == 0){
    DP.at(0) = "";
    return;
  }
  if(DP.at(i) != "a") return;
  DP.at(i) = "";
  REP(j, 9) if(can.at(j)){
    int u = data.at(j);
    if(i >= u){
      dp(i - u);
      if(DP.at(i - u) != "IMPOSSIBLE"){
        string tmp = DP.at(i - u) + (char)('1' + j);
        if(compare(tmp, DP.at(i))) DP.at(i) = tmp;
      }
    }
  }
  if(DP.at(i) == "") DP.at(i) = "IMPOSSIBLE";
}
 
int main(void){
  int n, m; cin >> n >> m;
  REP(i, m){
    int a; cin >> a;
    can.at(a - 1) = true;
  }
  dp(n);
  /*
  REP(i, n + 1){
    cout << i << " : " << DP.at(i) << "\n";
  }*/
  cout << DP.at(n) << "\n";
  return 0;
}

Measured memory_bytes: 42112