akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define MAXN 100
#define MAXRATE 4800
int main(int argc,char const* argv[])
{
  int n,i,j,k,tmp,min=0,max=0;
  bool anycolor=false;
  bool thereisbegi=false;
  vector<int> a;
  vector<int> flag(10,0);
  cin >> n;
  for(i=0;i<n;i++)
    {
      cin >> tmp;
      a.push_back(tmp);
    }
  for(i=0;i<n;i++)
    {
      if(a[i]<400) flag[0]=1;
      else if(a[i]<800 && a[i]>=400) flag[1]=1;
      else if(a[i]<1200 && a[i]>=800) flag[2]=1;
      else if(a[i]<1600 && a[i]>=1200) flag[3]=1;
      else if(a[i]<2000 && a[i]>=1600) flag[4]=1;
      else if(a[i]<2400 && a[i]>=2000) flag[5]=1;
      else if(a[i]<2800 && a[i]>=2400) flag[6]=1;
      else if(a[i]<3200 && a[i]>=2800) flag[7]=1;
      else if(a[i]>=3200)
	{
	  for(j=0;j<9;j++)
	    {
	      if(flag[j]==1) anycolor=true;
	    }
	  if(anycolor==false && i !=0) 
	    {
	      for(k=0;k<n;k++)
		{
		  if(a[i]<=3200) thereisbegi=true;
		}
	      if(thereisbegi==true)
		{
		  flag[8]=1;
		  continue;
		}
	    }
	  flag[9]++;
	}
    }
  for(i=0;i<9;i++)
    {
      min+=flag[i];
      max+=flag[i];
    }
  if(min==0) min=1;
  max+=flag[9];
  cout << min << " " << max << endl;
  return 0;
}


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

int main()
 {
 	string a,b,c;
 	 cin>>a>>b>>c;
 	 char cur='a';
 	int n=a.length();
 	int m=b.length();
 	int k=c.length();
 	 int x=0,y=0,z=0;
 	 while(x<=n&&y<=m&&z<=k)
 	 	{
 	 		if(cur=='a')
 	 			{
 	 			cur=a[x];
				  x++;	
				  }
			else if(cur=='b')
				{
					cur=b[y];
					y++;
			}
			else
				{
					cur=c[z];
					z++;
				}
		  }
 	if(x>n)
 		cout<<'A'<<endl;
 	else if(y>m)
 		cout<<'B'<<endl;
 	else
 		cout<<'C'<<endl;

 
     
 return 0;
 }






Measured memory_bytes: 3632
import Data.Vector.Unboxed ((!))
import qualified Data.Vector.Unboxed as V
import Control.Monad

data Survival = DropL | Survive | DropR deriving (Eq)

main = do
  [n,q]<-map read.words<$>getLine
  s<-getLine
  ops<-replicateM q$(\[a,b]->(a,b)).map head.words<$>getLine
  print $ solve n s ops

solve n s ops = right - left
  where
  right = findBorder ((/=DropR).eval) n
  left  = findBorder ((==DropL).eval) n
  eval = go ops
  go [] _ = Survive
  go ((t,d):ops) pos
    | t /= golems!pos = go ops pos
    | d == 'L' = if pos == 0 then DropL else go ops (pos-1)
    | d == 'R' = if pos == n-1 then DropR else go ops (pos+1)
  golems = V.fromListN n s

findBorder f = go (-1)
  where
  go l r
    | l+1 == r = l
    | f m = go m r
    | otherwise = go l m
    where m = (l+r) `div` 2

Measured memory_bytes: 89468
read x k d
x=$[x>0?x:-x]
q=$[x/d]
r=$[x-d*q]
if [ $k -le $q ];then
	echo $[x-k*d]
elif [ $[(k-q)%2] -eq 0 ];then
	echo $r
else
	echo $[d-r]
fi


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

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

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

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 K;
	cin >> K;
	string s;
	cin >> s;
	if (s.size() <= K) {
	  cout << s << endl;
	} else {
	  cout << s.substr(0, K) << "..." << endl;
	}
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;++i) cin >> a[i];
  int maxi = 0;
  for(int i=0;i<n;++i) {
    if( a[i] == 0 ) continue;
    int score = 0;
    while( i < n && a[i] == 1 ) ++i, ++score;
    maxi = max(maxi,score);
  }
  cout << maxi+1 << endl;
  return 0;
}



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

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

  int digi= N%10;

  if(digi==2)cout<<"hon";
  if(digi==4)cout<<"hon";
  if(digi==5)cout<<"hon";
  if(digi==7)cout<<"hon";
  if(digi==9)cout<<"hon";
  if(digi==0)cout<<"pon";
  if(digi==1)cout<<"pon";
  if(digi==6)cout<<"pon";
  if(digi==8)cout<<"pon";
  if(digi==3)cout<<"bon";
  return 0;
}

