akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;

vector<LL> fact;
vector<LL> inver(200001);

LL combi(int n,int r){
    if(n<r||n<0||r<0) return 0;
    return fact[n]%mod*inver[n-r]%mod*inver[r]%mod;
}


LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}

void set_combi(){
    LL s=1;
    fact.push_back(1);
    for(int i=1;i<=200000;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[200000]=fpow(fact[200000],mod-2);
    for(int i=199999;i>=0;i--){
        inver[i]=inver[i+1]*(i+1)%mod;
    }
}

vector<LL> divi(LL K){
    vector<LL> v;
    for(int i=1;i*i<=K;i++){
        if(K%i) continue;
        v.pb(i);
        v.pb(K/i);
    }
    sort(ALL(v));
    v.erase(unique(ALL(v)),v.end());
    return v;
}

vector<LL> t;
LL N,M;

LL dfs(int k,LL sum,LL c){
    if(c>N) return 0;
    if(sum==1){
        return 1;
    }
    if(k==t.size()-1) return 0;
    LL ret=0;
    for(int i=0;;i++){
        if(i&&sum%t[k]) break;
        if(i==0) ret+=combi(N-c,i)*dfs(k+1,sum,c);
        else{
            sum/=t[k];
            ret+=combi(N-c,i)*dfs(k+1,sum,c+i);
        }
        ret%=mod;
    }
    return ret%mod;
}



int main(){
    cin >> N >> M;
    t=divi(M);
    reverse(ALL(t));
    set_combi();
    cout << dfs(0,M,0)%mod << endl;
    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin

// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!
struct PotentialUnionFind {
  int n;
  std::vector<int> par;
  std::vector<int> rank;
private:
  std::vector<int> diff_w; // diff_w[v] means the difference of weight from its parent
public:
  PotentialUnionFind(int n_) : par(n_), rank(n_,0), diff_w(n_,0), n(n_) { for(int i=0;i<n;++i) par[i] = i; }
  int root(int x) { int r; return par[x] == x ? x : (r=root(par[x]), diff_w[x]+=diff_w[par[x]], par[x]=r); }
  bool same(int x, int y) { return root(x)==root(y); }
  bool unite(int x, int y, int w) {
    w += weight(x); w-=weight(y);
    x = root(x); y = root(y);
    if(x==y) return false;
    if(rank[x] < rank[y]) swap(x,y), w=-w;
    if(rank[x]==rank[y]) rank[x]++;
    par[y] = x; diff_w[y] = w;
    return true;
  }
  int weight(int x){ root(x); return diff_w[x]; }
  int diff(int x, int y){ return weight(y)-weight(x); }
};
// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n, q; cin>>n>>q;
  PotentialUnionFind uf(n);
  int c, x, y, w;
  rep(i,q){
    cin>>c;
    if(c==0){
      cin>>x>>y>>w;
      uf.unite(x,y,w);
    }
    else {
      cin>>x>>y;
      if(!uf.same(x,y)) cout << '?' << endl;
      else cout << uf.diff(x,y) << endl;
    }
  }
  return 0;
}



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

int main() {
  int N,K; cin>>N>>K;
  int h[N+1];
  for(int i=1;i<=N;i++)cin>>h[i];
  int dp[N+1];
  dp[1]=0;

  for(int i=2;i<=N;i++){
    dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
    for(int j=2;j<=K;j++){
      if(i>j)dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
  }
  cout<<dp[N]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;
int main(){
	long long i,n,k;
	cin >> n >> k;
	long long l = 0,r = k + 1;
	while(r - l>1){
		long long mid = (l + r)/2,res = 0;
		long long pr = mid;
		for(i=0;i<n;i++){
			res += pr;
			pr /= 2;
			if(pr==0) break;
		}
		if(res>k) r =  mid;
		else l = mid;
	}
	cout << l << endl;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define lol long long
using namespace std;

//const lol mod=1e9+7;

/*  author: H3XoRuSH  */

int main() {
    ios_base::sync_with_stdio(false);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lol a,b;
    cin >> a >> b;
    if((a+b)==15) cout << "+";
    else if((a*b)==15) cout << "*";
    else cout << "x";
    return 0;
}


Measured memory_bytes: 256
import math
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
l=[]
#まずX+Yを求め、上から順にソート
#10^6相当の計算
for i in range(X):
    for j in range(Y):
        l.append(A[i] + B[j])
l.sort(reverse=True)
ans=[]
#(X+Y)+Zより、全体の上位を求めるが、Zが何であれ、X+Yの和が上からK番目以下のものは考慮しなくて良い
#(X+YにおいてK+i番目のもの(X+Y)_K+i+Zjが全体でK番以内に食い込めるということは、1~K番目のX+Yにて(X+Y)_1~K+Zj>(X+Y)_K+i+Zjが成立することと矛盾する)
#これで高々10^7相当までのソートでよくなる
for i in range(min(K,len(l))):
    for j in range(Z):
        ans.append(l[i]+C[j])
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Measured memory_bytes: 151216
N, x = list(map(int, input().split()))
n = N
a = list(map(int, input().split()))
b = [[1000000000000000000000 for i in range(n)] for j in range(n)]
for i in range(n):
	b[i][0] = a[i]
	for j in range(1, n):
		b[i][j] = min(b[i][j-1], a[(i-j+n)%n])
s = [0 for i in range(n)]
for i in range(n):
	for j in range(n):
		s[j] += b[i][j]
ans = 1000000000000000000000
for i in range(n):
	for j in range(n):
		ans = min(ans, j*x+s[j])
print(ans)


Measured memory_bytes: 140892
#include<iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
const long long int mod1=1000000007;
const long long int mod2 = -1;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back                                       
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define ordered1 tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define inf mod1
#define all(x) x.begin(),x.end()
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll power1(ll a, ll b){
     if(b == 0) return 1;
     else if(b % 2) return a * power1(a, b - 1);
     else {
        ll temp = power1(a, b / 2);
        return temp * temp;
     }
}
ll power2(ll a, ll b, ll m){
     a %= m;
     if(b == 0) return 1;
     else if(b % 2) return (a * power2(a, b - 1, m)) % m;
     else{
        ll temp = power2(a, b / 2, m);
        return (temp * temp) % m;
     }
}
ll mod(ll x, ll p){
return (x % p + p) % p;
}
ll lcm(ll x, ll y){
return (x * y)/gcd(x, y);
}
int main(){
	fast;
	ll h = 1;
	//cin >> h;
    while(h--){
 	ll n,k;
 	cin >> n >> k;
 	ll h[n];
 	for(int i = 0; i < n; i++){
 		cin >> h[i];
 	}
 	sort(h, h + n);
 	ll o = 0;
 	for(int i = 0; i < n - k; i++){
 		o += h[i];
 	}
 	cout << o << endl;
}
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, D;
  while (cin >> N >> D) {
    vector<int> d(N);
    for (int i = 0; i < N; i++) cin >> d[i];
    vector<int> A(N + 1);
    A[0] = D;
    for (int i = 0; i < N; i++) {
      if (d[i] < 2 * A[i]) {
        A[i + 1] = abs(A[i] - d[i]);
      } else {
        A[i + 1] = A[i];
      }
    }
    vector<int> B(N + 1);
    B[N] = 1;
    for (int i = N - 1; i >= 0; i--) {
      if (d[i] >= 2 * B[i + 1]) {
        B[i] = B[i + 1];
      } else {
        B[i] = B[i + 1] + d[i];
      }
    }
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
      int q;
      cin >> q;
      --q;
      bool res = A[q] >= B[q + 1];
      cout << (res ? "YES" : "NO") << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 7808
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	X := make([]int, n)
	for i := range make([]struct{}, n) {
		fmt.Scan(&X[i])
	}
	Y := make([]int, n)
	copy(Y, X)
	sort.Ints(Y)

	a := Y[(n-1)/2]
	b := Y[n/2]

	for i := 0; i < n; i++ {
		if X[i] < b {
			fmt.Println(b)
		} else {
			fmt.Println(a)
		}
	}
}


Measured memory_bytes: 8576
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7;

fn main(){
    let a: isize = read();
    let b: isize = read();
    let ans = max(a - 2 * b, 0);
    println!("{}", ans);
}

fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
a, b, c, k = map(int, input().split())

cnt = 0

if k >= a:
    k = k - a #3
    cnt = cnt + 1*a  #1

    if k >= b:
        k = k - b #1

        if k >= c:
            cnt = cnt + -1*c
            k = k - c

        else:
            cnt = cnt + -1*k
            k = k - k
    
    else:
        k = k - k

else:
    cnt = cnt + 1*k
    k = k - k
    
print(cnt)

Measured memory_bytes: 9184
import java.util.Scanner;
public class Main {

    public static void main(String[] args){
        Scanner Ent = new Scanner(System.in);
        int a = Ent.nextInt();
        int b = Ent.nextInt();
        if(a>0 && a<10 && b<10 && b>0){
            System.out.println(a*b);
        }else{
            System.out.println(-1);
        }
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <climits>

long long a[404];
long long dp[404][404];
bool flag[404][404];

long long rec(int l, int r){
    if(flag[l][r]) return dp[l][r];
    flag[l][r] = true;
    if(l == r) return 0;
    long long res = LONG_LONG_MAX;
    for(int s = l; s < r; s++){
        res = std::min(res, rec(l, s)+rec(s+1, r)+a[r]-a[l-1]);
    }
    return dp[l][r] = res;
}

int main(){
    int n;
    std::cin >> n;
    for(int i = 1; i <= n; i++){
        std::cin >> a[i];
        a[i] += a[i-1];
    }
    std::cout << rec(1, n) << std::endl;
    return 0;
}


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

int main()
{
	int d, g;
	cin >> d >> g, g /= 100;

	vector<int> p(d), c(d);
	for (int i = 0; i < d; i++) cin >> p[i] >> c[i], c[i] /= 100;

	int ans = 1 << 29;
	for (int i = 0; i < 1 << d; i++) {
		int score = 0, cnt = 0;
		for (int j = 0; j < d; j++) {
			if ((i >> j) & 1) {
				score += (j + 1) * p[j] + c[j];
				cnt += p[j];
			}
		}
		for (int j = d - 1; j >= 0; j--) {
			if ((i >> j) & 1) continue;
			for (int k = 0; k < p[j] - 1; k++) {
				if (score >= g) continue;
				score += j + 1;
				cnt++;
			}
		}
		if (score >= g) ans = min(ans, cnt);
	}
cout << ans << endl;

return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] x = new int[N];

    for (int i = 0; i < N; i++) {
      x[i] = sc.nextInt();
    }

    sc.close();

    int d = 0;

    for (int i = 0; i < N; i++) {
      if (K / 2 < x[i]) {
        d += K - x[i];
      } else {
        d += x[i];
      }
    }

    System.out.println(d * 2);

  }

}

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

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

    while (true){
        int x, y;
        cin >> x >> y;
        if (x == 0 && y == 0) break;
        cout << min(x, y) << " " << max(x, y) << endl;

    }

    return 0;
}


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


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

  if(A<6){cout << 0 << endl;}
  if(A<13 && A>5){cout << B/2 << endl;}
  if(A>12){cout << B << endl;}
  
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dis[100005];
vector<int> v[100005];
int deg[100005];
int main()
{
    int n,m,i,x,y;
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        v[x].push_back(y);
        deg[y]++;
    }
    queue<int> q;
    int ans  =  0;
    for(i=1;i<=n;i++)
    if(deg[i]==0)q.push(i);
    while(!q.empty())
    {
        
        int  cur,l;
        cur=  q.front();
        ans =  max(ans,dis[cur]);
        q.pop();
       // printf("%d %d\n",cur,dis[cur]);
        l = v[cur].size();
        for(i=0;i<l;i++)
        {
            x =v[cur][i];
            deg[x]--;
            if(deg[x]==0)q.push(x);
            dis[x] =max(dis[x],dis[cur]+1);
        }
    }
    printf("%d\n",ans);
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for (int i = 0; i < k; ++i) {
        int d;
        cin >> d;
        for (int j = 0; j < d; ++j) {
            int a;
            cin >> a;
            if (v.at(a-1) == 0) {
                v.at(a-1) = 1;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (v.at(i) == 0) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      long n = sc.nextLong();
      long total = 1;
      for(int i = 0; i < n; i++) {
      long a = sc.nextLong();
      if(a == 0) {
        total = 0;
      } else {
        if(total <= ((long)Math.pow(10, 18) / a)) {
          if(total >= 0) total *= a;
        } else {
          total = -1;
        }
      }
    }
      System.out.print(total);
    }
}


Measured memory_bytes: 59328
import numpy as np
temp=list(map(int, input().split()))
H=temp[0]
W=temp[1]

s=(0,0)
g=(H-1,W-1)

c=np.zeros((H,W)).astype(int)

for i in range(H):
  temp=input()
  a=np.zeros(W).astype(int)
  for j in range(W):
      if temp[j]=='#':
        a[j]=1
      else:
        a[j]=0
  c[i]=a
n_black=int(np.sum(c))
def Adj(u):
  adj=[]
  for v in [(u[0]-1,u[1]),(u[0]+1,u[1]),(u[0],u[1]-1),(u[0],u[1]+1)]:
      if v[0]>=0 and v[0]<H and v[1]>=0 and v[1]<W:
        adj.append(v)
  return adj  

color=np.zeros((H,W)).astype(int)
d=np.zeros((H,W)).astype(int)-1
d[s[0],s[1]]=0
def BFS():
  Q=[s]
  while Q !=[]:
    u=Q[0]
    if g==u:
      print(H*W-n_black-(d[u[0],u[1]]+1))
      return
    del Q[0]
    for v in Adj(u):  
      if c[v[0],v[1]]==0 and color[v[0],v[1]]==0:
        color[v[0],v[1]]=1
        d[v[0],v[1]]=d[u[0],u[1]]+1
        Q.append(v)
  print(-1)
BFS()

Measured memory_bytes: 13692
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)
#define cio ios::sync_with_stdio(false);

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int main()
{
    int l;
    scanf("%d",&l);
    double t = l / 3.0;
    printf("%.12f\n",t*t*t);
    return 0;
}


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

using namespace std;

typedef long long ll;

inline ll read(){
	char ch=getchar();ll x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

int ans=0;
int a[6]={357,375,537,573,735,753};
int n;

void dfs(ll v,int a,int b,int c){
	if(a==1 && b==1 && c==1) ans++;
	if(v*10+3<=n){
		dfs(v*10+3,1,b,c);
	}
	if(v*10+5<=n){
		dfs(v*10+5,a,1,c);
	}
	if(v*10+7<=n){
		dfs(v*10+7,a,b,1);
	}
}

int main(){
	n=read();
	dfs(0,0,0,0);
	cout<<ans;
	return 0;
}





Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int A[3][3];
	int N, b[10];
	int flag = 0;
	for(int i = 0; i < 3; ++i){
		for(int j = 0; j < 3; ++j){
			scanf("%d", &A[i][j]);
		}
	}
	scanf("%d",&N);
	for(int i = 0; i < N; ++i){
		scanf("%d", &b[i]);
	}
	for(int i = 0; i < 3; ++i){
		for(int j = 0; j < 3; ++j){
			for(int k = 0; k < N; ++k){
				if(A[i][j] == b[k]){
					A[i][j] = 0;
					break;
				}
			}
		}
	}
	
	for(int i = 0; i < 3; ++i){
		if(A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0){
			flag = 1;
			break;
		}
	}
	
	for(int j = 0; j < 3; ++j){
		if(A[0][j] == 0 && A[1][j] == 0 && A[2][j] == 0){
			flag = 1;
			break;
		}
	}
	
	if(A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0) flag = 1;
	if(A[0][2] == 0 && A[1][1] == 0 && A[0][2] == 0) flag = 1;
	
	if(flag == 1) printf("Yes");
	else printf("No");
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> f(n);
	for(int i = 0; i < n; i++){
		cin>>a[i]; a[i]--;
		f[a[i]]++;
	}
	ll ans = 0;
	for(int i = 0; i < n; i++){
		ans += f[i]*1LL*(f[i] - 1)/2;
	}
	for(int i = 0; i < n; i++){
		cout<<ans - f[a[i]] + 1<<'\n';
	}

	return 0;
}

Measured memory_bytes: 4224
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n, m; cin>>n>>m;
    vector<int> c(m);
    for(int i=0; i<m; i++) cin>>c[i];

    vector<int> dp(n+10, 1e9);

    dp[0] = 0;
    for(int i=0; i<m; i++){
        for(int j=0; j<=n; j++){
            if(n < c[i] + j) continue;

            dp[c[i] + j] = min(dp[c[i] + j], dp[j] + 1);
        }
    }

    cout << dp[n] << endl;
}


Measured memory_bytes: 3168
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	s = input[0].split(' ').map((n) => (parseInt(n)))[1]
	input = input[1].split(' ').map((n) => (parseInt(n)))
	ans = input.filter((n) => (s <= n)).length



	//出力
	console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));

Measured memory_bytes: 28480
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long M = sc.nextLong();
		
		if(Math.abs(N - M) >= 2) {
			System.out.println(0);
		} else {
			long c = 1000000000 + 7;
			long tempN = 1;
			
			for(long i = 1; i <= N; i++) {
				tempN = tempN * i % c;
			}
			
			long ans = tempN;
			
			for(long i = 1; i <= M; i++) {
				ans = ans * i % c;
			}
			if(Math.abs(N - M) == 1) {
				System.out.println(ans);
			} else {
				System.out.println(ans * 2 % c);
			}
		}
	}
}


