akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    vector<ll> l(n);
    rep(i, n) cin >> l[i];

    sort(ALL(l));
    ll ans = 0;
    rep(i, n) {
        forr(j, i + 1, n) {
            ll sum = l[i] + l[j];
            int it = lower_bound(ALL(l), sum) - l.begin();
            ans += max(it - j - 1, 0);
        }
    }

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

Measured memory_bytes: 3616
#include <iostream>

using namespace std;

const int N = 50000, M = 20;

int count[N + 1], money[M];

int main(){
	int n, m;
	for(int i = 0;i <= N;++i){
		count[i] = M + M;
	}
	cin >> n >> m;
	for(int i = 0;i < m;++i){
		cin >> money[i];
		for(int j = money[i], k = 1; j <= N; j += money[i], ++k){
			count[j] = k;
		}
	}
	for(int i = 1;i <= n;++i){
		if(count[i] != M + M){
			int c = count[i] + 1;
			for(int j = 0;j < m;++j){
				if(i + money[j] <= n)
				count[i + money[j]] = count[i + money[j]] > c ? c : count[i + money[j]];
			}
		}
	}
	cout << count[n] << endl;
	return 0;
}

Measured memory_bytes: 1356
#include <stdio.h>

#define MAX 100005
#define NIL -1

struct Node{
  int p, l, r;
};
 
struct Node T[MAX];
int n, D[MAX];
 
int getD(int);
void print(int);
 
int dik[MAX];

int main(void){
  int i, j;
  int deg, ver;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;
  }
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &ver, &deg);
    for ( j = 0; j < deg; j++ ){
      scanf("%d", &dik[j]);
      T[dik[j]].p = ver;
      if(j == 0)
        T[ver].l = dik[0];
      else
        T[dik[j - 1]].r = dik[j];
    }
  }
  for ( i = 0; i < n; i++ )
    D[i] = getD(i);
  for ( i = 0; i < n; i++ )
    print(i);
  return 0;
}
 
int getD(int u){
  int d = 0;
  while(T[u].p >= 0){
    u = T[u].p;
    d++;
  }
  return d;
}
 
void print(int u){
  int i, cnt = 0;
  printf("node %d: parent = %d, depth = %d, ",u,T[u].p,D[u]);
  if(T[u].p == NIL)
    printf("root, [");
  else if(T[u].l == NIL)
    printf("leaf, [");
  else
    printf("internal node, [");
  u = T[u].l;
  while(u != NIL){
    if(cnt == 0)
      printf("%d",u); 
    else
      printf(", %d",u); 
    u = T[u].r;
    cnt++;
  } 
 
    printf("]\n");
}

Measured memory_bytes: 2564
#include<iostream>
#include<vector>
#include<map>
using namespace std;
int main()
{
int n,i;
cin>>n;
vector<int> V(n+1);
map<int,int> M;
for(i=2;i<=n;i++)
{
cin>>V[i];
++M[V[i]];
}
for(i=1;i<=n;i++)
cout<<M[i]<<endl;
}