Measured memory_bytes: 3652
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());
    int s[][] = new int[m][n];
    int pat[] = new int[n];
    int k[] = new int[m];
    int p[] = new int[m];
    int ans = 0;

    for (int i=0; i<m; i++){
      k[i] = Integer.parseInt(sc.next());
      for(int j=0; j<k[i]; j++){
        s[i][j] = Integer.parseInt(sc.next());
      }
    }

    for(int i=0; i<m; i++){
      p[i] = Integer.parseInt(sc.next());
    }

    for(int i=0; i<Math.pow(2, n); i++){
      String bin = Integer.toBinaryString(i);
      
      if(bin.length() < n){
        for(int j=bin.length(); j<n; j++){
          bin = "0" + bin;
        }
      }
      
      //System.out.println(bin);
      
      for(int j=0; j<n; j++){
        pat[j] = Integer.parseInt(bin.substring(j,j+1));
      }
      
      int tdon = 0;
      for(int kk=0; kk<m; kk++){ // 電球
        int tson = 0;
        for(int ll=0; ll<k[kk]; ll++){ // スイッチ
          tson += pat[s[kk][ll]-1];
        }
        if(tson%2 == p[kk]) {
          tdon++;
        }
      }
      if(tdon == m){
        ans++;
      }
    }
    
    System.out.println(ans);
    
  }
}


Measured memory_bytes: 23252
#include <cstdio>
#include <cmath>
int main()
{
	int x, h;
	while (scanf("%d%d", &x, &h))
	{
		if (x == 0.0 && h == 0.0) break;
		printf("%.6f\n", (4.0*(sqrt(double(h*h)+double(x*x)/4.0)*x))/2.0+x*x);
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int arr[4];
	while(cin>>arr[1]>>arr[2]>>arr[3])
	{
		sort(arr+1,arr+4);
		cout<<arr[2]-arr[1]+arr[3]-arr[2]<<endl;
	}
}

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

bool compare(vector<ll> a, vector<ll> b){
	if(a[0]<b[0]) return true;
	if(a[0]==b[0]){
		if(a[1]<b[1]) return true;
		return false;
	}
	return false;
}

void solve(){
	
}

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

#ifndef ONLINE_JUDGE
	//for getting input from input1.txt
	freopen("input1.txt", "r", stdin);
	//for getting output from output1.txt
	freopen("output1.txt", "w", stdout);
#endif

	ll n,d,count=0,i,j,dis=0;
    ll X=200001, Y=200001;
	cin>>n>>d;
	vector< vector<ll> > arr(n);

	for(i=0;i<n;i++){
		arr[i] = vector<ll> (2);
		cin>>arr[i][0]>>arr[i][1];
	}
	//sort(arr.begin(),arr.end(),compare);

	for(i=0;i<n;i++){
		dis = arr[i][0]*arr[i][0] + arr[i][1]*arr[i][1];
		if(dis<=d*d){ count++; X=arr[i][0]; Y=arr[i][1]; }

	}
	cout<<count;


}

Measured memory_bytes: 14208
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    vi dx = {0, 1, 0, -1}, dy = {1, 0, -1, 0};

    while(true) {
        int w, h; cin >> w >> h;

        if (w == 0 && h == 0) break;
        vector<vector<bool>> maze(h * w, vector<bool>(h * w, true));

        REP(i, 2 * h - 1) {
            if (i & 1) {
                // horizontal
                int hi = i / 2;
                REP(j, w) {
                    int b;
                    cin >> b;
                    if (b == 0) continue;
                    maze[hi * w + j][(hi + 1) * w + j] = false;
                    maze[(hi + 1) * w + j][hi * w + j] = false;
                }
            } else {
                // vertical
                int hi = i / 2;
                REP(j, w - 1) {
                    int b;
                    cin >> b;
                    if (b == 0) continue;
                    maze[hi * w + j][hi * w + j + 1] = false;
                    maze[hi * w + j + 1][hi * w + j] = false;
                }
            }
        }

        auto check = [&](int x, int y) -> bool {
            return x >= 0 && x < w && y >= 0 && y < h;
        };

        queue<pair<int, Pin>> q;
        q.push({1, {0, 0}});
        vector<vector<bool>> visit(h, vector<bool>(w, false));
        visit[0][0] = true;

        int ans = 0;
        while(!q.empty()) {
            auto p = q.front(); q.pop();
            int x = p.se.fi, y = p.se.se;
            int d = p.fi;

            if (x == w - 1 && y == h - 1) {
                ans = d;
                break;
            }

            REP(i, 4) {
                int nx = x + dx[i], ny = y + dy[i];
                if (!check(nx, ny) || !maze[y * w + x][ny * w + nx]) continue;

                if (!visit[ny][nx]) {
                    visit[ny][nx] = true;
                    q.push({d + 1, {nx, ny}});
                }
            }
        }

        print(ans);
    }

}


