akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
using namespace std;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
signed main(){
  int H,W;
  cin>>H>>W;
  vector<string> A(H);
  for(string &S:A)
    cin>>S;
  vector<vector<bool>> B(H,vector<bool>(W,true));
  queue<pair<pair<int,int>,int>> C;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      if(A[i][j]=='#'){
        C.push({{i,j},0});
        B[i][j]=false;
      }
  int ans=0;
  while(!C.empty()){
    pair<pair<int,int>,int> p=C.front();
    C.pop();
    ans=max(ans,p.second);
    for(int i=0;i<4;i++){
      int x=p.first.first+dx[i],y=p.first.second+dy[i];
      if(0<=x && x<H && 0<=y && y<W && B[x][y]){
        C.push({{x,y},p.second+1});
        B[x][y]=false;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 29500
#include<iostream>
#include<stdlib.h>
using namespace std;

int main() {
    int n,t,x,y,dx[4]={1,-1,0,0}, dy[4]={0,0,1,-1};
    int tt=0,tx=0,ty=0;
    cin >> n;

    while(n--) {
        cin>>t>>x>>y;
        int absxy = abs(x-tx) + abs(y-ty);
        if(absxy > t-tt || (absxy%2) != ((t-tt)%2)) {
            cout << "No" << endl;
            return 0;
        }
        tx = x; ty = y; tt = t;
    }
    cout << "Yes" << endl;
}

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

using namespace std;

int main(){

	int n;
	
	while(1){

		cin >> n;
		if(cin.eof())
			break;

		int count = 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)
							count++;
					}
				}
			}
		}
		
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>

#define ll long long

using namespace std;

int main(){

    ll w,h,x,y;

    cin >> w >> h >> x >> y;

    int g = 0;

    if(w / 2 == x && w % 2 == 0 && h / 2 == y && h % 2 == 0){
        g = 1;
    }

    w = (double)w;
    h = (double)h;

    ll a = w * h;
    ll amari = a % 2;
    a = a / 2;

    double b = (double)a;

    if(amari == 1){
        b = b + 0.5;
    }

    cout << b << " " << g << endl;


    return 0;
}   

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int x,y,i,a,b;
    for(i=0;i<3001;i++){
        scanf("%d%d",&x,&y);
        if(x > y){
            a = x;
            b = y;
            y = a;
            x = b;
        }
        if(x == 0 && y == 0){
            break;
        }
        printf("%d %d\n",x,y);
    }
    return 0;
    
}


Measured memory_bytes: 1928
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s1,s2,s3;
  char a,b,c;
  cin>>s1>>s2>>s3;
  a=s1.at(0);
  b=s2.at(0);
  c=s3.at(0);
  cout<<a<<b<<c<<endl;
  return 0;
}
 

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

const int N = 2003;
int dist[N][N];
int n;

vector<int> e[N];

void bfs(int s){
    for(int i = 1; i <= n; i++) dist[s][i] = INF;
    queue<int> q;
    dist[s][s] = 0;
    q.push(s);
    while(q.size()){
        int u = q.front();
        q.pop();
        for(int v : e[u]){
            if(dist[s][v] > dist[s][u] + 1){
                dist[s][v] = dist[s][u] + 1;
                q.push(v);
            }
        }
    }
}

int main(){
    fcin;
    int x, y;
    cin >> n >> x >> y;
    for(int i = 1; i < n; i++){
        e[i].pb(i+1);
        e[i+1].pb(i);
    }
    e[x].pb(y);
    e[y].pb(x);
    for(int i = 1; i <= n; i++) bfs(i);
    
    vector<int> ans(n, 0);
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            ans[dist[i][j]]++;
        }
    }
    for(int i = 1; i < n; i++) cout << ans[i] << endl;
    return 0;
}



Measured memory_bytes: 16000
import sys
import numpy as np

if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')

    @cc.export('is_ok', '(i8[:],i8[:],i8,i8)')
    def is_ok(A, F, x, k):
        tmp = 0
        for a, f in zip(A, F):
            y = a * f
            if y > x:
                tmp += a - x // f
        return tmp <= k

    cc.compile()
    exit(0)

from my_module import is_ok
n, k = map(int, input().split())
A = np.array(list(map(int, input().split())))
F = np.array(list(map(int, input().split())))

A = np.sort(A)
F = np.sort(F)[::-1]

ok = 10 ** 12
ng = -1
while ok - ng > 1:
    mid = (ok + ng) // 2
    if is_ok(A, F, mid, k):
        ok = mid
    else:
        ng = mid

print(ok)


Measured memory_bytes: 53432
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

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

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

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

const double PI = acos(-1.0);