Measured memory_bytes: 13556
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll mod = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    int n;
    cin>>n;
    int cnt=0;
    vector<int> p(n);
    rep(i,0,n) cin>>p[i];
    rep(i,1,n-1){
        if((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i+1]<p[i]&&p[i]<p[i-1])){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
s = input()
t = input()

x = "UNRESTORABLE"

sl = len(s)
tl = len(t)


if sl < tl:
    print(x)
    exit()

flag =0

for i in range(sl-tl,-1,-1):
    temp = s[i:i+tl]
    for j in range(tl):
        if temp[j] == t[j] or temp[j] =="?":
            if j == tl-1:
                x = s[:i] + t + s[i+tl:]
                flag = 1
                break            
        else:
            break

    if flag ==1:
        break

x = x.replace("?","a")

print(x)

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

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

G = A[0]
for a in A:
    G = gcd(G, a)

for a in A:
    if K <= a and (a - K) % G == 0:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')


Measured memory_bytes: 14224
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
using namespace std;
typedef long long ll;

int main() {
    int k, x; cin >> k >> x;
    k--;
    for (int i = k * (-1); i <= k; i++) {
        cout << x + i << endl;
    }
}


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

typedef long long int llint;

int main()
{
  int n;
  int x[101];
  int y[101];
  int h[101];

  cin>> n;
  for(int i = 0; i < n; i++) {
    cin>> x[i] >> y[i] >> h[i];
  }


  for(int i = 0; i <= 100; i++) {
    for(int j = 0; j <= 100; j++) {
       
      int ch;
      for(int k = 0; k < n; k++)
	if(h[k] != 0) ch = abs(j - x[k]) + abs(i - y[k]) + h[k];
      if(ch <= 0) continue;
      
      bool flg = true;
      for(int k = 0; k < n; k++) {
	int tmp = ch - abs(j - x[k]) - abs(i - y[k]);
	if(tmp > 0 && tmp != h[k]) flg = false;
	if(tmp <= 0 && h[k] != 0) flg = false;
	if(!flg) break;
      }
      
      if(flg) {
	cout<< j << ' ' << i << ' ' << ch <<endl;
	return 0;
      }
	
    }
  }
  
  

  return 0;
}


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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

void print(int a) {
  printf("%d\n",a);
  exit(0);
}

int main(){
  int n;
  string pre, suf;

  cin >> n >> pre >> suf;

  if (pre == suf) print(n);
  REP(i, n) {
    string prefix = pre;
    string suffix = suf;
    prefix = prefix.erase(0, i);
    suffix = suffix.erase(n - i, i);
    if (prefix == suffix) print(n + i);
  }
  print(2 * n);
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

unsigned long memo[50] = {};

int fib(int n) {
	if (n == 0 || n == 1)return 1;
	if (memo[n] != 0) {
		return memo[n];
	}
	return memo[n] = fib(n - 1) + fib(n - 2);
}
int main() {
	int n;

	cin >> n;

	cout << fib(n) << endl;

	return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>

double minget(int N, double *v){
  double min = 1001;
  for(int i = 0; i < N; i++){
    if(min > v[i]){
      min = v[i];
    }
  }
  return min;
}

double *change(int N, double *v){
  double min = 1001;
  int flag = 0;
  for(int i = 0; i < N; i++){
    if(min > v[i]){
      min = v[i];
      flag = i;
    }
  }
  v[flag] = 1001;
  return v;
}

int main(){
  int N;
  scanf("%d", &N);
  double *v = malloc(sizeof(double) * N);
  for(int i = 0; i < N; i++){
    scanf("%lf", &v[i]);
  }
  
  double ans = minget(N, v);
  v = change(N, v);
  
  for(int i = 0; i < N-1; i++){
    ans = (ans + minget(N,v)) / 2;
    v = change(N, v);
  }
  
  printf("%lf", ans);
  
  return 0;
}

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

int main() {
	int N, counter=0;
	cin>>N;
	for(int i=1;i<=N;i++)
	{
		if(i%2) counter++;
	}
	cout<<setprecision(9)<<counter/(double)N<<'\n';
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {
    string s, t;
    cin >> s >> t;
    int count = 0;
    REP(i, 3) if (s[i] == t[i]) count++;
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
main(void) {
	char a, b, c, x, y, z;
	int joi=0, ioi=0,i=0;
	while(scanf("%c%c%c", &a, &b, &c) != EOF) {
		for(;;) {
			if(b == c && y == z) scanf("%c", &c);
			if(c == '\n') break;
			x=a;
			y=b;
			z=c;
			if(a == 'J' && b == 'O' && c == 'I') joi++;
			a=b;
			b=c;
			if(x == 'I' && y == 'O' && z == 'I') ioi++;
			x=y;
			y=z;
		}
		printf("%d\n%d\n", joi, ioi);
		joi = ioi = 0;
	}
return 0;
}


Measured memory_bytes: 1976
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

#define for1(n) for (int i = 0 ; i < n ; i++)
#define for2(n) for (int j = 0 ; j < n ; j++)
#define for3(n) for (int k = 0 ; k < n ; k++)
#define for4(n) for (int l = 0 ; l < n ; l++)
#define forl(n) for (ll i = 0 ; i < n ; i++)

int main() {
    ios::sync_with_stdio(false);
    int n, b = 0;
    cin >> n;
    int a[n];
    for1(n) {
		cin >> a[n];
	    b += a[n];
	}
	cout << b - n;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

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

    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    debug(a);
    vector<int> ans(n);
    rep(i, n) {
        vector<P> tmp;
        rep(j, n-i) {
            if (a[j]-j==1) tmp.emplace_back(a[j], j);
        }
        if (tmp.empty()) {
            cout << -1 << endl;
            return 0;
        }
        sort(tmp.rbegin(), tmp.rend());
        ans[i] = tmp.front().fi;
        a.erase(a.begin()+tmp.front().se);
        debug(ans);
        debug(a);
    }
    reverse(all(ans));
    rep(i, n) cout << ans[i] << endl;
}

Measured memory_bytes: 256
//
//
#include <iostream>
#include <vector>

using namespace std;

int nibo(int, vector<int>);

int main(void) {
	int n;
	vector<int> ans;

	while(true) {	
		cin >> n;
		if (n == 0) {
			break;
		}
		vector<int> data(n + 1 , 0);
		for (int i = 0; i < n + 1; i++) {
			cin >> data[i]; 
		}
		cout << nibo(n, data) << endl;
	}
       
	return 0;

}

int nibo(int n, vector<int> data) {
	int times = 0;
	int right = n - 1;
	int left = 0;
	int mid;
	int target = data[n];
	while((right - left) >= 0) {
		times++;
		mid = (right + left) / 2;
		if (data[mid] == target) {
			break;
		}
		if (data[mid] < target) {
			left = mid + 1;
		}
		if (data[mid] > target) {
			right = mid - 1;
		}
	}
	return times;
}

Measured memory_bytes: 1208
class UnionFind():
    """
    UnionFindTreeのクラス
    
    Attributes:
    n: int: ノード数
    parents: そのノードが属する木の根を格納, 根の場合は-1

    """
    def __init__(self, n):
        """ノード数nで初期化"""
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        """ノードxが属するグループの根を返す"""
        if self.parents[x] < 0:
            return x
        else:
            #経路圧縮
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        """xが属するグループとyが属するグループを併合"""
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        """xが属するグループの要素数を返す"""
        return -self.parents[self.find(x)]

    def same(self, x, y):
        """x, yが同じグループに属するかどうかを返す"""
        return self.find(x) == self.find(y)

    def members(self, x):
        """xが属するグループ内の要素をリストで返す"""
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        """全ての根に対する要素をリストで返す"""
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        """グループの総数を返す"""
        return len(self.roots())

    def all_group_members(self):
        """{root: [そのグループの要素リスト]}の辞書を返す"""
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        """printデバッグ用. root: [要素リスト]をstrで返す"""
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    
N, M = map(int, input().split())
from collections import defaultdict
E = []
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    E.append((a, b))

ans = 0
for bri in range(M):
    uf = UnionFind(N)
    for e in range(M):
        if e == bri:
            continue
        uf.union(*E[e])

    if uf.group_count() != 1:
        ans += 1
print(ans)

Measured memory_bytes: 67936
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>pii;
typedef vector<pii>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n 
#define pl(n) cout<<n<<" "
const int Nx=1e5+2;
const int inf=(int)(1e9+10LL);
void subsetsUtil(vector<int>& A, vector<vector<int> >& res, 
                 vector<int>& subset, int index) 
{ 
    res.push_back(subset); 
    for (int i = index; i < A.size(); i++) { 
        subset.push_back(A[i]); 
        subsetsUtil(A, res, subset, i + 1); 
        subset.pop_back(); 
    } 
  
    return; 
} 
vector<vector<int> > subsets(vector<int>& A) 
{ 
    vector<int> subset; 
    vector<vector<int> > res; 
    int index = 0; 
    subsetsUtil(A, res, subset, index); 
  
    return res; 
} 
void solve()
{
 int n,m,x;
 sl(n);sl(m);sl(x);
 int arr[n+1][m+1];
 vector<int>X(n);
 for(int i=0;i<n;i++)X[i]=i+1;
 vector<vector<int>>ans=subsets(X);
 int price[n+1];
 for(int i=1;i<=n;i++){
 	sl(price[i]);
 	for(int j=1;j<=m;j++){
 		sl(arr[i][j]);
 	}
 }
 int maxprice=inf;
 Vl algo(m+1,0);
 for(auto vec:ans){
 	int cst=0;
 	for(auto it:vec){
 	  cst+=price[it];
 	  for(int i=1;i<=m;i++){
 	    algo[i]+=arr[it][i];	
 	  }	
 		
 	}
 	bool check=true;
 	for(int i=1;i<=m;i++){
 		if(algo[i]>=x)continue;
 		check=false;
 	}
 	if(check)maxprice=min(maxprice,cst);
 	for(int i=1;i<=m;i++)algo[i]=0;
 	
 }
 maxprice=(maxprice==inf)?-1:maxprice;
 cout<<maxprice<<endl;

}

signed main(){
  int test=1;
// sl(test);
 while(test--){
 	solve();
 }
 
}

Measured memory_bytes: 3972
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

LL mod(LL x, LL md) {
	return ((x % md) + md) % md;
}

class Mint {
public:
	static LL md;
	LL x;
	Mint(LL _x) {
		x = mod(_x, md);
	}
	Mint(const Mint &y) {
		x = mod(y.x, md);
	}
};

void MintMyExgcd(LL a, LL b, LL &x, LL &y) {
	// solve equation ax + by = 1 (mod m)
	LL md = Mint::md;
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	}
	MintMyExgcd(b, a % b, x, y);
	LL t = y;
	y = mod(x - (a / b) * y, md);
	x = t;
}

LL MintNY(LL x) {
	if (x == 0) {
		return 1;
	}
	LL md = Mint::md;
	LL a, b;
	MintMyExgcd(x, md, a, b);
	while (a < 0) {
		a += md;
	}
	return a;
}

/* LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
} */

Mint operator+(Mint a, Mint b) {
	return Mint(mod(a.x + b.x, Mint::md));
}
Mint operator-(Mint a, Mint b) {
	return Mint(mod(a.x - b.x, Mint::md));
}
Mint operator*(Mint a, Mint b) {
	return Mint(mod(a.x * b.x, Mint::md));
}
Mint operator/(Mint a, Mint b) {
	Mint c = Mint(MintNY(b.x));
	return Mint(mod(a.x * c.x, Mint::md));
}

Mint operator-(Mint a) {
	return Mint(-a.x);
}
bool operator==(Mint a, Mint b) {
	return a.x == b.x;
}
bool operator!=(Mint a, Mint b) {
	return a.x != b.x;
}
bool operator>(Mint a, Mint b) {
	return a.x > b.x;
}
bool operator<(Mint a, Mint b) {
	return a.x < b.x;
}
bool operator>=(Mint a, Mint b) {
	return a.x >= b.x;
}
bool operator<=(Mint a, Mint b) {
	return a.x <= b.x;
}

void operator+=(Mint &a, Mint b) {
	a = a + b;
}
void operator-=(Mint &a, Mint b) {
	a = a - b;
}
void operator*=(Mint &a, Mint b) {
	a = a * b;
}
void operator/=(Mint &a, Mint b) {
	a = a / b;
}

ostream& operator<<(ostream &out, Mint a) {
	out << a.x;
	return out;
}

istream& operator>>(istream &in, Mint &a) {
	in >> a.x;
	return in;
}

Mint factorial(LL n) {
	if (n == 0) {
		return Mint(1);
	}
	Mint res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
	}
	return res;
}
Mint multiRange(LL s, LL t) {
	Mint res = 1;
	for (LL i = s; i <= t; ++i) {
		res *= i;
	}
	return res;
}

Mint getC(LL n, LL k) {
	if (n - k < k) {
		return getC(n, n - k);
	}
	return multiRange(n - k + 1, n) / factorial(k);
}

Mint getA(LL n, LL k) {
	return multiRange(n - k + 1, n);
}

Mint countNonNegativeDivision(LL n, LL k) {
	return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(LL n, LL k) {
	if (n < k) {
		return 0;
	}
	if (k <= 0) {
		return 0;
	}
	return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, LL b) {
	Mint res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
		}
		a *= a;
		b /= 2;
	}
	return res;
}

LL Mint::md = 1000000007;

int main() {
	string s;
	cin >> s;
	if (s == "ABC") {
		cout << "ARC" << endl;
	} else {
		cout << "ABC" << endl;
	}
	return 0;
}

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

int main(){
  int n,i,ans,sum;
  string s;
  cin >> n >> s;
  sum=0;
  for(i=0;i<n;i++){
    if(s.at(i)=='E'){
      sum++;
    }
  }
  
  ans=sum;
  for(i=0;i<n;i++){
    if(s.at(i)=='E'){
      sum--;
    }else{
      sum++;
    }
    ans=min(ans,sum);
  }
  
  cout << ans << endl;
}

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

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


Measured memory_bytes: 3652
<?php

    // 標準入力を配列化して取得する
    function get_input() {
        $input = [];
        while ($line = fgets(STDIN)) {
            $input[] = trim($line);
        }
        return $input;
    }

    // 末尾に改行をつけて出力
    function output($str) {
        echo $str . PHP_EOL;
    }

    $input = get_input();

    $sheet = [
        explode(' ', $input[0]),
        explode(' ', $input[1]),
        explode(' ', $input[2]),
    ];

    $hit = [
        [false, false, false],
        [false, false, false],
        [false, false, false]
    ];

    for ($i = 4; $i < count($input); $i++) {
        for ($j = 0; $j < 3; $j++) {
            for ($k = 0; $k < 3; $k++) {
                if ($input[$i] == $sheet[$j][$k]) {
                    $hit[$j][$k] = true;
                }
            }
        }
    }

    $bingo = 'No';
    for ($i = 0; $i < 3; $i++) {
        if ($hit[$i][0] and $hit[$i][1] and $hit[$i][2]) {
            $bingo = 'Yes';
        }
        if ($hit[0][$i] and $hit[1][$i] and $hit[2][$i]) {
            $bingo = 'Yes';
        }
    }
    if ($hit[0][0] and $hit[1][1] and $hit[2][2]) {
        $bingo = 'Yes';
    }
    if ($hit[0][2] and $hit[1][1] and $hit[2][0]) {
        $bingo = 'Yes';
    }

    output($bingo);


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

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

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

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

using namespace std;

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

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

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

// Problem Specific Parameter:

string s;
ll dp[20][20][2][2];

int total = 0;
int table[20][10];
string node[20];

int main(void) {
	cin >> s;
	const int n = s.size();

	node[total++] = "";
	node[total++] = "5";
	node[total++] = "51";

	rep(d, 10) {
		string cur = to_string(510 + d);
		node[total++] = cur;
	}

	rep(i, total) {
		rep(d, 10) {
			if (node[i].size() == 3 and d == 3) {
				table[i][d] = total;
				continue;
			}

			string nxt = node[i] + string(1, char(d + '0'));
			const int m = nxt.size();

			bool ok = false;
			rrep(len, m + 1) {
				string tmp = nxt.substr(m - len, len);
				rep(j, total) {
					if (ok) break;
					if (tmp == node[j]) {
						table[i][d] = j;
						ok = true;
					}
				}
			}
		}
	}

	rep(d, 10) table[total][d] = total;

	/*
	rep(i, total + 1) {
		cerr << node[i] << " : ";
		rep(j, 10) cerr << table[i][j] << " ";
		cerr << endl;
	}
	*/



	dp[0][0][0][0] = 1LL;
	rep(i, n)rep(st, total + 1)rep(nz, 2)rep(le, 2) {
		if (dp[i][st][nz][le] == 0) continue;
		rep(d, 10) {
			const int ni = i + 1;
			const int nst = table[st][d];

			const int nnz = nz || (d != 0);

			int nle = le;
			if (le == 0 and d > (s[i] - '0')) continue;
			if (le == 0 and d < (s[i] - '0')) nle = 1;

			dp[ni][nst][nnz][nle] += dp[i][st][nz][le];
		}
	}

	ll ans = dp[n][total][1][0] + dp[n][total][1][1];
	cout << ans << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);

    long n, k;

    cin >> n >> k;

    ll x[n];
    ll left, right;
    ll ans = LLONG_MAX;
    ll pivot;

    long i, len = n - k + 1;

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

    rep(i, len) {
        left = min(x[i], 0LL);
        right = max(0LL, x[i + k - 1]);

        pivot = min(Abs(left), Abs(right));

        Min(ans, right - left + pivot);
    }

    Out(ans);

    return 0;
}


Measured memory_bytes: 1024
s=list(map(int,list(input())))

for i in range(8):
    sum=s[0]
    marks=[]
    for k in range(3):
        if 1&(i>>k):
            sum+=s[k+1]
            marks.append('+')
        else:
            sum-=s[k+1]
            marks.append('-')
    if sum==7:
        for l in range(3):
            print('{}{}'.format(s[l],marks[l]),end='')
        print('{}=7'.format(s[3]))
        exit()


Measured memory_bytes: 3064
n = gets.chomp.to_i
a = gets.chomp.split(/ /).map(&:to_i)

i = 1
if a.any?(&:zero?)
  puts 0
else
  a.each do |element|
    i *= element

    if i > 10 ** 18
      i = -1
      break
    end
  end

  puts i
end


Measured memory_bytes: 23504
#include <iostream>
#include <cstdlib>

int calcDigitSum(int n) {
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  char s[100];
  std::cin >> s;
  const int N = atoi(s);
  std::cin >> s;
  const int MIN = atoi(s);
  std::cin >> s;
  const int MAX = atoi(s);
  
  int sum = 0;
  for(int i = 1; i <= N; i++) {
    int s = calcDigitSum(i);
    if(MIN <= s && s <= MAX)
      sum += i;
  }
  std::cout<<sum<<std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
  
  int n;
  cin >> n;
  
  map<string, int> m;
  
  for (int i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    
    m[s] += 1;
  }
  
  int max = 0;
  
  map<string, int>::iterator iter;
  
  for (iter = m.begin(); iter != m.end(); iter++)
  {
    int v = iter->second;
    if(v > max)
    {
      max = v;
    }
  }
  
  for (iter = m.begin(); iter != m.end(); iter++)
  {
    if(iter->second == max)
    {
      cout << iter->first << endl;
    }
  }
  
	return 0;
}

Measured memory_bytes: 25216
N, K = map(int, input().split())
D = K.bit_length()
to = [[0] * D for _ in range(N)]

for i, a in enumerate(map(int, input().split())):
    to[i][0] = a - 1

for j in range(D - 1):
    for i in range(N):
        to[i][j+1] = to[to[i][j]][j]

v = 0
for i in reversed(range(D)):
    if (K >> i) & 1:
        v = to[v][i]

print(v + 1)

Measured memory_bytes: 207408
from collections import Counter
n = int(input())
A = Counter(map(int, input().split()))
A[0] = 2
mod = 10 ** 9 + 7


def n_power_m_mod(n, m, mod):
    ret = 1
    for _ in range(m):
        ret *= n
        ret %= mod
    return ret


if all(v == 2 for v in A.values()):
    print(n_power_m_mod(2, n//2, mod))
else:
    print(0)

Measured memory_bytes: 16620
package main

import "fmt"

var N, K int

func main() {
	fmt.Scan(&N, &K)
	ComInit(N+1)
	ans := 0
	for i := K; i<=N+1; i++ {
		ans = Madd(ans+1, Mmul(i, N-i+1))
	}
	fmt.Println(ans)
}

var fac, finv []int

func ComInit(N int) { comInit(N, MOD) }
func comInit(N int, mod int) {
	fac = make([]int, N+1)
	finv = make([]int, N+1)
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1

	for i := 2; i <= N; i++ {
		fac[i] = mmul(fac[i-1], i, mod)
		finv[i] = mmul(finv[i-1], minv(i, mod), mod)
	}
}

func Com(n, k int) int { return com(n, k, MOD) }
func com(n, k, mod int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return mmul(fac[n], mmul(finv[k], finv[n-k], mod), mod)
}

const MOD = 1000000007

func Madd(a, b int) int { return madd(a, b, MOD) }
func madd(a, b, mod int) int {
	if a+b > mod {
		return a + b - mod
	}
	return a + b
}

func Msub(a, b int) int { return msub(a, b, MOD) }
func msub(a, b, mod int) int {
	if a-b < 0 {
		return a - b + mod
	}
	return a - b
}

func Mmul(a, b int) int { return mmul(a, b, MOD) }
func mmul(a, b, mod int) int {
	return ((a % mod) * (b % mod)) % mod
}

func Mpow(a, b int) int { return mpow(a, b, MOD) }
func mpow(k, p, mod int) int {
	r := 1
	for ; p > 0; p >>= 1 {
		if p&1 == 1 {
			r = mmul(r, k, mod)
		}
		k = mmul(k, k, mod)
	}
	return r
}

func Minv(a int) int { return minv(a, MOD) }
func minv(a, mod int) int {
	b := mod
	u, v := 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= mod
	if u < 0 {
		u += mod
	}
	return u
}

func Mdiv(a, b int) int { return mdiv(a, b, MOD) }
func mdiv(a, b, mod int) int {
	return mmul(a, minv(b, mod), mod)
}


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

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,lessl<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define int long long
#define double long double

#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()

#define ff first
#define ss second
#define mp make_pair

#define pb push_back
#define endl "\n"

#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)

#define bp __builtin_popcountll
#define inf 1e18

const int N=2e3+5;
const int M=1e9+7;
void solve()
{
	int n,m,k;
	cin>>n>>m>>k;
	map<int,int> r,w;
	map<pair<int,int>,int> mm;
	vector<pair<int,int>> v(k);
	int ans=0;
	int rm=0,wm=0;
	for(int i=0;i<k;i++)
	{
		int t1,t2;
		cin>>t1>>t2;
		v[i].ff=t1;
		v[i].ss=t2;
		r[t1]++;
		w[t2]++;
		mm[mp(t1,t2)]++;
		rm=max(rm,r[t1]);
		wm=max(wm,w[t2]);
	}
	ans=rm+wm-1;
	
	for(int i=0;i<=n;i++)
	{
		if(r.find(i)!=r.end())
		{
			if(r[i]!=rm)
			{
				r.erase(r.find(i));
			}
		}
	}
	for(int i=0;i<=m;i++)
	{
		if(w.find(i)!=w.end())
		{
			if(w[i]!=wm)
			{
				w.erase(w.find(i));
			}
		}
	}
	for(auto X:r)
	{
		int tar=X.ff;
		if(X.ss==rm)
		{
			for(auto jj:w)
			{
				int j=jj.ff;
				if(jj.ss==wm && mm.find(mp(tar,j))==mm.end())
				{
					ans++;
					cout<<ans<<endl;
					return;
				}
			}
		}
	}
	cout<<ans<<endl;
	
}

signed main()
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}


Measured memory_bytes: 64144
#include <bits/stdc++.h>
using namespace std;
static const int WHITE = 0;
static const int GRAY  = 1;
static const int BLACK = 2;
static const int N     = 100;

int n, tt;
vector<vector<int>> M(N, vector<int>(N));
vector<int> color(N), d(N), f(N);

void dfs_visit(int u) {
  color[u] = GRAY;
  d[u]     = ++tt;
  for (int v = 0; v < n; v++) {
    if (M[u][v] == 0) continue;
    if (color[v] == WHITE) { dfs_visit(v); }
  }
  color[u] = BLACK;
  f[u]     = ++tt;
}

void dfs() {
  tt = 0;

  for (int u = 0; u < n; u++) {
    if (color[u] == WHITE) dfs_visit(u);
  }
  for (int u = 0; u < n; u++) {
    printf("%d %d %d\n", u + 1, d[u], f[u]);
  }
}

int main() {
  int u, v, k;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; j++) {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  dfs();
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int a[]=new int[n+1];
		for(int i=0;i<2*m;i++) {
			a[sc.nextInt()]++;
		}
		
		for(int i=1;i<=n;i++) {
			System.out.println(a[i]);
		}
		
	}
}


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

int n;
int a[100000];
int cnt[3];

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	for (i = 0; i < n; i++) {
		int x = 0;
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			x++;
		}
		if (x > 2) x = 2;
		cnt[x]++;
	}
	
	if (cnt[0] <= cnt[2] || (cnt[0] == cnt[2] + 1 && cnt[1] == 0)) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}

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

