akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
#define MAX 500001
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

Node treeMinimum(Node x){
while(x->left!=NIL){
  x=x->left;
}
return x;
}

Node treeMaximum(Node x){
while(x->right!=NIL){
  x=x->right;
}
return x;
}

Node treeSearch(Node x, int k){
while ( x!=NIL && k!=x->key){
  if(k<x->key) x=x->left;
  else x=x->right;
}
return x;
}

Node treeSuccessor(Node x){
Node y;
if(x->right !=NIL) return treeMinimum(x->right);

y=x->parent;
while ( y !=NIL && x == y->right) {
  x=y;
  y=y->parent;
}
return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
if(z->left == NIL || z->right ==NIL){
  y=z;
}
else y= treeSuccessor(z);

if(y->left != NIL) x=y->left;
else x=y->right;

if(x !=NIL) x->parent=y->parent;
if(y->parent==NIL) root=x;
else if(y==y->parent->left) y->parent->left=x;
else y->parent->right=x;

if(y!=z) z->key=y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

while( x!=NIL){
  y=x;
  if(z->key<x->key) x=x->left;
  else x=x->right;
}
z->parent=y;
if(y==NIL)root=z;
else{
  if(z->key<y->key) y->left=z;
  else y->right=z;
}
}

void inorder(Node u){
if(u==NIL) return;
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}


Measured memory_bytes: 20448
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, m, x, y;
int X[111], Y[111];

bool calc(int z){
    REP(i, n){
        if(X[i] >= z)return false;
    }
    REP(i, m){
        if(Y[i] < z)return false;
    }
    return true;
}