int main()
{
	int n;
	while (cin >> n, n)
	{
		int tx[128][128], ty[128][128];
		rep (i, n)
			rep (j, n)
				cin >> tx[i][j] >> ty[i][j];

		int visit[128][128];
		memset(visit, -1, sizeof(visit));

		int res = 0;
		for (int y = 0; y < n; ++y)
		{
			for (int x = 0; x < n; ++x)
			{
				int mark = n * y + x;
				if (visit[y][x] == -1)
				{
					int cx = x, cy = y;
					while (visit[cy][cx] == -1)
					{
						visit[cy][cx] = mark;
						int xx = cx, yy = cy;
						cx = tx[yy][xx];
						cy = ty[yy][xx];

						if (visit[cy][cx] == mark)
							++res;
					}
				}
			}
		}
		cout << res << endl;
	}
}

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

using namespace std;

int main(void) {
  string S; int Q; cin >> S >> Q;
  bool isReverse = false;
  string r = "", l = "";

  for (int i = 0; i < Q; i++) {
    int q; cin >> q;
    if (q == 1) {
      isReverse = !isReverse;
    } else {
      int f; char c; cin >> f >> c;
      if (isReverse) {
        if (f == 1) {
          r += c;
        } else {
          l += c;
        }
      } else {
        if (f == 1) {
          l += c;
        } else {
          r += c;
        }
      }
    }
  }

  if (isReverse) {
    reverse(S.begin(), S.end());
    reverse(r.begin(), r.end());
    cout << r << S << l << endl;
  } else {
    reverse(l.begin(), l.end());
    cout << l << S << r << endl;
  }

  return 0;
}