Measured memory_bytes: 3260
#include<bits/stdc++.h>
#define FastRead                      \
                                    ios_base::sync_with_stdio(false); \
                                    cin.tie(0);
#define ll long long
#define endl "\n"
#define f for
using namespace std;
int main()

{
    FastRead
    ll int n,m;
    cin>>n>>m;
    if(n==m)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;

}

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

int main(){
	string str;
	cin >> str;
	int count = 0;
	
	for(int i = 0; i < str.length() - 1; i++){
		if(str[i] != str[i + 1])count++;
	}
	cout << count << endl;
}



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

int main(){
  int h,w; cin>>h>>w;
  vector<string>S(h);
  for(int i=0;i<h;i++){
    string s; cin>>s;
    S[i]=s;
  }
  for(int i=0;i<h;i++){
    cout<<S[i]<<endl;
    cout<<S[i]<<endl;
  }
}

Measured memory_bytes: 256
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 

ll dp[100003];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,W;
    cin>>n>>W;
    ll w[1000],v[1000];
    for (int i = 1; i <=n; ++i)
    {
    	cin>>w[i]>>v[i];
    }
    for (int i = 1; i <=100000; ++i)
    {
    	dp[i]=1e18;
    }
    dp[0]=0;
    for (int i = 1; i <=n; ++i)
    {
    	for (int j = 100000-v[i]; j>=0 ; --j)
    	{
    		
            dp[j+v[i]]=min(dp[j+v[i]],dp[j]+w[i]);
    	}
    }
    ll ans=0;
    for (int i = 0; i <=100000; ++i)
    {
        if(dp[i]<=W)
        {
            ans=max(ans,(ll)i);
        }
    }
    cout<<ans<<'\n';
    
}


Measured memory_bytes: 1024
#include<stdio.h>
#define INFTY 1000000000

int cnt = 0;

void merge(int A[], int left, int mid, int right){

  int n1,n2,i,j,k;
  int L[500000],R[500000];
  
  n1 = mid - left;
  n2 = right - mid;

  for(i=0;i<n1;i++){
    L[i] = A[left+i];
  }
  for(j=0;j<n2;j++){
    R[j] = A[mid+j];
  }

  L[n1] = INFTY;
  R[n2] = INFTY;

  i = 0;
  j = 0;

  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k] = L[i];
      i++;
      cnt++;
    }
    else{
      A[k] = R[j];
      j++;
      cnt++;
    }
  }
}

void mergeSort(int A[],int left,int right){
  int mid;
  if(left+1<right){
    mid = (left + right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int main(){
  int A[500000];
  int n,i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  mergeSort(A,0,n);
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1){
      printf(" ");
    }
  }
  printf("\n%d\n",cnt);
  return 0;
}

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

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

  int sum=0;
  for(int i=0;i<N;++i){
    sum=sum+(L+i);
  }

  int aji=50000;
  int ans=0;

  for(int i=0;i<N;++i){
    int umami=0;
    for(int j=0;j<N;++j){
      if(j!=i){
        umami=umami+(L+j);
      }
    }
    if(max(sum-umami,umami-sum)<aji){
      aji=max(sum-umami,umami-sum);
      ans=umami;
    }
  }

  cout<<ans<<endl;
}

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

using namespace std;

main(){
	long long x,y,n=0;
	cin>>x>>y;
	long long a=x%y;
	long long b=y;
	while(a !=0){
		x=y;
		y=a;
		a=x%y;
		b=y;
	}
	printf("%d\n",b);
}



Measured memory_bytes: 3220
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n = load()
A = []
for i in range(n):
    A.append(load())

mx = max(A)
mx_count = 0
for e in A:
    if e == mx:
        mx_count += 1

sa = reversed(sorted(A))
mx2 = 0
for e in sa:
    if e != mx:
        mx2 = e
        break

for e in A:
    if e == mx:
        if mx_count == 1:
            print(mx2)
            continue
        else:
            print(mx)
            continue
    print(mx)


        
    

Measured memory_bytes: 14504
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

const int N=3e5+5;
int n,q,x,a[N];
long long sf[N],sg[N];

