akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    ll A,B,N;
    cin >> A >> B >> N;
    ll a = -1;
    if(B-1 <= N) a = B-1;
    else a = N;
    
    cout << (A*a/B)-a/B << endl;
    
    

    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	for(int i = 0; i < n1; i++) L[i] = A[left + i];
	for(int i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
	for(int k = left; k < right; k++) {
		cnt++;
		if(L[i] <= R[j]) {
			A[k] = L[i++];
		}
		else {
			A[k] = R[j++];
		}
	}	
} 

void mergeSort(int A[], int n, int left, int right) {
	if(left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

int main() {
	int A[MAX], n, i;
	cnt = 0;
    
    cin >> n;
    for(i = 0; i < n; i++) cin >> A[i];
    
    mergeSort(A, n, 0, n);
    
    for(i = 0; i < n; i++){
    	if(i) cout << " ";
    	cout << A[i];
    }
    cout << endl;
    
    cout << cnt << endl;
    
    return 0; 
}

Measured memory_bytes: 7000
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n,q; cin >> n >> q;
    dsu uf(n);
    rep(i,q){
        int t,u,v; cin >> t >> u >> v;
        if(t == 0){
            uf.merge(u,v);
        }else{
            cout << uf.same(u,v) << "\n";
        }
    }
}

Measured memory_bytes: 4100
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

a = get_int

puts a + a ** 2 + a ** 3


Measured memory_bytes: 14400
n = int(input())
a = list(map(int, input().split()))

x = max(a)
b1 = x//2
b2 = (x+1)//2

y = x
z = x
for i in range(len(a)):
    if a[i] != x:
        tmp = min(abs(a[i]-b1), abs(a[i]-b2))
        if tmp < y:
            z = a[i]
        y = min(tmp, y) 

ans = x*z
print(str(x) + ' '+ str(z))

Measured memory_bytes: 14052
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(auto &I:a){cin>>I; I--;}
    vector<ll> ans1(n+1,0);
    vector<ll> ans2(n+1,0);
    for(int i=1;i<n;i++){
        ans1[a[i]]+=i;
        ans2[a[i]+1]-=i;
    }
    for(int i=1;i<n;i++){ans1[i]+=ans1[i-1]; ans1[i]++; ans2[i]+=ans2[i-1]; ans2[i]--;}
    ll C=-1LL*ans2[n-1]+1LL;
    for(int i=0;i<n;i++){
        cout<<ans1[i]+C<<(i+1==n?"\n":" ");
    }
    for(int i=0;i<n;i++){
        cout<<ans2[i]+C<<(i+1==n?"\n":" ");
    }
    
    
    return 0;
}


Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
					
public class Program
{
	public static void Main()
	{
		var split = Console.ReadLine().Split(' ');
		var a = int.Parse(split[0]);
		var b = int.Parse(split[1]);
		if(b%a==0)Console.WriteLine(a+b); 
		else Console.WriteLine(b-a);
	}
}

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

#define fr(i,n) for(int i = 0; i<n; i++)
#define sz(v) (int)(v.size())
#define prin(a) cout << #a << " = " << a << endl
#define all(v) (v).begin(),(v).end()

typedef long long ll;

int main(){
	string s, t;
	cin >> s >> t;
	t.pop_back();
	if(s==t) puts("Yes");
	else puts("No");
}

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

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

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

int main() {
    int k, n;
    cin >> k >> n;
    if(!(k&1)){
        printf("%d" , k/2);
        for (int i = 1; i < n; ++i) {
            printf(" %d", k);
        }
        puts("");
        return 0;
    }else if(k == 1) {
        for (int i = 0; i < (n+1)/2; ++i) {
            if(i) printf(" ");
            printf("1");
        }
        puts("");
        return 0;
    }
    vector<int> ans(n, (k+1)/2);
    int cnt = n/2, cur = n-1;
    while(cnt--){
        ans[cur]--;
        if(ans[cur] == 0) --cur;
        else {
            for (int j = cur+1; j < n; ++j) {
                ans[j] = k;
            }
            cur = n-1;
        }
    }
    for (int i = 0; i < n; ++i) {
        if(!ans[i]) break;
        if(i) printf(" ");
        printf("%d", ans[i]);
    }
    puts("");
    return 0;
}

Measured memory_bytes: 3456
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;   
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;