Measured memory_bytes: 21716
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }
    let mut flag = true;
    let mut c_flag = false;
    for i in 0..s.len() {
        if i == 0 {
            if s[i] != 'A' {
                flag = false;
            }
        } else if 2 <= i && i <= s.len() - 2 {
            if s[i] == 'C' {
                if c_flag {
                    flag = false;
                } else {
                    c_flag = true;
                }
            } else {
                if s[i].is_uppercase() {
                    flag = false;
                }
            }
        } else {
            if s[i].is_uppercase() {
                flag = false;
            }
        }
    }

    println!("{}", if flag && c_flag { "AC" } else { "WA" });
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
const ll mo=1000000007;
ll ans=0;
ll dp[0][0];

int main()
{
ll a,b;
cin >> a>>b;
if(a==b)ans=a*2;
else if(a>b) ans=2*a-1;
else ans=2*b-1;


cout << ans << endl;
return 0;
}





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

int main() { 
  int n, a, b;
  cin >> n >> a >> b;
  int total = 0;
  
  for (int i = 1; i <= n; i++) {
    string num = to_string(i);
    int sum = 0;
    
    for (int j = 0; j < (int)num.size(); j++) {
      sum += (int)(num.at(j) - '0');
    }
    
    if (sum >= a && b >= sum) total += i;
  }
  
  cout << total << endl;
}


