akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;
ll int n,k;
ll int a[100005];
int dp[100005][2];

int solve (int k1,int flag)
{
  
  //cout<<k1<<" "<<flag<<endl;
  
  if(dp[k1][flag]!=-1)
    return dp[k1][flag];
  int ans=0;
  for(int i=0;i<n;i++)
  {
    //cout<<a[i]<<endl;
    //cout<<k1-a[i]<<endl;
    if(a[i]<=k1)
    ans|=1-solve(k1-a[i],1-flag);
  }
  dp[k1][flag]=ans;
  //dp[k1][1-flag]=1-ans;
  return ans;
}
int main()
{
  fastio();

 
ll int T;
T=1;
//T=1;
while(T--)
{
ll int i;
cin>>n>>k;
//ll int a[n];
for(i=0;i<n;i++)
cin>>a[i];
memset(dp,-1,sizeof(dp));
int ans = solve(k,0);
if(ans==1)
cout<<"First"<<endl;
else
cout<<"Second"<<endl;
}

    return 0;
}

Measured memory_bytes: 8832
from collections import deque
s = deque(input())
n = int(input())
f = 0
for i in range(n):
  l = list(map(str, input().split()))
  if l[0] == "2":
    if (l[1] == "1" and f == 0) or (l[1] == "2" and f == 1):
      s.appendleft(l[2])
    else:
      s.append(l[2])
  else:
    if f == 0:
      f = 1
    else:
      f = 0
if f == 1:
  s.reverse()
print("".join(s))


Measured memory_bytes: 8692
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;

int solve(int c, int a, int n){

  if(c < 0 || a < 0 || n < 0) return 0;
  if(c-1 >= 0 && a-1 >= 0 && n-1 >= 0) return  solve(c-1,a-1,n-1)+1;
  if(c-2 >= 0 && a-1 >= 0) return  max(solve(c-2,a-1,n),solve(c-1,a-1,n-1))+1;
  if(c-3 >= 0) return  max(solve(c-3,a,n),max(solve(c-2,a-1,n),solve(c-1,a-1,n-1)))+1;
  else return 0;

}

int main(){

  int q;
  int c,a,n;
  cin >> q;
  while(q--){
    cin >> c >> a >> n;
    cout << solve(c,a,n) << endl;
  }
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
long int gcd(long int a,long int b)
{
	if (a%b==0){
      return(b);
    }
  else{
    return(gcd(b,a%b));
  }
}
int main(){
	long int n,m;
    cin >>n >>m;
  string s,t;
  cin >> s >> t;
  long int l=gcd(n,m);
  long int k=n*m/l;
  bool bo=true;
  for(long int i=0;i<l;i++){
  	if (s[i*(n/l)]!=t[i*(m/l)]) bo=false;
  }
  if (bo==true) cout << k <<endl;
  else cout << -1 <<endl;
  
}

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

int main()
{
ll n;
  cin>>n;
  ll k;
  cin>>k;
  ll a[n+1];
  ll dp[n+1];
  ll i=1;
  while(i<=n)
  {
    
  cin>>a[i];  
   i++; 
  }
  
  
  dp[n+1];
  dp[1]=0;
  dp[0]=0;
  
  i=2;
  dp[i]=abs(a[i]-a[i-1])+dp[i-1];
//  cout<<dp[i]<<" ";
  i=3;
  while(i<=n)
  {
    
   //dp[i]=min(        abs(a[i]-a[i-1])      +dp[i-1],dp[i-2]+abs(a[i]-a[i-2])      ); 
   ll max1=1e18;
   ll j=1;
   while(j<=k)
   {
       
       if(i-j>=1)
       {
       ll k1 = abs(a[i]-a[i-j])+dp[i-j];
       if(max1>k1)
       {
           max1=k1;
       }
       
       }
       
       j++;
   }
   dp[i]=max1;
   
   
   
   
  //  cout<<dp[i]<<" ";
   i++; 
  }
  
  
  
  
  cout<<dp[n];
  
  
 return 0; 
}




Measured memory_bytes: 1792
import math

def solve():
    a, b, x = map(int, input().split(" "))
    area = float(a * b)
    if x > (area * a / 2.0):
        up_down = float(x / a) * 2.0 / a
        a2 = float(up_down - b)
        b2 = b - a2
        tan = float(b2 / a)
        print('{:.10f}'.format(math.degrees(math.atan(tan))))
        return
    else:
        base = (float(x) / area) * 2.0
        tan = float(base / b)
        print('{:.10f}'.format(90.0 - math.degrees(math.atan(tan))))
        return 

if __name__ == '__main__':
    solve()

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

const int64_t MOD = 1e9 + 7;

// O(log a)
int64_t powmod(int64_t a, int64_t p) {
    int64_t value = 1;
    for (int64_t mul = a; p > 0; p >>= 1, mul = (mul * mul) % MOD) {
        if (p & 1) value = (value * mul) % MOD;
    }
    return value;
}

int64_t invmod(int64_t x) {
    return powmod(x, MOD - 2);
}

struct Factorial {
    vector<int64_t> val;
    vector<int64_t> inv;
};

// O(N)
Factorial GetFact(int N) {
    Factorial fact;
    fact.val = vector<int64_t>(N);
    fact.inv = vector<int64_t>(N);
    fact.val[0] = 1;
    for (int i = 1; i < N; i++) {
        fact.val[i] = int64_t(fact.val[i - 1] * i) % MOD;
    }
    fact.inv[0] = 1;
    fact.inv[N - 1] = powmod(fact.val[N - 1], MOD - 2);
    for (int i = N - 1; i > 0; i--) {
        fact.inv[i - 1] = int64_t(fact.inv[i] * i) % MOD;
    }
    return fact;
}

struct MInt {
    static int64_t mod;
    int64_t v;
    MInt() {}
    MInt(int64_t x) : v(x) {}
    MInt operator+(const MInt &y) { return (v + y.v) % mod; }
    MInt operator-(const MInt &y) { return (v - y.v + mod) % mod; }
    MInt operator*(const MInt &y) { return (v * y.v) % mod; }
    MInt operator/(const MInt &y) { return (v * invmod(y.v)) % mod; }
    void operator+=(const MInt &y) { *this = *this + y; }
    void operator-=(const MInt &y) { *this = *this - y; }
    void operator*=(const MInt &y) { *this = *this * y; }
    void operator/=(const MInt &y) { *this = *this / y; }
    friend istream &operator>>(istream &ist, MInt &m) { return ist >> m.v; }
    friend ostream &operator<<(ostream &ost, MInt &m) { return ost << m.v; }
};
int64_t MInt::mod = MOD;

int64_t Combination(int n, int m, const Factorial &f) {
    if (n < m || m < 0 || n < 0) return 0;
    return ((f.val[n] * f.inv[m] % MOD) * f.inv[n - m]) % MOD;
}
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, M, K;
    cin >> N >> M >> K;
    MInt ans = 0;
    Factorial f = GetFact(N * M + 10);
    for(int i = 0; i < 2; i++) {
        ans += MInt(M) * MInt(M) * MInt(Combination(N + 1, 3, f));
        swap(N, M);
    }
    ans *= MInt(Combination(N * M - 2, K - 2, f));
    cout << ans << endl;
    return 0;
}

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

