akhauriyash/Code-Regression huggingface dataset:
#import math
from fractions import gcd

N = int(input())
As = [int(elm) for elm in input().split(" ")] 


def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            ass.append(n//i)
    return ass

if N >= 3:
    gs = []
    for i in range(0, (N//2)*2 , 2):
        g = gcd(As[i], As[i+1])
        gs.append(g)
    if N % 2 == 1:
        gs.append(As[N-1])

    while len(gs) != 2:
        #print(gs)
        new_gs = []
        N1 = len(gs)
        #print("len",len(gs), (N1//2)*2)
        for i in range(0, (N1//2)*2, 2):
            g = gcd(gs[i], gs[i+1])
            new_gs.append(g)
        if N1 % 2 == 1:
            new_gs.append(gs[-1])
        gs = new_gs

    g1, g2 = gs
    d1 = divisor(g1) 
    d2 = divisor(g2) 
    ds = sorted(d1 + d2, reverse=True)

    #print(gs)
    #print(ds)
    for d in ds:
        count = sum([int(A % d == 0) for A in As])
        if count >= N-1:
            out = d
            break

else:
    out = max(As)

print(out)

Measured memory_bytes: 16148
////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const ll MOD = 1e9 + 7;
const int N = 2e5;

ll fast(ll A, ll B) {
	ll res = 1 % MOD;
	while(B) {
		if(B & 1) res = res * A % MOD;
		B /= 2;
		A = A * A % MOD;
	}
	return res;
}

ll combin(int n, int r) {
	ll atas = 1, bawah = 1;
	for(int i = 0;i < r;i++) atas = (atas * (n - i)) % MOD;
	for(int i = 1;i <= r;i++) bawah = (bawah * i) % MOD;
	return atas * fast(bawah, MOD - 2) % MOD;
}

void hora(int tc) {
	ll n, a, b;
	cin>>n>>a>>b;
	ll tot = (fast(2, n) + MOD - 1) % MOD;
	tot = (tot + MOD - combin(n, a)) % MOD;
	tot = (tot + MOD - combin(n, b)) % MOD;
	cout<<tot<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


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

int main(void){
  int N;
  int a[100010];
  int cnt = 0;
  int onButton = 1;
  bool can = false;
  cin >> N;
  for(int i = 1; i <= N; i++){
    cin >> a[i];
    //cout << i << " " << a[i] << endl;
  }
  for(int i = 1; i <= N; i++){
    onButton = a[onButton];
    //cout << onButton << endl;
    if(onButton == 2){
      can = true;
      cnt = i;
      break;
    }
  }
  if(cnt){cout << cnt << endl;}
  else{cout << -1 << endl;}
  return 0;
}


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

typedef long long ll;
#define println(msg) cout << msg << endl

typedef struct Rec {
  int x;
  int y;
  ll h;
} Rec;

int main() {
  // 入力
  int N;
  cin >> N;

  vector<Rec> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data.at(i).x;
    cin >> data.at(i).y;
    cin >> data.at(i).h;
  }
  
  // 計算
  int cx = 0;
  int cy = 0;
  int ch = 0;
  
  Rec m = *min_element(
    data.begin(), data.end(),
    [](Rec &l, Rec &r) -> bool { return l.h > r.h; });
  ll hmin = m.h;
  ll hmax = hmin + 200;
  
  for (int y = 0; y <= 100; y++) {
    for (int x = 0; x <= 100; x++) {
      for (ll h = hmin; h <= hmax; h++) {
        bool flag = true;
        for (auto &t : data) {
          if (t.h != max(h - abs(x - t.x) - abs(y - t.y), (ll)0)) {
            flag = false;
            break;
          }
        }
        if (flag) {
          cx = x;
          cy = y;
          ch = h;
        }
      }
    }
  }
  
  // 出力
  cout << cx << " " << cy << " " << ch << endl;
}


Measured memory_bytes: 3596
#include <cassert>
#include <iostream>
#include <vector>

class Node {
  public:
    Node* parent;
    Node() { parent = nullptr; }
    Node(Node* n) { parent = n; }
    Node* update_and_find_root() {
      Node* p = this;
      while (p->parent != nullptr) {
        p = p->find_root();
      }
      if (p != this) {
        this->parent = p;
      }
      return p;
    }
    Node* find_root() {
      Node* p = this;
      while (p->parent != nullptr) {
        p = p->parent;
      }
      return p;
    }
};

int main()
{
  int nnodes, nswaps;
  std::cin >> nnodes >> nswaps;
  std::vector<Node> node(nnodes+1);
  std::vector<int> element(nnodes+1);
  for (int i = 1; i <= nnodes; i++) {
    std::cin >> element.at(i);
  }
  for (int i = 0; i < nswaps; i++) {
    int dst, src;
    std::cin >> dst >> src;
    Node* dst_root = node.at(dst).update_and_find_root();
    Node* src_root = node.at(src).update_and_find_root();
    if (dst_root != src_root) {
      src_root->parent = dst_root;
    }
  }
  int result = 0;
  for (int i = 1; i <= nnodes; i++) {
    int dst = element.at(i);
    int src = i;
    if (dst == src) {
      result++;
      continue;
    }
    Node* dst_root = node.at(dst).find_root();
    Node* src_root = node.at(src).find_root();
    if (dst_root == src_root) {
      result++;
    }
  }
  std::cout << result << '\n';
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;

ll a[100001];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; ll x,y;
	cin>>n>>x>>y;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	ll lo = 0; ll hi = ll(1e9);
	ll ans=0;
	while(lo<=hi)
	{
		ll mid=(lo+hi)>>1;
		ll cnt=0;
		for(int i=0;i<n;i++)
		{
			ll res=(a[i]-mid*y);
			res=max(res,0LL);
			res=((res+(x-y)-1)/(x-y));
			cnt+=res;
		}
		if(cnt<=mid)
		{
			ans=mid;
			hi=mid-1;
		}
		else lo=mid+1;
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
inline char nc() {
//	return getchar();
	static char buf[100000],*l=buf,*r=buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x) {
	x=0; int f=1,ch=nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x*=f; 
}
typedef long long ll;
const int maxn=5000+5;
int mod;
int n;
int v[maxn];
int dp[maxn][maxn];
inline void upd(int &x,int y) {x+=y; if(x>=mod) x-=mod;}
int main() {
	read(n),read(mod);
	v[2]=1;
	for(int i=3,j=n;i<=j;++i,--j) v[i]=v[j]=v[i-1]+1;
	dp[1][n]=1;
	for(int i=2;i<=n;++i) {
		for(int j=n;j>=0;--j) {
			upd(dp[i][j],dp[i-1][j]);
			if(j) upd(dp[i][max(0,j-v[i])],dp[i][j]);
		}
	}
	int an=0;
	for(int i=1;i<=n;++i) an=(an+(ll)i*dp[n][i])%mod;
	printf("%d\n",an);
	return 0;
} 

Measured memory_bytes: 101376
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;                        // 任意長整数
using Real = mp::number<mp::cpp_dec_float<1024>>;// 仮数部が1024bitの浮動小数点数
#include<bits/stdc++.h>

using namespace std;
using ll = long long;


int main()
{
    ll a;
    string b;
    cin >> a >> b;
    for(auto &i :b)i -= '0';
    ll c = (b[0] * 100) + (b[2] * 10) + (b[3]);
    cout << a * c / 100 << endl;
}

Measured memory_bytes: 3628
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

ll gcd(ll a,ll b)
{
   if (a%b == 0) return(b);
   else return(gcd(b,a%b));
}

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}



int main(){
    ll l,r,ans=1000000000;
    cin>>l>>r;
    if(r-l>=2018) {
            cout<<0<<endl;
            return 0;
        }
    else{
        l%=2019;
        r%=2019;
        if(r<l) r+=2019;
        for(ll i=l;i<r;i++){
            for(ll j=i+1;j<=r;j++){
                ans=min(ans,(i*j)%2019);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
list_score = [[] for i in range(n)]

for i in range(n):
    a = list_score[i]
    x, y = map(int, input().split())
    a.append(x)
    a.append(y)

list_score.sort(key=lambda x: x[1])

score = 0
ans = "Yes"
for i, j in list_score:
    score += i
    if score > j:
        ans = "No"

print(ans)


Measured memory_bytes: 41148
#include<stdio.h>
int main()
{
  int w,h,x,y,r;

  scanf("%d" "%d" "%d" "%d" "%d",&w,&h,&x,&y,&r);

  if(w>=x+r && h>=y+r && x>0 && y>0){
    printf("Yes\n");

  }else{
    printf("No\n");

  }

  return 0;

}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

void sieve(int n){
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	for(int p=2;p*p<=n;p++){
		if(prime[p]){
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false;
		}
	}
	for(int p=2;p<=n;p++){
		if(prime[p])
			cout<<p<<" ";
	}
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int n;
		double ans=0;
		cin>>n;
		for(int i=0;i<n;i++){
			double z;
			cin>>z;
			z=1/z;
			ans+=z;
		}
		ans=1/ans;
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b;
    cin >> a >> b;
    if (a * b % 2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int n, k, s;
int main() {
	cin >> n >> k >> s;
	if(s != inf) {
		for(int i = 1; i <= k; ++i) {
			cout << s << " ";
		}
		for(int i = k + 1; i <= n; ++i) {
			cout << inf << " ";
		}
		return 0;
	} else {
		for(int i = 1; i <= k; ++i) {
			cout << s << " ";
		}
		for(int i = k + 1; i <= n; ++i) {
			cout << 1 << " ";
		}
		return 0;
	}
	return 0;
}

Measured memory_bytes: 1280
Scanf.(Array.(scanf " %d %d" @@ fun n m ->
  let e = make n [] in
  let e_rev = make n [] in
  init (n-1+m) (fun i -> scanf " %d %d" @@ fun u v ->
    let u,v = u-1,v-1 in
    e.(u) <- v :: e.(u);
    e_rev.(v) <- u :: e_rev.(v)
  ) |> ignore;
  let root = fst @@ fold_left (fun (root,i) ls ->
    (if List.length ls = 0 then i else root),i+1
  ) (0,0) e_rev in
  let topological_sort root =
    let state = make n `Todo in
    let res = ref [] in
    let rec visit i = match state.(i) with
    | `Done -> true
    | `Temp -> false (* cycle detected *)
    | `Todo -> (
      state.(i) <- `Temp;
      let f =
        List.fold_left (fun u j ->
          u && visit j
        ) true e.(i)
      in
      state.(i) <- `Done;
      res := i :: !res; f
    ) in
    (* if
      fold_left (fun u i ->
        if state.(i) = `Todo then
          u && visit i
        else u
      ) true @@ init n (fun i -> i)
    then Some !res else None *)
    assert (visit root); !res
  in
  let tp = topological_sort root in
  let ord = make n 0 in
  List.iteri (fun i v -> ord.(v) <- i) tp;
  let res = init n (fun i ->
    if i = root then 0
    else 1 + (
      e_rev.(i)
      |> List.sort (fun u v -> -compare ord.(u) ord.(v))
      |> List.hd)
  ) in
  iter (Printf.printf "%d ") res
))

Measured memory_bytes: 25728
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<vvvi> vvvvi;

int n, d;
map<int, int> M;

bool solve(vi &A, vi &B) {
    int cur = 0;
    for (int i = 0; i < d; ++i) cur += (A[i]-B[i])*(A[i]-B[i]);
    return M.find(cur) != M.end();
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> d;
    vvi points(n, vi(d));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < d; ++j) cin >> points[i][j];
    }
    for (int i = 1; i <= 1e3; ++i) M[i*i] = 1;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) ans += solve(points[i], points[j]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){

  int n;
  while( cin >> n , n ){

    int aizu[7] = {0};

    int year;
    for( int i = 0 ; i < n ; i++ ){
      cin >> year; 
      if( year > 60 ) year = 60;
      aizu[year/10]++;
    }

    for( int i = 0 ; i < 7 ; i++ ){
      cout << aizu[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
import sys
import collections


def solve(N: int, A: "List[int]"):
    c = collections.Counter(A)
    for i in range(1, N + 1):
        if i in c:
            print(c[i])
        else:
            print(0)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N - 2 + 1)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 48972
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, ll>;

int main()
{
    string s;
    cin >> s;
    int ans = 1000;
    for (int i = 0; i < s.size() - 2; ++i)
    {
        int num = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
        ans = (min)(ans, abs(753 - num));
    }
    cout << ans << endl;
    return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

/*Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



  }*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    } else {
      x = x->right;
    }
  }
  
  z->parent = y;
  if(y==NIL){
    root = z;
  } else if(z->key < y->key){
    y->left = z;
  } else{
    y->right = z;
  }
  
}

void inorder(Node u){
  if(u->left!=NIL){
    inorder(u->left);
  } 
  printf(" %d",u->key);
  if(u->right!=NIL){
    inorder(u->right);
  } 
}

void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!=NIL){
    preorder(u->left);
  } 
  if(u->right!=NIL){
    preorder(u->right);
  } 
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    /*if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
      } else */
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } /*else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }*/
  }

  return 0;
}

Measured memory_bytes: 24040
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
double eps=1e-10;
int main(){
  int d;
  cin>>d;
  for(int dd=0;dd<d;dd++){
  double x1,x2,x3,x4,y1,y2,y3,y4;
  cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
  double c=(x2-x1)*(y3-y4)-(y2-y1)*(x3-x4);
  if(abs(c)<eps)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  }
}



Measured memory_bytes: 3056
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }


template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) {}
	ModInt(signed sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
};

typedef ModInt<1000000007> mint;

int main() {
	int N; int X; int Y; int Z;
	while(~scanf("%d%d%d%d", &N, &X, &Y, &Z)) {
		const int D = 10;
		int S = (1 << (X + Y + Z)) + 1;
		vector<vector<int>> nextst(S, vector<int>(D + 1, -1));
		int accept = 1 << (X + Y + Z);
		rep(s, 1 << (X + Y + Z)) if(s & 1) {
			rer(d, 1, 10) {
				int t = 1 << 0;
				rep(i, X + Y + Z) if(s >> i & 1) {
					int bound = i < X ? X : i < X + Y ? X + Y : X + Y + Z;
					if(i + d <= bound)
						t |= 1 << (i + d);
				}
				if(t >> (X + Y + Z) & 1)
					t = accept;
				nextst[s][d] = t;
			}
		}
		rer(d, 1, D)
			nextst[accept][d] = accept;
		vector<vector<mint>> dp(N + 1, vector<mint>(S));
		dp[0][1 << 0] = 1;
		rep(i, N) rep(s, S) {
			mint x = dp[i][s];
			if(x.x == 0) continue;
			rer(d, 1, D) {
				int t = nextst[s][d];
				dp[i + 1][t] += x;
			}
		}
		mint ans = dp[N][accept];
		printf("%d\n", ans.get());
	}
	return 0;
}


Measured memory_bytes: 33152
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n ;
    cin>>n;
   vector<int >x,y;int a,b;
    for (int i = 0;i<n;i++)
    {
    cin>>a>>b;
    x.push_back(a+b);
    y.push_back(a-b);
    }
    
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    
    cout<<max(x[n-1]-x[0],y[n-1]-y[0]);
    return 0;
}

Measured memory_bytes: 5024
#include<bits/stdc++.h> 
using namespace std;
int main() 
{  
    int n,m;
    cin>>n>>m;
    int i,a[m],s=0;
    for(i=0;i<m;i++){
        cin>>a[i];
        s+=a[i];
    }
    if(s>n) cout<<-1<<endl;
    else cout<<n-s<<endl;
} 


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>

using vi = std::vector<int>;

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

    int n; std::cin >> n;
    vi v(n);
    for (auto &a : v) std::cin >> a;
    std::sort(v.begin(), v.end());
    int s = 0;
    for (auto a : v) s += a;
    if (s % 10 == 0) {
        for (auto a : v) {
            if (a % 10 != 0) {
                s -= a;
                break;
            }
        }
    }
    std::cout << ((s % 10 == 0) ? 0 : s) << std::endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;


int main(void){
    int m,n;
	long long ans = -(1LL << 60);
    cin >> n >> m;
	vector<vector<long long> > v(8);

	for(int i = 0; i< n; i++) {
		long a=0,b=0,c=0;
		cin >> a >> b >> c;

		for (int j = 0; j < 8; j++) {
			int signA = (j<4?1:-1);
			int signB = (j%4<2?1:-1);
			int signC = (j%2==0?1:-1);
			v[j].push_back(signA*a + signB*b + signC*c);
		}
	}

	for (int i = 0; i<8;i++) {
		sort(v[i].begin(),v[i].end()); reverse(v[i].begin(),v[i].end());
		long long sum = 0;
		for(long j =0; j< m; j++)
			sum += v[i][j];
		if (sum > ans) ans = sum;
	}
	cout << ans << endl;
	
 } 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
std::vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
#define size_t ll
const int mod = 1000000007;
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
int n;
set<ll>s;
int main(){
  cin >> n;
  for (size_t i = 0; i < n; i++) {
    ll x;
    cin >> x;
    auto itr = s.find(x);
    if(itr == s.end()){
      s.insert(x);
    }else{
      s.erase(x);
    }
  }
  cout << s.size() << endl;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int n;
    int a[100000];
    bool f[100000];
    mset(f, 0);

    cin >> n;
    REP(i, n) {
        cin >> a[i];
    }

    int res = 0;
    REP(i, n) {
        if ( a[a[i] - 1] == i + 1 && !f[i] ) {
            f[i] = f[a[i] - 1] = true;
            ++res;
        }
    }

    cout << res << endl;


    return 0;
}



Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x=0,i,a,b[200005]={0};
	scanf("%d",&n);
	for(i=0;i<n-1;i++)
	{
		scanf("%d",&a);
		b[a]++;
	}
	for(i=1;i<=n-1;i++)
	printf("%d\n",b[i]);
	printf("0\n");
} 

Measured memory_bytes: 4608
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod1 1000000007
#define mod2 1000000009
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class ATakoyaki {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int n,x,t;
        cin>>n>>x>>t;
        int val=n/x;
        if (n%x!=0)
            val++;
        cout<<val*t<<endl;
	}
};


int main() {
	ATakoyaki solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3648
#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;
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    #define ll long long
    #define int long long
    #define lb long double
    #define f(i,a,b) for(int i=a;i<=b;i++)
    #define fd(i,a,b) for(int i=a;i>=b;i--)
    #define vi vector<int>
    #define mii map<int,int>
    #define pii pair<int,int>
    #define si set<int>
    #define pb push_back
    #define mk make_pair
    #define fi first
    #define se second
    #define fv(i,v) for(auto i=v.begin();i!=v.end();++i)
    #define fdv(i,v) for(auto i=v.rbegin();i!=v.rend();++i)
    #define print(a,n) f(i,1,n) cout<<a[i]<<" "; cout<<endl;
    #define printv(v) for(auto iv: v) cout<<iv<<" "; cout<<endl;
    #define all(v) v.begin(),v.end()
    #define r(a,n) ll a[n+1]; f(i,1,n) cin>>a[i];
    #define pi 3.141592653589793238
    const int mod=998244353;
    const int inf=1e18;
    //bool vis[1000+1]={};
    const int MAXN=1e6+1;
    int spf[MAXN];
    ll power(ll x, unsigned ll y)
    {
        ll res = 1;
        while (y > 0)
        {
            if (y & 1)
                res = res*x;
            y = y>>1;
            x = x*x;
        }
        return res;
    }

    bool isPrime(int n)
    {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;

        if (n % 2 == 0 || n % 3 == 0)
            return false;

        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;

        return true;
    }
        void sieve()
    {
        spf[1] = 1;
        for (int i=2; i<MAXN; i++)
            spf[i] = i;
        for (int i=4; i<MAXN; i+=2)
            spf[i] = 2;
        for (int i=3; i*i<MAXN; i++)
        {
            if (spf[i] == i)
            {
                for (int j=i*i; j<MAXN; j+=i)
                    if (spf[j]==j)
                        spf[j] = i;
            }
        }
    }

    int lcm(int a, int b)
    {
        return (a*b)/__gcd(a,b);
    }
    signed main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        int t=1;
        //cin>>t;
        while(t--)
        {
           int n,k;
           cin>>n>>k;
           r(p,n);
           sort(p+1,p+n+1);
           ll sum=0;
           f(i,1,k)
           sum+=p[i];
           cout<<sum<<endl;
        }
    }


Measured memory_bytes: 3664
N = int(input())
A = list(map(int, input().split()))
if N%2==1:
    s = 0
    for a in A:
        s^=a
    if s==0:
        print("Yes")
    else:
        print("No")
else:
    s1 = 0
    for a in A[::2]:
        s1 ^= a
    s2 = 0
    for a in A[1::2]:
        s2 ^= a
    if s1 == s2 == 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 14116
n=int(input())
a=list(map(int,input().split()))
cnt=0
while(1):
     a.sort()
     if a[1]==10**9+1:
          print(a[0])
          break
     m0=a[0]
     for i in range(n-1-cnt):
          m1=a[i+1]
          m1-=m0*(m1//m0)
          if m1==0:
               cnt+=1
               a[i+1]=10**9+1
          else:
               a[i+1]=m1

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_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(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    int D, T, S;
    cin >> D >> T >> S;
    cout << (D - T * S <= 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define INF (1<<29)
using namespace std;
int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){return x+y-min(x,y);}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
//ARC098
bool color[10000];//white=true,black=false
int main()
{
    long long n;
    cin>>n;
    long long a[n],cnt[21];
    rep(i,n)
    {
        cin>>a[i];
    }
    rep(i,21)
    {
        cnt[i]=0;
    }
    long long  fl=0,fl2=0,val,ans=0,last=0;
    bool flag=-1;
    rep(i,n)
    {
        val=a[i];
        rep(j,21)
        {
            if(val%2==1)
            {
                if(cnt[j]==1)
                {
                    fl2++;
                }
                cnt[j]++;
            }
            else{}
            val=val/2;
        }
        if(fl2!=0)
        {
            if(last-fl>=2)
            {
                ans-=((last-fl)*(last-fl-1))/2;
            }
            ans+=((i-fl)*(i-fl-1))/2;
            while(fl2!=0)
            {
                val=a[fl];
                rep(j,21)
                {
                    if(val%2==1)
                    {
                        if(cnt[j]==2)
                        {
                            fl2--;
                        }
                        cnt[j]--;
                    }
                    else{}
                    val=val/2;
                }
                fl++;
            }
            last=i;
        }
    }
    if(last-fl>=2)
    {
        ans-=((last-fl)*(last-fl-1))/2;
    }
    ans+=((n-fl-1)*(n-fl))/2+n;
    W(ans)
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
	char S[27];
	scanf("%s", &S);
	
	int i, j, l, flag[26] = {};
	for (l = 0; S[l] != 0; l++) flag[S[l] - 'a'] = 1;
	if (l < 26) {
		for (i = 0; i < 26; i++) if (flag[i] == 0) break;
		printf("%s%c\n", S, 'a' + i);
		fflush(stdout);
		return 0;
	}
	
	for (i = l - 1; i > 0; i--) {
		flag[S[i] - 'a'] = 0;
		if (S[i-1] < S[i]) break;
	}
	if (i == 0) printf("-1\n");
	else {
		for (j = S[i-1] - 'a'; j < 26; j++) if (flag[j] == 0) break;
		S[i-1] = 'a' + j;
		S[i] = 0;
		printf("%s\n", S);
	}
	
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

#define NUM_MAX 2000
#define DIVISOR 1000000007

struct pair {
    int x;
    int y;
};

struct pair gcdext(int a, int b) {
    if(a==0) { return (struct pair){0, 1}; }
    struct pair p = gcdext(b%a, a);
    return (struct pair){p.y - (b/a)*p.x, p.x};
}
static int64_t factorial[NUM_MAX+2];
static int64_t inv_factorial[NUM_MAX+2];

void init_combi(int size) {
    factorial[0] = factorial[1] = 1;
    inv_factorial[0] = inv_factorial[1] = 1;
    int i;
    for(i = 2; i <= size; i++) {
        factorial[i] = (factorial[i-1] * i)%DIVISOR;
        struct pair p = gcdext(i, DIVISOR);
        int inv = (p.x + DIVISOR)%DIVISOR;
        inv_factorial[i] = (inv_factorial[i-1] * inv)%DIVISOR;
    }
    return;
}

int64_t calc_combi(int n, int k) {
    if(k > n) return 0;
    int64_t ans = 1;
    ans = (ans * factorial[n])%DIVISOR;
    ans = (ans * inv_factorial[n-k])%DIVISOR;
    ans = (ans * inv_factorial[k])%DIVISOR;
    return ans;
}

int main(void) {
    int num, blues;
    get_int2(&num, &blues);
    int reds = num - blues;

    init_combi(num+1);

    int i;
    for(i = 1; i <= blues; i++) {
        int64_t ans = 1;
        ans = (ans * calc_combi(reds+1, i))%DIVISOR;
        ans = (ans * calc_combi(blues-1, i-1))%DIVISOR;
        printf("%d\n", (int)ans);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
    int A,B,K;
    cin >> A >> B;
    if((A+B)%2==0) cout << (A+B)/2 << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdio.h>
using namespace std;

struct Point
{
	double x, y;
};

void koch(int d, Point p1, Point p2)
{
	if (d == 0) return ;
	Point s, t, u;
	s.x = (2 * p1.x + 1 * p2.x) / 3;
	s.y = (2 * p1.y + 1 * p2.y) / 3;
	t.x = (1 * p1.x + 2 * p2.x) / 3;
	t.y = (1 * p1.y + 2 * p2.y) / 3;
	u.x = (t.x - s.x) * cos(M_PI / 3) - (t.y - s.y) * sin(M_PI / 3) + s.x;
	u.y = (t.x - s.x) * sin(M_PI / 3) + (t.y - s.y) * cos(M_PI / 3) + s.y;

	koch(d - 1, p1, s);
	printf("%.9lf %.9lf\n", s.x, s.y);
	koch(d - 1, s, u);
	printf("%.9lf %.9lf\n", u.x, u.y);
	koch(d - 1, u, t);
	printf("%.9lf %.9lf\n", t.x, t.y);
	koch(d - 1, t, p2);
}

int main()
{
	Point p1, p2;
	int n;

	cin >> n;
	p1.x = 0, p1.y = 0;
	p2.x = 100, p2.y = 0;

	printf("%.9lf %.9lf\n", p1.x, p1.y);
	koch(n, p1, p2);
	printf("%.9lf %.9lf\n", p2.x, p2.y);

	return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    

  int main(){
   lint x;
   cin>>x;
   lint f=x/500;
   lint g=x-f*500;
   lint c=g/5;
   cout<<c*5+f*1000;

  }
  
  
     
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
    string w;int m,n;
    while (1){
        cin>>w>>m;
        if(w=="-") break;
        for(int i=0;i<m;i++){
            cin>>n;string sw;
            sw=w.substr(0,n);
            w.erase(0,n);
            w+=sw;
        }
        cout<<w<<endl;
    }
    
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    double ans = 0;
    vector<double> x(N);
    vector<string> u(N);
    for(int i = 0;i < N;i++){
        cin >> x[i];
        cin >> u[i];
    }
    for(int i = 0;i < N;i++){
        if(u[i] == "JPY"){
          ans+= x[i];
        }else {
            ans+= x[i]*380000;
}
    }

    cout<<setprecision(20)<<ans<<endl;
        return 0;
    }


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> data(N);
  for(int i=0;i<N;i++){
    cin>>data.at(i);
  }
  sort(data.begin(), data.end());
  reverse(data.begin(), data.end());
  int i = 0;
  int cnt = 1;
  int tmp = data.at(i);
  while (true)
  {
    if(tmp>data.at(i)){
      cnt++;
    }
    tmp = data.at(i);
    i++;
    if(i==N)
      break;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define inf    0x3f3f3f3f
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
typedef vector<int>      vi;
typedef vector<bool>     vb;
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
//#define random_shuffle(r...)random_shuffle(r,[](int _){return my_rand()%_;})

  int main(){

   int n; cin>>n;
   string s; cin>>s;

   ll r=0,cnt=0;

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

   for(int j=0;j<r;j++){
      if(s[j] == 'W')
      cnt++; }

    cout<<cnt<<endl;

  return 0;
  }

Measured memory_bytes: 3668
N = int(input())

x_list = list(map(int, input().split()))

max_x = max(x_list)
min_x = min(x_list)

each_value_list = []
min_value = 10e1000
for i in range(min_x, max_x + 1):
    tmp_sum = 0
    for x in x_list:
        tmp_sum += (x - i)**2
    if min_value > tmp_sum:
        min_value = tmp_sum

print(min_value)

Measured memory_bytes: 38896
#include <iostream>
#include <string>
 
int main(){
	const std::string wrong_word("Hoshino");
	const std::string right_word("Hoshina");
	int num;
	std::cin >> num;
	std::cin.ignore();
	 
	for(int i = 0; i < num; ++i){
		std::string str;
		std::getline(std::cin, str);
		std::string::size_type pos = str.find(wrong_word);
		 
		while(pos != std::string::npos){
			str.replace(pos, wrong_word.length(), right_word);
			pos = str.find(wrong_word);
		}
		std::cout << str << std::endl;
	}
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;
using ll = long long;
int main() {
    int N; cin >> N;
    vector<int> D(N);
    for (int i=0;i<N;i++){
        cin >> D[i];
    }
    sort(D.begin(),D.end());
    int ans=0;
    int a = D[(N-1)/2-1];
    int b = D[(N-1)/2];
    int c = D[N/2];
    int d = D[N/2+1];
    // cout << a <<" " << b <<" " << c << " "<< d << endl;
    if (b<c) ans = c-b;
    // if (b<c) {
    //     if (a<b&&c<d) ans = c-b;
    //     else if (a<b&&c==d) ans = (c-1)-b;
    //     else if (a==b&&c<d) ans = c-(b+1);
    //     else if (a==b&&c==d) ans = (c-1)-(b+1);
    // }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
ll f[5000005];
ll modpow(ll a,ll n){
    ll ret = 1LL,t = a;
    while(n){
        if(n%2 == 1) ret = ret*t%mod;
        t = t*t%mod; n/=2;
    }
    return ret;
}
ll C(int a,int b){
    return f[a] * modpow(f[b],mod-2) % mod * modpow(f[a-b],mod-2) % mod;
}
int main(){
    f[0] = 1LL;
    for(int i=1;i<5000005;i++){
        f[i] = f[i-1]*1LL*i%mod;
    }
    while(1){
        int a,b,c,s1,s2;
        cin >> a >> c >> b >> s1 >> s2;
        if(a+b+c == 0) return 0;
        int S = min(s1,s2);
        ll ret = 0;
        for(int i=0;i<=S;i++){
            //s1-i???a???????????? & s2-i???c???????????? & i???a+b+c?????????
            if(s1-i < a || s2-i < c) continue;
            ll p = (a?C(s1-i-1,a-1):1); if(a == 0 && s1-i != 0) continue;
            ll q = (c?C(s2-i-1,c-1):1); if(c == 0 && s2-i != 0) continue;
            ret += p * q % mod * C(i+a+b+c-1,i) % mod;
        }
        ret %= mod;
        ret = ret * (C(a+b+c,a) * C(b+c,b) % mod) % mod;
        cout << ret << endl;
    }
}

Measured memory_bytes: 42100
#include <stdio.h>

int main(void){

	int n, u, i, j, k, v;
	int a[101][101] = {0};
	
	scanf("%d", &n);
	
	for(i=0; i<n; i++){
		scanf("%d%d", &u, &k);
		for(j=0; j<k; j++){
			scanf("%d", &v);
			a[u][v] = 1;
		}
	}
	
	for(i=0; i<n; i++){
		for(j=0; j<n; j++){
			printf("%d%c", a[i+1][j+1], (j==n-1?'\n':' '));
		}
	}
	
	return 0;

}

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

int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    for(int i=0;i<n;++i) cin>>h[i];
    reverse(h.begin(),h.end());
    int ans=0;
    int val=0;
    for(int i=1;i<n;i++){
        if(h[i-1]<=h[i]) val++;
        else val=0;
        ans=max(ans,val);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 2000009
#define MOD 1000000007
#define endl '\n'
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);
#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#endif
    ll n;
    cin>>n;
    cout<<int(ceil(n/1000.0)*1000)-n<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    char c;
    cin >> c;
    switch(c) {
        case 'a':
        case 'i':
        case 'u':
        case 'e':
        case 'o':
            cout << "vowel" << endl;
            break;
        default:
            cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, b;
  in(n);
  vector<ll> c(n);
  rep(i, n){
    in(b);
    c[i] = b - i - 1;
  }
  sort(all(c));
  a = (c[n / 2] + c[(n - 1) / 2]) / 2;
  b = 0;
  rep(i, n){
    b = b + abs(a - c[i]);
  }
  out(b);
  memi;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N;
  cin >> N;

  map<char, int> mp;
  for (int i = 0; i < N; i++) {
    char S;
    cin >> S;
    mp[S]++;
  }
  cout << (mp.size() == 3 ? "Three" : "Four") << endl;

  return 0;
}

Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())

ans=10**12
for i in range(max(X,Y)+1):
    cnt=0
    cnt+=i*C*2
    cnt+=max(0,X-i)*A
    cnt+=max(0,Y-i)*B
    ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 65836
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    int a, b, t;
    cin >> a >> b >> t;

    cout << t / a * b << endl;
    
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int A,B,C;

	scanf("%d%d%d",&A,&B,&C);

	if(1>A || A>100)
	printf("eroor\n");
	else if(1>B || B>100)
	printf("eroor\n");
	else if(1>C || C>100)
	printf("eroor\n");
	else{
		if(B/A<C)
			printf("%d",B/A);
		else
			printf("%d",C);
	}
return 0;
}

Measured memory_bytes: 128
from collections import deque
H, W = map(int, input().split())
s = ['#'*(W+2)] + ['#'+input()+'#' for _ in range(H)] + ['#'*(W+2)]
ans = 0

for y in range(1, H+1):
    for x in range(1, W+1):
        if s[y][x] == '#':
            continue
        visited = [[0]*(W+2) for _ in range(H+2)]
        visited[y][x] = 1
        max_s = 0
        dq = deque([(y, x, 0)])

        while dq:
            cy, cx, steps = dq.popleft()
            if steps > max_s:
                max_s = steps
            steps += 1

            for dy, dx in ((cy+1, cx), (cy-1, cx), (cy, cx+1), (cy, cx-1)):
                if s[dy][dx] == '#' or visited[dy][dx]:
                    continue
                visited[dy][dx] = 1
                dq.append((dy, dx, steps))

        ans = max(ans, max_s)

print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int X, A; cin >> X >> A;
	cout << (X<A?0:10) << endl;
}


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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;
 
// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) scanf("%d", a + i);

  int odd = 0;
  for (int i = 0; i < N; i++) if (a[i] & 1) {
    odd++;
  }

  cout << (odd > 0 ? "first" : "second") << endl;

  return 0;
}


Measured memory_bytes: 640