int main(){
    double a,b,d=0,n,m,ans=0;
    string s,s2;
    cin >> n;
    for(int i = 0; i < n;i++){
        cin >> a >> s;
        if(s=="JPY"){
            ans += a;
        }
        else 
            ans += (a*380000);
    }
   
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
using namespace std;
#define pi M_PI
#define ll long long

int main(){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    ans = a * b - a - b + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, P; string S;
int cnt[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> P >> S;
	ll ans = 0;

	if (P == 2 || P == 5) {
		rep(i, 0, N) if ((S[i] - '0') % P == 0) ans += i + 1;
	}
	else {
		int cu = 0; int dg = 1;

		rrep(i, N - 1, 0) {
			cu = (cu + dg * (S[i] - '0')) % P;
			dg = (dg * 10) % P;

			ans += cnt[cu];
			if (cu == 0) ans++;

			cnt[cu]++;
		}
	}

	cout << ans << endl;
}







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

int main()
{
	int A, B, C, K;
	scanf("%d%d%d%d", &A, &B, &C, &K);
	
	int ans = 0;
	if(K >= A)
	{
		K -= A;
		ans += A;
	}
	
	else
	{
		ans += K;
		K = 0;
	}
	
	//printf("ans1 = %d, K = %d\n", ans, K);
	
	if(K >= B)
	{
		K -= B;
	}
	
	else
		K = 0;
	
	//printf("ans2 = %d, K = %d\n", ans, K);
	if(K >= C)
	{
		K -= C;
		ans -= C;
	}
	
	else
	{
		ans -= K;
		K = 0;
	}
	
	printf("%d", ans);
}

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

#define INF 10000000

int W,N;
int v[1001],w[1001];

// dp[i][j] : iテァツ閉ェテァツ崢ョテ、ツサツ・テゥツ卍催」ツ?ョテ」ツつづ」ツ?ョテ」ツ?凝」ツつ嘉ゥツ?催」ツ?陛ッツスツ甘、ツサツ・テ、ツクツ凝」ツ?ォテ」ツ?ェテ」ツつ凝」ツつ暗」ツ??」ツ?ォテゥツ?クテ」ツつ禿」ツ??ヲツ卍づ」ツ?ョテヲツ慊?・ツ、ツァテ・ツ?、
int dp[1002][1002];

int rec(int i, int j){
  if(dp[i][j] >= 0){
    return dp[i][j];
  }
  int res;
  if(i == N){
    res = 0;
  }else if( j < w[i] ){
    res = rec(i + 1 , j);
  }else{
    res = max( rec(i + 1,j) , rec(i+1, j-w[i]) + v[i] );
  }
  return dp[i][j] = res;
}

int main(){
  int x = 1;
  while(1){
   
    cin >> W;
    if(W == 0) break;

    cin >> N;
    memset(dp,-1,sizeof(dp));
    for(int i = 0; i < 1001; i++){
      w[i] = INF;
      v[i] = -1;
    }
 
    for(int i = 0 ; i < N ; i++){
      char tmp;
      cin >> v[i] >> tmp >> w[i];
      //  cout << v[i] <<" "<< w[i] << endl; 
    }
    
    for(int i = 0; i < N ; i++){
      for(int j = 0; j <= W ; j++){
	rec(i,j);
      }
    }
    
    cout <<"Case " << x << ":" << endl;
    cout <<  dp[0][W] << endl;
    int t;
    for( t = 0; dp[0][W] != dp[0][t] ;t++){}
    cout << t << endl; 
    x++;
  }
  return 0;

}

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

int main()
{
    vector<int> a(3);
    rep(i, 3) cin >> a[i];

    sort(a.begin(), a.end());

    int ans = abs(a[1] - a[0]) + abs(a[1]- a[2]);

    cout << ans << endl;



    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, u, v;
  cin >> N >> u >> v;
  u--, v--;
  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  auto f = [&](int s) -> vector<int> {
    vector<int> res(N, -1);
    res[s] = 0;

    queue<int> que;
    que.push(s);

    while (!que.empty()) {
      int u = que.front();
      que.pop();

      for (int v : G[u]) {
        if (res[v] != -1) continue;
        res[v] = res[u] + 1;
        que.push(v);
      }
    }

    return res;
  };

  vector<int> takahashi = f(u), aoki = f(v);

  int res = 0;
  for (int i = 0; i < N; i++) {
    if (takahashi[i] < aoki[i]) res = max(res, aoki[i]);
  }
  cout << res - 1 << '\n';
  return 0;
}


Measured memory_bytes: 6656
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>

using namespace std;

const int NMAX = 55;

char s[NMAX];

int main()
{
    int num;
    cin>>(s+1);
    num = (s[1]-'0')*10+(s[2] - '0');
    int num1 = (s[3] - '0')*10 + (s[4]-'0');
    if((num > 12 || num == 0) && (num1 > 12 || num1 == 0))
    {
        cout<<"NA";
        return 0;
    }
    else if(num <= 12 && num > 0 && (num1 > 12 || num1 == 0))
    {
        cout<<"MMYY";
        return 0;
    }
    else if((num > 12 || num == 0) && num1 > 0 && num1 <= 12)
    {
        cout<<"YYMM";
        return 0;
    }
    else
    {
        cout<<"AMBIGUOUS";
        return 0;
    }
}


Measured memory_bytes: 256
import string

n=int(raw_input())


def decrypt(w,a,b):
    ret=[]
    for i in w:
        ret.append( (i*a+b)%26 )
    return ret
    
for i in range(n):
    inp=[[string.ascii_lowercase.index(c) for c in word] for word in raw_input().split()]
    #that
    that=[string.ascii_lowercase.index(c) for c in 'that']
    #this
    this=[string.ascii_lowercase.index(c) for c in 'this']
    a=0
    b=0
    bkf=0
    for word in inp:
        if len(word)==4:
            for i in range(26):
                for j in range(26):
                    dew=decrypt(word,i,j)
                    if dew==that or dew==this:
                        a=i
                        b=j
                        bkf=1
                        break
                if bkf:
                    break
        if bkf:
            break
    A=[]
    for word in inp:
        dw=decrypt(word,a,b)
        cdw=''.join([string.ascii_lowercase[w] for w in dw])
        A.append(cdw)
    print ' '.join(A)

Measured memory_bytes: 6416
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

func abs(a int) int {
	if a < 0 {
		return -a
	} else {
		return a
	}
}

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

func nextInt() int{
	sc.Scan()
	i,e:=strconv.Atoi(sc.Text())
	if e != nil{
		panic(e)
	}
	return i
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}



func main() {
	sc.Split(bufio.ScanWords)
	n:=nextInt()
	a:=make([]int,n)
	for i:=0;i<n;i++{
		a[i]=nextInt()
	}
	sort.IntSlice(a).Sort()
	maxA:=a[len(a)-1]
	dp:=make([]bool,maxA+1)

	count:=0
	for i:=0;i<n-1;i++{
		if dp[a[i]]==true{
			continue
		}
		for j:=1;j<=maxA/a[i];j++{
			dp[j*a[i]]=true
		}
		if a[i]!=a[i+1]{
			count++
		}
	}
	if dp[maxA] == false {
		count++
	}
	fmt.Println(count)


}


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

namespace Sample1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            string str ="";
            for(var i=N;N<=999; N++)
            {
                str = N.ToString();
                if((str[0]==str[1])&&(str[1]==str[2]))
                {
                    break;
                }
            }
            Console.WriteLine(str);
        }
    }
}