Measured memory_bytes: 3696
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
int N,x=0;
string S;
cin >>N>>S;

for(int i=0;i<N-2;i++){
  if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C'){
    x=x+1;
  }
}
cout<<x;



 return 0;
}


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

using namespace std;

int main()
{
	int n;
	string s, t;
	
	cin >> n >> s >> t;
	
	for (int i = 0; i < n; i++)
	{
		cout << s[i] << t[i];
	}
	
	
	return 0;
}


Measured memory_bytes: 256
n, m, k = map(int, input().split())
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.par = [-1 for i in range(self.n)]
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def unite(self, x, y):
        p = self.find(x)
        q = self.find(y)
        if p == q:
            return None
        if p > q:
            p, q = q, p
        self.par[p] += self.par[q]
        self.par[q] = p
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def size(self, x):
        return -self.par[self.find(x)]
UF = UnionFind(n)
f_or_b = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    UF.unite(a - 1, b - 1)
    f_or_b[a - 1] += 1
    f_or_b[b - 1] += 1
for i in range(k):
    c, d = map(int, input().split())
    if UF.same(c - 1, d - 1):
        f_or_b[c - 1] += 1
        f_or_b[d - 1] += 1
for i in range(n):
    print(UF.size(i) - f_or_b[i] - 1, end=" ")


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

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

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, na, wa, tle, re int
	var j string

	fmt.Scan(&N)
	for i := 1; i <= N; i++ {
		fmt.Scan(&j)
		switch j {
		case "AC":
			na++
		case "WA":
			wa++
		case "TLE":
			tle++
		case "RE":
			re++
		}
	}

	fmt.Printf("AC x %d\n", na)
	fmt.Printf("WA x %d\n", wa)
	fmt.Printf("TLE x %d\n", tle)
	fmt.Printf("RE x %d\n", re)
}