#define Online 1
#define multitest 1
#define Debug 1
void ControlIO();
void TimerStart();
void TimerStop();
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif
typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000003;
mt19937 rang(chrono::steady_clock::now().time_since_epoch().count());
int rng(int lim)
{
	uniform_int_distribution<int> uid(0, lim - 1);
	return uid(rang);
}

ll power(int base, int index)
{
	if (index == 0)
		return 1;
	ll temp = power(base, index / 2);
	temp = (temp * temp) % mod;
	if (index & 1)
		temp = (temp * base) % mod;
	return temp;
}
// cout << fmod((power(d, n+1) * fact(n-1) )%mod * beta((ld)a / d,n),mod) << '\n';

int n, a, b, c;

int _n = 1000003;
vector<ll> Fact(_n), Inv(_n);
int kmod = mod;

void pre()
{
	Fact[0] = 1;
	for (int i = 1; i < _n; ++i)
		Fact[i] = (Fact[i - 1] * i) % kmod;
	Inv[_n - 1] = power(Fact[_n - 1], kmod - 2);
	for (int i = _n - 2; i >= 0; --i)
		Inv[i] = (Inv[i + 1] * (1 + i)) % kmod;
	// db(Inv[2]*2%mod);
}

void solve()
{
	int a, d, n;
	cin >> a >> d >> n;
	if (d == 0)
		cout << power(a, n) << '\n';
	else
	{
		a = (a * power(d, mod - 2)) % mod;
		if (a + n > mod)
			cout << 0 << '\n';
		else
		{
			ll ans = power(d, n);
			ans *= Fact[a + n - 1];
			ans %= mod;
			ans *= Inv[a - 1];
			ans %= mod;
			cout << ans << '\n';
		}
	}
}

int main()
{
	pre();
	ControlIO();
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	TimerStart();
	while (t--)
		solve();
	TimerStop();
	return 0;
}

void ControlIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifndef Online
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();

void TimerStart()
{
#ifndef Online
	TimeStart = chrono::steady_clock::now();
#endif
}

void TimerStop()
{
#ifndef Online
	TimeEnd = chrono::steady_clock::now();
	auto ElapsedTime = TimeEnd - TimeStart;
	cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
#endif
}

Measured memory_bytes: 16512
def main():
    A, B, C, D = map(int, input().split())
    while True:
        C -= B
        if C <= 0:
            print("Yes")
            return 0
        A -= D
        if A <= 0:
            print("No")
            return 0

    return 0

if __name__ == '__main__':
    main()

Measured memory_bytes: 9176
#include<stdio.h>
#define ll long long 
int main(){
  int n,i;
  ll h,sum=0;
  scanf("%lld%d",&h,&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    sum+=a[i];
  }
  if(h<=sum)
    puts("Yes");
  else
    puts("No");
  return 0;
}

Measured memory_bytes: 512
r,c = map(int,input().split())
lst = [[0 for i in range(c+1)]for j in range(r+1)]

for i in range(r):
    tmp = list(map(int,input().split()))
    for j in range(c):
        lst[i][j] = tmp[j]

for i in range(c):
    for j in range(r):
        lst[-1][i] += lst[j][i]
        
for i in range(r+1):
    for j in range(c):
        lst[i][-1] += lst[i][j]
        
for i in lst:
    print(*i)


Measured memory_bytes: 6220
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
using namespace std;