Measured memory_bytes: 13140
import sys
n = int(input())
t_1=0
t_2=0
x_1=0
x_2=0
y_1=0
y_2=0

for i in range (n):
    t_1,x_1,y_1=t_2,x_2,y_2
    t_2,x_2,y_2=map(int,input().split())
    if (t_2-t_1) >= abs(x_2-x_1)+abs(y_2-y_1) and (t_2-t_1)%2 == (abs(x_2-x_1)+abs(y_2-y_1))%2:
        continue
    else:
        print('No')
        sys.exit()
print('Yes')


Measured memory_bytes: 3064
N = int(input())
Hs = list(map(int, input().split(" ")))
c = 0
t = 0
l = Hs[0]
for h in Hs[1:]:
  if l >= h:
    t += 1
  else:    
    if c < t:
      c = t
    t = 0
  l = h 

if c < t:
  c = t
print(c)

Measured memory_bytes: 63708
# include <bits/stdc++.h>
#define INF 9223372036854775807
using namespace std;

int main(){

  string S;
  cin >> S;
  map<char, char> m;
  m['A'] = 'T';
  m['T'] = 'A';
  m['C'] = 'G';
  m['G'] = 'C';
  string ans = "";
  for(int i=0; i< S.size();i++){
    ans += m[S[i]];
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long

vector<int>A(10);
vector<vector<int>>L(50,vector<int>(4));
int N,M,Q,ans,point;

int dfs(int cn){
    int i,j;
        for(i=A[cn-1];i<=M;i++){
            A[cn]=i;
            if(cn==N-1){
                point=0;
                for(j=0;j<Q;j++){
                    if(A[L[j][1]-1]-A[L[j][0]-1]==L[j][2])point+=L[j][3];
                }
                ans=max(ans,point);
                //return 0;
            }else{
                dfs(cn+1);
            }
        }
    return 0;
}

int main(){
    int i,j;
    cin>>N>>M>>Q;
    ans=0;
    point=0;
    for(i=0;i<Q;i++)for(j=0;j<4;j++)cin>>L[i][j];
    A[0]=1;
    dfs(1);
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>

int dist(std::string str, int start) {
  int cnt = 0;
  for (int i=0; i<str.length(); i++) {
    if (str[i] != static_cast<char>(start % 2 + 48)) cnt++;
    start++;
  }
  return cnt;
}

int main() {
  std::string str;
  std::cin >> str;
  
  int value1 = dist(str, 0);
  int value2 = dist(str, 1);
  std::cout << std::min(value1, value2) << std::endl;
  
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n);
  map<ll, ll> mp;
  rep(i, n) {
    cin >> a[i];
    mp[a[i]]++;
  }
  ll sum = 0;
  for(auto v : mp) sum += v.second * (v.second - 1) / 2;
  rep(i, n) {
    ll now = sum;
    now -= mp[a[i]] * (mp[a[i]] - 1) / 2;
    now += (mp[a[i]] - 1) * (mp[a[i]] - 2) / 2;
    cout << now << endl;
  }
}

Measured memory_bytes: 11776
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define pll pair<ll, ll>
#define N 200123
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define vpll vector<pll>
#define pb emplace_back
#define fs first
#define sc second
#define sz(x) ((int)((x).size()))
#define oo 1000000123
#define mod 1000000007LL
#define M 10000123

using namespace std;

int n;

int main(){
    ios_base::sync_with_stdio(0);
    cin >> n;
    n = n % 10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
        cout << "hon\n";
    else if(n == 0 || n == 1 || n == 6 || n == 8)
        cout << "pon\n";
    else cout << "bon\n";

    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX = 1e+5 + 10;

int action[MAX][3];
int dp[MAX][3];

int main() {

    int n;
    cin >> n;

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

    }

    
    dp[0][0] = action[0][0];
    dp[0][1] = action[0][1];
    dp[0][2] = action[0][2];

    for(int i = 1; i < n; ++i) {

        dp[i][0] = max(dp[i - 1][1] + action[i][0], dp[i - 1][2] + action[i][0]);
        dp[i][1] = max(dp[i - 1][0] + action[i][1], dp[i - 1][2] + action[i][1]);
        dp[i][2] = max(dp[i - 1][0] + action[i][2], dp[i - 1][1] + action[i][2]);

    }

    int ans = max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 2560
ary =[]
while   true
        a,b = gets.split.map(&:to_i)
        break if a == 0 && b == 0
        if a>b
                ary << b.to_s + " " + a.to_s
        else
                ary << a.to_s + " " + b.to_s
        end
end
puts ary

Measured memory_bytes: 8756
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int val[310][310];
int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			int r;
			cin >> r;
			val[i][r-1] = -j;
		}
	}
	int ans = 100000;
	int used[310];
	for(int z = 0; z < m; z++){
		used[z] = 1;
	}
	for(int z = 0; z < m; z++){
		int freq[310];
		for(int j = 0; j < m; j++){
			freq[j] = 0;
		}
		for(int i = 0; i < n; i++){
			int best = -1;
			for(int j = 0; j < m; j++){
				if(used[j] && (best == -1 || val[i][j] > val[i][best])){
					best = j;
				}
			}
			freq[best]++;
		}
		int sbest = -1;
		for(int j = 0; j < m; j++){
			if(used[j] && (sbest == -1 || freq[j] > freq[sbest])){
				sbest = j;
			}
		}

		ans = min(ans, freq[sbest]);

		used[sbest] = 0;
	}
	cout << ans << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main() {
  int x,n,a,m;
  cin >> x >> n;
  if(n==0){
    cout << x << endl;
  }else{
    vector<int> vec(n);
    for(int i=0; i<n; i++){
      cin >> vec.at(i);
    }
    a = x;
    m = 1;
    while(1 == 1){
      if(find(vec.begin(), vec.end(), a) != vec.end()) {
        a = a-m;
        if(find(vec.begin(), vec.end(), a) != vec.end()) {
          a = a+m*2;
          if(find(vec.begin(), vec.end(), a) != vec.end()) {
            a = x;
            m = m+1;
          }else{
            break;
          }
        }else{
          break;
        }
      }else {
        break;
      }
    } //while閉じてる
    cout << a << endl;
  }
}

Measured memory_bytes: 3640
N = int(input())
X = [0] * N
Y = [0] * N
H = [0] * N

for i in range(N):
    x, y, h = map(int, input().split())
    X[i] = x
    Y[i] = y
    H[i] = h

for cx in range(101):
    for cy in range(101):
        H_list = []
        check_list = []
        for i in range(N):
            if H[i] == 0:
                check_list.append(i)
                continue
            H_list.append(H[i] + abs(X[i] - cx) + abs(Y[i] - cy))
        if len(set(H_list)) == 1:
            h = H_list[0]
            flag = True
            for check in check_list:
                if H[check] == max(h - abs(X[check] - cx) - abs(Y[check] - cy), 0):
                    pass
                else:
                    flag = False
                    break
            if flag:
                print(cx, cy, h)
                exit()


Measured memory_bytes: 3064
class Dice
	attr_accessor :t, :b, :n, :e, :s, :w
	def initialize(*labels)
		@t = labels[0]
		@s = labels[1]
		@e = labels[2]
		@w = labels[3]
		@n = labels[4]
		@b = labels[5]
	end
	def roll(dir)
		case dir
		when 'N'
			@t, @s, @b, @n = @s, @b, @n, @t
		when 'S'
			@s, @b, @n, @t = @t, @s, @b, @n
		when 'W'
			@t, @e, @b, @w = @e, @b, @w, @t
		when 'E'
			@e, @b, @w, @t = @t, @e, @b, @w
		end
	end
end

dice = Dice.new(*gets.split)
gets.to_i.times{
	t, s = gets.split
	8.times{|i|
		break if dice.s == s
		dice.roll 'NW'[i%4/3]
	}
	dice.roll 'W' while dice.t != t
	puts dice.e
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int count_r = 0;
    for (char c : s) {
        if (c == 'R') {
            ++count_r;
        }
    }
    if (count_r > n - count_r) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

ll f(string &s) {
   string a = "";
   ll sum = 0;
   int n = s.size();
   rep (i, n) {
      if (s[i] == '+') {
         sum += stoll(a);
         a = "";
      } else {
         a += s[i];
      }
   }
   sum += stoll(a);
   return sum;
}

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

   int n = s.size();
   ll sum = 0;
   for (int mask = 0; mask < (1<<(n-1)); mask++) {
      string t;
      t += s[0];
      for (int i = 0; i < n-1; i++) {
         if ((mask >> i)&1) {
            t += '+';
         }
         t += s[i+1];
      }
      sum += f(t);
   }
   cout << sum << endl;

   return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define PII pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI2(N, M);
  vector<PII> s(N), c(M);
  FOR(i, N) { cin >> s[i].first >> s[i].second; }
  FOR(i, M) { cin >> c[i].first >> c[i].second; }
  FOR(i, N) {
    int x = s[i].first, y = s[i].second;
    int mn = 1 << 29, ind;
    FOR(j, M) {
      int dist = abs(x - c[j].first) + abs(y - c[j].second);
      if (mn > dist) {
        mn = dist;
        ind = j + 1;
      }
    }
    print(ind);
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
// ここに処理を記述
    int n;
    cin >> n;
    int R[n];
    for(int i=0; i<n; i++){
        cin >> R[i]; 
    } 

    int profit = R[1] - R[0];
    int min = R[0];

    for(int i=1; i<n; i++){
        if(profit < R[i] - min) profit = R[i] - min;
        if(min > R[i]) min = R[i];
    }

    cout << profit << endl;

    return 0;
}


Measured memory_bytes: 3896
import Control.Monad

main = do
  xy <- map (map read . words) <$> replicateM 3 getLine
  putStrLn $ solve xy

solve :: [[Int]] -> String
solve xy =
    let one = length . filter (\x -> elem 1 x) $ xy
        two = length . filter (\x -> elem 2 x) $ xy
        thr = length . filter (\x -> elem 3 x) $ xy
        fou = length . filter (\x -> elem 4 x) $ xy in
    if one >= 3 || two >= 3 || thr >= 3 || fou >= 3 then "NO"
    else "YES"



Measured memory_bytes: 3892
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
 
void swap (int *x, int *y) {
  int temp;    
 
  temp = *x;
  *x = *y;
  *y = temp;
}
 
int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }
 
  if(b==0){
    return a;
  }
 
  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }
 
  return b;
}
 
