akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include <stdio.h>
#include <time.h>
#include <queue>
using namespace std;
int main(){
    int n;
    cin>>n;
    int x;
    int c1=0,c2=0,c3=0;
    for(int i=0;i<n;i++){
      cin>>x;
      if(x%4==0) c1++;
      else if(x%2==0) c2++;
      else c3++;
    }
    if(c2) c2=1;
    if(c1+1>=c3+c2) cout<<"Yes";
    else cout<<"No";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int n;
double pi = acos(-1);
void koch(double xl, double yl, double xr, double yr, int depth) {
    if(depth == n) {
        printf("%.8lf %.8lf\n", xr, yr);
        return;
    }
    double px =(xr-xl)/3+xl, py = (yr-yl)/3+yl;
    double qx =(xr-xl)*2/3+xl, qy = (yr-yl)*2/3+yl;
    double len = sqrt(pow(xr-xl,2.0) + pow(yr-yl,2.0))/3.0;
    double rad = atan2(yr-yl,xr-xl);
    koch(xl,yl,px,py,depth+1);
    koch(px,py,len*cos((pi/3)+rad)+px,len*sin((pi/3)+rad)+py,depth+1);
    koch(len*cos((pi/3)+rad)+px,len*sin((pi/3)+rad)+py,qx,qy,depth+1);
    koch(qx,qy,xr,yr,depth+1);
}
int main() {
    cin >> n;
    printf("%.8lf %.8lf\n",0,0);
    koch(0,0,100,0,0);
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,sum=0;
    cin>>n>>m;
    int a[m];
    for(int i = 0;i<m;i++)
    {
      cin>>a[i];
      sum=sum+a[i];
    }
    
    if(sum>n)
    cout<<"-1"<<endl;
    else
    cout<<n-sum<<endl;
    
}

Measured memory_bytes: 3652
#include <stdio.h>
#define maxn 1000010
char mp[maxn],line[maxn];
int d[maxn],r1,c1,r2,c2,H,W,K,next[][2]={{-1,0},{1,0},{0,-1},{0,1}},in[maxn];
struct node{
	int r,c;
}q[maxn*10];
int main(){
	int i,j,h,t,r,c,nr,nc,p,np;
	scanf("%d%d%d",&H,&W,&K);
	scanf("%d%d%d%d",&r1,&c1,&r2,&c2),r1--,c1--,r2--,c2--;
	for(i=0;i<H;i++){
		scanf("%s",line);
		for(j=0;j<W;j++)mp[i*W+j]=line[j];
	}
	for(i=0;i<H;i++)
		for(j=0;j<W;j++)d[i*W+j]=maxn;
	d[r1*W+c1]=0,h=t=1,q[t].r=r1,q[t].c=c1,t++,in[r1*W+c1]=1;
	while(h<t){
		r=q[h].r,c=q[h].c,in[r*W+c]=0;
		if(r==r2&&c==c2)return 0*printf("%d\n",d[r*W+c]);
		for(i=0;i<4;i++)
			for(j=1;j<=K;j++){
				nr=r+next[i][0]*j,nc=c+next[i][1]*j;
				if(0<=nr&&nr<H&&0<=nc&&nc<W){
					p=r*W+c,np=nr*W+nc;
					if(mp[np]=='@'||d[np]<=d[p])break;
					if(d[np]>=d[p]+1){
						d[np]=d[p]+1;
						if(!in[np])q[t].r=nr,q[t].c=nc,t++,in[np]=1;
					}
				}else break;
			}
		h++;
	}
	printf("-1\n");
	return 0;
}

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

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

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	if((b-a-1)%2==1){
  		cout << "Alice" << endl;
    }else{
      cout << "Borys" << endl;
    }
}


Measured memory_bytes: 256
class Heap:
    def __init__(self, a = []):
        self.h = a
        self.n = len(a)
# 接点の添字iが与えられた時、その親、左の子、右の子の添字はそれぞれi//2, 2i, 2i+1
# ヒープの添字は1-indexed
    def parent(self, i): # 添字をもらって、その親の添字
        return i // 2
    def left(self, i):
        return i * 2
    def right(self, i):
        return i * 2 + 1
    def max_heapify(self, i):
        l = self.left(i)
        r = self.right(i)
