akhauriyash/Code-Regression huggingface dataset:
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int A, B;
	
	cin >> A >> B;
	if (A == 1) 
	{
		A = 14;
	}

	if (B == 1)
	{
		B = 14;
	}

	if (A > B)
	{
		
		cout << "Alice" << endl;
		
	}
	else if (A < B)
	{
		cout << "Bob" << endl;
	}
	else
	{
		cout << "Draw" << endl;
	}

	
	return 0;
}


Measured memory_bytes: 256
using System;

class Problem {
    public static void Main() {
        var tw = Console.ReadLine();
        var inp = Console.ReadLine();
        var ts = "" + inp;
        while ((inp = Console.ReadLine()) != "END_OF_TEXT") ts += " " + inp;
        var ws = ts.ToLower().Split();
        var c = 0;
        foreach (var w in ws) if (w == tw) c++;
        Console.WriteLine(c);
    }
}


Measured memory_bytes: 9116
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

ll gcd(ll n, ll m){

    if(m > n)  return gcd(m, n);

    ll r = n % m;
    if(r == 0) return m;
    else       return gcd(m, r);
}

ll lcm(ll n, ll m){
    return n / gcd(n, m) * m;
}

int main(){

    ll n, m; cin >> n >> m;

    string s, t; cin >> s >> t;

    ll g = gcd(n, m);
    ll l = lcm(n, m);

    bool flag = true;
    int cnt1 = 0;
    int cnt2 = 0;
    int ds = l/n;
    int dt = l/m;

    int i=0, j=0;
    while(i<n && j<m){
        if(cnt1 == cnt2){
            if(s[i] != t[j]){
                flag = false;
                break;
            }
        }

        if(cnt1 <= cnt2){
            i++;
            cnt1 += ds;
        }
        else{
            j++;
            cnt2 += dt;
        }
    }

    cout << (flag ? l : -1) << endl;

    return 0;
}

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

using namespace std;

int main(){
   int n,limit;
   cin >> n >> limit;

   int cost = -1;
   for(int i=0;i<n;i++){
      int c,t;
      cin >> c >> t;
      if(t <= limit){
         if(cost > c || cost == -1){
            cost = c;
         }
      }
   }

   cout << (cost == -1 ? "TLE" : to_string(cost)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
int main(){
    ll a,b,c ;
    cin >> a >>b >>c ;
    if(a<=c)
    { b=b-(c-a) ;
      a=0 ;
     if( b<=0) {b=0 ;} }

    else {a=a-c ;}

    cout << a <<' '<< b ;
    return 0 ;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    private final static int M = 1000000007;

    private static int solve(int N, boolean[][] a) {
        int states = 1 << N;

        int[] memo = new int[states];
        Arrays.fill(memo, -1);

        boolean[] state = new boolean[N];
        Arrays.fill(state, true);

        return solve(state, a, memo);
    }

    private static int solve(boolean[] state, boolean[][] a, int[] memo) {
        int packedState = 0;
        int bits = 0;

        for (int i=0, p=1; i < state.length; i++, p <<= 1) {
            if (!state[i]) continue;

            packedState += p;
            bits++;
        }

        if (bits == 0) return 1;
        if (memo[packedState] != -1) return memo[packedState];

        int result = 0;
        for (int j = 0; j < state.length; j++) {
            if (!a[bits-1][j]) continue;
            if (!state[j]) continue;

            state[j] = false;
            result = (result + solve(state, a, memo)) % M;
            state[j] = true;
        }

        memo[packedState] = result;
        return result;
    }

    public static int run(Scanner scanner) {
        int N = scanner.nextInt();
        boolean[][] a = new boolean[N][N];
        for (int i=0; i < N; i++)
            for (int j=0; j < N; j++)
                a[i][j] = scanner.nextInt() == 1;

        return solve(N, a);
    }

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            System.out.println(run(scanner));
        }
        //Tests.run();
    }
}

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

using namespace std;