/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}
 
 
int modpow(int a,int n,int mod){
  int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}
 
int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}
 
int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}
 
void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }
 
  return;
}
 
void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }
 
  return;
}
 

int main(void){
  int x;
  scanf("%d",&x);
  if(x<30){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
 
  return 0;
}

Measured memory_bytes: 1664
from collections import deque

row, col = map(int, input().split())
graph = [input() for i in range(row)]

count = 0
for i in range(row):
  for j in range(col):
    if graph[i][j] == ".":
      count += 1
      
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]


distance = [[-1]*col for _ in range(row)]
queue = deque([])
distance[0][0] = 0
queue.appendleft([0, 0])

while len(queue) > 0:
  v = queue.popleft() 

  for j in range(4):
    next_y, next_x = v[0]+dy[j], v[1]+dx[j]
    if not 0 <= next_y < row or not 0 <= next_x < col:
      continue
    if distance[next_y][next_x] != -1 or graph[next_y][next_x] == '#':
      continue 

    distance[next_y][next_x] = distance[v[0]][v[1]] + 1
    queue.append([next_y, next_x])
      
if distance[row-1][col-1] == -1:
  print(-1)
else:
  ans = count - distance[row-1][col-1] - 1
  print(ans)



Measured memory_bytes: 40816
#include<cstdio>
int N, a[15];
void solve()
{
    int x = a[0], y = 0;
    for(int i = 1; i < 10; i++){
        if(a[i] > x && a[i] > y){
            if(a[i] - x >= a[i] - y)
                y = a[i];
            else
                x = a[i];
        }
        else if(a[i] > x)
            x = a[i];
        else if(a[i] > y)
            y = a[i];
        else{
            printf("NO\n");
            return;
        }
    }
    printf("YES\n");
}
int main()
{
    scanf("%d", &N);
    while(N--){
        for(int i = 0; i < 10; i++)
            scanf("%d", &a[i]);
        solve();
    }
    return 0;
}



