akhauriyash/Code-Regression huggingface dataset:
from typing import List


def answer(n: int, m: int, a: List[str], b: List[str]) -> str:
    for i in range(n - m + 1):
        for j in range(n - m + 1):
            if a[i][j:j + m] == b[0]:
                matched_lines = 1
                for k in range(1, m):
                    if a[i + k][j:j + m] == b[k]:
                        matched_lines += 1
                    else:
                        break
                if matched_lines == m:
                    return 'Yes'

    return 'No'


def main():
    n, m = map(int, input().split())
    a = [input() for _ in range(n)]
    b = [input() for _ in range(m)]
    print(answer(n, m, a, b))


if __name__ == '__main__':
    main()

Measured memory_bytes: 10212
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(W));
  rep(i, H) {
    rep(j, W) {
      cin >> A[i][j];
    }
  }

  vector<vector<int>> dist(H, vector<int>(W, INF));

  rep(iter, 2) {
    rep(i, H) {
      rep(j, W) {
        if (A[i][j] == '#')
          dist[i][j] = 0;
      }
    }

    rep(i, H) {
      repp(j, 1, W - 1) {
        chmin(dist[i][j], dist[i][j - 1] + 1);
      }
    }

    rep(i, H) {
      repr(j, W - 2, 0) {
        chmin(dist[i][j], dist[i][j + 1] + 1);
      }
    }

    repp(i, 1, H - 1) {
      rep(j, W) {
        chmin(dist[i][j], dist[i - 1][j] + 1);
      }
    }

    repr(i, H - 2, 0) {
      rep(j, W) {
        chmin(dist[i][j], dist[i + 1][j] + 1);
      }
    }
  }
  int ans = 0;
  rep(i, H) {
    rep(j, W) {
      chmax(ans, dist[i][j]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
 
#define ll                      long long int
#define i(a,n)                  int a=n
#define l(a,n)                  ll a=n
#define d(a,n)                  double a=n
#define s(a)                    string a
#define c(a)                    ll a, cin>>a
#define cd(a)                   double a, cin>>a
#define cs(a)                   string a, cin>>a
#define ci(a)                   cin>>a
#define co(a)                   cout<<a
#define cos(a)                  cout<<a<<" ";
#define con(a)                  cout<<a<<endl
#define yes                     cout<<"YES"<<endl
#define no                      cout<<"NO"<<endl
#define nl                      cout<<endl
#define ca(arr,n)               for(ll i=0;i<n;i++) cin>>arr[i]
#define f0(i,a,n)               for(ll i=a;i>=n;i--)
#define f(i,n)                  for(ll i=0;i<n;i++)
#define f1(i,a,n)               for(ll i=a;i<n;i++)
#define T                       ll t=1; cin>>t; while(t--)
#define lcm(a,b)                (a*b)/__gcd(a,b)
#define fast                    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ret(x)                  return cout<<x,0;
 
using namespace std;
 
int main()
{
    fast;
    ll x,k=1;
  	cin>>x;
  	while (k * x % 360 != 0) k++;
  	cout <<k;
    return 0;
}
 


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

int main(){
    int N; cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    ll cnt = 0;
    for(int i = 0; i < N; i++){
        while(A[i] % 2 == 0){
            A[i] /= 2;
            cnt++;
        } 
    }
    cout << cnt << endl;

}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    ll A,B,C,D,N,X[3];
    ll ans=0;
    string S;
    bool F;
int main(){
    cin>>A;
    printf("%08lf",A*2*3.14159265358979);

    return 0;
}


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

const int MOD = 1000000007;
const int INF = 1000000000;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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


int main(){
int H, N;
cin >> H >> N;
vector<int> A(N);
REP(i, N) cin >> A[i];

sort(all(A));
reverse(all(A));
int sum = 0;
REP(i, N){
  sum += A.at(i);
  if(H <= sum){
    yes;
    return 0;
  }
}

no;

}




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


int main(void)
{
	int n,x;
	int spot[100001];
	int diff[100001];
	scanf("%d %d",&n,&x);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&spot[i]);
		diff[i] = abs(x-spot[i]);
	}	
	int i=0;
	for(i=0;i<n-1;i++)
	{
		if(diff[i] < diff[i+1])
		{
			int tmp = diff[i];
			diff[i] = diff[i+1];
			diff[i+1] = tmp; 
		}

		int r = diff[i] % diff[i+1];
		while(r!=0)
		{
			diff[i] = diff[i+1];
		    diff[i+1] = r;
		    r = diff[i] % diff[i+1];
		}
	}
	printf("%d\n",diff[i]);

return 0;
}

Measured memory_bytes: 896
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

tot = 0
cnt = 0
if sum(a) < x:
    print(n - 1)
elif sum(a) == x:
    print(n)
else :
    for i in a:
        if tot + i > x:
            print(cnt)
            break
        tot += i
        cnt += 1




Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>

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

using namespace std;

template<class T, class U>
istream& operator>>(istream& is, pair<T, U>& pair)
{
    is >> pair.first >> pair.second;
    return is;
}

template<class T>
istream& operator>>(istream& is, vector<T>& collection)
{
    for(auto& item : collection) is >> item;
    return is;
}

class modint_t {
public:
    modint_t() = default;
    modint_t(int64_t value):value(value % MOD){}

    bool operator<(const modint_t rhs) const { return value < rhs.value; }
    bool operator<=(const modint_t rhs) const { return value <= rhs.value; }
    bool operator>(const modint_t rhs) const { return value > rhs.value; }
    bool operator>=(const modint_t rhs) const { return value >= rhs.value; }

    modint_t operator+(const modint_t rhs) const { return modint_t(value + rhs.value); }
    modint_t operator+=(const modint_t rhs) { return value = (value + rhs.value) % MOD; }
    modint_t operator-(const modint_t rhs) const { return modint_t(MOD + value - rhs.value); }
    modint_t operator-=(const modint_t rhs) { return value = (MOD + value - rhs.value) % MOD; }

    modint_t operator*(const modint_t rhs) const { return modint_t(value * rhs.value); }
    modint_t operator*=(const modint_t rhs) { return value = value * rhs.value % MOD; }
    modint_t operator/(const modint_t rhs) const { return *this * rhs.invert(); }
    modint_t operator/=(const modint_t rhs) { return *this *= rhs.invert(); }

    modint_t square() const { return *this * *this; }
    modint_t power(int64_t y) const
    {
        if(y == 0) return 1;
        else if(y == 1) return *this;
        else if(y % 2 == 0) return this->power(y/2).square();
        else return *this * this->power(y-1);
    }

    modint_t invert() const
    {
        return power(MOD-2);
    }

    operator int64_t() const
    {
        return value;
    }
private:
    static const int MOD = 1000000007;
    int64_t value = 0;
};

void solution()
{
    int n, k;
    cin >> n >> k;
    modint_t a = n - k + 1;
    modint_t b = 1;
    cout << a << '\n';
    for(int i = 2; i <= k; ++i){
        a *= n-k+1-(i-1);
        a /= i;
        b *= k-1-(i-2);
        b /= (i-1);
        cout << a*b << '\n';
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solution();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <cmath>

using namespace std;

int main() {

	double v;
	double max_v = -1, min_v = numeric_limits<int>::max();
	while (cin >> v) {
		max_v = max(max_v, v);
		min_v = min(min_v, v);
	}

	cout << (max_v - min_v) << endl;

	return 0;
}

Measured memory_bytes: 1284
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <numeric>
#include <regex>
#include <locale>
#include <fstream>
#include <stdlib.h>
#include <cctype>

//#include <map>

using namespace std;

int main()
{
	int n;
	int pt, ph;
	pt = ph = 0;

	vector<string> vcTa, vcHa;

	cin >> n;
	cin.ignore();

	for (int i = 0; i < n; i++)
	{
		string t1, t2;
		cin >> t1 >> t2;
		cin.ignore();
		vcTa.push_back(t1);
		vcHa.push_back(t2);
	}

	for (int i = 0; i < n; i++)
	{
		if (vcTa.at(i) == vcHa.at(i))
		{
			pt++; ph++;
		}
		else if (vcTa.at(i) > vcHa.at(i))
		{
			pt += 3;
		}
		else
		{
			ph += 3;
		}
	}

	cout << pt << " " << ph << endl;

	return 0;
}

Measured memory_bytes: 3308
#include <bits/stdc++.h>
using namespace std;
  
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
  
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
  
typedef long long int ll;
  
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn =5*100001;
ll power(ll x, ll n) {
  ll res = 1;
  for (; n > 0; n >>= 1) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
  }
  return res;
}

const ll MAX = 100000; 

int main()
{
   
  IOS
  ll a,b;
  cin>>a>>b;
  cout<<max(0LL,a-2*b);
  
}
    
  

  
  
	




Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];

using Graph=vector<vector<pint>>;

Graph G;
vector<ll> color;
void dfs(ll v,ll p,ll c){
  color[v]=c;
  for(auto nv:G[v]){
    if(nv.first==p) continue;
    if(nv.second&1) dfs(nv.first,v,1-c);
    else dfs(nv.first,v,c);
  }
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;cin>>n;
  G.assign(n,vector<pint>());
  rep(i,n-1){
    ll u,v,w;cin>>u>>v>>w;u--;v--;
    G[u].push_back(pint(v,w));
    G[v].push_back(pint(u,w));
  }
  color.assign(n,0);
  ll root=0;
  dfs(0,-1,1);
  rep(i,n) cout<<color[i]<<endl;
}

Measured memory_bytes: 10880
import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long min = (long)999999999999.0;
        for(long i=1;i<=Math.sqrt(N);i++)  if(N%i==0&&min > (i-1)+(N/i)-1) min = (i-1)+(N/i)-1;
        System.out.println(min);
    }
}

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