int main()
{
    int n,i;
    cin>>n;
    int a[n],b[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    for(i=0;i<n;i++)
    {
        if(b[i]==a[n-1])
            cout<<a[n-2]<<endl;
        else
            cout<<a[n-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int n;
long long INF = 1e18+5;

long long sum(vector<int> &a, int l, int r)
{
    long long result = 0;
    for (int i = l; i <= r; ++i) {
        result += a[i];
    }
    return result;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<vector<long long>> dp(n+1,vector<long long>(n+1));

    for (int l = n-1; l >= 0; --l) {
        for (int r = l; r < n; ++r) {
            if(l == r)
                dp[l][r] = 0;
            else
            {
                long long s = sum(a,l,r);
                dp[l][r] = INF;
                for (int i = l; i <= r; ++i) {
                    dp[l][r] = min(dp[l][r],dp[l][i] + dp[i+1][r] + s);
                }
            }
        }
    }
    cout << dp[0][n-1];
    return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector <int> ans(N);
	for (int ii = 0; ii < N; ++ii){
		int A;
		cin >> A;
		A--;
		ans[A] = ii+1;
	}

	for (int ii = 0; ii < N; ++ii){
		cout << ans[ii] << " ";
	}
		cout << endl;

	return 0;
}


Measured memory_bytes: 1152
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
C = 0

for t in T:
    start = 0
    end = n
    while start < end:
        half = (start + end) // 2
        if t == S[half]:
            C += 1
            break
        elif t < S[half]:
            end = half
        else:
            start = half + 1
        
print(C)


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

int main(){
	int h,w;
	cin >> h >> w;
	cin.ignore();
	string* pic = new string[h];
	for(int i = 0; i < h; i++){
		getline(cin,pic[i]);
	}

	for(int i = 0; i <= w+1; i++){
		cout << '#';
	}
	cout << endl;
	for(int i = 0; i < h; i++){
		cout << '#';
		cout << pic[i];
		cout << '#';
		cout << endl;
	}

	for(int i = 0; i <= w+1; i++){
		cout << '#';
	}

	delete[] pic;
	getchar();
	return 0;
}

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

const int N = 49, M = 99;

int a, b;

void p(char c, char d, int x){
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            if(!!x & i & j & 1){ putchar(d); x--; }
            else putchar(c);
        }
        puts("");
    }
}

int main(){
    scanf("%d%d", &a, &b);
    printf("%d %d\n", 2 * N, M);
    p('#', '.', a - 1);
    p('.', '#', b - 1);
}

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


int main()
{
  ll K;
  cin >> K;
  vector<vector<ll>> dp(12, vector<ll>(10, 0));
  for (ll i = 0; i < 10; ++i)
  {
    dp.at(1).at(i) = 1;
  }
  for (ll i = 1; i < 10; ++i)
  {
    for (ll j = 0; j < 10; ++j)
    {
      dp.at(i + 1).at(j) += dp.at(i).at(j);
      if (j != 9)
      {
        dp.at(i + 1).at(j) += dp.at(i).at(j + 1);
      }
      if (j != 0)
      {
        dp.at(i + 1).at(j) += dp.at(i).at(j - 1);
      }
    }
  }
  ll ans = 0;
  ll ni, nj;
  for (ll i = 0; i < 11; ++i)
  {
    for (ll j = 1; j < 10; ++j)
    {
      if (K > dp.at(i).at(j))
      {
        K -= dp.at(i).at(j);
      }
      else
      {
        ni = i - 1;
        nj = j;
        ans = j;
        break;
      }
    }
    if (ans > 0)
    {
      break;
    }
  }

  while (ni > 0)
  {
    for (ll j = nj - 1; j < nj + 2; ++j)
    {
      if (j < 0 || j > 9)
      {
        continue;
      }
      if (K > dp.at(ni).at(j))
      {
        K -= dp.at(ni).at(j);
      }
      else
      {
        ans = ans * 10 + j;
        nj = j;
        break;
      }
    }
    ni -= 1;
  }
  cout << ans << endl;
  // for (ll i = 0; i < 12; ++i)
  // {
  //   for (ll j = 0; j < 10; ++j)
  //   {
  //     cout << dp.at(i).at(j) << ' ';
  //   }
  //   cout << endl;
  // }
}


Measured memory_bytes: 256
K,N=map(int,input().split())
A=list(map(int,input().split()))

l1=A[0]
l2=K-A[N-1]
L=[l1+l2]
for i in range(1,N):
    L.append(A[i]-A[i-1])

lmx=max(L)
print(K-lmx)

Measured memory_bytes: 26444
res = [int(idx) for idx in input().split()]
count = 0
for idx in res:
  if idx == 0:
    if count == 4:
      print(res[count-1]+1)
      break
    elif count == 0:
      print(res[count+1]-1)
      break
    else:
      print(res[count+1]-1)
      break
  count += 1

Measured memory_bytes: 8924
#include <iostream>
#include <math.h>

bool is_prime(int n,int r);

int main(void) {
	using namespace std;
	int x;
	int count;
	while (cin >> x) {
		count = 0;
		double r = pow(x, 0.5);
		for (int i = 2; i <= x; i++) {
			if (is_prime(i,r))count++;
		}
		cout << count << endl;
	}
	return 0;
}



bool is_prime(int n,int r) {
	static int flag = 0;
	static int list[78498];
	static int count = 0;
	if (flag == 1) {
		for (int i = 0; i < count; i++) { 
			if (list[i] >r) {
				return true;
			}
			if (n % list[i] == 0) {
				if (n == list[i]) {
					
					return true;
				}
				
				return false;
			}
		}

	}
	flag = 1;
	list[count] = n;		
	count++;
	
	return true;
}

Measured memory_bytes: 3120
#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    if(n==22) cout<<"Christmas Eve Eve Eve"<<endl;
    else if(n==23) cout<<"Christmas Eve Eve"<<endl;
    else if(n==24) cout<<"Christmas Eve"<<endl;
    else if(n==25) cout<<"Christmas"<<endl;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ab = Console.ReadLine().Split(' ');
            int a = int.Parse(ab[0]);
            int b = int.Parse(ab[1]);
            int tmp = a - 2 * b;
            
            Console.WriteLine((tmp>0?tmp:0).ToString());
        }
    }
}


