akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

#define _ { \
	ios_base::sync_with_stdio(false); \
    cin.tie(NULL); \
}

int main(){
   _;
   ll a,b,c;cin>>a>>b>>c;
   ll wow=(a-c)*(a-c)+b*b-2*b*c-2*a*b;
   if(wow>0&&c>a+b)cout<<"Yes";
   else cout<<"No";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
#define int long long
#define rep(i,a,n) for (int (i)=(a);(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef long double ld;
signed  main() {
	/*int n, sum = 0, ans = 0;
	string s;
	cin >> s;
	n = s.size();
	for (int i = 0; i < floor(n / 2.0); i++) {
		if (s[i] == s[n - i - 1])
			sum++;
	}
	for (int i = 0; i < n; i++) {
		if (n % 2 == 1 && i == ceil(n / 2.0)-1)
			continue;
		for (int j = 0; j < 26; j++) {
			if ((int)s[i] - 'A' != j) {
				if (i > floor(n / 2.0) && ((char)j + 'A' != s[i - (floor(n / 2.0))] || (char)j + 'A' == s[i - (floor(n / 2.0))-1] && sum + 1 != (sum - sum % 2) / 2)) {
					if (sum == 0 || s[i] == s[n - i - 1])
						ans++;
				}
				else if (i < floor(n / 2.0) && ((char)j + 'A' != s[i - (floor(n / 2.0))] || (char)j + 'A' == s[n-i-1] && sum + 1 != (sum - sum % 2) / 2)) {
					if (sum == 0 || s[i] == s[n - i - 1])
						ans++;
				}
			}
		}
	}
	if (n % 2 == 1 && sum == 0)
		ans += 25;
	if (n == 1)
		ans = 0;
	cout << ans << endl;*/
	int h, w;
	cin >> h >> w;
	string s;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> s;
			if (s == "snuke") {
				cout << (char)(j + 'A') << i + 1 << endl;
			}
		}
	}
	getchar(); getchar();
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[100007];
int get[128];
int main(){
	get['p'-'a']=1,get['d'-'a']=2,get['q'-'a']=3;
	scanf("%s",s+1);
	for(int i=1,l=strlen(s+1);i<=(l>>1)+1;++i)
		if(get[s[i]-'a']^(get[s[l-i+1]-'a']+2)%4)return puts("No"),0;
	return puts("Yes"),0;
}

Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<int, int>
const ll  MOD = 1000000007;

int main() {
	ll n, x;
	cin >> n >> x;
	vector<ll> l(n);

	rep(i, n) cin >> l.at(i);
	ll d = 0, ans = 1;
	rep(i, n) {
		d += l.at(i);
		if (d <= x) {
			ans++;
		}
		else break;
	}
	cout << ans;
	return 0;
}

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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);

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

    vector<int> dp(n+1);
    for(int i=0; i<n+1; i++) {
        dp[i] = i;
    }
    vector<int> aug;
    for(int w=6; w<=n; w*=6) {
        aug.push_back(w);
    }
    for(int w=9; w<=n; w*=9) {
        aug.push_back(w);
    }
    vector<int> _aug(aug.begin(), aug.end());
    reverse(_aug.begin(), _aug.end());

    // dpの入れ子は試行回数を表す
    for(int i=0; i<n+1; i++) {
        int a = dp[i];
        for(int j=0; j<_aug.size(); j++) {
            int w = _aug[j];
            if(i+w > n) continue;
            // i+w がnよりも小さい w(6^n or 9^n)が採用される余地がある場合
            // dp[i+w]のカウントとしてはdp[i]+1とdp[i+w]の小さい方に置き換える
            dp[i+w] = min(dp[i+w], a+1);
        }
    }

    cout << dp[n];

    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}
//int sum_digits(int num) {
//    int rtn = 0;
//    string num_str = to_string(num);
//    for(int i=0; i<num_str.size(); i++) {
//        rtn += num_str[i] - '0';
//    }   
//    return rtn;
//}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}



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

int main(){
   int c[10][10];
   int H,W,A,res=0;
   cin>>H>>W;
   for(int i=0;i<10;i++){
       for(int j=0;j<10;j++) cin>>c[i][j];
   }
   for(int k=0;k<10;k++){
       for(int i=0;i<10;i++){
           for(int j=0;j<10;j++){
               c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
           }
       }
   }
   for(int i=0;i<H;i++){
       for(int j=0;j<W;j++){
           cin>>A;
           if(A>=0) res+=c[A][1];
       }
   }
   cout<<res<<endl;
}


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