int main()
{
 long long X;
 cin>>X;
 
 if(X%11==0){
	 cout<<2*(X/11)<<endl;}
	 else{
		 if((X%11)<7){cout<<2*(X/11)+1<<endl;
		 }else{cout<<2*(X/11)+2<<endl;}
	 }
 
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N-1);
  int max=0;
  int maxsum=0;
  for (int i=0; i < N-1;i++){
      cin >> B.at(i);
  }
  A.at(0)=B.at(0);
  for (int i=1; i < N-1;i++){
      max=B.at(i);
      if (max >= B.at(i-1)){
        A.at(i)=B.at(i-1);
      }
      else{
         A.at(i)=max;
      }
  }
  A.at(N-1)=B.at(N-2);
  for (int i=0; i < N; i++){
      maxsum+=A.at(i);
  }
  cout << maxsum << endl;
}

Measured memory_bytes: 256
# coding: utf-8

import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
# A, B, T = map(int, input().split())
# S = input()

dp = [[0, 0] for _ in range(N)]

dp[0][0] = A[0]
dp[0][1] = -(A[0])

for i in range(N - 1):
    dp[i + 1][0] = max(dp[i][0] + A[i + 1], dp[i][1] - A[i + 1])
    dp[i + 1][1] = max(dp[i][0] - A[i + 1], dp[i][1] + A[i + 1])

