akhauriyash/Code-Regression huggingface dataset:
n, p = map(int,input().split())

# https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8
# 素因数分解
"""
>>> factorization(16)
[[2, 4]]
>>> factorization(48)
[[2, 4], [3, 1]]
"""

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr
l = factorization(p)
res = 1
for num,cnt in l:
    if cnt >=n:
        cnt = cnt // n
        res *= num ** cnt
print(res)

Measured memory_bytes: 38512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#define FAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
const int maxn = (int)1e6 + 5;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 9;
using namespace std;

ll x[maxn];
int v[maxn];
ll cc[maxn], c[maxn];
ll cmax[maxn], ccmax[maxn];

int main()
{
	int n; ll C;
	scanf("%d %lld", &n, &C);
	for(int i = 1; i <= n; i++){
		scanf("%lld %d", &x[i], &v[i]);
		c[i] = c[i-1] + v[i] - (x[i] - x[i-1]);
		cmax[i] = max(cmax[i-1], c[i]);
	}
	x[n+1] = C;
	for(int i = n; i >= 1; i--){
		cc[n-i+1] = cc[n-i] + v[i] - (x[i+1] - x[i]);
		ccmax[n-i+1] = max(ccmax[n-i], cc[n-i+1]);
	}
	ll ans = 0;
	for(int i = 0; i <= n; i++){
		ans = max(ans, c[i] - x[i] + ccmax[n-i]);
		ans = max(ans, cc[i] - (C - x[n-i+1]) + cmax[n-i]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 15360
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
#define fi first
#define se second
int main()
{
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int min = (h2-h1-1)*60 + m2 + 60-m1;
    cout<<min-k;
}   


Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, combinations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from operator import itemgetter
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

def main():
    S=ii()
    if S<=2:
        print(0)
        return
    a = deque()
    an = deque()
    for _ in range(3, S+1):
        a.append(1)
    ans = 0
    try:
        while True:
            ans += a.pop()
            a.pop()
            a.pop()
            an.append(a.popleft())
            while a:
                an.append(an[-1] + a.popleft())
            a, an = an, a
            an.clear()
    except:
        pass

    print(ans % N1097)






main()



Measured memory_bytes: 9936
N = int(input())
t = [0 for i in range(N + 1)]
x = [0 for i in range(N + 1)]
y = [0 for i in range(N + 1)]
for i in range(N):
    t[i + 1], x[i + 1], y[i + 1] = map(int, input().split())
flag = 1
for i in range(N):
    dl = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    dt = t[i + 1] - t[i]
    if dl > dt or (dl - dt) % 2 == 1:
        flag = 0
        break
if flag == 1:
    print("Yes")
else:
    print("No")


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

int main(int argc, char const *argv[]) {
    int H,W;
    std::cin >> H >> W;

    std::vector<char> words;
    for(int height = 0 ; height < H ; height++)
    {
        for(int width = 0 ; width < W ; width++ )
        {
            char word;
            std::cin >> word;
            words.push_back(word);
        }
    }

    for(int width = 0 ; width < W + 2 ; width++ )
    {
        std::cout << "#";
    }
    putchar('\n');

    for(int height = 0 ; height < H ; height++)
    {
        std::cout << "#";
        for(int width = 0 ; width < W ; width++ )
        {
            std::cout << words[W*height+width];
        }
        std::cout << "#" << '\n';
    }

    for(int width = 0 ; width < W + 2 ; width++ )
    {
        std::cout << "#";
    }
    putchar('\n');
    return 0;
}


Measured memory_bytes: 888
k=int(input())
num=[]

def d(n):
  num.append(n)
  if n > 3234570000:
    return
  a=n%10
  if a==0:
    l=[0,1]
  elif a==9:
    l=[8,9]
  else:
    l=[a-1,a,a+1]
  for i in l:
    s=int(str(n)+str(i))
    d(s)

for i in range(1,10):
  d(i)

num.sort()
print(num[k-1])

Measured memory_bytes: 15744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int A, B;
    cin >> A >> B;
    if(B%A == 0) cout << B+A;
    else cout << B-A;
}

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

#define vi vector<int>
#define vl vector<long long>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define INFTY 1e9
#define MOD 1e9+7
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

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

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

struct edge {int to, cost;};
vector< vector<edge> > es;
const int MAX_N = 10010;

int main() {
    int n;
    cin >> n;
    vi p, q;
    p.resize(n);
    q.resize(n);
    REP(i, n) cin >> p[i], --p[i];
    REP(i, n) cin >> q[i], --q[i];
    map<vi, int> ord;
    int iter = 0;
    vi v(n);
    REP(i, n) v[i] = i;

    do {
        ord[v] = iter++;
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(ord[p]-ord[q]) << endl;
    return 0;
}

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

using namespace std;

int const N = 5e5+10;

int n;
map<vector<int > ,int > fr;
long long an = 0;
int main() {
    cin>>n;
    string s;
    for(int i=0;i<n;i++){
        cin>>s;
        vector<int > f(26,0);
        for(int j=0;j<s.size();j++)
            f[s[j]-'a']++;
        an+=fr[f];
        fr[f]++;
    }
    cout<<an<<endl;
    return 0;
}






Measured memory_bytes: 18944
# D - Floor Function

a, b, n = map(int, input().split())

# max(floor(a * x / b) - a * floor(x / b) for 0 <= x <= n)
# x = k * b のとき, 第1項 == 第2項
# k * b <= x < (k+1) * b のとき, 第1項は単調増加, 第2項は一定

x = min(n, b - 1)
print(a * x // b - a * (x // b))


Measured memory_bytes: 9156
#include <iostream>
#include <algorithm>
#include <cmath>

int n, k, h[100005];
long long dp[100005];
int main() {
	std::cin >> n >> k;
	for (int i = 0; i < n; ++i)
		std::cin >> h[i];

	for (int i = 0; i < n - 1; ++i) {
		long long in = 100000000000;
		for (int j = 0; j < k && i >= j; ++j)
			in = std::min(in, dp[i - j] + std::abs(h[i + 1] - h[i - j]));
		dp[i + 1] = in;
	}
	std::cout << dp[n - 1] << std::endl;
	return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using ll = long long int;
using P = std::pair<int, int>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int dv[100100];
bool pu[100100];
std::vector<int> g[100100];

int solve(int v, int p = -1){
	int i,u,cnt=0,ret=0,tmp;
	if(pu[v]){
		++cnt;
	}
	for(i=(g[v].l_ength()-1); i>=0; --i){
		u = g[v][i];
		if(u == p){
			continue;
		}
		pu[u] = (pu[v]|(dv[v]>1));
		tmp = solve(u,v);
		ret += tmp;
		if(tmp){
			++cnt;
		}
	}
	if(dv[v]==1){
		return ret;
	}
	if(cnt<dv[v]){
		ret += (dv[v]-cnt);
	}
	return ret;
}

int main(void){
	int n,i,a,b;
	P dvm = P(-INF,n);
	std::cin >> n;
	for(i=1; i<n; ++i){
		std::cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
		++dv[a]; ++dv[b];
	}
	for(i=0; i<n; ++i){
		--dv[i];
		dvm = std::max(dvm,P(dv[i],i));
	}
	if(dvm.first<2){
		std::cout << 1 << std::endl;
		return 0;
	}
	std::cout << solve(dvm.second) << std::endl;

	return 0;
}


Measured memory_bytes: 12032
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,d;
  cin>>n>>d;
  int ans=0;
  ll x,y;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    if(x*x + y*y <= d*d) ans++;
  }
  cout << ans<<endl;

  return 0;
}


Measured memory_bytes: 3196
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

#define MAX 100
#define NIL -1

static char M[MAX][MAX];
static int color[MAX][MAX];
int W, H;

//int dh[4] = { 0,1,0,-1 };
//int dw[4] = { 1,0,-1,0 };

void dfs(int h, int w, int c, char k) {
	color[h][w] = c;
	//for (int i = 0; i < 4; i++) {
	//	int _h = h + dh[i],
	//		_w = w + dw[i];
	//	if (_h < H - 1 && _h > 0 && _w < W - 1 && _w > 0) {
	//		if (M[_h][_w] == k&&color[_h][_w] == NIL)
	//			dfs(_h, _w, c, k);
	//	}
	//}
	if (h != H - 1 && M[h + 1][w] == k&&color[h + 1][w] == NIL)
		dfs(h + 1, w, c, k);
	if (h != 0 && M[h - 1][w] == k&&color[h - 1][w] == NIL)
		dfs(h - 1, w, c, k);
	if (w != W - 1 && M[h][w + 1] == k&&color[h][w + 1] == NIL)
		dfs(h, w + 1, c, k);
	if (w != 0 && M[h][w - 1] == k&&color[h][w - 1] == NIL)
		dfs(h, w - 1, c, k);
}

int main() {
	while (cin >> H >> W&&W&&H) {
		for (int h = 0; h < H; h++) {
			for (int w = 0; w < W; w++) {
				cin >> M[h][w];
			}
		}
		fill(color[0], color[MAX], NIL);
		int c = 0;
		for (int h = 0; h < H; h++) {
			for (int w = 0; w < W; w++) {
				if (color[h][w] == NIL) { dfs(h, w, c++, M[h][w]); }
			}
		}
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 1832
import unittest
from io import StringIO
import sys


def resolve():
    n, m, x = [int(i) for i in input().split()]
    cc = []
    aa = []
    for comb in range(n):
        c, *a = [int(comb) for comb in input().split()]
        cc.append(c)
        aa.append(a)

    ans = float('inf')
    for comb in range(2**n):
        sum = 0
        xx = [0] * m
        for i in range(n):
            if (comb >> i) & 1:
                sum += cc[i]
                for j in range(m):
                    xx[j] += aa[i][j]
        for tx in xx:
            if tx < x:
                break
        else:
            ans = min(ans, sum)

    if ans == float('inf'):
        print(-1)
    else:
        print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 3 10
60 2 2 4
70 8 7 9
50 2 3 9"""
        output = """120"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 3 10
100 3 1 4
100 1 5 9
100 2 6 5"""
        output = """-1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """8 5 22
100 3 7 5 3 1
164 4 5 2 7 8
334 7 2 7 2 9
234 4 7 2 8 2
541 5 4 3 3 6
235 4 8 6 9 7
394 3 6 1 6 2
872 8 4 3 7 2"""
        output = """1067"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16284
import sys
import math
from bisect import bisect_left
def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
def bs(a,n,x): 
    i = bisect_left(a, x) 
    if i<n and a[i] == x:
    	return i
    elif i:
    	return (i-1) 
    else: 
        return -1
n,m,k = MI()
a = LI()
b = LI()
for i in range(1,n):
	a[i]+=a[i-1]
for i in range(1,m):
	b[i]+=b[i-1]
ans = max(bs(a,n,k),bs(b,m,k))+1
for i in range(n):
	if k<a[i]:
		break
	else:
		temp = i+1+bs(b,m,k-a[i])+1
		ans = max(ans,temp)
for i in range(m):
	if k<b[i]:
		break
	else:
		temp = i+1+bs(a,n,k-b[i])+1
		ans = max(ans,temp)
print(ans)



Measured memory_bytes: 111848
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

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

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

int n;
pair<int, int> lr[500000];

bool comp(pii a, pii b)
{
    return a.se < b.se;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        lr[i] = {x - y, x + y};
    }
    sort(lr, lr + n, comp);
    int aa = -1000000001, ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (lr[i].fi >= aa)
        {
            aa = lr[i].se;
            ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 1792
#include<stdio.h>
#define N 100
int main (){
  int flag,i,j,A[N],count=0,n,x;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
    
  
  flag = 1;
  i = 0;
  
  while(flag!=0){
    flag=0;

  
    for(j=n-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	x=A[j];
	A[j]=A[j-1];
	A[j-1]=x;
	flag=1;
	count++;
      }
    }
    i++;
  }
  for(i=0;i<n;i++){
    if(i==n-1)printf("%d\n",A[i]);
    else printf("%d ",A[i]);
  }
  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 600
import std.stdio, std.string, std.conv;
import std.algorithm;

void main()
{
    for(string t; (t=readln().chomp()).length;)
    {
        immutable N = t.length;
        auto a = new int[26][N+1];
        int s=-1, e=-1;
        void solve()
        {
            foreach(int i,c;t)
            {
                immutable int n = c-'a';
                a[i+1]=a[i];
                a[i+1][n]++;
                foreach(int j;max(0,i-2)..i) if(a[i+1][n]-a[j][n]>(i+1-j)/2)
                {
                    s=j+1;
                    e=i+1;
                    return;
                }
            }
        }
        solve();
        writeln(s,' ',e);
    }
}

Measured memory_bytes: 10520
function main()
	N,K=map(x->parse(Int,x),split(readline()))
	A=map(x->parse(Int,x),split(readline()))
	D=Dict{Int,Int}()
	D[0]=1
	X=[0]
	now=0
	ans=0
	for a=A
		now=(now+a-1)%K
		push!(X,now)
		if length(X)>K
			D[shift!(X)]-=1
		end
		u=get(D,now,0)
		ans+=u
		D[now]=u+1
	end
	println(ans)
end
main()


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

using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(c-a)<=d)cout<<"Yes";
    else
    {
        if(abs(b-a)<=d&&abs(c-b)<=d)cout<<"Yes";
        else cout<<"No";
    }
    return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  vpll xy(n);
  vll xs(n), ys(n);
  rep(i,n){
    ll x,y; cin>>x>>y;
    xy[i]={x,y};
    xs[i]=x, ys[i]=y;
  }
  vsort(xs);
  vsort(ys);
  
  ll ans=5*LINF;
  rep(i,n){
    irep(j,i+1,n){
      rep(k,n){
        irep(l,k+1,n){
          ll cnt=0;
          rep(ki,n){
            ll x=xy[ki].first, y=xy[ki].second;
            if(xs[i]<=x&&x<=xs[j] && ys[k]<=y&&y<=ys[l]) cnt++;
          }
          if(cnt>=m){
            ll s=(xs[j]-xs[i])*(ys[l]-ys[k]);
            if(chmin(ans,s)){
              // cout<<xs[i] <<" "<<xs[j] <<" "<< ys[k] <<" "<< ys[l] <<endl;
            }
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x=sc.nextLong();
		long y=100;
		long cnt = 0;
		for(int i=0;i<2;) {
			cnt+=1;
			y=(long) (y*1.01);
			if(y>=x) {
				break;
			}
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 35744
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC120_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = ABK[0];
            var B = ABK[1];
            var K = ABK[2];

            var cd = new List<int>();
            for (int i = 1; i <= 100; i++)
            {
                if (A % i == 0 && B % i == 0)
                {
                    cd.Add(i);
                }
            }

            cd = cd.OrderByDescending(x => x).ToList();

            Console.WriteLine(cd[K - 1]);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

void INX(){}
template<typename Head, typename... Tail>
void INX(Head&& head, Tail&&... tail)
{
    cin >> head;
    INX(forward<Tail>(tail)...);
}
void OUTX(){}
template<typename Head, typename... Tail>
void OUTX(Head&& head, Tail&&... tail)
{
    cout << head << endl;
    OUTX(forward<Tail>(tail)...);
}

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>


int main()
{
    ll x;
    INX(x);
    OUTX(1 - x);

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Yes() std::cout << "Yes" << std::endl
#define No() std::cout << "No" << std::endl
#define Say(s) std::cout << s << std::endl
const ll MOD = 1000000007;
const ll INF = 1061109567;

int main()
{
    ll n, m;
    std::vector<std::array<ll, 2>> k;
    std::cin >> n >> m;
    rep(i, m)
    {
        ll temp_1, temp_2;
        std::cin >> temp_1 >> temp_2;
        --temp_1;
        --temp_2;
        k.push_back({temp_1, temp_2});
    }
    // そもそもdfsは適用範囲が広く,これは単純なグラフの時にしか使えない
    using Graph = std::vector<std::vector<ll>>;
    auto make_graph = [&](const ll& num_points, const ll& num_sides, const auto& side_pairs) {
        //libproton 1.1.0
        //num_pointsは頂点数,num_sidesは辺数,side_pairsはvector::vector<ll>に相当するものを入力してください。
        //ただし二つ目のvectorは二つの要素しかないことを想定している
        //グラフ型(G[index]に頂点indexから直接行ける点の列挙が入っている)を返す
        //graphのiteratorが1次元の時しか対応していない
        Graph G(num_points);
        for (ll i = 0; i < num_sides; ++i) {
            G[side_pairs.at(i).at(0)].push_back(side_pairs.at(i).at(1));
            G[side_pairs.at(i).at(1)].push_back(side_pairs.at(i).at(0));
        }
        return G;
    };
    ll temp_temp = 0;
    std::vector<bool> graph_seen(n, false);  //100には頂点数を入れる。下のdfsは再帰なので外でdfsを定義する必要あり。
    std::function<void(const Graph&, const ll&, std::vector<bool>&)> dfs_mono = [&](const Graph& dfs_G, const ll& start_point, std::vector<bool>& dfs_seen) {
        //libproton 1.1.0
        //graphのiteratorが1次元の時しか対応していない
        //dfs_GにはGraph型を, start_pointには探索開始点を, dfs_seenには頂点数の大きさを持った全false配列を入れてください。
        //返す値はない。dfs_seenが訪問済みでtrueに切り替わっているはず。やりたい動作は使用時にこのなかに追記してください。
        dfs_seen[start_point] = true;  // start_point を訪問済にする
        ++temp_temp;
        // この部分にやりたい動作を書くと良い

        // start_point から行ける各頂点 next_v について
        for (auto next_v : dfs_G[start_point]) {
            if (dfs_seen[next_v])
                continue;  // next_v が探索済だったらスルー

            // この部分にやりたい動作を書くと良い

            dfs_mono(dfs_G, next_v, dfs_seen);  // 再帰的に探索
        }
        return 0;
    };
    Graph friend_graph = make_graph(n, k.size(), k);
    std::vector<ll> number_menber;
    for (ll i = 0; i < n; ++i) {
        temp_temp = 0;
        if (graph_seen[i] == false) {
            dfs_mono(friend_graph, i, graph_seen);
            number_menber.push_back(temp_temp);
        }
    }
    std::sort(number_menber.begin(), number_menber.end());
    Say(number_menber[number_menber.size() - 1]);
    return 0;
}

Measured memory_bytes: 32784
#include <bits/stdc++.h>
#define maxn 100101
#define ll long long
int n,l[maxn],r[maxn];ll ans;
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;for (int i=1;i<=n;i++)
	cin>>l[i]>>r[i];
	sort(l,l+1+n);sort(r,r+1+n);
	for (int i=0;i<=n;i++)
	ans+=max(0,l[n-i]-r[i]);
	cout<<ans*2<<endl;return 0;
}

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

int main(){
    string S;
    cin >> S;
    int N = S.length();

    int O[N];
    int last_R=0, od_cnt=0, ev_cnt=0;
    int ido, ide;
    for( int n=0; n < N ; n++ ){
        O[n] = 0;
        if( (n+1)%2 == 0 ){
            ev_cnt++;
        }else{
            od_cnt++;
        }
        //
        if( S[n]=='L' ){
            ido = (last_R+1)/2*2;
            ide = last_R/2 * 2 + 1;
            O[ido] += od_cnt;
            O[ide] += ev_cnt;
            od_cnt = 0;
            ev_cnt = 0;
        }else{
            last_R = n;
        }
    }

    for( int n=0; n < N ; n++ ){
        printf("%d ", O[n]);
    }
    printf("\n");

} 

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
 
public class Main {
    static int n,a,b,c;
    static int[] arr;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        n = sc.nextInt();
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        arr = sc.nextIntArray(n);
        System.out.println(dfs(0,0,0,0));
    }
    
    public static int dfs(int now, int A, int B, int C){
        if(now == n){
            if(A > 0 && B > 0 && C > 0){
                return Math.abs(A-a)+Math.abs(B-b)+Math.abs(C-c)-30;
            }else{
                return (int)Math.pow(10,9);
            }
        }
        int ret = Integer.MAX_VALUE;
        ret = Math.min(ret,dfs(now+1,A,B,C));
        ret = Math.min(ret,dfs(now+1,A+arr[now],B,C)+10);
        ret = Math.min(ret,dfs(now+1,A,B+arr[now],C)+10);
        ret = Math.min(ret,dfs(now+1,A,B,C+arr[now])+10);
        return ret;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

using namespace std;
template <typename T> void print(T vec) {for(auto d: vec) cout<<d<<' ';cout<<'\n';}
template<typename T> void print2D(T mat) {for(auto vec:mat) print(vec);}




int main() {
    int n;
    cin>>n;
    vector<int> A(n + 1);
    for(int i = 1; i <= n;i++) cin>>A[i];
    vector<int> dp(n + 1, 0);
    dp[1] = 0;
    dp[2] = abs(A[2] - A[1]);
    for(int i = 3; i <= n; i++) {
         dp[i] = min(dp[i - 2] + abs(A[i] - A[i - 2]), dp[i - 1] + abs(A[i] - A[i - 1]));
    }
    // print(dp);
    cout<<dp[n]<<'\n';
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var K = int.Parse(Console.ReadLine());
            var X = int.Parse(Console.ReadLine());
            var Y = int.Parse(Console.ReadLine());
            Console.WriteLine(Math.Min(K,N) * X + Math.Max(0,(N - K) * Y));
        }
    }
}

Measured memory_bytes: 11092
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ind = 0
min_val = 10000000
for i in range(N):
	_ = abs(A - (T - H[i] * 0.006))
	if min_val > _:
		min_val = _
		ind = i + 1
print(ind)

	

Measured memory_bytes: 3060
import sys
import bisect


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    L = list(map(int, input().split()))

    L.sort()
    count = 0

    for j in range(1, N - 1):
        for i in range(j):
            if L[i] == L[j]:
                break
            a = bisect.bisect_right(L[j + 1:], L[j])
            b = bisect.bisect_left(L[j + 1:], L[i] + L[j])
            count += b - a

    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 73492
package main

import (
    "fmt"
    "math"
    "strconv"
)

func main() {
    var S string
    fmt.Scan(&S)
    n := len(S)

    var ans float64
    ans = 1e31
    for i := 0; i <= n - 3; i++ {
        x, _ := strconv.Atoi(S[i:i+3])
        ans = math.Min(ans, math.Abs(float64(x - 753)))
    }
    fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
const int inf = 1e9;

struct info{
	int v,s,d; //vertex, skip, distance;
	info(int v, int s, int d):v(v),s(s),d(d){}
	info(){}
	bool operator<(const info &a) const{
		return d > a.d;
	}
};

int main(){
	while(1){
		int n,m,c;
		cin >> n >> m >> c;
		if(n==0) break;
		
		vector<vector<info> > adj(n);
		for(int i=0; i<m; i++){
			int f,t,d;
			cin >> f >> t >> d;
			f--; t--;
			adj[f].push_back(info(t, 0, d));
		}
		
		priority_queue<info> wait;
		wait.push(info(0, 0, 0));
		vector<vector<int> > mincost(n, vector<int>(n, inf));
		mincost[0][0] = 0;
		while(!wait.empty()){
			int v = wait.top().v;
			int s = wait.top().s;
			int d = wait.top().d;
			wait.pop();
			if(d > mincost[v][s]) continue;
			for(int i=0; i<(int)adj[v].size(); i++){
				int nv = adj[v][i].v;
				int nd = adj[v][i].d;
				if(d+nd < mincost[nv][s]){
					mincost[nv][s] = d+nd;
					wait.push(info(nv, s, d+nd));
				}
				if(s+1<n && d < mincost[nv][s+1]){
					mincost[nv][s+1] = d;
					wait.push(info(nv, s+1, d));
				}
			}
		}
		int ans = inf;
		for(int i=0; i<n; i++){
			if(mincost[n-1][i] <= c){
				ans = min(ans, i);
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3392
#include<stdio.h>
int main(){
  char s[4];
  scanf("%s",s);
  if((s[0]-'a')+(s[1]-'a')+(s[2]-'a')==3 &&
     (s[0]-'a'+1)*(s[1]-'a'+1)*(s[2]-'a'+1)==6)
    printf("Yes");
  else
    printf("No");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  int n;
  stringstream ss;
  cin >> n;
  if(n < 1200) cout << "ABC" << endl;
  else if(n < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] R = new int[n];
		for (int i = 0; i < n; i++) {
			R[i] = sc.nextInt();
		}
		int maxProfit = -2000000000;
		int minProfit = R[0];
		for (int i = 1; i < n; i++) {
			maxProfit = Math.max(maxProfit, R[i] - minProfit);
			minProfit = Math.min(minProfit, R[i]);
		}
		System.out.println(maxProfit);
		sc.close();
	}
}



Measured memory_bytes: 101584
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
        template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
    };

    inp inp1; // input one
}

int main() {

    ll n, k;
    cin >> n >> k;
    vector<int> a = inp(n);

    // dp[i][j] := i番目の人を見たときに残りの飴がj個となる場合の数
    vector<vector<ll>> dp(n + 1, vector<ll>(k + 1, 0LL));

    dp[0][k] = 1;
    // 累積和
    vector<ll> sum(k + 2);
    rep(i, n) {
        rep(j, k + 2) sum[j] = 0LL;
        rep(j, k + 1) {
            sum[j + 1] = sum[j] + dp[i][j];
            sum[j + 1] %= mod;
        }
        //Cout(sum);
        rep(kj, k + 1) {
            dp[i + 1][kj] += (sum[min(k + 1, kj + a[i] + 1)] - sum[kj] + mod);
            dp[i + 1][kj] %= mod;
            //rep(j, a[i] + 1) {
            //    // j個使う
            //    if (kj + j <= k) {
            //        dp[i + 1][kj] += dp[i][kj + j];
            //        dp[i + 1][kj] %= mod;
            //    }
            //}
        }
    }

    Cout(dp[n][0]);

    return 0;
}


Measured memory_bytes: 80256
X,K,D = list(map(int , input().split()))
ans = 0
if (X >=0):
    a = K*D
    if (X >= a):
        ans = X-a
    else:
        time = 0
        while (True):
            X -= D
            time += 1
            if X <= 0:
                break
        nokori = (K - time) % 2
        ans = X + D*nokori
else:
    a = -(K*D)
    if (X <= a):
        ans = X-a
    else:
        time = 0
        while (True):
            X += D
            time += 1
            if X >= 0:
                break
        nokori = (K - time) % 2
        ans = X - D*nokori
Answ = abs(ans)
print(Answ)


Measured memory_bytes: 62684
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)

float calcDistance(int d, vector<int> y, vector<int> z){
    float sum = 0;
    rep(k, d)
        sum += pow(y.at(k) - z.at(k), 2);
    sum = sqrt(sum);
    return sum;
}
int main(){
    
    int n, d;
    cin >> n >> d;

    vector<vector<int>> x(n, vector<int>(d));

    rep(j ,n){
        rep(i, d){
            cin >> x.at(j).at(i);
        }
    }
cout << endl;
    int ansNum = 0;
    rep(j, n-1){
        for (int i = j+1; i < n; i++){
            float dist = calcDistance(d, x.at(j), x.at(i));
            if (dist == (int)dist){
                ansNum++;
            }
        
        }
    }
    cout << ansNum << endl;

    return 0;
}

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

int main() {

	int n;
	cin >> n;

	vector<int> vec(n);
	for (int i = 0; i < n; i++) {
		cin >> vec.at(i);
	}

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

	bool ans = true;
	for (int i = 0; i < n - 1; i++) {
		if (vec.at(i) == vec.at(i + 1)) {
			ans = false;
			break;
		}
	}

	if (ans) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

int main()
{
	set<long long> s;	
	long q;

	cin >> q;

	for (long i = 0; i < q; i++) {
		int t;
		long long x;
		cin >> t >> x;

		if (t == 0) {
			s.insert(x);
			cout << s.size() << endl;
		}
		else if (t == 1) {
			int f = 1;
			if (s.find(x) == s.end())
				f = 0;
			cout << f << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 12400
#include <cstdio>
    
int main(){
//int a,b;
//scanf("%d%d",&a,&b);
//printf("%d %d/n",a*b,a*2+b*2);

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

Measured memory_bytes: 1024
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:usize,
    b:usize,
    c:usize,
    }
    if a%2==1&&b%2==1&&c%2==1{println!("{}",min(min(a*b,b*c),a*c))}
    else {println!("0")}
}

Measured memory_bytes: 2100
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

bool match (char a, char b) {
    return (a == '?' || b == '?' || a == b);
}
int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b, c; cin >> a >> b >> c;
    int A = a.length(), B = b.length(), C = c.length();
    int m = 2000, M = 10000;

    vector<bool> match_ab(2 * M + 1), match_bc(2 * M + 1), match_ca(2 * M + 1);
    rep (i, A) {
        rep (j, B) {
            if (!(match(a[i], b[j]))) match_ab[i - j + M] = true;
        }
    }
    rep (i, B) {
        rep (j, C) {
            if (!(match(b[i], c[j]))) match_bc[i - j + M] = true;
        }
    }
    rep (i, C) {
        rep (j, A) {
            if (!(match(c[i], a[j]))) match_ca[i - j + M] = true;
        }
    }

    int ans = 3 * m;
    rep (i, -2 * m, 2 * m + 1) {
        rep (j, -2 * m, 2 * m + 1) {
            if (!match_ab[i + M] && !match_bc[-i + j + M] && !match_ca[-j + M]) {
                if (chmin(ans, max({A, i + B, j + C}) - min({0, i, j}))) eprintf("%d %d %d\n", ans, i, j);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
ceildiv x y = div (x + y - 1) y

main = do
    k <- readLn :: IO Int
    [a, b] <- map read . words <$> getLine :: IO [Int]
    let x0 = k * ceildiv a k
    let x1 = k * div b k
    putStrLn $ if x0 <= x1 then "OK" else "NG"


Measured memory_bytes: 3920
N = int(input())
a = [int(i) for i in input().split()]
b = [0]*N
ans = []
M = 0
for i in range(N-1,N//2-1,-1):
  if a[i] == 1:
    M += 1
    b[i] = 1
    ans.append(i+1)
for i in range(N//2-1,-1,-1):
  j = (i+1)*2
  tmp = 0
  while j <= N:
    tmp += b[j-1]
    j += i+1
  if tmp%2 != a[i]:
    b[i] = 1
    ans.append(i+1)
    M += 1
print(M)
print(" ".join(map(str,ans)))

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int N,P;

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

class BellmanFord{
	vector<ll> dist;
	set<ll> visit;
	bool ignore_unrelated_loop{false};

	bool CanReachImpl(int start,int end,ConnectNodeInfo& connect){
		bool reach=false;
		if(start==end) return true;

		for(int i=0,ei=connect[start].size();i<ei;i++){
			auto res = visit.emplace(connect[start][i].first);
			if(!res.second) continue;
			reach |= CanReachImpl(connect[start][i].first,end,connect);
		}
		return reach;
	}
	bool CanReach(int start,int end,ConnectNodeInfo& connect){
		visit.clear();
		visit.emplace(start);
		return CanReachImpl(start,end,connect);
	}
public:
	pair<ll,bool> CalcShortestPath(int start,int end,ConnectNodeInfo& connect){
		dist.resize(connect.size(),1LL<<60);

		dist[start] = 0;
		for(int i=0,ei=dist.size();i<ei;i++){
			for(int u=0,eu=connect.size();u<eu;u++){
				for(int v=0,ev=connect[u].size();v<ev;v++){
					auto& e = connect[u][v];

					if(dist[e.first]>dist[u]+e.second){
						dist[e.first] = dist[u]+e.second;
						if(i==ei-1){
							if(!ignore_unrelated_loop || (CanReach(start,u,connect) && CanReach(u,end,connect))){
								return make_pair(dist[end],false);
							}
						}
					}
				}
			}
		}
		return make_pair(dist[end],true);
	}
	void SetIgnoreUnrelatedLoop(bool flag){ignore_unrelated_loop=flag;}
};

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

	N=in();
	int M=in();
	P=in();
	ConnectNodeInfo connect(N);
	REP(i,M){
		int u=in()-1,v=in()-1,w=in();
		connect.AddDirectionalConnection(u,v,-(w-P));
	}

	BellmanFord BF;
	BF.SetIgnoreUnrelatedLoop(true);
	auto res = BF.CalcShortestPath(0,N-1,connect);

	out(res.second? max(0LL,-res.first) : -1);
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<string.h>
char s[200];
std::string str;
int n;
int main() {
	std::cin >> s;
	str = s;
	n = str.size();
	for(int i=n-2;i>=0;i-=2)
		if (strncmp(s, s + i / 2, i / 2) == 0) {
			std::cout << i << "\n";
			break;
		}
	system("pause");
	return 0;
}

Measured memory_bytes: 504
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
use std::collections::VecDeque;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(Usize1, Usize1); m],
    }

    let mut g = vec![vec![]; n];
    for (a, b) in ab {
        g[a].push(b);
        g[b].push(a);
    }

    let mut q: VecDeque<usize> = VecDeque::new();
    q.push_back(0);

    let mut ans = vec![n; n];
    while let Some(p) = q.pop_front() {
        for &c in g[p].iter() {
            if ans[c] != n {
                continue;
            }
            ans[c] = p;
            q.push_back(c);
        }
    }

    if ans.iter().any(|a| *a == n) {
        println!("{}", "No");
    } else {
        println!("{}", "Yes");
        for i in 1..n {
            println!("{}", ans[i] + 1);
        }
    }
}


Measured memory_bytes: 16068
// Problem : A - Move and Win
// Contest : AtCoder Grand Contest 020
// URL : https://atcoder.jp/contests/agc020/tasks/agc020_a
// Memory Limit : 512.000000 MB 
// Time Limit : 1000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp,x,y;
string str;
set<ll> s;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
   cin>>n;
   cin>>a>>b;
   if((b-a)%2==0)
   {
      cout<<"Alice";
   }
   else
   cout<<"Borys";
}

Measured memory_bytes: 256
/*

 Remember, Hope is a good thing... May be the best of things... and No Good thing ever Dies !!!

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cout.tie(0);
#define endl "\n"
#define MOD 1000000007
const ll inf=(1LL<<60)-1;
int dx[]= {-1,1,0,0};
int dy[]= {0,0,-1,1};
void solve()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
   ll r,D,x2000,x1,t;
   cin>>r>>D>>x2000;
   t=x2000;
   for(ll i=0;i<=9;i++)
   {
       x1=r*t-D;
       cout<<x1<<endl;
       t=x1;
   }

}
int main()
{
    IOS;
    //ll t;
    //cin>>t;
    //while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3616