long long int  knapSack(long long int W,long long int wt[], long long int val[], long long int n) 
{ 
long long int i, w; 
long long int K[n+1][W+1]; 


for (i = 0; i <= n; i++) 
{ 
	for (w = 0; w <= W; w++) 
	{ 
		if (i==0 || w==0) 
			K[i][w] = 0; 
		else if (wt[i-1] <= w) 
				K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]], K[i-1][w]); 
		else
				K[i][w] = K[i-1][w]; 
	} 
} 

return K[n][W]; 
} 

int main() 
{ 
long long 	int val[100000]; 
long long 	int wt[100000]; 
long long 	int W;
long long 	int n;
	cin>>n>>W;
	for(int i = 0;i<n;i++)
	{
	    cin>>wt[i]>>val[i];
	}
cout<<knapSack(W, wt, val, n); 
	return 0; 
} 


Measured memory_bytes: 79104
#include <stdio.h>

int main(){
        int S;
        scanf("%d", &S);
        if(0==S)      printf("0\n");
        if(1==S)      printf("1\n");
        if(10==S)      printf("1\n");
        if(11==S)      printf("2\n");
        if(100==S)      printf("1\n");
        if(101==S)      printf("2\n");
        if(110==S)      printf("2\n");
        if(111==S)      printf("3\n");
        return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <queue>
#define ri register int 
#define ll long long 
#define ull unsigned long long 
using std::min;
using std::max;
using std::lower_bound;
using namespace __gnu_pbds;
template <class T>inline void read(T &x){
    x=0;int ne=0;char c;
    while(!isdigit(c=getchar()))ne=c=='-';
    x=c-48;
    while(isdigit(c=getchar()))x=(x<<3)+(x<<1)+c-48;
    x=ne?-x:x;return ;
}
const int maxn=200005;
const int inf=0x7fffffff;
int n,nn,a[maxn],b[maxn],c[maxn],mx=-inf,mi=inf;
ll sum[maxn<<2];
inline void update(int x,int d){for(;x<=nn;x+=x&(-x))sum[x]+=d;}
inline ll query(int x){ll ans=0;for(;x;x-=x&(-x))ans+=sum[x];return ans;}
inline ll chk(int k){
    ll ans=0;
    b[0]=0;
    for(ri i=1;i<=n;i++){
        b[i]=b[i-1]+((a[i]<=k)?1:-1);
        c[i]=b[i];
        ans+=(b[i]>0);
    }
    std::sort(c+1,c+1+n);
    nn=std::unique(c+1,c+1+n)-(c+1);
    memset(sum,0,sizeof(sum));
    for(ri i=1;i<=n;i++){
    	b[i]=lower_bound(c+1,c+1+nn,b[i])-c;
        ans+=query(b[i]-1);
        update(b[i],1);
    }
    return ans;
}
int main(){
    read(n);
    for(ri i=1;i<=n;i++){
        read(a[i]);
        mi=min(mi,a[i]),mx=max(mx,a[i]);
    }
    int L=mi,R=mx,mid,ans;
	ll lim=1ll*n*(n+1)/4+1;
    while(L<=R){
        mid=(L+R)>>1;
        if(chk(mid)>=lim)ans=mid,R=mid-1;
        else L=mid+1;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 8448
#include<stdio.h>
int main(){
  int n,i,max=0,min=0,ans1[100],ans2[100],count=0;
  long int a[50];
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
    if(a[max]<a[i])max=i;
    if(a[min]>a[i])min=i;
  }
  if(abs(a[min])<=abs(a[max])){
    for(i=1;i<n;i++){
      while(a[i-1]>a[i]){
        a[i]+=a[max];
        ans1[count]=max+1;
        ans2[count]=i+1;
        count++;
      }
      if(a[max]<=a[i])
        max=i;
    }
  }
  else {
    for(i=n-2;i>=0;i--){
      while(a[i+1]<a[i]){
        a[i]+=a[min];
        ans1[count]=min+1;
        ans2[count]=i+1;
        count++;
      }
      if(a[min]>=a[i])
        min=i;
    }
  }
  printf("%d\n",count);
  for(i=0;i<count;i++) printf("%d %d\n",ans1[i],ans2[i]);
  return 0;
}


Measured memory_bytes: 128
from itertools import product
from math import ceil

d ,g = map(int, input().split())
problem = [0]*d
bonus = [0]*d
compscore = [0]*d
for i in range(d):
    problem[i], bonus[i] = map(int, input().split())
    compscore[i] = 100*(i+1)*problem[i] + bonus[i]
ans = 1001

#product(range(2), repeat=d)の元は、d次元の元であって
#各成分が0or1となるもの(全部で2^d通り）
for c in product(range(2), repeat=d):
    score = 0
    solved = 0
    max_of_notcomp = -1

    for i in range(d):
        if c[i] == 1:
            score += compscore[i]
            solved += problem[i]
        else:
            max_of_notcomp = i
    
    if score < g and score + 100*(max_of_notcomp+1)*(problem[max_of_notcomp]-1) >= g:
        solved += ceil((g - score)/(100*(max_of_notcomp+1)))
        score += ceil((g - score)/(100*(max_of_notcomp+1)))*100*(max_of_notcomp+1)

    if score >= g:
        ans = min(ans, solved)
print(ans)



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

int main() {
  int n, k, x, ans = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x >= k) ans++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
X, N = gets.split.map(&:to_i)
result = []
if N == 0
  print X
else
  n_ary = gets.split.map(&:to_i)
  ary = []
  (-100..300).each do |i|
    ary.push i
  end
  n_ary.each do |j|
    ary.delete(j)
  end
  result.push ary.min_by{|x| (x-X).abs}
  puts result.min
end

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

#define ll long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

int main(){
	fastio
	string s1, s2;
	cin >> s1 >> s2;
	int ans = 0;
	for(int i = 0;i < s1.size();i++){
		if(s1[i]!=s2[i]) ans++;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3772
n,m = map(int,input().split())
ac_list = [0 for i in range(n+1)]
wa_list = [0 for i in range(n+1)]
p_list = []
ac = 0
pena = 0

for i in range(m):
    p,s = map(str,input().split())
    p = int(p)
    if s == 'AC' and ac_list[p-1] != 1:
        ac += 1
        ac_list[p-1] = 1
        pena += wa_list[p-1]
    elif s == 'WA' and ac_list[p-1] != 1:
        wa_list[p-1] += 1

print(ac, pena)


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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,y;
cin>>n>>y;
rep(i,n+1){
    rep(j,n+1){
        int k=n-(i+j);
        if(i*10000+j*5000+k*1000==y && k>=0){
            cout<<i<<" "<<j<<" "<<k<<endl;
           // system("pause");
            return 0;
        }
    }
}
cout<<"-1 -1 -1"<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;
 
ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
 
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
 
ll choose2(ll n){
    return n*(n-1)/2;
}
 
int main() {
    int n;
    cin>>n;
    cout<<n / 3 <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

	int antena[5];
	int k;
	int i;
	int count = 0;

	for (i = 0; i < 5; i++) scanf("%d", &antena[i]);
	scanf("%d", &k);

	for (i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			if (antena[j] - antena[i] > k)	count++;
		}
	}

	if (count)	printf(":(\n");
	else printf("Yay!\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    ll N;
    cin >> N;
    vector<pair<long long, long long>> res = prime_factorize(N);
    ll ans = 0;
    for(auto p : res) {
        ll ex = p.second;
        ll z = p.first;
        ll cnt = 1;
        while(1) {
            if(ex >= cnt) {
                ans++;
                ex -= cnt;
                cnt++;
            } else break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define mod 998244353 
int32_t main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int dp[n+1];dp[0]=0;dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
        //cout<<dp[i]<<" ";
    }
    cout<<dp[n-1];

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#define local
#ifdef local
    #include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
    #include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define pi std::pair<int, int>
#define stdabs std::abs
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=
#define npm next_permutation
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll& x, ll& y);
ll nCr(ll n, ll r);
void stat();
template <typename T> T fact(T num);
constexpr ll mod = 1000000000 + 7;
int main()
{
    stat();
    int n;
    cin >> n;

    vec<int> pp(n), q(n), N(n);
    rep(i, n) { cin >> pp[i]; }
    rep(i, n) { cin >> q[i]; }
    rep(i, n) { N[i] = i + 1; }
    int a,b,count=0;
    do {++count;
#ifdef local
        dbg(N);
#endif
	if(N==pp){a=count;}
	if(N==q){b=count;}
    } while (next_permutation(all(N)));
cout<<abs(a-b)<<endl;
    return 0;
}
ll extgcd(ll a, ll b, ll& x, ll& y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) {
        is_prime[i] = true;
    }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (unsigned ll j = 2 * i; j <= N; j += i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat(){
#ifdef local
    rep(i, 2){std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

ll nCr(ll n, ll r)
{
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

template <typename T> T fact(T num)
{
    if (num == 1) { return 1; }
    return num * fact(num - 1);
}


Measured memory_bytes: 3596
import math
N, K = list(map(lambda k: int(k), input().split(" ")))
A = list(map(lambda a: int(a), input().split(" ")))

pos_of_1 = A.index(1)

if K >= pos_of_1 + 1 or N - K <= pos_of_1:
  print(math.ceil((N - K) / (K - 1)) + 1) 
else:
  L = A[:pos_of_1 + 1]
  R = A[pos_of_1:]
  res = []
  for i in range(1, K):
    l = math.ceil((len(L) - i) / (K - 1)) + 1
    r = math.ceil((len(R) - K - 1 + i) / (K - 1)) + 1
    res.append(l + r - 1)
  print(min(res))

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N;
    cin>>N;
    set<string> Prize;
    REP(i, 0, N){
        string s;
        cin >> s;
        Prize.insert(s);
    }
    cout << Prize.size() << endl;
    
}

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

def solve():
    N, M = list(map(int, input().split()))
    """方針
    from1 := 1から行ける島番号のリスト
    canN[i] := 島iがNに行くことができるか否か
    from1の中の島bのうち、canN[b] == Trueのものがあるならば、POSSIBLE
    計算量はO(N)
    """
    from1 = []
    canN = [False] * (N+1)
    for i in range(M):
        a, b = list(map(int, input().split()))
        if a == 1:
            from1.append(b)
        elif b == N:
            canN[a] = True
    
    for b in from1:
        if canN[b]:
            print("POSSIBLE")
            return
    print("IMPOSSIBLE")
        

if __name__ == "__main__":
    solve()


Measured memory_bytes: 8688
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int f(int i, const vi& v, const vii& x) {
  for (pii p : x) {
    if (p.first == v[i]) i += p.second;
    if (i < 0) return -1;
    if (i >= (int)v.size()) return 1;
  }
  return 0;
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n, q;
  cin >> n >> q;
  string s;
  vi v(n);
  cin >> s;
  for (int i = 0; i < n; ++i) v[i] = s[i] - 'A';
  vii x(q);
  for (int i = 0; i < q; ++i) {
    string t, d;
    cin >> t >> d;
    x[i] = pii(t[0] - 'A', d[0] == 'L' ? -1 : 1);
  }
  //cerr << x[0].first << ' ' << x[0].second << ' ' << v[0] << ' ' << f(0, v, x) << endl;
  int l = -1, r = n;
  while (r - l > 1) {
    int m = (l + r) / 2;
    if (f(m, v, x) < 0) l = m;
    else r = m;
  }
  int res = l + 1;
  l = -1, r = n;
  while (r - l > 1) {
    int m = (l + r) / 2;
    if (f(m, v, x) > 0) r = m;
    else l = m;
  }
  res += n - r;
  cout << max(0, n - res) << endl;
  return 0;
}


Measured memory_bytes: 2964
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    int T = scan.nextInt();
    T = T / A * B;
    System.out.println(T);
  }
}


Measured memory_bytes: 35732
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
using db = double;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
  数値型から文字列に変換　to_string(number);これは簡単
  文字列から数値型に変換　stoi(number)
  文字列からllに変換　stoll(number)
  __gcd(a,b)は最大公約数を取ってくれる、aとb
  の大きい方をNとしたとき、計算量は log(N);
 */
const int mod = 1e9 + 7;
// pie = M_PI
//ここから書き始める
int main(){
	cout << setprecision(10);
	int k , s;
	cin >> k >> s; //x y zは0以上k以下
	ll ans = 0;
	if(3 * k <= s){
		if(3*k==s){
			cout << 1 << endl;
		}
		else cout << 0 << endl;
		return 0;
	}
	rep(i,k+1){//まずはxを固定する。0からkで動かす。y+zがs-xになればいい
		int yz = s - i;
		rep(j,k+1){//次にyの値を動かしていく
			int leave = yz - j;
			if(leave >=0){//0以上なら求める通りに＋できる。
				if(k>=leave){
				ans ++;
			//	cout <<"("<<"x: "<<i<<",y: "<<j<<",z: " <<leave<<")"<<endl;
				}
			}
		}
	}
	cout << ans << endl;

	
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        StringBuilder sb = new StringBuilder(s);
        for (int i = 0; i < s.length(); i++) {
            for (int j = i; j < s.length(); j++) {
                String ans = sb.replace(i, j, "").toString();
                if (ans.equals("keyence")) {
                    System.out.println("YES");
                    return;
                }
                sb = new StringBuilder(s);
            }
        }
        System.out.println("NO");
    }
}


Measured memory_bytes: 22612
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000001;

using namespace std;



int main(void) {
	int n;
	int s[101];
	int total = 0;

	cin >> n;
	FOR(i, 1, n) {
		cin >> s[i];
		total += s[i];
	}
	sort(s, s + n + 1);
	if (total % 10 != 0) {
		cout << total << endl;
	}
	else {
		FOR(i, 1, n) {
			if ((total - s[i]) % 10 != 0) {
				cout << total - s[i] << endl;
				break;
			}
			if (i == n) {
				cout << 0 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

const ll maxv=105;

int dist[maxv][maxv];
int n;

void warshall_floyd(){
  for(int k = 0; k < n; k++)
    for(int i = 0; i < n; i ++)
      for(int j = 0; j < n; j++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}
 
 
signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll m; cin>>n>>m;
  rep(i,n) rep(j,n) dist[i][j]=INF;
  vector<tuple<ll,ll,ll>> es;
  rep(i,m){
    ll a,b,c; cin>>a>>b>>c;
    a--,b--;
    es.emplace_back(a,b,c);
    dist[a][b]=dist[b][a]=c;
  }
  
  warshall_floyd();
  
  ll ans=0;
  rep(i,m){
    ll a,b,c;
    tie(a,b,c)=es[i];
    if(dist[a][b]<c) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll K;
  cin>>K;
  const ll a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout<<a[K-1]<<endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
const int N=4005;
int A,B,Stack[N],tot,ans[N];
char s[2];
int ask(int x,int y){
	cout<<'?'<<' '<<x<<' '<<y<<endl;
	scanf("%s",s);
	if (s[0]=='Y')return 1;
	return 0;
}
int main(){
	scanf("%d%d",&A,&B);
	if (A<=B){
		puts("Impossible");
		return 0;
	}
	int n=A+B;
	for (int i=0;i<n;i++)
		if (tot){
			if (!ask(i,Stack[tot]))tot--;
			else Stack[++tot]=i;
		}
		else Stack[++tot]=i;
	int x=Stack[1];
	for (int i=0;i<n;i++)ans[i]=ask(x,i);
	printf("! ");
	for (int i=0;i<n;i++)printf("%d",ans[i]);
}


Measured memory_bytes: 848
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

long int combination(long int n, long int r);

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)

long int combination(long int n, long int r)
{
	if(r>n-r) r = n-r;
	if(r == 0) return 1;
	else if(r == 1) return n;
	return (combination(n-1, r) + combination(n-1, r-1));
	//大きくなるとき
	/*
	long int tmp1, tmp2, tmp3;
	tmp1 = combination(n-1, r);
	if(tmp1>=MOD) tmp1 = tmp1%MOD;
	tmp2 = combination(n-1, r-1);
	if(tmp2>=MOD) tmp2 = tmp2%MOD;
	tmp3 = tmp1+tmp2;
	if(tmp3>=MOD) tmp3 = tmp3%MOD;
	return (tmp3);
	*/
}


int main(){
	int a, b;
	scanf("%d%d", &a, &b);
	int i=1, pre, now;
	for(; i<=1251; i++){
		pre = i*8/100;
		now = i*10/100;
		if((pre == a) && (now == b)){
			break;
		}
	}
	if(i==1252) printf("-1\n");
	else printf("%d\n", i);

	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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;
}
///////////////////////////////////////////////////////////////

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  int K,T; cin >> K >> T;
  int ans = 0;
  rep(i,T) {
    int a; cin >> a;
    if (K % 2 == 0) chmax(ans,(a - K / 2) * 2 - 1);
    else chmax(ans,(a - (K+1)/2)*2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

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

  for (int i = 0; i < K; ++i) {
    if (i%2) {
      if (B%2) B--;
      A += B/2;
      B /= 2;
    } else {
      if (A%2) A--;
      B += A/2;
      A /= 2;
    }
  }

  printf("%d %d\n", A, B);
}

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

using namespace std;

struct Node{
  int key;
  Node* left;
  Node* right;
  Node(){
    left = right = NULL;
  }
};

class Tree{
  Node* root = NULL;
  public:
  void insert(Node* n){
    Node* y = NULL;
    Node* x = root;
    while(x!=NULL){
      y = x;
      if(n->key < x->key){
        x = x->left;
      }else{
        x = x->right;
      }
    }
    if(y==NULL){
      root = n;
    }else if(n->key < y->key){
      y->left = n;
    }else{
      y->right = n;
    }
  }

  void print(){
    print_inorder(root);
    printf("\n");
    print_preorder(root);
    printf("\n");
  }

  void print_preorder(Node* n){
    if(n==NULL) return;
    printf(" %d",n->key);
    print_preorder(n->left);
    print_preorder(n->right);
  }
  void print_inorder(Node* n){
    if(n==NULL) return;
    print_inorder(n->left);
    printf(" %d",n->key);
    print_inorder(n->right);
  }

  bool find(int val){
    Node* x;
    x = root;
    while(1){
      if(x == NULL){
        return false;
      }else if(x->key == val){
        return true;
      }else if(val < x->key){
        x = x->left;
      }else{
        x = x->right;
      }
    }
  }

};

int main(){
  int n;cin>>n;
  Tree t;
  for(int i=0;i<n;i++){
    string ope; cin>>ope;
    if(ope=="insert"){
      int k; cin>>k;
      Node* node = new Node();
      node->key = k; 
      t.insert(node);
    }else if(ope=="print"){
      t.print(); 
    }else if(ope=="find"){
      int v; cin>>v;
      if(t.find(v)){
        cout<<"yes"<<endl;
      }else{
        cout<<"no"<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 15784
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var i, k int64
	fmt.Sscan(getNextLine(scanner), &k)
	var ans int64
	ans = 0
	for i = 0; i < k; i++ {
		ans = chokudai(ans + 1)
		fmt.Println(ans)
	}
}

func chokudai(j int64) int64 {
	var i, d, s, ts, temp int64
	d = 0
	s = 0
	for i = j; i > 0; i /= 10 {
		s += i % 10
		d++
	}
	min := j / s
	ans := j
	for i = 1; i < d; i++ {
		ts = 0
		temp = j
		for ii := i; ii > 0; ii-- {
			temp /= 10
		}
		temp++
		for ii := i; ii > 0; ii-- {
			temp *= 10
		}
		temp--

		for t := temp; t > 0; t /= 10 {
			ts += t % 10
		}
		if min >= temp/ts {
			min = temp / ts
			ans = temp
		}
	}
	return ans
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
struct Node
{
	int value;
   Node* prev,* next;
};
Node* head;
void Init()
{
    head=(Node*)malloc(sizeof(Node));
    head->next=head;
    head->prev=head;
}

Node* FindNode(int x)
{
	Node*temp=head->next;
	while(temp!=head&&temp->value!=x)
        temp=temp->next;
    return temp;
}
void Insert(int x)
{
	Node*temp=(Node*)malloc(sizeof(Node));
    temp->value=x;
    head->next->prev=temp;
    temp->next=head->next;
    head->next=temp;
    temp->prev=head;
}

void Delete(Node*temp)
{
	if(temp==head)
        return ;
	temp->next->prev=temp->prev;
	temp->prev->next=temp->next;
    free(temp);
}

void DeleteFirst()
{
    Delete(head->next);
}
void DeleteLast()
{
	Delete(head->prev);
}
/*
void PrintList()
{
    /*
    Node*temp=head->next;
    int flag=0;
    while(1)
    {
        if(temp==head)
            break;
        else
        {
            if(flag++>0)
                printf(" ");
            printf("%d",temp->value);
            temp=temp->next;
        }
    }
    printf("\n");
    
     Node* temp=head->next;
    while(temp->next!=head)
    {
        printf("%d ",temp->value);
        temp=temp->next;
    }
    printf("%d\n",temp->value);
}
*/
int main()
{
	int n;
	int i;
	scanf("%d",&n);
	char str[12];
	int x;
	Init();
    
	while(n--)
	{
		scanf("%s%d",str,&x);
		if(str[0]=='i'){Insert(x);}
		else if(str[0]=='d'&&str[6]=='F')DeleteFirst();
		else if(str[0]=='d'&&str[6]=='L')DeleteLast();
		else if(str[0]=='d'){Delete(FindNode(x));}
	}
    
    /*
	for(i = 0; i < n; i++) {
        scanf("%s %d", str, &x);
        if (str[0] == 'i') {
            Insert(x);
        }
        else if(str[0] == 'd') {
            if(str[6] == 'F')
                DeleteFirst();
            else if(str[6] == 'L')
                DeleteLast();
            else
                //DeleteValue(x);
                Delete(FindNode(x));
        }
    }
    */
    Node* temp=head->next;
    while(temp->next!=head)
    {
        printf("%d ",temp->value);
        temp=temp->next;
    }
    printf("%d\n",temp->value);
    
    //PrintList();
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i, n) cin >> l[i];
	int sum = 0;
	rep(i, n) sum += l[i];

	rep(i, n) {
		if (l[i] >= sum - l[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

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

int main( void )
{
    int a,b,c;
    cin >> a >> b >> c;
    
    if ( a + b >= c )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

int n, K;
vector<int> v[6];
vector<int> w[3];
vector<int> u[3];
vector<long long int> d[3];
long long int ans;

int main(){
	scanf("%d %d", &n, &K);
	for(int i=0; i<n; i++){
		for(int j=0; j<6; j++){
			int t;
			scanf("%d", &t);
			v[j].push_back(t);
			w[j%3].push_back(t);
		}
	}
	for(int i=0; i<3; i++){
		sort(w[i].begin(), w[i].end());
		w[i].erase(unique(w[i].begin(), w[i].end()), w[i].end());
	}
/*
	for(int i=0; i<3; i++){
		for(int j=0; j<w[i].size(); j++){
			printf("%d\t", w[i][j]);
		}
		printf("\n");
	}
*/
	for(int i=0; i<n; i++){
		for(int j=0; j<6; j++){
			v[j][i] = find(w[j%3].begin(), w[j%3].end(), v[j][i]) - w[j%3].begin();
		}
	}
/*
	for(int i=0; i<n; i++){
		for(int j=0; j<6; j++){
			printf("%d\t", v[j][i]);
		}
		printf("\n");
	}
*/
	for(int i=0; i<3; i++){
		for(int j=0; j<w[i].size()-1; j++){
			d[i].push_back(w[i][j+1]-w[i][j]);
		}
	}
/*
	for(int i=0; i<3; i++){
		for(int j=0; j<d[i].size(); j++){
			printf("%d\t", d[i][j]);
		}
		printf("\n");
	}
*/
	int u[w[0].size()][w[1].size()][w[2].size()];
	memset(u, 0, sizeof(u));
	for(int i=0; i<n; i++){
		for(int j=v[0][i]; j<v[3][i]; j++){
			for(int k=v[1][i]; k<v[4][i]; k++){
				for(int l=v[2][i]; l<v[5][i]; l++){
					u[j][k][l]++;
				}
			}
		}
	}

	for(int i=0; i<w[0].size(); i++){
		for(int j=0; j<w[1].size(); j++){
			for(int k=0; k<w[2].size(); k++){
				if(u[i][j][k] >= K) ans += d[0][i] * d[1][j] * d[2][k];
			}
		}
	}
/*
	for(int i=0; i<3; i++)
		for(int j=0; j<w[i].size(); j++)
			u[i].push_back(0);

	for(int i=0; i<3; i++){
		for(int j=0; j<n; j++){
			for(int k=v[i][j]; k<v[i+3][j]; k++){
				u[i][k]++;
			}
		}
	}

	for(int i=0; i<3; i++){
		for(int j=0; j<u[i].size(); j++){
			printf("%d\t", u[i][j]);
		}
		printf("\n");
	}

	for(int i=0; i<u[0].size()-1; i++){
		for(int j=0; j<u[1].size()-1; j++){
			for(int k=0; k<u[2].size()-1; k++){
				if(u[0][i] >= K && u[1][j] >= K && u[2][k] >= K){
					ans += d[0][i] * d[1][j] * d[2][k];
					printf("%d %d %d\n", i, j, k);
				}
			}
		}
	}
*/
	printf("%lld\n", ans);
}

Measured memory_bytes: 6676
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque

INF = 1 << 50


def run():
    N, K = map(int, sysread().split())
    A = list(map(int, sysread().split()))

    l = 0
    r = 10**9
    while int(l) != int(r):
        #print(l, r)
        test = (l + r) / 2
        sum = 0
        for a in A:
            sum += math.ceil(a / test) - 1

        if sum > K:
            l = test
        elif sum < K:
            r = test
        else:# sum == K
            r = test
        if int(r) == r and r-l < 1:
            print(int(r))
            return

    if int(l) == 0:
        print(1)
        return
    if int(l) == l:
        sum = 0
        for a in A:
            sum += math.ceil(a / int(l)) - 1
        if sum == K:
            print(int(l))
            return

    print(int(l)+1)

if __name__ == "__main__":
    run()

Measured memory_bytes: 101568
import Control.Monad

main = do 
    a <- map read . words <$> getLine :: IO [Int]
    let tmp = head a  
    -- ass <- replicateM n (map read . words <$> getLine) :: IO [[Int]]
    if (length $ filter (==tmp) a) == 3 then  putStrLn "Yes" else putStrLn "No"

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  vvll a(3, vll(3));
  rep(i,3) rep(j,3) cin>>a[i][j];
  vvll b(3, vll(3));
  
  ll n; cin>>n;
  rep(i,n){
    ll x; cin>>x;
    rep(j,3) rep(k,3) if(a[j][k]==x) b[j][k]=1;
  }
  
  rep(i,3){
    if(b[i][0] && b[i][1] && b[i][2]){
      cout<<"Yes"<<endl;
      return 0;
    }
    if(b[0][i] && b[1][i] && b[2][i]){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  if(b[0][0] && b[1][1] && b[2][2] || b[2][0] && b[1][1] && b[0][2]){
    cout<<"Yes"<<endl;
    return 0;
  }
  
  // rep(i,3){
  //   rep(j,3){
  //     cout<<b[i][j]<<' ';
  //   }
  //   cout<<endl;
  // }
  
  cout<<"No"<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>		//printf(), %d, %0.5f, %s
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num):>, lower_bound(A, A+N, num):>=
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>	// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>		// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>	// push(x), front(), pop()
#include <deque>
#include <stack>	// push(x), top(), pop()
#include <map>		// M[key],  insert(key, val), erase(key), find(key), 
#include <set>		// insert(key), erase(key), find(key)

using namespace std;
typedef long long ll;
// typedef pair<int, int> P;

#define pi 3.141592653589793)
#define mod 1000000007

struct edge { int to, cost; };

const int INF = 100000000;
int N, M;
int d[101][101];
int a[1001], b[1001], c[1001];

void solve() {
	cin >> N >> M;
	
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			d[i][j] = INF;
		}
	}
	for (int i = 0; i < N; i++) d[i][i] = 0;

	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i] >> c[i];
		d[a[i] -1][b[i] -1] = c[i];
		d[b[i] -1][a[i] -1] = c[i];
	}
	
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	
	int res = 0;
	for (int i = 0; i < M; i++) {
		if (d[a[i]-1][b[i]-1] != c[i]) res++;
	}

	cout << res << endl;

}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define sort(vec) sort(vec.begin(),vec.end())
#define reverse(vec) reverse(vec.begin(),vec.end())
int gcd(int x,int y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int n;
vector<int>a(200);
int al=0,bo=0;
signed main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    sort(a);
    reverse(a);
    rep(i,n){
        if(i%2==0)al+=a[i];
        else bo+=a[i];
    }
    int ans=al-bo;
    cout<<ans<<endl;
    return 0;
}

    

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

using namespace std;
#define INF 10000000
int main(void)
{
	int a; cin >> a;
	vector<int>arr(a * 2);
	vector<int>arr2(a * 2, 0);
	vector<int>arr3(a * 2, 0);
	for (int i = 1; i <= a; i++)
	{
		int b; cin >> b;
		b /= 10;
		arr[i] = b;
		arr[a * 2 - i] = b;
	}
	for (int i = 1; i < a * 2; i++)
	{
		arr2[i] = max(i + arr[i], arr2[i-1]);
	}
	int ddd = 1;
	for (int i = 0; i < a * 2; i++)
	{
		if (ddd>=a *2)
		{
			break;
		}
		ddd = arr2[ddd];
	}
	if (ddd >= a*2)
	{
		cout << "yes" << "\n";
	}
	else cout << "no" << "\n";
}



Measured memory_bytes: 9956
# include<bits/stdc++.h>
# include<unordered_map>
# include<unordered_set>
// # include<prettyprint.hpp>
using namespace std;
# define ll long long
ll mod = 998244353;
vector<ll> fact, powerM;
ll modInverse(ll a, ll m) { 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1){ 
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x; 
} 
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n, m, k; cin >> n >> m >> k;
    fact.resize(n+1), powerM.resize(n+1);
    fact[0] = 1;
    powerM[0] = 1;
    for(ll i = 1; i <= n; i++){
        fact[i] = (i*fact[i-1])%mod;
        powerM[i] = ((m-1)*powerM[i-1])%mod;
    }
    ll ans = 0;
    for (ll i = 0; i <= k; i++){
        ll val = fact[n-1];
        val*=modInverse(fact[n-1-i], mod);
        val%=mod;
        val*=modInverse(fact[i], mod);
        val%=mod;
        val*=m;
        val%=mod;
        val*=powerM[n-1-i];
        val%=mod;
        ans+=val;
        ans%=mod;
    }
    cout << ans << endl;
    return 0;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }


int n;
double x[10], y[10];
void solve() {
    cin >> n;

    rep(i, n) cin >> x[i] >> y[i];

    vector<int> v(n);
    rep(i, n) v[i] = i;

    double ans = 0;
    do {
        rep(i, n - 1) ans += sqrt(pow2(x[v[i]] - x[v[i + 1]]) + pow2(y[v[i]] - y[v[i + 1]]));
    } while (all(next_permutation, v));

    double m = 1;
    reps(i, n) m *= i;
    cout << ans / m << endn;
}

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


Measured memory_bytes: 256