void init()
{
	int i;
	scanf("%d%d",&n,&q);
	for(i=1;i<=n;++i) scanf("%d",&a[i]);
	for(i=1;i<=n;++i) sf[i]=sf[i-1]+a[i*2-(n&1)];
	for(i=1;i<=n;++i) sg[i]=sg[i-1]+a[n+1-i];
}

int fi(int L,int R)
{
	int l=1,r=n+1;
	while(l<r)
	{
		int mid=(l+r)>>1;
		if(a[mid]>=L) r=mid;
		else l=mid+1;
	}
	int nowl=l;
	
	l=0,r=n;
	while(l<r)
	{
		int mid=(l+r+1)>>1;
		if(a[mid]<=R) l=mid;
		else r=mid-1;
	}
	int nowr=l;
	
	return max(nowr-nowl+1,0);
}

int ok(int x,int mid)
{
	if(a[mid]<=x) return false;
	int tot_x=fi(x*2-a[mid],a[mid]);
	int tot_y=n-mid;
	return tot_x>tot_y;
}

void work()
{
	while(q--)
	{
		scanf("%d",&x);
		int l=1,r=n;
		while(l<r)
		{
			int mid=(l+r+1)>>1;
			if(ok(x,mid)) r=mid-1;
			else l=mid;
		}
		int tme=(n+1)>>1;
		int now=min(n-l,tme);
		printf("%lld\n",sg[now]+sf[tme-now]);
	}
}

int main()
{
	init();work();
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int x,y;
	cin>>x>>y;
	if(abs(x)==abs(y))
		cout<<1<<endl;
	else if(y==0 && x>0)cout<<1+abs(x+y)<<endl;
	else if(y==0 && x<0)cout<<abs(x+y)<<endl;
	else if(y>x && ((y>0 && x>0) || (y<0 && x<0)))
		cout<<min(y-x,2+abs(x-y))<<endl;
	else if(y>x)
		cout<<min(y-x,1+abs(abs(y)-abs(x)))<<endl;
	else if((y>0 && x>0) || (y<0 && x<0))
		cout<<2+abs(x-y)<<endl;
	else
		cout<<abs(abs(x)-abs(y))+1<<endl;
	return 0;
}




















Measured memory_bytes: 256
import heapq
import sys

input = sys.stdin.readline

def dijkstra_heap(s,edge,N):
    d = [float('inf')] * N
    used = [True] * N
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist, a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

def main():
    N = int(input())
    edge = [[] for i in range(N)]

    for i in range(N-1):
        u, v, w = map(int, input().split())
        u -= 1
        v -= 1
        edge[u].append([w,v])
        edge[v].append([w,u])

    D = dijkstra_heap(0,edge,N)
    first = D[0]
    for d in D:
        if abs(d - first) % 2 == 0:
            print(0)
        else:
            print(1)

main()

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll> v(N);
  for(ll i = 0; i < N; i++) cin>>v[i];
  ll ans = 0LL;
  for(ll i = 1; i<=K; i++){
    ll t = 0LL;
    for(ll j = (i+1)/2; j <=min(i,N); j++){
      ll s = 0LL;
      for(ll k = 0; k <= j;k++){
        ll u = 0LL;
        priority_queue<ll,vector<ll>,greater<ll>> q;
        for(ll l = 0; l<k;l++) q.push(v[l]);
        for(ll l = 0; l<j-k;l++) q.push(v[N-1-l]);
        for(ll l = 0; l<i-j;l++) q.pop();
        ll x = q.size();
        for(ll l = 0; l<x;l++) {
          u+=q.top();
          q.pop();
        }
        //cout<<i<<" "<<j<<" "<<k<<" "<<u<<" "<<endl;
        chmax(s,u);
      }
      chmax(t,s);
    }
    chmax(ans,t);
  }
  cout<<ans<<endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m, q;
  cin >> n >> m >> q;
  
  vector<vector<int>> x(n + 1, vector<int>(n + 1));
  for(int i = 0; i < m; i++){
    int l, r;
    cin >> l >> r;
    x.at(l).at(r)++;
  }
  
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      x.at(i).at(j) += x.at(i).at(j - 1);
    }
  }
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      x.at(i).at(j) += x.at(i - 1).at(j);
    }
  }
  
  for(int i = 0; i < q; i++){
    int p, q;
    cin >> p >> q;
    cout << x.at(n).at(q) - x.at(p - 1).at(q) << '\n';
  }
}