Measured memory_bytes: 1088
ABC = sorted(list(map(int,input().split())))
d1 = ABC[-1]-ABC[0]
d2 = ABC[-1]-ABC[1]
ans = 0
if d1 % 2 == 0 and d2 % 2 == 0:
    print(d1//2+d2//2)
elif d1 % 2 != 0 and d2 % 2 != 0:
    print(d1//2+d2//2+1)
else:
    if d1 % 2 == 0:
        ans += d1 // 2
        ans += d2 // 2 + 2
        print(ans)
    else:
        ans += d2 // 2
        ans += d1 // 2 + 2
        print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#define ll long long
using namespace std;
ll gcd(ll a, ll b);
ll sosuu(ll x);
int main() {
	ll a, b,r,tmp;
	cin >> a >> b;

	b = gcd(a, b);
	cout <<sosuu(b)+1 << endl;



}


/* ユークリッドの互除法 */
ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
/*xまでの素数の個数*/
ll sosuu(ll x) {
	ll b = x;
	ll ans=0;
	for (ll i = 2; i*i <= x; i++) {
		if (b%i == 0) {
			while (b%i == 0) {
				b = b / i;
			}
			ans++;
		}
	}
	if (b != 1) {
		ans++;
	}
	return ans;
}



Measured memory_bytes: 256
#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 pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
	string s;
	vi v;
	cin >> s;
	rep(i,s.size()){
		if(s[i]=='0') v.pb(0);
		else if(s[i]=='1') v.pb(1);
		else  if(v.size()>0) v.erase(v.end()-1,v.end());
	}
	rep(i,v.size()) cout << v[i];
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
n,s,*a=map(int,open(0).read().split())
d=[0]*3001
c=0
for i,a in enumerate(a):
    for j in range(s-a,0,-1):d[a+j]+=d[j]
    d[a]-=~i
    c+=d[s]
print(c%(998244353))

Measured memory_bytes: 66524
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
constexpr double PI = 3.141592653589793;

using namespace std;
//    cout << setprecision(20) << ans << "\n";

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> graph(n + 1);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }
    queue<int> q;
    q.push(0);
    vector<int> ans(n, -1);
    while (!q.empty())
    {
        int current = q.front();
        q.pop();
        for (int i = 0; i < graph[current].size(); i++)
        {
            if (ans[graph[current][i]] != -1)
            {
                continue;
            }
            ans[graph[current][i]] = current;
            q.push(graph[current][i]);
        }
    }
    if (any_of(ans.begin(), ans.end(), [](int x) {
            return x == -1;
        }))
    {
        cout << "No"
             << "\n";
    }
    else
    {
        cout << "Yes"
             << "\n";
        for (int i = 1; i < n; i++)
        {
            cout << ans[i] + 1 << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 10100
#include<stdio.h>
int main(){
	int dice[6],num,x1,y1,x2,y2;
	for(int i = 0;i<6;i++){
		scanf("%d",&dice[i]);
	}
	scanf("%d",&num);
	for(int i=0;i<num;i++){
			scanf("%d %d",&x1,&y1);
		for(int i = 0;i<6;i++){
			if(x1==dice[i]){
				x2=i;
			}
			if(y1==dice[i]){
				y2=i;
			}
		}
		if((x2==1&&y2==2)||(x2==2&&y2==4)||(x2==4&&y2==3)||(x2==3&&y2==1)){
			printf("%d\n",dice[0]);
		}
		else if((x2==5&&y2==2)||(x2==2&&y2==0)||(x2==0&&y2==3)||(x2==3&&y2==5)){
			printf("%d\n",dice[1]);
		}
		else if((x2==0&&y2==1)||(x2==1&&y2==5)||(x2==5&&y2==4)||(x2==4&&y2==0)){
			printf("%d\n",dice[2]);
		}
		else if((x2==0&&y2==4)||(x2==4&&y2==5)||(x2==5&&y2==1)||(x2==1&&y2==0)){
			printf("%d\n",dice[3]);
		}
		else if((x2==2&&y2==5)||(x2==5&&y2==3)||(x2==3&&y2==0)||(x2==0&&y2==2)){
			printf("%d\n",dice[4]);
		}
		else{
			printf("%d\n",dice[5]);
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define int ll
#define pb push_back
#define lb lower_bound

void pre() {
}

void solve() {
//    int n;
//    cin >> n;
//    vi a(n);
//    for (auto &i:a)cin >> i;
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin>>n;
    cout<<a[n-1];
}

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

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

int main() {
  int n;
  cin >> n;
  cout << 1 << endl;
  int a[3];
  a[2] = 1000000001;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }

  int i = 2;
  while( 1 ) {
    if( i > min(a[0], min(a[1], a[2])) ) break;
    int flag = true;
    for(int j=0; j<n; j++) {
      if( a[j] % i != 0 ) {
	flag = false;
      }
    }
    if( flag ) {
      cout << i << endl;
    }
    i++;
  }

}  

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	string a;
	cin>>a;
	
	cout<<"2018";
	for(int q=4;q<a.size();q++)cout<<a[q];
	cout<<endl;
}

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

int selectionSort(int A[], int N) {
    int i, j, sw = 0, minj;
    for ( i = 0; i < N - 1; i++ ) {
        minj = i;
        for ( j = i; j < N; j++ ) {
            if ( A[j] < A[minj] ) minj = j;
        }
        swap(A[i], A[minj]);
        if ( i != minj ) sw++;
    }
    return sw;
}

int main() {
    int N, sw, i, A[100];
    cin >> N;
    for ( i = 0; i < N; i++ ) cin >> A[i];

    sw = selectionSort(A, N);

    for ( i = 0; i < N; i++ ) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;

    return 0;
}



Measured memory_bytes: 3112
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

const int MAX = 100005;
const int NIL = -1;

struct Node
{
    int parent, left, right;
};

Node T[MAX];
int n, D[MAX], H[MAX];
int getsibling(int u)
{
    if (T[u].parent == NIL)
        return -1;
    if (T[T[u].parent].left != u && T[T[u].parent].left != NIL)
        return T[T[u].parent].left;

    if (T[T[u].parent].right != NIL && T[T[u].parent].right != u)
        return T[T[u].parent].right;

    return NIL;
}
void print(int u)
{
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "sibling = " << getsibling(u) << ", ";
    cout << "degree = ";

    int deg = 0;
    if (T[u].right != NIL)
        deg++;
    if (T[u].left != NIL)
        deg++;

    cout << deg << ", ";
    cout << "depth = " << D[u] << ", ";
    cout << "height = " << H[u] << ", ";

    if (T[u].parent == NIL)
        cout << "root";
    else if (T[u].left == NIL && T[u].right == NIL)
        cout << "leaf";
    else
        cout << "internal node";

    cout << endl;
}

void setDepth(int u, int d)
{
    if (u == NIL)
        return;
    D[u] = d;
    setDepth(T[u].left, d + 1);
    setDepth(T[u].right, d + 1);
}

int setHeight(int v)
{
    int h1 = 0, h2 = 0;

    if (T[v].left != NIL)
    {
        h1 = setHeight(T[v].left) + 1;
    }
    if (T[v].right != NIL)
    {
        h2 = setHeight(T[v].right) + 1;
    }

    return H[v] = max(h1, h2);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    cin >> n;
    for (int i = 0; i < n; ++i)
        T[i].parent = NIL;

    for (int i = 0; i < n; ++i)
    {
        int v, l, r; //vは節点の番号
        cin >> v >> l >> r;
        T[v].left = l;
        T[v].right = r;
        if (l != NIL)
            T[l].parent = v;
        if (r != NIL)
            T[r].parent = v;
    }

    int root = 0;
    for (int i = 0; i < n; ++i)
        if (T[i].parent == NIL)
            root = i;
    setDepth(root, 0);
    setHeight(root);

    for (int i = 0; i < n; ++i)
        print(i);
    return 0;
}


Measured memory_bytes: 3176
#include "stdio.h"

int main(void){
	int INPUT;
	int I1, I10, I100, I1000;

	scanf("%d", &INPUT);

	I1 = INPUT%10;
	I10 = (INPUT%100)/10;
	I100 = (INPUT%1000)/100;
	I1000 = (INPUT%10000)/1000;

	if((I1==I10&&I10==I100)||(I10==I100&&I100==I1000))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	
	return 0;
}

Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::max;
use std::cmp::min;

fn main() {
    let o: String = read();
    let e: String = read();
    let ov: Vec<char> = o.chars().collect();
    let ev: Vec<char> = e.chars().collect();
    let mut ans: String = "".to_string();

    for i in 0..o.len() {
        ans += &ov[i].to_string();
        if i < e.len() {
            ans += &ev[i].to_string();
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#pragma GCC target ("avx2")
#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
//#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll res=0,n,m,k,a,b,mxr=INT_MIN,mxc=INT_MIN,mn=INT_MAX;
    cin>>n>>m>>k;
    vector<pll> v;
    mll r,c;
    map<pair<ll,ll>,ll> mp;
    ll ans=0;
    for(ll i=0;i<k;i++)
    {
        cin>>a>>b;
        v.pb({a,b});
        mp[{a,b}]++;
        r[a]++;
        c[b]++;
    }
    for(ll i=1;i<=n;i++)
    {
        if(r[i]>mxr)
        {
            mxr=r[i];
            a=i;
        }
    }
    for(ll i=1;i<=m;i++)
    {
        if(c[i]>mxc)
        {
            mxc=c[i];
            b=i;
        }
    }
    if(mxr>mxc)
    {
        for(ll i=1;i<=m;i++)
        {
            if(mp.find({a,i})==mp.end())
            res=mxr+c[i];
            else
            {
                res=mxr+c[i]-1;
            }
            ans=max(ans,res);
        }
    }
    else
    {
        for(ll i=1;i<=n;i++)
        {
            if(mp.find({i,b})==mp.end())
                res=mxc+r[i];
            else
                res=mxc+r[i]-1;
            ans=max(ans,res);
        }
    }
    cout<<ans<< "\n";
    mp.clear();
    v.clear();
    r.clear();
    c.clear();
    return 0;
}


Measured memory_bytes: 64292
#include <iostream>

using namespace std;

int main()
{
    int sum=0,n,a[200000+10]={0};
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int g;
    g=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]-g==1)
        {
            sum++;
            g++;
        }
    }
    if(sum==0)
        cout<<-1;
    else
    cout<<n-sum;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

template<typename T> //最大公約数
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T> //最小公倍数
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; 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;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}


struct UnionFind {
	vector<int> par, rank, cnt;
	UnionFind(int n) : par(n), rank(n, 0), cnt(n, 1){
		for(int i = 0; i < n; ++i) par[i] = i;
	}
 
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}
	
 
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
 
		if (rank[x] < rank[y]) swap(x, y);
 
		par[y] = x;
		cnt[x] += cnt[y];
		if (rank[x] == rank[y]) rank[x]++;
	}
 
	bool same(int x, int y) {
		return find(x) == find(y);
	}
 
	int size(int x) {
		return cnt[find(x)];
	}
};

vector<int> dist;
int dfs(int pos, vector<vector<int> > &g){
	int maxDist = 0;
	for (int i = 0; i < g[pos].size(); i++){
		int to = g[pos][i];
		if (dist[to] != -1){
			maxDist = max(maxDist, dist[to]+1);
			continue;
		}
		int toDist = dfs(to, g);
		maxDist = max(maxDist, toDist + 1);
	}
	dist[pos] = maxDist;
	return maxDist;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main(){
        int A, B; cin >> A >> B;
        for (int i = B; i <= 1000; i++){
                int a = i * 0.08 / 1;
                int b = i * 0.10 / 1;
                if (a == A && b == B){
                        cout << i << endl;
                        return 0;
                }
        }
        cout << -1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 100000
using namespace std;

int main(){
  int n;  cin >> n;
  int i=0, ans=0, ipow2;
  while(true){
    ipow2 = pow(i, 2);
    if(pow(i, 2)<=n){
      ans = ipow2;
    }else{
      break;
    }
    i++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,m,nx,ny = map(int, input().split())

x = list(map(int,input().split()))
y = list(map(int,input().split()))

x.sort()
y.sort()

if (x[n-1] < y[0]) and (nx < y[0]) and (x[n-1] < ny) and (nx < ny) :
   print('No War')
else :
   print('War')

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define pye cout << "Yes" << endl;
#define pno cout << "No" << endl;
#define prin(num) cout << num << endl;
#define sprin(str) cout << "str" << endl;
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100001
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef pair<double, double> doup;
//typedef vector<ll> vec;
//typedef vector<vec> mat;


int main() {
    ll N, i;
    cin >> N;
    ll t, ans=N, cnt;
    for(i=0; i<=N; i++) {
        cnt=0;
        t=i;
        while(t>0) {
            cnt+=t%6;
            t/=6;
        }
        t=N-i;
        while(t>0) {
            cnt+=t%9;
            t/=9;
        }
        ans=min(ans, cnt);
    }
    prin(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
typedef pair<int,int> pii;

inline bool IN(int x, int y, int w, int h)
{
    return 0 <= x && x < w && 0 <= y && y < h;
}


int main()
{
	int a,b,c,d,e,f;
	    float x,y,dx,dy;
	    while( cin >> a >> b >>c >>d >> e >> f ) {
	        x = (c*e-b*f)/(float)(a*e-b*d);
	        y = (c - a*x)/(float)b;


	        printf("%.3f %.3f\n",x+EPS,y+EPS);
	    }

	return 0;
}

Measured memory_bytes: 1196
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), K = sc.nextInt(), t = 0, i = 0, ct = 0;
		Map<Integer, Integer> c = new HashMap<Integer, Integer>();
		while (N-->0) {
			int a = sc.nextInt();
			c.put(a, c.get(a)==null ? 1 : c.get(a)+1);
		}
		List<Map.Entry<Integer, Integer>> list = new ArrayList<Map.Entry<Integer, Integer>>(c.entrySet());
		Collections.sort(list, new Comparator<Map.Entry<Integer, Integer>>() {
			public int compare(Map.Entry<Integer, Integer> o1,
				Map.Entry<Integer, Integer> o2) {
				return o2.getValue().compareTo(o1.getValue());
			}
		});
		for (Map.Entry<Integer, Integer> e : list) if (++ct>K) t+=e.getValue();
		System.out.println(t);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

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

const int MAXN = 1e5+5;
int dp[MAXN][3],a[MAXN][3];

int main()
{
    int n;cin >> n;
    vector<int> dp(3);

    for(int i=1;i<=n;++i){
        vector<int> new_dp(3);
        vector<int> c(3);
        for(int j=0;j<3;++j){
            cin >> c[j];
        }
        for(int i=0;i<3;++i){
            for(int j=0;j<3;++j){
                if(i==j) continue;
                new_dp[i] = max(new_dp[i],dp[j]);
            }
            new_dp[i] += c[i];
        }
        dp = new_dp;
    }

    int maxs=0;
    for(int i=0;i<3;++i){
        maxs = max(maxs,dp[i]);
    }
    cout << maxs;
}


Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int64 INF = 1e15;

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

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

  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());

  auto ok = [&](int64 score) -> bool {
    int64 sum = 0LL;
    for (int i = 0; i < n; ++i) {
      if (a[i] * f[i] <= score) continue;
      sum += a[i] - score / f[i];
    }
    return sum <= k;
  };

  int64 high = INF, low = -1LL;
  while (high - low > 1LL) {
    int64 mid = (high + low) / 2;
    if (ok(mid)) {
      high = mid;
    } else {
      low = mid;
    }
  }

  cout << high << endl;

  return 0;
}

Measured memory_bytes: 3456
import numpy as np
N,W=list(map(int,input().split()))
DP=np.zeros(W+1)

for i in range(N):
    w,v=list(map(int,input().split()))
    a=DP[:-w]+v
    b=DP[w:]
    c=np.maximum(a,b)
    DP[w:]=c



print(int(DP[-1]))
# for i in DP:
#     print(i)


Measured memory_bytes: 17104
# エラトステネスの篩, フェルマーの小定理
def make_prime_table(N):
    sieve = [0] * (N + 1)
    sieve[0] = -1
    sieve[1] = -1
    for i in range(2, N + 1):
        if sieve[i] != 0:
            continue
        sieve[i] = i
        for j in range(i * i, N + 1, i):
            if sieve[j] == 0:
                sieve[j] = i
    return sieve


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

m = 1000000007

sieve = make_prime_table(1000000)

lcm_factors = {}
for i in range(N):
    t = []
    a = A[i]
    while a != 1:
        if len(t) != 0 and t[-1][0] == sieve[a]:
            t[-1][1] += 1
        else:
            t.append([sieve[a], 1])
        a //= sieve[a]
    for k, v in t:
        if k not in lcm_factors or lcm_factors[k] < v:
            lcm_factors[k] = v

lcm = 1
for k in lcm_factors:
    for i in range(lcm_factors[k]):
        lcm *= k
        lcm %= m

result = 0
for i in range(N):
    result += lcm * pow(A[i], m - 2, m)
    result %= m
print(result)


Measured memory_bytes: 82764
can = [0]
gets
a = gets.split.map &:to_i
gets
m = gets.split.map &:to_i
a.each_with_index {|e,i|
  i == 0 ? can << e : can.concat(can.map {|ele| ele + e})
  can.uniq!
}
m.each{|e|
  puts can.include?(e) ? 'yes' : 'no'
}

Measured memory_bytes: 6196
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s=="SUN") cout<<7;
    else if(s=="MON") cout<<6;
    else if(s=="TUE") cout<<5;
    else if(s=="WED") cout<<4;
    else if(s=="THU") cout<<3;
    else if(s=="FRI") cout<<2;
    else if(s=="SAT") cout<<1;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define NIL -1
#define N 250

int n, A[N];


void init(){
  int i;
  for(i = 0; i < N; i++){
    A[i] = NIL;
  }
}


int parent(int i){
  if(i/2 > n || i/2 <= 0) return NIL;
  return i/2;
}

int left(int i){
  if(2*i > n || 2*i <= 0) return NIL;
  return 2*i;
}

int right(int i){
  if(2*i+1 > n || 2*i+1 <= 0) return NIL;
   return 2*i+1;
}

int main(){

  int i, p, l, r;

  scanf("%d", &n);
  init();
  
  for ( i = 0; i < n; i++ ){
    scanf("%d", &A[i]);
  }

  for(i = 1; i <= n; i++){
    printf("node %d: key = %d, ", i, A[i-1]);
    if((p = parent(i)) != NIL) printf("parent key = %d, ", A[p-1]);
    if((l = left(i)) != NIL) printf("left key = %d, ", A[l-1]);
    if((r = right(i)) != NIL) printf("right key = %d, ", A[r-1]);
    printf("\n");
  }

  return 0;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 
	
signed main(){
	int a,b,n; cin>>a>>b>>n;
	vvi ans(a,vi(b));
	queue<int> q;
	rep(i,0,n){
		int c;
		cin>>c;
		q.push(c);
	}
	//cout<<endl;
	int cnt=1;
	pair<int,int> z=pair<int,int>(0,0);
	while(!q.empty()){
		int c=q.front(); q.pop();
		rep(i,0,c){
			int x=z.first;
			int y=z.second;
			ans[x][y]=cnt;
			if(x%2==0){
				if(y==b-1) z=pair<int,int>(x+1,y);
				else z=pair<int,int>(x,y+1);
			}
			else{
				if(y==0) z=pair<int,int>(x+1,y);
				else z=pair<int,int>(x,y-1);
			}
		}
		cnt++;
	}
	rep(i,0,a){
		rep(j,0,b){
			cout<<ans[i][j]<<" ";
		}
		cout<<endl;
	}
	
		
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios_base::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

struct ZigZag {
  const int N;
  int data[16][16];
  int index;
  ZigZag(int N) : N(N), index(1) {}
  void build(){
    int x = 0, y = 0;
    for (int i = 0; i < N - 1; i++){
      zig(x, y);
      if (x + 1 < N) x++;
      else y++;
      zag(x, y);
      if (x - 1 < 0 && y + 1 < N) y++;
      else x++;
    }
    zig(x, y);
  }
  void zig(int& x, int& y){
    while (0 <= x && x < N && 0 <= y && y < N){
      data[y--][x++] = index++;
    }
    y++, x--;
  }
  void zag(int& x, int& y){
    while (0 <= x && x < N && 0 <= y && y < N){
      data[y++][x--] = index++;
    }
    y--, x++;
  }
};

int main()
{
  int case_no = 1;
  while (int N = in()){
    ZigZag z(N);
    z.build();
    printf("Case %d:\n", case_no++);
    for (int y = 0; y < N; y++){
      for (int x = 0; x < N; x++){
        printf("%3d", z.data[y][x]);
      }
      puts("");
    }
  }
  return 0;
}

Measured memory_bytes: 1180
n,q = map(int,input().split())
s = input()

a = [0]*n
for i in range(1,n):
  a[i] = a[i-1] + (s[i-1:i+1] == "AC")
#print(a)

for _ in range(q):
  l,r = map(int,input().split())
  print(a[r-1]-a[l-1])

Measured memory_bytes: 9540
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>
#include <bitset>
#include <memory>
struct Edge {
	int to, weight;
};
int main() {
	int n; std::cin >> n;
	std::vector<std::vector<Edge>> nodes(n);
	for (auto i = 1; i < n; ++i) {
		int u, v, w; std::cin >> u >> v >> w; --u, --v;
		nodes[u].push_back(Edge{ v, w });
		nodes[v].push_back(Edge{ u, w });
	}
	std::vector<bool> color(n, false), visit(n, false);
	std::stack<int> stack; stack.push(0);
	while (!stack.empty()) {
		const auto top = stack.top(); stack.pop();
		visit[top] = true;
		for (const auto e : nodes[top]) if (!visit[e.to]) {
			if (e.weight % 2 == 0) {
				color[e.to] = color[top];
			}
			else {
				color[e.to] = !color[top];
			}
			stack.push(e.to);
		}
	}
	for (const auto b : color) {
		std::cout << (b ? '0' : '1') << '\n';
	}
}


Measured memory_bytes: 6400
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int[] num = new int[3];
    for(int i=0; i<3; i++) {
      num[i] = Integer.parseInt(str[i]);
    }
    
    Arrays.sort(num);
    
    int count = num[2]-num[1];
    count += (num[1]-num[0])/2;
    if((num[1]-num[0])%2!=0)
      count+=2;
    System.out.println(count);
  }
}

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

typedef long long int   ll;
#define int             ll
#define PI              3.1415926535897932384626433832795

#define pb              push_back
#define rep0            for(int i=0;i<n;i++)
#define rep1            for(int i=1;i<=n;i++)
#define inputar0(ar)    for(int i=0;i<n;i++)cin>>ar[i]
#define inputar1(ar)    for(int i=1;i<=n;i++)cin>>ar[i]

#define hell            freopen("input.txt","r", stdin);freopen("output.txt", "w", stdout);freopen("error.txt", "w",stderr);
#define fastasF_boi()   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
//#define cerr            if(false)cerr

int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
int binpow(int a,int b){int res=1;while(b>0){if(b%2){res=(res*a);b--;}a=(a*a);b/=2;}return res;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}
int mulmod(int a,int b){return ((a%mod)*(b%mod))%mod;}
int addmod(int a,int b){return (((a%mod)+(b%mod))+mod)%mod;}

void solve(){
    int n,d;cin>>n>>d;
    int cnt=0;
    for(int i=0;i<n;i++){

        double x,y;cin>>x>>y;
        if(sqrt(x*x+y*y)<=d) cnt++;
    }
    cout<<cnt<<endl;
}

signed main(){
//    hell;

    fastasF_boi();
    int t=1;
//    cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
}



Measured memory_bytes: 3828
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	S := sc.Text()
	sc.Scan()
	T := sc.Text()

	min := len(T)
	for i := 0; i+len(T) <= len(S); i++ {
		n := len(T) - Count(S[i:i+len(T)], T)
		if n < min {
			min = n
		}
	}

	fmt.Println(min)
}

func Count(s1, s2 string) int {
	n := 0
	for i := range s1 {
		if s1[i] == s2[i] {
			n++
		}
	}
	return n
}


Measured memory_bytes: 1780
c = []
for i in range(3):
    c.append(list(map(int,input().split())))
a = [0,0,0]
b = [0,0,0]
for i in range(3):
    b[i] = c[i][0]-0
for i in range(3):
    a[i] = c[0][i]-b[0]
for i in range(3):
    for j in range(3):
        if a[j]+b[i] != c[i][j]:
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 3064
using System;

namespace MyProgram{
    class AtCoder{
        static void Main(string[] args){
            int N = int.Parse(Console.ReadLine());
            int[] A = new int[N];
            int[] B = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            long sum=0;
            A[0] = B[0];
            A[N-1] = B[N-2];
            for(var i = 1;i<N-1;i++){
                A[i] = B[i-1]>B[i]?B[i]:B[i-1];
            }
            for(var i=0;i<N;i++){
                sum += A[i];
            }
            Console.WriteLine(sum);
        }
    }
}

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

int main() {

  vector<int> arr;
  arr = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};

  int x;
  cin >> x;
  cout << arr.at(x-1) << endl;

}


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

int main() {
  long long N,A,B;
  cin >> N>>A>>B;
  long long C=N%(A+B);
  long long D=N/(A+B);

  if (A==0) {
    cout << 0 << endl;
  }
  else if(C<=A){
    cout << A*D+C << endl;
  }
  else if(C>A){
    cout << A*D+A << endl;
  }
}


Measured memory_bytes: 256
// Create time: 2019-09-07  19:59:37
#include <bits/stdc++.h>
#define rint register int
using namespace std;

int a[1000], b[1000], c[1000];

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    int n;
    cin >> n;
    for (rint i = 1; i <= n; ++i)
        scanf("%d", a + i);
    long long ans = 0;
    for (rint i = 1; i <= n; ++i)
        scanf("%d", b + i), ans += b[i];
    for (rint i = 1; i < n; ++i)
        scanf("%d", c + i);
    for (rint i = 1; i < n; ++i)
        if (a[i + 1] == a[i] + 1)
            ans += c[a[i]];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int NN = 100000+10;
		int[] tot = new int[NN];
		for(int i=0;i<N;i++){
			tot[A[i]]++;
		}
		
		int max = 0;
		for(int i=0;i<NN-1;i++){
			int v = tot[i] + tot[i+1];
			if(i>0) v += tot[i-1];
			max = Math.Max(max,v);
		}
		
		Console.WriteLine(max);
		
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 19296
// Structured Programming

#include <iostream>
#include <cassert>

void call(int n)
{
  for (int i = 1; i <= n; ++i) {
    if (i % 3 == 0) {
      std::cout << " " << i;
      continue;
    }

    int digit = i;
    while (digit != 0) {
      if (digit % 10 == 3) {
        std::cout << " " << i;
        break;
      }
      digit /= 10;
    }
  }

  std::cout << std::endl;
}

int main()
{
  int n;
  std::cin >> n;
  assert(n >= 3 && n <= 10000);

  call(n);

  return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
int main(void)
{
	int a,b,c,i;
	scanf("%d %d",&a,&b);
	c=a/b;
	if(a%b!=0){
		for(i=1;i<=10000;i++){
			c++;
			a--;
			if(a%b==0)break;
		}
	}
	printf("%d\n",c);
	return 0;
}
			


Measured memory_bytes: 2084
import java.util.Scanner;

/**
 * B - Postdocs
 *
 * https://atcoder.jp/contests/nomura2020/tasks/nomura2020_b
 */
public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String input = sc.nextLine();
    System.out.print(input.replace('?', 'D'));
  }
}

