akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */

/** Problem0207 : Block **/
int main()
{
	int W, H;
	
	while (cin>>W>>H, W||H) {
		vector<vector<int> > board(W, vector<int>(H));
		int sx, sy, gx, gy;
		cin>>sx>>sy>>gx>>gy;
		sx--, sy--, gx--, gy--;
		
		int N; cin>>N;
		while (N--) {
			int c, d, x, y; cin>>c>>d>>x>>y;
			x--, y--;
			
			if (d==0) {
				board[x][y] = board[x+1][y] = board[x+2][y] = board[x+3][y] = c;
				board[x][y+1] = board[x+1][y+1] = board[x+2][y+1] = board[x+3][y+1] = c;
			} else {
				board[x][y] = board[x][y+1] = board[x][y+2] = board[x][y+3] = c;
				board[x+1][y] = board[x+1][y+1] = board[x+1][y+2] = board[x+1][y+3] = c;
			}
		}
		
		/**
		rep(i, H) {
			rep(j, W) {
				cerr << board[j][i] << " ";
			}
			cerr << endl;
		} **/
		
		queue<P> Q;
		bool vis[100][100]={0};
		Q.push(P(sx, sy));
		vis[sx][sy]=true;
		
		while (Q.size()) {
			P p = Q.front(); Q.pop();
			if (p.first == gx && p.second == gy) {
				cout << "OK" << endl;
				goto end;
			}
			rep(i, 4) {
				int nx = p.first+dx[i], ny = p.second+dy[i];
				if_range(nx, ny, W, H) {
					if (!vis[nx][ny] && board[nx][ny] == board[p.first][p.second]) {
						Q.push(P(nx, ny));
						vis[nx][ny] = true;
					}
				}
			}
		}
		cout << "NG" << endl;
	end:;
	}
}

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