Measured memory_bytes: 1920
#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() {
    vector<int> a(3);
    vector<int> b(3);
    //この2次元配列の宣言は記憶しておく
    vector<vector<int>> c(3,vector<int>(3));
    rep(i,3){
        rep(j,3)cin>>c[i][j];
    }
    //a[0]=0として一般性を失わない
    rep(i,3) b[i]=c[0][i];
    rep(i,3) a[i]=c[i][0]-b[0];
    bool ok=true;
    rep(i,3){
        rep(j,3){
            if(a[i]+b[j]!=c[i][j])ok=false;
        }
    }

    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Control.Monad
import Control.Monad.State
import Control.DeepSeq
import Data.Array
import Data.Bits
import Data.Char
import Data.Functor.Identity
import Data.List
import Data.Maybe
import Data.Ord
import Data.Tree
import Data.Tuple
import qualified System.IO
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.Sequence as Q
import qualified Data.ByteString.Char8 as B

main = do
  n <- readLn
  s <- getLine
  t <- getLine
  print $ head [length u | k <- [0..n], let u = take k s ++ t, s`isPrefixOf`u]

 
type Z = Int
type Q = Rational
type R = Double
type S = String

fint :: (Integral a, Num b) => a -> b
fint = fromIntegral

getInt = fst . fromJust . B.readInt <$> B.getLine
getIntPair = (\[a,b]->(a,b)) <$> getInts
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine
getStr = B.unpack <$> B.getLine

yesNo :: Bool -> String
yesNo True = "Yes"
yesNo False = "No"

printList :: (Show a) => [a] -> IO ()
printList = putStrLn . unwords . map show

readLnList :: (Read a) => IO [a]
readLnList = map read . words <$> getLine


-----  Union-find
type UnionFindT v m a = StateT (M.Map v (UnionFindVal v)) m a
newtype UnionFindVal v = UnionFindVal v

runUnionFindT :: (Monad m) => UnionFindT v m a -> m a
runUnionFindT = flip evalStateT $ M.empty

runUnionFind = runIdentity . runUnionFindT

ufFresh :: (Monad m, Ord v) => v -> UnionFindT v m ()
ufFresh v = modify $ M.insert v (UnionFindVal v)

ufClass :: (Monad m, Ord v) => v -> UnionFindT v m v
ufClass v = do
  (UnionFindVal pv) <- gets (M.! v)
  if v == pv
    then return v
    else do
      c <- ufClass pv
      modify $ M.insert v (UnionFindVal c)
      return c

ufUnify v w = do
  cv <- ufClass v
  cw <- ufClass w
  modify $ M.insert cw (UnionFindVal cv)
  return $ cv /= cw


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <deque>
#include <tuple>
#include <unordered_set>
#include <array>
#include <string>

using namespace std;
#define ll long long
#define ar array

int main() {
	int n, x, t;
	cin >> n >> x >> t;
	int ans=n/x*t;
	if (n%x!=0) ans+=t;	
	cout << ans;
	return 0;
}

Measured memory_bytes: 3628
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
A=list(map(int,input().split()))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

def count2(x):
    c=0
    while x%2==0:
        x//=2
        c+=1
    return c

c2=count2(A[0])
LCM=1