Measured memory_bytes: 2584
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,maxn=0,s;
	cin>>n;
	int a[n+5];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]>maxn){
			maxn=a[i];
			s=i;
		}
	} 
	double sum;
	for(int i=0;i<n;i++)
	  sum+=a[i];
	  
	sum-=a[s]*1.0/2;
	if(a[s]%2==0){
		cout<<sum<<endl;
	}
	else{
		cout<<fixed<<setprecision(1)<<sum<<endl;
	} 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;




int main(){
  int n;
  cin >> n;
  vector <int> a;

  REP(i,n){
    int b;
    cin >> b;
    a.pb(b);
  }
  sort(a.begin(),a.end());
  int b = a[a.size()-1]/2;
  int res = a[a.size()-1];
  int sum;
  if(n%2 == 0){
    REP(i,n-1){
      if(res > abs(b-a[i])){
	res = abs(b - a[i]);
	sum = a[i];
      }
            
    }
  }
  else{
    //cout << b << endl;
    REP(i,n-1){
      if(res >= abs(b-a[i])){
	res = abs(b-a[i]);
	sum = a[i];
      }
    }
    //cout << sum << endl;
    //cout << res << endl;
    b++;
    REP(i,n-1){
      if(res > abs(b-a[i])){
	res = abs(b-a[i]);
	sum = a[i];
      }
    }
  }
  cout << a[a.size()-1] << " " << sum << endl;
  return 0;
}


