akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
 
int main(){
	unsigned int N, K;
  	cin >> N >> K;
	unsigned int h[N];
    for(int i=0; i < N; i++){
    	cin >> h[i];
    }
  
    unsigned int counter=0;
  
    for(int i=0; i < N; i++){
      if (h[i] >= K){
        counter += 1;
      }
    }
      
    cout << counter << endl;
    return 0;
    }

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

int main(){
	ll n,k;
	cin>>n;
	ll arr[n+1],brr[n+1],crr[n+1];
	for(ll i=0;i<n;i++){
		cin>>arr[i]>>brr[i]>>crr[i];
	}
	ll dp[n+1][3];
	dp[0][0]=arr[0];
	dp[0][1]=brr[0];
	dp[0][2]=crr[0];
	
	for(ll i=1;i<n;i++){
		dp[i][0]=max(dp[i-1][2]+arr[i],dp[i-1][1]+arr[i]);
		dp[i][1]=max(dp[i-1][2]+brr[i],dp[i-1][0]+brr[i]);
		dp[i][2]=max(dp[i-1][1]+crr[i],dp[i-1][0]+crr[i]);
		
	//	cout<<dp[i][0]<<' '<<dp[i][1]<<' '<<dp[i][2]<<'\n';
		
	}
	
	cout<<*max_element(dp[n-1],dp[n-1]+3);
}

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

using namespace std;

int main()
{
    int n, cnt = 0;
    cin >> n;
    int arr[100];
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
        if(i % 2 == 0 && arr[i] % 2 == 1)
            cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3544
n,m=map(int,input().split())
a=list(map(int,input().split()))
count=0
sum=0
for i in range(n):
  sum+=a[i]
min=sum/(4*m)
for i in range(n):
  if a[i]>=min:
    count+=1
if count>=m:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38256
n = int(input())
dp = [float('inf')] * 100010
dp[0] = 0
for i in range(1, 100000 + 1):
    power = 1
    while (power <= i):
        dp[i] = min(dp[i], dp[i - power] + 1)
        power *= 6
    power = 1
    while (power <= i):
        dp[i] = min(dp[i], dp[i - power] + 1)
        power *= 9
print(dp[n])

Measured memory_bytes: 3828
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[5];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = sc.nextInt();
        }
        int ans = 0, c = 10;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] % 10 == 0) {
                ans += arr[i];
            } else {
                ans += ((arr[i] / 10) + 1) * 10;
                c = Math.min(arr[i] % 10, c);
            }
        }
        ans -= 10 - c;
        System.out.println(ans);
    }
}

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

int main()
{
	long a,b,x;
	cin >> a >> b >> x;
	a +=(a% x  == 0) ? 0 :  x - a % x;
  	b -= b % x;
  	
	cout << 1+(b-a)/x << endl;
}

Measured memory_bytes: 256
from heapq import heappop,heappush,heapify
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = list(map(int, input().split()))
a_minus = [-x for x in a]
heapify(a_minus)

pop = lambda: -heappop(a_minus)
push = lambda x: heappush(a_minus,-x)