int main(){
  ll N; cin>>N;
  vector <ll> A; A.resize(N+1,0);
  vector <ll> dp; dp.resize(N+1,0); dp[0] = 0;
  vector <ll> rp; rp.resize(N+1,0); rp[0] = -INF;
  for(int i=0;i<N;i++) cin>>A[i+1];
  dp[1] = (A[1]);
  rp[1] = -(A[1]);

  //cout<<1<<endl;
  //cout<<dp[1]<<"   "<<rp[1]<<endl;
  if(N == 2){
    cout<<max(dp[1] + A[2] , rp[1] - A[2]);
    return 0;
  }

  for(int i=2;i<=N-1;i++){ // 漸化式
//  ll a = A[i-1];
 // ll b = A[i];

  ll dp1,dp2,dp3,dp4;
  ll rp1,rp2,rp3,rp4;

  

  dp1 = max(dp[i-2] + A[i-1] + A[i], dp[i-2] - A[i-1] - A[i]); 
  //cout<<dp1<<endl;
  dp2 = dp[i-1] + A[i];
  dp3 = max(rp[i-2] - A[i-1] + A[i] , rp[i-2] + A[i-1] - A[i]);
  //if(i==2) dp3 = 0;
  //cout<<dp2<<endl;
  //cout<<dp3<<endl;
  dp4 = rp[i-1] - A[i];
  //cout<<dp4<<endl;

  rp1 = max(rp[i-2] - A[i-1] - A[i] , rp[i-2] + A[i-1] + A[i]);
  rp2 = rp[i-1] + A[i];
  rp3 = max(dp[i-2] + A[i-1] - A[i] , dp[i-2] - A[i-1] + A[i]);
  //if(i==2) rp3 = 0;
  rp4 = dp[i-1] - A[i];

  
ll res_dp = max(dp1,dp2);
res_dp = max(res_dp,dp3);
dp[i] = max(res_dp , dp4);

ll res_rp = max(rp1,rp2);
res_rp = max(res_rp,rp3);
rp[i] = max(res_rp , rp4);


//cout<<dp[i]<<"   "<<rp[i]<<endl;


  }


cout<<max(dp[N-1] + A[N] , rp[N-1] - A[N]) <<endl;

  return 0;
}

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

#define false 0
#define true 1

int isPrime(int);

int main()
{
  int n,ans = 0;
  int y;
  int i;
  scanf("%d",&n);
  for(i = 0; i < n; i++)
    {
      scanf("%d",&y);
      if(isPrime(y))
        ans++;
    }
  printf("%d\n",ans);
  return 0;
}

int isPrime(int x)
{
  int i;
  if(x == 2)
    return true;
  if(x < 2 || x%2 == 0)
    return false;
  i = 3;
  while((double)i <= sqrt((double)x))
    {
      if(x % i == 0)
        return false;
      i = i + 2;
    }
  return true;
}



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

int n;

int get(int x) {
	int sum = 0;
	while(x) { sum += x % 10; x /= 10; }
	return sum;
}

int main() {
	scanf("%d", &n);
	int mn = 1e9;
	for(int i = 1; i < n; ++i) mn = min(mn, get(i) + get(n-i));
	printf("%d\n", mn);
}


Measured memory_bytes: 256
S_n = lambda n:n*(n+1)//2

def solve():
  N,K = map(int, input().split())
  P = list(map(int, input().split()))
  Q_idx = 0
  Q = P[:K]
  sum_Q = sum(Q)
  sum_Q_ = sum(Q)
  for i in range(N-K):
    sum_Q_ = sum_Q_ - P[i] + P[K+i]
    if sum_Q < sum_Q_:
      Q_idx = i+1
      sum_Q = sum_Q_

  Q = P[Q_idx:Q_idx+K]
  # print(Q)
  print(sum(S_n(q)/q for q in Q))
  
solve()

Measured memory_bytes: 25060
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double PI = acos(-1.0), EPS = 1e-10;

inline double SQ(double x) {
	return x * x;
}

inline double DIST(double x1, double y1, double x2, double y2) {
	return sqrt(SQ(x1 - x2) + SQ(y1 - y2));
}

int main() {
	int N; cin >> N;
	while(N--) {
		double x1, y1, x2, y2, x3, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		double A = x1 - x2;
		double B = y1 - y2;
		double C = x1 - x3;
		double D = y1 - y3;
		
		double S = SQ(x1) - SQ(x2) + SQ(y1) - SQ(y2);
		double T = SQ(x1) - SQ(x3) + SQ(y1) - SQ(y3);
		
		double delta = (A * D - B * C);
		
		double X = (D * S - B * T) / 2 / delta;
		double Y = (-1 * C * S + A * T) / 2 / delta;
		
		printf("%.3f %.3f %.3f\n", X, Y, DIST(x1, y1, X, Y));
	}
	return 0;
}

Measured memory_bytes: 0
import itertools
A = list(itertools.chain.from_iterable([list(map(int, input().split())) for _ in range(3)]))

bingo = [0 for _ in range(10)]
N = int(input())

for i in range(N):
    b = int(input())
    for j in range(9):
        if b == A[j]:
            bingo[j] = 1

f = 0
for i in range(3):
    if sum(bingo[i*3:i*3+3]) == 3:
        f = 1
        break
    if sum(bingo[i::3]) == 3:
        f = 1
        break

if sum(bingo[0::4]) == 3:
    f = 1
if sum(bingo[2:7:2]) == 3:
    f = 1

if f:
    print("Yes")
else:
    print("No")