int main(){
    INIT;
    cin >> n >> m >> x >> y;
    REP(i, n)cin >> X[i];
    REP(i, m)cin >> Y[i];
    for(int i = x + 1;i <= y;i++){
        if(calc(i)){
            cout <<"No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
}

Measured memory_bytes: 256
from sys import stdin
def main():
    readline=stdin.readline
    bingo=[]
    for _ in range(3):
        A=list(map(int,readline().split()))
        bingo.append(A)
    N=int(readline())
    b=[0]*N
    c=[[False]*3 for _ in range(3)]
    for i in range(N):
        b[i]=int(readline())
        for j in range(3):
            for k in range(3):
                if bingo[j][k]==b[i]:
                    c[j][k]=True

    #縦
    flag=False
    for j in range(3):
        if c[0][j] and c[1][j] and c[2][j]:
            flag=True

    #横
    for i in range(3):
        if c[i][0] and c[i][1] and c[i][2]:
            flag=True
    
    #斜め
    if c[0][0] and c[1][1] and c[2][2]:
        flag=True

    if c[0][2] and c[1][1] and c[2][0]:
        flag=True

    if flag:
        print("Yes")
    else:
        print("No")
if __name__=="__main__":
    main()

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

using namespace std;

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

struct UnionFind {
    vector<int> par; 

    UnionFind(int N) : par(N) { 
        rep(i,N) par[i] = i;
    }

    int root(int x) { 
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        x = root(x); 
        y = root(y); 
        if (x == y) return; 
        par[x] = y; 
    }

    bool same(int x, int y) { 
      return root(x)== root(y);
    }

};

int main(){
  int n,m;
  cin >> n >>m;
  vector<int> p(n);
  UnionFind u(n);
  rep(i,n) {
    cin >> p[i];
    p[i]--;
  }
  rep(i,m){
   int x,y;
    cin >> x >> y;
    x--;
    y--;
    u.unite(x,y);
  }
  
  int res=0;
  rep(i,n) if(u.same(p[i],i)) res++;
  cout << res << endl;
  
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N,C;
    cin >> N >> C;
    vector<vector<int>> D(C,vector<int>(C));
    for(int i = 0;i < C;i++) {
        for(int j = 0;j < C;j++) {
            cin >> D.at(i).at(j);
        }
    }
    vector<vector<int>> color(3,vector<int>(C));
    for(int i = 0;i < N;i++) {
        for(int j = 0;j < N;j++) {
            int A;
            cin >> A;
            A--;
            color.at((i + j) % 3).at(A)++;
        }
    }
    int ret = Inf;
    for(int i = 0;i < C;i++) {
        for(int j = 0;j < C;j++) {
            for(int k = 0;k < C;k++) {
                if(i != j && j != k && i != k) {
                    int cnt = 0;
                    for(int l = 0;l < C;l++) {
                        cnt += color.at(0).at(l) * D.at(l).at(i);
                        cnt += color.at(1).at(l) * D.at(l).at(j);
                        cnt += color.at(2).at(l) * D.at(l).at(k);
                    }
                    ret = min(ret,cnt);
                }
            }
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N, K := getInt(), getInt()
	bit := make([]int, 31)
	n := 0
	for k := K; k > 0; {
		bit[n] = k % 2
		n++
		k >>= 1
	}

	pat := make([]int, 32)
	mask := 0
	pat[0] = K
	idx := 1
	for i := 30; i >= 0; i-- {
		if bit[i] == 1 {
			pat[idx] = mask | (1<<uint(i) - 1)
			idx++
			mask |= 1 << uint(i)
		}
	}

	/*	for i := 0; i < idx; i++ {
			fmt.Printf("%b\n", pat[i])
		}
	*/
	x := make([]int, idx)
	sum := make([]int, idx)
	for i := 0; i < N; i++ {
		a, b := getInt(), getInt()
		for j := 0; j < idx; j++ {
			if a|pat[j] == pat[j] {
				sum[j] += b
				x[j] |= a
				//				out("pat", j, "buy", i, b, "sum", sum[j])
			}
		}
	}

	ans := 0
	for i := 0; i < idx; i++ {
		if sum[i] > ans {
			ans = sum[i]
		}
	}
	out(ans)
}


Measured memory_bytes: 3840
#include <iostream>

using namespace std;

int main() {
  double w, h;
  int x, y;
  
  cin >> w >> h >> x >> y;
  
  int a = 0;
  if (x+x==w && y+y==h) {
    a = 1;
  }

  cout << std::fixed << w*h/2 << " " << a;
  
  return 0;
}

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

int main (){
	int K; 
	char S [101];
	
	scanf ("%d\n", &K);
	scanf ("%s", &S);
	
	int len = strlen (S);
	if	(len <= K){
		printf ("%s", S);
	}
	else {
		for (int i = 0 ; i < K; i++){
			printf ("%c", S[i]);
		}
		puts ("...");
	}
	
	return 0;
}

Measured memory_bytes: 1724
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    string s; cin >> s;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (s[i] == 'R') cnt++;
    }
    int ans = 0;
    for (int i = 0; i < cnt; i++) {
        if (s[i] == 'W') ans++;
    }
    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3760
/*
Read the question and constraints carefully .Take pen and paper and start solving
*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define pi acos(-1.0)/*
#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second*/
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

ll p,ans;

ll modinv(ll num,ll md)
{
    p = md-2;
    ans = 1;

    for(;p;num=(num*num)%md,p/=2)
    {
        if(p&1)
            ans = (ans*num)%md;
    }

    return ans;

}

int main()
{

    ll n,m,k,i,ans=0,v,d;

    cin>>n>>m>>k;

    ll fac[n+1],p[n+1];

    fac[0]=1;

    for(i=1;i<=n;++i)
            fac[i] = (fac[i-1]*i)%MOD;

    p[0]=m;

    for(i=1;i<=n;++i)
            p[i] = (p[i-1]*(m-1))%MOD;


    for(i=n-1-k;i<=n-1;++i)
    {
        v = (fac[n-1]*p[i])%MOD;
        d = (fac[n-1-i]*fac[i])%MOD;


        v = (v*modinv(d,MOD))%MOD;

        ans = (ans+v)%MOD;

    }


    cout<<ans;


    return 0;
}

Measured memory_bytes: 6720
#include <bits/stdc++.h>
#define maxn 200005
#define MOD 998244353
#define INF 10000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll a,  b, c, d;
ll x, y, X1, Y1, X2, Y2;

bool check(ll X, ll Y){
    if(X>= X1 && X <= X2 && Y >= Y1 && Y <= Y2) return true;
    return false;
}

void solve(){

    ll n = 3;
    ll a[n][n];
    for(ll i = 0; i < n; i++)
        for(ll j = 0 ; j < n; j++)
        cin >> a[i][j];
    ll q;
    cin >> q;
    ll mk[n][n];
    memset(mk, 0, sizeof(mk));
    while(q--){
        ll x; cin >> x;
        for(ll i = 0; i < n; i++)
        {for(ll j = 0 ; j < n; j++)
                {
                    if(a[i][j] == x) mk[i][j] = 1;
                }
        }

    }
    if( (mk[0][0] == 1 && mk[0][1] == 1 && mk[0][2] == 1)  || (mk[1][0] == 1 && mk[1][1] == 1 && mk[1][2] == 1)
       || (mk[2][0] == 1 && mk[2][1] == 1 && mk[2][2] == 1) || (mk[0][0] == 1 && mk[1][0] == 1 && mk[2][0] == 1)
       || (mk[0][1] == 1 && mk[1][1] == 1 && mk[2][1] == 1) || (mk[0][2] == 1 && mk[1][2] == 1 && mk[2][2] == 1)
       || (mk[0][0] == 1 && mk[1][1] == 1 && mk[2][2] == 1) || (mk[0][2] == 1 && mk[1][1] == 1 && mk[2][0] == 1) )
        cout << "Yes";
    else cout << "No";

}

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


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

 
int main()
{
	int n;
	for (; cin >> n, n != 0;)
	{
		int c = 0;
		if (n == 1 || n== 2)c = 1;
		else
		{
			for (int i = n + 1; i <= 2 * n; i++)
			{
				if (i % 2 == 0 ||i%3==0 )continue;
				else
				{
					int a= (i - 3) / 2;
					for (int l = 3; l*l <= i; l+=2)
					{
						if (i%l == 0) {
							a--;
							break;
						}
					}
					if (a == (i-3)/2) c++;
				}
			}
		}
		cout << c << endl;
	}							
	return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int x;
  cin>>x;
  int ans = 0;
  if(400<=x&&x<600)ans=8;
  if(600<=x&&x<800)ans=7;
  if(800<=x&&x<1000)ans=6;
  if(1000<=x&&x<1200)ans=5;
  if(1200<=x&&x<1400)ans=4;
  if(1400<=x&&x<1600)ans=3;
  if(1600<=x&&x<1800)ans=2;
  if(1800<=x&&x<2000)ans=1;
  cout<<ans<<endl;

}

Measured memory_bytes: 3632
#import<vector>
#import<set>
#import<cstdio>
using namespace std;
int main(){
	long long H,W;
	int N,h,w,h0,w0,z,t;
	scanf("%lld%lld%d",&H,&W,&N);
	vector<long long>v(10);
	set<pair<int,int>>se;
	v[0]=(H-2)*(W-2);
	for(;N--;)for(scanf("%d%d",&h,&w),h--,w--,se.emplace(h,w),h0=-2;++h0<2;)for(w0=-2;++w0<2;)if(1<=h+h0&&h+h0<H-1 && 1<=w+w0&&w+w0<W-1){
		for(t=z=0;z<9;z++)t+=se.find({h+h0+z/3-1,w+w0+z%3-1})!=se.end();
		v[t-1]--,v[t]++;
	}
	for(auto &e:v)printf("%lld\n",e);
}

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

using namespace std;

int main()
{  int n, c = 0;
    cin >> n;
    long long   a[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];

    }
    for (int i = 0; i < n; ++i){
    for (int j = i + 1; j < n; ++j){
    for (int k = j + 1; k < n; ++k){
            if ((a[i] + a[j] > a[k]) && (a[i] != a[j]) && (a[i] != a[k]) && (a[j] != a[k])) {
            if (a[i] + a[k] > a[j])
            if (a[k] + a[j] > a[i])
                c++;
            }
        }
    }
    }
 cout << c;
}




Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#ifdef LOCAL
	#define debug(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define debug(...) 42
#endif

#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

inline string getString(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string getLine(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
typedef long long ll;
typedef pair<int,int>pii;

const int INF=12345678;
const int S=1001;
int wx[]={1,-1,0,0};
int wy[]={0,0,1,-1};
int n,m;
int sx,sy,ex,ey;
string s[S+5];

bool isValid(int x,int y){return x>=0 && x<n && y>=0 && y<m;}
int main()
{
	while(~sf("%d %d",&n,&m))
	{
		sf("%d %d %d %d",&sx,&sy,&ex,&ey);
		sx--,sy--,ex--,ey--;

		for(int i=0;i<n;i++)
		{
			s[i]=getString(m+5);
		}

		/// 0-1 bfs starts
		deque<pii>dq;
		dq.push_back(pii(sx,sy));
		
		int level[n+5][m+5];
		for(int i=0;i<n;i++)fill(level[i],level[i]+m,INF);
		level[sx][sy]=0;

		while(!dq.empty())
		{
			pii cur=dq.front();
			dq.pop_front();
			int ux=cur.first;
			int uy=cur.second;

			for(int x=-2;x<=2;x++)
			{
				for(int y=-2;y<=2;y++)
				{
					int vx=ux+x;
					int vy=uy+y;
					if(vx==ux && vy==uy)continue;
					if(isValid(vx,vy) && s[vx][vy]=='.')		
					{
						if(abs(ux-vx)+abs(uy-vy)==1 && level[vx][vy]>level[ux][uy])
						{
							level[vx][vy]=level[ux][uy];
							dq.push_front(pii(vx,vy));
						}
						else if(level[vx][vy]>1+level[ux][uy])
						{
							level[vx][vy]=1+level[ux][uy];
							dq.push_back(pii(vx,vy));
						}
					}
				}
			}
		}
		///	0-1 bfs ends
		if(level[ex][ey]==INF)puts("-1");
		else pf("%d\n",level[ex][ey]);
	}
    return 0;
}



































Measured memory_bytes: 8796
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] w = new int[n];

        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
        }

        sc.close();

        int ans = Integer.MAX_VALUE;

        for (int i = 1; i < n; i++) {
            int s1 = 0;
            int s2 = 0;
            for (int k = 0; k < i; k++) {
                s1 += w[k];
            }
            for (int j = i; j < n; j++) {
                s2 += w[j];
            }
            ans = Math.min(ans, Math.abs(s1 - s2));
        }

        System.out.println(ans);

    }
}