Measured memory_bytes: 41380
/*WELCOME TO AYUSH RANJAN CODE'S*/
/*EVERY PROBLEM HAS A SOLUTION SOMETIMES ELEGENT OTHERWISE COMPLEX ELEGENCE*/

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

const int mod = 1e9 + 7;

int chkpower2(int x){
    return (x&&!(x&x-1));
}

void solve(){
    int n,x,t;
    cin>>n>>x>>t;
    int z=n/x;
    if(n%x==0){
        z--;
    }
    z++;
    cout<<z*t;
}

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

    int t;
    t=1;// cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}


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

char result[12];
int num;
char *p;


void print_result()
{
  int i,zerosup=0;
  for(i=0;i<12;i++)
    {
      if(zerosup==0)
	if(result[i])
	  zerosup=1;
      if(result[i]==0 && zerosup)
	putchar('0');
      if(result[i]==1)
	putchar('+');
      if(result[i]==-1)
	putchar('-');
    }
  printf("\n");
}

int main()
{
  int rem;

  scanf("%d",&num);
  memset(result,0,sizeof(result));
  p=&result[11];

  while(num)
    {
      rem = num % 3;
      //printf("rem=%d\n",rem);
      if(rem==1)
	{
	  p[0]++;
	  if(p[0]==2)
	    {
	      p[0] =- 1;
	      p[-1]++;
	    }
	}
      else if(rem==2)
	{
	  p[0] -= 1;
	  p[-1]++;
	}
      num /= 3;
      p--;
    }
  print_result();
  return(0);
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

int main(){
    int A,B;
    cin >> A >> B;
    A--,B--;
    int a1=A/50,a2=A%50,b1=B/50,b2=B%50;
    int h=((A+49)/50+(B+49)/50+1)*2;
    cout << h << ' ' << 100 << endl;
    rep(i,a1){
        rep(j,100){
            cout << '#';
        }
        cout << endl;
        rep(j,50){
            cout << "#.";
        }
        cout << endl;
    }
    if (a2>0){
        rep(j,100){
            cout << '#';
        }
        cout << endl;
        rep(j,a2){
            cout << "#.";
        }
        rep(j,100-2*a2){
            cout << '#';
        }
        cout << endl;
    }
    rep(j,100){
        cout << '#';
    }
    cout << endl;
    rep(i,b1){
        rep(j,100){
            cout << '.';
        }
        cout << endl;
        rep(j,50){
            cout << ".#";
        }
        cout << endl;
    }
    if (b2>0){
        rep(j,100){
            cout << '.';
        }
        cout << endl;
        rep(j,b2){
            cout << ".#";
        }
        rep(j,100-2*b2){
            cout << '.';
        }
        cout << endl;
    }
    rep(j,100){
        cout << '.';
    }
    cout << endl;
}

Measured memory_bytes: 256
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f

let () =
  let n = read_int () in let a = read_int() in let b = read_int () in
  for_iter 0 (n+1) (fun i ->
    let v, w, x, y, z = i/10000, (i/1000) mod 10, (i/100) mod 10, (i/10) mod 10, i mod 10 in
    let s = v+w+x+y+z in
    if a <= s && s <= b then i else 0)
  |> List.fold_left (+) 0
  |> printf "%d\n"


Measured memory_bytes: 1536