Measured memory_bytes: 6332
#include <stdio.h>
#include <string.h>

int main(void){
  char s1[4];
  char s2[4];
  char s3[4] = {'\0'};
  scanf("%4s", s1);
  scanf("%4s", s2);
  s3[0] = s2[2];
  s3[1] = s2[1];
  s3[2] = s2[0];
  if(strcmp(s3, s1) == 0) printf("YES\n");
  else printf("NO\n");
  return 0;
}

Measured memory_bytes: 128
function Main(input) {
  input = input.split('\n');
  var i0 = input[0].split(' ');
  var N = i0[0];
  var M = i0[1];
  var An = [];
  input[1].split(' ').map(n => heapPush(An, parseInt(n, 10)));


  var Atmp, Amax, Ai;
  for (var i = 0; i < M; i++) {
    Amax = An[0];
    heapPop(An);
    heapPush(An, Math.floor(Amax / Math.pow(2, 1)));
  }
  // console.log(An);
  var sum = 0;
  An.forEach(n => sum += parseInt(n));
  console.log(sum);
}
function heapPush(list, elem) {
  var n = list.length;
  list.push(elem);

  var i, tmp;
  while(n != 0) {
    i = Math.floor((n - 1) / 2);
    if (list[n] > list[i]) {
      tmp = list[n];
      list[n] = list[i];
      list[i] = tmp;
    }
    n = i;
  }
  return list;
}
function heapPop(list) {
  var n = list.length - 1;
  var i = 0;
  list[i] = list[n];
  var pop = list.pop();

  var j, tmp;
  for (i, j; (j = i * 2 + 1) < n;) {
    if ((j != n - 1) && (list[j] < list[j + 1])) {
      j = j + 1;
    }
    if (list[j] > list[i]) {
      tmp = list[j];
      list[j] = list[i];
      list[i] = tmp;
    }
    i = j;
  }
  return pop;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK cerr <<"OK"<< endl
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define double long double
#define tt tuple<int, int, int>
#define endl '\n'

double dp[303][303][303];

int n;

double f(int cnt1, int cnt2, int cnt3) {

	if(cnt1 + cnt2 + cnt3 == 0)
		return 0;

	double &ret = dp[cnt1][cnt2][cnt3];

	if(ret > -1)
		return ret;

  ret = 0;
  if(cnt1)
    ret += (cnt1) * f(cnt1 - 1, cnt2, cnt3);
  if(cnt2)
    ret += (cnt2) * f(cnt1 + 1, cnt2 - 1, cnt3);
  if(cnt3)
    ret += (cnt3) * f(cnt1, cnt2 + 1, cnt3 - 1);

  ret += n;

  ret /= 1.0 * (cnt1 + cnt2 + cnt3);
  return ret;
}

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

  for(int i = 0; i < 303; i++)
  	for(int j = 0; j < 303; j++)
  		for(int k = 0; k < 303; k++)
  			dp[i][j][k] = -INF;

  cin >> n;

  int cnt1, cnt2, cnt3;

  cnt3 = cnt2 = cnt1 = 0;
  for(int i = 0; i < n; i++) {
    int x;
    cin >> x;

    cnt1 += (x == 1);
    cnt2 += (x == 2);
    cnt3 += (x == 3);
  }

  cout << fixed << setprecision(10);
  cout << f(cnt1, cnt2, cnt3) << endl;

}