print(dp[N - 1][0])


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

int main() {
	int A, B, N;
	cin >> N >> A >> B;
	if (N < A + B - 1 || (ll)A * B < N) {
		puts("-1");
		return 0;
	}
	vi ans;
	int now = N;
	rep(i, B) {
		int c = max(B-i-1, now - A);
		for (int k = c; k < now; ++k) {
			ans.pb(k);
		}
		now = c;
	}
	rep(i, N) {
		printf("%d%c", ans[i] + 1, i == N-1 ? '\n' : ' ');
	}
	return 0;
}

Measured memory_bytes: 3440
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll mod = 1000000007;
static const ll INF = 1000000000000000000LL;
                    //999999997000000003
                    //1000000000000000000

using namespace std;

int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    ll res;
    if(A > B)res = 0;
    else if(N == 1 && A!= B)res = 0;
    else if(N == 2)
    {
        res = 1;
    }
    else
    {
        ll iMin,iMax;
        iMin = (N-1) * A + B;
        iMax = A + (N-1) * B;

        res = iMax - iMin + 1;
    }

    //999999997000000003
    

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define ll long long
#define ld long double

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)

#define pii pair<int, int>
#define pll pair<ll, ll>

#define fi first
#define se second

#define pb push_back
#define eb emplace_back

#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(), a.end()

#define endl '\n'
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
const int MOD=1e9+7;
const ll INF=1e18;
const double PI=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
int ddx[5] = {2,1,0,-1,-2};
int ddy[5] = {2,1,0,-1,-2};
 
const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int n;
  cin >> n;
  vector<vector<int>> G(n);
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].pb(b);
    G[b].pb(a);
  }
  int d1[n],d2[n];
  rep(i,n){
    d1[i]=MOD;
    d2[i]=MOD;
  }
  queue<int>que;
  que.push(0);
  d1[0]=0;
  while(!que.empty()){
    int v = que.front();
    que.pop();
    for(auto nv:G[v]){
      if(d1[nv]>d1[v]+1){
        d1[nv]=d1[v]+1;
        que.push(nv);
      }
    }
  }
  que.push(n-1);
  d2[n-1]=0;
  while(!que.empty()){
    int v = que.front();
    que.pop();
    for(auto nv:G[v]){
      if(d2[nv]>d2[v]+1){
        d2[nv]=d2[v]+1;
        que.push(nv);
      }
    }
  }
  int fennec=0,snuke=0;
  rep(i,n){
    if(d1[i]<=d2[i])fennec++;
    else snuke++;
  }

  if(fennec>snuke) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
  return 0;
}


Measured memory_bytes: 9532
N, M = map(int, input().split())

C = [0] * 100001
C[1] = 1
C[2] = 2

for i in range(3, 100001, 1):
    C[i] = C[i-1] + C[i-2]

start = 0

result = 1

for i in range(M):
    a = int(input())
    next = a - 1
    if next == start:
        start = a + 1
        continue
    if next < start:
        print(0)
        exit(0)
    range = a - 1 - start
    pattern = C[range]
    result *= pattern
    start = a + 1

if start < N:
    range = N - start
    pattern = C[range]
    result *= pattern