Measured memory_bytes: 11092
IDENTIFICATION DIVISION.
      PROGRAM-ID. 051A.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 INP PIC X(20).
      01 S.
      	03 WK-S PIC X(1) OCCURS 19 TIMES.
      
      01 IDX PIC 9(2).
      
      PROCEDURE DIVISION.
      ACCEPT INP.
      MOVE INP TO S.

      PERFORM VARYING IDX FROM 1 BY 1 UNTIL IDX > 19
      	IF WK-S(IDX) = ","
      		MOVE " " TO WK-S(IDX)
      	ELSE
      		CONTINUE
        END-IF
      END-PERFORM.

      DISPLAY S.
      STOP RUN.

Measured memory_bytes: 384
n = int(input())
h = [int(i) for i in input().split()]
dp = [0]*n

for i in range(1, n):
    if(i - 2 >= 0):
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
    else:
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1])

print(dp[n - 1])

Measured memory_bytes: 13780
N = int(input())
S = input()
maxd = 0
for a in range(1,N-1):
    X = set([])
    Y = set([])
    for x in range(0,a):
        X.add(S[x])
    for y in range(a,N):
        Y.add(S[y])
    diffnum = len(X&Y)
    maxd = max(diffnum,maxd)
print(maxd)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
    char x,y;
    int a,b;
    while(cin>>x>>y){
        if(x>='0'&&x<='9'){
            a=(int)(x-'0');
        }
        else if(x>='a'&&x<='f'){
            a=(int)(x-'a'+10);
        }
        else if(x>='A'&&x<='F'){
            a=(int)(x-'A'+10);
        }
        if(y>='0'&&y<='9'){
            b=(int)(y-'0');
        }
        else if(y>='a'&&y<='f'){
            b=(int)(y-'a'+10);
        }
        else if(y>='A'&&y<='F'){
            b=(int)(y-'A'+10);
        }
        if(a==b) cout<<'='<<endl;
        else if(a>b) cout<<'>'<<endl;
        else 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
	{
		printf("a > b\n");
	}
	return 0;
}

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

using namespace std;

int main(){
	int maxn,a,b,c,k,i,m;
	scanf("%d%d%d%d",&a,&b,&c,&k);
	if(a >= b&&a >= c){
		m = a;
		for(i=1;i<=k;i++){
			a *= 2;
		}
	}
	if(b > a&&b > c){
		m = b;
		for(i=1;i<=k;i++){
			b *= 2;
		}
	}
	if(c > a&&c > b){
		m = c;
		for(i=1;i<=k;i++){
			c *= 2;
		}
	}
	printf("%d",a + b + c);
	return 0;
}

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


int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    int count=0;
    for(int i=0;i<N;i++) {
        cin >> a[i];
        if(a[i]>=3200) count++;
    }

    int ans = 0;
    for(int i=0;i<=7;i++) {
        for(int j=0;j<N;j++) {
            if(a[j]>=400*i && a[j]<400*(i+1)) {
                ans++;
                break;
            }
        }
    }
    cout << max(ans,1) << ' '  << ans+count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    int list[N];
    for(int i = 0; i<N; i++) cin >> list[i];

    int dp[N];
    dp[0] = 0;
    dp[1] = abs(list[0] - list[1]);

    for (int i = 2; i<N; i++) {
        int step1 = dp[i - 1] + abs(list[i] - list[i - 1]);
        int step2 = dp[i - 2] + abs(list[i] - list[i - 2]);
        dp[i] = min(step1, step2);
    }

    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int S, T, N, M;

main()
{
    cin >> N >> M;
    vector<vector<ll>> G(N);
    vector<vector<ll>> d(N, vector<ll>(3, 2e9));
    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
    }

    cin >> S >> T;
    S--, T--;

    queue<pair<int, ll>> que;
    que.push({S, 0});
    d[S][0] = 0LL;
    while (!que.empty())
    {
        auto u = que.front().first;
        auto c = que.front().second;
        que.pop();
        for (auto &nv : G[u])
        {
            if (d[nv][(c + 1) % 3] > d[u][c] + 1)
            {
                d[nv][(c + 1) % 3] = d[u][c] + 1;
                que.push({nv, (c + 1) % 3});
            }
        }
    }
    cout << (d[T][0] % 3 == 0 ? d[T][0] / 3 : -1) << endl;
}