for a in A:
    if count2(a)!=c2:
        print(0)
        sys.exit()

    LCM=lcm(a//2,LCM)
    if LCM>M:
        print(0)
        sys.exit()

print(max(0,(M-LCM)//(2*LCM)+1))


Measured memory_bytes: 15012
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
#define int long long
signed main()
{
    int n;cin >>  n;
    int x = n%10;
    if(x == 2|| x == 5 || x == 7 || x == 9|| x == 4)cout <<"hon" << endl;
    else if(x == 3)cout << "bon" << endl;
    else cout << "pon" << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(int)(n);i++)
#define foi(i,k,n) for(int i=(k); i<(int)(n); i+=1)
#define fod(i,n,k) for(int i=k; i>=(int)n; i-=1)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define endl "\n"

#define EPS 1e-12
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef long long int llint;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<llint> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
llint toint(string s) {stringstream ss(s); llint x; ss >> x; return x;}
//gp_hash_table<string, llint> table;


//int mpow(llint base, llint exp) {
  //base %= MOD;
  //llint result = 1;
  //while (exp > 0) {
    //if (exp & 1) result = ((llint)result * base) % MOD;
    //base = ((llint)base * base) % MOD;
    //exp >>= 1;
  //}
  //result %= MOD;
  //return result;
//}


//void makegraph(int n, int m){
	//int i, u, v;
	//while(m--){
		//cin>>u>>v;
		//u--, v--;
		//g[u].pb(v);
		//g[v].pb(u);
	//}
//}

//void dfs(int u, int par){
	//for(int v:g[u]){
		//if (v == par) continue;
		//dfs(v, u);
	//}
//}


// ------------------------------------------------------------------PRIYANSHU RAJPUT----------------------------------------------------------------  //


void solve(){
	int a;
	cin>>a;
	cout<<a + a*a + a*a*a;
}



int main() {
	fast_io;
    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }
    return 0;
}



Measured memory_bytes: 3580
x1, x2, x3, x4, x5 =(int(x) for x in input().split())
if x1 == 0:
  print('1')
elif x2 == 0:
  print('2')
elif x3 == 0:
  print('3')
elif x4 == 0:
  print('4')
elif x5 == 0:
  print('5')

Measured memory_bytes: 9180
n = int(input())
s = input()
count = 0
for i in range(n-2):
    if s[i]!="A":
        pass
    else:
        if s[i+1]!="B":
            pass
        else:
            if s[i+2]!="C":
                pass
            else:
                count += 1
    
print(count)

Measured memory_bytes: 2940
N,M=map(int, input().split())
H = list(map(int, input().split()))
#AB=[list(map(int,list(input().split()))) for i in range(M)]

good = list(range(1,N+1))
good = [1]*N

for j in range(M):
  a,b=map(int, input().split())
  #print(a,b)
  if H[a-1]>H[b-1]:
    #good.remove(b)
    good[b-1] = 0
  elif H[a-1]<H[b-1]:
    #good.remove(a)
    good[a-1] = 0
  elif H[a-1]==H[b-1]:
    good[a-1] = 0
    good[b-1] = 0
  #print(good)
  
print(sum(good))

Measured memory_bytes: 20152
#include <iostream>
#include <algorithm>
using namespace std;
int dir[] = { 0, 1, 0, -1 };
int n, a[9][9], cnt, px[75], py[75]; bool vis[9][9];
bool solve(int sx, int sy, int cur, int vcnt, int sum) {
	if (cur == cnt) return vcnt == n * n + 1;
	if (sum == -a[px[cur]][py[cur]]) {
		vis[px[cur + 1]][py[cur + 1]] = true;
		bool res = solve(px[cur + 1], py[cur + 1], cur + 1, vcnt + 1, 0);
		vis[px[cur + 1]][py[cur + 1]] = false;
		return res;
	}
	for (int i = 0; i < 4; i++) {
		int tx = sx + dir[i], ty = sy + dir[i ^ 1];
		if (0 <= tx && tx < n && 0 <= ty && ty < n && !vis[tx][ty] && a[tx][ty] > 0 && sum + a[tx][ty] <= -a[px[cur]][py[cur]]) {
			vis[tx][ty] = true;
			bool res = solve(tx, ty, cur, vcnt + 1, sum + a[tx][ty]);
			vis[tx][ty] = false;
			if (res) return true;
		}
	}
	return false;
}
int main() {
	while (cin >> n, n) {
		cnt = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				cin >> a[i][j];
				if (a[i][j] < 0) {
					px[cnt] = i;
					py[cnt] = j;
					cnt++;
				}
			}
		}
		vis[px[0]][py[0]] = true;
		bool ret = solve(px[0], py[0], 0, 1, 0);
		vis[px[0]][py[0]] = false;
		cout << (ret ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 3044
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let mut A: Vec<usize> = sc.vec(N);
    let B: Vec<usize> = sc.vec(N);
    for i in 0..N {
        A[i] -= 1;
    }
    let C: Vec<usize> = sc.vec(N-1);
    let mut ans = 0;
    let mut prev = N+10;
    for i in 0..N {
        if prev + 1 == A[i] {
            ans += C[prev];
        }
        ans += B[A[i]];
        prev = A[i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;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 repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << p.first << " " << p.second ;
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int k;
	int ans=0;
	cin >>k;
	V a(k);
	bool can = true;
	cin >> a;
	if(a[k-1]>2){
		cout << -1 << endl;
		return 0;
	}
	P data = mp(2LL, 2LL);//min,max
	rrep(i,k){
		if(a[i]> data.S){
			cout << -1 << endl;
			return 0;
		}
		data.F = (data.F + a[i] - 1) / a[i] * a[i];
		data.S = data.S / a[i] * a[i] + (a[i] - 1);
		if(data.F >data.S){
			cout << -1 << endl;
			return 0;
		}
		clog << a[i] <<" : "<< data << endl;
	}
	cout << data << endl;
	
}

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

int main() {
	int N;
	cin >> N;
	vector<int> B(N - 1);
	for (int i = 0; i < N - 1; i++) {
		cin >> B.at(i);
	}

	int max_sum = 0;
	for (int i = N - 1; i >= 0; i--) {
		if (i == N - 1) {
			max_sum += B.at(i - 1);
		} else if (i == 0) {
			max_sum += B.at(0);
		} else {
			max_sum += min(B.at(i), B.at(i - 1));
		}
	}

	cout << max_sum << endl;
}

Measured memory_bytes: 256
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> P;
#define X real()
#define Y imag()
ld restant(P p){return abs(p);}
//polar(x,y) mag=l,arg=y
//typedef unordered_set<ll> usll;
//typedef unordered_multiset<ll> umsll;
typedef multiset<ll> msll;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,ll> > vpll;
typedef priority_queue<ll> pqll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
//typedef unordered_multiset<int> umsi;
//typedef unordered_set<int> usi;
typedef pair<int,int> pi;
typedef vector<pair<int,int> > vpi;
typedef vector<pair<double,double> > vpd;
typedef pair<double,double> pd;
typedef priority_queue<int> pqi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ind_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ind_setll;
#define in insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define be begin
#define en end
#define itr iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mo 1000000007
#define inf 1000000000000000001
#define ninf -1000000000000000001
#define ima INT_MAX
#define imi INT_MIN
#define oncnt __builtin_popcount
#define zerobegin __builtin_clz
#define zeroend __builtin_ctz
#define parity __builtin_parity
#define all(x) x.be(),x.en()
#define eps 1e-9
const ld pii=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return((a-b+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}


int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{	
int a[3];
for(int i=0;i<3;i++)
cin>>a[i];
sort(a,a+3);
if(a[0]!=5||a[1]!=5||a[2]!=7)
cout<<"NO";
else
cout<<"YES";

}return 0;}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        char s[] = sc.next().toCharArray();
        char ans[] = new char[7];

        for (int i = 0; i < 4; i++) {
            ans[i * 2] = s[i];
        }
        for (int tmp = 0; tmp < (1 << 3); tmp++) {
            for (int b = 0; b < 3; b++) {
                ans[b * 2 + 1] = ((((tmp & (1 << b)) >> b) == 1) ? '+' : '-');
            }
            if (check(ans)) {
                System.out.println(new String(ans) + "=7");
                break;
            }
        }
    }

    private boolean check(char str[]) {
        int ans = str[0] - '0';
        for (int i = 0; i < 3; i++) {
            if (str[i * 2 + 1] == '+') {
                ans += str[i * 2 + 2] - '0';
            } else {
                ans -= str[i * 2 + 2] - '0';
            }
        }

        return ans == 7;
    }

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            new Main().main(sc);
        } catch (Exception e) {
            throw e;
        }
    }
}