print(result % 1000000007)


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

int main(){
  int N;
  cin >> N;
  vector<string> vec1(N);
  for(int i=0; i<N; i++){
    cin >> vec1.at(i);
  }
  int M;
  cin >> M;
  vector<string> vec2(M);
  for(int j=0; j<M; j++){
    cin >> vec2.at(j);
  }
  
  int ans_cout = 0;
  
  for(int k=0; k<N; k++){
    int ans = 0;
    for(int l=0; l<N; l++){
      if(vec1.at(k) == vec1.at(l)){
        ans++;
      }
    }
    for(int m=0; m<M; m++){
      if(vec1.at(k) == vec2.at(m)){
        ans--;
      }
    }
    ans_cout = max(ans,ans_cout);
  }
  
  cout << ans_cout << endl;
  
}

Measured memory_bytes: 256
n,k = map(int,input().split())

ans = [[0]*k for i in range(n)]
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in a:
        ans[j-1][i] = 1

ass = 0
for i in range(n):
    if sum(ans[i]) == 0:
        ass += 1
        
print(ass)

Measured memory_bytes: 67960
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mod2 1000000000
#define mod1 998244353
#define lol ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define F(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define ss second
int main()
{
    ll x;cin >> x;
    ll y;cin >> y;
    if((y-2*x)%2 == 0 && (4*x-y)%2==0 && y>=2*x && 4*x>=y)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define MAXS 5007
#define INF 1234567890

#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define BZ freopen("input.txt", "r", stdin)
#define BX freopen("out.txt", "w", stdout)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main(){
  int n, m;
  cin >> n >> m;
  cout << (n <= 8 && m <= 8 ? "Yay!" : ":(");
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e1 + 10;
int dx[] = { 0,0,-1,1 };
int dy[] = { -1,1,0,0 };
char str[N][N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		cin >> str[i] + 1;
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (str[i][j] == '.') continue;
			int cnt = 0;
			for (int o = 0; o < 4; o++)
			{
				cnt += str[i + dx[o]][j + dy[o]] == '#';
			}
			if (cnt == 0) 
				puts("No"), exit(0);
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int func(int x){
  if(x<10) return x;
  return x%10+func(x/10);
}
 
int main(){
  int N;
  cin >> N;
  int S=func(N);
  if(N%S==0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String x[] = new String[2];
    int i = 0;
    while(i < 2){
      x[i] = sc.next();
      i++;
    }
    int num[] = new int[2];
    for(i = 0;i<2;i++){
      if(x[i].equals("A")){
        num[i] = 10;
      }else if(x[i].equals("B")){
        num[i] = 11;
      }else if(x[i].equals("C")){
        num[i] = 12;
      }else if(x[i].equals("D")){
        num[i] = 13;
      }else if(x[i].equals("E")){
        num[i] = 14;
      }else if(x[i].equals("F")){
        num[i] = 15;
      }
    }
    if(num[0] < num[1]){
      System.out.println("<");
    }else if(num[0] == num[1]){
      System.out.println("=");
    }else{
      System.out.println(">");
    }

  }
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int n,q;
vector<vector<int>> tree(200000, vector<int>());

int main() {
    int n;
    cin >> n;
    cout << "ABC" << n << endl;
}


Measured memory_bytes: 4992
S = input()
T = input()

index = []
ss = []
flag = False

for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if S[i+j] != T[j] and S[i+j] != '?':
            break
        if j == len(T) - 1:
            flag = True
            index.append(i)

if flag:
    for v in index:
        s = ''
        k = 0
        for i in range(len(S)):
            if v <= i <= v + len(T) - 1:
                s += T[k]
                k += 1
                continue
            if S[i] == '?':
                s += 'a'
            else:
                s += S[i]
        ss.append(s)
    ss.sort()
    s = ss[0]
else:
    s = 'UNRESTORABLE'

print(s)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,A,B; cin >> N >> A >> B;
    if(abs(A-B)%2==0){
        cout << abs(A-B)/2 << endl;
    } else {
        cout << min({max(A-1,B-1),max(N-A,N-B),min({A-1,B-1,N-A,N-B})+1+abs(A-B)/2}) << endl;
    }
}


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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int main(){
	int a,b;cin>>a>>b;b--;
	a--;
	cout<<(b+a-1)/a<<endl;
}

Measured memory_bytes: 256
n = int(input())
A = tuple(map(int, input().split()))
ans = 1
if 0 in A:
    print(0)
else:
    for a in A:
        ans *= a
        if ans > 10**18:
            break

    if ans > 10**18:
        print('-1')
    else:
        print(ans)

Measured memory_bytes: 21980
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <string>
#include <climits>
#include <iomanip>
#include <utility>

#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define PRINT(STR) cout << (STR) << endl
#define DEBUG(X) cerr << X << " (" << __LINE__ << ", " << __func__ << " )" << endl;

typedef long long ll;
using namespace std;

int main() {
	cin.tie(0); //?????±?????????????????????
	ios::sync_with_stdio(false); //printf??¨??±??????????????????

	double x1, y1, x2, y2, x3, y3, xp, yp;
	while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF) {
		double tx1 = x2 - x1;
		double tx2 = x3 - x1;
		double ty1 = y2 - y1;
		double ty2 = y3 - y1;
		
		double S1 = fabs((tx1 * ty2) - (tx2 * ty1));
		x1 -= xp;	x2 -= xp;	x3 -= xp;
		y1 -= yp;	y2 -= yp;	y3 -= yp;
		double S2 = fabs((x1 * y2) - (x2 * y1)) + fabs((x2 * y3) - (x3 * y2)) + fabs((x3 * y1) - (x1 * y3));
		if (S1 < S2) {
			PRINT("NO");
		} else {
			PRINT("YES");
		}
	}

	return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

int main() {
    int n; cin >> n;
    V<int> A(n);
    loop (n, i) cin >> A[i];

    V<int> ans(n);
    loop (n, i) {
        int j = n - i;
        ans[j - 1] = A[j - 1];
        for (int k = j * 2; k <= n; k += j) {
            ans[j - 1] ^= ans[k - 1];
        }
    }

    int os = 0;
    V<int> ot;
    loop (n, i) {
        if (ans[i]) {
            os++;
            ot.push_back(i + 1);
        }
    }

    cout << os << endl;
    if (os) {
        cout << ot[0];
        loop (os - 1, i) {
            cout << " " << ot[i + 1];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll a,b,k;cin>>a>>b>>k;
    if(a-k<0){
        b-=k-a;
        a=0;
        if(b<0){
            b=0;
        }
    }
    else{
        a-=k;
    }
    cout<<a<<" "<<b<<endl;
}

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

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

using namespace std;

typedef long long ll;

int N;
vector<vector<int>> dp;
vector<int> w = vector<int>(12, 1);

void init()
{
  REP(i, 6)
  {
    REP(j, i + 1)
    {
      w[i + 1] *= 6;
    }
  }
  REP(i, 5)
  {
    REP(j, i + 1)
    {
      w[i + 7] *= 9;
    }
  }

  sort(ALL(w), greater<int>());
}

int main()
{
  cin >> N;
  dp = vector<vector<int>>(N + 1, vector<int>(12, 1e9));
  init();

  REP(i, 12)
  {
    dp[N][i] = 0;
  }

  REP(i, 12)
  {
    for (int h = N; h >= 0; h--)
    {
      if (dp[h][i] != 1e9)
      {
        if (h - w[i] >= 0)
        {
          for (int j = i; j < 12; j++)
          {
            dp[h - w[i]][j] = min(dp[h][j] + 1, dp[h - w[i]][j]);
          }
        }
      }
    }
  }

  cout << dp[0][11] << endl;
  return 0;
}

Measured memory_bytes: 8832
#include<cstdio>
#include<vector>
using namespace std;
const int N=330,P=1000000007;
int i,j,k,n,m,l,r,x,L,R,ans;
int f[2][N][N];
vector<int> A[4][N];
bool check(int x,int y,int z) {
	int i,j,k;
	for (i=1;i<=3;i++) {
		for (j=0;j<A[i][x].size();j++) {
			k=0;
			if (A[i][x][j]<=z) k++;
			if (A[i][x][j]<=y) k++;
			if (A[i][x][j]<=x) k++;
			if (k!=i) return 0;
		}
	}
	return 1;
}
int main() {
	scanf("%d%d",&n,&m);
	for (i=1;i<=m;i++) {
		scanf("%d%d%d",&l,&r,&x);
		A[x][r].push_back(l);
	}
	L=0;R=1;f[R][0][0]=1;
	for (i=1;i<n;i++) {
		L^=1;R^=1;
		for (j=0;j<i;j++)
			for (k=0;k<=j;k++) if (f[L][j][k]) {
				int t=f[L][j][k];
				f[L][j][k]=0;
				if (!check(i,j,k)) continue;
				f[R][j][k]=(f[R][j][k]+t)%P;
				f[R][i][k]=(f[R][i][k]+t)%P;
				f[R][i][j]=(f[R][i][j]+t)%P;
			}
	}
	for (j=0;j<n;j++)
		for (k=0;k<=j;k++) if (f[R][j][k] && check(n,j,k)) ans=(3ll*f[R][j][k]+ans)%P;
	printf("%d\n",ans);
}

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

int main() {
  int A, B, T;
  cin >> A >> B >> T;
  int ans = T / A * B;
  cout << ans << endl;
  return 0;
}

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

#初めてBより大きくなるaの枚数をカウント
a = (B + A -1) //A

#その値は A * a
ans = A * a

# この時貧浴で支払う
b = ans//B
ans -= B * b
b += ans//A
ans -= A * (ans //A)
b += ans%A

if b >= a:
    print (A * a)
else:
    print (-1)


Measured memory_bytes: 5596
#include <iostream>
#include <fstream>
#include <vector>

short a,b;

int main(){
    
    std::cin >> a >> b;
    std::vector<bool>v(4,false);
    
    v[a] = true;
    v[b] = true;
    
    for(int i = 1;i <= 3;++i)
        if(v[i] == false){
            std::cout << i;
            break;
        }
    
    return 0;
}


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


int gcd(int a, int b){
  while(min(a,b)>0){
    if (a<b) swap(a,b);
    a = a % b;
  }
  return max(a,b);
}

int main(){
 int n,x;
  cin >> n>> x;
  vector<int> v(n);
  rep(i,n){
    int s;
    cin >> s;
    v[i] = abs(s-x);
  } 
  int ans=v[0]; 
  rep(i,n-1){
    ans = gcd(ans,v[i+1]);
  }
  cout << ans <<endl;
  return 0; 
}


Measured memory_bytes: 640
/*
	written by Pankaj Kumar.
	country:-INDIA
*/
#include<algorithm>
#include<string.h>
#include<iostream>
#include<vector>
#include<cmath>
#include<set>
using namespace std;
typedef long long ll ;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vpl;
typedef vector<string> vs;
typedef set<string> ss;
typedef set<int> si;
typedef set<ll> sl;
typedef set<pair<int,int>> spi;
typedef set<pair<ll,ll>> spl;
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
// define values.
#define mod 1000000007;
#define phi 1.618
/* Bit-Stuff */
#define get_set_bits(a) (__builtin_popcount(a))
#define get_set_bitsll(a) ( __builtin_popcountll(a))
#define get_trail_zero(a) (__builtin_ctz(a))
#define get_lead_zero(a) (__builtin_clz(a))
#define get_parity(a) (__builtin_parity(a))
/*  Abbrevations  */
#define ff first;
#define second ss;
#define mk make_pair;
#define line cout<<endl;
#define pb push_back
#define INT_SIZE sizeof(int)
#define INT_BITS INT_SIZE*8-1
/* ascii value 
A=65,Z=90,a=97,z=122
*/
/*  -----------------------------------------------------------------------------------*/


int main()
{
	pan;
	ll n,m,sum=0,no;
	cin>>n>>m;
	for(ll i=0;i<m;i++)
	{
		cin>>no;
		sum+=no;
	}
	if(sum>n)
		cout<<-1<<endl;
	else
		cout<<n-sum<<endl;
}

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

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

  if (N >= 400 && N < 600){
    cout << 8 << endl;
  }
  else if (N >= 600 && N < 800)
  {
    cout << 7 << endl;
  }
  else if (N >= 800 && N < 1000)
  {
    cout << 6 << endl;
  }
  else if (N >= 1000 && N < 1200)
  {
    cout << 5 << endl;
  }
  else if (N >= 1200 && N < 1400)
  {
    cout << 4 << endl;
  }
  else if (N >= 1400 && N < 1600)
  {
    cout << 3 << endl;
  }
  else if (N >= 1600 && N < 1800)
  {
    cout << 2 << endl;
  }
  else if (N >= 1800 && N < 2000)
  {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3632
#include<stdio.h>
 
#define MAX 101
 
int main(){
  int n,i,u,k,j,v;
  int Adj[MAX][MAX];
 
  for(i=0;i<MAX;i++){
    for(j=0;j<MAX;j++){ 
      Adj[i][j]=0;
    }
  }
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      Adj[u][v]=1;
    }
  }
 
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      printf("%d",Adj[i][j]);
      if(j!=n) printf(" ");
    }
    printf("\n");
  }
 
  return 0;
}

Measured memory_bytes: 644
import sys
#Read the input N
n = int(sys.stdin.readline())
#Read the height line
a = sys.stdin.readline().split()

#Convert into int List
h = []
for i in range(0, n):
    h.append(int(a[i]))

dp = [0] * n
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in xrange(2, n):
    dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), 
               dp[i-2] + abs(h[i-2] - h[i]))