Measured memory_bytes: 892
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] s = br.readLine().split(" ");
        int[] a = new int[6];

        for(int i = 0; i < s.length; i++){
            a[i] = Integer.parseInt(s[i]);    
        }

        Dice dice = new Dice(a);

        String order = br.readLine();

        for(int i = 0; i < order.length(); i++){
            char c = order.charAt(i);
            switch(c){
                case 'S':
                    dice.turnS();
                    break;
                case 'N':
                    dice.turnN();
                    break;
                case 'W':
                    dice.turnW();
                    break;
                case 'E':
                    dice.turnE();
                    break;
            }
        }

        System.out.println(dice.TOP);
    }
}

class Dice{
    int TOP,BOTTOM,LEFT,RIGHT,FRONT,BACK;

    Dice(int[] a){
        this.TOP = a[0];
        this.FRONT = a[1];
        this.RIGHT = a[2];
        this.LEFT = a[3];
        this.BACK = a[4];
        this.BOTTOM = a[5];
    }

    void turnS(){
        int tmp = this.TOP;
        this.TOP = this.BACK;
        this.BACK = this.BOTTOM;
        this.BOTTOM = this.FRONT;
        this.FRONT = tmp;
    }

    void turnN(){
        int tmp = this.TOP;
        this.TOP = this.FRONT;
        this.FRONT = this.BOTTOM;
        this.BOTTOM = this.BACK;
        this.BACK = tmp;
    }