Measured memory_bytes: 23764
m,n=[int(x) for x in str(input()).split()]
s=""
for i in range(m+2):
  s+="0"
A=[s]
for i in range(m):
  A.append("0"+input()+"0")
A.append(s)


s=""
for i in range(n+2):
  s+="0"
B=[s]
for j in range(n):
  B.append("0"+input()+"0")
B.append(s)
#print(A,B)

count=0
for j in range(1,m-n+2):
  for k in range(1,m-n+2):
    ans=1
    for a in range(1,n+1):
      for b in range(1,n+1):
        #print(a,b)
        if A[j+a-1][k+b-1]!=B[a][b]:
          ans=0
    if ans==1:
      count=1
if count==1:
  print("Yes")
else:
  print("No")
        


Measured memory_bytes: 3064
import numpy as np
n,m,c = map(int, input().split())
b = list(map(int, input().split()))
count=0
for i in range(n):
  a = list(map(int, input().split()))
  if sum(np.array(a)*np.array(b)) + c > 0:
    count+=1
print(count)

Measured memory_bytes: 12424
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

constexpr i64 MOD = 1000000007;

i64 N, M;

int main() {
    cin >> N >> M;
    if (abs(N-M) > 1) {
        cout << 0 << endl;
        return 0;
    }
    i64 A = max(N, M), B = min(N, M);

    i64 ans = 1;
    for (int j = 1; j <= A; ++j) {
        ans = (ans * j) % MOD;
    }
    for (int j = 1; j <= B; ++j) {
        ans = (ans * j) % MOD;
    }
    if (A - B == 0) ans = (ans * 2) % MOD;
    cout << ans << endl;

    return 0;
}


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