'''
1 2 3
4 5 6 
7 8 9
3
1
4
7
'''

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  string a, b, c;
  cin >> a >> b >> c;
  
  if (a+b+c=="575" || a+c+b=="575" || b+a+c=="575" ||
      b+c+a=="575" || c+a+b=="575" || c+b+a=="575") {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3584
#include<iostream>
#include<cstring>

using namespace std;

int main(){
	int n, m, l, r, cnt = 0;
	cin >> n >> m;
	int cum[n + 2];
	memset(cum, 0, sizeof(cum));
	for(int i = 0; i < m; i++){
		cin >> l >> r;
		++cum[l];
		--cum[r + 1];
	}

	for(int i = 1; i <= n; i++){
		cum[i] += cum[i - 1];
	}

	for(int i = 1; i <= n; i++){
		cnt += (cum[i] == m);
	}

	cout << cnt;
	return 0;
}


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

using namespace std;

using ll = long long int;

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanVecInt(V, N);
    array<vector<int>, 2> A;
    for (auto& a : A) a.resize(N / 2);
    REP(i, N){
        A[i % 2][i / 2] = V[i];
    }
    array<unordered_map<int, int>, 2> count;
    array<vector<pair<int, int>>, 2> sorted;
    REP(i, 2){
        REP(k, N / 2){
            count[i][A[i][k]]++;
        }
        for (auto& e : count[i]){
            sorted[i].push_back(e);
        }
        sort(sorted[i].begin(), sorted[i].end(), [](pair<int, int>& l, pair<int, int>& r){return l.second > r.second;});
        // for (auto& e : sorted[i]) cout << e.first << " " << e.second << endl;
        sorted[i].emplace_back(-1 - i, 0);
    }
    int b1, b2;
    if (sorted[0][0].first == sorted[1][0].first){
        if (sorted[0][1].second < sorted[1][1].second){
            b1 = sorted[0][0].second;
            b2 = sorted[1][1].second;
        }else{
            b1 = sorted[0][1].second;
            b2 = sorted[1][0].second;
        }
    }else{
        b1 = sorted[0][0].second;
        b2 = sorted[1][0].second;
    }
    cout << (N - b1 - b2) << endl;
}

Measured memory_bytes: 6280
N,K,S = map(int,input().split())
ans = []
for _ in range(K):
    ans.append(str(S))
if S == 10 ** 9:
    x = 10 ** 9 - 1
else:
    x = 10 ** 9
for _ in range(N-K):
    ans.append(str(x))
print(' '.join(ans))

Measured memory_bytes: 54000
N = int(input())
t = input()
S = []
for i in range(N):
    S.append(t[i])
import copy
ans = 0
f = []
for i in range(10):
    if str(i) in S:
        f.append(str(i))
while len(f) > 0 and len(S) > 2:
    k = S.pop(0)
    if k in f:
        f.remove(k)
        s = []
        for j in range(10):
            if str(j) in S:
                s.append(str(j))
        T = copy.deepcopy(S)
        while len(s) > 0 and len(T) > 1:
            l = T.pop(0)
            if l in s:
                s.remove(l)
                for i in range(10):
                    if str(i) in T:
                        ans += 1
                        
print(ans)