Measured memory_bytes: 21844
import java.math.BigInteger;
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    BigInteger x = new BigInteger(sc.next());
    BigInteger c = new BigInteger("100");
    BigInteger r = new BigInteger("100");
    long count = 0L;
    while(c.compareTo(x) < 0) {
      BigInteger tmp = c.divide(r);
      c = c.add(tmp);
      count++;
    }
    System.out.println(count);
  }
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

int N, M, K;
int A[111111];
int B[111111];
int C[111111];
int D[111111];
vector<int> fr[111111];
vector<int> bl[111111];
int label[111111];
map<int, int> rel_cnt;

void input() { cin >> N >> M >> K; rep (i, M) { cin >> A[i] >> B[i]; A[i]--, B[i]--; fr[A[i]].push_back(B[i]); fr[B[i]].push_back(A[i]); } rep (i, K) { cin >> C[i] >> D[i]; C[i]--, D[i]--; bl[C[i]].push_back(D[i]); bl[D[i]].push_back(C[i]); } }

int search(int prev, int now, int num) {
	label[now] = num;

	int ret = 0;
	for (int fr_now : fr[now]) {
		if (label[fr_now] != -1) continue;
		if (fr_now == now) continue;
		ret += search(now, fr_now, num) + 1;
	}

	return ret;
}