int main() {
        int n,m;
        cin >> n >> m;
        int ans = n*(n-1)/2 + m*(m-1)/2;
        cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let nm: String = read();
    let nm: Vec<isize> = nm.split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
    let n: isize = nm[0];
    let m: isize = nm[1];

    let ans = if n == m {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  long long int N,K,i,ans = 0;
  
    cin >> N>>K;
  if (K > N){
    cout << 0<<endl;
  }
  else {
    int H[N];
    int sum=0;
    REP(i,N){//配列に格納
        cin >> H[i];
    }
  sort(H,H+N);
  
  REPR(i,N-K-1){
    ans+=H[i];
  }
    cout << ans << endl;
  
 
}


}



Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int n, m; cin >> n >> m;
  vector<bool> one(n, false), enu(n, false);
  while (m--) {
    int a, b; cin >> a >> b; --a; --b;
    if (a == 0) {
      one[b] = true;
    } else if (b == n - 1) {
      enu[a] = true;
    }
  }
  FOR(i, 1, n - 1) {
    if (one[i] && enu[i]) {
      cout << "POSSIBLE\n";
      return 0;
    }
  }
  cout << "IMPOSSIBLE\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,x1,x2,x3,x4;
 

  cin >> N;
 
  x1 = N - N / 10 * 10;
  x2 = N / 10 - N / 100 * 10;
  x3 = N / 100 - N / 1000 * 10;
  x4 = N / 1000;
    
    if(x1 == x2 && x2 == x3){
      cout << "Yes";
    }
  else if(x2 == x3 && x3 == x4){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
int n,l,q,x[maxn],fa[maxn][18],sum[maxn],summ;
inline void pre()
{
	register int i,j=2;
	for(i=1;i<=n;++i)
	{
		while(summ+sum[j]-sum[j-1]<=l&&j<=n) summ+=sum[j]-sum[j-1],++j;
		fa[i][0]=j-1;
		summ-=sum[i+1]-sum[i];
	}
	for(i=1;i<=17;++i)
		for(j=1;j<=n;++j)
			fa[j][i]=fa[fa[j][i-1]][i-1];
}
inline void solve(int a,int b)
{
	if(a>b) swap(a,b);
	int ans=0;
	for(register int i=17;i>=0;--i)
		if(fa[a][i]<b) a=fa[a][i],ans+=(1<<i);
	printf("%d\n",++ans);
}
int main()
{
	scanf("%d",&n);
	register int i;
	for(i=1;i<=n;++i)
		scanf("%d",&x[i]),sum[i]=sum[i-1]+x[i]-x[i-1];
	scanf("%d%d",&l,&q);
	pre();
	int a,b;
	for(i=1;i<=q;++i)
		scanf("%d%d",&a,&b),solve(a,b);
	return 0;
}

Measured memory_bytes: 8576
import java.util.*;

public class Main{
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String s = sc.next();
	List<String> list = new ArrayList<String>();
	for ( int i = 0; i < s.length(); i++ ) {
	    char tmp = s.charAt(i);
	    if ( tmp == '0' ) {
		list.add("0");
	    } else if ( tmp == '1' ) {
		list.add("1");
	    } else if ( tmp == 'B' ) {
		if ( !list.isEmpty() ) list.remove(list.size()-1);
	    }
	}
	for ( Iterator it = list.iterator(); it.hasNext();) {
	    System.out.print(it.next());
	}
	System.out.println();
    }
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<ll,ll>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll H,N;
    vector<pl> S;
    ll dp[20010];
    fillnum(dp,LINF);
    cin >> H >> N;
    for (int i = 0; i < N; i++) {
        ll A,B;
        cin >> A >> B;
        S.pb(mp(A,B));
    }
    dp[0] = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < N; j++) {
            dp[i+S[j].first] = min(dp[i+S[j].first],dp[i]+S[j].second);
        }
    }
    ll ans = LINF;
    for (int i = H; i < H+10000; i++) {
        ans = min(ans,dp[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define int long long int
#define double long double
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define MAX 1e15+1
const int M = 1e9+7;
const int mod = M;
const int N = 2e5+7;
#define pi  pair<int,int>
signed main()
 {
    int k;
    cin>>k;
    int val=0;
    int ans =0;
    while(k>val){

        val=(val*10)+7;
        ans++;
    }
    
    while(1){
        int rem = val%k;
        val = rem;
        if(rem==0){
            cout<<ans<<"\n";
            return 0;
        }
        while(k>val){

            val=(val*10)+7;
            ans++;

        }


        if(ans>2000000){
            break;
        }

    }
    cout<<-1;

    
    

}

Measured memory_bytes: 3528
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

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

  queue <ll> que;
  for (int i = 1; i < 10; i++) que.push(i);

  for (int i = 0; i < N - 1; i++){
    ll now = que.front(); que.pop();

    ll dig = now % 10; now *= 10;

    if (dig > 0) que.push(now + dig - 1);
    que.push(now + dig);
    if (dig < 9) que.push(now + dig + 1);
  }
  cout << que.front() << endl;

  return 0;
}


Measured memory_bytes: 1792