print(dp[n-1])

Measured memory_bytes: 14368
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}

#define ll long long
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=1e6+500;
const ll mod=1e9+7;

ll zarb(long long a,long long b){return (a*b)%mod;}
ll jam(long long a,long long b){return (a+b)%mod;}
ll fac[maxn];
ll rfac[maxn];

ll poww(ll a,ll b){
	ll ans=1;
	while(b){
		if(b&1){
			ans=zarb(ans,a);
		}
		a=zarb(a,a);
		b>>=1;
	}
	return ans;
}
ll ent(ll n,ll k){
	if(k>n || k<0)return 0;
	return zarb(fac[n],zarb(rfac[k],rfac[n-k]));
}
ll juy(ll n,ll k){
	if(k>n || k<0)return 0;
	return zarb(fac[n],rfac[n-k]);
}	

ll a[maxn];
ll b[maxn];
ll n,m;

ll findAns(ll x,ll y,ll c){
	ll ax=a[x]-c;
	ll by=b[y]-c;
	ll tolx=n-x;
	ll toly=m-y;
	ll s=tolx*toly;
	if(s==0)return 1;
	if(ax==by){
		return  zarb(findAns(x+1,y+1,c+tolx+toly-1),juy(ax-1,tolx+toly-2));
	}
	if(ax<by){
		return  zarb(zarb(findAns(x+1,y,c+toly),juy(ax-1,toly-1)),toly);
	}
	if(ax>by){
		return  zarb(zarb(findAns(x,y+1,c+tolx),juy(by-1,tolx-1)),tolx);
	}
}
int main(){
	fac[0]=1;
	for(ll i=1;i<maxn;i++){
		fac[i]=zarb(fac[i-1],i);
	}
	for(ll i=0;i<maxn;i++){
		rfac[i]=poww(fac[i],mod-2);
	}

	cin>>n>>m;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	for(ll i=0;i<m;i++){
		cin>>b[i];
	}
	sort(a,a+n);
	sort(b,b+m);
	for(ll i=0;i+1<n;i++){
		if(a[i]==a[i+1]){
			cout<<0;
			return 0;
		}
	}
	for(ll i=0;i+1<m;i++){
		if(b[i]==b[i+1]){
			cout<<0;
			return 0;
		}
	}

	cout<<findAns(0,0,0);
}




