int main() {
  ll N;
  cin >> N;
  vector<string> S(N);
  for(int i = 0;i<N;i++){
    cin >> S[i];
  }
  for(int i = 0;i<N;i++){
    sort(S[i].begin(),S[i].end());
  }
  
  sort(S.begin(),S.end());

  S.push_back("aa");
  
  vector<pair<string,ll>> p;
  ll c = 1;
  for(int i = 0;i<N;i++){
    if(S[i] == S[i+1]){
      c++;
    }
    else if(S[i] != S[i+1]){
      if(c>=2){
      p.push_back(make_pair(S[i],c));
      c = 1;
      }
    }
  }

  ll ans = 0;
  for(int i = 0;i<p.size();i++){
    ans += (p[i].second*(p[i].second-1))/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 8064
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int ans[3] = {};
int fans[3] = {};
int mny[3] = {10000, 5000, 1000};
int n, y;

//もし, n=a+b+cなら、1を返し、無理なら0を返す
int solve(int a, int b, int c)
{
    if (n == a + b + c)
    {
        fans[0] = a;
        fans[1] = b;
        fans[2] = c;
        return 1;
    }
    if (a < 0 || b < 0 || c < 0 || a + b + c > n)
    {
        return 0;
    }
    return max({solve(a - 1, b + 2, c), solve(a - 1, b, c + 10), solve(a, b - 1, c + 5)});
}

int main()
{
    cin >> n >> y;
    int sum = 0;
    rep(i, 3)
    {
        ans[i] = y / mny[i];
        sum += ans[i];
        y -= ans[i] * mny[i];
    }

    for (int i = 0; i <= ans[0]; i++)
    {
        for (int j = 0; j <= ans[0] - i; j++)
        {
            for (int k = 0; k <= ans[1] + 2 * i; k++)
            {
                if (n == ans[0] - i - j + ans[1] + 2 * i - k + ans[2] + 10 * j + 5 * k)
                {
                    cout << ans[0] - i - j << " " << ans[1] + 2 * i - k
                         << " " << ans[2] + 10 * j + 5 * k << endl;
                    return 0;
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#define MOD_P 1000000007
#define ll long long
using namespace std;


int main()
{

	int a, b, c, d;
	int counta = 0, countb = 0;
	cin >> a >> b >> c >> d;

	while (a > 0) {
		counta++;
		a -= d;
	}

	while (c > 0) {
		countb++;
		c -= b;
	}

	//printf("[%d,%d]\n", counta, countb);

	printf("%s", countb <= counta ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 3688
//***Faithless is he that says farewell when the road darkens***

#include<bits/stdc++.h>
using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
   ll m,d,c=0;
   cin>>m>>d;

   for(ll i =1;i<=m;i++){
      for(ll j=1;j<=d;j++){
         ll a=j%10;
         ll b=(j/10)%10;
         if((a>=2)&&(b>=2)&&(a*b==i))
         c++;
      }
   }
   cout<<c;
}

Measured memory_bytes: 256
using System;

class ABC_141_D
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int M = int.Parse(input[1]);

        string[] input2 = Console.ReadLine().Split(' ');
        int[] A = new int[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = int.Parse(input2[i]);
        }
        Array.Sort(A);
        Array.Reverse(A);

        while(M>0)
        {
            A[0] /= 2;
            M--;
            if (M <= 0) break;

            for (int i = 1; i < N; i++)
            {
                if (A[0] > A[i])
                {
                    Array.Sort(A);
                    Array.Reverse(A);
                    break;
                }

                A[i] /= 2;
                M--;
                if (M <= 0) break;
            }
        }

        long ans = 0;
        for (int i = 0; i < N; i++)
        {
            ans += A[i];
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 27100
#!/usr/bin/env python3
import sys

def solve_(n, A):
    tmp = {}
    for i, a in enumerate(A):
        v = i + a
        if not v in tmp:
            tmp[v] = 0
        tmp[v] += 1
    ret = 0
    for i, a in enumerate(A):
        t = i - a
        if t >= 0 and t in tmp:
            ret += tmp[t]
    return ret

def solve(n, A):
    ret = solve_(n, A) + solve_(n, A[::-1])
    print(ret // 2)
    return ret

def main():
    n = int(input())
    a = list(map(int, input().split()))
    solve(n, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 143956
import math
N = int(input())
ans = [0]*N
l = int(math.sqrt(N))

for i in range(1,l):
    for j in range(1,l):
        for k in range(1,l):
            a = (i+j+k)**2-(i*j+j*k+k*i)
            if a <= N:
                ans[a-1] += 1

print(*ans, sep='\n')


Measured memory_bytes: 9372
n, k = map(int,input().split())
i = 0
kitaichi = [0] * n
kitaichi_sum = [0] * n
ans = 0
for p in input().split():
  kitaichi[i] = int(p) * (int(p)+1) / 2 / int(p)
  if i == 0:
    kitaichi_sum[i] = kitaichi[i]
  elif i >= k:
    kitaichi_sum[i] = kitaichi_sum[i-1] + kitaichi[i] - kitaichi[i-k]
    if kitaichi_sum[i] > ans:
      ans = kitaichi_sum[i]
  else:
    kitaichi_sum[i] = kitaichi_sum[i-1] + kitaichi[i]
  if kitaichi_sum[i] > ans:
    ans = kitaichi_sum[i]
  i += 1
print(ans)

Measured memory_bytes: 77808
#include <iostream>
#include <numeric>

using namespace std;

int main(void) {
    int K;
    cin >> K;

    int ans = 0;
    for(int a=1; a<=K; a++) {
        for(int b=1; b<=K; b++) {
            int g = gcd(a, b);
            for(int c=1; c<=K; c++) {
                ans += gcd(g, c);
            }
        }
    }

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


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

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 2e5+5;

bitset<N>now;
vector<int>c[N];

int main(){
	int h=get(),w=get(),n=get();
	int ans=h;
	fo(i,1,n){
		int x=get(),y=get();
		c[x].push_back(y);
	}
	now[1]=1;
	fo(i,2,h){
		for(auto x:c[i])
		if (now[x]){
			ans=i-1;
			break;
		}
		if (ans<h)break;
		now=now|(now<<1);
		for(auto x:c[i])now[x]=0;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N;
ll W, w[110];
ll v[110];

// int dp[110][1000000000]
map<ll, ll> dp[110];

int main(void){
	cin >> N >> W;
	rep(i, N) cin >> w[i] >> v[i];
	dp[0][0] = 0;
	rep(i, N){
		for(auto tmp : dp[i]){
			//dp[i][weight] = value
			ll weight = tmp.fi, value = tmp.se; //今までの重さと価格の最大値
			if(dp[i + 1].count(weight + w[i]) == 0 || dp[i + 1][weight + w[i]] < dp[i][weight] + v[i]){
				// printf("%lld\n", dp[i][weight] + v[i]);
				dp[i + 1][weight + w[i]] = dp[i][weight] + v[i];
			}
			if(dp[i + 1].count(weight) == 0 || dp[i + 1][weight] < dp[i][weight]){
				// printf("%lld\n", dp[i][weight] + v[i]);
				dp[i + 1][weight] = dp[i][weight];
			}
		}
	}
	ll ans = 0;
	for(auto tmp : dp[N]){
		ll weight = tmp.fi, value = tmp.se; //今までの重さと価格の最大値
		if(weight > W) continue;
		chmax(ans, value);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13952
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;



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

	int A,P;
	cin>>A>>P;
	cout<<(3*A+P)/2<<endl;
}


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

int main()
{
    string S;
    cin >> S;
    bool flag = false;
    if (S.at(1) == S.at(2))
    {
        if ((S.at(0) == S.at(1)) || (S.at(2) == S.at(3)))
        {
            flag = true;
        }
    }

    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n; string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; ;) {
		int tmp = s.find("ABC", i);
		if (tmp == s.npos)
			break;
		i = tmp + 3;
		ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n)cin >> p[i];
    sort(all(p));
    int ans = 0;
    rep(i, k)ans += p[i];
    cout << ans << endl;
}

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

int main(){
int n,ans;
while(cin>>n){
ans=0;
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
for(int k=0;k<10;k++){
for(int l=0;l<10;l++){
if(i+j+k+l==n){ans++;}}}}}cout<<ans<<endl;}}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
using T = tuple<int, int, int, int>;

int main()
{
	int p, q;
	string s;
	while (cin >> p >> q, p | q) {
		vector<int> cnt(3);
		vector<T> base;
		for (int i = 0; i < p; i++) {
			cin >> s;
			int ind = 0;
			while (ind < (int)s.size() && s[ind] == '.') ind++;
			base.emplace_back(cnt[0], cnt[1], cnt[2], ind);
			for (auto c : s) {
				switch (c)
				{
				case '(': cnt[0]++; break;
				case ')': cnt[0]--; break;
				case '{': cnt[1]++; break;
				case '}': cnt[1]--; break;
				case '[': cnt[2]++; break;
				case ']': cnt[2]--; break;
				default:
					break;
				}
			}
		}
		vector<vector<int>> kouho;
		for (int r = 1; r <= 20; r++) {
			for (int c = 1; c <= 20; c++) {
				for (int s = 1; s <= 20; s++) {
					bool ok = true;
					for (auto t : base) {
						if (get<0>(t) * r + get<1>(t) * c + get<2>(t) * s != get<3>(t)) {
							ok = false;
						}
					}
					if (ok) {
						kouho.push_back({ r, c, s });
					}
				}
			}
		}
		cnt[0] = cnt[1] = cnt[2] = 0;
		vector<int> res(q);
		for (int i = 0; i < q; i++) {
			cin >> s;
			vector<int> tmp;
			for (auto t : kouho) {
				int x = 0;
				for (int j = 0; j < 3; j++) {
					x += t[j] * cnt[j];
				}
				tmp.push_back(x);
			}
			sort(tmp.begin(), tmp.end());
			tmp.erase(unique(tmp.begin(), tmp.end()), tmp.end());
			res[i] = tmp.size() == 1 ? tmp[0] : -1;
			for (auto c : s) {
				switch (c)
				{
				case '(': cnt[0]++; break;
				case ')': cnt[0]--; break;
				case '{': cnt[1]++; break;
				case '}': cnt[1]--; break;
				case '[': cnt[2]++; break;
				case ']': cnt[2]--; break;
				default:
					break;
				}
			}
		}
		for (int i = 0; i < q; i++) {
			cout << res[i] << " \n"[i + 1 == q];
		}
	}
	return 0;
}

Measured memory_bytes: 3348
#include <stdio.h>

int main(void) {
    int a1, a2, a3;

    scanf("%d %d %d", &a1, &a2, &a3);

    if (a1 + a2 + a3 >= 22) {
        printf("bust");
    } else {
        printf("win");
    }

    return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

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

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

template< typename T, typename 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);
}

int main() {
  int n, a;
  cin >> n >> a;
  cout << n * n - a << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define LARGE 1001

int Get_min(int a,int b,int c){
	int x=MIN(a,b);
	int y=MIN(b,c);
	return MIN(x,y);
}


int main(){
	char s1[LARGE];
	char s2[LARGE];
	int m,n;
	int i,j;
	int **dp;
	
	scanf("%s",s1); scanf("%s",s2);
	
	m=strlen(s1)+1; n=strlen(s2)+1;
	
	dp=malloc(sizeof(int*)*m);
	for(i=0;i<m;i++){
		dp[i]=malloc(sizeof(int)*n);
		for(j=0;j<n;j++)dp[i][j]=0;
	}
	
	for(i=0;i<m;i++)dp[i][0]=i;
	for(i=0;i<n;i++)dp[0][i]=i;
	
	for(i=1;i<m;i++){
		for(j=1;j<n;j++){
			if(s1[i-1]==s2[j-1])dp[i][j]=Get_min(dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]);
			else dp[i][j]=Get_min(dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]+1);
		}
	}
	
	printf("%d\n",dp[m-1][n-1]);
	
	return 0;
}


Measured memory_bytes: 5712
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n,w; cin >> n >> w;
    vvc<ll> dp(n+1, vc<ll>(100*1001,INF));
    dp[0][0] = 0;
    rng(i,1,n+1){
        int x,y; cin >> x >> y;
        per(j,100*1001){
            if(j >= y) chmin(dp[i][j], dp[i-1][j-y] + x);
            chmin(dp[i][j], dp[i-1][j]);
        }
    }
    per(i,100*1001){
        if(dp[n][i] <= w){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 80256
#include <iostream>

int main(int argc, const char * argv[]) {
    int a, b, c;
    std::cin >> a >> b >> c;
    int cnt = 0;
    for (int i = a; i <= b; i++) {
        if (c % i == 0) {
           cnt++;
        }
    }
    std::cout << cnt << std::endl;
    return 0;
}

Measured memory_bytes: 3096
#include <string.h>
#include <cmath>
#include <stdio.h>

char c[200];

int main(){
	int ans;
	int n;
	while(scanf("%s",&c) != EOF){
		n = strlen(c);
		ans = 0;
		for(int i = 0; i < n; i++){
			if(c[i] == 'I'){
				if(c[i + 1] == 'V' || c[i + 1] == 'X' || c[i + 1] == 'L' || c[i + 1] == 'C' || c[i + 1] == 'D' || c[i + 1] == 'M'){
					ans -= 1;
				}else{
					ans += 1;
				}
			}
			if(c[i] == 'V'){
				if(c[i + 1] == 'X' || c[i + 1] == 'L' || c[i + 1] == 'C' || c[i + 1] == 'D' || c[i + 1] == 'M'){
					ans -= 5;
				}else{
					ans += 5;
				}
			}
			if(c[i] == 'X'){
				if(c[i + 1] == 'L' || c[i + 1] == 'C' || c[i + 1] == 'D' || c[i + 1] == 'M'){
					ans -= 10;
				}else{
					ans += 10;
				}
			}
			if(c[i] == 'L'){
				if(c[i + 1] == 'C' || c[i + 1] == 'D' || c[i + 1] == 'M'){
					ans -= 50;
				}else{
					ans += 50;
				}
			}
			if(c[i] == 'C'){
				if(c[i + 1] == 'D' || c[i + 1] == 'M'){
					ans -= 100;
				}else{
					ans += 100;
				}
			}
			if(c[i] == 'D'){
				if(c[i + 1] == 'M'){
					ans -= 500;
				}else{
					ans += 500;
				}
			}
			if(c[i] == 'M'){
				ans += 1000;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 968
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()

a = LIST()

xorTot = 0
for el in a:
    xorTot^=el

ans = []

for el in a:
    ans.append(el^xorTot)
print(*ans)








Measured memory_bytes: 106988
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
using namespace std;

int main(void) {
	string str;
	int a, b,i;
	cin >> str;
	for (i = 0; i < str.size(); i++) {
		if (str[i] == 'A') {
			a = i;
			break;
		}
	}
	for (i = str.size() - 1; i >= 0; i--) {
		if (str[i] == 'Z') {
			b = i;
			break;
		}
	}
	cout << b - a+1 << endl;
	return 0;
}

Measured memory_bytes: 640
n, x, y = map(int, input().split())

ans = [0]*(n-1)

for i in range(1, n):
    for j in range(i+1, n+1):
        ans[min(j-i, abs(x-i)+1+abs(y-j))-1] += 1

for k in range(n-1):
    print(ans[k])

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#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(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

ll dp[1001];

void fn(int n){
	FOR(i,2,n+1){
		if(i==n) dp[n]=2;
		if(n%i==0) dp[n]=dp[n%i]*(dp[i]-1);
	}
}

int main(void){	
	string n,div;
	cin>>n;
	reverse(n.begin(),n.end());
	int i=0;
	while(i!=(int)n.length()){
		div=n.substr(i,7);

		if(div.substr(0,5)=="maerd"||div.substr(0,5)=="esare") i+=5;
		else if(div.substr(0,6)=="resare") i+=6;
		else if(div=="remaerd") i+=7;
		else{
			puts("NO");
			return 0;
		}
	}
	
	puts("YES");

	return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
  {
  char a,b;
  cin>>a>>b;
  
  if(a=='H' && b == 'H')
  cout<<"H"<<endl;
  else if(a=='H' && b == 'D')
  cout<<"D"<<endl;
   else if(a=='D' && b == 'D')
  cout<<"H"<<endl;
   if(a=='D' && b == 'H')
  cout<<"D"<<endl;
  }

Measured memory_bytes: 3548
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int a,b,t;
  
  cin >> a >> b;
  
  if (b<10) t=a*10+b;
  else if (b<100) t=a*100+b;
  else t=a*1000+b;
  
  int i=4;
  while (i*i<=t){
    if (i*i==t){
      cout << "Yes" << endl;
      return 0;
    }
    i++;
  }
  
  cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc076/tasks/abc076_c
s = input()
t = input()

ans = []
for i in range(1, len(s) + 1):
    l = s[:i - 1]
    r = s[i + len(t) - 1:]
    temp = l + t + r
    if len(temp) == len(s):
        for i in range(len(s)):
            if s[i] == '?' or s[i] == temp[i]:
                continue
            else:
                break
        else:
            ans.append(temp)
if len(ans) == 0:
    print('UNRESTORABLE')
else:
    ans.sort()
    a = ans[0]
    a = a.replace('?', 'a')
    print(a)

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
    T r;
    while (a)
        r = b, b = a, a = r % a;
    return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements
#define VEC(type, c, n)     \
    std::vector<type> c(n); \
    for (auto &i : c)       \
        std::cin >> i;

// input
#define INIT                          \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define VAR(type, ...) \
    type __VA_ARGS__;  \
    MACRO_VAR_Scan(__VA_ARGS__);

// output
template <typename T>
void MACRO_OUT(const T t) { std::cout << t; }

#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout << " ";
#define TAB std::cout << "\t";
#define BR std::cout << "\n";
#define ENDL std::cout << std::endl;

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
    cout << a;
    ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
    cout << a << ' ';
}

ll ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
// ll a, b, c, d, n;
int x, y;
int sum;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// cout << (conditon ? (result:  == 1 ): (==0)) << endl; <- output result of if
// long long 型が表せる値の上限はおよそ 9 × 10＾18 です．
int main()
{
    INIT;

// 
// 2 つの数の桁数が異なる場合、桁の多い数の方が大きいです。
// 桁数が等しい場合、数の大小は大きい桁から順に並べた文字列の辞書式比較と等しくなる
	char a[100+2], b[100+2];
	int r;
    cin >>a >> b;

 

		r=strlen(a)-strlen(b);
		if(r==0)
		{
			r=strcmp(a, b);
		}
		if(r>0) printf("GREATER\n");
		if(r<0) printf("LESS\n");
	if(r==0) printf("EQUAL\n");
	
    return 0;
}


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

# AtCoder Beginner Contest
# Problem C


def count_initial_name(people_count: int) -> dict:
    matching_strings_count = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}

    for person in range(people_count):
        initial_name = input()[0]

        if initial_name in matching_strings_count.keys():
            matching_strings_count[initial_name] += 1

    return matching_strings_count


def count_patterns(matching_strings_count):
    import itertools

    patterns = itertools.combinations(matching_strings_count.keys(), 3)
    pattern_count = 0

    for a_pattern in patterns:
        pattern_count += matching_strings_count[a_pattern[0]] * \
            matching_strings_count[a_pattern[1]] * \
            matching_strings_count[a_pattern[2]]
    return pattern_count


if __name__ == '__main__':
    matching_strings_count = count_initial_name(people_count=int(input()))

    if sum(matching_strings_count.values()) >= 3:
        print(count_patterns(matching_strings_count))
    else:
        print(0)


Measured memory_bytes: 3064
import java.util.*;

class Edge{
	int a,b,c;
	public Edge(int A,int B,int C){
		a=A;
		b=B;
		c=C;
	}
}
class Main{
	static Scanner s=new Scanner(System.in);

	static int gInt(){
		return Integer.parseInt(s.next());
	}

	public static void main(String[]$){
		final long INIT=Long.MAX_VALUE;

		TreeMap<Integer,List<Edge>>a=new TreeMap<>();
		int n=gInt(),m=gInt();
		long[] pos=new long[n];
		Arrays.fill(pos,INIT);

		for(int q=0;q<m;++q){
			int l=gInt()-1,r=gInt()-1,d=gInt();
			a.computeIfAbsent(l,(i)->new ArrayList<>(1)).add(new Edge(l,r,d));
			a.computeIfAbsent(r,(i)->new ArrayList<>(1)).add(new Edge(r,l,-d));
		}

		Deque<Edge> d=new ArrayDeque<>();
		while(!a.isEmpty()){
			d.addAll(a.pollFirstEntry().getValue());
			while(!d.isEmpty()){
				Edge o=d.poll();
				if(pos[o.a]==INIT){
					pos[o.a]=0;
				}
				if(pos[o.b]==INIT){
					pos[o.b]=pos[o.a]+o.c;
					List<Edge> v=a.remove(o.b);
					if(v!=null)
						d.addAll(v);
				}
				if(pos[o.b]-pos[o.a]!=o.c){
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 120848
import numpy as np


dp = np.zeros((2, 4), dtype=np.int64)
mod = 1e9+7
dp[0][0] = 1
for s in input():
    if s == '?':
        dp[1] = dp[0]*3
        dp[1][1:] += dp[0][:3]
        dp[1] = np.remainder(dp[1], mod)
    else:
        dp[1] = dp[0]
        if s == 'A':
            dp[1][1] += dp[0][0]
            dp[1][1] = np.remainder(dp[1][1], mod)
        elif s == 'B':
            dp[1][2] += dp[0][1]
            dp[1][2] = np.remainder(dp[1][2], mod)
        elif s == 'C':
            dp[1][3] += dp[0][2]
            dp[1][3] = np.remainder(dp[1][3], mod)
    dp[0] = dp[1]
print(dp[0][3])


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

using namespace std;

int main(){
while(1){
int H, W;
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 || i == H - 1 || j == 0 || j ==W - 1) cout<<"#";
else cout <<".";
}
cout<<endl;
}
cout<<endl;
}
}



Measured memory_bytes: 3020
#include <stdio.h>
#include <inttypes.h>

int main(){
    intmax_t a, b, gcd, lcm;
    while(scanf("%jd %jd", &a, &b) != EOF){
        gcd = calcGCD(a, b);
        lcm = a * b / gcd;
        printf("%jd %jd\n", gcd, lcm);
    }
    return 0;
}

int calcGCD(intmax_t a, intmax_t b){
    int r;

    if(a < b){
        a = a ^ b;
        b = a ^ b;
        a = a ^ b;
    }

    while(1){
        r = a % b;
        if(r == 0){
            break;
        }
        a = b;
        b = r;
    }
    return b;
}

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

int main(){
	for(int i=1;i<=10000;i++){
	    int a,b;
	    cin>>a>>b;
	    if(a==b&&b==0){
	        break;
	    }
	    if(a<=b){
	        cout<<a<<" "<<b<<endl;
	    }
	    else{
	        cout<<b<<" "<<a<<endl;
	    }
	}
}



Measured memory_bytes: 2960
using System;
using System.Linq;

namespace AtCoderTutorial
{
    public class AtCoder174
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToList();
            int N = input[0];
            int D = input[1];

            var total = 0;
            for (int i = 0; i < N; i++)
            {
                var points = Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToList();
                if (Math.Sqrt(Math.Pow(points[0], 2) + Math.Pow(points[1], 2)) <= D)
                {
                    total++;
                }
            }


            Console.WriteLine(total);
        }
    }
}

Measured memory_bytes: 41312
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.awt.Point;


public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int n = Integer.parseInt(br.readLine());
        
        System.out.println(3 * (int)Math.pow(n,2));
    }

    
}





Measured memory_bytes: 22484
/**
 * Created by hiramekun at 20:56 on 2020-05-17.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll a, b, h, m;
    cin >> a >> b >> h >> m;
    double long_m = 6;
    double short_m = 0.5;
    double long_kakudo = long_m * m;
    double short_kakudo = 30 * h + short_m * m;
    double aida = max(long_kakudo, short_kakudo) - min(long_kakudo, short_kakudo);
    double r = aida * 2 * M_PI / 360;
    cout << fixed << setprecision(10) << sqrt(a * a + b * b - 2 * a * b * cos(r)) << endl;
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int main() {
    string s;
    int cnt = 0, maxv = -1;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            cnt++;
        } else {
            cnt = 0;
        }
        maxv = max(cnt, maxv);
    }
    cout << maxv << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

int main(void)
{
	int a, b, c;
	while(scanf("%d%d%d", &a, &b, &c)==3)
	{
		int f=0;
		if(a==b) f++;
		if(b==c) f++;
		if(c==a) f++;

		bool ans=(f==1);
		printf("%s\n", ans?"Yes":"No");
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <limits.h>

using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<lint> vl;
typedef pair<lint,lint> pll;

#define mpr make_pair


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

    lint x; cin>>x;

    map<lint, lint> five;
    for (lint i=0; i<1000; i++){
        //if (i*i*i*i*i < )
        five[i*i*i*i*i] = i;
    }

    for (lint i=0; i<1000; ++i){
        lint need = i*i*i*i*i - x;
        int flag = 1;
        if (need < 0){
            flag = -1;
            need = -need;
        }
        if (five.count(need)){
            cout<<i << " "<<flag*five[need];
            return 0;
        }
    }


}


Measured memory_bytes: 3720
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	N, K := ReadInt(), ReadInt()
	A := ReadInts(N)
	var plusCount, minusCount int
	for i := 0; i < N; i++ {
		if A[i] > 0 {
			plusCount++
		} else if A[i] < 0 {
			minusCount++
		}
	}
	if K == N || (plusCount == 0 && K%2 == 1) {
		sort.Slice(A, func(i, j int) bool {
			return Abs(A[i]) < Abs(A[j])
		})
		p := 1
		for i := 0; i < K; i++ {
			p = ModMul(p, A[i])
		}
		fmt.Println(p)
		return
	}
	sort.Slice(A, func(i, j int) bool {
		return Abs(A[i]) > Abs(A[j])
	})
	p := 1
	pSign := 1
	lastMinus := 0
	lastPlus := 0
	for i := 0; i < K; i++ {
		p = ModMul(p, A[i])
		if A[i] == 0 {
			fmt.Println(0)
			return
		}
		if A[i] < 0 {
			pSign *= -1
			lastMinus = A[i]
		} else if A[i] > 0 {
			lastPlus = A[i]
		}
	}
	if pSign == 1 {
		fmt.Println(p)
		return
	}

	nextMinus := 0
	nextPlus := 0
	for i := N - 1; i >= K; i-- {
		if A[i] > 0 {
			nextPlus = A[i]
		} else if A[i] < 0 {
			nextMinus = A[i]
		}
	}

	if lastPlus != 0 && nextMinus != 0 && Abs(nextPlus*lastPlus) < Abs(lastMinus*nextMinus) {
		p = ModDiv(p, lastPlus)
		p = ModMul(p, nextMinus)
	} else {
		p = ModDiv(p, lastMinus)
		p = ModMul(p, nextPlus)
	}
	fmt.Println(p)
}

const Mod = int(1e9) + 7

func ModMul(a, b int) int  { return (Mod + a%Mod) * (Mod + b%Mod) % Mod }
func ModInverse(n int) int { return ModPow(n, Mod-2) }
func ModDiv(a, b int) int  { return a * ModInverse(b) }
func ModPow(a, b int) (x int) {
	for x = 1; b > 0; b >>= 1 {
		if b&1 == 1 {
			x = x * a % Mod
		}
		a = a * a % Mod
	}
	return
}

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 6024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
    fast;
    
    long double n, d;
    cin>>n>>d;
    long double x, y;
    ll ans=0;
    forn(i, 0, n){
        cin>>x>>y;
        if(sqrt(x*x + y*y)<=d){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3872
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

bool dp[100100];

int main(void){
    int n, k;
    cin >> n >> k;

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

    dp[0] = false;

    for(int i = 1; i <= k; i++){
        for(int j = 0; j < n; j++){
            bool win = false;
            bool canact = false;
            if(i - a[j] >= 0){
                canact = true;
                if(!dp[i - a[j]]){
                    win = true;
                }
            }
            if(!canact) continue;
            if(win){
                dp[i] = true;
            }
        }
    }

    if(dp[k]){
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
}

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

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), b(n, 0), p(n);
    a[0] = 1;
    for (int i = 1; i < n; i++) a[i] = a[i - 1] + n;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }
    b[p[0]] = a[n - 1];
    for (int i = 1; i < n; i++) {
        if (b[p[i]] != 0) continue;
        b[p[i]] = a[p[i - 1]] + b[p[i - 1]] + 1 - a[p[i]];              
    }
    for (int i = 0; i < n; i++) {
        cout << a[i];
        if (i != n - 1) cout << " ";
        else cout << endl;
    }    
    for (int i = 0; i < n; i++) {
        cout << b[i];
        if (i != n - 1) cout << " ";
        else cout << endl;
    }
    return 0;
}

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

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
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; }
/**************************************/

/******** User-defined Function *******/




/**************************************/

/********** Main()  function **********/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int x,n; cin >> x >> n;
  set<int> s;
  rep(i,n){
      int a; cin >> a;
      s.insert(a);
  }

  rep(i,101){
      int x1 = x-i;
      int x2 = x+i;

      set<int>::iterator iti = s.find(x1);    // find() で要素が見つかれば、要素へのイテレータが得られる。
      if (iti == s.end()) {
          cout << x1 << endl;
          return 0;
      }

      set<int>::iterator iti2 = s.find(x2);    // find() で要素が見つかれば、要素へのイテレータが得られる。
      if (iti2 == s.end()) {
          cout << x2 << endl;
          return 0;
      }


  }

  return 0;
}
/********  Main() Ends Here *************/


Measured memory_bytes: 3664
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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







int main(){
    int n, ans(0); std::cin >> n;
    if (n == 0 || n == 2) ans = 1;
    else if (n == 1) ans = 2;
    std::cout << ans << std::endl;
    return 0;
}



Measured memory_bytes: 3108
n = int(input())
f = [list(map(int,input().split())) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]

def calcBit(num):
    res = []
    for _ in range(10):
        res.append(num%2)
        num >>= 1
    return res

ans = -float('inf')
for i in range(1,2**10):
    ans_t = 0
    for k,l in enumerate(f):
        tmp = 0
        for (a,b) in zip(l,calcBit(i)):
            if a==1 and b==1:
                tmp += 1
        ans_t += p[k][tmp]
    ans = max(ans,ans_t)

print(ans)


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

int s[1000001],f[1000001],t,n;
const int mod = 1e9+7;
main() {
	cin >> n;
	if (n == 1) {
		cout << 1;
		exit(0);
	}
	f[0] = 1;
	f[1] = n;
	s[0] = 1;
	s[1] = n+1;
	t = 1ll*(n-1)*(n-1)%mod;
	for (int i = 2; i <=n ;i++) {
	    f[i] = (1ll*t + (n - i + 1) + f[i-1] + (i >= 3 ? s[i-3] : 0))%mod;
	    s[i] = s[i-1] + f[i];
	    if (s[i] > mod) s[i] -= mod;
	}
	cout << f[n];
}

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

using namespace std;
typedef long long ll;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> H;
	vector<bool> good(N,true);
	for (int i = 0; i<N; i++){
		int tn; cin >> tn;
		H.push_back(tn);
	}
	for (int i = 0; i<M; i++){
		int a, b;
		cin >> a >> b;
		if (H[a-1] > H[b-1]){
			good[b-1] = false;
		} else if (H[a-1] < H[b-1]) {
			good[a-1] = false;
		} else {
			good[a-1] = false;
			good[b-1] = false;
		}
	}
	int ans = 0;
	for (int i = 0; i<N; i++){
		if (good[i]) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3944
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int NMAX=1000010;

ll fac[NMAX], finv[NMAX], inv[NMAX];

void init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < NMAX; i++) {
    fac[i] = fac[i-1] * i % mod;
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}

ll C(int n,int k) {
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main() {
  init();
  int X, Y; cin >> X >> Y;
  if((X+Y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  int n = (X+Y) / 3+1;
  int k = 2*(n-1) - Y + 1; // y = 2xより最も上にくる点からどれだけ離れているか。
  cout << C(n-1, k-1) << endl;
  return 0;
}


Measured memory_bytes: 23680
N = int(input())
P = list(map(float, input().split()))

# dp[i][j] := i番目までのコインを投げて、表がj枚出るものの確率
dp = [[0] * (N + 1) for i in range(N)]
dp[0][0] = (1 - P[0])
dp[0][1] = P[0]

for i in range(1, N):
    for j in range(i + 2):
        dp[i][j] = dp[i - 1][j] * (1 - P[i]) + dp[i - 1][j - 1] * P[i]

print(sum(dp[-1][N // 2 + 1:]))


Measured memory_bytes: 262536
n,a,b,c,d = map(int, input().split())
s = input()

long_s = s[a-1:max(c,d)]
short_s = s[b-2:min(c,d)+1]
rocks = long_s.count("##")
change = short_s.count("...")

if rocks >= 1:
  print("No")
elif c > d and change == 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3700