signed main() {
	input();
	fill(label, label + N, -1);

	vector<int> ans;
	int num = 1;
	rep (i, N) {
		if (label[i] != -1) { continue; }

		int t = search(-1, i, num);
		rel_cnt[num] = t;
		num++;
	}

	rep (i, N) {
		int cnt = rel_cnt[label[i]] - fr[i].size();
		for (int b : bl[i]) {
			if (label[b] == label[i]) cnt--;
		}

		ans.push_back(cnt);
	}

	rep (i, N-1) {
		cout << ans[i] << " ";
	}
	cout << ans.back() << endl;

	return 0;
}


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

from collections import defaultdict
d = defaultdict(int)

for i in range(1, n):
    for j in range(i+1, n+1):
        if i <= x and j >= y:
            dis = (x-i)+(j-y)+1
        elif j <= x or i >= y:
            dis = j - i
        elif i <= x and j >= x:
            dis = (x-i)+min(j-x, y-j+1)
        elif i <= y and j >= y:
            dis = min(y-i, i-x+1)+(j-y)
        elif i >= x and j <= y:
            dis = min(j-i, (i-x)+1+(y-j))
        d[dis] += 1
            

for i in range(1, n):
    print(d[i])

Measured memory_bytes: 50396
##################################################################

if __name__ == "__main__":
    Input = [input() for i in range(2)]
    N = int(Input[0])
    #S = list(map(int,Input[1].split()))
    S = str(Input[1])
    c = 1
    for i in range(1,N):
        if S[i] != S[i-1]:
            c += 1
        else:
            pass
    print(c)

    


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

using namespace std;

#define int long long 
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

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

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

    int W;
    cin >> W;
    cout << W * 32 << endl;
	return 0;
}



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

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

    int len = S.length();
    vector<int> ans(len, 1);

    for (int head = 0; head < len;) {
        //! find the head and the tail of the running same characters
        char c = S[head];
        int tail = head;
        while (tail+1 < len && S[tail+1] == c) ++tail;

        // update ans
        int slen = tail - head + 1;
        int direction = 1;
        int start = head;
        if (c == 'L') {
            direction = -1;
            start = tail;
        }
        for (int i = 0; i < slen; ++i) {
            --ans[start + direction * i];
        }
        if (slen %2) {
            int h = (slen-1) / 2;
            ans[start + direction * (slen-1)] += h+1;
            ans[start + direction * slen] += h;
        } else {
            ans[start + direction * (slen-1)] += (slen / 2);
            ans[start + direction * slen] += (slen / 2);
        }

        // next iteration
        head = tail + 1;
    }

    cout << ans[0];
    for (int i = 1; i < len; ++i) {
        cout << ' ' << ans[i];
    }
    cout << endl;

    return 0;
}



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