Measured memory_bytes: 19328
#include<stdio.h>
int main(){
  int m,f,r,b=0,i,c;
  char a,e[999]={0};
  while(1){
    scanf("%d %d %d",&m,&f,&r);
    c=m+f;
    if(m==-1&&f==-1&&r==-1){
      break;
    }
    if(m==-1||f==-1){
      a='F';
    }
    else{
      if(c>=80){
    a='A';
      }
      else if(c>=65){
    a='B';
      }
      else if(c>=50){
    a='C';
      }
      else if(c>=30&&r>=50){
    a='C';
      }
      else if(c>=30&&r<50){
    a='D';
      }
      else if(c<30){
    a='F';
      }
    }
    e[b]=a;
    b++;
  }
  for(i=0;i<b;i++){
    printf("%c\n",e[i]);
  }
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

namespace
{
	struct modint
	{
		static constexpr ll MOD = 1000000007;
		ll x_;
		modint(ll x) : x_(x % MOD) {}
		modint& operator+=(const modint& src)
		{
			if ((x_ += src.x_) >= MOD)
				x_ -= MOD;
			return *this;
		}
		modint& operator-=(const modint& src)
		{
			if ((x_ += MOD - src.x_) >= MOD)
				x_ -= MOD;
			return *this;
		}
		modint& operator*=(const modint& src)
		{
			(x_ *= src.x_) %= MOD;
			return *this;
		}

		modint& operator/=(const modint& src)
		{
			return (*this) *= src.inv();
		}
		modint inv() const
		{
			return pow(MOD - 2);
		}
		modint pow(ll t) const
		{
			if (t == 0)
				return 1;
			modint a = pow(t >> 1);
			a *= a;
			if (t & 1)
				a *= *this;
			return a;
		}
	};

	void dfs2(modint& ct, int K, int v, const vector<set<int> >& graph, int p = -1)
	{
		for (int u : graph[v])
		{
			if (u == p)
				continue;
			dfs2(ct, K, u, graph, v);
		}
		int nC = static_cast<int>(graph[v].size()) - (p==-1 ? 0 : 1);
		int x = p == -1 ? 1 : 2;
		for (int i = 0; i < nC; ++i, ++p)
		{
			ct *= K - x - i;
		}
	}
}

void ABC133E()
{
	int N, K;
	cin >> N >> K;
	vector<set<int> > graph(N);
	for (int i = 0; i < N - 1; ++i)
	{
		int a, b;
		cin >> a >> b;
		graph[a - 1].insert(b - 1);
		graph[b - 1].insert(a - 1);
	}

	modint ct = K;
	dfs2(ct, K, 0, graph);

	cout << ct.x_ << endl;
}
int main()
{
	ABC133E();
	return 0;
}

Measured memory_bytes: 20224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,d,x,y,ans=0;cin>>n>>d;
  rep(i,n) {
    cin>>x>>y;
    if(x*x+y*y<=d*d) ans++;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 100100100
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

 
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<int, int> mp;
    set<int> s;
    rep(i,n){
        mp[a[i]]++;
        s.insert(a[i]);
    }
    vector<pair<int, int>> b;
    
    for(auto i : mp){
        int x = i.second, y = i.first;
        b.push_back(make_pair(x, y));
        
    }
    sort(b.begin(), b.end());
    
    
    
     
    int ans = 0;
    int t = s.size(); //整数の種類の総数
    for(auto i : b){
        if(t <= k){
            cout << ans << endl;
            return 0;
        }
        t--;
        ans += i.first;
    }
    

}


Measured memory_bytes: 22008
#include<iostream>
#include<string>
#include <cmath>
#include<vector>
#include<algorithm>
 
using namespace std;

#define ll long long
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)