Measured memory_bytes: 11136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		long n = fs.nextLong();
		
		int digitNum = 1;
		long cumulate = pow(26L, digitNum);
		while(n > cumulate) {
			digitNum++;
			cumulate += pow(26L, digitNum);
		}
		
		
		n -= cumulate - pow(26L, digitNum);
		n--;
		
		String[] id = new String[digitNum];
		for(int i = 0; i < digitNum; i++) {
			id[i] = "a";
		}
		
		
		for(int i = digitNum; i >= 1; i--) {
			
//			long  sub = 0;
//			for(int j = 1; j <= digitNum-1;j++) {
//				sub += pow(26L, j);
//			}
			
			long pow = pow(26L, i-1);
			int num = 1;
			while(n >= num * pow) {
				num++;
			}
			num--;
			
			
			char[] arr = new char[1];
			arr[0] = (char)(97+num);
//			System.out.println(num);
			id[i-1] = new String(arr);
			n -= pow*num;
		}
		
		
		String ans = "";
		for(int i = digitNum-1; i >= 0; i--) {
			ans+=id[i];
		}
		
		System.out.println(ans);
	}

	public long pow(long base, int n) {
		long retVal = 1;
		while (n > 0) {
			if ((n & 1) == 1) {
				retVal *= base;
			}
			n >>= 1;
			base *= base;
		}
		return retVal;
	}

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 37200
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int N;
    cin >> N;
    double m =  N/2 + 1;
    m = m/N;
    if(N%2 == 1.0){
      cout << m << endl;
    }
    else{
      cout << 0.5 << endl;
    }

    
    return 0;
}


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

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


Measured memory_bytes: 3136
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p.at(i);
	}
	int h=0;
	for (int i = 0; i < n; i++) {
		if (h < p.at(i)) {
			h = p.at(i);
		}
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += p.at(i);
	}
	int ans = sum - h / 2;
	cout << ans << endl;
}

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

int main() {
  // 入力
  string S, T;
  cin >> S >> T;
  int A, B;
  cin >> A >> B;
  string U;
  cin >> U;
  
  if (U==S) {
    A--;
  } else {  
    B--;
  }

  // 出力
  cout << A << " " << B <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int c,a,n,i,sum=0,b;
    scanf("%d",&n);
    c=n;
    for(i=0;n!=0;i++){
        a=n%10;
        n=n/10;
        sum=sum+a;

    }
    if(c%sum==0){
        printf("Yes\n");
    }
    else printf("No\n");


    return 0;
}


Measured memory_bytes: 128
# include <bits/stdc++.h>
using namespace std;
# define FOR(i, a, b) for (int i = a; i <= b; ++i)
# define FDR(i, a, b) for (int i = a; i >= b; --i)
# define mp make_pair
# define pb push_back
typedef long long i64;
const int N = 20005;

char s[15];

int main ()
{
    cin >> s + 1;
    int n = strlen(s + 1);
    int num1 = 0, num2 = 0, num3 = 0, p1, p2;
    FOR(i, 1, n) {
        if (s[i] == 'A') ++num1, p1 = i;
        else if (s[i] == 'C') ++num2, p2 = i;
        else if (s[i] >= 'A' && s[i] <= 'Z') ++num3;
    }
    if (num1 == 1 && p1 == 1 && num2 == 1 && p2 >= 3 && p2 <= n - 1 && num3 == 0) puts("AC");
    else puts("WA");
    return 0;
}


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