    void turnW(){
        int tmp = this.TOP;
        this.TOP = this.RIGHT;
        this.RIGHT = this.BOTTOM;
        this.BOTTOM = this.LEFT;
        this.LEFT = tmp;
    }

    void turnE(){
        int tmp = this.TOP;
        this.TOP = this.LEFT;
        this.LEFT = this.BOTTOM;
        this.BOTTOM = this.RIGHT;
        this.RIGHT = tmp;
    }

}

Measured memory_bytes: 24324
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int main() {
    
    ll x;
    cin >> x;
    ll ans=0;
    ans+=(x/500)*1000;
    ans+=((x-((x/500)*500))/5)*5;

    cout << ans << endl;


 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define double long double
#define int long long
#define mii map<int,int>
#define pii pair<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf (int)50000000000000000 //5･10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
int n,cnt=0;
int a[100010];
signed main() {
  cin>>n;
  rep(i,n) cin>>a[i];
  rep(i,n) {
    if(i==a[a[i]-1]-1&&a[i]!=0) {
      cnt++;
      a[i]=0;
      a[a[i]-1]=0;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
int const mod = 998244353;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x , int m){
    return power(x,m-2,m);
}

int const N = 2e5+5;
int const inf = 2e16;

void solve(){  
    int i,j,l;
    int a;
    cin>>a;
    int ans = a+ a*a + a*a*a;
    cout<<ans<<endl;
}           


int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}


/*

1 3 4 7 8 8 


*/

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

using namespace std;

using ll = long long;

//引数unzipには圧縮前のvectorを入れる
int compress(vector<ll>& unzip, map<ll, int>& zip) {
    sort(unzip.begin(), unzip.end());
    unzip.erase(unique(unzip.begin(), unzip.end()), unzip.end());
    for (int i = 0; i < unzip.size(); i++) {
        zip[unzip[i]] = i;
    }
    return unzip.size();
}

int sum[55][55];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<ll> x(N), y(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }
    vector<ll> x2(x), y2(y);
    map<ll, int> mx, my;
    compress(x, mx);
    compress(y, my);
    for (int i = 0; i < N; i++) {
        sum[mx[x2[i]] + 1][my[y2[i]] + 1]++;
    }
    int n = x.size(), m = y.size();
    for (int i = 0; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            sum[i][j] += sum[i][j - 1];
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            sum[i][j] += sum[i - 1][j];
        }
    }

    ll ans = 8000000000000000011LL;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            for (int k = i; k < n; k++) {
                for (int l = j; l < m; l++) {
                    int hoge = sum[k + 1][l + 1] - sum[k + 1][j] - sum[i][l + 1] + sum[i][j];
                    if (hoge < K) continue;
                    ans = min(ans,max(x[k]-x[i], 1LL)*max(y[l]-y[j], 1LL));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<int> > happiness(n, vector<int>(3));
    for (int i = 0; i < n; i++) {
      cin >> happiness[i][0];
      cin >> happiness[i][1];
      cin >> happiness[i][2];
    }

    for (int i = 1; i < n; i++) {
        happiness[i][0] += max(happiness[i-1][1], happiness[i-1][2]);
        happiness[i][1] += max(happiness[i-1][0], happiness[i-1][2]);
        happiness[i][2] += max(happiness[i-1][0], happiness[i-1][1]);
    }
    cout << *max_element(&happiness[n-1][0], &happiness[n-1][0] + 3) << endl;
    return 0;
}


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

struct dat {
  int d;
  vector<int> c;
  vector<vector<int>> s;
};

int calc(const dat &a, const vector<int> &last, int day, int t) {
  int v = 0;
  v += a.s.at(day - 1).at(t);
  for (int i = 0; i < 26; i++) {
    if (i == t) continue;
    v -= a.c.at(i) * (day - last.at(i));
  }
  return v;
}

int main() {
  int d;
  cin >> d;
  vector<int> c(26);
  vector<vector<int>> s(d, vector<int>(26));
  for (int i = 0; i < 26; i++) {
    cin >> c.at(i);
  }
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s.at(i).at(j);
    }
  }
  dat a = {d, c, s};
  
  vector<int> last(26);
  vector<vector<int>> ans(5);
  for (int i = 0; i < a.d; i++) {
    int vmax = -1e9, tmax = 0;
    for (int t = 0; t < 26; t++) {
      int v = calc(a, last, i + 1, t);
      if (v > vmax) {
        vmax = v;
        tmax = t;
      }
    }
    last.at(tmax) = i + 1;
    cout << tmax + 1 << endl;
  }
}