Measured memory_bytes: 4400
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<iomanip>
using namespace std;
int main() {
	int h,w;
	cin >> h>>w;
	for(int i = 0; i < h; ++i) {
		string s;
		cin >> s;
		cout << s <<endl;
		cout << s << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdio.h>
int main(){
  int n,i,j;
  int H[251];
  scanf("%d",&n);
  for(i=1; i<=n; i++){
    scanf("%d",&H[i]);
  }

  for(i=1; i<=n; i++){
    printf("node %d: key = %d, ",i,H[i]);
    if(i-1){
      printf("parent key = %d, ",H[i/2]);
    }
    if(2*i<=n){
      printf("left key = %d, ",H[2*i]);
    }
    if(2*i+1<=n){
	printf("right key = %d, ",H[2*i+1]);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2104
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int ans = k;
    for (int i = 2; i <= n; i++) {
      ans = ans * (k - 1);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35612
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
#include<cmath>
#define id(i,j) (i-1)*m+j
#define ll long long
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,m,first[30010],dep[30010],cur[30010],cnte=-1,tot;
struct edge{
	int to,next,w;
}a[200010];
inline void add(int u,int v,int w){
//	cout<<"add "<<u<<' '<<v<<' '<<w<<'\n';
	a[++cnte]=(edge){v,first[u],w};first[u]=cnte;
	a[++cnte]=(edge){u,first[v],0};first[v]=cnte;
}
bool bfs(int s,int t){
//	cout<<"bfs "<<s<<' '<<t<<'\n';
	int i,q[30010],head=0,tail=1,u,v;
	for(i=1;i<=tot;i++) dep[i]=-1,cur[i]=first[i];
	q[0]=s;dep[s]=0;
	while(head<tail){
		u=q[head++];
//			cout<<"start "<<u<<'\n';
		for(i=first[u];~i;i=a[i].next){
			v=a[i].to;if(~dep[v]||!a[i].w) continue;
//			cout<<"		from "<<u<<" to "<<v<<' '<<a[i].w<<'\n';
			dep[v]=dep[u]+1;q[tail++]=v;
		}
	}
	return ~dep[t];
}
int dfs(int u,int t,int lim){
	if(u==t||!lim) return lim;
	int i,v,f,flow=0;
	for(i=cur[u];~i;i=a[i].next){
		v=a[i].to;cur[u]=i;
		if(dep[v]==dep[u]+1&&(f=dfs(v,t,min(lim,a[i].w)))){
			flow+=f;lim-=f;
			a[i].w-=f;a[i^1].w+=f;
			if(!lim) return flow;
		}
	}
	return flow;
}
void dinic(int s,int t){
	int ans=0;
	while(bfs(s,t)) ans+=dfs(s,t,1e9);
	if(ans<=n*m) printf("%d\n",ans);
	else puts("-1");
}
int x[110][110],S,T;
int main(){
	memset(first,-1,sizeof(first));
	n=read();m=read();char s[110];int i,j;
	for(i=1;i<=n;i++){
		scanf("%s",s);
		for(j=0;j<m;j++){
			if(s[j]=='.') continue;
			x[i][j+1]=1;
			if(s[j]=='S') S=id(i,j+1); 
			if(s[j]=='T') T=id(i,j+1);
		}
	}
	tot=n*m*2;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			if(!x[i][j]) continue;
			add(n*m+id(i,j),tot+i,1e9);
			add(n*m+id(i,j),tot+n+j,1e9);
			add(tot+i,id(i,j),1e9);
			add(tot+n+j,id(i,j),1e9);
			if(id(i,j)!=S&&id(i,j)!=T) add(id(i,j),n*m+id(i,j),1);
		}
	}
	tot=n*m*2+n+m;
	dinic(n*m+S,T);
}


Measured memory_bytes: 1920
#include<iostream>
using namespace std;
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
#include<queue>
#include<unordered_map>
#include<set>
#include<cmath>
#define mod 1000000007
#define inf 1000000000000000
#define int long long int
void dfs(int src,vector<int> adj[],int arr[],bool visited[],int d)
{
	if(visited[src])
	    return ;
	else
	{
		visited[src]=true;
		arr[src]=d;
		for(int x:adj[src])
		   dfs(x,adj,arr,visited,d+1);
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	bool visited[n+1]={false},visited2[n+1]={false};
	vector<int> adj[n+1];
	int j;
	for(j=1;j<n;j++)
	{
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	int arr1[n+1],arr2[n+1];
	dfs(1,adj,arr1,visited,0);
	dfs(n,adj,arr2,visited2,0);
	int f=0,s=0;
	for(j=1;j<=n;j++)
	{
		if(arr1[j]<=arr2[j])
		{
			f++;
		}
		else
		   s++;
	}
	if(f>s)
	  cout<<"Fennec"<<endl;
	else
	  cout<<"Snuke"<<endl;
}


Measured memory_bytes: 17080
n = int(input())
w = []
for i in range(n):
    w.append(str(input()))

if not len(w)==len(set(w)):
    print('No')
    import sys
    sys.exit()

for i in range(len(w)-1):
    if not w[i][-1]==w[i+1][0]:
        print('No')
        import sys
        sys.exit()
print('Yes')

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



int main(){
  long long n, x, i, j, minv = 10000000000, maxv = -1000000000;
  cin >> n;
  for (j = 0; j < n; j++){
    cin >> x;
    maxv = max(maxv, x - minv);
    minv = min(minv, x);
  }
  // cout << "\n";
  cout << maxv << "\n";
  return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}

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

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

    for(int i = 0; i < s.size(); i++) {
        s[i] -= 65;
        s[i] += n;
        s[i] %= 26;
        s[i] += 65;
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
// execute g++ main.cpp -std=c++14 -I C:\Users\naoya\Desktop\code\Atcoder
#include<bits/stdc++.h>
//#include<atcoder/all>
typedef long long ll;
typedef long double ld;
using namespace std;
//using namespace atcoder;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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;}

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;}


char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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


int main(){
    ll n; cin >> n;
    int ans = 0;
    REP(a, 1, n){
        REP(b, 1, n){
            if(a * b <= n-1){
                ans++;
            }else{
                break;
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int k, a, b;

void input() {
    cin >> k;
    cin >> a >> b;
}

void judge() {
    for(int i = a; i <= b; i++) {
        if(i % k == 0) {
            cout << "OK" << endl;
            exit(0);
        }
    }
    cout << "NG" << endl;
}

int main() {
    input();
    judge();
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    string S;
    cin >> S;

    string ans;
    if( S <= "2019/04/30" )  ans = "Heisei";
    else    ans = "TBD";

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

const int MAXN = (int)2e5;

int64_t a[MAXN], b[MAXN];

int solve(int a_len, int b_len, int total_time) {
  for (int i = 1; i < a_len; ++i) {
    a[i] += a[i - 1];
  }
  for (int i = 1; i < b_len; ++i) {
    b[i] += b[i - 1];
  }
  
  int p_a = 0, p_b = b_len - 1;
  while (p_b >= 0 && b[p_b] > total_time) {
    --p_b;
  }
  int ans = p_b + 1;
  while (p_a < a_len) {
    while (p_b >= 0 && a[p_a] + b[p_b] > total_time) {
      --p_b;
    }
    if (p_b < 0 && a[p_a] > total_time) {
      break;
    }
    int cur = p_a + p_b + 2;
    if (cur > ans) ans = cur;
    ++p_a;
  }
  return ans;
}

int main() {
  int n, m, k;
  std::cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) std::cin >> a[i];
  for (int i = 0; i < m; ++i) std::cin >> b[i];
  
  std::cout << solve(n, m, k) << std::endl;
  return 0;
}


Measured memory_bytes: 6748
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int H, N;
	int aMax, bMax;
	List<Pair> list;
	int result = 0;

	static class Pair {
		int A, B;

		Pair(int A, int B) {
			this.A = A;
			this.B = B;
		}

		void show() {
			double val = (double) A / (double) B;
			System.out.println(A + ", " + B + ", " + val);
		}
	}

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		H = Integer.parseInt(tokens[0]);
		N = Integer.parseInt(tokens[1]);
		list = new ArrayList<>(N);
		for (int i = 0; i < N; ++i) {
			tokens = in.readLine().split(" ");
			list.add(new Pair(Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1])));
		}
		Collections.sort(list, new Comparator<Pair>() {
			@Override
			public int compare(Pair o1, Pair o2) {
				double val1 = (double) o1.A / (double) o1.B;
				double val2 = (double) o2.A / (double) o2.B;
				if (val1 != val2) {
					return -1 * Double.compare(val1, val2);
				} else {
					return Integer.compare(o1.A, o2.A);
				}
			}
		});
		aMax = list.get(0).A;
		bMax = list.get(0).B;
	}

	void calc() {
		int[] magic = new int[H + 1];
		Arrays.fill(magic, 0);
		// 初期化
		Pair first = list.get(0);
		for (int i = 1; i <= Math.min(H, first.A); ++i) {
			magic[i] = first.B;
		}
		for (int i = first.A + 1; i <= H; ++i) {
			magic[i] = magic[i - first.A] + first.B;
		}

		// 順に適用していく
		for (int i = 1; i < list.size(); ++i) {
			Pair pair = list.get(i);
			for (int j = 1; j <= H; ++j) {
				if (j - pair.A < 0) {
					magic[j] = Math.min(magic[j], pair.B);
				} else {
					magic[j] = Math.min(magic[j], magic[j - pair.A] + pair.B);
				}
			}
		}

		result = magic[H];

	}

	void showResult() {
		System.out.println(result);
	}
}

Measured memory_bytes: 23508
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	final long MOD=(long)1e9+7;
	
	long pow(long a,long n,long p) {
		long ret=1;
		for (;n>0;n>>=1,a=a*a%p) if(n%2==1) ret=ret*a%p;
		return ret;
	}
	
	long gcd(long a,long b) {
		return a==0?b:gcd(a,b);
	}
	

	void run() {
		Scanner sc=new Scanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		boolean[] isPrime=new boolean[(int)1e5+10];
		boolean[] isQrime=new boolean[(int)1e5+10];
		int[] cnt=new int[(int)1e5+10];
		Arrays.fill(isPrime, true);Arrays.fill(isQrime, true);;
		isPrime[0]=isPrime[1]=isQrime[0]=isQrime[1]=false;
		ArrayList<Integer> qrime=new ArrayList<>();
		qrime.add(1);
		for (int i=2;i<isPrime.length;++i) {
			if (isQrime[i]) qrime.add(i);
			if (!isPrime[i]) continue;
			for (int j=2*i;j<isPrime.length;j+=i) isPrime[j]=false;
			for (int j=1*i;j<isPrime.length;j+=i) ++cnt[j];
			for (long j=(long)i*i;j<isQrime.length;j+=i*i) isQrime[(int)j]=false;
		}
		long N=sc.nextLong();
		long K=sc.nextLong();
		long ans=0;
		for (long gcd=1;gcd<=K;++gcd) {
			for (int q:qrime) {
				if (K<gcd*q) break;
				ans+=pow(K/(gcd*q),N,MOD)*(cnt[q]%2==0?1:MOD-1)%MOD*gcd%MOD;
				ans%=MOD;
			}
		}
		pw.println(ans);
		pw.close();
	} 
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
	
    public static void main(String[] args) {
    	new Main().run();
    }
}


Measured memory_bytes: 42344
N = map(int, input())
A = list(map(int, input().split()))

A.insert(0, A[0])

stand_h = 0

for i in range(1, len(A)):
  diff = A[i - 1] - A[i]
  if (diff > 0):
   A[i] = A[i] + diff
   stand_h += (diff)

print(stand_h)

Measured memory_bytes: 32220
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Integer a[] = new Integer[N];
        for (int i=0; i<N; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());

        int diff = 0;
        for (int i=0; i<N; i++) {
            if (i % 2 == 0)
                diff += a[i];
            else
                diff -= a[i];
        }
        System.out.println(diff);
    }
}


Measured memory_bytes: 21972
#include<stdio.h>

#define ll long long int
#define MAX 2019

int main() {
  ll l, r;
  scanf("%lld %lld", &l, &r);
  ll i, j;
  int min = MAX - 1;
  int cand;
  int imod, jmod;
  int idiv, jdiv;
  int flag = 0;
  for(i = l; i <= r - 1; i++) {
    imod = i;
    idiv = imod / MAX;
    imod -= idiv * MAX;
    if(imod == 0 || flag == 1) {
      min = 0;
      break;
    }
    for(j = i + 1; j <= r; j++) {
      jmod = j;
      jdiv = jmod / MAX;
      jmod -= jdiv * MAX;
      if(jmod == 0) {
        flag = 1;
        break;
      }
      cand = (imod * jmod) % MAX;
      if(cand < min) min = cand;
    }
  }
  printf("%d\n", min);
  return 0;
}


Measured memory_bytes: 128
import sys,math

N,H = map(int,input().split())
a=[]
b=[]

for i in range(N):
	aa,bb=map(int,input().split())
	a.append(aa)
	b.append(bb)

a.sort(reverse=True)
b.sort(reverse=True)

atk=0
count=0
for i in range(N):
	if b[i]>a[0]:
		atk+=b[i]
		count+=1
		if atk>=H:
			print(count)
			sys.exit()
	else:
		break


count+=math.ceil((H-atk)/a[0])
print(count)


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

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

int main(){
    int H, W;
    cin >> H >> W;
    vii A(H, vi(W)), B(H, vi(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];
    }
    vii C(H, vi(W));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            C[i][j]=abs(A[i][j]-B[i][j]);
        }
    }
    int N=80*80;
    bool dp[H][W][N+1];
    memset(dp, 0, sizeof(dp));
    vii check(H, vi(W, 0));
    queue<pii> que;
    check[0][0]=1;
    que.push({0, 0});
    dp[0][0][C[0][0]]=1;
    while(!que.empty()){
        int x, y;
        tie(x, y)=que.front();
        que.pop();
        for(int i=0; i<2; i++){
            int nx, ny;
            nx=x+dx[i], ny=y+dy[i];
            if(nx<0 || nx>=H || ny<0 || ny>=W) continue;
            if(check[nx][ny]) continue;
            check[nx][ny]=1;
            que.push({nx, ny});
        }
        for(int i=0; i<2; i++){
            int px, py;
            px=x-dx[i], py=y-dy[i];
            if(px<0 || px>=H || py<0 || py>=W) continue;
            for(int j=0; j<=N; j++){
                if(dp[px][py][j]){
                    dp[x][y][abs(j-C[x][y])]=1;
                    if(j+C[x][y] <= N){
                        dp[x][y][j+C[x][y]]=1;
                    }
                }
            }
        }
    }
    int res;
    for(int i=0; i<=N; i++){
        if(dp[H-1][W-1][i]){
            res=i;
            break;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 43736
from collections import deque

H,W=[int(i) for i in input().split()]
C=[input() for _ in range(H)]
C=[list(i) for i in C] 

ans = 10**9

visited_list = [[10**9]*W for _ in range(H)]

if C[0][0] == "#": 
    stack = deque([[0, 0, 1]])
    visited_list[0][0] = 1
else:
    stack = deque([[0, 0, 0]])
    visited_list[0][0] = 0

def dfs(town, visited_list, stack):
    global ans
    while len(stack) > 0:
        h, w, cnt = stack.pop()
        if h == H-1 and w == W-1 and ans > cnt:
            ans = cnt
            continue
        for j, k in ([1, 0], [0, 1]):
            new_h, new_w = h+j, w+k
            if new_h < 0 or new_h >= H or new_w < 0 or new_w >= W:
                continue
            if  town[new_h][new_w] != "#" and visited_list[new_h][new_w] > cnt:
                visited_list[new_h][new_w] = cnt
                stack.append([new_h, new_w, cnt])
            elif town[h][w] == "#" and town[new_h][new_w] == "#" and visited_list[new_h][new_w] > cnt:
                visited_list[new_h][new_w] = cnt
                stack.append([new_h, new_w, cnt])
            elif town[new_h][new_w] == "#" and visited_list[new_h][new_w] > cnt + 1:
                visited_list[new_h][new_w] = cnt + 1
                # print("a " + str(cnt+1))
                stack.append([new_h, new_w, cnt+1])
    return ans

print(dfs(C, visited_list, stack))

Measured memory_bytes: 45036
import java.util.*;

public class Main {

    static List<Long> divisor(long n) {
        List<Long> list = new ArrayList<Long>();
        for (long i=1;i<=Math.sqrt(n);i++) {
            if (n%i==0) {
                list.add((long)i);
                if (i*i!=n) {
                    list.add(n/i);
                }
            }
        }
        Collections.sort(list);
        return list;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        ArrayList<Long> list_2 = new ArrayList<Long>(divisor(N));
        int ans = 0;
        for (int i=0;i<list_2.size();i++) {
            long tmp = N;
            if (list_2.get(i)==1) continue;

            while (tmp%list_2.get(i)==0) {
                tmp = tmp/list_2.get(i);
            }
            if (tmp%list_2.get(i)==1) ans++;
        }
        ArrayList<Long> list = new ArrayList<Long>(divisor(N-1));
        System.out.println(ans+list.size()-1);
    }
}

Measured memory_bytes: 24020
function Main(s) {
  var s = s.split("\n");
  var n = s[0].split(" ")[0]*1, k = s[0].split(" ")[1]*1;
  var h = s[1].split(" ").map(e => e*1);
  var dp = new Array(n).fill(Infinity);
  dp[0] = 0;
  for (var i = 1; i < n; i++) {
    for (var j = i - 1; j >= i - k; j--) {
      dp[i] = Math.min(dp[i], dp[j] + Math.abs(h[j] - h[i]));
      if (j === 0) break;
    }
  }
  console.log(dp[dp.length - 1]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 27816
A,B = map(int,input().split())
S = input()
ans = True
for i in range(len(S)):
    if(i == A):
        if(S[i] != "-"):
            ans = False
    else:
        if(S[i].isdigit() != True):
            ans = False
if(len(S) != A + B + 1):
    ans = True
if(ans):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include <iostream>
using namespace std;
int main(void){
   int W,H,x,y,r;
   cin >> W >> H >> x >> y >> r;
   if(x>=r && x<=W-r && y>=r && y<=H-r){
       cout << "Yes";
   }
   
   else{
       cout << "No";       
   }
    cout << endl; 
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define llinf LONG_LONG_MAX
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rrep(i,a,b) for(i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define pf push_front
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
const ll N=5e2+1,mod=1000000007;
signed main()
{
    fast;
    ll pro=1,temp,t,n,i,m,k,j,l,r,mid,x,y,z,rem,carry=0,ind,ans=0,mx=-llinf,mn=llinf,cnt=0,curr=0,prev,sum=0,flag=1,i1=-1,i2=-1;
    cin>>n;
    ll a[n+1];
    rep(i,1,n)
    {
        cin>>a[i];
        if(a[i]!=i)
        {
            if(i1==-1)
            {
                i1=i;
            }
            i2=i;
        }
    }
    if(i1!=-1 && i2!=-1)
    {
        swap(a[i1],a[i2]);
    }
    rep(i,1,n)
    {
        if(a[i]!=i)
        {
            return cout<<"NO",0;
        }
    }
    cout<<"YES";
    return 0;
} 

Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <iomanip>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <cassert>
#include <stack>
#include <climits>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <memory>
#include <functional>
#include <cfloat>
#include <numeric>

#include <atcoder/convolution>
int main() {
	int n, m; std::cin >> n >> m;
	std::vector<int> a(n), b(m);
	for (auto& x : a) std::cin >> x;
	for (auto& x : b) std::cin >> x;
	const auto c = atcoder::convolution(a, b);
	for (auto i = 0; i < c.size(); ++i) {
		if (i > 0) std::cout << ' ';
		std::cout << c[i];
	}
	std::cout << '\n';
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll a, b, c;
  cin >> a >> b >> c;

  string ans = "No";
  if(a < b && c < b && a < c){
    ans = "Yes";
  } else if (a > b && c > b && a > c){
    ans = "Yes";
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3532
using System;
class Program
{
	static void Main(string[] args)
	{
        string S = Console.ReadLine();

		//出力
        if((S[0] == S[1]) && (S[1] == S[2]) && (S[2] == S[0]))
        {
            Console.WriteLine("No");
        }
        else
        {
            Console.WriteLine("Yes");
        }
	}
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();

		System.out.println(A<=8 && B<=8?"Yay!":":(");
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main(void){
	string str;
	string w;
	int ans = 0;

	cin >> w;

	for(int i=0; i<w.size(); i++){
		if(w[i] >= 'a' && w[i] <= 'z'){
			w[i] -= 'a' - 'A';
		}
	}

	while(cin >> str){
		if(str == "END_OF_TEXT") break;
		for(int i=0; i<str.size(); i++){
			if(str[i] >= 'a' && str[i] <= 'z'){
				str[i] -= 'a' - 'A';
			}
		}
		if(w == str) ans++;
	}
	printf("%d\n", ans);

	return 0;
}

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

int main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  for (int i = 0; i < H; i ++) {
    for (int j = 0; j < W; j++) {
      if (i < B && j < A) cout << 0;
      else if (B <= i && A <= j) cout << 0;
      else cout << 1;
      if (j == W-1) cout << endl;
    }
  }
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;
// assert(a[i]<n ) // if we want to check for special cond , used for debug
// make less_equal in order to make a multiset pbds
const ll Mod = (ll)1e9+7;
ll CaseN=1;

ll tst(ll n,ll *a)
{
ll ans=0;


return ans;
}


void solve()
{
	ll n;
	ll ans=0;
	cin>>n;
	ll a[n+1];
	
	for(ll i=1;i<=n;i++)
	{
	cin>>a[i];	
	}
	
	for(ll i=2;i<=n;i++)
	{
		if(a[i]<a[i-1])
		{
			ans+=(a[i-1]-a[i]);
			a[i]=a[i-1];
		}

	}

	cout<<ans<<endl;
	//cout<<"Case #"<<CaseN<<": ";	
	CaseN++;
		// print your ans below;		
	
return ;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	while(t--)
	{
	solve();	
	}
}
/*
 if(ans)
  {
  cout<<"YES"<<endl; 
  }
  else
   {
  cout<<"NO"<<endl;
  }

*/


Measured memory_bytes: 5208
using System;

namespace tst
{
    class Program
    {
        static void Main(string[] args)
        {
            //nは繰り返しの回数
            int n = int.Parse(Console.ReadLine());
            //input//5 3 2 4 1 //strをint配列に
            string str = Console.ReadLine();
            string[] dt_str = str.Split(' ');
            int[] dt = new int[n];
            for (int i = 0; i <= n - 1; i++)
            {
                dt[i] = int.Parse(dt_str[i]);
            }
            //int [] dt=[5,3,2,4,1}となってるはず
            int ct = 0;
            for(int i=0; i<=n-1; i++)
            {   
                //一番小さい数字のindexをminにいれる
                int min = i;
                for(int j = i; j <= n - 1; j++)
                {
                    if (dt[j] < dt[min]) min = j;
                }
                //もし一つ目がminなら交換は不要
                if (i != min)
                {
                    int alt = dt[i];
                    dt[i] = dt[min];
                    dt[min] = alt;
                    ct += 1;
                }
            }
            //結果の出力
            Console.Write(dt[0]);
            for (int i = 1; i <= n - 1; i++)
            {
                Console.Write(" " + dt[i]);
            }
            Console.WriteLine();
            Console.WriteLine(ct);
        }
    }
}


Measured memory_bytes: 15936
#include<stdio.h>
int main(void){
	int data[100],n,max=0;
	for(n=0; n<100; n++){
		data[n]=0;
	}
	while(scanf("%d",&n)!=EOF){
		data[n-1]++;
		if(max<data[n-1]){
			max=data[n-1];
		}
	}
	for(n=0; n<100; n++){
		if(max==data[n]){
			printf("%d\n",n+1);
		}
	}
	return 0;
}

Measured memory_bytes: 596
N, M, C = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(N)]
ans = 0

for i in range(N):
  num = 0
  for j in range(M):
    num += b[j]*a[i][j]
  if num > (-1)*C:
    ans += 1

print(ans)

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

int main()
{
    char ch;
    int cnt[26] = {};
    
    while(cin >> ch){
        ch = tolower(ch);
        if( isalpha(ch)){
            cnt[ch - 'a']++;
        }
    }
    for( int i = 0;i < 26;i++){
        printf("%c : %d\n",i+'a',cnt[i]);
    }
    return 0;
}

Measured memory_bytes: 3140
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt() + sc.nextInt();
        int m = sc.nextInt() + sc.nextInt();
        String ans;
        if(n > m) ans = "Left";
        else if(n == m) ans = "Balanced";
        else ans = "Right";
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
<?php
fscanf(STDIN, '%d %d', $a, $b);
if($a == 1){$a = 14;}
if($b == 1){$b = 14;}
if($a > $b){
    print 'Alice';
}elseif($a == $b){
    print 'Draw';
}else{
    print 'Bob';
}

Measured memory_bytes: 4604
#include <stdio.h>
#include <stdlib.h>
int linearsearch(int, int *, int);
int main(){
  int n, q, S[10000], T;
  int i, num, count = 0;
  scanf("%d",&n);
  for(i = 0; i < n; i++)scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&T);
    num = linearsearch(T, S, n);
    if(num == 1)count++;
  }
  printf("%d\n",count);
  return 0;
}

int linearsearch(int T, int S[], int n){
  int i = 0;
  while(T != S[i]){
    i++;
    if(i == n)return 0;
  }
  return 1;
}



Measured memory_bytes: 2044