akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, K;
vector<PL> xy;
struct edge {
    ll to, cost;
    bool operator<(const edge &another) const { return cost < another.cost; };
    bool operator>(const edge &another) const { return cost > another.cost; };
};
vector<vector<edge>> g;
VL d;

signed main() {
    cin >> N;
    REP(i, N) {
        LCIN(x, y);
        xy.emplace_back(x, y);
    }
    sort(All(xy));
    ll ans = LINF;
    REP(i, N) FOR(j, i + 1, N) {
        ll p = xy[j].first - xy[i].first;
        ll q = xy[j].second - xy[i].second;
        ll tmp = N;
        REP(k, N) FOR(l, i + 1, N) {
            if(xy[l].first - xy[k].first == p && xy[l].second - xy[k].second == q) {
                tmp--;
            }
        }
        ans = min(ans, tmp);
    }
    cout << (ans == LINF ? 1 : ans) << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main()
{
    int n,m,x,y,z,temp;
    scanf("%d %d",&n,&m);
    x = n+m;
    y = n-m;
    z= n*m;
    temp =x;
    if (temp<y)
        temp=y;
    if (temp<z)
        temp=z;
    printf("%d",temp);

    return 0;
}

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

int main()
{
	string s;
	long long k;

	cin >> s >> k;

	int i = 0;
	
	while (s[i] == '1' && k > 1) {
		k--;
		i++;
	}

	cout << s[i] << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

const i32 mod = 1000000007;

i32 mod_pow (i32 r, i32 n) {
  i32 t = 1;
  while (n > 0) {
    if (n & 1) t = (i64) t * r % mod;
    r = (i64) r * r % mod;
    n >>= 1;
  }
  return t;
}

i32 fact (i32 n) {
  i32 res = 1;
  for (i32 i = 1; i <= n; ++i) {
    res = (i64) res * i % mod;
  }
  return res;
}

i32 comb (i32 n, i32 k) {
  if (!(0 <= k && k <= n)) return 0;
  i32 nu = 1;
  i32 de = 1;
  for (i32 i = 1; i <= k; ++i) {
    nu = (i64) nu * (n + 1 - i) % mod;
    de = (i64) de * i % mod;
  }
  return (i64) nu * mod_pow (de, mod - 2) % mod;
}

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  i32 ans = 0;
  for (i32 i = k, sign = 1; i > 0; --i, sign = -sign) {
    ans = (ans + mod + (i64)sign * comb (k, i) * mod_pow (i, n) % mod) % mod;
  }
  ans = (i64) ans * mod_pow (fact (k), mod - 2) % mod;
  printf ("%" PRIi32 "\n", ans);
}

int main (void) {
  run();
  return 0;
}



Measured memory_bytes: 2148
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main() {
  long long N,P;
  cin >> N >> P;
  int A[N+10];
  bool ans=true;
  for(int i=0; i<N; i++){
    cin >> A[i];
    if(A[i]%2!=0) ans=false;
  }
  long long a=0;
  if(ans && P==1) a=0;
  else if(ans) a=pow(2,N);
  else a=pow(2,N-1);
  cout << a << endl;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>

using namespace std;

int main(){
	vector<int> v(3);
	int ans = 0;

	cin >> v[0] >> v[1] >> v[2];
	sort(v.begin(), v.end(), greater<int>());

	cout << v[0] * 10 + v[1] + v[2] << endl;

	return 0;
}

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

bool d[11] = {};

bool solve(int n) {
    for (int i=1; i<=n; i*=10) {
        int tmp = n / i; tmp %= 10;
        if (d[tmp])
            return false;
    }
    return true;
}

int main() {
    int n, k;
    cin >> n >> k;
    for (int i=0; i<k; i++) {
        int t;
        cin >> t;
        d[t] = true;
    }
    for (int i=n; i<=10*n; i++)
        if (solve(i)) {
            cout << i << endl;
            return 0;
        }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var N, T int
	fmt.Scan(&N, &T)

	minc := 1001
	for i := 0; i < N; i++ {
		var c, t int
		fmt.Scan(&c, &t)
		if t > T {
			continue
		}
		minc = min(minc, c)
	}

	if minc == 1001 {
		fmt.Println("TLE")
	} else {
		fmt.Println(minc)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int s, w;
    cin >> s >> w;

    if (w >= s) puts("unsafe");
    else puts("safe");
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>

int main(){
  char S[5];
  int d[28]={};
  scanf("%s",S);
  for(int i=0;i<4;i++)
    d[S[i]-'A']++;
  int c=0;
  for(int i=0;i<26;i++)
    if(!(d[i]==0 || d[i]==2)){
      c=1;
      break;
    }
  
  if(c==0) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		
		System.out.println((int)kaijo(n));
	}

	static double kaijo(int m){
		double s = 0.0;
		for (int i1 = 1; i1 <= m; i1++)
			s += (double)i1;
			return s;
	}
}

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

int main() {
  
  string N;
  cin >> N;
  string A = "No";
  
  for(int i = 0;i < 3;i++) {
    
    if(N.at(i) == '7') {
      A = "Yes";
      break;
    }
  }
  
  cout << A <<endl;
  return 0;
}
      


Measured memory_bytes: 3628
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<math.h>
using namespace std;
int main()
{
	int num;
	scanf("%d", &num);
	int nt = 0, nx = 0, ny = 0;
	for (int i = 0; i < num; i++)
	{
		int t, x, y;
		scanf("%d%d%d", &t, &x, &y);
		if (abs(x - nx) + abs(y - ny)>t - nt || t % 2 != (x + y) % 2)
		{
			printf("No\n");
			return 0;
		}
		nt = t, nx = x, ny = y;
	}
	printf("Yes\n");
}

Measured memory_bytes: 128
import bisect,copy,heapq,itertools,math,string
from collections import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')
if abs(a-b)<=1 and abs(b-c)<=1 and abs(c-a)<=1:
    print("YES")
else:
    print("NO")

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

using namespace std;

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    for (int i=0;i<s.size();i++){
        s[i]=(s[i]-64+n)%26+64;
        if(s[i]==64){
            s[i]=90;
        }
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc146/tasks/abc146_d
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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< typename T >
struct edge {
	int src, to;
	T cost;
    T no;
    ll col=0;
	edge(int _to, T _cost) : src(-1), to(_to), cost(_cost) {}
	edge(int _src, int _to, T _cost, T _no) : src(_src), to(_to), cost(_cost), no(_no) {}
	edge &operator=(const int &x) {
		to = x;
		return *this;
	}
	operator int() const { return to; }
};

template< typename T>
struct node {
	vector<edge<T>> edges;
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< node< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

vector<ll> col; //edgeのいろ1-N-1
//木の直径,aoj_grl_5_a
template< typename T >
pair< T, int > tree_dfs(const WeightedGraph< T > &g, int idx, int par) {
    pair< T, int > ret(0, idx);
    map<ll,ll> tmp; //---
    for(auto &e : g[idx].edges) {
        ll id=e.no; //edgeの番号
        if(col.at(id)!=0) tmp[col.at(id)]=1;
    }
    ll cn=1;
    auto get_col = [&](){
        while(tmp.count(cn)){
            ++cn;
        }
        return cn++;
    };
    for(auto &e : g[idx].edges) {
        ll id=e.no; //edgeの番号
        if(col.at(id)==0) {
            col.at(id)=get_col();
        }else{
        }
    } //---
    for(auto &e : g[idx].edges) {
        if(e.to == par) continue;
        auto cost = tree_dfs(g, e.to, idx);
        cost.first += e.cost;
        ret = max(ret, cost);

        ll id=e.no; //edgeの番号
        auto c=col.at(id);
    } 
#if 0
    map<ll,ll> tmp;
    for(auto &e : g[idx].edges) {
        ll id=e.no; //edgeの番号
        if(col.at(id)!=0) tmp[col.at(id)]=1;
    }
    ll cn=1;
    auto get_col = [&](){
        while(tmp.count(cn)){
            ++cn;
        }
        return cn;
    };
    for(auto &e : g[idx].edges) {
        ll id=e.no; //edgeの番号
        if(col.at(id)==0) {
            col.at(id)=get_col();
        }else{

        }
    }
#endif
    return ret;
}

int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-2.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N; cin>>N;
    WeightedGraph<ll> graph(N+1);
    col.resize(N,0);
    FOR(i,1,N){
        ll a,b; cin>>a>>b;
        graph.at(a).edges.emplace_back(a,b,1,i);
        graph.at(b).edges.emplace_back(b,a,1,i);
    }
    ll color_num=0;
    FOR(i,1,graph.size()){
        if (chmax<ll>(color_num,graph.at(i).edges.size())){
        }
    }

    tree_dfs(graph, 1,-1);
    dump(col);

    cout<<color_num<<endl;
    FOR(i,1,col.size()){
        cout<<col.at(i)<<endl;
    }

    return 0;
}

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

int main() {
  int s;
    cin >> s;
    cout << s/100/*100の位*/
          +(s-s/100*100)/10//10の位
          +(s-s/100*100-(s-s/100*100)/10*10)//1の位
         << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

typedef struct node node;
typedef struct edge{
    lld w;
    node* target;
    struct edge* next;
}edge;
typedef struct node{
    lld value;
    int fl;
    edge* fst;
    edge* lst;
}node;
void initNodeArray(node* p, int n){
    for(int i=0; i<n; i++){
        (p+i)->value = 0;
        (p+i)->fl = 1;
        (p+i)->fst = NULL;
        (p+i)->lst = NULL;
    }
}
void addEdge(node* p, node* target, lld w){
    if(p->fst == NULL){
        p->fst = (edge*)malloc(sizeof(edge));
        p->lst = p->fst;
    }else{
        p->lst->next = (edge*)malloc(sizeof(edge));
        p->lst = p->lst->next;
    }
    p->lst->target = target;
    p->lst->w = w;
    p->lst->next = NULL;
}

int f = 1;

void func(node* p, node* pre){
    edge* e = p->fst;
    p->fl = 0;
    while(e != NULL){
        if(e->target == pre){
            e = e->next;
            continue;
        }
        if(e->target->fl){
            e->target->value = p->value + e->w;
            func(e->target, p);
        }else{
            if(p->value + e->w != e->target->value){
                f = 0;
            }
        }
        e = e->next;
    }
}

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    node a[n+1];
    initNodeArray(a, n+1);
    rep(i, 0, m){
        int l, r;
        lld d;
        scanf("%d %d %lld", &l, &r, &d);
        addEdge(&a[l], &a[r], d);
        addEdge(&a[r], &a[l], -1 * d);
    }
    rep(i, 1, n){
        func(&a[i], &a[i]);
    }
    lld max = LLONG_MIN, min = LLONG_MAX;
    rep(i, 1, n){
        if(a[i].value > max){
            max = a[i].value;
        }
        if(a[i].value < min){
            min = a[i].value;
        }
    }
    if(max - min > 1000000000){
        f = 0;
    }
    printf(f ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 17664
a,b = map(int,input().split())

if a+b >=  a-b and a+b >= a*b:
    print(a+b)

elif a-b >= a+b and a-b >= a*b:
    print(a-b)

elif a*b >= a+b and a*b >= a-b:
    print(a*b)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

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

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

int main() {
	double n, m;
	cin >> n >> m;
	vector<int>a(n, 0);
	double all = 0;
	rep(i, n) {
		cin >> a[i];
		all += a[i];
	}

	int cnt = 0;
	double check = all * (1 / (4 * m));
	rep(i, n) {
		if (a[i] >= check) {
			cnt++;
		}
	}

	if (cnt >= m)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[233],ans=INT_MAX;
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	sort(a,a+n);
	for(int pos=0;pos<=100;pos++){
		int tmp=0;
	    for(int i=0;i<n;i++)tmp+=(a[i]-pos)*(a[i]-pos);
	    ans=min(ans,tmp);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++){
        int temp;
        cin >> temp;
        if(temp % 2 == 0){
            if(temp % 3 != 0 && temp % 5 != 0){
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";
}

Measured memory_bytes: 256
W, H, N = map(int, input().split())
list = [list(map(int, input().split())) for i in range(N)]

minx = 0
miny = 0
MAXx = W
MAXy = H

for k in range(N):
    if list[k][2] == 1:
        minx = max(list[k][0], minx)
    elif list[k][2] == 2:
        MAXx = min(list[k][0], MAXx)
    elif list[k][2] == 3:
        miny = max(list[k][1], miny)
    elif list[k][2] == 4:
        MAXy = min(list[k][1], MAXy)

if MAXx - minx < 0 or MAXy - miny < 0:
    print(0)
else:
    print((MAXx - minx) * (MAXy - miny))




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

int main() {

  int N, K;
  cin >> N >> K;

  vector <int> X(N);

  for (int i = 0; i < N; i++) {
   cin >> X.at(i);
  }

  vector <int> s(100);
  int ans = 0;

   for (int i = 0; i < N; i++) {

    s.at(i) = (min ( (X.at(i)-0), (K-X.at(i)) ))*2;
    ans += s.at(i);

   }
    cout << ans << endl;


return 0;

}


Measured memory_bytes: 256
Imports System.Collections.Generic
Imports System.Console
Module Program
 	Sub Main()
 	    Dim inputs as String()
        inputs = Console.ReadLine().Split(" ")
	    Dim A As Integer = inputs(0)
	    Dim B As Integer = inputs(1)
	    Dim C As Integer = inputs(2)
	    Dim D As Integer = inputs(3)
        Console.WriteLine(IIf(A*B > C*D, A*B, C*D))
    End Sub
End Module


Measured memory_bytes: 11220
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/
ll laip(ll a, ll b, ll liek) {
	a=a%liek;
	if (b==0) {return 1;}
	if (b==1) {return a;}
	ll x=laip(a*a,b/2,liek);
	if (b%2==0) {return x;}
	return (a*x)%liek;
	}
	
ll atv(ll a, ll liek) {
	return laip(a,liek-2,liek);
	}


 
 ll cnk(vector <ll> &F, int n, int k, ll liek) {
	 ll ats=F[n];
	 ll b=(F[k]*F[n-k])%liek;
	 ats=ats*laip(b,liek-2,liek);
	 return ats%liek;
	 }
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    ll liek=1000000007;
    vector <ll> F(m+1,1);
    for (int i=2;i<=m;i++) {
		F[i]=(F[i-1]*i)%liek;
		}
	ll ats=0;
	ll y=atv(F[m-n],liek);
	y=(y*y)%liek;
	y=(y*F[m])%liek;
	for (int i=0;i<=n;i++) {
		ll x=cnk(F,n,i,liek)*F[m-i];
		x=x%liek;
		if (i%2==0) {ats+=(x*y)%liek;}
		else {ats-=(x*y)%liek;}
		ats=(ats+liek)%liek;
		}
	cout<<ats<<endl;
    return 0;
}


Measured memory_bytes: 7068
from operator import itemgetter
import sys
input = sys.stdin.readline
N = int(input())
LR = []
for _ in range(N):
    l, r = map(int, input().split())
    LR.append([l, r+1])
ans = 0
for l, r in LR:
    ans = max(ans, r - l)

LR.sort(key=itemgetter(1))

sch = 0
rr = 0
for l, r in LR:
    if l >= rr:
        rr = r
        sch += 1
#print(sch)
if sch >= 3:
    print(ans)
elif sch == 2:
    # ここは合ってる
    LR_ = []
    pl = 0
    for l, r in LR:
        if pl >= l:
            pass
        else:
            LR_.append([l, r])
            pl = l
    assert len(LR_) >= 2
    LR = LR_
    Ll, Lr = LR[0]
    Rl, Rr = LR[-1][0], LR[1][1]
    ans = max(ans, max(Rr-Rl, 0) + Lr-Ll)
    for i, (l, r) in enumerate(LR[1:-1], 1):
        Ll = l
        Rr = LR[i+1][1]
        ans = max(ans, max(Rr-Rl, 0) + max(Lr-Ll, 0))
    print(ans)
else:
    mid_l = 0
    mid_r = float("inf")
    for l, r in LR:
        mid_l = max(l, mid_l)
        mid_r = min(r, mid_r)
    for i in range(N):
        LR[i][1] -= mid_r-mid_l
    LR_ = []
    pl = 0
    for l, r in LR:
        if pl >= l:
            pass
        else:
            LR_.append([l, r])
            pl = l
    if not len(LR_) >= 2:
        print(ans + mid_r - mid_l)
        exit()
    assert mid_r - mid_l > 0
    assert LR_ == sorted(LR_)
    an = 0
    LR, LR_ = LR_, LR
    Ll, Lr = LR[0]
    Rl, Rr = LR[-1][0], LR[1][1]
    an = max(an, max(Rr-Rl, 0) + Lr-Ll)
    for i, (l, r) in enumerate(LR[1:-1], 1):
        Ll = l
        Rr = LR[i+1][1]
        an = max(an, max(Rr-Rl, 0) + max(Lr-Ll, 0))
    ans += mid_r - mid_l
    an += (mid_r - mid_l) * 2
    print(max(ans, an))


Measured memory_bytes: 74204
use proconio::*;

fn run() {
    input! {
        n: usize,
        k: usize,
        p: [(usize, usize); k],
    }
    const MOD: u64 = 998_244_353;
    let mut dp = vec![0; 2 * n + 2];
    dp[1] = 1;
    dp[2] = MOD - 1;
    for i in 1..n {
        dp[i] += dp[i - 1];
        dp[i] %= MOD;
        let v = dp[i];
        for &(l, r) in p.iter() {
            dp[l + i] += v;
            dp[r + 1 + i] += MOD - v;
        }
    }
    let ans = (dp[n] + dp[n - 1]) % MOD;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 5052
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
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 = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	cin >> n;
	vector<ll> x(n);
	ll p, q;
	p = 110; q = -1;
	rep(i, n) {
		cin >> x[i];
	}
	ll sum = ma;
	for (ll i = 1; i <= 100; i++) {
		ll tmp = 0;
		rep(j, x.size()) {
			tmp += (x[j] - i) * (x[j] - i);
		}
		chmin(sum, tmp);
	}
	cout << sum << endl;
}


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

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

  int n = t.size();

  if (n == 1) {
    if (t[0] == '?')
      cout << 'D' << endl;
    else
      cout << t << endl;
  } else if (n == 2) {
    if (t[0] == '?' && t[1] == 'P')
      cout << "DP" << endl;
    else if (t[0] == '?' && t[1] == 'D')
      cout << "PD" << endl;
    else if (t[0] == '?' && t[1] == '?')
      cout << "PD" << endl;
    else if (t[1] == '?')
      cout << t[0] << 'D' << endl;
    else
      cout << t << endl;
  } else {
    for (int i = 0; i < n; i++) {
      if (t[i] == 'P')
        s.push_back('P');
      else if (t[i] == 'D')
        s.push_back('D');
      else if (t[i] == '?') {
        if (i == 0 && t[1] == 'P')
          s.push_back('D');
        else if (i == 0 && t[1] == 'D')
          s.push_back('P');
        else if (i == 0 && t[1] == '?') {
          s.push_back('P');
          s.push_back('D');
          i++;
        } else if (i > 0 && i < n - 1 && t[i - 1] == 'P')
          s.push_back('D');
        else if (i > 0 && i < n - 1 && t[i + 1] == 'P')
          s.push_back('D');
        else if (i > 0 && i < n - 1 && t[i + 1] == 'D')
          s.push_back('P');
        else if (i > 0 && i < n - 1 && t[i + 1] == '?') {
          s.push_back('P');
          s.push_back('D');
          i++;
        } else if (i == n - 1)
          s.push_back('D');
      }
    }
    cout << s << endl;
  }
}

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

int main() {
    ll n,m; cin >> n >> m;
    ll out;
    //n<=mとする
    if(n > m)swap(n,m);
    if(n==1 && m == 1)out = 1;
    else if(n==1)out = m-2;
    else out = (n-2)*(m-2);
    cout << out << endl;
}   



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

int main(){
    ll N,f,sn=0;
    cin>>N;
    f=N;
    while(N>0){
        sn+=N%10;
        N/=10;
    }
    if(f%sn==0) cout<<"Yes";
    else cout<<"No";
}

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

int main() {
	int a , b , q; cin >> a >> b >> q;
	long long ans;
	vector<long long> s(a+2),t(b+2);
	const long long INF = 1LL << 60;
	s[0] = -INF; s[a+1] = INF;
	t[0] = -INF; t[b+1] = INF;
	for(int i = 1 ; i < a+1 ; i++){
		cin >> s[i];
	}
	for(int i = 1 ; i < b+1 ; i++){
		cin >> t[i];
	}
	for(int i = 0 ; i < q ; i++){
		long long x; cin >> x;
		int k = a/2+1 , l = b/2+1 , m = a/4 , n = b/4;
		while(s[k]>x || x>s[k+1]){
			if(x < s[k]){
				k -= max(m,1);
			}
			if(s[k+1] < x){
				k += max(m,1);
			}
			m /= 2;
		}
		while(t[l]>x || x>t[l+1]){
			if(x < t[l]){
				l -= max(n,1);
			}
			if(t[l+1] < x){
				l += max(n,1);
			}
			n /= 2;
		}
		ans = s[k+1]-t[l]+min(s[k+1]-x,x-t[l]);
		ans = min(ans,t[l+1]-s[k]+min(t[l+1]-x,x-s[k]));
		ans = min(ans,max(s[k+1],t[l+1])-x);
		ans = min(ans,x-min(s[k],t[l]));
		cout << ans << endl;
	}
}

Measured memory_bytes: 2944
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;


int main(){
  int n;
  cin >> n;
  string a[n];
  rep(i,n){
    string s; cin >> s;
    a[i] = s+s;
  }
  ll ans = 0;
  rep(i,n){
    bool flag = true;
    rep(j,n)rep(k,n){
      if(a[j][k+i] != a[k][j+i]){
        flag = false;
      }
    }
    if(flag){
      ans += n;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
X = int(input())

if 400<=X<600:
    ans = 8

elif 600<=X<800:
    ans = 7

elif 800<=X<1000:
    ans = 6

elif 1000<=X<1200:
    ans = 5

elif 1200<=X<1400:
    ans = 4

elif 1400<=X<1600:
    ans = 3

elif 1600<=X<1800:
    ans = 2

elif 1800<=X<2000:
    ans = 1

print(ans)

Measured memory_bytes: 9044
#include <iostream>
using namespace std;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    if (n%2==1)
        cout << "No";
    else
    {
        for (int i=0;i<n/2;i++)
            if (s[i]!=s[n/2+i])
            {
                cout << "No";
                return 0;
            }
        cout << "Yes";
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
/*#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX*/

using namespace std;

using ll = long long;

#define mp make_pair

const int p = 998244353;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};*/

/*const int N = 1000000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

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

    ll suma = 0, sumb = 0, sumc = 0, sumd = 0;

    suma = 0;
    sumb = 0;
    sumc = a[0];
    for (int i = 1; i<n; i++) sumd+=a[i];
    int curl = 0;
    int curr = 1;
    ll res = 1e18;
    for (int i = 0; i<n-2; i++)
    {
        sumb+=a[i];
        sumc-=a[i];
        while (suma + a[curl]<=sumb - a[curl])
        {
            suma+=a[curl];
            sumb-=a[curl];
            curl++;
        }
        while (sumc + a[curr]<=sumd - a[curr])
        {
            sumc+=a[curr];
            sumd-=a[curr];
            curr++;
        }
        vector<pair<ll, ll>> L = {mp(suma, sumb), mp(suma + a[curl], sumb - a[curl])};
        vector<pair<ll, ll>> R = {mp(sumc, sumd), mp(sumc + a[curr], sumd - a[curr])};

        for (auto x: L) for (auto y: R)
        {
            res = min(res, max({x.first, x.second, y.first, y.second}) - min({x.first, x.second, y.first, y.second}));
        }
    }
    cout<<res;

}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define all(c) begin(c),end(c)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
 
 
 
 
int main() {
  int n,m;
  cin>>n>>m;
 
  priority_queue<int> q;
  rep(i,n){
    int a;
    cin>>a;
    q.push(a);
  }
  rep(i,m){
     int a=q.top();
     q.pop();
     q.push(a/2);
  }
 
 
  ll sum=0;
  rep(i,n){
    sum+=q.top();
    q.pop();
  }
  cout<<sum;
}




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

char s[1000000];
ll t[3][1000001];

int main() {
  int n, q;
  scanf("%d%s%d", &n, s, &q);

  V D, C;
  rep(i, n) {
    rep(j, 3) t[j][i+1] = t[j][i];
    switch(s[i]){
      case 'D':
        ++t[0][i+1];
        D.push_back(i+1);
        break;
      case 'M':
        ++t[1][i+1];
        break;
      case 'C':
        ++t[2][i+1];
        C.push_back(i);
        break;
    }
  }

  ll suma = 0, sumc = 0;
  for (auto &a : D) suma += t[1][a] * t[2][a];
  for (auto &c : C) sumc += t[1][c] * t[0][c];

  rep(_, q) {
    int k; 
    scanf("%d", &k);
    ll ans = suma + sumc;
    for (auto &a : D) ans -= t[1][a] * t[2][min(a+k-1, n)];
    for (auto &c : C) ans -= t[1][c] * t[0][max(c-k+1, 0)];
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 28780
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string a;
	cin>>a;
	int l=a.size();
	bool flag=false;
	for(int i=0;i<l;i++)
	{
	    if(a[i]=='C')
	    {
	        for(int j=i+1;j<l;j++)
                if(a[j]=='F')
                {
                cout<<"Yes "<<endl;
                return 0;
                }
	    }
}

	cout<<"No"<<" "<<endl;
	return 0;
}

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

void main() {
    auto N = readln.chomp.to!int;
    auto edges = new int[][](N);

    foreach (i; 0..N-1) {
        auto s = readln.split.map!(to!int);
        edges[s[0] - 1] ~= s[1] - 1;
        edges[s[1] - 1] ~= s[0] - 1;
    }

    int[] path;

    bool dfs(int n, int p) {
        if (n == N - 1) {
            path ~= N - 1;
            return true;
        }
        foreach (m; edges[n]) if (m != p && dfs(m, n)) {
            path ~= n;
            return true;
        }
        return false;
    }

    dfs(0, -1);
    path.reverse();
    auto colors = new int[](N);

    DList!(int) A;
    DList!(int) B;
    int M = path.length.to!int;

    foreach (i; 0..M/2+M%2) colors[path[i]] = 1, A.insertBack(path[i]);
    foreach (i; M/2+M%2..M) colors[path[i]] = 2, B.insertBack(path[i]);


    void bfs(DList!int q, int c) {
        while (!q.empty) {
            int n = q.front;
            q.removeFront;
            colors[n] = c;
            foreach (m; edges[n]) if (colors[m] == 0) q.insertBack(m);
        }
    }

    bfs(A, 1);
    bfs(B, 2);

    int a = 0, b = 0;
    foreach (c; colors) if (c == 1) a += 1; else b += 1;

    writeln( a > b ? "Fennec" : "Snuke" );
}


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

int main(){

    int N;
    cin >> N;
    string S;
    cin >> S;

    int ans = 0;
    for(int i = 1; i < N - 1; i++){
        set<char> left, right;
        for(int j = 0; j < i; j++) left.insert(S[j]);
        for(int j = i; j < N; j++) right.insert(S[j]);
        int num = 0;
        for(int j = 'a'; j <= 'z'; j++){
            if(left.find(j) != left.end() && right.find(j) != right.end()) num++;
        }
        ans = max(ans, num);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    char s[99];
    cin>>s;
    s[3]='8';
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3480
#include "bits/stdc++.h"
using namespace std;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	long long x, y, rest = 0;
	cin >> x >> y;
	for(auto i = 0; i < n - 2; ++ i){
		long long x;
		cin >> x;
		rest ^= x;
	}
	if((x ^ y ^ rest) & 1 || x + y < rest){
		cout << "-1\n";
		return 0;
	}
	long long a = x + y - rest >> 1;
	if(a > x){
		cout << "-1\n";
		return 0;
	}
	long long init_x = x;
	int limit = 10000;
	while(x && x & y ^ a && limit --){
		for(auto bit = 40; bit >= 0; -- bit){
			if(x & y & 1LL << bit ^ a & 1LL << bit){
				long long d = min(x - (x >> bit << bit) + 1, ((y >> bit) + 1 << bit) - y);
				x -= d, y += d;
				break;
			}
		}
	}
	x && limit >= 0 ? cout << init_x - x << "\n" : cout << "-1\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 3652
A, B, C = map(int, input().split())

l = [A, B, C]
A, B, C = sorted(l)

res = 0
if ((C - A) % 2 == 0 and (C - B) % 2 == 0):
    res += (C - A) // 2 + (C - B) // 2
elif (C - A) % 2 != (C - B) % 2:
    res += (C - A) // 2 + (C - B) // 2 + 2
else:
    res += (C - A) // 2 + (C - B) // 2 + 1

print(res)


Measured memory_bytes: 3064
using System;
using System.Linq;

namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            int count = int.Parse(Console.ReadLine());
            while(count-- > 0) {
                var l = Console.ReadLine().Split().Select(p => int.Parse(p)).OrderBy(p => p).ToArray();
                Console.WriteLine(l[0] * l[0] + l[1] * l[1] == l[2] * l[2] ? "YES" : "NO");
            }
        }
    }
}

Measured memory_bytes: 6284
#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;



set<LL> enum_div(LL n)//nの約数を列挙
{
	set<LL> ret;
    LL t = (LL)(sqrt(n) + 1);
	for(LL i=1 ; i <= t; ++i)
	{
		if(n%i == 0)
		{
			ret.insert(i);
			//if(i!=1 && i*i!=n)
			//{
            ret.insert(n/i);
                //}
		}
	}
    //ret.PB(n);
	return ret;
}



int main() {
    LL N;
    cin >> N;
    
    set<LL> R = enum_div(N);
    LL ans = 0;
    EACH(x, R) {
        //dump(x);
        if (x == 1) {
            continue;
        }
        if (N / (x - 1) == N % (x - 1)) {
            ans += x - 1;
        }
        
    }
    cout << ans << endl;
	
    return 0;
}


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

template<class T>
void merge(vector<T>& a,int left,int right){
  vector<T> tmp(right-left);
  int mid= (left+right)/2;
  int tl = left;
  int tr = mid;
  for(int idx=0;idx<(right-left);++idx){
    if(tl>=mid)tmp[idx]=a[tr++];
    else if(tr>=right)tmp[idx]=a[tl++];
    else tmp[idx] = (a[tl]<a[tr]?a[tl++]:a[tr++]);
  }
  for(int i=0;i<(right-left);++i){
    a[left+i] = tmp[i];
  }
}

template<class T>
void split(vector<T>& a,int left,int right){
  if(right-left>1){
    split(a,left,(left+right)/2);
    split(a,(left+right)/2,right);
  }
  merge(a,left,right);
}

template<class T>
void merge_sort(vector<T>& a){
  split(a,0,a.size());
}

void test(){

  int n;
  cin>>n;
  vector<int> a(n);
  for(auto& ai:a)cin>>ai;

  merge_sort(a);

  for(auto x:a)cout<<x<<" ";
  cout<<endl;

}

main(){

  int n;
  cin>>n;
  vector<double> a(n);
  for(auto& ai:a)cin>>ai;

  merge_sort(a);

  double ans = a[0];
  for(int i=1;i<n;++i){
    ans += a[i];
    ans /= 2.0;
  }

  cout<<fixed<<setprecision(10)<<ans<<endl;;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
const int MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B, C;
    cin >> A >> B >> C;
    cout << min(C, B / A) << endl;
    return 0;
}

Measured memory_bytes: 256
/*input
314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3
*/
 
 
 
#include <bits/stdc++.h>
using namespace std;
 
 
 
#define int long long int
#define rep(i,n) \
    for(int i = 0; i < n; i++)
#define rep2(i, a, b) \
    for(int i = a; i < b; i++)
#define all(c) \
    c.begin(), c.end()
#define init(arr, num) \
    memset(arr, num, sizeof(arr))
#define fast\
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inputFile \
    freopen("input.txt", "r", stdin); 
#define outputFile \
    freopen("output.txt", "w", stdout);
#define modM 1000000007
#define PI 3.1415926535897932
#define F first
#define S second 
#define pb push_back   
 
#ifdef gaviria
#define TRACE
#endif
#ifdef TRACE
#define trace(...) _f(#VA_ARGS, __VA_ARGS_)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
 
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef unordered_set<int> usi;
 
ll i,j,k,c=0,m;
ll n;

void solve() 
{

cin>>m>>n;
ll a[n];
for(i=0;i<n;i++)
{    cin>>a[i];
c+=a[i];
}
if(m<c)
    cout<<"-1";
else cout<<m-c;

}










            












     
 
 
 
 
signed main()
{
 
    // inputFile;
    fast;
    int T = 1;
//cin >> T;

    while(T--){

      
        solve();

        cout << endl;
        
        
 
    }
    
    
    return 0;
 
}

Measured memory_bytes: 3732
#n = int(input())
#a = list(map(int, input().split()))
L, R= map(int, input().split())

if R-L >= 673:
        print(0)
else:
        x = 10000
        for i in range(L,R):
                for j in range(i+1,R+1):
                        x = min(x, (i*j)%2019)
        print(x)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>

using namespace std;

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

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

  vector<int> s(n, 0);
  int d;
  for (int i = 0; i < k; i++)
  {
    cin >> d;
    vector<int> a(d);
    for (int j = 0; j < d; j++)
    {
      cin >> a[j];
      a[j]--;
      s[a[j]]++;
    }
  }

  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    if (s[i] == 0)
    {
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, res = 0;
    cin>>n;
    if(n % 2) n++;
    rep(i, 1, n / 2){
        res++;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256