#define ran 55

int n, m, q;
int a[ran], b[ran], diff[ran], score[ran];
int v[ran];
int ans;

void dfs(int id, int lo) {
	if(id>n) {
		int res = 0;
		for(int i=0;i<q;i++)
			if(v[b[i]] - v[a[i]] == diff[i])
				res += score[i];
			
		ans = max(ans, res);
		return;
	}
	
	for(int i=lo; i<=m; i++) {
		v[id] = i;
		dfs(id+1, i);
	}
}

int main() {
	scanf("%d%d%d", &n, &m, &q);
	for(int i=0;i<q;i++)
		scanf("%d%d%d%d", &a[i], &b[i], &diff[i], &score[i]);
	
	ans = 0;
	dfs(1, 1);
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 3668
#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(){
  int N;cin>>N;
  int A[2][N];rep(i,2)rep(j,N)cin>>A[i][j];
  ll ans=0;
  rep(i,N){
    ll tmp=0;
    for(int j=0;j<=i;++j) tmp+=A[0][j];
    for(int k=i;k<N;++k) tmp+=A[1][k];
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long N, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        int eat = A[i];
        ans += B[eat-1];
    }
    
    for (int i = 1; i < N; i++)
    {
        if(A[i] - A[i-1] == 1){
            ans += C[A[i-1]-1];
        }
    }  
    cout << ans << endl;
    
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    std::vector<long long> C(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&C[i]);
    }
    solve(N, std::move(A), std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 256
import scala.io.Source.stdin

object Main extends App {
  stdin.getLines.foreach { s =>
    val n = s.split(" ").map(_.toDouble)
    if( n(4) > n(2) || n(6) < n(0) || n(5) > n(3) || n(7) < n(1) ) println("NO") else println("YES")
  }
}

Measured memory_bytes: 44160
// Author : MohamedSameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
void fo (){fflush(stdout);}
using namespace std;
int n , h , mx ;
ll ans ;
vector <int>  a ;
int main ()
{
scanf ("%d%d" , &n ,&h );
for (int i =0 ; i < n ;i++)
{
  int u , v ;
  scanf ("%d%d" , &u  , &v );
  a.pb(v);
  mx = max (mx , u );
}
sort(all(a));
for (int i = n-1 ; i >= 0 ; i--)
{
  if (h <= 0 )break;
  if (a[i] >= mx )
  {
    ans++;
    h-=a[i];
  }
}
if (h > 0 )ans += h / mx + ( h %mx != 0);
printf ("%lld\n" ,ans );



  //cerr << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}


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

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

  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  vector<ll> lsum(n, 0), rsum(n, 0);
  lsum[0] = a[0];
  rsum[n - 1] = a[n - 1];
  for (int i = 1; i < n; i++) {
    lsum[i] = lsum[i - 1] + a[i];
    rsum[n - 1 - i] = rsum[n - 1 - (i - 1)] + a[n - 1 - i];
  }

  ll ans = -1;
  for (int i = 0; i < n - 1; i++) {
    ll t = abs(lsum[i] - rsum[i + 1]);
    if (ans == -1) {
      ans = t;
    } else {
      ans = min(ans, t);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4992
/*
	Name: Prathamesh Shendarkar
	My Motto: IS TO NEVER GIVE UP
	My Belief: If you are not able to solve a particular question don't copy and paste a solution, 
			   no one is going to look into your account and tell you that, oh my look he has solved so many questions, 
			   remeber you are cheating on yourself, Just try to solve that question after some time or some days, 
			   or look upon a solution and check for the intiution or approach they have used, 
			   But never mug up there solution. 
			   Go for Learning don't copy plz.
*/

#include<bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define len(s) s.length()
#define loopa(i,a,b) for( i=a;i<=b;i++)
#define loop(i,n)    for( i=0;i<n;i++)
#define pool(i,n)    for( i=n-1;i>=0;i--)
#define poop(i,a,b) for( i=a;i>=b;i--)
#define on cout<<endl
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define all(v) v.begin(),v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ret return 0
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100001
#define SIZ 1000001
#define SIZE 200001

typedef long long  ll;
typedef long double  ldo;
typedef double  db ;
using namespace std;

ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}

//ll exp(ll x,ll y){ 
//	ll res=1;
//	x=x%mod;
//	while(y>0) 
//	{ 
//		if(y&1) 
//			res=(res*x)%mod; 
//		y = y>>1;
//		x=(x*x)%mod; 
//	} 
//	return res; 
//} 

ll check_prime(ll n){
	for(ll i = 2;i<=ceil(sqrt(n));i++){
		if(n%i == 0){
			return 0;
		}
	}
	return 1;
}

bool check_princi(vector<ll> v){
	ll n = v.size();
	for(ll i = 1;i<n - 1;i++){
		if(v[i - 1] + v[i + 1] < v[i]){
			return false;
		}
	}
	return true;
}

int main(){
    fastio;
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	ll cp1 = b,cp2 = d;
	while(a > 0 && c > 0){
		c = c - cp1;
		if(c <= 0)
			break;
		a = a - cp2;
		if(a <= 0)
			break;
//		cout << c << " " << a << "\n";
	}
	if(a <= 0)
		cout << "No" << "\n";
	else
		cout << "Yes" << "\n";
    
}




Measured memory_bytes: 3668
N,S=int(input()),input()
r,g,b=0,0,0
for i in list(S):
    if i=='R':r+=1
    if i=='G':g+=1
    if i=='B':b+=1
ans=r*g*b
for i in range(N-2):
    for j in range(i+1,N-1):
        if j-i>N-j-1:break
        if S[i]!=S[j]and S[j]!=S[2*j-i]and S[2*j-i]!=S[i]:
            ans-=1
print(ans)

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

int main() {
    ll n, m;
    cin >> n >> m;

    vector<ll> x(n),y(m);
    ll xsum = 0, ysum = 0;

    REP(i, n) cin >> x[i];
    sort(all(x));
    REP(i, n - 1) addM(xsum, (x[i+1] - x[i])*(i + 1)*(n - i - 1));
       

    REP(i, m) cin >> y[i];
    sort(all(y));
    REP(i, m - 1) addM(ysum, (y[i+1] - y[i])*(i + 1)*(m - i - 1));

    mulM(xsum,ysum);    

    cout << xsum << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    rep(i, 3) {
        if(s[i] == '1') {
            s[i] = '9';
        }
        else if(s[i] == '9') {
            s[i] = '1';
        }
    }

    out(s);
    re0;
}

Measured memory_bytes: 256
import collections

N = int(input())
A_list = list(map(int, input().split()))
A_count_list = collections.Counter(A_list)
A_sum = sum(A_list)
Q = int(input())
for _ in range(Q):
    B, C = map(int, input().split())
    A_sum += (C - B)*A_count_list[B]
    A_count_list[C] += A_count_list[B]
    A_count_list[B] = 0
    print(A_sum)

Measured memory_bytes: 23972
#include<bits/stdc++.h>
#define ll long long 
#define inf 0x3f
#define INF 0x3f3f3f3f
#define fi first
#define se second 
#define mp make_pair
#define pa pair<int,int>

using namespace std;

inline ll read()
{
	ll sum=0,f=1;char c=getchar();
	while (!isdigit(c)) {if (c=='-') f=-1;c=getchar();}
	while (isdigit(c)) {sum=sum*10+c-'0';c=getchar();}
	return sum*f;
}
int d[5],num[5];
int main()
{
	for (int i=1;i<=3;i++)
	{
		int u=read(),v=read();
		d[u]++,d[v]++;
	} 
	bool flag=true;
	for (int i=1;i<=4;i++)
		num[d[i]]++;
	if (num[0] || num[3]) flag=false;
	if (num[1]>=3) flag=false;
	if (!flag) cout<<"NO";
	else cout<<"YES";
	return 0;
}

Measured memory_bytes: 256
/*

	Raghul
	
*/	
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
	  ll n,a,b;
	  ll x = 0, y = 0, z = 0;
	  cin>>n>>a>>b;
	  ll t;
	  for(int i=0;i<n;i++){
	  	cin>>t;
	  	if(t<=a)	x++;
	  	else if(t>b)	z++;
	  	else			y++;
	  }
	  cout<<min(x,min(y,z));
}
int main(){
	int T;
	T = 1;
	while(T--){
		solve();
	}
	return 0;
}
/*}
int main(){
	int T;
	T = 1;
	while(T--){
		solve();
	}
	return 0;
}*/

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	int cnt[10][10];
	for (int i = 0; i < 10; i++){
		for (int j = 0; j < 10; j++) cnt[i][j] = 0;
	}
	for (int i = 1; i <= n; i++){
		string s = to_string(i);
		int front = (int)(s[0]-'0');
		int back = (int)(s[s.size()-1]-'0');
		cnt[front][back]++;
	}

	long long res = 0;
	for (int i = 0; i < 10; i++){
		for (int j = 0; j < 10; j++){
			res += (cnt[i][j] * cnt[j][i]);
		}
	}

	cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

    int H, W, N;
	cin >> H >> W >> N;
	map<P, int> mp1, mp2;
	P p[N];
	rep(i,N){
		int a, b;
		cin >> a >> b;
		p[i] = P(a, b);
		mp1[P(a,b)]++;
	}
	int ans[10]{};
	ans[0] = (H-2)*(W-2);
	rep(i,N){
		int y = p[i].second;
		int x = p[i].first;
		for(int i=-1;i<=1;i++){
			for(int j=-1;j<=1;j++){
				int nx = x+i, ny = y+j;
				if(nx <= 1 || nx >= H) continue;
				if(ny <= 1 || ny >= W) continue;
				if(mp2[P(nx, ny)] > 0) continue;
				int cnt = 0;
				for(int k=-1;k<=1;k++){
					for(int l=-1;l<=1;l++){
						if(mp1[P(nx+k, ny+l)]) ++cnt;
					}
				}
				ans[cnt]++;
				ans[0]--;
                mp2[P(nx,ny)] = cnt;
			}
		}
	}
	rep(i,10){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 214272
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;

int n,k;
vector<int> E[2010];

int dfs(int x,int p,int d,int mx){
    int ans=1;
    if(d !=mx){
        for(int y:E[x]){
            if(y==p) continue;
            ans +=dfs(y,x,d+1,mx);
        }
    }
    return ans;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>k;
    rep(i,n-1){
        int a,b;
        cin >>a>>b;
        E[a].pb(b);
        E[b].pb(a);
    }
    int ans=0;
    if(k%2==0){
        for(int v=1;v<=n;v++){
            ans=max(ans,dfs(v,-1,0,k/2));
        }
    }
    else{
        for(int v=1;v<=n;v++){
            for(int u : E[v]){
                ans=max(ans,dfs(v,u,0,k/2)+dfs(u,v,0,k/2));
            }
        }
    }
    cout<<n-ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip> 
#include <bits/stdc++.h>
using namespace std;
double pi=3.14159265358979323846264338;
const int MOD=1000000007;
int arr[1001];
int main() {
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>arr[i];
	sort(arr,arr+n);
	int ans=0;
	for(int i=0;i<k;i++)ans+=arr[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3588
N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]
 
from itertools import permutations
from math import sqrt
 
paths = list(permutations(range(N), N))
l = len(paths)
total = 0
for path in paths:
    tmp = 0
    x, y = xy[path[0]][0], xy[path[0]][1]
    for p in path[1:]:
        px, py = xy[p][0], xy[p][1]
        tmp += sqrt((px-x)**2 + (py-y)**2)
    total += tmp
print(total / l)

Measured memory_bytes: 80292