# 左の子、自分、右の子で値が最大のノードを選ぶ
        if l <= self.n and self.h[l-1] > self.h[i-1]:
            largest = l
        else:
            largest = i
        if r <= self.n and self.h[r-1] > self.h[largest-1]:
            largest = r
        if largest != i: # 子の方が値が大きい場合
            self.h[i-1], self.h[largest-1] = self.h[largest-1], self.h[i-1]
            self.max_heapify(largest)
    def build_max_heap(self):
        for i in range((self.n // 2), 0, -1):
            self.max_heapify(i)

heap = Heap()
heap.n = int(input())
heap.h = list(map(int, input().split()))
heap.build_max_heap()
print("", *heap.h)


Measured memory_bytes: 63972
#include <iostream>
#define llint long long

using namespace std;

int N, P;
int odd;

int main(void)
{
	cin >> N >> P;
	int a;
	for(int i = 0; i < N; i++){
		cin >> a;
		if(a % 2) odd++;
	}
	
	if(odd == 0){
		if(P == 1) cout << 0 << endl;
		else cout << ((llint)1 << N) << endl;
	}
	else cout << ((llint)1 << (N-1)) << endl;
	return 0;
}

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

int main(){
    int N,A,B;
    cin>>N>>A>>B;
    int sum=0;
    int n=0;
    int total=0;
    for(int i=1;i<=N;i++){
        n=i;
        while(n>0){
            sum+=n%10;
            n/=10;
        }
        if(sum>=A&&sum<=B){
            total+=i;
        }
        sum=0;
    }
    cout<<total<<endl;
}

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

int main(){
  int N, cnt1=0, cnt=0, fin=0;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  while(fin==0){
  	for(int i=0; i<N; i++){
    	if (A.at(i) % 2 == 0){
      		cnt1+=1;
    	}
  	}
  	if (cnt1==N){
    	cnt+=1;
      	for(int i=0; i<N; i++){
    		A.at(i)=A.at(i)/2;
  		}
      	cnt1=0;
  	}else{
      fin=1;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
typedef long long ll;
map<ll,ll> mp;
vector<ll> vc;
void gys(ll a,ll b){
	for(ll i = 1; i <= sqrt(a); i++){
		if(a%i == 0){
			mp[i]++;
			if(i != a/i) 
				mp[a/i]++;
		}
	}
	for(ll i = 1; i <= sqrt(b); i++){
		if(b%i == 0){
			mp[i]++; 
			if(i != b/i) 
				mp[b/i]++;
		} 
	}
	vc.clear();
	for(map<ll,ll>::iterator it = mp.begin(); it!= mp.end(); it++){
		if(it->second == 2) vc.push_back(it->first);
	}
}
bool is_zs(ll n){
	for(ll i = 2; i<=sqrt(n); i++){
		if( n % i == 0) return false;
	}
	return true;
}
int main(){
	ll a,b;
	scanf("%lld%lld",&a,&b);
	gys(a,b); 
	ll ans = 0;
	for(vector<ll>::iterator it = vc.begin(); it != vc.end(); it++){
		if(is_zs(*it))ans++;
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <numeric>
#include <cmath>
#include <iomanip>

typedef long long ll;

#define rep(i, n) for(ll i = 0;i < (ll)(n); i++)
#define pb push_back


using namespace std;


char const *digitString(ll num, int digit) {
    char c[32];
    sprintf(c, "%LL", num);

    std::string s(c);
    while (s.length() < digit) {
        s = "0" + s;
    }
    return s.c_str();
}

int main() {
    ll n,m;
    cin >> n >> m;
    vector<vector<pair<ll,ll>>> v(n + 1);
    vector<pair<ll,ll>> result;
    rep(i, m){
        ll p,y;
        cin >> p >> y;
        v[p].pb(make_pair(i + 1,y));
    }
    for(ll i = 1;i <= n;i++) {
        if(v[i].size() == 0) continue;
        sort(v[i].begin(), v[i].end(), [](const std::pair<ll, ll> &left, const std::pair<ll, ll> &right) {
            return left.second < right.second;
        });
        rep(j,v[i].size()){
            v[i][j].second = i * 1000000 + j + 1;
        }
        result.insert(result.end(), v[i].begin(),v[i].end());
    }
    sort(result.begin(), result.end(), [](const std::pair<ll, ll> &left, const std::pair<ll, ll> &right) {
        return left.first < right.first;
    });

    rep(i, m){
        string ans = to_string(result[i].second);
        if(ans.size() < 12){
            rep(j,12 - ans.size()) cout << "0";
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 8688
#include<set>
#include<iostream>

using namespace std;

int main() {
    int T;
    cin >> T;
    multiset<int> s;
    while (T--) {
        int a;
        cin >> a;
        if (a == 0) {
            int t;
            cin >> t;
            s.insert(t);
            cout << s.size() << endl;
        } else if (a == 1) {
            int t;
            cin >> t;
            cout << s.count(t) << endl;
        } else if (a == 2) {
            int t;
            cin >> t;
            s.erase(t);
        } else {
            int l, r;
            cin >> l >> r;
            auto it = s.lower_bound(l);
            auto it1 = s.upper_bound(r);
            for (; it != it1; it++) cout << *it << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 12360
#include <iostream>

using namespace std;

int main() {
    int H,W;
    while(1){
        cin>>H>>W;
        if( H==0 && W==0) break;
        for(int i =0; i < H; ++i){
            for (int j = 0; j < W ; ++j) {
                if(i==0 or i == H-1 or j==0 or j==W-1)
                        cout<<"#";
                else{
                    cout<<".";
                }
                }
                    cout<<endl;
            }
        cout<<endl;
        }
    return 0;}

Measured memory_bytes: 3068
import queue

N = int(input())
E = {n: set() for n in range(N)}

for _ in range(N - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    E[a].add((b, c))
    E[b].add((a, c))

def m():
    Q, K = map(int, input().split())
    K -= 1
    dist = [-1] * N
    already = set()
    que = queue.Queue()
    dist[K] = 0
    que.put(K)
    while not que.empty():
        now = que.get()
        out = E[now]
        for n, c in out:
            if dist[n] != -1:
                continue
            dist[n] = dist[now] + c        
            que.put(n)
    
    res = ""
    for _ in range(Q):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        res += str(dist[x] + dist[y]) + "\n"
    
    print(res)

if __name__ == "__main__":
    m()


Measured memory_bytes: 67036
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
# mod = 998244353
# mod = 10 ** 9 + 9
mod = 10 ** 9 + 7
PI = Math::PI
dx = [ 1,  0, -1,  0,  1,  1, -1, -1]
dy = [ 0,  1,  0, -1,  1, -1,  1, -1]
eight = [0, 1, 1, 0, -1, -1, 1, -1, 0]
def max(a,b);       a > b ? a : b                              end
def min(a,b);       a < b ?  a : b                             end
def swap(a,b);      a, b = b, a                                end
def gi;             gets.to_i                                  end
def gf;             gets.to_f                                  end
def gs;             gets.chomp                                 end
def gai(n=nil); n.nil? ? gets.split.map(&:to_i) : n.times.map{ gets.to_i } end
def gaf(n=nil); n.nil? ? gets.split.map(&:to_f) : n.times.map{ gets.to_f } end
def gas(n=nil); n.nil? ? gets.split : n.times.map{ gets.chomp } end
def ga2i(h);        h.times.map{ gets.split.map(&:to_i) }      end
def yn(f); puts f ? "Yes" : "No" end
def YN(f); puts f ? "YES" : "NO" end
def yes(f=nil); f.nil? ? (puts "Yes"; exit) : (puts f ? "Yes" : "No") end
def no(f=nil); f.nil? ? (puts "No"; exit) : (puts f ? "Yes" : "No") end
def yay(f=nil); f.nil? ? (puts "Yay!"; exit) : (puts f ? "Yay!" : ":(") end

class Array
  def lcm; inject(:lcm) end
  def gcd; inject(:gcd) end
  def prod; inject(:*) end
  def abs; map{|k| k.abs } end
  def mod(m); map{|e|e%m} end
  def cumsum; s = 0; map{|k| s += k } end
  # frequency dist.
  def fd(n=nil); n = self.max if n.nil?; res = Array.new(n+1,0);self.map{|e| res[e]+=1 };res;end
  # cumlative frequency dist.
  def cfd(n=nil); fd.cumsum; end
  def diff; s = self[0]; self[1...(self.size)].map{|k|d=k-s; s=k; d} end
  # def sum; inject(:+) end
  # def append(k); push(k) end
  # def prepend(k); unshift(k) end
end

def an(n,d=0) Array.new(n,d)end
def an2(n,m,d=0) Array.new(n){an(m,d)}end
def an3(n,m,l,d=0) Array.new(n){an2(m,l,d)}end
def zeros(n); an2(n,n) end
def eye(n); an2(n,n).each_with_index{|e,i|e[i]=1} end # 単位行列 identity matrix

k,n = gai
a = gai

d = a.diff.push(k-a[-1] + a[0]).max

ans = k - d

puts ans


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

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

  cout << (n<3200? "red" : s) << endl;
}


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

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> C(H, vector<char>(W));
	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			cin >> C[i][j];
		}
	}
	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			cout << C[i][j];
		}
		cout << endl;
		for (int j = 0;j < W;++j) {
			cout << C[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a1 = sc.nextInt();
    int a2 = sc.nextInt();
    int a3 = sc.nextInt();
    System.out.println(a1 + a2 + a3 >= 22 ? "bust" : "win");
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
deque<char> dq;
bool invers;
int q, op, p;
char c;
string s;
int main() {
    DAU
    cin >> s;
    for (const char& c : s)
        dq.push_back(c);
    cin >> q;
    while (q--) {
        cin >> op;
        if (op == 1)
            invers = !invers;
        else {
            cin >> p >> c;
            if (p == 1) {
                if (invers)
                    dq.push_back(c);
                else dq.push_front(c);
            }
            else {
                if (invers)
                    dq.push_front(c);
                else dq.push_back(c);
            }
        }
    }
    s.clear();
    while (!dq.empty())
        s += dq.front(), dq.pop_front();
    if (invers)
        reverse(s.begin(), s.end());
    cout << s;
    PLEC
}

Measured memory_bytes: 1168
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

int main(){
  int n;
  cin>>n;
  vector<pair<int, int> > vec(n+1);
  vec[0]=mp(1,1);
  rep(i,n){int t,a; scanf("%d %d", &t, &a); vec[i+1]=mp(t,a); }

  long a=1, b=1;
  repl(i,1,n+1){
    int gg = vec[i-1].se * vec[i].fi - vec[i].se * vec[i-1].fi;
    if(gg==0) continue;
    long b1,b2,a1,a2;
    b1 = vec[i].se * ((b + vec[i].se -1) / vec[i].se);
    a1 = b1/vec[i].se * vec[i].fi;

    a2 = vec[i].fi * ((a + vec[i].fi -1) / vec[i].fi);
    b2 = a2/vec[i].fi * vec[i].se;

    if(a1<a || b1<b)  a=a2,b=b2;
    else if(a2<a || b2<b)  a=a1,b=b1;
    else if(a1+b1 <= a2+b2) a=a1,b=b1;
    else a=a2,b=b2;
  }
  cout<<a+b<<endl;

  return 0;
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfLong()
    val ans = A.sumByLong { it - 1 }
    println(ans)
}
inline fun <T> Iterable<T>.sumByLong(selector: (T) -> Long): Long {
    var sum = 0L
    for (element in this) sum += selector(element)
    return sum
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun nextInt(offset: Int = 0) = nextInt() + offset
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { it.toLong() }





Measured memory_bytes: 40652
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val As = readLine()!!.split(" ").map(String::toInt)
    val Bs = Array<Int>(N + 1) { 0 }

    for (i in N downTo 1) {
        val a = As[i - 1]
        var s = 0
        for (j in i..N step i) {
            s += Bs[j]
        }

        if (s % 2 != a) {
            Bs[i] = 1
        }
    }

    println(Bs.filter { it == 1 }.size)
    for (i in 1..N) {
        if (Bs[i] == 1) {
            println("$i ")
        }
    }
}

Measured memory_bytes: 68048
N = int(input())
S = input()

ans = ''
for i in S:
    if ord(i) + N > 90:  # ord('A')が65, ord('Z')が90.ord()関数でchar型をint型に
        ans += chr(ord(i) + N - 26)
    else:
        ans += chr(ord(i) + N)
print(ans)

Measured memory_bytes: 40684
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  int cnt=0;
  int ans=0;
  while(true){
    if(cnt==K)break;
    if(A>0){
      A--;
      ans++;
    }
    else if(A==0&&B>0){
      B--;
    }
    else if(A==0&&B==0&&C>0){
      ans--;
    }
  cnt++;

//  cout<<cnt<<" "<<ans<<endl;
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 3556
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

const int MAX = 1000000;
const int MAX_N = 10000;

int main ()
{
    vector<bool> v(MAX + 1, true);
    vector<int> prim_sum;
    prim_sum.push_back(0);
    v[0] = v[1] = false;
    int i = 2;
    while (prim_sum.size() <= 10000) {
        if (v[i]) {
            prim_sum.push_back(i);
            for (int j = 2; i * j<= MAX; j++) {
                v[i * j] = false;
            }
            prim_sum[prim_sum.size()-1] += prim_sum[prim_sum.size()-2];
        }
        i++;
    }

    int n;
    while (cin >> n, n) {
        cout << prim_sum[n] << endl;
    }

    return 0;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int N = 40;
int a[N][N];
LL f[N][N][N];
LL solve(int l, int r, int m) {
    assert(0 <= l && l <= m && m <= r && r <= 39);
    if (f[l][r][m] != -1)
        return f[l][r][m];
    if (l == r)
        return f[l][r][m] = 1;
    LL result = 0;
    for (int i = l; i < m; ++i)
        for (int j = m + 1; j <= r; ++j)
            if (a[i][j] == 1)
                for (int x = i; x < m; ++x)
                    for (int y = m + 1; y <= j; ++y)
                        result += solve(l, x, i) * solve(y, r, j) * solve(x + 1, y - 1, m);
    return f[l][r][m] = result;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    memset(f, -1, sizeof(f));
    int n;
    cin >> n;
    for (int i = 0; i < 2 * n; ++i) {
        for (int j = 0; j < 2 * n; ++j) {
            char c;
            cin >> c;
            a[i][j] = c - '0';
        }
    }
    LL ans = 0;
    for (int i = 1; i < 2 * n; ++i)
        if (a[0][i] == 1)
            ans += solve(1, 2 * n - 1, i);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 896
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long k = sc.nextLong();
    long d = sc.nextLong();
    long ans = 0;
    if(x >= 0) {
      long t = (x + d - 1) / d;
      if(t <= k) {
        if((t % 2) == (k % 2)) {
          ans = Math.abs(x - (t * d));
        } else {
          ans = x - (t * d) + d;
        }
      } else {
        ans = x - (k * d);
      }
    } else {
      long t = (d - x - 1) / d;
      if(t <= k) {
        if((t % 2) == (k % 2)) {
          ans = Math.abs(x + (t * d));
        } else {
          ans = Math.abs(x + (t * d) - d);
        }
      } else {
        ans = Math.abs(x + (k * d));
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35880
#include <stdio.h>

int main(){
	char s[4];
  	int i = 0,k = 0;
    scanf("%s", s);
  	while(i < 4){
      if(s[i] == '+')
        k = k + 1;
      if(s[i] == '-')
        k = k - 1;
      i++;
     }
  	printf("%d",k);
  	return 0;
}

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

#define ff              first
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int N = 3e5, M = N;
//=======================

vi g[N];

void solve() {
	int i, j, n, m;
	double d;
	cin >> n >> d;
	double count = 0;
	fo(i, n) {
		int x, y;
		cin >> x >> y;
		double c = sqrt(x * x + y * y);
		if (c <= d) count++;
	}
	cout << count << "\n";
}


int32_t main()
{
	FIO;
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	solve();
	return 0;
}

void ipgraph(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);
	}
}

Measured memory_bytes: 10808
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        Integer h[] = new Integer[N];
        int c = 0;
        for (int i=0; i<N; i++) {
            h[i] = Integer.parseInt(sc.next());
            if (h[i] >= K)
                c++;
        }
        System.out.println(c);
    }
}

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

#define mp(x, y) make_pair((x), (y))

#define ceildiv(a, b) ((a)%(b)==0 ? (a)/(b) : (a)/(b)+1)

typedef long long ll;

int N, A, B;
int h[100005];
ll c[100005];
ll le, ri;

int main()
{
	scanf("%d%d%d", &N, &A, &B);
	for(int i=0; i<N; i++) {
		scanf("%d", &h[i]);
		ri+=h[i]/A+1;
	}
	le=1;
	while(le<ri) {
		ll mi=(le+ri)/2;
		ll s=0;
		for(int i=0; i<N; i++) {
			if(h[i]-B*mi<=0) {
				c[i]=0;
			} else {
				c[i]=ceildiv(h[i]-B*mi, A-B);
			}
			s+=c[i];
		}
		if(s<=mi) ri=mi;
		else le=mi+1;
	}
	printf("%lld\n", le);

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  string s;
  cin >> s;
  ll k;
  cin >> k;
  int c;
  REP(i, (int)s.size()) {
    if (s[i] != '1') {
      c = i;
      break;
    }
  }
  if (c == 0) dump(s[0]);
  else {
    if (k <= c) dump(1);
    else dump(s[c]);
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	  static int mod=1_000_000_007;
  public static void main(String[] args) {
	  Scanner sc = new Scanner(System.in);
      long cnt =0;
      String N = sc.next();
      
      for(int i=1;i<N.length();i++) {
    	  if(N.substring(i-1, i).equals(N.substring(i,i+1))) {
    		  cnt = 1;
    	  }
      }
      
      if(cnt==1) {
    	  System.out.println("Bad");
      } else {
    	  System.out.println("Good");    	  
      }
  }
 
}

Measured memory_bytes: 21844
import bisect as bis

def main() :
	N = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]

	a.sort()
	b.sort()
	c.sort()

	count = 0
	for i in b :
		n = bis.bisect_left(a,i)
		m = len(c) - bis.bisect_right(c,i)
		count += n*m

	print(count)

main()

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

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

num_dict = dict()

ans = 0

num_dict[0 + A[0]] = 1
  
for i in range(1, N-1):
  if (A[i] + i in num_dict):
    num_dict[A[i]+i] += 1
  else:
    num_dict[A[i]+i] = 1
    
  if (i + 1 - A[i+1] in num_dict):
    ans += num_dict[i + 1 - A[i+1]]
    
    
print(ans)
  
  

Measured memory_bytes: 40384
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=(a) ; i<=(b) ; ++i)
#define Task ""
using namespace std;
const int N=1000005;
int a[N], n, c[N];
string s;
long long b[N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(Task".inp", "r", stdin);
    //freopen(Task".out", "w", stdout);
    cin >> n >> s;
    s='*'+s;
    rep(i, 1, n) {
        a[i]=a[i-1]+(s[i]=='M');
        c[i]=c[i-1]+(s[i]=='C');
    }
    rep(i, 1, n) {
        b[i]=b[i-1]+(s[i]=='C'?a[i]:0);
    }
    int Q; cin >> Q;
    while(Q--) {
        int k;
        cin >> k;
        long long ans=0;
        rep(i, 1, n) {
            if(s[i]!='D') continue;
            int numC=c[min(i+k-1, n)]-c[i];
            ans+=0ll+b[min(i+k-1, n)]-b[i]-1ll*numC*a[i];
        }
        cout << ans << '\n';
    }

    return 0;
}


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

bool is_prime[50050];
int prime[50050];
int main() {
	memset(is_prime, 1, sizeof(is_prime));
	is_prime[0] = is_prime[1] = false;
	int p = 0;
	for (int i = 2; i < 50050; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = i * 2; j < 50050; j += i)is_prime[j] = false;
		}
	}
	int n;
	while (cin >> n) {
		int i = lower_bound(prime, prime + p, n) - prime;
		cout << prime[i - 1] << ' ' << (prime[i] == n ? prime[i + 1] : prime[i]) << endl;
	}
	return 0;
}

Measured memory_bytes: 3128
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#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 SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}


int n;
vector<int> l;

void input(){
    cin >> n;
    l.resize(n);
    REP(i, n){
        cin >> l[i];
    }
}

void solve(){
    lint ans = 0;
    sort(ALL(l));
    for (int i=0; i<n; ++i){
        for (int j=i+1; j<n; ++j){
            int a = l[i];
            int b = l[j];
            int lb = abs(a - b) + 1;
            int ub = a + b - 1;
            int c_lb = lower_bound(l.begin() + j + 1, l.end(), lb) - l.begin();
            int c_ub = upper_bound(l.begin() + j + 1, l.end(), ub) - l.begin();
            ans += c_ub - c_lb;
        }
    }
    cout << ans << endl;
    return;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main(void) {
int  x, k = 0;
double i, j;
std::vector<long double> a(1000);
std::cin >> x;

for (i = 1; i < 32; i++) {
  for (j = 2; j < 10; j++) {
    a[k] = pow(i, j);
    k++;
    if (a[k-1] > 1000) {
      break;
    }
  }
}

sort(a.begin(), a.end());

for (i = 0; i < 1000; i++) {
  if (a[i] <= x && a[i + 1] > x) {
    std::cout << a[i] << '\n';
  }
}

return 0;
}


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

int main(){
    int r, d, x;
    cin >> r >> d >> x;
    for(int i = 0; i < 10; i++){
        x = r*x - d;
        cout << x << '\n';
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    //ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 0;i < N;i++){
        if(N < 4){
            ans = 1;
            break;
        }
        if(i * i > N){
            ans = (i - 1) * (i - 1);
            break;
        }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<stack>
#include<vector>
#include<queue>
#define MAX 1200000
using namespace std;

int G[MAX],m,cnt;

void insertionSort(int A[],int n,int g){
  for(int i=g;i<n;i++){
    int v=A[i];
    int j=i-g;
    while(j>=0 && A[j]>v){
      A[j+g]=A[j];
      j=j-g;
      cnt++;
    }
    A[j+g]=v;
  }
}

void shellSort(int A[],int n){
  cnt=0;
  m=0;
  for(int i=1;i<=n;i=3*i+1){
    G[m]=i;
    m++;
  }
  reverse(G,G+m);
  for(int i=0;i<m;i++){
    insertionSort(A,n,G[i]);
  }

}

int main(){
  int n;
  int A[MAX];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  shellSort(A,n);

  cout<<m<<endl;
  for(int i=0;i<m;i++){
    if(i) cout<<" ";
    cout<<G[i];
  }
  cout<<endl;
  cout<<cnt<<endl;
  for(int i=0;i<n;i++){
    cout<<A[i]<<endl;
  }
}



Measured memory_bytes: 6992
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner =new Scanner(System.in);
		int N = scanner.nextInt();
		int A = scanner.nextInt();
		
		int[] card = new int[N];
		
		for (int i = 0; i < N; i++) {
			card[i] = scanner.nextInt();
		}

		long[][][] dp = new long[N+1][N+1][2550];

		dp[0][0][0] = 1;

		//dp[i][j][k]:= i枚目までを見たときにｊ枚選んで合計値をkにする通り数
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N+1; j++) {
				for (int k = 0; k < 2550; k++) {
					if (dp[i][j][k] > 0) {
						//選ばない
						dp[i + 1][j][k] += dp[i][j][k]; 

						//選ぶ
						dp[i + 1][j + 1][k + card[i]] += dp[i][j][k];
					}
				}
			}
		}
		long ans = 0;
		for (int i = 0; i < N+1; i++) {
			ans += dp[N][i][i*A];
		}

		System.out.println(ans - 1);

		scanner.close();
	}

}


Measured memory_bytes: 92248
x,n = list(map(int,input().split()))
a = list(map(int,input().split()))
d_max = a[0] + x - a[n -1]
for k in range(n-1):
    if d_max < a[k+1] - a[k]:
        d_max = a[k+1] - a[k]
print(x - d_max)

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

#pragma region lib_unionfind_tree
namespace lib {
  /*
    class UnionFind
    usage: Unionfind u(100), u.unite(1, 10), u.find(1, 13)
  */
  class UnionFind {
    public:
    UnionFind() {}
    UnionFind(int n) :
        parent(n, -1), rank(n, 0) {}

    int find(int a) {
      if (parent[a] == -1)
        return a;
      else
        return parent[a] = find(parent[a]);
    }

    void unite(int a, int b) {
      a = find(a);
      b = find(b);

      if (a == b) return;
      if (rank[a] == rank[b]) {
        parent[a] = b;
        rank[b]++;
        return;
      }
      if (rank[a] > rank[b]) swap(a, b);
      parent[a] = b;
    }

    private:
    vector<int> parent, rank;
  };
}  // namespace lib
#pragma endregion

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

  lib::UnionFind uf(N);

  while (Q--) {
    int t, u, v;
    cin >> t >> u >> v;

    if (t == 0)
      uf.unite(u, v);
    else
      cout << (uf.find(u) == uf.find(v)) << endl;
  }

  return 0;
}


Measured memory_bytes: 4756
#include<bits/stdc++.h>
using namespace std;
#define int long long
//BEGIN CUT HERE
struct TopologicalSort{
  int n;
  vector<set<int> > G;
  vector<int> indeg,V,p;
  TopologicalSort(){}
  TopologicalSort(int n):n(n){init();}
  
  void init(){
    for(int i=0;i<(int)G.size();i++) G[i].clear();
    G.clear();
    indeg.clear();
    V.clear();
    p.clear();
    G.resize(n);
    indeg.resize(n);
    V.resize(n);
  }

  void add_edge(int s,int t){
    G[s].insert(t);
  }
  
  void bfs(int s){
    queue<int> q;
    q.push(s);
    V[s]=1;
    while(!q.empty()){
      int u=q.front();q.pop();
      p.push_back(u);
      for(int v:G[u]){
	indeg[v]--;
	if(indeg[v]==0&&!V[v]){
	  V[v]=1;
	  q.push(v);
	}
      }
    }
  }
  
  void tsort(){
    fill(V.begin(),V.end(),0);
    fill(indeg.begin(),indeg.end(),0);
    for(int u=0;u<n;u++)
      for(int v:G[u])
	indeg[v]++;
    for(int u=0;u<n;u++)
      if(indeg[u]==0&&!V[u]) bfs(u);
    for(int i=0;i<n;i++)
      cout<<p[i]<<endl;
  }
};
//END CUT HERE

signed main(){
  int n,e;
  cin>>n>>e;
  TopologicalSort ts(n);
  for(int i=0;i<e;i++){
    int s,t;
    cin>>s>>t;
    ts.add_edge(s,t);
  }
  ts.tsort();
  return 0;
}

/*
verified on 2017/06/29
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_4_B&lang=jp
*/

Measured memory_bytes: 5808
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

struct Data{
	vector<int> c;
	int sum,id;
	bool operator<(const Data &d)const{
		if(sum==d.sum) return c[c.size()-1]>d.c[d.c.size()-1];
		return sum<d.sum;
	}
	bool operator>(const Data &d)const{
		if(sum==d.sum) return c[c.size()-1]<d.c[d.c.size()-1];
		return sum>d.sum;
	}
};

void Solve(){
	while(true){
		int n,d;
		cin >> n >> d;
		if(n==0&&d==0) break;

		vector<vector<int>> c(n);
		vector<int> sum(n);
		REP(i,0,n){
			int m; cin >> m;
			c[i].resize(m);
			REP(j,0,m){
				cin >> c[i][j];
				sum[i]+=c[i][j];
			}
		}

		while(true){
			bool update=false;
			REP(i,0,n){
				if(!c[i].empty()){
					sum[i]-=c[i].back();
					if(*max_element(sum.begin(),sum.end())-sum[i]<=d){
						c[i].pop_back();
						update=true;
					}else sum[i]+=c[i].back();
				}
			}
			if(!update) break;
		}

		if(!accumulate(sum.begin(),sum.end(),0)) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 1228
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

ans = 1
ans_t = abs(A-(T-H[1]*0.006))
for i in range(N):
    if abs(A-(T-H[i]*0.006)) < ans_t:
        ans = i+1
        ans_t = abs(A-(T-H[i]*0.006))
print(ans)


Measured memory_bytes: 3060
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

def rand_letter(size):
    ascii_original='ABCD'
    digits_original='01'

    digits='0123456789'
    ascii_lowercase='abcdefghijklmnopqrstuvwxyz'
    ascii_uppercase='ABCDEFGHIJKLMNOPQRSTUVWXYZ'

    # 好きなものを使ってね
    psuedo = ascii_original

    return ''.join([random.choice(psuedo) for i in range(size)])

S = input()
N = len(S)

ans = [-1, -1]
for i in range(1, N):
    if S[i] == S[i - 1]:
        ans = [i, i + 1]
        break
    if i > 1 and S[i] == S[i - 2]:
        ans = [i - 1, i + 1]
        break
print(*ans)

Measured memory_bytes: 61036
/* HARDWORK IS THE KEY TO SUCCESS.
       RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.!!!*/
    #include <bits/stdc++.h>
    #define pragma
    using namespace std;
    #define ll long long
    #define ld long double
    #define T ll t = 1; cin>>t; while(t--)
    #define vin ll n; cin>>n; vector<ll>x(n); for(ll i=0; i<n; i++) cin>>x[i]
    #define vout for(ll i=0; i<n; i++) cout<<x[i]<<" "
    #define ain ll n,k,i; cin>>n; ll a[n]; for( i=0; i<n; i++) cin>>a[i]
    #define aout for(ll i=0; i<n; i++) cout<<a[i]<<" "
    #define matin ll m,n; cin >> n >> m; ll a[n + 1][m + 1] ; for(ll i=1;i<=n;i++) for(ll j=1;j<=m;j++) cin>>a[i][j];
    #define matout for(ll i=0;i<m;i++){for(ll j=0;j<n;j++) cout<<a[i][j]<<" "; cout<<"\n";}
    #define sin set<ll>s; ll n; cin>>n; ll tmp; for(ll i=0;i<n;i++){cin>>tmp; s.I(tmp);}
    #define sout for(auto it=s.begin();it!=s.end();++it) cout<<*it<<" "
    #define F first
    #define S second
    #define I insert
    #define pb push_back
    #define ppb pop_back
    #define AISORT sort(a,a+n)
    #define ADSORT sort(a,a+n,greater<ll>())
    #define VISORT sort(x.begin(),x.end())
    #define VDSORT sort(x.begin(),x.end(),greater<ll>())

    const ll maxs = 1e5+3;
    const ll maxs1 = 1e3+4;
    const ll mod = 1e9 + 7;

    //MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

    //POWER
    ll fastpow(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;}

    //MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}

//     ll n;
//     ll a[maxs];
//     ll tree[maxs];
    bool vis[maxs];
    vector<ll>graph[maxs];
    //ALWAYS CLEAR THEM WHEN TESTCASES ARE GIVEN
    //ALWAYS RETURN WHEN ST == ED CONDITION IN SEGMENT TREES


    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        ain;
        unordered_map<ll,ll>mp;
        for(i = 0;i < n;++i)
            mp[a[i]]++;
        
        ll ans = 0;
        for(auto it : mp)
            {
                ans += ((it.S) * (it.S - 1)) / 2;
            }
        for(i = 0;i < n;++i)
        {
           
           ll tmp = ans - ((mp[a[i]] * (mp[a[i]] - 1)) / 2); 
           mp[a[i]]--;
           tmp += ((mp[a[i]] * (mp[a[i]] - 1)) / 2);
            cout << tmp << "\n";
            mp[a[i]]++;
        }
        
        
    }


Measured memory_bytes: 11464
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
d = [a[0],b[0],c[0]]
e = [a[1],b[1],c[1]]
f = [a[2],b[2],c[2]]
g = [a[0],b[1],c[2]]
h = [a[2],b[1],c[0]]

n = int(input())

bs = []
for _ in range(n):
    bs.append(int(input()))
       
for l in [a,b,c,d,e,f,g,h]:
    if (l[0] in bs) and (l[1] in bs) and (l[2] in bs):
        print("Yes")
        break
else:
    print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
    string a,b,c;
    cin >> a >> b >> c;
    map<int,string> mp;
    mp[0] = a;
    mp[1] = b;
    mp[2] = c;
    int next = 0;
    while(1){
        if(mp[next].size() == 0){
            if(next == 0) puts("A");
            if(next == 1) puts("B");
            if(next == 2) puts("C");
            return 0;
        }
        char cc = mp[next].at(0);
        mp[next] = mp[next].substr(1);
        if(cc == 'a') next = 0;
        if(cc == 'b') next = 1;
        if(cc == 'c') next = 2;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<string.h>
#include<functional>
#include<set>
#include<string>
#include<bitset>
//aoj 0121
using namespace std;
char zzzt[8]={0,1,2,3,4,5,6,7};
char bj[8];
bitset<80000000> vis;
struct pt{
	int ztt;
	int lwz;
	int step;
};
int bs;
pt dl[1<<16];
int front=1,back=1;
int tt;
int ddd[8]={10000000,1000000,100000,10000,1000,100,10,1};
void bfs()
{
	tt=0;
	front=1;
	back=1;
	bs=0;
//	memset(vis,0,sizeof(vis));
	vis.reset();
	
	int cs=atoi(bj);
	vis[cs]=1;
	pt lsss;
	lsss.ztt=cs;
	lsss.lwz=strchr(bj,'0')-bj;
	lsss.step=0;
	dl[back]=lsss;
	back++;
	while(front<back)
	{
		pt ls1=dl[front];
		front++;
		if(ls1.ztt==1234567)
		{
			bs=ls1.step;
			tt=1;
			return;
		}
		pt lsjr;
		int kkk[4]={-1,1,-4,4};
		char sss[9];
//		sprintf(sss,"%08d", ls1.ztt);
		int tt=ls1.ztt;
		for(int i=7;i>=0;i--){
			sss[i]=tt%10;
			tt/=10;
		}
		for(int i=0;i<4;i++){
			lsjr.lwz=ls1.lwz+kkk[i];
			if((ls1.lwz==3&&lsjr.lwz==4) || (ls1.lwz==4&&lsjr.lwz==3)) continue;
			if(lsjr.lwz>=0&&lsjr.lwz<=7){
/*				
					int  a,b;
					a=ls1.ztt/ddd[ls1.lwz]%10;
					b=ls1.ztt/ddd[lsjr.lwz]%10;
					lsjr.ztt=ls1.ztt+(b-a)*ddd[ls1.lwz]+(a-b)*ddd[lsjr.lwz];
*/
				swap(sss[ls1.lwz],sss[lsjr.lwz]);
				lsjr.ztt=0;
				for(int i=0;i<=7;i++){
					lsjr.ztt*=10;
					lsjr.ztt+=sss[i];
				}
				swap(sss[ls1.lwz],sss[lsjr.lwz]);
				if(!vis[lsjr.ztt])
					{
						lsjr.step=ls1.step+1;
						vis[lsjr.ztt]=1;
						dl[back]=lsjr;
						back++;
					}
			}
		}
	}
}
int main()
{
//	freopen("in","r",stdin);
	while(1)
	{
		if(scanf("%c",&bj[0])==EOF)
		{
			return 0;
		}
		scanf("%*c");
		for(int i=1;i<=6;i++)
		{
			scanf("%c%*c",&bj[i]);
		}
		scanf("%c",&bj[7]);
		bfs();
		if(tt)
		{
			printf("%d\n",bs);
		}else{
			printf("-1\n");
		}
		while(getchar()!='\n');
	}
	return 0;
}



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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

long long powmod(long long a,long long b){
    long long c=1;
    while(b>0){
        if(b&1) c=a*c%mod;
        a=a*a%mod;
        b>>=1;
    }
    return c;
}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	string s;
	cin >> s;
	ll n=SIZE(s);
	vll a(n+1);
	rep(i,n){
		if(s[i]=='<') chmax(a[i+1],a[i]+1);
	}
	for(ll i=n-1;i>=0;i--){
		if(s[i]=='>') chmax(a[i],a[i+1]+1);
	}
	cerr << a;
	cout << sumvec(a) << endl;
	return 0;
}


Measured memory_bytes: 4868
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
  int a;
  cin>>a;
  cout<<a+a*a+a*a*a<<"\n";
}



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

using namespace std;

int main()
{
    char b;
    scanf("%c", &b);
    char ans;
    switch (b)
    {
    case 'A':
        ans = 'T';
        break;
    case 'T':
        ans = 'A';
        break;
    case 'C':
        ans = 'G';
        break;
    case 'G':
        ans = 'C';
        break;
    default:
        break;
    }

    printf("%c\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	int N;
	cin >> N;
	vector<int> a(N);
	for(int i=0;i<N;i++)cin >> a[i];
	sort(ALL(a));
	int ans = 0;
	for(int i=0;i<N;i++){
		ans^= a[i];
	}
	if(ans){
		cout <<"No"<<endl;
	}else{
		cout <<"Yes"<<endl;
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int gcd( int x, int y ){ return y ? gcd(y, x%y) : x; }
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x;
if(x%2==0)std::cout << (x/2)*(x/2) << '\n';
else std::cout << (x/2)*(x/2+1) << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  int n[]={0,0,0,0};
  map<char,int> mp{{'N',0},{'S',1},{'E',2},{'W',3}};
  for(auto c:S) n[mp[c]]=1;
  if(n[0]^n[1] || n[2]^n[3]) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256