int main() {
  int a,b,k;
  cin>>a>>b>>k;
  
  int ch=min(a,b);
  int count =0;
  int ans=0;
  
  for(int i=min(a,b);0<i;i--){
  	if(a%i==0&&b%i==0){
      	ans=i;
      	count++;
      
    }
    
    if(count==k)break;
  }
  
  cout<<ans<<endl;
  
	
}
    

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


int main () {
  int r,g,b; cin >> r >> g >> b;

  int c = r*100 + g*10 + b;

  if(c % 4 == 0){
      cout << "YES" << endl;
  } else {
      cout << "NO" << endl;
  }
  return 0;
}

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

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")
}

fn main() {
    let mut i: [i64; 3] = [0; 3];
    for j in 0..3 { i[j] = read(); }
    println!("{} {}",
        if i[0] <= i[2] { 0 } else { i[0] - i[2] },
        if i[0] <= i[2] { if i[1] - (i[2] - i[0]) < 0 { 0 } else { i[1] - (i[2] - i[0]) } } else { i[1] }
    );
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    int res=0,tmp=0;
    rep(i,n){
        int h;cin>>h;
        if(tmp<h){
            res+=h-tmp;
            tmp=h;
        }
        else tmp=h;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    int ans = A[0];
    for(int i = 0; i < N; i++) {
        ans = euclidean_gcd(ans, A[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

int[][10^^5+1] X, Y;
bool[10^^5+1] XF, YF;

void main()
{
    auto N = readln.chomp.to!int;
    foreach (_; 0..N) {
        auto xy = readln.split.to!(int[]);
        X[xy[0]] ~= xy[1];
        Y[xy[1]] ~= xy[0];
    }

    long r;
    foreach (i; 1..10^^5+1) {
        if (XF[i]) continue;
        XF[i] = true;
        auto ss = [[1, i]];
        long xp = 1, yp, e;
        while (!ss.empty) {
            auto h = ss[0];
            auto x = h[0];
            auto n = h[1];
            ss = ss[1..$];
            foreach (nxt; (x ? X[n] : Y[n])) {
                ++e;
                if (x) {
                    if (YF[nxt]) continue;
                    YF[nxt] = true;
                    ss ~= [0, nxt];
                    ++yp;
                } else {
                    if (XF[nxt]) continue;
                    XF[nxt] = true;
                    ss ~= [1, nxt];
                    ++xp;
                }
            }
        }
        r += xp * yp - e/2;
    }
    writeln(r);
}

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

using namespace std;

#define ll long long int

int main(){
  int N,A;
  cin >> N;
  int pattern[N];
  vector<int> yes[N],no[N];
  for(int i=0;i<N;i++){
    cin >> A;
    yes[i].clear();
    no[i].clear();
    for(int a=0;a<A;a++){
      int x,y;
      cin >> x >> y;
      if(y==0) no[i].push_back(x-1);
      else yes[i].push_back(x-1);
    }
  }

  int max=0;
  for(int bit=0;bit<(1<<N);bit++){
    for(int i=0;i<N;i++){
      if(bit & 1<<i) pattern[i]=1;
      else pattern[i]=0 ;
      //cout << pattern[i] ;
    }
    //cout << endl;
    bool possible=true;
    for(int j=0;j<N;j++){
      if(pattern[j]==1){
        //cout << "yes[" << j << "].size()=" << yes[j].size() << endl;
        for(int k=0;k<yes[j].size();k++){
          //cout << "yes[" << j << "][" << k << "]=" << yes[j][k] << endl;
          if(pattern[yes[j][k]]==0){
            possible=false;
            goto IMP;
          }
        }
        //cout << "no[" << j << "].size()=" << no[j].size() << endl;
        for(int k=0;k<no[j].size();k++){
          //cout << "no[" << j << "][" << k << "]=" << no[j][k] << endl;
          if(pattern[no[j][k]]==1){
            possible=false;
            goto IMP;
          }
        }
      }
    }
    IMP:
      if(possible==true){
        int count=0;
        for(int l=0;l<N;l++){
          if(pattern[l]==1) count++;
        }
        if(count>max) max=count;
      }
  }
  cout << max << endl;

  return 0;
}

Measured memory_bytes: 256
def linearSearch(t):
    i=0
    s=S[:]+[t]
    while s[i]!=t:
        i+=1
    if i==n:
        return 0
    return 1

n=int(input())
S=list(map(int,input().split()))
q=int(input())
T=list(map(int,input().split()))

C=0

for t in T:
    C+=linearSearch(t)
    
print(C)

Measured memory_bytes: 8352
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
// #include <bitset>
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
using namespace std;
typedef long long LL;
typedef double db;
#define pritnf printf
//char buf[1<<24],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
	if (x< 0) putchar('-'),x=-x;
	if (x>=10) print(x/10);
	putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
int pri[N]; bool vis[N];
void init (const int n=2200)
{
	for (int i=2; i<=n; i++)
	{
		if (!vis[i]) pri[++pri[0]]=i;
		for (int j=i+i; j<=n; j+=i)
			vis[j]=1;
	}
}
LL a[N],b[N];
#define pll pair<LL,LL>
#define fi first
#define se second
#define mp make_pair
pll s[N];
map <LL,int> cnt;
map <LL,bool> us;
int main ()
{
	// freopen (".in","r",stdin);
	// freopen (".out","w",stdout);
	init ();
	int n; sc(n);
	for (int i=1; i<=n; i++)
	{
		sc(a[i]);
		LL x=b[i]=1;
		for (int j=1; j<=pri[0]; j++) if (a[i]%pri[j]==0)
		{
			int p=pri[j],g=0;
			if (p> a[i]) break;
			while (a[i]%p==0) a[i]/=p,++g;
			g%=3;
			if (!g) continue;
			x*=p,b[i]*=p;
			g==1?b[i]*=p:x*=p;
		}
		if (a[i]> 1)
		{
			LL g=sqrt (a[i]);
			if (g*g==a[i]) b[i]*=g;
			else b[i]*=a[i]*a[i];
		}
		a[i]*=x;
		++cnt[a[i]];
	}
	for (int i=1; i<=n; i++)
		s[i]=mp(a[i],b[i]);
	sort (s+1,s+n+1);
	n=unique (s+1,s+n+1)-s-1;
	int ans=0;
	for (int i=1; i<=n; i++)
	{
		LL a=s[i].fi,b=s[i].se;
		if (a==1||us[a]||us[b]) continue;
		us[a]=1;
		ans+=max (cnt[a],cnt[b]);
	}
	pr(ans+(bool)cnt[1]);
	

	return 0;
}


Measured memory_bytes: 34944
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    s[3]='8';
    cout<<s<<endl;
}


Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner (System.in);

    int times = cin.nextInt();
    int start = cin.nextInt();
    int[] pos = new int[times];
    for (int i=0;i<times;i++){
      pos[i] = Math.abs(start - cin.nextInt());
    }


      System.out.println(getMoreBigDiv(pos, times));


  }


  public static int getBigDiv(int a, int b) {// 求两个数的最大公约数
    if (b == 0)
      return a;
    return getBigDiv(b, a % b);

  }

  public static int getMoreBigDiv(int num[], int n) { // 求多个数的最大公约数
    if (n == 1)
      return num[n - 1];
    return getBigDiv(num[n - 1], getMoreBigDiv(num, n - 1));
  }


}

Measured memory_bytes: 57688
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    n = int(input())
    s = [input() for i in range(n)]
    print("AC x " + str(s.count("AC")))
    print("WA x " + str(s.count("WA")))
    print("TLE x " + str(s.count("TLE")))
    print("RE x " + str(s.count("RE")))
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 17612
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+1;
const int mod = 1e9+7;
vector<pii> gst;
int dp[upperlimit];
int main() {
	string s;
	int n;
	cin >> n >> s;
	for(int i = 0; i < n; i++){
		if(i!=n-1){
			if((s[i]=='1')&&(s[i+1]=='0')){
				int j=i+2;
				while((j<n)&&(s[j]=='1')){
					gst.pb(mp(i+1,j+1));
					j++;
				}
			}
		}
		if(i!=0){
			if((s[i]=='1')&&(s[i-1]=='0')){
				int j=i-2;
				while((j>=0)&&(s[j]=='1')){
					gst.pb(mp(j+1,i+1));
					j--;
				}
			}
		}
	}
	sort(gst.begin(),gst.end());
	int j=0;
	for(int i = 1; i <= n; i++){
		while((j<gst.size())&&(gst[j].F==i)){
			dp[gst[j].S]=max(dp[gst[j].S],dp[i-1]+gst[j].S-i-1);
			j++;
		}
		dp[i]=max(dp[i],dp[i-1]);
	}
	cout << dp[n];
	return 0;
}

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

#define MAX_M 100

using namespace std;

int main()
{
    int N, M, X, toH = 0, toT = 0, buf;

    scanf("%d %d %d", &N, &M, &X);
    for (int i = 1; i <= M; i++)
    {
        scanf("%d", &buf);
        if (buf < X)
            toH++;
        else if (buf > X)
            toT++;
    }

    printf("%d\n", min(toH, toT));

    return 0;
}

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

const long long INF = 1LL << 60;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // Debug::set_INF(INF);
    int N, M, L;  cin >> N >> M >> L;
    vector<vector<long long>> dist(N, vector<long long>(N, INF));
    for (int i = 0; i < M; ++i) {
        int a, b, c;  cin >> a >> b >> c;
        --a;  --b;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    for (int i = 0; i < N; ++i) dist[i][i] = 0LL;

    // Warshall Floyd for dist
    for (int k = 0; k < N; ++k) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                if (dist[i][j] > dist[i][k] + dist[k][j]) {
                    dist[i][j] = dist[i][k] + dist[k][j];
                }
            }
        }
    }

    vector<vector<long long>> dist2(N, vector<long long>(N, INF));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (dist[i][j] <= L) dist2[i][j] = 1;
        }
    }
    for (int i = 0; i < N; ++i) dist[i][i] = 0;

    // Warshall Floyd for dist2
    for (int k = 0; k < N; ++k) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                if (dist2[i][j] > dist2[i][k] + dist2[k][j]) {
                    dist2[i][j] = dist2[i][k] + dist2[k][j];
                }
            }
        }
    }

    int Q;  cin >> Q;
    for (int i = 0; i < Q; ++i) {
        int s, t;  cin >> s >> t;  --s;  --t;
        cout << (dist2[s][t] == INF ? -1 : dist2[s][t] - 1) << endl;
    }
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int r = 0;
  vector<bool> memo(8);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a >= 3200) {
      r++;
    }
    else {
      int c = 0;
      while (true) {
        a -= 400;
        c++;
        if (a < 0) {
          break;
        }
      }
      memo.at(c - 1) = true;
    }
  }
  int ans = 0;
  for (int i = 0; i < 8; i++) {
    if (memo.at(i)) {
      ans++;
    }
  }
  if (ans == 0) {
    cout << ans + 1 << " ";
  }
  else {
    cout << ans << " ";
  }
  cout << ans + r << endl;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(int argc, char const *argv[])
{
	int i;
	char str[100];
	scanf("%s", str);
	int len = strlen(str);
	if(len <= 20) {
		for(i = len; i >= 0; i--) {
			if(isalnum(str[i]))
			printf("%c", str[i]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 520
#!venv/bin/python

import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

N,M = [int(x) for x in input().split()]
BRIDGES = []
for _i in range(M):
    BRIDGES.append([int(x) for x in input().split()])

group_len = {}
group = {}





class UnionFind():
    def __init__(self, n):
        self.parent = [i for i in range(n)]
        self.rank = [0 for i in range(n)]
        self.size = [1 for i in range(n)]
    
    def find(self, x):
        if(self.parent[x] == x):
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y: return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
            self.size[y] = self.size[x] + self.size[y]
            #self.size[x] = self.size[x] + self.size[y]
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.size[x] = self.size[x] + self.size[y]
            #self.size[y] = 0
    
    def gsize(self, x):
        return self.size[self.find(x)]
    
    def same(self, x, y):
        return self.find(x) == self.find(y)

uf = UnionFind(N)
fuben = int(N * (N - 1) / 2)
ans = []
ans.append(fuben)
for i in range(M-1, 0, -1):
    a, b = BRIDGES[i]
    a = a - 1
    b = b - 1
    if not uf.same(a,b):
        fuben -= int(uf.gsize(a) * uf.gsize(b))
        uf.unite(a,b)
    ans.append(fuben)
print("\n".join([ str(a) for a in ans][::-1]))

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

int main(){
  int n,k,tmp;
  int s[100];

  while(1){
    cin >> n >> k;
    if(!n && !k)break;

    for(int i=0;i<k;i++)cin >> s[i];

    for(int i=0;i<n;i++){
      for(int j=0;j<k;j++){
	cin >> tmp;
	s[j] -= tmp;
      }
    }

    tmp = 1;
    for(int i=0;i<k;i++){
      if(s[i] < 0)tmp = 0;
    }

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

Measured memory_bytes: 852
from collections import deque
import sys
sys.setrecursionlimit(10**5)

N, M = map(int, input().split())
E = []
for i in range(M):
    a, b, c = map(int, input().split())
    E.append((c, a-1, b-1))
E.sort()

*p, = range(N)
def root(x):
    if x == p[x]:
        return x
    p[x] = y = root(p[x])
    return y

L = 2*N-1
G = [[]] * L
C = [0]*L
*lb, = range(N)
cur = N

s = 0
for c, a, b in E:
    pa = root(a); pb = root(b)
    if pa == pb:
        continue
    s += c
    chds = [lb[pa], lb[pb]]
    if pa < pb:
        p[pb] = pa
        lb[pa] = cur
    else:
        p[pa] = pb
        lb[pb] = cur
    C[cur] = c
    G[cur] = chds
    cur += 1

H = [0]*L
prv = [-1]*L
def dfs(v):
    s = 1; heavy = -1; m = 0
    for w in G[v]:
        prv[w] = v
        c = dfs(w)
        if m < c:
            heavy = w
            m = c
        s += c
    H[v] = heavy
    return s
dfs(L-1)

SS = []
D = []
LB = [0]*L
I = [0]*L
que = deque([(L-1, 0)])
while que:
    v, d = que.popleft()
    S = []
    k = len(SS)
    while v != -1:
        I[v] = len(S)
        S.append(v)
        LB[v] = k
        h = H[v]
        for w in G[v]:
            if h == w:
                continue
            que.append((w, d+1))
        v = h
    SS.append(S)
    D.append(d)


def query(u, v):
    lu = LB[u]; lv = LB[v]
    dd = D[lv] - D[lu]
    if dd < 0:
        lu, lv = lv, lu
        v, u = u, v
        dd = -dd

    for _ in range(dd):
        v = prv[SS[lv][0]]
        lv = LB[v]

    while lu != lv:
        u = prv[SS[lu][0]]
        lu = LB[u]

        v = prv[SS[lv][0]]
        lv = LB[v]

    return u if I[u] < I[v] else v


def gen():
    Q = int(input())
    for i in range(Q):
        u, v = map(int, input().split())
        w = query(u-1, v-1)
        yield "%d\n" % (s - C[w])
ans = list(gen())
sys.stdout.writelines(ans)

Measured memory_bytes: 82352
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  int a = n % 10;
  string res;
  if(a == 3) res = "bon";
  else if(a == 0 || a == 1 || a == 6 || a == 8) res = "pon";
  else res = "hon";
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
using namespace std;
const int N=19;
int n,a[N],b[N];
int dp[1<<18][18],inv[1<<18][18];
int main(){
    for(int i=0;i<1<<18;i++){
        for(int j=0;j<18;j++){
            if(!(i>>j&1)){
                for(int k=0;k<18;k++){
                    if(i>>k&1) {
                        if(k>j) inv[i][j]++;
                    }
                }
            }
        }
    }
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    for(int i=0;i<n;i++) scanf("%d",&b[i]);
    for(int i=0;i<1<<18;i++)for(int j=0;j<18;j++)dp[i][j]=1e9;
    dp[0][0]=0;for(int i=0;i<n;i++)dp[1<<i][i]=0;
    
    for(int i=0;i<1<<n;i++){
        for(int j=0;j<n;j++){
            if(i>>j&1) {
                //printf("dp[%d][%d]=%d\n", i,j,dp[i][j]);
                int pos=-1;
                for(int k=0;k<n;k++) if(i>>k&1) ++pos;
                int f1=((pos%2==0)==(j%2==0)?a[j]:b[j]);
                //printf("f1=%d\n",f1);
                for(int k=0;k<n;k++){
                    if(!(i>>k&1)) {
                        int f2=((pos%2==0)==(k%2==0)?b[k]:a[k]);
                        if(f1 <= f2) {
                            dp[i|(1<<k)][k] = min(dp[i|(1<<k)][k], dp[i][j]+inv[i][k]);
                        }
                    }
                }
            }
        }
    }
    int ans=1e9;
    for(int i=0;i<n;i++)ans=min(ans,dp[(1<<n)-1][i]);
    if(ans==1e9)cout<<-1<<endl;
    else cout<<ans<<endl;
}
/*
3
3 2 1 
1 2 3

*/

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

P add(ll a, ll b){
  ll sum = a + b;
  ll s = sum % 10 + sum / 10;
  ll cnt = 1 + sum / 10;
  return P(s, cnt);
}

P calc(ll d,ll c){
  if(c == 1){
    return P(d, 0);
  }
  ll sum = d * c;
  if(sum < 10){
    return P(sum,c-1);
  }
  P sub = calc(1, sum/10);
  P sub2 = add(sum%10, sub.first);
  ll cnt = (c-1) + sub.second + sub2.second;
  return P(sub2.first, cnt);
}


int main(void){
  int m;
  cin >> m;
  ll res = 0LL;
  ll carry = 0LL;
  for(int i = 0;i < m;++i){
    ll d,c;
    cin >> d >> c;
    P sub = calc(d,c);
    res += sub.second;
    if(i == 0){
      carry = sub.first;
    }else{
      P sub2 = add(carry, sub.first);
      carry = sub2.first;
      res += sub2.second;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		long N = ni();
		long D = ni();
		int result = 0;
		for(int i = 0; i < N; i++) {
			long X = ni();
			long Y = ni();
			result += (X * X + Y * Y <= D * D) ? 1 : 0;
		}
		System.out.println(result);
	}


	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 46496
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int a,b,t;
  cin>>a>>b>>t;
  int n = t/a;
  cout<<b*n<<endl;
  return 0;
}


Measured memory_bytes: 256