Measured memory_bytes: 435072
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main() {

    int N, W; cin>>N>>W;
    int item[N+1][2];
    for (int i = 1; i <= N; ++i) cin>>item[i][0]>>item[i][1];

    ll dp[N+1][W+1];
    for (int i = 0; i <= N; ++i) dp[i][0]=0;
    for (int i = 0; i <= W; ++i) dp[0][i]=0;

    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= W; ++j) {
            if(j >= item[i][0]){
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-item[i][0]]+item[i][1]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    cout<<dp[N][W]<<endl;

    return 0;
}


Measured memory_bytes: 79104
from collections import deque

h, w = map(int, input().split())
C = list(map(int, input().split()))
C = tuple([C[0]-1, C[1]-1])
D = tuple(map(int, input().split()))
D = tuple([D[0]-1, D[1]-1])
maze = [list(input()) for _ in range(h)]

visit = [[False]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if maze[i][j] == "#":
            visit[i][j] = True

DQ = deque([C])
DQ_warp = deque([])

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

ans = 0

while DQ or DQ_warp:
    while DQ:
        now = DQ.popleft()
        if now == D:
            print(ans)
            exit()
        x, y = now[0], now[1]
        if visit[x][y]:
            continue
        visit[x][y] = True
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if 0<=nx<=h-1 and 0<=ny<=w-1 and visit[nx][ny]==False:
                DQ.append(tuple([nx, ny]))

        for i in range(-2, 3):
            for j in range(-2, 3):
                if i == j == 0: continue
                nx = x + i
                ny = y + j
                if 0<=nx<=h-1 and 0<=ny<=w-1 and visit[nx][ny]==False:
                    DQ_warp.append(tuple([nx, ny]))

    if DQ_warp:
        DQ = DQ_warp.copy()
        DQ_warp = deque([])
        ans += 1

print(-1)

Measured memory_bytes: 210980
a, b, q = map(int, input().split())
listS = []
listT = []
listAns = []

def nibutan(listA, x):
    minY=0
    maxY=len(listA)-1
    while True:
        middle = (minY+maxY)//2
        if listA[middle] < x:
            if middle == len(listA)-1:
                return listA[middle-1], listA[middle]
                break
            else:
                if x < listA[middle+1] :
                    return listA[middle], listA[middle+1]
                    break
                else:
                    minY = middle
        else:
            if middle==0:
                return listA[middle], listA[middle+1]
                break
            else:
                if listA[middle-1] < x:
                    return listA[middle-1], listA[middle]
                    break
                else:
                    maxY = middle


index=0
while index < a:
    s = int(input())
    listS.append(s)
    index+=1
listS.reverse()
listS.append(-10**11)
listS.reverse()
listS.append(10**11)
index2=0
while index2 < b:
    t = int(input())
    listT.append(t)
    index2+=1
listT.reverse()
listT.append(-10**11)
listT.reverse()
listT.append(10**11)
index3=0
while index3 < q:
    x = int(input())
    #nibutan!
    sa, sb = nibutan(listS, x)
    ta, tb = nibutan(listT, x)
    listDis = [abs(sa-x)+abs(sa-ta), abs(ta-x)+abs(sa-ta), abs(sa-x)+abs(sa-tb), abs(tb-x)+abs(sa-tb),
               abs(sb-x)+abs(sb-ta), abs(ta-x)+abs(sb-ta), abs(sb-x)+abs(sb-tb), abs(tb-x)+abs(sb-tb)]
    minDist = min(listDis)
    listAns.append(minDist)
    index3+=1
for ans in listAns:
    print(ans)

Measured memory_bytes: 16956
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) {cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;}
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */

