akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// 最大公約数
ll GCD(ll a, ll b)
{
    if (a < 0)
        a = -a;
    if (b < 0)
        b = -b;
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

// 最小公倍数
ll LCM(ll a, ll b)
{
    ll g = GCD(a, b);
    return a / g * b;
}

int main()
{
    string in;
    cin >> in;
    int ret = 0;
    if (in == "SUN")
    {
        ret = 7;
    }
    if (in == "MON")
    {
        ret = 6;
    }
    if (in == "TUE")
    {
        ret = 5;
    }
    if (in == "WED")
    {
        ret = 4;
    }
    if (in == "THU")
    {
        ret = 3;
    }
    if (in == "FRI")
    {
        ret = 2;
    }
    if (in == "SAT")
    {
        ret = 1;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let mut a=(0..3).map(|_|read::<i32>()).collect::<Vec<i32>>();
    a.sort();
    println!("{}",a[2]-a[0])
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    string S; cin >> S;
    bool f = true;
    if(SZ(S) % 2 == 1){
        Out("No");
        return 0;
    }else{
        REP(i, SZ(S)){
            if(i % 2 == 0 && S[i] != 'h') f = false;
            if(i % 2 == 1 && S[i] != 'i') f = false;
        }
    }
    Ans(f, "Yes", "No");

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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 int MAX = 2100000;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

long long Perm(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[n-k] % MOD;
}

int main(){
  COMinit();
  ll n, m; cin >> n >> m;
  ll res = Perm(m, n) * Perm(m, n), extra = 0;
  for(int k=1; k<=n; k++){
    ll tmp = COM(n, k);
    tmp = tmp * Perm(m-k, n-k) % MOD;
    if(k&1)extra = (extra + tmp) % MOD;
    else extra = (extra + MOD - tmp) % MOD;
  }
  extra = extra * Perm(m, n) % MOD;
  res = (res + MOD - extra) % MOD;
  cout << res << ln;
}


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

int main() 
{ 
	long int n,a;
	cin>>n>>a;
	
	long long int sum  = 0;
	long long int dp[55][2507];
	memset(dp,0,sizeof dp);
	dp[0][0] = 1;
	int temp;
	
	for(int i=1;i<=n;i++){
			cin>>temp;
			for(int j=i;j>0;j--){
					for(int k=temp;k<=2500;k++){
							dp[j][k] += dp[j-1][k-temp];
					}
			}
	}
	
	for(int i=1;i<=n;i++)
		sum += dp[i][a*i];
		
	cout<<sum;
} 


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    vector<ll> digits;
    ll count = 0;
    ll base = 1;
    cin >> N;
    digits.resize(60);
    rep(i, N) {
        ll temp;
        cin >> temp;
        rep(j, 60) {
            if(temp & (1LL << j)) digits[j]++;
        }
    }
    rep(i, 60) (count += (digits[i] * (N - digits[i])) % MOD * base % MOD) %= MOD, (base *= 2) %= MOD;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list>
#include <unordered_set>

#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define _GLIBCXX_DEBUG
using namespace std;
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 long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<double, long long> pair_t;
bool PSecComp(const pair_t& a, const pair_t& b) {
	if (a.second == b.second)return  a.first > b.first;
	else {
		return a.second > b.second;
	}
}

int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll>a(n),b(m),c(m);
	rep(i, n)cin >> a[i];
	rep(i, m)cin >> b[i] >> c[i];
	priority_queue<pair<ll,ll>>pq;
	vector<pair<ll, ll>>aP, cbP;
	rep(i, n)aP.push_back(make_pair(a[i], 1));
	rep(i, m) {
		cbP.push_back(make_pair(c[i], b[i]));
	}
	rep(i, n)pq.push(aP[i]);
	rep(i, m)pq.push(cbP[i]);
	ll sum = 0,ans=0;
	while (sum < n) {
		ans += pq.top().first * min(pq.top().second,n-sum);
		sum += pq.top().second;
		pq.pop();
	}
	cout << ans << endl;
}


Measured memory_bytes: 11888
N = int(input())
num = []
import collections
for i in range(2,int(N**0.5)+1):
    while N%i==0:
        num.append(i)
        N //= i
if N != 1:
    num.append(N)
A = collections.Counter(num)
lis = []
num = 0
for i in range(1,10):
    num += i
    lis.append(num)
from bisect import bisect_left,bisect_right
ans = 0
num = 0
for v in A.values():
    num = bisect_right(lis,v)
    ans += num
print(ans)

Measured memory_bytes: 68324
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
 
using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
 

int main(){

    int n;
    string s,t;
    
    cin >> n;
    cin >> s >> t;
    
    string res;
    
    for(int i=0;i<n;i++){
        res = res + s[i] + t[i];
    }
    
    cout << res << endl;
    
} 
 
 
 

Measured memory_bytes: 256
#include<stdio.h>

int main(){
   int x,y,i,j;
   for(;;){
      scanf("%d %d",&y,&x);
      if(x+y==0) break;
      for(i=0;i<y;i++){
         for(j=0;j<x;j++)
            if(i*j==0 || i+1==y || j+1==x)
               printf("#");
            else
               printf(".");
         printf("\n");
      }
   printf("\n");
   }
   return 0;
}



Measured memory_bytes: 2032
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

const double PI = 2 * acos(0);

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<double, double> pdd;
typedef pair<double, pdd> pddd;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int n, m;
int dp[100005];

int main() {
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        dp[i] = i;
    }
    for(int a = 6; a <= n; a *= 6) {
        for(int i = 0; i + a <= n; i++) {
            dp[i+a] = min(dp[i+a], dp[i]+1);
        }
    }
    for(int a = 9; a <= n; a *= 9) {
        for(int i = 0; i + a <= n; i++) {
            dp[i+a] = min(dp[i+a], dp[i]+1);
        }
    }
    printf("%d\n", dp[n]);
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

int main(){
	int ans;
	string s;	 //a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
	int key[26] = {1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,1,1,1,1,2,1,1,1,2,1};
	while(1){
		cin >> s;
		if(s[0] == '#')break;
		int now = 0;
		ans = -1;
		for(int i =0; i < s.size();i++){
			if(key[(s[i]-'a')] != now){
				ans++;
				now = key[(s[i]-'a')];
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1180
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,m;
    cin>>n>>m;
    int day,money;
    //小さい順に出てくる
    priority_queue<P, vector<P>, greater<P>> que;
    
    rep(i,n){
        cin>>day>>money;
        que.emplace(day,money);
    }

    priority_queue<int> able;

    int sum=0;
    REP(i,1,m+1){
        while(!que.empty()){
            tie(day,money)=que.top();
            if(day>i) break;
            que.pop();
            able.emplace(money);
        }
        if(able.empty()) continue;
        sum += able.top();
        able.pop();
    }
    cout<<sum<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 4640
import queue

def bfs(start):
  d_mat = [[-1]*(w+2) for i in range(h+2)]
  q.put(start)
  d_mat[start[0]][start[1]] = 0
  while not q.empty():
    x, y = q.get()
    d = d_mat[x][y]
    if mat[x-1][y] == "." and d_mat[x-1][y] == -1:
      d_mat[x-1][y] = d+1
      q.put((x-1, y))
    
    if mat[x+1][y] == "." and d_mat[x+1][y] == -1:
      d_mat[x+1][y] = d+1
      q.put((x+1, y))
    
    if mat[x][y-1] == "." and d_mat[x][y-1] == -1:
      d_mat[x][y-1] = d+1
      q.put((x, y-1))
    
    if mat[x][y+1] == "." and d_mat[x][y+1] == -1:
      d_mat[x][y+1] = d+1
      q.put((x, y+1))
  return d_mat[x][y]
h, w = map(int, input().split())
mat = ["#"*(w+2)]
for y in range(h):
  mat.append("#"+input()+"#")
mat.append("#"*(w+2))

d_mat1 = [[-1]*(w+2) for i in range(h+2)]
d_mat2 = [[-1]*(w+2) for i in range(h+2)]
q = queue.Queue()
start_list = []
flag = True
for x in range(1, w+1):
  if flag:
    for y in range(1, h+1):
      if mat[y][x] == ".":
        start = (y, x)
        start_list.append(start)
        
q.put(start)

while not q.empty():
  x, y = q.get()
  d = d_mat1[x][y]
  if mat[x-1][y] == "." and d_mat1[x-1][y] == -1:
    d_mat1[x-1][y] = d+1
    q.put((x-1, y))
    
  if mat[x+1][y] == "." and d_mat1[x+1][y] == -1:
    d_mat1[x+1][y] = d+1
    q.put((x+1, y))
    
  if mat[x][y-1] == "." and d_mat1[x][y-1] == -1:
    d_mat1[x][y-1] = d+1
    q.put((x, y-1))
    
  if mat[x][y+1] == "." and d_mat1[x][y+1] == -1:
    d_mat1[x][y+1] = d+1
    q.put((x, y+1))



print(max(list(map(bfs, start_list))))


Measured memory_bytes: 3944
import java.util.Scanner

object Main extends App {

    def input(i: Int): Unit = {
        if (i == 10) return
        mountains(i) = scanner.nextInt()
        input(i + 1)
    }

    def output(i: Int): Unit = {
        if (i == 3) return
        println(result(i))
        output(i + 1)
    }

    val scanner = new Scanner(System.in)
    val mountains = new Array[Int](10)
    input(0)
    val result = mountains.sortWith((a, b) => b < a)
    output(0)
}

Measured memory_bytes: 45128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

int n, m;
int q;
vector<int> edge[108000];
int query[11][108000];
int a, b, v, d;
int c[108000];

int main(){
  cin >> n >> m;
  for(int i = 0;i < m;i++){
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  cin >> q;
  for(int i = 1;i <= q;i++){
    cin >> v >> d >> c[i];
    query[d][v] = i;
  }
  for(int d = 10;d >= 1;d--){
    for(int i = 1;i <= n;i++){
      query[d-1][i] = max(query[d-1][i], query[d][i]);
      for(auto to:edge[i]){
	query[d-1][to] = max(query[d-1][to],query[d][i]);
      }
    }
  }
  for(int i = 1;i <= n;i++){
    cout << c[query[0][i]] << endl;
  }
  return 0;
}

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

using namespace std;
int N, M;
vector<int> g[10];
int used[10];

int rec(int i){

   int k=0;
   for(int i=0; i<N; i++) k+=used[i];
   if(k==N) return 1;

   int ret=0;
   for(int j: g[i]){
      if(used[j]) continue;
      used[j]=1;
      ret+=rec(j);
      used[j]=0;
   }

   return ret;
}

int main(){

   cin>> N>> M;
   for(int i=0; i<M; i++){
      int a, b;
      cin>> a>> b;
      a--; b--;
      g[a].push_back(b);
      g[b].push_back(a);
   }

   used[0]=1;
   cout<< rec(0)<< endl;

   return 0;
}


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

int main (){
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  
  int ans = 0;
  
  if(N > K){
  ans = K * X + (N - K) * Y;
  }
  else{
  ans = N * X;
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n, x;
        cin >> n >> x;
        ll g = 0;
        for(i = 0; i <n ;i++){
            ll xi;
            cin >> xi;
            xi = abs(x - xi);
            g = __gcd(g, xi);
        }
        cout << g;
    }
    return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




int main() {
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, pair<ll, ll>>> v;
    REP(i, m){
        ll p, y;
        cin >> p >> y;
        v.push_back({y, {p, i}});
    }
    sort(v.begin(), v.end());
    vector<ll> cnt(n + 1, 1);
    vector<pair<ll, ll>> ans(m);
    REP(i, m){
        ll p = v[i].second.first, idx = v[i].second.second;
        ans[idx].first = p;
        ans[idx].second = cnt[p];
        cnt[p]++;
    }
    REP(i, m){
        printf("%06lld%06lld\n", ans[i].first, ans[i].second);
    }
}

Measured memory_bytes: 6896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef double D;
typedef complex<D> P;
D pi=acos(-1);
P normize(P x){
	return x/abs(x);
}
int main(){
	while(true){
		int N;
		double R;
		cin>>N>>R;
		if(N==0) break;
		P r=P(R,0),l=P(-R,0);
		rep(i,N){
			D a,b,c;
			cin>>a>>b>>c;
			if(a==b){
				D len=a*c*pi/180;
				P x=normize((r-l)*P(0,1));
				r+=len*x,l+=len*x;
			}else{
				P x=(-b*l+a*r)/(a-b);
				D th;
				if(a!=0) th=abs(a)*c*pi/180/abs(l-x);
				else th=abs(b)*c*pi/180/abs(r-x);
				if(a>b) th=-th;
				l=(l-x)*polar(1.0,th)+x,r=(r-x)*polar(1.0,th)+x;
			}
		}
		P m=(l+r)/2.0;
		printf("%.5f\n%.5f\n",m.real(),m.imag());
	}
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*int find(int a){
     if(a==par[a])return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);
     if(a==b)return ;
     par[b]=a;
}
ll modexpo(ll a,ll b)
{
     int ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/











int n,k;
int x[60],y[60];
vector<pair<int,int>> vec;
int main(){
     cin>>n>>k;
     for(int i=0;i<n;i++){
          cin>>x[i]>>y[i];
     }
     for(int i=0;i<n;i++){
          for(int j=0;j<n;j++){
               vec.pb({x[i],y[j]});
          }
     }
     ll res=-1;
     for(int i=0;i<vec.size();i++){
          for(int j=i+1;j<vec.size();j++){
               int x1=min(vec[i].fi,vec[j].fi);
               int x2=max(vec[i].fi,vec[j].fi);
               int y1=min(vec[i].se,vec[j].se);
               int y2=max(vec[i].se,vec[j].se);
               int ct=0;
               for(int k=0;k<n;k++){
                    if(x1<=x[k]&&x[k]<=x2&&y1<=y[k]&&y[k]<=y2){
                         ct++;
                    }
               }
               if(ct>=k){
                    ll ar=1LL*abs(x2-x1)*abs(y2-y1);
                    if(res==-1)res=ar;
                    else res=min(res,ar);
               }
          }
     }
     cout<<res;
}



















































Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
int main() {
  int n,k;
  cin >> n >> k;
  vector<int>p(n,0);
  rep(i,k) {
    int d;
    cin >> d;
    vector<vector<int>> a(k, vector<int>(d));
    rep(j,d) {
      cin >> a[i][j];
      p[a[i][j]-1]++;
    }
  }
  int ans=0;
  rep(i,n) {
    if(p[i]==0) ans++; }
  cout << ans << endl;
  return 0;
}

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

const long long INF = (1 << 30);

int main(){
  int n, k;
  cin >> n >> k;
  
  long long h[100000];
  long long dp[100110];
  
  rep(i,n) cin >> h[i];
  rep(i,n) dp[i] = INF;
  
  dp[0] = 0;
  
  rep(i,n){
    for(int j = 1; j <= k; j++){
      dp[i+j] = min(dp[i] + abs(h[i] - h[i+j]), dp[i+j]);
    }
  }
  
  cout << dp[n-1] << endl;
  
  return 0;
}

Measured memory_bytes: 1792
fibonacci :: Int -> Int
fibonacci = fibo (1, 1) 2
    where
      fibo :: (Int, Int) -> Int -> Int -> Int
      fibo (pp, prev) pos n
          | n < 2 = 1
          | pos >= n = pp + prev
          | otherwise = fibo (prev, pp+prev) (pos+1) n

main :: IO ()
main = do
  n <- readLn
  putStrLn $ show $ fibonacci n

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

int main() {
  int x;
  while(cin >> x) {
    int ans= 0;
    for (int i=0; i<10; i++)
      for (int j=0; j<10; j++)
        for (int k=0; k<10; k++)
          for (int l=0; l<10; l++)
            if(i+j+k+l==x) ans++;
    cout << ans << endl;
  }
}



Measured memory_bytes: 3056
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    cout.precision(18);

    long long N;
    cin >> N;

    for (long long i = 0; i < INF; i++)
    {
        for (long long j = -1; j <= 1; j += 2)
        {
            long long t = N + j * (long long)pow(i, 5);
            long long a = pow((long double)t, (long double)0.2);
            if ((long long)pow(a, 5) - (long long)pow(j * i, 5) == N)
            {
                cout << a << ' ' << i * j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4104
#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define M 800050
#define file(x)freopen(x".in","r",stdin);freopen(x".out","w",stdout)
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    ll x=0;char zf=1;char ch=getchar();
    while(ch!='-'&&!isdigit(ch))ch=getchar();
    if(ch=='-')zf=-1,ch=getchar();
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();return x*zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int k,m,n,x,y,z,cnt,S,T;
int sum[M];
vector<int>s[100010];//数字i在哪些集合 
int F[M],N[M],a[M],c[M],dis[M],pre[M],num[M],fa[M],cur[M];
void add(int x,int y,int z){
	a[++k]=y;c[k]=z;
	N[k]=F[x];F[x]=k;
}
int q[200010],h,t;bool vis[200010];
bool bfs(){
	memset(dis,0,n*4+8);h=t=0;q[++t]=S;dis[S]=1;
	for(rt i=1;i<=n;i++)cur[i]=F[i];
	while(h<t){
		const int x=q[++h];
		for(rt i=F[x];i;i=N[i])if(!dis[a[i]]&&c[i])dis[a[i]]=dis[x]+1,q[++t]=a[i];
	}
	return dis[T];
}
int dfs(int x,int flow){
	if(x==T)return flow;int used=0;
	for(rt i=cur[x];i;i=cur[x]=N[i])if(c[i]&&dis[a[i]]==dis[x]+1){
		const int v=dfs(a[i],1);
		if(v)used++,c[i]--,c[i^1]++,pre[a[i]]=x; 
		if(flow==used||dis[S]>=n)return used;
	}
	return used;
}

void print(int x,int y){
	write(x),putchar(' ');writeln(y);
}
int main(){
	n=r;k=1;
	for(rt i=1;i<n;i++){
		sum[i]=r;
		for(rt j=1;j<=sum[i];j++){
			x=r;s[x].push_back(i);
			if(x>1)add(i,n-1+x-1,1),add(n-1+x-1,i,0);
		}
	}
	S=n*2-1,T=n*2;
	for(rt i=1;i<n;i++)add(S,i,1),add(i,S,0);
	for(rt i=n;i<=n*2-2;i++)add(i,T,1),add(T,i,0);
	n<<=1;int ans=0;
	while(bfs())ans+=dfs(S,1000000000);
	if(ans+1<n/2)return puts("-1"),0;
	n>>=1;h=t=0;
	for(rt i=n;i<=n*2-2;i++)num[pre[i]]=i-n+2;q[t=1]=1;
	while(h<t){
		x=q[++h];
		for(auto i:s[x])if(!vis[num[i]])vis[num[i]]=1,fa[num[i]]=x,q[++t]=num[i];
	}
	for(rt i=1;i<n;i++)if(!fa[num[i]])return puts("-1"),0;
	for(rt i=1;i<n;i++)print(fa[num[i]],num[i]);
	return 0;
}

Measured memory_bytes: 31744
#include <iostream>

int main() {

	int a, b, c, temp;

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



	if (c < b) {
		temp = b;
		b = c;
		c = temp;
	}

	if (b < a) {
		temp = a;
		a = b;
		b = temp;
	}

	if (c < b) {
		temp = b;
		b = c;
		c = temp;
	}

	std::cout << a << " "<< b << " "<< c << std::endl;
	
	return 0;


}


Measured memory_bytes: 3068
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] a = new int[300];
		int[] b = new int[300];
		Arrays.fill(a, 1);
		for(int i=2;i<=17;i++){
			for(int j=1;;j++){
				if(i*i*j>=300) break;
				for(int k=0;i*i*j+k<300;k++){
					b[i*i*j+k] += a[k];
				}
			}
			for(int j=0;j<300;j++) a[j] += b[j];
			Arrays.fill(b, 0);
		}
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			System.out.println(a[n]);
		}	
	}	
}

Measured memory_bytes: 16596
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
///////////////////////////////////////

int main() {
	int N;
	cin >> N;
	vector<int>A(N), B(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i] >> B[i];
	}
	vector<ll>sum;
	sum.push_back(0);
	for (int i = N - 1; i >= 0; --i) {
		int key1 = (A[i]+sum.back()) / B[i];
		int x;
		if ((A[i]+sum.back()) % B[i] == 0) {
			x = 0;
		}
		else {
			x = (1 + key1)*B[i] - (A[i]+sum.back());
		}
		sum.push_back(sum.back() + x);
	}
	cout << sum.back() << endl;
	return 0;
}


Measured memory_bytes: 2168
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let x = v[0];
	let a = v[1];
	let b = v[2];
	if (a-x).abs() < (b-x).abs() {
		println!("A");
	}else{
		println!("B");
	}
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << "\n"
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  string s;
  cin >> s;
  int n = len(s);
  rep(i, n) {
    repp(j, i + 1, n - 1) {
      if (s[i] == 'C' && s[j] == 'F') {
        cout << "Yes\n";
        return 0;
      }
    }
  }
  cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort(ALL(c))
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


int main() {
	VI X(5);
	LL last = 0, last_wait = 0;
	REP(i, 5) {
		cin >> X[i];
		LL wait = (10 - (X[i] % 10)) % 10;
		if (wait > last_wait) {
			last = i;
			last_wait = wait;
		}
	}
	LL ans = 0;
	REP(i, 5) {
		if (i == last) {
			ans += X[i];
		} else {
			ans += (X[i] / 10) * 10;
			if (X[i] % 10 != 0) {
				ans += 10;
			}
		}
	}
	cout << ans << endl;
	
    return 0;
}


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

int main() {

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

    bool ans = false;
    for (int i = 0; i<n;++i) {
        h -= a[i];
        if ( h <= 0 ) {
            ans = true;
            break;
        }
    }
    
    cout << (ans ? "Yes" :  "No") << endl;
}

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

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    rep(i, n){
        cnt += i+1;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{

    int n;  cin >> n;
    int numOdd = 0;
    int* arr = new int[n];
    for (int i = 0; i < n; i++){
        cin >> arr[i];
        if (arr[i] % 2 != 0 && i % 2 == 0){
            numOdd++;
        }
    }

    cout << numOdd << endl;

    return 0;
}


Measured memory_bytes: 3128
#define rep(i, m, n) for(int i = m; i < n; i++)
#define repM(i, m, n) for(int i = n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll; using namespace std;
//typedef pair<int,int> pii;
// d = distance(lower_bound(all(x)), upper_bound(all(x)));
int INF = 1e9;
int M = 1e9+7;
#include <iostream>
#include <vector>
//#include <cmath>
//#include <algorithm>
#include <queue>

int main(){
  int N; cin >> N; int A[N][N-1], p[N], pd[N];
  fill(p, p+N, 0); fill(pd, pd+N, 0);
  for(int i=0; i<N; i++) for(int j=0; j<N-1; j++) {cin >> A[i][j]; A[i][j]--;}

  queue<int> q;
  for(int i=0; i<N; i++) {
    q.push(i);
  }
  int d=1, er=0;
  for(d=1; d<=N*N && er!=N*(N-1); d++) {
    fill(pd, pd+N, 0);
    int l=q.size();
    for(int k=0; k<l; k++) {
      int j = q.front(); q.pop();
      if (p[j]==N-1) continue;
      int e = A[j][p[j]];
      if (p[e]==N-1) continue;
      int f = A[e][p[e]]; //me
      
      if (f == j && pd[e] == 0 && pd[j] == 0) {
        q.push(j); q.push(e);
        pd[j]=1; pd[e]=1;
        //cout << j <<" "<< e <<" "<<p[j]<<" "<<p[e]<<" "<<A[j][p[j]]<<" "<<A[e][p[e]] <<endl;
        p[j]++; p[e]++; er+=2;
      }
    }
    if (q.empty()) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << d-1 << endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

ll N, K, W, H, M;

int main() {
	cin >> N >> K;
	if(N >= 10) {
		cout << K;
	}
	else{
		cout << K +100*(10 -N);
	}
	return 0;
}

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int ans = min(B, D) - max(A, C);
    if (ans > 0){
        cout << ans << endl;
    } else {
        cout << '0' << endl;
    }
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main() {
    ll n,p;
    cin >>n>>p;
    map<ll,int>mp;
    for (ll i = 2; i*i<=p; ++i) {
        while(p%i==0){
            mp[i]++;
            p/=i;
        }
    }
    if(p!=1)mp[p]++;
    ll ans=1;
    for(auto u:mp){
        for (int i = 0; i < u.second / n; ++i) {
            ans*=u.first;
        }
    }
    cout <<ans <<endl;
    return 0;
}



Measured memory_bytes: 256
K=4000
R=range
y=min
l=len
A,B,C=[input()for i in R(3)]
def F(a,b):
 Q=[1]*(K*2+1)
 for i in R(-l(b),l(a)):
  for j in R(max(i,0),y(l(a),l(b)+i)):
   if l(set([a[j],b[j-i],'?']))>2:Q[i]=0
 return Q
S=F(A,B)
T=F(A,C)
U=F(B,C)
m=K*3
k=R(-K,K+1)
for p in k:
 if S[p]!=0:
  for q in k:
   if T[q]!=0 and U[q-p]!=0:m=y(m,max(p+l(B),q+l(C),l(A))-y(p,q,0))
print(m)

Measured memory_bytes: 52572
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

pint pillers[3010];
vint spa[5010];

int main() {
	int n;
	while(n=in()){
		memset(pillers,0,sizeof(pillers));
		int i,j;
		for(i=0;i<5010;i++)spa[i].clear();
		for(i=0;i<n;i++){
			cin>>pillers[i].first>>pillers[i].second;
			spa[pillers[i].first].push_back(pillers[i].second);
		}
		for(i=0;i<5010;i++)sort(spa[i].begin(),spa[i].end());
		int mx=0;
		for(i=0;i<n;i++){
			for(j=i+1;j<n;j++){
				if(i==j)continue;
				int x=pillers[i].first,y=pillers[i].second;
				int xx=pillers[j].first,yy=pillers[j].second;
				if(0<=x+(y-yy)&&x+(y-yy)<=5000&&
				0<=xx+(y-yy)&&xx+(y-yy)<=5000&&
				find(spa[x+(y-yy)].begin(),spa[x+(y-yy)].end(),y+(xx-x))!=spa[x+(y-yy)].end()&&
				find(spa[xx+(y-yy)].begin(),spa[xx+(y-yy)].end(),yy+(xx-x))!=spa[xx+(y-yy)].end()){
//cout<<i<<" "<<j<<endl;
					chmax(mx,(x-xx)*(x-xx)+(y-yy)*(y-yy));
				}
			}
		}
		cout<<mx<<endl;
	}
	return 0;
}

Measured memory_bytes: 1112
(N, M, K), As, Bs = readlines.map{_1.split.map(&:to_i)}

s = ->(a){a.each_with_object([0]){|e, o| o << o.last + e}.take_while{_1 <= K}}
as, bs = s[As], s[Bs] + [10**10]
ans = 0
ma = ->(x, y){x > y ? x : y}
as.each_with_index do |a, i|
  ans = ma[bs.bsearch_index{|b| b + a > K} - 1 + i, ans]
end
puts ans

Measured memory_bytes: 45884
S = input()
year = int(S[0:4])
month = int(S[5:7])
day = int(S[8:])
if(year < 2019):
    print("Heisei")
elif(year >= 2019):
    if(month < 5):
        print("Heisei")
    elif(month >= 5):
        print("TBD")

Measured memory_bytes: 3060
s=input()

def is_month(s):
  return 0 < int(s) < 13

s1_is_month = is_month(s[:2])
s2_is_month = is_month(s[2:])

if s1_is_month and s2_is_month:
  print('AMBIGUOUS')
elif s1_is_month:
  print('MMYY')
elif s2_is_month:
  print('YYMM')
else:
  print('NA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main(){
  int N, M;
  cin >> N >> M;
  vector<int> num(N+1);
  for( int i = 0; i < M; i++ ){
    int A, B;
    cin >> A >> B;
    num[A]++;
    num[B]++;
  }

  for( int i = 1; i <= N; i++ ){
    if( num[i]%2 == 1 ){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int N, C, X, D[30][39], t[3][30]={0};
	cin >> N >> C;
	for(int i=0; i<C; i++){
		for(int j=0; j<C; j++){
			cin >> D[i][j];
		}
	}
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			cin >> X;
			t[(i+j)%3][X-1]++;
		}
	}
	int res=1<<30;
	for(int i=0; i<C; i++){
		for(int j=0; j<C; j++){
			for(int k=0; k<C; k++){
				if(i!=k && j!=k && i!=j){
					int tt=0;
					for(int l=0; l<C; l++){
						tt+=D[l][i]*t[0][l];
					}
					for(int l=0; l<C; l++){
						tt+=D[l][j]*t[1][l];
					}
					for(int l=0; l<C; l++){
						tt+=D[l][k]*t[2][l];
					}
					if(tt<res){
						res=tt;
					}
				}
			}
		}
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int S, W;
    scanf("%d%d", &S, &W);
    //scanf("%d", &x);
    //scanf("%d", &y);
    if (S <= W) {
        printf("unsafe\n");
    } else {
        printf("safe\n");
    }
    return 0;
}


Measured memory_bytes: 1616
#include <iostream>
#include <stdio.h>
using namespace std;
main(){
  int N,M;
  scanf("%d %d",&N,&M);
  int vote=0;
  int A[N];
  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
    vote+=A[i];
  }
  int minvote=(vote-1)/4/M;
  int large=0;
  for(int i=0;i<N;i++){
    if(A[i]>minvote)large++;
  }
  if(large>=M)printf("Yes");else printf("No");
}

Measured memory_bytes: 256
N = gets.to_i
S = gets.chomp

count = 0
for i in 0..9
  a = S.index(i.to_s)
  if a != nil
    for j in 0..9
      b = S.index(j.to_s, a+1)
      if b != nil
        for k in 0..9
          c = S.index(k.to_s, b+1)
          if c != nil
            count += 1
          end
        end
      end
    end
  end
end

puts count

Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};



int main(){
	int n,a[200200],b[200200];
	cin>>n;
	rep(i,0,n)cin>>a[i],b[i]=a[i];
	sort(a,a+n,greater<>());
	rep(i,0,n){
		if(b[i]==a[0])print(a[1]);
		else print(a[0]);
	}
}

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

#define ll long long
#define endl "\n"

int n;
int mat[25][25];
ll int dp[25][1<<21];
const int mod = 1e9 + 7;

ll int kil(int idx, int mask)
{
    if(idx == n)
    {
        if(!mask)
            return 1;
        return 0;
    }

    if(dp[idx][mask] != -1)
        return dp[idx][mask];

    dp[idx][mask] = 0;

    for(int j=0;j<n;j++)
        if(mat[idx][j] && (mask & (1<<j)))
            dp[idx][mask] = (dp[idx][mask] + kil(idx+1, mask ^ (1<<j))) % mod;

    return dp[idx][mask];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;

    memset(dp, -1, sizeof dp);

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>mat[i][j];

    // bit is 1 -> means not yet selected
    cout<<kil(0, (1<<n)-1)<<endl;

    return 0;
}


Measured memory_bytes: 409984
namespace ABC_087
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = int.Parse(System.Console.ReadLine());
            var a = int.Parse(System.Console.ReadLine());
            var b = int.Parse(System.Console.ReadLine());
            System.Console.WriteLine(buyingSweets(x, a, b));
        }

        static private int buyingSweets(int x, int a, int b)
        {
            var remains = x - a;
            var more = (int)(remains / b) * b;
            return remains - more;
        }
    }
}


Measured memory_bytes: 11092
K = input(str())
a = 'ACL'

if K == '1':
    print(a)

if K == '2':
    print(a * 2)

if K == '3':
    print(a * 3)

if K == '4':
    print(a * 4)

if K == '5':
    print(a * 5)


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

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto A = RD;
	auto B = RD;
	long ans = -1;
	foreach (i; 1..10^^5)
	{
		if (cast(long)(i*0.08) == A && cast(long)(i*0.1) == B)
		{
			ans = i;
			break;
		}
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 256