int main()
{
    vector<ll> a,b,c;
    ll N;
    cin >> N;
    ll tmp;
    REP(i, N)
    {
        cin >> tmp;
        a.push_back(tmp);
    }
    REP(i, N)
    {
        cin >> tmp;
        b.push_back(tmp);
    }
    REP(i, N)
    {
        cin >> tmp;
        c.push_back(tmp);
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    
    ll cnt = 0;

    ll A, C;
    REP(j, N)
    {
        A = lower_bound(a.begin(), a.end(), b[j]) - a.begin();
        C = c.end() - upper_bound(c.begin(), c.end(), b[j]);
        cnt += A*C;
    }

    cout << cnt << endl;

}

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin >> S; int N = (int) S.size();
  string T = "";
  
  for(int i = 0; i < N; ){
    if( i != N-1 && S[i] == 'B' && S[i+1] == 'C'){
      T.push_back('X'); i+= 2;}
    else{
      T.push_back(S[i]); i++;}
    
  }
 
  
  int M =(int) T.size(); int head = 0; int tail = 0; int cnt = 0;
  
  vector<string> vec(M);
  while( head < M){
    if( T[head] == 'B' || T[head] == 'C'){ head++; tail++; continue;}
    while( tail < M && T[tail] == 'A' || T[tail] == 'X'){
      tail++;}
    vec[cnt] = T.substr(head, tail-head);
   head = tail; cnt++;
   }
  long long ans = 0;
  for(int i = 0; i < M; i++){
    if( !vec.empty()){ 
      int m = (int) vec[i].size(); 
      int res = 0;
      for(int j = m - 1; j >= 0; j--){
        if(vec[i][j] == 'X'){ res++;}
        else if( vec[i][j] == 'A'){ ans += res;}
      }
    
    }}
  
  cout << ans << endl;
  
  return 0;}
      
    
      