for _ in range(m):
    x = pop()
    push(x//2)

print(-sum(a_minus))


Measured memory_bytes: 69612
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

//

int main(){
	int x=ci(), k=ci();
	puts(x*500>=k? "Yes":"No");
	return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.math.*;
class Main{
	public static void main(String[]Z){
		Scanner cin=new Scanner(System.in);
		int r=cin.nextInt(),c=cin.nextInt(),a1=cin.nextInt(),a2=cin.nextInt(),b1=cin.nextInt(),b2=cin.nextInt();
		int x=Math.abs(a1-b1),y=Math.abs(a2-b2);
		x=Math.min(x,r-x);y=Math.min(y,c-y);
		int z=1,C=Math.min(x,y);
		if(x==r-x)z*=2;
		if(y==c-y)z*=2;
		BigInteger b=BigInteger.ONE;
		for(int i=0;i<C;i++)b=b.multiply(new BigInteger(String.valueOf(x+y-i))).divide(new BigInteger(String.valueOf(i+1)));
		System.out.println(b.multiply(new BigInteger(String.valueOf(z))).mod(new BigInteger("100000007")));
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <cstdio> 
#include <cstring>
using namespace std;
#define MOD 924844033
#define ll long long
#define N 2050
ll dp[N<<1][N][2],n,k,link[2*N],tot,sum,jc[N];
int main()
{
	scanf("%lld%lld",&n,&k);
	jc[0]=1;dp[0][0][0]=1;
	for(int i=1;i<=n;i++)jc[i]=jc[i-1]*i%MOD; 
	for(int i=1;i<=k;i++)
		for(int t=1;t<=2;t++)
			for(int j=i;j<=n;j+=k)
				j!=i?link[++tot]=1:++tot;
	for(int i=1;i<=tot;i++)
		for(int j=0;j<=n;j++)
		{
			dp[i][j][0]=(dp[i-1][j][1]+dp[i-1][j][0])%MOD;
			if(link[i])dp[i][j][1]=dp[i-1][j-1][0];
	 	}
	for(int i=0;i<=n;i++)
	{
		ll tmp=(dp[n<<1][i][0]+dp[n<<1][i][1])%MOD;
		tmp=tmp*jc[n-i]%MOD;
		i%2==1?sum=((sum-tmp)%MOD+MOD)%MOD:sum=(sum+tmp)%MOD;
	}
	printf("%lld",sum);
	return 0;
}

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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

map<string, int> mp;
int N;
string S[110000];

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> S[i];
        vector<char> s;
        for (int j = 0; j < S[i].size(); j++)s.push_back(S[i][j]);
        sort(s.begin(), s.end());
        S[i] = string(s.begin(), s.end());
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += mp[S[i]];
        mp[S[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12032
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;

ll bit[200010];
//ll kai[3010];
ll Cnt[1000010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }



/*ll sum(ll i)
{
	i += 1;
	ll t = 0;
	while (i > 0)
	{
		t += bit[i];
		i -= i & -i;
	}
	return t;
}

void add(ll i, ll x)
{
	i += 1;
	while (i <= 200005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

/*`ll SAIKI(ll S) {
	for (ll T = S; ; T = (T - 1) & S) {

	}
}*/



void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; 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;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

void makePrimeList(ll x) {
	ll X = x;
	for (ll j = 2; j * j <= x; j++) {
		ll cnt = 0;
		while (X % j == 0) {
			cnt++;
			X /= j;
		}
		if (cnt) {
			Cnt[j] = max(Cnt[j], cnt);
		}
	}
	if (X != 1) Cnt[X] = max(Cnt[X], 1LL);
}

ll N;
vector<ll> sum[100010];
bool used[100010];

void solve() {
	cin >> N;
	sum[0].pb(0);
	for (ll i = 1; i <= N; i++) {
		vector<ll> tmp;
		for (ll a : sum[i - 1]) {
			if (!used[a + 1]) tmp.pb(a + 1);
		}
		for (ll a : tmp) {
			while (!used[a]) {
				used[a] = true;
				sum[i].pb(a);
				a = a * 10 % N;
			}
		}
		if (used[0]) {
			cout << i << endl;
			return;
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}

Measured memory_bytes: 5916
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin>>S;
    int len = SZ(S);
    LL ans = 0;
    for(int t = 0; t < (1 << (len - 1)); t++)
    {
        LL num = S[0]-'0';
        for(int i = 0; i < len-1; i++)
        {
            if(t&(1<<i))
            {
                ans += num;
                num = 0;
            }
            num = num * 10 + S[i+1]-'0';
        }
        ans += num;
    }

    cout << ans << endl;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz size()
#define endl "\n"
#define ll long long int
#define llu unsigned long long int
#define freverse(str) reverse(str.begin(),str.end());
#define Allah_Hafez return 0;
void solve(){
    int N,ne=1000;
    cin>>N;
    if(N%1000==0)
    {
        cout<<"0"<<endl;
    }
    else
    {
        while(N>=ne)
        {
            ne+=1000;
        }
        cout<<ne-N<<endl;
    }
}
int main(){
    int T=1;
    //cin>>T;
    while(T--)solve();
    Allah_Hafez
}




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

using namespace std;
using ll = long long int;

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

    map<ll,ll> cnt;

    ll n;
    cin >> n;
    while(n--) {
        ll x;
        cin >> x;
        cnt[x]++;
    }
    cin >> n;
    while(n--) {
        ll x;
        cin >> x;
        if(cnt[x]--==0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 12800
#include<iostream>
#include<cstdio>
using namespace std;
int N;
int parent(int i) { return i / 2; }
int left(int i) { return i * 2; }
int right(int i) { return i * 2 + 1; }

void maxHeapify(int A[], int i)
{
	int l = left(i);
	int r = right(i);
	int largest = 0;
	if (l <= N&&A[l] > A[i]) {
		largest = l;
	}
	else
		largest = i;
	if (r <= N&&A[r] > A[largest])
		largest = r;
	if (largest != i) {
		swap(A[largest], A[i]);
		maxHeapify(A, largest);
	}
}
int main()
{
	scanf("%d", &N);
	int A[500000];
	for (int i = 1; i <= N; i++)
		scanf("%d", &A[i]);
	for (int i = N / 2; i >= 1; i--)
		maxHeapify(A, i);
	for (int i = 1; i <= N; i++) {
		printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 5096
#include <stdio.h>
#include <math.h>
 
int main()
{
    long num;
    int i;
    float fVar;
  
   
    scanf("%d",&num);
  for(i=num;i>=1;i--)
{
    
     int temp = i,count=1;
      while(temp > 0)
      {
            temp = temp - count;
            count = count + 2;
      }
      if(temp == 0)
      {
            printf("%d", i);
            break;
      }
      

 
    
 }  
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
  int n, m, x, a[100], i, j, k = 0, p = 0;

  scanf("%d%d%d",&n,&m,&x);
  for(i=0;i<m;i++){
   scanf("%d",&a[i]);
  }

  for(i=x;i<n;i++){
    for(j=0;j<m;j++){
      if(i==a[j]) k++;
    }
  }
  for(i=0;i<x;i++){
    for(j=0;j<m;j++){
      if(i==a[j]) p++;
    }
  }

  if(k <= p) printf("%d\n",k);
  else             printf("%d\n",p);

  return 0;
}

Measured memory_bytes: 128
#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;
    vector<int> d1(n), d2(n);
    rep(i, n) cin >> d1.at(i) >> d2.at(i);
    int zoro = 0;
    rep(i, n) {
        if (d1.at(i) == d2.at(i)) zoro++;
        else zoro = 0;
        if (3 == zoro) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  
  vector<bool> av(f), as(f);
  int bw = 100*a;
  int bs = 0;
  av[0] = true;
  rep(i, 1, f+1) {
    if ((100*a<=i&&av[i-100*a])||(100*b<=i&&av[i-100*b])) av[i] = true;
  }
  as[0] = true;
  rep(i, 1, f+1) {
    if ((c<=i&&as[i-c])||(d<=i&&as[i-d])) as[i] = true;
  }
  rep(i, 0, f+1) {
    rep(j, 0, f-i+1) {
      if (av[i]&&as[j]&&(j<=(i/100)*e)) {
        if (bs*(i+j) < j*(bs+bw)) bs = j, bw = i;
      }
    }
  }
  cout << bs + bw << " " << bs << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
#include <fstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

vector<ll> dx = { 0, 1, 0, -1, 1, -1, 1, -1, 0};
vector<ll> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0};

void chmin(double& x, double y) {
	x = min(x, y);
}

void chmax(double& x, double y) {
	x = max(x, y);
}

ll pow_long(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y % 2 == 1) res *= x;
		x *= x;
		y /= 2;
	}
	return res;
}

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 1000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; 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;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

ll n, k;
ll ans;

void solve() {
	COMinit();
	cin >> n >> k;
	if (k >= n - 1) {
		cout << comb(2 * n - 1, n - 1) << endl;
		return;
	}
	rep(i, k + 1) {
		ans += comb(n - 1, n - 1 - i) * comb(n, i) % mod;
		ans %= mod;
	}
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll T = 1;
	//cin >> T;
	rep(i, T) solve();
}


Measured memory_bytes: 23680
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 800005
#define ll long long
#define mod 924844033
int n, A[N], B[N], C[N], tot[N], fac[N], inv[N];
int cnt, tar[N], nex[N], fir[N], siz[N];
void Read(int &p)
{
	p = 0;
	char c = getchar();
	for (; c < '0' || c > '9'; c = getchar());
	for (; c >= '0' && c <= '9'; c = getchar())p = p * 10 + c - '0';
}
int Pow(int a, int k)
{
	if (!k)
		return 1;
	int p = Pow(a, k / 2);
	if (k & 1)
		return (ll)p * p % mod * a % mod;
	return (ll)p * p % mod;
}
int Add(int a, int b){return a + b >= mod ? a + b - mod : a + b;}
int Sub(int a, int b){return a - b < 0 ? a - b + mod : a - b;}
void DFT(int *A, int w, int f)
{
	for (int i = 1, j = 0; i < w; i++)
	{
		for (int d = w >> 1; j ^= d, ~j & d; d >>= 1);
		if (i < j)
			swap(A[i], A[j]);
	}
	for (int i = 1; i < w; i <<= 1)
	{
		int wn = Pow(5, (mod - 1) / (i << 1));
		if (f == -1)
			wn = Pow(wn, mod - 2);
		for (int j = 0; j < w; j += i << 1)
		{
			int w1 = 1;
			for (int k = 0; k < i; k++)
			{
				int x = A[j + k], y = (ll)A[j + k + i] * w1 % mod;
				A[j + k] = Add(x, y);
				A[j + k + i] = Sub(x, y);
				w1 = (ll)w1 * wn % mod;
			}
		}
	}
	if (f == -1)
	{
		int x = Pow(w, mod - 2);
		for (int i = 0; i < w; i++)
			A[i] = (ll)A[i] * x % mod;
	}
}
void Link(int a, int b)
{
	++cnt;
	tar[cnt] = b;
	nex[cnt] = fir[a];
	fir[a] = cnt;
}
void Dfs(int r, int fat)
{
	siz[r] = 1;
	for (int i = fir[r]; i; i = nex[i])
	{
		int v = tar[i];
		if (v != fat)
		{
			Dfs(v, r);
			tot[siz[v]]++;
			siz[r] += siz[v];
		}
	}
	tot[n - siz[r]]++;
}
int main()
{
	Read(n);
	for (int i = 1; i < n; i++)
	{
		int a, b;
		Read(a), Read(b);
		Link(a, b), Link(b, a);
	}
	Dfs(1, 0);
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = (ll)fac[i - 1] * i % mod;
	inv[n] = Pow(fac[n], mod - 2);
	for (int i = n; i >= 1; i--)
		inv[i - 1] = (ll)inv[i] * i % mod;
	for (int i = 1; i <= n; i++)
	{
		tot[i] = (ll)tot[i] * fac[i] % mod;
		A[i] = tot[i];
		B[i] = inv[n - i];
	}
	int w = 1;
	while (w <= 2 * n)w <<= 1;
	DFT(A, w, 1);
	DFT(B, w, 1);
	for (int i = 0; i < w; i++)
		C[i] = (ll)A[i] * B[i] % mod;
	DFT(C, w, -1);
	for (int i = n + 1; i <= 2 * n; i++)
	{
		int ans = (ll)C[i] * inv[i - n] % mod;
		ans = Sub((ll)fac[n] * inv[i - n] % mod * inv[2 * n - i] % mod * n % mod, ans);
		printf("%d\n", ans);
	}
}


Measured memory_bytes: 37504
#include <stdio.h>

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



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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        //Solve();
        return;
    }

    public static string Solve()
    {
        int[] input = ReadInts();
        int N = input[0], K = input[1];
        if(K==1)
        {
            return "0";
        }
        int ans = N - K;
        return ans.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


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

int A[101][101] = {0};
int n, tt = 0, d[101] = {0}, color[101] = {0};
queue<int> Q;


void bfs (int u) {
    int i, j ,k;
    Q.push(u);
    d[u] = tt++;
    color[u] = 1;
    while ( !Q.empty() ) {
        j = Q.front();
        Q.pop();
        for ( i = 1; i <= n; i++ ) {
            if ( A[j][i] == 1 && color[i] != 1 ) {
                Q.push(i);
                color[i] = 1;
                d[i] = d[j] + 1;
            }

        }
        }
    }



int main() {
    int i, j, k, v;
    cin >> n;
    for ( i = 0; i < n; i++ ) {
        cin >> j >> k;
        while ( k-- ) {
            cin >> v;
            A[j][v] = 1;
        }
    }

    bfs(1);
    for ( i = 1; i <= n; i++ ) if ( color[i] != 1 ) d[i] = -1;
    for ( i = 1; i <= n; i++ ) cout << i << ' ' << d[i] << endl;

    return 0;

}



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

int main() {
    int bell[2], mx = 1;
    for (int i = 0; i < 3; i++) {
        cin >> bell[i];
        if (mx < bell[i]) mx = bell[i];
    }
    cout << bell[0] + bell[1] + bell[2] - mx << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append([a + b, a, b])
ab.sort(reverse = True)

num = (n + 1) // 2
ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += ab[i][1]
    else:
        ans -= ab[i][2]
print(ans)

Measured memory_bytes: 29176
n = int(input())
x = list(map(int, input().split()))

#最小値と最大値を変数に代入
minx = min(x)
maxx = max(x)

#差の二乗の合計値の初期値を代入
total = -1

#差の二乗を返す関数
def square(i, x):
  return ((x-i)**2)

#xの最小値から最大値の間でループ
for i in range(minx, maxx+1):
  list_i = [i] * n
  tmp = sum(map(square, list_i, x))
  
  if total == -1:
    total = tmp
  else:
    if total > tmp:
      total = tmp

print(total)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll k,cnt=0;
    cin>>k;
    queue<ll> q;
    for(ll i=1;i<=9;i++){
        cnt++;
        q.push(i);
        if(cnt==k){
            cout<<i<<endl;
            return 0;
        }
    }
    while(1){
        ll num=q.front();
        q.pop();
        for(ll i=-1;i<=1;i++){
            ll d=num%10+i;
            if(d<0||d>9) continue;
            cnt++;
            q.push(num*10+d);
            if(cnt==k){
                cout<<num*10+d<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int P = max({A, B, C});
    int R = min({A, B, C});
    int Q = A + B + C - P - R;
    
    if(Q%2==R%2) cout << (2*P-Q-R)/2 << endl;
    else {
        P++;
        Q++;
        cout << (2*P-Q-R)/2 + 1 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
	string x, y;
	cin >> x >> y;
	if (x < y) {
		cout << "<" << endl;
	}
	else if (x > y) {
		cout << ">" << endl;
	}
	else if (x == y) {
		cout << "=" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string w;
    int ans;
    cin >> w;
    if(w[0]=='R' && w[1]=='R' && w[2]=='R') ans = 3;
    else if(w[0]=='S' && w[1]=='R' && w[2]=='R') ans = 2;
    else if(w[0]=='R' && w[1]=='R' && w[2]=='S') ans = 2;
    else if(w[0]=='R' || w[1]=='R' || w[2]=='R') ans = 1;
    else ans = 0;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3484
import math
a, b, x = [int(i) for i in input().split()]

V_max = a * a * b

if x <= 0.5 * V_max:
    theta = math.atan((a*b*b)/(2*x))
else:
    theta = math.atan(2*(a**2*b - x)/(a**3))

print(math.degrees(theta))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll inf = 1e18+5;
ll h, n;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> h >> n;
	ll sum = 0;
	for (ll i= 0; i < n; i++){
		ll a; cin >> a;
		sum += a;
	}
	if (sum >= h)cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<stdio.h>

using namespace std;

int main()
{
    int n,m,i,j,k,sum;
    cin >> n >> m;
    int A[n][m];
    int B[m];
    int C[n];
    for(i = 0;i < m;i++){
        B[i] = 0;
    }
    for(i = 0;i < n;i++){
        for(j = 0;j < m;j++){
            A[i][j] = 0;
        }
        C[i] = 0;
    }
    for(i = 0;i < n;i++){
        for( j = 0;j < m;j++){
            cin >> A[i][j];
        }
    }
    for(i = 0;i < m;i++){
        cin >> B[i];
    }
    for(i = 0;i < n;i++){
        sum = 0;
        for(j = 0;j < m;j++){
            sum += A[i][j] * B[j];
        }
        cout << sum << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3160
//***Wherever you are, and whatever you do, be in love.***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define PI 3.14159265 

int main(){
   string s;
   cin>>s;
   forn(i,s.length()){
       if(s[i]!='?') continue;
       s[i]='D';
   }
   cout<<s;
}

Measured memory_bytes: 3724
n,k=map(int, input().split())
r,s,p=map(int, input().split())
t=list(input())
hl=[]
ans=0
for i in range(n):
		if i<k:
			if t[i]=='r':
				ans+=p
				hl.append('r')
			elif t[i]=='p':
				ans+=s
				hl.append('p')
			elif t[i]=='s':
				ans+=r
				hl.append('s')
		elif i>=k:
			if t[i]==hl[i-k]:
				hl.append('a')
			else: 
				if t[i]==('r'):
					ans+=p
					hl.append('r')
				elif t[i]=='p':
					ans+=s
					hl.append('p')
				elif t[i]=='s':
					ans+=r
					hl.append('s')
print(ans)
			

Measured memory_bytes: 4796
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
long long S,ans=0,Sum=0,Now=0;
int A[15],n;
void DFS(int p){
    if(p<=0){
        ans+=Sum;
        return ;
    }
    long long tNow = Now, tSum = Sum;
    Now = tNow*10+A[p];
    /* add + */
    Sum = tSum + Now;
    Now = 0;
    DFS(p-1);
    /* no + */
    Now = tNow*10+A[p];
    Sum = tSum;
    if(p>1)DFS(p-1);
    Now = tNow;
    Sum = tSum;
}
int main(){
    scanf("%lld",&S);
    ans=0;
    n=0;
    while(S>0){
        n++;
        A[n]=S%10;
        S/=10;
    }
    DFS(n);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
result = []

while True:
    str_in = input()
    if (str_in == '-'):
        break
    m = int(input())
    for i in range(0, m):
        h = int(input())
        n = len(str_in)
        str_in = str_in[h : n] + str_in[0 : h]
    result.append(str_in)

for i in result:
    print(i)
        


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

int main(){
    ll A, B, K; cin >> A >> B >> K;

    ll cnt = 0;
    while(true) {
        if(A % 2 == 1) {
            A--;
        }
        B = B + A / 2;
        A = A / 2;
        cnt++;

        if(K == cnt) {
            break;
        }

        if(B % 2 == 1) {
            B--;
        }
        A = A + B / 2;
        B = B / 2;
        cnt++;

        if(K == cnt) {
            break;
        }
    }

    cout << A << " " << B << endl;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

long long modpow(long long x, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}


ll n, p;
string s;

int main() {
    cin >> n >> p >> s;

    Vl u(n+1, 0);
    ll cnt = 0, cnt2 = 0;
    Vl mod(p, 0);
    mod[0]++;
    RREP(i, n-1, 0) {
        u[i] = (u[i+1] + modpow(10, n-1-i, p) * (s[i] - '0')) % p;
        cnt += mod[u[i]];
        mod[u[i]]++;
        if ((s[i] - '0') % p == 0) {
            cnt2 += i+1;
        }
    }
    if (p == 2 || p == 5) {
        cout << cnt2 << '\n';
    } else {
        cout << cnt << '\n';
    }

    return 0;
}


Measured memory_bytes: 2180
import java.util.*;
    public class Main {
    	public static void main(String[] args){
    		Scanner sc = new Scanner(System.in);
    		// 整数の入力
    		int a = sc.nextInt();
    		// スペース区切りの整数の入力
    		int b = sc.nextInt();
    		int c = sc.nextInt();
    	    if((a+b)<c||a>c) {
    		  System.out.println("NO");
    	    }else {
    	      System.out.println("YES");
    	    }
    	}
    }

Measured memory_bytes: 20564
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using ll = long long;
using namespace std;
int x, y, z, l, m, n, r=0, q, k;

void solve() {
    cin>>n>>m;
    vector<int> dist(m, 0);
    for(int i=0;i<m;i++){
        cin>>dist[i];
    }
    int dsum=0;
    sort(dist.begin(), dist.end());
    for(int i=0;i<m-1;i++){
        dist[i]= dist[i+1]- dist[i];
        dsum+=dist[i];
    }
    dist.resize(m-1);
    sort(dist.begin(), dist.end());
    int cnt=0;
    for(int i=0;i<m-n;i++){

        cnt+=dist[i];
    
    }
    cout<<cnt;
}

int main() 
{
    std::ios::sync_with_stdio(false); \
        std::cin.tie(NULL);
    int test;
    test  =1 ;
    while (test--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#define N 200
int main(int argc, const char * argv[])
{
    double x1=0;
    double x2=0;
    //int a[N][2];
    //int b[N];
    while(scanf("%lf",&x1) != EOF){
        scanf("%lf",&x2);
        int y=x1+x2;
        int z=1;
        y=y*(0.1);
        while(y>=1){
            z++;
            y=y*(0.1);
        }
        
        printf("%d\n",z);
        
    }
}

Measured memory_bytes: 1208
from fractions import gcd
A,B,C,D=map(int,input().split())
#CとDのどちらかで割り切れる
#=(Cで割り切れる)+(Dで割り切れる)-(lcm(C,D)で割り切れる)
L=(C*D)//gcd(C,D)
#(i-1)<A/C<=i
#i*C<=B<(i+1)C
i=(B//C)-((A-1)//C)
j=(B//D)-((A-1)//D)
k=(B//L)-((A-1)//L)
print(B-A+1-(i+j-k))


Measured memory_bytes: 5048
object Main {
  def main(args: Array[String]): Unit = {
    val array = Array("YYMM", "MMYY", "AMBIGUOUS", "NA")
    val sc = new java.util.Scanner(System.in)
    val nk = sc.nextLine()
    val f = nk.substring(0, 2)
    val l = nk.substring(2, 4)
    val fb = f.toInt >= 1 && f.toInt < 13
    val lb = l.toInt >= 1 && l.toInt < 13

    if (fb && lb) { println(array(2)) }
    else if (!fb && !lb){ println(array(3)) }
    else if (!fb && lb) { println(array(0)) }
    else if (fb && !lb) { println(array(1)) }
  }
}

Measured memory_bytes: 25676
using System;

class Problem
{
  public static void Main()
  {
    var n = Console.ReadLine();
    var arr = new bool[26];
    foreach (var c in n) arr[c - 'a'] = true;
    for (var i = 0; i < arr.Length; i++)
    {
      if (!arr[i])
      {
        Console.WriteLine($"{Convert.ToChar('a' + i)}");
		return;
      }
    }
    Console.WriteLine("None");
  }
}


Measured memory_bytes: 13408
#! /usr/bin/env python3
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

H1, M1, H2, M2, K = map(int, read().split())
start = H1 * 60 + M1
end = H2 * 60 + M2

gap = end - start

res = gap - K

print(res)

Measured memory_bytes: 9132
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int x;
    std::cin>>x;

    if(x == 3 || x == 5 || x == 7){
        std::cout<<"YES"<<std::endl;
    }else{
        std::cout<<"NO"<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename T> ll min(ll a, const T&& b) { return a < b ? a : b; }
template<typename T> ll min(const T&& a, ll b) { return a < b ? a : b; }
template<typename T> ll max(ll a, const T&& b) { return a > b ? a : b; }
template<typename T> ll max(const T&& a, ll b) { return a > b ? a : b; }
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  vector<P> v;
  rep(i, n) {
    ll x, y; cin >> x >> y;
    v.eb(x, y);
  }
  ll ans = n;
  if (n >= 2) {
    vector<P> kh;
    set<P> s(all(v));
    each(p1, v) each(p2, v) {
      ll dx = p1.first - p2.first;
      ll dy = p1.second - p2.second;
      if (dx != 0 || dy != 0) {
        kh.eb(dx, dy);
      }
    }
    each(q, kh) {
      ll cnt = 0;
      each(p, v) {
        if (s.count(P(p.first + q.first, p.second + q.second)) > 0) {
          ++cnt;
        }
      }
      chmin(ans, n - cnt);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        Integer[] a = new Integer[n];
        int sum = 0;
        for(int i = 0; i < n; i++){
            a[i] = scan.nextInt();
            sum += a[i];
        }
        Arrays.sort(a, Comparator.reverseOrder());
        double min = (double) sum / (4 * m);
        System.out.println(a[m - 1] >= min ? "Yes" : "No");
    }
}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

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

	vector<ll> factor(k+1,1);
	// repi(i,1,k+1) factor[i] = power(i,n);

	ll ans=0;
	repr(i,k,1){
		factor[k/i] = power(k/i,n);
		ll tmp = factor[k/i];
		repi(j,2,k+1){
			if(i*j>k)break;
			tmp -= factor[k/(i*j)];
			tmp += mod;
			tmp %= mod;
		}
		
		ans+=(i*tmp)%mod;
		ans%=mod;

		factor[k/i] = tmp;
	}

	// repi(i,1,k+1)cout<<i<<" "<<factor[i]<<endl;

	cout<<ans<<endl;

	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  int N;
  cin >> N;
  int d[51];

  ll ans=0;
  REP(i,N){
    cin >> d[i];
  }
  FOR(i,0,N-1)FOR(j,i+1,N){
    ans+=d[i]*d[j];
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#importを忘れずに
import queue
w,h=map(int,input().split())
while w!=0 or h!=0:
    #壁の情報
    maps=[]
    for i in range(h*2-1):
        k=list(map(int,input().split()))
        maps.append(k)
    
    #壁による移動制限のチェック
    def check(x,y,x2,y2):
        global maps
        if x2<0 or x2>=w or y2<0 or y2>=h:
            return False
        if x==x2:
            if maps[y+y2][x]!=0:
                return False
        if y==y2:
            if maps[y*2][(x+x2)//2]!=0:
                return False
        return True

    def bfs():
        #queueをつくる
        q=queue.Queue()
        #rawmapはその地点までの最短距離をあらわす
        rawmap=[[0]*h for i in range(w)]
        #移動4方向のベクトル
        dx=[1,0,-1,0]
        dy=[0,1,0,-1]
        #putでqueueにいれる
        q.put([0,0])
        rawmap[0][0]=1
        #pythonでは0以外の数値はTrueとして扱われる
        while q.qsize():
            #getでqueueから取り出す
            x,y=q.get()
            if x==w-1 and y==h-1:
                break
            for i in range(4):
                x2=x+dx[i]
                y2=y+dy[i]
                if check(x,y,x2,y2) and rawmap[x2][y2]==0:
                    q.put([x2,y2])
                    rawmap[x2][y2]=rawmap[x][y]+1
        return rawmap[w-1][h-1]
        
    print(bfs())
    w,h=map(int,input().split())


Measured memory_bytes: 6880
#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i<=b;i++)
#define fore(i,a) for(auto &i:a)


using namespace std;
typedef long long ll;

int main() {
	int N, M;
	cin >> N >> M;

	vector<int>A(N);

	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	map<int, int>m;
	vector<int> sum(N + 1);

	for (int i = 0; i < N; i++) {
		sum[i + 1] = (sum[i] + A[i]) % M;
	}

	ll ans = 0;

	for (int i = 0; i < sum.size(); i++) {
		ans += m[sum[i]];
		m[sum[i]]++;
	}

	cout << ans << endl;
}

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

typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)
#define OUT(x) cout<<(x)<<"\n"
#define FASTIO cin.tie(0),ios::sync_with_stdio(0)

using P = pair<int, int>;
ll cnt[10];

int main() {
    FASTIO;
    ll h, w, n;
    cin >> h >> w >> n;

    map<P, int> M; // (x, y);
    for(ll i = 0; i < n; i++) {
        int y, x;
        cin >> y >> x;
        --y; --x;
        rep(dy, 3) rep(dx, 3) {
            int px = x - dx, py = y - dy;
            if(px < 0 || py < 0 || px >= w - 2 || py >= h - 2) continue;
            M[make_pair(px, py)]++;
        }
    }

    cnt[0] = (h - 2) * (w - 2) - M.size();
    for(auto&& i : M) {
        cnt[i.second]++;
    }
    rep(i, 10) OUT(cnt[i]);

    return 0;
}

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

int main() {
string S;
  cin >> S;
  string ans = "No";
    if(((S[0]==S[1])&&(S[1]==S[2]))||((S[1]==S[2])&&(S[2]==S[3])))ans="Yes";
  cout<<ans<<endl;
    
}


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

int main (){
    ll n;
    cin >> n;
    vector<string> s(n);
    vector<string> list(n);
    unordered_set<string> list1;
    map<string,ll> mp;
    for(int i=0;i<n;i++){
        cin>>s[i];
        mp[s[i]]+=1;
    }
    
    cout << mp.size() << endl;
    return 0;
}


Measured memory_bytes: 31520
#include <bits/stdc++.h>
#define POS(c) (int)(c)-97
using namespace std;


int count(int* tab1, int* tab2){
    int cnt = 0;
    for(int j=0; j<26; j++)if(tab1[j]>0 && tab2[j]>0)cnt++;
    return cnt;
}

void solve(long long N, std::string S){
    int counts_r[26] = {0}, counts_l[26] = {0};
    for(int i=0; i<N; i++)
        counts_r[POS(S[i])] += 1;

    int ans=0;
    for(int i=0; i<N; i++){
        counts_l[POS(S[i])] += 1;
        counts_r[POS(S[i])] -= 1;
        auto cnt = count(counts_l, counts_r);
        if(cnt>ans)ans=cnt;
    }
    cout << ans << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


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

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

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

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

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

bool CanContinuous(int i,vector<int>& n){
	if(i>=7) return false;
	if(n[i] && n[i+1] && n[i+2]) return true;
	return false;
}

bool DFS(vector<int>& n,int triplet,int twin){
	bool res = false;

	if(twin==1 && triplet==4) return true;

	for(int i=0;i<9;i++){
		if(n[i]>=3){
			n[i]-=3;
			res |= DFS(n,triplet+1,twin);
			n[i]+=3;
		}
		if(n[i]>=2 && !twin){
			n[i]-=2;
			res |= DFS(n,triplet,1);
			n[i]+=2;
		}
		if(n[i]>=1 && CanContinuous(i,n)){
			n[i]--;
			n[i+1]--;
			n[i+2]--;
			res |= DFS(n,triplet+1,twin);
			n[i]++;
			n[i+1]++;
			n[i+2]++;
		}
	}
	return res;
}

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

	string S;
	while(cin>>S){
		vector<int> num(9,0);
		REP(i,13){
			num[(S[i]-'0')-1]++;
		}
		vector<int> ans;
		REP(i,9){
			num[i]++;
			if(num[i]<=4 && DFS(num,0,0)){
				ans.push_back(i+1);
			}
			num[i]--;
		}

		if(ans.empty()){
			out(0);
		}
		else{
			for(int i=0,ei=ans.size();i<ei;i++){
				if(i) cout << ' ';
				cout << ans[i];
			}
			out();
		}
	}

	return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>

using namespace std;

int main(){
    int n;
    cin >> n;
    int sum = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        sum += x -1 ;
    }
    cout << sum;
}

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

const int N = 100005, MOD = 1E9 + 7;

int n, a[N];
long long ans = 0, fct = 1, inv[N];

long long pw(int u, int p)
{
    long long ret = 1;
    for (int i = 31; i >= 0; i--)
    {
        (ret *= ret) %= MOD;
        if (p >> i & 1)
            (ret *= u) %= MOD;
    }
    return ret;
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", a + i);
        inv[i] = (inv[i - 1] + pw(i, MOD - 2)) % MOD;
        (fct *= i) %= MOD;
    }
    for (int i = 1; i <= n; i++)
    {
        long long cur = (inv[n - i + 1] + inv[i] + MOD - 1) % MOD;
        (ans += cur * a[i]) %= MOD;
    }
    printf("%lld", ans * fct % MOD);
}

Measured memory_bytes: 1408
x=int(input())
a=x//100
b=x%100
answer=0
for i in range(a):
    if b-5>=0:
        b-=5
    elif b-4>=0:
        b-=4
    elif b-3>=0:
        b-=3
    elif b-2>=0:
        b-=2
    elif b-1>=0:
        b-=1
if b==0:
    answer=1
print(answer)

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

using namespace std;

signed main() {
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    cout << (s.find("AC") != string::npos ? "Yes" : "No") << "\n";
}


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

string S[18] = {
"",
"Man",
"Oku",
"Cho",
"Kei",
"Gai",
"Jo",
"Jou",
"Ko",
"Kan",
"Sei",
"Sai",
"Gok",
"Ggs",
"Asg",
"Nyt",
"Fks",
"Mts",
};
int main() {
	int a, b;
	while (cin >> a >> b, a | b) {
		int c[18]{};
		c[0] = a;
		for (int i = 0; i < b-1; i++) {
			int k[19]{};
			for (int d = 0; d < 18; d++) {
				c[d]=c[d]*a+k[d];
				k[d+1]=c[d] / 10000;
				c[d] %= 10000;
			}
		}
		for (int i = 17; i >= 0; i--) {
			if (c[i])cout << c[i] << S[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3172
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <set>
#include <cmath>
using namespace std;

int main(){
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;

    S = ' ' + S;

    vector<int> a(N+1), b(N+1);

    for(int i=1; i<N; i++)
        if(S[i] == 'A' && S[i+1] == 'C')
            a[i] = 1;

    for(int i=1; i<=N; i++)
        b[i] = b[i-1] + a[i];

    for(int i=0; i<Q; i++){
        int l, r;
        cin >> l >> r;
        if(S[r] == 'A') r--;
        cout << b[r] - b[l-1] << endl;
    }


    return 0;
}


Measured memory_bytes: 1788