akhauriyash/Code-Regression huggingface dataset:
void main()
{
    long[] tmp = rdRow;
    long h = tmp[0], n = tmp[1];
    long[] a = rdRow;

    writeln(a.sum >= h ? "Yes" : "No");
}

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 4376
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
bool in(int x,int y){
	if(x>=0 && x<8 && y>=0 && y<8){
		return true;
	}else{
		return false;
	}
}
int n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		char field[10][10];
		for(int j=0;j<8;j++){
			scanf(" %s",field[j]);
		}
		int a,b;
		scanf("%d %d",&a,&b);
		queue<P>que;
		que.pu(mp(b-1,a-1));
		while(!que.empty()){
			P p=que.front();
			que.pop();
			field[p.first][p.second]='0';
			int dx[12]={-1,-2,-3,0,0,0,1,2,3,0,0,0};
			int dy[12]={0,0,0,-1,-2,-3,0,0,0,1,2,3};
			for(int j=0;j<12;j++){
				if(in(p.first+dx[j],p.second+dy[j])){
					if(field[p.first+dx[j]][p.second+dy[j]]=='1'){
						que.push(mp(p.first+dx[j],p.second+dy[j]));
						field[p.first+dx[j]][p.second+dy[j]]='0';
					}
				}
			}
		}
		printf("Data %d:\n",i);
		for(int j=0;j<8;j++){
			printf("%s\n",field[j]);
		}
	}
}

Measured memory_bytes: 1200
#include<cstdio>
#include<algorithm>

using namespace std;

const long long mod = 1000000007;

long long fact[4000400];
long long ifact[4000400];
long long invs[4000400];

const int MA = 4000300;

void init(){
	//factorial
	invs[1] = 1;
	for(int i = 2; i < MA; ++i){
		long long k = mod / i;
		long long l = mod % i;
		long long tmp = -k * invs[l];
		tmp %= mod;
		if(tmp < 0) tmp += mod;
		invs[i] = tmp;
	}
	
	fact[0] = 1;
	ifact[0] = 1;
	for(int i = 1; i < MA; ++i){
		fact[i] = (fact[i - 1] * i) % mod;
		ifact[i] = (ifact[i - 1] * invs[i]) % mod;
	}
}

long long C(int n, int k){
	if(k < 0 || k > n) return 0;
	long long res = fact[n];
	res *= ifact[k];
	res %= mod;
	res *= ifact[n - k];
	res %= mod;
	return res;
}

int N, K;

long long dp[2020][2020];
long long sum[2020][2020];

long long solve(){
	if(K == 1) return 1;
	for(int i = 0; i <= N; ++i){
		for(int j = 0; j <= N; ++j){
			dp[i][j] = 0;
			sum[i][j] = 0;
		}
	}
	dp[N][1] = 1;
	sum[N][1] = 1;
	sum[N][0] = 1;
	for(int i = N - 1; i >= 1; --i){
		for(int j = 1; j <= N; ++j){
			int d = N - i;
			if(j > d + 1){
				dp[i][j] = 0;
				continue;
			}
			int num = d * K - (j - 1);
			int cur = K - 1;
			long long coe = C(num + cur - 1, cur - 1);
			dp[i][j] += dp[i + 1][j - 1] * coe;
			dp[i][j] %= mod;
			
			coe = C(num + cur - 1, cur - 1);
			dp[i][j] += sum[i + 1][j] * coe;
			dp[i][j] %= mod;
		}
		sum[i][N] = dp[i][N];
		for(int j = N - 1; j >= 0; --j){
			sum[i][j] = (sum[i][j + 1] + dp[i][j]) % mod;
		}
	}
	long long ans = 0;
	for(int i = 0; i <= N; ++i){
		ans += dp[1][i];
		ans %= mod;
	}
	ans *= fact[N];
	ans %= mod;
	return ans;
}