struct UnionFind{
  vector<long long> data;
  UnionFind(long long N) : data(vector<long long>(N,-1)){}
  long long root(long long x){
    if(data[x] < 0)return x;
    else return data[x] = root(data[x]);
  }
  bool same(long long x,long long y){
    return root(x) == root(y);
  }
  void unite(long long x,long long y){
    if(!same(x,y)){
      x = root(x);
      y = root(y);
      if(data[x] < data[y]){
        data[x] += data[y];
        data[y] = x;
      }
      else{
        data[y] += data[x];
        data[x] = y;
      }
    }
    return;
  }
  long long getsize(long long x){
    return -data[root(x)];
  }
};

/* main */

signed main(){
    ll N,M;
    cin >> N >> M;
    UnionFind UF(N);
    vl a(N);
    FOR(i,0,N)cin >> a[i];
    ll x,y;
    while(cin >> x >> y)UF.unite(x,y);
    set<ll> s;
    vl costs[N];
    FOR(i,0,N){
		s.insert(UF.root(i));
		costs[UF.root(i)].pb(a[i]);
	}
	if(s.size() == 1){
		cout << 0 << endl;
		return 0;
	}
	ll ans = 0;
	for(auto x:s){
		sort(ALL(costs[x]));
		ans += costs[x][0];
		costs[x].erase(costs[x].begin());
	}
	vl v;
	for(auto V:s)for(auto x:costs[V])v.pb(x);
	sort(ALL(v));
	FOR(i,0,s.size()-2){
		if(i >= v.size()){
			cout << "Impossible" << endl;
			return 0;
		}
		ans += v[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  map<pair<int, int>, int> mp;
  ll ans = 0;
  rep2(i, 1, n+1){
    string s = to_string(i);
    int fr = s.front() - '0';
    int re = s.back() - '0';
    mp[{fr, re}]++;
  }
  rep(i, 10){
    rep(j, 10){
      ans += (ll)mp[{i, j}]*mp[{j, i}];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from math import sqrt
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
def hoge(c):
    return int((-1+sqrt(1+8*c))/2)
n = int(input())
a = prime_factorize(n)
b = set(a)
print(sum([hoge(a.count(e)) for e in b]))


Measured memory_bytes: 9208
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  vector<int> A(3); vector<int> B(3);
  vector<vector<bool>> graph(4, vector<bool>(4,false));
  map<int, int> dict;
  for(int i=0; i<3; i++) {
    int a,b; cin>>a>>b;
    a--; b--;
    graph[a][b] = graph[b][a] = true;
    dict[a]++;
    dict[b]++;
  }

  string ans = "YES";
  for(auto p: dict) {
    if(p.second >= 3) {
      ans = "NO";
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<bl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<bl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define present(c,x) ((c).find(x) != (c).end())
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll fast_exp(ll base, ll exp) {
    ll res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%MOD;
       base=(base*base)%MOD;
       exp/=2;
    }
    return res%MOD;
}
ll fib(ll n)
{
    if(n < 2)
        return n;
    ll a = 0,b = 1,ans;
    int i = 1;
    while(i < n)
    {
        ans = (a+b) % MOD;
        a = b;
        b = ans;
        i++;
    }
    return ans;
}
int main()
{
    fastio();
    string s1,s2;
    cin>>s1>>s2;
    int n=s1.length();
    bool flag=true;
    for(int i=0;i<n;i++)
    {
        if(s1[i]!=s2[i])
        {
            flag=false;
        }
    }
    if(flag and s2.length()==n+1)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No\n";
    }
    

}

Measured memory_bytes: 3656
s = input()
k = int(input())

list = sorted(list(set(s)))

result=[]

def substring(l):
    result.append(l)
    if len(result) < k:
        for m in list:
            if l+m in s:
                return substring(l+m)
            else:
                pass
for l in list:
    substring(l)
print(result[k-1])


Measured memory_bytes: 38396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll h, w;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    if (h % 2 == 1 && w % 2 == 1) {
        cout << h * w / 2 + 1LL << endl;
    } else {
        cout << h * w / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    S = [input() for _ in range(N)]
    c_AC = len([x for x in S if x == "AC"])
    c_WA = len([x for x in S if x == "WA"])
    c_TLE = len([x for x in S if x == "TLE"])
    c_RE = len([x for x in S if x == "RE"])
    print("AC x", c_AC)
    print("WA x", c_WA)
    print("TLE x", c_TLE)
    print("RE x", c_RE)


if __name__ == '__main__':
    main()


Measured memory_bytes: 16820
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))
acc = 0
s = defaultdict(int)
s[0] = 1
ans = 0
for a in A:
    acc = (acc + a) % M
    ans += s[acc]
    s[acc] += 1
print(ans)


Measured memory_bytes: 14636
N = int(input())

F = []
for _ in range(N):
    mask = 0
    for f in map(int, input().split()):
        mask <<= 1
        mask |= f
    F.append(mask)

P = [list(map(int, input().split())) for _ in range(N)]

def calc(state):
    ret = 0
    for f, ps in zip(F, P):
        f &= state
        cnt = 0
        while f > 0:
            cnt += f % 2
            f //= 2
        ret += ps[cnt]
    return ret

ans = -10**18
for state in range(1, 1 << 10):
    ans = max(ans, calc(state))
print(ans)


Measured memory_bytes: 3188
#include <stdio.h>
#include <algorithm>
#include <deque>
using namespace std;
using ll = long long;

using pii = pair<int, int>;
int n, k;
char s[100010];
deque<pii> dq;

int main() {
	scanf("%d %d", &n, &k);
	scanf("%s", s);

	int max_c = 0, sum = 0;
	for (int i = 0; i < n; i++) {
		if (dq.empty() || dq.back().first != s[i])
			dq.emplace_back(s[i], 1);
		else
			dq.back().second++;
		sum++;

		while (2 * k + 1 < dq.size())
			sum -= dq.front().second, dq.pop_front();
		if (2 * k + 1 <= dq.size() && s[i] == '0')
			sum -= dq.front().second, dq.pop_front();

		max_c = max(max_c, sum);
	}
	printf("%d\n", max_c);
}

Measured memory_bytes: 768
/*
 * Click `Run` to execute the snippet below!
 */

import java.io.*;
import java.util.*;

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int N = sc.nextInt();
    int sum = 0;
    for(int i = 0 ;i<N; i++){
      int k  = sc.nextInt();
      sum += k;
    }
    if(H <= sum){
      System.out.println("Yes"); 
    }
    else{
      System.out.println("No"); 
    }
  }
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << ""; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n, a, b, x;

	cin >> n >> a >> b >> x;

	ll ans = 0;
	ll prev = x;

	REP(i, n - 1) {
		cin >> x;
		ans += min((x - prev) * a, b);
		prev = x;
	}

	cout << ans << endl;
}

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

typedef long long ll;

int N;
vector<int> V[200010];
int vis[200010];
int cx, cy;

void DFS(int v)
{
    if(vis[v] != 0)return;
    if(v % 2 == 1)cy++;
    else cx++;
    vis[v] = 1;
    for(int i = 0; i < V[v].size(); i++)DFS(V[v][i]);
}

int main()
{
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        int a, b;
        cin >> a >> b;
        int x = 2 * a;
        int y = 2 * b + 1;
        V[x].push_back(y);
        V[y].push_back(x);
    }

    ll cnt = 0;
    for(int i = 0; i < 200000; i++)
    {
        if(vis[i] == 0)
        {
            cx = cy = 0;
            DFS(i);
            cnt += (ll)cx * (ll)cy;
        }
    }

    cout << cnt - N << endl;
    return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    ll n;
    std::cin >> n;
    ll cnt=0ll,ans=0ll;
    ans=1ll;
    for(;;){
        ans*=2ll;
        if(ans-1>=n){
            std::cout << ans-1 << std::endl;    
            exit(0);
        }
        
    }
}


Measured memory_bytes: 256