Measured memory_bytes: 3724
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>

using namespace std;
typedef long long int ll;


bool sort2(const pair<int, int> &a, const pair<int, int> &b)
{
    return a.first > b.first;
}

bool sort1(const pair<int, int> &a, const pair<int, int> &b)
{
    return a.second < b.second;
}
// use case
//sort(V.begin(), V.end(), compare_function);

void print(vector <pair <int,int>> M)
{
    cout<<"Pradedam"<<endl;
    for (int i=0; i<M.size(); i++)
    {
        cout<<i<<" "<<M[i].first<<" "<<M[i].second<<endl;
    }
    cout<<endl;
}

void solve (int n, vector <string> &S)
{
    vector <pair <int,int>> O;
    vector <pair <int,int>> C;
    for (int i=0; i<n; i++)
    {
        int o=0;
        int c=0;
        string s=S[i];
        for (int j=0; j<s.length(); j++)
        {
            if (s[j]=='(')
            {
                o++;
            }
            else
            {
                if (o>0)
                {
                    o--;
                }
                else
                {
                    c++;
                }
            }
        }
        if (o>c)
        {
            //cout<<"O "<<i<<" "<<o<<" "<<c<<endl;
            O.push_back({o,c});
        }
        else
        {
            //cout<<"C "<<i<<" "<<o<<" "<<c<<endl;
            C.push_back({o,c});
        }
    }
    int ats=0;
    //print(O);
    //print(C);
    sort(O.begin(),O.end(),sort1);
    sort(C.begin(),C.end(),sort2);
    //print(O);
    //print(C);
    for (int i=0; i<O.size(); i++)
    {
        if (ats<O[i].second)
        {
            cout<<"No"<<endl;
            return;
        }
        ats=ats+O[i].first-O[i].second;
        //cout<<ats<<endl;
    }
    for (int i=0; i<C.size(); i++)
    {
        if (ats<C[i].second)
        {
            cout<<"No"<<endl;
            return;
        }
        ats=ats+C[i].first-C[i].second;
        //cout<<ats<<endl;
    }
    if (ats!=0)
    {
        cout<<"No"<<endl;
        return;
    }
    cout<<"Yes"<<endl;
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector <string> S(n,"00");
    for (int i=0; i<n; i++)
    {
        cin>>S[i];
    }
    solve(n,S);
    return 0;
}


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

int main(){
	int n;
	scanf("%d", &n);
	vector<bitset<20> > bit((1 << n), bitset<20>(0));
	for(int i = 0; i < (1 << n); i++) {
		printf("%d:", i);
		for(int j = 0; j < n; j++) {
			if(i & (1 << j))
				printf(" %d", j);
		}
		printf("\n");
	}
}



Measured memory_bytes: 4852
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

Int digits(Int n) {
    return (Int)to_string(n).size();
}

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

    Int n, k;
    cin >> n >> k;
    vector<pair<Int, Int>> ab(n);
    for (Int i = 0; i < n; i++) {
        cin >> ab[i].first >> ab[i].second;
    }

    sort(ab.begin(), ab.end());
    Int ans = 0, cnt = 0;
    for (Int i = 0; i < n; i++) {
        cnt += ab[i].second;
        if (k <= cnt) {
            ans = ab[i].first;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll scan(){ll tmp;cin>>tmp;return tmp;}

int main(){
	cout << "ABC" << scan() << endl;
}

Measured memory_bytes: 3612