Measured memory_bytes: 4360
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let S = get!(String);
    let w = get!(usize);

    let T = S.chars().collect::<Vec<_>>();
    for i in 0..((T.len() + w - 1) / w) {
        print!("{}", T[i * w]);
    }
    println!("");
}

Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long MOD = 1000000007;

        public void Run()
        {
            var X = new List<int>();
            for (int i = 0; i < 5; i++)
            {
                var x = Input.ReadInt();
                X.Add(x);
            }

            int K = Input.ReadInt();

            Console.WriteLine(X[4] - X[0] <= K ? "Yay!" : ":(");

        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

string toUpper( string s ){
 string t = s;
    for ( int i = 0; i < s.size(); i++ ){
      t[i] = toupper(s[i]);
    }
    return t;
}

int main(){
     string target, source;
    
    cin >> target;
    target = toUpper(target);
    
    int cnt = 0;
    
    while(1){
      cin >> source;
      if( source == "END_OF_TEXT" ) break;
      source = toUpper(source);
      if( target == source ) cnt++;
    }
    
    cout << cnt << endl;
    
    
 return 0;
}    

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define int long long int 
#define fi first
#define se second
#define FIO {ios::sycnt2_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pow10(n) stoll("1"+string(n,'0'))
//fill(all(arr),1)
//if(map.count(key)){}
//bitset<20>(n);
//int mini=min({a,b,c,d,e});
#define int long long int
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;
int32_t main()
{
string s;
cin>>s;
int maxi=0;
int cnt=0;
if(s=="RRR"){cout<<3;return 0;}
for(int i=0;i<s.size();i++)
{
if(s[i]=='R')
{
  cnt++;
}
else
{
  maxi=max(maxi,cnt);
  cnt=0;
}
}
cout<<max(maxi,cnt);

}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

int main()
{
	int n;
	while (cin >> n, n){
		priority_queue<P, vector<P>, greater<P> > pq;
		while (n--){
			int a, b;
			cin >> a >> b;
			pq.push(P(b, a));
		}
		
		bool res = true;
		int sum = 0;
		for (; pq.size(); pq.pop()){
			P p = pq.top();
			sum += p.second;
			if (sum > p.first){
				res = false;
				break;
			}
		}
		
		if (res) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1196