int main(){
	scanf("%d%d", &N, &K);
	init();
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 157056
#include <bits/stdc++.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
int main(){
  	int N, a[100], i, T, t, s=0, S[99];
		cin >> N;
		for(i=0; i<N; i++){
				cin >> a[i];
				s += a[i];
			}
		for(T=0; T<N-1; T++){
			t=0;
    	for (i = 0; i <= T; i++) {
        t += a[i];
    	}
			S[T] = t;
		}
		int min = abs(2 * S[0] - s);
		for(i=1; i<T; i++){
			if(abs(2 * S[i] - s)<=min){
				min = abs(2 * S[i] - s);
			}
			}

    cout << min <<endl;
}


Measured memory_bytes: 256
def main():
    n, x = map(int, input().split())

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

    result = 1
    D = 0

    for i in range(0, n):
        Dn = D + L[i]

        if Dn <= x:
            result += 1

        D = Dn



    return result



if __name__ == "__main__":
    print(main())



Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
#include<numeric>
#include<limits>
#include<type_traits>
using namespace std;

int main(void){
  //入力
  string S;
  cin >> S;
  vector<int > A;
  for(int i = 0; i < S.size(); i++){
    int temp = S[i] - '0';
    A.push_back(temp);
  }
  //ビット全探索を行う．
  //1の時+，0の時-
  int ans_bit = -1;
  for(int i = 0; i < pow(2, A.size()-1); i++){
    int temp_sum = A[0];
    for(int j = 0; j < A.size() - 1; j++){
      if(i & (1<<j)){
        temp_sum += A[j+1];
      }
      else{
        temp_sum -= A[j+1];
      }
    }
    if(temp_sum == 7){
      ans_bit = i;
      break;
    }
  }
  //出力
  for(int i = 0; i < A.size(); i++){
    cout << A[i];
    if(i < A.size()-1){
      if(ans_bit & (1<<i)){
        cout << '+';
      }
      else{
        cout << '-';
      }
    }
  }
  cout << "=7" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int n;
int s;
int count;

void sum(int x,int y,int z){
  int i;
  if(x==n && z==s){
    count++;
  }
  for(i=y;i<10;i++){
    sum(x+1,i+1,z+i);
  }
}
int main(){
  while(1){
    scanf("%d %d",&n,&s);
    if(n==0 && s==0)break;
    count=0;
    sum(0,0,0);
    printf("%d\n",count);
  }
  return 0;
}

Measured memory_bytes: 1668
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int N; cin >> N;
  vector<int> X(N);
  for (int i = 0; i < N; i++) cin>>X[i];
  int M; cin >> M;
  vector<int> A(M);
  for (int i = 0; i < M; i++) cin>>A[i];
  
  for (int i = 0; i < M; i++) {
    int ok = 1;
    for (int j = 0; j < N; j++) {
      if (X[A[i]-1]+1 == X[j]) {
        ok = 0;
        break;
      }
    }
    if (ok && X[A[i]-1] != 2019) {
      X[A[i]-1]++;
    }
  }
  
  for (int i = 0; i < N; i++) {
    cout << X[i] << endl;
  }
}




Measured memory_bytes: 3112
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=3005;
int f[MAXN],mod,a[MAXN];
int pow_mod(int a,int b)
{
	int ret=1;
	for(;b;b>>=1,a=1LL*a*a%mod)if(b&1)ret=1LL*ret*a%mod;
	return ret;
}
int g[MAXN],h[MAXN];
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
void dl(int &x,int y){x-=y;if(x<0)x+=mod;}
void mul(int *x,int *y,int len)
{
	static int A[MAXN];memset(A,0,sizeof(A));
	for(int i=0;i<len;i++)for(int j=0;j<=1;j++)
		ad(A[i+j],1LL*x[i]*y[j]%mod);
	for(int i=0;i<=len;i++)x[i]=A[i];
}
void div(int *x,int *y,int len,int mu)
{
	static int A[MAXN],B[MAXN];memset(B,0,sizeof(B));
	int inv=pow_mod(y[1],mod-2);
	for(int i=0;i<len;i++)A[i]=x[i];
	for(int i=len-1;i>0;i--)
	{
		ad(B[i-1],A[i]);dl(A[i-1],1LL*A[i]*y[0]%mod);
	}
	for(int i=0;i<len;i++)ad(h[i],1LL*B[i]*mu%mod);
}
int main()
{
	mod=read();
	for(int i=0;i<mod;i++)a[i]=read();
	f[0]=1;
	for(int i=0;i<mod;i++)
	{
		g[0]=(-i+mod)%mod;g[1]=1;
		mul(f,g,i+1);
	}
	for(int i=0;i<mod;i++)
	{
		int mu=1;
		for(int j=0;j<mod;j++)if(i!=j)mu=1LL*mu*(i%mod-j%mod+mod)%mod;
		mu=1LL*pow_mod(mu,mod-2)*a[i]%mod;g[0]=(-i+mod)%mod;g[1]=1;
		div(f,g,mod+1,mu);
	}
	for(int i=0;i<mod;i++)pr1(h[i]);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,p,sum;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&p);
	int J;
	J=a*p;
	if(p>c){
		int K;
		K=p-c;
		sum=d*K;
		b=b+sum;
	}
	if(J>b){
		printf("%d",b);
	}
	else if(J==b){
		printf("%d",b);
	}
	else if(J<b){
		printf("%d",J);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <algorithm> //min

using namespace std;

int main() {

	int L, R;
	cin >> L >> R;

	int mod_min = 2018; //余りはどんなに大きくても2018

	R = min(R, L + 2020); //2019周期でパターンが同じなので

	for (int i = L; i < R; i++)
	{
		for (int j = i + 1; j <= R; j++)
		{

			int mod = ((i % 2019) * (j % 2019)) % 2019;
			//cout << mod << "\n";

			if (mod < mod_min) {
				mod_min = mod;
			}
		}
	}

	cout << mod_min;

	return 0;
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int dy[] = {0, 1, 0, -1};
int dx[] = {1, 0, -1, 0};

int main(){

    int h,w;
    cin >> h >> w;

    int ch,cw, dh,dw;
    cin >> ch >> cw;
    cin >> dh >> dw;

    const int max = INT_MAX;

    ch--;
    cw--;
    dh--;
    dw--;

    vector<string> s(h);

    rep(i, h){
        cin >> s[i];
    }

    typedef pair<int, pair<int, int>> State;

    priority_queue<State, vector<State>, greater<State>> pq;

    pq.push(make_pair(0, make_pair(ch, cw)));

    function<bool(int, int)> judge = [&](int y, int x) -> bool{
        return 0 <= y && y < h && 0 <= x && x < w && s[y][x] == '.';
    };

    vector<vector<int>> v(h, vector<int>(w, max));

    while(!pq.empty()){

        int tmpd = pq.top().first;
        int tmpy = pq.top().second.first;
        int tmpx = pq.top().second.second;

        pq.pop();

        //if(tmpy == 0 && tmpx == 0 && tmpd == 0) cerr << "catch!!" << endl;

        if(tmpd < v[tmpy][tmpx]){

            //cerr << tmpy << " " << tmpx << " " << v[tmpy][tmpx] << " " << tmpd << endl;

            v[tmpy][tmpx] = tmpd;

            rep(i, 4){
                int nexty = tmpy + dy[i];
                int nextx = tmpx + dx[i];

                if(judge(nexty, nextx)){
                    //if(nexty == 0 && nextx == 0 && tmpd == 0) cerr << "push!!" << endl;
                    pq.push(make_pair(tmpd, make_pair(nexty, nextx)));
                }
            }

            for(int i = -2; i <= 2; i++){
                for(int j = -2; j <= 2; j++){
                    int nexty = tmpy + i;
                    int nextx = tmpx + j;

                    if(judge(nexty, nextx)){
                        pq.push(make_pair(tmpd + 1, make_pair(nexty, nextx)));
                    }
                }
            }
        }
    }

    cout << (v[dh][dw] == max ? -1 : v[dh][dw]) << endl;
    return 0;
}

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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int x, y, a , b  ;
    cin >> x >> y;
    for(int a = 0; a <= x; a++) {
        b = x - a;
        int z = a * 2 + b * 4;

        if (y == z) {
            cout << "Yes";
            return  0;
        }
    }
    cout << "No";


}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int main() {
    int a, b, m;
    cin >> a >> b >> m;
    vector<int> fr(a);
    for (auto &e: fr) cin >> e;
    vector<int> mi(b);
    for (auto &e: mi) cin >> e;

    int ans = *min_element(fr.begin(), fr.end()) + *min_element(mi.begin(), mi.end());

    for (int i = 0; i < m; ++i) {
        int x, y, c;
        cin >> x >> y >> c;
        ans = min(ans, fr[x-1]+mi[y-1]-c);
    }

    cout << ans << endl;
    


    return 0;
}


Measured memory_bytes: 1024
/*input
6
1 1
2 2
3 3
4 4
5 5
6 6
*/

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

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      cnt++;
      if (cnt == 3) {
        cout << "Yes" << endl;
        return 0;
      }
    }
    else cnt = 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int m;
map<string, int> f;
int main()
{
	string s, t, u;
	int N=0;
	while(cin >> s)
	{
		f[s]++;
		if(f[s]>N)
		{
			N++;
			t=s;
		}
		if(s.size()>u.size())
		{
			u=s;
		}
	}
	cout << t << ' ' << u << endl;
	return 0;
}

Measured memory_bytes: 3064
//Littleboy123 Template 1.7
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

//pragmas

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")t
// #pragma GCC optimization ("unroll-loops")


typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef unsigned long long int ull;
typedef long double ld;
typedef unsigned long long ull;

const long double pi = acos(-1.0);

#define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define TC(n) cout << "Case #" << (n) << ": "
#define DEBUG(x) cout << "DEBUG " << #x << ' ' << x << '\n';
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>

void init(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

void infile(){
    freopen("fenwick.in", "r", stdin);
}

void outfile(){
    freopen("fenwick.out", "w", stdout);
}

ll modex(ll a, ll b, ll mod){
    if(b == 0)
        return 1;
    if(b == 1)
        return a;
    ll tmp = modex(a, b/2LL, mod);
    tmp = (tmp * tmp) % mod;
    if(b & 1LL)
        tmp = (tmp * a) % mod;
    return tmp;
}

//End of template

int main(){
    init();

    string s;
    cin >> s;
    ll mod = 0;
    int len = s.length();
    FOR(i, 0, len){
        mod *= 10;
        mod += s[i]-'0';
        mod %= 9;
    }
    if(mod == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 3740
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
#include <fstream>
#include <climits>
 
  using namespace std;
   
 
//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ

  typedef long long ll;
  typedef long double lld;
  typedef unsigned long long ull;
  int INF = INT_MAX;
  ll mod = 1e9+7;
  // lld PI = 3.141592653;


  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     // fstream cin("text.txt");

      int n;
      cin>>n;
      char a[n][n];
      bool ok = false;
      for (int x = 0; x<n;x++){
        for (int y = 0;y<n;y++){
          cin>>a[x][y];
          if (a[x][y]=='#') ok = true;
        }
      }

      if (!ok){
        cout<<"-1\n";
        return 0;
      }
     
      int cost = n;
      vector<bool> row(n);

      for (int y = 0; y<n; y++){
        bool bb = false;
        for (int x =0;x<n;x++){
          if (a[x][y] == '#') bb =true;
        }
        row[y] = bb;
      }

      for (int x = 0; x<n; x++){
        int cnt = 0;
        for (int y =0;y<n;y++){
          if (a[x][y] == '#') cnt++;
        }
        cnt = n- cnt;
        if (!row[x]) {cnt++; }
        cost = min(cost, cnt);
      }


      int str = 0;
      for (int y = 0; y<n; y++){
        int cnt = 0;
        for (int x = 0;x<n;x++){
          if (a[x][y] == '.') cnt = 1;
        }
        str += cnt;
      }
      cout<< cost+ str <<"\n";
}
  

Measured memory_bytes: 3388
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

const int mod = 1e9+7;
struct mint {
    ll x;
    mint (ll x = 0) : x((x%mod+mod)%mod) {}
    mint operator -() const {return mint(-x);}
    mint& operator +=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator -=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator *=(const mint a) {(x *= a.x) %= mod; return *this;}
    mint operator +(const mint a) const {return mint(*this) += a;}
    mint operator -(const mint a) const {return mint(*this) -= a;}
    mint operator *(const mint a) const {return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {return pow(mod-2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {return mint(*this) /= a;}
};
istream& operator >>(istream &is, const mint &a) {return is >> a.x;}
ostream& operator <<(ostream &os, const mint &a) {return os << a.x;}

int main() {
    int n, m; cin >> n >> m;
    vint x(n), y(m);
    rep(i,n) cin >> x[i];
    rep(i,m) cin >> y[i];
    auto f_x = [&](int i) {
        return (mint)i*(n-i)*(x[i]-x[i-1]);
    };
    auto f_y = [&](int j) {
        return (mint)j*(m-j)*(y[j]-y[j-1]);
    };
    mint sum_x = 0, sum_y = 0;
    REP(i,n) sum_x += f_x(i);
    REP(j,m) sum_y += f_y(j);
    mint ans = sum_x * sum_y;
    cout << ans << endl;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

string sh(const string& str){
  char p = str[0];
  string res;
  res += p;
  for(int i = 1; i < str.size(); i++){
    if(p=='a' || p=='e' || p=='i' || p=='o' || p=='u'){
      res += str[i];
    }
      p = str[i];
  }
  return res;
}
int main(){
  int n;
  while(cin >> n, n != 0){
    vector<string> s(n);
    REP(i,n) cin >> s[i];
    int ml = 0;
    REP(i, n){
      ml = max(ml, (int)sh(s[i]).size());
    }
    int k;
    for(k = 1; k <= ml ; k++){
      set<string> ss;
      REP(i,n) {
        ss.insert(sh(s[i]).substr(0, k));
      }
      if(ss.size() == n) break;
    }
    if (k > ml){
      cout << -1 << endl;
    }else{
      cout << k << endl;
    }
  }
  return 0;
}

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

int a,b,c; 
cin >> a >> b >> c ;

if (a < b && b < c){
    cout << "Yes" << endl;
}
else {
    cout << "No" << endl;
}

return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int a,b,c;
	cin>>a>>b>>c;
	if((a+b+c)>=22)
	{
		cout<<"bust"<<endl;
	}
	else 
	{
		cout<<"win"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<map>
#include<cmath>
#include<algorithm>
#include<stack>
#include<deque>
#include<queue>
#include<vector>
#include<string>
#include<time.h>
#include<unordered_map>
#include<random>
#include<unordered_set>
#include<forward_list>

#pragma GCC optimize("Ofast")

#define ll long long
#define int long long
#define endl "\n"
#define ld long double
#define si pair<string,int>
#define mp make_pair
#define ii pair<int,int>
#define is pair<int,string>
#define fi first
#define se second
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable : 4996)


using namespace std;


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

    //freopen("08.in", "r", stdin);
	//freopen("output.txt", "w", stdout);

	//mt19937 gen{ std::random_device{}() };
	//gen();
	
	string str;
	cin >> str;
	if (str[2] == str[3] && str[4] == str[5])cout << "Yes";
	else cout << "No";



	//system("pause");
	return 0;
}

Measured memory_bytes: 256
a,b,k=map(int,input().split())
k2=0
a2=0
if a>=k:
    k2=a-k
    a=a-k
    print("{0} {1}".format(a,b))
    exit()
else:
    k2=k-a
    a=0
if b>=k2:
    b=b-k2
else:
    b=0
print("{0} {1}".format(a,b))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	private static final int X = 600;

    public static void main(String[] args) {

        //input
        Scanner sc = new Scanner(System.in);

        int S,d;
        while(sc.hasNext()){
            S = 0;
        	d = sc.nextInt();
        	for(int i=1,j=d;j<X;j+=d,i++){
        		S += Math.pow(d*i,2)*d;
        	}

        	//output
        	System.out.println(S);
        }
    }
}

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

int main() {
  int N, sum;
  cin >> N;
  
  for (int i=0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    int x =b-a+1;
    sum += x;
  }
  cout << sum <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (100001)
#define MOD (1000000007)


char l[MAXN+1];
ll dp[MAXN+1][2];

int main(void)
{
    scanf("%s",l);
    ll len = 0;
    while(l[len]!='\0') len++;

    dp[0][0] = 1;
    for(ll i=0;i<len;i++)
    {
        if(l[i]=='0')
        {
            dp[i+1][0] = dp[i][0];
            dp[i+1][1] = dp[i][1]*3 % MOD;
        }else
        {
            dp[i+1][0] = dp[i][0]*2 % MOD;
            dp[i+1][1] = (dp[i][0] + dp[i][1]*3) % MOD;
        }
    }
    ll ans = (dp[len][0] + dp[len][1])% MOD;
    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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

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

int main(){
    int N;
    cin>>N;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
        if(i*j==N){
            cout<<"Yes"<<endl;
            return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}
//a=97,z=122

Measured memory_bytes: 256
if __name__ == '__main__':
    x, y, z = (int(_) for _ in input().split(' '))
    if x % 2 == 0 or y % 2 == 0 or z % 2 == 0:
        print(0)
    else:
        t = max((x, y, z))
        if t == x:
            print(y * z)
        elif t == y:
            print(x * z)
        elif t == z:
            print(x * y)


Measured memory_bytes: 3064
N=int(input())
E=[list(map(int,input().split())) for i in range(N-1)]
C=list(map(int,input().split()))
C.sort(reverse=True)

print(sum(C[1:]))

ELIST=[[] for i in range(N+1)]
for a,b in E:
    ELIST[a].append(b)
    ELIST[b].append(a)

from collections import deque
QUE=deque([1])
i=0
ANS=[-1]*(N+1)
while QUE:
    x=QUE.pop()
    ANS[x]=C[i]
    i+=1

    for to in ELIST[x]:
        if ANS[to]==-1:
            QUE.append(to)
            ANS[to]=0

print(*ANS[1:])
    

Measured memory_bytes: 7584
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll N, L; cin >> N >> L;
	string s[100];
	rep(i, 0, N) {
		cin >> s[i];
	}
	sort(s, s + N);
	rep(i, 0, N) {
		cout << s[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#-*- coding:utf-8 -*-

if __name__ == "__main__":
	N = int(input())
	blue_cards = [input() for i in range(N)]
	M = int(input())
	red_cards = [input() for i in range(M)]
	# STőˇé(O(N*N*M), X10^6)
	max_money = 0
	for word in blue_cards:
		money = 0
		for blue in blue_cards:
			if word == blue:
				money += 1
		for red in red_cards:
			if word == red:
				money -= 1
		if money > max_money:
			max_money = money
	print(max_money)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

// auto mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator-=(const mint a) {
      if ((x += mod-a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
      if (t&1) a *= *this;
      return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[110][5][5][5];

int main() {
    int n; cin >> n;
    // Sは333Sなら0, 1, 2は影響しない
    dp[0][3][3][3] = 1;

    for(int len = 0; len < n; ++len) {
        for(int i = 0; i < 4; ++i) {
            for(int j = 0; j < 4; ++j) {
                for(int k = 0; k < 4; ++k) {
                    // 新しく追加する文字
                    for(int m = 0; m < 4; ++m) {
                        if(m == 2 && i == 1 && j == 0) continue;
                        if(m == 2 && i == 0 && j == 1) continue;
                        if(m == 1 && i == 2 && j == 0) continue;
                        if(m == 2 && i == 1 && k == 0) continue;
                        if(m == 2 && j == 1 && k == 0) continue;

                        dp[len+1][m][i][j] += dp[len][i][j][k];
                    }
                }
            }
        }
    }

    mint ans = 0;
    for(int i = 0; i < 4; ++i) {
        for(int j = 0; j < 4; ++j) {
            for(int k = 0; k < 4; ++k) {
                ans += dp[n][i][j][k];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

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

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

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

	string str;
	for (int i = 0; i < n; i++)
	{
		str += s.at(i);
	}

	cout << str << endl;
}

Measured memory_bytes: 256
S=input()
K=int(input())
alpha=set()
for i in S:
    alpha.add(i)
for i in range(len(S)-1):
    alpha.add(S[i:i+2])
for i in range(len(S)-2):
    alpha.add(S[i:i+3])
for i in range(len(S)-3):
    alpha.add(S[i:i+4])
for i in range(len(S)-4):
    alpha.add(S[i:i+5])
alpha=list(alpha)
alpha.sort()
print(alpha[K-1])


Measured memory_bytes: 40560
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
    long long N;
    cin >> N;
    long long M = (N - 1) * N / 2;
    cout << M << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a;
	int x;
	int y;
	for(;;){
		scanf("%d",&a);
		if (a==0)
		{
			return 0;
		}
		x=1000-a;
		y=x/500;
		x=x%500;
		y=y+x/100;
		x=x%100;
		y=y+x/50;
		x=x%50;
		y=y+x/10;
		x=x%10;
		y=y+x/5;
		x=x%5;
		y=y+x;
		printf("%d\n",y);
	}		
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		double c = (double)(a+b)/2;
		//System.out.println(c);
		double syosuC = c-(int)c;
		int ans=0;
		if(syosuC>0) {
			ans = (int)c+1;
		}else {
			ans = (int)c;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 22736
#include <stdio.h>

int main(void)
{
	char str[1001];
	int i;
	
	scanf("%s", str);
	
	for (i = 0; str[i] != '\0'; i++){
		if (str[i] == 'A'){
			str[i] = 'X';
		}else if (str[i] == 'B'){
			str[i] = 'Y';
		}else if (str[i] == 'C'){
			str[i] = 'Z';
		}else {
			str[i] -= 3;
		}
	}
	
	printf("%s\n", str);
	
	return (0);
}

Measured memory_bytes: 524
a,b,c = map(int,input().split())
if a == 7:
    if b == 5 and c == 5:
        print('YES')
    else:
        print('NO')
elif b == 7:
    if a == 5 and c == 5:
        print('YES')
    else:
        print('NO')
elif c == 7:
    if a == 5 and b == 5:
        print('YES')
    else:
        print('NO')
else:
    print('NO')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
    	string s,t;
    	cin>>s>>t;
    	int i;

    	for(i=0;i<s.size();i++)
    	{
    		if(s[i]!=t[i])
    			break;
    	}

    	if(i==s.size())
    		cout<<"Yes\n";
    	else
    		cout<<"No\n";



    	
    }


	return 0;
}

Measured memory_bytes: 3652
n=int(input())
s=input()
x=[]
y=0
for i in range(n):
    if s[i]=="(":
        x.append("(")
        y+=1
    elif y>0:
        x.append(")")
        y-=1
    else:
        x.append(")")
        x=["("]+x
x=x+[")"]*y
print("".join(x))

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

int main(){
  int A , B , K ; 
  cin >> A >> B >> K ; 
  int N = max(A , B ) ; 
  int cnt = 0 ; 
  
  for(int i = N ; i >= 1 ; i--){
    if(A%i == 0 && B%i == 0 ){
      cnt++ ; 
    }
    //cout << i << " " << cnt << endl ; 
    if( cnt == K){
      cout << i << endl ; 
      return 0 ; 
    }
  }
  
}

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

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

int main() {
    int N,a,c2=0,c4=0,r=0;
    cin >> N;
    
    rep(i,N) {
        cin >> a;
        if(a%4 == 0)
            c4++;
        else if(a%2 == 0)
            c2++;
    }

    if(N%2 && c4)
        r++;
    r += c4*2 + c2;

    if(r >= N)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
}

Measured memory_bytes: 256
q,h,s,d = map(int,input().split())
n = int(input())

min2 = min(q*8,h*4,s*2,d)
min1 = min(q*4,h*2,s)

if 2*min1 < min2 or n == 1:
    print(n*min1)
else:
    if n%2:
        print((n//2)*min2+min1)
    else:
        print((n//2)*min2)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int mx=n/2+(n%2==0?0:1);
	if(k<=mx)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int d, n;
	cin >> d >> n;
	if (d == 0) {
		if (n == 100)
			cout << "101" << endl;
		else
			cout << n << endl;
	}
	else if (d == 1) {
		if (n == 100) {
			cout << "10100" << endl;
		}else
			cout << n * 100 << endl;
	}
	else {
		if (n == 100)
			cout << "1010000" << endl;
		else
			cout << n * 10000 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int ret=0;
	for(int i=0;i<s.size();i++)
	{
		for(int j=i;j<s.size();j++)
	{
		bool f=1;
			for(int k=i;k<=j;k++)
	{
		if(s[k]!='A'&& s[k]!='T'&&s[k]!='G'&&s[k]!='C') f=0;
	}
	if(f)
	{
		ret=max(ret,j-i+1);
	}
	}
	}
	cout<<ret<<endl;
}


Measured memory_bytes: 256
while true do
  str=gets.chomp
  num=str.split
  a=num[0].to_i
  b=num[1].to_i
  if a==0 && b==0 then
    break
  end
  if a<=b then
    puts "#{a} #{b}"
  elsif a>b then
    puts "#{b} #{a}"
  end
end

Measured memory_bytes: 8612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  int b[N];
  int all=0;
  memset(b,0,sizeof(b));
  for(int i=N;i>0;i--){
    int sum=0;
    int j=i;
    while (j<=N){
      sum+=b[j-1];
      j += i;
    }
    /*for(int j=i;j<N+1;j++){
      if(j%N==0) sum+=b[j-1];
      }*/
    if(sum%2!=a[i-1]) {
      b[i-1]=1;
    }
    all += b[i-1];
  }
  cout << all << endl;
  for (int i=0;i<N;i++){
    if(b[i]==1) cout << i+1 << " ";
  }
}


Measured memory_bytes: 4608
"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split("\n");

const N = parseInt(input[0], 10);

const A = input[1]
  .split(" ")
  .map(val => parseInt(val, 10))
  .sort((a, b) => a - b);

while (A[1]) {
  for (let i = 1; i < A.length; i++) {
    A[i] %= A[0];
  }
  A.sort((a, b) => a - b);

  A.splice(0, A.lastIndexOf(0) + 1);
}

console.log(A[0]);


Measured memory_bytes: 28864
from functools import reduce
import math

memo = []
memo_inv = []
MOD = 10**9+7
    
def get_factorial(i):
    return memo[i]

def get_factorial_inv(i):
    return memo_inv[i]

def nCr(n, r):
    return get_factorial(n) * get_factorial_inv(n-r) * get_factorial_inv(r)

def main():
    # 一文字のみを読み込み
    # s = input().rstrip().split(' ')
    
    # スペース区切りで標準入力を配列として読み込み
    # s = input().rstrip().split(' ')

    # 位置文字ずつ標準入力を配列として読み込み
    # s = list(input().rstrip())
    
    slist = input().rstrip().split(' ')
    H = int(slist[0])
    W = int(slist[1])
    A = int(slist[2])
    B = int(slist[3])
    global memo
    memo = [1]*(H+W+1)
    f= 1
    for i in range(1,H+W+1):
        f *=i
        f %=MOD
        memo[i] = f
        
    global memo_inv
    memo_inv = [1]*(H+W+1)
    memo_inv[H+W] = pow(memo[H+W],MOD-2,MOD)
    f_inv = memo_inv[H+W]
    for i in range(H+W-1,0,-1):
        f_inv *= i +1
        f_inv %= MOD
        memo_inv[i] = f_inv
        
    ans = 0
    for i in range(B,W):
        ans += nCr(i+H-A-1,i) * nCr(W-i-1+A-1,A-1)
    print(ans % MOD)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 19428
#include<bits/stdc++.h>
using namespace std;
char s[200007];
int main(){
	int n,i,res=0;
	long long ans=0;
	scanf("%s",s+1);
	n=strlen(s+1);
	for(i=1;i<=n;++i)
        if(s[i]=='A')
            ++res;
        else if(s[i]=='B'&&i<n&&s[i+1]=='C'){
            ans+=res;
            ++i;
        }
        else res=0;
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

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

    if(A==B && B==C){
        printf("No\n");
    }else if(A!=B && B!=C && C!=A){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0;i < n;i++) {
        cin >> d.at(i);
    }
    sort(d.begin(),d.end());
    unsigned j = d.at(d.size() / 2 - 1) + 1;
    unsigned k = d.at(d.size() / 2);
    int count = 0;
    for(int i = j;i <= k;i++) {
        count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define INF 10000000000
int main(){
  long long N,K;
  cin>>N>>K;
  vector<long long> H(N);
  for(long long i=0;i<N;i++){
    cin>>H.at(i);
  }
  sort(H.begin(),H.end());
  long long ans=INF;
  for(long long i=0;i<=N-K;i++){
    ans=min(ans,H.at(i+K-1)-H.at(i));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int main() {
  ll X;
  cin >> X;

  ll ans = 0;
  ll a = X / 500;
  X -= 500*a;
  ans += 1000*a;
  ll b = X / 5;
  X -= 5*b;
  ans += 5*b;
  cout<< ans << endl;
  return 0;
}



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

int main()
{
    long long n,d=0,k=0,i;
    vector<char>v;
    char b;
    cin>>n;
    while(n>0)
    {
        n-=1;
        d=n%26;
        b='a'+d;
        v.push_back(b);
        k++;
      //  cout<<b;
        n=n/26;
    }
     for(i=k-1;i>=0;i--)
     {
             cout<<v[i];
     }
    return 0;
}


Measured memory_bytes: 3596
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

bitset<36> bs;
ll H,W,K; 
ll cnt=0;

int main(){
  cin>>H>>W>>K;
  bs.reset();
  for(ll i=0;i<H;i++){
    string s;
    cin>>s;
    for(ll j=0;j<W;j++){
      if(s[j]=='#'){
        bs.set(i*W+j,true);
      }
    }
  }
  ll mx = 1<<H+W;
  rep(k,mx){
    auto bs2 = bs;
    bitset<36> bs3(k);
    REP(i,0,H){
      if(bs3.test(i)){
        rep(j,W){
          bs2.set(i*W+j,false);
        }
      }
    }
    REP(i,H,H+W){
      if(bs3.test(i)){
        rep(j,H){
          bs2.set(j*W+(i-H),false);
        }
      }
    }
    if(bs2.count()==K) cnt++;
  }
  cout<<cnt<<endl;
}

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

int main(int argc, char *argv[]){
  int n, t, l, b, skip = 1, back = 2;
  while(cin >> n >> t >> l >> b, n){
    n++;
    int measure[n];
    double probably[2][n];
    double for_skip[n];
    memset(measure, 0, sizeof(measure));
    memset(for_skip, 0, sizeof(for_skip));
    memset(probably, 0, sizeof(probably));
    probably[0][0] = 1;
    int tmp;
    for (int i = 0; i < l; i++) {
      cin >> tmp;
      measure[tmp] = skip;
    }
    for (int i = 0; i < b; i++) {
      cin >> tmp;
      measure[tmp] = back;
    }
    for (int i = 0; i < t; i++) {
      for (int j = 0; j < n - 1; j++) {
        for (int k = 1; k < 7; k++) {
          int pos = j + k;
          if(pos > n - 1){
            pos = 2*(n - 1) - pos;
          }
          if(measure[pos] == 0){
            probably[(i+1)&1][pos] += probably[i&1][j]/6;
          }else if(measure[pos] == back){
            probably[(i+1)&1][0] += probably[i&1][j]/6;
          }else{
            for_skip[pos] += probably[i&1][j]/6;
          }
        }
      }
      probably[(i+1)&1][n - 1] += probably[i&1][n - 1];
      for (int j = 0; j < n; j++) {
        probably[i&1][j] = for_skip[j];
        for_skip[j] = 0;
      }
    }
    // for (int i = 0; i < n; i++) {
    //   std::cout << probably[0][i] << " ";
    // }
    // std::cout << std::endl;
    // for (int i = 0; i < n; i++) {
    //   std::cout << probably[1][i] << " ";
    // }
    // std::cout << std::endl;
    // double a = 0;
    // for (int i = 0; i < 2; i++) {
    //   for (int j = 0; j < n; j++) {
    //     a += probably[i][j];
    //   }
    // }
    // for (int i = 0; i < n; i++) {
    //   a += for_skip[i];
    // }

    // std::cout << "sum:" << a << std::endl;
    printf("%.6lf\n", probably[t&1][n - 1]);
  }
  return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>

int main(){
    int a,b;

    scanf("%d%d", &a ,&b);

    if (a == b){
        printf("a == b\n");
    }
    else if(a > b){
        printf("a > b\n");
    }
    else{ //a < b
        printf("a < b\n");
    }

    return 0;
}



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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
	cin >> S;
	vector<string> q = { "01","02","03","04", "05", "06", "07", "08", "09", "10", "11", "12" };
	int res1 = 0;
	rep(i, 12) {
		if (S.substr(0, 2) == q[i]) res1++;
	}
	int res2 = 0;
	rep(i, 12) {
		if (S.substr(2, 2) == q[i]) res2++;
	}
	if (res1 == 0 && res2 == 0) cout << "NA" << endl;
	else if (res1 == 0 && res2 != 0) cout << "YYMM" << endl;
	else if (res1 != 0 && res2 == 0) cout << "MMYY" << endl;
	else cout << "AMBIGUOUS" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int n; cin>>n;
    if(n%10==9||n/10==9) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int h,w;
int a[82][82];
int b[82][82];
int c[82][82];

int dp[82][82][16000];
int ans = 100000;

int slv(int nh,int nw,int nd){

	if(h<=nh || w<=nw)return(0);
	if(dp[nh][nw][nd] != -1)return(0);
	dp[nh][nw][nd] = 1;
	if(nh==h-1 && nw==w-1){
		ans = min(ans,nd);
		return(0);
	}

	slv(nh+1,nw,abs(nd+c[nh+1][nw]));
	slv(nh+1,nw,abs(nd-c[nh+1][nw]));
	slv(nh,nw+1,abs(nd+c[nh][nw+1]));
	slv(nh,nw+1,abs(nd-c[nh][nw+1]));

	return(0);

}

int main(){

	for(int i=0;i<81;i++){for(int j=0;j<81;j++){for(int k=0;k<16000;k++)dp[i][j][k]=-1;}}

	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>b[i][j];
			c[i][j] = abs(a[i][j]-b[i][j]);
		}
	}

	// slv
	slv(0,0,c[0][0]);
	cout<<ans<<endl;

	return(0);
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

//入力
int N;
int x[101], y[101];
ll h[101];
bool flg;

int main()
{
    int si = -1;
    scanf("%d", &N);
    REP(i, N)
    {
        scanf("%d %d %lld", &x[i], &y[i], &h[i]);
        if (h[i] > 0)
            si = i;
    }
    int Cx = -1, Cy = -1;
    REP(cx, 101)
    {
        REP(cy, 101)
        {
            flg = true;
            REP(i, N)
            {
                if (h[i] > 0 && (h[i] + abs(x[i] - cx) + abs(y[i] - cy)) != (h[si] + abs(x[si] - cx) + abs(y[si] - cy)))
                    flg = false;
                if (h[i] == 0 && (h[si] + abs(x[si] - cx) + abs(y[si] - cy)) > abs(x[i] - cx) + abs(y[i] - cy))
                    flg = false;
            }
            if (flg)
                Cx = cx, Cy = cy;
        }
    }
    printf("%d %d %lld\n", Cx, Cy, h[si] + abs(x[si] - Cx) + abs(y[si] - Cy));
    return 0;
}

Measured memory_bytes: 256
"
ABC076 C - Dubious Document 2 
https://atcoder.jp/contests/abc076/tasks/abc076_c
"

INIT = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'

# 入力
s = gets.chomp
t = gets.chomp

ans = []
ans = INIT

# strの連続するt.size個の区間について
(s.size - t.size + 1).times do |i|
  safe = true
  tmp = s.split("").map(&:dup).inject(:+)
  # 区間の1文字目から比較
  (t.size).times do |j|
    # ?だったらtの文字に置き換え
    if tmp[i+j] == '?'
      tmp[i+j] = t[j]
    # ?じゃないのに違ったらそれ以上比較をしない
    elsif tmp[i+j] != t[j]
      safe = false
      break
    end
  end
  # puts "tmp=#{tmp}"
  if safe
    # ?が残ってる場合は，辞書順最小にするために全部aにする
    tmp = tmp.gsub(/\?/, 'a')
    ans = [ans, tmp.split("").map(&:dup).inject(:+)].min
  end
end
puts "#{(ans==INIT) ? 'UNRESTORABLE' : ans}"

Measured memory_bytes: 1916
#include <cstdio>
#include <climits>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int ans = 0;
    if (a >= b && a >= c) ans = a * 10 + b + c;
    else if (b >= a && b >= c) ans = b * 10 + a + c;
    else ans = c * 10 + a + b;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256