int main(){
	
	int h,m,s ;
	int cnt[2];
	for( int i=0 ; i<3 ; i++ ){
		for( int j=0 ; j<2 ; j++ ){
			cin >> h >> m >> s ;
			cnt[j] = h*3600 + m*60 + s ;
		}
		
		int ans = cnt[1] - cnt[0] ;
		cout << ans/3600 << " " ;
		ans -= (ans/3600)*3600 ;
		cout << ans/60   << " " ;
		ans -=  (ans/60) * 60  ;
		cout << ans      << endl ;
	}
	
	return 0 ;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

signed main() {
    ll N,K;
    cin>>N>>K;
    vector<ll> x(N),y(N);
    rep(i,0,N){
        cin>>x[i]>>y[i];
    }

    ll ans = 1ll << 62;
    rep(i,0,N)
    rep(j,0,N)
    rep(k,0,N)
    rep(l,0,N) {
        ll lx = x[i];
        ll ux = x[j];
        ll ly = y[k];
        ll uy = y[l];
        ll n = 0;
        rep(i,0,N){
            if (lx<=x[i] && x[i]<=ux && ly<=y[i] && y[i]<=uy){
                n++;
            }
        }
        if (n >= K){
            ans = min(ans, (ux-lx)*(uy-ly));
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    
    if(s < t)cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

quickSortVec l u arr
  | l >= u    = return ()
  | otherwise = do
      VM.unsafeSwap arr l ((u+l)`div`2)
      t <- VM.unsafeRead arr l
      let i = l
          j = u + 1
      nj <- loopVec t u i j arr
      VM.unsafeSwap arr l nj
      quickSortVec l (nj-1) arr
      quickSortVec (nj+1) u arr

loopVec !t !u !i !j arr = do
  ni <- doWhile i (+1)         (< t)
  nj <- doWhile j (subtract 1) (> t)
  if ni > nj
    then return nj
    else do VM.unsafeSwap arr ni nj
            loopVec t u ni nj arr
              where
                {-# INLINE doWhile #-}
                doWhile k op p
                  | nk > u    = return nk
                  | otherwise = do
                      x <- VM.unsafeRead arr nk
                      if p x then
                        doWhile nk op p
                        else
                        return nk
                        where
                          nk = op k

main = do
  n <- getInt
  as'' <- getIntVec n

  as' <- V.thaw as''
  quickSortVec 0 (n-1) as'
  as <- V.freeze as'

  d <- VM.new (10^6 + 1)
  VM.set d (0::Int)

  let loop0 a i
        | a*i > 10^6 = return ()
        | i == 1 = do
            t <- VM.read d a
            if t == 0
              then do VM.write d a 1
                      loop0 a (i+1)
              else VM.write d a 2
        | otherwise = do
            VM.write d (a*i) 2
            loop0 a (i+1)

  V.forM_ as $ \a -> loop0 a 1
  d' <- V.freeze d

  let solve i res
        | i == n = res
        | otherwise = let
            ai = as V.! i
            res' = if d' V.! ai == 1
                   then res + 1
                   else res
            in solve (i+1) res'

  print $ solve 0 0

Measured memory_bytes: 27804
from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

count = 1
for case in permutations([i+1 for i in range(N)]):
    if case == P:
        p_num = count
    
    if case == Q:
        q_num = count

    count += 1

print(abs(p_num-q_num))

Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.TreeMap;

public class Main{

	public static void main (String[] args) {

		Main main = new Main();
		main.solve();
	}

	private void solve() {

		Scanner scanner = new Scanner (System.in);

		int N = scanner.nextInt();
		int M = scanner.nextInt();

		TreeMap <Long,Long> costAmount = new TreeMap <Long,Long>();

		for (int index=0; index<N; index++) {
			Long cost = scanner.nextLong();
			Long amount = scanner.nextLong();

			if (costAmount.containsKey(cost)) {
				costAmount.put(cost, costAmount.get(cost)+amount);
			} else {
				costAmount.put(cost, amount);
			}
		}

		Long nowAmount = 0l;
		Long money = 0l;

		for (Long nKey : costAmount.keySet()) {

			Long amount = costAmount.get(nKey);
			Long cost = nKey;

			if (M-nowAmount>amount) {
				nowAmount+=amount;
				money+=(amount*cost);
			} else {
				money+=(M-nowAmount)*cost;
				break;
			}

		}

		System.out.println(money);
	}
}

Measured memory_bytes: 92304
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, cos, radians, pi, sin
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
x = LI() + [INF]
l = I()
q = I()
db = [[0] * n for _ in range(31)]
now = 0
for i in range(n):
    while x[i] + l >= x[now + 1]:
        now += 1
    db[0][i] = now

for j in range(1, 31):
    for k in range(n):
        db[j][k] = db[j - 1][db[j - 1][k]]

for _ in range(q):
    a, b = LI()
    if a > b:
        a, b = b, a
    a -= 1
    b -= 1
    ret = 0
    for kk in range(30, -1, -1):
        if db[kk][a] < b:
            a = db[kk][a]
            ret += 2 ** kk
    print(ret + 1)





Measured memory_bytes: 126296
#include<iostream>
using namespace std;
int main() {
  int n,m; cin >> n >> m;
  int ans=0;
  int count[35]={0}; // m種類のそれぞれの食べ物を何人が好きかカウントする.
  for(int i=0;i<n;i++){
    int k; cin >> k;
    for(int j=0;j<k;j++){
      int num; cin >> num;
      count[num-1]++; // 人数のカウント
    }
  }
  for(int i=0;i<m;i++){
    if(count[i]==n) ans++; // 全員好きならば答えに加算.
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  long int A, V, B, W, T;
  cin >> A >> V >> B >> W >> T;
  if(W >= V){
    cout << "NO";
  }else if(abs(A-B) > (V-W) * T){
    cout << "NO";
  }else{
    cout << "YES";
  }
}

Measured memory_bytes: 3496
#include "bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const int INF = 1 << 30;
const long long MOD = 1000000000 + 7;

int main() {
	int X, A; cin >> X >> A;
	if (X < A)cout << 0;
	else cout << 10;
}

Measured memory_bytes: 256
a=int(input())
List = list(map(int, input().split()))
res =1
List.sort()
for i in range(a):
  res = res *List[i]
  if res > 1000000000000000000:
    res = -1
    break
  elif res == 0:
    break
  else:
    pass
print(res)

Measured memory_bytes: 21636
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace AtCoder {
    class Practice {
        static void Main() => CustomMain();

        static void Solve() {
            var ans = "";
            for (int i = 0; i < 3; i++) {
                var s = ReadString();
                ans += s[i];
            }

            WriteAnswer(ans);
        }


        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }

        static long GCD(long a, long b) {
            return b != 0 ? GCD(b, a % b) : a;
        }
    }
}

Measured memory_bytes: 11092
/*
 * Code Be weshen zyk :(
 */

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using ii = pair<int,int>;
using ll = long long;

const int N = 2e3 + 5;
const int mod = 1000000007;

/*
 * i can't really think up top
 * however i can think down low
 * let's say all of the pieces at the beginning are
 * apart i can connect pieces i and i + 1 if and only if
 * their size[i] + size[j] >= L
 * and it doesn't matter the order of connections
 * so for every string i need it's left most index it's right most index
 * and it's total
 */

set<pair<ll,pair<int,int>>>st;

map<int, pair<int,ll>>getByL;	///L : (R,val)
map<int, pair<int,ll>>getByR;

int main() {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif

	int n, L;

	cin >> n >> L;

	vector<int>a(n);

	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(i)
			st.insert({a[i]+a[i-1], make_pair(i-1,i)});
		getByL[i] = getByR[i] = {i,a[i]};
	}
	vector<int>ans;
	while(st.size() && st.rbegin()->first >= L){
		auto it = *st.rbegin();
		st.erase(it);
		ll val = it.first;
		int L = it.second.first, R = it.second.second;
		ans.push_back(L);
		///L->the R of Range A
		///R->the L of Range B
		/// Delete Range B with Range X
		if(getByL.upper_bound(R) != getByL.end()){
			auto nxt = (*getByL.upper_bound(R)).second;
			st.erase({nxt.second+getByL[R].second,make_pair(getByL[R].first,getByR[nxt.first].first)});
		}
		if(getByR.find(L) != getByR.begin()){
			auto prv = (*(--getByR.find(L))).second;
			st.erase({prv.second+getByR[L].second,make_pair(getByL[prv.first].first,getByR[L].first)});
		}
		pair<ll, pair<int,int>> newRange = {val, make_pair(getByR[L].first,getByL[R].first)};
		getByL.erase(getByR[L].first);
		getByR.erase(L);
		getByR.erase(getByL[R].first);
		getByL.erase(R);
		getByL[newRange.second.first] ={newRange.second.second,newRange.first};
		getByR[newRange.second.second] ={newRange.second.first,newRange.first};
		if(getByL.find(newRange.second.first) != getByL.begin()){
			auto prv = (*(--getByL.find(newRange.second.first))).second;
			st.insert({prv.second+newRange.first,make_pair(prv.first,newRange.second.first)});
		}
		if(getByR.upper_bound(newRange.second.second) != getByR.end()){
			auto nxt = (*(getByR.upper_bound(newRange.second.second))).second;
			st.insert({nxt.second+newRange.first,make_pair(newRange.second.second,nxt.first)});
		}
	}
	if(st.size()){
		cout << "Impossible\n";
		return 0;
	}
	cout << "Possible\n";
	reverse(ans.begin(),ans.end());

	for(auto x : ans)
		cout << x+1 <<'\n';



	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i=0;i<N;i++)cin >> H[i];
  H[0]--;
  for(int i=1;i<N;i++){
    if(H[i-1]>H[i]){cout << "No" << endl; return 0;}
    else if(H[i-1]<H[i]){H[i]--;}
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 640
n = int(input())
# s = [list(input()) for _ in range(2)]
s1 = input()
s2 = input()

MOD = 10 ** 9 + 7

i = 0
pattern = 0
res = 1
while i < n:
    if s1[i] == s2[i]:
        i += 1
        res *= (3 - pattern)
        pattern = 1
    else:
        i += 2
        if pattern == 1:
            res *= 2
        elif pattern == 2:
            res *= 3
        else:
            res *= 6
        pattern = 2
    res %= MOD

res %= MOD
print(res)

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

using namespace std;

const int M = 1e4 + 3;
const int MOD = 1e9 + 7;
string k;
int n, d;
int dp[M][102][2];

int solve (int i, int s, bool b) {
    if (i >= n) {
        if (!s) return 1;
        return 0;
    }
    int &ret = dp[i][s][b];
    if (ret != -1) return ret;
    ret = 0;
    for (int add = 0; add <= (b ? 9 : k[i]-'0'); add++) {
        ret = (ret + solve (i+1, (s+add)%d , b||(add<k[i]-'0'))) % MOD;
    }
    return ret;

}

int main () {
    cin >> k >> d;
    n = k.size();
    memset(dp, -1, sizeof dp);
    cout << (solve (0, 0, 0)-1+MOD)%MOD;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
const int MAXN=10010,P=1e9+7;
int n,ans,a[MAXN],inv[MAXN],app[MAXN*100],lc;
int qpow (int a,int b) {
	int res=1;
	while (b) {
		if (b&1) {res=(1ll*res*a)%P;}
		a=(1ll*a*a)%P,b>>=1; 
	}
	return res;
}
int main () {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		inv[i]=qpow(a[i],P-2);
		for (int j=2;j*j<=a[i];j++) {
			int cnt=0;
			while (a[i]%j==0) {cnt++,a[i]/=j;}
			app[j]=max(app[j],cnt);
		}
		if (a[i]>1) {app[a[i]]=max(app[a[i]],1);}
	}
	lc=1;
	for (int i=1;i<=1000000;i++) {lc=(1ll*lc*qpow(i,app[i]))%P;}
	for (int i=1;i<=n;i++) {
		ans=(ans+(1ll*inv[i]*lc)%P)%P;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
	ll h,w;
	
	while (true) {
		cin >> h >> w;
		if (h == 0 && w == 0)
			break;

		for (ll i = 0; i < h; i++) {
			for (ll j = 0; j < w; j++) {
				if ((i > 0 && j>0) && (h-1>i && w-1>j))
					cout << ".";
				else
					cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
		
}



Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main(){

	int x, y, z, count=0, pepole=0;
	cin >> x >> y >> z;
	x = x - z;
	y = y + z;
	while(count <= x){
		count += y;
		pepole++;
	}
	cout << pepole-1 << endl;

	return 0;
}


Measured memory_bytes: 256
def test():
    a,b,c = map(int,input().split())

    for i in range(a):
        if b == a:
            break
        else:
            b += 1
            c -= 1
            if c == 0:
                break
            else:
                pass

    print(c)


if __name__ == "__main__":
    test()


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
#define ANS(s) cout << s << endl


using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}



int main(void) { 
    string s;
    int n ,m, l;
    n = 1000;
    cin >> s;
    l = s.size();
    for (int i = 0; i < l-2; i++){
        int si = stoi(s.substr(i, 3));
        //cout << si << endl; 
        m = abs(753 - si);
        if(m < n){
            n = m;
        }
        
    } 
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

int main(){
  long long n;
  cin >> n;
  long long a[n+1];
  long long b[n];

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

  for(int i=0;i<n;i++){
    cin >> b[i];
  }

  long long count = 0;

  for(int i=n-1;i>=0;i--){
    if(a[i+1] >= b[i]){
      count += b[i];
      a[i+1] = 0;
      continue;
    }
    count += a[i+1];
    b[i] -= a[i+1];
    if(a[i] >= b[i]){
      count += b[i];
      a[i] -= b[i];
    }
    else{
      count += a[i];
      a[i] = 0;
    }

  }

  cout << count << endl;

  return 0;
}


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

using namespace std;

const int MAXN = 2e5 + 10;

long long dp[MAXN];

struct f {
	long long a, b;
	f(long long _a = 0, long long _b = 0) : a(_a), b(_b) {}
};

int chtSize = 0;
f cht[MAXN];

bool scot(f f0, f f1, f f2) {
	return 1.0*(f2.b - f0.b)/(1.0*(f0.a - f2.a)) <= 1.0*(f1.b - f0.b)/(1.0*(f0.a - f1.a));
}

long long eval(f f0, long long x) {
	return x*f0.a + f0.b;
}

int main() {
    #ifdef BLAT
        freopen("input", "r", stdin);
    #endif

   	int n;
   	cin >> n;
   	long long c;
   	cin >> c;

   	long long h;
   	cin >> h;

   	int chtNow = 1;
   	cht[++chtSize] = f(-2ll*h, h*h);
   	for(int i = 2; i <= n; ++i) {
   		cin >> h;
   		while(chtNow < chtSize && eval(cht[chtNow+1], h) < eval(cht[chtNow], h)) ++ chtNow;
   		dp[i] = 1ll*h*h + c + eval(cht[chtNow], h);
   		f acum(-2ll*h, dp[i] + 1ll*h*h);
   		while(chtSize > 1 && scot(acum, cht[chtSize-1], cht[chtSize])) chtSize --;
   		cht[++chtSize] = acum;
   		chtNow = min(chtNow, chtSize);
   	}

   	cout << dp[n] << '\n';
}   	

Measured memory_bytes: 4992
#include <stdio.h>

int cjudge(int pm,int pe,int pj){
    int c;//クラス
    if(pm == 100 || pe== 100 || pj== 100)c=0;
    else if(pm + pe >= 180)c=0;
    else if(pm + pe + pj >= 240)c=0;
    else if(pm + pe + pj >= 210)c=1;
    else if((pm + pe + pj >= 150) && (pm >= 80 || pe >= 80))c=1;
    else c=2;
    return c;
}

int main(void){
    int n,pm,pe,pj;
    while(scanf("%d",&n) != EOF && n != 0){
        for(int i=0;i < n;i++){
            scanf("%d %d %d",&pm,&pe,&pj);
            printf("%c\n",'A' + cjudge(pm,pe,pj));
        }
    }
    return 0;
}

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

using namespace std;

ifstream fin("fisier.in");
ofstream fout("fisier.out");

int v[100005];
int dp[100005];

int main(){
    int n,k,i,j;

    cin>>n>>k;

    for(i=1;i<=n;i++){
        cin>>v[i];
        dp[i]=1000000000;
    }

    dp[1]=0;

    for(i=2;i<=n;i++)
        for(j=i-1;j>=i-k && j>=1;j--)
            dp[i]=min(dp[i],abs(v[i]-v[j])+dp[j]);

    cout<<dp[n];

    return 0;
}


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

long long N, L[1 << 18], R[1 << 18], ans;
pair<long long, long long> A[1 << 18];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) { cin >> A[i].first >> A[i].second; A[i].second++; }
	sort(A + 1, A + N + 1);

	L[0] = (1LL << 60);
	for (int i = 1; i <= N; i++) L[i] = min(L[i - 1], A[i].second);
	R[N + 1] = (1LL << 60);
	for (int i = N; i >= 1; i--) R[i] = min(R[i + 1], A[i].second);

	// 1 個だけ取る場合
	for (int i = 1; i <= N; i++) {
		long long s1 = A[i].second - A[i].first;
		long long cl = A[N].first; if (i == N) cl = A[N - 1].first;
		long long cr = min(L[i - 1], R[i + 1]);
		ans = max(ans, s1 + max(0LL, cr - cl));
	}

	// 2 個以上取る場合
	for (int i = 1; i <= N - 1; i++) {
		long long al = A[i].first;
		long long ar = L[i];
		long long bl = A[N].first;
		long long br = R[i + 1];
		ans = max(ans, (ar - al) + (br - bl));
	}

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

Measured memory_bytes: 5888
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

std::string solve(int n)
{
  switch (n % 10) {
  case 0:
  case 1:
  case 6:
  case 8:
    return "pon";
  case 2:
  case 4:
  case 5:
  case 7:
  case 9:
    return "hon";
  case 3:
    return "bon";
  }
  throw "error";
}

int main()
{
  int n;
  std::cin >> n;

  std::cout << std::setprecision(20);
  std::cout << solve(n) << std::endl;
}


Measured memory_bytes: 3628
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto L = readln.chomp.to!int;
    L -= 1;
    int N = L.bsr + 1;
    auto A = new int[](N);
    auto G = new Tuple!(int, int)[][](N);

    if (L <= 10) {
        writeln(2, " ", L+1);
        foreach (i; 0..L+1) {
            writeln(1, " ", 2, " ", i);
        }
        return;
    }

    foreach (i; 0..N) {
        A[i] = L % 2;
        L /= 2;
    }

    foreach (i; 1..N) {
        G[i] ~= tuple(i+1, 0);
    }

    foreach (i; 1..N) {
        G[i] ~= tuple(i+1, 1<<(N-i-1));
    }


    int tmp = 1 << (N - 1);

    foreach (i; 1..N) {
        if (A[N-i-1] == 1) {
            int to = i + 1;
            if (to > N) to = N;
            G[0] ~= tuple(to, tmp);
            tmp += 1 << (N-i-1);
        }
    }

    G[0] ~= tuple(N, tmp);
    G[1] ~= G[0];
    G[0] = [];

    writeln(N, " ", N.iota.map!(i => G[i].length).sum);
    foreach (i; 1..N) {
        foreach (j; G[i]) {
            writeln(i, " ", j[0], " ", j[1]);
        }
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int a[N];
 
signed main() {
    IOS;
    int n, x, y;
    cin >> n >> x >> y;
    if(y < x)
        swap(x, y);
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            if(j == i+1)
                a[1]++;
            else{
                int d = j-i;
                d = min(d, abs(i-x) + abs(y-j) + 1);
                a[d]++;
            }
        }
    }
    for(int i = 1; i <= n-1; i++)
        cout << a[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    LL a, b;
    cin >> a >> b;
    LL mi = min(a, b);
    LL ma = max(a, b);
    LL sub = ma + mi;
    if (sub % 2 == 0) cout << sub / 2 << endl;
    else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 764